Hueman Addons - Version 2.0.13

Version Description

November 11th 2017 = * Fix : admin bar style printed when user not logged in * Fix : polylang compat => exclude nav_menu_locations, blogname and blogdescription from "by page customization" when polylang is active. Fixes #34. Fix presscustomizr/hueman#377 * added : a set of shared functions in a new separated file : addons/ha-functions.php * Fix : remove unused skop _dev files * Improved : compatibility with WordPress 4.9, release target date November 14th 2017

Download this release

Release Info

Developer nikeo
Plugin Icon 128x128 Hueman Addons
Version 2.0.13
Comparing to
See all releases

Code changes from version 2.0.12 to 2.0.13

addons/assets/czr/css/czr-control-base.css CHANGED
@@ -271,13 +271,21 @@ li[id*="customize-control-"] {
271
  -webkit-box-shadow: 1px 0px 2px 0px rgba(204, 204, 204, 0.45);
272
  }
273
 
 
 
 
 
 
 
 
 
 
 
 
274
  /* GENERAL STYLE */
275
  .control-section .accordion-section-content {
276
  overflow-y: auto;
277
  }
278
- li[id*="customize-control-"] {
279
- margin: 8px 0;
280
- }
281
 
282
  .wp-customizer .control-section h3.accordion-section-title {
283
  padding: 10px 25px 11px 14px;
@@ -2713,7 +2721,7 @@ body.czr-editing-sektion #czr-sektion-settings-panel {
2713
  body.czr-editing-sektion #customize-preview {
2714
  opacity: 0.7;
2715
  }/* WP SAVE BUTTON */
2716
- .czr-api-dirty input#save {
2717
  background-color: #FFBD2E;
2718
  border-color: #d99400;
2719
  color: black;
@@ -2728,7 +2736,7 @@ body.czr-editing-sektion #customize-preview {
2728
  }
2729
  .czr-api-dirty input#save:hover {
2730
  background-color: #fcad06;
2731
- }
2732
 
2733
  /* FIX CUSTOMIZE INFO OVERLAPPING SKOPE SWITCHER */
2734
  .czr-skop-on #customize-controls .customize-info.is-in-view, #customize-controls .customize-section-title.is-in-view {
@@ -2741,7 +2749,7 @@ body.czr-editing-sektion #customize-preview {
2741
  height: 185px;
2742
  }
2743
  .czr-skop-on .wp-full-overlay-sidebar .wp-full-overlay-sidebar-content {
2744
- top: 185px;
2745
  }
2746
  .wp-customizer .in-sub-panel .wp-full-overlay-sidebar .wp-full-overlay-header {
2747
  padding: 0 15px;
@@ -2749,8 +2757,13 @@ body.czr-editing-sektion #customize-preview {
2749
  .customize-controls-close {
2750
  border-bottom: 1px solid #ddd;
2751
  }
2752
-
2753
-
 
 
 
 
 
2754
 
2755
  .wp-customizer #customize-header-actions {
2756
  border-bottom: 0px;
271
  -webkit-box-shadow: 1px 0px 2px 0px rgba(204, 204, 204, 0.45);
272
  }
273
 
274
+ /*<@4.9compat>*/
275
+ /* outer section introduced in v4.9 needs to keep its original width */
276
+ #customize-outer-theme-controls li[id*="customize-control-"] {
277
+ width: 100%;
278
+ }
279
+ #customize-outer-theme-controls input[type=checkbox], #customize-outer-theme-controls input[type=radio] {
280
+ float: none;
281
+ min-height: inherit;
282
+ }
283
+ /*</@4.9compat>*/
284
+
285
  /* GENERAL STYLE */
286
  .control-section .accordion-section-content {
287
  overflow-y: auto;
288
  }
 
 
 
289
 
290
  .wp-customizer .control-section h3.accordion-section-title {
291
  padding: 10px 25px 11px 14px;
2721
  body.czr-editing-sektion #customize-preview {
2722
  opacity: 0.7;
2723
  }/* WP SAVE BUTTON */
2724
+ /*.czr-api-dirty input#save {
2725
  background-color: #FFBD2E;
2726
  border-color: #d99400;
2727
  color: black;
2736
  }
2737
  .czr-api-dirty input#save:hover {
2738
  background-color: #fcad06;
2739
+ }*/
2740
 
2741
  /* FIX CUSTOMIZE INFO OVERLAPPING SKOPE SWITCHER */
2742
  .czr-skop-on #customize-controls .customize-info.is-in-view, #customize-controls .customize-section-title.is-in-view {
2749
  height: 185px;
2750
  }
2751
  .czr-skop-on .wp-full-overlay-sidebar .wp-full-overlay-sidebar-content {
2752
+ top: 185px!important;
2753
  }
2754
  .wp-customizer .in-sub-panel .wp-full-overlay-sidebar .wp-full-overlay-header {
2755
  padding: 0 15px;
2757
  .customize-controls-close {
2758
  border-bottom: 1px solid #ddd;
2759
  }
2760
+ /*
2761
+ * when skope is on, the z-index of the #customize-notifications-area has to be increased
2762
+ * this #customize-notifications-area block has been introduced in WP 4.9
2763
+ */
2764
+ .czr-skop-on #customize-controls #customize-notifications-area {
2765
+ z-index: 1000;
2766
+ }
2767
 
2768
  .wp-customizer #customize-header-actions {
2769
  border-bottom: 0px;
addons/assets/czr/css/czr-control-base.min.css CHANGED
@@ -1 +1 @@
1
- .rtl.wp-customizer .wp-full-overlay-sidebar,.wp-customizer .wp-full-overlay-sidebar{width:440px}i.czr-notice,span.czr-notice{display:block;clear:both}.tabs nav ul,li.czr-module-candidate.gu-mirror,li.czr-single-module.gu-mirror{list-style:none}.wp-customizer a{color:#000}.wp-customizer a:focus,.wp-customizer a:hover{color:#0073aa}.wp-customizer .wp-full-overlay.expanded{margin-left:440px}.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left:-440px}#customize-theme-controls .control-section.current-panel>h3.accordion-section-title{left:-440px}.accordion-sub-container.control-panel-content{left:440px}.rtl.wp-customizer .wp-full-overlay.expanded{margin-right:440px;margin-left:0}.rtl.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-right:-440px;margin-left:0}.rtl #customize-theme-controls .control-section.current-panel>h3.accordion-section-title{right:-440px}.rtl .accordion-sub-container.control-panel-content{right:440px}.customize-section-description-container+#customize-control-custom_css:last-child{margin:0;width:100%}li#customize-control-custom_css textarea{font-size:13px;background:#394143;color:#95ff0c;min-height:300px}@media screen and (max-width:1400px){.rtl.wp-customizer .wp-full-overlay-sidebar,.wp-customizer .wp-full-overlay-sidebar{width:380px}.wp-customizer .wp-full-overlay.expanded{margin-left:380px}.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left:-380px}#customize-theme-controls .control-section.current-panel>h3.accordion-section-title{left:-380px}.accordion-sub-container.control-panel-content{left:380px}.rtl.wp-customizer .wp-full-overlay.expanded{margin-right:380px;margin-left:0}.rtl.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-right:-380px;margin-left:0}.rtl #customize-theme-controls .control-section.current-panel>h3.accordion-section-title{right:-380px}.rtl .accordion-sub-container.control-panel-content{right:380px}}@media screen and (max-width:979px){.rtl.wp-customizer .wp-full-overlay-sidebar,.wp-customizer .wp-full-overlay-sidebar{width:300px}.wp-customizer .wp-full-overlay.expanded{margin-left:300px}.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left:-300px}#customize-theme-controls .control-section.current-panel>h3.accordion-section-title{left:-300px}.accordion-sub-container.control-panel-content{left:300px}.rtl.wp-customizer .wp-full-overlay.expanded{margin-right:300px;margin-left:0}.rtl.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-right:-300px;margin-left:0}.rtl #customize-theme-controls .control-section.current-panel>h3.accordion-section-title{right:-300px}.rtl .accordion-sub-container.control-panel-content{right:300px}}@media screen and (max-width:640px){.wp-customizer .customize-controls-preview-toggle{height:46px;border-bottom:1px solid #ddd;left:87px}.wp-customizer .wp-full-overlay.expanded{margin-left:0}#customize-theme-controls .control-section.current-panel>h3.accordion-section-title{left:-100%}.accordion-sub-container.control-panel-content{left:100%}.rtl.wp-customizer .wp-full-overlay.expanded{margin-right:0}.rtl #customize-theme-controls .control-section.current-panel>h3.accordion-section-title,.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-100%;left:auto}.rtl .accordion-sub-container.control-panel-content{right:100%}}.wp-customizer .control-section.control-panel .accordion-section-title .panel-title{font-size:24px;font-weight:inherit;line-height:30px}.wp-core-ui h3{color:#555}.accordion-section-title:after,.control-section.control-panel>.accordion-section-title:after,.handlediv,.item-edit,.sidebar-name-arrow,.widget-action,.wp-customizer #available-menu-items .menu-item-handle:hover .item-add,.wp-customizer #customize-controls .customize-info .customize-help-toggle:focus,.wp-customizer #customize-controls .customize-info .customize-help-toggle:hover,.wp-customizer #customize-controls .customize-info.open .customize-help-toggle,.wp-customizer .menu-item-handle:hover,.wp-customizer .menu-item-handle:hover .item-edit,.wp-customizer .menu-item-handle:hover .item-type{color:#00a0d2}.accordion-section-content{padding:10px 10px 15px 20px}.customize-control-title{line-height:19px}.wp-customizer #customize-theme-controls .accordion-section-content{background:#fff}.wp-customizer #customize-controls .customize-info .customize-help-toggle:focus:before,.wp-customizer .customize-screen-options-toggle:focus:before{-webkit-box-shadow:0 0 0 1px #00a0d2;box-shadow:0 0 0 1px #00a0d2;-webkit-border-radius:100%;border-radius:100%}#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:active,#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:focus,#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:hover,.active-menu-screen-options .customize-screen-options-toggle,.customize-screen-options-toggle:active,.customize-screen-options-toggle:focus,.customize-screen-options-toggle:hover{color:#00a0d2!important}.customize-control input[type=text]{line-height:23px}li[id*=customize-control-]{padding:2%;width:96%;border:1px solid rgba(221,221,221,.43);box-shadow:1px 0 2px 0 rgba(204,204,204,.45);-webkit-box-shadow:1px 0 2px 0 rgba(204,204,204,.45);margin:8px 0}.control-section .accordion-section-content{overflow-y:auto}.wp-customizer .control-section h3.accordion-section-title{padding:10px 25px 11px 14px}.wp-customizer #customize-controls h3{font-size:15px;font-weight:400}.control-section .accordion-section-title:after{top:7px}.control-section.control-panel .accordion-section-title:after{top:11px;-webkit-transition:right .3s ease-in-out,opacity .3s ease-in-out;-moz-transition:right .3s ease-in-out,opacity .3s ease-in-out;-ms-transition:right .3s ease-in-out,opacity .3s ease-in-out;-o-transition:right .3s ease-in-out,opacity .3s ease-in-out;transition:right .3s ease-in-out,opacity .3s ease-in-out;right:10px;opacity:.7}.rtl .control-section.control-panel .accordion-section-title:after{-webkit-transition:left .3s ease-in-out,opacity .3s ease-in-out;-moz-transition:left .3s ease-in-out,opacity .3s ease-in-out;-ms-transition:left .3s ease-in-out,opacity .3s ease-in-out;-o-transition:left .3s ease-in-out,opacity .3s ease-in-out;transition:left .3s ease-in-out,opacity .3s ease-in-out;left:10px;right:initial}#customize-theme-controls .control-section.control-panel h3.accordion-section-title:focus:after,#customize-theme-controls .control-section.control-panel h3.accordion-section-title:hover:after{right:8px;opacity:1;color:#666!important}.rtl #customize-theme-controls .control-section.control-panel h3.accordion-section-title:focus:after,.rtl #customize-theme-controls .control-section.control-panel h3.accordion-section-title:hover:after{left:6px;right:initial}#customize-theme-controls .control-section.control-panel>h3.accordion-section-title:focus:after,#customize-theme-controls .control-section.control-panel>h3.accordion-section-title:hover:after,.control-section.control-panel>.accordion-section-title:after{background:0 0!important;border:none!important}#customize-theme-controls h3.accordion-section-title{-webkit-transition:background .1s ease-in-out;-moz-transition:background .1s ease-in-out;-ms-transition:background .1s ease-in-out;-o-transition:background .1s ease-in-out;transition:background .1s ease-in-out}.customize-control-checkbox label,.customize-control-nav_menu_auto_add label,.customize-control-radio label{line-height:16px;margin-left:0}input::-webkit-input-placeholder{color:#9A9A9A;font-style:italic}input:-moz-placeholder{color:#9A9A9A;font-style:italic}input::-moz-placeholder{color:#9A9A9A;font-style:italic}input:-ms-input-placeholder{color:#9A9A9A;font-style:italic}.czr-customizr-title{text-transform:uppercase;margin:1em 0 5px;font-size:15px!important;border-bottom:1px dotted #555;padding-bottom:5px;text-align:center}h3.czr-customizr-title::before{content:'\00b7';padding-right:3px}h3.czr-customizr-title::after{content:'\00b7';padding-left:3px}.czr-after-button{border-color:#fff;margin-top:15px}.czr-emphasize{line-height:1.2em;color:#2E2E2E}span.czr-notice{color:#313131;font-size:12px;font-style:italic;line-height:18px}.czr-customizer-separator-invisible{border:none;margin-top:15px}.czr-skin-gen-label{float:left}.czr-skin-gen-color-picker{float:right}.czr-number-label{float:left}.czr-number-input{float:right}.czr-check-label{float:left;max-width:85%}.rtl .czr-check-label{float:right}input[type=checkbox],input[type=radio]{float:right;min-height:18px}.czr-font-select{float:left}li#customize-control-tc_theme_options-tc_custom_css textarea{font-size:14px;background:#394143;color:#E2E728;min-height:300px}.customize-control .czr-navigate-to-post-list{color:#00a0d2;font-weight:700;float:left;clear:both;width:100%;margin-bottom:8px}.czr-sub-control{padding-left:13%;max-width:87%;position:relative}.czr-sub-control:before{content:'';height:116%;background:#00a0d2;width:2%;position:absolute;left:7%}.customize-control-tc_cropped_image .upload-button{float:right}.customize-control-tc_cropped_image .remove-button{float:left;margin-right:3px}.customize-control-tc_cropped_image .actions{margin-bottom:32px}.customize-control-tc_cropped_image .current{margin-bottom:8px}.customize-control-tc_cropped_image .remove-button,.customize-control-tc_cropped_image .upload-button{white-space:normal;width:48%;height:auto}.customize-control-tc_cropped_image .current .container{min-height:40px;overflow:hidden;border:1px solid #eee;-webkit-border-radius:2px;border-radius:2px}.customize-control-tc_cropped_image img{width:100%;-webkit-border-radius:2px;border-radius:2px}.customize-control-tc_cropped_image .inner{line-height:20px;top:10px}.rtl .customize-control-tc_cropped_image .upload-button{float:left}.rtl .customize-control-tc_cropped_image .remove-button{float:right;margin-left:3px}.czr-layout-img{height:26px;padding-top:2px;border:1px solid #FFF}.czr-layout-title{padding:0 0 18px 12px;display:inline-block;line-height:0;vertical-align:middle}.customize-control-czr_multi_input{width:96%;border:1px solid #ccc;padding:2%}.czr-multi-input-wrapper{width:95%;padding:0 0 0 5%}.czr-multi-input-wrapper [data-input-type=color] .czr-input{float:left;clear:both}#customize-theme-controls #accordion-panel-czr-footer-panel{border-bottom:1px solid #ddd}#customize-theme-controls #accordion-panel-hu-advanced-panel,#customize-theme-controls #accordion-panel-nav_menus,#customize-theme-controls .control-panel-widgets{margin-top:10px}#customize-theme-controls #accordion-panel-hu-advanced-panel,#customize-theme-controls #accordion-panel-hu-header-panel,#customize-theme-controls #accordion-panel-nav_menus,#customize-theme-controls .control-panel-widgets{border-top:1px solid #ddd}#customize-theme-controls #accordion-panel-hu-general-panel,#customize-theme-controls #accordion-panel-tc-global-panel,#customize-theme-controls #accordion-section-frontpage_sec,#customize-theme-controls #accordion-section-static_front_page,#customize-theme-controls #accordion-section-tc_font_customizer_settings,#customize-theme-controls #accordion-section-tc_fpu{margin-bottom:10px}#customize-header-actions .customize-controls-close{left:45px}.customize-controls-close,.customize-controls-home{top:-1px}.customize-controls-home{display:block;position:absolute;left:0;width:45px;height:41px;padding:0 2px 0 0;background:#eee;border:none;border-top:4px solid #eee;border-right:1px solid #ddd;border-bottom:1px solid #ddd;color:#444;text-align:left;cursor:pointer;text-decoration:none;-webkit-transition:color .15s ease-in-out,border-color .15s ease-in-out,background .15s ease-in-out;transition:color .1s ease-in-out,border-color .15s ease-in-out,background .15s ease-in-out;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.customize-controls-home:before{font-size:17px;line-height:45px;position:relative;top:-4px;left:15px}.customize-controls-home:hover{background:#fff;color:#0073aa;border-top-color:#0073aa;outline:0;-webkit-box-shadow:none;box-shadow:none}.rtl.wp-customizer #customize-header-actions .customize-controls-close{right:45px;left:auto}.rtl.wp-customizer .customize-controls-home{left:auto;right:0;border-right:0;border-left:1px solid #ddd}.control-panel-content .hu-menu-notice{margin-left:3%}span.czr-panel-subtitle{display:block;font-size:12px;font-style:italic}.control-section-czr-customize-section-pro .accordion-section-title .button,.pro-title-block{display:inline-block;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;color:#fff}.pro-title-block{background:#f0ad4e;border:1px solid #eea236;padding:0 6px;font-size:.7em;margin-right:3px;bottom:2px;position:relative;webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);border-radius:3px}#customize-controls .control-section-czr-customize-section-pro .accordion-section-title:focus,#customize-controls .control-section-czr-customize-section-pro .accordion-section-title:hover{background-color:#fff}#customize-theme-controls .control-section-czr-customize-section-pro .accordion-section-title:after{content:none}#accordion-section-go_pro_sec .accordion-section-title{margin:0 0 15px}.control-section-czr-customize-section-pro .accordion-section-title .button{font-size:15px;line-height:24px;height:30px;padding:1px 20px;background:#f0ad4e;border:1px solid #eea236;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;border-radius:3px;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;-ms-transition:all .2s ease-in-out;transition:all .2s ease-in-out;user-select:none;margin-top:-4px;font-weight:400;margin-left:8px}.control-section-czr-customize-section-pro .accordion-section-title .button:hover{color:#fff;background:#ed9c28;border-color:#d58512}.rtl .control-section-czr-customize-section-pro .accordion-section-title .button{margin-left:0;margin-right:8px}.czr-open-pre-add-new{display:block;float:left;margin:2% 2% 0;width:99%;padding:2%;background:#3b8dbd;opacity:1;color:#fff;font-size:16px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;-webkit-border-radius:3px;border-radius:3px;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:opacity 1s ease-in-out;-moz-transition:opacity 1s ease-in-out;-ms-transition:opacity 1s ease-in-out;-o-transition:opacity 1s ease-in-out;transition:opacity 1s ease-in-out}.czr-open-pre-add-new.active{background:#646464;opacity:.5;border-radius:3px 3px 0 0}.czr-adding-new .czr-items-wrapper,.czr-items-wrapper .inactive{opacity:.6}.czr-single-item{padding:0;border:1px solid #ccc;margin:1% 0 0 2%;float:left;width:98%;-webkit-border-radius:3px;border-radius:3px;-webkit-transition:opacity 1s ease-in-out;-moz-transition:opacity 1s ease-in-out;-ms-transition:opacity 1s ease-in-out;-o-transition:opacity 1s ease-in-out;transition:opacity 1s ease-in-out}.czr-single-item .czr-item-content input,.czr-sub-set{margin-bottom:0}#customize-theme-controls .czr-single-item.open{border:1px solid #dedede}#customize-theme-controls .mono-item-mod .czr-single-item{border:1px solid #ccc}.czr-single-item .czr-item-content,.czr-single-item .czr-item-header{padding:1%}.czr-items-wrapper .czr-single-item .czr-builtin-model{background:#E1DFDF;color:#555}.czr-item-sort-handle{cursor:move}.czr-single-item .czr-item-header{position:relative;background:#dfdfdf;color:#fff;float:left;width:98%;-webkit-transition:background .1s ease-in-out;-moz-transition:background .1s ease-in-out;-ms-transition:background .1s ease-in-out;-o-transition:background .1s ease-in-out;transition:background .1s ease-in-out}.czr_widget_areas_module .czr-single-item .czr-custom-model{background:#3b8dbd}. .czr-single-item .czr-custom-model:hover{background:#aaa}.czr-items-wrapper .czr-single-item .czr-builtin-model:hover,.czr-single-item .czr-item-header:hover{background:#ccc}.czr-move-icon{position:absolute;top:-2px;left:3px;font-size:10px;color:#999}.czr-item-title{float:left;font-size:17px;color:#000;padding:7px;width:67%}.czr-inactive-alert{font-size:12px;font-style:italic}.czr_widget_areas_module .czr-item-title{color:#fff}.czr-builtin-model .czr-item-title{color:#23282d}.czr-item-title h4{margin:0}.czr-item-title .fa:before{padding-right:2px}.czr-item-btns{float:right}.czr-item-btns a{font-size:17px;padding:7px 5px;color:#777;-webkit-transition:color .1s ease-in-out;-moz-transition:color .1s ease-in-out;-ms-transition:color .1s ease-in-out;-o-transition:color .1s ease-in-out;transition:color .1s ease-in-out}.czr-item-btns a:active,.czr-item-btns a:focus{outline:0;-webkit-box-shadow:none;box-shadow:none}.czr_widget_areas_module .czr-item-btns a{color:#fff}.czr-builtin-model .czr-item-btns a{color:#555}.czr-builtin-model .czr-item-btns .czr-edit-view.active,.czr-builtin-model .czr-item-btns .czr-edit-view:hover,.czr-item-btns .czr-edit-view.active,.czr-item-btns .czr-edit-view:hover{color:#00a0d2}.czr_widget_areas_module .czr-edit-view:hover,.czr_widget_areas_module .czr-item-btns .czr-edit-view.active{color:#000}.czr_widget_areas_module .czr-builtin-model .czr-edit-view.active,.czr_widget_areas_module .czr-builtin-model .czr-edit-view:hover{color:#00a0d2}.czr-item-btns .czr-display-alert.active,.czr-item-btns .czr-display-alert:hover{color:#23282d}.czr-single-item .czr-item-content{display:none;background:rgba(238,238,238,.5);clear:both;width:96%;padding:2%}.czr-sub-set{display:block;float:left;width:100%;padding:1% 0;position:relative}.czr-sub-set .czr-input{float:right;width:60%}.czr-sub-set .customize-control-title.width-100,.width-100 .czr-input{width:100%}.czr-sub-set .customize-control-title{float:left;width:40%;padding:1px 0;font-size:13px}.rtl.wp-customizer .czr-sub-set .customize-control-title{float:right}.disabled .customize-control-title,.disabled .czr-input{opacity:.6;filter:blur(1px);-webkit-filter:blur(1px)}.czr-item-title .fa{font-size:18px}.czr-remove-alert-wrapper{display:none;clear:both;float:left;padding:2%;width:95%;margin:10px 0;text-shadow:0 1px 0 rgba(255,255,255,.5);background-color:#EEE;color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.czr-remove-alert-wrapper p{padding:5px;margin:0}.czr-pre-add-wrapper{position:relative;float:left;width:100%}.czr-pre-add-view-content{display:none;padding:3%;border:1px solid #00a0d2;border-top:none;margin:0 0 0 2%;float:left;width:92%;background:#eee;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;position:relative;opacity:1;-webkit-transition:opacity .2s linear;-moz-transition:opacity .2s linear;-ms-transition:opacity .2s linear;-o-transition:opacity .2s linear;transition:opacity .2s linear}.czr-model-added .czr-pre-add-view-content{opacity:.2}.czr-pre-add-wrapper .czr-add-new{background:#3b8dbd;color:#fff;-webkit-transition:background .5s linear;-moz-transition:background .5s linear;-ms-transition:background .5s linear;-o-transition:background .5s linear;transition:background .5s linear;float:right;border:none}.czr-add-success{width:100%;margin:0 0 0 2%;position:absolute;top:0;left:0;font-size:25px;text-align:center;opacity:0;-webkit-transition:opacity .1s linear;-moz-transition:opacity .1s linear;-ms-transition:opacity .1s linear;-o-transition:opacity .1s linear;transition:opacity .1s linear}.czr-model-added .czr-add-success{opacity:1}.czr-unavailable-location,body.czr-editing-modopt #customize-preview{opacity:.7}.czr-add-success p{vertical-align:middle;display:inline-block;line-height:35px;margin:0;font-size:25px;color:#82b965;padding:0 3%}.control-section-widget_zones_management{margin:10px 0;z-index:1}.czr-zone-infos{width:96%;padding:0 2%;font-size:12px;float:left;font-style:italic}.czr-location-alert{float:left;width:100%;padding:1% 0;margin:1% 0;text-align:center;border:1px solid orange;background:#FEE5B6;color:#000;font-size:11px;font-style:italic}.czr-toggle-modopt{color:#495050;text-shadow:1px 1px 0 #fff;-webkit-transition:color .4s;transition:color .4s;position:absolute;right:0;padding-left:3px;font-size:25px;line-height:24px}.rtl.wp-customizer .czr-toggle-modopt{left:0;right:auto;padding-left:0;padding-right:3px}.czr-modopt-visible .czr-toggle-modopt,.czr-toggle-modopt:hover{color:#3b8dbd}body #customize-controls{-webkit-transition:opacity .4s ease-in-out;-moz-transition:opacity .4s ease-in-out;-ms-transition:opacity .4s ease-in-out;-o-transition:opacity .4s ease-in-out;transition:opacity .4s ease-in-out}body.czr-editing-modopt #customize-controls{opacity:.4}.czr-mod-opt-wrapper{position:absolute;top:0;bottom:0;left:-301px;opacity:0;overflow-x:hidden;overflow-y:auto;margin:0;z-index:4;width:60%;min-width:300px;padding:1% 2%;color:#fff;background:rgba(0,0,0,.8);-webkit-transition:all .18s ease-in-out;-moz-transition:all .18s ease-in-out;-ms-transition:all .18s ease-in-out;-o-transition:all .18s ease-in-out;transition:all .18s ease-in-out;border-right:1px solid #4c4c4c}body.czr-editing-modopt .czr-mod-opt-wrapper{left:0;visibility:visible;opacity:1}.czr-close-modopt{position:absolute;top:10px;right:25px;font-size:31px;cursor:pointer}.czr-mod-opt-wrapper .czr-sub-set{background:rgba(238,238,238,.13);padding:3% 2%;width:96%;margin:5px 0}.tabs,.tabs nav ul{position:relative;margin:0 auto;overflow:hidden}.czr-mod-opt-wrapper .czr-notice{color:#fff}.czr-mod-opt-wrapper .mod-opt-title{color:#fff;border-bottom:1px solid #fff;padding:5% 0;text-align:center}.tabs{display:none;width:100%;font-weight:300;font-size:1.25em}.tabs nav{text-align:center}.tabs nav ul{display:-ms-flexbox;display:-webkit-flex;display:-moz-flex;display:-ms-flex;display:flex;padding:0;max-width:1200px;-ms-box-orient:horizontal;-ms-box-pack:center;-webkit-flex-flow:row wrap;-moz-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;-webkit-justify-content:center;-moz-justify-content:center;-ms-justify-content:center;justify-content:center}.tabs nav a,.tabs nav ul li{position:relative;display:block}.tabs nav ul li{z-index:1;margin:0;text-align:center;-webkit-flex:1;-moz-flex:1;-ms-flex:1;flex:1}.tabs nav ul li.cols-4{width:25%}.tabs nav ul li.cols-3{width:33%}.tabs nav ul li.cols-2{width:50%}.tabs nav ul li.cols-1{width:100%}.tabs nav a{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:2.5}li.tab-current::after,li.tab-current::before,li.tab-inactive::after{content:'';position:absolute;width:100%}.tabs nav a span{vertical-align:middle;font-size:.75em}.tabs nav li.tab-current a{color:#74777b}.tabs nav a:focus{outline:0}li.tab-current::after,li.tab-current::before{height:100%;-webkit-box-shadow:4px 0 15px 0 rgba(37,37,37,.63);box-shadow:4px 0 15px 0 rgba(37,37,37,.63);top:0;right:0;z-index:4}li.tab-current::before{left:0;-webkit-box-shadow:0 0 15px 4px rgba(37,37,37,.63);box-shadow:0 0 15px 4px rgba(37,37,37,.63)}li.tab-inactive::after{height:2px;bottom:-7px;left:0;-webkit-box-shadow:4px 0 15px 0 rgba(119,119,119,.58);box-shadow:4px 0 15px 0 rgba(0,0,0,.86)}.content-wrap{position:relative}.content-wrap section{display:none;margin:0 auto;max-width:1200px}section .czr-sub-set:first-child{margin:0}.content-wrap section.content-current,.no-flexbox nav ul{display:block}.no-flexbox nav ul li{min-width:15%;display:inline-block}.tabs-style-topline{max-width:1200px}.tabs-style-topline nav li{border:1px solid rgba(40,44,42,.1)}.czr-items-wrapper .tabs-style-topline nav li{border:none}.tabs-style-topline nav li:not(:last-child){border-right:none}.tabs-style-topline nav li.tab-current{border-top-color:#fff;border-bottom:none;background:rgba(238,238,238,.13)}.tabs-style-topline nav a{padding:.65em .5em;background:rgba(40,44,42,.05);color:#fff;line-height:1;-webkit-transition:color .2s;transition:color .2s;text-decoration:none}.czr-disable-bottom-infos,.czr-skope-switch,.czr-skp-switch-link:hover,.tabs-style-topline nav a:focus,.tabs-style-topline nav a:hover,.tabs-style-topline nav li.tab-current a{text-decoration:underline}.czr-items-wrapper .tabs-style-topline nav a{background:rgba(40,44,42,.45)}.tabs-style-topline nav li.tab-current a{background:0 0;box-shadow:inset 0 3px 0 #fff;color:#fff}.czr-items-wrapper .tabs-style-topline nav li.tab-current a{color:#000}.tabs-style-topline .icon::before{display:block;margin:0}.tabs-style-topline nav a span{text-transform:uppercase;letter-spacing:1px;font-weight:700}@media screen and (max-width:58em){.tabs nav a.icon span{display:none}.tabs nav a:before{margin-right:0}}.czr_slide_module .czr-item-title{padding:0 7px;height:32px}.czr_slide_module .slide-thumb,.czr_slide_module .slide-title{display:block;height:32px;line-height:32px;float:left}.czr_slide_module .slide-title{padding-left:5px}.slide-mod-skope-notice{padding:3%;background:rgba(116,210,116,.42);float:left;font-size:12px;line-height:1.5em}.slide-mod-skope-notice .czr-skope-switch{cursor:pointer;text-decoration:underline}.modopts-top-buttons{width:100%;float:left;margin-bottom:4%;text-align:center}.item-bottom-buttons{width:100%;float:left;padding:1% 0}.item-bottom-btn,.modopt-top-btn{color:#fff;font-size:14px;cursor:pointer;border-width:1px;-webkit-appearance:none;-webkit-border-radius:3px;border-radius:4px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-ms-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;opacity:1}.item-bottom-btn{background:#868686;width:47%;margin-right:2%;padding:1% 0}.modopt-top-btn{background:rgba(171,171,171,.5);width:170px;padding:2px 0}.item-bottom-btn:hover{background:#5d5d5d}.modopt-top-btn:hover{background:rgba(41,41,41,.53)}.item-bottom-btn[disabled],.item-bottom-btn[disabled]:hover,.modopt-top-btn[disabled],.modopt-top-btn[disabled]:hover{opacity:.4;cursor:default;-webkit-box-shadow:none!important;box-shadow:none!important;background:inherit}.czr-notice{font-size:12px;font-weight:400}.in-sub-panel #czr-donate-customizer,.in-sub-panel .czr-cta-wrap{left:-450px;height:0}.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-450px}@media screen and (max-width:1400px){.in-sub-panel #czr-donate-customizer,.in-sub-panel .czr-cta-wrap{left:-380px}.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-380px}}@media screen and (max-width:979px){.in-sub-panel #czr-donate-customizer,.in-sub-panel .czr-cta-wrap{left:-300px}.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-300px}}@media screen and (max-width:640px){.in-sub-panel #czr-donate-customizer,.in-sub-panel .czr-cta-wrap{left:-100%}.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-100%;left:auto}}@media screen and (min-width:980px){.wp-customizer .expanded #customize-footer-actions{width:380px}}@media screen and (min-width:1401px){.wp-customizer .expanded #customize-footer-actions{width:440px}}.selecter-element{position:absolute;opacity:0}.selecter{display:block;float:right;margin:2px 0;position:relative;width:100%;z-index:100}.selecter .selecter-selected{background:url(img/jquery.fs.selecter-arrow.png) right center no-repeat #F9F9F9;border:1px solid #ccc;border-radius:3px;color:#333;cursor:pointer;display:block;font-size:13px;margin:0;overflow:hidden;padding:4px 4.6%;position:relative;text-overflow:clip;z-index:49;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);height:auto;line-height:18px;width:90%}.selecter .selecter-options{border:1px solid #ccc;border-width:0 1px 1px;background-color:#fefefe;border-radius:0 0 3px 3px;box-shadow:0 1px 4px rgba(0,0,0,.15);display:none;left:0;margin:0;max-height:260px;overflow:auto;overflow-x:hidden;padding:0;position:relative;top:100%;width:99%;z-index:50}.selecter .selecter-group{background:#F9F9F9;border-bottom:1px solid #e3e3e3;color:#999;display:block;font-size:11px;padding:5px 10px 4px;text-transform:uppercase}.selecter .selecter-item{background:#fff;border-bottom:1px solid #e3e3e3;color:#333;cursor:pointer;display:block;font-size:13px;margin:0;overflow:hidden;text-overflow:ellipsis;width:86%;height:auto;line-height:14px;padding:8px 24px 8px 10px}.selecter.disabled .selecter-group,.selecter.disabled .selecter-item,.selecter.disabled .selecter-selected{cursor:default;color:#ccc;border-color:#eee}.selecter .selecter-item.selected{background:#F9F9F9}.selecter .selecter-item.disabled{color:#999;cursor:default}.selecter .selecter-item:first-child{border-radius:0}.selecter .selecter-item:last-child{border-radius:0 0 2px 2px;border-bottom:0}.rtl .selecter .selecter-selected{background:url(img/jquery.fs.selecter-arrow.png) 4% center no-repeat #F9F9F9}@media screen and (min-width:980px){.selecter .selecter-item.selected:hover,.selecter .selecter-item:hover{background-color:#f3f3f3}.selecter .selecter-item.disabled:hover,.selecter:hover .selecter-selected{background-color:#fff}.selecter.disabled .selecter-item:hover{background:#fff}}.selecter.open{z-index:101}.selecter.open .selecter-selected{border-radius:3px 3px 0 0;z-index:51}.selecter.focus .selecter-selected,.selecter.open .selecter-selected{background-color:#fff;box-shadow:0 0 5px rgba(0,0,0,.1)}.selecter.cover .selecter-options{border-radius:3px;border-width:1px;top:0}.selecter.cover .selecter-options .selecter-item.first{border-radius:3px 3px 0 0}.selecter.cover.open .selecter-selected{border-radius:3px 3px 0 0;z-index:49}.selecter.bottom .selecter-options{border-width:1px 1px 0;bottom:100%;top:auto}.selecter.bottom .selecter-item:last-child{border:none}.selecter.bottom.open .selecter-selected{border-radius:0 0 3px 3px}.selecter.bottom.open .selecter-options{border-radius:3px 3px 0 0}.selecter.bottom.cover.open .selecter-options,.selecter.bottom.cover.open .selecter-selected,.stepper{border-radius:3px}.selecter.bottom.cover .selecter-options{bottom:0;top:auto}.selecter.multiple .selecter-options{border-radius:3px;border-width:1px;box-shadow:none;display:block;position:static;width:100%}.selecter.disabled .selecter-selected{background:#fff}.selecter.disabled .selecter-options{background:#fff;border-color:#eee}.selecter.disabled .selecter-item.selected{background:#fafafa}.selecter .selecter-options.scroller{overflow:hidden}.selecter .selecter-options.scroller .scroller-content{max-height:260px;padding:0}@media screen and (max-width:740px){.selecter{max-width:100%}}@media screen and (max-width:500px){.selecter{max-width:100%}}.stepper{margin:0 0 10px;overflow:hidden;position:relative;width:35%;float:left;clear:both}.stepper .stepper-input{background:#F9F9F9;border:1px solid #ccc;border-radius:3px;color:#333;font-size:13px;line-height:1.2;margin:0;overflow:hidden;padding:5px 10px!important;width:100%!important;z-index:49;-moz-appearance:textfield;max-width:none!important}.stepper .stepper-input::-webkit-inner-spin-button,.stepper .stepper-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.stepper .stepper-input:focus{background-color:#fff}.stepper .stepper-arrow{background:url(img/jquery.fs.stepper-arrows.png) no-repeat #eee;border:1px solid #ccc;cursor:pointer;display:block;height:46%;position:absolute;right:0;text-indent:-99999px;width:20px;z-index:50}.stepper .stepper-arrow.up{background-position:center top;border-bottom:none;top:0}.stepper .stepper-arrow.down{background-position:center bottom;bottom:0}.rtl .stepper .stepper-input{text-align:left}@media screen and (min-width:740px){.stepper:hover .stepper-input{background-color:#fff}.stepper .stepper-step:hover{background-color:#F9F9F9}.stepper.disabled .stepper-arrow{background:#fff;border-color:#eee;cursor:default}}.stepper.disabled .stepper-input{background:#fff;border-color:#eee;color:#ccc}.stepper.disabled .stepper-arrow{background:#fff;border-color:#eee;cursor:default}.icheckbox_flat-green,.icheckbox_flat-grey,.iradio_flat-green,.iradio_flat-grey{display:inline-block;margin:0;padding:0;width:20px;height:20px;border:none;top:4px;vertical-align:middle}.icheckbox_flat-green,.iradio_flat-green{background:url(img/green.png) no-repeat;cursor:pointer;float:right}.rtl [class*=icheckbox_flat-]{float:left}.icheckbox_flat-green{background-position:0 0}.icheckbox_flat-green.checked{background-position:-22px 0}.icheckbox_flat-green.disabled{background-position:-44px 0;cursor:default}.icheckbox_flat-green.checked.disabled{background-position:-66px 0}.iradio_flat-green{background-position:-88px 0}.iradio_flat-green.checked{background-position:-110px 0}.iradio_flat-green.disabled{background-position:-132px 0;cursor:default}.iradio_flat-green.checked.disabled{background-position:-154px 0}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (-moz-min-device-pixel-ratio:1.5),only screen and (-o-min-device-pixel-ratio:3/2),only screen and (min-device-pixel-ratio:1.5){.icheckbox_flat-green,.iradio_flat-green{background-image:url(img/green@2x.png);-webkit-background-size:176px 22px;background-size:176px 22px}}.icheckbox_flat-grey,.iradio_flat-grey{background:url(img/grey.png) no-repeat;cursor:pointer;float:right}.icheckbox_flat-grey{background-position:0 0}.icheckbox_flat-grey.checked{background-position:-22px 0}.icheckbox_flat-grey.disabled{background-position:-44px 0;cursor:default}.icheckbox_flat-grey.checked.disabled{background-position:-66px 0}.iradio_flat-grey{background-position:-88px 0}.iradio_flat-grey.checked{background-position:-110px 0}.iradio_flat-grey.disabled{background-position:-132px 0;cursor:default}.iradio_flat-grey.checked.disabled{background-position:-154px 0}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (-moz-min-device-pixel-ratio:1.5),only screen and (-o-min-device-pixel-ratio:3/2),only screen and (min-device-pixel-ratio:1.5){.icheckbox_flat-grey,.iradio_flat-grey{background-image:url(img/grey@2x.png);-webkit-background-size:176px 22px;background-size:176px 22px}}.czr-sub-set .icheckbox_flat-green,.iradio_flat-green{float:left}body .select2-container{z-index:1000000;width:100%!important}.customize-control-czr_layouts .select2-selection--single{height:33px}.customize-control-czr_layouts .select2-container--default .select2-selection--single .select2-selection__arrow{height:30px}.customize-control-czr_layouts .select2-selection--single:focus,.select2-selection__rendered:focus{outline:0}body .select2-drop{z-index:1000000}body .select2-container,span.select2-results{font-size:14px}.select2-container--default .select2-selection--multiple{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;width:99%;min-height:36px;border:1px solid #ddd;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.07);box-shadow:inset 0 1px 2px rgba(0,0,0,.07)}.select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#00a0d2!important;-webkit-box-shadow:0 0 2px rgba(26,188,156,.8)!important;box-shadow:0 0 2px rgba(26,188,156,.8)!important}.select2-results__options li{margin-bottom:0}.select2-container--default .select2-selection--multiple .select2-selection__choice{padding:2px;font-size:13px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;margin-bottom:0}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#00a0d2}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{font-size:17px;position:relative;top:2px;color:#23282d}.customize-control-czr_socials .select2-container--default .select2-selection--single .select2-selection__rendered{padding:5px;line-height:16px}#czr-customize-content_editor-pane{border-top:solid 1px #ddd;position:absolute;height:300px;bottom:-301px;right:0;left:0;z-index:20;background:#f1f1f1;display:block;-webkit-transition:all .2s;transition:all .2s;visibility:hidden}body.czr-customize-content_editor-pane-resize #customize-preview,body.czr-customize-content_editor-pane-resize #czr-customize-content_editor-pane{-webkit-transition:none;transition:none}body.mce-fullscreen.czr-customize-content_editor-pane-open #czr-customize-content_editor-pane{top:0}body.czr-customize-content_editor-pane-open #czr-customize-content_editor-pane{bottom:0;visibility:inherit}#czr-customize-content_editor-pane .wp-editor-tools{padding-top:5px;padding-right:10px}#czr-customize-content_editor-pane .wp-media-buttons{padding-left:5px}#customize-preview{height:auto}body.czr-customize-content_editor-pane-open #customize-preview{bottom:300px}body.mce-fullscreen #customize-preview{bottom:0}body.mce-fullscreen.czr-customize-content_editor-pane-open div.mce-fullscreen{position:relative;left:0}#wp-czr-customize-content_editor-container{border-left:0}#czr-customize-content_editor-dragbar{top:0;cursor:row-resize;display:block;height:4px;position:absolute;width:100%;z-index:21}body.czr-customize-content_editor-pane-resize #customize-preview:before{top:0;right:0;bottom:0;left:0;position:absolute;height:100%;width:100%;z-index:999999}.wp-customizer .ui-autocomplete.wplink-autocomplete{z-index:500110}.wp-customizer #wp-link-wrap{z-index:500105}.wp-customizer #wp_editbtns,.wp-customizer #wp_gallerybtns{z-index:500020}.wp-customizer #TB_overlay,.wp-customizer #TB_window{z-index:500050}.wp-customizer .mce-panel,.wp-customizer .mce-tooltip{z-index:500100!important}.czr-customize-content_editor-pane-open .wp-full-overlay.collapsed .wp-full-overlay-sidebar{z-index:30}.czr-customize-content_editor-pane-open .wp-full-overlay.collapsed .collapse-sidebar{bottom:308px}.czr-customize-content_editor-pane-open .wp-full-overlay.expanded .collapse-sidebar{bottom:0!important}.czr-customize-content_editor-pane-resize .wp-full-overlay.collapsed .collapse-sidebar{-webkit-transition:none;transition:none}.czr-customize-content_editor-pane-open.mce-fullscreen .wp-full-overlay.collapsed .collapse-sidebar{bottom:8px!important}.czr-sub-set[data-input-type=content_picker] .customize-control-title,.czr-sub-set[data-input-type=content_picker] .czr-input{width:100%}.content-picker-item{height:2em}.content-picker-item .czr-picker-item-type{float:right;display:inline-block}.content-item-bar{line-height:1.2em;font-size:.9em}.content-item-bar .czr-picker-item-title{display:block;float:left;max-width:80%;text-overflow:ellipsis;overflow:hidden;font-size:13px;line-height:1.3em}.czr-sub-set[data-input-type=content_picker] span.czr-picker-item-title{display:block;float:left;max-width:80%;text-overflow:ellipsis;overflow:hidden;font-size:14px;line-height:2em;color:#000}.czr-sub-set[data-input-type=content_picker] span.czr-picker-item-type{display:inline-block;padding:0 10px 0 0;float:right;line-height:2em}.rangeslider,.rangeslider__fill{display:block;-moz-box-shadow:inset 0 1px 3px rgba(0,0,0,.3);-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,.3);box-shadow:inset 0 1px 3px rgba(0,0,0,.3);-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}.rangeslider{background:#e6e6e6;position:relative}.rangeslider--horizontal{height:20px;width:100%}.rangeslider--vertical{width:20px;min-height:150px;max-height:100%}.rangeslider--disabled{filter:alpha(Opacity=40);opacity:.4}.rangeslider__fill{background:#3b8dbd;position:absolute}.rangeslider--horizontal .rangeslider__fill{top:0;height:100%}.rangeslider--vertical .rangeslider__fill{bottom:0;width:100%}.rangeslider__handle{background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDAwMDAiIHN0b3Atb3BhY2l0eT0iMC4xIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g) #fff;border:1px solid #ccc;cursor:pointer;display:inline-block;width:40px;height:40px;position:absolute;background-size:100%;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,rgba(255,255,255,0)),color-stop(100%,rgba(0,0,0,.1)));background-image:-moz-linear-gradient(rgba(255,255,255,0),rgba(0,0,0,.1));background-image:-webkit-linear-gradient(rgba(255,255,255,0),rgba(0,0,0,.1));background-image:linear-gradient(rgba(255,255,255,0),rgba(0,0,0,.1));-moz-box-shadow:0 0 8px rgba(0,0,0,.3);-webkit-box-shadow:0 0 8px rgba(0,0,0,.3);box-shadow:0 0 8px rgba(0,0,0,.3);-moz-border-radius:50%;-webkit-border-radius:50%;border-radius:50%;line-height:42px;text-align:center;color:#000;font-size:13px;font-weight:700}.rangeslider__handle:after{content:"";display:block;width:18px;height:18px;margin:auto;position:absolute;top:0;right:0;bottom:0;left:0;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjEzIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIiBzdG9wLW9wYWNpdHk9IjAuMCIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==);background-size:100%;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,rgba(0,0,0,.13)),color-stop(100%,rgba(255,255,255,0)));background-image:-moz-linear-gradient(rgba(0,0,0,.13),rgba(255,255,255,0));background-image:-webkit-linear-gradient(rgba(0,0,0,.13),rgba(255,255,255,0));background-image:linear-gradient(rgba(0,0,0,.13),rgba(255,255,255,0));-moz-border-radius:50%;-webkit-border-radius:50%;border-radius:50%}.rangeslider--active .rangeslider__handle,.rangeslider__handle:active{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjEiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDAwMDAiIHN0b3Atb3BhY2l0eT0iMC4xMiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==);background-size:100%;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,rgba(0,0,0,.1)),color-stop(100%,rgba(0,0,0,.12)));background-image:-moz-linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.12));background-image:-webkit-linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.12));background-image:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.12))}.rangeslider--horizontal .rangeslider__handle{top:-10px;touch-action:pan-y;-ms-touch-action:pan-y}.rangeslider--vertical .rangeslider__handle{left:-10px;touch-action:pan-x;-ms-touch-action:pan-x}input[type=range]:focus+.rangeslider .rangeslider__handle{-moz-box-shadow:0 0 8px rgba(255,0,255,.9);-webkit-box-shadow:0 0 8px rgba(255,0,255,.9);box-shadow:0 0 8px rgba(255,0,255,.9)}.attachment-media-view button{color:#000;padding:5px 7px;line-height:1.5em}.czr-sektion-buttons{position:absolute;right:0}.czr-column{width:99%;margin-bottom:1%;float:left;padding:2% 0;border:2px dotted #aaa;text-align:center}.czr-column-header{position:relative}.czr-col-drag-handler{position:absolute;left:0;padding:1%;color:#999;cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab}.czr-module-collection-wrapper{width:100%;min-height:5px;float:left}.czr-single-module{width:98%;float:left;min-height:20px;margin:1px 1%;border:1px solid #ccc}.czr-single-module textarea{max-width:100%}#customize-theme-controls .czr-single-module .czr-single-item{width:96%}.czr-mod-header{background:#eee;float:left;width:100%}.czr-mod-title{position:relative}.czr-mod-title>h4{float:left;width:70%;margin:2% 0}.czr-mod-drag-handler{position:absolute;left:0;padding:1%;margin:2% 0;color:#999;cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab}.czr-mod-buttons{float:right;width:30%;margin:2% 0}.czr-mod-content{position:absolute;top:0;left:100%;float:left;width:100%;background:#d5e9cc;display:none}.czr-module-open #customize-info,.czr-module-open #customize-theme-controls{left:-200%}.czr-module-open #customize-theme-controls .accordion-section-content{overflow:visible}.czr-module-description-container{margin-bottom:15px}.czr-module-title{border-bottom:1px solid #ddd;background:#fff}.czr-module-title h3{padding:10px 10px 12px 14px;margin:0;color:#555;font-size:20px;font-weight:200;line-height:26px;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#customize-controls .czr-module-title span.customize-action{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:13px;display:block;font-weight:400}.czr-module-back{display:block;float:left;width:48px;height:74px;padding:0 24px 0 0;margin:0;background:#fff;border:none;border-right:1px solid #ddd;-webkit-box-shadow:none;box-shadow:none;cursor:pointer;-webkit-transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out;-moz-transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out;-ms-transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out;-o-transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out;transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out}.czr-module-back:focus,.czr-module-back:hover{color:#23282d;background:#f5f5f5;outline:0;-webkit-box-shadow:none;box-shadow:none}.czr-module-back:before{font:400 20px/72px dashicons;content:"\f341";position:relative;left:13px}.czr-module-back:hover{color:#23282d;background:#f5f5f5;outline:0;-webkit-box-shadow:none;box-shadow:none}.gu-mirror{position:fixed!important;margin:0!important;z-index:999999!important;opacity:.8;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80)}#czr-module-list-panel,#czr-sektion-settings-panel{left:-301px;overflow-x:hidden;overflow-y:auto;z-index:4;bottom:0}.gu-hide{display:none!important}.gu-unselectable{-webkit-user-select:none!important;-moz-user-select:none!important;-ms-user-select:none!important;user-select:none!important}.gu-transit{opacity:.2;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20)}.gu-unselectable .czr-module-collection-wrapper{width:98%;border:1px dotted green;background:#d1ffe0;min-height:31px}#czr-module-list-panel{position:absolute;top:0;opacity:0;margin:0;background:rgba(0,0,0,.47);-webkit-transition:all .18s;-moz-transition:all .18s;-ms-transition:all .18s;-o-transition:all .18s;transition:all .18s;border-right:1px solid #ddd}#czr-available-modules-filter,#czr-module-list-panel{width:45%;min-width:300px}body.czr-adding-module #czr-module-list-panel{left:0;visibility:visible;opacity:1}body.czr-adding-module #customize-preview{opacity:.7}.add-new-module:before{content:"\f132";display:inline-block;position:relative;left:-2px;top:-1px;font:400 20px/1 dashicons;vertical-align:middle;-webkit-transition:all .2s;-moz-transition:all .2s;-ms-transition:all .2s;-o-transition:all .2s;transition:all .2s;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.czr-column .add-new-module{margin:1%;float:right}body.czr-adding-module .add-new-module,body.czr-adding-module .add-new-module:hover{background:#eee;border-color:#929793;color:#32373c;-webkit-box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5)}body.czr-adding-module .add-new-module:before{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}#czr-available-modules-list{top:60px;position:absolute;overflow:auto;bottom:0;width:100%}#czr-available-modules-filter{position:fixed;top:0;z-index:1;background:rgba(0,0,0,.47);border-bottom:1px solid #e5e5e5;padding:12px 15px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#czr-available-modules-filter input{padding:6px 10px;width:100%}#czr-available-modules-list .czr-module-candidate{position:relative;border-bottom:1px solid #e5e5e5}#czr-available-modules-list .czr-module-candidate h3{color:#fff;padding:0;margin:0}#czr-available-modules-list .czr-mod-drag-handler{position:relative;left:0;padding:1%;margin:2% 4%;color:inherit;cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab}#czr-sektion-settings-panel{position:absolute;top:0;width:45%;min-width:300px;opacity:0;margin:0;background:rgba(0,0,0,.47);-webkit-transition:all .18s;-moz-transition:all .18s;-ms-transition:all .18s;-o-transition:all .18s;transition:all .18s;border-right:1px solid #ddd;color:#fff}#czr-sektion-settings-panel h3{color:#fff}body.czr-editing-sektion #czr-sektion-settings-panel{left:0;visibility:visible;opacity:1}body.czr-editing-sektion #customize-preview{opacity:.7}.czr-api-dirty input#save{background-color:#FFBD2E;border-color:#d99400;color:#000;text-shadow:none;-webkit-box-shadow:none;box-shadow:none;-webkit-transition:background-color .2s ease-in-out;-moz-transition:background-color .2s ease-in-out;-ms-transition:background-color .2s ease-in-out;-o-transition:background-color .2s ease-in-out;transition:background-color .2s ease-in-out}.czr-api-dirty input#save:hover{background-color:#fcad06}#customize-controls .customize-section-title.is-in-view,.czr-skop-on #customize-controls .customize-info.is-in-view{opacity:0}.czr-skop-on .wp-full-overlay-sidebar .wp-full-overlay-header{height:185px}.czr-skop-on .wp-full-overlay-sidebar .wp-full-overlay-sidebar-content{top:185px}.wp-customizer .in-sub-panel .wp-full-overlay-sidebar .wp-full-overlay-header{padding:0 15px}.customize-controls-close{border-bottom:1px solid #ddd}.wp-customizer #customize-header-actions{border-bottom:0}.czr-scope-switcher{width:100%;float:right;position:absolute;left:0;bottom:0;overflow:hidden}.czr-scope-switcher .czr-skp-permanent-title{position:relative;color:#5f5f5f}#customize-header-actions .czr-scope-switcher .spinner{float:none;display:none;margin:0;left:-26px;top:0;position:absolute;visibility:visible}h2.czr-current-skope-title{font-size:13px;line-height:21px;margin:6px 0 4px;text-align:center;height:63px;font-weight:400;overflow:hidden}.czr-main-title{max-height:24px;overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:nowrap;width:95%}.czr-skope-title{display:block;font-size:17px;font-style:italic;line-height:25px}.czr-toggle-title-notice{cursor:pointer;font-size:14px;color:#777}.czr-skope-inherits-from{display:inline-block;opacity:0;width:90%;font-size:12px;line-height:18px;color:#0029ff;top:-6px;position:relative}.notice-visible .czr-toggle-title-notice{color:#0029ff}.notice-visible .czr-skope-inherits-from{opacity:1;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out}.czr-scope,.czr-scope-switcher .button{-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;float:left}.czr-scope-switcher .button{width:40%;text-align:center;margin:0 2%;opacity:.7;transition:opacity .3s ease-in-out}.czr-scope-switcher .button.active{font-weight:700;opacity:1}.czr-scope-switcher .active,.czr-scope-switcher .czr-scope:hover{opacity:1}.czr-skopes-wrapper{overflow:hidden;position:relative}.czr-scope-switcher .active:after,.czr-scope.active:before{position:absolute;content:'';top:0}.czr-scope.active:before{height:101%;float:left;z-index:1;-webkit-box-shadow:-4px 0 15px 0 rgba(119,119,119,.58);box-shadow:-4px 0 15px 0 rgba(119,119,119,.58)}.czr-scope-switcher .active:after{height:100%;-webkit-box-shadow:4px 0 15px 0 rgba(119,119,119,.58);box-shadow:4px 0 15px 0 rgba(119,119,119,.58);z-index:3}.czr-skopes-wrapper .active-collection.local:after{right:0}.czr-scope-switcher .czr-scope:last-child:after{-webkit-box-shadow:none;box-shadow:none;right:0}.czr-scope-switcher .czr-scope:first-child:after{left:0}.czr-scope{width:30.5%;background:#fff;border-top:1px solid #ccc;overflow:hidden;opacity:.65;transition:opacity .3s ease-in-out}.czr-scope-switcher .width-100,.czr-scope.width-100.active:after,.czr-scope.width-100.active:before{width:100%}.czr-scope-switcher .width-50,.czr-scope.width-50.active:after,.czr-scope.width-50.active:before{width:50%}.czr-scope-switcher .width-33,.czr-scope.width-33.active:after,.czr-scope.width-33.active:before{width:33.33%}.czr-scope-switcher .width-25,.czr-scope.width-25.active:after,.czr-scope.width-25.active:before{width:25%}.czr-scope-footer,.czr-scope-header{width:100%;min-height:16px;position:relative;z-index:5}.inactive .czr-scope-footer:after{content:'';width:100%;position:absolute;height:5px;bottom:-7px;left:0;-webkit-box-shadow:0 0 13px 4px rgba(119,119,119,.85);box-shadow:0 0 13px 4px rgba(119,119,119,.85)}.czr-scope-content{height:35px;padding:0 3%;width:94%;line-height:35px;text-align:center;clear:both;color:#000;overflow:hidden}.czr-scope-content h4{margin:0;display:inline-block;text-align:center;font-size:14px;line-height:18px;font-weight:400;text-shadow:1px 1px 0 #dedede}.czr-reset-fail,.czr-reset-success,.czr-scope-force{display:none}.czr-scope .fa{font-size:10px;padding:2%;color:#585858;cursor:pointer;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out}.czr-scope .czr-scope-footer .info{cursor:inherit}.czr-scope-header .czr-scope-switch{font-size:22px;padding:0 2px 0 0;text-shadow:1px 1px 2px #fff}.czr-skp-switch-link{cursor:pointer}.czr-pull-left{float:left}.czr-pull-right{float:right}.active .czr-scope-switch{color:#59b15c;cursor:inherit}.czr-scope .czr-scope-reset{display:none;font-size:13px;text-shadow:1px 1px 0 #dedede}.has-db-val .czr-scope-reset{color:#00a0d2}.dirty .czr-scope-reset{color:#FFBD2E!important}.is_winner .czr-scope-winner{color:#59b15c;font-size:14px;position:absolute;bottom:2px;left:2px}.czr-skope-switch{cursor:pointer}.czr-spinner-wrapper{visibility:hidden}.czr-spinner{background:url(img/czr-spinner.gif) no-repeat;-webkit-background-size:32px 32px;background-size:32px 32px;display:inline-block;float:right;vertical-align:middle;opacity:.7;filter:alpha(opacity=70);width:32px;height:32px;margin:4px 10px 0}.customize-control span.customize-control-title:first-child{padding-left:16px;-webkit-transition:left,right,.15s ease-in-out;-moz-transition:left,right,.15s ease-in-out;-ms-transition:left,right,.15s ease-in-out;-o-transition:left,right,.15s ease-in-out;transition:left,right,.15s ease-in-out;position:relative}.wp-customizer .customize-control.czr-not-skoped .customize-control-title{padding-left:0}.czr-setting-reset{color:#eee;-webkit-transition:color .4s;transition:color .4s;position:absolute;left:0;line-height:21px;display:none;text-shadow:1px 1px 0 #a0a0a0}#czr-bottom-infos,#czr-top-note,.czr-resetting-control .czr-remove-alert-wrapper{-moz-transition:all,.3s ease-in-out;-ms-transition:all,.3s ease-in-out;-o-transition:all,.3s ease-in-out}.czr-global-skope-level .is-wp-authorized-setting.has-db-val .czr-setting-reset{color:#eee}.has-db-val .czr-setting-reset{color:#00a0d2}.is-dirty .czr-setting-reset{color:#FFBD2E!important}.czr-ctrl-reset-warning .czr-spinner{display:none}.czr-resetting-control .czr-ctrl-reset-warning .czr-spinner{display:block}.is-dirty .czr-remove-alert-wrapper{background-color:rgba(255,189,46,.54)!important;border:1px solid #FFBD2E!important;text-shadow:none;color:#000}.has-db-val .czr-remove-alert-wrapper{background-color:rgba(0,160,210,.45);border:1px solid #00a0d2;text-shadow:none;color:#000}.czr-resetting-control .czr-remove-alert-wrapper{-webkit-transition:all,.3s ease-in-out;transition:all,.3s ease-in-out}body.czr-skop-loading #czr-skope-pane{top:0}body.czr-skop-loading #customize-preview{filter:blur(3px);-webkit-filter:blur(3px)}@-webkit-keyframes czr-mr-loader{0%{-webkit-transform:scale(.1);transform:scale(.1);opacity:1}70%{-webkit-transform:scale(1);transform:scale(1);opacity:.7}100%{opacity:0}}@keyframes czr-mr-loader{0%{-webkit-transform:scale(.1);transform:scale(.1);opacity:1}70%{-webkit-transform:scale(1);transform:scale(1);opacity:.7}100%{opacity:0}}.czr-css-loader{width:50px;height:50px;position:absolute;-webkit-transform:translate3d(-50%,-50%,0);-ms-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0);top:50%;left:50%;display:block}.czr-mr-loader>div:nth-child(0){-webkit-animation-delay:-.8s;animation-delay:-.8s}.czr-mr-loader>div:nth-child(1){-webkit-animation-delay:-.6s;animation-delay:-.6s}.czr-mr-loader>div:nth-child(2){-webkit-animation-delay:-.4s;animation-delay:-.4s}.czr-mr-loader>div:nth-child(3){-webkit-animation-delay:-.2s;animation-delay:-.2s}.czr-mr-loader>div{position:absolute;top:-4%;left:-4%;width:100%;height:100%;border-radius:100%;border:2px solid #fff;-webkit-animation:czr-mr-loader 1.25s 0s infinite cubic-bezier(.21,.53,.56,.8);animation:czr-mr-loader 1.25s 0s infinite cubic-bezier(.21,.53,.56,.8)}#czr-bottom-infos,#czr-top-note{position:absolute;text-align:center;right:0;left:0;z-index:20;color:#fff;display:block;-webkit-transition:all .3s ease-in-out;transition:all .3s ease-in-out;visibility:hidden}.czr-preview-notification a,.czr-preview-notification h2{color:#fff;margin:1em 0}.czr-preview-notification .czr-preview-note-close{position:absolute;top:10px;right:25px;font-size:31px;cursor:pointer}.czr-preview-notification .fa-arrow-left{position:absolute;bottom:10px;left:25px;font-size:40px}.czr-preview-notification .czr-note-content{display:inline-block;line-height:20px;width:80%}.czr-preview-notification .czr-note-message{font-size:16px;line-height:1.5em;margin:.5em 0}#czr-top-note{top:-100%;background:rgba(0,0,0,.8);padding:2%}#czr-top-note h2{font-size:25px}body.czr-top-note-open #czr-top-note{top:0;visibility:inherit}#czr-bottom-infos{bottom:-100%;background-color:rgba(0,0,0,.85);padding:1px}body.czr-bottom-infos-open #czr-bottom-infos{bottom:0;visibility:inherit}#czr-bottom-infos .czr-note-content .czr-note-message{font-size:13px}#czr-bottom-infos .action-links-wrap{width:100%}#czr-bottom-infos .action-link{font-style:italic;display:inline-block;width:40%}#czr-bottom-infos .action-link a:hover{color:#fff}.czr-disable-bottom-infos{cursor:pointer}#czr-skope-pane{position:absolute;min-height:100%;text-align:center;padding:2%;top:-100%;right:0;left:0;z-index:20;color:#fff;display:block;-webkit-transition:all .3s ease-in-out;-moz-transition:all,.3s ease-in-out;-ms-transition:all,.3s ease-in-out;-o-transition:all,.3s ease-in-out;transition:all .3s ease-in-out;visibility:hidden}#czr-skope-pane.dirty-reset{background:rgba(252,173,6,.23)}#czr-skope-pane.db-reset{background:rgba(0,160,210,.3)}.czr-reset-content{display:inline-block;line-height:20px;width:80%;padding:5%;background:rgba(0,0,0,.63)}#czr-skope-pane h2{color:#fff;line-height:1.5em}body.czr-skope-pane-open #czr-skope-pane{top:0;visibility:inherit;min-height:100%}body.czr-skope-pane-open #customize-preview,body.czr-skope-pane-open .wp-full-overlay-sidebar{opacity:.5}body.czr-resetting-skope #czr-skope-pane .czr-spinner-wrapper{visibility:visible}.czr-skope-pane-open .wp-full-overlay.collapsed .wp-full-overlay-sidebar{z-index:30}.czr-skope-pane-open .wp-full-overlay.expanded .collapse-sidebar{bottom:0!important}.customize-control .czr-skope-notice{color:#3a3a3a;font-family:Verdana,'DejaVu Sans','Bitstream Vera Sans',Geneva,sans-serif;font-size:10px;line-height:1.5em;font-style:normal;border-left:3px solid rgba(99,99,99,.36);padding-left:5px}.czr-toggle-notice{color:#95a5a6;text-shadow:1px 1px 0 #fff;-webkit-transition:color .4s;transition:color .4s;position:absolute;padding-left:3px;line-height:21px;display:none}.czr-notice-visible .czr-toggle-notice,.czr-toggle-notice:hover{color:rgba(0,0,0,.67)}.wp-full-overlay-header,.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content{-webkit-transition:height,top,.4s ease-in-out;-moz-transition:height,top,.4s ease-in-out;-ms-transition:height,top,.4s ease-in-out;-o-transition:height,top,.4s ease-in-out;transition:height,top,.4s ease-in-out}.czr-server-notice{width:calc(96% - 2px);bottom:75px;text-align:center;background:rgba(0,156,0,.18);color:#000;display:none;position:absolute;font-size:12px;line-height:13px;padding:2%;overflow:hidden}.czr-server-notice.czr-server-error{color:#000;background:rgba(255,0,0,.24)}.czr-dismiss-notification{position:absolute;right:5px;top:5px;cursor:pointer}.wp-customizer .icheckbox_flat-grey,.wp-customizer .iradio_flat-grey{border:1px solid #fff;-webkit-border-radius:5px;border-radius:5px;background-color:#fff}.czr-painted{-webkit-transition:background .3s ease-in-out!important;-moz-transition:background .3s ease-in-out!important;-ms-transition:background .3s ease-in-out!important;-o-transition:background .3s ease-in-out!important;transition:background .3s ease-in-out!important}
1
+ .rtl.wp-customizer .wp-full-overlay-sidebar,.wp-customizer .wp-full-overlay-sidebar{width:440px}i.czr-notice,span.czr-notice{display:block;clear:both}.wp-customizer a{color:#000}.wp-customizer a:focus,.wp-customizer a:hover{color:#0073aa}.wp-customizer .wp-full-overlay.expanded{margin-left:440px}.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left:-440px}#customize-theme-controls .control-section.current-panel>h3.accordion-section-title{left:-440px}.accordion-sub-container.control-panel-content{left:440px}.rtl.wp-customizer .wp-full-overlay.expanded{margin-right:440px;margin-left:0}.rtl.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-right:-440px;margin-left:0}.rtl #customize-theme-controls .control-section.current-panel>h3.accordion-section-title{right:-440px}.rtl .accordion-sub-container.control-panel-content{right:440px}.customize-section-description-container+#customize-control-custom_css:last-child{margin:0;width:100%}li#customize-control-custom_css textarea{font-size:13px;background:#394143;color:#95ff0c;min-height:300px}@media screen and (max-width:1400px){.rtl.wp-customizer .wp-full-overlay-sidebar,.wp-customizer .wp-full-overlay-sidebar{width:380px}.wp-customizer .wp-full-overlay.expanded{margin-left:380px}.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left:-380px}#customize-theme-controls .control-section.current-panel>h3.accordion-section-title{left:-380px}.accordion-sub-container.control-panel-content{left:380px}.rtl.wp-customizer .wp-full-overlay.expanded{margin-right:380px;margin-left:0}.rtl.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-right:-380px;margin-left:0}.rtl #customize-theme-controls .control-section.current-panel>h3.accordion-section-title{right:-380px}.rtl .accordion-sub-container.control-panel-content{right:380px}}@media screen and (max-width:979px){.rtl.wp-customizer .wp-full-overlay-sidebar,.wp-customizer .wp-full-overlay-sidebar{width:300px}.wp-customizer .wp-full-overlay.expanded{margin-left:300px}.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left:-300px}#customize-theme-controls .control-section.current-panel>h3.accordion-section-title{left:-300px}.accordion-sub-container.control-panel-content{left:300px}.rtl.wp-customizer .wp-full-overlay.expanded{margin-right:300px;margin-left:0}.rtl.wp-customizer .wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-right:-300px;margin-left:0}.rtl #customize-theme-controls .control-section.current-panel>h3.accordion-section-title{right:-300px}.rtl .accordion-sub-container.control-panel-content{right:300px}}@media screen and (max-width:640px){.wp-customizer .customize-controls-preview-toggle{height:46px;border-bottom:1px solid #ddd;left:87px}.wp-customizer .wp-full-overlay.expanded{margin-left:0}#customize-theme-controls .control-section.current-panel>h3.accordion-section-title{left:-100%}.accordion-sub-container.control-panel-content{left:100%}.rtl.wp-customizer .wp-full-overlay.expanded{margin-right:0}.rtl #customize-theme-controls .control-section.current-panel>h3.accordion-section-title,.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-100%;left:auto}.rtl .accordion-sub-container.control-panel-content{right:100%}}.wp-customizer .control-section.control-panel .accordion-section-title .panel-title{font-size:24px;font-weight:inherit;line-height:30px}.wp-core-ui h3{color:#555}.accordion-section-title:after,.control-section.control-panel>.accordion-section-title:after,.handlediv,.item-edit,.sidebar-name-arrow,.widget-action,.wp-customizer #available-menu-items .menu-item-handle:hover .item-add,.wp-customizer #customize-controls .customize-info .customize-help-toggle:focus,.wp-customizer #customize-controls .customize-info .customize-help-toggle:hover,.wp-customizer #customize-controls .customize-info.open .customize-help-toggle,.wp-customizer .menu-item-handle:hover,.wp-customizer .menu-item-handle:hover .item-edit,.wp-customizer .menu-item-handle:hover .item-type{color:#00a0d2}.accordion-section-content{padding:10px 10px 15px 20px}.customize-control-title{line-height:19px}.wp-customizer #customize-theme-controls .accordion-section-content{background:#fff}.wp-customizer #customize-controls .customize-info .customize-help-toggle:focus:before,.wp-customizer .customize-screen-options-toggle:focus:before{-webkit-box-shadow:0 0 0 1px #00a0d2;box-shadow:0 0 0 1px #00a0d2;-webkit-border-radius:100%;border-radius:100%}#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:active,#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:focus,#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:hover,.active-menu-screen-options .customize-screen-options-toggle,.customize-screen-options-toggle:active,.customize-screen-options-toggle:focus,.customize-screen-options-toggle:hover{color:#00a0d2!important}.customize-control input[type=text]{line-height:23px}li[id*=customize-control-]{margin:8px 0;padding:2%;width:96%;border:1px solid rgba(221,221,221,.43);box-shadow:1px 0 2px 0 rgba(204,204,204,.45);-webkit-box-shadow:1px 0 2px 0 rgba(204,204,204,.45)}#customize-outer-theme-controls li[id*=customize-control-]{width:100%}#customize-outer-theme-controls input[type=checkbox],#customize-outer-theme-controls input[type=radio]{float:none;min-height:inherit}.control-section .accordion-section-content{overflow-y:auto}.wp-customizer .control-section h3.accordion-section-title{padding:10px 25px 11px 14px}.wp-customizer #customize-controls h3{font-size:15px;font-weight:400}.control-section .accordion-section-title:after{top:7px}.control-section.control-panel .accordion-section-title:after{top:11px;-webkit-transition:right .3s ease-in-out,opacity .3s ease-in-out;-moz-transition:right .3s ease-in-out,opacity .3s ease-in-out;-ms-transition:right .3s ease-in-out,opacity .3s ease-in-out;-o-transition:right .3s ease-in-out,opacity .3s ease-in-out;transition:right .3s ease-in-out,opacity .3s ease-in-out;right:10px;opacity:.7}.rtl .control-section.control-panel .accordion-section-title:after{-webkit-transition:left .3s ease-in-out,opacity .3s ease-in-out;-moz-transition:left .3s ease-in-out,opacity .3s ease-in-out;-ms-transition:left .3s ease-in-out,opacity .3s ease-in-out;-o-transition:left .3s ease-in-out,opacity .3s ease-in-out;transition:left .3s ease-in-out,opacity .3s ease-in-out;left:10px;right:initial}#customize-theme-controls .control-section.control-panel h3.accordion-section-title:focus:after,#customize-theme-controls .control-section.control-panel h3.accordion-section-title:hover:after{right:8px;opacity:1;color:#666!important}.rtl #customize-theme-controls .control-section.control-panel h3.accordion-section-title:focus:after,.rtl #customize-theme-controls .control-section.control-panel h3.accordion-section-title:hover:after{left:6px;right:initial}#customize-theme-controls .control-section.control-panel>h3.accordion-section-title:focus:after,#customize-theme-controls .control-section.control-panel>h3.accordion-section-title:hover:after,.control-section.control-panel>.accordion-section-title:after{background:0 0!important;border:none!important}#customize-theme-controls h3.accordion-section-title{-webkit-transition:background .1s ease-in-out;-moz-transition:background .1s ease-in-out;-ms-transition:background .1s ease-in-out;-o-transition:background .1s ease-in-out;transition:background .1s ease-in-out}.customize-control-checkbox label,.customize-control-nav_menu_auto_add label,.customize-control-radio label{line-height:16px;margin-left:0}input::-webkit-input-placeholder{color:#9A9A9A;font-style:italic}input:-moz-placeholder{color:#9A9A9A;font-style:italic}input::-moz-placeholder{color:#9A9A9A;font-style:italic}input:-ms-input-placeholder{color:#9A9A9A;font-style:italic}.czr-customizr-title{text-transform:uppercase;margin:1em 0 5px;font-size:15px!important;border-bottom:1px dotted #555;padding-bottom:5px;text-align:center}h3.czr-customizr-title::before{content:'\00b7';padding-right:3px}h3.czr-customizr-title::after{content:'\00b7';padding-left:3px}.czr-after-button{border-color:#fff;margin-top:15px}.czr-emphasize{line-height:1.2em;color:#2E2E2E}span.czr-notice{color:#313131;font-size:12px;font-style:italic;line-height:18px}.czr-customizer-separator-invisible{border:none;margin-top:15px}.czr-skin-gen-label{float:left}.czr-skin-gen-color-picker{float:right}.czr-number-label{float:left}.czr-number-input{float:right}.czr-check-label{float:left;max-width:85%}.rtl .czr-check-label{float:right}input[type=checkbox],input[type=radio]{float:right;min-height:18px}.czr-font-select{float:left}li#customize-control-tc_theme_options-tc_custom_css textarea{font-size:14px;background:#394143;color:#E2E728;min-height:300px}.customize-control .czr-navigate-to-post-list{color:#00a0d2;font-weight:700;float:left;clear:both;width:100%;margin-bottom:8px}.czr-sub-control{padding-left:13%;max-width:87%;position:relative}.czr-sub-control:before{content:'';height:116%;background:#00a0d2;width:2%;position:absolute;left:7%}.customize-control-tc_cropped_image .upload-button{float:right}.customize-control-tc_cropped_image .remove-button{float:left;margin-right:3px}.customize-control-tc_cropped_image .actions{margin-bottom:32px}.customize-control-tc_cropped_image .current{margin-bottom:8px}.customize-control-tc_cropped_image .remove-button,.customize-control-tc_cropped_image .upload-button{white-space:normal;width:48%;height:auto}.customize-control-tc_cropped_image .current .container{min-height:40px;overflow:hidden;border:1px solid #eee;-webkit-border-radius:2px;border-radius:2px}.customize-control-tc_cropped_image img{width:100%;-webkit-border-radius:2px;border-radius:2px}.customize-control-tc_cropped_image .inner{line-height:20px;top:10px}.rtl .customize-control-tc_cropped_image .upload-button{float:left}.rtl .customize-control-tc_cropped_image .remove-button{float:right;margin-left:3px}.czr-layout-img{height:26px;padding-top:2px;border:1px solid #FFF}.czr-layout-title{padding:0 0 18px 12px;display:inline-block;line-height:0;vertical-align:middle}.customize-control-czr_multi_input{width:96%;border:1px solid #ccc;padding:2%}.czr-multi-input-wrapper{width:95%;padding:0 0 0 5%}.czr-multi-input-wrapper [data-input-type=color] .czr-input{float:left;clear:both}#customize-theme-controls #accordion-panel-czr-footer-panel{border-bottom:1px solid #ddd}#customize-theme-controls #accordion-panel-hu-advanced-panel,#customize-theme-controls #accordion-panel-nav_menus,#customize-theme-controls .control-panel-widgets{margin-top:10px}#customize-theme-controls #accordion-panel-hu-advanced-panel,#customize-theme-controls #accordion-panel-hu-header-panel,#customize-theme-controls #accordion-panel-nav_menus,#customize-theme-controls .control-panel-widgets{border-top:1px solid #ddd}#customize-theme-controls #accordion-panel-hu-general-panel,#customize-theme-controls #accordion-panel-tc-global-panel,#customize-theme-controls #accordion-section-frontpage_sec,#customize-theme-controls #accordion-section-static_front_page,#customize-theme-controls #accordion-section-tc_font_customizer_settings,#customize-theme-controls #accordion-section-tc_fpu{margin-bottom:10px}#customize-header-actions .customize-controls-close{left:45px}.customize-controls-close,.customize-controls-home{top:-1px}.customize-controls-home{display:block;position:absolute;left:0;width:45px;height:41px;padding:0 2px 0 0;background:#eee;border:none;border-top:4px solid #eee;border-right:1px solid #ddd;border-bottom:1px solid #ddd;color:#444;text-align:left;cursor:pointer;text-decoration:none;-webkit-transition:color .15s ease-in-out,border-color .15s ease-in-out,background .15s ease-in-out;transition:color .1s ease-in-out,border-color .15s ease-in-out,background .15s ease-in-out;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.customize-controls-home:before{font-size:17px;line-height:45px;position:relative;top:-4px;left:15px}.customize-controls-home:hover{background:#fff;color:#0073aa;border-top-color:#0073aa;outline:0;-webkit-box-shadow:none;box-shadow:none}.rtl.wp-customizer #customize-header-actions .customize-controls-close{right:45px;left:auto}.rtl.wp-customizer .customize-controls-home{left:auto;right:0;border-right:0;border-left:1px solid #ddd}.control-panel-content .hu-menu-notice{margin-left:3%}span.czr-panel-subtitle{display:block;font-size:12px;font-style:italic}.pro-title-block{background:#f0ad4e;border:1px solid #eea236;padding:0 6px;font-size:.7em;display:inline-block;margin-right:3px;bottom:2px;position:relative;color:#fff;webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);border-radius:3px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}#customize-controls .control-section-czr-customize-section-pro .accordion-section-title:focus,#customize-controls .control-section-czr-customize-section-pro .accordion-section-title:hover{background-color:#fff}#customize-theme-controls .control-section-czr-customize-section-pro .accordion-section-title:after{content:none}#accordion-section-go_pro_sec .accordion-section-title{margin:0 0 15px}.control-section-czr-customize-section-pro .accordion-section-title .button{font-size:15px;line-height:24px;height:30px;padding:1px 20px;display:inline-block;color:#fff;background:#f0ad4e;border:1px solid #eea236;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;border-radius:3px;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;-ms-transition:all .2s ease-in-out;transition:all .2s ease-in-out;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin-top:-4px;font-weight:400;margin-left:8px}.control-section-czr-customize-section-pro .accordion-section-title .button:hover{color:#fff;background:#ed9c28;border-color:#d58512}.rtl .control-section-czr-customize-section-pro .accordion-section-title .button{margin-left:0;margin-right:8px}.czr-open-pre-add-new{display:block;float:left;margin:2% 2% 0;width:99%;padding:2%;background:#3b8dbd;opacity:1;color:#fff;font-size:16px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;-webkit-border-radius:3px;border-radius:3px;white-space:nowrap;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:opacity 1s ease-in-out;-moz-transition:opacity 1s ease-in-out;-ms-transition:opacity 1s ease-in-out;-o-transition:opacity 1s ease-in-out;transition:opacity 1s ease-in-out}.czr-open-pre-add-new.active{background:#646464;opacity:.5;border-radius:3px 3px 0 0}.czr-adding-new .czr-items-wrapper,.czr-items-wrapper .inactive{opacity:.6}.czr-single-item{padding:0;border:1px solid #ccc;margin:1% 0 0 2%;float:left;width:98%;-webkit-border-radius:3px;border-radius:3px;-webkit-transition:opacity 1s ease-in-out;-moz-transition:opacity 1s ease-in-out;-ms-transition:opacity 1s ease-in-out;-o-transition:opacity 1s ease-in-out;transition:opacity 1s ease-in-out}.czr-single-item .czr-item-content input,.czr-sub-set{margin-bottom:0}#customize-theme-controls .czr-single-item.open{border:1px solid #dedede}#customize-theme-controls .mono-item-mod .czr-single-item{border:1px solid #ccc}.czr-single-item .czr-item-content,.czr-single-item .czr-item-header{padding:1%}.czr-items-wrapper .czr-single-item .czr-builtin-model{background:#E1DFDF;color:#555}.czr-item-sort-handle{cursor:move}.czr-single-item .czr-item-header{position:relative;background:#dfdfdf;color:#fff;float:left;width:98%;-webkit-transition:background .1s ease-in-out;-moz-transition:background .1s ease-in-out;-ms-transition:background .1s ease-in-out;-o-transition:background .1s ease-in-out;transition:background .1s ease-in-out}.czr_widget_areas_module .czr-single-item .czr-custom-model{background:#3b8dbd}. .czr-single-item .czr-custom-model:hover{background:#aaa}.czr-items-wrapper .czr-single-item .czr-builtin-model:hover,.czr-single-item .czr-item-header:hover{background:#ccc}.czr-move-icon{position:absolute;top:-2px;left:3px;font-size:10px;color:#999}.czr-item-title{float:left;font-size:17px;color:#000;padding:7px;width:67%}.czr-inactive-alert{font-size:12px;font-style:italic}.czr_widget_areas_module .czr-item-title{color:#fff}.czr-builtin-model .czr-item-title{color:#23282d}.czr-item-title h4{margin:0}.czr-item-title .fa:before{padding-right:2px}.czr-item-btns{float:right}.czr-item-btns a{font-size:17px;padding:7px 5px;color:#777;-webkit-transition:color .1s ease-in-out;-moz-transition:color .1s ease-in-out;-ms-transition:color .1s ease-in-out;-o-transition:color .1s ease-in-out;transition:color .1s ease-in-out}.czr-item-btns a:active,.czr-item-btns a:focus{outline:0;-webkit-box-shadow:none;box-shadow:none}.czr_widget_areas_module .czr-item-btns a{color:#fff}.czr-builtin-model .czr-item-btns a{color:#555}.czr-builtin-model .czr-item-btns .czr-edit-view.active,.czr-builtin-model .czr-item-btns .czr-edit-view:hover,.czr-item-btns .czr-edit-view.active,.czr-item-btns .czr-edit-view:hover{color:#00a0d2}.czr_widget_areas_module .czr-edit-view:hover,.czr_widget_areas_module .czr-item-btns .czr-edit-view.active{color:#000}.czr_widget_areas_module .czr-builtin-model .czr-edit-view.active,.czr_widget_areas_module .czr-builtin-model .czr-edit-view:hover{color:#00a0d2}.czr-item-btns .czr-display-alert.active,.czr-item-btns .czr-display-alert:hover{color:#23282d}.czr-single-item .czr-item-content{display:none;background:rgba(238,238,238,.5);clear:both;width:96%;padding:2%}.czr-sub-set{display:block;float:left;width:100%;padding:1% 0;position:relative}.czr-sub-set .czr-input{float:right;width:60%}.czr-sub-set .customize-control-title.width-100,.width-100 .czr-input{width:100%}.czr-sub-set .customize-control-title{float:left;width:40%;padding:1px 0;font-size:13px}.rtl.wp-customizer .czr-sub-set .customize-control-title{float:right}.disabled .customize-control-title,.disabled .czr-input{opacity:.6;filter:blur(1px);-webkit-filter:blur(1px)}.czr-item-title .fa{font-size:18px}.czr-remove-alert-wrapper{display:none;clear:both;float:left;padding:2%;width:95%;margin:10px 0;text-shadow:0 1px 0 rgba(255,255,255,.5);background-color:#EEE;color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.czr-remove-alert-wrapper p{padding:5px;margin:0}.czr-pre-add-wrapper{position:relative;float:left;width:100%}.czr-pre-add-view-content{display:none;padding:3%;border:1px solid #00a0d2;border-top:none;margin:0 0 0 2%;float:left;width:92%;background:#eee;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;position:relative;opacity:1;-webkit-transition:opacity .2s linear;-moz-transition:opacity .2s linear;-ms-transition:opacity .2s linear;-o-transition:opacity .2s linear;transition:opacity .2s linear}.czr-model-added .czr-pre-add-view-content{opacity:.2}.czr-pre-add-wrapper .czr-add-new{background:#3b8dbd;color:#fff;-webkit-transition:background .5s linear;-moz-transition:background .5s linear;-ms-transition:background .5s linear;-o-transition:background .5s linear;transition:background .5s linear;float:right;border:none}.czr-add-success{width:100%;margin:0 0 0 2%;position:absolute;top:0;left:0;font-size:25px;text-align:center;opacity:0;-webkit-transition:opacity .1s linear;-moz-transition:opacity .1s linear;-ms-transition:opacity .1s linear;-o-transition:opacity .1s linear;transition:opacity .1s linear}.czr-model-added .czr-add-success{opacity:1}.czr-unavailable-location,body.czr-editing-modopt #customize-preview{opacity:.7}.czr-add-success p{vertical-align:middle;display:inline-block;line-height:35px;margin:0;font-size:25px;color:#82b965;padding:0 3%}.control-section-widget_zones_management{margin:10px 0;z-index:1}.czr-zone-infos{width:96%;padding:0 2%;font-size:12px;float:left;font-style:italic}.czr-location-alert{float:left;width:100%;padding:1% 0;margin:1% 0;text-align:center;border:1px solid orange;background:#FEE5B6;color:#000;font-size:11px;font-style:italic}.czr-toggle-modopt{color:#495050;text-shadow:1px 1px 0 #fff;-webkit-transition:color .4s;transition:color .4s;position:absolute;right:0;padding-left:3px;font-size:25px;line-height:24px}.rtl.wp-customizer .czr-toggle-modopt{left:0;right:auto;padding-left:0;padding-right:3px}.czr-modopt-visible .czr-toggle-modopt,.czr-toggle-modopt:hover{color:#3b8dbd}body #customize-controls{-webkit-transition:opacity .4s ease-in-out;-moz-transition:opacity .4s ease-in-out;-ms-transition:opacity .4s ease-in-out;-o-transition:opacity .4s ease-in-out;transition:opacity .4s ease-in-out}body.czr-editing-modopt #customize-controls{opacity:.4}.czr-mod-opt-wrapper{position:absolute;top:0;bottom:0;left:-301px;opacity:0;overflow-x:hidden;overflow-y:auto;margin:0;z-index:4;width:60%;min-width:300px;padding:1% 2%;color:#fff;background:rgba(0,0,0,.8);-webkit-transition:all .18s ease-in-out;-moz-transition:all .18s ease-in-out;-ms-transition:all .18s ease-in-out;-o-transition:all .18s ease-in-out;transition:all .18s ease-in-out;border-right:1px solid #4c4c4c}body.czr-editing-modopt .czr-mod-opt-wrapper{left:0;visibility:visible;opacity:1}.czr-close-modopt{position:absolute;top:10px;right:25px;font-size:31px;cursor:pointer}.czr-mod-opt-wrapper .czr-sub-set{background:rgba(238,238,238,.13);padding:3% 2%;width:96%;margin:5px 0}.tabs,.tabs nav ul{position:relative;margin:0 auto;overflow:hidden}.czr-mod-opt-wrapper .czr-notice{color:#fff}.czr-mod-opt-wrapper .mod-opt-title{color:#fff;border-bottom:1px solid #fff;padding:5% 0;text-align:center}.tabs{display:none;width:100%;font-weight:300;font-size:1.25em}.tabs nav{text-align:center}.tabs nav ul{display:-ms-flexbox;display:-webkit-flex;display:-moz-flex;display:-ms-flex;display:flex;padding:0;max-width:1200px;list-style:none;-ms-box-orient:horizontal;-ms-box-pack:center;-webkit-flex-flow:row wrap;-moz-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;-webkit-justify-content:center;-moz-justify-content:center;-ms-justify-content:center;justify-content:center}.tabs nav a,.tabs nav ul li{position:relative;display:block}.tabs nav ul li{z-index:1;margin:0;text-align:center;-webkit-flex:1;-moz-flex:1;-ms-flex:1;flex:1}.tabs nav ul li.cols-4{width:25%}.tabs nav ul li.cols-3{width:33%}.tabs nav ul li.cols-2{width:50%}.tabs nav ul li.cols-1{width:100%}.tabs nav a{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:2.5}li.tab-current::after,li.tab-current::before,li.tab-inactive::after{content:'';position:absolute;width:100%}.tabs nav a span{vertical-align:middle;font-size:.75em}.tabs nav li.tab-current a{color:#74777b}.tabs nav a:focus{outline:0}li.tab-current::after,li.tab-current::before{height:100%;-webkit-box-shadow:4px 0 15px 0 rgba(37,37,37,.63);box-shadow:4px 0 15px 0 rgba(37,37,37,.63);top:0;right:0;z-index:4}li.tab-current::before{left:0;-webkit-box-shadow:0 0 15px 4px rgba(37,37,37,.63);box-shadow:0 0 15px 4px rgba(37,37,37,.63)}li.tab-inactive::after{height:2px;bottom:-7px;left:0;-webkit-box-shadow:4px 0 15px 0 rgba(119,119,119,.58);box-shadow:4px 0 15px 0 rgba(0,0,0,.86)}.content-wrap{position:relative}.content-wrap section{display:none;margin:0 auto;max-width:1200px}section .czr-sub-set:first-child{margin:0}.content-wrap section.content-current,.no-flexbox nav ul{display:block}.no-flexbox nav ul li{min-width:15%;display:inline-block}.tabs-style-topline{max-width:1200px}.tabs-style-topline nav li{border:1px solid rgba(40,44,42,.1)}.czr-items-wrapper .tabs-style-topline nav li{border:none}.tabs-style-topline nav li:not(:last-child){border-right:none}.tabs-style-topline nav li.tab-current{border-top-color:#fff;border-bottom:none;background:rgba(238,238,238,.13)}.tabs-style-topline nav a{padding:.65em .5em;background:rgba(40,44,42,.05);color:#fff;line-height:1;-webkit-transition:color .2s;transition:color .2s;text-decoration:none}.czr-disable-bottom-infos,.czr-skope-switch,.czr-skp-switch-link:hover,.tabs-style-topline nav a:focus,.tabs-style-topline nav a:hover,.tabs-style-topline nav li.tab-current a{text-decoration:underline}.czr-items-wrapper .tabs-style-topline nav a{background:rgba(40,44,42,.45)}.tabs-style-topline nav li.tab-current a{background:0 0;box-shadow:inset 0 3px 0 #fff;color:#fff}.czr-items-wrapper .tabs-style-topline nav li.tab-current a{color:#000}.tabs-style-topline .icon::before{display:block;margin:0}.tabs-style-topline nav a span{text-transform:uppercase;letter-spacing:1px;font-weight:700}@media screen and (max-width:58em){.tabs nav a.icon span{display:none}.tabs nav a:before{margin-right:0}}.czr_slide_module .czr-item-title{padding:0 7px;height:32px}.czr_slide_module .slide-thumb,.czr_slide_module .slide-title{display:block;height:32px;line-height:32px;float:left}.czr_slide_module .slide-title{padding-left:5px}.slide-mod-skope-notice{padding:3%;background:rgba(116,210,116,.42);float:left;font-size:12px;line-height:1.5em}.slide-mod-skope-notice .czr-skope-switch{cursor:pointer;text-decoration:underline}.modopts-top-buttons{width:100%;float:left;margin-bottom:4%;text-align:center}.item-bottom-buttons{width:100%;float:left;padding:1% 0}.item-bottom-btn,.modopt-top-btn{color:#fff;font-size:14px;cursor:pointer;border-width:1px;-webkit-appearance:none;-webkit-border-radius:3px;border-radius:4px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-ms-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;opacity:1}.item-bottom-btn{background:#868686;width:47%;margin-right:2%;padding:1% 0}.modopt-top-btn{background:rgba(171,171,171,.5);width:170px;padding:2px 0}.item-bottom-btn:hover{background:#5d5d5d}.modopt-top-btn:hover{background:rgba(41,41,41,.53)}.item-bottom-btn[disabled],.item-bottom-btn[disabled]:hover,.modopt-top-btn[disabled],.modopt-top-btn[disabled]:hover{opacity:.4;cursor:default;-webkit-box-shadow:none!important;box-shadow:none!important;background:inherit}.czr-notice{font-size:12px;font-weight:400}.in-sub-panel #czr-donate-customizer,.in-sub-panel .czr-cta-wrap{left:-450px;height:0}.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-450px}@media screen and (max-width:1400px){.in-sub-panel #czr-donate-customizer,.in-sub-panel .czr-cta-wrap{left:-380px}.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-380px}}@media screen and (max-width:979px){.in-sub-panel #czr-donate-customizer,.in-sub-panel .czr-cta-wrap{left:-300px}.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-300px}}@media screen and (max-width:640px){.in-sub-panel #czr-donate-customizer,.in-sub-panel .czr-cta-wrap{left:-100%}.rtl .in-sub-panel #czr-donate-customizer,.rtl .in-sub-panel .czr-cta-wrap{right:-100%;left:auto}}@media screen and (min-width:980px){.wp-customizer .expanded #customize-footer-actions{width:380px}}@media screen and (min-width:1401px){.wp-customizer .expanded #customize-footer-actions{width:440px}}.selecter-element{position:absolute;opacity:0}.selecter{display:block;float:right;margin:2px 0;position:relative;width:100%;z-index:100}.selecter .selecter-selected{background:url(img/jquery.fs.selecter-arrow.png) right center no-repeat #F9F9F9;border:1px solid #ccc;border-radius:3px;color:#333;cursor:pointer;display:block;font-size:13px;margin:0;overflow:hidden;padding:4px 4.6%;position:relative;text-overflow:clip;z-index:49;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);height:auto;line-height:18px;width:90%}.selecter .selecter-options{border:1px solid #ccc;border-width:0 1px 1px;background-color:#fefefe;border-radius:0 0 3px 3px;box-shadow:0 1px 4px rgba(0,0,0,.15);display:none;left:0;margin:0;max-height:260px;overflow:auto;overflow-x:hidden;padding:0;position:relative;top:100%;width:99%;z-index:50}.selecter .selecter-group{background:#F9F9F9;border-bottom:1px solid #e3e3e3;color:#999;display:block;font-size:11px;padding:5px 10px 4px;text-transform:uppercase}.selecter .selecter-item{background:#fff;border-bottom:1px solid #e3e3e3;color:#333;cursor:pointer;display:block;font-size:13px;margin:0;overflow:hidden;text-overflow:ellipsis;width:86%;height:auto;line-height:14px;padding:8px 24px 8px 10px}.selecter.disabled .selecter-group,.selecter.disabled .selecter-item,.selecter.disabled .selecter-selected{cursor:default;color:#ccc;border-color:#eee}.selecter .selecter-item.selected{background:#F9F9F9}.selecter .selecter-item.disabled{color:#999;cursor:default}.selecter .selecter-item:first-child{border-radius:0}.selecter .selecter-item:last-child{border-radius:0 0 2px 2px;border-bottom:0}.rtl .selecter .selecter-selected{background:url(img/jquery.fs.selecter-arrow.png) 4% center no-repeat #F9F9F9}@media screen and (min-width:980px){.selecter .selecter-item.selected:hover,.selecter .selecter-item:hover{background-color:#f3f3f3}.selecter .selecter-item.disabled:hover,.selecter:hover .selecter-selected{background-color:#fff}.selecter.disabled .selecter-item:hover{background:#fff}}.selecter.open{z-index:101}.selecter.open .selecter-selected{border-radius:3px 3px 0 0;z-index:51}.selecter.focus .selecter-selected,.selecter.open .selecter-selected{background-color:#fff;box-shadow:0 0 5px rgba(0,0,0,.1)}.selecter.cover .selecter-options{border-radius:3px;border-width:1px;top:0}.selecter.cover .selecter-options .selecter-item.first{border-radius:3px 3px 0 0}.selecter.cover.open .selecter-selected{border-radius:3px 3px 0 0;z-index:49}.selecter.bottom .selecter-options{border-width:1px 1px 0;bottom:100%;top:auto}.selecter.bottom .selecter-item:last-child{border:none}.selecter.bottom.open .selecter-selected{border-radius:0 0 3px 3px}.selecter.bottom.open .selecter-options{border-radius:3px 3px 0 0}.selecter.bottom.cover.open .selecter-options,.selecter.bottom.cover.open .selecter-selected,.stepper{border-radius:3px}.selecter.bottom.cover .selecter-options{bottom:0;top:auto}.selecter.multiple .selecter-options{border-radius:3px;border-width:1px;box-shadow:none;display:block;position:static;width:100%}.selecter.disabled .selecter-selected{background:#fff}.selecter.disabled .selecter-options{background:#fff;border-color:#eee}.selecter.disabled .selecter-item.selected{background:#fafafa}.selecter .selecter-options.scroller{overflow:hidden}.selecter .selecter-options.scroller .scroller-content{max-height:260px;padding:0}@media screen and (max-width:740px){.selecter{max-width:100%}}@media screen and (max-width:500px){.selecter{max-width:100%}}.stepper{margin:0 0 10px;overflow:hidden;position:relative;width:35%;float:left;clear:both}.stepper .stepper-input{background:#F9F9F9;border:1px solid #ccc;border-radius:3px;color:#333;font-size:13px;line-height:1.2;margin:0;overflow:hidden;padding:5px 10px!important;width:100%!important;z-index:49;-moz-appearance:textfield;max-width:none!important}.stepper .stepper-input::-webkit-inner-spin-button,.stepper .stepper-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.stepper .stepper-input:focus{background-color:#fff}.stepper .stepper-arrow{background:url(img/jquery.fs.stepper-arrows.png) no-repeat #eee;border:1px solid #ccc;cursor:pointer;display:block;height:46%;position:absolute;right:0;text-indent:-99999px;width:20px;z-index:50}.stepper .stepper-arrow.up{background-position:center top;border-bottom:none;top:0}.stepper .stepper-arrow.down{background-position:center bottom;bottom:0}.rtl .stepper .stepper-input{text-align:left}@media screen and (min-width:740px){.stepper:hover .stepper-input{background-color:#fff}.stepper .stepper-step:hover{background-color:#F9F9F9}.stepper.disabled .stepper-arrow{background:#fff;border-color:#eee;cursor:default}}.stepper.disabled .stepper-input{background:#fff;border-color:#eee;color:#ccc}.stepper.disabled .stepper-arrow{background:#fff;border-color:#eee;cursor:default}.icheckbox_flat-green,.icheckbox_flat-grey,.iradio_flat-green,.iradio_flat-grey{display:inline-block;margin:0;padding:0;width:20px;height:20px;border:none;top:4px;vertical-align:middle}.icheckbox_flat-green,.iradio_flat-green{background:url(img/green.png) no-repeat;cursor:pointer;float:right}.rtl [class*=icheckbox_flat-]{float:left}.icheckbox_flat-green{background-position:0 0}.icheckbox_flat-green.checked{background-position:-22px 0}.icheckbox_flat-green.disabled{background-position:-44px 0;cursor:default}.icheckbox_flat-green.checked.disabled{background-position:-66px 0}.iradio_flat-green{background-position:-88px 0}.iradio_flat-green.checked{background-position:-110px 0}.iradio_flat-green.disabled{background-position:-132px 0;cursor:default}.iradio_flat-green.checked.disabled{background-position:-154px 0}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (-moz-min-device-pixel-ratio:1.5),only screen and (-o-min-device-pixel-ratio:3/2),only screen and (min-device-pixel-ratio:1.5){.icheckbox_flat-green,.iradio_flat-green{background-image:url(img/green@2x.png);-webkit-background-size:176px 22px;background-size:176px 22px}}.icheckbox_flat-grey,.iradio_flat-grey{background:url(img/grey.png) no-repeat;cursor:pointer;float:right}.icheckbox_flat-grey{background-position:0 0}.icheckbox_flat-grey.checked{background-position:-22px 0}.icheckbox_flat-grey.disabled{background-position:-44px 0;cursor:default}.icheckbox_flat-grey.checked.disabled{background-position:-66px 0}.iradio_flat-grey{background-position:-88px 0}.iradio_flat-grey.checked{background-position:-110px 0}.iradio_flat-grey.disabled{background-position:-132px 0;cursor:default}.iradio_flat-grey.checked.disabled{background-position:-154px 0}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (-moz-min-device-pixel-ratio:1.5),only screen and (-o-min-device-pixel-ratio:3/2),only screen and (min-device-pixel-ratio:1.5){.icheckbox_flat-grey,.iradio_flat-grey{background-image:url(img/grey@2x.png);-webkit-background-size:176px 22px;background-size:176px 22px}}.czr-sub-set .icheckbox_flat-green,.iradio_flat-green{float:left}body .select2-container{z-index:1000000;width:100%!important}.customize-control-czr_layouts .select2-selection--single{height:33px}.customize-control-czr_layouts .select2-container--default .select2-selection--single .select2-selection__arrow{height:30px}.customize-control-czr_layouts .select2-selection--single:focus,.select2-selection__rendered:focus{outline:0}body .select2-drop{z-index:1000000}body .select2-container,span.select2-results{font-size:14px}.select2-container--default .select2-selection--multiple{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;width:99%;min-height:36px;border:1px solid #ddd;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.07);box-shadow:inset 0 1px 2px rgba(0,0,0,.07)}.select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#00a0d2!important;-webkit-box-shadow:0 0 2px rgba(26,188,156,.8)!important;box-shadow:0 0 2px rgba(26,188,156,.8)!important}.select2-results__options li{margin-bottom:0}.select2-container--default .select2-selection--multiple .select2-selection__choice{padding:2px;font-size:13px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;margin-bottom:0}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#00a0d2}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{font-size:17px;position:relative;top:2px;color:#23282d}.customize-control-czr_socials .select2-container--default .select2-selection--single .select2-selection__rendered{padding:5px;line-height:16px}#czr-customize-content_editor-pane{border-top:solid 1px #ddd;position:absolute;height:300px;bottom:-301px;right:0;left:0;z-index:20;background:#f1f1f1;display:block;-webkit-transition:all .2s;transition:all .2s;visibility:hidden}body.czr-customize-content_editor-pane-resize #customize-preview,body.czr-customize-content_editor-pane-resize #czr-customize-content_editor-pane{-webkit-transition:none;transition:none}body.mce-fullscreen.czr-customize-content_editor-pane-open #czr-customize-content_editor-pane{top:0}body.czr-customize-content_editor-pane-open #czr-customize-content_editor-pane{bottom:0;visibility:inherit}#czr-customize-content_editor-pane .wp-editor-tools{padding-top:5px;padding-right:10px}#czr-customize-content_editor-pane .wp-media-buttons{padding-left:5px}#customize-preview{height:auto}body.czr-customize-content_editor-pane-open #customize-preview{bottom:300px}body.mce-fullscreen #customize-preview{bottom:0}body.mce-fullscreen.czr-customize-content_editor-pane-open div.mce-fullscreen{position:relative;left:0}#wp-czr-customize-content_editor-container{border-left:0}#czr-customize-content_editor-dragbar{top:0;cursor:row-resize;display:block;height:4px;position:absolute;width:100%;z-index:21}body.czr-customize-content_editor-pane-resize #customize-preview:before{top:0;right:0;bottom:0;left:0;position:absolute;height:100%;width:100%;z-index:999999}.wp-customizer .ui-autocomplete.wplink-autocomplete{z-index:500110}.wp-customizer #wp-link-wrap{z-index:500105}.wp-customizer #wp_editbtns,.wp-customizer #wp_gallerybtns{z-index:500020}.wp-customizer #TB_overlay,.wp-customizer #TB_window{z-index:500050}.wp-customizer .mce-panel,.wp-customizer .mce-tooltip{z-index:500100!important}.czr-customize-content_editor-pane-open .wp-full-overlay.collapsed .wp-full-overlay-sidebar{z-index:30}.czr-customize-content_editor-pane-open .wp-full-overlay.collapsed .collapse-sidebar{bottom:308px}.czr-customize-content_editor-pane-open .wp-full-overlay.expanded .collapse-sidebar{bottom:0!important}.czr-customize-content_editor-pane-resize .wp-full-overlay.collapsed .collapse-sidebar{-webkit-transition:none;transition:none}.czr-customize-content_editor-pane-open.mce-fullscreen .wp-full-overlay.collapsed .collapse-sidebar{bottom:8px!important}.czr-sub-set[data-input-type=content_picker] .customize-control-title,.czr-sub-set[data-input-type=content_picker] .czr-input{width:100%}.content-picker-item{height:2em}.content-picker-item .czr-picker-item-type{float:right;display:inline-block}.content-item-bar{line-height:1.2em;font-size:.9em}.content-item-bar .czr-picker-item-title{display:block;float:left;max-width:80%;text-overflow:ellipsis;overflow:hidden;font-size:13px;line-height:1.3em}.czr-sub-set[data-input-type=content_picker] span.czr-picker-item-title{display:block;float:left;max-width:80%;text-overflow:ellipsis;overflow:hidden;font-size:14px;line-height:2em;color:#000}.czr-sub-set[data-input-type=content_picker] span.czr-picker-item-type{display:inline-block;padding:0 10px 0 0;float:right;line-height:2em}.rangeslider,.rangeslider__fill{display:block;-moz-box-shadow:inset 0 1px 3px rgba(0,0,0,.3);-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,.3);box-shadow:inset 0 1px 3px rgba(0,0,0,.3);-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}.rangeslider{background:#e6e6e6;position:relative}.rangeslider--horizontal{height:20px;width:100%}.rangeslider--vertical{width:20px;min-height:150px;max-height:100%}.rangeslider--disabled{filter:alpha(Opacity=40);opacity:.4}.rangeslider__fill{background:#3b8dbd;position:absolute}.rangeslider--horizontal .rangeslider__fill{top:0;height:100%}.rangeslider--vertical .rangeslider__fill{bottom:0;width:100%}.rangeslider__handle{background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDAwMDAiIHN0b3Atb3BhY2l0eT0iMC4xIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g) #fff;border:1px solid #ccc;cursor:pointer;display:inline-block;width:40px;height:40px;position:absolute;background-size:100%;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,rgba(255,255,255,0)),color-stop(100%,rgba(0,0,0,.1)));background-image:-moz-linear-gradient(rgba(255,255,255,0),rgba(0,0,0,.1));background-image:-webkit-linear-gradient(rgba(255,255,255,0),rgba(0,0,0,.1));background-image:linear-gradient(rgba(255,255,255,0),rgba(0,0,0,.1));-moz-box-shadow:0 0 8px rgba(0,0,0,.3);-webkit-box-shadow:0 0 8px rgba(0,0,0,.3);box-shadow:0 0 8px rgba(0,0,0,.3);-moz-border-radius:50%;-webkit-border-radius:50%;border-radius:50%;line-height:42px;text-align:center;color:#000;font-size:13px;font-weight:700}.rangeslider__handle:after{content:"";display:block;width:18px;height:18px;margin:auto;position:absolute;top:0;right:0;bottom:0;left:0;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjEzIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIiBzdG9wLW9wYWNpdHk9IjAuMCIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==);background-size:100%;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,rgba(0,0,0,.13)),color-stop(100%,rgba(255,255,255,0)));background-image:-moz-linear-gradient(rgba(0,0,0,.13),rgba(255,255,255,0));background-image:-webkit-linear-gradient(rgba(0,0,0,.13),rgba(255,255,255,0));background-image:linear-gradient(rgba(0,0,0,.13),rgba(255,255,255,0));-moz-border-radius:50%;-webkit-border-radius:50%;border-radius:50%}.rangeslider--active .rangeslider__handle,.rangeslider__handle:active{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjEiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDAwMDAiIHN0b3Atb3BhY2l0eT0iMC4xMiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==);background-size:100%;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,rgba(0,0,0,.1)),color-stop(100%,rgba(0,0,0,.12)));background-image:-moz-linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.12));background-image:-webkit-linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.12));background-image:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.12))}.rangeslider--horizontal .rangeslider__handle{top:-10px;touch-action:pan-y;-ms-touch-action:pan-y}.rangeslider--vertical .rangeslider__handle{left:-10px;touch-action:pan-x;-ms-touch-action:pan-x}input[type=range]:focus+.rangeslider .rangeslider__handle{-moz-box-shadow:0 0 8px rgba(255,0,255,.9);-webkit-box-shadow:0 0 8px rgba(255,0,255,.9);box-shadow:0 0 8px rgba(255,0,255,.9)}.attachment-media-view button{color:#000;padding:5px 7px;line-height:1.5em}.czr-sektion-buttons{position:absolute;right:0}.czr-column{width:99%;margin-bottom:1%;float:left;padding:2% 0;border:2px dotted #aaa;text-align:center}.czr-column-header{position:relative}.czr-col-drag-handler{position:absolute;left:0;padding:1%;color:#999;cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab}.czr-module-collection-wrapper{width:100%;min-height:5px;float:left}.czr-single-module{width:98%;float:left;min-height:20px;margin:1px 1%;border:1px solid #ccc}.czr-single-module textarea{max-width:100%}#customize-theme-controls .czr-single-module .czr-single-item{width:96%}.czr-mod-header{background:#eee;float:left;width:100%}.czr-mod-title{position:relative}.czr-mod-title>h4{float:left;width:70%;margin:2% 0}.czr-mod-drag-handler{position:absolute;left:0;padding:1%;margin:2% 0;color:#999;cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab}.czr-mod-buttons{float:right;width:30%;margin:2% 0}.czr-mod-content{position:absolute;top:0;left:100%;float:left;width:100%;background:#d5e9cc;display:none}.czr-module-open #customize-info,.czr-module-open #customize-theme-controls{left:-200%}.czr-module-open #customize-theme-controls .accordion-section-content{overflow:visible}.czr-module-description-container{margin-bottom:15px}.czr-module-title{border-bottom:1px solid #ddd;background:#fff}.czr-module-title h3{padding:10px 10px 12px 14px;margin:0;color:#555;font-size:20px;font-weight:200;line-height:26px;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#customize-controls .czr-module-title span.customize-action{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:13px;display:block;font-weight:400}.czr-module-back{display:block;float:left;width:48px;height:74px;padding:0 24px 0 0;margin:0;background:#fff;border:none;border-right:1px solid #ddd;-webkit-box-shadow:none;box-shadow:none;cursor:pointer;-webkit-transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out;-moz-transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out;-ms-transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out;-o-transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out;transition:left .18s ease-in-out,color .1s ease-in-out,background .1s ease-in-out}.czr-module-back:focus,.czr-module-back:hover{color:#23282d;background:#f5f5f5;outline:0;-webkit-box-shadow:none;box-shadow:none}.czr-module-back:before{font:400 20px/72px dashicons;content:"\f341";position:relative;left:13px}.czr-module-back:hover{color:#23282d;background:#f5f5f5;outline:0;-webkit-box-shadow:none;box-shadow:none}.gu-mirror{position:fixed!important;margin:0!important;z-index:999999!important;opacity:.8;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80)}.gu-hide{display:none!important}.gu-unselectable{-webkit-user-select:none!important;-moz-user-select:none!important;-ms-user-select:none!important;user-select:none!important}.gu-transit{opacity:.2;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20)}.gu-unselectable .czr-module-collection-wrapper{width:98%;border:1px dotted green;background:#d1ffe0;min-height:31px}li.czr-module-candidate.gu-mirror,li.czr-single-module.gu-mirror{list-style:none}#czr-module-list-panel{position:absolute;top:0;bottom:0;left:-301px;opacity:0;overflow-x:hidden;overflow-y:auto;margin:0;z-index:4;background:rgba(0,0,0,.47);-webkit-transition:all .18s;-moz-transition:all .18s;-ms-transition:all .18s;-o-transition:all .18s;transition:all .18s;border-right:1px solid #ddd}#czr-available-modules-filter,#czr-module-list-panel{width:45%;min-width:300px}body.czr-adding-module #czr-module-list-panel{left:0;visibility:visible;opacity:1}body.czr-adding-module #customize-preview{opacity:.7}.add-new-module:before{content:"\f132";display:inline-block;position:relative;left:-2px;top:-1px;font:400 20px/1 dashicons;vertical-align:middle;-webkit-transition:all .2s;-moz-transition:all .2s;-ms-transition:all .2s;-o-transition:all .2s;transition:all .2s;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.czr-column .add-new-module{margin:1%;float:right}body.czr-adding-module .add-new-module,body.czr-adding-module .add-new-module:hover{background:#eee;border-color:#929793;color:#32373c;-webkit-box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5)}body.czr-adding-module .add-new-module:before{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}#czr-available-modules-list{top:60px;position:absolute;overflow:auto;bottom:0;width:100%}#czr-available-modules-filter{position:fixed;top:0;z-index:1;background:rgba(0,0,0,.47);border-bottom:1px solid #e5e5e5;padding:12px 15px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#czr-available-modules-filter input{padding:6px 10px;width:100%}#czr-available-modules-list .czr-module-candidate{position:relative;border-bottom:1px solid #e5e5e5}#czr-available-modules-list .czr-module-candidate h3{color:#fff;padding:0;margin:0}#czr-available-modules-list .czr-mod-drag-handler{position:relative;left:0;padding:1%;margin:2% 4%;color:inherit;cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab}#czr-sektion-settings-panel{position:absolute;top:0;bottom:0;width:45%;min-width:300px;left:-301px;opacity:0;overflow-x:hidden;overflow-y:auto;margin:0;z-index:4;background:rgba(0,0,0,.47);-webkit-transition:all .18s;-moz-transition:all .18s;-ms-transition:all .18s;-o-transition:all .18s;transition:all .18s;border-right:1px solid #ddd;color:#fff}#czr-sektion-settings-panel h3{color:#fff}body.czr-editing-sektion #czr-sektion-settings-panel{left:0;visibility:visible;opacity:1}body.czr-editing-sektion #customize-preview{opacity:.7}#customize-controls .customize-section-title.is-in-view,.czr-skop-on #customize-controls .customize-info.is-in-view{opacity:0}.czr-skop-on .wp-full-overlay-sidebar .wp-full-overlay-header{height:185px}.czr-skop-on .wp-full-overlay-sidebar .wp-full-overlay-sidebar-content{top:185px!important}.wp-customizer .in-sub-panel .wp-full-overlay-sidebar .wp-full-overlay-header{padding:0 15px}.customize-controls-close{border-bottom:1px solid #ddd}.czr-skop-on #customize-controls #customize-notifications-area{z-index:1000}.wp-customizer #customize-header-actions{border-bottom:0}.czr-scope-switcher{width:100%;float:right;position:absolute;left:0;bottom:0;overflow:hidden}.czr-scope-switcher .czr-skp-permanent-title{position:relative;color:#5f5f5f}#customize-header-actions .czr-scope-switcher .spinner{float:none;display:none;margin:0;left:-26px;top:0;position:absolute;visibility:visible}h2.czr-current-skope-title{font-size:13px;line-height:21px;margin:6px 0 4px;text-align:center;height:63px;font-weight:400;overflow:hidden}.czr-main-title{max-height:24px;overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:nowrap;width:95%}.czr-skope-title{display:block;font-size:17px;font-style:italic;line-height:25px}.czr-toggle-title-notice{cursor:pointer;font-size:14px;color:#777}.czr-skope-inherits-from{display:inline-block;opacity:0;width:90%;font-size:12px;line-height:18px;color:#0029ff;top:-6px;position:relative}.notice-visible .czr-toggle-title-notice{color:#0029ff}.notice-visible .czr-skope-inherits-from{opacity:1;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out}.czr-scope,.czr-scope-switcher .button{-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;float:left}.czr-scope-switcher .button{width:40%;text-align:center;margin:0 2%;opacity:.7;transition:opacity .3s ease-in-out}.czr-scope-switcher .button.active{font-weight:700;opacity:1}.czr-scope-switcher .active,.czr-scope-switcher .czr-scope:hover{opacity:1}.czr-skopes-wrapper{overflow:hidden;position:relative}.czr-scope-switcher .active:after,.czr-scope.active:before{position:absolute;content:'';top:0}.czr-scope.active:before{height:101%;float:left;z-index:1;-webkit-box-shadow:-4px 0 15px 0 rgba(119,119,119,.58);box-shadow:-4px 0 15px 0 rgba(119,119,119,.58)}.czr-scope-switcher .active:after{height:100%;-webkit-box-shadow:4px 0 15px 0 rgba(119,119,119,.58);box-shadow:4px 0 15px 0 rgba(119,119,119,.58);z-index:3}.czr-skopes-wrapper .active-collection.local:after{right:0}.czr-scope-switcher .czr-scope:last-child:after{-webkit-box-shadow:none;box-shadow:none;right:0}.czr-scope-switcher .czr-scope:first-child:after{left:0}.czr-scope{width:30.5%;background:#fff;border-top:1px solid #ccc;overflow:hidden;opacity:.65;transition:opacity .3s ease-in-out}.czr-scope-switcher .width-100,.czr-scope.width-100.active:after,.czr-scope.width-100.active:before{width:100%}.czr-scope-switcher .width-50,.czr-scope.width-50.active:after,.czr-scope.width-50.active:before{width:50%}.czr-scope-switcher .width-33,.czr-scope.width-33.active:after,.czr-scope.width-33.active:before{width:33.33%}.czr-scope-switcher .width-25,.czr-scope.width-25.active:after,.czr-scope.width-25.active:before{width:25%}.czr-scope-footer,.czr-scope-header{width:100%;min-height:16px;position:relative;z-index:5}.inactive .czr-scope-footer:after{content:'';width:100%;position:absolute;height:5px;bottom:-7px;left:0;-webkit-box-shadow:0 0 13px 4px rgba(119,119,119,.85);box-shadow:0 0 13px 4px rgba(119,119,119,.85)}.czr-scope-content{height:35px;padding:0 3%;width:94%;line-height:35px;text-align:center;clear:both;color:#000;overflow:hidden}.czr-scope-content h4{margin:0;display:inline-block;text-align:center;font-size:14px;line-height:18px;font-weight:400;text-shadow:1px 1px 0 #dedede}.czr-reset-fail,.czr-reset-success,.czr-scope-force{display:none}.czr-scope .fa{font-size:10px;padding:2%;color:#585858;cursor:pointer;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out}.czr-scope .czr-scope-footer .info{cursor:inherit}.czr-scope-header .czr-scope-switch{font-size:22px;padding:0 2px 0 0;text-shadow:1px 1px 2px #fff}.czr-skp-switch-link{cursor:pointer}.czr-pull-left{float:left}.czr-pull-right{float:right}.active .czr-scope-switch{color:#59b15c;cursor:inherit}.czr-scope .czr-scope-reset{display:none;font-size:13px;text-shadow:1px 1px 0 #dedede}.has-db-val .czr-scope-reset{color:#00a0d2}.dirty .czr-scope-reset{color:#FFBD2E!important}.is_winner .czr-scope-winner{color:#59b15c;font-size:14px;position:absolute;bottom:2px;left:2px}.czr-skope-switch{cursor:pointer}.czr-spinner-wrapper{visibility:hidden}.czr-spinner{background:url(img/czr-spinner.gif) no-repeat;-webkit-background-size:32px 32px;background-size:32px 32px;display:inline-block;float:right;vertical-align:middle;opacity:.7;filter:alpha(opacity=70);width:32px;height:32px;margin:4px 10px 0}.customize-control span.customize-control-title:first-child{padding-left:16px;-webkit-transition:left,right,.15s ease-in-out;-moz-transition:left,right,.15s ease-in-out;-ms-transition:left,right,.15s ease-in-out;-o-transition:left,right,.15s ease-in-out;transition:left,right,.15s ease-in-out;position:relative}.wp-customizer .customize-control.czr-not-skoped .customize-control-title{padding-left:0}.czr-setting-reset{color:#eee;-webkit-transition:color .4s;transition:color .4s;position:absolute;left:0;line-height:21px;display:none;text-shadow:1px 1px 0 #a0a0a0}#czr-bottom-infos,#czr-top-note,.czr-resetting-control .czr-remove-alert-wrapper{-moz-transition:all,.3s ease-in-out;-ms-transition:all,.3s ease-in-out;-o-transition:all,.3s ease-in-out}.czr-global-skope-level .is-wp-authorized-setting.has-db-val .czr-setting-reset{color:#eee}.has-db-val .czr-setting-reset{color:#00a0d2}.is-dirty .czr-setting-reset{color:#FFBD2E!important}.czr-ctrl-reset-warning .czr-spinner{display:none}.czr-resetting-control .czr-ctrl-reset-warning .czr-spinner{display:block}.is-dirty .czr-remove-alert-wrapper{background-color:rgba(255,189,46,.54)!important;border:1px solid #FFBD2E!important;text-shadow:none;color:#000}.has-db-val .czr-remove-alert-wrapper{background-color:rgba(0,160,210,.45);border:1px solid #00a0d2;text-shadow:none;color:#000}.czr-resetting-control .czr-remove-alert-wrapper{-webkit-transition:all,.3s ease-in-out;transition:all,.3s ease-in-out}body.czr-skop-loading #czr-skope-pane{top:0}body.czr-skop-loading #customize-preview{filter:blur(3px);-webkit-filter:blur(3px)}@-webkit-keyframes czr-mr-loader{0%{-webkit-transform:scale(.1);transform:scale(.1);opacity:1}70%{-webkit-transform:scale(1);transform:scale(1);opacity:.7}100%{opacity:0}}@keyframes czr-mr-loader{0%{-webkit-transform:scale(.1);transform:scale(.1);opacity:1}70%{-webkit-transform:scale(1);transform:scale(1);opacity:.7}100%{opacity:0}}.czr-css-loader{width:50px;height:50px;position:absolute;-webkit-transform:translate3d(-50%,-50%,0);-ms-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0);top:50%;left:50%;display:block}.czr-mr-loader>div:nth-child(0){-webkit-animation-delay:-.8s;animation-delay:-.8s}.czr-mr-loader>div:nth-child(1){-webkit-animation-delay:-.6s;animation-delay:-.6s}.czr-mr-loader>div:nth-child(2){-webkit-animation-delay:-.4s;animation-delay:-.4s}.czr-mr-loader>div:nth-child(3){-webkit-animation-delay:-.2s;animation-delay:-.2s}.czr-mr-loader>div{position:absolute;top:-4%;left:-4%;width:100%;height:100%;border-radius:100%;border:2px solid #fff;-webkit-animation:czr-mr-loader 1.25s 0s infinite cubic-bezier(.21,.53,.56,.8);animation:czr-mr-loader 1.25s 0s infinite cubic-bezier(.21,.53,.56,.8)}#czr-bottom-infos,#czr-top-note{position:absolute;text-align:center;right:0;left:0;z-index:20;color:#fff;display:block;-webkit-transition:all .3s ease-in-out;transition:all .3s ease-in-out;visibility:hidden}.czr-preview-notification a,.czr-preview-notification h2{color:#fff;margin:1em 0}.czr-preview-notification .czr-preview-note-close{position:absolute;top:10px;right:25px;font-size:31px;cursor:pointer}.czr-preview-notification .fa-arrow-left{position:absolute;bottom:10px;left:25px;font-size:40px}.czr-preview-notification .czr-note-content{display:inline-block;line-height:20px;width:80%}.czr-preview-notification .czr-note-message{font-size:16px;line-height:1.5em;margin:.5em 0}#czr-top-note{top:-100%;background:rgba(0,0,0,.8);padding:2%}#czr-top-note h2{font-size:25px}body.czr-top-note-open #czr-top-note{top:0;visibility:inherit}#czr-bottom-infos{bottom:-100%;background-color:rgba(0,0,0,.85);padding:1px}body.czr-bottom-infos-open #czr-bottom-infos{bottom:0;visibility:inherit}#czr-bottom-infos .czr-note-content .czr-note-message{font-size:13px}#czr-bottom-infos .action-links-wrap{width:100%}#czr-bottom-infos .action-link{font-style:italic;display:inline-block;width:40%}#czr-bottom-infos .action-link a:hover{color:#fff}.czr-disable-bottom-infos{cursor:pointer}#czr-skope-pane{position:absolute;min-height:100%;text-align:center;padding:2%;top:-100%;right:0;left:0;z-index:20;color:#fff;display:block;-webkit-transition:all .3s ease-in-out;-moz-transition:all,.3s ease-in-out;-ms-transition:all,.3s ease-in-out;-o-transition:all,.3s ease-in-out;transition:all .3s ease-in-out;visibility:hidden}#czr-skope-pane.dirty-reset{background:rgba(252,173,6,.23)}#czr-skope-pane.db-reset{background:rgba(0,160,210,.3)}.czr-reset-content{display:inline-block;line-height:20px;width:80%;padding:5%;background:rgba(0,0,0,.63)}#czr-skope-pane h2{color:#fff;line-height:1.5em}body.czr-skope-pane-open #czr-skope-pane{top:0;visibility:inherit;min-height:100%}body.czr-skope-pane-open #customize-preview,body.czr-skope-pane-open .wp-full-overlay-sidebar{opacity:.5}body.czr-resetting-skope #czr-skope-pane .czr-spinner-wrapper{visibility:visible}.czr-skope-pane-open .wp-full-overlay.collapsed .wp-full-overlay-sidebar{z-index:30}.czr-skope-pane-open .wp-full-overlay.expanded .collapse-sidebar{bottom:0!important}.customize-control .czr-skope-notice{color:#3a3a3a;font-family:Verdana,'DejaVu Sans','Bitstream Vera Sans',Geneva,sans-serif;font-size:10px;line-height:1.5em;font-style:normal;border-left:3px solid rgba(99,99,99,.36);padding-left:5px}.czr-toggle-notice{color:#95a5a6;text-shadow:1px 1px 0 #fff;-webkit-transition:color .4s;transition:color .4s;position:absolute;padding-left:3px;line-height:21px;display:none}.czr-notice-visible .czr-toggle-notice,.czr-toggle-notice:hover{color:rgba(0,0,0,.67)}.wp-full-overlay-header,.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content{-webkit-transition:height,top,.4s ease-in-out;-moz-transition:height,top,.4s ease-in-out;-ms-transition:height,top,.4s ease-in-out;-o-transition:height,top,.4s ease-in-out;transition:height,top,.4s ease-in-out}.czr-server-notice{width:calc(96% - 2px);bottom:75px;text-align:center;background:rgba(0,156,0,.18);color:#000;display:none;position:absolute;font-size:12px;line-height:13px;padding:2%;overflow:hidden}.czr-server-notice.czr-server-error{color:#000;background:rgba(255,0,0,.24)}.czr-dismiss-notification{position:absolute;right:5px;top:5px;cursor:pointer}.wp-customizer .icheckbox_flat-grey,.wp-customizer .iradio_flat-grey{border:1px solid #fff;-webkit-border-radius:5px;border-radius:5px;background-color:#fff}.czr-painted{-webkit-transition:background .3s ease-in-out!important;-moz-transition:background .3s ease-in-out!important;-ms-transition:background .3s ease-in-out!important;-o-transition:background .3s ease-in-out!important;transition:background .3s ease-in-out!important}
addons/assets/czr/js/czr-control-base.js CHANGED
@@ -43,7 +43,24 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
43
  }
44
  });
45
  })( wp.customize , jQuery, _);//NOT USED YET
 
 
 
 
 
 
 
46
  ( function ( api, $, _ ) {
 
 
 
 
 
 
 
 
 
 
47
  var _prettyPrintLog = function( args ) {
48
  var _defaults = {
49
  bgCol : '#5ed1f5',
@@ -58,6 +75,9 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
58
  return '';
59
  return string.length > 150 ? string.substr( 0, 149 ) : string;
60
  };
 
 
 
61
  if ( ! _.isEmpty( _.filter( _toArr, function( it ) { return ! _.isString( it ); } ) ) ) {
62
  _toArr = JSON.stringify( _toArr.join(' ') );
63
  } else {
@@ -68,15 +88,18 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
68
  [ 'background:' + args.bgCol, 'color:' + args.textCol, 'display: block;' ].join(';')
69
  ];
70
  };
 
71
  api.consoleLog = function() {
72
  if ( ! serverControlParams.isDevMode )
73
  return;
 
74
  if ( ( _.isUndefined( console ) && typeof window.console.log != 'function' ) )
75
  return;
76
  console.log.apply( console, _prettyPrintLog( { consoleArguments : arguments } ) );
77
  };
78
 
79
  api.errorLog = function() {
 
80
  if ( ( _.isUndefined( console ) && typeof window.console.log != 'function' ) )
81
  return;
82
 
@@ -84,7 +107,7 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
84
  };
85
 
86
  api.czr_isSkopOn = function() {
87
- return serverControlParams.isSkopOn && _.has( api, 'czr_skopeBase' );
88
  };
89
 
90
  api.czr_isChangeSetOn = function() {
@@ -93,6 +116,8 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
93
 
94
  })( wp.customize , jQuery, _);
95
  ( function ( api, $, _ ) {
 
 
96
  /*****************************************************************************
97
  * A "CONTEXT AWARE" SET METHD
98
  *****************************************************************************/
@@ -110,6 +135,8 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
110
  to = this._setter.apply( this, arguments );
111
  to = this.validate( to );
112
  args = _.extend( { silent : false }, _.isObject( o ) ? o : {} );
 
 
113
  if ( null === to || _.isEqual( from, to ) ) {
114
  return dfd.resolveWith( self, [ to, from, o ] ).promise();
115
  }
@@ -137,7 +164,12 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
137
  }
138
  return dfd.promise( self );
139
  };
 
 
 
 
140
  api.Value.prototype.bind = function() {
 
141
  var self = this,
142
  _isDeferred = false,
143
  _cbs = [];
@@ -156,6 +188,7 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
156
  self._deferreds.push( _cb );
157
  });
158
  } else {
 
159
  self.callbacks.add.apply( self.callbacks, arguments );
160
  }
161
  return this;
@@ -168,12 +201,17 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
168
  * => add an object param to the callback to inform that this is a silent process
169
  * , this is typically used in the overridden api.Setting.preview method
170
  *****************************************************************************/
 
 
 
171
  api.Setting.prototype.silent_set =function( to, dirtyness ) {
172
  var from = this._value,
173
  _save_state = api.state('saved')();
174
 
175
  to = this._setter.apply( this, arguments );
176
  to = this.validate( to );
 
 
177
  if ( null === to || _.isEqual( from, to ) ) {
178
  return this;
179
  }
@@ -182,11 +220,18 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
182
  this._dirty = ( _.isUndefined( dirtyness ) || ! _.isBoolean( dirtyness ) ) ? this._dirty : dirtyness;
183
 
184
  this.callbacks.fireWith( this, [ to, from, { silent : true } ] );
 
185
  api.state('saved')( _save_state );
186
  return this;
187
  };
188
  })( wp.customize , jQuery, _ );
189
  ( function ( api, $, _ ) {
 
 
 
 
 
 
190
  api.Setting.prototype.initialize = function( id, value, options ) {
191
  var setting = this;
192
  api.Value.prototype.initialize.call( setting, value, options );
@@ -195,8 +240,19 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
195
  setting.transport = setting.transport || 'refresh';
196
  setting._dirty = options.dirty || false;
197
  setting.notifications = new api.Values({ defaultConstructor: api.Notification });
 
 
198
  setting.bind( setting.preview );
 
 
 
 
 
199
  };
 
 
 
 
200
  api.Setting.prototype.preview = function( to, from , data ) {
201
  var setting = this, transport, dfd = $.Deferred();
202
 
@@ -206,28 +262,68 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
206
  this.previewer.refresh();
207
  return dfd.resolve( arguments ).promise();
208
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  if ( ! _.isUndefined( from ) && ! _.isEmpty( from ) && ! _.isNull( from ) ) {
210
  if ( _.isObject( data ) && true === data.not_preview_sent ) {
211
  return dfd.resolve( arguments ).promise();
212
  }
213
  }
 
 
214
  if ( _.has( data, 'silent' ) && false !== data.silent )
215
  return dfd.resolve( arguments ).promise();
 
 
 
216
  if ( 'postMessage' === transport && ! api.state( 'previewerAlive' ).get() ) {
217
  transport = 'refresh';
218
  }
219
 
220
  if ( 'postMessage' === transport ) {
 
 
221
  setting.previewer.send( 'pre_setting', {
222
  set_id : setting.id,
223
  data : data,//<= { module_id : 'string', module : {} } which typically includes the module_id and the module model ( items, mod options )
224
  value : to
225
  });
 
 
 
 
 
226
  setting.previewer.send( 'setting', [ setting.id, setting() ] );
227
 
228
  dfd.resolve( arguments );
229
 
230
  } else if ( 'refresh' === transport ) {
 
231
  if ( serverControlParams.isSkopOn ) {
232
  setting.previewer.refresh().always( function() {
233
  dfd.resolve( arguments );
@@ -243,9 +339,12 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
243
  })( wp.customize , jQuery, _ );
244
  ( function ( api, $, _ ) {
245
  /* monkey patch for the content height set */
 
246
  if ( 'function' == typeof api.Section ) {
 
247
  var _original_section_initialize = api.Section.prototype.initialize;
248
  api.Section.prototype.initialize = function( id, options ) {
 
249
  _original_section_initialize.apply( this, [id, options] );
250
  var section = this;
251
 
@@ -255,10 +354,12 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
255
 
256
  var container = section.container.closest( '.wp-full-overlay-sidebar-content' ),
257
  content = section.container.find( '.accordion-section-content' );
 
258
  _resizeContentHeight = function() {
259
  content.css( 'height', container.innerHeight() );
260
  };
261
  _resizeContentHeight();
 
262
  $( window ).on( 'resize.customizer-section', _.debounce( _resizeContentHeight, 110 ) );
263
  });
264
  };
@@ -266,7 +367,17 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
266
  })( wp.customize , jQuery, _ );
267
  (function (api, $, _) {
268
  api.CZR_Helpers = api.CZR_Helpers || {};
 
 
 
 
 
 
269
  api.CZR_Helpers = $.extend( api.CZR_Helpers, {
 
 
 
 
270
  getControlSettingId : function( control_id, setting_type ) {
271
  setting_type = 'default' || setting_type;
272
  if ( ! api.control.has( control_id ) ) {
@@ -306,8 +417,23 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
306
  * simple helper to build the setting wp api ready id
307
  */
308
  build_setId : function ( setId ) {
 
309
  if ( _.contains( serverControlParams.wpBuiltinSettings, setId ) )
310
  return setId;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  if ( ! _.contains( serverControlParams.themeSettingList, setId ) )
312
  return setId;
313
 
@@ -320,10 +446,16 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
320
  */
321
  getOptionName : function(name) {
322
  var self = this;
 
323
  if ( -1 == name.indexOf(serverControlParams.themeOptions) )
324
  return name;
325
  return name.replace(/\[|\]/g, '').replace(serverControlParams.themeOptions, '');
326
  },
 
 
 
 
 
327
  hasPartRefresh : function( setId ) {
328
  if ( ! _.has( api, 'czr_partials') )
329
  return;
@@ -331,6 +463,8 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
331
  return _.contains( partial.settings, setId );
332
  }), true );
333
  },
 
 
334
  getSectionControlIds : function( section_id ) {
335
  section_id = section_id || api.czr_activeSectionId();
336
  return ! api.section.has( section_id ) ?
@@ -339,6 +473,12 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
339
  return _ctrl.id;
340
  });
341
  },
 
 
 
 
 
 
342
  getSectionSettingIds : function( section_id ) {
343
  section_id = section_id || api.czr_activeSectionId();
344
  if ( ! api.section.has( section_id) )
@@ -354,6 +494,11 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
354
  });
355
  return _sec_settings;
356
  },
 
 
 
 
 
357
  capitalize : function( string ) {
358
  if( ! _.isString(string) )
359
  return string;
@@ -369,6 +514,13 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
369
  s_ = (useWordBoundary && isTooLong) ? s_.substr(0,s_.lastIndexOf(' ')) : s_;
370
  return isTooLong ? s_ + '...' : s_;
371
  },
 
 
 
 
 
 
 
372
  isMultiItemModule : function( module_type, moduleInst ) {
373
  if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
374
  return;
@@ -381,6 +533,9 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
381
 
382
  return api.czrModuleMap[module_type].crud || api.czrModuleMap[module_type].multi_item || false;
383
  },
 
 
 
384
  isCrudModule : function( module_type, moduleInst ) {
385
  if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
386
  return;
@@ -393,6 +548,9 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
393
 
394
  return api.czrModuleMap[module_type].crud || false;
395
  },
 
 
 
396
  hasModuleModOpt : function( module_type, moduleInst ) {
397
  if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
398
  return;
@@ -405,6 +563,15 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
405
 
406
  return api.czrModuleMap[module_type].has_mod_opt || false;
407
  },
 
 
 
 
 
 
 
 
 
408
  setupInputCollectionFromDOM : function() {
409
  var inputParentInst = this;//<= because fired with .call( inputParentInst )
410
  if ( ! _.isFunction( inputParentInst ) ) {
@@ -412,9 +579,17 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
412
  }
413
  var module = inputParentInst.module,
414
  is_mod_opt = _.has( inputParentInst() , 'is_mod_opt' );
 
 
415
  if ( _.has( inputParentInst, 'czr_Input') && ! _.isEmpty( inputParentInst.inputCollection() ) )
416
  return;
 
 
 
417
  inputParentInst.czr_Input = new api.Values();
 
 
 
418
  inputParentInst.inputConstructor = is_mod_opt ? module.inputModOptConstructor : module.inputConstructor;
419
 
420
  var _defaultInputParentModel = is_mod_opt ? inputParentInst.defaultModOptModel : inputParentInst.defaultItemModel;
@@ -422,6 +597,9 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
422
  if ( _.isEmpty( _defaultInputParentModel ) || _.isUndefined( _defaultInputParentModel ) ) {
423
  throw new Error( 'No default model found in item or mod opt ' + inputParentInst.id + '.' );
424
  }
 
 
 
425
  var inputParentInst_model = $.extend( true, {}, inputParentInst() );
426
 
427
  if ( ! _.isObject( inputParentInst_model ) )
@@ -430,19 +608,28 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
430
  inputParentInst_model = $.extend( _defaultInputParentModel, inputParentInst_model );
431
 
432
  var dom_inputParentInst_model = {};
 
 
433
  $( '.' + module.control.css_attr.sub_set_wrapper, inputParentInst.container).each( function( _index ) {
434
  var _id = $(this).find('[data-type]').attr( 'data-type' ),
435
  _value = _.has( inputParentInst_model, _id ) ? inputParentInst_model[ _id ] : '';
 
 
436
  if ( _.isUndefined( _id ) || _.isEmpty( _id ) ) {
437
  api.consoleLog( 'setupInputCollectionFromDOM : missing data-type for ' + module.id );
438
  return;
439
  }
 
440
  if ( ! _.has( inputParentInst_model, _id ) ) {
441
  throw new Error('The item or mod opt property : ' + _id + ' has been found in the DOM but not in the item or mod opt model : '+ inputParentInst.id + '. The input can not be instantiated.');
442
  }
 
 
443
  var _inputType = $(this).attr( 'data-input-type' ),
444
  _inputTransport = $(this).attr( 'data-transport' ) || 'inherit',//<= if no specific transport ( refresh or postMessage ) has been defined in the template, inherits the control transport
445
  _inputOptions = _.has( module.inputOptions, _inputType ) ? module.inputOptions[ _inputType ] : {};
 
 
446
  inputParentInst.czr_Input.add( _id, new inputParentInst.inputConstructor( _id, {
447
  id : _id,
448
  type : _inputType,
@@ -454,12 +641,25 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
454
  is_mod_opt : is_mod_opt,
455
  module : module
456
  } ) );
 
 
 
457
  inputParentInst.czr_Input( _id ).ready();
 
 
458
  dom_inputParentInst_model[ _id ] = _value;
 
459
  });//each
 
 
460
  inputParentInst.inputCollection( dom_inputParentInst_model );
 
 
461
  return inputParentInst;
462
  },
 
 
 
463
  removeInputCollection : function() {
464
  var inputParentInst = this;//<= because fired with .call( inputParentInst )
465
  if ( ! _.isFunction( inputParentInst ) ) {
@@ -467,22 +667,36 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
467
  }
468
  if ( ! _.has( inputParentInst, 'czr_Input') )
469
  return;
 
470
  inputParentInst.czr_Input.each( function( _input ) {
471
  inputParentInst.czr_Input.remove( _input.id );
472
  });
 
473
  inputParentInst.inputCollection({});
474
  },
 
 
 
475
  refreshModuleControl : function( wpSetId ) {
476
  var _constructor = api.controlConstructor.czr_module,
477
  _control_type = api.control( wpSetId ).params.type,
478
  _control_data = api.settings.controls[wpSetId];
 
 
479
  $.when( api.control( wpSetId ).container.remove() ).done( function() {
 
480
  api.control.remove( wpSetId );
 
 
481
  api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
482
  });
483
 
484
  },
 
 
 
485
  hexToRgb : function( hex ) {
 
486
  var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
487
  try {
488
  hex = hex.replace(shorthandRegex, function(m, r, g, b) {
@@ -511,9 +725,18 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
511
  }
512
 
513
  });//$.extend
 
 
 
514
  })( wp.customize , jQuery, _);
515
  (function (api, $, _) {
516
  api.CZR_Helpers = api.CZR_Helpers || {};
 
 
 
 
 
 
517
  api.CZR_Helpers = $.extend( api.CZR_Helpers, {
518
  addActions : function( event_map, new_events, instance ) {
519
  var control = this;
@@ -526,6 +749,9 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
526
  doActions : function( action, $dom_el, obj ) {
527
  $dom_el.trigger( action, obj );
528
  },
 
 
 
529
  setupDOMListeners : function( event_map , args, instance ) {
530
  var control = this,
531
  _defaultArgs = {
@@ -534,44 +760,78 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
534
  };
535
 
536
  instance = instance || control;
 
537
  if ( ! _.isArray( event_map ) ) {
538
  api.errorLog( 'setupDomListeners : event_map should be an array', args );
539
  return;
540
  }
 
 
541
  if ( ! _.isObject( args ) ) {
542
  api.errorLog( 'setupDomListeners : args should be an object', event_map );
543
  return;
544
  }
545
 
546
  args = _.extend( _defaultArgs, args );
 
547
  if ( ! args.dom_el instanceof jQuery || 1 != args.dom_el.length ) {
548
  api.errorLog( 'setupDomListeners : dom element should be an existing dom element', args );
549
  return;
550
  }
 
 
 
 
 
 
 
 
 
551
  _.map( event_map , function( _event ) {
552
  if ( ! _.isString( _event.selector ) || _.isEmpty( _event.selector ) ) {
553
  api.errorLog( 'setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : ' + _event.actions.join(',') );
554
  return;
555
  }
 
 
556
  if ( ! _.isString( _event.selector ) || _.isEmpty( _event.selector ) ) {
557
  api.errorLog( 'setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : ' + _event.actions.join(',') );
558
  return;
559
  }
 
 
560
  args.dom_el.on( _event.trigger , _event.selector, function( e, event_params ) {
 
561
  e.stopPropagation();
 
562
  if ( api.utils.isKeydownButNotEnterEvent( e ) ) {
563
  return;
564
  }
565
  e.preventDefault(); // Keep this AFTER the key filter above
 
 
 
566
  var actionsParams = $.extend( true, {}, args );
 
 
567
  if ( _.has( actionsParams, 'model') && _.has( actionsParams.model, 'id') ) {
568
  if ( _.has( instance, 'get' ) )
569
  actionsParams.model = instance();
570
  else
571
  actionsParams.model = instance.getModel( actionsParams.model.id );
572
  }
 
 
 
573
  $.extend( actionsParams, { event : _event, dom_event : e } );
 
 
574
  $.extend( actionsParams, event_params );
 
 
 
 
 
575
  if ( ! _.has( actionsParams, 'event' ) || ! _.has( actionsParams.event, 'actions' ) ) {
576
  api.errorLog( 'executeEventActionChain : missing obj.event or obj.event.actions' );
577
  return;
@@ -583,12 +843,26 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
583
  });//.on()
584
  });//_.map()
585
  },//setupDomListeners
 
 
 
 
 
586
  executeEventActionChain : function( args, instance ) {
587
  var control = this;
 
 
588
  if ( 'function' === typeof( args.event.actions ) )
589
  return args.event.actions.call( instance, args );
 
 
 
 
590
  if ( ! _.isArray( args.event.actions ) )
591
  args.event.actions = [ args.event.actions ];
 
 
 
592
  var _break = false;
593
  _.map( args.event.actions, function( _cb ) {
594
  if ( _break )
@@ -597,18 +871,32 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
597
  if ( 'function' != typeof( instance[ _cb ] ) ) {
598
  throw new Error( 'executeEventActionChain : the action : ' + _cb + ' has not been found when firing event : ' + args.event.selector );
599
  }
 
 
 
 
 
 
600
  var $_dom_el = ( _.has(args, 'dom_el') && -1 != args.dom_el.length ) ? args.dom_el : control.container;
601
 
602
  $_dom_el.trigger( 'before_' + _cb, _.omit( args, 'event' ) );
 
 
603
  var _cb_return = instance[ _cb ].call( instance, args );
 
604
  if ( false === _cb_return )
605
  _break = true;
 
 
606
  $_dom_el.trigger( 'after_' + _cb, _.omit( args, 'event' ) );
607
  });//_.map
608
  }
609
  });//$.extend
610
  })( wp.customize , jQuery, _);
611
  (function (api, $, _) {
 
 
 
612
 
613
  api.czr_wpQueryDataReady = $.Deferred();
614
  api.czr_wpQueryInfos = api.czr_wpQueryInfos || new api.Value();
@@ -616,8 +904,11 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
616
  /*****************************************************************************
617
  * CAPTURE PREVIEW INFORMATIONS ON REFRESH + REACT TO THEM
618
  *****************************************************************************/
 
619
  api.bind( 'ready', function() {
 
620
  api.previewer.bind('houston-widget-settings', function(data) {
 
621
  var _candidates = _.filter( data.registeredSidebars, function( sb ) {
622
  return ! _.findWhere( _wpCustomizeWidgetsSettings.registeredSidebars, { id: sb.id } );
623
  });
@@ -633,6 +924,8 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
633
  var _registered = _.map( data.registeredSidebars, function(obj) {
634
  return obj.id;
635
  });
 
 
636
  api.czr_widgetZoneSettings = api.czr_widgetZoneSettings || new api.Value();//will store all widget zones data sent by preview as an observable object
637
  api.czr_widgetZoneSettings.set( {
638
  actives : data.renderedSidebars,
@@ -651,15 +944,21 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
651
  api.czr_wpQueryDataReady.resolve( data );
652
  }
653
  });
 
 
654
  api.previewer.bind( 'czr-partial-refresh-data', function( data ) {
655
  api.czr_partials.set( data );
656
  });
 
 
 
657
  api.previewer.bind( 'czr-partial-refresh-done', function( data ) {
658
  if ( ! _.has( data, 'set_id' ) )
659
  return;
660
  var setId = api.CZR_Helpers.build_setId( data.set_id );
661
  if ( ! api.has( setId ) )
662
  return;
 
663
  var ctrlId = api.CZR_Helpers.getControlSettingId( setId );
664
  if ( ! api.control.has( ctrlId ) )
665
  return;
@@ -667,6 +966,19 @@ api.CZR_Helpers = $.extend( api.CZR_Helpers, {
667
  });
668
  });//api.bind('ready')
669
  })( wp.customize , jQuery, _ );var CZRInputMths = CZRInputMths || {};
 
 
 
 
 
 
 
 
 
 
 
 
 
670
  ( function ( api, $, _ ) {
671
  $.extend( CZRInputMths , {
672
  initialize: function( name, options ) {
@@ -680,11 +992,22 @@ $.extend( CZRInputMths , {
680
  api.Value.prototype.initialize.call( this, null, options );
681
 
682
  var input = this;
 
 
683
  $.extend( input, options || {} );
 
 
 
684
  input.isReady = $.Deferred();
 
 
685
  if ( ! _.isUndefined(options.input_value) ) {
686
  input.set( options.input_value );
687
  }
 
 
 
 
688
  if ( api.czrInputMap && _.has( api.czrInputMap, input.type ) ) {
689
  var _meth = api.czrInputMap[ input.type ];
690
  if ( _.isFunction( input[_meth]) ) {
@@ -701,7 +1024,10 @@ $.extend( CZRInputMths , {
701
  color : 'colorpickerchange',
702
  range : 'input propertychange'
703
  };
 
 
704
  input.input_event_map = [
 
705
  {
706
  trigger : $.trim( ['change', trigger_map[input.type] || '' ].join(' ') ),//was 'propertychange change click keyup input',//colorpickerchange is a custom colorpicker event @see method setupColorPicker => otherwise we don't
707
  selector : 'input[data-type], select[data-type], textarea[data-type]',
@@ -713,6 +1039,8 @@ $.extend( CZRInputMths , {
713
  }//was 'updateInput'
714
  }
715
  ];
 
 
716
  input.visible = new api.Value( true );
717
  input.isReady.done( function() {
718
  input.visible.bind( function( visible ) {
@@ -722,6 +1050,8 @@ $.extend( CZRInputMths , {
722
  input.container.stop( true, true ).slideUp( 200 );
723
  });
724
  });
 
 
725
  input.enabled = new api.Value( true );
726
  input.isReady.done( function() {
727
  input.enabled.bind( function( enabled ) {
@@ -730,20 +1060,35 @@ $.extend( CZRInputMths , {
730
  });
731
 
732
  },
 
 
 
 
733
  ready : function() {
734
  var input = this;
735
  input.setupDOMListeners( input.input_event_map , { dom_el : input.container }, input );
 
736
  input.callbacks.add( function() { return input.inputReact.apply( input, arguments ); } );
 
 
737
  $.when( input.setupSynchronizer() ).done( function() {
738
  input.isReady.resolve( input );
739
  } );
740
 
741
  },
 
 
 
 
 
742
  setupSynchronizer: function() {
743
  var input = this,
744
  input_parent = input.input_parent,
745
  $_input_el = input.container.find('[data-type]'),
746
  is_textarea = input.container.find('[data-type]').is('textarea');
 
 
 
747
  if ( is_textarea ) {
748
  throw new Error('TO DO : THE TEXTAREA INPUT ARE NOT READY IN THE SYNCHRONIZER!');
749
  }
@@ -754,22 +1099,45 @@ $.extend( CZRInputMths , {
754
  syncElement.sync( input );//sync with the input instance
755
  syncElement.set( input() );
756
  },
 
 
 
 
 
 
 
757
  inputReact : function( to, from, data ) {
758
  var input = this,
759
  _current_input_parent = input.input_parent(),
760
  _new_model = _.clone( _current_input_parent ),//initialize it to the current value
761
  _isPreItemInput = input.is_preItemInput;
 
 
762
  if ( ! input.enabled() )
763
  return;
 
 
764
  _new_model = ( ! _.isObject(_new_model) || _.isEmpty(_new_model) ) ? {} : _new_model;
 
765
  _new_model[ input.id ] = to;
 
 
766
  input.input_parent.set( _new_model, {
767
  input_changed : input.id,
768
  input_transport : input.transport,
769
  not_preview_sent : 'postMessage' === input.transport//<= this parameter set to true will prevent the setting to be sent to the preview ( @see api.Setting.prototype.preview override ). This is useful to decide if a specific input should refresh or not the preview.
770
  } );
 
 
771
  if ( ! _isPreItemInput ) {
 
 
772
  input.input_parent.trigger( input.id + ':changed', to );
 
 
 
 
 
773
  if ( ! _.isEmpty( from ) || ! _.isUndefined( from ) && 'postMessage' === input.transport ) {
774
  input.module.sendInputToPreview( {
775
  input_id : input.id,
@@ -792,6 +1160,14 @@ $.extend( CZRInputMths , {
792
  palettes: true,
793
  hide:false,
794
  change : function( e, o ) {
 
 
 
 
 
 
 
 
795
  $(this).val( o.color.toString() ).trigger('colorpickerchange').trigger('change');
796
  }
797
  });
@@ -802,6 +1178,10 @@ $.extend( CZRInputMths , {
802
  $('select', input.container ).not('.no-selecter-js')
803
  .each( function() {
804
  $(this).selecter({
 
 
 
 
805
  });
806
  });
807
  },
@@ -831,6 +1211,8 @@ $.extend( CZRInputMths , {
831
  $(this).stepper();
832
  });
833
  },
 
 
834
  setupRangeSlider : function( options ) {
835
  var input = this,
836
  $handle,
@@ -839,18 +1221,30 @@ $.extend( CZRInputMths , {
839
  };
840
 
841
  $( input.container ).find('input').rangeslider( {
 
 
 
 
842
  polyfill: false,
 
 
843
  rangeClass: 'rangeslider',
844
  disabledClass: 'rangeslider--disabled',
845
  horizontalClass: 'rangeslider--horizontal',
846
  verticalClass: 'rangeslider--vertical',
847
  fillClass: 'rangeslider__fill',
848
  handleClass: 'rangeslider__handle',
 
 
849
  onInit: function() {
850
  $handle = $('.rangeslider__handle', this.$range);
851
  $('.rangeslider__handle', this.$range);
852
  _updateHandle( $handle[0], this.value );
853
  },
 
 
 
 
854
  } ).on('input', function() {
855
  _updateHandle( $handle[0], this.value );
856
  });
@@ -862,12 +1256,18 @@ $.extend( CZRInputMths , {
862
  setupImageUploader : function() {
863
  var input = this,
864
  _model = input();
 
 
865
  input.attachment = {};
 
 
866
  if ( ! input.container )
867
  return this;
868
 
869
  this.tmplRendered = $.Deferred();
870
  this.setupContentRendering( _model, {} );
 
 
871
  this.tmplRendered.done( function(){
872
  input.czrImgUploaderBinding();
873
  });
@@ -875,11 +1275,14 @@ $.extend( CZRInputMths , {
875
 
876
  setupContentRendering : function( to, from) {
877
  var input = this, _attachment;
 
 
878
  if ( ( input.attachment.id != to ) && from !== to ) {
879
  if ( ! to ) {
880
  input.attachment = {};
881
  input.renderImageUploaderTemplate();
882
  }
 
883
  _attachment = wp.media.attachment( to );
884
  if ( _.isObject( _attachment ) && _.has( _attachment, 'attributes' ) && _.has( _attachment.attributes, 'sizes' ) ) {
885
  input.attachment = _attachment.attributes;
@@ -898,7 +1301,11 @@ $.extend( CZRInputMths , {
898
 
899
  czrImgUploaderBinding : function() {
900
  var input = this;
 
 
901
  _.bindAll( input, 'czrImgUploadRemoveFile', 'czrImgUploadOpenFrame', 'czrImgUploadSelect');
 
 
902
  input.container.on( 'click keydown', '.upload-button', input.czrImgUploadOpenFrame );
903
  input.container.on( 'click keydown', '.thumbnail-image img', input.czrImgUploadOpenFrame );
904
  input.container.on( 'click keydown', '.remove-button', input.czrImgUploadRemoveFile );
@@ -945,6 +1352,7 @@ $.extend( CZRInputMths , {
945
  })
946
  ]
947
  });
 
948
  input.frame.on( 'select', input.czrImgUploadSelect );
949
  },
950
 
@@ -960,7 +1368,9 @@ $.extend( CZRInputMths , {
960
  return;
961
  }
962
  event.preventDefault();
 
963
  input.attachment = {};
 
964
  input.set('');
965
  },
966
 
@@ -974,15 +1384,28 @@ $.extend( CZRInputMths , {
974
  input = this,
975
  attachment = input.frame.state().get( 'selection' ).first().toJSON(), // Get the attachment from the modal frame.
976
  mejsSettings = window._wpmejsSettings || {};
 
977
  input.attachment = attachment;
 
978
  input.set(attachment.id);
979
  },
 
 
 
 
 
 
 
980
  renderImageUploaderTemplate: function() {
981
  var input = this;
 
 
982
  if ( 0 === $( '#tmpl-czr-input-img-uploader-view-content' ).length )
983
  return;
984
 
985
  var view_template = wp.template('czr-input-img-uploader-view-content');
 
 
986
  if ( ! view_template || ! input.container )
987
  return;
988
 
@@ -1017,6 +1440,8 @@ $.extend( CZRInputMths , {
1017
  'frame_title' : _ts.frame_title_image,
1018
  'frame_button': _ts.frame_button_image
1019
  };
 
 
1020
  _.each( _map, function( ts_string, key ) {
1021
  if ( _.isUndefined( ts_string ) ) {
1022
  var input = this;
@@ -1029,6 +1454,36 @@ $.extend( CZRInputMths , {
1029
  }
1030
  });//$.extend
1031
  })( wp.customize , jQuery, _ );/* Fix caching, select2 default one seems to not correctly work, or it doesn't what I think it should */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1032
  var CZRInputMths = CZRInputMths || {};
1033
  ( function ( api, $, _ ) {
1034
  $.extend( CZRInputMths , {
@@ -1037,6 +1492,7 @@ $.extend( CZRInputMths , {
1037
  _event_map = [];
1038
 
1039
  /* Dummy for the prototype purpose */
 
1040
  $.extend( {
1041
  post : '',
1042
  taxonomy : ''
@@ -1046,7 +1502,10 @@ $.extend( CZRInputMths , {
1046
 
1047
  /* Methodize this or use a template */
1048
  input.container.find('.czr-input').append('<select data-select-type="content-picker-select" class="js-example-basic-simple"></select>');
 
 
1049
  _event_map = [
 
1050
  {
1051
  trigger : 'change',
1052
  selector : 'select[data-select-type]',
@@ -1068,6 +1527,9 @@ $.extend( CZRInputMths , {
1068
  api.errorLog( 'Content Picker Input : the picked value should be an object not empty.');
1069
  return;
1070
  }
 
 
 
1071
  _.each( _default, function( val, k ){
1072
  if ( '_custom_' !== _raw_val.id ) {
1073
  if ( ! _.has( _raw_val, k ) || _.isEmpty( _raw_val[ k ] ) ) {
@@ -1077,25 +1539,39 @@ $.extend( CZRInputMths , {
1077
  }
1078
  _val_candidate[ k ] = _raw_val[ k ];
1079
  } );
 
1080
  input.set( _val_candidate );
1081
  }
1082
  }
1083
  ];
1084
 
1085
  input.setupDOMListeners( _event_map , { dom_el : input.container }, input );
 
1086
  input.isReady.done( function() {
1087
  input.setupContentSelecter();
1088
  });
1089
 
1090
  },
 
 
 
 
 
 
 
 
 
 
1091
  setupContentSelecter : function() {
1092
  var input = this;
 
1093
  if ( ! _.isEmpty( input() ) ) {
1094
  var _attributes = {
1095
  value : input().id || '',
1096
  title : input().title || '',
1097
  selected : "selected"
1098
  };
 
1099
  input.container.find('select').append( $( '<option>', _attributes ) );
1100
  }
1101
 
@@ -1105,6 +1581,7 @@ $.extend( CZRInputMths , {
1105
  title: 'Select'
1106
  },
1107
  data : input.setupSelectedContents(),
 
1108
  ajax: {
1109
  url: serverControlParams.AjaxUrl,
1110
  type: 'POST',
@@ -1112,6 +1589,7 @@ $.extend( CZRInputMths , {
1112
  delay: 250,
1113
  debug: true,
1114
  data: function ( params ) {
 
1115
  var page = params.page ? params.page : 0;
1116
  page = params.term ? params.page : page;
1117
  return {
@@ -1132,6 +1610,7 @@ $.extend( CZRInputMths , {
1132
  return $request;
1133
  },*/
1134
  processResults: function ( data, params ) {
 
1135
  input.defaultContentPickerOption = input.defaultContentPickerOption || [];
1136
 
1137
  if ( ! data.success )
@@ -1152,6 +1631,7 @@ $.extend( CZRInputMths , {
1152
  });
1153
  return {
1154
  results: _results,
 
1155
  pagination: { more: data.data.items.length >= 10 }//<= the pagination boolean param can be tricky => here set to >= 10 because we query 10 + add a custom link item on the first query
1156
  };
1157
  },
@@ -1161,6 +1641,15 @@ $.extend( CZRInputMths , {
1161
  escapeMarkup: function ( markup ) { return markup; },
1162
  });//select2 setup
1163
  },
 
 
 
 
 
 
 
 
 
1164
  czrFormatContentSelected: function ( item ) {
1165
  if ( item.loading ) return item.text;
1166
  var markup = "<div class='content-picker-item clearfix'>" +
@@ -1189,6 +1678,8 @@ $.extend( CZRInputMths , {
1189
  setupTextEditor : function() {
1190
  var input = this,
1191
  _model = input();
 
 
1192
  if ( ! input.container ) {
1193
  throw new Error( 'The input container is not set for WP text editor in module.' + input.module.id );
1194
  }
@@ -1210,7 +1701,12 @@ $.extend( CZRInputMths , {
1210
 
1211
  input.textpreview = input.container.find('textarea');
1212
  input.toggleButton = input.container.find('button.text_editor-button');
 
 
1213
  input.editorExpanded = new api.Value( false );
 
 
 
1214
  input.czrUpdateTextPreview();
1215
  input.czrSetToggleButtonText( input.editorExpanded() );
1216
 
@@ -1238,6 +1734,8 @@ $.extend( CZRInputMths , {
1238
  editor.focus();
1239
  }
1240
  });
 
 
1241
  input.module.czr_ModuleState.bind(
1242
  function( state ) {
1243
  if ( 'expanded' != state )
@@ -1257,6 +1755,8 @@ $.extend( CZRInputMths , {
1257
  $(document.body).toggleClass('czr-customize-content_editor-pane-open', expanded);
1258
  editor.locker = input;
1259
  }
 
 
1260
  input.czrSetToggleButtonText( expanded );
1261
 
1262
  if ( expanded ) {
@@ -1270,6 +1770,8 @@ $.extend( CZRInputMths , {
1270
  editor.off( 'input change keyup', input.czrOnVisualEditorChange );
1271
  textarea.off( 'input', input.czrOnTextEditorChange );
1272
  $( window ).off('resize', input.czrResizeEditorOnWindowResize );
 
 
1273
  input.czrResizeReset();
1274
  }
1275
  } );
@@ -1296,20 +1798,30 @@ $.extend( CZRInputMths , {
1296
  var input = this,
1297
  input_model = input(),
1298
  value;
 
 
1299
  value = input_model.replace(/(<([^>]+)>)/ig,"");
 
1300
  if ( value.length > 30 )
1301
  value = value.substring(0, 34) + '...';
1302
 
1303
  input.textpreview.val( value );
1304
  },
 
 
 
1305
  czrRenderInputTextEditorTemplate: function() {
1306
  var input = this;
 
 
1307
  if ( 0 === $( '#tmpl-czr-input-text_editor-view-content' ).length ) {
1308
  throw new Error('Missing js template for text editor input in module : ' + input.module.id );
1309
  }
1310
 
1311
  var view_template = wp.template('czr-input-text_editor-view-content'),
1312
  $_view_el = input.container.find('input');
 
 
1313
  if ( ! view_template || ! input.container )
1314
  return;
1315
 
@@ -1438,6 +1950,12 @@ $.extend( CZRInputMths , {
1438
  }
1439
  });//$.extend
1440
  })( wp.customize , jQuery, _ );//extends api.Value
 
 
 
 
 
 
1441
 
1442
  var CZRItemMths = CZRItemMths || {};
1443
  ( function ( api, $, _ ) {
@@ -1449,18 +1967,39 @@ $.extend( CZRItemMths , {
1449
 
1450
  var item = this;
1451
  api.Value.prototype.initialize.call( item, null, options );
 
 
 
 
1452
  item.isReady = $.Deferred();
 
1453
  item.embedded = $.Deferred();
1454
  item.container = null;//will store the item $ dom element
1455
  item.contentContainer = null;//will store the item content $ dom element
1456
  item.inputCollection = new api.Value({});
 
 
 
 
1457
  item.viewState = new api.Value( 'closed' );
1458
  item.removeDialogVisible = new api.Value( false );
 
 
 
1459
  $.extend( item, options || {} );
 
 
1460
  item.defaultItemModel = _.clone( options.defaultItemModel ) || { id : '', title : '' };
 
 
1461
  var _initial_model = $.extend( item.defaultItemModel, options.initial_item_model );
 
 
1462
  item.set( _initial_model );
 
 
1463
  item.userEventMap = new api.Value( [
 
1464
  {
1465
  trigger : 'click keydown',
1466
  selector : [ '.' + item.module.control.css_attr.display_alert_btn, '.' + item.module.control.css_attr.cancel_alert_btn ].join(','),
@@ -1471,62 +2010,129 @@ $.extend( CZRItemMths , {
1471
  this.removeDialogVisible( ! _isVisible );
1472
  }
1473
  },
 
1474
  {
1475
  trigger : 'click keydown',
1476
  selector : '.' + item.module.control.css_attr.remove_view_btn,
1477
  name : 'remove_item',
1478
  actions : ['removeItem']
1479
  },
 
1480
  {
1481
  trigger : 'click keydown',
1482
  selector : [ '.' + item.module.control.css_attr.edit_view_btn, '.' + item.module.control.css_attr.item_title ].join(','),
1483
  name : 'edit_view',
1484
  actions : [ 'setViewVisibility' ]
1485
  },
 
1486
  {
1487
  trigger : 'click keydown',
1488
  selector : '.tabs nav li',
1489
  name : 'tab_nav',
1490
  actions : function( args ) {
 
1491
  this.module.toggleTabVisibility.call( this, args );
1492
  }
1493
  }
1494
  ]);
 
 
 
 
 
 
 
1495
  item.isReady.done( function() {
 
1496
  item.module.updateItemsCollection( { item : item() } );
 
1497
  item.callbacks.add( function() { return item.itemReact.apply(item, arguments ); } );
 
 
 
 
1498
  item.bind( 'contentRendered', function() {
 
 
1499
  if ( ! _.has( item, 'czr_Input' ) || _.isEmpty( item.inputCollection() ) ) {
1500
  try {
1501
  api.CZR_Helpers.setupInputCollectionFromDOM.call( item );
 
 
 
1502
  item.module.setupTabNav.call( item );
1503
  } catch( er ) {
1504
  api.errorLog( 'In item.isReady.done : ' + er );
1505
  }
1506
  }
1507
  });
 
 
1508
  item.bind( 'contentRemoved', function() {
1509
  if ( _.has(item, 'czr_Input') )
1510
  api.CZR_Helpers.removeInputCollection.call( item );
1511
  });
 
 
 
 
 
 
 
1512
  item.mayBeRenderItemWrapper();
 
 
 
1513
  item.embedded.done( function() {
 
 
1514
  item.itemWrapperViewSetup( _initial_model );
1515
  });
1516
  });//item.isReady.done()
1517
 
 
 
 
 
 
 
1518
  },//initialize
 
 
 
 
1519
  ready : function() {
1520
  this.isReady.resolve();
1521
  },
 
 
 
 
 
 
 
 
 
 
 
 
1522
  itemReact : function( to, from, data ) {
1523
  var item = this,
1524
  module = item.module;
1525
 
1526
  data = data || {};
 
 
1527
  module.updateItemsCollection( { item : to, data : data } ).done( function() {
 
1528
  item.writeItemViewTitle( to, data );
1529
  });
 
 
 
 
 
 
1530
  }
1531
  });//$.extend
1532
  })( wp.customize , jQuery, _ );//extends api.CZRBaseControl
@@ -1534,48 +2140,72 @@ $.extend( CZRItemMths , {
1534
  var CZRItemMths = CZRItemMths || {};
1535
  ( function ( api, $, _ ) {
1536
  $.extend( CZRItemMths , {
 
 
1537
  _sendItem : function( to, from ) {
1538
  var item = this,
1539
  module = item.module,
1540
  _changed_props = [];
 
 
1541
  _.each( from, function( _val, _key ) {
1542
  if ( _val != to[_key] )
1543
  _changed_props.push(_key);
1544
  });
1545
 
1546
  _.each( _changed_props, function( _prop ) {
1547
- module.control.previewer.send( 'sub_setting', {
1548
  set_id : module.control.id,
1549
  id : to.id,
1550
  changed_prop : _prop,
1551
  value : to[_prop]
1552
  });
 
 
1553
  module.trigger('item_sent', { item : to , dom_el: item.container, changed_prop : _prop } );
1554
  });
1555
  },
 
 
 
1556
  removeItem : function() {
1557
  var item = this,
1558
  module = this.module,
1559
  _new_collection = _.clone( module.itemCollection() );
 
 
1560
  module.trigger('pre_item_dom_remove', item() );
 
 
1561
  item._destroyView();
 
 
 
1562
  _new_collection = _.without( _new_collection, _.findWhere( _new_collection, {id: item.id }) );
1563
  module.itemCollection.set( _new_collection );
 
1564
  module.trigger('pre_item_api_remove', item() );
1565
 
1566
  var _item_ = $.extend( true, {}, item() );
 
1567
  module.czr_Item.remove( item.id );
1568
  module.trigger( 'item-removed', _item_ );
1569
  },
 
 
 
1570
  getModel : function(id) {
1571
  return this();
1572
  }
1573
 
1574
  });//$.extend
1575
  })( wp.customize , jQuery, _ );
 
1576
  var CZRItemMths = CZRItemMths || {};
1577
  ( function ( api, $, _ ) {
1578
  $.extend( CZRItemMths , {
 
 
1579
  mayBeRenderItemWrapper : function() {
1580
  var item = this;
1581
 
@@ -1587,17 +2217,31 @@ $.extend( CZRItemMths , {
1587
  if ( _.isUndefined(item.container) || ! item.container.length ) {
1588
  throw new Error( 'In mayBeRenderItemWrapper the Item view has not been rendered : ' + item.id );
1589
  } else {
 
1590
  item.embedded.resolve();
1591
  }
1592
  });
1593
  },
 
 
 
 
 
1594
  itemWrapperViewSetup : function( item_model ) {
1595
  var item = this,
1596
  module = this.module;
1597
 
1598
  item_model = item() || item.initial_item_model;//could not be set yet
 
 
1599
  item.writeItemViewTitle();
 
 
 
 
 
1600
  var _updateItemContentDeferred = function( $_content, to, from ) {
 
1601
  if ( ! _.isUndefined( $_content ) && false !== $_content.length ) {
1602
  item.trigger( 'contentRendered' );
1603
  item.contentContainer = $_content;
@@ -1610,70 +2254,103 @@ $.extend( CZRItemMths , {
1610
 
1611
  if ( item.module.isMultiItem() ) {
1612
  item.viewState.callbacks.add( function( to, from ) {
 
1613
  var _isExpanded = -1 !== to.indexOf( 'expanded' );
 
 
1614
  if ( module.hasModOpt() && _isExpanded ) {
1615
  api.czr_ModOptVisible( false );
1616
  }
1617
 
1618
  if ( _isExpanded ) {
 
1619
  if ( _.isObject( item.contentContainer ) && false !== item.contentContainer.length ) {
 
1620
  item.toggleItemExpansion(to, from );
1621
  } else {
1622
  $.when( item.renderItemContent( item() || item.initial_item_model ) ).done( function( $_item_content ) {
 
 
1623
  _updateItemContentDeferred = _.debounce(_updateItemContentDeferred, 50 );
1624
  _updateItemContentDeferred( $_item_content, to, from );
1625
  });
1626
  }
1627
  } else {
 
1628
  item.toggleItemExpansion( to, from ).done( function() {
1629
  if ( _.isObject( item.contentContainer ) && false !== item.contentContainer.length ) {
1630
  item.trigger( 'beforeContenRemoved' );
 
1631
  $( '.' + module.control.css_attr.item_content, item.container ).children().each( function() {
1632
  $(this).remove();
1633
  });
 
1634
  $( '.' + module.control.css_attr.item_content, item.container ).html('');
 
1635
  item.contentContainer = null;
 
1636
  item.trigger( 'contentRemoved' );
1637
  }
1638
  });
1639
  }
1640
  });
1641
  } else {
 
1642
  item.viewState.callbacks.add( function( to, from ) {
 
1643
  item.toggleItemExpansion.apply(item, arguments );
1644
  });
 
 
1645
  $.when( item.renderItemContent( item_model ) ).done( function( $_item_content ) {
1646
  _updateItemContentDeferred( $_item_content, true );
 
1647
  });
1648
  }
 
 
1649
  api.CZR_Helpers.setupDOMListeners(
1650
  item.userEventMap(),//actions to execute
1651
  { model:item_model, dom_el:item.container },//model + dom scope
1652
  item //instance where to look for the cb methods
1653
  );
 
 
1654
  item.removeDialogVisible.bind( function( visible ) {
1655
  var module = item.module,
1656
  $_alert_el = $( '.' + module.control.css_attr.remove_alert_wrapper, item.container ).first();
 
 
1657
  if ( visible )
1658
  module.closeAllItems();
 
 
1659
  if ( visible && module.hasModOpt() ) {
1660
  api.czr_ModOptVisible( false );
1661
  }
 
 
1662
  if ( visible && _.has( module, 'preItem' ) ) {
1663
  module.preItemExpanded(false);
1664
  }
 
 
1665
  $('.' + module.control.css_attr.remove_alert_wrapper, item.container ).not( $_alert_el ).each( function() {
1666
  if ( $(this).hasClass( 'open' ) ) {
1667
  $(this).slideToggle( {
1668
  duration : 200,
1669
  done : function() {
1670
  $(this).toggleClass('open' , false );
 
1671
  $(this).siblings().find('.' + module.control.css_attr.display_alert_btn).toggleClass( 'active' , false );
1672
  }
1673
  } );
1674
  }
1675
  });
 
 
1676
  if ( visible ) {
 
1677
  if ( ! wp.template( module.AlertPart ) || ! item.container ) {
1678
  api.consoleLog( 'No removal alert template available for items in module :' + module.id );
1679
  return;
@@ -1681,9 +2358,13 @@ $.extend( CZRItemMths , {
1681
 
1682
  $_alert_el.html( wp.template( module.AlertPart )( { title : ( item().title || item.id ) } ) );
1683
  }
 
 
1684
  var _slideComplete = function( visible ) {
1685
  $_alert_el.toggleClass( 'open' , visible );
 
1686
  item.container.find('.' + module.control.css_attr.display_alert_btn ).toggleClass( 'active', visible );
 
1687
  if ( visible )
1688
  module._adjustScrollExpandedBlock( item.container );
1689
  };
@@ -1693,40 +2374,78 @@ $.extend( CZRItemMths , {
1693
  $_alert_el.stop( true, true ).slideUp( 200, function() { _slideComplete( visible ); } );
1694
  });//item.removeDialogVisible.bind()
1695
  },//itemWrapperViewSetup
 
 
 
 
 
1696
  renderItemWrapper : function( item_model ) {
 
1697
  var item = this,
1698
  module = item.module;
1699
 
1700
  item_model = item_model || item();
 
 
1701
  $_view_el = $('<li>', { class : module.control.css_attr.single_item, 'data-id' : item_model.id, id : item_model.id } );
 
 
 
 
 
1702
  module.itemsWrapper.append( $_view_el );
 
 
 
1703
  if ( module.isMultiItem() ) {
1704
  var _template_selector = module.getTemplateEl( 'rudItemPart', item_model );
 
1705
  if ( 0 === $( '#tmpl-' + _template_selector ).length ) {
1706
  throw new Error('Missing template for item ' + item.id + '. The provided template script has no been found : #tmpl-' + module.getTemplateEl( 'rudItemPart', item_model ) );
1707
  }
1708
  $_view_el.append( $( wp.template( _template_selector )( item_model ) ) );
1709
  }
 
 
 
1710
  $_view_el.append( $( '<div/>', { class: module.control.css_attr.item_content } ) );
1711
 
1712
  return $_view_el;
1713
  },
 
 
 
 
 
1714
  renderItemContent : function( item_model ) {
 
1715
  var item = this,
1716
  module = this.module;
1717
 
1718
  item_model = item_model || item();
 
 
1719
  if ( 0 === $( '#tmpl-' + module.getTemplateEl( 'itemInputList', item_model ) ).length ) {
1720
  throw new Error('No item content template defined for module ' + module.id + '. The template script id should be : #tmpl-' + module.getTemplateEl( 'itemInputList', item_model ) );
1721
  }
1722
 
1723
  var item_content_template = wp.template( module.getTemplateEl( 'itemInputList', item_model ) );
 
 
1724
  if ( ! item_content_template )
1725
  return this;
 
 
1726
  $( item_content_template( item_model )).appendTo( $('.' + module.control.css_attr.item_content, item.container ) );
1727
 
1728
  return $( $( item_content_template( item_model )), item.container );
1729
  },
 
 
 
 
 
 
1730
  writeItemViewTitle : function( item_model ) {
1731
  var item = this,
1732
  module = item.module,
@@ -1735,8 +2454,15 @@ $.extend( CZRItemMths , {
1735
 
1736
  _title = api.CZR_Helpers.truncate( _title, 20 );
1737
  $( '.' + module.control.css_attr.item_title , item.container ).text( _title );
 
1738
  api.CZR_Helpers.doActions('after_writeViewTitle', item.container , _model, item );
1739
  },
 
 
 
 
 
 
1740
  setViewVisibility : function( obj, is_added_by_user ) {
1741
  var item = this,
1742
  module = this.module;
@@ -1755,6 +2481,10 @@ $.extend( CZRItemMths , {
1755
  _getViewState : function() {
1756
  return -1 == this.viewState().indexOf('expanded') ? 'closed' : 'expanded';
1757
  },
 
 
 
 
1758
  toggleItemExpansion : function( status, from, duration ) {
1759
  var visible = 'closed' != status,
1760
  item = this,
@@ -1763,8 +2493,12 @@ $.extend( CZRItemMths , {
1763
  dfd = $.Deferred(),
1764
  _slideComplete = function( visible ) {
1765
  item.container.toggleClass( 'open' , visible );
 
1766
  if ( visible )
1767
  module.closeRemoveDialogs();
 
 
 
1768
  var $_edit_icon = $el.siblings().find('.' + module.control.css_attr.edit_view_btn );
1769
 
1770
  $_edit_icon.toggleClass('active' , visible );
@@ -1772,6 +2506,8 @@ $.extend( CZRItemMths , {
1772
  $_edit_icon.removeClass('fa-pencil').addClass('fa-minus-square').attr('title', serverControlParams.i18n.close );
1773
  else
1774
  $_edit_icon.removeClass('fa-minus-square').addClass('fa-pencil').attr('title', serverControlParams.i18n.edit );
 
 
1775
  if ( 'expanded' == status )
1776
  module._adjustScrollExpandedBlock( item.container );
1777
 
@@ -1785,6 +2521,9 @@ $.extend( CZRItemMths , {
1785
 
1786
  return dfd.promise();
1787
  },
 
 
 
1788
  _destroyView : function ( duration ) {
1789
  this.container.fadeOut( {
1790
  duration : duration ||400,
@@ -1795,6 +2534,11 @@ $.extend( CZRItemMths , {
1795
  }
1796
  });//$.extend
1797
  })( wp.customize , jQuery, _ );//extends api.Value
 
 
 
 
 
1798
 
1799
  var CZRModOptMths = CZRModOptMths || {};
1800
  ( function ( api, $, _ ) {
@@ -1806,18 +2550,42 @@ $.extend( CZRModOptMths , {
1806
 
1807
  var modOpt = this;
1808
  api.Value.prototype.initialize.call( modOpt, null, options );
 
 
 
 
1809
  modOpt.isReady = $.Deferred();
 
 
1810
  modOpt.container = null;//will store the modOpt $ dom element
1811
  modOpt.inputCollection = new api.Value({});
 
 
 
1812
  $.extend( modOpt, options || {} );
 
 
1813
  modOpt.defaultModOptModel = _.clone( options.defaultModOptModel ) || { is_mod_opt : true };
 
 
1814
  var _initial_model = $.extend( modOpt.defaultModOptModel, options.initial_modOpt_model );
1815
  var ctrl = modOpt.module.control;
 
1816
  modOpt.set( _initial_model );
 
 
1817
  api.czr_ModOptVisible = new api.Value( false );
 
 
 
 
 
 
 
1818
  api.czr_ModOptVisible.bind( function( visible, from, args ) {
1819
  args = args || {};
1820
  if ( visible ) {
 
1821
  modOpt.module.closeRemoveDialogs().closeAllItems();
1822
 
1823
  modOpt.modOptWrapperViewSetup( _initial_model ).done( function( $_container ) {
@@ -1849,7 +2617,19 @@ $.extend( CZRModOptMths , {
1849
  });
1850
  }
1851
  } );
 
 
 
1852
  modOpt.isReady.done( function() {
 
 
 
 
 
 
 
 
 
1853
  if( ! $( '.' + ctrl.css_attr.edit_modopt_icon, ctrl.container ).length ) {
1854
  $.when( ctrl.container
1855
  .find('.customize-control-title').first()//was.find('.customize-control-title')
@@ -1861,8 +2641,11 @@ $.extend( CZRModOptMths , {
1861
  $( '.' + ctrl.css_attr.edit_modopt_icon, ctrl.container ).fadeIn( 400 );
1862
  });
1863
  }
 
 
1864
  api.CZR_Helpers.setupDOMListeners(
1865
  [
 
1866
  {
1867
  trigger : 'click keydown',
1868
  selector : '.' + ctrl.css_attr.edit_modopt_icon,
@@ -1875,9 +2658,14 @@ $.extend( CZRModOptMths , {
1875
  { dom_el: ctrl.container },//dom scope
1876
  modOpt //instance where to look for the cb methods
1877
  );
 
1878
  });//modOpt.isReady.done()
1879
 
1880
  },//initialize
 
 
 
 
1881
  ready : function() {
1882
  this.isReady.resolve();
1883
  }
@@ -1887,13 +2675,18 @@ $.extend( CZRModOptMths , {
1887
  var CZRModOptMths = CZRModOptMths || {};
1888
  ( function ( api, $, _ ) {
1889
  $.extend( CZRModOptMths , {
 
 
 
1890
  modOptWrapperViewSetup : function( modOpt_model ) {
1891
  var modOpt = this,
1892
  module = this.module,
1893
  dfd = $.Deferred(),
1894
  _setupDOMListeners = function( $_container ) {
 
1895
  api.CZR_Helpers.setupDOMListeners(
1896
  [
 
1897
  {
1898
  trigger : 'click keydown',
1899
  selector : '.' + module.control.css_attr.close_modopt_icon,
@@ -1902,11 +2695,13 @@ $.extend( CZRModOptMths , {
1902
  api.czr_ModOptVisible( false );
1903
  }
1904
  },
 
1905
  {
1906
  trigger : 'click keydown',
1907
  selector : '.tabs nav li',
1908
  name : 'tab_nav',
1909
  actions : function( args ) {
 
1910
  this.module.toggleTabVisibility.call( this, args );
1911
  }
1912
  }
@@ -1917,8 +2712,11 @@ $.extend( CZRModOptMths , {
1917
  };
1918
 
1919
  modOpt_model = modOpt() || modOpt.initial_modOpt_model;//could not be set yet
 
 
1920
  $.when( modOpt.renderModOptContent( modOpt_model ) )
1921
  .done( function( $_container ) {
 
1922
  if ( ! _.isUndefined( $_container ) && false !== $_container.length ) {
1923
  _setupDOMListeners( $_container );
1924
  dfd.resolve( $_container );
@@ -1928,21 +2726,34 @@ $.extend( CZRModOptMths , {
1928
  }
1929
  })
1930
  .then( function() {
 
 
 
1931
  modOpt.module.setupTabNav.call( modOpt );
1932
  });
1933
 
1934
  return dfd.promise();
1935
  },
 
 
 
 
 
1936
  renderModOptContent : function( modOpt_model ) {
 
1937
  var modOpt = this,
1938
  module = this.module;
1939
 
1940
  modOpt_model = modOpt_model || modOpt();
 
 
1941
  if ( 0 === $( '#tmpl-' + module.getTemplateEl( 'modOptInputList', modOpt_model ) ).length ) {
1942
  api.errorLog('renderModOptContent : No modOpt content template defined for module ' + module.id + '. The template script id should be : #tmpl-' + module.getTemplateEl( 'modOptInputList', modOpt_model ) );
1943
  return;
1944
  }
1945
  var modOpt_content_template = wp.template( module.getTemplateEl( 'modOptInputList', modOpt_model ) );
 
 
1946
  if ( ! modOpt_content_template )
1947
  return this;
1948
 
@@ -1961,6 +2772,8 @@ $.extend( CZRModOptMths , {
1961
  '<span class="fa fa-times ' + module.control.css_attr.close_modopt_icon + '" title="close"></span>'
1962
  ].join('')
1963
  } ) );
 
 
1964
  $( '.' + module.control.css_attr.mod_opt_wrapper ).append( $( modOpt_content_template( modOpt_model ) ) );
1965
 
1966
  return $( '.' + module.control.css_attr.mod_opt_wrapper );
@@ -1976,6 +2789,7 @@ $.extend( CZRModOptMths , {
1976
 
1977
  module.control.container.toggleClass( 'czr-modopt-visible', visible );
1978
  $('body').toggleClass('czr-editing-modopt', visible );
 
1979
  _.delay( function() {
1980
  dfd.resolve();
1981
  }, 200 );
@@ -1983,6 +2797,21 @@ $.extend( CZRModOptMths , {
1983
  }
1984
  });//$.extend
1985
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1986
  var CZRModuleMths = CZRModuleMths || {};
1987
  ( function ( api, $, _ ) {
1988
  $.extend( CZRModuleMths, {
@@ -1992,8 +2821,15 @@ $.extend( CZRModuleMths, {
1992
  }
1993
  var module = this;
1994
  api.Value.prototype.initialize.call( this, null, constructorOptions );
 
 
 
1995
  module.isReady = $.Deferred();
 
 
1996
  $.extend( module, constructorOptions || {} );
 
 
1997
  $.extend( module, {
1998
  crudModulePart : 'czr-crud-module-part',//create, read, update, delete
1999
  rudItemPart : 'czr-rud-item-part',//read, update, delete
@@ -2003,17 +2839,25 @@ $.extend( CZRModuleMths, {
2003
  AlertPart : 'czr-rud-item-alert-part',//used both for items and modules removal
2004
 
2005
  } );
 
 
2006
  module.embedded = $.Deferred();
2007
  module.itemsWrapper = '';//will store the $ item container
 
 
 
2008
  if ( ! module.isInSektion() ) {
2009
  module.container = $( module.control.selector );
2010
  module.embedded.resolve();
2011
  }
 
 
2012
  module.embedded.done( function() {
2013
  $.when( module.renderModuleParts() ).done(function( $_module_items_wrapper ){
2014
  if ( false === $_module_items_wrapper.length ) {
2015
  throw new Error( 'The items wrapper has not been rendered for module : ' + module.id );
2016
  }
 
2017
  module.itemsWrapper = $_module_items_wrapper;
2018
  });
2019
  });
@@ -2021,19 +2865,26 @@ $.extend( CZRModuleMths, {
2021
  /*-----------------------------------------------
2022
  * MODULE OPTIONS
2023
  ------------------------------------------------*/
 
2024
  module.defaultAPImodOptModel = {
2025
  initial_modOpt_model : {},
2026
  defaultModOptModel : {},
2027
  control : {},//control instance
2028
  module : {}//module instance
2029
  };
 
 
2030
  module.defaultModOptModel = {};
 
 
2031
  module.modOptConstructor = api.CZRModOpt;
2032
 
2033
  /*-----------------------------------------------
2034
  * ITEMS
2035
  ------------------------------------------------*/
2036
  module.itemCollection = new api.Value( [] );
 
 
2037
  module.defaultAPIitemModel = {
2038
  id : '',
2039
  initial_item_model : {},
@@ -2042,8 +2893,13 @@ $.extend( CZRModuleMths, {
2042
  module : {},//module instance
2043
  is_added_by_user : false
2044
  };
 
 
2045
  module.defaultItemModel = { id : '', title : '' };
 
 
2046
  module.itemConstructor = api.CZRItem;
 
2047
  module.czr_Item = new api.Values();
2048
 
2049
 
@@ -2055,45 +2911,83 @@ $.extend( CZRModuleMths, {
2055
  module.inputModOptConstructor = api.CZRInput;//constructor for the modOpt input
2056
  }
2057
  module.inputOptions = {};//<= can be set by each module specifically
 
2058
 
2059
 
2060
  /*-----------------------------------------------
2061
  * FIRE ON isReady
2062
  ------------------------------------------------*/
 
2063
  module.isReady.done( function() {
 
2064
  module.isDirty = new api.Value( constructorOptions.dirty || false );
 
 
 
 
2065
  module.initializeModuleModel( constructorOptions )
2066
  .done( function( initialModuleValue ) {
2067
  module.set( initialModuleValue );
2068
  })
2069
  .fail( function( response ){ api.consoleLog( 'Module : ' + module.id + ' initialize module model failed : ', response ); })
2070
  .always( function( initialModuleValue ) {
 
2071
  module.callbacks.add( function() { return module.moduleReact.apply( module, arguments ); } );
 
 
 
 
2072
  if ( ! module.control.isModuleRegistered( module.id ) ) {
2073
  module.control.updateModulesCollection( { module : constructorOptions, is_registered : false } );
2074
  }
2075
 
2076
  module.bind('items-collection-populated', function( collection ) {
 
2077
  module.itemCollection.callbacks.add( function() { return module.itemCollectionReact.apply( module, arguments ); } );
 
 
2078
  if ( module.isMultiItem() ) {
2079
  module._makeItemsSortable();
2080
  }
2081
  });
 
 
 
2082
  if ( ! module.isInSektion() )
2083
  module.populateSavedItemCollection();
 
 
 
2084
  if ( module.hasModOpt() ) {
2085
  module.instantiateModOpt();
2086
  }
2087
  });
2088
  });//module.isReady.done()
2089
  },
 
 
 
 
 
 
 
 
 
 
2090
  ready : function() {
2091
  var module = this;
2092
  module.isReady.resolve();
2093
  },
 
 
 
 
 
2094
  initializeModuleModel : function( constructorOptions ) {
2095
  var module = this, dfd = $.Deferred();
2096
  if ( ! module.isMultiItem() && ! module.isCrud() ) {
 
 
2097
  if ( _.isEmpty( constructorOptions.items ) ) {
2098
  var def = _.clone( module.defaultItemModel );
2099
  constructorOptions.items = [ $.extend( def, { id : module.id } ) ];
@@ -2101,37 +2995,75 @@ $.extend( CZRModuleMths, {
2101
  }
2102
  return dfd.resolve( constructorOptions ).promise();
2103
  },
 
 
 
 
 
 
 
 
 
 
 
2104
  itemCollectionReact : function( to, from, data ) {
2105
  var module = this,
2106
  _current_model = module(),
2107
  _new_model = $.extend( true, {}, _current_model );
2108
  _new_model.items = to;
 
2109
  module.isDirty.set(true);
 
2110
  module.set( _new_model, data || {} );
2111
  },
 
 
 
2112
  moduleReact : function( to, from, data ) {
 
2113
  var module = this,
2114
  control = module.control,
2115
  isItemUpdate = ( _.size( from.items ) == _.size( to.items ) ) && ! _.isEmpty( _.difference( to.items, from.items ) ),
2116
  isColumnUpdate = to.column_id != from.column_id,
2117
  refreshPreview = function() {
2118
- module.control.previewer.refresh();
2119
  };
 
 
2120
  control.updateModulesCollection( {
2121
  module : $.extend( true, {}, to ),
2122
  data : data//useful to pass contextual info when a change happens
2123
  } );
 
 
 
 
 
 
 
 
 
2124
  },
 
 
2125
  getModuleSection : function() {
2126
  return this.section;
2127
  },
 
 
2128
  isInSektion : function() {
2129
  var module = this;
2130
  return _.has( module, 'sektion_id' );
2131
  },
 
 
 
2132
  isMultiItem : function() {
2133
  return api.CZR_Helpers.isMultiItemModule( null, this );
2134
  },
 
 
 
2135
  isCrud : function() {
2136
  return api.CZR_Helpers.isCrudModule( null, this );
2137
  },
@@ -2139,28 +3071,60 @@ $.extend( CZRModuleMths, {
2139
  hasModOpt : function() {
2140
  return api.CZR_Helpers.hasModuleModOpt( null, this );
2141
  },
 
 
 
 
 
 
 
 
 
2142
  instantiateModOpt : function() {
2143
  var module = this;
 
2144
  var modOpt_candidate = module.prepareModOptForAPI( module().modOpt || {} );
2145
  module.czr_ModOpt = new module.modOptConstructor( modOpt_candidate );
2146
  module.czr_ModOpt.ready();
 
2147
  module.czr_ModOpt.callbacks.add( function( to, from, data ) {
2148
  var _current_model = module(),
2149
  _new_model = $.extend( true, {}, _current_model );
2150
  _new_model.modOpt = to;
 
2151
  module.isDirty(true);
 
 
 
 
 
 
 
 
 
2152
  module( _new_model, data );
2153
  });
2154
  },
 
 
 
 
 
 
 
2155
  prepareModOptForAPI : function( modOpt_candidate ) {
2156
  var module = this,
2157
  api_ready_modOpt = {};
 
 
 
2158
  modOpt_candidate = _.isObject( modOpt_candidate ) ? modOpt_candidate : {};
2159
 
2160
  _.each( module.defaultAPImodOptModel, function( _value, _key ) {
2161
  var _candidate_val = modOpt_candidate[_key];
2162
  switch( _key ) {
2163
  case 'initial_modOpt_model' :
 
2164
  _.each( module.getDefaultModOptModel() , function( _value, _property ) {
2165
  if ( ! _.has( modOpt_candidate, _property) )
2166
  modOpt_candidate[_property] = _value;
@@ -2181,12 +3145,29 @@ $.extend( CZRModuleMths, {
2181
  });
2182
  return api_ready_modOpt;
2183
  },
 
 
 
2184
  getDefaultModOptModel : function( id ) {
2185
  var module = this;
2186
  return $.extend( _.clone( module.defaultModOptModel ), { is_mod_opt : true } );
2187
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
2188
  sendInputToPreview : function( args ) {
2189
  var module = this;
 
2190
  args = _.extend(
2191
  {
2192
  input_id : '',
@@ -2197,7 +3178,9 @@ $.extend( CZRModuleMths, {
2197
 
2198
  if ( _.isEqual( args.to, args.from ) )
2199
  return;
2200
- module.control.previewer.send( 'czr_input', {
 
 
2201
  set_id : api.CZR_Helpers.getControlSettingId( module.control.id ),
2202
  module_id : module.id,//<= will allow us to target the right dom element on front end
2203
  module : { items : $.extend( true, {}, module().items ) , modOpt : module.hasModOpt() ? $.extend( true, {}, module().modOpt ): {} },
@@ -2206,13 +3189,24 @@ $.extend( CZRModuleMths, {
2206
  value : args.to,
2207
  isPartialRefresh : args.isPartialRefresh//<= let us know if it is a full wrapper refresh or a single input update ( true when fired from sendModuleInputsToPreview )
2208
  });
 
 
2209
  module.trigger( 'input_sent', { input : args.to , dom_el: module.container } );
2210
  },
 
 
 
 
 
 
 
 
2211
  sendModuleInputsToPreview : function( args ) {
2212
  var module = this,
2213
  _sendInputData = function() {
2214
  var inputParent = this,//this is the input parent : item or modOpt
2215
  inputParentModel = $.extend( true, {}, inputParent() );
 
2216
  inputParentModel = _.omit( inputParentModel, 'id' );
2217
 
2218
  _.each( inputParentModel, function( inputVal, inputId ) {
@@ -2236,26 +3230,60 @@ $.extend( CZRModuleMths, {
2236
  }
2237
  });//$.extend//CZRBaseControlMths
2238
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
 
 
 
 
 
2239
 
2240
  var CZRModuleMths = CZRModuleMths || {};
2241
  ( function ( api, $, _ ) {
2242
  $.extend( CZRModuleMths, {
 
 
2243
  populateSavedItemCollection : function() {
2244
  var module = this, _saved_items = [];
2245
  if ( ! _.isArray( module().items ) ) {
2246
  api.errorLog( 'populateSavedItemCollection : The saved items collection must be an array in module :' + module.id );
2247
  return;
2248
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2249
  _.each( module().items, function( item_candidate , key ) {
2250
  if ( _.has( item_candidate, 'id') && ! _.has( item_candidate, 'is_mod_opt' ) ) {
2251
  _saved_items.push( item_candidate );
2252
  }
2253
  });
 
 
2254
  _.each( _saved_items, function( item_candidate , key ) {
 
2255
  try { module.instantiateItem( item_candidate ).ready(); } catch( er ) {
2256
  api.errorLog( 'populateSavedItemCollection : ' + er );
2257
  }
2258
  });
 
 
2259
  _.each( _saved_items, function( _item ) {
2260
  if ( _.isUndefined( _.findWhere( module.itemCollection(), _item.id ) ) ) {
2261
  throw new Error( 'populateSavedItemCollection : The saved items have not been properly populated in module : ' + module.id );
@@ -2263,28 +3291,48 @@ $.extend( CZRModuleMths, {
2263
  });
2264
 
2265
  module.trigger( 'items-collection-populated' );
 
 
2266
  },
2267
 
2268
 
2269
  instantiateItem : function( item, is_added_by_user ) {
2270
  var module = this;
 
2271
  item_candidate = module.prepareItemForAPI( item );
 
2272
  if ( ! _.has( item_candidate, 'id' ) ) {
2273
  throw new Error('CZRModule::instantiateItem() : an item has no id and could not be added in the collection of : ' + this.id );
2274
  }
2275
  if ( module.czr_Item.has( item_candidate.id ) ) {
2276
  throw new Error('CZRModule::instantiateItem() : the following item id ' + item_candidate.id + ' already exists in module.czr_Item() for module ' + this.id );
2277
  }
 
2278
  module.czr_Item.add( item_candidate.id, new module.itemConstructor( item_candidate.id, item_candidate ) );
2279
 
2280
  if ( ! module.czr_Item.has( item_candidate.id ) ) {
2281
  throw new Error('CZRModule::instantiateItem() : instantiation failed for item id ' + item_candidate.id + ' for module ' + this.id );
2282
  }
 
 
2283
  return module.czr_Item( item_candidate.id );
2284
  },
 
 
 
 
 
 
 
 
 
 
2285
  prepareItemForAPI : function( item_candidate ) {
2286
  var module = this,
2287
  api_ready_item = {};
 
 
 
2288
  item_candidate = _.isObject( item_candidate ) ? item_candidate : {};
2289
 
2290
  _.each( module.defaultAPIitemModel, function( _value, _key ) {
@@ -2298,6 +3346,7 @@ $.extend( CZRModuleMths, {
2298
  }
2299
  break;
2300
  case 'initial_item_model' :
 
2301
  _.each( module.getDefaultItemModel() , function( _value, _property ) {
2302
  if ( ! _.has( item_candidate, _property) )
2303
  item_candidate[_property] = _value;
@@ -2319,14 +3368,22 @@ $.extend( CZRModuleMths, {
2319
  break;
2320
  }//switch
2321
  });
 
 
2322
  if ( ! _.has( api_ready_item, 'id' ) ) {
2323
  api_ready_item.id = module.generateItemId( module.module_type );
2324
  }
 
 
2325
  api_ready_item.initial_item_model.id = api_ready_item.id;
2326
 
2327
  return api_ready_item;
2328
  },
 
 
 
2329
  generateItemId : function( module_type, key, i ) {
 
2330
  i = i || 1;
2331
  if ( i > 100 ) {
2332
  throw new Error( 'Infinite loop when generating of a module id.' );
@@ -2334,19 +3391,31 @@ $.extend( CZRModuleMths, {
2334
  var module = this;
2335
  key = key || module._getNextItemKeyInCollection();
2336
  var id_candidate = module_type + '_' + key;
 
 
2337
  if ( ! _.has(module, 'itemCollection') || ! _.isArray( module.itemCollection() ) ) {
2338
  throw new Error('The item collection does not exist or is not properly set in module : ' + module.id );
2339
  }
 
 
2340
  if ( module.isItemRegistered( id_candidate ) ) {
2341
  key++; i++;
2342
  return module.generateItemId( module_type, key, i );
2343
  }
2344
  return id_candidate;
2345
  },
 
 
 
 
2346
  _getNextItemKeyInCollection : function() {
2347
  var module = this,
2348
  _maxItem = {},
2349
  _next_key = 0;
 
 
 
 
2350
  if ( _.isEmpty( module.itemCollection() ) )
2351
  return _next_key;
2352
  if ( _.isArray( module.itemCollection() ) && 1 === _.size( module.itemCollection() ) ) {
@@ -2358,21 +3427,57 @@ $.extend( CZRModuleMths, {
2358
  return parseInt( _item.id.replace( /[^\/\d]/g, '' ), 10 );
2359
  });
2360
  }
 
 
2361
  if ( ! _.isUndefined( _maxItem ) && _.isNumber( _maxItem.id.replace(/[^\/\d]/g,'') ) ) {
2362
  _next_key = parseInt( _maxItem.id.replace(/[^\/\d]/g,''), 10 ) + 1;
2363
  }
2364
  return _next_key;
2365
  },
 
 
 
 
 
2366
  isItemRegistered : function( id_candidate ) {
2367
  var module = this;
2368
  return ! _.isUndefined( _.findWhere( module.itemCollection(), { id : id_candidate}) );
2369
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2370
  updateItemsCollection : function( args ) {
2371
  var module = this,
2372
  _current_collection = module.itemCollection(),
2373
  _new_collection = _.clone(_current_collection),
2374
  dfd = $.Deferred();
 
 
 
2375
  if ( _.has( args, 'collection' ) ) {
 
2376
  module.itemCollection.set( args.collection );
2377
  return;
2378
  }
@@ -2380,29 +3485,46 @@ $.extend( CZRModuleMths, {
2380
  if ( ! _.has( args, 'item' ) ) {
2381
  throw new Error('updateItemsCollection, no item provided ' + module.control.id + '. Aborting');
2382
  }
 
2383
  args = _.extend( { data : {} }, args );
2384
 
2385
  var item = _.clone( args.item );
 
 
2386
  if ( _.findWhere( _new_collection, { id : item.id } ) ) {
2387
  _.each( _current_collection , function( _item, _ind ) {
2388
  if ( _item.id != item.id )
2389
  return;
 
 
2390
  _new_collection[_ind] = item;
2391
  });
2392
  }
 
2393
  else {
2394
  _new_collection.push(item);
2395
  }
 
 
 
2396
  module.itemCollection.set( _new_collection, args.data );
2397
  return dfd.resolve( { collection : _new_collection, data : args.data } ).promise();
2398
  },
 
 
 
 
 
2399
  _getSortedDOMItemCollection : function( ) {
2400
  var module = this,
2401
  _old_collection = _.clone( module.itemCollection() ),
2402
  _new_collection = [],
2403
  dfd = $.Deferred();
 
 
2404
  $( '.' + module.control.css_attr.single_item, module.container ).each( function( _index ) {
2405
  var _item = _.findWhere( _old_collection, {id: $(this).attr('data-id') });
 
2406
  if ( ! _item )
2407
  return;
2408
 
@@ -2414,30 +3536,61 @@ $.extend( CZRModuleMths, {
2414
  }
2415
  return dfd.resolve( _new_collection ).promise();
2416
  },
 
 
 
 
 
 
 
 
 
 
2417
  refreshItemCollection : function() {
2418
  var module = this;
 
2419
  module.czr_Item.each( function( _itm ) {
2420
  $.when( module.czr_Item( _itm.id ).container.remove() ).done( function() {
 
2421
  module.czr_Item.remove( _itm.id );
2422
  });
2423
  });
 
 
 
2424
  module.itemCollection = new api.Value( [] );
2425
  module.populateSavedItemCollection();
2426
  }
2427
  });//$.extend//CZRBaseControlMths
2428
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
 
 
 
 
 
2429
 
2430
  var CZRModuleMths = CZRModuleMths || {};
2431
  ( function ( api, $, _ ) {
2432
  $.extend( CZRModuleMths, {
 
 
2433
  getDefaultItemModel : function( id ) {
2434
  var module = this;
2435
  return $.extend( _.clone( module.defaultItemModel ), { id : id || '' } );
2436
  },
 
 
 
 
 
 
 
2437
  _initNewItem : function( _item , _next_key ) {
2438
  var module = this,
2439
  _new_item = { id : '' },
2440
  _id;
 
 
2441
  _next_key = 'undefined' != typeof(_next_key) ? _next_key : _.size( module.itemCollection() );
2442
 
2443
  if ( _.isNumber(_next_key) ) {
@@ -2445,6 +3598,7 @@ $.extend( CZRModuleMths, {
2445
  }
2446
  else {
2447
  _id = _next_key;
 
2448
  _next_key = 0;
2449
  }
2450
 
@@ -2452,7 +3606,10 @@ $.extend( CZRModuleMths, {
2452
  _new_item = $.extend( _item, { id : _id } );
2453
  else
2454
  _new_item = this.getDefaultItemModel( _id );
 
 
2455
  if ( _.has(_new_item, 'id') && module._isItemIdPossible(_id) ) {
 
2456
  _.map( module.getDefaultItemModel() , function( value, property ){
2457
  if ( ! _.has(_new_item, property) )
2458
  _new_item[property] = value;
@@ -2460,21 +3617,35 @@ $.extend( CZRModuleMths, {
2460
 
2461
  return _new_item;
2462
  }
 
 
2463
  return module._initNewItem( _new_item, _next_key + 1);
2464
  }
2465
  });//$.extend
2466
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
 
 
 
 
 
2467
 
2468
  var CZRModuleMths = CZRModuleMths || {};
2469
  ( function ( api, $, _ ) {
2470
  $.extend( CZRModuleMths, {
 
 
2471
  renderModuleParts : function() {
2472
  var module = this,
2473
  $_moduleContentEl = module.isInSektion() ? $( module.container ).find('.czr-mod-content') : $( module.container );
 
 
2474
  if ( module.isCrud() ) {
 
2475
  if ( 0 === $( '#tmpl-' + module.crudModulePart ).length ) {
2476
  throw new Error('No crud Module Part template for module ' + module.id + '. The template script id should be : #tmpl-' + module.crudModulePart );
2477
  }
 
 
2478
  $_moduleContentEl.append( $( wp.template( module.crudModulePart )( {} ) ) );
2479
  }
2480
  var $_module_items_wrapper = $(
@@ -2493,6 +3664,15 @@ $.extend( CZRModuleMths, {
2493
 
2494
  return $( $_module_items_wrapper, $_moduleContentEl );
2495
  },
 
 
 
 
 
 
 
 
 
2496
  getTemplateEl : function( type, item_model ) {
2497
  var module = this, _el;
2498
  switch(type) {
@@ -2515,10 +3695,17 @@ $.extend( CZRModuleMths, {
2515
  return _el;
2516
  }
2517
  },
 
 
 
2518
  getViewEl : function( id ) {
2519
  var module = this;
2520
  return $( '[data-id = "' + id + '"]', module.container );
2521
  },
 
 
 
 
2522
  closeAllItems : function( id ) {
2523
  var module = this,
2524
  _current_collection = _.clone( module.itemCollection() ),
@@ -2530,6 +3717,10 @@ $.extend( CZRModuleMths, {
2530
  } );
2531
  return this;
2532
  },
 
 
 
 
2533
  _adjustScrollExpandedBlock : function( $_block_el, adjust ) {
2534
  if ( ! $_block_el.length || _.isUndefined( this.getModuleSection() ) )
2535
  return;
@@ -2550,6 +3741,11 @@ $.extend( CZRModuleMths, {
2550
  }
2551
  }, 50);
2552
  },
 
 
 
 
 
2553
  closeRemoveDialogs : function() {
2554
  var module = this;
2555
  if ( ! _.isArray( module.itemCollection() ) )
@@ -2558,8 +3754,24 @@ $.extend( CZRModuleMths, {
2558
  module.czr_Item.each( function( _item_ ) {
2559
  _item_.removeDialogVisible( false );
2560
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
2561
  return this;
2562
  },
 
 
 
2563
  _makeItemsSortable : function(obj) {
2564
  if ( wp.media.isTouchDevice || ! $.fn.sortable )
2565
  return;
@@ -2567,8 +3779,10 @@ $.extend( CZRModuleMths, {
2567
  $( '.' + module.control.css_attr.items_wrapper, module.container ).sortable( {
2568
  handle: '.' + module.control.css_attr.item_sort_handle,
2569
  start: function() {
 
2570
  if ( _.has(api, 'czrModulePanelState' ) )
2571
  api.czrModulePanelState.set(false);
 
2572
  if ( _.has(api, 'czrSekSettingsPanelState' ) )
2573
  api.czrSekSettingsPanelState.set(false);
2574
  },
@@ -2582,6 +3796,10 @@ $.extend( CZRModuleMths, {
2582
  var refreshPreview = function() {
2583
  api.previewer.refresh();
2584
  };
 
 
 
 
2585
  if ( 'postMessage' == api(module.control.id).transport && ! api.CZR_Helpers.hasPartRefresh( module.control.id ) ) {
2586
  refreshPreview = _.debounce( refreshPreview, 500 );//500ms are enough
2587
  refreshPreview();
@@ -2596,6 +3814,10 @@ $.extend( CZRModuleMths, {
2596
  .then( function() {
2597
  _sortedCollectionReact();
2598
  });
 
 
 
 
2599
  }//update
2600
  }
2601
  );
@@ -2606,6 +3828,11 @@ $.extend( CZRModuleMths, {
2606
  /*-----------------------------------------------
2607
  * TABS NAVIGATION IN ITEMS AND MODOPT
2608
  ------------------------------------------------*/
 
 
 
 
 
2609
  toggleTabVisibility : function( args ) {
2610
  var inputParent = this,
2611
  tabs = $( inputParent.container ).find('li'),
@@ -2622,6 +3849,11 @@ $.extend( CZRModuleMths, {
2622
  });
2623
  $( inputParent.container ).find('section[id="' + tabIdSwitchedTo + '"]').addClass('content-current');
2624
  },
 
 
 
 
 
2625
  setupTabNav : function() {
2626
  var inputParent = this,
2627
  preProcessTabs = function() {
@@ -2633,6 +3865,7 @@ $.extend( CZRModuleMths, {
2633
  });
2634
  $tabs.first().addClass( 'tab-current' ).removeClass('tab-inactive');
2635
  $( 'section', inputParent.container ).first().addClass( 'content-current' );
 
2636
  var _nb = $tabs.length;
2637
  $tabs.each( function() {
2638
  $(this).addClass( _nb > 0 ? 'cols-' + _nb : '' );
@@ -2650,6 +3883,11 @@ $.extend( CZRModuleMths, {
2650
  }
2651
  });//$.extend
2652
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
 
 
 
 
 
2653
 
2654
  var CZRDynModuleMths = CZRDynModuleMths || {};
2655
  ( function ( api, $, _ ) {
@@ -2657,19 +3895,33 @@ $.extend( CZRDynModuleMths, {
2657
  initialize: function( id, options ) {
2658
  var module = this;
2659
  api.CZRModule.prototype.initialize.call( module, id, options );
 
 
2660
  $.extend( module, {
2661
  itemPreAddEl : ''//is specific for each crud module
2662
  } );
2663
 
2664
  module.preItemsWrapper = '';//will store the pre items wrapper
 
 
 
 
 
 
2665
  module.itemAddedMessage = serverControlParams.i18n.successMessage;
 
 
 
 
2666
  module.userEventMap = new api.Value( [
 
2667
  {
2668
  trigger : 'click keydown',
2669
  selector : [ '.' + module.control.css_attr.open_pre_add_btn, '.' + module.control.css_attr.cancel_pre_add_btn ].join(','),
2670
  name : 'pre_add_item',
2671
  actions : [ 'closeAllItems', 'closeRemoveDialogs', 'renderPreItemView','setPreItemViewVisibility' ],
2672
  },
 
2673
  {
2674
  trigger : 'click keydown',
2675
  selector : '.' + module.control.css_attr.add_new_btn, //'.czr-add-new',
@@ -2678,29 +3930,52 @@ $.extend( CZRDynModuleMths, {
2678
  }
2679
  ]);//module.userEventMap
2680
  },
 
 
 
 
 
2681
  ready : function() {
2682
  var module = this;
 
2683
  module.setupDOMListeners( module.userEventMap() , { dom_el : module.container } );
 
 
2684
  module.preItem = new api.Value( module.getDefaultItemModel() );
 
 
2685
  module.preItemEmbedded = $.Deferred();//was module.czr_preItem.create('item_content');
 
2686
  module.preItemEmbedded.done( function( $preWrapper ) {
2687
  module.preItemsWrapper = $preWrapper;
2688
  module.setupPreItemInputCollection();
2689
  });
 
 
2690
  module.preItemExpanded = new api.Value(false);
 
2691
  module.preItemExpanded.callbacks.add( function( to, from ) {
2692
  module._togglePreItemViewExpansion( to );
2693
  });
2694
 
2695
  api.CZRModule.prototype.ready.call( module );//fires the parent
2696
  },//ready()
 
 
 
 
2697
  setupPreItemInputCollection : function() {
2698
  var module = this;
 
 
2699
  module.preItem.czr_Input = new api.Values();
 
 
2700
  $('.' + module.control.css_attr.pre_add_wrapper, module.container)
2701
  .find( '.' + module.control.css_attr.sub_set_wrapper)
2702
  .each( function( _index ) {
2703
  var _id = $(this).find('[data-type]').attr('data-type') || 'sub_set_' + _index;
 
2704
  module.preItem.czr_Input.add( _id, new module.inputConstructor( _id, {//api.CZRInput;
2705
  id : _id,
2706
  type : $(this).attr('data-input-type'),
@@ -2709,15 +3984,24 @@ $.extend( CZRDynModuleMths, {
2709
  module : module,
2710
  is_preItemInput : true
2711
  } ) );
 
 
2712
  module.preItem.czr_Input(_id).ready();
2713
  });//each
2714
  },
 
 
 
 
 
 
2715
  addItem : function(obj) {
2716
  var module = this,
2717
  item = module.preItem(),
2718
  collapsePreItem = function() {
2719
  module.preItemExpanded.set(false);
2720
  module._resetPreItemInputs();
 
2721
  },
2722
  dfd = $.Deferred();
2723
 
@@ -2725,17 +4009,29 @@ $.extend( CZRDynModuleMths, {
2725
  api.errorLog( 'addItem : an item should be an object and not empty. In : ' + module.id +'. Aborted.' );
2726
  return dfd.resolve().promise();
2727
  }
 
2728
  collapsePreItem = _.debounce( collapsePreItem, 200 );
 
 
2729
  module.instantiateItem( item, true ).ready(); //true == Added by user
 
 
 
2730
  ( function() {
2731
  return $.Deferred( function() {
2732
  var _dfd_ = this;
2733
  module.czr_Item( item.id ).isReady.then( function() {
 
2734
  collapsePreItem();
2735
 
2736
  module.trigger('item-added', item );
 
 
 
 
 
2737
  if ( 'postMessage' == api(module.control.id).transport && _.has( obj, 'dom_event') && ! _.has( obj.dom_event, 'isTrigger' ) && ! api.CZR_Helpers.hasPartRefresh( module.control.id ) ) {
2738
- module.control.previewer.refresh().done( function() {
2739
  _dfd_.resolve();
2740
  });
2741
  } else {
@@ -2756,6 +4052,7 @@ $.extend( CZRDynModuleMths, {
2756
  module.preItem.set( module.getDefaultItemModel() );
2757
  module.preItem.czr_Input.each( function( input_instance ) {
2758
  var _input_id = input_instance.id;
 
2759
  if ( ! _.has( module.getDefaultItemModel(), _input_id ) )
2760
  return;
2761
  input_instance.set( module.getDefaultItemModel()._input_id );
@@ -2763,47 +4060,82 @@ $.extend( CZRDynModuleMths, {
2763
  }
2764
  });//$.extend
2765
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
 
 
 
 
 
2766
 
2767
  var CZRDynModuleMths = CZRDynModuleMths || {};
2768
  ( function ( api, $, _ ) {
2769
  $.extend( CZRDynModuleMths, {
 
 
 
2770
  renderPreItemView : function( obj ) {
2771
  var module = this;
 
2772
  if ( 'pending' != module.preItemEmbedded.state() ) //was ! _.isEmpty( module.czr_preItem('item_content')() ) )
2773
  return;
 
 
2774
  if ( ! _.has(module, 'itemPreAddEl') || 0 === $( '#tmpl-' + module.itemPreAddEl ).length )
2775
  return this;
 
 
2776
  var pre_add_template = wp.template( module.itemPreAddEl );
 
 
2777
  if ( ! pre_add_template || ! module.container )
2778
  return this;
2779
 
2780
  var $_pre_add_el = $('.' + module.control.css_attr.pre_add_item_content, module.container );
2781
  $_pre_add_el.prepend( pre_add_template() );
 
 
2782
  module.preItemEmbedded.resolve( $_pre_add_el );
2783
  },
 
 
2784
  _getPreItemView : function() {
2785
  var module = this;
2786
  return $('.' + module.control.css_attr.pre_add_item_content, module.container );
2787
  },
 
 
 
 
2788
  setPreItemViewVisibility : function(obj) {
2789
  var module = this;
2790
  module.preItemExpanded.set( ! module.preItemExpanded() );
2791
  },
 
 
 
 
2792
  _togglePreItemViewExpansion : function( _is_expanded ) {
2793
  var module = this,
2794
  $_pre_add_el = $( '.' + module.control.css_attr.pre_add_item_content, module.container );
 
 
2795
  $_pre_add_el.slideToggle( {
2796
  duration : 200,
2797
  done : function() {
2798
  var $_btn = $( '.' + module.control.css_attr.open_pre_add_btn, module.container );
2799
 
2800
  $(this).toggleClass('open' , _is_expanded );
 
2801
  if ( _is_expanded )
2802
  $_btn.find('.fa').removeClass('fa-plus-square').addClass('fa-minus-square');
2803
  else
2804
  $_btn.find('.fa').removeClass('fa-minus-square').addClass('fa-plus-square');
 
 
2805
  $_btn.toggleClass( 'active', _is_expanded );
 
 
2806
  $( module.container ).toggleClass( module.control.css_attr.adding_new, _is_expanded );
 
2807
  module._adjustScrollExpandedBlock( $(this), 120 );
2808
  }//done
2809
  } );
@@ -2817,7 +4149,10 @@ $.extend( CZRDynModuleMths, {
2817
  $_success_wrapper = $('.' + module.control.css_attr.pre_add_success, module.container );
2818
 
2819
  if ( 'on' == status ) {
 
2820
  $_success_wrapper.find('p').text(_message);
 
 
2821
  $_success_wrapper.css('z-index', 1000001 )
2822
  .css('height', $_pre_add_wrapper.height() + 'px' )
2823
  .css('line-height', $_pre_add_wrapper.height() + 'px');
@@ -2829,14 +4164,22 @@ $.extend( CZRDynModuleMths, {
2829
  }
2830
  });//$.extend//CZRBaseControlMths
2831
  })( wp.customize , jQuery, _ );//BASE CONTROL CLASS
 
 
 
 
2832
 
2833
  var CZRBaseControlMths = CZRBaseControlMths || {};
2834
  ( function ( api, $, _ ) {
2835
  $.extend( CZRBaseControlMths, {
2836
  initialize: function( id, options ) {
2837
  var control = this;
 
2838
  control.css_attr = _.has( serverControlParams , 'css_attr') ? serverControlParams.css_attr : {};
2839
  api.Control.prototype.initialize.call( control, id, options );
 
 
 
2840
  control.bind( 'czr-partial-refresh-done', function() {
2841
  if ( _.has( control, 'czr_moduleCollection' ) ) {
2842
  _.each( control.czr_moduleCollection(), function( _mod_ ) {
@@ -2848,11 +4191,18 @@ $.extend( CZRBaseControlMths, {
2848
  }
2849
  });
2850
  },
 
 
2851
  refreshPreview : function( obj ) {
2852
  this.previewer.refresh();
2853
  }
2854
  });//$.extend//CZRBaseControlMths
2855
  })( wp.customize , jQuery, _ );
 
 
 
 
 
2856
  var CZRBaseModuleControlMths = CZRBaseModuleControlMths || {};
2857
  ( function ( api, $, _ ) {
2858
  $.extend( CZRBaseModuleControlMths, {
@@ -2860,19 +4210,43 @@ $.extend( CZRBaseModuleControlMths, {
2860
  var control = this;
2861
 
2862
  control.czr_Module = new api.Values();
 
 
2863
  control.czr_moduleCollection = new api.Value();
2864
  control.czr_moduleCollection.set([]);
 
 
2865
  control.moduleCollectionReady = $.Deferred();
 
2866
  control.moduleCollectionReady.done( function( obj ) {
2867
- if ( ! control.isMultiModuleControl( options.params ) ) {
 
2868
  }
 
 
 
 
 
 
 
2869
  control.czr_moduleCollection.callbacks.add( function() { return control.moduleCollectionReact.apply( control, arguments ); } );
 
 
2870
  } );
2871
- if ( control.isMultiModuleControl( options.params ) ) {
 
 
2872
  control.syncSektionModule = new api.Value();
2873
  }
2874
 
2875
  api.CZRBaseControl.prototype.initialize.call( control, id, options );
 
 
 
 
 
 
 
2876
  api.section( control.section() ).expanded.bind(function(to) {
2877
  control.czr_Module.each( function( _mod ){
2878
  _mod.closeAllItems().closeRemoveDialogs();
@@ -2883,39 +4257,80 @@ $.extend( CZRBaseModuleControlMths, {
2883
  });
2884
 
2885
  },
 
 
 
 
 
 
 
 
2886
  ready : function() {
2887
  var control = this;
2888
  if ( control.isMultiModuleControl() ) {
 
2889
  control.syncSektionModule.bind( function( sektion_module_instance, from) {
2890
  if ( 'resolved' == control.moduleCollectionReady.state() )
2891
  return;
2892
  control.registerModulesOnInit( sektion_module_instance );
 
2893
  control.moduleCollectionReady.resolve();
2894
  });
2895
  } else {
2896
  var single_module = {};
 
 
2897
  _.each( control.getSavedModules() , function( _mod, _key ) {
 
2898
  single_module = _mod;
 
 
 
2899
  try { control.instantiateModule( _mod, {} ); } catch( er ) {
2900
  api.errorLog( 'Failed to instantiate module ' + _mod.id + ' ' + er );
2901
  return;
2902
  }
 
 
2903
  control.container.attr('data-module', _mod.id );
2904
  });
 
2905
  control.moduleCollectionReady.resolve( single_module );
2906
  }
 
 
 
2907
  control.bind( 'user-module-candidate', function( _module ) {
2908
  var module;
 
 
2909
  try {
2910
  module = control.instantiateModule( _module, {} ); //module, constructor
2911
  } catch( er ) {
2912
  api.errorLog( 'Failed to instantiate module ' + _module.id + ' ' + er );
2913
  return;
2914
  }
 
2915
  module.ready( _module.is_added_by_user );
2916
  });
2917
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2918
  getDefaultModuleApiModel : function() {
 
2919
  var commonAPIModel = {
2920
  id : '',//module.id,
2921
  module_type : '',//module.module_type,
@@ -2926,6 +4341,8 @@ $.extend( CZRBaseModuleControlMths, {
2926
  sortable : false,//<= a module can be multi-item but not necessarily sortable
2927
  control : {},//control,
2928
  };
 
 
2929
  if ( ! this.isMultiModuleControl() ) {
2930
  return $.extend( commonAPIModel, {
2931
  section : ''//id of the control section
@@ -2940,10 +4357,15 @@ $.extend( CZRBaseModuleControlMths, {
2940
  } );
2941
  }
2942
  },
 
 
 
2943
  getDefaultModuleDBModel : function() {
2944
  var commonDBModel = {
2945
  items : [],//$.extend( true, {}, module.items ),
2946
  };
 
 
2947
  if ( this.isMultiModuleControl() ) {
2948
  return $.extend( commonDBModel, {
2949
  id : '',
@@ -2956,9 +4378,25 @@ $.extend( CZRBaseModuleControlMths, {
2956
  return commonDBModel;
2957
  }
2958
  },
2959
- isMultiModuleControl : function( params ) {
2960
- return 'czr_multi_module' == ( params || this.params ).type;
 
 
 
 
 
 
 
 
 
 
 
 
 
2961
  },
 
 
 
2962
  getSyncCollectionControl : function() {
2963
  var control = this;
2964
  if ( _.isUndefined( control.params.syncCollection ) ) {
@@ -2966,6 +4404,22 @@ $.extend( CZRBaseModuleControlMths, {
2966
  }
2967
  return api.control( api.CZR_Helpers.build_setId( control.params.syncCollection ) );
2968
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2969
  getSavedModules : function() {
2970
  var control = this,
2971
  _savedModulesCandidates = [],
@@ -2973,16 +4427,52 @@ $.extend( CZRBaseModuleControlMths, {
2973
  _raw_saved_module_val = [],
2974
  _saved_items = [],
2975
  _saved_modOpt = {};
 
 
 
 
 
2976
  if ( control.isMultiModuleControl() ) {
2977
  _savedModulesCandidates = $.extend( true, [], api( control.id )() );//deep clone
2978
  } else {
 
 
 
 
 
 
2979
  if ( api.CZR_Helpers.isMultiItemModule( _module_type ) && ! _.isEmpty( api( control.id )() ) && ! _.isObject( api( control.id )() ) ) {
2980
  api.consoleLog('Module Control Init for ' + control.id + ' : a mono item module control value should be an object if not empty.');
2981
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2982
  _raw_saved_module_val = _.isArray( api( control.id )() ) ? api( control.id )() : [ api( control.id )() ];
2983
 
2984
  _.each( _raw_saved_module_val, function( item_or_mod_opt_candidate , key ) {
2985
  if ( api.CZR_Helpers.hasModuleModOpt( _module_type ) && 0*0 === key ) {
 
2986
  if ( _.has( item_or_mod_opt_candidate, 'id') ) {
2987
  api.consoleLog( 'getSavedModules : the module ' + _module_type + ' in control ' + control.id + ' has no mod_opt defined while it should.' );
2988
  } else {
@@ -2993,6 +4483,9 @@ $.extend( CZRBaseModuleControlMths, {
2993
  _saved_items.push( item_or_mod_opt_candidate );
2994
  }
2995
  });
 
 
 
2996
  _savedModulesCandidates.push(
2997
  {
2998
  id : api.CZR_Helpers.getOptionName( control.id ) + '_' + control.params.type,
@@ -3005,35 +4498,58 @@ $.extend( CZRBaseModuleControlMths, {
3005
  }
3006
  return _savedModulesCandidates;
3007
  },
 
 
 
 
3008
  isModuleRegistered : function( id_candidate ) {
3009
  var control = this;
3010
  return ! _.isUndefined( _.findWhere( control.czr_moduleCollection(), { id : id_candidate}) );
3011
  }
3012
  });//$.extend//CZRBaseControlMths
3013
  })( wp.customize , jQuery, _ );
 
 
 
 
 
3014
  var CZRBaseModuleControlMths = CZRBaseModuleControlMths || {};
3015
  ( function ( api, $, _ ) {
3016
  $.extend( CZRBaseModuleControlMths, {
 
 
3017
  instantiateModule : function( module, constructor ) {
3018
  if ( ! _.has( module,'id') ) {
3019
  throw new Error('CZRModule::instantiateModule() : a module has no id and could not be added in the collection of : ' + this.id +'. Aborted.' );
3020
  }
3021
  var control = this;
 
 
3022
  if ( _.isUndefined(constructor) || _.isEmpty(constructor) ) {
3023
  constructor = control.getModuleConstructor( module );
3024
  }
 
 
 
3025
  if ( ! _.isEmpty( module.id ) && control.czr_Module.has( module.id ) ) {
3026
  throw new Error('The module id already exists in the collection in control : ' + control.id );
3027
  }
3028
 
3029
  var module_api_ready = control.prepareModuleForAPI( module );
 
 
3030
  control.czr_Module.add( module_api_ready.id, new constructor( module_api_ready.id, module_api_ready ) );
3031
 
3032
  if ( ! control.czr_Module.has( module_api_ready.id ) ) {
3033
  throw new Error('instantiateModule() : instantiation failed for module id ' + module_api_ready.id + ' in control ' + control.id );
3034
  }
 
3035
  return control.czr_Module(module_api_ready.id);
3036
  },
 
 
 
 
3037
  getModuleConstructor : function( module ) {
3038
  var control = this,
3039
  parentConstructor = {},
@@ -3049,10 +4565,13 @@ $.extend( CZRBaseModuleControlMths, {
3049
  var _mthds = api.czrModuleMap[ module.module_type ].mthds,
3050
  _is_crud = api.czrModuleMap[ module.module_type ].crud,
3051
  _base_constructor = _is_crud ? api.CZRDynModule : api.CZRModule;
 
 
3052
  if ( ! _.isEmpty( module.sektion_id ) ) {
3053
  parentConstructor = _base_constructor.extend( _mthds );
3054
  constructor = parentConstructor.extend( control.getMultiModuleExtender( parentConstructor ) );
3055
  } else {
 
3056
  constructor = _base_constructor.extend( _mthds );
3057
  }
3058
 
@@ -3061,6 +4580,13 @@ $.extend( CZRBaseModuleControlMths, {
3061
  }
3062
  return constructor;
3063
  },
 
 
 
 
 
 
 
3064
  prepareModuleForAPI : function( module_candidate ) {
3065
  if ( ! _.isObject( module_candidate ) ) {
3066
  throw new Error('prepareModuleForAPI : a module must be an object to be instantiated.');
@@ -3072,6 +4598,7 @@ $.extend( CZRBaseModuleControlMths, {
3072
  _.each( control.getDefaultModuleApiModel() , function( _value, _key ) {
3073
  var _candidate_val = module_candidate[_key];
3074
  switch( _key ) {
 
3075
  case 'id' :
3076
  if ( _.isEmpty( _candidate_val ) ) {
3077
  api_ready_module[_key] = control.generateModuleId( module_candidate.module_type );
@@ -3098,6 +4625,7 @@ $.extend( CZRBaseModuleControlMths, {
3098
  api_ready_module[_key] = _candidate_val;
3099
  break;
3100
  case 'crud' :
 
3101
  if ( _.has( api.czrModuleMap, module_candidate.module_type ) ) {
3102
  _candidate_val = api.czrModuleMap[ module_candidate.module_type ].crud;
3103
  } else if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
@@ -3106,6 +4634,7 @@ $.extend( CZRBaseModuleControlMths, {
3106
  api_ready_module[_key] = _candidate_val || false;
3107
  break;
3108
  case 'multi_item' :
 
3109
  if ( _.has( api.czrModuleMap, module_candidate.module_type ) ) {
3110
  _candidate_val = api.czrModuleMap[ module_candidate.module_type ].crud || api.czrModuleMap[ module_candidate.module_type ].multi_item;
3111
  } else if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
@@ -3113,7 +4642,9 @@ $.extend( CZRBaseModuleControlMths, {
3113
  }
3114
  api_ready_module[_key] = _candidate_val || false;
3115
  break;
 
3116
  case 'sortable' :
 
3117
  if ( _.has( api.czrModuleMap, module_candidate.module_type ) ) {
3118
  _candidate_val = api.czrModuleMap[ module_candidate.module_type ].sortable || api.czrModuleMap[ module_candidate.module_type ].crud || api.czrModuleMap[ module_candidate.module_type ].multi_item;
3119
  } else if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
@@ -3124,12 +4655,20 @@ $.extend( CZRBaseModuleControlMths, {
3124
  case 'control' :
3125
  api_ready_module[_key] = control;//this
3126
  break;
 
 
 
 
3127
  case 'section' :
3128
  if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
3129
  throw new Error('prepareModuleForAPI : a module section must be a string not empty');
3130
  }
3131
  api_ready_module[_key] = _candidate_val;
3132
  break;
 
 
 
 
3133
  case 'column_id' :
3134
  if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
3135
  throw new Error('prepareModuleForAPI : a module column id must a string not empty');
@@ -3161,7 +4700,11 @@ $.extend( CZRBaseModuleControlMths, {
3161
  });
3162
  return api_ready_module;
3163
  },
 
 
 
3164
  generateModuleId : function( module_type, key, i ) {
 
3165
  i = i || 1;
3166
  if ( i > 100 ) {
3167
  throw new Error('Infinite loop when generating of a module id.');
@@ -3169,9 +4712,13 @@ $.extend( CZRBaseModuleControlMths, {
3169
  var control = this;
3170
  key = key || control._getNextModuleKeyInCollection();
3171
  var id_candidate = module_type + '_' + key;
 
 
3172
  if ( ! _.has(control, 'czr_moduleCollection') || ! _.isArray( control.czr_moduleCollection() ) ) {
3173
  throw new Error('The module collection does not exist or is not properly set in control : ' + control.id );
3174
  }
 
 
3175
  if ( control.isModuleRegistered( id_candidate ) ) {
3176
  key++; i++;
3177
  return control.generateModuleId( module_type, key, i );
@@ -3179,10 +4726,18 @@ $.extend( CZRBaseModuleControlMths, {
3179
 
3180
  return id_candidate;
3181
  },
 
 
 
 
3182
  _getNextModuleKeyInCollection : function() {
3183
  var control = this,
3184
  _max_mod_key = {},
3185
  _next_key = 0;
 
 
 
 
3186
  if ( ! _.isEmpty( control.czr_moduleCollection() ) ) {
3187
  _max_mod_key = _.max( control.czr_moduleCollection(), function( _mod ) {
3188
  return parseInt( _mod.id.replace(/[^\/\d]/g,''), 10 );
@@ -3193,39 +4748,73 @@ $.extend( CZRBaseModuleControlMths, {
3193
  }
3194
  });//$.extend//CZRBaseControlMths
3195
  })( wp.customize , jQuery, _ );
 
 
 
 
 
3196
  var CZRBaseModuleControlMths = CZRBaseModuleControlMths || {};
3197
  ( function ( api, $, _ ) {
3198
  $.extend( CZRBaseModuleControlMths, {
 
 
3199
  registerModulesOnInit : function( sektion_module_instance ) {
3200
  var control = this,
3201
  _orphan_mods = [];
3202
 
3203
  _.each( control.getSavedModules() , function( _mod, _key ) {
 
3204
  if ( ! sektion_module_instance.czr_Item.has( _mod.sektion_id ) ) {
3205
  api.errorLog( 'Warning Module ' + _mod.id + ' is orphan : it has no sektion to be embedded to. It Must be removed.');
3206
  _orphan_mods.push(_mod);
3207
  return;
3208
  }
 
 
3209
 
3210
  var _sektion = sektion_module_instance.czr_Item( _mod.sektion_id );
3211
 
3212
  if ( _.isUndefined( _sektion ) ) {
3213
  throw new Error( 'sektion instance missing. Impossible to instantiate module : ' + _mod.id );
3214
  }
 
 
3215
  $.extend( _mod, {sektion : _sektion} );
 
 
 
3216
  control.updateModulesCollection( {module : _mod } );
3217
  });
 
 
 
3218
  control.moduleCollectionReady.then( function() {
 
3219
  if ( ! _.isEmpty( _orphan_mods ) ) {
3220
  control.moduleCollectionReact( control.czr_moduleCollection(), [], { orphans_module_removal : _orphan_mods } );
3221
  }
3222
  });
3223
  },
 
 
 
 
 
 
 
 
 
 
 
3224
  updateModulesCollection : function( obj ) {
3225
  var control = this,
3226
  _current_collection = control.czr_moduleCollection(),
3227
  _new_collection = $.extend( true, [], _current_collection);
 
 
 
3228
  if ( _.has( obj, 'collection' ) ) {
 
3229
  control.czr_moduleCollection.set( obj.collection, obj.data || {} );
3230
  return;
3231
  }
@@ -3233,49 +4822,102 @@ $.extend( CZRBaseModuleControlMths, {
3233
  if ( ! _.has(obj, 'module') ) {
3234
  throw new Error('updateModulesCollection, no module provided ' + control.id + '. Aborting');
3235
  }
 
 
3236
  var module_api_ready = control.prepareModuleForAPI( _.clone( obj.module ) );
 
 
3237
  if ( _.findWhere( _new_collection, { id : module_api_ready.id } ) ) {
3238
  _.each( _current_collection , function( _elt, _ind ) {
3239
  if ( _elt.id != module_api_ready.id )
3240
  return;
 
 
3241
  _new_collection[_ind] = module_api_ready;
3242
  });
3243
  }
 
3244
  else {
3245
  _new_collection.push( module_api_ready );
3246
  }
 
 
3247
  var _params = {};
 
 
3248
  if ( _.has( obj, 'data') ) {
3249
  _params = $.extend( true, {}, obj.data );
3250
  $.extend( _params, { module : module_api_ready } );
3251
  }
 
3252
  control.czr_moduleCollection.set( _new_collection, _params );
3253
  },
 
 
 
 
 
 
 
 
 
 
 
3254
  moduleCollectionReact : function( to, from, data ) {
3255
  var control = this,
3256
  is_module_added = _.size(to) > _.size(from),
3257
  is_module_removed = _.size(from) > _.size(to),
3258
  is_module_update = _.size(from) == _.size(to);
3259
  is_collection_sorted = false;
 
 
 
3260
  if ( is_module_removed ) {
 
3261
  var _to_remove = _.filter( from, function( _mod ){
3262
  return _.isUndefined( _.findWhere( to, { id : _mod.id } ) );
3263
  });
3264
  _to_remove = _to_remove[0];
3265
  control.czr_Module.remove( _to_remove.id );
3266
  }
 
 
 
 
3267
  if ( _.isObject( data ) && _.has( data, 'module' ) ) {
3268
  data.module_id = data.module.id;
3269
  data.module = control.prepareModuleForDB( $.extend( true, {}, data.module ) );
3270
  }
 
 
 
 
 
3271
  if ( ! control.isMultiModuleControl() && is_module_added ) {
3272
  return;
3273
  }
3274
  else {
 
 
3275
  api( this.id )
3276
  .set( control.filterModuleCollectionBeforeAjax( to ), data );
 
3277
  }
3278
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3279
  filterModuleCollectionBeforeAjax : function( collection ) {
3280
  var control = this,
3281
  _filtered_collection = $.extend( true, [], collection ),
@@ -3285,9 +4927,16 @@ $.extend( CZRBaseModuleControlMths, {
3285
  var db_ready_mod = $.extend( true, {}, _mod );
3286
  _filtered_collection[_key] = control.prepareModuleForDB( db_ready_mod );
3287
  });
 
 
 
 
 
 
3288
  if ( control.isMultiModuleControl() ) {
3289
  return _filtered_collection;
3290
  } else {
 
3291
  if ( _.size( collection ) > 1 ) {
3292
  throw new Error('There should not be several modules in the collection of control : ' + control.id );
3293
  }
@@ -3303,10 +4952,20 @@ $.extend( CZRBaseModuleControlMths, {
3303
  if ( ! _.isArray( module_instance().items ) ) {
3304
  throw new Error('The module ' + module_id + ' should be an array in control : ' + control.id );
3305
  }
 
 
3306
  _to_return = module_instance.isMultiItem() ? module_instance().items : ( module_instance().items[0] || [] );
 
 
3307
  return module_instance.hasModOpt() ? _.union( [ module_instance().modOpt ] , _to_return ) : _to_return;
3308
  }
3309
  },
 
 
 
 
 
 
3310
  prepareModuleForDB : function ( module_db_candidate ) {
3311
  if ( ! _.isObject( module_db_candidate ) ) {
3312
  throw new Error('MultiModule Control::prepareModuleForDB : a module must be an object. Aborting.');
@@ -3321,12 +4980,17 @@ $.extend( CZRBaseModuleControlMths, {
3321
 
3322
  var _candidate_val = module_db_candidate[ _key ];
3323
  switch( _key ) {
 
3324
  case 'items' :
3325
  if ( ! _.isArray( _candidate_val ) ) {
3326
  throw new Error('prepareModuleForDB : a module item list must be an array');
3327
  }
3328
  db_ready_module[ _key ] = _candidate_val;
3329
  break;
 
 
 
 
3330
  case 'id' :
3331
  if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
3332
  throw new Error('prepareModuleForDB : a module id must a string not empty');
@@ -3349,6 +5013,8 @@ $.extend( CZRBaseModuleControlMths, {
3349
  if ( ! _.isObject( module_db_candidate.sektion ) || ! _.has( module_db_candidate.sektion, 'id' ) ) {
3350
  throw new Error('prepareModuleForDB : a module sektion must be an object with an id.');
3351
  }
 
 
3352
  db_ready_module[ _key ] = module_db_candidate.sektion.id;
3353
  break;
3354
  case 'dirty' :
@@ -3366,14 +5032,26 @@ $.extend( CZRBaseModuleControlMths, {
3366
  }
3367
  });//$.extend//CZRBaseControlMths
3368
  })( wp.customize , jQuery, _ );
 
3369
  var CZRMultiModuleControlMths = CZRMultiModuleControlMths || {};
3370
  ( function ( api, $, _ ) {
3371
  $.extend( CZRMultiModuleControlMths, {
3372
  initialize: function( id, options ) {
3373
  var control = this;
 
 
 
3374
  api.consoleLog('IN MULTI MODULE INITIALIZE ? ', options );
3375
  api(id).callbacks.add( function() { return control.syncColumn.apply( control, arguments ); } );
3376
 
 
 
 
 
 
 
 
 
3377
  api.CZRBaseModuleControl.prototype.initialize.call( control, id, options );
3378
  },
3379
 
@@ -3383,14 +5061,24 @@ $.extend( CZRMultiModuleControlMths, {
3383
  api.consoleLog('MODULE-COLLECTION CONTROL READY', this.id );
3384
  api.CZRBaseModuleControl.prototype.ready.apply( control, arguments);
3385
  },
 
 
3386
  syncColumn : function( to, from, data ) {
3387
  api.consoleLog('IN SYNC COLUMN', to, from, data );
3388
  if ( ! _.isUndefined(data) && data.silent )
3389
  return;
3390
  api.consoleLog('IN SYNXXX', api.control('hu_theme_options[module-collection]').syncSektionModule()(), this.syncSektionModule()(), this.id );
 
 
 
3391
  if ( _.has( data, 'orphans_module_removal' ) )
3392
  return;
 
 
 
3393
  var control = api.control( this.id );
 
 
3394
  var added_mod = _.filter( to, function( _mod, _key ){
3395
  return ! _.findWhere( from, { id : _mod.id } );
3396
  } );
@@ -3400,6 +5088,8 @@ $.extend( CZRMultiModuleControlMths, {
3400
  control.syncSektionModule().czr_Column( _mod.column_id ).updateColumnModuleCollection( { module : _mod } );
3401
  });
3402
  }
 
 
3403
  var removed_mod = _.filter( from, function( _mod, _key ){
3404
  return ! _.findWhere( to, { id : _mod.id } );
3405
  } );
@@ -3408,6 +5098,8 @@ $.extend( CZRMultiModuleControlMths, {
3408
  control.syncSektionModule().czr_Column( _mod.column_id ).removeModuleFromColumnCollection( _mod );
3409
  });
3410
  }
 
 
3411
  if ( _.size(from) == _.size(to) && _.has( data, 'module') && _.has( data, 'source_column') && _.has( data, 'target_column') ) {
3412
  $.when( control.syncSektionModule().moveModuleFromTo( data.module, data.source_column, data.target_column ) ).done( function() {
3413
  control.syncSektionModule().control.trigger('module-moved', { module : data.module, source_column: data.source_column, target_column :data.target_column });
@@ -3415,10 +5107,19 @@ $.extend( CZRMultiModuleControlMths, {
3415
  }
3416
  control.trigger( 'columns-synchronized', to );
3417
  },
 
 
 
 
 
 
3418
  removeModule : function( module ) {
3419
  var control = this;
 
3420
  if ( control.czr_Module.has( module.id ) && 'resolved' == control.czr_Module( module.id ).embedded.state() )
3421
  control.czr_Module( module.id ).container.remove();
 
 
3422
  control.removeModuleFromCollection( module );
3423
  },
3424
 
@@ -3435,38 +5136,80 @@ $.extend( CZRMultiModuleControlMths, {
3435
  }
3436
  });//$.extend//CZRBaseControlMths
3437
  })( wp.customize , jQuery, _ );
 
3438
  var CZRMultiModuleControlMths = CZRMultiModuleControlMths || {};
3439
  ( function ( api, $, _ ) {
3440
  $.extend( CZRMultiModuleControlMths, {
 
 
3441
  getMultiModuleExtender : function( parentConstructor ) {
3442
  var control = this;
3443
  $.extend( control.CZRModuleExtended, {
3444
  initialize: function( id, constructorOptions ) {
3445
  var module = this;
 
3446
  parentConstructor.prototype.initialize.call( module, id, constructorOptions );
3447
 
3448
  api.consoleLog('MODULE INSTANTIATED : ', module.id );
 
 
3449
  $.extend( module, {
3450
  singleModuleWrapper : 'czr-single-module-wrapper',
3451
  sektionModuleTitle : 'czr-module-sektion-title-part',
3452
  ruModuleEl : 'czr-ru-module-sektion-content'
3453
  } );
 
 
 
 
3454
  module.czr_ModuleState = new api.Value( false );
 
 
3455
  module.isReady.done( function() {
3456
  module.setupModuleView();
3457
  });
 
 
3458
  module.moduleTitleEmbedded = $.Deferred();
 
 
3459
  module.modColumn = new api.Value();
3460
  module.modColumn.set( constructorOptions.column_id );
 
 
3461
  module.modColumn.bind( function( to, from ) {
3462
  api.consoleLog('MODULE ' + module.id + ' HAS BEEN MOVED TO COLUMN', to, module() );
3463
  var _current_model = module(),
3464
  _new_model = $.extend( true, {}, _current_model );
3465
 
3466
  _new_model.column_id = to;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3467
  module.set( _new_model, { target_column : to, source_column : from } );
 
 
3468
  } );
3469
  },
 
 
 
 
 
 
 
3470
  ready : function( is_added_by_user ) {
3471
  var module = this;
3472
  api.consoleLog('MODULE READY IN EXTENDED MODULE CLASS : ', module.id );
@@ -3477,17 +5220,29 @@ $.extend( CZRMultiModuleControlMths, {
3477
  module.container = $_module_container;
3478
  module.embedded.resolve();
3479
  } );
 
3480
  parentConstructor.prototype.ready.call( module );
 
3481
  }
3482
 
3483
  });
3484
  return control.CZRModuleExtended;
3485
  },
 
 
 
3486
  CZRModuleExtended : {
 
 
3487
  renderModuleWrapper : function( is_added_by_user ) {
 
3488
  var module = this;
 
 
3489
  if ( 'resolved' == module.embedded.state() )
3490
  return module.container;
 
 
3491
  if ( 0 === $( '#tmpl-' + module.singleModuleWrapper ).length ) {
3492
  throw new Error('No template for module ' + module.id + '. The template script id should be : #tmpl-' + module.singleModuleWrapper );
3493
  }
@@ -3498,6 +5253,9 @@ $.extend( CZRMultiModuleControlMths, {
3498
  type : module.module_type
3499
  },
3500
  $_module_el = $( module_wrapper_tmpl( tmpl_data ) );
 
 
 
3501
  if ( is_added_by_user ) {
3502
  $.when( $( '.czr-module-collection-wrapper' , module._getColumn().container ).find( '.czr-module-candidate').after( $_module_el ) ).
3503
  done( function() {
@@ -3507,6 +5265,13 @@ $.extend( CZRMultiModuleControlMths, {
3507
  $( '.czr-module-collection-wrapper' , module._getColumn().container).append( $_module_el );
3508
  }
3509
 
 
 
 
 
 
 
 
3510
  return $_module_el;
3511
  },
3512
 
@@ -3518,18 +5283,21 @@ $.extend( CZRMultiModuleControlMths, {
3518
  var module = this;
3519
 
3520
  module.view_event_map = [
 
3521
  {
3522
  trigger : 'click keydown',
3523
  selector : [ '.czr-remove-mod', '.' + module.control.css_attr.cancel_alert_btn ].join(','),
3524
  name : 'toggle_remove_alert',
3525
  actions : ['toggleModuleRemoveAlert']
3526
  },
 
3527
  {
3528
  trigger : 'click keydown',
3529
  selector : '.' + module.control.css_attr.remove_view_btn,
3530
  name : 'remove_module',
3531
  actions : ['removeModule']
3532
  },
 
3533
  {
3534
  trigger : 'click keydown',
3535
  selector : '.czr-edit-mod',
@@ -3547,7 +5315,7 @@ $.extend( CZRMultiModuleControlMths, {
3547
  selector : '.czr-mod-header',
3548
  name : 'hovering_module',
3549
  actions : function( obj ) {
3550
- module.control.previewer.send( 'start_hovering_module', {
3551
  id : module.id
3552
  });
3553
  }
@@ -3557,14 +5325,19 @@ $.extend( CZRMultiModuleControlMths, {
3557
  selector : '.czr-mod-header',
3558
  name : 'hovering_module',
3559
  actions : function( obj ) {
3560
- module.control.previewer.send( 'stop_hovering_module', {
3561
  id : module.id
3562
  });
3563
  }
3564
  }
3565
  ];
 
 
3566
  module.embedded.done( function() {
 
3567
  module.czr_ModuleState.callbacks.add( function() { return module.setupModuleViewStateListeners.apply(module, arguments ); } );
 
 
3568
  api.CZR_Helpers.setupDOMListeners(
3569
  module.view_event_map,//actions to execute
3570
  { module : { id : module.id } , dom_el:module.container },//model + dom scope
@@ -3572,37 +5345,93 @@ $.extend( CZRMultiModuleControlMths, {
3572
  );//listeners for the view wrapper
3573
  });
3574
  },
 
 
3575
  setModuleViewVisibility : function( obj, is_added_by_user ) {
3576
  var module = this;
3577
 
3578
  module.czr_ModuleState( ! module.czr_ModuleState() );
 
 
3579
  api.czrModulePanelState.set(false);
 
3580
  api.czrSekSettingsPanelState.set(false);
 
 
3581
  module.control.syncSektionModule().closeAllOtherSektions( $(obj.dom_event.currentTarget, obj.dom_el ) );
 
 
 
 
 
 
 
 
 
 
 
3582
  },
 
 
3583
  sendEditModule : function( obj ) {
3584
  var module = this;
3585
- module.control.previewer.send( 'edit_module', {
3586
  id : module.id
3587
  });
3588
  },
 
 
 
3589
  setupModuleViewStateListeners : function( expanded ) {
3590
  var module = this;
 
3591
  api.czr_isModuleExpanded = api.czr_isModuleExpanded || new api.Value();
3592
 
3593
  if ( expanded )
3594
  api.czr_isModuleExpanded( module );
3595
  else
3596
  api.czr_isModuleExpanded( false );
 
 
3597
  $.when( module.toggleModuleViewExpansion( expanded ) ).done( function() {
3598
  if ( expanded ) {
 
3599
  module.renderModuleTitle();
 
 
3600
  module.populateSavedItemCollection();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3601
  }
3602
  else {
3603
  module.czr_Item.each ( function( item ) {
3604
  item.viewState.set('closed');
3605
  item._destroyView( 0 );
 
3606
  module.czr_Item.remove( item.id );
3607
  } );
3608
  }
@@ -3614,17 +5443,26 @@ $.extend( CZRMultiModuleControlMths, {
3614
  var module = this;
3615
  if( 'resolved' == module.moduleTitleEmbedded.state() )
3616
  return;
 
 
 
3617
  if ( 0 === $( '#tmpl-' + module.sektionModuleTitle ).length ) {
3618
  throw new Error('No sektion title Module Part template for module ' + module.id + '. The template script id should be : #tmpl-' + module.sektionModuleTitle );
3619
  }
 
3620
  $.when( $( module.container ).find('.czr-mod-content').prepend(
3621
  $( wp.template( module.sektionModuleTitle )( { id : module.id } ) )
3622
  ) ).done( function() {
3623
  module.moduleTitleEmbedded.resolve();
3624
  });
3625
  },
 
 
 
3626
  toggleModuleViewExpansion : function( expanded, duration ) {
3627
  var module = this;
 
 
3628
  $( '.czr-mod-content' , module.container ).slideToggle( {
3629
  duration : duration || 200,
3630
  done : function() {
@@ -3642,6 +5480,21 @@ $.extend( CZRMultiModuleControlMths, {
3642
  } else {
3643
  $_modTitle.focus();
3644
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3645
  if ( expanded )
3646
  module._adjustScrollExpandedBlock( module.container );
3647
  }//done callback
@@ -3662,36 +5515,57 @@ $.extend( CZRMultiModuleControlMths, {
3662
  $_alert_el = $( '.' + module.control.css_attr.remove_alert_wrapper, module.container ).first(),
3663
  $_clicked = obj.dom_event,
3664
  $_column_container = control.syncSektionModule().czr_Column( module.column_id ).container;
 
 
 
 
 
3665
  if ( _.has(module, 'preItem') ) {
3666
  control.syncSektionModule().preItemExpanded.set( false );
3667
  }
 
 
3668
  $('.' + module.control.css_attr.remove_alert_wrapper, $_column_container ).not($_alert_el).each( function() {
3669
  if ( $(this).hasClass('open') ) {
3670
  $(this).slideToggle( {
3671
  duration : 200,
3672
  done : function() {
3673
  $(this).toggleClass('open' , false );
 
3674
  $(this).siblings().find('.' + module.control.css_attr.display_alert_btn).toggleClass('active' , false );
3675
  }
3676
  } );
3677
  }
3678
  });
 
 
 
3679
  if ( ! wp.template( module.AlertPart ) || ! module.container ) {
3680
  throw new Error( 'No removal alert template available for module :' + module.id );
3681
  }
3682
 
3683
  $_alert_el.html( wp.template( module.AlertPart )( { title : ( module().title || module.id ) } ) );
 
 
3684
  $_alert_el.slideToggle( {
3685
  duration : 200,
3686
  done : function() {
3687
  var _is_open = ! $(this).hasClass('open') && $(this).is(':visible');
3688
  $(this).toggleClass('open' , _is_open );
 
3689
  $( obj.dom_el ).find('.' + module.control.css_attr.display_alert_btn).toggleClass( 'active', _is_open );
 
3690
  if ( _is_open )
3691
  module._adjustScrollExpandedBlock( module.container );
3692
  }
3693
  } );
3694
  },
 
 
 
 
 
 
3695
  removeModule : function( obj ) {
3696
  this.control.removeModule( obj.module );
3697
  },
@@ -3721,16 +5595,26 @@ $.extend( CZRMultiModuleControlMths, {
3721
  });//$.extend//CZRBaseControlMths
3722
  })( wp.customize , jQuery, _ );
3723
  ( function ( api, $, _ ) {
 
 
3724
  $.extend( CZRBaseControlMths, api.Events );
3725
  $.extend( api.Control.prototype, api.Events );//ensures that the default WP control constructor is extended as well
3726
  $.extend( CZRModuleMths, api.Events );
3727
  $.extend( CZRItemMths, api.Events );
3728
  $.extend( CZRModOptMths, api.Events );
 
 
3729
  $.extend( CZRBaseControlMths, api.CZR_Helpers );
3730
  $.extend( CZRInputMths, api.CZR_Helpers );
3731
  $.extend( CZRModuleMths, api.CZR_Helpers );
 
 
3732
  api.CZRInput = api.Value.extend( CZRInputMths );
 
3733
  api.czrInputMap = api.czrInputMap || {};
 
 
 
3734
  $.extend( api.czrInputMap, {
3735
  text : '',
3736
  textarea : '',
@@ -3744,13 +5628,24 @@ $.extend( CZRMultiModuleControlMths, {
3744
  password : '',
3745
  range_slider : 'setupRangeSlider'
3746
  });
 
 
3747
  api.CZRItem = api.Value.extend( CZRItemMths );
 
 
3748
  api.CZRModOpt = api.Value.extend( CZRModOptMths );
 
 
3749
  api.CZRModule = api.Value.extend( CZRModuleMths );
3750
  api.CZRDynModule = api.CZRModule.extend( CZRDynModuleMths );
 
 
 
3751
  if ( ! _.isUndefined( window.CZRColumnMths ) ) {
3752
  api.CZRColumn = api.Value.extend( CZRColumnMths );
3753
  }
 
 
3754
  api.CZRBaseControl = api.Control.extend( CZRBaseControlMths );
3755
  api.CZRBaseModuleControl = api.CZRBaseControl.extend( CZRBaseModuleControlMths );
3756
  api.CZRMultiModuleControl = api.CZRBaseModuleControl.extend( CZRMultiModuleControlMths );
@@ -3758,6 +5653,7 @@ $.extend( CZRMultiModuleControlMths, {
3758
  $.extend( api.controlConstructor, {
3759
  czr_module : api.CZRBaseModuleControl,
3760
  czr_multi_module : api.CZRMultiModuleControl,
 
3761
  });
3762
 
3763
  })( wp.customize, jQuery, _ );
@@ -3775,24 +5671,53 @@ $.extend( CZRMultiModuleControlMths, {
3775
  * @return {object}
3776
  */
3777
  var _coreQuery = api.previewer.query;
 
 
 
 
 
 
 
 
 
 
 
3778
  api.previewer.query = function( queryVars ) {
 
 
3779
  if ( ! serverControlParams.isSkopOn ) {
3780
  return _coreQuery.apply( this );
3781
  }
 
 
 
3782
  if ( ! _.has( api, 'czr_skope') ) {
3783
  api.consoleLog('QUERY : SKOPE IS NOT FULLY READY YEY. FALLING BACK ON CORE QUERY');
3784
  return _coreQuery.apply( this );
3785
  }
 
 
3786
  if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() ) {
3787
  api.consoleLog('QUERY : INITIAL SKOPE COLLECTION NOT POPULATED YET. FALLING BACK ON CORE QUERY');
3788
  return _coreQuery.apply( this );
3789
  }
 
 
3790
  if ( 'pending' == api.czr_isPreviewerSkopeAware.state() ) {
3791
  api.czr_isPreviewerSkopeAware.resolve();
 
3792
  }
 
 
 
3793
  if ( ! _.isObject( queryVars ) && 'resolved' == api.czr_initialSkopeCollectionPopulated.state() && 'resolved' == api.czr_initialSkopeCollectionPopulated.state() ) {
3794
  return _coreQuery.apply( this );
3795
  }
 
 
 
 
 
3796
  if ( _.isUndefined( queryVars.skope_id ) || ! _.isString( queryVars.skope_id ) ) {
3797
  queryVars.skope_id = api.czr_activeSkopeId() || api.czr_skopeBase.getGlobalSkopeId();
3798
  }
@@ -3809,22 +5734,39 @@ $.extend( CZRMultiModuleControlMths, {
3809
  _to_return;
3810
 
3811
  queryVars = $.extend( _defaults, queryVars );
 
 
3812
  if ( ! _.isObject( queryVars.the_dirties ) ) {
3813
  api.consoleLog('QUERY PARAMS : ', queryVars );
3814
  throw new Error( 'QUERY DIRTIES MUST BE AN OBJECT. Requested action : ' + queryVars.action );
3815
  }
 
 
3816
  if ( 'pending' != api.czr_isPreviewerSkopeAware.state() && _.isNull( queryVars.skope_id ) ) {
3817
  api.consoleLog('QUERY PARAMS : ', queryVars );
 
3818
  throw new Error( 'OVERRIDEN QUERY : NO SKOPE ID. FALLING BACK ON CORE QUERY. Requested action : ' + queryVars.action );
 
3819
  }
 
 
3820
  if ( ! _.contains( [ null, 'refresh', 'save', 'reset', 'changeset_update' ], queryVars.action ) ) {
3821
  api.consoleLog('QUERY PARAMS : ', queryVars );
3822
  throw new Error( 'A REQUESTED QUERY HAS NO AUTHORIZED ACTION. Requested action : ' + queryVars.action );
3823
  }
 
 
 
 
 
 
3824
  var _getSkopesCustomized = function() {
 
3825
  if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() )
3826
  return {};
3827
  var _skpCust = {};
 
 
3828
  _.each( api.czr_currentSkopesCollection(), function( _skp ) {
3829
  if ( 'global' == _skp.skope )
3830
  return;
@@ -3832,6 +5774,13 @@ $.extend( CZRMultiModuleControlMths, {
3832
  } );
3833
  return _skpCust;
3834
  };
 
 
 
 
 
 
 
3835
  if ( _.isNull( queryVars.the_dirties ) || _.isEmpty( queryVars.the_dirties ) ) {
3836
  globalCustomized = api.dirtyValues( { unsaved: queryVars.excludeCustomizedSaved || false } );
3837
  skopeCustomized = _getSkopesCustomized();
@@ -3841,9 +5790,24 @@ $.extend( CZRMultiModuleControlMths, {
3841
  else
3842
  skopeCustomized[ api.czr_activeSkopeId() ] = queryVars.the_dirties;
3843
  }
 
 
 
 
 
3844
  switch( queryVars.action ) {
3845
  case null :
3846
  case 'refresh' :
 
 
 
 
 
 
 
 
 
 
3847
  break;
3848
 
3849
  case 'changeset_update' :
@@ -3854,14 +5818,23 @@ $.extend( CZRMultiModuleControlMths, {
3854
 
3855
 
3856
  case 'save' :
 
 
 
 
 
 
3857
  if ( _.isNull( queryVars.dyn_type ) )
3858
  queryVars.dyn_type = api.czr_skope( queryVars.skope_id )().dyn_type;//post_meta, term_meta, user_meta, trans, option
3859
  if ( _.isNull( queryVars.dyn_type ) || _.isUndefined( queryVars.dyn_type ) ) {
3860
  throw new Error( 'QUERY : A SAVE QUERY MUST HAVE A VALID DYN TYPE.' + queryVars.skope_id );
3861
  }
 
 
3862
  break;
3863
 
3864
  case 'reset' :
 
3865
  if ( _.isNull( queryVars.dyn_type ) )
3866
  queryVars.dyn_type = api.czr_skope( queryVars.skope_id )().dyn_type;//post_meta, term_meta, user_meta, trans, option
3867
  if ( _.isNull( queryVars.dyn_type ) || _.isUndefined( queryVars.dyn_type ) ) {
@@ -3869,12 +5842,38 @@ $.extend( CZRMultiModuleControlMths, {
3869
  }
3870
  break;
3871
  }
 
 
 
3872
  var _current_skopes = {};
3873
  _.each( api.czr_currentSkopesCollection(), function( _skp ) {
3874
  _current_skopes[_skp.skope] = { id : _skp.id, opt_name : _skp.opt_name };
3875
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3876
  _to_return = {
3877
  wp_customize: 'on',
 
 
 
3878
  customized: '{}' == JSON.stringify( globalCustomized ) ? '{\"__not_customized__\"}' : JSON.stringify( globalCustomized ),
3879
  skopeCustomized: JSON.stringify( skopeCustomized ),
3880
  nonce: this.nonce.preview,
@@ -3888,17 +5887,21 @@ $.extend( CZRMultiModuleControlMths, {
3888
  channel: this.channel(),
3889
  revisionIndex: api._latestRevision
3890
  };
 
 
3891
  if ( api.czr_isChangeSetOn() ) {
3892
  _to_return = $.extend( _to_return , {
3893
  customize_theme: api.settings.theme.stylesheet,
3894
  customize_changeset_uuid: api.settings.changeset.uuid
3895
  });
3896
  }
 
3897
  else {
3898
  _to_return = $.extend( _to_return , {
3899
  theme: api.settings.theme.stylesheet
3900
  });
3901
  }
 
3902
  return _to_return;
3903
 
3904
  };//api.previewer.query
@@ -3906,9 +5909,139 @@ $.extend( CZRMultiModuleControlMths, {
3906
  })( wp.customize , jQuery, _ );
3907
  ( function ( api, $, _ ) {
3908
  api.bind( 'czr-skope-started', function() {
 
 
 
 
 
 
 
3909
  api.previewer.save = function( args ) {
3910
- return api.czr_skopeSave.save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3911
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3912
  });//api.bind('ready')
3913
  })( wp.customize , jQuery, _ );
3914
  (function (api, $, _) {
@@ -3918,6 +6051,17 @@ $.extend( CZRMultiModuleControlMths, {
3918
  /*****************************************************************************
3919
  * SYNCHRONIZER AUGMENTED
3920
  *****************************************************************************/
 
 
 
 
 
 
 
 
 
 
 
3921
  api.Element.synchronizer.checkbox.update = function( to ) {
3922
  this.element.prop( 'checked', to );
3923
  this.element.iCheck('update');
@@ -3927,15 +6071,22 @@ $.extend( CZRMultiModuleControlMths, {
3927
  api.Element.synchronizer.val.update = function(to) {
3928
  var self = this,
3929
  _modifySynchronizer = function() {
 
3930
  if ( self.element.is('select') ) {
 
 
3931
  self.element.val(to).trigger('change');
3932
  } else if ( self.element.hasClass('wp-color-picker') ) {
 
3933
  self.element.val(to).trigger('change');
3934
  }
3935
  else {
 
3936
  self.element.val( to );
3937
  }
3938
  };
 
 
3939
  if ( serverControlParams.isSkopOn ) {
3940
  if ( 'resolved' != api.czr_skopeReady.state() ) {
3941
  return _original.call( self, to );
@@ -3951,6 +6102,9 @@ $.extend( CZRMultiModuleControlMths, {
3951
 
3952
  api.Element.synchronizer.val.refresh = function() {
3953
  var syncApiInstance = this;
 
 
 
3954
  if ( this.element.is('select') && _.isNull( this.element.val() ) ) {
3955
  if ( _.isArray( syncApiInstance() ) )
3956
  return [];
@@ -3959,6 +6113,7 @@ $.extend( CZRMultiModuleControlMths, {
3959
  else
3960
  return '';
3961
  } else {
 
3962
  return this.element.val();
3963
  }
3964
  };
@@ -3974,14 +6129,32 @@ $.extend( CZRMultiModuleControlMths, {
3974
  );
3975
 
3976
  var previewer = this, dfd = $.Deferred();
 
 
 
3977
  if ( ! serverControlParams.isSkopOn ) {
3978
  return dfd.resolve().promise();
3979
  }
 
 
3980
  if ( ! _.has( api, 'czr_activeSkopeId') || _.isUndefined( api.czr_activeSkopeId() ) ) {
3981
  api.consoleLog( 'The api.czr_activeSkopeId() is undefined in the api.previewer._new_refresh() method.');
 
3982
  coreRefresh.apply( previewer );
3983
  return dfd.resolve().promise();
 
 
 
 
 
 
 
 
 
 
3984
  }
 
 
3985
  previewer.send( 'loading-initiated' );
3986
 
3987
  previewer.abort();
@@ -4000,7 +6173,6 @@ $.extend( CZRMultiModuleControlMths, {
4000
  signature: 'WP_CUSTOMIZER_SIGNATURE'//will be deprecated in 4.7
4001
  });
4002
 
4003
-
4004
  previewer.settingsModifiedWhileLoading = {};
4005
  onSettingChange = function( setting ) {
4006
  previewer.settingsModifiedWhileLoading[ setting.id ] = true;
@@ -4010,6 +6182,8 @@ $.extend( CZRMultiModuleControlMths, {
4010
  previewer.loading.always( function() {
4011
  api.unbind( 'change', onSettingChange );
4012
  } );
 
 
4013
  if ( ! api.czr_isChangeSetOn() ) {
4014
  previewer._previousPreview = previewer._previousPreview || previewer.preview;
4015
  }
@@ -4036,9 +6210,17 @@ $.extend( CZRMultiModuleControlMths, {
4036
  previewer.deferred.active.resolve();
4037
  delete previewer.loading;
4038
 
 
 
 
 
 
 
4039
  api.trigger( 'pre_refresh_done', { previewer : previewer, skopesServerData : skopesServerData || {} } );
4040
  dfd.resolve( { previewer : previewer, skopesServerData : skopesServerData || {} } );
4041
  };
 
 
4042
  if ( ! api.czr_isChangeSetOn() ) {
4043
  previewer.send( 'sync', {
4044
  scroll: previewer.scroll,
@@ -4049,13 +6231,20 @@ $.extend( CZRMultiModuleControlMths, {
4049
  if ( params.waitSkopeSynced ) {
4050
  loadingFrame.bind( 'czr-skopes-synced', onceSynced );
4051
  } else {
 
4052
  loadingFrame.bind( 'synced', onceSynced );
4053
  }
 
 
 
4054
  previewer.trigger( 'ready', readyData );
4055
  });
 
 
4056
  previewer.loading.fail( function( reason, location ) {
4057
- api.consoleLog('LOADING FAILED : ' , arguments );
4058
  previewer.send( 'loading-failed' );
 
4059
  if ( ! api.czr_isChangeSetOn() ) {
4060
  if ( 'redirect' === reason && location ) {
4061
  previewer.previewUrl( location );
@@ -4079,10 +6268,24 @@ $.extend( CZRMultiModuleControlMths, {
4079
 
4080
  return dfd.promise();
4081
  };//_new_refresh()
 
 
 
 
 
 
4082
  api.bind( 'czr-skope-started' , function() {
 
 
 
 
4083
  czr_override_refresh_for_skope();
 
4084
  api.Previewer.prototype.refresh = _new_refresh;
4085
  });
 
 
 
4086
  api.czr_getSkopeQueryParams = function( params ) {
4087
  if ( ! api.czr_isChangeSetOn() )
4088
  return params;
@@ -4095,6 +6298,9 @@ $.extend( CZRMultiModuleControlMths, {
4095
  }
4096
  return params;
4097
  };
 
 
 
4098
  czr_override_refresh_for_skope = function() {
4099
  if ( ! serverControlParams.isSkopOn )
4100
  return;
@@ -4103,6 +6309,24 @@ $.extend( CZRMultiModuleControlMths, {
4103
  /**
4104
  * Refresh the preview.
4105
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4106
  api.previewer.refresh = function( _params_ ) {
4107
  var dfd = $.Deferred();
4108
  var _refresh_ = function( params ) {
@@ -4154,18 +6378,61 @@ $.extend( CZRMultiModuleControlMths, {
4154
  ( function ( api, $, _ ) {
4155
  if ( ! serverControlParams.isSkopOn || ! api.czr_isChangeSetOn() )
4156
  return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4157
  var _original_requestChangesetUpdate = api.requestChangesetUpdate;
4158
 
4159
  /**
4160
  * Request updates to the changeset.
4161
- * Always calls the original method when the first promise (the skope changeset save) has been executed.
4162
- * Returns the $ promise with the set of data from the original method
4163
  *
4164
- * @param {object} [changes] Mapping of setting IDs to setting params each normally including a value property, or mapping to null.
4165
- * If not provided, then the changes will still be obtained from unsaved dirty settings.
4166
- * @returns {jQuery.Promise}
 
 
 
 
 
4167
  */
4168
- api.requestChangesetUpdate = function( changes ) {
 
4169
  var self = this,
4170
  dfd = $.Deferred(),
4171
  data,
@@ -4175,14 +6442,37 @@ $.extend( CZRMultiModuleControlMths, {
4175
  failedPromises = [],
4176
  _all_skopes_data_ = [],
4177
  _recursiveCallDeferred = $.Deferred();
 
 
 
 
 
 
 
 
 
 
4178
  if ( ! serverControlParams.isSkopOn ) {
4179
  return _original_requestChangesetUpdate();
4180
  }
 
 
 
 
 
 
 
 
 
4181
  if ( 0 === api._lastSavedRevision || _.isEmpty( api.state( 'changesetStatus' )() ) ) {
4182
  _global_skope_changes = _.extend( _global_skope_changes, {
4183
  blogname : { dummy_change : 'dummy_change' }
4184
  } );
4185
  }
 
 
 
 
4186
  _.each( api.czr_currentSkopesCollection(), function( _skp ) {
4187
  if ( 'global' == _skp.skope )
4188
  return;
@@ -4207,7 +6497,12 @@ $.extend( CZRMultiModuleControlMths, {
4207
  }
4208
  return true;
4209
  };
 
 
 
4210
  var recursiveCall = function( _index ) {
 
 
4211
  if ( _.isUndefined( _index ) || ( ( 0 * 0 ) == _index ) ) {
4212
  api.state( 'processing' ).set( 1 );
4213
  }
@@ -4217,7 +6512,10 @@ $.extend( CZRMultiModuleControlMths, {
4217
  api.consoleLog( 'Undefined Skope in changeset recursive call ', _index, _skopesToUpdate, _skopesToUpdate[_index] );
4218
  return _recursiveCallDeferred.resolve( _all_skopes_data_ ).promise();
4219
  }
4220
- api._requestSkopeChangetsetUpdate( changes, _skopesToUpdate[_index] )
 
 
 
4221
  .always( function() { _promises.push( _index ); } )
4222
  .fail( function( response ) {
4223
  failedPromises.push( response );
@@ -4233,25 +6531,76 @@ $.extend( CZRMultiModuleControlMths, {
4233
 
4234
  return _recursiveCallDeferred.promise();
4235
  };
 
 
 
 
 
 
 
 
 
4236
  var _lastSavedRevisionBefore = api._lastSavedRevision;
4237
- _original_requestChangesetUpdate( _global_skope_changes )
 
4238
  .fail( function( r ) {
4239
  api.consoleLog( 'WP requestChangesetUpdateFail', r, api.czr_skopeBase.buildServerResponse(r) );
 
 
4240
  api._lastSavedRevision = Math.max( api._latestRevision, api._lastSavedRevision );
 
 
4241
  api.state( 'processing' ).set( 0 );
4242
 
4243
  dfd.reject( r );
4244
  r = api.czr_skopeBase.buildServerResponse(r);
4245
- api.czr_serverNotification( { message: r, status : 'error' } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4246
  })
4247
  .done( function( wp_original_response ) {
 
 
 
 
 
 
4248
  if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() )
4249
  dfd.resolve( wp_original_response );
4250
 
4251
  api._lastSavedRevision = _lastSavedRevisionBefore;
4252
  recursiveCall()
4253
  .always( function() {
 
4254
  api._lastSavedRevision = Math.max( api._latestRevision, api._lastSavedRevision );
 
 
 
4255
  api.state( 'processing' ).set( 0 );
4256
  })
4257
  .fail( function( r ) {
@@ -4267,7 +6616,13 @@ $.extend( CZRMultiModuleControlMths, {
4267
 
4268
  return dfd.promise();
4269
  };
4270
- api._requestSkopeChangetsetUpdate = function( changes, skope_id ) {
 
 
 
 
 
 
4271
  if ( _.isUndefined( skope_id ) || ! api.czr_skope.has( skope_id ) ) {
4272
  throw new Error( 'In api._requestSkopeChangetsetUpdate() : a valid and registered skope_id must be provided' );
4273
  }
@@ -4275,12 +6630,35 @@ $.extend( CZRMultiModuleControlMths, {
4275
  var deferred = new $.Deferred(),
4276
  request,
4277
  submittedChanges = {},
4278
- data;
 
 
 
4279
  skope_id = skope_id || api.czr_activeSkopeId();
4280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4281
  if ( changes ) {
4282
  _.extend( submittedChanges, changes );
4283
  }
 
 
 
4284
  _.each( api.czr_skopeBase.getSkopeDirties( skope_id ) , function( dirtyValue, settingId ) {
4285
  if ( ! changes || null !== changes[ settingId ] ) {
4286
  submittedChanges[ settingId ] = _.extend(
@@ -4290,15 +6668,37 @@ $.extend( CZRMultiModuleControlMths, {
4290
  );
4291
  }
4292
  } );
4293
- if ( _.isEmpty( submittedChanges ) ) {
 
 
 
 
 
 
 
 
 
4294
  deferred.resolve( {} );
4295
  return deferred.promise();
4296
  }
4297
 
 
 
 
 
 
 
 
 
 
 
 
4298
  if ( api._latestRevision <= api._lastSavedRevision ) {
4299
  deferred.resolve( {} );
4300
  return deferred.promise();
4301
  }
 
 
4302
  api.trigger( 'skope-changeset-save', submittedChanges );
4303
 
4304
  var queryVars = {
@@ -4306,24 +6706,41 @@ $.extend( CZRMultiModuleControlMths, {
4306
  action : 'changeset_update',
4307
  opt_name : api.czr_skope( skope_id ).opt_name
4308
  };
 
 
4309
  data = api.previewer.query( _.extend( queryVars, { excludeCustomizedSaved: true } ) );
4310
  delete data.customized; // Being sent in customize_changeset_data instead.
4311
  _.extend( data, {
4312
  nonce: api.settings.nonce.save,
4313
  customize_changeset_data: JSON.stringify( submittedChanges )
4314
  } );
 
 
 
 
 
 
 
 
 
 
 
4315
  wp.ajax.post( 'customize_skope_changeset_save', data )
4316
  .done( function requestChangesetUpdateDone( _data_ ) {
 
4317
  deferred.resolve( _data_ );
 
4318
  } )
4319
  .fail( function requestChangesetUpdateFail( _data_ ) {
4320
  api.consoleLog('SKOPE CHANGESET FAIL FOR SKOPE ' + _data_.skope_id, _data_ );
4321
  deferred.reject( _data_ );
 
4322
  } )
4323
  .always( function( _data_ ) {
4324
- if ( _data_.setting_validities ) {
4325
  api._handleSettingValidities( {
4326
- settingValidities: _data_.setting_validities
 
4327
  } );
4328
  }
4329
  } );
@@ -4335,7 +6752,12 @@ $.extend( CZRMultiModuleControlMths, {
4335
  /*****************************************************************************
4336
  * FIRE SKOPE ON READY
4337
  *****************************************************************************/
4338
- api.czr_skopeReady = $.Deferred();
 
 
 
 
 
4339
  api.bind( 'ready' , function() {
4340
  if ( serverControlParams.isSkopOn ) {
4341
  api.czr_isLoadingSkope = new api.Value( false );
@@ -4343,10 +6765,13 @@ $.extend( CZRMultiModuleControlMths, {
4343
  toggleSkopeLoadPane( loading );
4344
  });
4345
  api.czr_skopeBase = new api.CZR_skopeBase();
4346
- api.czr_skopeSave = new api.CZR_skopeSave();
4347
  api.czr_skopeReset = new api.CZR_skopeReset();
4348
 
4349
  api.trigger('czr-skope-started');
 
 
 
4350
  var _toggleTopFailureNote = function() {
4351
  api.czr_skopeBase.toggleTopNote( true, {
4352
  title : serverControlParams.i18n.skope['There was a problem when trying to load the customizer.'],
@@ -4368,15 +6793,22 @@ $.extend( CZRMultiModuleControlMths, {
4368
  })
4369
  .fail( function( error ) {
4370
  api.errorLog( 'Skope could not be instantiated : ' + error );
 
4371
  _toggleTopFailureNote();
4372
  serverControlParams.isSkopOn = false;
4373
  })
4374
  .always( function() {
4375
  api.czr_isLoadingSkope( false );
4376
  });
 
 
4377
  if ( 'rejected' != api.czr_skopeReady.state() ) {
 
 
 
4378
  setTimeout( function() {
4379
  if ( 'pending' == api.czr_skopeReady.state() ) {
 
4380
  _toggleTopFailureNote();
4381
 
4382
  api.czr_isLoadingSkope( false );
@@ -4384,10 +6816,14 @@ $.extend( CZRMultiModuleControlMths, {
4384
  }, 40000);
4385
  }
4386
  }
 
 
4387
  if ( serverControlParams.isChangeSetOn ) {
4388
  api.settings.timeouts.changesetAutoSave = 10000;
4389
  }
4390
  } );
 
 
4391
  if ( ! _.has( api, '_latestRevision') ) {
4392
  /**
4393
  * Current change count.
@@ -4419,6 +6855,8 @@ $.extend( CZRMultiModuleControlMths, {
4419
  } );
4420
  } );
4421
  }
 
 
4422
  var toggleSkopeLoadPane = function( loading ) {
4423
  loading = _.isUndefined( loading ) ? true : loading;
4424
  var self = this, $skopeLoadingPanel,
@@ -4452,6 +6890,8 @@ $.extend( CZRMultiModuleControlMths, {
4452
  });
4453
  }, 50);
4454
  };
 
 
4455
  if ( 'pending' == api.czr_skopeReady.state() && loading ) {
4456
  $('body').addClass('czr-skop-loading');
4457
  _render()
@@ -4463,8 +6903,10 @@ $.extend( CZRMultiModuleControlMths, {
4463
  return;
4464
 
4465
  _.delay( function() {
 
4466
  var _height = $('#customize-preview').height();
4467
  $skopeLoadingPanel.css( 'line-height', _height +'px' ).css( 'height', _height + 'px' );
 
4468
  $('body').addClass('czr-skope-pane-open');
4469
  }, 50 );
4470
  });
@@ -4473,6 +6915,7 @@ $.extend( CZRMultiModuleControlMths, {
4473
  api.czr_skopeReady.done( function() {
4474
  _destroy();
4475
  });
 
4476
  if ( ! loading ) {
4477
  _destroy();
4478
  }
@@ -4480,6 +6923,143 @@ $.extend( CZRMultiModuleControlMths, {
4480
 
4481
  })( wp.customize , jQuery, _);
4482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4483
 
4484
 
4485
 
@@ -4494,28 +7074,66 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4494
 
4495
  initialize: function() {
4496
  var self = this;
 
4497
  self.skope_colors = {
4498
  global : 'rgb(255, 255, 255)',
4499
  special_group : 'rgba(173, 213, 247, 0.55)',
4500
- group : 'rgba(39, 59, 88, 0.12)',// 'rgba(173, 213, 247, 0.55)',
4501
- local : 'rgba(39, 59, 88, 0.28)'// 'rgba(78, 122, 199, 0.35)'
4502
  };
 
4503
  api.czr_isPreviewerSkopeAware = $.Deferred();
 
4504
  api.czr_initialSkopeCollectionPopulated = $.Deferred();
 
4505
  self.skopeWrapperEmbedded = $.Deferred();
 
 
4506
  api.czr_skope = new api.Values();
 
 
 
 
4507
  api.czr_skopeCollection = new api.Value([]);//all available skope, including the current skopes
 
4508
  api.czr_currentSkopesCollection = new api.Value([]);
 
 
 
4509
  api.czr_activeSkopeId = new api.Value();
 
4510
  api.czr_dirtyness = new api.Value( false );
 
4511
  api.czr_isResettingSkope = new api.Value( false );
 
 
4512
  api.state.create('switching-skope')( false );
 
 
 
4513
  api.czr_dirtyness.callbacks.add( function() { return self.apiDirtynessReact.apply(self, arguments ); } );
 
 
 
4514
  api.czr_isLoadingSkope( true );
 
 
 
4515
  self.bindAPISettings();
4516
- api.state.bind( 'change', function() {
4517
- self.setSaveButtonStates();
4518
- });
 
 
 
 
 
 
 
 
 
 
 
4519
  api.czr_skopeReady.then( function() {
4520
  if ( 'pending' == self.skopeWrapperEmbedded.state() ) {
4521
  $.when( self.embedSkopeWrapper() ).done( function() {
@@ -4523,12 +7141,27 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4523
  });
4524
  }
4525
  });
 
 
 
 
 
 
 
 
 
 
 
 
4526
  api.previewer.bind( 'czr-skopes-synced', function( data ) {
4527
  if ( ! serverControlParams.isSkopOn || 'rejected' == api.czr_skopeReady.state() ) {
4528
  return;
4529
  }
 
4530
  var preview = this,
4531
  previousSkopeCollection = api.czr_currentSkopesCollection();
 
 
4532
  if ( ! _.has( data, 'czr_skopes') ) {
4533
  if ( 'resolved' != api.czr_skopeReady.state() ) {
4534
  api.czr_skopeReady.reject();
@@ -4536,23 +7169,42 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4536
  api.errorLog( "On 'czr-skopes-synced' : missing skopes in the server data" );
4537
  return;
4538
  }
 
 
 
 
4539
  try {
4540
  api.czr_skopeBase.updateSkopeCollection( data.czr_skopes , preview.channel() );
4541
  } catch ( er ) {
4542
  api.czr_skopeReady.reject( er );
4543
  return;
4544
  }
 
 
 
 
4545
  var _refreshSkopeInfosNotices = function() {
 
4546
  self._writeCurrentSkopeTitle();
 
 
 
 
4547
  if ( api.czr_bottomInfosVisible() ) {
4548
  self.renderBottomInfosTmpl();//<= will build a new bottom skope message infos in the preview based on the new active skopes
4549
  } else {
 
4550
  api.czr_bottomInfosVisible( true );
4551
  }
4552
  };
 
 
 
4553
  api.czr_initialSkopeCollectionPopulated.then( function() {
4554
  var refreshActiveSkope = _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), {id : api.czr_activeSkopeId() } ) );
4555
  api.czr_skopeBase.reactWhenSkopeSyncedDone( data ).done( function() {
 
 
4556
  if ( refreshActiveSkope ) {
4557
  try {
4558
  api.czr_activeSkopeId( self.getActiveSkopeId() )
@@ -4560,6 +7212,7 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4560
  if ( 'resolved' != api.czr_skopeReady.state() ) {
4561
  api.czr_skopeReady.resolve( self.getActiveSkopeId() );
4562
  }
 
4563
  _refreshSkopeInfosNotices();
4564
  })
4565
  .fail( function() {
@@ -4573,17 +7226,32 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4573
  _newLoc =_.findWhere( data.czr_skopes, { skope : 'local' } ).opt_name;
4574
 
4575
  if ( _newLoc !== _prevLoc && 'resolved' == api.czr_skopeReady.state() ) {
 
4576
  _refreshSkopeInfosNotices();
4577
  }
4578
  }
4579
  });
4580
  });
4581
  });
 
 
 
 
 
 
 
4582
  api.czr_currentSkopesCollection.bind( function( to, from ) {
4583
  return self.currentSkopesCollectionReact( to, from );
4584
  }, { deferred : true });
 
 
 
 
4585
  api.czr_initialSkopeCollectionPopulated.done( function() {
 
 
4586
  api.czr_activeSkopeId.bind( function( to, from ) {
 
4587
  if ( _.has( api, 'czr_ModOptVisible') ) {
4588
  api.czr_ModOptVisible( false );
4589
  }
@@ -4597,9 +7265,29 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4597
  );
4598
  });
4599
  }, { deferred : true } );
 
 
 
4600
  api.czr_activeSectionId.callbacks.add( function() { return self.activeSectionReact.apply(self, arguments ); } );
 
 
 
4601
  api.czr_activePanelId.callbacks.add( function() { return self.activePanelReact.apply(self, arguments ); } );
 
 
 
4602
  });
 
 
 
 
 
 
 
 
 
 
 
4603
  api.bind( 'skope-switched-done', function( args ) {
4604
  args = _.extend(
4605
  {
@@ -4611,12 +7299,28 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4611
  );
4612
  return self.skopeSwitchedDoneReact( args );
4613
  });
 
 
 
 
4614
  api.czr_serverNotification = new api.Value( {status : 'success', message : '', expanded : true} );
4615
  api.czr_serverNotification.bind( function( to, from ) {
4616
  self.toggleServerNotice( to );
4617
  });
 
 
 
 
 
 
 
4618
  self._setupPreviewNotificationsBlocks();//top note and bottom skope infos
 
 
 
 
4619
  self.scopeSwitcherEventMap = [
 
4620
  {
4621
  trigger : 'click keydown',
4622
  selector : '.czr-dismiss-notification',
@@ -4625,6 +7329,7 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4625
  api.czr_serverNotification( { expanded : false } );
4626
  }
4627
  },
 
4628
  {
4629
  trigger : 'click keydown',
4630
  selector : '.czr-toggle-title-notice',
@@ -4642,11 +7347,31 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4642
  }
4643
  }
4644
  ];
 
 
4645
  self.skopeWrapperEmbedded.then( function() {
4646
  api.CZR_Helpers.setupDOMListeners( self.scopeSwitcherEventMap , { dom_el : $('.czr-scope-switcher') }, self );
4647
  });
 
 
 
 
4648
  self.refreshedControls = [ 'czr_cropped_image'];// [ 'czr_cropped_image', 'czr_multi_module', 'czr_module' ];
 
 
4649
  self.initWidgetSidebarSpecifics();
 
 
 
 
 
 
 
 
 
 
 
 
4650
  api.bind( 'czr-paint', function( params ) {
4651
  api.czr_skopeReady.then( function() {
4652
  self.wash( params ).paint( params );
@@ -4673,11 +7398,16 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4673
  /*****************************************************************************
4674
  * EMBED WRAPPER
4675
  *****************************************************************************/
 
 
 
 
4676
  embedSkopeWrapper : function() {
4677
  var self = this;
4678
  $('#customize-header-actions').append( $('<div/>', {class:'czr-scope-switcher', html:'<div class="czr-skopes-wrapper"></div>'}) );
4679
  $('body').addClass('czr-skop-on');
4680
  var _eventMap = [
 
4681
  {
4682
  trigger : 'click keydown',
4683
  selector : '.czr-skope-switch',
@@ -4703,6 +7433,7 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4703
  /*****************************************************************************
4704
  * API DIRTYNESS REACTIONS
4705
  *****************************************************************************/
 
4706
  apiDirtynessReact : function( is_dirty ) {
4707
  $('body').toggleClass('czr-api-dirty', is_dirty );
4708
  api.state( 'saved')( ! is_dirty );
@@ -4719,7 +7450,10 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4719
  /*****************************************************************************
4720
  * OVERRIDE SAVE BUTTON STATES : api.state.bind( 'change') callback
4721
  *****************************************************************************/
 
4722
  setSaveButtonStates : function() {
 
 
4723
  if ( ! api.state.has('saving') ) {
4724
  api.state.create('saving');
4725
  api.state('saving').bind( function( isSaving ) {
@@ -4743,9 +7477,31 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4743
  var canSave = ! saving() && ( ! activated() || ! saved() ) && 'publish' !== changesetStatus;
4744
  saveBtn.prop( 'disabled', ! canSave );
4745
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4746
  skopeSwitchedDoneReact : function( args ) {
4747
  var self = this,
4748
  _doWhenSkopeReady = function() {
 
4749
  api.czr_CrtlDependenciesReady.then( function() {
4750
  if ( ! _.isUndefined( api.czr_activeSectionId() ) && ! _.isEmpty( api.czr_activeSectionId() ) ) {
4751
  try {
@@ -4755,13 +7511,21 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4755
  }
4756
  }
4757
  });
 
 
4758
  self.updateCtrlSkpNot( api.CZR_Helpers.getSectionControlIds() );
 
 
4759
  if ( api.czr_skope.has( args.previous_skope_id ) ) {
4760
  $( '#customize-controls' ).removeClass( [ 'czr-', api.czr_skope( args.previous_skope_id )().skope, '-skope-level'].join('') );
4761
  }
4762
  if ( api.czr_skope.has( args.current_skope_id ) ) {
4763
  $( '#customize-controls' ).addClass( [ 'czr-', api.czr_skope( args.current_skope_id )().skope, '-skope-level'].join('') );
4764
  }
 
 
 
 
4765
  var _setupSectionControlDialogs = function() {
4766
  if ( _.isUndefined( api.czr_activeSectionId() ) || _.isEmpty( api.czr_activeSectionId() ) )
4767
  return;
@@ -4773,27 +7537,60 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4773
  return;
4774
 
4775
  ctrl.deferred.embedded.then( function() {
 
 
4776
  ctrl.czr_states( 'noticeVisible' )( self.isCtrlNoticeVisible( ctrlId ) );
4777
  ctrl.czr_states( 'resetVisible' )( false );
4778
  });
4779
  });
4780
  });
4781
  };
 
 
 
 
4782
  if ( api.czr_bottomInfosVisible() ) {
4783
  self.renderBottomInfosTmpl();//<= will build a new bottom skope message infos in the preview based on the new active skopes
4784
  } else {
 
4785
  api.czr_bottomInfosVisible( true );
4786
  }
 
 
 
4787
  _.delay( function() {
4788
  _setupSectionControlDialogs();
4789
  }, 500 );
4790
  };
 
 
 
 
 
 
4791
  api.czr_skopeReady.then( function() {
4792
  _doWhenSkopeReady();
4793
  });
4794
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4795
  _setupPreviewNotificationsBlocks : function() {
4796
  var self = this;
 
4797
  api.czr_topNoteVisible = new api.Value( false );
4798
  api.czr_skopeReady.then( function() {
4799
  api.czr_topNoteVisible.bind( function( visible ) {
@@ -4804,7 +7601,16 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4804
  actions : '',
4805
  selfCloseAfter : 20000
4806
  };
 
 
 
 
 
 
 
4807
  noteParams = $.extend( _defaultParams , serverControlParams.topNoteParams );
 
 
4808
  noteParams.actions = function() {
4809
  var _query = $.extend(
4810
  api.previewer.query(),
@@ -4818,12 +7624,19 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4818
 
4819
  self.toggleTopNote( visible, noteParams );
4820
  });
 
 
4821
  _.delay( function() {
4822
  api.czr_topNoteVisible( ! _.isEmpty( serverControlParams.isTopNoteOn ) || 1 == serverControlParams.isTopNoteOn );
4823
  }, 2000 );
4824
  });
 
 
 
 
4825
  api.czr_bottomInfosVisible = new api.Value( false );
4826
  api.czr_skopeReady.then( function() {
 
4827
  api.czr_bottomInfosVisible.bind( function( visible ) {
4828
  var noteParams = {},
4829
  _defaultParams = {
@@ -4832,10 +7645,19 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4832
  actions : '',
4833
  selfCloseAfter : 20000
4834
  };
 
 
 
 
 
 
 
4835
  noteParams = $.extend( _defaultParams , {} );
4836
 
4837
  return self.toggleBottomInfos( visible, noteParams );//returns a promise()
4838
  }, { deferred : true } );
 
 
4839
  var _skopeInfosSetId = api.CZR_Helpers.build_setId( 'show-skope-infos' );
4840
  api.when( _skopeInfosSetId, function( _set_ ){
4841
  api.czr_bottomInfosVisible.validate = function( value ) {
@@ -4844,21 +7666,63 @@ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4844
 
4845
  return _isChecked ? value : false;
4846
  };
 
 
4847
  _set_.bind( function( visible ) {
4848
  api.czr_bottomInfosVisible( 0 !== visible && '0' !== visible && false !== visible && 'off' !== visible );
4849
  });
4850
  });
 
 
 
 
4851
  _.delay( function() {
4852
  api.czr_bottomInfosVisible( true );
4853
  }, 2000 );
4854
  });//api.czr_skopeReady.then()
4855
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4856
  });//$.extend()
4857
  })( wp.customize , jQuery, _);
4858
 
4859
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4860
  (function ( api, $, _ ) {
4861
  $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
 
 
 
4862
  toggleServerNotice : function( notice ) {
4863
  notice = _.isObject( notice ) ? notice : {};
4864
  notice = _.extend( {
@@ -4867,8 +7731,12 @@ $.extend( CZRSkopeBaseMths, {
4867
  message : '',
4868
  auto_collapse : false
4869
  }, notice );
 
 
4870
  if ( 'changeset_already_published' == notice.message )
4871
  return;
 
 
4872
  if ( ! serverControlParams.isDevMode )
4873
  return;
4874
 
@@ -4890,8 +7758,16 @@ $.extend( CZRSkopeBaseMths, {
4890
  _header_height,
4891
  _notif_wrap_height,
4892
  _set_height = function( _h ) {
 
 
 
 
 
 
4893
  return true;
4894
  };
 
 
4895
  if ( self.skopeTitleNoticeVisible )
4896
  self.skopeTitleNoticeVisible( false );
4897
 
@@ -4900,6 +7776,7 @@ $.extend( CZRSkopeBaseMths, {
4900
  .fadeOut( {
4901
  duration : 200,
4902
  complete : function() {
 
4903
  } } );
4904
  setTimeout( function() {
4905
  _set_height();
@@ -4929,6 +7806,8 @@ $.extend( CZRSkopeBaseMths, {
4929
  }, 400 );
4930
  }
4931
  };
 
 
4932
  if ( 'pending' == self.serverNoticeEmbedded.state() ) {
4933
  $.when( _embed() ).done( function() {
4934
  setTimeout( function() {
@@ -4939,18 +7818,31 @@ $.extend( CZRSkopeBaseMths, {
4939
  } else {
4940
  _toggleNotice();
4941
  }
 
 
4942
  _.delay( function() {
4943
  api.czr_serverNotification( { expanded : false } );
4944
  },
4945
  ( 'success' == notice.status || false !== notice.auto_collapse ) ? 4000 : 5000
4946
  );
4947
  },
 
 
 
4948
  buildServerResponse : function( _r ) {
4949
  var resp = false;
 
4950
  if ( _.isObject( _r ) ) {
4951
  if ( _.has( _r, 'responseJSON') && ! _.isUndefined( _r.responseJSON.data ) && ! _.isEmpty( _r.responseJSON.data ) ) {
4952
  resp = _r.responseJSON.data;
4953
  }
 
 
 
 
 
 
 
4954
  else if ( _.has( _r , 'statusText' ) && ! _.isEmpty( _r.statusText ) ) {
4955
  resp = _r.statusText;
4956
  }
@@ -4964,6 +7856,7 @@ $.extend( CZRSkopeBaseMths, {
4964
  } else if ( ! resp ) {
4965
  resp = '0' === _r ? 'Not logged in.' : _r;
4966
  } else if ( '-1' === _r ) {
 
4967
  resp = 'Identification issue detected, please refresh your page.';
4968
  }
4969
  return resp;
@@ -4973,6 +7866,14 @@ $.extend( CZRSkopeBaseMths, {
4973
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4974
  (function ( api, $, _ ) {
4975
  $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
 
 
4976
  toggleTopNote : function( visible, noteParams ) {
4977
  noteParams = _.isObject( noteParams ) ? noteParams : {};
4978
  var self = this,
@@ -4985,6 +7886,7 @@ $.extend( CZRSkopeBaseMths, {
4985
  _renderAndSetup = function() {
4986
  $.when( self.renderTopNoteTmpl( noteParams ) ).done( function( $_el ) {
4987
  self.welcomeNote = $_el;
 
4988
  _.delay( function() {
4989
  $('body').addClass('czr-top-note-open');
4990
  }, 200 );
@@ -5010,6 +7912,7 @@ $.extend( CZRSkopeBaseMths, {
5010
  var dfd = $.Deferred();
5011
  $('body').removeClass('czr-top-note-open');
5012
  if ( self.welcomeNote.length ) {
 
5013
  _.delay( function() {
5014
  self.welcomeNote.remove();
5015
  dfd.resolve();
@@ -5029,12 +7932,17 @@ $.extend( CZRSkopeBaseMths, {
5029
  api.czr_topNoteVisible( false );//should be already false
5030
  });
5031
  }
 
 
5032
  _.delay( function() {
5033
  api.czr_topNoteVisible( false );
5034
  },
5035
  noteParams.selfCloseAfter || 20000
5036
  );
5037
  },
 
 
 
5038
  renderTopNoteTmpl : function( params ) {
5039
  if ( $( '#czr-top-note' ).length )
5040
  return $( '#czr-top-note' );
@@ -5062,36 +7970,64 @@ $.extend( CZRSkopeBaseMths, {
5062
  /*****************************************************************************
5063
  * WORDPRESS API ACTIONS ON INIT
5064
  *****************************************************************************/
 
 
 
 
 
 
5065
  bindAPISettings : function( requestedSetId ) {
5066
  var self = this,
 
5067
  _settingChangeReact = function( new_val, old_val, o ) {
 
5068
  var setId = this.id,
5069
  skope_id;
 
 
 
5070
  if ( ! serverControlParams.isSkopOn )
5071
  return;
5072
 
5073
  if ( ! _.has( api, 'czr_activeSkopeId') || _.isUndefined( api.czr_activeSkopeId() ) ) {
5074
  api.errorLog( 'The api.czr_activeSkopeId() is undefined in the api.czr_skopeBase.bindAPISettings method.');
 
5075
  }
 
 
 
 
 
 
 
5076
  if ( api( setId )._dirty ) {
5077
  skope_id = self.isSettingSkopeEligible( setId ) ? api.czr_activeSkopeId() : self.getGlobalSkopeId();
5078
  api.czr_skope( skope_id ).updateSkopeDirties( setId, new_val );
5079
  }
 
 
5080
  if ( _.has( api.control(setId), 'czr_states' ) && ! api.control(setId).czr_states( 'isResetting' )() ) {
5081
  api.control( setId ).czr_states( 'resetVisible' )( false );
5082
  }
 
 
5083
  if ( self.isSettingSkopeEligible( setId ) ) {
5084
  self.updateCtrlSkpNot( setId );
5085
  }
5086
  };//_settingChangeReact()
 
 
5087
  if ( ! _.isUndefined( requestedSetId ) ) {
5088
  api( requestedSetId ).bind( _settingChangeReact );
5089
  }
5090
  else {
 
5091
  api.each( function ( _setting ) {
5092
  _setting.bind( _settingChangeReact );
5093
  });
5094
  }
 
 
5095
  var _dynamicallyAddedSettingsReact = function( setting_instance ) {
5096
  if ( setting_instance.callbacks.has( _settingChangeReact ) )
5097
  return;
@@ -5111,38 +8047,66 @@ $.extend( CZRSkopeBaseMths, {
5111
  /*****************************************************************************
5112
  * REACT ON SKOPE SYNCED
5113
  *****************************************************************************/
 
 
 
 
 
 
5114
  reactWhenSkopeSyncedDone : function( server_params ) {
5115
  var self = this, dfd = $.Deferred();
5116
  if ( ! _.has( server_params, 'czr_skopes' ) || _.isEmpty( server_params.czr_skopes ) ) {
5117
  api.errorLog( 'Missing skope data after refresh', server_params );
5118
  return dfd.resolve().promise();
5119
  }
 
5120
  if ( ! api.czr_dirtyness() ) {
5121
  api.czr_dirtyness( _.isBoolean( server_params.isChangesetDirty ) ? server_params.isChangesetDirty : false );
5122
  }
5123
 
5124
  var _sentSkopeCollection = server_params.czr_skopes;
 
 
 
5125
  _.each( api.czr_skopeCollection(), function( _skp ) {
5126
  var _sent_skope = _.findWhere( _sentSkopeCollection, { opt_name : _skp.opt_name } );
 
5127
  if ( _.isUndefined( _sent_skope ) )
5128
  return;
 
5129
  var _changeset_candidate = _.isEmpty( _sent_skope.changeset || {} ) ? {} : _sent_skope.changeset,
5130
  _api_ready_chgset = {};
 
 
5131
  _.each( _changeset_candidate, function( _val, _setId ) {
5132
  if ( ! api.has( _setId ) ) {
5133
  api.consoleLog( 'In reactWhenSkopeSyncedDone : attempting to update the changeset with a non registered setting : ' + _setId );
5134
  }
5135
  _api_ready_chgset[_setId] = _val;
5136
  });
 
 
 
5137
  api.czr_skope( _skp.id ).changesetValues( _api_ready_chgset );
5138
  });
 
 
 
 
 
 
5139
  _.each( api.czr_skopeCollection(), function( _skp ) {
5140
  var _sent_skope = _.findWhere( _sentSkopeCollection, { opt_name : _skp.opt_name } );
 
5141
  if ( _.isUndefined( _sent_skope ) )
5142
  return;
 
 
5143
  var _current_db_vals = $.extend( true, {}, api.czr_skope( _skp.id ).dbValues() ),
5144
  _dbVals_candidate = $.extend( _current_db_vals , _sent_skope.db || {} ),
5145
  _api_ready_dbvals = {};
 
 
5146
  _.each( _dbVals_candidate, function( _val, _setId ) {
5147
  if ( ! api.has( _setId ) ) {
5148
  api.consoleLog( 'In reactWhenSkopeSyncedDone : attempting to update the db values with a non registered setting : ' + _setId );
@@ -5153,6 +8117,8 @@ $.extend( CZRSkopeBaseMths, {
5153
 
5154
  api.czr_skope( _skp.id ).dbValues( _api_ready_dbvals );
5155
  });
 
 
5156
  _.delay( function() {
5157
  dfd.resolve();
5158
  }, 500 );
@@ -5168,13 +8134,19 @@ $.extend( CZRSkopeBaseMths, {
5168
  /*****************************************************************************
5169
  * REACT ON ACTIVE SECTION SETUP DONE
5170
  *****************************************************************************/
 
 
5171
  _maybeSetupAssignedMenuLocations : function( active_section ) {
5172
  if ( _.isUndefined( active_section ) || _.isEmpty( active_section ) || ! api.section.has( active_section.id ) ) {
5173
  api.consoleLog( 'In _maybeSetupAssignedMenuLocations : no valid section_id provided.');
5174
  }
5175
  var self = this;
 
5176
  if ( ! active_section.assignedLocations )
5177
  return;
 
 
 
5178
  var _assignedLocReact = function( locations ) {};
5179
 
5180
  if ( ! active_section.assignedLocations.callbacks.has( _assignedLocReact ) ) {
@@ -5187,13 +8159,16 @@ $.extend( CZRSkopeBaseMths, {
5187
  /*****************************************************************************
5188
  * REACT TO ACTIVE SECTION EXPANSION
5189
  *****************************************************************************/
 
5190
  activeSectionReact : function( active_sec_id , previous_sec_id ) {
 
5191
  if ( 'add_menu' != active_sec_id ) {
5192
  api.trigger('czr-paint', { active_section_id : active_sec_id } );
5193
  }
5194
 
5195
  var self = this,
5196
  _doReactPrevious = function( previous_sec_id ) {
 
5197
  var controls = api.CZR_Helpers.getSectionControlIds( previous_sec_id );
5198
  _.each( controls, function( ctrlId ) {
5199
  if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
@@ -5206,14 +8181,24 @@ $.extend( CZRSkopeBaseMths, {
5206
  });
5207
  },
5208
  _doReactActive = function( active_section, active_sec_id ) {
 
5209
  self.setupActiveSkopedControls( {
5210
  section_id : active_sec_id
5211
  });
 
 
5212
  self.processSilentUpdates( { section_id : active_sec_id } )
5213
  .fail( function() {
5214
  throw new Error( 'Fail to process silent updates after initial skope collection has been populated' );
5215
  })
5216
  .done( function() {
 
 
 
 
 
 
 
5217
  var _setupSectionCtrlNotices = function() {
5218
  var controls = api.CZR_Helpers.getSectionControlIds( active_sec_id );
5219
  _.each( controls, function( ctrlId ) {
@@ -5225,13 +8210,24 @@ $.extend( CZRSkopeBaseMths, {
5225
  ctrl.czr_states( 'noticeVisible' )( self.isCtrlNoticeVisible( ctrlId ) );
5226
  });
5227
  };
 
 
 
5228
  _.delay( function() {
5229
  _setupSectionCtrlNotices();
5230
  }, 700 );
 
 
5231
  if ( ! self.isExcludedSidebarsWidgets() ) {
5232
  self.forceSidebarDirtyRefresh( active_sec_id , api.czr_activeSkopeId() );
5233
  }
5234
  });
 
 
 
 
 
 
5235
  if ( ! _.has( api.topics, 'active-section-setup' ) ) {
5236
  api.bind( 'active-section-setup', function( params ) {
5237
  var defaults = {
@@ -5242,36 +8238,96 @@ $.extend( CZRSkopeBaseMths, {
5242
  self._maybeSetupAssignedMenuLocations( params );
5243
  });
5244
  }
 
 
5245
  api.czr_skopeReady.then( function() {
5246
  var _switchBack = function( _title ) {
5247
- api.czr_serverNotification({
5248
- status:'success',
5249
- message : [ _title, serverControlParams.i18n.skope['can only be customized sitewide.'] ].join(' ')
5250
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5251
  api.czr_activeSkopeId( self.getGlobalSkopeId() );
5252
  };
 
5253
  if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
5254
- if (
5255
- self.isExcludedWPCustomCss() &&
5256
- ( 'custom_css' == active_sec_id || 'admin_sec' == active_sec_id )
5257
- ) {
5258
  _switchBack( api.section( active_sec_id ).params.title );
5259
  }
5260
 
5261
  if ( 'nav_menu[' == active_sec_id.substring( 0, 'nav_menu['.length ) || 'add_menu' == active_sec_id ) {
5262
- api.czr_serverNotification({
5263
- status:'success',
5264
- message : [
5265
- serverControlParams.i18n.skope['Menus are created sitewide.']
5266
- ].join(' ')
5267
- });
5268
- }
5269
- }
5270
- });
5271
- api.trigger('active-section-setup', active_section );
5272
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5273
  api.czr_initialSkopeCollectionPopulated.then( function() {
5274
  api.section.when( active_sec_id , function( active_section ) {
 
 
 
 
 
5275
  active_section.deferred.embedded.then( function() {
5276
  try { _doReactActive( active_section, active_sec_id ); } catch( er ) {
5277
  api.errorLog( 'activeSectionReact => _doReactActive : ' + er );
@@ -5289,32 +8345,85 @@ $.extend( CZRSkopeBaseMths, {
5289
  /*****************************************************************************
5290
  * REACT TO ACTIVE PANEL EXPANSION
5291
  *****************************************************************************/
 
5292
  activePanelReact : function( active_panel_id , previous_panel_id ) {
5293
  var self = this;
5294
  api.czr_initialSkopeCollectionPopulated.then( function() {
5295
  api.trigger('czr-paint', { active_panel_id : active_panel_id } );
5296
  var _switchBack = function( _title ) {
5297
- api.czr_serverNotification({
5298
- status:'success',
5299
- message : [ _title, serverControlParams.i18n.skope['can only be customized sitewide.'] ].join(' ')
5300
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5301
  api.czr_activeSkopeId( self.getGlobalSkopeId() );
5302
  };
 
 
5303
  api.czr_skopeReady.then( function() {
5304
  if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
5305
  if ( self.isExcludedSidebarsWidgets() && 'widgets' == active_panel_id ) {
5306
- api.czr_serverNotification({
5307
- status:'success',
5308
- message : [
5309
- serverControlParams.i18n.skope['Widgets are created sitewide.']
5310
- ].join(' ')
5311
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5312
  }
5313
  }
5314
  });
 
 
 
5315
  api.czr_skopeReady.then( function() {
5316
  if ( 'nav_menus' == active_panel_id ) {
5317
  _.each( api.panel( active_panel_id ).sections(), function( _sec ) {
 
5318
  self.processSilentUpdates( { section_id : _sec.id, awake_if_not_active : true } );
5319
  });
5320
  }
@@ -5333,8 +8442,15 @@ $.extend( CZRSkopeBaseMths, {
5333
  /*****************************************************************************
5334
  * PAINT AND WASH
5335
  *****************************************************************************/
 
 
 
 
 
 
5336
  wash : function( params ) {
5337
  var self = this,
 
5338
  _do_wash = function( element ) {
5339
  if ( ! _.has( element, 'el') || ! element.el.length )
5340
  return;
@@ -5348,6 +8464,13 @@ $.extend( CZRSkopeBaseMths, {
5348
  }
5349
  return this;
5350
  },
 
 
 
 
 
 
 
5351
  paint : function( params ) {
5352
  var _bgColor = 'inherit',
5353
  defaults = {
@@ -5361,9 +8484,12 @@ $.extend( CZRSkopeBaseMths, {
5361
  if ( ! _.isUndefined( api.czr_activeSkopeId() ) && api.czr_skope.has( api.czr_activeSkopeId() ) ) {
5362
  _bgColor = api.czr_skope( api.czr_activeSkopeId() ).color;
5363
  }
 
 
5364
  var _do_paint = function( element ) {
5365
  if ( ! _.has( element, 'el') || ! element.el.length )
5366
  return;
 
5367
  if ( params.is_skope_switch ) {
5368
  $.when( element.el.addClass('czr-painted') ).done( function() {
5369
  $(this).css( 'background', element.bgColor || _bgColor );
@@ -5371,6 +8497,7 @@ $.extend( CZRSkopeBaseMths, {
5371
  } else {
5372
  element.el.css( 'background', element.bgColor || _bgColor );
5373
  }
 
5374
  if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
5375
  element.el.css( 'color', '#000');
5376
  }
@@ -5378,15 +8505,20 @@ $.extend( CZRSkopeBaseMths, {
5378
  };
5379
 
5380
  api.czr_skopeBase.paintedElements = api.czr_skopeBase.paintedElements || new api.Value( [] );
 
 
5381
  if ( _.isEmpty( params.active_panel_id ) && _.isEmpty( params.active_section_id ) ) {
5382
  _paint_candidates.push( {
5383
  el : $( '#customize-info' ).find('.accordion-section-title').first()
5384
  });
5385
  api.panel.each( function( _panel ) {
 
5386
  _paint_candidates.push( {
5387
  el : _panel.container.find( '.accordion-section-title').first()
5388
  });
5389
  });
 
 
5390
  api.section.each( function( _section ) {
5391
  if ( ! _.isEmpty( _section.panel() ) )
5392
  return;
@@ -5395,15 +8527,20 @@ $.extend( CZRSkopeBaseMths, {
5395
  });
5396
  });
5397
  }
 
 
5398
  if ( ! _.isEmpty( params.active_panel_id ) && _.isEmpty( params.active_section_id ) ) {
5399
  api.panel.when( params.active_panel_id , function( active_panel ) {
5400
  active_panel.deferred.embedded.then( function() {
 
5401
  _paint_candidates.push( {
5402
  el : active_panel.container.find( '.accordion-section-title, .customize-panel-back' )
5403
  });
5404
  });
5405
  });
5406
  }
 
 
5407
  if ( ! _.isEmpty( params.active_section_id ) ) {
5408
  api.section.when( params.active_section_id , function( active_section ) {
5409
  active_section.deferred.embedded.then( function() {
@@ -5416,6 +8553,7 @@ $.extend( CZRSkopeBaseMths, {
5416
  el : active_section.container
5417
  }
5418
  );
 
5419
  if ( ! api.czr_isChangeSetOn() ) {
5420
  _paint_candidates.push(
5421
  {
@@ -5426,6 +8564,8 @@ $.extend( CZRSkopeBaseMths, {
5426
  });
5427
  });
5428
  }
 
 
5429
  _.each( _paint_candidates, function( _el ) { _do_paint( _el ); } );
5430
  api.czr_skopeBase.paintedElements( _paint_candidates );
5431
  return this;
@@ -5435,6 +8575,14 @@ $.extend( CZRSkopeBaseMths, {
5435
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
5436
  (function ( api, $, _ ) {
5437
  $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
 
 
5438
  toggleBottomInfos : function( visible, noteParams ) {
5439
  noteParams = _.isObject( noteParams ) ? noteParams : {};
5440
  var self = this,
@@ -5448,13 +8596,17 @@ $.extend( CZRSkopeBaseMths, {
5448
  _skopeInfosSetId = api.CZR_Helpers.build_setId('show-skope-infos'),
5449
  _renderAndSetup = function() {
5450
  var _dfd = $.Deferred();
 
5451
  $.when( self.renderBottomInfosTmpl( noteParams ) )
5452
  .done( function( $_el ) {
5453
  self.bottomInfosContainer = $_el;
 
5454
  _.delay( function() {
5455
  $('body').addClass('czr-bottom-infos-open');
5456
  _dfd.resolve();
5457
  }, 200 );
 
 
5458
  api.CZR_Helpers.setupDOMListeners(
5459
  [
5460
  {
@@ -5469,6 +8621,7 @@ $.extend( CZRSkopeBaseMths, {
5469
  });
5470
  }
5471
  },
 
5472
  {
5473
  trigger : 'click keydown',
5474
  selector : '.czr-skope-switch',
@@ -5502,6 +8655,7 @@ $.extend( CZRSkopeBaseMths, {
5502
  var _dfd_ = this;
5503
  $('body').removeClass('czr-bottom-infos-open');
5504
  if ( self.bottomInfosContainer.length ) {
 
5505
  _.delay( function() {
5506
  self.bottomInfosContainer.remove();
5507
  self.bottomInfosContainer = false;
@@ -5526,13 +8680,25 @@ $.extend( CZRSkopeBaseMths, {
5526
  dfd.resolve();
5527
  });
5528
  }
 
 
 
 
 
 
 
5529
  return dfd.promise();
5530
  },
 
 
 
5531
  renderBottomInfosTmpl : function( params ) {
5532
  params = params || {};
5533
  var self = this,
5534
  _tmpl = '',
5535
  _skope_id = api.czr_activeSkopeId();
 
 
5536
  if ( ! api.czr_skope.has( _skope_id ) || ! _.isObject( api.czr_skope( _skope_id )() ) )
5537
  return false;
5538
 
@@ -5557,6 +8723,8 @@ $.extend( CZRSkopeBaseMths, {
5557
  }
5558
  });
5559
  };
 
 
5560
  if ( _.isUndefined( this.bottomInfosContainer ) || 1 != this.bottomInfosContainer.length ) {
5561
  _renderTmpl().done( function() {
5562
  $('.czr-note-message', '#czr-bottom-infos').html( _message );
@@ -5574,9 +8742,30 @@ $.extend( CZRSkopeBaseMths, {
5574
  }
5575
  return ( this.bottomInfosContainer && 1 == this.bottomInfosContainer.length ) ? this.bottomInfosContainer : $( '#czr-bottom-infos' );
5576
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5577
  _getSkopeInfosMessage : function( skope_id ) {
5578
  skope_id = skope_id || api.czr_activeSkopeId();
5579
  var _localSkopeId = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
 
 
 
 
 
5580
  if ( ! api.czr_skope.has( skope_id ) || ! _.isObject( api.czr_skope( skope_id )() ) || _.isUndefined( _localSkopeId ) )
5581
  return '';
5582
 
@@ -5632,6 +8821,17 @@ $.extend( CZRSkopeBaseMths, {
5632
  _html,
5633
  '</span>'
5634
  ].join(' ') );
 
 
 
 
 
 
 
 
 
 
 
5635
  }
5636
  });//$.extend()
5637
  })( wp.customize , jQuery, _);
@@ -5642,20 +8842,27 @@ $.extend( CZRSkopeBaseMths, {
5642
  /*****************************************************************************
5643
  * HELPERS
5644
  *****************************************************************************/
 
5645
  isSkopeRegisteredInCollection : function( skope_id, collection ) {
5646
  var self = this;
5647
  collection = collection || api.czr_skopeCollection();
5648
  return ! _.isUndefined( _.findWhere( collection, { id : skope_id } ) );
5649
  },
 
 
5650
  isSkopeRegisteredInCurrentCollection : function( skope_id, collection ) {
5651
  var self = this;
5652
  collection = collection || api.czr_currentSkopesCollection();
5653
  return ! _.isUndefined( _.findWhere( collection, { id : skope_id } ) );
5654
  },
 
 
5655
  isGlobalSkopeRegistered : function() {
5656
  var _model = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'global'} );
5657
  return _.isObject( _model ) && _.has( _model, 'id' );
5658
  },
 
 
5659
  getGlobalSkopeId : function() {
5660
  if ( ! _.has(api, 'czr_skope') )
5661
  return '';
@@ -5666,6 +8873,9 @@ $.extend( CZRSkopeBaseMths, {
5666
  });
5667
  return id;
5668
  },
 
 
 
5669
  getChangedGlobalDBSettingValues : function( serverGlobalDBValues ) {
5670
  var _changedDbVal = {};
5671
 
@@ -5680,6 +8890,11 @@ $.extend( CZRSkopeBaseMths, {
5680
  });
5681
  return _changedDbVal;
5682
  },
 
 
 
 
 
5683
  getActiveSkopeId : function( _current_skope_collection ) {
5684
  _current_skope_collection = _current_skope_collection || api.czr_currentSkopesCollection();
5685
 
@@ -5699,13 +8914,32 @@ $.extend( CZRSkopeBaseMths, {
5699
  if ( _.isUndefined( _skpId ) ) {
5700
  throw new Error( 'No default skope was found in getActiveSkopeId ', _current_skope_collection );
5701
  }
 
 
 
 
 
 
 
 
 
 
 
 
5702
  return _skpId;
 
5703
  },
 
 
5704
  getActiveSkopeName : function() {
5705
  if ( ! api.czr_skope.has( api.czr_activeSkopeId() ) )
5706
  return 'global';
5707
  return api.czr_skope( api.czr_activeSkopeId() )().skope;
5708
  },
 
 
 
 
5709
  isSettingSkopeEligible : function( setId ) {
5710
  var self = this,
5711
  shortSetId = api.CZR_Helpers.getOptionName( setId );
@@ -5714,15 +8948,40 @@ $.extend( CZRSkopeBaseMths, {
5714
  api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO SKOPE BECAUSE UNDEFINED OR NOT REGISTERED IN THE API.' );
5715
  return false;
5716
  }
 
 
 
 
 
5717
  if ( self.isExcludedWPBuiltinSetting( setId ) )
5718
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5719
  if ( _.contains( serverControlParams.skopeExcludedSettings, shortSetId ) ) {
 
5720
  return false;
5721
  } else if ( self.isThemeSetting( setId ) ) {
5722
  return true;
 
5723
  } else
5724
  return true;
5725
  },
 
 
 
 
5726
  isSettingResetEligible : function( setId ) {
5727
  var self = this,
5728
  shortSetId = api.CZR_Helpers.getOptionName( setId );
@@ -5731,6 +8990,7 @@ $.extend( CZRSkopeBaseMths, {
5731
  api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO RESET BECAUSE UNDEFINED OR NOT REGISTERED IN THE API.' );
5732
  return;
5733
  }
 
5734
  if ( self.isExcludedWPBuiltinSetting( setId ) )
5735
  return;
5736
  if ( ! self.isThemeSetting( setId ) && ! self.isWPAuthorizedSetting( setId ) ) {
@@ -5738,20 +8998,36 @@ $.extend( CZRSkopeBaseMths, {
5738
  } else
5739
  return true;
5740
  },
 
 
5741
  isThemeSetting : function( setId ) {
5742
  return _.isString( setId ) && -1 !== setId.indexOf( serverControlParams.themeOptions );
5743
  },
 
 
5744
  isWPAuthorizedSetting : function( setId ) {
5745
  return _.isString( setId ) && _.contains( serverControlParams.wpBuiltinSettings, setId );
5746
  },
 
 
5747
  isExcludedWPBuiltinSetting : function( setId ) {
5748
  var self = this;
5749
  if ( _.isUndefined(setId) )
5750
  return true;
5751
  if ( 'active_theme' == setId )
5752
  return true;
 
5753
  if ( _.contains( serverControlParams.wpBuiltinSettings, setId ) )
5754
  return false;
 
 
 
 
 
 
 
 
 
5755
  var _patterns = [ 'widget_', 'nav_menu', 'sidebars_', 'custom_css', 'nav_menu[', 'nav_menu_item', 'nav_menus_created_posts', 'nav_menu_locations' ],
5756
  _isExcld = false;
5757
  _.each( _patterns, function( _ptrn ) {
@@ -5788,20 +9064,30 @@ $.extend( CZRSkopeBaseMths, {
5788
  });
5789
  return _isExcld;
5790
  },
 
 
5791
  isExcludedSidebarsWidgets : function() {
5792
  var _servParam = serverControlParams.isSidebarsWigetsSkoped;//can be a boolean or a string "" for false, "1" for true
5793
  return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
5794
  },
 
 
5795
  isExcludedNavMenuLocations : function() {
 
5796
  if ( ! api.czr_isChangeSetOn() )
5797
  return true;
5798
  var _servParam = serverControlParams.isNavMenuLocationsSkoped;//can be a boolean or a string "" for false, "1" for true
5799
  return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
5800
  },
 
 
5801
  isExcludedWPCustomCss : function() {
5802
  var _servParam = serverControlParams.isWPCustomCssSkoped;//can be a boolean or a string "" for false, "1" for true
5803
  return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
5804
  },
 
 
 
5805
  _getDBSettingVal : function( setId, skope_id ) {
5806
  var shortSetId = api.CZR_Helpers.getOptionName(setId),
5807
  wpSetId = api.CZR_Helpers.build_setId(setId);
@@ -5817,18 +9103,30 @@ $.extend( CZRSkopeBaseMths, {
5817
  return '_no_db_val';
5818
  }
5819
  },
 
 
 
 
 
5820
  getSkopeDirties : function( skope_id, options ) {
5821
  if ( ! api.czr_skope.has( skope_id ) )
5822
  return {};
 
 
 
5823
  options = options || {};
5824
  options = _.extend( { unsaved : true }, options );
5825
 
5826
  var values = {};
 
5827
  _.each( api.czr_skope( skope_id ).dirtyValues(), function( _val, _setId ) {
5828
  var settingRevision;
 
5829
  if ( api.czr_isChangeSetOn() ) {
5830
  settingRevision = api._latestSettingRevisions[ _setId ];
 
5831
  if ( api.state( 'changesetStatus' ).get() && ( options && options.unsaved ) && ( _.isUndefined( settingRevision ) || settingRevision <= api._lastSavedRevision ) ) {
 
5832
  return;
5833
  }
5834
  }
@@ -5838,6 +9136,7 @@ $.extend( CZRSkopeBaseMths, {
5838
  },
5839
 
5840
  getSkopeExcludedDirties : function() {
 
5841
  var self = this,
5842
  _wpDirties = {};
5843
  api.each( function ( value, setId ) {
@@ -5845,9 +9144,14 @@ $.extend( CZRSkopeBaseMths, {
5845
  _wpDirties[ setId ] = value();
5846
  }
5847
  } );
 
 
5848
  var _globalSkopeId = self.getGlobalSkopeId(),
5849
  _globalSkpDirties = self.getSkopeDirties( _globalSkopeId );
 
 
5850
  return _.omit( _wpDirties, function( _value, setId ) {
 
5851
  return self.isSettingSkopeEligible( setId );
5852
  } );
5853
  },
@@ -5867,6 +9171,7 @@ $.extend( CZRSkopeBaseMths, {
5867
  parsed.id_base = matches[1];
5868
  parsed.number = parseInt( matches[2], 10 );
5869
  } else {
 
5870
  parsed.id_base = widgetId;
5871
  }
5872
 
@@ -5916,11 +9221,17 @@ $.extend( CZRSkopeBaseMths, {
5916
  api.errorLog( 'getAppliedPrioritySkopeId : the requested skope id is not registered : ' + skope_id );
5917
  return skope_id;
5918
  }
 
 
5919
  var self = this,
5920
  _local_skope_id = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
5921
 
5922
  if ( _.isUndefined( _local_skope_id ) || skope_id == _local_skope_id )
5923
  return skope_id;
 
 
 
 
5924
  var _salmonToMatch = function( _skp_id ) {
5925
  var wpSetId = api.CZR_Helpers.build_setId( setId ),
5926
  val_candidate = '___',
@@ -5929,36 +9240,52 @@ $.extend( CZRSkopeBaseMths, {
5929
 
5930
  if ( _skp_id == skope_id )
5931
  return skope_id;
 
 
5932
  if ( api.czr_skope( _skp_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
5933
  return skope_model.id;
 
 
5934
  if ( api.czr_isChangeSetOn() ) {
5935
  if ( api.czr_skope( _skp_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
5936
  return skope_model.id;
5937
  }
 
 
5938
  var _skope_db_val = self._getDBSettingVal( setId, _skp_id);
5939
  if ( _skope_db_val != '_no_db_val' ) {
5940
  return skope_model.id;
5941
  }
 
5942
  else if( 'global' == skope_model.skope ) {
 
 
 
5943
  return skope_model.id;
5944
  }
5945
  else {
 
5946
  return '___' != val_candidate ? skope_model.title : _salmonToMatch( self._getParentSkopeId( skope_model ) );
5947
  }
5948
  };
5949
  return _salmonToMatch( _local_skope_id );
5950
  },
 
 
5951
  getOverridenSkopeTitles : function() {
5952
  var skope_id = skope_id || api.czr_activeSkopeId();
5953
  if ( ! api.czr_skope.has( skope_id ) ) {
5954
  api.errorLog( 'getInheritedSkopeTitles : the requested skope id is not registered : ' + skope_id );
5955
  return '';
5956
  }
 
5957
  var self = this,
5958
  _local_skope_id = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
5959
 
5960
  if ( _.isUndefined( _local_skope_id ) || skope_id == _local_skope_id )
5961
  return '';
 
 
5962
  var _salmonToMatch = function( _skp_id, _skp_ids ) {
5963
  _skp_ids = _skp_ids || [];
5964
  var skope_model = api.czr_skope( _skp_id )();
@@ -5973,6 +9300,9 @@ $.extend( CZRSkopeBaseMths, {
5973
  return self.buildSkopeLink( id );
5974
  }).join( ' ' + serverControlParams.i18n.skope['and'] + ' ' );
5975
  },
 
 
 
5976
  getInheritedSkopeId : function( setId, skope_id ) {
5977
  if ( ! api.has( api.CZR_Helpers.build_setId(setId) ) ) {
5978
  api.errorLog( 'getInheritedSkopeId : the requested setting id does not exist in the api : ' + api.CZR_Helpers.build_setId(setId) );
@@ -5988,25 +9318,42 @@ $.extend( CZRSkopeBaseMths, {
5988
  val_candidate = '___',
5989
  skope_model = api.czr_skope( skope_id )(),
5990
  initial_val;
 
 
5991
  if ( _.has( api.settings.settings, wpSetId ) )
5992
  initial_val = api.settings.settings[wpSetId].value;
5993
  else
5994
  initial_val = null;
 
 
5995
  if ( api.czr_skope( skope_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
5996
  return skope_id;
 
 
5997
  if ( api.czr_isChangeSetOn() ) {
5998
  if ( api.czr_skope( skope_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
5999
  return skope_id;
6000
  }
 
 
6001
  var _skope_db_val = self._getDBSettingVal( setId, skope_id );
6002
  if ( _skope_db_val != '_no_db_val' )
6003
  return skope_id;
 
6004
  else if( 'global' == skope_model.skope ) {
 
 
 
6005
  return skope_id;
6006
  }
6007
  else
 
6008
  return '___' != val_candidate ?skope_id : self.getInheritedSkopeId( setId, self._getParentSkopeId( skope_model ) );
6009
  },
 
 
 
 
6010
  getInheritedSkopeTitles : function( skope_id, skope_ids ) {
6011
  skope_id = skope_id || api.czr_activeSkopeId();
6012
  if ( ! api.czr_skope.has( skope_id ) ) {
@@ -6027,6 +9374,8 @@ $.extend( CZRSkopeBaseMths, {
6027
  return self.buildSkopeLink( id );
6028
  }).join(' ' + serverControlParams.i18n.skope['and'] + ' ');
6029
  },
 
 
6030
  buildSkopeLink : function( skope_id ) {
6031
  if ( ! api.czr_skope.has( skope_id ) ) {
6032
  api.errorLog( 'buildSkopeLink : the requested skope id is not registered : ' + skope_id );
@@ -6039,6 +9388,13 @@ $.extend( CZRSkopeBaseMths, {
6039
  '</span>'
6040
  ].join( '' );
6041
  },
 
 
 
 
 
 
 
6042
  getSkopeSettingVal : function( setId, skope_id ) {
6043
  if ( ! api.has( api.CZR_Helpers.build_setId(setId) ) ) {
6044
  api.errorLog( 'getSkopeSettingVal : the requested setting id does not exist in the api : ' + api.CZR_Helpers.build_setId(setId) );
@@ -6054,25 +9410,43 @@ $.extend( CZRSkopeBaseMths, {
6054
  val_candidate = '___',
6055
  skope_model = api.czr_skope( skope_id )(),
6056
  initial_val;
 
 
 
6057
  if ( _.has( api.settings.settings, wpSetId ) )
6058
  initial_val = api.settings.settings[wpSetId].value;
6059
  else
6060
  initial_val = null;
 
 
6061
  if ( api.czr_skope( skope_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
6062
  return api.czr_skope( skope_id ).dirtyValues()[ wpSetId ];
 
 
6063
  if ( api.czr_isChangeSetOn() ) {
6064
  if ( api.czr_skope( skope_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
6065
  return api.czr_skope( skope_id ).changesetValues()[ wpSetId ];
6066
  }
 
 
6067
  var _skope_db_val = self._getDBSettingVal( setId, skope_id );
6068
  if ( _skope_db_val != '_no_db_val' )
6069
  return _skope_db_val;
 
6070
  else if( 'global' == skope_model.skope ) {
 
 
 
6071
  return '___' == val_candidate ? initial_val : val_candidate;
6072
  }
6073
  else
 
6074
  return '___' != val_candidate ? val_candidate : self.getSkopeSettingVal( setId, self._getParentSkopeId( skope_model ) );
6075
  },
 
 
 
 
6076
  applyDirtyCustomizedInheritance : function( dirtyCustomized, skope_id ) {
6077
  skope_id = skope_id || api.czr_activeSkopeId() || api.czr_skopeBase.getGlobalSkopeId();
6078
  dirtyCustomized = dirtyCustomized || {};
@@ -6085,6 +9459,8 @@ $.extend( CZRSkopeBaseMths, {
6085
 
6086
  var parent_skope_id = self._getParentSkopeId( skope_model ),
6087
  parent_dirties = api.czr_skope( parent_skope_id ).dirtyValues();
 
 
6088
  _.each( parent_dirties, function( _val, wpSetId ){
6089
  var shortSetId = api.CZR_Helpers.getOptionName( wpSetId );
6090
  if ( _.isUndefined( dirtyCustomized[wpSetId] ) && _.isUndefined( api.czr_skope( skope_model.id ).dbValues()[shortSetId] ) )
@@ -6092,6 +9468,11 @@ $.extend( CZRSkopeBaseMths, {
6092
  });
6093
  return 'global' == api.czr_skope( parent_skope_id )().skope ? dirtyCustomized : self.applyDirtyCustomizedInheritance( dirtyCustomized, parent_skope_id );
6094
  },
 
 
 
 
 
6095
  _getParentSkopeId : function( skope_model, _index ) {
6096
  var self = this,
6097
  hierark = ['local', 'group', 'special_group', 'global'],
@@ -6101,11 +9482,17 @@ $.extend( CZRSkopeBaseMths, {
6101
  if ( _.isUndefined( parent_skope_skope ) ) {
6102
  return _.findWhere( api.czr_currentSkopesCollection(), { skope : 'global' } ).id;
6103
  }
 
 
6104
  if ( _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), { skope : parent_skope_skope } ) ) ) {
6105
  return self._getParentSkopeId( skope_model, parent_skope_ind + 1 );
6106
  }
6107
  return _.findWhere( api.czr_currentSkopesCollection(), { skope : parent_skope_skope } ).id;
6108
  },
 
 
 
 
6109
  _getChildSkopeId : function( skope_model, _index ) {
6110
  var self = this,
6111
  hierark = ['local', 'group', 'special_group', 'global'],
@@ -6115,6 +9502,8 @@ $.extend( CZRSkopeBaseMths, {
6115
  if ( _.isUndefined( child_skope_skope ) ) {
6116
  return _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
6117
  }
 
 
6118
  if ( _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), { skope : child_skope_skope } ) ) ) {
6119
  return self._getParentSkopeId( skope_model, child_skope_ind - 1 );
6120
  }
@@ -6126,13 +9515,44 @@ $.extend( CZRSkopeBaseMths, {
6126
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
6127
  ( function ( api, $, _ ) {
6128
  $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6129
  updateSkopeCollection : function( sent_collection, sent_channel ) {
 
6130
  var self = this;
6131
  _api_ready_collection = [];
 
 
6132
  _.each( sent_collection, function( _skope, _key ) {
6133
  var skope_candidate = $.extend( true, {}, _skope );//deep clone to avoid any shared references
6134
  _api_ready_collection.push( self.prepareSkopeForAPI( skope_candidate ) );
6135
  });
 
 
 
6136
  if ( self.isGlobalSkopeRegistered() ) {
6137
  var _updated_api_ready_collection = [],
6138
  _global_skp_model = $.extend( true, {}, api.czr_skope( self.getGlobalSkopeId() )() );
@@ -6145,8 +9565,32 @@ $.extend( CZRSkopeBaseMths, {
6145
  });
6146
  _api_ready_collection = _updated_api_ready_collection;
6147
  }
 
 
 
6148
  api.czr_currentSkopesCollection( _api_ready_collection );
6149
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6150
  prepareSkopeForAPI : function( skope_candidate ) {
6151
  if ( ! _.isObject( skope_candidate ) ) {
6152
  throw new Error('prepareSkopeForAPI : a skope must be an object to be API ready');
@@ -6217,6 +9661,8 @@ $.extend( CZRSkopeBaseMths, {
6217
  }
6218
  api_ready_skope[_key] = _candidate_val;
6219
  break;
 
 
6220
  case 'db' :
6221
  if ( _.isArray( _candidate_val ) || _.isEmpty( _candidate_val ) )
6222
  _candidate_val = {};
@@ -6241,7 +9687,11 @@ $.extend( CZRSkopeBaseMths, {
6241
  break;
6242
  }//switch
6243
  });
 
 
6244
  api_ready_skope.color = self.skope_colors[ api_ready_skope.skope ] || 'rgb(255, 255, 255)';
 
 
6245
  api_ready_skope.id = api_ready_skope.skope + '_' + api_ready_skope.level;
6246
  if ( ! _.isString( api_ready_skope.id ) || _.isEmpty( api_ready_skope.id ) ) {
6247
  throw new Error('prepareSkopeForAPI : a skope id must a string not empty');
@@ -6252,20 +9702,34 @@ $.extend( CZRSkopeBaseMths, {
6252
  }
6253
  return api_ready_skope;
6254
  },
 
 
 
 
6255
  currentSkopesCollectionReact : function( to, from ) {
6256
  var self = this,
6257
  _new_collection = $.extend( true, [], to ) || [],
6258
  _old_collection = $.extend( true, [], from ) || [],
6259
  dfd = $.Deferred();
 
 
 
 
6260
  var _to_instantiate = [];
6261
  _to_remove = [];
6262
  _to_update = [];
6263
  _instantiateAndEmbed = function( _candidates_ ) {
 
 
6264
  _.each( _candidates_, function( _skope ) {
6265
  _skope = $.extend( true, {}, _skope );//use a cloned skop to instantiate : @todo : do we still need that ?
6266
  api.czr_skope.add( _skope.id , new api.CZR_skope( _skope.id , _skope ) );
6267
  });
 
 
 
6268
  _.each( _candidates_, function( _skope ) {
 
6269
  if ( ! api.czr_skope.has( _skope.id ) ) {
6270
  throw new Error( 'Skope id : ' + _skope.id + ' has not been instantiated.');
6271
  }
@@ -6274,19 +9738,29 @@ $.extend( CZRSkopeBaseMths, {
6274
  }
6275
  });
6276
  };
 
 
6277
  _.each( _new_collection, function( _sent_skope ) {
6278
  if ( ! api.czr_skope.has( _sent_skope.id ) )
6279
  _to_instantiate.push( _sent_skope );
6280
  });
 
 
6281
  try {
6282
  _instantiateAndEmbed( _to_instantiate );
6283
  } catch( er ) {
6284
  api.errorLog( "currentSkopesCollectionReact : " + er );
6285
  return dfd.resolve().promise();
6286
  }
 
 
 
 
 
6287
  var _setActiveAndLayout = function() {
6288
  var _activeSkopeNum = _.size( _new_collection ),
6289
  _setLayoutClass = function( _skp_instance ) {
 
6290
  var _newClasses = _skp_instance.container.attr('class').split(' ');
6291
  _.each( _skp_instance.container.attr('class').split(' '), function( _c ) {
6292
  if ( 'width-' == _c.substring( 0, 6) ) {
@@ -6295,6 +9769,7 @@ $.extend( CZRSkopeBaseMths, {
6295
  });
6296
  $.when( _skp_instance.container.attr('class', _newClasses.join(' ') ) )
6297
  .done( function() {
 
6298
  _skp_instance.container.addClass( 'width-' + ( Math.round( 100 / _activeSkopeNum ) ) );
6299
  });
6300
  };
@@ -6321,15 +9796,34 @@ $.extend( CZRSkopeBaseMths, {
6321
  }
6322
  } );
6323
  };
 
 
6324
  self.skopeWrapperEmbedded.then( function() {
6325
  _setActiveAndLayout();
6326
  });
 
 
 
 
6327
  if ( _.isEmpty( from ) && ! _.isEmpty( to ) )
6328
  api.czr_initialSkopeCollectionPopulated.resolve();
 
 
6329
  self.maybeSynchronizeGlobalSkope();
6330
 
6331
  return dfd.resolve( 'changed' ).promise();
6332
  },//listenToSkopeCollection()
 
 
 
 
 
 
 
 
 
 
 
6333
  maybeSynchronizeGlobalSkope : function( args ) {
6334
  args = args || {};
6335
  if ( ! _.isObject( args ) ) {
@@ -6357,6 +9851,8 @@ $.extend( CZRSkopeBaseMths, {
6357
  api.settings.settings[setId].value = _val;
6358
  }
6359
  });
 
 
6360
  if ( args.isGlobalReset && args.isSetting ) {
6361
  _setIdToReset = args.settingIdToReset;
6362
  shortSetId = api.CZR_Helpers.getOptionName( _setIdToReset );
@@ -6368,6 +9864,8 @@ $.extend( CZRSkopeBaseMths, {
6368
  api.settings.settings[ _setIdToReset ].value = defaultVal;
6369
  }
6370
  }
 
 
6371
  if ( args.isGlobalReset && args.isSkope ) {
6372
  _.each( api.settings.settings, function( _params, _setId ) {
6373
  if ( ! self.isThemeSetting( _setId ) )
@@ -6387,8 +9885,15 @@ $.extend( CZRSkopeBaseMths, {
6387
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
6388
  ( function ( api, $, _ ) {
6389
  $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
6390
  activeSkopeReact : function( to, from ) {
6391
  var self = this, dfd = $.Deferred();
 
6392
  if ( ! _.isUndefined(from) && api.czr_skope.has(from) )
6393
  api.czr_skope(from).active(false);
6394
  else if ( ! _.isUndefined( from ) )
@@ -6398,28 +9903,88 @@ $.extend( CZRSkopeBaseMths, {
6398
  api.czr_skope(to).active(true);
6399
  else
6400
  throw new Error('listenToActiveSkope : requested scope ' + to + ' does not exist in the collection');
 
 
 
 
 
6401
  var _switchBack = function( _title ) {
6402
  api.czr_activeSkopeId( self.getGlobalSkopeId() );
6403
- api.czr_serverNotification({
6404
- status:'success',
6405
- message : [ _title , 'can only be customized sitewide.' ].join(' ')
6406
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6407
  return dfd.resolve().promise();
6408
  };
 
 
6409
  if ( self.isExcludedSidebarsWidgets() && 'widgets' == api.czr_activePanelId() && to != self.getGlobalSkopeId() ) {
6410
- api.czr_serverNotification({
6411
- status:'success',
6412
- message : [
6413
- serverControlParams.i18n.skope['Widgets are created sitewide.']
6414
- ].join(' ')
6415
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6416
  }
 
6417
  if ( self.isExcludedWPCustomCss() && 'custom_css' == api.czr_activeSectionId() && to != self.getGlobalSkopeId() ) {
6418
  return _switchBack( api.section( api.czr_activeSectionId() ).params.title );
6419
  }
6420
  if ( 'admin_sec' == api.czr_activeSectionId() && to != self.getGlobalSkopeId() ) {
6421
  return _switchBack( api.section( api.czr_activeSectionId() ).params.title );
6422
  }
 
 
 
 
6423
  if ( ( 'nav_menu' == api.czr_activeSectionId().substring( 0, 'nav_menu'.length ) || 'add_menu' == api.czr_activeSectionId() ) && to != self.getGlobalSkopeId() ) {
6424
  api.czr_serverNotification({
6425
  status:'success',
@@ -6427,23 +9992,53 @@ $.extend( CZRSkopeBaseMths, {
6427
  serverControlParams.i18n.skope['Menus are created sitewide.']
6428
  ].join(' ')
6429
  });
 
6430
  }
 
 
 
 
6431
  if ( 'nav_menus' == api.czr_activePanelId() ) {
6432
  _.each( api.panel( api.czr_activePanelId() ).sections(), function( _sec ) {
 
6433
  self.processSilentUpdates( { section_id : _sec.id, awake_if_not_active : true } );
6434
  });
6435
  }
 
 
 
6436
  api.state('switching-skope')( true );
 
6437
  self._writeCurrentSkopeTitle( to );
 
6438
  api.trigger( 'czr-paint', { is_skope_switch : true } );
 
 
 
 
 
 
6439
  if ( _.isUndefined( api.czr_activeSectionId() ) ) {
 
 
 
 
 
6440
  api.state('switching-skope')( false );
6441
  api.previewer.refresh();
6442
  return dfd.resolve().promise();
6443
  }
 
 
6444
  if ( _.has( api, 'czrModulePanelState') )
6445
  api.czrModulePanelState(false);
 
 
 
 
6446
  var _silentUpdateCands = self._getSilentUpdateCandidates();
 
 
6447
  if ( ! _.isUndefined( from ) ) {
6448
  _.each( api.czr_skope( from ).dirtyValues(), function( val, _setId ) {
6449
  if ( ! _.contains( _silentUpdateCands, _setId ) )
@@ -6456,6 +10051,11 @@ $.extend( CZRSkopeBaseMths, {
6456
  _silentUpdateCands.push( _setId );
6457
  } );
6458
  }
 
 
 
 
 
6459
  var _debouncedProcessSilentUpdates = function() {
6460
  self.processSilentUpdates( {
6461
  candidates : _silentUpdateCands,
@@ -6473,8 +10073,24 @@ $.extend( CZRSkopeBaseMths, {
6473
  dfd.resolve( _updatedSetIds );
6474
  api.state( 'switching-skope' )( false );
6475
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
6476
  });
6477
  };
 
 
 
6478
  if ( _.has(api, 'czr_isModuleExpanded') && false !== api.czr_isModuleExpanded() ) {
6479
  api.czr_isModuleExpanded().setupModuleViewStateListeners(false);
6480
  _debouncedProcessSilentUpdates = _.debounce( _debouncedProcessSilentUpdates, 400 );
@@ -6484,6 +10100,11 @@ $.extend( CZRSkopeBaseMths, {
6484
  }
6485
  return dfd.promise();
6486
  },//activeSkopeReact
 
 
 
 
 
6487
  _writeCurrentSkopeTitle : function( skope_id ) {
6488
  var self = this,
6489
  current_title = api.czr_skope( skope_id || api.czr_activeSkopeId() )().long_title,
@@ -6513,6 +10134,8 @@ $.extend( CZRSkopeBaseMths, {
6513
  $('.czr-scope-switcher').find('.spinner').fadeOut();
6514
  }
6515
  };
 
 
6516
  self.skopeWrapperEmbedded
6517
  .then( function() {
6518
  if ( ! $('.czr-scope-switcher').find('.czr-current-skope-title').length ) {
@@ -6547,7 +10170,16 @@ $.extend( CZRSkopeBaseMths, {
6547
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
6548
  ( function ( api, $, _ ) {
6549
  $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
 
6550
  processSilentUpdates : function( params ) {
 
 
6551
  if ( _.isString( params ) )
6552
  params = { candidates : [ params ] };
6553
  else
@@ -6563,14 +10195,20 @@ $.extend( CZRSkopeBaseMths, {
6563
  dfd = $.Deferred();
6564
 
6565
  params = $.extend( defaultParams, params );
 
 
6566
  if ( _.isString( params.candidates ) ) {
6567
  params.candidates = [ params.candidates ];
6568
  }
 
 
6569
  if ( _.isEmpty( params.candidates ) )
6570
  params.candidates = self._getSilentUpdateCandidates( params.section_id, params.awake_if_not_active );
6571
  if ( ! _.isArray( params.candidates ) ) {
6572
  throw new Error('processSilentUpdates : the update candidates must be an array.');
6573
  }
 
 
6574
  if ( _.isEmpty( params.candidates ) )
6575
  return dfd.resolve( [] ).promise();
6576
 
@@ -6589,6 +10227,9 @@ $.extend( CZRSkopeBaseMths, {
6589
  dfd.resolve( updated_settings );
6590
  });
6591
  };
 
 
 
6592
  if ( 'resolved' != api.czr_skopeReady.state() ) {
6593
  dfd.resolve( [] );
6594
  api.czr_skopeReady.done( function() {
@@ -6607,11 +10248,18 @@ $.extend( CZRSkopeBaseMths, {
6607
  /*****************************************************************************
6608
  * UPDATE SETTING VALUES
6609
  *****************************************************************************/
 
 
 
 
6610
  silentlyUpdateSettings : function( _silentUpdateCands, refresh ) {
 
6611
  if ( ! api.state.has( 'silent-update-processing') )
6612
  api.state.create( 'silent-update-processing' )( false );
6613
 
6614
  api.state( 'silent-update-processing' )(true);
 
 
6615
  var self = this,
6616
  _silentUpdatePromises = {},
6617
  dfd = $.Deferred();
@@ -6625,6 +10273,10 @@ $.extend( CZRSkopeBaseMths, {
6625
  if ( _.isString( _silentUpdateCands ) ) {
6626
  _silentUpdateCands = [ _silentUpdateCands ];
6627
  }
 
 
 
 
6628
  _.each( _silentUpdateCands, function( setId ) {
6629
  if ( api.control.has( setId ) && 'czr_multi_module' == api.control(setId).params.type )
6630
  return;
@@ -6634,8 +10286,20 @@ $.extend( CZRSkopeBaseMths, {
6634
 
6635
  var _deferred = [],
6636
  _updatedSetIds = [];
 
 
 
 
 
 
 
 
 
 
 
6637
  _.each( _silentUpdatePromises, function( _promise_ , setId ) {
6638
  _promise_.done( function( _new_setting_val_ ) {
 
6639
  var wpSetId = api.CZR_Helpers.build_setId( setId ),
6640
  _skopeDirtyness = api.czr_skope( api.czr_activeSkopeId() ).getSkopeSettingDirtyness( setId );
6641
  if ( ! _.isEqual( api( wpSetId )(), _new_setting_val_ ) ) {
@@ -6646,7 +10310,22 @@ $.extend( CZRSkopeBaseMths, {
6646
 
6647
  _deferred.push( _promise_ );
6648
  });
 
 
6649
  $.when.apply( null, _deferred )
 
 
 
 
 
 
 
 
 
 
 
 
 
6650
  .fail( function() {
6651
  dfd.reject();
6652
  throw new Error( 'silentlyUpdateSettings FAILED. Candidates : ' + _silentUpdateCands );
@@ -6660,6 +10339,7 @@ $.extend( CZRSkopeBaseMths, {
6660
  throw new Error( 'a silent update promise is unresolved : ' + _silentUpdateCands );
6661
  }
6662
  });
 
6663
  if ( refresh && ! _.isEmpty( _updatedSetIds ) ) {
6664
  api.previewer.refresh()
6665
  .always( function() {
@@ -6669,8 +10349,22 @@ $.extend( CZRSkopeBaseMths, {
6669
  dfd.resolve( _updatedSetIds );
6670
  }
6671
  });
 
 
6672
  return dfd.promise();
6673
  },
 
 
 
 
 
 
 
 
 
 
 
 
6674
  getSettingUpdatePromise : function( setId ) {
6675
  if ( _.isUndefined( setId ) ) {
6676
  throw new Error('getSettingUpdatePromise : the provided setId is not defined');
@@ -6686,15 +10380,30 @@ $.extend( CZRSkopeBaseMths, {
6686
  _promise = false,
6687
  skope_id = api.czr_activeSkopeId(),
6688
  val = api.czr_skopeBase.getSkopeSettingVal( setId, skope_id );
 
 
6689
  if ( _.isEqual( current_setting_val, val ) ) {
6690
  return dfd.resolve( val ).promise();
6691
  }
 
 
 
6692
  if ( api.control.has( wpSetId ) ) {
 
 
 
6693
  var control_type = api.control( wpSetId ).params.type,
6694
  _control_data = api.settings.controls[wpSetId],
6695
  _constructor;
6696
 
 
 
 
 
 
 
6697
  switch ( control_type ) {
 
6698
  case 'czr_cropped_image' :
6699
  _promise = self._getCzrCroppedImagePromise( wpSetId, _control_data );
6700
  break;
@@ -6702,8 +10411,31 @@ $.extend( CZRSkopeBaseMths, {
6702
  case 'czr_module' :
6703
  self._processCzrModuleSilentActions( wpSetId, control_type, skope_id , _control_data);
6704
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6705
  }//switch
6706
  }//end if api.control.has( wpSetId )
 
 
 
 
 
6707
  if ( _.has(api.settings.controls, 'header_image') && 'header_image' == wpSetId ) {
6708
  _promise = self._getHeaderImagePromise( wpSetId, skope_id );
6709
  }
@@ -6728,9 +10460,14 @@ $.extend( CZRSkopeBaseMths, {
6728
  var self = this,
6729
  SilentUpdateCands = [];
6730
  section_id = ( _.isUndefined( section_id ) || _.isNull( section_id ) ) ? api.czr_activeSectionId() : section_id;
 
 
 
 
6731
  if ( _.isEmpty( api.czr_activeSectionId() ) && ! awake_if_not_active ) {
6732
  return [];
6733
  }
 
6734
  if ( _.isUndefined( section_id ) ) {
6735
  api.consoleLog( '_getSilentUpdateCandidates : No active section provided');
6736
  return [];
@@ -6738,10 +10475,16 @@ $.extend( CZRSkopeBaseMths, {
6738
  if ( ! api.section.has( section_id ) ) {
6739
  throw new Error( '_getSilentUpdateCandidates : The section ' + section_id + ' is not registered in the API.');
6740
  }
 
 
6741
  var section_settings = api.CZR_Helpers.getSectionSettingIds( section_id );
 
 
6742
  section_settings = _.filter( section_settings, function( setId ) {
6743
  return self.isSettingSkopeEligible( setId );
6744
  });
 
 
6745
  _.each( section_settings, function( setId ) {
6746
  SilentUpdateCands.push( setId );
6747
  });
@@ -6758,31 +10501,50 @@ $.extend( CZRSkopeBaseMths, {
6758
  * SILENT ACTIONS for czr_module_type on skope switch
6759
  * ?? @todo : can't we fire this earlier than in getPromises ?
6760
  *****************************************************************************/
 
6761
  _processCzrModuleSilentActions : function( wpSetId, control_type, skope_id, _control_data) {
6762
  var _synced_control_id, _synced_control_val, _synced_control_data, _synced_control_constructor, _syncSektionModuleId,
6763
  _synced_short_id = _.has( api.control( wpSetId ).params, 'syncCollection' ) ? api.control( wpSetId ).params.syncCollection : '',
6764
  _shortSetId = api.CZR_Helpers.build_setId(wpSetId),
6765
  _val = api.czr_skopeBase.getSkopeSettingVal( _shortSetId, skope_id ),
6766
  current_skope_instance = api.czr_skope( api.czr_activeSkopeId() );
 
 
6767
  if ( ! _.isEmpty( _synced_short_id ) && ! _.isUndefined( _synced_short_id ) ) {
6768
  _synced_control_id = api.CZR_Helpers.build_setId( _synced_short_id );
6769
  _synced_control_val = api.czr_skopeBase.getSkopeSettingVal( _synced_control_id, skope_id );
6770
  _synced_control_data = api.settings.controls[_synced_control_id];
6771
  _synced_control_constructor = api.controlConstructor.czr_multi_module;
6772
  _syncSektionModuleId = api.control( _synced_control_id ).syncSektionModule()().id;
 
 
6773
  api.control( _synced_control_id ).container.remove();
6774
  api.control.remove(_synced_control_id );
 
6775
  api( _synced_control_id ).silent_set( _synced_control_val, current_skope_instance.getSkopeSettingDirtyness( _synced_control_id ) );
 
 
6776
  $.extend( _synced_control_data, { czr_skope : skope_id });
 
 
6777
  api.control.add( _synced_control_id, new _synced_control_constructor( _synced_control_id, { params : _synced_control_data, previewer : api.previewer }) );
6778
  }
6779
 
6780
  _constructor = api.controlConstructor[control_type];
 
 
6781
  api.control( wpSetId ).container.remove();
6782
  api.control.remove( wpSetId );
 
6783
  api( wpSetId ).silent_set( _val, current_skope_instance.getSkopeSettingDirtyness( _shortSetId ) );
 
 
6784
  $.extend( _control_data, { czr_skope : skope_id });
 
 
6785
  api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
 
 
6786
  if ( ! _.isEmpty( _synced_short_id ) && ! _.isUndefined( _synced_short_id ) ) {
6787
  api.consoleLog('FIRE SEKTION MODULE?', _syncSektionModuleId, api.control( wpSetId ).czr_Module( _syncSektionModuleId ).isReady.state() );
6788
  api.control( wpSetId ).czr_Module( _syncSektionModuleId ).fireSektionModule();
@@ -6796,23 +10558,37 @@ $.extend( CZRSkopeBaseMths, {
6796
  /*****************************************************************************
6797
  * GET PROMISE FOR TYPE : czr_cropped_image
6798
  *****************************************************************************/
 
6799
  _getCzrCroppedImagePromise : function( wpSetId, _control_data ) {
6800
  var _constructor = api.controlConstructor.czr_cropped_image, dfd = $.Deferred(),
6801
  val = api.has(wpSetId) ? api(wpSetId)() : null;
 
6802
  val = null === val ? "" : val;
 
 
 
 
6803
  wp.media.attachment( val ).fetch().done( function() {
 
6804
  api.control( wpSetId ).container.remove();
6805
  api.control.remove( wpSetId );
 
6806
  _control_data.attachment = this.attributes;
 
6807
  api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
6808
  dfd.resolve();
6809
  } ).fail( function() {
 
6810
  api.control( wpSetId ).container.remove();
6811
  api.control.remove( wpSetId );
 
6812
  _control_data = _.omit( _control_data, 'attachment' );
 
6813
  api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
6814
  dfd.reject();
6815
  });
 
 
6816
  return dfd.promise();
6817
  },
6818
 
@@ -6821,6 +10597,7 @@ $.extend( CZRSkopeBaseMths, {
6821
  /*****************************************************************************
6822
  * HEADER IMAGE PROMISE
6823
  *****************************************************************************/
 
6824
  _getHeaderImagePromise : function( wpSetId, skope_id ) {
6825
  var dfd = $.Deferred();
6826
  if ( ! _.has(api.settings.controls, 'header_image') || 'header_image' != wpSetId ) {
@@ -6829,17 +10606,23 @@ $.extend( CZRSkopeBaseMths, {
6829
 
6830
  var _header_constructor = api.controlConstructor.header,
6831
  _header_control_data = $.extend( true, {}, api.settings.controls.header_image );
 
 
6832
  header_image_data = null === api.czr_skopeBase.getSkopeSettingVal( 'header_image_data', skope_id ) ? "" : api.czr_skopeBase.getSkopeSettingVal( 'header_image_data', skope_id );
6833
 
6834
  var attachment_id;
6835
  var _reset_header_image_crtl = function( _updated_header_control_data ) {
6836
  _updated_header_control_data = _updated_header_control_data || _header_control_data;
 
6837
  api.control( 'header_image' ).container.remove();
6838
  api.control.remove( 'header_image' );
 
 
6839
  api.HeaderTool.UploadsList = api.czr_HeaderTool.UploadsList;
6840
  api.HeaderTool.DefaultsList = api.czr_HeaderTool.DefaultsList;
6841
  api.HeaderTool.CombinedList = api.czr_HeaderTool.CombinedList;
6842
  var _render_control = function() {
 
6843
  api.control.add( 'header_image', new _header_constructor( 'header_image', { params : _updated_header_control_data, previewer : api.previewer }) );
6844
  };
6845
  _render_control = _.debounce( _render_control, 800 );
@@ -6852,21 +10635,34 @@ $.extend( CZRSkopeBaseMths, {
6852
  dfd.resolve();
6853
  } else {
6854
  attachment_id = header_image_data.attachment_id;
 
 
 
 
6855
  wp.media.attachment( attachment_id ).fetch().done( function() {
 
6856
  _header_control_data.attachment = this.attributes;
6857
  _reset_header_image_crtl( _header_control_data );
6858
  dfd.resolve();
6859
  } ).fail( function() {
 
6860
  _header_control_data = _.omit( _header_control_data, 'attachment' );
 
 
6861
  api.control( 'header_image' ).container.remove();
6862
  api.control.remove( 'header_image' );
 
 
6863
  api.HeaderTool.UploadsList = api.czr_HeaderTool.UploadsList;
6864
  api.HeaderTool.DefaultsList = api.czr_HeaderTool.DefaultsList;
6865
  api.HeaderTool.CombinedList = api.czr_HeaderTool.CombinedList;
 
6866
  api.control.add( 'header_image', new _header_constructor( 'header_image', { params : _header_control_data, previewer : api.previewer }) );
6867
  dfd.reject();
6868
  });
6869
  }//else
 
 
6870
  return dfd.promise();
6871
  }
6872
  });//$.extend
@@ -6881,6 +10677,13 @@ $.extend( CZRSkopeBaseMths, {
6881
  /*****************************************************************************
6882
  * SETUP CONTROL RESET ON SECTION EXPANSION + SKOPE SWITCH
6883
  *****************************************************************************/
 
 
 
 
 
 
 
6884
  setupActiveSkopedControls : function( obj ) {
6885
  var self = this, section_id, controls, setupParams, eligibleCtrls, dfd = $.Deferred();
6886
  defaultSetupParams = {
@@ -6905,6 +10708,10 @@ $.extend( CZRSkopeBaseMths, {
6905
  }
6906
 
6907
  controls = _.isString( controls ) ? [controls] : controls;
 
 
 
 
6908
  eligibleCtrls = _.filter( controls, function( ctrlId ) {
6909
  var setId = api.CZR_Helpers.getControlSettingId( ctrlId );
6910
  if ( setId && ! self.isSettingSkopeEligible( setId ) ) {
@@ -6914,24 +10721,41 @@ $.extend( CZRSkopeBaseMths, {
6914
  api.control( ctrlId ).container.addClass('is-wp-authorized-setting');
6915
  }
6916
  return setId && self.isSettingSkopeEligible( setId );
 
 
 
6917
  });
 
 
6918
  if ( 'nav_menu[' == section_id.substring( 0, 'nav_menu['.length ) )
6919
  return dfd.resolve().promise();
 
 
 
6920
  if ( ! _.isEmpty( controls ) ) {
6921
  api.czr_skopeReady.then( function() {
6922
  $.when( self.renderControlsSingleReset( eligibleCtrls ) ).done( function() {
 
 
6923
  _.each( controls, function( ctrlId ) {
6924
  self.listenSkopedControl( ctrlId );
6925
  } );
6926
  dfd.resolve();
6927
  });
6928
  });
 
6929
  if ( 'rejected' == api.czr_skopeReady.state() )
6930
  dfd.resolve();
6931
  }
 
 
6932
  self.renderCtrlSkpNotIcon( controls );
6933
  return dfd.promise();
6934
  },//setupActiveSkopedControls
 
 
 
 
6935
  listenSkopedControl : function( ctrlId ) {
6936
  var self = this;
6937
 
@@ -6949,22 +10773,38 @@ $.extend( CZRSkopeBaseMths, {
6949
  isResetting : false
6950
  },
6951
  initial_states = {};
 
 
 
6952
  if ( ! _.has( ctrl, 'czr_states' ) ) {
6953
  ctrl.czr_states = new api.Values();
6954
  _.each( defaults, function( _state_val, _state_name ) {
6955
  ctrl.czr_states.create( _state_name );
6956
  ctrl.czr_states( _state_name )( _state_val );
6957
  });
 
6958
  try { self.bindControlStates( ctrl ); } catch( er ) {
6959
  api.errorLog( 'bindControlStates : ' + er );
6960
  }
6961
  }
 
 
 
 
 
 
 
 
 
6962
  ctrl.czr_states( 'hasDBVal' )( api.czr_skope( api.czr_activeSkopeId() ).hasSkopeSettingDBValues( setId ) );
6963
  ctrl.czr_states( 'isDirty' )( api.czr_skope( api.czr_activeSkopeId() ).getSkopeSettingDirtyness( setId ) );
6964
 
 
 
6965
 
6966
  if ( ! _.has( ctrl, 'userEventMap' ) ) {
6967
  ctrl.userEventMap = [
 
6968
  {
6969
  trigger : 'click keydown',
6970
  selector : '.czr-setting-reset, .czr-cancel-button',
@@ -6972,15 +10812,18 @@ $.extend( CZRSkopeBaseMths, {
6972
  actions : function() {
6973
  if ( ! ctrl.czr_states('isDirty')() && ! ctrl.czr_states( 'hasDBVal' )() )
6974
  return;
 
6975
  _.each( _.without( api.CZR_Helpers.getSectionControlIds( ctrl.section() ), ctrlId ) , function( _id ) {
6976
  if ( _.has( api.control(_id), 'czr_states') ) {
6977
  api.control(_id).czr_states( 'resetVisible' )( false );
6978
  }
6979
  });
6980
  ctrl.czr_states( 'resetVisible' )( ! ctrl.czr_states( 'resetVisible' )() );
 
6981
  ctrl.czr_states( 'noticeVisible' )( ! ctrl.czr_states( 'resetVisible' )() );
6982
  }
6983
  },
 
6984
  {
6985
  trigger : 'click keydown',
6986
  selector : '.czr-control-do-reset',
@@ -6989,6 +10832,7 @@ $.extend( CZRSkopeBaseMths, {
6989
  self.doResetSetting( ctrlId );
6990
  }
6991
  },
 
6992
  {
6993
  trigger : 'click keydown',
6994
  selector : '.czr-skope-switch',
@@ -6999,12 +10843,14 @@ $.extend( CZRSkopeBaseMths, {
6999
  api.czr_activeSkopeId( _skopeIdToSwithTo );
7000
  }
7001
  },
 
7002
  {
7003
  trigger : 'click keydown',
7004
  selector : '.czr-toggle-notice',
7005
  name : 'control_toggle_notice',
7006
  actions : function( params ) {
7007
  ctrl.czr_states( 'noticeVisible' )( ! ctrl.czr_states( 'noticeVisible' )() );
 
7008
  if ( ctrl.czr_states( 'noticeVisible' )() ) {
7009
  ctrl.czr_states( 'resetVisible' )( false );
7010
  }
@@ -7014,12 +10860,20 @@ $.extend( CZRSkopeBaseMths, {
7014
  api.CZR_Helpers.setupDOMListeners( ctrl.userEventMap , { dom_el : ctrl.container }, self );
7015
  }
7016
  },
 
 
 
 
 
 
7017
  bindControlStates : function( ctrl ) {
7018
  if ( ! api.control.has( ctrl.id ) ) {
7019
  throw new Error( 'in bindControlStates, the provided ctrl id is not registered in the api : ' + ctrl.id );
7020
  }
7021
  var self = this,
7022
  setId = api.CZR_Helpers.getControlSettingId( ctrl.id );
 
 
7023
  ctrl.czr_states( 'hasDBVal' ).bind( function( bool ) {
7024
  ctrl.container.toggleClass( 'has-db-val', bool );
7025
  if ( bool ) {
@@ -7031,6 +10885,8 @@ $.extend( CZRSkopeBaseMths, {
7031
  }
7032
  ctrl.container.find('.czr-setting-reset').attr( 'title', _title );
7033
  });
 
 
7034
  ctrl.czr_states( 'isDirty' ).bind( function( bool ) {
7035
  ctrl.container.toggleClass( 'is-dirty', bool );
7036
  var _title;
@@ -7043,6 +10899,8 @@ $.extend( CZRSkopeBaseMths, {
7043
  }
7044
  ctrl.container.find('.czr-setting-reset').attr( 'title', _title );
7045
  });
 
 
7046
  ctrl.czr_states( 'noticeVisible' ).bind( function( visible ) {
7047
  ctrl.container.toggleClass( 'czr-notice-visible', visible );
7048
  var $noticeContainer = ctrl.getNotificationsContainerElement();
@@ -7065,14 +10923,23 @@ $.extend( CZRSkopeBaseMths, {
7065
  }
7066
  }
7067
  });
 
 
7068
  ctrl.czr_states( 'resetVisible' ).bind( function( visible ) {
7069
  var section_id = ctrl.section() || api.czr_activeSectionId();
7070
  if ( visible ) {
 
 
7071
  $.when( self.renderControlResetWarningTmpl( ctrl.id ) ).done( function( _params ) {
7072
  if ( _.isEmpty( _params ) )
7073
  return;
7074
  ctrl.czr_resetDialogContainer = _params.container;
7075
  _params.container.slideToggle('fast');
 
 
 
 
 
7076
  if ( ! _params.is_authorized ) {
7077
  _.delay( function() {
7078
  $.when( ctrl.czr_resetDialogContainer.slideToggle('fast') ).done( function() {
@@ -7098,10 +10965,18 @@ $.extend( CZRSkopeBaseMths, {
7098
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
7099
  ( function ( api, $, _ ) {
7100
  $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
7101
  renderControlsSingleReset : function( controls ) {
7102
  var self = this, dfd = $.Deferred();
 
7103
  if ( _.isUndefined( controls ) || _.isEmpty( controls ) ) {
7104
  controls = api.CZR_Helpers.getSectionControlIds( api.czr_activeSectionId() );
 
7105
  controls = _.filter( controls, function( _id ) {
7106
  var setId = api.CZR_Helpers.getControlSettingId( _id );
7107
  return setId && self.isSettingSkopeEligible( setId );
@@ -7114,6 +10989,7 @@ $.extend( CZRSkopeBaseMths, {
7114
  dfd.resolve();
7115
  return;
7116
  }
 
7117
  _.each( ctrlIds, function( _id ) {
7118
  api.control.when( _id, function() {
7119
  var ctrl = api.control( _id ),
@@ -7141,10 +11017,17 @@ $.extend( CZRSkopeBaseMths, {
7141
  });//when()
7142
  });//_each
7143
  };
 
 
7144
  render_reset_icons = _.debounce( render_reset_icons , 200 );
7145
  render_reset_icons( controlIds );
7146
  return dfd.promise();
7147
  },
 
 
 
 
 
7148
  renderControlResetWarningTmpl : function( ctrlId ) {
7149
  if ( ! api.control.has( ctrlId ) )
7150
  return {};
@@ -7156,6 +11039,7 @@ $.extend( CZRSkopeBaseMths, {
7156
  warning_message,
7157
  success_message,
7158
  isWPSetting = ( function() {
 
7159
  if ( _.contains( serverControlParams.wpBuiltinSettings, api.CZR_Helpers.getOptionName( setId ) ) )
7160
  return true;
7161
  if ( ! _.contains( serverControlParams.themeSettingList, api.CZR_Helpers.getOptionName( setId ) ) )
@@ -7181,6 +11065,11 @@ $.extend( CZRSkopeBaseMths, {
7181
  success_message = serverControlParams.i18n.skope['The option has been reset'];
7182
  }
7183
  }
 
 
 
 
 
7184
  var is_authorized = ! ( isWPSetting && 'global' == api.czr_skope( api.czr_activeSkopeId() )().skope && ! ctrl.czr_states( 'isDirty' )() ),
7185
  _tmpl_data = {
7186
  warning_message : warning_message + '.',
@@ -7198,6 +11087,12 @@ $.extend( CZRSkopeBaseMths, {
7198
 
7199
  return { container : $( '.czr-ctrl-reset-warning', ctrl.container ), is_authorized : is_authorized };
7200
  },
 
 
 
 
 
 
7201
  doResetSetting : function( ctrlId ) {
7202
  var self = this,
7203
  setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
@@ -7216,6 +11111,8 @@ $.extend( CZRSkopeBaseMths, {
7216
  .fail( function() { api.consoleLog( 'Silent update failed after resetting control : ' + ctrlId ); } )
7217
  .done( function() {
7218
  api.control.when( ctrlId, function() {
 
 
7219
  var ctrl = api.control( ctrlId );
7220
  $.when( $('.czr-crtl-reset-dialog', ctrl.container ).fadeOut('300') ).done( function() {
7221
  $.when( $('.czr-reset-success', ctrl.container ).fadeIn('300') ).done( function( $_el ) {
@@ -7234,9 +11131,21 @@ $.extend( CZRSkopeBaseMths, {
7234
  });
7235
  });//done()
7236
  };//_silentUpdate
 
 
 
 
7237
  self[reset_method](ctrlId)
7238
  .done( function() {
7239
  api.consoleLog('REFRESH AFTER A SETTING RESET');
 
 
 
 
 
 
 
 
7240
  api.previewer.refresh()
7241
  .fail( function( refresh_data ) {
7242
  api.errorLog('Setting reset refresh failed.', refresh_data );
@@ -7268,6 +11177,8 @@ $.extend( CZRSkopeBaseMths, {
7268
  ctrl.czr_states( 'isResetting' )( true );
7269
  ctrl.container.addClass('czr-resetting-control');
7270
 
 
 
7271
  api.czr_skopeReset[ ctrl.czr_states( 'isDirty' )() ? 'resetChangeset' : 'resetPublished' ](
7272
  { skope_id : skope_id, setId : setId, is_setting : true } )
7273
  .done( function( r ) {
@@ -7287,6 +11198,8 @@ $.extend( CZRSkopeBaseMths, {
7287
  });
7288
 
7289
  },
 
 
7290
  _resetControlDirtyness : function( ctrlId ) {
7291
  var setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
7292
  skope_instance = api.czr_skope( api.czr_activeSkopeId() ),
@@ -7303,6 +11216,11 @@ $.extend( CZRSkopeBaseMths, {
7303
 
7304
  return dfd.resolve().promise();
7305
  },
 
 
 
 
 
7306
  _resetControlAPIVal : function( ctrlId ) {
7307
  var setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
7308
  current_skope_db = api.czr_skope( api.czr_activeSkopeId() ).dbValues(),
@@ -7311,6 +11229,7 @@ $.extend( CZRSkopeBaseMths, {
7311
 
7312
  if ( _.has( api.control( ctrlId ), 'czr_states') ) {
7313
  api.control(ctrlId).czr_states( 'hasDBVal' )( false );
 
7314
  api.czr_skope( api.czr_activeSkopeId() ).dbValues( _.omit( new_skope_db, setId ) );
7315
  }
7316
  return dfd.resolve().promise();
@@ -7324,6 +11243,9 @@ $.extend( CZRSkopeBaseMths, {
7324
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
7325
  ( function ( api, $, _ ) {
7326
  $.extend( CZRSkopeBaseMths, {
 
 
 
7327
  renderCtrlSkpNotIcon : function( controlIdCandidates ) {
7328
  var self = this,
7329
  controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates];
@@ -7332,6 +11254,7 @@ $.extend( CZRSkopeBaseMths, {
7332
  api.control.when( _id, function() {
7333
  var ctrl = api.control( _id );
7334
  ctrl.deferred.embedded.then( function() {
 
7335
  if( $('.czr-toggle-notice', ctrl.container ).length )
7336
  return;
7337
 
@@ -7350,7 +11273,10 @@ $.extend( CZRSkopeBaseMths, {
7350
 
7351
  });
7352
  },
7353
- updateCtrlSkpNot : function( controlIdCandidates, visible ) {
 
 
 
7354
  var self = this,
7355
  controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates],
7356
  _isSkoped = function( setId ) {
@@ -7365,13 +11291,20 @@ $.extend( CZRSkopeBaseMths, {
7365
  _isCustomized,
7366
  _hasDBVal,
7367
  _ctxTitle;
 
 
 
7368
  if ( ! _isSkoped( setId ) ) {
7369
  _html.push( [
7370
  serverControlParams.i18n.skope['This option is always customized sitewide and cannot be reset.']
7371
  ].join(' ') );
7372
  return _html.join(' | ');
7373
  }
 
 
 
7374
  if ( _inheritedFromSkopeId == _overridedBySkopeId && api.czr_skope.has( _inheritedFromSkopeId ) && _currentSkopeId == _inheritedFromSkopeId ) {
 
7375
  _isCustomized = ! _.isUndefined( api.czr_skope( _currentSkopeId ).dirtyValues()[setId] );
7376
  _hasDBVal = ! _.isUndefined( api.czr_skope( _currentSkopeId ).dbValues()[setId] );
7377
 
@@ -7408,7 +11341,12 @@ $.extend( CZRSkopeBaseMths, {
7408
  }
7409
  }
7410
  }
 
 
 
 
7411
  if ( _inheritedFromSkopeId !== _currentSkopeId && api.czr_skope.has( _inheritedFromSkopeId ) ) {
 
7412
  _isCustomized = ! _.isUndefined( api.czr_skope( _inheritedFromSkopeId ).dirtyValues()[setId] );
7413
  _hasDBVal = ! _.isUndefined( api.czr_skope( _inheritedFromSkopeId ).dbValues()[setId] );
7414
 
@@ -7435,7 +11373,13 @@ $.extend( CZRSkopeBaseMths, {
7435
  );
7436
  }
7437
  }
 
 
 
 
7438
  if ( _overridedBySkopeId !== _currentSkopeId && api.czr_skope.has( _overridedBySkopeId ) ) {
 
 
7439
  _isCustomized = ! _.isUndefined( api.czr_skope( _overridedBySkopeId ).dirtyValues()[setId] );
7440
 
7441
  _ctxTitle = api.czr_skope( _localSkopeId )().ctx_title;
@@ -7461,6 +11405,8 @@ $.extend( CZRSkopeBaseMths, {
7461
  var ctrl = api.control( _id ),
7462
  setId = api.CZR_Helpers.getControlSettingId( _id ),//get the relevant setting_id for this control
7463
  _visible = _.isUndefined( visible ) ? ( ctrl.czr_states && ctrl.czr_states( 'noticeVisible' )() ) : visible;
 
 
7464
  if ( ! _visible )
7465
  return;
7466
 
@@ -7490,6 +11436,13 @@ $.extend( CZRSkopeBaseMths, {
7490
  });
7491
  });
7492
  },//updateCtrlSkpNot
 
 
 
 
 
 
 
7493
  isCtrlNoticeVisible : function( ctrlId ) {
7494
  if ( ! api.control.has( ctrlId ) )
7495
  return false;
@@ -7509,6 +11462,9 @@ $.extend( CZRSkopeBaseMths, {
7509
  }
7510
  return false;
7511
  },
 
 
 
7512
  removeCtrlSkpNot : function( controlIdCandidates ) {
7513
  var self = this,
7514
  controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates];
@@ -7532,515 +11488,6 @@ $.extend( CZRSkopeBaseMths, {
7532
  }
7533
  });//$.extend()
7534
  })( wp.customize , jQuery, _ );
7535
- var CZRSkopeSaveMths = CZRSkopeSaveMths || {};
7536
- ( function ( api, $, _ ) {
7537
- $.extend( CZRSkopeSaveMths, {
7538
- initialize: function() {
7539
- var self = this;
7540
- this.changesetStatus = 'publish';
7541
- this.saveBtn = $( '#save' );
7542
- },
7543
-
7544
-
7545
- save: function( args ) {
7546
- var self = this,
7547
- processing = api.state( 'processing' ),
7548
- submitWhenDoneProcessing,
7549
- parent = new api.Messenger({
7550
- url: api.settings.url.parent,
7551
- channel: 'loader',
7552
- });//this has to be reinstantiated because not accessible from core
7553
- self.globalSaveDeferred = $.Deferred();
7554
- self.previewer = api.previewer;
7555
- self.globalSkopeId = api.czr_skopeBase.getGlobalSkopeId();
7556
- self.saveArgs = args;
7557
-
7558
- if ( args && args.status ) {
7559
- self.changesetStatus = args.status;
7560
- }
7561
-
7562
- if ( api.state( 'saving' )() ) {
7563
- self.globalSaveDeferred.reject( 'already_saving' );
7564
- }
7565
- var alwaysAfterSubmission = function( response, state ) {
7566
- api.state( 'saving' )( false );
7567
- api.state( 'processing' ).set( 0 );
7568
- self.saveBtn.prop( 'disabled', false );
7569
- if ( ! _.isUndefined( response ) && response.setting_validities ) {
7570
- api._handleSettingValidities( {
7571
- settingValidities: response.setting_validities,
7572
- focusInvalidControl: true
7573
- } );
7574
- }
7575
- if ( 'pending' == state ) {
7576
- api.czr_serverNotification( { message: response, status : 'error' } );
7577
- } else {
7578
- }
7579
- },
7580
- resolveSave = function( params ) {
7581
- var response, resolveSaveDfd = $.Deferred();
7582
- api.state( 'saving' )( true );
7583
- self.fireAllSubmission( params )
7584
- .always( function( _response_ ) {
7585
- response = _response_.response;
7586
- alwaysAfterSubmission( response , this.state() );
7587
- })
7588
- .fail( function( _response_ ) {
7589
- response = _response_.response;
7590
- api.consoleLog('ALL SUBMISSIONS FAILED', response );
7591
- self.globalSaveDeferred.reject( response );
7592
- api.trigger( 'error', response );
7593
- resolveSaveDfd.resolve( _response_.hasNewMenu );
7594
- })
7595
- .done( function( _response_ ) {
7596
- response = _response_.response;
7597
- api.previewer.refresh( { waitSkopeSynced : true } )
7598
- .fail( function( refresh_data ) {
7599
- self.globalSaveDeferred.reject( self.previewer, [ response ] );
7600
- api.consoleLog('SAVE REFRESH FAIL', refresh_data );
7601
- })
7602
- .done( function( refresh_data ) {
7603
- api.previewer.send( 'saved', response );
7604
- response = _.extend( { changeset_status : 'publish' }, response || {} );
7605
- if ( api.czr_isChangeSetOn() ) {
7606
- var latestRevision = api._latestRevision;
7607
- api.state( 'changesetStatus' ).set( response.changeset_status );
7608
- if ( 'publish' === response.changeset_status ) {
7609
- api.each( function( setting ) {
7610
- /*
7611
- * Note that the setting revision will be undefined in the case of setting
7612
- * values that are marked as dirty when the customizer is loaded, such as
7613
- * when applying starter content. All other dirty settings will have an
7614
- * associated revision due to their modification triggering a change event.
7615
- */
7616
- if ( setting._dirty && ( _.isUndefined( api._latestSettingRevisions[ setting.id ] ) || api._latestSettingRevisions[ setting.id ] <= latestRevision ) ) {
7617
- setting._dirty = false;
7618
- }
7619
- } );
7620
-
7621
- api.state( 'changesetStatus' ).set( '' );
7622
- api.settings.changeset.uuid = response.next_changeset_uuid;
7623
- parent.send( 'changeset-uuid', api.settings.changeset.uuid );
7624
- }
7625
- } else {
7626
- api.each( function ( value ) {
7627
- value._dirty = false;
7628
- } );
7629
- }
7630
- refresh_data = _.extend( {
7631
- previewer : refresh_data.previewer || self.previewer,
7632
- skopesServerData : refresh_data.skopesServerData || {},
7633
- },
7634
- refresh_data
7635
- );
7636
- self.reactWhenSaveDone( refresh_data.skopesServerData );
7637
- self.globalSaveDeferred.resolveWith( self.previewer, [ response ] );
7638
-
7639
- api.trigger( 'saved', response || {} );
7640
- resolveSaveDfd.resolve( _response_.hasNewMenu );
7641
- });
7642
- });
7643
- return resolveSaveDfd.promise();
7644
- };//resolveSave
7645
-
7646
- if ( 0 === processing() ) {
7647
- resolveSave().done( function( hasNewMenu ) {
7648
- if ( hasNewMenu ) {
7649
- resolveSave( { saveGlobal :false, saveSkopes : true } );
7650
- }
7651
- } );
7652
- } else {
7653
- submitWhenDoneProcessing = function () {
7654
- if ( 0 === processing() ) {
7655
- api.state.unbind( 'change', submitWhenDoneProcessing );
7656
- resolveSave();
7657
- }
7658
- };
7659
- api.state.bind( 'change', submitWhenDoneProcessing );
7660
- }
7661
- return self.globalSaveDeferred.promise();
7662
- }//save
7663
- });//$.extend
7664
- })( wp.customize , jQuery, _ );
7665
- var CZRSkopeSaveMths = CZRSkopeSaveMths || {};
7666
- ( function ( api, $, _ ) {
7667
- $.extend( CZRSkopeSaveMths, {
7668
- getSubmitPromise : function( skope_id ) {
7669
- var self = this,
7670
- dfd = $.Deferred(),
7671
- submittedChanges = {};
7672
-
7673
- if ( _.isEmpty( skope_id ) || ! api.czr_skope.has( skope_id ) ) {
7674
- api.consoleLog( 'getSubmitPromise : no skope id requested OR skope_id not registered : ' + skope_id );
7675
- return dfd.resolve().promise();
7676
- }
7677
-
7678
- var skopeObjectToSubmit = api.czr_skope( skope_id )();
7679
- if ( ! api.czr_skope( skope_id ).dirtyness() && skope_id !== self.globalSkopeId ) {
7680
- return dfd.resolve().promise();
7681
- }
7682
- _.each( api.czr_skopeBase.getSkopeDirties( skope_id ) , function( dirtyValue, settingId ) {
7683
- submittedChanges[ settingId ] = _.extend(
7684
- { value: dirtyValue }
7685
- );
7686
- } );
7687
-
7688
- this.submit(
7689
- {
7690
- skope_id : skope_id,
7691
- customize_changeset_data : submittedChanges,//{}
7692
- dyn_type : skopeObjectToSubmit.dyn_type
7693
- })
7694
- .done( function(_resp) {
7695
- dfd.resolve( _resp );
7696
- } )
7697
- .fail( function( _resp ) {
7698
- api.consoleLog('GETSUBMIT FAILED PROMISE FOR SKOPE : ', skope_id, _resp );
7699
- dfd.reject( _resp );
7700
- } );
7701
-
7702
- return dfd.promise();
7703
- },//getSubmitPromise
7704
-
7705
-
7706
-
7707
-
7708
- submit : function( params ) {
7709
- var self = this,
7710
- default_params = {
7711
- skope_id : null,
7712
- the_dirties : {},
7713
- customize_changeset_data : {},
7714
- dyn_type : null,
7715
- opt_name : null
7716
- },
7717
- invalidSettings = [],
7718
- settingInvalidities = [],
7719
- modifiedWhileSaving = {},
7720
- invalidControls,
7721
- submit_dfd = $.Deferred();
7722
-
7723
-
7724
- params = $.extend( default_params, params );
7725
-
7726
- if ( _.isNull( params.skope_id ) ) {
7727
- throw new Error( 'OVERRIDEN SAVE::submit : MISSING skope_id');
7728
- }
7729
- if ( _.isNull( params.the_dirties ) ) {
7730
- throw new Error( 'OVERRIDEN SAVE::submit : MISSING the_dirties');
7731
- }
7732
-
7733
- /*
7734
- * Block saving if there are any settings that are marked as
7735
- * invalid from the client (not from the server). Focus on
7736
- * the control.
7737
- */
7738
- if ( _.has( api, 'Notification') ) {
7739
- api.each( function( setting ) {
7740
- setting.notifications.each( function( notification ) {
7741
- if ( 'error' === notification.type ) {
7742
- api.consoleLog('NOTIFICATION ERROR on SUBMIT SAVE' , notification );
7743
- }
7744
- if ( 'error' === notification.type && ( ! notification.data || ! notification.data.from_server ) ) {
7745
- invalidSettings.push( setting.id );
7746
- if ( ! settingInvalidities[ setting.id ] ) {
7747
- settingInvalidities[ setting.id ] = {};
7748
- }
7749
- settingInvalidities[ setting.id ][ notification.code ] = notification;
7750
- }
7751
- } );
7752
- } );
7753
- invalidControls = api.findControlsForSettings( invalidSettings );
7754
- if ( ! _.isEmpty( invalidControls ) ) {
7755
- _.values( invalidControls )[0][0].focus();
7756
- return submit_dfd.rejectWith( self.previewer, [
7757
- { setting_invalidities: settingInvalidities }
7758
- ] ).promise();
7759
- }
7760
- }
7761
- var query_params = {
7762
- skope_id : params.skope_id,
7763
- action : 'save',
7764
- the_dirties : params.the_dirties,
7765
- dyn_type : params.dyn_type,
7766
- opt_name : params.opt_name
7767
- };
7768
- if ( api.czr_isChangeSetOn() ) {
7769
- $.extend( query_params, { excludeCustomizedSaved: false } );
7770
- }
7771
-
7772
- /*
7773
- * Note that excludeCustomizedSaved is intentionally false so that the entire
7774
- * set of customized data will be included if bypassed changeset update.
7775
- */
7776
- var query = $.extend( self.previewer.query( query_params ), {
7777
- nonce: self.previewer.nonce.save,
7778
- customize_changeset_status: self.changesetStatus,
7779
- customize_changeset_data : JSON.stringify( params.customize_changeset_data )
7780
- } );
7781
- if ( api.czr_isChangeSetOn() ) {
7782
- if ( self.saveArgs && self.saveArgs.date ) {
7783
- query.customize_changeset_date = self.saveArgs.date;
7784
- }
7785
- if ( self.saveArgs && self.saveArgs.title ) {
7786
- query.customize_changeset_title = self.saveArgs.title;
7787
- }
7788
- }
7789
-
7790
- /*
7791
- * Note that the dirty customized values will have already been set in the
7792
- * changeset and so technically query.customized could be deleted. However,
7793
- * it is remaining here to make sure that any settings that got updated
7794
- * quietly which may have not triggered an update request will also get
7795
- * included in the values that get saved to the changeset. This will ensure
7796
- * that values that get injected via the saved event will be included in
7797
- * the changeset. This also ensures that setting values that were invalid
7798
- * will get re-validated, perhaps in the case of settings that are invalid
7799
- * due to dependencies on other settings.
7800
- */
7801
- var request = wp.ajax.post(
7802
- 'global' !== query.skope ? 'customize_skope_changeset_save' : 'customize_save',
7803
- query
7804
- );
7805
- self.saveBtn.prop( 'disabled', true );
7806
-
7807
- api.trigger( 'save', request );
7808
-
7809
- request.fail( function ( response ) {
7810
- api.consoleLog('SUBMIT REQUEST FAIL', params.skope_id, response );
7811
- if ( '0' === response ) {
7812
- response = 'not_logged_in';
7813
- } else if ( '-1' === response ) {
7814
- response = 'invalid_nonce';
7815
- }
7816
-
7817
- if ( 'invalid_nonce' === response ) {
7818
- self.previewer.cheatin();
7819
- } else if ( 'not_logged_in' === response ) {
7820
- self.previewer.preview.iframe.hide();
7821
- self.previewer.login().done( function() {
7822
- self.previewer.save();
7823
- self.previewer.preview.iframe.show();
7824
- } );
7825
- }
7826
- api.trigger( 'error', response );
7827
- submit_dfd.reject( response );
7828
- } );
7829
-
7830
- request.done( function( response ) {
7831
- submit_dfd.resolve( response );
7832
- } );
7833
- return submit_dfd.promise();
7834
- }//submit()
7835
- });//$.extend
7836
- })( wp.customize , jQuery, _ );
7837
- var CZRSkopeSaveMths = CZRSkopeSaveMths || {};
7838
- ( function ( api, $, _ ) {
7839
- $.extend( CZRSkopeSaveMths, {
7840
- fireAllSubmission : function( params ) {
7841
- var self = this,
7842
- dfd = $.Deferred(),
7843
- skopesToSave = [],
7844
- _recursiveCallDeferred = $.Deferred(),
7845
- _responses_ = {},
7846
- _promises = [],
7847
- failedPromises = [],
7848
- _defaultParams = {
7849
- saveGlobal : true,
7850
- saveSkopes : true
7851
- };
7852
- params = $.extend( _defaultParams, params );
7853
- _.each( api.czr_skopeCollection(), function( _skp_ ) {
7854
- if ( 'global' !== _skp_.skope ) {
7855
- skopesToSave.push( _skp_.id );
7856
- }
7857
- });
7858
-
7859
- var _mayBeresolve = function( _index ) {
7860
- if ( ! _.isUndefined( skopesToSave[ _index + 1 ] ) || _promises.length != skopesToSave.length )
7861
- return;
7862
-
7863
- if ( _.isEmpty( failedPromises ) ) {
7864
- _recursiveCallDeferred.resolve( _responses_ );
7865
- } else {
7866
- var _buildResponse = function() {
7867
- var _failedResponse = [];
7868
- _.each( failedPromises, function( _r ) {
7869
- _failedResponse.push( api.czr_skopeBase.buildServerResponse( _r ) );
7870
- } );
7871
- return $.trim( _failedResponse.join( ' | ') );
7872
- };
7873
- _recursiveCallDeferred.reject( _buildResponse() );
7874
- }
7875
- return true;
7876
- };
7877
- var recursiveCall = function( _index ) {
7878
- _index = _index || 0;
7879
- if ( _.isUndefined( skopesToSave[_index] ) ) {
7880
- api.consoleLog( 'Undefined Skope in Save recursive call ', _index, _skopesToUpdate, _skopesToUpdate[_index] );
7881
- _recursiveCallDeferred.resolve( _responses_ );
7882
- }
7883
- self.getSubmitPromise( skopesToSave[ _index ] )
7884
- .always( function() { _promises.push( _index ); } )
7885
- .fail( function( response ) {
7886
- failedPromises.push( response );
7887
- api.consoleLog('RECURSIVE PUSH FAIL FOR SKOPE : ', skopesToSave[_index] );
7888
- if ( ! _mayBeresolve( _index ) )
7889
- recursiveCall( _index + 1 );
7890
- } )
7891
- .done( function( response ) {
7892
- response = response || {};
7893
- if ( _.isEmpty( _responses_ ) ) {
7894
- _responses_ = response || {};
7895
- } else {
7896
- _responses_ = $.extend( _responses_ , response );
7897
- }
7898
- if ( ! _mayBeresolve( _index ) )
7899
- recursiveCall( _index + 1 );
7900
- } );
7901
-
7902
- return _recursiveCallDeferred.promise();
7903
- };
7904
- var _globalHasNewMenu = false;
7905
- _.each( api.czr_skope('global__all_').dirtyValues(), function( _setDirtVal , _setId ) {
7906
- if ( 'nav_menu[' != _setId.substring( 0, 'nav_menu['.length ) )
7907
- return;
7908
- _globalHasNewMenu = true;
7909
- } );
7910
-
7911
- var _submitGlobal = function() {
7912
- self.getSubmitPromise( self.globalSkopeId )
7913
- .fail( function( r ) {
7914
- api.consoleLog('GLOBAL SAVE SUBMIT FAIL', r );
7915
- r = api.czr_skopeBase.buildServerResponse( r );
7916
- dfd.reject( r );
7917
- })
7918
- .done( function( r ) {
7919
- if ( _.isEmpty( _responses_ ) ) {
7920
- _responses_ = r || {};
7921
- } else {
7922
- _responses_ = $.extend( _responses_ , r );
7923
- }
7924
- dfd.resolve( { response : _responses_, hasNewMenu : _globalHasNewMenu } );
7925
- });
7926
- };
7927
-
7928
-
7929
- if ( _globalHasNewMenu && params.saveGlobal ) {
7930
- _submitGlobal();
7931
- } else {
7932
- if ( params.saveGlobal && params.saveSkopes ) {
7933
- recursiveCall()
7934
- .fail( function( r ) {
7935
- api.consoleLog('RECURSIVE SAVE CALL FAIL', r );
7936
- dfd.reject( r );
7937
- })
7938
- .done( function( r ) {
7939
- self.cleanSkopeChangesetMetas().always( function() { _submitGlobal(); } );
7940
- });
7941
- } else if ( params.saveGlobal && ! params.saveSkopes ) {
7942
- _submitGlobal();
7943
- } else if ( ! params.saveGlobal && params.saveSkopes ) {
7944
- recursiveCall()
7945
- .fail( function( r ) {
7946
- api.consoleLog('RECURSIVE SAVE CALL FAIL', r );
7947
- dfd.reject( r );
7948
- })
7949
- .done( function( r ) {
7950
- if ( _.isEmpty( _responses_ ) ) {
7951
- _responses_ = r || {};
7952
- } else {
7953
- _responses_ = $.extend( _responses_ , r );
7954
- }
7955
- self.cleanSkopeChangesetMetas().always( function() {
7956
- dfd.resolve( { response : _responses_, hasNewMenu : _globalHasNewMenu } );
7957
- });
7958
- });
7959
- }
7960
- }//else
7961
-
7962
- return dfd.promise();
7963
- },//fireAllSubmissions
7964
- cleanSkopeChangesetMetas : function() {
7965
- var self = this,
7966
- dfd = $.Deferred();
7967
- _query = $.extend(
7968
- api.previewer.query(),
7969
- { nonce: api.previewer.nonce.save }
7970
- );
7971
- wp.ajax.post( 'czr_clean_skope_changeset_metas_after_publish' , _query )
7972
- .always( function () { dfd.resolve(); })
7973
- .fail( function ( response ) { api.consoleLog( 'cleanSkopeChangesetMetas failed', _query, response ); })
7974
- .done( function( response ) { api.consoleLog( 'cleanSkopeChangesetMetas done', _query, response ); });
7975
-
7976
- return dfd.promise();
7977
- }
7978
- });//$.extend
7979
- })( wp.customize , jQuery, _ );
7980
- var CZRSkopeSaveMths = CZRSkopeSaveMths || {};
7981
- ( function ( api, $, _ ) {
7982
- $.extend( CZRSkopeSaveMths, {
7983
- reactWhenSaveDone : function( skopesServerData ) {
7984
- var saved_dirties = {};
7985
- skopesServerData = _.extend(
7986
- {
7987
- czr_skopes : [],
7988
- isChangesetDirty : false
7989
- },
7990
- skopesServerData
7991
- );
7992
- _.each( api.czr_skopeCollection(), function( _skp_ ) {
7993
- saved_dirties[ _skp_.opt_name ] = api.czr_skopeBase.getSkopeDirties( _skp_.id );
7994
- api.czr_skope( _skp_.id ).dirtyValues( {} );
7995
- api.czr_skope( _skp_.id ).changesetValues( {} );
7996
- });
7997
- var _notSyncedSettings = [],
7998
- _sentSkopeCollection = skopesServerData.czr_skopes;
7999
-
8000
- api.consoleLog('REACT WHEN SAVE DONE', saved_dirties, _sentSkopeCollection );
8001
-
8002
- _.each( saved_dirties, function( skp_data, _saved_opt_name ) {
8003
- _.each( skp_data, function( _val, _setId ) {
8004
- if ( _.isUndefined( _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ) ) )
8005
- return;
8006
- if ( ! api.czr_skopeBase.isSettingSkopeEligible( _setId ) )
8007
- return;
8008
-
8009
- var sent_skope_db_values = _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ).db,
8010
- sent_skope_level = _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ).skope,
8011
- wpSetId = api.CZR_Helpers.build_setId( _setId ),
8012
- shortSetId = api.CZR_Helpers.getOptionName( _setId ),
8013
- sent_set_val = sent_skope_db_values[wpSetId];
8014
- if ( _.isUndefined( sent_set_val ) && 'global' == sent_skope_level && _val === serverControlParams.defaultOptionsValues[shortSetId] )
8015
- return;
8016
-
8017
- if ( _.isUndefined( sent_set_val ) || ! _.isEqual( sent_set_val, _val ) ) {
8018
- _notSyncedSettings.push( { opt_name : _saved_opt_name, setId : wpSetId, server_val : sent_set_val, api_val : _val } );
8019
- }
8020
- });
8021
- });
8022
-
8023
- if ( ! _.isEmpty( _notSyncedSettings ) ) {
8024
- api.consoleLog('SOME SETTINGS HAVE NOT BEEN PROPERLY SAVED : ', _notSyncedSettings );
8025
- } else {
8026
- api.consoleLog('ALL RIGHT, SERVER AND API ARE SYNCHRONIZED AFTER SAVE' );
8027
- }
8028
- api.czr_skopeBase.maybeSynchronizeGlobalSkope();
8029
- api.czr_skopeBase.updateCtrlSkpNot( api.CZR_Helpers.getSectionControlIds() );
8030
- var _setupSectionCtrlNotices = function() {
8031
- var sectionCtrls = api.CZR_Helpers.getSectionControlIds( api.czr_activeSectionId() );
8032
- _.each( sectionCtrls, function( ctrlId ) {
8033
- if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
8034
- return;
8035
- var ctrl = api.control( ctrlId );
8036
- if ( ! _.has( ctrl, 'czr_states' ) )
8037
- return;
8038
- ctrl.czr_states( 'noticeVisible' )( api.czr_skopeBase.isCtrlNoticeVisible( ctrlId ) );
8039
- });
8040
- };
8041
- }
8042
- });//$.extend
8043
- })( wp.customize , jQuery, _ );
8044
  var CZRSkopeResetMths = CZRSkopeResetMths || {};
8045
  ( function ( api, $, _ ) {
8046
  $.extend( CZRSkopeResetMths, {
@@ -8052,6 +11499,13 @@ $.extend( CZRSkopeResetMths, {
8052
  $( document.body ).toggleClass( 'czr-resetting', false !== state );
8053
  });
8054
  },
 
 
 
 
 
 
 
8055
  resetChangeset : function( args ) {
8056
  var dfd = $.Deferred(),
8057
  self = this,
@@ -8075,11 +11529,15 @@ $.extend( CZRSkopeResetMths, {
8075
 
8076
  if( ! api.czr_isChangeSetOn() )
8077
  return dfd.resolve().promise();
 
 
 
8078
  submit_reset = function( skope_id, setId ) {
8079
  if ( _.isUndefined( skope_id ) ) {
8080
  throw new Error( 'RESET: MISSING skope_id');
8081
  }
8082
  api.state( 'czr-resetting' )( true );
 
8083
  query_params = {
8084
  skope_id : skope_id,
8085
  action : 'reset'
@@ -8088,6 +11546,10 @@ $.extend( CZRSkopeResetMths, {
8088
  self.previewer.query( query_params ),
8089
  { nonce: self.previewer.nonce.save }
8090
  );
 
 
 
 
8091
  if ( args.is_setting ) {
8092
  $.extend( query , { setting_id : setId } );
8093
  requestAjaxAction = 'czr_changeset_setting_reset';
@@ -8105,6 +11567,7 @@ $.extend( CZRSkopeResetMths, {
8105
  if ( '0' === response ) {
8106
  response = 'not_logged_in';
8107
  } else if ( '-1' === response ) {
 
8108
  response = 'invalid_nonce';
8109
  }
8110
 
@@ -8143,6 +11606,17 @@ $.extend( CZRSkopeResetMths, {
8143
 
8144
  return dfd.promise();
8145
  },
 
 
 
 
 
 
 
 
 
 
 
8146
  resetPublished : function( args ) {
8147
  var dfd = $.Deferred(),
8148
  self = this,
@@ -8163,11 +11637,14 @@ $.extend( CZRSkopeResetMths, {
8163
  args = _.extend( defaults, args );
8164
  var skope_id = args.skope_id,
8165
  setId = args.setId;
 
 
8166
  submit_reset = function( skope_id, setId ) {
8167
  if ( _.isUndefined( skope_id ) ) {
8168
  throw new Error( 'RESET: MISSING skope_id');
8169
  }
8170
  api.state( 'czr-resetting' )( true );
 
8171
  query_params = {
8172
  skope_id : skope_id,
8173
  action : 'reset'
@@ -8176,6 +11653,10 @@ $.extend( CZRSkopeResetMths, {
8176
  self.previewer.query( query_params ),
8177
  { nonce: self.previewer.nonce.save }
8178
  );
 
 
 
 
8179
  if ( args.is_setting ) {
8180
  $.extend( query , { setting_id : setId } );
8181
  requestAjaxAction = 'czr_published_setting_reset';
@@ -8195,6 +11676,7 @@ $.extend( CZRSkopeResetMths, {
8195
  if ( '0' === response ) {
8196
  response = 'not_logged_in';
8197
  } else if ( '-1' === response ) {
 
8198
  response = 'invalid_nonce';
8199
  }
8200
 
@@ -8240,6 +11722,7 @@ $.extend( CZRSkopeResetMths, {
8240
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
8241
  ( function ( api, $, _ ) {
8242
  $.extend( CZRSkopeBaseMths, {
 
8243
  initWidgetSidebarSpecifics : function() {
8244
  var self = this;
8245
  if ( ! self.isExcludedSidebarsWidgets() ) {
@@ -8247,11 +11730,14 @@ $.extend( CZRSkopeBaseMths, {
8247
  self.forceSidebarDirtyRefresh( api.czr_activeSectionId(), active_skope );
8248
  });
8249
  }
 
 
8250
  $( document ).bind( 'widget-added', function( e, $o ) {
8251
  if ( self.isExcludedSidebarsWidgets() )
8252
  return;
8253
 
8254
  var wgtIdAttr = $o.closest('.customize-control').attr('id'),
 
8255
  wdgtSetId = api.czr_skopeBase.widgetIdToSettingId( wgtIdAttr, 'customize-control-' );
8256
  if ( ! api.has( wdgtSetId ) ) {
8257
  throw new Error( 'AN ADDED WIDGET COULD NOT BE BOUND IN SKOPE. ' + wdgtSetId);
@@ -8267,11 +11753,15 @@ $.extend( CZRSkopeBaseMths, {
8267
  if ( self.isExcludedSidebarsWidgets() )
8268
  return;
8269
  var _save_state = api.state('saved')();
 
 
8270
  var _debounced = function() {
8271
  if ( api.section.has( active_section ) && "sidebar" == api.section(active_section).params.type ) {
8272
  var active_skope = active_skope || api.czr_activeSkopeId(),
8273
  related_setting_name = 'sidebars_widgets[' + api.section(active_section).params.sidebarId + ']',
8274
  related_setting_val = self.getSkopeSettingVal( related_setting_name, active_skope );
 
 
8275
  api.czr_skope( active_skope ).updateSkopeDirties( related_setting_name, related_setting_val );
8276
 
8277
  api.previewer.refresh( { the_dirties : api.czr_skope( active_skope ).dirtyValues() } )
@@ -8288,10 +11778,19 @@ $.extend( CZRSkopeBaseMths, {
8288
 
8289
  var CZRSkopeMths = CZRSkopeMths || {};
8290
  ( function ( api, $, _ ) {
 
8291
  $.extend( CZRSkopeMths, {
8292
  /*****************************************************************************
8293
  * THE SKOPE MODEL
8294
  *****************************************************************************/
 
 
 
 
 
 
 
 
8295
  initialize: function( skope_id, constructor_options ) {
8296
  var skope = this;
8297
  api.Value.prototype.initialize.call( skope, null, constructor_options );
@@ -8299,18 +11798,29 @@ $.extend( CZRSkopeMths, {
8299
  skope.isReady = $.Deferred();
8300
  skope.embedded = $.Deferred();
8301
  skope.el = 'czr-scope-' + skope_id;//@todo replace with a css selector based on the scope name
 
 
8302
  $.extend( skope, constructor_options || {} );
 
 
8303
  skope.visible = new api.Value( true );
8304
  skope.winner = new api.Value( false ); //is this skope the one that will be applied on front end in the current context?
8305
  skope.priority = new api.Value(); //shall this skope always win or respect the default skopes priority
8306
  skope.active = new api.Value( false ); //active, inactive. Are we currently customizing this skope ?
8307
  skope.dirtyness = new api.Value( false ); //true or false : has this skope been customized ?
8308
  skope.skopeResetDialogVisibility = new api.Value( false );
 
 
8309
  skope.hasDBValues = new api.Value( false );
8310
  skope.dirtyValues = new api.Value({});//stores the current customized value.
8311
  skope.dbValues = new api.Value({});//stores the latest db values => will be updated on each skope synced event
8312
  skope.changesetValues = new api.Value({});//stores the latest changeset values => will be updated on each skope synced eventsynced event
 
 
 
 
8313
  skope.userEventMap = new api.Value( [
 
8314
  {
8315
  trigger : 'click keydown',
8316
  selector : '.czr-scope-switch, .czr-skp-switch-link',
@@ -8319,6 +11829,7 @@ $.extend( CZRSkopeMths, {
8319
  api.czr_activeSkopeId( skope().id );
8320
  }
8321
  },
 
8322
  {
8323
  trigger : 'click keydown',
8324
  selector : '.czr-scope-reset',
@@ -8326,37 +11837,81 @@ $.extend( CZRSkopeMths, {
8326
  actions : 'reactOnSkopeResetUserRequest'
8327
  }
8328
  ]);//module.userEventMap
 
 
8329
  skope.skopeResetDialogVisibility.bind( function( to, from ) {
8330
  return skope.skopeResetDialogReact( to );
8331
  }, { deferred : true } );
 
 
 
 
8332
  skope.dirtyValues.callbacks.add(function() { return skope.dirtyValuesReact.apply(skope, arguments ); } );
 
 
8333
  skope.changesetValues.callbacks.add(function() { return skope.changesetValuesReact.apply(skope, arguments ); } );
 
 
8334
  skope.dbValues.callbacks.add(function() { return skope.dbValuesReact.apply(skope, arguments ); } );
 
 
8335
  skope.callbacks.add(function() { return skope.skopeReact.apply( skope, arguments ); } );
 
 
 
 
8336
  skope.set( _.omit( constructor_options, function( _v, _key ) {
8337
  return _.contains( [ 'db', 'changeset', 'has_db_val' ], _key );
8338
  } ) );
 
 
 
 
 
 
 
 
 
8339
  skope.setupObservableViewValuesCallbacks();
 
 
8340
  skope.dirtyness( ! _.isEmpty( constructor_options.changeset ) );
8341
  skope.hasDBValues( ! _.isEmpty( constructor_options.db ) );
8342
  skope.winner( constructor_options.is_winner );
 
 
 
 
 
 
 
8343
  skope.embedded
8344
  .fail( function() {
8345
  throw new Error('The container of skope ' + skope().id + ' has not been embededd');
8346
  })
8347
  .done( function() {
 
 
8348
  skope.setupDOMListeners( skope.userEventMap() , { dom_el : skope.container } );
8349
 
8350
  skope.isReady.resolve();
8351
  });
8352
 
8353
  },//initialize
 
 
 
 
8354
  ready : function() {
8355
  var skope = this;
 
 
8356
  api.czr_skopeBase.skopeWrapperEmbedded.done( function() {
 
8357
  try {
8358
  $.when( skope.embedSkopeDialogBox() ).done( function( $_container ){
8359
  if ( false !== $_container.length ) {
 
8360
  $_container.css('background-color', skope.color );
8361
  skope.container = $_container;
8362
  skope.embedded.resolve( $_container );
@@ -8378,21 +11933,48 @@ $.extend( CZRSkopeMths, {
8378
  * SKOPE API DIRTIES REACTIONS
8379
  *****************************************************************************/
8380
  dirtyValuesReact : function( to, from ) {
 
8381
  var skope = this;
 
 
8382
  skope.dirtyness( ! _.isEmpty( to ) );
 
 
 
 
 
 
 
 
 
 
 
8383
  api.czr_dirtyness( ! _.isEmpty(to) );
 
 
8384
  var ctrlIdDirtynessToClean = [];
8385
  _.each( from, function( _val, _id ) {
8386
  if ( _.has( to, _id ) )
8387
  return;
8388
  ctrlIdDirtynessToClean.push( _id );
8389
  });
 
 
 
 
 
 
 
 
 
8390
  if ( skope().id == api.czr_activeSkopeId() ) {
 
8391
  _.each( ctrlIdDirtynessToClean , function( setId ) {
8392
  if ( ! _.has( api.control( setId ), 'czr_states') )
8393
  return;
8394
  api.control( setId ).czr_states( 'isDirty' )( false );
8395
  });
 
8396
  _.each( to, function( _val, _setId ) {
8397
  if ( ! _.has( api.control( _setId ), 'czr_states') )
8398
  return;
@@ -8417,6 +11999,8 @@ $.extend( CZRSkopeMths, {
8417
  *****************************************************************************/
8418
  dbValuesReact : function( to, from ) {
8419
  var skope = this;
 
 
8420
  skope.hasDBValues(
8421
  ! _.isEmpty(
8422
  'global' != skope().skope ?
@@ -8426,18 +12010,29 @@ $.extend( CZRSkopeMths, {
8426
  })
8427
  )
8428
  );
 
 
 
8429
  var ctrlIdDbToReset = [];
8430
  _.each( from, function( _val, _id ) {
8431
  if ( _.has( to, _id ) )
8432
  return;
8433
  ctrlIdDbToReset.push( _id );
8434
  });
 
 
 
 
 
 
 
8435
  if ( skope().id == api.czr_activeSkopeId() ) {
8436
  _.each( ctrlIdDbToReset , function( setId ) {
8437
  if ( ! _.has( api.control( setId ), 'czr_states') )
8438
  return;
8439
  api.control( setId ).czr_states( 'hasDBVal' )( false );
8440
  });
 
8441
  _.each( to, function( _val, _setId ) {
8442
  if ( ! _.has( api.control( _setId ), 'czr_states') )
8443
  return;
@@ -8451,18 +12046,26 @@ $.extend( CZRSkopeMths, {
8451
  /*****************************************************************************
8452
  * SKOPE MODEL CHANGES CALLBACKS
8453
  *****************************************************************************/
 
8454
  skopeReact : function( to, from ) {
8455
  var skope = this,
8456
  _current_collection = [],
8457
  _new_collection = [];
 
 
 
8458
  if ( ! api.czr_skopeBase.isSkopeRegisteredInCollection( to.id ) ) {
 
8459
  _current_collection = $.extend( true, [], api.czr_skopeCollection() );
8460
  _current_collection.push( to );
8461
  api.czr_skopeCollection( _current_collection );
8462
  }
 
8463
  else {
 
8464
  _current_collection = $.extend( true, [], api.czr_skopeCollection() );
8465
  _new_collection = _current_collection;
 
8466
  _.each( _current_collection, function( _skope, _key ) {
8467
  if ( _skope.id != skope().id )
8468
  return;
@@ -8483,8 +12086,10 @@ $.extend( CZRSkopeMths, {
8483
  * VALUES CALLBACKS WHEN SKOPE EMBEDDED AND READY
8484
  * => The skope container exists at this stage
8485
  *****************************************************************************/
 
8486
  setupObservableViewValuesCallbacks : function() {
8487
  var skope = this;
 
8488
  skope.visible.bind( function( is_visible ){
8489
  if ( 'pending' == skope.embedded.state() ) {
8490
  skope.embedded.done( function() {
@@ -8495,6 +12100,11 @@ $.extend( CZRSkopeMths, {
8495
  }
8496
 
8497
  });
 
 
 
 
 
8498
  skope.active.bind( function() {
8499
  if ( 'pending' == skope.embedded.state() ) {
8500
  skope.embedded.done( function() {
@@ -8535,11 +12145,16 @@ $.extend( CZRSkopeMths, {
8535
  }
8536
  });
8537
  },//setupObservableViewValuesCallbacks
 
 
8538
  activeStateReact : function( to, from ){
8539
  var skope = this;
8540
  skope.container.toggleClass('inactive', ! to ).toggleClass( 'active', to );
 
8541
  $('.czr-scope-switch', skope.container).toggleClass('fa-toggle-on', to).toggleClass('fa-toggle-off', !to);
8542
  },
 
 
8543
  dirtynessReact : function( to, from ) {
8544
  var skope = this;
8545
  $.when( this.container.toggleClass( 'dirty', to ) ).done( function() {
@@ -8549,6 +12164,8 @@ $.extend( CZRSkopeMths, {
8549
  $( '.czr-scope-reset', skope.container).fadeOut('fast');
8550
  });
8551
  },
 
 
8552
  hasDBValuesReact : function( to, from ) {
8553
  var skope = this;
8554
  $.when( skope.container.toggleClass('has-db-val', to ) ).done( function() {
@@ -8565,11 +12182,14 @@ $.extend( CZRSkopeMths, {
8565
  }
8566
  });
8567
  },
 
 
8568
  winnerReact : function( is_winner ) {
8569
  var skope = this;
8570
  this.container.toggleClass('is_winner', is_winner );
8571
 
8572
  if ( is_winner ) {
 
8573
  _.each( api.czr_currentSkopesCollection(), function( _skope ) {
8574
  if ( _skope.id == skope().id )
8575
  return;
@@ -8586,9 +12206,14 @@ $.extend( CZRSkopeMths, {
8586
  /*****************************************************************************
8587
  * HELPERS
8588
  *****************************************************************************/
 
 
 
8589
  updateSkopeDirties : function( setId, new_val ) {
8590
  var skope = this,
8591
  shortSetId = api.CZR_Helpers.getOptionName( setId );
 
 
8592
  if ( ! api.czr_skopeBase.isSettingSkopeEligible( setId ) && 'global' != skope().skope )
8593
  return api.czr_skope( api.czr_skopeBase.getGlobalSkopeId() ).updateSkopeDirties( setId, new_val );
8594
 
@@ -8599,20 +12224,30 @@ $.extend( CZRSkopeMths, {
8599
  skope.dirtyValues.set( $.extend( current_dirties , _dirtyCustomized ) );
8600
  return skope.dirtyValues();
8601
  },
 
 
 
 
8602
  getSkopeSettingDirtyness : function( setId ) {
8603
  var skope = this;
8604
  return skope.getSkopeSettingAPIDirtyness( setId ) || skope.getSkopeSettingChangesetDirtyness( setId );
8605
  },
 
 
8606
  getSkopeSettingAPIDirtyness : function( setId ) {
8607
  var skope = this;
8608
  return _.has( skope.dirtyValues(), api.CZR_Helpers.build_setId( setId ) );
8609
  },
 
 
8610
  getSkopeSettingChangesetDirtyness : function( setId ) {
8611
  var skope = this;
8612
  if ( ! api.czr_isChangeSetOn() )
8613
  return skope.getSkopeSettingAPIDirtyness( setId );
8614
  return _.has( skope.changesetValues(), api.CZR_Helpers.build_setId( setId ) );
8615
  },
 
 
8616
  hasSkopeSettingDBValues : function( setId ) {
8617
  var skope = this,
8618
  _setId = api.CZR_Helpers.build_setId(setId);
@@ -8628,6 +12263,8 @@ $.extend( CZRSkopeMths, {
8628
  var skope = this,
8629
  skope_model = $.extend( true, {}, skope() ),
8630
  _tmpl = '';
 
 
8631
  if ( ! $('#customize-header-actions').find('.czr-scope-switcher').length ) {
8632
  throw new Error('The skope switcher wrapper is not printed, the skope can not be embedded.');
8633
  }
@@ -8644,6 +12281,15 @@ $.extend( CZRSkopeMths, {
8644
 
8645
 
8646
 
 
 
 
 
 
 
 
 
 
8647
  /*****************************************************************************
8648
  * RESET
8649
  *****************************************************************************/
@@ -8707,10 +12353,15 @@ $.extend( CZRSkopeMths, {
8707
 
8708
  var CZRSkopeMths = CZRSkopeMths || {};
8709
  ( function ( api, $, _ ) {
 
8710
  $.extend( CZRSkopeMths, {
8711
  /*****************************************************************************
8712
  * RESET
8713
  *****************************************************************************/
 
 
 
 
8714
  reactOnSkopeResetUserRequest : function() {
8715
  var skope = this,
8716
  _fireReaction = function() {
@@ -8729,6 +12380,8 @@ $.extend( CZRSkopeMths, {
8729
  });
8730
  }
8731
  };
 
 
8732
  if ( ( api.state( 'czr-resetting')() || 0 !== api.state( 'processing' )() ) ) {
8733
  api.czr_serverNotification( {
8734
  message: 'Slow down, you move too fast !',
@@ -8737,6 +12390,7 @@ $.extend( CZRSkopeMths, {
8737
  });
8738
  return;
8739
  }
 
8740
  if ( api.czr_activeSkopeId() != skope().id && api.czr_skope( api.czr_activeSkopeId() ).skopeResetDialogVisibility() ) {
8741
  api.czr_skope( api.czr_activeSkopeId() ).skopeResetDialogVisibility( false ).done( function() {
8742
  _fireReaction();
@@ -8745,9 +12399,36 @@ $.extend( CZRSkopeMths, {
8745
  _fireReaction();
8746
  }
8747
  },
 
 
 
 
 
 
 
 
 
 
 
 
8748
  skopeResetDialogReact : function( visible ) {
8749
  var skope = this, dfd = $.Deferred();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8750
  skope.userResetEventMap = skope.userResetEventMap || new api.Value( [
 
8751
  {
8752
  trigger : 'click keydown',
8753
  selector : '.czr-scope-reset-cancel',
@@ -8756,6 +12437,7 @@ $.extend( CZRSkopeMths, {
8756
  skope.skopeResetDialogVisibility( ! skope.skopeResetDialogVisibility() );
8757
  }
8758
  },
 
8759
  {
8760
  trigger : 'click keydown',
8761
  selector : '.czr-scope-do-reset',
@@ -8766,15 +12448,24 @@ $.extend( CZRSkopeMths, {
8766
  );
8767
 
8768
  if ( visible ) {
 
 
 
8769
  api.czr_isResettingSkope( skope().id );
 
 
8770
  $.when( skope.renderResetWarningTmpl() ).done( function( $_container ) {
8771
  skope.resetPanel = $_container;
 
8772
  skope.resetPanel.addClass( skope.dirtyness() ? 'dirty-reset' : 'db-reset' );
8773
  skope.setupDOMListeners( skope.userResetEventMap() , { dom_el : skope.resetPanel } );
 
8774
  }).then( function() {
8775
  setTimeout( function() {
 
8776
  var _height = $('#customize-preview').height();
8777
  skope.resetPanel.css( 'line-height', _height +'px' ).css( 'height', _height + 'px' );
 
8778
  $('body').addClass('czr-skope-pane-open');
8779
  }, 50 );
8780
  });
@@ -8788,10 +12479,17 @@ $.extend( CZRSkopeMths, {
8788
  }
8789
  });
8790
  }
 
 
8791
  _.delay( function() { dfd.resolve(); }, 350 );
8792
 
8793
  return dfd.promise();
8794
  },
 
 
 
 
 
8795
  doResetSkopeValues : function() {
8796
  var skope = this,
8797
  skope_id = skope().id,
@@ -8814,6 +12512,14 @@ $.extend( CZRSkopeMths, {
8814
 
8815
  skope[reset_method]()
8816
  .done( function() {
 
 
 
 
 
 
 
 
8817
  api.previewer.refresh()
8818
  .fail( function( refresh_data ) {
8819
  api.consoleLog('SKOPE RESET REFRESH FAILED', refresh_data );
@@ -8843,6 +12549,9 @@ $.extend( CZRSkopeMths, {
8843
  };//_updateAPI
8844
 
8845
  $('body').addClass('czr-resetting-skope');
 
 
 
8846
  api.czr_skopeReset[ skope.dirtyness() ? 'resetChangeset' : 'resetPublished' ](
8847
  { skope_id : skope().id, is_skope : true } )
8848
  .always( function() {
@@ -8856,39 +12565,56 @@ $.extend( CZRSkopeMths, {
8856
  api.consoleLog('Skope reset failed', r );
8857
  });
8858
  },
 
 
 
 
8859
  _resetSkopeDirties : function() {
8860
  var skope = this, dfd = $.Deferred();
8861
  skope.dirtyValues({});
8862
  skope.changesetValues({});
8863
  return dfd.resolve().promise();
8864
  },
 
 
 
8865
  _resetSkopeAPIValues : function() {
8866
  var skope = this, dfd = $.Deferred();
 
8867
  skope.dbValues( {} );
8868
  return dfd.resolve().promise();
8869
  }
8870
  });//$.extend(
8871
  })( wp.customize , jQuery, _ );
8872
  ( function ( api, $, _ ) {
 
 
8873
  $.extend( CZRSkopeBaseMths, api.Events );
8874
  $.extend( CZRSkopeMths, api.Events );
8875
  $.extend( CZRSkopeMths, api.CZR_Helpers );
8876
  api.CZR_skopeBase = api.Class.extend( CZRSkopeBaseMths );
8877
- api.CZR_skopeSave = api.Class.extend( CZRSkopeSaveMths );
8878
  api.CZR_skopeReset = api.Class.extend( CZRSkopeResetMths );
8879
  api.CZR_skope = api.Value.extend( CZRSkopeMths ); //=> used as constructor when creating the collection of skopes
 
 
 
 
 
8880
  if ( _.has(api, 'HeaderTool') ) {
8881
  api.czr_HeaderTool = $.extend( true, {}, api.HeaderTool );
8882
  }
8883
 
8884
  })( wp.customize, jQuery, _ );
8885
  ( function ( api, $, _ ) {
 
8886
  api.bind('ready', function() {
8887
  var _do = function() {
8888
  api.section('themes').active.bind( function( active ) {
8889
  if ( ! _.has( serverControlParams, 'isThemeSwitchOn' ) || ! _.isEmpty( serverControlParams.isThemeSwitchOn ) )
8890
  return;
8891
  api.section('themes').active( serverControlParams.isThemeSwitchOn );
 
8892
  api.section('themes').active.callbacks = $.Callbacks();
8893
  });
8894
  };
@@ -8907,6 +12633,8 @@ $.extend( CZRSkopeMths, {
8907
  /*****************************************************************************
8908
  * DEFINE SOME USEFUL OBSERVABLE VALUES
8909
  *****************************************************************************/
 
 
8910
  api.czr_activeSectionId = new api.Value('');
8911
  api.czr_activePanelId = new api.Value('');
8912
 
@@ -8914,8 +12642,11 @@ $.extend( CZRSkopeMths, {
8914
  * OBSERVE UBIQUE CONTROL'S SECTIONS EXPANSION
8915
  *****************************************************************************/
8916
  if ( 'function' === typeof api.Section ) {
 
 
8917
  api.control.bind( 'add', function( _ctrl ) {
8918
  if ( _ctrl.params.ubq_section && _ctrl.params.ubq_section.section ) {
 
8919
  _ctrl.params.original_priority = _ctrl.params.priority;
8920
  _ctrl.params.original_section = _ctrl.params.section;
8921
 
@@ -8943,8 +12674,10 @@ $.extend( CZRSkopeMths, {
8943
  * OBSERVE UBIQUE CONTROL'S PANELS EXPANSION
8944
  *****************************************************************************/
8945
  if ( 'function' === typeof api.Panel ) {
 
8946
  api.section.bind( 'add', function( _sec ) {
8947
  if ( _sec.params.ubq_panel && _sec.params.ubq_panel.panel ) {
 
8948
  _sec.params.original_priority = _sec.params.priority;
8949
  _sec.params.original_panel = _sec.params.panel;
8950
 
@@ -8971,6 +12704,7 @@ $.extend( CZRSkopeMths, {
8971
  /*****************************************************************************
8972
  * CLOSE THE MOD OPTION PANEL ( if exists ) ON : section change, panel change, skope switch
8973
  *****************************************************************************/
 
8974
  var _closeModOpt = function() {
8975
  if ( ! _.has( api, 'czr_ModOptVisible') )
8976
  return;
@@ -8991,15 +12725,27 @@ $.extend( CZRSkopeMths, {
8991
  api.czr_activeSectionId( expanded ? section_id : '' );
8992
  };
8993
  api.section.each( function( _sec ) {
 
 
 
 
 
8994
  _sec.expanded.bind( function( expanded ) { _storeCurrentSection( expanded, _sec.id ); } );
8995
  });
8996
  api.section.bind( 'add', function( section_instance ) {
 
 
 
 
 
8997
  api.trigger('czr-paint', { active_panel_id : section_instance.panel() } );
8998
  section_instance.expanded.bind( function( expanded ) { _storeCurrentSection( expanded, section_instance.id ); } );
8999
  });
9000
 
9001
  var _storeCurrentPanel = function( expanded, panel_id ) {
9002
  api.czr_activePanelId( expanded ? panel_id : '' );
 
 
9003
  if ( _.isEmpty( api.czr_activePanelId() ) ) {
9004
  api.czr_activeSectionId( '' );
9005
  }
@@ -9020,16 +12766,22 @@ $.extend( CZRSkopeMths, {
9020
  *****************************************************************************/
9021
  if ( serverControlParams.isPro ) {
9022
  _.each( [
9023
- 'tc_font_customizer_settings',//WFC
9024
-
9025
- 'header_image_sec',//hueman pro
9026
- 'content_blog_sec',//hueman pro
9027
- 'static_front_page',//hueman pro
9028
- 'content_single_sec',//hueman pro
9029
-
9030
- 'tc_fpu',//customizr-pro
9031
- 'nav',//customizr-pro
9032
- 'post_lists_sec'//customizr-pro
 
 
 
 
 
 
9033
 
9034
  ], function( _secId ) {
9035
  _.delay( function() {
@@ -9041,12 +12793,15 @@ $.extend( CZRSkopeMths, {
9041
  }, 1000 );
9042
  });
9043
  _.each( [
9044
- 'hu-header-panel',//hueman pro
9045
- 'hu-content-panel',//hueman pro
9046
-
9047
- 'tc-header-panel',//customizr-pro
9048
- 'tc-content-panel',//customizr-pro
9049
- 'tc-footer-panel'//customizr-pro
 
 
 
9050
  ], function( _secId ) {
9051
  api.panel.when( _secId, function( _sec_ ) {
9052
  if ( 1 >= _sec_.headContainer.length ) {
@@ -9063,7 +12818,9 @@ $.extend( CZRSkopeMths, {
9063
  if ( ! serverControlParams.isPro && _.isFunction( api.Section ) ) {
9064
  proSectionConstructor = api.Section.extend( {
9065
  active : true,
 
9066
  attachEvents: function () {},
 
9067
  isContextuallyActive: function () {
9068
  return this.active();
9069
  },
@@ -9076,12 +12833,16 @@ $.extend( CZRSkopeMths, {
9076
  });
9077
  }
9078
  })( wp.customize , jQuery, _);
 
9079
  var CZRSocialModuleMths = CZRSocialModuleMths || {};
9080
  ( function ( api, $, _ ) {
9081
  $.extend( CZRSocialModuleMths, {
9082
  initialize: function( id, options ) {
9083
  var module = this;
 
9084
  api.CZRDynModule.prototype.initialize.call( module, id, options );
 
 
9085
  $.extend( module, {
9086
  itemPreAddEl : 'czr-module-social-pre-add-view-content',
9087
  itemInputList : 'czr-module-social-item-content',
@@ -9240,13 +13001,19 @@ $.extend( CZRSocialModuleMths, {
9240
  'youtube-play',
9241
  'youtube-square'
9242
  ];
 
9243
  module.inputConstructor = api.CZRInput.extend( module.CZRSocialsInputMths || {} );
 
9244
  module.itemConstructor = api.CZRItem.extend( module.CZRSocialsItem || {} );
 
 
9245
  this.defaultModOptModel = {
9246
  is_mod_opt : true,
9247
  module_id : module.id,
9248
  'social-size' : serverControlParams.social_el_params.defaultSocialSize || 14
9249
  };
 
 
9250
  this.defaultItemModel = {
9251
  id : '',
9252
  title : '' ,
@@ -9255,18 +13022,26 @@ $.extend( CZRSocialModuleMths, {
9255
  'social-color' : serverControlParams.social_el_params.defaultSocialColor,
9256
  'social-target' : 1
9257
  };
 
 
9258
  this.itemAddedMessage = serverControlParams.i18n.socialLinkAdded;
 
 
 
 
9259
  if ( _.has( api, 'czr_activeSectionId' ) && module.control.section() == api.czr_activeSectionId() && 'resolved' != module.isReady.state() ) {
9260
  module.ready();
9261
  }
9262
 
9263
  api.section( module.control.section() ).expanded.bind(function(to) {
 
9264
  if ( 'resolved' != module.isReady.state() ) {
9265
  module.ready();
9266
  }
9267
  });
9268
 
9269
  module.isReady.then( function() {
 
9270
  module.preItem.bind( function( to, from ) {
9271
  if ( ! _.has(to, 'social-icon') )
9272
  return;
@@ -9276,9 +13051,17 @@ $.extend( CZRSocialModuleMths, {
9276
  });
9277
  });
9278
  },//initialize
 
 
 
 
 
 
9279
  updateItemModel : function( item_instance, is_preItem ) {
9280
  var item = item_instance;
9281
  is_preItem = is_preItem || false;
 
 
9282
  if ( ! _.has( item(), 'social-icon') || _.isEmpty( item()['social-icon'] ) )
9283
  return;
9284
 
@@ -9289,6 +13072,8 @@ $.extend( CZRSocialModuleMths, {
9289
  _new_color = serverControlParams.social_el_params.defaultSocialColor;
9290
  if ( ! is_preItem && item.czr_Input.has( 'social-color' ) )
9291
  _new_color = item.czr_Input('social-color')();
 
 
9292
  _new_title = [ serverControlParams.i18n.followUs, _new_title].join(' ');
9293
 
9294
  if ( is_preItem ) {
@@ -9296,6 +13081,7 @@ $.extend( CZRSocialModuleMths, {
9296
  item.set( _new_model );
9297
  } else {
9298
  item.czr_Input('title').set( _new_title );
 
9299
  if ( item.czr_Input('social-color') ) { //optional
9300
  item.czr_Input('social-color').set( _new_color );
9301
  }
@@ -9324,11 +13110,18 @@ $.extend( CZRSocialModuleMths, {
9324
  module = input.module,
9325
  socialList = module.social_icons,
9326
  _model = item(),
 
9327
  is_preItem = _.isEmpty( _model.id );
 
 
9328
  if ( is_preItem ) {
9329
  socialList = _.union( [ serverControlParams.i18n.selectSocialIcon ], socialList );
9330
  }
 
 
9331
  _.each( socialList , function( icon_name, k ) {
 
 
9332
  var _value = ( is_preItem && 0 === k ) ? '' : 'fa-' + icon_name.toLowerCase(),
9333
  _attributes = {
9334
  value : _value,
@@ -9347,6 +13140,8 @@ $.extend( CZRSocialModuleMths, {
9347
  );
9348
  return $state;
9349
  }
 
 
9350
  $( 'select[data-type="social-icon"]', input.container ).select2( {
9351
  templateResult: addIcon,
9352
  templateSelection: addIcon
@@ -9364,6 +13159,10 @@ $.extend( CZRSocialModuleMths, {
9364
  hide:false,
9365
  defaultColor : serverControlParams.social_el_params.defaultSocialColor || 'rgba(255,255,255,0.7)',
9366
  change : function( e, o ) {
 
 
 
 
9367
  if ( _.has( o, 'color') && 16777215 == o.color._color )
9368
  $(this).val( serverControlParams.social_el_params.defaultSocialColor || 'rgba(255,255,255,0.7)' );
9369
  else
@@ -9372,6 +13171,9 @@ $.extend( CZRSocialModuleMths, {
9372
  $(this).trigger('colorpickerchange').trigger('change');
9373
  }
9374
  });
 
 
 
9375
  $el.closest('div').on('click keydown', function() {
9376
  module._adjustScrollExpandedBlock( input.container );
9377
  });
@@ -9388,9 +13190,13 @@ $.extend( CZRSocialModuleMths, {
9388
 
9389
 
9390
  CZRSocialsItem : {
 
 
9391
  ready : function() {
9392
  var item = this;
9393
  api.CZRItem.prototype.ready.call( item );
 
 
9394
  item.bind('social-icon:changed', function(){
9395
  item.module.updateItemModel( item );
9396
  });
@@ -9408,6 +13214,9 @@ $.extend( CZRSocialModuleMths, {
9408
 
9409
  return '<div><span class="fa ' + icon + '" style="color:' + color + '"></span> ' + title + '</div>';
9410
  },
 
 
 
9411
  writeItemViewTitle : function( model ) {
9412
  var item = this,
9413
  module = item.module,
@@ -9429,17 +13238,26 @@ $.extend( CZRWidgetAreaModuleMths, {
9429
  var module = this;
9430
 
9431
  api.CZRDynModule.prototype.initialize.call( this, id, constructorOptions );
 
 
9432
  $.extend( module, {
9433
  itemPreAddEl : 'czr-module-widgets-pre-add-view-content',
9434
  itemInputList : 'czr-module-widgets-item-input-list',
9435
  itemInputListReduced : 'czr-module-widgets-item-input-list-reduced',
9436
  ruItemPart : 'czr-module-widgets-ru-item-part'
9437
  } );
 
 
9438
  module.inputConstructor = api.CZRInput.extend( module.CZRWZonesInputMths || {} );
 
9439
  module.itemConstructor = api.CZRItem.extend( module.CZRWZonesItem || {} );
9440
 
9441
  module.serverParams = serverControlParams.widget_area_el_params || {};
 
 
9442
  module.contexts = _.has( module.serverParams , 'sidebar_contexts') ? module.serverParams.sidebar_contexts : {};
 
 
9443
  module.context_match_map = {
9444
  is_404 : '404',
9445
  is_category : 'archive-category',
@@ -9451,6 +13269,8 @@ $.extend( CZRWidgetAreaModuleMths, {
9451
 
9452
 
9453
  module.locations = _.has( module.serverParams , 'sidebar_locations') ? module.serverParams.sidebar_locations : {};
 
 
9454
  module.defaultItemModel = {
9455
  id : '',
9456
  title : serverControlParams.i18n.widgetZone,
@@ -9458,7 +13278,12 @@ $.extend( CZRWidgetAreaModuleMths, {
9458
  locations : [ module.serverParams.defaultWidgetLocation ],
9459
  description : ''
9460
  };
 
 
9461
  this.itemAddedMessage = serverControlParams.i18n.widgetZoneAdded;
 
 
 
9462
  if ( ! _.has( api, 'sidebar_insights' ) ) {
9463
  api.sidebar_insights = new api.Values();
9464
  api.sidebar_insights.create('candidates');//will store the sidebar candidates on preview refresh
@@ -9470,6 +13295,13 @@ $.extend( CZRWidgetAreaModuleMths, {
9470
 
9471
 
9472
  this.listenToSidebarInsights();
 
 
 
 
 
 
 
9473
  api.czr_widgetZoneSettings = api.czr_widgetZoneSettings || new api.Value();
9474
  api.czr_widgetZoneSettings.bind( function( updated_data_sent_from_preview , from ) {
9475
  module.isReady.then( function() {
@@ -9478,10 +13310,20 @@ $.extend( CZRWidgetAreaModuleMths, {
9478
  });
9479
  });
9480
  });
 
 
 
 
 
 
9481
  module.preItem_location_alert_view_state = new api.Value( 'closed');
 
9482
  module.preItem_location_alert_view_state.callbacks.add( function( to, from ) {
9483
  module._toggleLocationAlertExpansion( module.container, to );
9484
  });
 
 
 
9485
  module.bind( 'item-added', function( model ) {
9486
  module.addWidgetSidebar( model );
9487
  });
@@ -9489,29 +13331,57 @@ $.extend( CZRWidgetAreaModuleMths, {
9489
  module.bind( 'pre_item_api_remove' , function(model) {
9490
  module.removeWidgetSidebar( model );
9491
  });
 
 
 
9492
  var fixTopMargin = new api.Values();
9493
  fixTopMargin.create('fixed_for_current_session');
9494
  fixTopMargin.create('value');
9495
 
9496
  api.section(module.serverParams.dynWidgetSection).fixTopMargin = fixTopMargin;
9497
  api.section(module.serverParams.dynWidgetSection).fixTopMargin('fixed_for_current_session').set(false);
 
 
 
 
 
 
 
 
9498
  api.panel('widgets').expanded.callbacks.add( function(to, from) {
9499
  module.widgetPanelReact();//setup some visual adjustments, must be ran each time panel is closed or expanded
 
 
9500
  if ( 'resolved' == module.isReady.state() )
9501
  return;
9502
  module.ready();
9503
  });
9504
  },//initialize
 
 
 
 
 
 
9505
  ready : function() {
9506
  var module = this;
9507
  api.CZRDynModule.prototype.ready.call( module );
 
 
9508
  module.preItemExpanded.callbacks.add( function( to, from ) {
9509
  if ( ! to )
9510
  return;
 
9511
  module.preItem.czr_Input('locations')._setupLocationSelect( true );//true for refresh
 
9512
  module.preItem.czr_Input('locations').mayBeDisplayModelAlert();
9513
  });
9514
  },
 
 
 
 
 
9515
  initializeModuleModel : function( constructorOptions ) {
9516
  var module = this, dfd = $.Deferred();
9517
  constructorOptions.items = _.union( _.has( module.serverParams, 'default_zones' ) ? module.serverParams.default_zones : [], constructorOptions.items );
@@ -9543,6 +13413,13 @@ $.extend( CZRWidgetAreaModuleMths, {
9543
 
9544
  api.CZRInput.prototype.ready.call( input);
9545
  },
 
 
 
 
 
 
 
9546
  setupSelect : function() {
9547
  var input = this;
9548
  if ( 'locations' == this.id )
@@ -9551,11 +13428,15 @@ $.extend( CZRWidgetAreaModuleMths, {
9551
  this._setupContextSelect();
9552
 
9553
  },
 
 
9554
  _setupContextSelect : function() {
9555
  var input = this,
9556
  input_contexts = input(),
9557
  item = input.input_parent,
9558
  module = input.module;
 
 
9559
  _.each( module.contexts, function( title, key ) {
9560
  var _attributes = {
9561
  value : key,
@@ -9566,14 +13447,22 @@ $.extend( CZRWidgetAreaModuleMths, {
9566
 
9567
  $( 'select[data-type="contexts"]', input.container ).append( $('<option>', _attributes) );
9568
  });
 
9569
  $( 'select[data-type="contexts"]', input.container ).select2();
9570
  },
 
 
 
 
9571
  _setupLocationSelect : function(refresh ) {
9572
  var input = this,
9573
  input_locations = input(),
9574
  item = input.input_parent,
9575
  module = input.module,
9576
  available_locs = api.sidebar_insights('available_locations')();
 
 
 
9577
  if ( ! $( 'select[data-type="locations"]', input.container ).children().length ) {
9578
  _.each( module.locations, function( title, key ) {
9579
  var _attributes = {
@@ -9600,15 +13489,22 @@ $.extend( CZRWidgetAreaModuleMths, {
9600
  if ( refresh ) {
9601
  $( 'select[data-type="locations"]', input.container ).select2( 'destroy' );
9602
  }
 
 
9603
  $( 'select[data-type="locations"]', input.container ).select2( {
9604
  templateResult: setAvailability,
9605
  templateSelection: setAvailability
9606
  });
9607
  },
 
 
 
9608
  mayBeDisplayModelAlert : function() {
9609
  var input = this,
9610
  item = input.input_parent,
9611
  module = input.module;
 
 
9612
  if ( ! _.has( item(), 'locations') || _.isEmpty( item().locations ) )
9613
  return;
9614
 
@@ -9617,6 +13513,8 @@ $.extend( CZRWidgetAreaModuleMths, {
9617
  _unavailable = _.filter( _selected_locations, function( loc ) {
9618
  return ! _.contains(available_locs, loc);
9619
  });
 
 
9620
  if ( ! _.has( item(), 'id' ) || _.isEmpty( item().id ) ) {
9621
  module.preItem_location_alert_view_state.set( ! _.isEmpty( _unavailable ) ? 'expanded' : 'closed' );
9622
  } else {
@@ -9643,30 +13541,53 @@ $.extend( CZRWidgetAreaModuleMths, {
9643
  initialize : function( id, options ) {
9644
  var item = this,
9645
  module = item.module;
 
 
9646
  item.czr_itemLocationAlert = new api.Value();
9647
 
9648
  api.CZRItem.prototype.initialize.call( item, null, options );
9649
  },
 
 
 
 
9650
  itemWrapperViewSetup : function() {
9651
  var item = this,
9652
  module = item.module;
9653
 
9654
  api.CZRItem.prototype.itemWrapperViewSetup.call(item);
 
 
9655
  item.czr_itemLocationAlert.set('closed');
 
 
9656
  item.czr_itemLocationAlert.callbacks.add( function( to, from ) {
9657
  module._toggleLocationAlertExpansion( item.container , to );
9658
  });
 
 
9659
  item.writeSubtitleInfos(item());
 
 
 
 
9660
  item.viewState.callbacks.add( function( to, from ) {
9661
  if ( -1 == to.indexOf('expanded') )//can take the expanded_noscroll value !
9662
  return;
 
 
9663
  item.bind('contentRendered', function() {
 
9664
  item.czr_Input('locations')._setupLocationSelect( true );//true for refresh
 
9665
  item.czr_Input('locations').mayBeDisplayModelAlert();
9666
  });
9667
 
9668
  });
9669
  },
 
 
 
9670
  itemReact : function(to, from) {
9671
  var item = this;
9672
  api.CZRItem.prototype.itemReact.call(item, to, from);
@@ -9674,6 +13595,11 @@ $.extend( CZRWidgetAreaModuleMths, {
9674
  item.writeSubtitleInfos(to);
9675
  item.updateSectionTitle(to).setModelUpdateTimer();
9676
  },
 
 
 
 
 
9677
  writeSubtitleInfos : function(model) {
9678
  var item = this,
9679
  module = item.module,
@@ -9684,6 +13610,8 @@ $.extend( CZRWidgetAreaModuleMths, {
9684
 
9685
  if ( ! item.container.length )
9686
  return this;
 
 
9687
  _model.locations =_.isString(_model.locations) ? [_model.locations] : _model.locations;
9688
  _.each( _model.locations, function( loc ) {
9689
  if ( _.has( module.locations , loc ) )
@@ -9692,7 +13620,11 @@ $.extend( CZRWidgetAreaModuleMths, {
9692
  _locations.push(loc);
9693
  }
9694
  );
 
 
9695
  _model.contexts =_.isString(_model.contexts) ? [_model.contexts] : _model.contexts;
 
 
9696
  if ( item._hasModelAllContexts( model ) ) {
9697
  _contexts.push(module.contexts._all_);
9698
  } else {
@@ -9704,6 +13636,8 @@ $.extend( CZRWidgetAreaModuleMths, {
9704
  }
9705
  );
9706
  }
 
 
9707
  var _locationText = serverControlParams.i18n.locations,
9708
  _contextText = serverControlParams.i18n.contexts,
9709
  _notsetText = serverControlParams.i18n.notset;
@@ -9711,6 +13645,12 @@ $.extend( CZRWidgetAreaModuleMths, {
9711
  _locations = _.isEmpty( _locations ) ? '<span style="font-weight: bold;">' + _notsetText + '</span>' : _locations.join(', ');
9712
  _contexts = _.isEmpty( _contexts ) ? '<span style="font-weight: bold;">' + _notsetText + '</span>' : _contexts.join(', ');
9713
 
 
 
 
 
 
 
9714
  _html = '<u>' + _locationText + '</u> : ' + _locations + ' <strong>|</strong> <u>' + _contextText + '</u> : ' + _contexts;
9715
 
9716
  if ( ! $('.czr-zone-infos', item.container ).length ) {
@@ -9725,17 +13665,46 @@ $.extend( CZRWidgetAreaModuleMths, {
9725
 
9726
  return this;
9727
  },//writeSubtitleInfos
 
 
 
 
9728
  updateSectionTitle : function(model) {
9729
  var _sidebar_id = 'sidebar-widgets-' + model.id,
9730
  _new_title = model.title;
 
9731
  if ( ! api.section.has(_sidebar_id) )
9732
  return this;
 
 
9733
  $('.accordion-section-title', api.section(_sidebar_id).container ).text(_new_title);
 
 
9734
  $('.customize-section-title h3', api.section(_sidebar_id).container ).html(
9735
  '<span class="customize-action">' + api.section(_sidebar_id).params.customizeAction + '</span>' + _new_title
9736
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9737
  return this;
9738
  },
 
 
 
 
 
9739
  setModelUpdateTimer : function() {
9740
  var item = this,
9741
  module = item.module;
@@ -9745,10 +13714,15 @@ $.extend( CZRWidgetAreaModuleMths, {
9745
  this,
9746
  'modelUpdateTimer',
9747
  setTimeout( function() {
 
9748
  module.control.refreshPreview();
9749
  } , 1000)
9750
  );//$.data
9751
  },
 
 
 
 
9752
  _hasModelAllContexts : function( model ) {
9753
  var item = this,
9754
  module = item.module,
@@ -9761,8 +13735,13 @@ $.extend( CZRWidgetAreaModuleMths, {
9761
 
9762
  if ( _.contains( model.contexts, '_all_') )
9763
  return true;
 
 
9764
  return _.isEmpty( _.difference( _.without(moduleContexts, '_all_') , model.contexts ) );
9765
  },
 
 
 
9766
  _getMatchingContexts : function( defaults ) {
9767
  var module = this,
9768
  _current = api.czr_wpQueryInfos().conditional_tags || {},
@@ -9771,10 +13750,83 @@ $.extend( CZRWidgetAreaModuleMths, {
9771
  return _.isEmpty( _matched ) ? defaults : _matched;
9772
  }
9773
  },//CZRWZonesItem
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9774
  addWidgetSidebar : function( model, sidebar_data ) {
9775
  if ( ! _.isObject(model) && _.isEmpty(sidebar_data) ) {
9776
  throw new Error('No valid input were provided to add a new Widget Zone.');
9777
  }
 
 
 
 
9778
  var module = this,
9779
  _model = ! _.isEmpty(model) ? _.clone(model) : sidebar_data,
9780
  _new_sidebar = _.isEmpty(model) ? sidebar_data : $.extend(
@@ -9784,7 +13836,15 @@ $.extend( CZRWidgetAreaModuleMths, {
9784
  id : _model.id
9785
  }
9786
  );
 
 
9787
  api.Widgets.registeredSidebars.add( _new_sidebar );
 
 
 
 
 
 
9788
  var _params = $.extend(
9789
  _.clone( api.section( "sidebar-widgets-" + module.serverParams.defaultWidgetSidebar ).params ),
9790
  {
@@ -9793,12 +13853,18 @@ $.extend( CZRWidgetAreaModuleMths, {
9793
  sidebarId: _new_sidebar.id,
9794
  title: _new_sidebar.name,
9795
  description : 'undefined' != typeof(sidebar_data) ? sidebar_data.description : api.section( "sidebar-widgets-" + module.serverParams.defaultWidgetSidebar ).params.description,
 
9796
  priority: _.max( _.omit( api.settings.sections, module.serverParams.dynWidgetSection), function(sec){ return sec.instanceNumber; }).priority + 1,
9797
  }
9798
  );
9799
 
9800
  api.section.add( _params.id, new api.sectionConstructor[ _params.type ]( _params.id ,{ params : _params } ) );
 
 
9801
  api.settings.sections[ _params.id ] = _params.id;
 
 
 
9802
  var _new_set_id = 'sidebars_widgets['+_model.id+']',
9803
  _new_set = $.extend(
9804
  _.clone( api.settings.settings['sidebars_widgets[' + module.serverParams.defaultWidgetSidebar + ']'] ),
@@ -9806,58 +13872,101 @@ $.extend( CZRWidgetAreaModuleMths, {
9806
  value:[]
9807
  }
9808
  );
 
 
9809
  api.settings.settings[ _new_set_id ] = _new_set;
 
 
9810
  api.create( _new_set_id, _new_set_id, _new_set.value, {
9811
  transport: _new_set.transport,
9812
  previewer: api.previewer,
9813
  dirty: false
9814
  } );
 
 
 
 
9815
  var _cloned_control = $.extend(
9816
  _.clone( api.settings.controls['sidebars_widgets[' + module.serverParams.defaultWidgetSidebar + ']'] ),
9817
  {
9818
  settings : { default : _new_set_id }
9819
  }),
9820
  _new_control = {};
 
 
 
9821
  _.each( _cloned_control, function( param, key ) {
9822
  if ( 'string' == typeof(param) ) {
9823
  param = param.replace( module.serverParams.defaultWidgetSidebar , _model.id );
9824
  }
9825
  _new_control[key] = param;
9826
  });
 
 
9827
  _new_control.instanceNumber = _.max(api.settings.controls, function(con){ return con.instanceNumber; }).instanceNumber + 1;
 
 
9828
  api.settings.controls[_new_set_id] = _new_control;
 
 
9829
  api.control.add( _new_set_id, new api.controlConstructor[ _new_control.type ]( _new_set_id, {
9830
  params: _new_control,
9831
  previewer: api.previewer
9832
  } ) );
 
 
 
 
9833
  if ( _.has(this, 'container') )
9834
  this.container.trigger( 'widget_zone_created', { model : _model, section_id : "sidebar-widgets-" + _model.id , setting_id : _new_set_id });
9835
  },//addWidgetSidebar
 
 
 
9836
  removeWidgetSidebar : function( model ) {
9837
  var module = this;
9838
  if ( ! _.isObject(model) || _.isEmpty(model) ) {
9839
  throw new Error('No valid data were provided to remove a Widget Zone.');
9840
  }
 
 
9841
  api.Widgets.registeredSidebars.remove( model.id );
 
 
9842
  if ( api.section.has("sidebar-widgets-" + model.id) ) {
 
9843
  api.section("sidebar-widgets-" + model.id).container.remove();
 
9844
  api.section.remove( "sidebar-widgets-" + model.id );
 
9845
  delete api.settings.sections[ "sidebar-widgets-" + model.id ];
9846
  }
 
 
9847
  if ( api.has('sidebars_widgets['+model.id+']') ) {
 
9848
  api.remove( 'sidebars_widgets['+model.id+']' );
 
9849
  delete api.settings.settings['sidebars_widgets['+model.id+']'];
9850
  }
 
 
9851
  if ( api.control.has('sidebars_widgets['+model.id+']') ) {
 
9852
  api.control( 'sidebars_widgets['+model.id+']' ).container.remove();
 
9853
  api.control.remove( 'sidebars_widgets['+model.id+']' );
 
9854
  delete api.settings.controls['sidebars_widgets['+model.id+']'];
9855
  }
 
 
9856
  var _refresh = function() {
9857
  api.previewer.refresh();
9858
  };
9859
  _refresh = _.debounce( _refresh, 500 );
9860
  $.when( _refresh() ).done( function() {
 
9861
  module.trigger( 'widget_zone_removed',
9862
  {
9863
  model : model,
@@ -9867,8 +13976,24 @@ $.extend( CZRWidgetAreaModuleMths, {
9867
  );
9868
  });
9869
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9870
  widgetPanelReact : function() {
9871
  var module = this;
 
9872
  var _top_margin = api.panel('widgets').container.find( '.control-panel-content' ).css('margin-top');
9873
 
9874
  api.section(module.serverParams.dynWidgetSection).fixTopMargin('value').set( _top_margin );
@@ -9879,13 +14004,21 @@ $.extend( CZRWidgetAreaModuleMths, {
9879
  _section_content.css( 'margin-top', '' );
9880
  _panel_content.css('margin-top', api.section(module.serverParams.dynWidgetSection).fixTopMargin('value')() );
9881
  };
 
 
9882
  api.bind( 'pane-contents-reflowed', _.debounce( function() {
9883
  _set_margins();
9884
  }, 150 ) );
 
 
9885
  module.closeAllItems().closeRemoveDialogs();
 
9886
  if ( _.has( module, 'preItemExpanded' ) )
9887
  module.preItemExpanded.set(false);
9888
  },//widgetPanelReact()
 
 
 
9889
  widgetSectionReact : function( to, from ) {
9890
  var module = this,
9891
  section = api.section(module.serverParams.dynWidgetSection),
@@ -9900,6 +14033,7 @@ $.extend( CZRWidgetAreaModuleMths, {
9900
  if ( to ) {
9901
  overlay.removeClass( 'section-open' );
9902
  content.css( 'height', 'auto' );
 
9903
  sectionTitle.attr( 'tabindex', '0' );
9904
  content.css( 'margin-top', '' );
9905
  container.scrollTop( 0 );
@@ -9909,8 +14043,21 @@ $.extend( CZRWidgetAreaModuleMths, {
9909
 
9910
  content.slideToggle();
9911
  },
 
 
 
 
 
 
 
 
 
 
 
9912
  listenToSidebarInsights : function() {
9913
  var module = this;
 
 
9914
  api.sidebar_insights('registered').callbacks.add( function( _registered_zones ) {
9915
  var _current_collection = _.clone( module.itemCollection() );
9916
  _.each( _current_collection, function( _model ) {
@@ -9920,6 +14067,8 @@ $.extend( CZRWidgetAreaModuleMths, {
9920
  module.getViewEl(_model.id).css('display' , _.contains( _registered_zones, _model.id ) ? 'block' : 'none' );
9921
  });
9922
  });
 
 
9923
  api.sidebar_insights('inactives').callbacks.add( function( _inactives_zones ) {
9924
  var _current_collection = _.clone( module.itemCollection() );
9925
  _.each( _current_collection, function( _model ) {
@@ -9941,20 +14090,41 @@ $.extend( CZRWidgetAreaModuleMths, {
9941
  }
9942
  });
9943
  });
 
 
 
9944
  api.sidebar_insights('candidates').callbacks.add( function(_candidates) {
9945
  if ( ! _.isArray(_candidates) )
9946
  return;
9947
  _.each( _candidates, function( _sidebar ) {
9948
  if ( ! _.isObject(_sidebar) )
9949
  return;
 
 
9950
  if ( api.section.has("sidebar-widgets-" +_sidebar.id ) )
9951
  return;
 
 
9952
  module.addWidgetSidebar( {}, _sidebar );
 
9953
  if ( _.has( api.sidebar_insights('actives')(), _sidebar.id ) && api.section.has("sidebar-widgets-" +_sidebar.id ) )
9954
  api.section( "sidebar-widgets-" +_sidebar.id ).activate();
9955
  });
9956
  });
9957
  },//listenToSidebarInsights()
 
 
 
 
 
 
 
 
 
 
 
 
 
9958
  _adjustScrollExpandedBlock : function( $_block_el, adjust ) {
9959
  if ( ! $_block_el.length )
9960
  return;
@@ -9971,6 +14141,11 @@ $.extend( CZRWidgetAreaModuleMths, {
9971
  }
9972
  }, 50);
9973
  },
 
 
 
 
 
9974
  getDefaultItemModel : function( id ) {
9975
  var module = this,
9976
  _current_collection = module.itemCollection(),
@@ -9978,10 +14153,25 @@ $.extend( CZRWidgetAreaModuleMths, {
9978
  _default_contexts = _default.contexts;
9979
  return $.extend( _default, {
9980
  title : 'Widget Zone ' + ( _.size(_current_collection)*1 + 1 )
 
9981
  });
9982
  },
 
 
 
 
 
 
 
 
 
 
 
 
9983
  getTemplateEl : function( type, item_model ) {
9984
  var module = this, _el;
 
 
9985
  if ( 'rudItemPart' == type ) {
9986
  type = ( _.has(item_model, 'is_builtin') && item_model.is_builtin ) ? 'ruItemPart' : type;
9987
  } else if ( 'itemInputList' == type ) {
@@ -10031,17 +14221,26 @@ $.extend( CZRWidgetAreaModuleMths, {
10031
  }
10032
  });//$.extend()
10033
  })( wp.customize , jQuery, _ );
 
10034
  var CZRBodyBgModuleMths = CZRBodyBgModuleMths || {};
10035
  ( function ( api, $, _ ) {
10036
  $.extend( CZRBodyBgModuleMths, {
10037
  initialize: function( id, options ) {
10038
  var module = this;
 
10039
  api.CZRModule.prototype.initialize.call( module, id, options );
 
 
10040
  $.extend( module, {
10041
  itemInputList : 'czr-module-bodybg-item-content'
10042
  } );
 
 
10043
  module.inputConstructor = api.CZRInput.extend( module.CZRBodyBgInputMths || {} );
 
10044
  module.itemConstructor = api.CZRItem.extend( module.CZBodyBgItemMths || {} );
 
 
10045
  module.defaultItemModel = {
10046
  'background-color' : '#eaeaea',
10047
  'background-image' : '',
@@ -10051,6 +14250,9 @@ $.extend( CZRBodyBgModuleMths, {
10051
  'background-size' : 'cover'
10052
  };
10053
  api.consoleLog('New module instantiated : ', module.id );
 
 
 
10054
  if ( _.has( api, 'czr_activeSectionId' ) && module.control.section() == api.czr_activeSectionId() && 'resolved' != module.isReady.state() ) {
10055
  module.ready();
10056
  }
@@ -10064,6 +14266,10 @@ $.extend( CZRBodyBgModuleMths, {
10064
 
10065
 
10066
  CZRBodyBgInputMths : {
 
 
 
 
10067
  setupSelect : function() {
10068
  var input = this,
10069
  _id_param_map = {
@@ -10084,6 +14290,7 @@ $.extend( CZRBodyBgModuleMths, {
10084
  options = serverParams[ _id_param_map[input.id] ];
10085
  if ( _.isEmpty(options) )
10086
  return;
 
10087
  _.each( options, function( title, key ) {
10088
  var _attributes = {
10089
  value : key,
@@ -10094,12 +14301,15 @@ $.extend( CZRBodyBgModuleMths, {
10094
 
10095
  $( 'select[data-type]', input.container ).append( $('<option>', _attributes) );
10096
  });
 
10097
  $( 'select[data-type]', input.container ).select2();
10098
  }
10099
  },
10100
 
10101
 
10102
  CZBodyBgItemMths : {
 
 
10103
  ready : function() {
10104
  var item = this;
10105
  api.CZRItem.prototype.ready.call( item );
@@ -10114,6 +14324,7 @@ $.extend( CZRBodyBgModuleMths, {
10114
  });
10115
  };
10116
  set_visibilities( input_instance() );
 
10117
  item.bind('background-image:changed', function(){
10118
  set_visibilities( item.czr_Input('background-image')() );
10119
  });
@@ -10127,6 +14338,14 @@ $.extend( CZRBodyBgModuleMths, {
10127
  });//$.extend
10128
  })( wp.customize , jQuery, _ );
10129
  (function ( api, $, _ ) {
 
 
 
 
 
 
 
 
10130
  api.czrModuleMap = api.czrModuleMap || {};
10131
  $.extend( api.czrModuleMap, {
10132
  czr_widget_areas_module : {
@@ -10149,6 +14368,7 @@ $.extend( CZRBodyBgModuleMths, {
10149
  }
10150
  });
10151
  })( wp.customize, jQuery, _ );
 
10152
  var CZRMultiplePickerMths = CZRMultiplePickerMths || {};
10153
  /* Multiple Picker */
10154
  /**
@@ -10169,8 +14389,11 @@ $.extend( CZRMultiplePickerMths , {
10169
  });
10170
 
10171
  function czrEscapeMarkup(obj) {
 
10172
  return obj.text.replace(/\u2013|\u2014/g, "");
10173
  }
 
 
10174
  _select.on('change', function(e){
10175
  if ( 0 === $(this).find("option:selected").length )
10176
  control.setting.set([]);
@@ -10178,10 +14401,12 @@ $.extend( CZRMultiplePickerMths , {
10178
  }
10179
  });//$.extend
10180
  })( wp.customize , jQuery, _ );
 
10181
  var CZRCroppedImageMths = CZRCroppedImageMths || {};
10182
 
10183
  (function (api, $, _) {
10184
  /* IMAGE UPLOADER CONTROL IN THE CUSTOMIZER */
 
10185
  if ( 'function' != typeof wp.media.controller.Cropper || 'function' != typeof api.CroppedImageControl )
10186
  return;
10187
 
@@ -10272,6 +14497,7 @@ var CZRCroppedImageMths = CZRCroppedImageMths || {};
10272
  onSelect: function() {
10273
  var attachment = this.frame.state().get( 'selection' ).first().toJSON();
10274
  if ( ! ( attachment.mime && attachment.mime.indexOf("image") > -1 ) ){
 
10275
  this.frame.trigger( 'content:error' );
10276
  return;
10277
  }
@@ -10285,6 +14511,8 @@ var CZRCroppedImageMths = CZRCroppedImageMths || {};
10285
  },
10286
  });//extend
10287
  })( wp.customize, jQuery, _);
 
 
10288
  var CZRUploadMths = CZRUploadMths || {};
10289
  ( function ( api, $, _ ) {
10290
  /**
@@ -10303,6 +14531,7 @@ $.extend( CZRUploadMths, {
10303
  this.uploader = $.extend({
10304
  container: this.container,
10305
  browser: this.container.find('.czr-upload'),
 
10306
  success: this.success,
10307
  plupload: {},
10308
  params: {}
@@ -10345,6 +14574,7 @@ $.extend( CZRUploadMths, {
10345
  }
10346
  });//extend
10347
  })( wp.customize , jQuery, _ );
 
10348
  var CZRLayoutSelectMths = CZRLayoutSelectMths || {};
10349
  ( function ( api, $, _ ) {
10350
  $.extend( CZRLayoutSelectMths , {
@@ -10369,6 +14599,11 @@ $.extend( CZRLayoutSelectMths , {
10369
  );
10370
  return $state;
10371
  }
 
 
 
 
 
10372
  $_select.select2( {
10373
  templateResult: addImg,
10374
  templateSelection: addImg,
@@ -10378,6 +14613,10 @@ $.extend( CZRLayoutSelectMths , {
10378
  });//$.extend
10379
  })( wp.customize , jQuery, _ );
10380
  ( function ( api, $, _ ) {
 
 
 
 
10381
 
10382
  api.CZRUploadControl = api.Control.extend( CZRUploadMths );
10383
  api.CZRLayoutControl = api.Control.extend( CZRLayoutSelectMths );
@@ -10386,8 +14625,11 @@ $.extend( CZRLayoutSelectMths , {
10386
 
10387
  $.extend( api.controlConstructor, {
10388
  czr_upload : api.CZRUploadControl,
 
 
10389
  czr_multiple_picker : api.CZRMultiplePickerControl,
10390
  czr_layouts : api.CZRLayoutControl
 
10391
  });
10392
 
10393
  if ( 'function' == typeof api.CroppedImageControl ) {
@@ -10398,6 +14640,12 @@ $.extend( CZRLayoutSelectMths , {
10398
  });
10399
  }
10400
 
 
 
 
 
 
 
10401
  })( wp.customize, jQuery, _ );
10402
  ( function (api, $, _) {
10403
  var $_nav_section_container,
@@ -10409,6 +14657,11 @@ $.extend( CZRLayoutSelectMths , {
10409
  if ( _.has( api, 'czr_ctrlDependencies') )
10410
  return;
10411
  if ( serverControlParams.isSkopOn ) {
 
 
 
 
 
10412
  if ( 'resolved' != api.czr_skopeReady.state() ) {
10413
  api.czr_skopeReady.done( function() {
10414
  api.czr_ctrlDependencies = new api.CZR_ctrlDependencies();
@@ -10435,6 +14688,8 @@ $.extend( CZRLayoutSelectMths , {
10435
  actions : null,
10436
  onSectionExpand : true
10437
  };
 
 
10438
  this.dominiDeps = _.extend( this.dominiDeps, this._getControlDeps() );
10439
  if ( ! _.isArray( self.dominiDeps ) ) {
10440
  throw new Error('Visibilities : the dominos dependency array is not an array.');
@@ -10448,7 +14703,15 @@ $.extend( CZRLayoutSelectMths , {
10448
  }
10449
  }
10450
  });
 
 
 
 
 
 
 
10451
  api.bind( 'awaken-section', function( target_source ) {
 
10452
  if ( serverControlParams.isSkopOn && _.has( api ,'czr_skopeBase' ) ) {
10453
  api.czr_skopeBase.processSilentUpdates( {
10454
  candidates : {},
@@ -10469,8 +14732,17 @@ $.extend( CZRLayoutSelectMths , {
10469
  }
10470
  }
10471
  });
 
 
 
 
10472
  this._handleFaviconNote();
10473
  },
 
 
 
 
 
10474
  setServiDependencies : function( targetSectionId, sourceSectionId, refresh ) {
10475
  var self = this, params, dfd = $.Deferred();
10476
 
@@ -10479,9 +14751,16 @@ $.extend( CZRLayoutSelectMths , {
10479
  if ( _.isUndefined( targetSectionId ) || ! api.section.has( targetSectionId ) ) {
10480
  throw new Error( 'Control Dependencies : the targetSectionId is missing or not registered : ' + targetSectionId );
10481
  }
 
 
10482
  api.section( targetSectionId ).czr_ctrlDependenciesReady = api.section( targetSectionId ).czr_ctrlDependenciesReady || $.Deferred();
 
 
10483
  if ( ! refresh && 'resolved' == api.section( targetSectionId ).czr_ctrlDependenciesReady.state() )
10484
  return dfd.resolve().promise();
 
 
 
10485
  _.each( self.dominiDeps , function( params ) {
10486
  if ( ! _.has( params, 'dominus' ) || ! _.isString( params.dominus ) || _.isEmpty( params.dominus ) ) {
10487
  throw new Error( 'Control Dependencies : a dominus control id must be a not empty string.');
@@ -10493,6 +14772,8 @@ $.extend( CZRLayoutSelectMths , {
10493
 
10494
  if ( api.control( wpDominusId ).section() != targetSectionId )
10495
  return;
 
 
10496
  params = self._prepareDominusParams( params );
10497
  if ( _.isEmpty(params) )
10498
  return;
@@ -10506,6 +14787,10 @@ $.extend( CZRLayoutSelectMths , {
10506
  dfd.resolve();
10507
  });
10508
  });
 
 
 
 
10509
  var _secCtrls = api.CZR_Helpers.getSectionControlIds( targetSectionId ),
10510
  _getServusDomini = function( shortServudId ) {
10511
  var _dominiIds = [];
@@ -10516,6 +14801,7 @@ $.extend( CZRLayoutSelectMths , {
10516
  }
10517
 
10518
  if ( _.contains( params.servi , shortServudId ) && ! _.contains( _dominiIds , params.dominus ) ) {
 
10519
  params = self._prepareDominusParams( params );
10520
  if ( _.isEmpty(params) )
10521
  return;
@@ -10526,29 +14812,50 @@ $.extend( CZRLayoutSelectMths , {
10526
  return ! _.isArray( _dominiIds ) ? [] : _dominiIds;
10527
  },
10528
  _servusDominiIds = [];
 
 
10529
  _.each( _secCtrls, function( servusCandidateId ) {
10530
  if ( _.isEmpty( _getServusDomini( servusCandidateId ) ) )
10531
  return;
10532
 
10533
  _servusDominiIds = _.union( _servusDominiIds, _getServusDomini( servusCandidateId ) );
10534
  });
 
 
10535
  _.each( _servusDominiIds, function( shortDominusId ){
10536
 
10537
  var wpDominusId = api.CZR_Helpers.build_setId( shortDominusId );
 
10538
  if ( api.control( wpDominusId ).section() == targetSectionId )
10539
  return;
 
10540
  if ( sourceSectionId == api.control( wpDominusId ).section() )
10541
  return;
 
 
 
10542
  api.trigger( 'awaken-section', {
10543
  target : api.control( wpDominusId ).section(),
10544
  source : targetSectionId
10545
  } );
10546
  } );
 
 
10547
  dfd.always( function() {
10548
  api.section( targetSectionId ).czr_ctrlDependenciesReady.resolve();
10549
  });
10550
  return dfd.promise();
10551
  },
 
 
 
 
 
 
 
 
 
 
10552
  _deferCallbackForControl : function( wpCrtlId, callback, args ) {
10553
  var dfd = $.Deferred();
10554
  if ( _.isEmpty(wpCrtlId) || ! _.isString(wpCrtlId) ) {
@@ -10596,10 +14903,15 @@ $.extend( CZRLayoutSelectMths , {
10596
  dominusSetInst = api( wpDominusId ),
10597
  dfd = $.Deferred(),
10598
  hasProcessed = false;
 
 
10599
  _.each( dominusParams.servi , function( servusShortSetId ) {
10600
  if ( ! api.control.has( api.CZR_Helpers.build_setId( servusShortSetId ) ) ) {
10601
  return;
10602
  }
 
 
 
10603
  var _fireDominusCallbacks = function( dominusSetVal, servusShortSetId, dominusParams, refresh ) {
10604
  var _toFire = [],
10605
  _args = arguments;
@@ -10627,10 +14939,19 @@ $.extend( CZRLayoutSelectMths , {
10627
  .fail( function() { dfd.reject(); })
10628
  .done( function() { dfd.resolve(); });
10629
  };
 
 
 
10630
  _deferCallbacks();
 
 
 
10631
  if ( ! _.has( dominusSetInst, 'czr_visibilityServi' ) )
10632
  dominusSetInst.czr_visibilityServi = new api.Value( [] );
 
 
10633
  var _currentDependantBound = dominusSetInst.czr_visibilityServi();
 
10634
  if ( ! _.contains( _currentDependantBound, servusShortSetId ) ) {
10635
  dominusSetInst.bind( function( dominusSetVal ) {
10636
  _deferCallbacks( dominusSetVal );
@@ -10642,13 +14963,22 @@ $.extend( CZRLayoutSelectMths , {
10642
  return dfd.resolve().promise();
10643
  return dfd.promise();
10644
  },
 
 
 
 
10645
  _setVisibility : function ( dominusSetVal, servusShortSetId, dominusParams, refresh ) {
10646
  var wpServusSetId = api.CZR_Helpers.build_setId( servusShortSetId ),
10647
  visibility = dominusParams.visibility( dominusSetVal, servusShortSetId, dominusParams.dominus );
10648
 
10649
  refresh = refresh || false;
 
 
10650
  if ( ! _.isBoolean( visibility ) || ( 'unchanged' == visibility && ! refresh ) )
10651
  return;
 
 
 
10652
  var _doVisibilitiesWhenPossible = function() {
10653
  if ( api.state.has( 'silent-update-processing' ) && api.state( 'silent-update-processing' )() )
10654
  return;
@@ -10700,9 +15030,21 @@ $.extend( CZRLayoutSelectMths , {
10700
  _getControlDeps : function() {
10701
  return {};
10702
  },
 
 
 
 
 
 
 
 
 
 
10703
  _prepareDominusParams : function( params_candidate ) {
10704
  var self = this,
10705
  _ready_params = {};
 
 
10706
  if ( ! _.isObject( params_candidate ) ) {
10707
  api.errorLog( 'Visibilities : a dominus param definition must be an object.');
10708
  return _ready_params;
@@ -10765,15 +15107,25 @@ $.extend( CZRLayoutSelectMths , {
10765
  _handleFaviconNote : function() {
10766
  var self = this,
10767
  _fav_setId = api.CZR_Helpers.build_setId( serverControlParams.faviconOptionName );
 
 
 
 
10768
  if ( ! api.has('site_icon') || ! api.control('site_icon') || ( api.has( _fav_setId ) && 0 === + api( _fav_setId )() ) || + api('site_icon')() > 0 )
10769
  return;
10770
 
10771
  var _oldDes = api.control('site_icon').params.description;
10772
  _newDes = ['<strong>' , i18n.faviconNote || '' , '</strong><br/><br/>' ].join('') + _oldDes;
 
 
10773
  self._printFaviconNote(_newDes );
 
 
10774
  api('site_icon').callbacks.add( function(to) {
10775
  if ( +to > 0 ) {
 
10776
  api.control('site_icon').container.find('.description').text(_oldDes);
 
10777
  if ( api.has( _fav_setId ) )
10778
  api( _fav_setId ).set("");
10779
  }
@@ -10782,16 +15134,35 @@ $.extend( CZRLayoutSelectMths , {
10782
  }
10783
  });
10784
  },
 
 
10785
  _printFaviconNote : function( _newDes ) {
10786
  api.control('site_icon').container.find('.description').html(_newDes);
10787
  }
10788
  }
10789
  );//api.Class.extend() //api.CZR_ctrlDependencies
10790
  })( wp.customize, jQuery, _);
 
 
 
 
10791
  ( function ( wp, $ ) {
10792
  $( function($) {
10793
  var api = wp.customize || api;
10794
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10795
  /* RECENTER CURRENT SECTIONS */
10796
  $('.accordion-section').not('.control-panel').click( function () {
10797
  _recenter_current_section($(this));
@@ -10799,6 +15170,7 @@ $.extend( CZRLayoutSelectMths , {
10799
 
10800
  function _recenter_current_section( section ) {
10801
  var $siblings = section.siblings( '.open' );
 
10802
  if ( 0 !== $siblings.length && $siblings.offset().top < 0 ) {
10803
  $('.wp-full-overlay-sidebar-content').animate({
10804
  scrollTop: - $('#customize-theme-controls').offset().top - $siblings.height() + section.offset().top + $('.wp-full-overlay-sidebar-content').offset().top
@@ -10811,18 +15183,23 @@ $.extend( CZRLayoutSelectMths , {
10811
  api.czrSetupCheckbox = function( controlId, refresh ) {
10812
  var _ctrl = api.control( controlId );
10813
  $('input[type=checkbox]', _ctrl.container ).each( function() {
 
10814
  if ( 'tc_font_customizer_settings' == _ctrl.params.section )
10815
  return;
 
10816
  if ( 0 === $(this).val() || '0' == $(this).val() || 'off' == $(this).val() || _.isEmpty($(this).val() ) ) {
10817
  $(this).prop('checked', false);
10818
  } else {
10819
  $(this).prop('checked', true);
10820
  }
 
 
10821
  if ( 0 !== $(this).closest('div[class^="icheckbox"]').length )
10822
  return;
10823
 
10824
  $(this).iCheck({
10825
  checkboxClass: 'icheckbox_flat-grey',
 
10826
  radioClass: 'iradio_flat-grey',
10827
  })
10828
  .on( 'ifChanged', function(e){
@@ -10834,10 +15211,15 @@ $.extend( CZRLayoutSelectMths , {
10834
 
10835
  /* SELECT INPUT */
10836
  api.czrSetupSelect = function(controlId, refresh) {
 
10837
  $('select[data-customize-setting-link]', api.control(controlId).container )
10838
  .not('.no-selecter-js')
10839
  .each( function() {
10840
  $(this).selecter({
 
 
 
 
10841
  });
10842
  });
10843
  };//api.czrSetupSelect()
@@ -10845,24 +15227,33 @@ $.extend( CZRLayoutSelectMths , {
10845
 
10846
  /* NUMBER INPUT */
10847
  api.czrSetupStepper = function( controlId, refresh ) {
 
10848
  var _ctrl = api.control( controlId );
10849
- $('input[type="number"]', _ctrl.container ).each( function() {
10850
- if ( 'tc_font_customizer_settings' != _ctrl.params.section ) {
10851
- $(this).stepper();
10852
- }
10853
- });
10854
  };//api.czrSetupStepper()
10855
 
10856
- api.control.each(function(control){
10857
- if ( ! _.has(control,'id') )
 
 
10858
  return;
 
10859
  if ( 'widget_' != control.id.substring(0, 'widget_'.length ) && 'nav_menu' != control.id.substring( 0, 'nav_menu'.length ) ) {
10860
  api.czrSetupCheckbox(control.id);
10861
  }
10862
  if ( 'nav_menu_locations' != control.id.substring( 0, 'nav_menu_locations'.length ) ) {
10863
  api.czrSetupSelect(control.id);
10864
  }
10865
- api.czrSetupStepper(control.id);
 
 
 
 
 
 
 
 
 
10866
  });
10867
 
10868
 
@@ -10879,6 +15270,8 @@ $.extend( CZRLayoutSelectMths , {
10879
  event.preventDefault();
10880
  })
10881
  .on( 'click.customize-controls-home', function() {
 
 
10882
  if ( api.section.has( api.czr_activeSectionId() ) ) {
10883
  api.section( api.czr_activeSectionId() ).expanded( false );
10884
  } else {
43
  }
44
  });
45
  })( wp.customize , jQuery, _);//NOT USED YET
46
+ // var czr_debug = {
47
+ // log: function(o) {debug.queue.push(['log', arguments, debug.stack.slice(0)]); if (window.console && typeof window.console.log == 'function') {window.console.log(o);}},
48
+ // error: function(o) {debug.queue.push(['error', arguments, debug.stack.slice(0)]); if (window.console && typeof window.console.error == 'function') {window.console.error(o);}},
49
+ // queue: [],
50
+ // stack: []
51
+ // };
52
+ //var api = api || wp.customize, $ = $ || jQuery;
53
  ( function ( api, $, _ ) {
54
+ //The api.czr_skopeReady is used by some modules like the slider to fire actions
55
+ //if skope is disabled, we need to resolve it now.
56
+ api.czr_skopeReady = $.Deferred();
57
+ if ( _.isUndefined( serverControlParams.isSkopOn ) || ! serverControlParams.isSkopOn ) {
58
+ api.czr_skopeReady.resolve();
59
+ }
60
+
61
+ //@return [] for console method
62
+ //@bgCol @textCol are hex colors
63
+ //@arguments : the original console arguments
64
  var _prettyPrintLog = function( args ) {
65
  var _defaults = {
66
  bgCol : '#5ed1f5',
75
  return '';
76
  return string.length > 150 ? string.substr( 0, 149 ) : string;
77
  };
78
+
79
+ //if the array to print is not composed exclusively of strings, then let's stringify it
80
+ //else join(' ')
81
  if ( ! _.isEmpty( _.filter( _toArr, function( it ) { return ! _.isString( it ); } ) ) ) {
82
  _toArr = JSON.stringify( _toArr.join(' ') );
83
  } else {
88
  [ 'background:' + args.bgCol, 'color:' + args.textCol, 'display: block;' ].join(';')
89
  ];
90
  };
91
+ //Dev mode aware and IE compatible api.consoleLog()
92
  api.consoleLog = function() {
93
  if ( ! serverControlParams.isDevMode )
94
  return;
95
+ //fix for IE, because console is only defined when in F12 debugging mode in IE
96
  if ( ( _.isUndefined( console ) && typeof window.console.log != 'function' ) )
97
  return;
98
  console.log.apply( console, _prettyPrintLog( { consoleArguments : arguments } ) );
99
  };
100
 
101
  api.errorLog = function() {
102
+ //fix for IE, because console is only defined when in F12 debugging mode in IE
103
  if ( ( _.isUndefined( console ) && typeof window.console.log != 'function' ) )
104
  return;
105
 
107
  };
108
 
109
  api.czr_isSkopOn = function() {
110
+ return ! _.isUndefined ( serverControlParams.isSkopOn ) && serverControlParams.isSkopOn && _.has( api, 'czr_skopeBase' );
111
  };
112
 
113
  api.czr_isChangeSetOn = function() {
116
 
117
  })( wp.customize , jQuery, _);
118
  ( function ( api, $, _ ) {
119
+ // if ( ! serverControlParams.isSkopOn )
120
+ // return;
121
  /*****************************************************************************
122
  * A "CONTEXT AWARE" SET METHD
123
  *****************************************************************************/
135
  to = this._setter.apply( this, arguments );
136
  to = this.validate( to );
137
  args = _.extend( { silent : false }, _.isObject( o ) ? o : {} );
138
+
139
+ // Bail if the sanitized value is null or unchanged.
140
  if ( null === to || _.isEqual( from, to ) ) {
141
  return dfd.resolveWith( self, [ to, from, o ] ).promise();
142
  }
164
  }
165
  return dfd.promise( self );
166
  };
167
+
168
+ //allows us to specify a list of callbacks + a { deferred : true } param
169
+ //if deferred is found and true, then the callback(s) are added in a list of deferred
170
+ //@see how this deferred list is used in api.Value.prototype.set()
171
  api.Value.prototype.bind = function() {
172
+ //find an object in the argument
173
  var self = this,
174
  _isDeferred = false,
175
  _cbs = [];
188
  self._deferreds.push( _cb );
189
  });
190
  } else {
191
+ //original method
192
  self.callbacks.add.apply( self.callbacks, arguments );
193
  }
194
  return this;
201
  * => add an object param to the callback to inform that this is a silent process
202
  * , this is typically used in the overridden api.Setting.preview method
203
  *****************************************************************************/
204
+ //@param to : the new value to set
205
+ //@param dirtyness : the current dirtyness status of this setting in the skope
206
+ //
207
  api.Setting.prototype.silent_set =function( to, dirtyness ) {
208
  var from = this._value,
209
  _save_state = api.state('saved')();
210
 
211
  to = this._setter.apply( this, arguments );
212
  to = this.validate( to );
213
+
214
+ // Bail if the sanitized value is null or unchanged.
215
  if ( null === to || _.isEqual( from, to ) ) {
216
  return this;
217
  }
220
  this._dirty = ( _.isUndefined( dirtyness ) || ! _.isBoolean( dirtyness ) ) ? this._dirty : dirtyness;
221
 
222
  this.callbacks.fireWith( this, [ to, from, { silent : true } ] );
223
+ //reset the api state to its value before the callback call
224
  api.state('saved')( _save_state );
225
  return this;
226
  };
227
  })( wp.customize , jQuery, _ );
228
  ( function ( api, $, _ ) {
229
+ //PREPARE THE SKOPE AWARE PREVIEWER
230
+
231
+ //@return void()
232
+ //Changed the core to specify that the setting preview is actually a deferred callback
233
+ //=> allows us to use syntax like :
234
+ //api( setId ).set( new_value ).done( function() { execute actions when all the setting callbacks have been done })
235
  api.Setting.prototype.initialize = function( id, value, options ) {
236
  var setting = this;
237
  api.Value.prototype.initialize.call( setting, value, options );
240
  setting.transport = setting.transport || 'refresh';
241
  setting._dirty = options.dirty || false;
242
  setting.notifications = new api.Values({ defaultConstructor: api.Notification });
243
+
244
+ // Whenever the setting's value changes, refresh the preview.
245
  setting.bind( setting.preview );
246
+
247
+ // the deferred can be used in moduleCollectionReact to execute actions after the module has been set.
248
+ // setting.bind( function( to, from , data ) {
249
+ // return setting.preview( to, from , data );
250
+ // }, { deferred : true } );
251
  };
252
+
253
+
254
+ //var _old_preview = api.Setting.prototype.preview;
255
+ //@return a deferred promise
256
  api.Setting.prototype.preview = function( to, from , data ) {
257
  var setting = this, transport, dfd = $.Deferred();
258
 
262
  this.previewer.refresh();
263
  return dfd.resolve( arguments ).promise();
264
  }
265
+ //as soon as the previewer is setup, let's behave as usual
266
+ //=> but don't refresh when silently updating
267
+
268
+ //Each input instantiated in an item or a modOpt can have a specific transport set.
269
+ //the input transport is hard coded in the module js template, with the attribute : data-transport="postMessage" or "refresh"
270
+ //=> this is optional, if not set, then the transport will be inherited from the the module, which inherits from the control.
271
+ //
272
+ //If the input transport is specifically set to postMessage, then we don't want to send the 'setting' event to the preview
273
+ //=> this will prevent any partial refresh to be triggered if the input control parent is defined has a partial refresh one.
274
+ //=> the input will be sent to preview with api.previewer.send( 'czr_input', {...} )
275
+ //
276
+ //One exception : if the input transport is set to postMessage but the setting has not been set yet in the api (from is undefined, null, or empty) , we usually need to make an initial refresh
277
+ //=> typically, the initial refresh can be needed to set the relevant module css id selector that will be used afterwards for the postMessage input preview
278
+
279
+ //If we are in an input postMessage situation, the not_preview_sent param has been set in the czr_Input.inputReact method
280
+ //=> 1) We bail here
281
+ //=> 2) and we will send a custom event to the preview looking like :
282
+ //api.previewer.send( 'czr_input', {
283
+ // set_id : module.control.id,
284
+ // module : { items : $.extend( true, {}, module().items) , modOpt : module.hasModOpt() ? $.extend( true, {}, module().modOpt ): {} },
285
+ // module_id : module.id,//<= will allow us to target the right dom element on front end
286
+ // input_id : input.id,
287
+ // input_parent_id : input.input_parent.id,//<= can be the mod opt or the item
288
+ // value : to
289
+ // });
290
+
291
+ //=> if no from (setting not set yet => fall back on defaut transport)
292
  if ( ! _.isUndefined( from ) && ! _.isEmpty( from ) && ! _.isNull( from ) ) {
293
  if ( _.isObject( data ) && true === data.not_preview_sent ) {
294
  return dfd.resolve( arguments ).promise();
295
  }
296
  }
297
+
298
+ //Don't do anything id we are silent
299
  if ( _.has( data, 'silent' ) && false !== data.silent )
300
  return dfd.resolve( arguments ).promise();
301
+
302
+
303
+ //CORE PREVIEW AS OF WP 4.7+
304
  if ( 'postMessage' === transport && ! api.state( 'previewerAlive' ).get() ) {
305
  transport = 'refresh';
306
  }
307
 
308
  if ( 'postMessage' === transport ) {
309
+ //Pre setting event with a richer object passed
310
+ //=> can be used in a partial refresh scenario to execute actions prior to the actual selective refresh which is triggered on 'setting', just after
311
  setting.previewer.send( 'pre_setting', {
312
  set_id : setting.id,
313
  data : data,//<= { module_id : 'string', module : {} } which typically includes the module_id and the module model ( items, mod options )
314
  value : to
315
  });
316
+
317
+ //WP Default
318
+ //=> the 'setting' event is used for normal and partial refresh post message actions
319
+ //=> the partial refresh is fired on the preview if a partial has been registered for this setting in the php customize API
320
+ //=> When a partial has been registered, the "normal" ( => the not partial refresh ones ) postMessage callbacks will be fired before the ajax ones
321
  setting.previewer.send( 'setting', [ setting.id, setting() ] );
322
 
323
  dfd.resolve( arguments );
324
 
325
  } else if ( 'refresh' === transport ) {
326
+ //the refresh() method only returns a promise when skope is on
327
  if ( serverControlParams.isSkopOn ) {
328
  setting.previewer.refresh().always( function() {
329
  dfd.resolve( arguments );
339
  })( wp.customize , jQuery, _ );
340
  ( function ( api, $, _ ) {
341
  /* monkey patch for the content height set */
342
+ //wp.customize.Section is not available before wp 4.1
343
  if ( 'function' == typeof api.Section ) {
344
+ // backup the original function
345
  var _original_section_initialize = api.Section.prototype.initialize;
346
  api.Section.prototype.initialize = function( id, options ) {
347
+ //call the original constructor
348
  _original_section_initialize.apply( this, [id, options] );
349
  var section = this;
350
 
354
 
355
  var container = section.container.closest( '.wp-full-overlay-sidebar-content' ),
356
  content = section.container.find( '.accordion-section-content' );
357
+ //content resizing to the container height
358
  _resizeContentHeight = function() {
359
  content.css( 'height', container.innerHeight() );
360
  };
361
  _resizeContentHeight();
362
+ //this is set to off in the original expand callback if 'expanded' is false
363
  $( window ).on( 'resize.customizer-section', _.debounce( _resizeContentHeight, 110 ) );
364
  });
365
  };
367
  })( wp.customize , jQuery, _ );
368
  (function (api, $, _) {
369
  api.CZR_Helpers = api.CZR_Helpers || {};
370
+ //////////////////////////////////////////////////
371
+ /// ACTIONS AND DOM LISTENERS
372
+ //////////////////////////////////////////////////
373
+ //adds action to an existing event map
374
+ //@event map = [ {event1}, {event2}, ... ]
375
+ //@new_event = { trigger : event name , actions : [ 'cb1', 'cb2', ... ] }
376
  api.CZR_Helpers = $.extend( api.CZR_Helpers, {
377
+ //While a control should always have a default setting,
378
+ //It can have additional setting assigned
379
+ //This method returns the default setting or the specified type if requested
380
+ //Example : header_image has default and data
381
  getControlSettingId : function( control_id, setting_type ) {
382
  setting_type = 'default' || setting_type;
383
  if ( ! api.control.has( control_id ) ) {
417
  * simple helper to build the setting wp api ready id
418
  */
419
  build_setId : function ( setId ) {
420
+ //exclude the WP built-in settings like blogdescription, show_on_front, etc
421
  if ( _.contains( serverControlParams.wpBuiltinSettings, setId ) )
422
  return setId;
423
+
424
+ // //extract the setting id for theme mods
425
+ // var _pattern;
426
+
427
+ //exclude the WP built-in settings like sidebars_widgets*, nav_menu_*, widget_*, custom_css
428
+ // var _patterns = [ 'widget_', 'nav_menu', 'sidebars_', 'custom_css' ],
429
+ // _isExcld = false;
430
+ // _.each( _patterns, function( _ptrn ) {
431
+ // if ( _isExcld )
432
+ // return;
433
+ // _isExcld = _ptrn == setId.substring( 0, _ptrn.length );
434
+ // });
435
+ // if ( _isExcld )
436
+ // return setId;
437
  if ( ! _.contains( serverControlParams.themeSettingList, setId ) )
438
  return setId;
439
 
446
  */
447
  getOptionName : function(name) {
448
  var self = this;
449
+ //targets only the options of the theme
450
  if ( -1 == name.indexOf(serverControlParams.themeOptions) )
451
  return name;
452
  return name.replace(/\[|\]/g, '').replace(serverControlParams.themeOptions, '');
453
  },
454
+
455
+
456
+
457
+ //@return bool
458
+ //@uses api.czr_partials
459
  hasPartRefresh : function( setId ) {
460
  if ( ! _.has( api, 'czr_partials') )
461
  return;
463
  return _.contains( partial.settings, setId );
464
  }), true );
465
  },
466
+
467
+ //@return the array of controls in a given section_id
468
  getSectionControlIds : function( section_id ) {
469
  section_id = section_id || api.czr_activeSectionId();
470
  return ! api.section.has( section_id ) ?
473
  return _ctrl.id;
474
  });
475
  },
476
+
477
+
478
+ //1) get the control of a given section
479
+ //2) for each control get the associated setting(s)
480
+ //=> important, a control might have several associated settings. Typical example : header_image.
481
+ //@return [] of setting ids for a given czr section
482
  getSectionSettingIds : function( section_id ) {
483
  section_id = section_id || api.czr_activeSectionId();
484
  if ( ! api.section.has( section_id) )
494
  });
495
  return _sec_settings;
496
  },
497
+
498
+
499
+ //////////////////////////////////////////////////
500
+ /// STRINGS HELPERS
501
+ //////////////////////////////////////////////////
502
  capitalize : function( string ) {
503
  if( ! _.isString(string) )
504
  return string;
514
  s_ = (useWordBoundary && isTooLong) ? s_.substr(0,s_.lastIndexOf(' ')) : s_;
515
  return isTooLong ? s_ + '...' : s_;
516
  },
517
+
518
+
519
+ //////////////////////////////////////////////////
520
+ /// STRINGS HELPERS
521
+ //////////////////////////////////////////////////
522
+ //is a module multi item ?
523
+ //@return bool
524
  isMultiItemModule : function( module_type, moduleInst ) {
525
  if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
526
  return;
533
 
534
  return api.czrModuleMap[module_type].crud || api.czrModuleMap[module_type].multi_item || false;
535
  },
536
+
537
+ //is a module crud ?
538
+ //@return bool
539
  isCrudModule : function( module_type, moduleInst ) {
540
  if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
541
  return;
548
 
549
  return api.czrModuleMap[module_type].crud || false;
550
  },
551
+
552
+ //is a module crud ?
553
+ //@return bool
554
  hasModuleModOpt : function( module_type, moduleInst ) {
555
  if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
556
  return;
563
 
564
  return api.czrModuleMap[module_type].has_mod_opt || false;
565
  },
566
+
567
+
568
+
569
+ //This method is now statically accessed by item and modopt instances because it does the same job for both.
570
+ //=> It instantiates the inputs based on what it finds in the DOM ( item or mod opt js templates )
571
+ //
572
+ //Fired on 'contentRendered' for items and on user click for module options (mod opt)
573
+ //creates the inputs based on the rendered parent item or mod option
574
+ //inputParentInst can be an item instance or a module option instance
575
  setupInputCollectionFromDOM : function() {
576
  var inputParentInst = this;//<= because fired with .call( inputParentInst )
577
  if ( ! _.isFunction( inputParentInst ) ) {
579
  }
580
  var module = inputParentInst.module,
581
  is_mod_opt = _.has( inputParentInst() , 'is_mod_opt' );
582
+
583
+ //bail if already done
584
  if ( _.has( inputParentInst, 'czr_Input') && ! _.isEmpty( inputParentInst.inputCollection() ) )
585
  return;
586
+
587
+ //INPUTS => Setup as soon as the view content is rendered
588
+ //the inputParentInst is a collection of inputs, each one has its own view module.
589
  inputParentInst.czr_Input = new api.Values();
590
+
591
+ //IS THE PARENT AN ITEM OR A MODULE OPTION ?
592
+ //those default constructors (declared in the module init ) can be overridden by extended item or mod opt constructors inside the modules
593
  inputParentInst.inputConstructor = is_mod_opt ? module.inputModOptConstructor : module.inputConstructor;
594
 
595
  var _defaultInputParentModel = is_mod_opt ? inputParentInst.defaultModOptModel : inputParentInst.defaultItemModel;
597
  if ( _.isEmpty( _defaultInputParentModel ) || _.isUndefined( _defaultInputParentModel ) ) {
598
  throw new Error( 'No default model found in item or mod opt ' + inputParentInst.id + '.' );
599
  }
600
+
601
+ //prepare and sets the inputParentInst value on api ready
602
+ //=> triggers the module rendering + DOM LISTENERS
603
  var inputParentInst_model = $.extend( true, {}, inputParentInst() );
604
 
605
  if ( ! _.isObject( inputParentInst_model ) )
608
  inputParentInst_model = $.extend( _defaultInputParentModel, inputParentInst_model );
609
 
610
  var dom_inputParentInst_model = {};
611
+
612
+ //creates the inputs based on the rendered item or mod opt
613
  $( '.' + module.control.css_attr.sub_set_wrapper, inputParentInst.container).each( function( _index ) {
614
  var _id = $(this).find('[data-type]').attr( 'data-type' ),
615
  _value = _.has( inputParentInst_model, _id ) ? inputParentInst_model[ _id ] : '';
616
+
617
+ //skip if no valid input data-type is found in this node
618
  if ( _.isUndefined( _id ) || _.isEmpty( _id ) ) {
619
  api.consoleLog( 'setupInputCollectionFromDOM : missing data-type for ' + module.id );
620
  return;
621
  }
622
+ //check if this property exists in the current inputParentInst model
623
  if ( ! _.has( inputParentInst_model, _id ) ) {
624
  throw new Error('The item or mod opt property : ' + _id + ' has been found in the DOM but not in the item or mod opt model : '+ inputParentInst.id + '. The input can not be instantiated.');
625
  }
626
+
627
+ //Do we have a specific set of options defined in the parent module for this inputConstructor ?
628
  var _inputType = $(this).attr( 'data-input-type' ),
629
  _inputTransport = $(this).attr( 'data-transport' ) || 'inherit',//<= if no specific transport ( refresh or postMessage ) has been defined in the template, inherits the control transport
630
  _inputOptions = _.has( module.inputOptions, _inputType ) ? module.inputOptions[ _inputType ] : {};
631
+
632
+ //INSTANTIATE THE INPUT
633
  inputParentInst.czr_Input.add( _id, new inputParentInst.inputConstructor( _id, {
634
  id : _id,
635
  type : _inputType,
641
  is_mod_opt : is_mod_opt,
642
  module : module
643
  } ) );
644
+
645
+ //FIRE THE INPUT
646
+ //fires ready once the input Value() instance is initialized
647
  inputParentInst.czr_Input( _id ).ready();
648
+
649
+ //POPULATES THE PARENT INPUT COLLECTION
650
  dom_inputParentInst_model[ _id ] = _value;
651
+ //shall we trigger a specific event when the input collection from DOM has been populated ?
652
  });//each
653
+
654
+ //stores the collection
655
  inputParentInst.inputCollection( dom_inputParentInst_model );
656
+
657
+ //chain
658
  return inputParentInst;
659
  },
660
+
661
+ //@self explanatory: removes a collection of input from a parent item or modOpt instance
662
+ //Triggered by : user actions usually when an item is collapsed or when the modOpt panel is closed
663
  removeInputCollection : function() {
664
  var inputParentInst = this;//<= because fired with .call( inputParentInst )
665
  if ( ! _.isFunction( inputParentInst ) ) {
667
  }
668
  if ( ! _.has( inputParentInst, 'czr_Input') )
669
  return;
670
+ //remove each input api.Value() instance
671
  inputParentInst.czr_Input.each( function( _input ) {
672
  inputParentInst.czr_Input.remove( _input.id );
673
  });
674
+ //reset the input collection property
675
  inputParentInst.inputCollection({});
676
  },
677
+
678
+ //Re-instantiate a module control based on its id
679
+ //@param wpSetId : the api id of the control to refresh
680
  refreshModuleControl : function( wpSetId ) {
681
  var _constructor = api.controlConstructor.czr_module,
682
  _control_type = api.control( wpSetId ).params.type,
683
  _control_data = api.settings.controls[wpSetId];
684
+
685
+ //remove the container and its control
686
  $.when( api.control( wpSetId ).container.remove() ).done( function() {
687
+ //remove the control from the api control collection
688
  api.control.remove( wpSetId );
689
+
690
+ //re-instantiate the control with the updated _control_data
691
  api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
692
  });
693
 
694
  },
695
+
696
+
697
+ //COLORS
698
  hexToRgb : function( hex ) {
699
+ // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
700
  var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
701
  try {
702
  hex = hex.replace(shorthandRegex, function(m, r, g, b) {
725
  }
726
 
727
  });//$.extend
728
+ // $( window ).on( 'message', function( e, o) {
729
+ // api.consoleLog('WHAT ARE WE LISTENING TO?', e, o );
730
+ // });
731
  })( wp.customize , jQuery, _);
732
  (function (api, $, _) {
733
  api.CZR_Helpers = api.CZR_Helpers || {};
734
+ //////////////////////////////////////////////////
735
+ /// ACTIONS AND DOM LISTENERS
736
+ //////////////////////////////////////////////////
737
+ //adds action to an existing event map
738
+ //@event map = [ {event1}, {event2}, ... ]
739
+ //@new_event = { trigger : event name , actions : [ 'cb1', 'cb2', ... ] }
740
  api.CZR_Helpers = $.extend( api.CZR_Helpers, {
741
  addActions : function( event_map, new_events, instance ) {
742
  var control = this;
749
  doActions : function( action, $dom_el, obj ) {
750
  $dom_el.trigger( action, obj );
751
  },
752
+
753
+
754
+ //@args = {model : model, dom_el : $_view_el, refreshed : _refreshed }
755
  setupDOMListeners : function( event_map , args, instance ) {
756
  var control = this,
757
  _defaultArgs = {
760
  };
761
 
762
  instance = instance || control;
763
+ //event_map : are we good ?
764
  if ( ! _.isArray( event_map ) ) {
765
  api.errorLog( 'setupDomListeners : event_map should be an array', args );
766
  return;
767
  }
768
+
769
+ //args : are we good ?
770
  if ( ! _.isObject( args ) ) {
771
  api.errorLog( 'setupDomListeners : args should be an object', event_map );
772
  return;
773
  }
774
 
775
  args = _.extend( _defaultArgs, args );
776
+ // => we need an existing dom element
777
  if ( ! args.dom_el instanceof jQuery || 1 != args.dom_el.length ) {
778
  api.errorLog( 'setupDomListeners : dom element should be an existing dom element', args );
779
  return;
780
  }
781
+
782
+ //loop on the event map and map the relevant callbacks by event name
783
+ // @param _event :
784
+ //{
785
+ // trigger : '',
786
+ // selector : '',
787
+ // name : '',
788
+ // actions : ''
789
+ // },
790
  _.map( event_map , function( _event ) {
791
  if ( ! _.isString( _event.selector ) || _.isEmpty( _event.selector ) ) {
792
  api.errorLog( 'setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : ' + _event.actions.join(',') );
793
  return;
794
  }
795
+
796
+ //Are we good ?
797
  if ( ! _.isString( _event.selector ) || _.isEmpty( _event.selector ) ) {
798
  api.errorLog( 'setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : ' + _event.actions.join(',') );
799
  return;
800
  }
801
+
802
+ //LISTEN TO THE DOM => USES EVENT DELEGATION
803
  args.dom_el.on( _event.trigger , _event.selector, function( e, event_params ) {
804
+ //stop propagation to ancestors modules, typically a sektion
805
  e.stopPropagation();
806
+ //particular treatment
807
  if ( api.utils.isKeydownButNotEnterEvent( e ) ) {
808
  return;
809
  }
810
  e.preventDefault(); // Keep this AFTER the key filter above
811
+
812
+ //It is important to deconnect the original object from its source
813
+ //=> because we will extend it when used as params for the action chain execution
814
  var actionsParams = $.extend( true, {}, args );
815
+
816
+ //always get the latest model from the collection
817
  if ( _.has( actionsParams, 'model') && _.has( actionsParams.model, 'id') ) {
818
  if ( _.has( instance, 'get' ) )
819
  actionsParams.model = instance();
820
  else
821
  actionsParams.model = instance.getModel( actionsParams.model.id );
822
  }
823
+
824
+ //always add the event obj to the passed args
825
+ //+ the dom event
826
  $.extend( actionsParams, { event : _event, dom_event : e } );
827
+
828
+ //add the event param => useful for triggered event
829
  $.extend( actionsParams, event_params );
830
+
831
+ //SETUP THE EMITTERS
832
+ //inform the container that something has happened
833
+ //pass the model and the current dom_el
834
+ //the model is always passed as parameter
835
  if ( ! _.has( actionsParams, 'event' ) || ! _.has( actionsParams.event, 'actions' ) ) {
836
  api.errorLog( 'executeEventActionChain : missing obj.event or obj.event.actions' );
837
  return;
843
  });//.on()
844
  });//_.map()
845
  },//setupDomListeners
846
+
847
+
848
+
849
+ //GENERIC METHOD TO SETUP EVENT LISTENER
850
+ //NOTE : the args.event must alway be defined
851
  executeEventActionChain : function( args, instance ) {
852
  var control = this;
853
+
854
+ //if the actions param is a anonymous function, fire it and stop there
855
  if ( 'function' === typeof( args.event.actions ) )
856
  return args.event.actions.call( instance, args );
857
+
858
+ //execute the various actions required
859
+ //first normalizes the provided actions into an array of callback methods
860
+ //then loop on the array and fire each cb if exists
861
  if ( ! _.isArray( args.event.actions ) )
862
  args.event.actions = [ args.event.actions ];
863
+
864
+ //if one of the callbacks returns false, then we break the loop
865
+ //=> allows us to stop a chain of callbacks if a condition is not met
866
  var _break = false;
867
  _.map( args.event.actions, function( _cb ) {
868
  if ( _break )
871
  if ( 'function' != typeof( instance[ _cb ] ) ) {
872
  throw new Error( 'executeEventActionChain : the action : ' + _cb + ' has not been found when firing event : ' + args.event.selector );
873
  }
874
+
875
+ //Allow other actions to be bound before action and after
876
+ //
877
+ //=> we don't want the event in the object here => we use the one in the event map if set
878
+ //=> otherwise will loop infinitely because triggering always the same cb from args.event.actions[_cb]
879
+ //=> the dom element shall be get from the passed args and fall back to the controler container.
880
  var $_dom_el = ( _.has(args, 'dom_el') && -1 != args.dom_el.length ) ? args.dom_el : control.container;
881
 
882
  $_dom_el.trigger( 'before_' + _cb, _.omit( args, 'event' ) );
883
+
884
+ //executes the _cb and stores the result in a local var
885
  var _cb_return = instance[ _cb ].call( instance, args );
886
+ //shall we stop the action chain here ?
887
  if ( false === _cb_return )
888
  _break = true;
889
+
890
+ //allow other actions to be bound after
891
  $_dom_el.trigger( 'after_' + _cb, _.omit( args, 'event' ) );
892
  });//_.map
893
  }
894
  });//$.extend
895
  })( wp.customize , jQuery, _);
896
  (function (api, $, _) {
897
+ //This promise will let us know when we have the first set of preview query ready to use
898
+ //This is needed for modules contextually dependant
899
+ //For example, the slider module will initialize the module model based on the contextual informations, if no items have been set yet.
900
 
901
  api.czr_wpQueryDataReady = $.Deferred();
902
  api.czr_wpQueryInfos = api.czr_wpQueryInfos || new api.Value();
904
  /*****************************************************************************
905
  * CAPTURE PREVIEW INFORMATIONS ON REFRESH + REACT TO THEM
906
  *****************************************************************************/
907
+ //Data are sent by the preview frame when the panel has sent the 'sync' or even better 'active' event
908
  api.bind( 'ready', function() {
909
+ //observe widget settings changes
910
  api.previewer.bind('houston-widget-settings', function(data) {
911
+ //get the difference
912
  var _candidates = _.filter( data.registeredSidebars, function( sb ) {
913
  return ! _.findWhere( _wpCustomizeWidgetsSettings.registeredSidebars, { id: sb.id } );
914
  });
924
  var _registered = _.map( data.registeredSidebars, function(obj) {
925
  return obj.id;
926
  });
927
+
928
+ //stores and update the widget zone settings
929
  api.czr_widgetZoneSettings = api.czr_widgetZoneSettings || new api.Value();//will store all widget zones data sent by preview as an observable object
930
  api.czr_widgetZoneSettings.set( {
931
  actives : data.renderedSidebars,
944
  api.czr_wpQueryDataReady.resolve( data );
945
  }
946
  });
947
+
948
+ //PARTIAL REFRESHS => stores and observes the partials data sent by the preview
949
  api.previewer.bind( 'czr-partial-refresh-data', function( data ) {
950
  api.czr_partials.set( data );
951
  });
952
+
953
+ //PARTIAL REFRESHS : React on partial refresh done
954
+ // @data : { set_id : api setting id }
955
  api.previewer.bind( 'czr-partial-refresh-done', function( data ) {
956
  if ( ! _.has( data, 'set_id' ) )
957
  return;
958
  var setId = api.CZR_Helpers.build_setId( data.set_id );
959
  if ( ! api.has( setId ) )
960
  return;
961
+ //inform the control
962
  var ctrlId = api.CZR_Helpers.getControlSettingId( setId );
963
  if ( ! api.control.has( ctrlId ) )
964
  return;
966
  });
967
  });//api.bind('ready')
968
  })( wp.customize , jQuery, _ );var CZRInputMths = CZRInputMths || {};
969
+
970
+ //extends api.Value
971
+ //an input is instanciated with the typical set of options :
972
+ // container : $(this),
973
+ // id : _id,
974
+ // input_options : {} <= a set of options that are used when setting up the input type
975
+ // input_parent : {} can be an item instance or a modOpt instance (Value instance, has a parent module)
976
+ // input_value : $(this).find('[data-type]').val(),
977
+ // module : module,
978
+ // transport : inherit or specified in the template with data-transport="postMessage" or "refresh".
979
+ // type : $(this).attr('data-input-type'),
980
+ // is_mod_opt : bool,
981
+ // is_preItemInput : bool
982
  ( function ( api, $, _ ) {
983
  $.extend( CZRInputMths , {
984
  initialize: function( name, options ) {
992
  api.Value.prototype.initialize.call( this, null, options );
993
 
994
  var input = this;
995
+ //input.options = options;
996
+ //write the options as properties, name is included
997
  $.extend( input, options || {} );
998
+
999
+ //DEFERRED STATES
1000
+ //store the state of ready.
1001
  input.isReady = $.Deferred();
1002
+
1003
+ //initialize to the provided value if any
1004
  if ( ! _.isUndefined(options.input_value) ) {
1005
  input.set( options.input_value );
1006
  }
1007
+
1008
+ //Try to find a match with the provided constructor type
1009
+ //=> fire the relevant callback with the provided input_options
1010
+ //input.type_map is declared in extend_api_base
1011
  if ( api.czrInputMap && _.has( api.czrInputMap, input.type ) ) {
1012
  var _meth = api.czrInputMap[ input.type ];
1013
  if ( _.isFunction( input[_meth]) ) {
1024
  color : 'colorpickerchange',
1025
  range : 'input propertychange'
1026
  };
1027
+
1028
+ //Input Event Map
1029
  input.input_event_map = [
1030
+ //set input value
1031
  {
1032
  trigger : $.trim( ['change', trigger_map[input.type] || '' ].join(' ') ),//was 'propertychange change click keyup input',//colorpickerchange is a custom colorpicker event @see method setupColorPicker => otherwise we don't
1033
  selector : 'input[data-type], select[data-type], textarea[data-type]',
1039
  }//was 'updateInput'
1040
  }
1041
  ];
1042
+
1043
+ //Visibility
1044
  input.visible = new api.Value( true );
1045
  input.isReady.done( function() {
1046
  input.visible.bind( function( visible ) {
1050
  input.container.stop( true, true ).slideUp( 200 );
1051
  });
1052
  });
1053
+
1054
+ //Visibility
1055
  input.enabled = new api.Value( true );
1056
  input.isReady.done( function() {
1057
  input.enabled.bind( function( enabled ) {
1060
  });
1061
 
1062
  },
1063
+
1064
+
1065
+ //this method is not fired automatically
1066
+ //It has to be invoked once the input has been instanciated.
1067
  ready : function() {
1068
  var input = this;
1069
  input.setupDOMListeners( input.input_event_map , { dom_el : input.container }, input );
1070
+ //Setup individual input listener
1071
  input.callbacks.add( function() { return input.inputReact.apply( input, arguments ); } );
1072
+ //synchronizer setup
1073
+ //the input instance must be initialized. => initialize method has been done.
1074
  $.when( input.setupSynchronizer() ).done( function() {
1075
  input.isReady.resolve( input );
1076
  } );
1077
 
1078
  },
1079
+
1080
+
1081
+ //fired when input is intanciated and ready.
1082
+ //=> we must have an input instance to synchronize,
1083
+ //invoking this method in the initialize() method is too early, instance not ready
1084
  setupSynchronizer: function() {
1085
  var input = this,
1086
  input_parent = input.input_parent,
1087
  $_input_el = input.container.find('[data-type]'),
1088
  is_textarea = input.container.find('[data-type]').is('textarea');
1089
+
1090
+ //@hack => todo
1091
+ //for text area inputs, the synchronizer is buggy
1092
  if ( is_textarea ) {
1093
  throw new Error('TO DO : THE TEXTAREA INPUT ARE NOT READY IN THE SYNCHRONIZER!');
1094
  }
1099
  syncElement.sync( input );//sync with the input instance
1100
  syncElement.set( input() );
1101
  },
1102
+
1103
+
1104
+
1105
+ //@return void()
1106
+ //react to a single input change
1107
+ //update the collection of input
1108
+ //cb of input.callbacks.add
1109
  inputReact : function( to, from, data ) {
1110
  var input = this,
1111
  _current_input_parent = input.input_parent(),
1112
  _new_model = _.clone( _current_input_parent ),//initialize it to the current value
1113
  _isPreItemInput = input.is_preItemInput;
1114
+
1115
+ //is this input currently enabled ?
1116
  if ( ! input.enabled() )
1117
  return;
1118
+
1119
+ //make sure the _new_model is an object and is not empty
1120
  _new_model = ( ! _.isObject(_new_model) || _.isEmpty(_new_model) ) ? {} : _new_model;
1121
+ //set the new val to the changed property
1122
  _new_model[ input.id ] = to;
1123
+
1124
+ //inform the input_parent : item or modOpt
1125
  input.input_parent.set( _new_model, {
1126
  input_changed : input.id,
1127
  input_transport : input.transport,
1128
  not_preview_sent : 'postMessage' === input.transport//<= this parameter set to true will prevent the setting to be sent to the preview ( @see api.Setting.prototype.preview override ). This is useful to decide if a specific input should refresh or not the preview.
1129
  } );
1130
+
1131
+ //Trigger and send specific events when changing a published input item
1132
  if ( ! _isPreItemInput ) {
1133
+ //inform the input_parent that an input has changed
1134
+ //=> useful to handle dependant reactions between different inputs
1135
  input.input_parent.trigger( input.id + ':changed', to );
1136
+
1137
+ //Each input instantiated in an item or a modOpt can have a specific transport set.
1138
+ //the input transport is hard coded in the module js template, with the attribute : data-transport="postMessage" or "refresh"
1139
+ //=> this is optional, if not set, then the transport will be inherited from the one of the module, which is inherited from the control.
1140
+ //send input to the preview. On update only, not on creation.
1141
  if ( ! _.isEmpty( from ) || ! _.isUndefined( from ) && 'postMessage' === input.transport ) {
1142
  input.module.sendInputToPreview( {
1143
  input_id : input.id,
1160
  palettes: true,
1161
  hide:false,
1162
  change : function( e, o ) {
1163
+ //if the input val is not updated here, it's not detected right away.
1164
+ //weird
1165
+ //is there a "change complete" kind of event for iris ?
1166
+ //$(this).val($(this).wpColorPicker('color'));
1167
+ //input.container.find('[data-type]').trigger('colorpickerchange');
1168
+
1169
+ //synchronizes with the original input
1170
+ //OLD => $(this).val( $(this).wpColorPicker('color') ).trigger('colorpickerchange').trigger('change');
1171
  $(this).val( o.color.toString() ).trigger('colorpickerchange').trigger('change');
1172
  }
1173
  });
1178
  $('select', input.container ).not('.no-selecter-js')
1179
  .each( function() {
1180
  $(this).selecter({
1181
+ //triggers a change event on the view, passing the newly selected value + index as parameters.
1182
+ // callback : function(value, index) {
1183
+ // self.triggerSettingChange( window.event || {} , value, index); // first param is a null event.
1184
+ // }
1185
  });
1186
  });
1187
  },
1211
  $(this).stepper();
1212
  });
1213
  },
1214
+
1215
+ //@use rangeslider https://github.com/andreruffert/rangeslider.js
1216
  setupRangeSlider : function( options ) {
1217
  var input = this,
1218
  $handle,
1221
  };
1222
 
1223
  $( input.container ).find('input').rangeslider( {
1224
+ // Feature detection the default is `true`.
1225
+ // Set this to `false` if you want to use
1226
+ // the polyfill also in Browsers which support
1227
+ // the native <input type="range"> element.
1228
  polyfill: false,
1229
+
1230
+ // Default CSS classes
1231
  rangeClass: 'rangeslider',
1232
  disabledClass: 'rangeslider--disabled',
1233
  horizontalClass: 'rangeslider--horizontal',
1234
  verticalClass: 'rangeslider--vertical',
1235
  fillClass: 'rangeslider__fill',
1236
  handleClass: 'rangeslider__handle',
1237
+
1238
+ // Callback function
1239
  onInit: function() {
1240
  $handle = $('.rangeslider__handle', this.$range);
1241
  $('.rangeslider__handle', this.$range);
1242
  _updateHandle( $handle[0], this.value );
1243
  },
1244
+ // Callback function
1245
+ //onSlide: function(position, value) {},
1246
+ // Callback function
1247
+ //onSlideEnd: function(position, value) {}
1248
  } ).on('input', function() {
1249
  _updateHandle( $handle[0], this.value );
1250
  });
1256
  setupImageUploader : function() {
1257
  var input = this,
1258
  _model = input();
1259
+
1260
+ //an instance field where we'll store the current attachment
1261
  input.attachment = {};
1262
+
1263
+ //do we have an html template and a input container?
1264
  if ( ! input.container )
1265
  return this;
1266
 
1267
  this.tmplRendered = $.Deferred();
1268
  this.setupContentRendering( _model, {} );
1269
+
1270
+ //valid just in the init
1271
  this.tmplRendered.done( function(){
1272
  input.czrImgUploaderBinding();
1273
  });
1275
 
1276
  setupContentRendering : function( to, from) {
1277
  var input = this, _attachment;
1278
+ //retrieve new image if 'to' is different from the saved one
1279
+ //NEED A BETTER WAY?
1280
  if ( ( input.attachment.id != to ) && from !== to ) {
1281
  if ( ! to ) {
1282
  input.attachment = {};
1283
  input.renderImageUploaderTemplate();
1284
  }
1285
+ //Has this image already been fetched ?
1286
  _attachment = wp.media.attachment( to );
1287
  if ( _.isObject( _attachment ) && _.has( _attachment, 'attributes' ) && _.has( _attachment.attributes, 'sizes' ) ) {
1288
  input.attachment = _attachment.attributes;
1301
 
1302
  czrImgUploaderBinding : function() {
1303
  var input = this;
1304
+ //Bind events
1305
+ // Shortcut so that we don't have to use _.bind every time we add a callback.
1306
  _.bindAll( input, 'czrImgUploadRemoveFile', 'czrImgUploadOpenFrame', 'czrImgUploadSelect');
1307
+
1308
+ // Bind events, with delegation to facilitate re-rendering.
1309
  input.container.on( 'click keydown', '.upload-button', input.czrImgUploadOpenFrame );
1310
  input.container.on( 'click keydown', '.thumbnail-image img', input.czrImgUploadOpenFrame );
1311
  input.container.on( 'click keydown', '.remove-button', input.czrImgUploadRemoveFile );
1352
  })
1353
  ]
1354
  });
1355
+ // When a file is selected, run a callback.
1356
  input.frame.on( 'select', input.czrImgUploadSelect );
1357
  },
1358
 
1368
  return;
1369
  }
1370
  event.preventDefault();
1371
+ //reset the attachment class field
1372
  input.attachment = {};
1373
+ //set the model
1374
  input.set('');
1375
  },
1376
 
1384
  input = this,
1385
  attachment = input.frame.state().get( 'selection' ).first().toJSON(), // Get the attachment from the modal frame.
1386
  mejsSettings = window._wpmejsSettings || {};
1387
+ //save the attachment in a class field
1388
  input.attachment = attachment;
1389
+ //set the model
1390
  input.set(attachment.id);
1391
  },
1392
+
1393
+
1394
+
1395
+
1396
+ //////////////////////////////////////////////////
1397
+ /// HELPERS
1398
+ //////////////////////////////////////////////////
1399
  renderImageUploaderTemplate: function() {
1400
  var input = this;
1401
+
1402
+ //do we have view template script?
1403
  if ( 0 === $( '#tmpl-czr-input-img-uploader-view-content' ).length )
1404
  return;
1405
 
1406
  var view_template = wp.template('czr-input-img-uploader-view-content');
1407
+
1408
+ // //do we have an html template and a module container?
1409
  if ( ! view_template || ! input.container )
1410
  return;
1411
 
1440
  'frame_title' : _ts.frame_title_image,
1441
  'frame_button': _ts.frame_button_image
1442
  };
1443
+
1444
+ //are we fine ?
1445
  _.each( _map, function( ts_string, key ) {
1446
  if ( _.isUndefined( ts_string ) ) {
1447
  var input = this;
1454
  }
1455
  });//$.extend
1456
  })( wp.customize , jQuery, _ );/* Fix caching, select2 default one seems to not correctly work, or it doesn't what I think it should */
1457
+ // the content_picker options are set in the module with :
1458
+ // $.extend( module.inputOptions, {
1459
+ // 'content_picker' : {
1460
+ // post : '',//<= all post types
1461
+ // taxonomy : ''//<= all taxonomy types
1462
+ // }
1463
+ // });
1464
+ // To narrow down the post or taxonomy types, the option can be set this way :
1465
+ // $.extend( module.inputOptions, {
1466
+ // 'content_picker' : {
1467
+ // post : [ 'page', 'cpt1', ...]
1468
+ // taxonomy : [ 'category', 'tag', 'Custom_Tax_1', ... ]
1469
+ // }
1470
+ // });
1471
+ // To disable all posts or taxonomy, use '_none_'
1472
+ // $.extend( module.inputOptions, {
1473
+ // 'content_picker' : {
1474
+ // post : [ 'page', 'cpt1', ...]
1475
+ // taxonomy : '_none_' //<= won't load or search in taxonomies when requesting wp in ajax
1476
+ // }
1477
+ // });
1478
+ //
1479
+ // input is an object structured this way
1480
+ // {
1481
+ // id:"2838"
1482
+ // object_type:"post"
1483
+ // title:"The Importance of Water and Drinking Lots Of It"
1484
+ // type_label:"Post"
1485
+ // url:"http://customizr-dev.dev/?p=2838"
1486
+ // }
1487
  var CZRInputMths = CZRInputMths || {};
1488
  ( function ( api, $, _ ) {
1489
  $.extend( CZRInputMths , {
1492
  _event_map = [];
1493
 
1494
  /* Dummy for the prototype purpose */
1495
+ //input.object = ['post']; //this.control.params.object_types - array('page', 'post')
1496
  $.extend( {
1497
  post : '',
1498
  taxonomy : ''
1502
 
1503
  /* Methodize this or use a template */
1504
  input.container.find('.czr-input').append('<select data-select-type="content-picker-select" class="js-example-basic-simple"></select>');
1505
+
1506
+ //binding
1507
  _event_map = [
1508
+ //set input value
1509
  {
1510
  trigger : 'change',
1511
  selector : 'select[data-select-type]',
1527
  api.errorLog( 'Content Picker Input : the picked value should be an object not empty.');
1528
  return;
1529
  }
1530
+
1531
+ //normalize and purge useless select2 fields
1532
+ //=> skip a possible _custom_ id, used for example in the slider module to set a custom url
1533
  _.each( _default, function( val, k ){
1534
  if ( '_custom_' !== _raw_val.id ) {
1535
  if ( ! _.has( _raw_val, k ) || _.isEmpty( _raw_val[ k ] ) ) {
1539
  }
1540
  _val_candidate[ k ] = _raw_val[ k ];
1541
  } );
1542
+ //set the value now
1543
  input.set( _val_candidate );
1544
  }
1545
  }
1546
  ];
1547
 
1548
  input.setupDOMListeners( _event_map , { dom_el : input.container }, input );
1549
+ //setup when ready.
1550
  input.isReady.done( function() {
1551
  input.setupContentSelecter();
1552
  });
1553
 
1554
  },
1555
+
1556
+
1557
+ // input is an object structured this way
1558
+ // {
1559
+ // id:"2838"
1560
+ // object_type:"post"
1561
+ // title:"The Importance of Water and Drinking Lots Of It"
1562
+ // type_label:"Post"
1563
+ // url:"http://customizr-dev.dev/?p=2838"
1564
+ // }
1565
  setupContentSelecter : function() {
1566
  var input = this;
1567
+ //set the previously selected value
1568
  if ( ! _.isEmpty( input() ) ) {
1569
  var _attributes = {
1570
  value : input().id || '',
1571
  title : input().title || '',
1572
  selected : "selected"
1573
  };
1574
+ //input.container.find('select')
1575
  input.container.find('select').append( $( '<option>', _attributes ) );
1576
  }
1577
 
1581
  title: 'Select'
1582
  },
1583
  data : input.setupSelectedContents(),
1584
+ // allowClear: true,
1585
  ajax: {
1586
  url: serverControlParams.AjaxUrl,
1587
  type: 'POST',
1589
  delay: 250,
1590
  debug: true,
1591
  data: function ( params ) {
1592
+ //for some reason I'm not getting at the moment the params.page returned when searching is different
1593
  var page = params.page ? params.page : 0;
1594
  page = params.term ? params.page : page;
1595
  return {
1610
  return $request;
1611
  },*/
1612
  processResults: function ( data, params ) {
1613
+ //let us remotely set a default option like custom link when initializing the content picker input.
1614
  input.defaultContentPickerOption = input.defaultContentPickerOption || [];
1615
 
1616
  if ( ! data.success )
1631
  });
1632
  return {
1633
  results: _results,
1634
+ //The pagination param will trigger the infinite load
1635
  pagination: { more: data.data.items.length >= 10 }//<= the pagination boolean param can be tricky => here set to >= 10 because we query 10 + add a custom link item on the first query
1636
  };
1637
  },
1641
  escapeMarkup: function ( markup ) { return markup; },
1642
  });//select2 setup
1643
  },
1644
+
1645
+ // item is structured this way :
1646
+ // {
1647
+ // id : item.id,
1648
+ // title : item.title,
1649
+ // type_label : item.type_label,
1650
+ // object_type : item.object,
1651
+ // url : item.url
1652
+ // }
1653
  czrFormatContentSelected: function ( item ) {
1654
  if ( item.loading ) return item.text;
1655
  var markup = "<div class='content-picker-item clearfix'>" +
1678
  setupTextEditor : function() {
1679
  var input = this,
1680
  _model = input();
1681
+
1682
+ //do we have an html template and a input container?
1683
  if ( ! input.container ) {
1684
  throw new Error( 'The input container is not set for WP text editor in module.' + input.module.id );
1685
  }
1701
 
1702
  input.textpreview = input.container.find('textarea');
1703
  input.toggleButton = input.container.find('button.text_editor-button');
1704
+
1705
+ //status
1706
  input.editorExpanded = new api.Value( false );
1707
+
1708
+
1709
+ //initial filling of the textpreview and button text
1710
  input.czrUpdateTextPreview();
1711
  input.czrSetToggleButtonText( input.editorExpanded() );
1712
 
1734
  editor.focus();
1735
  }
1736
  });
1737
+
1738
+ //on this module section close close the editor and unbind this input
1739
  input.module.czr_ModuleState.bind(
1740
  function( state ) {
1741
  if ( 'expanded' != state )
1755
  $(document.body).toggleClass('czr-customize-content_editor-pane-open', expanded);
1756
  editor.locker = input;
1757
  }
1758
+
1759
+ //set toggle button text
1760
  input.czrSetToggleButtonText( expanded );
1761
 
1762
  if ( expanded ) {
1770
  editor.off( 'input change keyup', input.czrOnVisualEditorChange );
1771
  textarea.off( 'input', input.czrOnTextEditorChange );
1772
  $( window ).off('resize', input.czrResizeEditorOnWindowResize );
1773
+
1774
+ //resize reset
1775
  input.czrResizeReset();
1776
  }
1777
  } );
1798
  var input = this,
1799
  input_model = input(),
1800
  value;
1801
+
1802
+ //TODO: better stripping
1803
  value = input_model.replace(/(<([^>]+)>)/ig,"");
1804
+ //max 30 chars
1805
  if ( value.length > 30 )
1806
  value = value.substring(0, 34) + '...';
1807
 
1808
  input.textpreview.val( value );
1809
  },
1810
+ //////////////////////////////////////////////////
1811
+ /// HELPERS
1812
+ //////////////////////////////////////////////////
1813
  czrRenderInputTextEditorTemplate: function() {
1814
  var input = this;
1815
+
1816
+ //do we have view template script?
1817
  if ( 0 === $( '#tmpl-czr-input-text_editor-view-content' ).length ) {
1818
  throw new Error('Missing js template for text editor input in module : ' + input.module.id );
1819
  }
1820
 
1821
  var view_template = wp.template('czr-input-text_editor-view-content'),
1822
  $_view_el = input.container.find('input');
1823
+
1824
+ // //do we have an html template and a module container?
1825
  if ( ! view_template || ! input.container )
1826
  return;
1827
 
1950
  }
1951
  });//$.extend
1952
  })( wp.customize , jQuery, _ );//extends api.Value
1953
+ //options:
1954
+ // id : item.id,
1955
+ // initial_item_model : item,
1956
+ // defaultItemModel : module.defaultItemModel,
1957
+ // module : module,
1958
+ // is_added_by_user : is_added_by_user || false
1959
 
1960
  var CZRItemMths = CZRItemMths || {};
1961
  ( function ( api, $, _ ) {
1967
 
1968
  var item = this;
1969
  api.Value.prototype.initialize.call( item, null, options );
1970
+
1971
+ //DEFERRED STATES
1972
+ //store the state of ready.
1973
+ //=> we don't want the ready method to be fired several times
1974
  item.isReady = $.Deferred();
1975
+ //will store the embedded and content rendered state
1976
  item.embedded = $.Deferred();
1977
  item.container = null;//will store the item $ dom element
1978
  item.contentContainer = null;//will store the item content $ dom element
1979
  item.inputCollection = new api.Value({});
1980
+
1981
+ //VIEW STATES FOR ITEM AND REMOVE DIALOG
1982
+ //viewState stores the current expansion status of a given view => one value by created by item.id
1983
+ //viewState can take 3 values : expanded, expanded_noscroll (=> used on view creation), closed
1984
  item.viewState = new api.Value( 'closed' );
1985
  item.removeDialogVisible = new api.Value( false );
1986
+
1987
+ //input.options = options;
1988
+ //write the options as properties, name is included
1989
  $.extend( item, options || {} );
1990
+
1991
+ //declares a default model
1992
  item.defaultItemModel = _.clone( options.defaultItemModel ) || { id : '', title : '' };
1993
+
1994
+ //set initial values
1995
  var _initial_model = $.extend( item.defaultItemModel, options.initial_item_model );
1996
+
1997
+ //this won't be listened to at this stage
1998
  item.set( _initial_model );
1999
+
2000
+ //USER EVENT MAP
2001
  item.userEventMap = new api.Value( [
2002
+ //toggles remove view alert
2003
  {
2004
  trigger : 'click keydown',
2005
  selector : [ '.' + item.module.control.css_attr.display_alert_btn, '.' + item.module.control.css_attr.cancel_alert_btn ].join(','),
2010
  this.removeDialogVisible( ! _isVisible );
2011
  }
2012
  },
2013
+ //removes item and destroys its view
2014
  {
2015
  trigger : 'click keydown',
2016
  selector : '.' + item.module.control.css_attr.remove_view_btn,
2017
  name : 'remove_item',
2018
  actions : ['removeItem']
2019
  },
2020
+ //edit view
2021
  {
2022
  trigger : 'click keydown',
2023
  selector : [ '.' + item.module.control.css_attr.edit_view_btn, '.' + item.module.control.css_attr.item_title ].join(','),
2024
  name : 'edit_view',
2025
  actions : [ 'setViewVisibility' ]
2026
  },
2027
+ //tabs navigation
2028
  {
2029
  trigger : 'click keydown',
2030
  selector : '.tabs nav li',
2031
  name : 'tab_nav',
2032
  actions : function( args ) {
2033
+ //toggleTabVisibility is defined in the module ctor and its this is the item or the modOpt
2034
  this.module.toggleTabVisibility.call( this, args );
2035
  }
2036
  }
2037
  ]);
2038
+
2039
+
2040
+
2041
+
2042
+ //ITEM IS READY
2043
+ //1) push it to the module item collection
2044
+ //2) observe its changes
2045
  item.isReady.done( function() {
2046
+ //push it to the collection
2047
  item.module.updateItemsCollection( { item : item() } );
2048
+ //listen to each single item change
2049
  item.callbacks.add( function() { return item.itemReact.apply(item, arguments ); } );
2050
+
2051
+ //SCHEDULE INPUTS SETUP
2052
+ //=> when the item content has been rendered. Typically on item expansion for a multi-items module.
2053
+ // => or for mono item, right on item.renderItemWrapper()
2054
  item.bind( 'contentRendered', function() {
2055
+ //create the collection of inputs if needed
2056
+ //first time or after a removal
2057
  if ( ! _.has( item, 'czr_Input' ) || _.isEmpty( item.inputCollection() ) ) {
2058
  try {
2059
  api.CZR_Helpers.setupInputCollectionFromDOM.call( item );
2060
+ //the item.container is now available
2061
+ //Setup the tabs navigation
2062
+ //setupTabNav is defined in the module ctor and its this is the item or the modOpt
2063
  item.module.setupTabNav.call( item );
2064
  } catch( er ) {
2065
  api.errorLog( 'In item.isReady.done : ' + er );
2066
  }
2067
  }
2068
  });
2069
+
2070
+ //SCHEDULE INPUTS DESTROY
2071
  item.bind( 'contentRemoved', function() {
2072
  if ( _.has(item, 'czr_Input') )
2073
  api.CZR_Helpers.removeInputCollection.call( item );
2074
  });
2075
+
2076
+ //When shall we render the item ?
2077
+ //If the module is part of a simple control, the item can be render now,
2078
+ //If the module is part of a sektion, then the item will be rendered on module edit.
2079
+ // if ( ! item.module.isInSektion() ) {
2080
+ // item.mayBeRenderItemWrapper();
2081
+ // }
2082
  item.mayBeRenderItemWrapper();
2083
+
2084
+ //ITEM WRAPPER VIEW SETUP
2085
+ //defer actions on item view embedded
2086
  item.embedded.done( function() {
2087
+ //define the item view DOM event map
2088
+ //bind actions when the item is embedded : item title, etc.
2089
  item.itemWrapperViewSetup( _initial_model );
2090
  });
2091
  });//item.isReady.done()
2092
 
2093
+ //if an item is manually added : open it
2094
+ // if ( item.is_added_by_user ) {
2095
+ // item.setViewVisibility( {}, true );//empty obj because this method can be fired by the dom chain actions, always passing an object. true for added_by_user
2096
+ // }
2097
+ //item.setViewVisibility( {}, item.is_added_by_user );
2098
+
2099
  },//initialize
2100
+
2101
+ //overridable method
2102
+ //Fired if the item has been instantiated
2103
+ //The item.callbacks are declared.
2104
  ready : function() {
2105
  this.isReady.resolve();
2106
  },
2107
+
2108
+
2109
+ //React to a single item change
2110
+ //cb of module.czr_Item( item.id ).callbacks
2111
+ //the data can typically hold informations passed by the input that has been changed and its specific preview transport (can be PostMessage )
2112
+ //data looks like :
2113
+ //{
2114
+ // module : {}
2115
+ // input_changed : string input.id
2116
+ // input_transport : 'postMessage' or '',
2117
+ // not_preview_sent : bool
2118
+ //}
2119
  itemReact : function( to, from, data ) {
2120
  var item = this,
2121
  module = item.module;
2122
 
2123
  data = data || {};
2124
+
2125
+ //update the collection
2126
  module.updateItemsCollection( { item : to, data : data } ).done( function() {
2127
+ //Always update the view title when the item collection has been updated
2128
  item.writeItemViewTitle( to, data );
2129
  });
2130
+
2131
+ //send item to the preview. On update only, not on creation.
2132
+ // if ( ! _.isEmpty(from) || ! _.isUndefined(from) ) {
2133
+ // api.consoleLog('DO WE REALLY NEED TO SEND THIS TO THE PREVIEW WITH _sendItem(to, from) ?');
2134
+ // item._sendItem(to, from);
2135
+ // }
2136
  }
2137
  });//$.extend
2138
  })( wp.customize , jQuery, _ );//extends api.CZRBaseControl
2140
  var CZRItemMths = CZRItemMths || {};
2141
  ( function ( api, $, _ ) {
2142
  $.extend( CZRItemMths , {
2143
+ //The idea is to send only the currently modified item instead of the entire collection
2144
+ //the entire collection is sent anyway on api(setId).set( value ), and accessible in the preview via api(setId).bind( fn( to) )
2145
  _sendItem : function( to, from ) {
2146
  var item = this,
2147
  module = item.module,
2148
  _changed_props = [];
2149
+
2150
+ //which property(ies) has(ve) changed ?
2151
  _.each( from, function( _val, _key ) {
2152
  if ( _val != to[_key] )
2153
  _changed_props.push(_key);
2154
  });
2155
 
2156
  _.each( _changed_props, function( _prop ) {
2157
+ api.previewer.send( 'sub_setting', {
2158
  set_id : module.control.id,
2159
  id : to.id,
2160
  changed_prop : _prop,
2161
  value : to[_prop]
2162
  });
2163
+
2164
+ //add a hook here
2165
  module.trigger('item_sent', { item : to , dom_el: item.container, changed_prop : _prop } );
2166
  });
2167
  },
2168
+
2169
+ //fired on click dom event
2170
+ //for dynamic multi input modules
2171
  removeItem : function() {
2172
  var item = this,
2173
  module = this.module,
2174
  _new_collection = _.clone( module.itemCollection() );
2175
+
2176
+ //hook here
2177
  module.trigger('pre_item_dom_remove', item() );
2178
+
2179
+ //destroy the Item DOM el
2180
  item._destroyView();
2181
+
2182
+ //new collection
2183
+ //say it
2184
  _new_collection = _.without( _new_collection, _.findWhere( _new_collection, {id: item.id }) );
2185
  module.itemCollection.set( _new_collection );
2186
+ //hook here
2187
  module.trigger('pre_item_api_remove', item() );
2188
 
2189
  var _item_ = $.extend( true, {}, item() );
2190
+ //remove the item from the collection
2191
  module.czr_Item.remove( item.id );
2192
  module.trigger( 'item-removed', _item_ );
2193
  },
2194
+
2195
+ //@return the item {...} from the collection
2196
+ //takes a item unique id as param
2197
  getModel : function(id) {
2198
  return this();
2199
  }
2200
 
2201
  });//$.extend
2202
  })( wp.customize , jQuery, _ );
2203
+ //extends api.CZRBaseControl
2204
  var CZRItemMths = CZRItemMths || {};
2205
  ( function ( api, $, _ ) {
2206
  $.extend( CZRItemMths , {
2207
+ //fired on initialize for items in module embedded in a regular control
2208
+ //fired when user edit module for items in modules embedded in a sektion
2209
  mayBeRenderItemWrapper : function() {
2210
  var item = this;
2211
 
2217
  if ( _.isUndefined(item.container) || ! item.container.length ) {
2218
  throw new Error( 'In mayBeRenderItemWrapper the Item view has not been rendered : ' + item.id );
2219
  } else {
2220
+ //say it
2221
  item.embedded.resolve();
2222
  }
2223
  });
2224
  },
2225
+
2226
+
2227
+ //fired when item is ready and embedded
2228
+ //define the item view DOM event map
2229
+ //bind actions when the item is embedded
2230
  itemWrapperViewSetup : function( item_model ) {
2231
  var item = this,
2232
  module = this.module;
2233
 
2234
  item_model = item() || item.initial_item_model;//could not be set yet
2235
+
2236
+ //always write the title
2237
  item.writeItemViewTitle();
2238
+
2239
+
2240
+ //When do we render the item content ?
2241
+ //If this is a multi-item module, let's render each item content when they are expanded.
2242
+ //In the case of a single item module, we can render the item content now.
2243
  var _updateItemContentDeferred = function( $_content, to, from ) {
2244
+ //update the $.Deferred state
2245
  if ( ! _.isUndefined( $_content ) && false !== $_content.length ) {
2246
  item.trigger( 'contentRendered' );
2247
  item.contentContainer = $_content;
2254
 
2255
  if ( item.module.isMultiItem() ) {
2256
  item.viewState.callbacks.add( function( to, from ) {
2257
+ //viewState can take 3 states : expanded, expanded_noscroll, closed
2258
  var _isExpanded = -1 !== to.indexOf( 'expanded' );
2259
+
2260
+ //If this module has mod Opt, always close the opt pane on view state change
2261
  if ( module.hasModOpt() && _isExpanded ) {
2262
  api.czr_ModOptVisible( false );
2263
  }
2264
 
2265
  if ( _isExpanded ) {
2266
+ //item already rendered ?
2267
  if ( _.isObject( item.contentContainer ) && false !== item.contentContainer.length ) {
2268
+ //toggle on view state change
2269
  item.toggleItemExpansion(to, from );
2270
  } else {
2271
  $.when( item.renderItemContent( item() || item.initial_item_model ) ).done( function( $_item_content ) {
2272
+ //introduce a small delay to give some times to the modules to be printed.
2273
+ //@todo : needed ?
2274
  _updateItemContentDeferred = _.debounce(_updateItemContentDeferred, 50 );
2275
  _updateItemContentDeferred( $_item_content, to, from );
2276
  });
2277
  }
2278
  } else {
2279
+ //toggle on view state change
2280
  item.toggleItemExpansion( to, from ).done( function() {
2281
  if ( _.isObject( item.contentContainer ) && false !== item.contentContainer.length ) {
2282
  item.trigger( 'beforeContenRemoved' );
2283
+ //Removes DOM input nodes
2284
  $( '.' + module.control.css_attr.item_content, item.container ).children().each( function() {
2285
  $(this).remove();
2286
  });
2287
+ //clean any other content like a commented html markup
2288
  $( '.' + module.control.css_attr.item_content, item.container ).html('');
2289
+ //reset the contentContainer property
2290
  item.contentContainer = null;
2291
+ //will remove the input collection values
2292
  item.trigger( 'contentRemoved' );
2293
  }
2294
  });
2295
  }
2296
  });
2297
  } else {
2298
+ //react to the item state changes
2299
  item.viewState.callbacks.add( function( to, from ) {
2300
+ //toggle on view state change
2301
  item.toggleItemExpansion.apply(item, arguments );
2302
  });
2303
+
2304
+ //renderview content now for a single item module
2305
  $.when( item.renderItemContent( item_model ) ).done( function( $_item_content ) {
2306
  _updateItemContentDeferred( $_item_content, true );
2307
+ //item.viewState.set('expanded');
2308
  });
2309
  }
2310
+
2311
+ //DOM listeners for the user action in item view wrapper
2312
  api.CZR_Helpers.setupDOMListeners(
2313
  item.userEventMap(),//actions to execute
2314
  { model:item_model, dom_el:item.container },//model + dom scope
2315
  item //instance where to look for the cb methods
2316
  );
2317
+
2318
+ //Listen to the remove dialog state
2319
  item.removeDialogVisible.bind( function( visible ) {
2320
  var module = item.module,
2321
  $_alert_el = $( '.' + module.control.css_attr.remove_alert_wrapper, item.container ).first();
2322
+
2323
+ //first close all open items views and dialogs
2324
  if ( visible )
2325
  module.closeAllItems();
2326
+
2327
+ //Close Mod opts if any
2328
  if ( visible && module.hasModOpt() ) {
2329
  api.czr_ModOptVisible( false );
2330
  }
2331
+
2332
+ //Close Pre item dialog
2333
  if ( visible && _.has( module, 'preItem' ) ) {
2334
  module.preItemExpanded(false);
2335
  }
2336
+
2337
+ //then close any other open remove dialog in the item container
2338
  $('.' + module.control.css_attr.remove_alert_wrapper, item.container ).not( $_alert_el ).each( function() {
2339
  if ( $(this).hasClass( 'open' ) ) {
2340
  $(this).slideToggle( {
2341
  duration : 200,
2342
  done : function() {
2343
  $(this).toggleClass('open' , false );
2344
+ //deactivate the icons
2345
  $(this).siblings().find('.' + module.control.css_attr.display_alert_btn).toggleClass( 'active' , false );
2346
  }
2347
  } );
2348
  }
2349
  });
2350
+
2351
+ //print the html if dialod is expanded
2352
  if ( visible ) {
2353
+ //do we have an html template and a control container?
2354
  if ( ! wp.template( module.AlertPart ) || ! item.container ) {
2355
  api.consoleLog( 'No removal alert template available for items in module :' + module.id );
2356
  return;
2358
 
2359
  $_alert_el.html( wp.template( module.AlertPart )( { title : ( item().title || item.id ) } ) );
2360
  }
2361
+
2362
+ //Slide it
2363
  var _slideComplete = function( visible ) {
2364
  $_alert_el.toggleClass( 'open' , visible );
2365
+ //set the active class of the clicked icon
2366
  item.container.find('.' + module.control.css_attr.display_alert_btn ).toggleClass( 'active', visible );
2367
+ //adjust scrolling to display the entire dialog block
2368
  if ( visible )
2369
  module._adjustScrollExpandedBlock( item.container );
2370
  };
2374
  $_alert_el.stop( true, true ).slideUp( 200, function() { _slideComplete( visible ); } );
2375
  });//item.removeDialogVisible.bind()
2376
  },//itemWrapperViewSetup
2377
+
2378
+
2379
+ //the view wrapper has been rendered by WP
2380
+ //the content ( the various inputs ) is rendered by the following methods
2381
+ //an event is triggered on the control.container when content is rendered
2382
  renderItemWrapper : function( item_model ) {
2383
+ //=> an array of objects
2384
  var item = this,
2385
  module = item.module;
2386
 
2387
  item_model = item_model || item();
2388
+
2389
+ //render the item wrapper
2390
  $_view_el = $('<li>', { class : module.control.css_attr.single_item, 'data-id' : item_model.id, id : item_model.id } );
2391
+
2392
+ //append the item view to the first module view wrapper
2393
+ //!!note : => there could be additional sub view wrapper inside !!
2394
+ //$( '.' + module.control.css_attr.items_wrapper , module.container).first().append( $_view_el );
2395
+ // module.itemsWrapper has been stored as a $ var in module initialize() when the tmpl has been embedded
2396
  module.itemsWrapper.append( $_view_el );
2397
+
2398
+ //if module is multi item, then render the item crud header part
2399
+ //Note : for the widget module, the getTemplateEl method is overridden
2400
  if ( module.isMultiItem() ) {
2401
  var _template_selector = module.getTemplateEl( 'rudItemPart', item_model );
2402
+ //do we have view template script?
2403
  if ( 0 === $( '#tmpl-' + _template_selector ).length ) {
2404
  throw new Error('Missing template for item ' + item.id + '. The provided template script has no been found : #tmpl-' + module.getTemplateEl( 'rudItemPart', item_model ) );
2405
  }
2406
  $_view_el.append( $( wp.template( _template_selector )( item_model ) ) );
2407
  }
2408
+
2409
+
2410
+ //then, append the item content wrapper
2411
  $_view_el.append( $( '<div/>', { class: module.control.css_attr.item_content } ) );
2412
 
2413
  return $_view_el;
2414
  },
2415
+
2416
+
2417
+ //renders saved items views and attach event handlers
2418
+ //the saved item look like :
2419
+ //array[ { id : 'sidebar-one', title : 'A Title One' }, {id : 'sidebar-two', title : 'A Title Two' }]
2420
  renderItemContent : function( item_model ) {
2421
+ //=> an array of objects
2422
  var item = this,
2423
  module = this.module;
2424
 
2425
  item_model = item_model || item();
2426
+
2427
+ //do we have view content template script?
2428
  if ( 0 === $( '#tmpl-' + module.getTemplateEl( 'itemInputList', item_model ) ).length ) {
2429
  throw new Error('No item content template defined for module ' + module.id + '. The template script id should be : #tmpl-' + module.getTemplateEl( 'itemInputList', item_model ) );
2430
  }
2431
 
2432
  var item_content_template = wp.template( module.getTemplateEl( 'itemInputList', item_model ) );
2433
+
2434
+ //do we have an html template ?
2435
  if ( ! item_content_template )
2436
  return this;
2437
+
2438
+ //the view content
2439
  $( item_content_template( item_model )).appendTo( $('.' + module.control.css_attr.item_content, item.container ) );
2440
 
2441
  return $( $( item_content_template( item_model )), item.container );
2442
  },
2443
+
2444
+
2445
+
2446
+
2447
+
2448
+ //fired in setupItemListeners
2449
  writeItemViewTitle : function( item_model ) {
2450
  var item = this,
2451
  module = item.module,
2454
 
2455
  _title = api.CZR_Helpers.truncate( _title, 20 );
2456
  $( '.' + module.control.css_attr.item_title , item.container ).text( _title );
2457
+ //add a hook here
2458
  api.CZR_Helpers.doActions('after_writeViewTitle', item.container , _model, item );
2459
  },
2460
+
2461
+
2462
+
2463
+ //@param : obj = { event : {}, model : {}, view : ${} }
2464
+ //Fired on view_rendered:new when a new model has been added
2465
+ //Fired on click on edit_view_btn
2466
  setViewVisibility : function( obj, is_added_by_user ) {
2467
  var item = this,
2468
  module = this.module;
2481
  _getViewState : function() {
2482
  return -1 == this.viewState().indexOf('expanded') ? 'closed' : 'expanded';
2483
  },
2484
+
2485
+
2486
+ //callback of item.viewState.callbacks
2487
+ //viewState can take 3 states : expanded, expanded_noscroll, closed
2488
  toggleItemExpansion : function( status, from, duration ) {
2489
  var visible = 'closed' != status,
2490
  item = this,
2493
  dfd = $.Deferred(),
2494
  _slideComplete = function( visible ) {
2495
  item.container.toggleClass( 'open' , visible );
2496
+ //close all remove dialogs
2497
  if ( visible )
2498
  module.closeRemoveDialogs();
2499
+
2500
+ //toggle the icon activate class depending on the status
2501
+ //switch icon
2502
  var $_edit_icon = $el.siblings().find('.' + module.control.css_attr.edit_view_btn );
2503
 
2504
  $_edit_icon.toggleClass('active' , visible );
2506
  $_edit_icon.removeClass('fa-pencil').addClass('fa-minus-square').attr('title', serverControlParams.i18n.close );
2507
  else
2508
  $_edit_icon.removeClass('fa-minus-square').addClass('fa-pencil').attr('title', serverControlParams.i18n.edit );
2509
+
2510
+ //scroll to the currently expanded view
2511
  if ( 'expanded' == status )
2512
  module._adjustScrollExpandedBlock( item.container );
2513
 
2521
 
2522
  return dfd.promise();
2523
  },
2524
+
2525
+
2526
+ //removes the view dom module
2527
  _destroyView : function ( duration ) {
2528
  this.container.fadeOut( {
2529
  duration : duration ||400,
2534
  }
2535
  });//$.extend
2536
  })( wp.customize , jQuery, _ );//extends api.Value
2537
+ //options:
2538
+ // module : module,
2539
+ // initial_modOpt_model : modOpt, can contains the already db saved values
2540
+ // defaultModOptModel : module.defaultModOptModel
2541
+ // control : control instance
2542
 
2543
  var CZRModOptMths = CZRModOptMths || {};
2544
  ( function ( api, $, _ ) {
2550
 
2551
  var modOpt = this;
2552
  api.Value.prototype.initialize.call( modOpt, null, options );
2553
+
2554
+ //DEFERRED STATES
2555
+ //store the state of ready.
2556
+ //=> we don't want the ready method to be fired several times
2557
  modOpt.isReady = $.Deferred();
2558
+
2559
+ //VARIOUS DEFINITIONS
2560
  modOpt.container = null;//will store the modOpt $ dom element
2561
  modOpt.inputCollection = new api.Value({});
2562
+
2563
+ //input.options = options;
2564
+ //write the options as properties, name is included
2565
  $.extend( modOpt, options || {} );
2566
+
2567
+ //declares a default modOpt model
2568
  modOpt.defaultModOptModel = _.clone( options.defaultModOptModel ) || { is_mod_opt : true };
2569
+
2570
+ //set initial values
2571
  var _initial_model = $.extend( modOpt.defaultModOptModel, options.initial_modOpt_model );
2572
  var ctrl = modOpt.module.control;
2573
+ //this won't be listened to at this stage
2574
  modOpt.set( _initial_model );
2575
+
2576
+ //MOD OPT PANEL SETTINGS
2577
  api.czr_ModOptVisible = new api.Value( false );
2578
+
2579
+ //MOD OPT VISIBLE REACT
2580
+ // passing an optional args object allows us to expand the modopt panel and focus on a specific tab right after
2581
+ //@args : {
2582
+ // module : module,//the current module for which the modOpt is being expanded
2583
+ // focus : 'section-topline-2'//the id of the tab we want to focus on
2584
+ //}
2585
  api.czr_ModOptVisible.bind( function( visible, from, args ) {
2586
  args = args || {};
2587
  if ( visible ) {
2588
+ //first close all opened remove dialogs and opened items
2589
  modOpt.module.closeRemoveDialogs().closeAllItems();
2590
 
2591
  modOpt.modOptWrapperViewSetup( _initial_model ).done( function( $_container ) {
2617
  });
2618
  }
2619
  } );
2620
+
2621
+ //OPTIONS IS READY
2622
+ //observe its changes when ready
2623
  modOpt.isReady.done( function() {
2624
+ //listen to any modOpt change
2625
+ //=> done in the module
2626
+ //modOpt.callbacks.add( function() { return modOpt.modOptReact.apply(modOpt, arguments ); } );
2627
+
2628
+ //When shall we render the modOpt ?
2629
+ //If the module is part of a simple control, the modOpt can be render now,
2630
+ //modOpt.mayBeRenderModOptWrapper();
2631
+
2632
+ //RENDER THE CONTROL TITLE GEAR ICON
2633
  if( ! $( '.' + ctrl.css_attr.edit_modopt_icon, ctrl.container ).length ) {
2634
  $.when( ctrl.container
2635
  .find('.customize-control-title').first()//was.find('.customize-control-title')
2641
  $( '.' + ctrl.css_attr.edit_modopt_icon, ctrl.container ).fadeIn( 400 );
2642
  });
2643
  }
2644
+
2645
+ //LISTEN TO USER ACTIONS ON CONTROL EL
2646
  api.CZR_Helpers.setupDOMListeners(
2647
  [
2648
+ //toggle mod options
2649
  {
2650
  trigger : 'click keydown',
2651
  selector : '.' + ctrl.css_attr.edit_modopt_icon,
2658
  { dom_el: ctrl.container },//dom scope
2659
  modOpt //instance where to look for the cb methods
2660
  );
2661
+ //modOpt.userEventMap = new api.Value( [] );
2662
  });//modOpt.isReady.done()
2663
 
2664
  },//initialize
2665
+
2666
+ //overridable method
2667
+ //Fired if the modOpt has been instantiated
2668
+ //The modOpt.callbacks are declared.
2669
  ready : function() {
2670
  this.isReady.resolve();
2671
  }
2675
  var CZRModOptMths = CZRModOptMths || {};
2676
  ( function ( api, $, _ ) {
2677
  $.extend( CZRModOptMths , {
2678
+ //fired when modOpt is ready and embedded
2679
+ //define the modOpt view DOM event map
2680
+ //bind actions when the modOpt is embedded
2681
  modOptWrapperViewSetup : function( modOpt_model ) {
2682
  var modOpt = this,
2683
  module = this.module,
2684
  dfd = $.Deferred(),
2685
  _setupDOMListeners = function( $_container ) {
2686
+ //DOM listeners for the user action in modOpt view wrapper
2687
  api.CZR_Helpers.setupDOMListeners(
2688
  [
2689
+ //toggle mod options
2690
  {
2691
  trigger : 'click keydown',
2692
  selector : '.' + module.control.css_attr.close_modopt_icon,
2695
  api.czr_ModOptVisible( false );
2696
  }
2697
  },
2698
+ //tabs navigation
2699
  {
2700
  trigger : 'click keydown',
2701
  selector : '.tabs nav li',
2702
  name : 'tab_nav',
2703
  actions : function( args ) {
2704
+ //toggleTabVisibility is defined in the module ctor and its this is the item or the modOpt
2705
  this.module.toggleTabVisibility.call( this, args );
2706
  }
2707
  }
2712
  };
2713
 
2714
  modOpt_model = modOpt() || modOpt.initial_modOpt_model;//could not be set yet
2715
+
2716
+ //renderview content now
2717
  $.when( modOpt.renderModOptContent( modOpt_model ) )
2718
  .done( function( $_container ) {
2719
+ //update the $.Deferred state
2720
  if ( ! _.isUndefined( $_container ) && false !== $_container.length ) {
2721
  _setupDOMListeners( $_container );
2722
  dfd.resolve( $_container );
2726
  }
2727
  })
2728
  .then( function() {
2729
+ //the modOpt.container is now available
2730
+ //Setup the tabs navigation
2731
+ //setupTabNav is defined in the module ctor and its this is the item or the modOpt
2732
  modOpt.module.setupTabNav.call( modOpt );
2733
  });
2734
 
2735
  return dfd.promise();
2736
  },
2737
+
2738
+
2739
+ //renders saved modOpt views and attach event handlers
2740
+ //the saved modOpt look like :
2741
+ //array[ { id : 'sidebar-one', title : 'A Title One' }, {id : 'sidebar-two', title : 'A Title Two' }]
2742
  renderModOptContent : function( modOpt_model ) {
2743
+ //=> an array of objects
2744
  var modOpt = this,
2745
  module = this.module;
2746
 
2747
  modOpt_model = modOpt_model || modOpt();
2748
+
2749
+ //do we have view content template script?
2750
  if ( 0 === $( '#tmpl-' + module.getTemplateEl( 'modOptInputList', modOpt_model ) ).length ) {
2751
  api.errorLog('renderModOptContent : No modOpt content template defined for module ' + module.id + '. The template script id should be : #tmpl-' + module.getTemplateEl( 'modOptInputList', modOpt_model ) );
2752
  return;
2753
  }
2754
  var modOpt_content_template = wp.template( module.getTemplateEl( 'modOptInputList', modOpt_model ) );
2755
+
2756
+ //do we have an html template ?
2757
  if ( ! modOpt_content_template )
2758
  return this;
2759
 
2772
  '<span class="fa fa-times ' + module.control.css_attr.close_modopt_icon + '" title="close"></span>'
2773
  ].join('')
2774
  } ) );
2775
+
2776
+ //render the mod opt content for this module
2777
  $( '.' + module.control.css_attr.mod_opt_wrapper ).append( $( modOpt_content_template( modOpt_model ) ) );
2778
 
2779
  return $( '.' + module.control.css_attr.mod_opt_wrapper );
2789
 
2790
  module.control.container.toggleClass( 'czr-modopt-visible', visible );
2791
  $('body').toggleClass('czr-editing-modopt', visible );
2792
+ //Let the panel slide ( -webkit-transition: left .18s ease-in-out )
2793
  _.delay( function() {
2794
  dfd.resolve();
2795
  }, 200 );
2797
  }
2798
  });//$.extend
2799
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
2800
+ //extends api.Value
2801
+ //
2802
+ //Setup the collection of items
2803
+ //renders the control view
2804
+ //Listen to items collection changes and update the control setting
2805
+ //MODULE OPTIONS :
2806
+ // control : control,
2807
+ // crud : bool
2808
+ // id : '',
2809
+ // items : [], module.items,
2810
+ // modOpt : {}
2811
+ // module_type : module.module_type,
2812
+ // multi_item : bool
2813
+ // section : module.section,
2814
+ // is_added_by_user : is_added_by_user || false
2815
  var CZRModuleMths = CZRModuleMths || {};
2816
  ( function ( api, $, _ ) {
2817
  $.extend( CZRModuleMths, {
2821
  }
2822
  var module = this;
2823
  api.Value.prototype.initialize.call( this, null, constructorOptions );
2824
+
2825
+ //store the state of ready.
2826
+ //=> we don't want the ready method to be fired several times
2827
  module.isReady = $.Deferred();
2828
+
2829
+ //write the options as properties
2830
  $.extend( module, constructorOptions || {} );
2831
+
2832
+ //extend the module with new template Selectors
2833
  $.extend( module, {
2834
  crudModulePart : 'czr-crud-module-part',//create, read, update, delete
2835
  rudItemPart : 'czr-rud-item-part',//read, update, delete
2839
  AlertPart : 'czr-rud-item-alert-part',//used both for items and modules removal
2840
 
2841
  } );
2842
+
2843
+ //embed : define a container, store the embed state, fire the render method
2844
  module.embedded = $.Deferred();
2845
  module.itemsWrapper = '';//will store the $ item container
2846
+
2847
+ //if a module is embedded in a control, its container == the control container.
2848
+ //if the module is part of a sektion, its container will be set and resolve() later ( @see multi_module part )
2849
  if ( ! module.isInSektion() ) {
2850
  module.container = $( module.control.selector );
2851
  module.embedded.resolve();
2852
  }
2853
+
2854
+ //render the item(s) wrapper
2855
  module.embedded.done( function() {
2856
  $.when( module.renderModuleParts() ).done(function( $_module_items_wrapper ){
2857
  if ( false === $_module_items_wrapper.length ) {
2858
  throw new Error( 'The items wrapper has not been rendered for module : ' + module.id );
2859
  }
2860
+ //stores the items wrapper ( </ul> el ) as a jQuery var
2861
  module.itemsWrapper = $_module_items_wrapper;
2862
  });
2863
  });
2865
  /*-----------------------------------------------
2866
  * MODULE OPTIONS
2867
  ------------------------------------------------*/
2868
+ //declares a default Mod options API model
2869
  module.defaultAPImodOptModel = {
2870
  initial_modOpt_model : {},
2871
  defaultModOptModel : {},
2872
  control : {},//control instance
2873
  module : {}//module instance
2874
  };
2875
+
2876
+ //declares a default modOpt model
2877
  module.defaultModOptModel = {};
2878
+
2879
+ //define a default Constructors
2880
  module.modOptConstructor = api.CZRModOpt;
2881
 
2882
  /*-----------------------------------------------
2883
  * ITEMS
2884
  ------------------------------------------------*/
2885
  module.itemCollection = new api.Value( [] );
2886
+
2887
+ //declares a default Item API model
2888
  module.defaultAPIitemModel = {
2889
  id : '',
2890
  initial_item_model : {},
2893
  module : {},//module instance
2894
  is_added_by_user : false
2895
  };
2896
+
2897
+ //declares a default item model
2898
  module.defaultItemModel = { id : '', title : '' };
2899
+
2900
+ //define a default Constructors
2901
  module.itemConstructor = api.CZRItem;
2902
+ //czr_model stores the each model value => one value by created by model.id
2903
  module.czr_Item = new api.Values();
2904
 
2905
 
2911
  module.inputModOptConstructor = api.CZRInput;//constructor for the modOpt input
2912
  }
2913
  module.inputOptions = {};//<= can be set by each module specifically
2914
+ //For example, if I need specific options for the content_picker, this is where I will set them in the module extended object
2915
 
2916
 
2917
  /*-----------------------------------------------
2918
  * FIRE ON isReady
2919
  ------------------------------------------------*/
2920
+ //module.ready(); => fired by children
2921
  module.isReady.done( function() {
2922
+ //store the module dirtyness, => no items set
2923
  module.isDirty = new api.Value( constructorOptions.dirty || false );
2924
+
2925
+ //initialize the module api.Value()
2926
+ //constructorOptions has the same structure as the one described in prepareModuleforAPI
2927
+ //setting the module Value won't be listen to at this stage
2928
  module.initializeModuleModel( constructorOptions )
2929
  .done( function( initialModuleValue ) {
2930
  module.set( initialModuleValue );
2931
  })
2932
  .fail( function( response ){ api.consoleLog( 'Module : ' + module.id + ' initialize module model failed : ', response ); })
2933
  .always( function( initialModuleValue ) {
2934
+ //listen to each single module change
2935
  module.callbacks.add( function() { return module.moduleReact.apply( module, arguments ); } );
2936
+
2937
+ //if the module is not registered yet (for example when the module is added by user),
2938
+ //=> push it to the collection of the module-collection control
2939
+ //=> updates the wp api setting
2940
  if ( ! module.control.isModuleRegistered( module.id ) ) {
2941
  module.control.updateModulesCollection( { module : constructorOptions, is_registered : false } );
2942
  }
2943
 
2944
  module.bind('items-collection-populated', function( collection ) {
2945
+ //listen to item Collection changes
2946
  module.itemCollection.callbacks.add( function() { return module.itemCollectionReact.apply( module, arguments ); } );
2947
+
2948
+ //it can be overridden by a module in its initialize method
2949
  if ( module.isMultiItem() ) {
2950
  module._makeItemsSortable();
2951
  }
2952
  });
2953
+
2954
+ //populate and instantiate the items now when a module is embedded in a regular control
2955
+ //if in a sektion, the populateSavedItemCollection() will be fired on module edit
2956
  if ( ! module.isInSektion() )
2957
  module.populateSavedItemCollection();
2958
+
2959
+ //When the module has modOpt :
2960
+ //=> Instantiate the modOpt and setup listener
2961
  if ( module.hasModOpt() ) {
2962
  module.instantiateModOpt();
2963
  }
2964
  });
2965
  });//module.isReady.done()
2966
  },
2967
+
2968
+
2969
+
2970
+
2971
+ //////////////////////////////////
2972
+ ///READY
2973
+ //////////////////////////////////
2974
+ //When the control is embedded on the page, this method is fired in api.CZRBaseModuleControl:ready()
2975
+ //=> right after the module is instantiated.
2976
+ //If the module is a dynamic one (CRUD like), then this method is invoked by the child class
2977
  ready : function() {
2978
  var module = this;
2979
  module.isReady.resolve();
2980
  },
2981
+
2982
+
2983
+
2984
+ //fired when module is initialized, on module.isReady.done()
2985
+ //designed to be extended or overridden to add specific items or properties
2986
  initializeModuleModel : function( constructorOptions ) {
2987
  var module = this, dfd = $.Deferred();
2988
  if ( ! module.isMultiItem() && ! module.isCrud() ) {
2989
+ //this is a static module. We only have one item
2990
+ //init module item if needed.
2991
  if ( _.isEmpty( constructorOptions.items ) ) {
2992
  var def = _.clone( module.defaultItemModel );
2993
  constructorOptions.items = [ $.extend( def, { id : module.id } ) ];
2995
  }
2996
  return dfd.resolve( constructorOptions ).promise();
2997
  },
2998
+
2999
+
3000
+ //cb of : module.itemCollection.callbacks
3001
+ //the data can typically hold informations passed by the input that has been changed and its specific preview transport (can be PostMessage )
3002
+ //data looks like :
3003
+ //{
3004
+ // module : {}
3005
+ // input_changed : string input.id
3006
+ // input_transport : 'postMessage' or '',
3007
+ // not_preview_sent : bool
3008
+ //}
3009
  itemCollectionReact : function( to, from, data ) {
3010
  var module = this,
3011
  _current_model = module(),
3012
  _new_model = $.extend( true, {}, _current_model );
3013
  _new_model.items = to;
3014
+ //update the dirtyness state
3015
  module.isDirty.set(true);
3016
+ //set the the new items model
3017
  module.set( _new_model, data || {} );
3018
  },
3019
+
3020
+
3021
+ //cb of module.callbacks
3022
  moduleReact : function( to, from, data ) {
3023
+ //cb of : module.callbacks
3024
  var module = this,
3025
  control = module.control,
3026
  isItemUpdate = ( _.size( from.items ) == _.size( to.items ) ) && ! _.isEmpty( _.difference( to.items, from.items ) ),
3027
  isColumnUpdate = to.column_id != from.column_id,
3028
  refreshPreview = function() {
3029
+ api.previewer.refresh();
3030
  };
3031
+
3032
+ //update the collection + pass data
3033
  control.updateModulesCollection( {
3034
  module : $.extend( true, {}, to ),
3035
  data : data//useful to pass contextual info when a change happens
3036
  } );
3037
+
3038
+ // //Always update the view title
3039
+ // module.writeViewTitle(to);
3040
+
3041
+ // //@todo : do we need that ?
3042
+ // //send module to the preview. On update only, not on creation.
3043
+ // if ( ! _.isEmpty(from) || ! _.isUndefined(from) ) {
3044
+ // module._sendModule(to, from);
3045
+ // }
3046
  },
3047
+
3048
+ //@todo : create a smart helper to get either the wp api section or the czr api sektion, depending on the module context
3049
  getModuleSection : function() {
3050
  return this.section;
3051
  },
3052
+
3053
+ //@return bool
3054
  isInSektion : function() {
3055
  var module = this;
3056
  return _.has( module, 'sektion_id' );
3057
  },
3058
+
3059
+ //is this module multi item ?
3060
+ //@return bool
3061
  isMultiItem : function() {
3062
  return api.CZR_Helpers.isMultiItemModule( null, this );
3063
  },
3064
+
3065
+ //is this module crud ?
3066
+ //@return bool
3067
  isCrud : function() {
3068
  return api.CZR_Helpers.isCrudModule( null, this );
3069
  },
3071
  hasModOpt : function() {
3072
  return api.CZR_Helpers.hasModuleModOpt( null, this );
3073
  },
3074
+
3075
+
3076
+ //////////////////////////////////
3077
+ ///MODULE OPTION :
3078
+ ///1) PREPARE
3079
+ ///2) INSTANTIATE
3080
+ ///3) LISTEN TO AND SET PARENT MODULE ON CHANGE
3081
+ //////////////////////////////////
3082
+ //fired when module isReady
3083
  instantiateModOpt : function() {
3084
  var module = this;
3085
+ //Prepare the modOpt and instantiate it
3086
  var modOpt_candidate = module.prepareModOptForAPI( module().modOpt || {} );
3087
  module.czr_ModOpt = new module.modOptConstructor( modOpt_candidate );
3088
  module.czr_ModOpt.ready();
3089
+ //update the module model on modOpt change
3090
  module.czr_ModOpt.callbacks.add( function( to, from, data ) {
3091
  var _current_model = module(),
3092
  _new_model = $.extend( true, {}, _current_model );
3093
  _new_model.modOpt = to;
3094
+ //update the dirtyness state
3095
  module.isDirty(true);
3096
+ //set the the new items model
3097
+ //the data can typically hold informations passed by the input that has been changed and its specific preview transport (can be PostMessage )
3098
+ //data looks like :
3099
+ //{
3100
+ // module : {}
3101
+ // input_changed : string input.id
3102
+ // input_transport : 'postMessage' or '',
3103
+ // not_preview_sent : bool
3104
+ //}
3105
  module( _new_model, data );
3106
  });
3107
  },
3108
+
3109
+ //@return an API ready modOpt object with the following properties
3110
+ // initial_modOpt_model : {},
3111
+ // defaultModOptModel : {},
3112
+ // control : {},//control instance
3113
+ // module : {},//module instance
3114
+ //@param modOpt_candidate is an object. Can contain the saved modOpt properties on init.
3115
  prepareModOptForAPI : function( modOpt_candidate ) {
3116
  var module = this,
3117
  api_ready_modOpt = {};
3118
+ // if ( ! _.isObject( modOpt_candidate ) ) {
3119
+ // throw new Error('preparemodOptForAPI : a modOpt must be an object to be instantiated.');
3120
+ // }
3121
  modOpt_candidate = _.isObject( modOpt_candidate ) ? modOpt_candidate : {};
3122
 
3123
  _.each( module.defaultAPImodOptModel, function( _value, _key ) {
3124
  var _candidate_val = modOpt_candidate[_key];
3125
  switch( _key ) {
3126
  case 'initial_modOpt_model' :
3127
+ //make sure that the provided modOpt has all the default properties set
3128
  _.each( module.getDefaultModOptModel() , function( _value, _property ) {
3129
  if ( ! _.has( modOpt_candidate, _property) )
3130
  modOpt_candidate[_property] = _value;
3145
  });
3146
  return api_ready_modOpt;
3147
  },
3148
+
3149
+ //Returns the default modOpt defined in initialize
3150
+ //Each chid class can override the default item and the following method
3151
  getDefaultModOptModel : function( id ) {
3152
  var module = this;
3153
  return $.extend( _.clone( module.defaultModOptModel ), { is_mod_opt : true } );
3154
  },
3155
+
3156
+
3157
+ //The idea is to send only the currently modified item instead of the entire collection
3158
+ //the entire collection is sent anyway on api(setId).set( value ), and accessible in the preview via api(setId).bind( fn( to) )
3159
+ //This method can be called on input change and on czr-partial-refresh-done
3160
+ //{
3161
+ // input_id :
3162
+ // input_parent_id :
3163
+ // is_mod_opt :
3164
+ // to :
3165
+ // from :
3166
+ // isPartialRefresh : bool//<= let us know if it is a full wrapper refresh or a single input update ( true when fired from sendModuleInputsToPreview )
3167
+ //}
3168
  sendInputToPreview : function( args ) {
3169
  var module = this;
3170
+ //normalizes the args
3171
  args = _.extend(
3172
  {
3173
  input_id : '',
3178
 
3179
  if ( _.isEqual( args.to, args.from ) )
3180
  return;
3181
+
3182
+ //This is listened to by the preview frame
3183
+ api.previewer.send( 'czr_input', {
3184
  set_id : api.CZR_Helpers.getControlSettingId( module.control.id ),
3185
  module_id : module.id,//<= will allow us to target the right dom element on front end
3186
  module : { items : $.extend( true, {}, module().items ) , modOpt : module.hasModOpt() ? $.extend( true, {}, module().modOpt ): {} },
3189
  value : args.to,
3190
  isPartialRefresh : args.isPartialRefresh//<= let us know if it is a full wrapper refresh or a single input update ( true when fired from sendModuleInputsToPreview )
3191
  });
3192
+
3193
+ //add a hook here
3194
  module.trigger( 'input_sent', { input : args.to , dom_el: module.container } );
3195
  },
3196
+
3197
+
3198
+ //@return void()
3199
+ //Fired on partial refresh in base control initialize, only for module type controls
3200
+ //This method can be called when don't have input instances available
3201
+ //=> typically when reordering items, mod options and items are closed, therefore there's no input instances.
3202
+ //=> the input id are being retrieved from the input parent models : items and mod options.
3203
+ //@param args = { isPartialRefresh : bool }
3204
  sendModuleInputsToPreview : function( args ) {
3205
  var module = this,
3206
  _sendInputData = function() {
3207
  var inputParent = this,//this is the input parent : item or modOpt
3208
  inputParentModel = $.extend( true, {}, inputParent() );
3209
+ //we don't need to send the id, which is never an input, but generated by the api.
3210
  inputParentModel = _.omit( inputParentModel, 'id' );
3211
 
3212
  _.each( inputParentModel, function( inputVal, inputId ) {
3230
  }
3231
  });//$.extend//CZRBaseControlMths
3232
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
3233
+ //extends api.CZRBaseControl
3234
+ //
3235
+ //Setup the collection of items
3236
+ //renders the module view
3237
+ //Listen to items collection changes and update the control setting
3238
 
3239
  var CZRModuleMths = CZRModuleMths || {};
3240
  ( function ( api, $, _ ) {
3241
  $.extend( CZRModuleMths, {
3242
+ //@fired in module ready on api('ready')
3243
+ //the module().items has been set in initialize
3244
  populateSavedItemCollection : function() {
3245
  var module = this, _saved_items = [];
3246
  if ( ! _.isArray( module().items ) ) {
3247
  api.errorLog( 'populateSavedItemCollection : The saved items collection must be an array in module :' + module.id );
3248
  return;
3249
  }
3250
+
3251
+ //populates the collection with the saved items
3252
+ //the modOpt must be skipped
3253
+ //the saved items + modOpt is an array looking like :
3254
+ ////MODOPT IS THE FIRST ARRAY ELEMENT: A modOpt has no unique id and has the property is_mod_opt set to true
3255
+ //[
3256
+ // is_mod_opt : true //<= inform us that this is not an item but a modOpt
3257
+ //],
3258
+ ////THEN COME THE ITEMS
3259
+ //[
3260
+ // id : "czr_slide_module_0"
3261
+ // slide-background : 21,
3262
+ // ....
3263
+ // ],
3264
+ // [
3265
+ // id : "czr_slide_module_1"
3266
+ // slide-background : 21,
3267
+ // ....
3268
+ // ]
3269
+
3270
+ //FILTER THE ACTUAL ITEMS ( REMOVE THE MODOPTS ELEMENT IF ANY )
3271
+ //=> the items and the modOpt should already be split at this stage, because it's done before module instantiation... this check is totally paranoid.
3272
  _.each( module().items, function( item_candidate , key ) {
3273
  if ( _.has( item_candidate, 'id') && ! _.has( item_candidate, 'is_mod_opt' ) ) {
3274
  _saved_items.push( item_candidate );
3275
  }
3276
  });
3277
+
3278
+ //INSTANTIATE THE ITEMS
3279
  _.each( _saved_items, function( item_candidate , key ) {
3280
+ //adds it to the collection and fire item.ready()
3281
  try { module.instantiateItem( item_candidate ).ready(); } catch( er ) {
3282
  api.errorLog( 'populateSavedItemCollection : ' + er );
3283
  }
3284
  });
3285
+
3286
+ //check if everything went well
3287
  _.each( _saved_items, function( _item ) {
3288
  if ( _.isUndefined( _.findWhere( module.itemCollection(), _item.id ) ) ) {
3289
  throw new Error( 'populateSavedItemCollection : The saved items have not been properly populated in module : ' + module.id );
3291
  });
3292
 
3293
  module.trigger( 'items-collection-populated' );
3294
+ //do we need to chain this method ?
3295
+ //return this;
3296
  },
3297
 
3298
 
3299
  instantiateItem : function( item, is_added_by_user ) {
3300
  var module = this;
3301
+ //Prepare the item, make sure its id is set and unique
3302
  item_candidate = module.prepareItemForAPI( item );
3303
+ //Item id checks !
3304
  if ( ! _.has( item_candidate, 'id' ) ) {
3305
  throw new Error('CZRModule::instantiateItem() : an item has no id and could not be added in the collection of : ' + this.id );
3306
  }
3307
  if ( module.czr_Item.has( item_candidate.id ) ) {
3308
  throw new Error('CZRModule::instantiateItem() : the following item id ' + item_candidate.id + ' already exists in module.czr_Item() for module ' + this.id );
3309
  }
3310
+ //instanciate the item with the default constructor
3311
  module.czr_Item.add( item_candidate.id, new module.itemConstructor( item_candidate.id, item_candidate ) );
3312
 
3313
  if ( ! module.czr_Item.has( item_candidate.id ) ) {
3314
  throw new Error('CZRModule::instantiateItem() : instantiation failed for item id ' + item_candidate.id + ' for module ' + this.id );
3315
  }
3316
+ //the item is now ready and will listen to changes
3317
+ //return the instance
3318
  return module.czr_Item( item_candidate.id );
3319
  },
3320
+
3321
+
3322
+
3323
+ //@return an API ready item object with the following properties
3324
+ // id : '',
3325
+ // initial_item_model : {},
3326
+ // defaultItemModel : {},
3327
+ // control : {},//control instance
3328
+ // module : {},//module instance
3329
+ // is_added_by_user : false
3330
  prepareItemForAPI : function( item_candidate ) {
3331
  var module = this,
3332
  api_ready_item = {};
3333
+ // if ( ! _.isObject( item_candidate ) ) {
3334
+ // throw new Error('prepareitemForAPI : a item must be an object to be instantiated.');
3335
+ // }
3336
  item_candidate = _.isObject( item_candidate ) ? item_candidate : {};
3337
 
3338
  _.each( module.defaultAPIitemModel, function( _value, _key ) {
3346
  }
3347
  break;
3348
  case 'initial_item_model' :
3349
+ //make sure that the provided item has all the default properties set
3350
  _.each( module.getDefaultItemModel() , function( _value, _property ) {
3351
  if ( ! _.has( item_candidate, _property) )
3352
  item_candidate[_property] = _value;
3368
  break;
3369
  }//switch
3370
  });
3371
+
3372
+ //if we don't have an id at this stage, let's generate it.
3373
  if ( ! _.has( api_ready_item, 'id' ) ) {
3374
  api_ready_item.id = module.generateItemId( module.module_type );
3375
  }
3376
+
3377
+ //Now amend the initial_item_model with the generated id
3378
  api_ready_item.initial_item_model.id = api_ready_item.id;
3379
 
3380
  return api_ready_item;
3381
  },
3382
+
3383
+
3384
+ //recursive
3385
  generateItemId : function( module_type, key, i ) {
3386
+ //prevent a potential infinite loop
3387
  i = i || 1;
3388
  if ( i > 100 ) {
3389
  throw new Error( 'Infinite loop when generating of a module id.' );
3391
  var module = this;
3392
  key = key || module._getNextItemKeyInCollection();
3393
  var id_candidate = module_type + '_' + key;
3394
+
3395
+ //do we have a module collection value ?
3396
  if ( ! _.has(module, 'itemCollection') || ! _.isArray( module.itemCollection() ) ) {
3397
  throw new Error('The item collection does not exist or is not properly set in module : ' + module.id );
3398
  }
3399
+
3400
+ //make sure the module is not already instantiated
3401
  if ( module.isItemRegistered( id_candidate ) ) {
3402
  key++; i++;
3403
  return module.generateItemId( module_type, key, i );
3404
  }
3405
  return id_candidate;
3406
  },
3407
+
3408
+
3409
+ //helper : return an int
3410
+ //=> the next available id of the item collection
3411
  _getNextItemKeyInCollection : function() {
3412
  var module = this,
3413
  _maxItem = {},
3414
  _next_key = 0;
3415
+
3416
+ //get the initial key
3417
+ //=> if we already have a collection, extract all keys, select the max and increment it.
3418
+ //else, key is 0
3419
  if ( _.isEmpty( module.itemCollection() ) )
3420
  return _next_key;
3421
  if ( _.isArray( module.itemCollection() ) && 1 === _.size( module.itemCollection() ) ) {
3427
  return parseInt( _item.id.replace( /[^\/\d]/g, '' ), 10 );
3428
  });
3429
  }
3430
+
3431
+ //For a single item collection, with an index free id, it might happen that the item is not parsable. Make sure it is. Otherwise, use the default key 0
3432
  if ( ! _.isUndefined( _maxItem ) && _.isNumber( _maxItem.id.replace(/[^\/\d]/g,'') ) ) {
3433
  _next_key = parseInt( _maxItem.id.replace(/[^\/\d]/g,''), 10 ) + 1;
3434
  }
3435
  return _next_key;
3436
  },
3437
+
3438
+
3439
+
3440
+ //this helper allows to check if an item has been registered in the collection
3441
+ //no matter if it's not instantiated yet
3442
  isItemRegistered : function( id_candidate ) {
3443
  var module = this;
3444
  return ! _.isUndefined( _.findWhere( module.itemCollection(), { id : id_candidate}) );
3445
  },
3446
+
3447
+
3448
+ //Fired in module.czr_Item.itemReact
3449
+ //@param args can be
3450
+ //{
3451
+ // collection : [],
3452
+ // data : data {}
3453
+ //},
3454
+ //
3455
+ //or {
3456
+ // item : {}
3457
+ // data : data {}
3458
+ //}
3459
+ //if a collection is provided in the passed args then simply refresh the collection
3460
+ //=> typically used when reordering the collection item with sortable or when a item is removed
3461
+ //
3462
+ //the args.data can typically hold informations passed by the input that has been changed and its specific preview transport (can be PostMessage )
3463
+ //data looks like :
3464
+ //{
3465
+ // module : {}
3466
+ // input_changed : string input.id
3467
+ // input_transport : 'postMessage' or '',
3468
+ // not_preview_sent : bool
3469
+ //}
3470
+ //@return a deferred promise
3471
  updateItemsCollection : function( args ) {
3472
  var module = this,
3473
  _current_collection = module.itemCollection(),
3474
  _new_collection = _.clone(_current_collection),
3475
  dfd = $.Deferred();
3476
+
3477
+ //if a collection is provided in the passed args then simply refresh the collection
3478
+ //=> typically used when reordering the collection item with sortable or when a item is removed
3479
  if ( _.has( args, 'collection' ) ) {
3480
+ //reset the collection
3481
  module.itemCollection.set( args.collection );
3482
  return;
3483
  }
3485
  if ( ! _.has( args, 'item' ) ) {
3486
  throw new Error('updateItemsCollection, no item provided ' + module.control.id + '. Aborting');
3487
  }
3488
+ //normalizes with data
3489
  args = _.extend( { data : {} }, args );
3490
 
3491
  var item = _.clone( args.item );
3492
+
3493
+ //the item already exist in the collection
3494
  if ( _.findWhere( _new_collection, { id : item.id } ) ) {
3495
  _.each( _current_collection , function( _item, _ind ) {
3496
  if ( _item.id != item.id )
3497
  return;
3498
+
3499
+ //set the new val to the changed property
3500
  _new_collection[_ind] = item;
3501
  });
3502
  }
3503
+ //the item has to be added
3504
  else {
3505
  _new_collection.push(item);
3506
  }
3507
+
3508
+ //updates the collection value
3509
+ //=> is listened to by module.itemCollectionReact
3510
  module.itemCollection.set( _new_collection, args.data );
3511
  return dfd.resolve( { collection : _new_collection, data : args.data } ).promise();
3512
  },
3513
+
3514
+
3515
+
3516
+ //fire on sortable() update callback
3517
+ //@returns a sorted collection as an array of item objects
3518
  _getSortedDOMItemCollection : function( ) {
3519
  var module = this,
3520
  _old_collection = _.clone( module.itemCollection() ),
3521
  _new_collection = [],
3522
  dfd = $.Deferred();
3523
+
3524
+ //re-build the collection from the DOM
3525
  $( '.' + module.control.css_attr.single_item, module.container ).each( function( _index ) {
3526
  var _item = _.findWhere( _old_collection, {id: $(this).attr('data-id') });
3527
+ //do we have a match in the existing collection ?
3528
  if ( ! _item )
3529
  return;
3530
 
3536
  }
3537
  return dfd.resolve( _new_collection ).promise();
3538
  },
3539
+
3540
+
3541
+ //This method should
3542
+ //1) remove the item views
3543
+ //2) remove the czr_items instances
3544
+ //3) remove the item collection
3545
+ //4) re-initialize items
3546
+ //5) re-setup the item collection
3547
+ //6) re-instantiate the items
3548
+ //7) re-render their views
3549
  refreshItemCollection : function() {
3550
  var module = this;
3551
+ //Remove item views and instances
3552
  module.czr_Item.each( function( _itm ) {
3553
  $.when( module.czr_Item( _itm.id ).container.remove() ).done( function() {
3554
+ //Remove item instances
3555
  module.czr_Item.remove( _itm.id );
3556
  });
3557
  });
3558
+
3559
+ // Reset the item collection
3560
+ // => the collection listeners will be setup after populate, on 'items-collection-populated'
3561
  module.itemCollection = new api.Value( [] );
3562
  module.populateSavedItemCollection();
3563
  }
3564
  });//$.extend//CZRBaseControlMths
3565
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
3566
+ //extends api.CZRBaseControl
3567
+ //
3568
+ //Setup the collection of items
3569
+ //renders the module view
3570
+ //Listen to items collection changes and update the control setting
3571
 
3572
  var CZRModuleMths = CZRModuleMths || {};
3573
  ( function ( api, $, _ ) {
3574
  $.extend( CZRModuleMths, {
3575
+ //Returns the default item defined in initialize
3576
+ //Each chid class can override the default item and the following method
3577
  getDefaultItemModel : function( id ) {
3578
  var module = this;
3579
  return $.extend( _.clone( module.defaultItemModel ), { id : id || '' } );
3580
  },
3581
+
3582
+ //////////////////////////////////
3583
+ ///MODEL HELPERS
3584
+ //////////////////////////////////
3585
+ //the job of this function is to return a new item ready to be added to the collection
3586
+ //the new item shall have a unique id
3587
+ //!!recursive
3588
  _initNewItem : function( _item , _next_key ) {
3589
  var module = this,
3590
  _new_item = { id : '' },
3591
  _id;
3592
+
3593
+ //get the next available key of the collection
3594
  _next_key = 'undefined' != typeof(_next_key) ? _next_key : _.size( module.itemCollection() );
3595
 
3596
  if ( _.isNumber(_next_key) ) {
3598
  }
3599
  else {
3600
  _id = _next_key;
3601
+ //reset next key to 0 in case a recursive loop is needed later
3602
  _next_key = 0;
3603
  }
3604
 
3606
  _new_item = $.extend( _item, { id : _id } );
3607
  else
3608
  _new_item = this.getDefaultItemModel( _id );
3609
+
3610
+ //check the id existence, and its unicity
3611
  if ( _.has(_new_item, 'id') && module._isItemIdPossible(_id) ) {
3612
+ //make sure that the provided item has all the default properties set
3613
  _.map( module.getDefaultItemModel() , function( value, property ){
3614
  if ( ! _.has(_new_item, property) )
3615
  _new_item[property] = value;
3617
 
3618
  return _new_item;
3619
  }
3620
+
3621
+ //if id already exists, then test a new one
3622
  return module._initNewItem( _new_item, _next_key + 1);
3623
  }
3624
  });//$.extend
3625
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
3626
+ //extends api.CZRBaseControl
3627
+ //
3628
+ //Setup the collection of items
3629
+ //renders the module view
3630
+ //Listen to items collection changes and update the control setting
3631
 
3632
  var CZRModuleMths = CZRModuleMths || {};
3633
  ( function ( api, $, _ ) {
3634
  $.extend( CZRModuleMths, {
3635
+ //fired on module.isReady.done()
3636
+ //the module.container is set. Either as the control.container or the single module wrapper in a sektion
3637
  renderModuleParts : function() {
3638
  var module = this,
3639
  $_moduleContentEl = module.isInSektion() ? $( module.container ).find('.czr-mod-content') : $( module.container );
3640
+
3641
+ //Crud modules => then let's add the crud module part tmpl
3642
  if ( module.isCrud() ) {
3643
+ //do we have view template script?
3644
  if ( 0 === $( '#tmpl-' + module.crudModulePart ).length ) {
3645
  throw new Error('No crud Module Part template for module ' + module.id + '. The template script id should be : #tmpl-' + module.crudModulePart );
3646
  }
3647
+
3648
+ //append the module wrapper to the column
3649
  $_moduleContentEl.append( $( wp.template( module.crudModulePart )( {} ) ) );
3650
  }
3651
  var $_module_items_wrapper = $(
3664
 
3665
  return $( $_module_items_wrapper, $_moduleContentEl );
3666
  },
3667
+
3668
+ //called before rendering a view. Fired in module::renderItemWrapper()
3669
+ //can be overridden to set a specific view template depending on the model properties
3670
+ //@return string
3671
+ //@type can be
3672
+ //Read Update Delete (rud...)
3673
+ //Read Update (ru)
3674
+ //...
3675
+ //@item_model is an object describing the current item model
3676
  getTemplateEl : function( type, item_model ) {
3677
  var module = this, _el;
3678
  switch(type) {
3695
  return _el;
3696
  }
3697
  },
3698
+
3699
+ //helper
3700
+ //get the $ view DOM el from the item id
3701
  getViewEl : function( id ) {
3702
  var module = this;
3703
  return $( '[data-id = "' + id + '"]', module.container );
3704
  },
3705
+
3706
+
3707
+ //fired on add_item
3708
+ //fired on views_sorted
3709
  closeAllItems : function( id ) {
3710
  var module = this,
3711
  _current_collection = _.clone( module.itemCollection() ),
3717
  } );
3718
  return this;
3719
  },
3720
+
3721
+
3722
+ //make sure a given jQuery block is fully visible
3723
+ //@param $(el)
3724
  _adjustScrollExpandedBlock : function( $_block_el, adjust ) {
3725
  if ( ! $_block_el.length || _.isUndefined( this.getModuleSection() ) )
3726
  return;
3741
  }
3742
  }, 50);
3743
  },
3744
+
3745
+
3746
+
3747
+ //close alert wrapper
3748
+ //+ deactivate the icon
3749
  closeRemoveDialogs : function() {
3750
  var module = this;
3751
  if ( ! _.isArray( module.itemCollection() ) )
3754
  module.czr_Item.each( function( _item_ ) {
3755
  _item_.removeDialogVisible( false );
3756
  });
3757
+
3758
+ // $('.' + module.control.css_attr.remove_alert_wrapper, module.container ).each( function() {
3759
+ // if ( $(this).hasClass('open') ) {
3760
+ // $(this).slideToggle( {
3761
+ // duration : 100,
3762
+ // done : function() {
3763
+ // $(this).toggleClass('open' , false );
3764
+ // //deactivate the icons
3765
+ // $(this).siblings().find('.' + module.control.css_attr.display_alert_btn).toggleClass('active' , false );
3766
+ // }
3767
+ // } );
3768
+ // }
3769
+ // });
3770
  return this;
3771
  },
3772
+
3773
+
3774
+ //fired when module.isReady.done
3775
  _makeItemsSortable : function(obj) {
3776
  if ( wp.media.isTouchDevice || ! $.fn.sortable )
3777
  return;
3779
  $( '.' + module.control.css_attr.items_wrapper, module.container ).sortable( {
3780
  handle: '.' + module.control.css_attr.item_sort_handle,
3781
  start: function() {
3782
+ //close the module panel if needed
3783
  if ( _.has(api, 'czrModulePanelState' ) )
3784
  api.czrModulePanelState.set(false);
3785
+ //close the sektion settings panel if needed
3786
  if ( _.has(api, 'czrSekSettingsPanelState' ) )
3787
  api.czrSekSettingsPanelState.set(false);
3788
  },
3796
  var refreshPreview = function() {
3797
  api.previewer.refresh();
3798
  };
3799
+ //refreshes the preview frame :
3800
+ //1) only needed if transport is postMessage, because is triggered by wp otherwise
3801
+ //2) only needed when : add, remove, sort item(s).
3802
+ //var isItemUpdate = ( _.size(from) == _.size(to) ) && ! _.isEmpty( _.difference(from, to) );
3803
  if ( 'postMessage' == api(module.control.id).transport && ! api.CZR_Helpers.hasPartRefresh( module.control.id ) ) {
3804
  refreshPreview = _.debounce( refreshPreview, 500 );//500ms are enough
3805
  refreshPreview();
3814
  .then( function() {
3815
  _sortedCollectionReact();
3816
  });
3817
+ //refreshes the preview frame, only if the associated setting is a postMessage transport one, with no partial refresh
3818
+ // if ( 'postMessage' == api( module.control.id ).transport && ! api.CZR_Helpers.hasPartRefresh( module.control.id ) ) {
3819
+ // _.delay( function() { api.previewer.refresh(); }, 100 );
3820
+ // }
3821
  }//update
3822
  }
3823
  );
3828
  /*-----------------------------------------------
3829
  * TABS NAVIGATION IN ITEMS AND MODOPT
3830
  ------------------------------------------------*/
3831
+ //This method is fired on tab click
3832
+ //the @args is the classical DOM listener obj {model : model, dom_el : $_view_el, event : _event, dom_event : e ,refreshed : _refreshed }
3833
+ // IMPORTANT : the this is the item or the modopt instance. NOT the module.
3834
+ // =>This method has been added to the module constructor to avoid repeating the code in two places because it is used both in items and modOpts
3835
+ // @return void()
3836
  toggleTabVisibility : function( args ) {
3837
  var inputParent = this,
3838
  tabs = $( inputParent.container ).find('li'),
3849
  });
3850
  $( inputParent.container ).find('section[id="' + tabIdSwitchedTo + '"]').addClass('content-current');
3851
  },
3852
+
3853
+ // @return void()
3854
+ // the inputParent.container (item or modOpt) is now available ar this stage
3855
+ // Setup the tabs navigation
3856
+ //=> Make sure the first tab is the current visible one
3857
  setupTabNav : function() {
3858
  var inputParent = this,
3859
  preProcessTabs = function() {
3865
  });
3866
  $tabs.first().addClass( 'tab-current' ).removeClass('tab-inactive');
3867
  $( 'section', inputParent.container ).first().addClass( 'content-current' );
3868
+ //set the layout class based on the number of tabs
3869
  var _nb = $tabs.length;
3870
  $tabs.each( function() {
3871
  $(this).addClass( _nb > 0 ? 'cols-' + _nb : '' );
3883
  }
3884
  });//$.extend
3885
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
3886
+ //extends api.CZRModule
3887
+ //
3888
+ //Setup the collection of items
3889
+ //renders the module view
3890
+ //Listen to items collection changes and update the control setting
3891
 
3892
  var CZRDynModuleMths = CZRDynModuleMths || {};
3893
  ( function ( api, $, _ ) {
3895
  initialize: function( id, options ) {
3896
  var module = this;
3897
  api.CZRModule.prototype.initialize.call( module, id, options );
3898
+
3899
+ //extend the module with new template Selectors
3900
  $.extend( module, {
3901
  itemPreAddEl : ''//is specific for each crud module
3902
  } );
3903
 
3904
  module.preItemsWrapper = '';//will store the pre items wrapper
3905
+
3906
+ //EXTENDS THE DEFAULT MONO MODEL CONSTRUCTOR WITH NEW METHODS
3907
+ //=> like remove item
3908
+ //module.itemConstructor = api.CZRItem.extend( module.CZRItemDynamicMths || {} );
3909
+
3910
+ //default success message when item added
3911
  module.itemAddedMessage = serverControlParams.i18n.successMessage;
3912
+
3913
+ ////////////////////////////////////////////////////
3914
+ /// MODULE DOM EVENT MAP
3915
+ ////////////////////////////////////////////////////
3916
  module.userEventMap = new api.Value( [
3917
+ //pre add new item : open the dialog box
3918
  {
3919
  trigger : 'click keydown',
3920
  selector : [ '.' + module.control.css_attr.open_pre_add_btn, '.' + module.control.css_attr.cancel_pre_add_btn ].join(','),
3921
  name : 'pre_add_item',
3922
  actions : [ 'closeAllItems', 'closeRemoveDialogs', 'renderPreItemView','setPreItemViewVisibility' ],
3923
  },
3924
+ //add new item
3925
  {
3926
  trigger : 'click keydown',
3927
  selector : '.' + module.control.css_attr.add_new_btn, //'.czr-add-new',
3930
  }
3931
  ]);//module.userEventMap
3932
  },
3933
+
3934
+
3935
+
3936
+ //When the control is embedded on the page, this method is fired in api.CZRBaseModuleControl:ready()
3937
+ //=> right after the module is instantiated.
3938
  ready : function() {
3939
  var module = this;
3940
+ //Setup the module event listeners
3941
  module.setupDOMListeners( module.userEventMap() , { dom_el : module.container } );
3942
+
3943
+ //PRE MODEL VALUE
3944
  module.preItem = new api.Value( module.getDefaultItemModel() );
3945
+
3946
+ //PRE MODEL EMBED PROMISE
3947
  module.preItemEmbedded = $.Deferred();//was module.czr_preItem.create('item_content');
3948
+ //Add view rendered listeners
3949
  module.preItemEmbedded.done( function( $preWrapper ) {
3950
  module.preItemsWrapper = $preWrapper;
3951
  module.setupPreItemInputCollection();
3952
  });
3953
+
3954
+ //PRE MODEL VIEW STATE
3955
  module.preItemExpanded = new api.Value(false);
3956
+ //add state listeners
3957
  module.preItemExpanded.callbacks.add( function( to, from ) {
3958
  module._togglePreItemViewExpansion( to );
3959
  });
3960
 
3961
  api.CZRModule.prototype.ready.call( module );//fires the parent
3962
  },//ready()
3963
+
3964
+
3965
+ //PRE MODEL INPUTS
3966
+ //fired when preItem is embedded.done()
3967
  setupPreItemInputCollection : function() {
3968
  var module = this;
3969
+
3970
+ //Pre item input collection
3971
  module.preItem.czr_Input = new api.Values();
3972
+
3973
+ //creates the inputs based on the rendered items
3974
  $('.' + module.control.css_attr.pre_add_wrapper, module.container)
3975
  .find( '.' + module.control.css_attr.sub_set_wrapper)
3976
  .each( function( _index ) {
3977
  var _id = $(this).find('[data-type]').attr('data-type') || 'sub_set_' + _index;
3978
+ //instantiate the input
3979
  module.preItem.czr_Input.add( _id, new module.inputConstructor( _id, {//api.CZRInput;
3980
  id : _id,
3981
  type : $(this).attr('data-input-type'),
3984
  module : module,
3985
  is_preItemInput : true
3986
  } ) );
3987
+
3988
+ //fire ready once the input Value() instance is initialized
3989
  module.preItem.czr_Input(_id).ready();
3990
  });//each
3991
  },
3992
+
3993
+
3994
+
3995
+ //Fired on user Dom action.
3996
+ //the item is manually added.
3997
+ //@return a promise() for future sequential actions
3998
  addItem : function(obj) {
3999
  var module = this,
4000
  item = module.preItem(),
4001
  collapsePreItem = function() {
4002
  module.preItemExpanded.set(false);
4003
  module._resetPreItemInputs();
4004
+ //module.toggleSuccessMessage('off');
4005
  },
4006
  dfd = $.Deferred();
4007
 
4009
  api.errorLog( 'addItem : an item should be an object and not empty. In : ' + module.id +'. Aborted.' );
4010
  return dfd.resolve().promise();
4011
  }
4012
+ //display a sucess message if item is successfully instantiated
4013
  collapsePreItem = _.debounce( collapsePreItem, 200 );
4014
+
4015
+ //instantiates and fires ready
4016
  module.instantiateItem( item, true ).ready(); //true == Added by user
4017
+
4018
+ //this iife job is to close the pre item and to maybe refresh the preview
4019
+ //@return a promise(), then once done the item view is expanded to start editing it
4020
  ( function() {
4021
  return $.Deferred( function() {
4022
  var _dfd_ = this;
4023
  module.czr_Item( item.id ).isReady.then( function() {
4024
+ //module.toggleSuccessMessage('on');
4025
  collapsePreItem();
4026
 
4027
  module.trigger('item-added', item );
4028
+ //module.doActions( 'item_added_by_user' , module.container, { item : item , dom_event : obj.dom_event } );
4029
+
4030
+ //refresh the preview frame (only needed if transport is postMessage )
4031
+ //must be a dom event not triggered
4032
+ //otherwise we are in the init collection case where the item are fetched and added from the setting in initialize
4033
  if ( 'postMessage' == api(module.control.id).transport && _.has( obj, 'dom_event') && ! _.has( obj.dom_event, 'isTrigger' ) && ! api.CZR_Helpers.hasPartRefresh( module.control.id ) ) {
4034
+ api.previewer.refresh().done( function() {
4035
  _dfd_.resolve();
4036
  });
4037
  } else {
4052
  module.preItem.set( module.getDefaultItemModel() );
4053
  module.preItem.czr_Input.each( function( input_instance ) {
4054
  var _input_id = input_instance.id;
4055
+ //do we have a default value ?
4056
  if ( ! _.has( module.getDefaultItemModel(), _input_id ) )
4057
  return;
4058
  input_instance.set( module.getDefaultItemModel()._input_id );
4060
  }
4061
  });//$.extend
4062
  })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
4063
+ //extends api.CZRBaseControl
4064
+ //
4065
+ //Setup the collection of items
4066
+ //renders the module view
4067
+ //Listen to items collection changes and update the module setting
4068
 
4069
  var CZRDynModuleMths = CZRDynModuleMths || {};
4070
  ( function ( api, $, _ ) {
4071
  $.extend( CZRDynModuleMths, {
4072
+ //////////////////////////////////////////////////
4073
+ /// PRE ADD MODEL DIALOG AND VIEW
4074
+ //////////////////////////////////////////////////
4075
  renderPreItemView : function( obj ) {
4076
  var module = this;
4077
+ //is this view already rendered ?
4078
  if ( 'pending' != module.preItemEmbedded.state() ) //was ! _.isEmpty( module.czr_preItem('item_content')() ) )
4079
  return;
4080
+
4081
+ //do we have view template script?
4082
  if ( ! _.has(module, 'itemPreAddEl') || 0 === $( '#tmpl-' + module.itemPreAddEl ).length )
4083
  return this;
4084
+
4085
+ //print the html
4086
  var pre_add_template = wp.template( module.itemPreAddEl );
4087
+
4088
+ //do we have an html template and a module container?
4089
  if ( ! pre_add_template || ! module.container )
4090
  return this;
4091
 
4092
  var $_pre_add_el = $('.' + module.control.css_attr.pre_add_item_content, module.container );
4093
  $_pre_add_el.prepend( pre_add_template() );
4094
+
4095
+ //say it
4096
  module.preItemEmbedded.resolve( $_pre_add_el );
4097
  },
4098
+
4099
+ //@return $ el of the pre Item view
4100
  _getPreItemView : function() {
4101
  var module = this;
4102
  return $('.' + module.control.css_attr.pre_add_item_content, module.container );
4103
  },
4104
+
4105
+
4106
+ //toggles the visibility of the Remove View Block
4107
+ //@param : obj = { event : {}, item : {}, view : ${} }
4108
  setPreItemViewVisibility : function(obj) {
4109
  var module = this;
4110
  module.preItemExpanded.set( ! module.preItemExpanded() );
4111
  },
4112
+
4113
+
4114
+ //callback of module.preItemExpanded
4115
+ //@_is_expanded = boolean.
4116
  _togglePreItemViewExpansion : function( _is_expanded ) {
4117
  var module = this,
4118
  $_pre_add_el = $( '.' + module.control.css_attr.pre_add_item_content, module.container );
4119
+
4120
+ //toggle it
4121
  $_pre_add_el.slideToggle( {
4122
  duration : 200,
4123
  done : function() {
4124
  var $_btn = $( '.' + module.control.css_attr.open_pre_add_btn, module.container );
4125
 
4126
  $(this).toggleClass('open' , _is_expanded );
4127
+ //switch icons
4128
  if ( _is_expanded )
4129
  $_btn.find('.fa').removeClass('fa-plus-square').addClass('fa-minus-square');
4130
  else
4131
  $_btn.find('.fa').removeClass('fa-minus-square').addClass('fa-plus-square');
4132
+
4133
+ //set the active class to the btn
4134
  $_btn.toggleClass( 'active', _is_expanded );
4135
+
4136
+ //set the adding_new class to the module container wrapper
4137
  $( module.container ).toggleClass( module.control.css_attr.adding_new, _is_expanded );
4138
+ //make sure it's fully visible
4139
  module._adjustScrollExpandedBlock( $(this), 120 );
4140
  }//done
4141
  } );
4149
  $_success_wrapper = $('.' + module.control.css_attr.pre_add_success, module.container );
4150
 
4151
  if ( 'on' == status ) {
4152
+ //write message
4153
  $_success_wrapper.find('p').text(_message);
4154
+
4155
+ //set various properties
4156
  $_success_wrapper.css('z-index', 1000001 )
4157
  .css('height', $_pre_add_wrapper.height() + 'px' )
4158
  .css('line-height', $_pre_add_wrapper.height() + 'px');
4164
  }
4165
  });//$.extend//CZRBaseControlMths
4166
  })( wp.customize , jQuery, _ );//BASE CONTROL CLASS
4167
+ //extends api.Control
4168
+ //define a set of methods, mostly helpers, to extend the base WP control class
4169
+ //this will become our base constructor for main complex controls
4170
+ //EARLY SETUP
4171
 
4172
  var CZRBaseControlMths = CZRBaseControlMths || {};
4173
  ( function ( api, $, _ ) {
4174
  $.extend( CZRBaseControlMths, {
4175
  initialize: function( id, options ) {
4176
  var control = this;
4177
+ //add a shortcut to the css properties declared in the php controls
4178
  control.css_attr = _.has( serverControlParams , 'css_attr') ? serverControlParams.css_attr : {};
4179
  api.Control.prototype.initialize.call( control, id, options );
4180
+
4181
+ //When a partial refresh is done we need to send back all postMessage input to the preview
4182
+ //=> makes sure that all post message inputs not yet saved in db are properly applied
4183
  control.bind( 'czr-partial-refresh-done', function() {
4184
  if ( _.has( control, 'czr_moduleCollection' ) ) {
4185
  _.each( control.czr_moduleCollection(), function( _mod_ ) {
4191
  }
4192
  });
4193
  },
4194
+
4195
+ //@return void()
4196
  refreshPreview : function( obj ) {
4197
  this.previewer.refresh();
4198
  }
4199
  });//$.extend//CZRBaseControlMths
4200
  })( wp.customize , jQuery, _ );
4201
+ //BASE CONTROL CLASS
4202
+ //extends api.CZRBaseControl
4203
+ //define a set of methods, mostly helpers, to extend the base WP control class
4204
+ //this will become our base constructor for main complex controls
4205
+ //EARLY SETUP
4206
  var CZRBaseModuleControlMths = CZRBaseModuleControlMths || {};
4207
  ( function ( api, $, _ ) {
4208
  $.extend( CZRBaseModuleControlMths, {
4210
  var control = this;
4211
 
4212
  control.czr_Module = new api.Values();
4213
+
4214
+ //czr_collection stores the module collection
4215
  control.czr_moduleCollection = new api.Value();
4216
  control.czr_moduleCollection.set([]);
4217
+
4218
+ //let's store the state of the initial module collection
4219
  control.moduleCollectionReady = $.Deferred();
4220
+ //and listen to changes when it's ready
4221
  control.moduleCollectionReady.done( function( obj ) {
4222
+ if ( ! control.isMultiModuleControl( options ) ) {
4223
+ //api.consoleLog('MODULE COLLECTION READY IN CONTROL : ', control.id , obj.id, control.isModuleRegistered( obj.id ) );
4224
  }
4225
+ //if the module is not registered yet for a single module control
4226
+ //=> push it to the collection now, before listening to the module collection changes
4227
+ // if ( ! control.isModuleRegistered( module.id ) ) {
4228
+ // control.updateModulesCollection( { module : constructorOptions } );
4229
+ // }
4230
+
4231
+ //LISTEN TO MODULE COLLECTION
4232
  control.czr_moduleCollection.callbacks.add( function() { return control.moduleCollectionReact.apply( control, arguments ); } );
4233
+
4234
+ //control.removeModule( _mod );
4235
  } );
4236
+
4237
+ //FOR MULTI MODULE CONTROL : Stores the module instance of the synchronized sektion
4238
+ if ( control.isMultiModuleControl( options ) ) {
4239
  control.syncSektionModule = new api.Value();
4240
  }
4241
 
4242
  api.CZRBaseControl.prototype.initialize.call( control, id, options );
4243
+
4244
+ //FOR TEST PURPOSES
4245
+ // api(this.id).bind( function( to, from) {
4246
+ // api.consoleLog( 'SETTING ', control.id, ' HAS CHANGED : ', to, from );
4247
+ // });
4248
+
4249
+ //close any open item and dialog boxes on section expansion
4250
  api.section( control.section() ).expanded.bind(function(to) {
4251
  control.czr_Module.each( function( _mod ){
4252
  _mod.closeAllItems().closeRemoveDialogs();
4257
  });
4258
 
4259
  },
4260
+
4261
+
4262
+
4263
+
4264
+ //////////////////////////////////
4265
+ ///READY = CONTROL INSTANTIATED AND DOM ELEMENT EMBEDDED ON THE PAGE
4266
+ ///FIRED BEFORE API READY
4267
+ //////////////////////////////////
4268
  ready : function() {
4269
  var control = this;
4270
  if ( control.isMultiModuleControl() ) {
4271
+ //POPULATE THE SAVED MODULE COLLECTION WHEN THE SYNCHRONIZED SEKTIONS SETTING HAS PROVIDED ITS INSTANCE
4272
  control.syncSektionModule.bind( function( sektion_module_instance, from) {
4273
  if ( 'resolved' == control.moduleCollectionReady.state() )
4274
  return;
4275
  control.registerModulesOnInit( sektion_module_instance );
4276
+ //the module collection is ready
4277
  control.moduleCollectionReady.resolve();
4278
  });
4279
  } else {
4280
  var single_module = {};
4281
+ //inits the collection with the saved module => there's only one module to instantiate in this case.
4282
+ //populates the collection with the saved module
4283
  _.each( control.getSavedModules() , function( _mod, _key ) {
4284
+ //stores it
4285
  single_module = _mod;
4286
+
4287
+ //adds it to the collection
4288
+ //=> it will be fired ready usually when the control section is expanded
4289
  try { control.instantiateModule( _mod, {} ); } catch( er ) {
4290
  api.errorLog( 'Failed to instantiate module ' + _mod.id + ' ' + er );
4291
  return;
4292
  }
4293
+
4294
+ //adds the module name to the control container element
4295
  control.container.attr('data-module', _mod.id );
4296
  });
4297
+ //the module collection is ready
4298
  control.moduleCollectionReady.resolve( single_module );
4299
  }
4300
+
4301
+
4302
+ //LISTEN TO MODULE CANDIDATES ADDED BY USERS
4303
  control.bind( 'user-module-candidate', function( _module ) {
4304
  var module;
4305
+ //instanciate + fire ready()
4306
+ //=> the module will be added in the collection on isReady.done()
4307
  try {
4308
  module = control.instantiateModule( _module, {} ); //module, constructor
4309
  } catch( er ) {
4310
  api.errorLog( 'Failed to instantiate module ' + _module.id + ' ' + er );
4311
  return;
4312
  }
4313
+ //If everything went fine, fires ready
4314
  module.ready( _module.is_added_by_user );
4315
  });
4316
  },
4317
+
4318
+
4319
+
4320
+
4321
+
4322
+
4323
+
4324
+
4325
+
4326
+ //////////////////////////////////
4327
+ /// VARIOUS HELPERS
4328
+ //////////////////////////////////
4329
+ ///
4330
+ //@return the default API model {} needed to instantiate a module
4331
+ //Depending on the module context, control or sektion, the default model has to hold different properties
4332
  getDefaultModuleApiModel : function() {
4333
+ //Modules share the common model either they are in a sektion or in a control
4334
  var commonAPIModel = {
4335
  id : '',//module.id,
4336
  module_type : '',//module.module_type,
4341
  sortable : false,//<= a module can be multi-item but not necessarily sortable
4342
  control : {},//control,
4343
  };
4344
+
4345
+ //if embedded in a control, amend the common model with the section id
4346
  if ( ! this.isMultiModuleControl() ) {
4347
  return $.extend( commonAPIModel, {
4348
  section : ''//id of the control section
4357
  } );
4358
  }
4359
  },
4360
+
4361
+ //@return the default DB model {} that will be used when the setting will send the ajax save request
4362
+ //Depending on the module context, control or sektion, the default DB model has to hold different properties
4363
  getDefaultModuleDBModel : function() {
4364
  var commonDBModel = {
4365
  items : [],//$.extend( true, {}, module.items ),
4366
  };
4367
+
4368
+ //if embedded in a sektion, we need more the item(s) collection
4369
  if ( this.isMultiModuleControl() ) {
4370
  return $.extend( commonDBModel, {
4371
  id : '',
4378
  return commonDBModel;
4379
  }
4380
  },
4381
+
4382
+
4383
+ //@return bool
4384
+ //@param options is optional.
4385
+ //Passed when first invoked in the constructor.
4386
+ //Once the control is instantiated, we can access the options from the instance
4387
+ isMultiModuleControl : function( options ) {
4388
+ var _type, control = this;
4389
+ //since WP v4.9, the control options are not wrapper in the params property but passed directly instead.
4390
+ if ( _.isUndefined( options ) ){
4391
+ _type = _.has( control, 'params') ? control.params.type : control.type;
4392
+ } else {
4393
+ _type = _.has( options, 'params') ? options.params.type : options.type;
4394
+ }
4395
+ return 'czr_multi_module' == _type;
4396
  },
4397
+
4398
+
4399
+ //@return the control instance of the synchronized collection of modules
4400
  getSyncCollectionControl : function() {
4401
  var control = this;
4402
  if ( _.isUndefined( control.params.syncCollection ) ) {
4404
  }
4405
  return api.control( api.CZR_Helpers.build_setId( control.params.syncCollection ) );
4406
  },
4407
+
4408
+
4409
+ //@return the collection [] of saved module(s) to instantiate
4410
+ //This method does not make sure that the module model is ready for API.
4411
+ //=> it just returns an array of saved module candidates to instantiate.
4412
+ //
4413
+ //Before instantiation, we will make sure that all required property are defined for the modules with the method control.prepareModuleForAPI()
4414
+ // control : control,
4415
+ // crud : bool
4416
+ // id : '',
4417
+ // items : [], module.items,
4418
+ // modOpt : {}
4419
+ // module_type : module.module_type,
4420
+ // multi_item : bool
4421
+ // section : module.section,
4422
+ // is_added_by_user : is_added_by_user || false
4423
  getSavedModules : function() {
4424
  var control = this,
4425
  _savedModulesCandidates = [],
4427
  _raw_saved_module_val = [],
4428
  _saved_items = [],
4429
  _saved_modOpt = {};
4430
+
4431
+ //In the case of multi module control synchronized with a sektion
4432
+ // => the saved modules is a collection saved in the setting
4433
+ //For a module embedded in a regular control, we need to hard code the single module collection
4434
+ // => in this case, the corresponding setting will store the collection of item(s)
4435
  if ( control.isMultiModuleControl() ) {
4436
  _savedModulesCandidates = $.extend( true, [], api( control.id )() );//deep clone
4437
  } else {
4438
+ //What is the current server saved value for this setting?
4439
+ //in a normal case, it should be an array of saved properties
4440
+ //But it might not be if coming from a previous option system.
4441
+ //=> let's normalize it.
4442
+ //First let's perform a quick check on the current saved db val.
4443
+ //If the module is not multi-item, the saved value should be an object or empty if not set yet
4444
  if ( api.CZR_Helpers.isMultiItemModule( _module_type ) && ! _.isEmpty( api( control.id )() ) && ! _.isObject( api( control.id )() ) ) {
4445
  api.consoleLog('Module Control Init for ' + control.id + ' : a mono item module control value should be an object if not empty.');
4446
  }
4447
+
4448
+ //SPLIT ITEMS [] and MODOPT {}
4449
+ //In database, items and modOpt are saved in the same option array.
4450
+ //If the module has modOpt ( the slider module for example ), the modOpt are described by an object which is always unshifted at the beginning of the setting value.
4451
+
4452
+ //the raw DB setting value is an array : modOpt {} + the saved items :
4453
+ ////META IS THE FIRST ARRAY ELEMENT: A modOpt has no unique id and has the property is_modOpt set to true
4454
+ //[
4455
+ // is_mod_opt : true //<= inform us that this is not an item but a modOpt
4456
+ //],
4457
+ ////THEN COME THE ITEMS
4458
+ //[
4459
+ // id : "czr_slide_module_0"
4460
+ // slide-background : 21,
4461
+ // ....
4462
+ // ],
4463
+ // [
4464
+ // id : "czr_slide_module_1"
4465
+ // slide-background : 21,
4466
+ // ....
4467
+ // ]
4468
+ // [...]
4469
+
4470
+ //POPULATE THE ITEMS [] and the MODOPT {} FROM THE RAW DB SAVED SETTING VAL
4471
  _raw_saved_module_val = _.isArray( api( control.id )() ) ? api( control.id )() : [ api( control.id )() ];
4472
 
4473
  _.each( _raw_saved_module_val, function( item_or_mod_opt_candidate , key ) {
4474
  if ( api.CZR_Helpers.hasModuleModOpt( _module_type ) && 0*0 === key ) {
4475
+ // a saved module mod_opt object should not have an id
4476
  if ( _.has( item_or_mod_opt_candidate, 'id') ) {
4477
  api.consoleLog( 'getSavedModules : the module ' + _module_type + ' in control ' + control.id + ' has no mod_opt defined while it should.' );
4478
  } else {
4483
  _saved_items.push( item_or_mod_opt_candidate );
4484
  }
4485
  });
4486
+
4487
+
4488
+ //for now this is a collection with one module
4489
  _savedModulesCandidates.push(
4490
  {
4491
  id : api.CZR_Helpers.getOptionName( control.id ) + '_' + control.params.type,
4498
  }
4499
  return _savedModulesCandidates;
4500
  },
4501
+
4502
+
4503
+ //this helper allows to check if a module has been registered in the collection
4504
+ //no matter if it's not instantiated yet
4505
  isModuleRegistered : function( id_candidate ) {
4506
  var control = this;
4507
  return ! _.isUndefined( _.findWhere( control.czr_moduleCollection(), { id : id_candidate}) );
4508
  }
4509
  });//$.extend//CZRBaseControlMths
4510
  })( wp.customize , jQuery, _ );
4511
+ //BASE CONTROL CLASS
4512
+ //extends api.CZRBaseControl
4513
+ //define a set of methods, mostly helpers, to extend the base WP control class
4514
+ //this will become our base constructor for main complex controls
4515
+ //EARLY SETUP
4516
  var CZRBaseModuleControlMths = CZRBaseModuleControlMths || {};
4517
  ( function ( api, $, _ ) {
4518
  $.extend( CZRBaseModuleControlMths, {
4519
+ //@param : module {}
4520
+ //@param : constructor string
4521
  instantiateModule : function( module, constructor ) {
4522
  if ( ! _.has( module,'id') ) {
4523
  throw new Error('CZRModule::instantiateModule() : a module has no id and could not be added in the collection of : ' + this.id +'. Aborted.' );
4524
  }
4525
  var control = this;
4526
+ //is a constructor provided ?
4527
+ //if not try to look in the module object if we an find one
4528
  if ( _.isUndefined(constructor) || _.isEmpty(constructor) ) {
4529
  constructor = control.getModuleConstructor( module );
4530
  }
4531
+ //on init, the module collection is populated with module already having an id
4532
+ //For now, let's check if the id is empty and is not already part of the collection.
4533
+ //@todo : improve this.
4534
  if ( ! _.isEmpty( module.id ) && control.czr_Module.has( module.id ) ) {
4535
  throw new Error('The module id already exists in the collection in control : ' + control.id );
4536
  }
4537
 
4538
  var module_api_ready = control.prepareModuleForAPI( module );
4539
+
4540
+ //instanciate the module with the default constructor
4541
  control.czr_Module.add( module_api_ready.id, new constructor( module_api_ready.id, module_api_ready ) );
4542
 
4543
  if ( ! control.czr_Module.has( module_api_ready.id ) ) {
4544
  throw new Error('instantiateModule() : instantiation failed for module id ' + module_api_ready.id + ' in control ' + control.id );
4545
  }
4546
+ //return the module instance for chaining
4547
  return control.czr_Module(module_api_ready.id);
4548
  },
4549
+
4550
+
4551
+
4552
+ //@return a module constructor object
4553
  getModuleConstructor : function( module ) {
4554
  var control = this,
4555
  parentConstructor = {},
4565
  var _mthds = api.czrModuleMap[ module.module_type ].mthds,
4566
  _is_crud = api.czrModuleMap[ module.module_type ].crud,
4567
  _base_constructor = _is_crud ? api.CZRDynModule : api.CZRModule;
4568
+
4569
+ //in the general case of multi_module / sektion control, we need to extend the module constructors
4570
  if ( ! _.isEmpty( module.sektion_id ) ) {
4571
  parentConstructor = _base_constructor.extend( _mthds );
4572
  constructor = parentConstructor.extend( control.getMultiModuleExtender( parentConstructor ) );
4573
  } else {
4574
+ //in the particular case of a module embedded in a control, the constructor is ready to be fired.
4575
  constructor = _base_constructor.extend( _mthds );
4576
  }
4577
 
4580
  }
4581
  return constructor;
4582
  },
4583
+
4584
+
4585
+
4586
+
4587
+
4588
+ //@return an API ready module object
4589
+ //To be instantiated in the API, the module model must have all the required properties defined in the defaultAPIModel properly set
4590
  prepareModuleForAPI : function( module_candidate ) {
4591
  if ( ! _.isObject( module_candidate ) ) {
4592
  throw new Error('prepareModuleForAPI : a module must be an object to be instantiated.');
4598
  _.each( control.getDefaultModuleApiModel() , function( _value, _key ) {
4599
  var _candidate_val = module_candidate[_key];
4600
  switch( _key ) {
4601
+ //PROPERTIES COMMON TO ALL MODULES IN ALL CONTEXTS
4602
  case 'id' :
4603
  if ( _.isEmpty( _candidate_val ) ) {
4604
  api_ready_module[_key] = control.generateModuleId( module_candidate.module_type );
4625
  api_ready_module[_key] = _candidate_val;
4626
  break;
4627
  case 'crud' :
4628
+ //get the value from the czrModuleMap
4629
  if ( _.has( api.czrModuleMap, module_candidate.module_type ) ) {
4630
  _candidate_val = api.czrModuleMap[ module_candidate.module_type ].crud;
4631
  } else if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
4634
  api_ready_module[_key] = _candidate_val || false;
4635
  break;
4636
  case 'multi_item' :
4637
+ //get the value from the czrModuleMap
4638
  if ( _.has( api.czrModuleMap, module_candidate.module_type ) ) {
4639
  _candidate_val = api.czrModuleMap[ module_candidate.module_type ].crud || api.czrModuleMap[ module_candidate.module_type ].multi_item;
4640
  } else if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
4642
  }
4643
  api_ready_module[_key] = _candidate_val || false;
4644
  break;
4645
+ //if the sortable property is not set, then check if crud or multi-item
4646
  case 'sortable' :
4647
+ //get the value from the czrModuleMap
4648
  if ( _.has( api.czrModuleMap, module_candidate.module_type ) ) {
4649
  _candidate_val = api.czrModuleMap[ module_candidate.module_type ].sortable || api.czrModuleMap[ module_candidate.module_type ].crud || api.czrModuleMap[ module_candidate.module_type ].multi_item;
4650
  } else if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
4655
  case 'control' :
4656
  api_ready_module[_key] = control;//this
4657
  break;
4658
+
4659
+
4660
+
4661
+ //PROPERTIES FOR MODULE EMBEDDED IN A CONTROL
4662
  case 'section' :
4663
  if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
4664
  throw new Error('prepareModuleForAPI : a module section must be a string not empty');
4665
  }
4666
  api_ready_module[_key] = _candidate_val;
4667
  break;
4668
+
4669
+
4670
+
4671
+ //PROPERTIES FOR MODULE EMBEDDED IN A SEKTION
4672
  case 'column_id' :
4673
  if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
4674
  throw new Error('prepareModuleForAPI : a module column id must a string not empty');
4700
  });
4701
  return api_ready_module;
4702
  },
4703
+
4704
+
4705
+ //recursive
4706
  generateModuleId : function( module_type, key, i ) {
4707
+ //prevent a potential infinite loop
4708
  i = i || 1;
4709
  if ( i > 100 ) {
4710
  throw new Error('Infinite loop when generating of a module id.');
4712
  var control = this;
4713
  key = key || control._getNextModuleKeyInCollection();
4714
  var id_candidate = module_type + '_' + key;
4715
+
4716
+ //do we have a module collection value ?
4717
  if ( ! _.has(control, 'czr_moduleCollection') || ! _.isArray( control.czr_moduleCollection() ) ) {
4718
  throw new Error('The module collection does not exist or is not properly set in control : ' + control.id );
4719
  }
4720
+
4721
+ //make sure the module is not already instantiated
4722
  if ( control.isModuleRegistered( id_candidate ) ) {
4723
  key++; i++;
4724
  return control.generateModuleId( module_type, key, i );
4726
 
4727
  return id_candidate;
4728
  },
4729
+
4730
+
4731
+ //helper : return an int
4732
+ //=> the next available id of the module collection
4733
  _getNextModuleKeyInCollection : function() {
4734
  var control = this,
4735
  _max_mod_key = {},
4736
  _next_key = 0;
4737
+
4738
+ //get the initial key
4739
+ //=> if we already have a collection, extract all keys, select the max and increment it.
4740
+ //else, key is 0
4741
  if ( ! _.isEmpty( control.czr_moduleCollection() ) ) {
4742
  _max_mod_key = _.max( control.czr_moduleCollection(), function( _mod ) {
4743
  return parseInt( _mod.id.replace(/[^\/\d]/g,''), 10 );
4748
  }
4749
  });//$.extend//CZRBaseControlMths
4750
  })( wp.customize , jQuery, _ );
4751
+ //BASE CONTROL CLASS
4752
+ //extends api.CZRBaseControl
4753
+ //define a set of methods, mostly helpers, to extend the base WP control class
4754
+ //this will become our base constructor for main complex controls
4755
+ //EARLY SETUP
4756
  var CZRBaseModuleControlMths = CZRBaseModuleControlMths || {};
4757
  ( function ( api, $, _ ) {
4758
  $.extend( CZRBaseModuleControlMths, {
4759
+ //Multi Module method
4760
+ //fired when the main sektion module has synchronised its if with the module-collection control
4761
  registerModulesOnInit : function( sektion_module_instance ) {
4762
  var control = this,
4763
  _orphan_mods = [];
4764
 
4765
  _.each( control.getSavedModules() , function( _mod, _key ) {
4766
+ //a module previously embedded in a deleted sektion must not be registered
4767
  if ( ! sektion_module_instance.czr_Item.has( _mod.sektion_id ) ) {
4768
  api.errorLog( 'Warning Module ' + _mod.id + ' is orphan : it has no sektion to be embedded to. It Must be removed.');
4769
  _orphan_mods.push(_mod);
4770
  return;
4771
  }
4772
+ //@todo handle the case of a module embedded in a previously deleted column
4773
+ //=> register it in the first column of the sektion ?
4774
 
4775
  var _sektion = sektion_module_instance.czr_Item( _mod.sektion_id );
4776
 
4777
  if ( _.isUndefined( _sektion ) ) {
4778
  throw new Error( 'sektion instance missing. Impossible to instantiate module : ' + _mod.id );
4779
  }
4780
+
4781
+ //add the sektion instance before update the api collection
4782
  $.extend( _mod, {sektion : _sektion} );
4783
+
4784
+ //push it to the collection of the module-collection control
4785
+ //=> the instantiation will take place later, on column instantiation
4786
  control.updateModulesCollection( {module : _mod } );
4787
  });
4788
+
4789
+ //REMOVE ORPHAN MODULES ON INIT
4790
+ //But only when the module collectionn has been resolved
4791
  control.moduleCollectionReady.then( function() {
4792
+ //if there are some orphans mods, the module-collection setting must be updated now.
4793
  if ( ! _.isEmpty( _orphan_mods ) ) {
4794
  control.moduleCollectionReact( control.czr_moduleCollection(), [], { orphans_module_removal : _orphan_mods } );
4795
  }
4796
  });
4797
  },
4798
+
4799
+
4800
+
4801
+ //@return void()
4802
+ //@param obj can be { collection : []}, or { module : {} }
4803
+ //Can be called :
4804
+ //1) for multimodule control, in register modules on init, when the main sektion module has synchronised with the module-collection control
4805
+ //2) for all modules, in module.isReady.done() if the module is not registered in the collection yet.
4806
+ //3) for all modules on moduleReact ( module.callbacks )
4807
+ //
4808
+ //=> sets the setting value via the module collection !
4809
  updateModulesCollection : function( obj ) {
4810
  var control = this,
4811
  _current_collection = control.czr_moduleCollection(),
4812
  _new_collection = $.extend( true, [], _current_collection);
4813
+
4814
+ //if a collection is provided in the passed obj then simply refresh the collection
4815
+ //=> typically used when reordering the collection module with sortable or when a module is removed
4816
  if ( _.has( obj, 'collection' ) ) {
4817
+ //reset the collection
4818
  control.czr_moduleCollection.set( obj.collection, obj.data || {} );
4819
  return;
4820
  }
4822
  if ( ! _.has(obj, 'module') ) {
4823
  throw new Error('updateModulesCollection, no module provided ' + control.id + '. Aborting');
4824
  }
4825
+
4826
+ //normalizes the module for the API
4827
  var module_api_ready = control.prepareModuleForAPI( _.clone( obj.module ) );
4828
+
4829
+ //the module already exist in the collection
4830
  if ( _.findWhere( _new_collection, { id : module_api_ready.id } ) ) {
4831
  _.each( _current_collection , function( _elt, _ind ) {
4832
  if ( _elt.id != module_api_ready.id )
4833
  return;
4834
+
4835
+ //set the new val to the changed property
4836
  _new_collection[_ind] = module_api_ready;
4837
  });
4838
  }
4839
+ //the module has to be added
4840
  else {
4841
  _new_collection.push( module_api_ready );
4842
  }
4843
+
4844
+ //WHAT ARE THE PARAMS WE WANT TO PASS TO THE NEXT ACTIONS
4845
  var _params = {};
4846
+ //if a data property has been passed,
4847
+ //amend the data property with the changed module
4848
  if ( _.has( obj, 'data') ) {
4849
  _params = $.extend( true, {}, obj.data );
4850
  $.extend( _params, { module : module_api_ready } );
4851
  }
4852
+ //Inform the collection
4853
  control.czr_moduleCollection.set( _new_collection, _params );
4854
  },
4855
+
4856
+
4857
+
4858
+
4859
+
4860
+
4861
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4862
+ ////////////////////////////////////////////////////// WHERE THE STREETS HAVE NO NAMES //////////////////////////////////////////////////////
4863
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4864
+ //cb of control.czr_moduleCollection.callbacks
4865
+ //@data is an optional object. { silent : true }
4866
  moduleCollectionReact : function( to, from, data ) {
4867
  var control = this,
4868
  is_module_added = _.size(to) > _.size(from),
4869
  is_module_removed = _.size(from) > _.size(to),
4870
  is_module_update = _.size(from) == _.size(to);
4871
  is_collection_sorted = false;
4872
+
4873
+ //MODULE REMOVED
4874
+ //Remove the module instance if needed
4875
  if ( is_module_removed ) {
4876
+ //find the module to remove
4877
  var _to_remove = _.filter( from, function( _mod ){
4878
  return _.isUndefined( _.findWhere( to, { id : _mod.id } ) );
4879
  });
4880
  _to_remove = _to_remove[0];
4881
  control.czr_Module.remove( _to_remove.id );
4882
  }
4883
+
4884
+ //is there a passed module param ?
4885
+ //if so prepare it for DB
4886
+ //if a module is provided, we also want to pass its id to the preview => can be used to target specific selectors in a partial refresh scenario
4887
  if ( _.isObject( data ) && _.has( data, 'module' ) ) {
4888
  data.module_id = data.module.id;
4889
  data.module = control.prepareModuleForDB( $.extend( true, {}, data.module ) );
4890
  }
4891
+
4892
+ //Inform the the setting
4893
+ //If we are in a single module control (not a sektion, multimodule)
4894
+ //AND that the module is being added to the collection for the first time,
4895
+ //We don't want to say it to the setting, because it might alter the setting dirtyness for nothing on init.
4896
  if ( ! control.isMultiModuleControl() && is_module_added ) {
4897
  return;
4898
  }
4899
  else {
4900
+ //control.filterModuleCollectionBeforeAjax( to ) returns an array of items
4901
+ //if the module has modOpt, the modOpt object is always added as the first element of the items array (unshifted)
4902
  api( this.id )
4903
  .set( control.filterModuleCollectionBeforeAjax( to ), data );
4904
+ //.done( function( to, from, o ) {});
4905
  }
4906
  },
4907
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4908
+ ////////////////////////////////////////////////////// WHERE THE STREETS HAVE NO NAMES //////////////////////////////////////////////////////
4909
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4910
+
4911
+
4912
+
4913
+
4914
+
4915
+
4916
+
4917
+
4918
+
4919
+ //an overridable method to act on the collection just before it is ajaxed
4920
+ //@return the collection array
4921
  filterModuleCollectionBeforeAjax : function( collection ) {
4922
  var control = this,
4923
  _filtered_collection = $.extend( true, [], collection ),
4927
  var db_ready_mod = $.extend( true, {}, _mod );
4928
  _filtered_collection[_key] = control.prepareModuleForDB( db_ready_mod );
4929
  });
4930
+
4931
+ //we don't want to save the same things if we the modules are embedded in a control or in a sektion
4932
+ //=> in a sektion : we save the collection of modules
4933
+ //=> in a control : we save
4934
+ //1) the collection of item(s)
4935
+ //2) the modOpt
4936
  if ( control.isMultiModuleControl() ) {
4937
  return _filtered_collection;
4938
  } else {
4939
+ //at this point we should be in the case of a single module collection, typically use to populate a regular setting
4940
  if ( _.size( collection ) > 1 ) {
4941
  throw new Error('There should not be several modules in the collection of control : ' + control.id );
4942
  }
4952
  if ( ! _.isArray( module_instance().items ) ) {
4953
  throw new Error('The module ' + module_id + ' should be an array in control : ' + control.id );
4954
  }
4955
+
4956
+ //items
4957
  _to_return = module_instance.isMultiItem() ? module_instance().items : ( module_instance().items[0] || [] );
4958
+
4959
+ //Add the modOpt if any
4960
  return module_instance.hasModOpt() ? _.union( [ module_instance().modOpt ] , _to_return ) : _to_return;
4961
  }
4962
  },
4963
+
4964
+
4965
+
4966
+
4967
+ //fired before adding a module to the collection of DB candidates
4968
+ //the module must have the control.getDefaultModuleDBModel structure :
4969
  prepareModuleForDB : function ( module_db_candidate ) {
4970
  if ( ! _.isObject( module_db_candidate ) ) {
4971
  throw new Error('MultiModule Control::prepareModuleForDB : a module must be an object. Aborting.');
4980
 
4981
  var _candidate_val = module_db_candidate[ _key ];
4982
  switch( _key ) {
4983
+ //PROPERTIES COMMON TO ALL MODULES IN ALL CONTEXTS
4984
  case 'items' :
4985
  if ( ! _.isArray( _candidate_val ) ) {
4986
  throw new Error('prepareModuleForDB : a module item list must be an array');
4987
  }
4988
  db_ready_module[ _key ] = _candidate_val;
4989
  break;
4990
+
4991
+
4992
+
4993
+ //PROPERTIES FOR MODULE EMBEDDED IN A SEKTION
4994
  case 'id' :
4995
  if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
4996
  throw new Error('prepareModuleForDB : a module id must a string not empty');
5013
  if ( ! _.isObject( module_db_candidate.sektion ) || ! _.has( module_db_candidate.sektion, 'id' ) ) {
5014
  throw new Error('prepareModuleForDB : a module sektion must be an object with an id.');
5015
  }
5016
+ //in the API, the sektion property hold by the module is an instance
5017
+ //let's use only the id for the DB
5018
  db_ready_module[ _key ] = module_db_candidate.sektion.id;
5019
  break;
5020
  case 'dirty' :
5032
  }
5033
  });//$.extend//CZRBaseControlMths
5034
  })( wp.customize , jQuery, _ );
5035
+ //extends api.CZRBaseModuleControl
5036
  var CZRMultiModuleControlMths = CZRMultiModuleControlMths || {};
5037
  ( function ( api, $, _ ) {
5038
  $.extend( CZRMultiModuleControlMths, {
5039
  initialize: function( id, options ) {
5040
  var control = this;
5041
+
5042
+ //listen to the module-collection setting changes
5043
+ //=> synchronize the columns in the sektion setting
5044
  api.consoleLog('IN MULTI MODULE INITIALIZE ? ', options );
5045
  api(id).callbacks.add( function() { return control.syncColumn.apply( control, arguments ); } );
5046
 
5047
+ //when the synchronized sektion module sends its instance, check the consistency with the module-collection setting
5048
+ //=> each modules of the module-collection setting should be present in a column of the synchronized sektion
5049
+ // control.syncSektionModule().bind( function( sektion_module_instance ) {
5050
+ // sektion_module_instance.czr_columnCollection.each( function( _col ) {
5051
+ // api.consoleLog('_col.modules', _col.modules);
5052
+ // });
5053
+ // });
5054
+
5055
  api.CZRBaseModuleControl.prototype.initialize.call( control, id, options );
5056
  },
5057
 
5061
  api.consoleLog('MODULE-COLLECTION CONTROL READY', this.id );
5062
  api.CZRBaseModuleControl.prototype.ready.apply( control, arguments);
5063
  },
5064
+
5065
+ //cb of : api(control.id).callbacks.
5066
  syncColumn : function( to, from, data ) {
5067
  api.consoleLog('IN SYNC COLUMN', to, from, data );
5068
  if ( ! _.isUndefined(data) && data.silent )
5069
  return;
5070
  api.consoleLog('IN SYNXXX', api.control('hu_theme_options[module-collection]').syncSektionModule()(), this.syncSektionModule()(), this.id );
5071
+
5072
+ //ORPHANS MODULE REMOVED ON INIT, VOID()
5073
+ //=> there's no column to synchronize
5074
  if ( _.has( data, 'orphans_module_removal' ) )
5075
  return;
5076
+
5077
+ //always get the control instance from the api
5078
+ //=> because the control on which this callback is binded can be re instantiated, typically on skope switch
5079
  var control = api.control( this.id );
5080
+ //MODULE ADDED
5081
+ //determine if a module has been added
5082
  var added_mod = _.filter( to, function( _mod, _key ){
5083
  return ! _.findWhere( from, { id : _mod.id } );
5084
  } );
5088
  control.syncSektionModule().czr_Column( _mod.column_id ).updateColumnModuleCollection( { module : _mod } );
5089
  });
5090
  }
5091
+
5092
+ //MODULE REMOVED
5093
  var removed_mod = _.filter( from, function( _mod, _key ){
5094
  return ! _.findWhere( to, { id : _mod.id } );
5095
  } );
5098
  control.syncSektionModule().czr_Column( _mod.column_id ).removeModuleFromColumnCollection( _mod );
5099
  });
5100
  }
5101
+
5102
+ //MODULE HAS BEEN MOVED TO ANOTHER COLUMN
5103
  if ( _.size(from) == _.size(to) && _.has( data, 'module') && _.has( data, 'source_column') && _.has( data, 'target_column') ) {
5104
  $.when( control.syncSektionModule().moveModuleFromTo( data.module, data.source_column, data.target_column ) ).done( function() {
5105
  control.syncSektionModule().control.trigger('module-moved', { module : data.module, source_column: data.source_column, target_column :data.target_column });
5107
  }
5108
  control.trigger( 'columns-synchronized', to );
5109
  },
5110
+
5111
+
5112
+ ////////////////////////////////////////////
5113
+ /// REMOVE MODULE
5114
+ ///////////////////////////////////////////
5115
+ //@param module = obj => the module model
5116
  removeModule : function( module ) {
5117
  var control = this;
5118
+ //remove module from DOM if it's been embedded
5119
  if ( control.czr_Module.has( module.id ) && 'resolved' == control.czr_Module( module.id ).embedded.state() )
5120
  control.czr_Module( module.id ).container.remove();
5121
+
5122
+ //remove module from API
5123
  control.removeModuleFromCollection( module );
5124
  },
5125
 
5136
  }
5137
  });//$.extend//CZRBaseControlMths
5138
  })( wp.customize , jQuery, _ );
5139
+ //extends api.CZRBaseModuleControl
5140
  var CZRMultiModuleControlMths = CZRMultiModuleControlMths || {};
5141
  ( function ( api, $, _ ) {
5142
  $.extend( CZRMultiModuleControlMths, {
5143
+ //adapt modules for them to be used in a multimodule control, synchronized with a sektions control.
5144
+ //@todo. => create equivalent extender when they are used in controls.
5145
  getMultiModuleExtender : function( parentConstructor ) {
5146
  var control = this;
5147
  $.extend( control.CZRModuleExtended, {
5148
  initialize: function( id, constructorOptions ) {
5149
  var module = this;
5150
+ //run the parent initialize
5151
  parentConstructor.prototype.initialize.call( module, id, constructorOptions );
5152
 
5153
  api.consoleLog('MODULE INSTANTIATED : ', module.id );
5154
+
5155
+ //extend the module with new template Selectors
5156
  $.extend( module, {
5157
  singleModuleWrapper : 'czr-single-module-wrapper',
5158
  sektionModuleTitle : 'czr-module-sektion-title-part',
5159
  ruModuleEl : 'czr-ru-module-sektion-content'
5160
  } );
5161
+
5162
+ //ADD A MODULE STATE OBSERVER
5163
+ //czr_ModuleState stores the current expansion status of a given module
5164
+ //can take 2 values : expanded, closed
5165
  module.czr_ModuleState = new api.Value( false );
5166
+
5167
+ //SETUP MODULE VIEW WHEN MODULE READY
5168
  module.isReady.done( function() {
5169
  module.setupModuleView();
5170
  });
5171
+
5172
+ //ADD A MODULE TITLE ELEMENT EMBEDDED STATE
5173
  module.moduleTitleEmbedded = $.Deferred();
5174
+
5175
+ //ADD A MODULE COLUMN STATE OBSERVER
5176
  module.modColumn = new api.Value();
5177
  module.modColumn.set( constructorOptions.column_id );
5178
+
5179
+ //React to a module column change. Typically fired when moving a module from one column to another.
5180
  module.modColumn.bind( function( to, from ) {
5181
  api.consoleLog('MODULE ' + module.id + ' HAS BEEN MOVED TO COLUMN', to, module() );
5182
  var _current_model = module(),
5183
  _new_model = $.extend( true, {}, _current_model );
5184
 
5185
  _new_model.column_id = to;
5186
+
5187
+ //When the module value changes, here's what happens :
5188
+ //IN THE MODULE COLLECTION CONTROL / SETTING
5189
+ //1) the module reacts and inform the control.czr_moduleCollection()
5190
+ //2) the control.czr_moduleCollection() reacts and inform the 'module-collection' setting
5191
+ //3) the module-collection setting react and inform the relevant column.columnModuleCollection() instance with the syncColumn() method
5192
+ //
5193
+ //IN THE SEKTIONS CONTROL / SETTING
5194
+ //4) the column.columnModuleCollection() instance reacts and inform the column() instance
5195
+ //5) the column() instance reacts and inform the sektion module.czr_columnCollection() instance
5196
+ //6) the module.czr_columnCollection() instance reacts and inform the relevant sektion() instance
5197
+ //7) the sektion() instance reacts and inform the itemCollection() (=> a sektion() is actually an item )
5198
+ //8) the itemCollection() reacts and inform its module() instance
5199
+ //9) the module() instance reacts and inform the moduleCollection() instance
5200
+ //10) the control.czr_moduleCollection() instance reacts and inform the 'sektions' setting
5201
  module.set( _new_model, { target_column : to, source_column : from } );
5202
+ //var updatedModuleCollection = $.extend( true, [], module.control.czr_moduleCollection() );
5203
+ //api(module.control.id).set( module.control.filterModuleCollectionBeforeAjax( updatedModuleCollection ) );
5204
  } );
5205
  },
5206
+
5207
+ //////////////////////////////////
5208
+ ///READY
5209
+ //////////////////////////////////
5210
+ //when a module is embedded in a sektion, we need to render it before ready is done
5211
+ //=> this allows us to override the container element declared in the parent initialize
5212
+ //when ready done => the module items are embedded (without their content)
5213
  ready : function( is_added_by_user ) {
5214
  var module = this;
5215
  api.consoleLog('MODULE READY IN EXTENDED MODULE CLASS : ', module.id );
5220
  module.container = $_module_container;
5221
  module.embedded.resolve();
5222
  } );
5223
+ //run the parent initialize
5224
  parentConstructor.prototype.ready.call( module );
5225
+ //module.isReady.resolve();
5226
  }
5227
 
5228
  });
5229
  return control.CZRModuleExtended;
5230
  },
5231
+
5232
+
5233
+ //this object holds the various methods allowing a module to be rendered in a multimodule control
5234
  CZRModuleExtended : {
5235
+ //fired in ready.
5236
+ //=> before isReady.done().
5237
  renderModuleWrapper : function( is_added_by_user ) {
5238
+ //=> an array of objects
5239
  var module = this;
5240
+
5241
+ //has this module view already been rendered?
5242
  if ( 'resolved' == module.embedded.state() )
5243
  return module.container;
5244
+
5245
+ //do we have view template script?
5246
  if ( 0 === $( '#tmpl-' + module.singleModuleWrapper ).length ) {
5247
  throw new Error('No template for module ' + module.id + '. The template script id should be : #tmpl-' + module.singleModuleWrapper );
5248
  }
5253
  type : module.module_type
5254
  },
5255
  $_module_el = $( module_wrapper_tmpl( tmpl_data ) );
5256
+
5257
+ //append the module wrapper to the column
5258
+ //if added by user, search for the module candidate element, render after and delete the element
5259
  if ( is_added_by_user ) {
5260
  $.when( $( '.czr-module-collection-wrapper' , module._getColumn().container ).find( '.czr-module-candidate').after( $_module_el ) ).
5261
  done( function() {
5265
  $( '.czr-module-collection-wrapper' , module._getColumn().container).append( $_module_el );
5266
  }
5267
 
5268
+
5269
+ // //then append the ru module template
5270
+ // var mod_content_wrapper_tmpl = wp.template( module.ruModuleEl ),
5271
+ // $_mod_content_wrapper = $( mod_content_wrapper_tmpl( tmpl_data ) );
5272
+
5273
+ // $( '.czr-mod-content', $_module_el).append( $_mod_content_wrapper );
5274
+
5275
  return $_module_el;
5276
  },
5277
 
5283
  var module = this;
5284
 
5285
  module.view_event_map = [
5286
+ //toggles remove view alert
5287
  {
5288
  trigger : 'click keydown',
5289
  selector : [ '.czr-remove-mod', '.' + module.control.css_attr.cancel_alert_btn ].join(','),
5290
  name : 'toggle_remove_alert',
5291
  actions : ['toggleModuleRemoveAlert']
5292
  },
5293
+ //removes module and destroys its view
5294
  {
5295
  trigger : 'click keydown',
5296
  selector : '.' + module.control.css_attr.remove_view_btn,
5297
  name : 'remove_module',
5298
  actions : ['removeModule']
5299
  },
5300
+ //edit view
5301
  {
5302
  trigger : 'click keydown',
5303
  selector : '.czr-edit-mod',
5315
  selector : '.czr-mod-header',
5316
  name : 'hovering_module',
5317
  actions : function( obj ) {
5318
+ api.previewer.send( 'start_hovering_module', {
5319
  id : module.id
5320
  });
5321
  }
5325
  selector : '.czr-mod-header',
5326
  name : 'hovering_module',
5327
  actions : function( obj ) {
5328
+ api.previewer.send( 'stop_hovering_module', {
5329
  id : module.id
5330
  });
5331
  }
5332
  }
5333
  ];
5334
+
5335
+ //defer actions on module view embedded
5336
  module.embedded.done( function() {
5337
+ //add a listener on view state change
5338
  module.czr_ModuleState.callbacks.add( function() { return module.setupModuleViewStateListeners.apply(module, arguments ); } );
5339
+
5340
+ //setup DOM listener
5341
  api.CZR_Helpers.setupDOMListeners(
5342
  module.view_event_map,//actions to execute
5343
  { module : { id : module.id } , dom_el:module.container },//model + dom scope
5345
  );//listeners for the view wrapper
5346
  });
5347
  },
5348
+
5349
+ //fired on click
5350
  setModuleViewVisibility : function( obj, is_added_by_user ) {
5351
  var module = this;
5352
 
5353
  module.czr_ModuleState( ! module.czr_ModuleState() );
5354
+
5355
+ //always close the module panel
5356
  api.czrModulePanelState.set(false);
5357
+ //always close the sektion settings panel
5358
  api.czrSekSettingsPanelState.set(false);
5359
+
5360
+ //close all sektions but the one from which the button has been clicked
5361
  module.control.syncSektionModule().closeAllOtherSektions( $(obj.dom_event.currentTarget, obj.dom_el ) );
5362
+
5363
+ // if ( is_added_by_user ) {
5364
+ // item.viewState.set( 'expanded_noscroll' );
5365
+ // } else {
5366
+ // module.closeAllItems( item.id );
5367
+ // if ( _.has(module, 'preItem') ) {
5368
+ // module.preItemExpanded.set( false );
5369
+ // }
5370
+ // }
5371
+ // item.viewState.set( 'expanded' == item._getViewState() ? 'closed' : 'expanded' );
5372
+ // }
5373
  },
5374
+
5375
+ //fired on click
5376
  sendEditModule : function( obj ) {
5377
  var module = this;
5378
+ api.previewer.send( 'edit_module', {
5379
  id : module.id
5380
  });
5381
  },
5382
+
5383
+ //cb of module.czr_ModuleState.callbacks
5384
+ //On first module expansion, render the module item(s) content
5385
  setupModuleViewStateListeners : function( expanded ) {
5386
  var module = this;
5387
+ //setup an api value for the current opened module.
5388
  api.czr_isModuleExpanded = api.czr_isModuleExpanded || new api.Value();
5389
 
5390
  if ( expanded )
5391
  api.czr_isModuleExpanded( module );
5392
  else
5393
  api.czr_isModuleExpanded( false );
5394
+
5395
+ //expand / collapse
5396
  $.when( module.toggleModuleViewExpansion( expanded ) ).done( function() {
5397
  if ( expanded ) {
5398
+ //render the module title
5399
  module.renderModuleTitle();
5400
+
5401
+ //populates the saved items collection
5402
  module.populateSavedItemCollection();
5403
+
5404
+ //render the item(s)
5405
+ //on first rendering, use the regular method.
5406
+ //for further re-rendering, when the embedded state is resolved()
5407
+ // => 1) re-render each item
5408
+ // => 2) re-instantiate each input
5409
+ // module.czr_Item.each ( function( item ) {
5410
+ // if ( ! item.module.isMultiItem() )
5411
+ // item.viewState.set('expanded');
5412
+ // if ( 'resolved' == item.embedded.state() ) {
5413
+ // $.when( item.renderItemWrapper() ).done( function( $_item_container ) {
5414
+ // item.container = $_item_container;
5415
+
5416
+ // $.when( item.renderItemContent() ).done( function() {
5417
+ // api.CZR_Helpers.setupInputCollectionFromDOM.call( item );
5418
+ // });
5419
+
5420
+ // if ( ! item.module.isMultiItem() )
5421
+ // item.viewState.set('expanded');
5422
+ // });
5423
+
5424
+ // }
5425
+ // else {
5426
+ // item.mayBeRenderItemWrapper();
5427
+ // }
5428
+ // } );
5429
  }
5430
  else {
5431
  module.czr_Item.each ( function( item ) {
5432
  item.viewState.set('closed');
5433
  item._destroyView( 0 );
5434
+ //api.CZR_Helpers.removeInputCollection.call( item );
5435
  module.czr_Item.remove( item.id );
5436
  } );
5437
  }
5443
  var module = this;
5444
  if( 'resolved' == module.moduleTitleEmbedded.state() )
5445
  return;
5446
+
5447
+ //render the module title
5448
+ //do we have view template script?
5449
  if ( 0 === $( '#tmpl-' + module.sektionModuleTitle ).length ) {
5450
  throw new Error('No sektion title Module Part template for module ' + module.id + '. The template script id should be : #tmpl-' + module.sektionModuleTitle );
5451
  }
5452
+ //append the title when in a sektion and resolve the embedded state
5453
  $.when( $( module.container ).find('.czr-mod-content').prepend(
5454
  $( wp.template( module.sektionModuleTitle )( { id : module.id } ) )
5455
  ) ).done( function() {
5456
  module.moduleTitleEmbedded.resolve();
5457
  });
5458
  },
5459
+
5460
+
5461
+ //fired in setupModuleViewStateListeners()
5462
  toggleModuleViewExpansion : function( expanded, duration ) {
5463
  var module = this;
5464
+
5465
+ //slide Toggle and toggle the 'open' class
5466
  $( '.czr-mod-content' , module.container ).slideToggle( {
5467
  duration : duration || 200,
5468
  done : function() {
5480
  } else {
5481
  $_modTitle.focus();
5482
  }
5483
+
5484
+ //close all alerts
5485
+ //module.closeRemoveDialogs();
5486
+
5487
+ //toggle the icon activate class depending on the status
5488
+ //switch icon
5489
+ //var $_edit_icon = $(this).siblings().find('.' + module.control.css_attr.edit_view_btn );
5490
+
5491
+ // $_edit_icon.toggleClass('active' , expanded );
5492
+ // if ( expanded )
5493
+ // $_edit_icon.removeClass('fa-pencil').addClass('fa-minus-square').attr('title', serverControlParams.i18n.close );
5494
+ // else
5495
+ // $_edit_icon.removeClass('fa-minus-square').addClass('fa-pencil').attr('title', serverControlParams.i18n.edit );
5496
+
5497
+ //scroll to the currently expanded view
5498
  if ( expanded )
5499
  module._adjustScrollExpandedBlock( module.container );
5500
  }//done callback
5515
  $_alert_el = $( '.' + module.control.css_attr.remove_alert_wrapper, module.container ).first(),
5516
  $_clicked = obj.dom_event,
5517
  $_column_container = control.syncSektionModule().czr_Column( module.column_id ).container;
5518
+
5519
+ //first close all open views
5520
+ //module.closeAllItems();
5521
+
5522
+ //close the main sektion pre_item view
5523
  if ( _.has(module, 'preItem') ) {
5524
  control.syncSektionModule().preItemExpanded.set( false );
5525
  }
5526
+
5527
+ //then close any other open remove alert in the column containuer
5528
  $('.' + module.control.css_attr.remove_alert_wrapper, $_column_container ).not($_alert_el).each( function() {
5529
  if ( $(this).hasClass('open') ) {
5530
  $(this).slideToggle( {
5531
  duration : 200,
5532
  done : function() {
5533
  $(this).toggleClass('open' , false );
5534
+ //deactivate the icons
5535
  $(this).siblings().find('.' + module.control.css_attr.display_alert_btn).toggleClass('active' , false );
5536
  }
5537
  } );
5538
  }
5539
  });
5540
+
5541
+ //print the html
5542
+ //do we have an html template and a control container?
5543
  if ( ! wp.template( module.AlertPart ) || ! module.container ) {
5544
  throw new Error( 'No removal alert template available for module :' + module.id );
5545
  }
5546
 
5547
  $_alert_el.html( wp.template( module.AlertPart )( { title : ( module().title || module.id ) } ) );
5548
+
5549
+ //toggle it
5550
  $_alert_el.slideToggle( {
5551
  duration : 200,
5552
  done : function() {
5553
  var _is_open = ! $(this).hasClass('open') && $(this).is(':visible');
5554
  $(this).toggleClass('open' , _is_open );
5555
+ //set the active class of the clicked icon
5556
  $( obj.dom_el ).find('.' + module.control.css_attr.display_alert_btn).toggleClass( 'active', _is_open );
5557
+ //adjust scrolling to display the entire dialog block
5558
  if ( _is_open )
5559
  module._adjustScrollExpandedBlock( module.container );
5560
  }
5561
  } );
5562
  },
5563
+
5564
+
5565
+
5566
+
5567
+ //@param module = obj => the module model
5568
+ //Fired on click
5569
  removeModule : function( obj ) {
5570
  this.control.removeModule( obj.module );
5571
  },
5595
  });//$.extend//CZRBaseControlMths
5596
  })( wp.customize , jQuery, _ );
5597
  ( function ( api, $, _ ) {
5598
+ //BASE
5599
+ //BASE : Extends some constructors with the events manager
5600
  $.extend( CZRBaseControlMths, api.Events );
5601
  $.extend( api.Control.prototype, api.Events );//ensures that the default WP control constructor is extended as well
5602
  $.extend( CZRModuleMths, api.Events );
5603
  $.extend( CZRItemMths, api.Events );
5604
  $.extend( CZRModOptMths, api.Events );
5605
+
5606
+ //BASE : Add the DOM helpers (addAction, ...) to the Control Base Class + Input Base Class
5607
  $.extend( CZRBaseControlMths, api.CZR_Helpers );
5608
  $.extend( CZRInputMths, api.CZR_Helpers );
5609
  $.extend( CZRModuleMths, api.CZR_Helpers );
5610
+
5611
+ //BASE INPUTS => used as constructor when creating the collection of inputs
5612
  api.CZRInput = api.Value.extend( CZRInputMths );
5613
+ //Declare all available input type as a map
5614
  api.czrInputMap = api.czrInputMap || {};
5615
+ //input_type => callback fn to fire in the Input constructor on initialize
5616
+ //the callback can receive specific params define in each module constructor
5617
+ //For example, a content picker can be given params to display only taxonomies
5618
  $.extend( api.czrInputMap, {
5619
  text : '',
5620
  textarea : '',
5628
  password : '',
5629
  range_slider : 'setupRangeSlider'
5630
  });
5631
+
5632
+ //BASE ITEMS => used as constructor when creating the collection of models
5633
  api.CZRItem = api.Value.extend( CZRItemMths );
5634
+
5635
+ //BASE MODULE OPTIONS => used as constructor when creating module options
5636
  api.CZRModOpt = api.Value.extend( CZRModOptMths );
5637
+
5638
+ //BASE MODULES => used as constructor when creating the collection of modules
5639
  api.CZRModule = api.Value.extend( CZRModuleMths );
5640
  api.CZRDynModule = api.CZRModule.extend( CZRDynModuleMths );
5641
+
5642
+ //BASE COLUMNS => used as constructor
5643
+ //Columns are a pro feature, only part of the full build.
5644
  if ( ! _.isUndefined( window.CZRColumnMths ) ) {
5645
  api.CZRColumn = api.Value.extend( CZRColumnMths );
5646
  }
5647
+
5648
+ //BASE CONTROLS
5649
  api.CZRBaseControl = api.Control.extend( CZRBaseControlMths );
5650
  api.CZRBaseModuleControl = api.CZRBaseControl.extend( CZRBaseModuleControlMths );
5651
  api.CZRMultiModuleControl = api.CZRBaseModuleControl.extend( CZRMultiModuleControlMths );
5653
  $.extend( api.controlConstructor, {
5654
  czr_module : api.CZRBaseModuleControl,
5655
  czr_multi_module : api.CZRMultiModuleControl,
5656
+ //czr_sektions : api.CZRSektionsControl
5657
  });
5658
 
5659
  })( wp.customize, jQuery, _ );
5671
  * @return {object}
5672
  */
5673
  var _coreQuery = api.previewer.query;
5674
+
5675
+
5676
+ //@todo : turn those arguments into an object ?
5677
+ //the dyn_type can also be set to 'wp_default_type' when saving a skope excluded setting
5678
+ //@queryVars = {
5679
+ // skope_id : string,
5680
+ // action : string,
5681
+ // the_dirties : {},
5682
+ // dyn_type : string,
5683
+ // opt_name : string
5684
+ // }
5685
  api.previewer.query = function( queryVars ) {
5686
+ //if skope instantiation went wrong, serverControlParams.isSkopOn has been reset to false
5687
+ //=> that's why we check it here again before doing anything else
5688
  if ( ! serverControlParams.isSkopOn ) {
5689
  return _coreQuery.apply( this );
5690
  }
5691
+
5692
+ //IS SKOP ON
5693
+ //falls back to WP core treatment if skope is not on or if the requested skope is not registered
5694
  if ( ! _.has( api, 'czr_skope') ) {
5695
  api.consoleLog('QUERY : SKOPE IS NOT FULLY READY YEY. FALLING BACK ON CORE QUERY');
5696
  return _coreQuery.apply( this );
5697
  }
5698
+
5699
+ //HAS THE FIRST SKOPE COLLECTION BEEN POPULATED ?
5700
  if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() ) {
5701
  api.consoleLog('QUERY : INITIAL SKOPE COLLECTION NOT POPULATED YET. FALLING BACK ON CORE QUERY');
5702
  return _coreQuery.apply( this );
5703
  }
5704
+
5705
+ //the previewer is now skope aware
5706
  if ( 'pending' == api.czr_isPreviewerSkopeAware.state() ) {
5707
  api.czr_isPreviewerSkopeAware.resolve();
5708
+ //return _coreQuery.apply( this );
5709
  }
5710
+
5711
+ //Skope is fully ready but the query is accessed from core (widgets) or a plugin
5712
+ //=> fallback on the core method
5713
  if ( ! _.isObject( queryVars ) && 'resolved' == api.czr_initialSkopeCollectionPopulated.state() && 'resolved' == api.czr_initialSkopeCollectionPopulated.state() ) {
5714
  return _coreQuery.apply( this );
5715
  }
5716
+
5717
+ //IS THE SKOPE ID PROVIDED ?
5718
+ //When navigating in the preview, the skope_id might not be provided.
5719
+ //In this case, falls back on the activeSkope() or the global skope
5720
+ //skope_id = skope_id || api.czr_activeSkopeId() || api.czr_skopeBase.getGlobalSkopeId();
5721
  if ( _.isUndefined( queryVars.skope_id ) || ! _.isString( queryVars.skope_id ) ) {
5722
  queryVars.skope_id = api.czr_activeSkopeId() || api.czr_skopeBase.getGlobalSkopeId();
5723
  }
5734
  _to_return;
5735
 
5736
  queryVars = $.extend( _defaults, queryVars );
5737
+
5738
+ //ARE THE DIRTIES WELL FORMED OR NOT EMPTY ?
5739
  if ( ! _.isObject( queryVars.the_dirties ) ) {
5740
  api.consoleLog('QUERY PARAMS : ', queryVars );
5741
  throw new Error( 'QUERY DIRTIES MUST BE AN OBJECT. Requested action : ' + queryVars.action );
5742
  }
5743
+
5744
+ ///TO CHANGE ?
5745
  if ( 'pending' != api.czr_isPreviewerSkopeAware.state() && _.isNull( queryVars.skope_id ) ) {
5746
  api.consoleLog('QUERY PARAMS : ', queryVars );
5747
+ //api.consoleLog( 'OVERRIDEN QUERY : NO SKOPE ID. FALLING BACK ON CORE QUERY.' );
5748
  throw new Error( 'OVERRIDEN QUERY : NO SKOPE ID. FALLING BACK ON CORE QUERY. Requested action : ' + queryVars.action );
5749
+ //return _coreQuery.apply( this );
5750
  }
5751
+
5752
+ //IS THE REQUESTED ACTION AUTHORIZED ?
5753
  if ( ! _.contains( [ null, 'refresh', 'save', 'reset', 'changeset_update' ], queryVars.action ) ) {
5754
  api.consoleLog('QUERY PARAMS : ', queryVars );
5755
  throw new Error( 'A REQUESTED QUERY HAS NO AUTHORIZED ACTION. Requested action : ' + queryVars.action );
5756
  }
5757
+
5758
+ //@return an object of customized values for each of the current skopes :
5759
+ //{
5760
+ // 'skope_id_1' = { ... },
5761
+ // 'skope_id_2' = { ... }
5762
+ //}
5763
  var _getSkopesCustomized = function() {
5764
+ //if the initial skope collection has been populated, let's populate the skopeCustomized
5765
  if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() )
5766
  return {};
5767
  var _skpCust = {};
5768
+ //Loop current skopes collection
5769
+ //Exclude the global skope
5770
  _.each( api.czr_currentSkopesCollection(), function( _skp ) {
5771
  if ( 'global' == _skp.skope )
5772
  return;
5774
  } );
5775
  return _skpCust;
5776
  };
5777
+
5778
+
5779
+
5780
+ ///BUILD THE DIRTIES
5781
+ //There are cases ( _forceSidebarDirtyRefresh ) when the dirties can be passed as param
5782
+ //In this cases, we use them and assign them to the relevant customized object
5783
+ //Since 4.7 and the changeset introduction, the boolean param 'excludeCustomizedSaved' can be passed to the query
5784
  if ( _.isNull( queryVars.the_dirties ) || _.isEmpty( queryVars.the_dirties ) ) {
5785
  globalCustomized = api.dirtyValues( { unsaved: queryVars.excludeCustomizedSaved || false } );
5786
  skopeCustomized = _getSkopesCustomized();
5790
  else
5791
  skopeCustomized[ api.czr_activeSkopeId() ] = queryVars.the_dirties;
5792
  }
5793
+
5794
+
5795
+ ///HANDLE THE VARIOUS CASES : REFRESH, SAVE, RESET
5796
+ //on first load OR if the current skope is the customized one, build the globalCustomized the regular way : typically a refresh after setting change
5797
+ //otherwise, get the dirties from the requested skope instance : typically a save action on several skopes
5798
  switch( queryVars.action ) {
5799
  case null :
5800
  case 'refresh' :
5801
+ //INHERITANCE : FILTER THE DIRTIES
5802
+ //when refreshing the preview, we need to apply the skope inheritance to the customized values
5803
+ //apply the inheritance
5804
+ // var _inheritanceReadyCustomized = {};
5805
+ // _.each( skopeCustomized, function( _custValues, _skopId ) {
5806
+ // _inheritanceReadyCustomized[_skopId] = api.czr_skopeBase.applyDirtyCustomizedInheritance( _custValues, _skopId );
5807
+ // } );
5808
+ // skopeCustomized = _inheritanceReadyCustomized;
5809
+
5810
+ //globalCustomized = api.czr_skopeBase.applyDirtyCustomizedInheritance( globalCustomized, api.czr_skopeBase.getGlobalSkopeId() );
5811
  break;
5812
 
5813
  case 'changeset_update' :
5818
 
5819
 
5820
  case 'save' :
5821
+ // if ( _.isEmpty( queryVars.the_dirties ) ) {
5822
+ // throw new Error( 'QUERY : A SAVE QUERY MUST HAVE A NOT EMPTY DIRTY OBJECT TO SUBMIT' );
5823
+ // }
5824
+ //Set the Dyn type
5825
+ //the dyn type might be passed as a param to the query in some cases
5826
+ //typically to save skope excluded settings. In this case the dyn_type is set to false, to fall back on the default wp one : theme_mod or option
5827
  if ( _.isNull( queryVars.dyn_type ) )
5828
  queryVars.dyn_type = api.czr_skope( queryVars.skope_id )().dyn_type;//post_meta, term_meta, user_meta, trans, option
5829
  if ( _.isNull( queryVars.dyn_type ) || _.isUndefined( queryVars.dyn_type ) ) {
5830
  throw new Error( 'QUERY : A SAVE QUERY MUST HAVE A VALID DYN TYPE.' + queryVars.skope_id );
5831
  }
5832
+ //Set the dirties || api.czr_skopeBase.getSkopeDirties(skope_id) ?
5833
+ //globalCustomized = queryVars.the_dirties; //was : api.czr_skope( skope_id ).dirtyValues();
5834
  break;
5835
 
5836
  case 'reset' :
5837
+ //no specific treatment for reset
5838
  if ( _.isNull( queryVars.dyn_type ) )
5839
  queryVars.dyn_type = api.czr_skope( queryVars.skope_id )().dyn_type;//post_meta, term_meta, user_meta, trans, option
5840
  if ( _.isNull( queryVars.dyn_type ) || _.isUndefined( queryVars.dyn_type ) ) {
5842
  }
5843
  break;
5844
  }
5845
+
5846
+
5847
+ //BUILD THE CURRENT SKOPES ARRAY
5848
  var _current_skopes = {};
5849
  _.each( api.czr_currentSkopesCollection(), function( _skp ) {
5850
  _current_skopes[_skp.skope] = { id : _skp.id, opt_name : _skp.opt_name };
5851
  });
5852
+
5853
+
5854
+ //Before 4.7 and the changeset introduction, the queryVars were :
5855
+ //{
5856
+ // wp_customize: 'on',
5857
+ // theme: api.settings.theme.stylesheet,
5858
+ // customized: JSON.stringify( globalCustomized ),
5859
+ // nonce: this.nonce.preview
5860
+ //}
5861
+
5862
+ //Since 4.7 the queryVars are :
5863
+ //{
5864
+ // wp_customize: 'on',
5865
+ // customize_theme: api.settings.theme.stylesheet,
5866
+ // customized : JSON.stringify( api.dirtyValues( { unsaved: options && options.excludeCustomizedSaved } ) );
5867
+ // nonce: this.nonce.preview,
5868
+ // customize_changeset_uuid: api.settings.changeset.uuid
5869
+ //}
5870
+
5871
+ //common properties
5872
  _to_return = {
5873
  wp_customize: 'on',
5874
+ //theme is added after, because the property name has been changed to customize_theme in 4.7
5875
+ //always make sure that the customized values is not empty, otherwise nothing will be posted since 4.7.
5876
+ //@see api.PreviewFrame::run()
5877
  customized: '{}' == JSON.stringify( globalCustomized ) ? '{\"__not_customized__\"}' : JSON.stringify( globalCustomized ),
5878
  skopeCustomized: JSON.stringify( skopeCustomized ),
5879
  nonce: this.nonce.preview,
5887
  channel: this.channel(),
5888
  revisionIndex: api._latestRevision
5889
  };
5890
+
5891
+ //since 4.7
5892
  if ( api.czr_isChangeSetOn() ) {
5893
  _to_return = $.extend( _to_return , {
5894
  customize_theme: api.settings.theme.stylesheet,
5895
  customize_changeset_uuid: api.settings.changeset.uuid
5896
  });
5897
  }
5898
+ //before 4.7
5899
  else {
5900
  _to_return = $.extend( _to_return , {
5901
  theme: api.settings.theme.stylesheet
5902
  });
5903
  }
5904
+ // api.consoleLog('DIRTY VALUES TO SUBMIT ? ', globalCustomized, api.czr_skopeBase.getSkopeDirties(skope_id) );
5905
  return _to_return;
5906
 
5907
  };//api.previewer.query
5909
  })( wp.customize , jQuery, _ );
5910
  ( function ( api, $, _ ) {
5911
  api.bind( 'czr-skope-started', function() {
5912
+ var _original_save = api.previewer.save, response;
5913
+
5914
+ // OVERRIDES WP
5915
+ // Save the changesets for all skopes as post metas of the customize_changeset post
5916
+ // Then fire the original save method
5917
+ // => server side, if the changeset post status transitions to "publish", the skope metas attached to the customize_changeset post will be merged with the post metas of the skope post.
5918
+ // This "publish" case is handled by add_action( 'transition_post_status', 'ha_publish_skope_changeset_metas', 0, 3 );
5919
  api.previewer.save = function( args ) {
5920
+ //return api.czr_skopeSave.save( args );
5921
+ return api.requestChangesetUpdate()
5922
+ .always( function( _response_ ) {
5923
+ response = _response_.response;
5924
+ _original_save.apply( api.previewer, args ).done( function() {
5925
+ //<@4.9compat>
5926
+ //api.state( 'selectedChangesetStatus' ) was introduced in 4.9
5927
+ if ( api.state.has( 'selectedChangesetStatus' ) && 'publish' != api.state( 'selectedChangesetStatus' )() )
5928
+ return;
5929
+ //</@4.9compat>
5930
+ api.previewer.refresh( { waitSkopeSynced : true } )
5931
+ .fail( function( refresh_data ) {
5932
+ api.consoleLog('Refresh failed after a save action', refresh_data );
5933
+ })
5934
+ .done( function( refresh_data ) {
5935
+ //response can be undefined, always set them as an object with 'publish' changet_setstatus by default
5936
+ //because this will be used in various api events ( 'saved', ... ) that does not accept an undefined val.
5937
+ response = _.extend( { changeset_status : 'publish' }, response || {} );
5938
+ //POST PROCESS AFTER SAVE
5939
+ //Reset dirtyness
5940
+ //check if synchronized with server
5941
+ reactWhenSaveDone( refresh_data.skopesServerData );
5942
+ });
5943
+ });
5944
+ })
5945
+ .fail( function( _response_ ) {
5946
+ response = _response_.response;
5947
+ api.consoleLog( 'apiRequestChangesetUpdate failed => ', response );
5948
+ })
5949
+ .done( function( _response_ ) {});
5950
  };
5951
+
5952
+ //Fired when all submissions are done and the preview has been refreshed
5953
+ //@param {} skopesServerData looks like :
5954
+ //{
5955
+ // czr_skopes : [
5956
+ // 0 : { ... skope_model_0 ... },
5957
+ // 1 : { ... skope_model_1 ... },
5958
+ // 2 : { ... skope_model_2 ... }
5959
+ // ],
5960
+ // isChangesetDirty : boolean
5961
+ //}
5962
+ var reactWhenSaveDone = function( skopesServerData ) {
5963
+ var saved_dirties = {};
5964
+ skopesServerData = _.extend(
5965
+ {
5966
+ czr_skopes : [],
5967
+ isChangesetDirty : false
5968
+ },
5969
+ skopesServerData
5970
+ );
5971
+
5972
+ //STORE THE SAVED DIRTIES AND RESET THEM FOR EACH SKOPE
5973
+ // store the saved dirties with their opt name ! important because we will need to match the data sent by the server, before the skope id is generated
5974
+ // (will be used as param to update the db val property of each saved skope)
5975
+ // AND THEN reset them for each skope
5976
+ _.each( api.czr_skopeCollection(), function( _skp_ ) {
5977
+ saved_dirties[ _skp_.opt_name ] = api.czr_skopeBase.getSkopeDirties( _skp_.id );
5978
+ api.czr_skope( _skp_.id ).dirtyValues( {} );
5979
+ api.czr_skope( _skp_.id ).changesetValues( {} );
5980
+ });
5981
+
5982
+
5983
+ //ARE THE SAVED DIRTIES AND THE UPDATED DB VALUES SENT BY SERVER SYNCHRONIZED ?
5984
+ // => let's check if the server sends the same saved values
5985
+ // => reset the czr_saveDirties to default.
5986
+ var _notSyncedSettings = [],
5987
+ _sentSkopeCollection = skopesServerData.czr_skopes;
5988
+
5989
+ //api.consoleLog('REACT WHEN SAVE DONE', skopesServerData, saved_dirties, _sentSkopeCollection );;
5990
+
5991
+ _.each( saved_dirties, function( skp_data, _saved_opt_name ) {
5992
+ _.each( skp_data, function( _val, _setId ) {
5993
+ //first, let's check if the sent skopes have not changed ( typically, if a user has opened another page in the preview )
5994
+ if ( _.isUndefined( _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ) ) )
5995
+ return;
5996
+ //exclude ExcludedWPBuiltinSetting and not eligible theme settings from this check
5997
+ if ( ! api.czr_skopeBase.isSettingSkopeEligible( _setId ) )
5998
+ return;
5999
+
6000
+ var sent_skope_db_values = _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ).db,
6001
+ sent_skope_level = _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ).skope,
6002
+ wpSetId = api.CZR_Helpers.build_setId( _setId ),
6003
+ shortSetId = api.CZR_Helpers.getOptionName( _setId ),
6004
+ sent_set_val = sent_skope_db_values[wpSetId];
6005
+
6006
+ //for the global skope, the server won't send the settings for which the value has been reset to default
6007
+ //skip this case too
6008
+ if ( _.isUndefined( sent_set_val ) && 'global' == sent_skope_level && _val === serverControlParams.defaultOptionsValues[shortSetId] )
6009
+ return;
6010
+
6011
+ if ( _.isUndefined( sent_set_val ) || ! _.isEqual( sent_set_val, _val ) ) {
6012
+ _notSyncedSettings.push( { opt_name : _saved_opt_name, setId : wpSetId, server_val : sent_set_val, api_val : _val } );
6013
+ }
6014
+ });
6015
+ });
6016
+
6017
+ if ( ! _.isEmpty( _notSyncedSettings ) ) {
6018
+ api.consoleLog('SOME SETTINGS HAVE NOT BEEN PROPERLY SAVED : ', _notSyncedSettings );
6019
+ console.log('_notSyncedSettings', _notSyncedSettings );
6020
+ } else {
6021
+ api.consoleLog('ALL RIGHT, SERVER AND API ARE SYNCHRONIZED AFTER SAVE' );
6022
+ }
6023
+
6024
+ //SYNCHRONIZE THE API.SETTINGS.SETTINGS WITH THE SAVED VALUE FOR GLOBAL SKOPE
6025
+ //finally make sure the api.settings.settings values are always synchronized with the global skope instance
6026
+ api.czr_skopeBase.maybeSynchronizeGlobalSkope();
6027
+
6028
+ //UPDATE CURRENT SKOPE CONTROL NOTICES IN THE CURRENTLY EXPANDED SECTION
6029
+ api.czr_skopeBase.updateCtrlSkpNot( api.CZR_Helpers.getSectionControlIds() );
6030
+
6031
+ //MAKE SURE TO COLLAPSE THE CONTROL NOTICES AFTER SAVED IF CURRENT SKOPE IS GLOBAL
6032
+ var _setupSectionCtrlNotices = function() {
6033
+ var sectionCtrls = api.CZR_Helpers.getSectionControlIds( api.czr_activeSectionId() );
6034
+ _.each( sectionCtrls, function( ctrlId ) {
6035
+ if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
6036
+ return;
6037
+ var ctrl = api.control( ctrlId );
6038
+ if ( ! _.has( ctrl, 'czr_states' ) )
6039
+ return;
6040
+ ctrl.czr_states( 'noticeVisible' )( api.czr_skopeBase.isCtrlNoticeVisible( ctrlId ) );
6041
+ });
6042
+ };
6043
+ //_.delay( _setupSectionCtrlNotices, 500 );
6044
+ };//reactWhenSaveDone()
6045
  });//api.bind('ready')
6046
  })( wp.customize , jQuery, _ );
6047
  (function (api, $, _) {
6051
  /*****************************************************************************
6052
  * SYNCHRONIZER AUGMENTED
6053
  *****************************************************************************/
6054
+ // var _original_element_initialize = api.Element.prototype.initialize;
6055
+ // api.Element.prototype.initialize = function( element, options ) {
6056
+ // //call the original constructor
6057
+ // _original_element_initialize .apply( this, [element, options ] );
6058
+ // api.consoleLog('IN OVERRIDEN INITIALIZE ELEMENT ?');
6059
+ // // if ( this.element.is('select') ) {
6060
+ // // api.consoleLog('element, options', element, options);
6061
+ // // }
6062
+ // };
6063
+
6064
+ // //CHECKBOX WITH ICHECK
6065
  api.Element.synchronizer.checkbox.update = function( to ) {
6066
  this.element.prop( 'checked', to );
6067
  this.element.iCheck('update');
6071
  api.Element.synchronizer.val.update = function(to) {
6072
  var self = this,
6073
  _modifySynchronizer = function() {
6074
+ //SELECT CASE
6075
  if ( self.element.is('select') ) {
6076
+ //SELECT2 OR SELECTER
6077
+ //select2.val() documented https://select2.github.io/announcements-4.0.html
6078
  self.element.val(to).trigger('change');
6079
  } else if ( self.element.hasClass('wp-color-picker') ) {
6080
+ //COLOR PICKER CASE
6081
  self.element.val(to).trigger('change');
6082
  }
6083
  else {
6084
+ //falls back to the parent behaviour
6085
  self.element.val( to );
6086
  }
6087
  };
6088
+ //if skope on,
6089
+ //wait for skope to be fully loaded to alter this
6090
  if ( serverControlParams.isSkopOn ) {
6091
  if ( 'resolved' != api.czr_skopeReady.state() ) {
6092
  return _original.call( self, to );
6102
 
6103
  api.Element.synchronizer.val.refresh = function() {
6104
  var syncApiInstance = this;
6105
+ //SELECT CASE
6106
+ //Avoid null values because not taken into account by the api.value.set() method
6107
+ //=> keep the same var type empty if the setting val is reset by user
6108
  if ( this.element.is('select') && _.isNull( this.element.val() ) ) {
6109
  if ( _.isArray( syncApiInstance() ) )
6110
  return [];
6113
  else
6114
  return '';
6115
  } else {
6116
+ //falls back to the parent behaviour
6117
  return this.element.val();
6118
  }
6119
  };
6129
  );
6130
 
6131
  var previewer = this, dfd = $.Deferred();
6132
+
6133
+ //if skope instantiation went wrong, serverControlParams.isSkopOn has been reset to false
6134
+ //=> that's why we check it here again before doing anything else
6135
  if ( ! serverControlParams.isSkopOn ) {
6136
  return dfd.resolve().promise();
6137
  }
6138
+
6139
+ //if too early, then let's fall back on core
6140
  if ( ! _.has( api, 'czr_activeSkopeId') || _.isUndefined( api.czr_activeSkopeId() ) ) {
6141
  api.consoleLog( 'The api.czr_activeSkopeId() is undefined in the api.previewer._new_refresh() method.');
6142
+ //Fire the core one
6143
  coreRefresh.apply( previewer );
6144
  return dfd.resolve().promise();
6145
+
6146
+ //PREVIOUS CODE
6147
+ // if ( 'resolved' != api.czr_skopeReady.state() ) {
6148
+ // api.czr_skopeReady.done( function() {
6149
+ // _new_refresh.apply( api.previewer, params );
6150
+ // });
6151
+ // //Fire the core one
6152
+ // coreRefresh.apply( previewer );
6153
+ // return dfd.resolve().promise();
6154
+ // }
6155
  }
6156
+
6157
+ // Display loading indicator
6158
  previewer.send( 'loading-initiated' );
6159
 
6160
  previewer.abort();
6173
  signature: 'WP_CUSTOMIZER_SIGNATURE'//will be deprecated in 4.7
6174
  });
6175
 
 
6176
  previewer.settingsModifiedWhileLoading = {};
6177
  onSettingChange = function( setting ) {
6178
  previewer.settingsModifiedWhileLoading[ setting.id ] = true;
6182
  previewer.loading.always( function() {
6183
  api.unbind( 'change', onSettingChange );
6184
  } );
6185
+
6186
+ //Needed before WP 4.7
6187
  if ( ! api.czr_isChangeSetOn() ) {
6188
  previewer._previousPreview = previewer._previousPreview || previewer.preview;
6189
  }
6210
  previewer.deferred.active.resolve();
6211
  delete previewer.loading;
6212
 
6213
+ //Before WP 4.7
6214
+ // if ( ! api.czr_isChangeSetOn() ) {
6215
+ // previewer.targetWindow( this.targetWindow() );
6216
+ // previewer.channel( this.channel() );
6217
+ // }
6218
+
6219
  api.trigger( 'pre_refresh_done', { previewer : previewer, skopesServerData : skopesServerData || {} } );
6220
  dfd.resolve( { previewer : previewer, skopesServerData : skopesServerData || {} } );
6221
  };
6222
+
6223
+ //Before WP 4.7 !!
6224
  if ( ! api.czr_isChangeSetOn() ) {
6225
  previewer.send( 'sync', {
6226
  scroll: previewer.scroll,
6231
  if ( params.waitSkopeSynced ) {
6232
  loadingFrame.bind( 'czr-skopes-synced', onceSynced );
6233
  } else {
6234
+ //default WP behaviour before and after 4.7
6235
  loadingFrame.bind( 'synced', onceSynced );
6236
  }
6237
+
6238
+
6239
+ // This event will be received directly by the previewer in normal navigation; this is only needed for seamless refresh.
6240
  previewer.trigger( 'ready', readyData );
6241
  });
6242
+
6243
+ // Note : the location param has been removed in WP 4.7
6244
  previewer.loading.fail( function( reason, location ) {
6245
+ api.consoleLog('LOADING FAILED : ' , reason, location, arguments );
6246
  previewer.send( 'loading-failed' );
6247
+ //Before WP 4.7 !!
6248
  if ( ! api.czr_isChangeSetOn() ) {
6249
  if ( 'redirect' === reason && location ) {
6250
  previewer.previewUrl( location );
6268
 
6269
  return dfd.promise();
6270
  };//_new_refresh()
6271
+
6272
+
6273
+
6274
+
6275
+ //'czr-skope-started' is fired after the skopeBase has been initialized.
6276
+ //the api is 'ready' at this point
6277
  api.bind( 'czr-skope-started' , function() {
6278
+ //post process after refresh
6279
+ //@param param = { previewer : previewer, skopesServerData : skopesServerData || {} }
6280
+ // api.bind( 'pre_refresh_done', function( params ) {
6281
+ // });
6282
  czr_override_refresh_for_skope();
6283
+ //OVERRIDES CORE
6284
  api.Previewer.prototype.refresh = _new_refresh;
6285
  });
6286
+
6287
+ //since 4.7 (when changeset has been introduced ), the core query takes parameter
6288
+ //Typically an object looking like { excludeCustomizedSaved: true }
6289
  api.czr_getSkopeQueryParams = function( params ) {
6290
  if ( ! api.czr_isChangeSetOn() )
6291
  return params;
6298
  }
6299
  return params;
6300
  };
6301
+
6302
+
6303
+ //fired on 'czr-skope-started', after the skopeBase has been initialized
6304
  czr_override_refresh_for_skope = function() {
6305
  if ( ! serverControlParams.isSkopOn )
6306
  return;
6309
  /**
6310
  * Refresh the preview.
6311
  */
6312
+ //The purpose of this refresh method is to pass additional params to the query()
6313
+ //=> we want to know the skope, and the action
6314
+ //=> here the action is always refresh.
6315
+ //=> this way we are able to better identify what to do in the api.previewer.query method
6316
+ //
6317
+ //@params can hold an obj looking like :
6318
+ //{
6319
+ // waitSkopeSynced : true,
6320
+ // the_dirties : {}
6321
+ //}
6322
+ //
6323
+ //When waitSkopeSynced is set to true, the refresh will wait for the 'czr_skopes_synced' event to be synced
6324
+ //if not, it waits for the default 'synced' wp event to be resolved
6325
+ //api.previewer._new_refresh = _new_refresh;
6326
+
6327
+ // Debounce to prevent hammering server and then wait for any pending update requests.
6328
+ // Overrides the WP api.previewer.refresh method
6329
+ // We may need to pass force dirties here
6330
  api.previewer.refresh = function( _params_ ) {
6331
  var dfd = $.Deferred();
6332
  var _refresh_ = function( params ) {
6378
  ( function ( api, $, _ ) {
6379
  if ( ! serverControlParams.isSkopOn || ! api.czr_isChangeSetOn() )
6380
  return;
6381
+
6382
+ //WP Changeset is requested for an update with an ajax query in the following situation :
6383
+ //1) before unloading the window
6384
+ //2) when focus removed from window.
6385
+ //3) on schedule : every 60 000 ms. ( api.settings.timeouts.changesetAutoSave ) <= set to 10 000 ms on api 'ready' for skope
6386
+ //
6387
+ //
6388
+ //But the update will only takes place if the current api.dirtyValues() are not empty. That's the problem we address with this override.
6389
+ //The function api.dirtyValues() only returns :
6390
+ //1) the dirty settings of the global skope
6391
+ //2) AND that have not been saved during the latest saved revision ( api._lastSavedRevision )
6392
+ //
6393
+ //
6394
+ //So we need to find a way to fire a changeset update for all the other skopes
6395
+ //The proposed solution here is to base the changeset update decision not on the emptyness of the dirtyValues but on the api._latestRevision index.
6396
+ //
6397
+ //
6398
+ //How does the saved and revision index works.
6399
+ //api._lastSavedRevision is set when the changeset update request is done() with the following code :
6400
+ //api._lastSavedRevision = Math.max( api._latestRevision, api._lastSavedRevision );
6401
+ //
6402
+ //api._latestRevision is incremented +1 each time a setting change occurs in the api. Not matter in which skope this change has been done.
6403
+ //
6404
+ //Therefore, as soon as we detect that api._latestRevision > api._lastSavedRevision, then we can authorize a changeset update.
6405
+ //The changeset update request will pass the usual skope query parameters, including the current skope dirtyness.
6406
+ //=> this will allow an ajax update of the changeset post metas for the modified skopes.
6407
+ //
6408
+ //
6409
+ //IMPORTANT :
6410
+ //If the 0 === api._lastSavedRevision is empty and that we are not customizing the global skope,
6411
+ //it means that the changeset post ID will not be set yet
6412
+ //=> But the skope meta changeset need a post ID ! when doing the ajax request server side
6413
+ //so the original method has to be fired with a dummy change,
6414
+ //this will pass the write the _.isEmpty( submittedChanges ) test in api.requestChangesetUpdate() and create a post ID
6415
+
6416
+
6417
+ //Backup the original method
6418
  var _original_requestChangesetUpdate = api.requestChangesetUpdate;
6419
 
6420
  /**
6421
  * Request updates to the changeset.
6422
+ * @since 4.7.0
6423
+ * @access public
6424
  *
6425
+ * @param {object} [changes] - Mapping of setting IDs to setting params each normally including a value property, or mapping to null.
6426
+ * If not provided, then the changes will still be obtained from unsaved dirty settings.
6427
+ * @param {object} [_args_] - Additional options for the save request.
6428
+ * @param {boolean} [_args_.autosave=false] - Whether changes will be stored in autosave revision if the changeset has been promoted from an auto-draft.
6429
+ * @param {boolean} [_args_.force=false] - Send request to update even when there are no changes to submit. This can be used to request the latest status of the changeset on the server.
6430
+ * @param {string} [_args_.title] - Title to update in the changeset. Optional.
6431
+ * @param {string} [_args_.date] - Date to update in the changeset. Optional.
6432
+ * @returns {jQuery.Promise} Promise resolving with the response data.
6433
  */
6434
+ //@4.9compat : added _args_
6435
+ api.requestChangesetUpdate = function( changes, _args_ ) {
6436
  var self = this,
6437
  dfd = $.Deferred(),
6438
  data,
6442
  failedPromises = [],
6443
  _all_skopes_data_ = [],
6444
  _recursiveCallDeferred = $.Deferred();
6445
+ // _original = function( changes ) {
6446
+ // _original_requestChangesetUpdate(changes).then( function( data ) {
6447
+ // dfd.resolve( data );
6448
+ // });
6449
+ // };
6450
+ //<@4.9compat>
6451
+ _args_ = _args_ || {};
6452
+ //</@4.9compat>
6453
+ //if skope instantiation went wrong, serverControlParams.isSkopOn has been reset to false
6454
+ //=> that's why we check it here again before doing anything else
6455
  if ( ! serverControlParams.isSkopOn ) {
6456
  return _original_requestChangesetUpdate();
6457
  }
6458
+
6459
+
6460
+ //MAKES SURE THAT A CHANGESET POST ID EXISTS
6461
+ //=> add a dummy_change to global if if ( 0 === api._lastSavedRevision || _.isEmpty( api.state( 'changesetStatus' )() ) )
6462
+ //
6463
+ //and that we are not customizing the global skope,
6464
+ //it means that the changeset post ID will not be set yet, so let's fire the original
6465
+ //The core WP method will only create a new changeset post if there is something to save
6466
+ //=> that's the purpose of this dummy_change
6467
  if ( 0 === api._lastSavedRevision || _.isEmpty( api.state( 'changesetStatus' )() ) ) {
6468
  _global_skope_changes = _.extend( _global_skope_changes, {
6469
  blogname : { dummy_change : 'dummy_change' }
6470
  } );
6471
  }
6472
+
6473
+ //POPULATE THE SKOPE CHANGESET UPDATES PROMISES
6474
+ //Loop current skopes collection
6475
+ //Exclude the global skope
6476
  _.each( api.czr_currentSkopesCollection(), function( _skp ) {
6477
  if ( 'global' == _skp.skope )
6478
  return;
6497
  }
6498
  return true;
6499
  };
6500
+
6501
+
6502
+ // recursive pushes for not global skopes
6503
  var recursiveCall = function( _index ) {
6504
+ //on first push run, set the api state to processing.
6505
+ // Make sure that publishing a changeset waits for all changeset update requests to complete.
6506
  if ( _.isUndefined( _index ) || ( ( 0 * 0 ) == _index ) ) {
6507
  api.state( 'processing' ).set( 1 );
6508
  }
6512
  api.consoleLog( 'Undefined Skope in changeset recursive call ', _index, _skopesToUpdate, _skopesToUpdate[_index] );
6513
  return _recursiveCallDeferred.resolve( _all_skopes_data_ ).promise();
6514
  }
6515
+
6516
+ //_promises.push( self.getSubmitPromise( _skopesToUpdate[ _index ] ) );
6517
+ ////@4.9compat : added _args_ param
6518
+ api._requestSkopeChangetsetUpdate( changes, _skopesToUpdate[_index], _args_ )
6519
  .always( function() { _promises.push( _index ); } )
6520
  .fail( function( response ) {
6521
  failedPromises.push( response );
6531
 
6532
  return _recursiveCallDeferred.promise();
6533
  };
6534
+
6535
+
6536
+
6537
+
6538
+ //RESOLVE WITH THE WP GLOBAL CHANGESET PROMISE WHEN ALL SKOPE PROMISES ARE DONE
6539
+ //PROBLEM TO SOLVE : in the core original changeset method, the api._lastSavedRevision property is incremented when global dirties are saved
6540
+ //=> between the core changeset update and before the skope changeset update, we need to reset the api._lastSavedRevision to its previous value
6541
+ //=> otherwise some dirties might not be taken into account in the skope.
6542
+ //=> This can happen typically for a setting dirty both in global and other skope(s)
6543
  var _lastSavedRevisionBefore = api._lastSavedRevision;
6544
+ //@4.9 compat : added _args_ param
6545
+ _original_requestChangesetUpdate( _global_skope_changes, _args_ )
6546
  .fail( function( r ) {
6547
  api.consoleLog( 'WP requestChangesetUpdateFail', r, api.czr_skopeBase.buildServerResponse(r) );
6548
+
6549
+ // Ensure that all settings updated subsequently will be included in the next changeset update request.
6550
  api._lastSavedRevision = Math.max( api._latestRevision, api._lastSavedRevision );
6551
+ //api.state( 'changesetStatus' ).set( _data_.changeset_status );
6552
+ // Make sure that publishing a changeset waits for all changeset update requests to complete.
6553
  api.state( 'processing' ).set( 0 );
6554
 
6555
  dfd.reject( r );
6556
  r = api.czr_skopeBase.buildServerResponse(r);
6557
+
6558
+ //<@4.9compat>
6559
+ if ( ! _.isUndefined( api.notifications ) ) {
6560
+ api.notifications.add( new wp.customize.Notification( 'changeset_update_failed', {
6561
+ type: 'error',
6562
+ message: r,
6563
+ dismissible: true
6564
+ } ) );
6565
+
6566
+ // Removed if not dismissed after 5 seconds
6567
+ _.delay( function() {
6568
+ if ( api.notifications.has( 'changeset_update_failed' ) ) {
6569
+ var _notif_ = api.notifications( 'changeset_update_failed' );
6570
+ if ( _notif_.parent ) {
6571
+ _notif_.parent.remove( _notif_.code );
6572
+ } else {
6573
+ _notif_.container.remove();
6574
+ }
6575
+ }
6576
+ }, 5000 );
6577
+ }
6578
+ //</@4.9compat>
6579
+ else {
6580
+ api.czr_serverNotification({
6581
+ status:'error',
6582
+ message : r
6583
+ });
6584
+ }
6585
  })
6586
  .done( function( wp_original_response ) {
6587
+ // $.when.apply( null, _promises ).then( function() {
6588
+ // dfd.resolve( wp_original_response );
6589
+ // });
6590
+ //Restore the _lastSavedRevision index to its previous state to not miss any setting that could have been updated by WP for global.
6591
+
6592
+ //Bail if attempting to update the skope changesets before the initial collection has been populated
6593
  if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() )
6594
  dfd.resolve( wp_original_response );
6595
 
6596
  api._lastSavedRevision = _lastSavedRevisionBefore;
6597
  recursiveCall()
6598
  .always( function() {
6599
+ // Ensure that all settings updated subsequently will be included in the next changeset update request.
6600
  api._lastSavedRevision = Math.max( api._latestRevision, api._lastSavedRevision );
6601
+
6602
+ //api.state( 'changesetStatus' ).set( _data_.changeset_status );
6603
+ // Make sure that publishing a changeset waits for all changeset update requests to complete.
6604
  api.state( 'processing' ).set( 0 );
6605
  })
6606
  .fail( function( r ) {
6616
 
6617
  return dfd.promise();
6618
  };
6619
+
6620
+
6621
+
6622
+ //@update the changeset meta for a given skope
6623
+ //Adapted copy from the original api.requestChangesetUpdate()
6624
+ //@4.9compat : added _args_ param
6625
+ api._requestSkopeChangetsetUpdate = function( changes, skope_id, _args_ ) {
6626
  if ( _.isUndefined( skope_id ) || ! api.czr_skope.has( skope_id ) ) {
6627
  throw new Error( 'In api._requestSkopeChangetsetUpdate() : a valid and registered skope_id must be provided' );
6628
  }
6630
  var deferred = new $.Deferred(),
6631
  request,
6632
  submittedChanges = {},
6633
+ data,
6634
+ submittedArgs;
6635
+
6636
+ //if no skope has been provided, then let's use the active one
6637
  skope_id = skope_id || api.czr_activeSkopeId();
6638
 
6639
+ //<@4.9compat>
6640
+ // Prevent attempting changeset update while request is being made.
6641
+ // Disabled
6642
+ // if ( 0 !== api.state( 'processing' ).get() ) {
6643
+ // deferred.reject( 'already_processing' );
6644
+ // return deferred.promise();
6645
+ // }
6646
+
6647
+ //<@4.9compat>
6648
+ submittedArgs = _.extend( {
6649
+ title: null,
6650
+ date: null,
6651
+ autosave: false,
6652
+ force: false
6653
+ }, _args_ );
6654
+ //</@4.9compat>
6655
+
6656
  if ( changes ) {
6657
  _.extend( submittedChanges, changes );
6658
  }
6659
+
6660
+
6661
+ //Ensure all revised settings (changes pending save) are also included, but not if marked for deletion in changes.
6662
  _.each( api.czr_skopeBase.getSkopeDirties( skope_id ) , function( dirtyValue, settingId ) {
6663
  if ( ! changes || null !== changes[ settingId ] ) {
6664
  submittedChanges[ settingId ] = _.extend(
6668
  );
6669
  }
6670
  } );
6671
+
6672
+ // _.each( api.czr_skope( skope_id ).dirtyValues(), function( dirtyValue, settingId ) {
6673
+ // submittedChanges[ settingId ] = _.extend(
6674
+ // { value: dirtyValue }
6675
+ // );
6676
+ // } );
6677
+
6678
+ //<@4.9compat>
6679
+ // Short-circuit when there are no pending changes.
6680
+ if ( ! submittedArgs.force && _.isEmpty( submittedChanges ) && null === submittedArgs.title && null === submittedArgs.date ) {
6681
  deferred.resolve( {} );
6682
  return deferred.promise();
6683
  }
6684
 
6685
+ // A status would cause a revision to be made, and for this wp.customize.previewer.save() should be used. Status is also disallowed for revisions regardless.
6686
+ if ( submittedArgs.status ) {
6687
+ return deferred.reject( { code: 'illegal_status_in_changeset_update' } ).promise();
6688
+ }
6689
+
6690
+ // Dates not being allowed for revisions are is a technical limitation of post revisions.
6691
+ if ( submittedArgs.date && submittedArgs.autosave ) {
6692
+ return deferred.reject( { code: 'illegal_autosave_with_date_gmt' } ).promise();
6693
+ }
6694
+ //</@4.9compat>
6695
+
6696
  if ( api._latestRevision <= api._lastSavedRevision ) {
6697
  deferred.resolve( {} );
6698
  return deferred.promise();
6699
  }
6700
+
6701
+ // Allow plugins to attach additional params to the settings.
6702
  api.trigger( 'skope-changeset-save', submittedChanges );
6703
 
6704
  var queryVars = {
6706
  action : 'changeset_update',
6707
  opt_name : api.czr_skope( skope_id ).opt_name
6708
  };
6709
+
6710
+ //BUILD THE QUERY
6711
  data = api.previewer.query( _.extend( queryVars, { excludeCustomizedSaved: true } ) );
6712
  delete data.customized; // Being sent in customize_changeset_data instead.
6713
  _.extend( data, {
6714
  nonce: api.settings.nonce.save,
6715
  customize_changeset_data: JSON.stringify( submittedChanges )
6716
  } );
6717
+
6718
+ // var _dumby_request = function( _data ) {
6719
+ // var dfd = $.Deferred();
6720
+ // setTimeout( function() {
6721
+ // dfd.resolve( _data );
6722
+ // }, 5000 );
6723
+ // return dfd.promise();
6724
+ // };
6725
+
6726
+ ////////////////////// FIRE THE REQUEST //////////////////////
6727
+ //request = _dumby_request( data );
6728
  wp.ajax.post( 'customize_skope_changeset_save', data )
6729
  .done( function requestChangesetUpdateDone( _data_ ) {
6730
+ //api.consoleLog('SKOPE CHANGETSET DONE FOR SKOPE ' + _data_.skope_id , _data_ );
6731
  deferred.resolve( _data_ );
6732
+ //api.trigger( 'changeset-saved', _data_ );
6733
  } )
6734
  .fail( function requestChangesetUpdateFail( _data_ ) {
6735
  api.consoleLog('SKOPE CHANGESET FAIL FOR SKOPE ' + _data_.skope_id, _data_ );
6736
  deferred.reject( _data_ );
6737
+ //api.trigger( 'changeset-error', _data_ );
6738
  } )
6739
  .always( function( _data_ ) {
6740
+ if ( ! _.isUndefined( _data_ ) && _data_.setting_validities ) {
6741
  api._handleSettingValidities( {
6742
+ settingValidities: _data_.setting_validities,
6743
+ focusInvalidControl: true
6744
  } );
6745
  }
6746
  } );
6752
  /*****************************************************************************
6753
  * FIRE SKOPE ON READY
6754
  *****************************************************************************/
6755
+ //this promise will be resolved when
6756
+ //1) the initial skopes collection has been populated
6757
+ //2) the initial skope has been switched to
6758
+ //
6759
+ //OR if skope is disabled
6760
+ //note : api.czr_skopeReady has been declared earlier, in the early helpers
6761
  api.bind( 'ready' , function() {
6762
  if ( serverControlParams.isSkopOn ) {
6763
  api.czr_isLoadingSkope = new api.Value( false );
6765
  toggleSkopeLoadPane( loading );
6766
  });
6767
  api.czr_skopeBase = new api.CZR_skopeBase();
6768
+ //api.czr_skopeSave = new api.CZR_skopeSave();
6769
  api.czr_skopeReset = new api.CZR_skopeReset();
6770
 
6771
  api.trigger('czr-skope-started');
6772
+
6773
+ //@return void()
6774
+ //This top note will be rendered 40s and self closed if not closed before by the user
6775
  var _toggleTopFailureNote = function() {
6776
  api.czr_skopeBase.toggleTopNote( true, {
6777
  title : serverControlParams.i18n.skope['There was a problem when trying to load the customizer.'],
6793
  })
6794
  .fail( function( error ) {
6795
  api.errorLog( 'Skope could not be instantiated : ' + error );
6796
+ //This top note will be rendered 40s and self closed if not closed before by the user
6797
  _toggleTopFailureNote();
6798
  serverControlParams.isSkopOn = false;
6799
  })
6800
  .always( function() {
6801
  api.czr_isLoadingSkope( false );
6802
  });
6803
+
6804
+ //If skope was properly instantiated but there's another problem occuring after, display a self closing top notification after 30 s
6805
  if ( 'rejected' != api.czr_skopeReady.state() ) {
6806
+ //Make sure the loading icon panel is destroyed after a moment
6807
+ //Typically if there was a problem in the WP js API and the skope could not be initialized
6808
+ //if the skopeReady state is still pending after 40 seconds, there's obviously a problem
6809
  setTimeout( function() {
6810
  if ( 'pending' == api.czr_skopeReady.state() ) {
6811
+ //This top note will be rendered 40s and self closed if not closed before by the user
6812
  _toggleTopFailureNote();
6813
 
6814
  api.czr_isLoadingSkope( false );
6816
  }, 40000);
6817
  }
6818
  }
6819
+
6820
+ //let's set a lower autosave interval ( default is 60000 ms )
6821
  if ( serverControlParams.isChangeSetOn ) {
6822
  api.settings.timeouts.changesetAutoSave = 10000;
6823
  }
6824
  } );
6825
+
6826
+ //INCLUDE THE REVISION COUNT IF WP < 4.7
6827
  if ( ! _.has( api, '_latestRevision') ) {
6828
  /**
6829
  * Current change count.
6855
  } );
6856
  } );
6857
  }
6858
+
6859
+ //@fired before skopeReady
6860
  var toggleSkopeLoadPane = function( loading ) {
6861
  loading = _.isUndefined( loading ) ? true : loading;
6862
  var self = this, $skopeLoadingPanel,
6890
  });
6891
  }, 50);
6892
  };
6893
+
6894
+ //display load pane if skope is not yet ready and loading is true
6895
  if ( 'pending' == api.czr_skopeReady.state() && loading ) {
6896
  $('body').addClass('czr-skop-loading');
6897
  _render()
6903
  return;
6904
 
6905
  _.delay( function() {
6906
+ //set height
6907
  var _height = $('#customize-preview').height();
6908
  $skopeLoadingPanel.css( 'line-height', _height +'px' ).css( 'height', _height + 'px' );
6909
+ //display
6910
  $('body').addClass('czr-skope-pane-open');
6911
  }, 50 );
6912
  });
6915
  api.czr_skopeReady.done( function() {
6916
  _destroy();
6917
  });
6918
+ //if a destroy is requested, typically when the loading delay exceeds 15 seconds
6919
  if ( ! loading ) {
6920
  _destroy();
6921
  }
6923
 
6924
  })( wp.customize , jQuery, _);
6925
 
6926
+ //WHAT IS A SKOPE ?
6927
+ //A skope is an object describing a set of options for a given customization context
6928
+ //It is constructed by the czr_skopeModel constructor
6929
+ //it has a model with the following properties
6930
+ // - a name : 'global', 'all_posts'
6931
+ // - a corresponding database option name
6932
+ // - a database option type (dyn_type)
6933
+ // - a customization status : active, inactive. Are we currently customizing this skope ?
6934
+ // - a priority status that can be forced
6935
+ // - an applied status => is this skope the one that will be applied on front end in the current context?
6936
+ // => this status depends on :
6937
+ // 1) a default priority local (post id ) > global specific (all posts) > global (default options)
6938
+ // 2) a user decision : a priority can be forced. For example who is the winner when two categories have been customized ?
6939
+ // - a dirtyness status : has this skope been customized ?
6940
+ // - a set of values, each one having a dirtyness state => the : { optname#2 : { value : ..., _dirty : bool }, optname#2 : {...}, ... }
6941
+ //
6942
+ // It is rendered with a view which includes DOM listeners.
6943
+ // Users can :
6944
+ // - customize each skope separately,
6945
+ // - force a priority
6946
+ // - reset a skope set of option
6947
+ // - copy the values of one skope to another
6948
+ //
6949
+ // What is the default skope ?
6950
+ // - 'global' when accessing the customizer from appearance > customize
6951
+ // - 'local' when customizing from the front end, or an edit screen : post (post, cpt, page, attachment), tax term, user
6952
+ //
6953
+ // What are the options eligibile for the skope customization ?
6954
+ // - the skope customization can be applied to all theme settings 'hu_theme_options'. The option not eligible have been flagged 'no-skope' when registered server side.
6955
+ // - the WP built-in settings like blogname, site-icon,... are also eligible
6956
+ // - all other settings like menu, widgets, sidebars are excluded for the moment.
6957
+ //
6958
+ // On init, the default skope is set as active.
6959
+ // if the default skope is not 'global', then the switch to the relevant skope is triggered and the eligible settings values are updated "silently"
6960
+ // the dirties are stored in each skope models when the user customize
6961
+ //
6962
+ //
6963
+ // On skope switch,
6964
+ // 1) the values of the dirty values of the current skope are stored in the model
6965
+ // 2) the values of the new skope are fetched from the db if they have not been yet.
6966
+ // 3) all eligible settings are updated with the new values.
6967
+ // 4) if the new skope has no dirty value yet, the saved state is reset.
6968
+ //
6969
+ //
6970
+ //
6971
+ //
6972
+ //
6973
+ // WHAT IS THE SKOPE PRIORITY CONCEPT ?
6974
+ // Since a given option can have its value set differently for each skope level, a priority must be defined, in order to know what is the value to use.
6975
+ //
6976
+ // => The skope priority defines which option value will be used if this option has been customized in several skopes.
6977
+ //
6978
+ // There are 3 main levels of skopes :
6979
+ // 1) GLOBAL : the options applied to the entire website. Those are saved in the regular (the old) theme options
6980
+ // 2) SPECIAL GROUP : those groups are dynamically set, depending on how a user creates a post or a page
6981
+ // all posts from a specific author,
6982
+ // all posts tagged with a specific tag,
6983
+ // all posts tagged with a specific category,
6984
+ // all pages using a specific template
6985
+ // 3) GROUP : the options applied to a group of contexts. Those are saved as long life transients
6986
+ // all pages,
6987
+ // all posts,
6988
+ // all tags,
6989
+ // all categories,
6990
+ // all authors,
6991
+ // 4) LOCAL : the options applied to a specific context :
6992
+ // a page,
6993
+ // a post (or a CPT),
6994
+ // an attachment,
6995
+ // a tag archive page,
6996
+ // a category archive page,
6997
+ // an author archive page,
6998
+ // the home page,
6999
+ // the 404 page,
7000
+ // the search results page,
7001
+ // Note: except for home, 404 and search which are saved as transients, the other local skopes are saved as metas : post metas, term metas, user metas
7002
+ //
7003
+ // Priorities without the special group (tag, cat, author):
7004
+ // - For a post, page or term : LOCAL (this post id) > GROUP (all posts) > GLOBAL (entire website options)
7005
+ // - For home, 404, search : LOCAL > GLOBAL. There's no GROUP in this case.
7006
+ // - for a term archive (tag, cat, custom tax) : LOCAL (the term id) > GROUP ( all terms of this type ) > GLOBAL
7007
+ //
7008
+ // Priorities with the special groups : this is relevant for post and pages only.
7009
+ // Let's take a post example.
7010
+ // A user can decide to define a set of option (a skope) for all posts tagged with a specific tag.
7011
+ // In this case the priority is : LOCAL > SPECIAL GROUP (the "post tagged with {tag}") > GROUP > GLOBAL
7012
+ // CONFLICT CASE : If a given post has several terms, and if more than one term have a customized skope.
7013
+ // => since no priority can be defined between two terms, the priority is back to the default : LOCAL > GROUP > GLOBAL
7014
+ // How to fix a conflict case ?
7015
+ // It is possible to force a "winner" within the special groups. When editing a skope, the user can check an option (! => force this skope when relevant )
7016
+ // => if there's a forced winner the priority becomes : LOCAL > FORCED SPECIAL GROUP > GROUP > GLOBAL
7017
+ // In the customizer, only one special group winner can be set at a time.
7018
+ // If different winners have been set in separate customization sessions, and that the user add several winners term in the post edit screen, it might happen that
7019
+ // a the customizer ends up to have several special group winners. In this case, a conflict notice is displayed in the skope dialog box, explaining how to resolve this
7020
+ // winner conflict. As long as the winner conflict is unresolved, the priority falls back to : LOCAL > GROUP > GLOBAL.
7021
+ //
7022
+ //
7023
+ //
7024
+ //
7025
+ //
7026
+ //
7027
+ // WHAT IS THE SKOPE INHERITANCE CONCEPT ?
7028
+ // In the customizer, all skopes are partially customized => For example, a page can only have specific layout options set
7029
+ // The question to adress is then : What about all the un-customized options of this skope? Which value should be applied ?
7030
+ //
7031
+ // The skope inheritance is the complement of the skope priority.
7032
+ // It addresses the problem of which values should be used for un-customized options in a given skope.
7033
+ //
7034
+ // Taking the same page example, if the "skin" option has not been set locally, then it checks the lower skope priority level.
7035
+ // In this case, the previous level is "All Pages".
7036
+ // If nothing has been set in the "All Pages", we'll go to the previous one : "Global."
7037
+ //
7038
+ // In the customizer, this skope inheritance has to be reflected so that user can immediately understand which option is applied to which skope.
7039
+ // For a given skope, all un-customized settings will inherit their value from the lower priority levels, down to GLOBAL.
7040
+ //
7041
+ //
7042
+ //
7043
+ // HOW DOES THIS WORK ?
7044
+ // CZR_skopeBase listens to skope collection changes
7045
+ // 1) instantiate new models (CZR_skope), remove old ones and their view
7046
+ // 2) sets each skope models active skope state changes
7047
+
7048
+
7049
+ // CZR_skope
7050
+ // 1) instantiate, the skope view (CZR_skopeView)
7051
+ // 2) listens to the active state
7052
+ // => store dirtyness on switch
7053
+ // => fetch the db values, build the full set of values ( db + dirties + default) and update the settings
7054
+
7055
+ // CZR_skopeView
7056
+ // 1) renders the view
7057
+ // 2) listens to model active state
7058
+ // => change the view display elements
7059
+ // 3) listen to DOM interactions and set skope values : state, priority
7060
+
7061
+ // @todo in the view, return the $() element to store the view.container
7062
+
7063
 
7064
 
7065
 
7074
 
7075
  initialize: function() {
7076
  var self = this;
7077
+ ///////////////////// DEFINITIONS /////////////////////
7078
  self.skope_colors = {
7079
  global : 'rgb(255, 255, 255)',
7080
  special_group : 'rgba(173, 213, 247, 0.55)',
7081
+ group : 'rgba(120, 136, 158, 0.12)',// 'rgba(39, 59, 88, 0.12)',// 'rgba(173, 213, 247, 0.55)',
7082
+ local : 'rgba(187, 211, 247, 0.28)', //rgba(39, 59, 88, 0.28)'// 'rgba(78, 122, 199, 0.35)'
7083
  };
7084
+ //Deferred used to make sure the overridden api.previewer.query method has been taken into account
7085
  api.czr_isPreviewerSkopeAware = $.Deferred();
7086
+ //Store the state of the first skope collection state
7087
  api.czr_initialSkopeCollectionPopulated = $.Deferred();
7088
+ //store the embed state
7089
  self.skopeWrapperEmbedded = $.Deferred();
7090
+
7091
+ //the skope instance constructor
7092
  api.czr_skope = new api.Values();
7093
+
7094
+ //the czr_skopeCollection stores all skopes instantiated by the user
7095
+ //this collection is not updated directly
7096
+ //=> it's updated on skope() instance change
7097
  api.czr_skopeCollection = new api.Value([]);//all available skope, including the current skopes
7098
+ //the current skopes collection get updated each time the 'czr-skopes-synced' event is triggered on the api by the preview
7099
  api.czr_currentSkopesCollection = new api.Value([]);
7100
+
7101
+
7102
+ //the currently active skope
7103
  api.czr_activeSkopeId = new api.Value();
7104
+ //Store the global dirtyness state of the API
7105
  api.czr_dirtyness = new api.Value( false );
7106
+ //store the resetting state
7107
  api.czr_isResettingSkope = new api.Value( false );
7108
+
7109
+ //Add new state to the api
7110
  api.state.create('switching-skope')( false );
7111
+
7112
+ ///////////////////// SKOPIFY THE API AND THE PANEL /////////////////////
7113
+ //REACT TO API DIRTYNESS
7114
  api.czr_dirtyness.callbacks.add( function() { return self.apiDirtynessReact.apply(self, arguments ); } );
7115
+
7116
+ //LOADING ICON DURING INITIAL SKOPE SETUP
7117
+ //this api.Value() and its callback are declared in pre_base
7118
  api.czr_isLoadingSkope( true );
7119
+
7120
+ //LISTEN TO EACH API SETTING CHANGES
7121
+ // => POPULATE THE DIRTYNESS OF THE CURRENTLY ACTIVE SKOPE
7122
  self.bindAPISettings();
7123
+
7124
+ //LISTEN TO THE API STATES => SET SAVE BUTTON STATE
7125
+ //=> this value is set on control and skope reset
7126
+ //+ set by wp
7127
+ //
7128
+ //<@4.9compat>
7129
+ // => deactivated for v4.9
7130
+ // api.state.bind( 'change', function() {
7131
+ // self.setSaveButtonStates();
7132
+ // });
7133
+ //</@4.9compat>
7134
+
7135
+ //EMBED THE SKOPE WRAPPER
7136
+ //=> WAIT FOR SKOPE TO BE READY api.czr_skopeReady.state == 'resolved'
7137
  api.czr_skopeReady.then( function() {
7138
  if ( 'pending' == self.skopeWrapperEmbedded.state() ) {
7139
  $.when( self.embedSkopeWrapper() ).done( function() {
7141
  });
7142
  }
7143
  });
7144
+
7145
+
7146
+ ///////////////////// SKOPE COLLECTIONS SYNCHRONISATION AND LISTENERS /////////////////////
7147
+ //LISTEN TO SKOPE SYNC => UPDATE SKOPE COLLECTION ON START AND ON EACH REFRESH
7148
+ //Will make sure server DB values are always synchronized with the instantiated skopes
7149
+ //the sent data look like :
7150
+ //{
7151
+ // czr_skopes : _wpCustomizeSettings.czr_skopes || [],
7152
+ // isChangesetDirty : boolean
7153
+ // }
7154
+ //
7155
+ //Bail if skope has not been properly instantiated 'rejected' == api.czr_skopeReady.state()
7156
  api.previewer.bind( 'czr-skopes-synced', function( data ) {
7157
  if ( ! serverControlParams.isSkopOn || 'rejected' == api.czr_skopeReady.state() ) {
7158
  return;
7159
  }
7160
+ //api.consoleLog('czr-skopes-ready DATA', data );
7161
  var preview = this,
7162
  previousSkopeCollection = api.czr_currentSkopesCollection();
7163
+ //initialize skopes with the server sent data
7164
+ //if skope has not been initialized yet and the server sent wrong data, then reject the skope ready promise()
7165
  if ( ! _.has( data, 'czr_skopes') ) {
7166
  if ( 'resolved' != api.czr_skopeReady.state() ) {
7167
  api.czr_skopeReady.reject();
7169
  api.errorLog( "On 'czr-skopes-synced' : missing skopes in the server data" );
7170
  return;
7171
  }
7172
+
7173
+ //1) Updated the collection with normalized skopes => prepareSkopeForAPI + api.czr_currentSkopesCollection( collection )
7174
+ //2) When the api.czr_currentSkopesCollection() Value is set => instantiates the missing skope
7175
+ //3) Set the skope layout view when the skope embedded promise is resolved
7176
  try {
7177
  api.czr_skopeBase.updateSkopeCollection( data.czr_skopes , preview.channel() );
7178
  } catch ( er ) {
7179
  api.czr_skopeReady.reject( er );
7180
  return;
7181
  }
7182
+
7183
+ //@return void()
7184
+ // => refresh skope notice below the skope switcher title
7185
+ // => refresh bottom skope infos in the preview
7186
  var _refreshSkopeInfosNotices = function() {
7187
+ //WRITE THE CURRENT SKOPE TITLE
7188
  self._writeCurrentSkopeTitle();
7189
+
7190
+ //REFRESH PREVIEW BOTTOM INFOS
7191
+ //the default behaviour is to display the bottom infos block in the preview
7192
+ //and to refresh its content
7193
  if ( api.czr_bottomInfosVisible() ) {
7194
  self.renderBottomInfosTmpl();//<= will build a new bottom skope message infos in the preview based on the new active skopes
7195
  } else {
7196
+ //Display + build and render the skope infos
7197
  api.czr_bottomInfosVisible( true );
7198
  }
7199
  };
7200
+
7201
+
7202
+ //Always wait for the initial collection to be populated
7203
  api.czr_initialSkopeCollectionPopulated.then( function() {
7204
  var refreshActiveSkope = _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), {id : api.czr_activeSkopeId() } ) );
7205
  api.czr_skopeBase.reactWhenSkopeSyncedDone( data ).done( function() {
7206
+ //if the current active skope has been removed from the current skopes collection
7207
+ //=> set relevant scope as active. Falls back on 'global'
7208
  if ( refreshActiveSkope ) {
7209
  try {
7210
  api.czr_activeSkopeId( self.getActiveSkopeId() )
7212
  if ( 'resolved' != api.czr_skopeReady.state() ) {
7213
  api.czr_skopeReady.resolve( self.getActiveSkopeId() );
7214
  }
7215
+ //REFRESH SKOPE INFOS IN TITLE AND PREVIEW FRAME
7216
  _refreshSkopeInfosNotices();
7217
  })
7218
  .fail( function() {
7226
  _newLoc =_.findWhere( data.czr_skopes, { skope : 'local' } ).opt_name;
7227
 
7228
  if ( _newLoc !== _prevLoc && 'resolved' == api.czr_skopeReady.state() ) {
7229
+ //REFRESH SKOPE INFOS IN TITLE AND PREVIEW FRAME
7230
  _refreshSkopeInfosNotices();
7231
  }
7232
  }
7233
  });
7234
  });
7235
  });
7236
+
7237
+
7238
+ //CURRENT SKOPE COLLECTION LISTENER
7239
+ //The skope collection is set on 'czr-skopes-synced' triggered by the preview
7240
+ //setup the callbacks of the skope collection update
7241
+ //on init and on preview change : the collection of skopes is populated with new skopes
7242
+ //=> instanciate the relevant skope object + render them
7243
  api.czr_currentSkopesCollection.bind( function( to, from ) {
7244
  return self.currentSkopesCollectionReact( to, from );
7245
  }, { deferred : true });
7246
+
7247
+
7248
+ //WHEN THE INITIAL SKOPE COLLECTION HAS BEEN POPULATED ( in currentSkopesCollectionReact )
7249
+ //LET'S BIND CALLBACKS TO ACTIVE SKOPE AND ACTIVE SECTION
7250
  api.czr_initialSkopeCollectionPopulated.done( function() {
7251
+ //LISTEN AND REACT TO ACTIVE SKOPE UPDATE
7252
+ //api.czr_activeSkopeId.callbacks.add( function() { return self.activeSkopeReact.apply(self, arguments ); } );
7253
  api.czr_activeSkopeId.bind( function( to, from ) {
7254
+ //Always close the mod option panel if exists
7255
  if ( _.has( api, 'czr_ModOptVisible') ) {
7256
  api.czr_ModOptVisible( false );
7257
  }
7265
  );
7266
  });
7267
  }, { deferred : true } );
7268
+
7269
+ //REACT TO EXPANDED ACTIVE SECTION
7270
+ //=> silently update all eligible controls of this sektion with the current skope values
7271
  api.czr_activeSectionId.callbacks.add( function() { return self.activeSectionReact.apply(self, arguments ); } );
7272
+
7273
+ //REACT TO EXPANDED ACTIVE PANEL
7274
+ //=> silently update all eligible controls of this sektion with the current skope values
7275
  api.czr_activePanelId.callbacks.add( function() { return self.activePanelReact.apply(self, arguments ); } );
7276
+
7277
+ //GLOBAL SKOPE COLLECTION LISTENER
7278
+ //api.czr_skopeCollection.callbacks.add( function() { return self.globalSkopeCollectionReact.apply(self, arguments ); } );
7279
  });
7280
+
7281
+
7282
+ //////////////// LISTEN TO SKOPE SWITCH EVENT //////////////////
7283
+ //1) reset visibilities
7284
+ //2) update control skope notices
7285
+ //@args =
7286
+ //{
7287
+ // current_skope_id : string
7288
+ // previous_skope_id : string
7289
+ // updated_setting_ids : [] //<= can be empty if no section was expanded
7290
+ //}
7291
  api.bind( 'skope-switched-done', function( args ) {
7292
  args = _.extend(
7293
  {
7299
  );
7300
  return self.skopeSwitchedDoneReact( args );
7301
  });
7302
+
7303
+
7304
+ ///////////////////// LISTEN TO THE SERVER /////////////////////
7305
+ //SERVER NOTIFICATION SETUP
7306
  api.czr_serverNotification = new api.Value( {status : 'success', message : '', expanded : true} );
7307
  api.czr_serverNotification.bind( function( to, from ) {
7308
  self.toggleServerNotice( to );
7309
  });
7310
+
7311
+
7312
+
7313
+ ///////////////////// SETUP PREVIEW NOTE AND INFOS BLOCKS /////////////////////
7314
+ /// 1) defines observable value to control the block view visibilities
7315
+ /// 2) listen to those values state to render / destroy the views
7316
+ /// 3) setup DOM listeners inside the views to react on user actions : close block + write an ajax option for example
7317
  self._setupPreviewNotificationsBlocks();//top note and bottom skope infos
7318
+
7319
+
7320
+
7321
+ ///////////////////// SKOPE SWITCHER EVENT MAP /////////////////
7322
  self.scopeSwitcherEventMap = [
7323
+ //skope reset : do reset
7324
  {
7325
  trigger : 'click keydown',
7326
  selector : '.czr-dismiss-notification',
7329
  api.czr_serverNotification( { expanded : false } );
7330
  }
7331
  },
7332
+ //toggle title notice
7333
  {
7334
  trigger : 'click keydown',
7335
  selector : '.czr-toggle-title-notice',
7347
  }
7348
  }
7349
  ];
7350
+
7351
+ //Setup DOM user actions when api.czr_skopeReady => self.skopeWrapperEmbedded are resolved
7352
  self.skopeWrapperEmbedded.then( function() {
7353
  api.CZR_Helpers.setupDOMListeners( self.scopeSwitcherEventMap , { dom_el : $('.czr-scope-switcher') }, self );
7354
  });
7355
+
7356
+
7357
+ ///////////////////// VARIOUS /////////////////////
7358
+ //DECLARE THE LIST OF CONTROL TYPES FOR WHICH THE VIEW IS REFRESHED ON CHANGE
7359
  self.refreshedControls = [ 'czr_cropped_image'];// [ 'czr_cropped_image', 'czr_multi_module', 'czr_module' ];
7360
+
7361
+ //WIDGETS AND SIDEBAR SPECIFIC TREATMENTS
7362
  self.initWidgetSidebarSpecifics();
7363
+
7364
+ //LISTEN TO GLOBAL DB OPTION CHANGES
7365
+ //When an option is reset on the global skope,
7366
+ //we need to update it in the initially sent _wpCustomizeSettings.settings
7367
+ //api.czr_globalDBoptions.callbacks.add( function() { return self.globalDBoptionsReact.apply(self, arguments ); } );
7368
+
7369
+
7370
+ ///////////////////// LISTEN TO PAINT EVENT /////////////////////
7371
+ //The paint event occurs :
7372
+ //1) on skope switch
7373
+ //2) on sektion expansion
7374
+ //3) on panel expansion
7375
  api.bind( 'czr-paint', function( params ) {
7376
  api.czr_skopeReady.then( function() {
7377
  self.wash( params ).paint( params );
7398
  /*****************************************************************************
7399
  * EMBED WRAPPER
7400
  *****************************************************************************/
7401
+ //fired in initialize
7402
+ //=> embed the wrapper for all skope boxes
7403
+ //=> add a specific class to the body czr-skop-on
7404
+ //=> Listen to skope switch in main title
7405
  embedSkopeWrapper : function() {
7406
  var self = this;
7407
  $('#customize-header-actions').append( $('<div/>', {class:'czr-scope-switcher', html:'<div class="czr-skopes-wrapper"></div>'}) );
7408
  $('body').addClass('czr-skop-on');
7409
  var _eventMap = [
7410
+ //skope switch
7411
  {
7412
  trigger : 'click keydown',
7413
  selector : '.czr-skope-switch',
7433
  /*****************************************************************************
7434
  * API DIRTYNESS REACTIONS
7435
  *****************************************************************************/
7436
+ //cb of api.czr_dirtyness()
7437
  apiDirtynessReact : function( is_dirty ) {
7438
  $('body').toggleClass('czr-api-dirty', is_dirty );
7439
  api.state( 'saved')( ! is_dirty );
7450
  /*****************************************************************************
7451
  * OVERRIDE SAVE BUTTON STATES : api.state.bind( 'change') callback
7452
  *****************************************************************************/
7453
+ //@return void()
7454
  setSaveButtonStates : function() {
7455
+ //the 'saving' state was introduced in 4.7
7456
+ //For prior versions, let's declare it and add its callback that we need in the api.previewer.save() method
7457
  if ( ! api.state.has('saving') ) {
7458
  api.state.create('saving');
7459
  api.state('saving').bind( function( isSaving ) {
7477
  var canSave = ! saving() && ( ! activated() || ! saved() ) && 'publish' !== changesetStatus;
7478
  saveBtn.prop( 'disabled', ! canSave );
7479
  },
7480
+
7481
+
7482
+
7483
+
7484
+
7485
+
7486
+
7487
+
7488
+
7489
+
7490
+
7491
+ //cb of 'skope-switched-done' event => fired when the api.czr_activeSkopeId().done() <=> refresh is done()
7492
+ //1) set the ctrl dependencies in the currently active section
7493
+ //2) update ctrl skope notices in the currently active section + expand the ctrl notice if skope is not 'global'
7494
+ //3) adds a skope level class to the #customize-controls wrapper
7495
+ //@args =
7496
+ //{
7497
+ // current_skope_id : string
7498
+ // previous_skope_id : string
7499
+ // updated_setting_ids : [] //<= can be empty if no section was expanded
7500
+ //}
7501
  skopeSwitchedDoneReact : function( args ) {
7502
  var self = this,
7503
  _doWhenSkopeReady = function() {
7504
+ //CURRENTLY EXPANDED SECTION : SET CTRL DEPENDENCIES WHEN POSSIBLE
7505
  api.czr_CrtlDependenciesReady.then( function() {
7506
  if ( ! _.isUndefined( api.czr_activeSectionId() ) && ! _.isEmpty( api.czr_activeSectionId() ) ) {
7507
  try {
7511
  }
7512
  }
7513
  });
7514
+
7515
+ //CURRENTLY EXPANDED SECTION : UPDATE CURRENT SKOPE CONTROL NOTICES AND MAYBE EXPAND THE NOTICE
7516
  self.updateCtrlSkpNot( api.CZR_Helpers.getSectionControlIds() );
7517
+
7518
+ //ADD A SKOPE LEVEL CSS CLASS TO THE #customize-controls wrapper
7519
  if ( api.czr_skope.has( args.previous_skope_id ) ) {
7520
  $( '#customize-controls' ).removeClass( [ 'czr-', api.czr_skope( args.previous_skope_id )().skope, '-skope-level'].join('') );
7521
  }
7522
  if ( api.czr_skope.has( args.current_skope_id ) ) {
7523
  $( '#customize-controls' ).addClass( [ 'czr-', api.czr_skope( args.current_skope_id )().skope, '-skope-level'].join('') );
7524
  }
7525
+
7526
+ //CURRENTLY EXPANDED SECTION
7527
+ //=> Display ctrl notice if skope is not global
7528
+ //=> Hide the reset dialog
7529
  var _setupSectionControlDialogs = function() {
7530
  if ( _.isUndefined( api.czr_activeSectionId() ) || _.isEmpty( api.czr_activeSectionId() ) )
7531
  return;
7537
  return;
7538
 
7539
  ctrl.deferred.embedded.then( function() {
7540
+ //Always display the notice when skope is not global
7541
+ //=> let user understand where the setting value is coming from
7542
  ctrl.czr_states( 'noticeVisible' )( self.isCtrlNoticeVisible( ctrlId ) );
7543
  ctrl.czr_states( 'resetVisible' )( false );
7544
  });
7545
  });
7546
  });
7547
  };
7548
+
7549
+ //REFRESH PREVIEW BOTTOM INFOS
7550
+ //on skope switched done, the default behaviour is to display the bottom infos block in the preview
7551
+ //and to refresh its content
7552
  if ( api.czr_bottomInfosVisible() ) {
7553
  self.renderBottomInfosTmpl();//<= will build a new bottom skope message infos in the preview based on the new active skopes
7554
  } else {
7555
+ //Display + build and render the skope infos
7556
  api.czr_bottomInfosVisible( true );
7557
  }
7558
+
7559
+ //Setup control dialogs after a delay on skope switched.
7560
+ //=> the delay is needed for controls that have been re-rendered.
7561
  _.delay( function() {
7562
  _setupSectionControlDialogs();
7563
  }, 500 );
7564
  };
7565
+
7566
+
7567
+ //api.consoleLog('SKOPE SWITCHED TO', args.current_skope_id, api.czr_activeSectionId() );
7568
+ //Skope is ready when :
7569
+ //1) the initial skopes collection has been populated
7570
+ //2) the initial skope has been switched to
7571
  api.czr_skopeReady.then( function() {
7572
  _doWhenSkopeReady();
7573
  });
7574
  },
7575
+
7576
+
7577
+
7578
+
7579
+
7580
+
7581
+
7582
+
7583
+
7584
+
7585
+
7586
+
7587
+
7588
+
7589
+
7590
+ //@return void()
7591
  _setupPreviewNotificationsBlocks : function() {
7592
  var self = this;
7593
+ ///////////////////// TOP NOTE BLOCK /////////////////////
7594
  api.czr_topNoteVisible = new api.Value( false );
7595
  api.czr_skopeReady.then( function() {
7596
  api.czr_topNoteVisible.bind( function( visible ) {
7601
  actions : '',
7602
  selfCloseAfter : 20000
7603
  };
7604
+ //noteParams is an object :
7605
+ //{
7606
+ // title : '',
7607
+ // message : '',
7608
+ // actions : fn(),
7609
+ // selfCloseAfter : 20000 in ms
7610
+ //}
7611
  noteParams = $.extend( _defaultParams , serverControlParams.topNoteParams );
7612
+
7613
+ //SPECIFIC AJAX ACTION FOR THE WELCOME NOTE
7614
  noteParams.actions = function() {
7615
  var _query = $.extend(
7616
  api.previewer.query(),
7624
 
7625
  self.toggleTopNote( visible, noteParams );
7626
  });
7627
+
7628
+ //Toggle the top note on initialization
7629
  _.delay( function() {
7630
  api.czr_topNoteVisible( ! _.isEmpty( serverControlParams.isTopNoteOn ) || 1 == serverControlParams.isTopNoteOn );
7631
  }, 2000 );
7632
  });
7633
+
7634
+
7635
+
7636
+ ///////////////////// BOTTOM INFOS BLOCK /////////////////////
7637
  api.czr_bottomInfosVisible = new api.Value( false );
7638
  api.czr_skopeReady.then( function() {
7639
+ //Listen to changes
7640
  api.czr_bottomInfosVisible.bind( function( visible ) {
7641
  var noteParams = {},
7642
  _defaultParams = {
7645
  actions : '',
7646
  selfCloseAfter : 20000
7647
  };
7648
+ //noteParams is an object :
7649
+ //{
7650
+ // title : '',
7651
+ // message : '',
7652
+ // actions : fn(),
7653
+ // selfCloseAfter : 20000 in ms
7654
+ //}
7655
  noteParams = $.extend( _defaultParams , {} );
7656
 
7657
  return self.toggleBottomInfos( visible, noteParams );//returns a promise()
7658
  }, { deferred : true } );
7659
+
7660
+ //never set to true if 'show-skope-infos' is unchecked
7661
  var _skopeInfosSetId = api.CZR_Helpers.build_setId( 'show-skope-infos' );
7662
  api.when( _skopeInfosSetId, function( _set_ ){
7663
  api.czr_bottomInfosVisible.validate = function( value ) {
7666
 
7667
  return _isChecked ? value : false;
7668
  };
7669
+
7670
+ //Listen to skope infos setting in admin section
7671
  _set_.bind( function( visible ) {
7672
  api.czr_bottomInfosVisible( 0 !== visible && '0' !== visible && false !== visible && 'off' !== visible );
7673
  });
7674
  });
7675
+
7676
+
7677
+
7678
+ //Toggle the top note on initialization
7679
  _.delay( function() {
7680
  api.czr_bottomInfosVisible( true );
7681
  }, 2000 );
7682
  });//api.czr_skopeReady.then()
7683
  }
7684
+
7685
+
7686
+
7687
+
7688
+
7689
+ //cb of api.czr_globalDBoptions.callbacks
7690
+ //update the _wpCustomizeSettings.settings if they have been updated by a reset of global skope, or a control reset of global skope
7691
+ //When an option is reset on the global skope, we need to set the new value to default in _wpCustomizeSettings.settings
7692
+ // globalDBoptionsReact : function( to, from ) {
7693
+ // var self = this,
7694
+ // resetted_opts = _.difference( from, to );
7695
+
7696
+ // //reset option case
7697
+ // if ( ! _.isEmpty(resetted_opts) ) {
7698
+ // api.consoleLog( 'HAS RESET OPTIONS', resetted_opts );
7699
+ // //reset each reset setting to its default val
7700
+ // _.each( resetted_opts, function( shortSetId ) {
7701
+ // var wpSetId = api.CZR_Helpers.build_setId( shortSetId );
7702
+ // if ( _.has( api.settings.settings, wpSetId) )
7703
+ // api.settings.settings[wpSetId].value = serverControlParams.defaultOptionsValues[shortSetId];
7704
+ // self.processSilentUpdates( { refresh : false } );//silently update with no refresh
7705
+ // });
7706
+ // }
7707
+
7708
+ // //make sure the hasDBValues is synchronized with the server
7709
+ // api.czr_skope( self.getGlobalSkopeId() ).hasDBValues( ! _.isEmpty( to ) );//might trigger cb hasDBValuesReact()
7710
+ // }
7711
  });//$.extend()
7712
  })( wp.customize , jQuery, _);
7713
 
7714
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
7715
  (function ( api, $, _ ) {
7716
  $.extend( CZRSkopeBaseMths, {
7717
+
7718
+ //callback of api.czr_serverNotification
7719
+ //notice is an object :
7720
+ // {
7721
+ // status : 'success',
7722
+ // expanded : true,
7723
+ // message : '',
7724
+ // auto_collapse : false
7725
+ // }
7726
  toggleServerNotice : function( notice ) {
7727
  notice = _.isObject( notice ) ? notice : {};
7728
  notice = _.extend( {
7731
  message : '',
7732
  auto_collapse : false
7733
  }, notice );
7734
+
7735
+ //bail for changeset_already_published
7736
  if ( 'changeset_already_published' == notice.message )
7737
  return;
7738
+
7739
+ //bail if not dev mode
7740
  if ( ! serverControlParams.isDevMode )
7741
  return;
7742
 
7758
  _header_height,
7759
  _notif_wrap_height,
7760
  _set_height = function( _h ) {
7761
+ // $header.css( 'height', '');
7762
+ // $sidebar.css( 'top', '' );
7763
+ // if ( _.isUndefined( _h ) )
7764
+ // return;
7765
+ // $header.css( 'height', _h + 'px' );
7766
+ // $sidebar.css( 'top', _h + 'px' );
7767
  return true;
7768
  };
7769
+
7770
+ //Close the main skope switcher title inheritance infos if exists and opened
7771
  if ( self.skopeTitleNoticeVisible )
7772
  self.skopeTitleNoticeVisible( false );
7773
 
7776
  .fadeOut( {
7777
  duration : 200,
7778
  complete : function() {
7779
+ //$( this ).css( 'height', 'auto' );
7780
  } } );
7781
  setTimeout( function() {
7782
  _set_height();
7806
  }, 400 );
7807
  }
7808
  };
7809
+
7810
+ //prepend the wrapper if needed
7811
  if ( 'pending' == self.serverNoticeEmbedded.state() ) {
7812
  $.when( _embed() ).done( function() {
7813
  setTimeout( function() {
7818
  } else {
7819
  _toggleNotice();
7820
  }
7821
+
7822
+ //Always auto-collapse the notification after a custom delay
7823
  _.delay( function() {
7824
  api.czr_serverNotification( { expanded : false } );
7825
  },
7826
  ( 'success' == notice.status || false !== notice.auto_collapse ) ? 4000 : 5000
7827
  );
7828
  },
7829
+
7830
+ //utility : build a server response as a string
7831
+ //ready to be displayed in the notifications
7832
  buildServerResponse : function( _r ) {
7833
  var resp = false;
7834
+ //server error
7835
  if ( _.isObject( _r ) ) {
7836
  if ( _.has( _r, 'responseJSON') && ! _.isUndefined( _r.responseJSON.data ) && ! _.isEmpty( _r.responseJSON.data ) ) {
7837
  resp = _r.responseJSON.data;
7838
  }
7839
+ // else if ( _.has( _r, 'responseText') && ! _.isEmpty( _r.responseText ) ) {
7840
+ // try {
7841
+ // resp = JSON.parse( _r.responseText );
7842
+ // } catch( e ) {
7843
+ // resp = 'Server Error';
7844
+ // }
7845
+ // }
7846
  else if ( _.has( _r , 'statusText' ) && ! _.isEmpty( _r.statusText ) ) {
7847
  resp = _r.statusText;
7848
  }
7856
  } else if ( ! resp ) {
7857
  resp = '0' === _r ? 'Not logged in.' : _r;
7858
  } else if ( '-1' === _r ) {
7859
+ // Back-compat in case any other check_ajax_referer() call is dying
7860
  resp = 'Identification issue detected, please refresh your page.';
7861
  }
7862
  return resp;
7866
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
7867
  (function ( api, $, _ ) {
7868
  $.extend( CZRSkopeBaseMths, {
7869
+
7870
+ //can be call directly, but is also a callback of api.czr_topNoteVisible, fired on skope base initialize
7871
+ //noteParams is an object :
7872
+ //{
7873
+ // title : '',
7874
+ // message : '',
7875
+ // actions : fn()
7876
+ //}
7877
  toggleTopNote : function( visible, noteParams ) {
7878
  noteParams = _.isObject( noteParams ) ? noteParams : {};
7879
  var self = this,
7886
  _renderAndSetup = function() {
7887
  $.when( self.renderTopNoteTmpl( noteParams ) ).done( function( $_el ) {
7888
  self.welcomeNote = $_el;
7889
+ //display
7890
  _.delay( function() {
7891
  $('body').addClass('czr-top-note-open');
7892
  }, 200 );
7912
  var dfd = $.Deferred();
7913
  $('body').removeClass('czr-top-note-open');
7914
  if ( self.welcomeNote.length ) {
7915
+ //remove Dom element after slide up
7916
  _.delay( function() {
7917
  self.welcomeNote.remove();
7918
  dfd.resolve();
7932
  api.czr_topNoteVisible( false );//should be already false
7933
  });
7934
  }
7935
+
7936
+ //Always auto-collapse the notification
7937
  _.delay( function() {
7938
  api.czr_topNoteVisible( false );
7939
  },
7940
  noteParams.selfCloseAfter || 20000
7941
  );
7942
  },
7943
+
7944
+
7945
+ //@param = { note_title : '', note_message : '' }
7946
  renderTopNoteTmpl : function( params ) {
7947
  if ( $( '#czr-top-note' ).length )
7948
  return $( '#czr-top-note' );
7970
  /*****************************************************************************
7971
  * WORDPRESS API ACTIONS ON INIT
7972
  *****************************************************************************/
7973
+ //fired in initialize
7974
+ //Listen to each api settings changes
7975
+ //1) update the current skope dirties with the user val
7976
+ //2) Refresh the controls reset state
7977
+ //can be fired when a setting is dynamically added. For example a widget.
7978
+ //In this case, the param SetId is not null
7979
  bindAPISettings : function( requestedSetId ) {
7980
  var self = this,
7981
+ //This is fired after the WP Core callback : setting.bind( setting.preview );
7982
  _settingChangeReact = function( new_val, old_val, o ) {
7983
+ //"this" is the setting instance
7984
  var setId = this.id,
7985
  skope_id;
7986
+
7987
+ //if skope instantiation went wrong, serverControlParams.isSkopOn has been reset to false
7988
+ //=> that's why we check it here again before doing anything else
7989
  if ( ! serverControlParams.isSkopOn )
7990
  return;
7991
 
7992
  if ( ! _.has( api, 'czr_activeSkopeId') || _.isUndefined( api.czr_activeSkopeId() ) ) {
7993
  api.errorLog( 'The api.czr_activeSkopeId() is undefined in the api.czr_skopeBase.bindAPISettings method.');
7994
+ //return;
7995
  }
7996
+
7997
+ //For skope eligible settings : Update the skope dirties with the new val of this setId
7998
+ //=> not eligibile skope will update the global skope dirties
7999
+ //=> this has to be kept like this because the global dirties aare being populated with :
8000
+ // api.dirtyValues = function dirtyValues( options ) {
8001
+ // return api.czr_skopeBase.getSkopeDirties( api.czr_skopeBase.getGlobalSkopeId(), options );
8002
+ // };
8003
  if ( api( setId )._dirty ) {
8004
  skope_id = self.isSettingSkopeEligible( setId ) ? api.czr_activeSkopeId() : self.getGlobalSkopeId();
8005
  api.czr_skope( skope_id ).updateSkopeDirties( setId, new_val );
8006
  }
8007
+
8008
+ //collapse any expanded reset modifications if the control is not currently being reset.
8009
  if ( _.has( api.control(setId), 'czr_states' ) && ! api.control(setId).czr_states( 'isResetting' )() ) {
8010
  api.control( setId ).czr_states( 'resetVisible' )( false );
8011
  }
8012
+
8013
+ //Update the skope inheritance notice for the setting control
8014
  if ( self.isSettingSkopeEligible( setId ) ) {
8015
  self.updateCtrlSkpNot( setId );
8016
  }
8017
  };//_settingChangeReact()
8018
+
8019
+ //if a setting Id is requested
8020
  if ( ! _.isUndefined( requestedSetId ) ) {
8021
  api( requestedSetId ).bind( _settingChangeReact );
8022
  }
8023
  else {
8024
+ //parse the current eligible skope settings and write a setting val object
8025
  api.each( function ( _setting ) {
8026
  _setting.bind( _settingChangeReact );
8027
  });
8028
  }
8029
+
8030
+ //BIND SETTINGS ADDED LATER : Typical example : menus
8031
  var _dynamicallyAddedSettingsReact = function( setting_instance ) {
8032
  if ( setting_instance.callbacks.has( _settingChangeReact ) )
8033
  return;
8047
  /*****************************************************************************
8048
  * REACT ON SKOPE SYNCED
8049
  *****************************************************************************/
8050
+ //Fired on 'czr-skopes-synced'
8051
+ //with param :
8052
+ //{
8053
+ // czr_skopes : _wpCustomizeSettings.czr_skopes || [],
8054
+ // isChangesetDirty : boolean,
8055
+ // }
8056
  reactWhenSkopeSyncedDone : function( server_params ) {
8057
  var self = this, dfd = $.Deferred();
8058
  if ( ! _.has( server_params, 'czr_skopes' ) || _.isEmpty( server_params.czr_skopes ) ) {
8059
  api.errorLog( 'Missing skope data after refresh', server_params );
8060
  return dfd.resolve().promise();
8061
  }
8062
+ //API DIRTYNESS UPDATE
8063
  if ( ! api.czr_dirtyness() ) {
8064
  api.czr_dirtyness( _.isBoolean( server_params.isChangesetDirty ) ? server_params.isChangesetDirty : false );
8065
  }
8066
 
8067
  var _sentSkopeCollection = server_params.czr_skopes;
8068
+ //CHANGESET UPDATE
8069
+ //always update the changesets of the sent skope collection after a refresh
8070
+ //match them with the opt_name, because they don't have an id when emitted from server
8071
  _.each( api.czr_skopeCollection(), function( _skp ) {
8072
  var _sent_skope = _.findWhere( _sentSkopeCollection, { opt_name : _skp.opt_name } );
8073
+ //do we have a match based on opt_name with the _sentSkopeCollection ?
8074
  if ( _.isUndefined( _sent_skope ) )
8075
  return;
8076
+ //if so then let's update the skope model with the new db values
8077
  var _changeset_candidate = _.isEmpty( _sent_skope.changeset || {} ) ? {} : _sent_skope.changeset,
8078
  _api_ready_chgset = {};
8079
+
8080
+ //We only update the changeset with registered setting id
8081
  _.each( _changeset_candidate, function( _val, _setId ) {
8082
  if ( ! api.has( _setId ) ) {
8083
  api.consoleLog( 'In reactWhenSkopeSyncedDone : attempting to update the changeset with a non registered setting : ' + _setId );
8084
  }
8085
  _api_ready_chgset[_setId] = _val;
8086
  });
8087
+
8088
+ //_new_changeset = $.extend( api.czr_skope( _skp.id ).changesetValues(), _sent_changeset );
8089
+ //=> updating the changeset will also trigger a skope dirtyValues() update
8090
  api.czr_skope( _skp.id ).changesetValues( _api_ready_chgset );
8091
  });
8092
+
8093
+ //DB VALUES UPDATE
8094
+ //UPDATE EACH SKOPE MODEL WITH THE NEW DB VAL SENT BY THE SERVER
8095
+ //The sent skope have no id (because assigned in the api)
8096
+ //=> however we can match them with their unique opt_name property
8097
+ //then update the skope db values, including the global skope
8098
  _.each( api.czr_skopeCollection(), function( _skp ) {
8099
  var _sent_skope = _.findWhere( _sentSkopeCollection, { opt_name : _skp.opt_name } );
8100
+ //do we have a match based on opt_name with the _sentSkopeCollection ?
8101
  if ( _.isUndefined( _sent_skope ) )
8102
  return;
8103
+
8104
+ //if so then let's update the skope model with the new db values
8105
  var _current_db_vals = $.extend( true, {}, api.czr_skope( _skp.id ).dbValues() ),
8106
  _dbVals_candidate = $.extend( _current_db_vals , _sent_skope.db || {} ),
8107
  _api_ready_dbvals = {};
8108
+
8109
+ //We only update the dbValues with registered setting id
8110
  _.each( _dbVals_candidate, function( _val, _setId ) {
8111
  if ( ! api.has( _setId ) ) {
8112
  api.consoleLog( 'In reactWhenSkopeSyncedDone : attempting to update the db values with a non registered setting : ' + _setId );
8117
 
8118
  api.czr_skope( _skp.id ).dbValues( _api_ready_dbvals );
8119
  });
8120
+ //introduce a small delay to let the api values be fully updated
8121
+ //useful when attempting to refresh the control notices after a save action
8122
  _.delay( function() {
8123
  dfd.resolve();
8124
  }, 500 );
8134
  /*****************************************************************************
8135
  * REACT ON ACTIVE SECTION SETUP DONE
8136
  *****************************************************************************/
8137
+ // fired on 'active-section-setup'
8138
+ // params looks like : { controls : controls, section_id : section_id }
8139
  _maybeSetupAssignedMenuLocations : function( active_section ) {
8140
  if ( _.isUndefined( active_section ) || _.isEmpty( active_section ) || ! api.section.has( active_section.id ) ) {
8141
  api.consoleLog( 'In _maybeSetupAssignedMenuLocations : no valid section_id provided.');
8142
  }
8143
  var self = this;
8144
+ //is this a menu section ? and does it have assigned locations ?
8145
  if ( ! active_section.assignedLocations )
8146
  return;
8147
+
8148
+ //locations is an array of locations for a menu
8149
+ //=> we want to synchronize the reset button of this menu location in this section, with the one of the nav_menu_location setting
8150
  var _assignedLocReact = function( locations ) {};
8151
 
8152
  if ( ! active_section.assignedLocations.callbacks.has( _assignedLocReact ) ) {
8159
  /*****************************************************************************
8160
  * REACT TO ACTIVE SECTION EXPANSION
8161
  *****************************************************************************/
8162
+ //cb of api.czr_activeSectionId()
8163
  activeSectionReact : function( active_sec_id , previous_sec_id ) {
8164
+ //PAINT
8165
  if ( 'add_menu' != active_sec_id ) {
8166
  api.trigger('czr-paint', { active_section_id : active_sec_id } );
8167
  }
8168
 
8169
  var self = this,
8170
  _doReactPrevious = function( previous_sec_id ) {
8171
+ //COLLAPSE ANY RESET DIALOG
8172
  var controls = api.CZR_Helpers.getSectionControlIds( previous_sec_id );
8173
  _.each( controls, function( ctrlId ) {
8174
  if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
8181
  });
8182
  },
8183
  _doReactActive = function( active_section, active_sec_id ) {
8184
+ //PRE RENDER THE CONTROL RESET ICONS + NOTICE
8185
  self.setupActiveSkopedControls( {
8186
  section_id : active_sec_id
8187
  });
8188
+
8189
+ //PROCESS SILENT UPDATES
8190
  self.processSilentUpdates( { section_id : active_sec_id } )
8191
  .fail( function() {
8192
  throw new Error( 'Fail to process silent updates after initial skope collection has been populated' );
8193
  })
8194
  .done( function() {
8195
+ // var _update_candidates = self._getSilentUpdateCandidates( active_sec_id );
8196
+ // self.processSilentUpdates( { candidates : _update_candidates } );
8197
+ // //add control single reset + observable values
8198
+ // self.setupActiveSkopedControls();
8199
+
8200
+ //Always display the notice when skope is not global
8201
+ //=> let user understand where the setting value is coming from
8202
  var _setupSectionCtrlNotices = function() {
8203
  var controls = api.CZR_Helpers.getSectionControlIds( active_sec_id );
8204
  _.each( controls, function( ctrlId ) {
8210
  ctrl.czr_states( 'noticeVisible' )( self.isCtrlNoticeVisible( ctrlId ) );
8211
  });
8212
  };
8213
+
8214
+ //Setup ctrol notices after a delay
8215
+ //=>the delay is needed for controls that have been re-rendered.
8216
  _.delay( function() {
8217
  _setupSectionCtrlNotices();
8218
  }, 700 );
8219
+
8220
+ //Sidebar Widget specific
8221
  if ( ! self.isExcludedSidebarsWidgets() ) {
8222
  self.forceSidebarDirtyRefresh( active_sec_id , api.czr_activeSkopeId() );
8223
  }
8224
  });
8225
+
8226
+ //TRIGGER AN OBJECT RICH EVENT
8227
+ //LISTEN TO ACTIVE SECTION SETUP : RESET ICONS + CONTROL NOTICES ARE WRITEEN
8228
+ //=> handles the synchronized assigned locations for menus
8229
+ // 'skoped-controls-setup' is triggered when self.setupActiveSkopedControls()
8230
+ // params looks like : { controls : controls, section_id : section_id }
8231
  if ( ! _.has( api.topics, 'active-section-setup' ) ) {
8232
  api.bind( 'active-section-setup', function( params ) {
8233
  var defaults = {
8238
  self._maybeSetupAssignedMenuLocations( params );
8239
  });
8240
  }
8241
+
8242
+ //Switch to global skope for not skoped sections
8243
  api.czr_skopeReady.then( function() {
8244
  var _switchBack = function( _title ) {
8245
+ //<@4.9compat>
8246
+ if ( ! _.isUndefined( api.notifications ) ) {
8247
+ api.notifications.add( new wp.customize.Notification( _title, {
8248
+ type: 'info',
8249
+ message: [ _title, serverControlParams.i18n.skope['is always customized sitewide.'] ].join(' '),
8250
+ dismissible: true
8251
+ } ) );
8252
+
8253
+ // Removed if not dismissed after 5 seconds
8254
+ _.delay( function() {
8255
+ if ( api.notifications.has( _title ) ) {
8256
+ var _notif_ = api.notifications( _title );
8257
+ if ( _notif_.parent ) {
8258
+ _notif_.parent.remove( _notif_.code );
8259
+ } else {
8260
+ _notif_.container.remove();
8261
+ }
8262
+ }
8263
+ }, 5000 );
8264
+ }
8265
+ //</@4.9compat>
8266
+ else {
8267
+ api.czr_serverNotification({
8268
+ status:'success',
8269
+ message : [ _title, serverControlParams.i18n.skope['is always customized sitewide.'] ].join(' ')
8270
+ });
8271
+ }
8272
+
8273
  api.czr_activeSkopeId( self.getGlobalSkopeId() );
8274
  };
8275
+ //Switch to global skope for not skoped sections
8276
  if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
8277
+ if ( self.isExcludedWPCustomCss() && 'custom_css' == active_sec_id ) {
8278
+ _switchBack( api.section( active_sec_id ).params.title );
8279
+ }
8280
+ if ( _.contains( ['admin_sec', 'tc_font_customizer_settings' ], active_sec_id ) ) {
8281
  _switchBack( api.section( active_sec_id ).params.title );
8282
  }
8283
 
8284
  if ( 'nav_menu[' == active_sec_id.substring( 0, 'nav_menu['.length ) || 'add_menu' == active_sec_id ) {
8285
+ //<@4.9compat>
8286
+ if ( ! _.isUndefined( api.notifications ) ) {
8287
+ api.notifications.add( new wp.customize.Notification( 'nav_menus_sitewide', {
8288
+ type: 'info',
8289
+ message: serverControlParams.i18n.skope['Menus are created sitewide.'],
8290
+ dismissible: true
8291
+ } ) );
8292
+
8293
+ // Removed if not dismissed after 5 seconds
8294
+ _.delay( function() {
8295
+ if ( api.notifications.has( 'nav_menus_sitewide' ) ) {
8296
+ var _notif_ = api.notifications( 'nav_menus_sitewide' );
8297
+ if ( _notif_.parent ) {
8298
+ _notif_.parent.remove( _notif_.code );
8299
+ } else {
8300
+ _notif_.container.remove();
8301
+ }
8302
+ }
8303
+ }, 5000 );
8304
+ }
8305
+ //</@4.9compat>
8306
+ else {
8307
+ api.czr_serverNotification({
8308
+ status:'success',
8309
+ message : serverControlParams.i18n.skope['Menus are created sitewide.']
8310
+ });
8311
+ }
8312
+ }
8313
+ }
8314
+ });
8315
+
8316
+ //SAY IT
8317
+ api.trigger('active-section-setup', active_section );
8318
+ };
8319
+
8320
+
8321
+
8322
+ //defer the callback execution when the first skope collection has been populated
8323
+ //=> otherwise it might be to early. For example in autofocus request cases.
8324
  api.czr_initialSkopeCollectionPopulated.then( function() {
8325
  api.section.when( active_sec_id , function( active_section ) {
8326
+ //<@4.9compat>
8327
+ // Bail if is opening the publish_setting section
8328
+ if ( 'publish_settings' == active_sec_id )
8329
+ return;
8330
+ //</@4.9compat>
8331
  active_section.deferred.embedded.then( function() {
8332
  try { _doReactActive( active_section, active_sec_id ); } catch( er ) {
8333
  api.errorLog( 'activeSectionReact => _doReactActive : ' + er );
8345
  /*****************************************************************************
8346
  * REACT TO ACTIVE PANEL EXPANSION
8347
  *****************************************************************************/
8348
+ //cb of api.czr_activePanelId()
8349
  activePanelReact : function( active_panel_id , previous_panel_id ) {
8350
  var self = this;
8351
  api.czr_initialSkopeCollectionPopulated.then( function() {
8352
  api.trigger('czr-paint', { active_panel_id : active_panel_id } );
8353
  var _switchBack = function( _title ) {
8354
+ //<@4.9compat>
8355
+ if ( ! _.isUndefined( api.notifications ) ) {
8356
+ api.notifications.add( new wp.customize.Notification( _title, {
8357
+ type: 'info',
8358
+ message: [ _title, serverControlParams.i18n.skope['is always customized sitewide.'] ].join(' '),
8359
+ dismissible: true
8360
+ } ) );
8361
+
8362
+ // Removed if not dismissed after 5 seconds
8363
+ _.delay( function() {
8364
+ if ( api.notifications.has( _title ) ) {
8365
+ var _notif_ = api.notifications( _title );
8366
+ if ( _notif_.parent ) {
8367
+ _notif_.parent.remove( _notif_.code );
8368
+ } else {
8369
+ _notif_.container.remove();
8370
+ }
8371
+ }
8372
+ }, 5000 );
8373
+ }
8374
+ //</@4.9compat>
8375
+ else {
8376
+ api.czr_serverNotification({
8377
+ status:'success',
8378
+ message : [ _title, serverControlParams.i18n.skope['is always customized sitewide.'] ].join(' ')
8379
+ });
8380
+ }
8381
+
8382
  api.czr_activeSkopeId( self.getGlobalSkopeId() );
8383
  };
8384
+
8385
+ //Display a notifictation skoped panels
8386
  api.czr_skopeReady.then( function() {
8387
  if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
8388
  if ( self.isExcludedSidebarsWidgets() && 'widgets' == active_panel_id ) {
8389
+ //<@4.9compat>
8390
+ if ( ! _.isUndefined( api.notifications ) ) {
8391
+ api.notifications.add( new wp.customize.Notification( 'widgets_are_sitewide', {
8392
+ type: 'info',
8393
+ message: serverControlParams.i18n.skope['Widgets are created sitewide.'],
8394
+ dismissible: true
8395
+ } ) );
8396
+
8397
+ // Removed if not dismissed after 5 seconds
8398
+ _.delay( function() {
8399
+ if ( api.notifications.has( 'widgets_are_sitewide' ) ) {
8400
+ var _notif_ = api.notifications( 'widgets_are_sitewide' );
8401
+ if ( _notif_.parent ) {
8402
+ _notif_.parent.remove( _notif_.code );
8403
+ } else {
8404
+ _notif_.container.remove();
8405
+ }
8406
+ }
8407
+ }, 5000 );
8408
+ }
8409
+ //</@4.9compat>
8410
+ else {
8411
+ api.czr_serverNotification({
8412
+ status:'success',
8413
+ message : serverControlParams.i18n.skope['Widgets are created sitewide.']
8414
+ });
8415
+ }
8416
+ //_switchBack( api.panel( active_panel_id ).params.title );
8417
  }
8418
  }
8419
  });
8420
+
8421
+ //Silently update all sections of the nav_menus panel each time it's switch to
8422
+ //=> fixes the problem of locations not being refreshd below the menu titles
8423
  api.czr_skopeReady.then( function() {
8424
  if ( 'nav_menus' == active_panel_id ) {
8425
  _.each( api.panel( active_panel_id ).sections(), function( _sec ) {
8426
+ //PROCESS SILENT UPDATES
8427
  self.processSilentUpdates( { section_id : _sec.id, awake_if_not_active : true } );
8428
  });
8429
  }
8442
  /*****************************************************************************
8443
  * PAINT AND WASH
8444
  *****************************************************************************/
8445
+ //fired on 'czr-paint'
8446
+ //params = {
8447
+ // active_panel_id : '',
8448
+ // active_section_id : '',
8449
+ // is_skope_switch : false
8450
+ //}
8451
  wash : function( params ) {
8452
  var self = this,
8453
+ //@param element = { el : ${}, color : string }
8454
  _do_wash = function( element ) {
8455
  if ( ! _.has( element, 'el') || ! element.el.length )
8456
  return;
8464
  }
8465
  return this;
8466
  },
8467
+
8468
+ //fired on 'czr-paint'
8469
+ //params = {
8470
+ // active_panel_id : '',
8471
+ // active_section_id : '',
8472
+ // is_skope_switch : false
8473
+ //}
8474
  paint : function( params ) {
8475
  var _bgColor = 'inherit',
8476
  defaults = {
8484
  if ( ! _.isUndefined( api.czr_activeSkopeId() ) && api.czr_skope.has( api.czr_activeSkopeId() ) ) {
8485
  _bgColor = api.czr_skope( api.czr_activeSkopeId() ).color;
8486
  }
8487
+
8488
+ //@param element = { el : ${}, color : string }
8489
  var _do_paint = function( element ) {
8490
  if ( ! _.has( element, 'el') || ! element.el.length )
8491
  return;
8492
+ //If is skope switch, add a css class to handle a smoother background color transition
8493
  if ( params.is_skope_switch ) {
8494
  $.when( element.el.addClass('czr-painted') ).done( function() {
8495
  $(this).css( 'background', element.bgColor || _bgColor );
8497
  } else {
8498
  element.el.css( 'background', element.bgColor || _bgColor );
8499
  }
8500
+ //paint text in dark for accessibility when skope background is not white ( == not global skope )
8501
  if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
8502
  element.el.css( 'color', '#000');
8503
  }
8505
  };
8506
 
8507
  api.czr_skopeBase.paintedElements = api.czr_skopeBase.paintedElements || new api.Value( [] );
8508
+
8509
+ //CASE 1 : NO ACTIVE PANEL, NO ACTIVE SECTION => WE ARE ON ROOT
8510
  if ( _.isEmpty( params.active_panel_id ) && _.isEmpty( params.active_section_id ) ) {
8511
  _paint_candidates.push( {
8512
  el : $( '#customize-info' ).find('.accordion-section-title').first()
8513
  });
8514
  api.panel.each( function( _panel ) {
8515
+ // _panel.container.css('background', _bgColor );
8516
  _paint_candidates.push( {
8517
  el : _panel.container.find( '.accordion-section-title').first()
8518
  });
8519
  });
8520
+ //Also include orphaned sections that have no panel assigned
8521
+ //=> example front page content
8522
  api.section.each( function( _section ) {
8523
  if ( ! _.isEmpty( _section.panel() ) )
8524
  return;
8527
  });
8528
  });
8529
  }
8530
+
8531
+ //CASE 2 : ACTIVE PANEL, NO ACTIVE SECTION => WE ARE IN A PANEL ROOT
8532
  if ( ! _.isEmpty( params.active_panel_id ) && _.isEmpty( params.active_section_id ) ) {
8533
  api.panel.when( params.active_panel_id , function( active_panel ) {
8534
  active_panel.deferred.embedded.then( function() {
8535
+ //active_panel.container.css('background', _bgColor );
8536
  _paint_candidates.push( {
8537
  el : active_panel.container.find( '.accordion-section-title, .customize-panel-back' )
8538
  });
8539
  });
8540
  });
8541
  }
8542
+
8543
+ //CASE 3 : ACTIVE SECTION
8544
  if ( ! _.isEmpty( params.active_section_id ) ) {
8545
  api.section.when( params.active_section_id , function( active_section ) {
8546
  active_section.deferred.embedded.then( function() {
8553
  el : active_section.container
8554
  }
8555
  );
8556
+ //for WP < 4.7
8557
  if ( ! api.czr_isChangeSetOn() ) {
8558
  _paint_candidates.push(
8559
  {
8564
  });
8565
  });
8566
  }
8567
+
8568
+ //PROCESS PAINT AND POPULATE THE VALUE
8569
  _.each( _paint_candidates, function( _el ) { _do_paint( _el ); } );
8570
  api.czr_skopeBase.paintedElements( _paint_candidates );
8571
  return this;
8575
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
8576
  (function ( api, $, _ ) {
8577
  $.extend( CZRSkopeBaseMths, {
8578
+
8579
+ //can be call directly, but the recommend way is to use api.czr_bottomInfosVisible, fired on skope base initialize, for which the following method is a callback
8580
+ //noteParams is an object :
8581
+ //{
8582
+ // title : '',
8583
+ // message : '',
8584
+ // actions : fn()
8585
+ //}
8586
  toggleBottomInfos : function( visible, noteParams ) {
8587
  noteParams = _.isObject( noteParams ) ? noteParams : {};
8588
  var self = this,
8596
  _skopeInfosSetId = api.CZR_Helpers.build_setId('show-skope-infos'),
8597
  _renderAndSetup = function() {
8598
  var _dfd = $.Deferred();
8599
+ //Render and setup DOM listeners
8600
  $.when( self.renderBottomInfosTmpl( noteParams ) )
8601
  .done( function( $_el ) {
8602
  self.bottomInfosContainer = $_el;
8603
+ //Reveal and resolve
8604
  _.delay( function() {
8605
  $('body').addClass('czr-bottom-infos-open');
8606
  _dfd.resolve();
8607
  }, 200 );
8608
+
8609
+ //setup DOM listeners
8610
  api.CZR_Helpers.setupDOMListeners(
8611
  [
8612
  {
8621
  });
8622
  }
8623
  },
8624
+ //skope switch
8625
  {
8626
  trigger : 'click keydown',
8627
  selector : '.czr-skope-switch',
8655
  var _dfd_ = this;
8656
  $('body').removeClass('czr-bottom-infos-open');
8657
  if ( self.bottomInfosContainer.length ) {
8658
+ //remove and reset
8659
  _.delay( function() {
8660
  self.bottomInfosContainer.remove();
8661
  self.bottomInfosContainer = false;
8680
  dfd.resolve();
8681
  });
8682
  }
8683
+
8684
+ //Always auto-collapse the infos block
8685
+ // _.delay( function() {
8686
+ // api.czr_bottomInfosVisible( false );
8687
+ // },
8688
+ // noteParams.selfCloseAfter || 20000
8689
+ // );
8690
  return dfd.promise();
8691
  },
8692
+
8693
+
8694
+ //@param = { note_title : '', note_message : '' }
8695
  renderBottomInfosTmpl : function( params ) {
8696
  params = params || {};
8697
  var self = this,
8698
  _tmpl = '',
8699
  _skope_id = api.czr_activeSkopeId();
8700
+
8701
+ //Don't go further if the current skope is not registered yet
8702
  if ( ! api.czr_skope.has( _skope_id ) || ! _.isObject( api.czr_skope( _skope_id )() ) )
8703
  return false;
8704
 
8723
  }
8724
  });
8725
  };
8726
+
8727
+ //on initial rendering, print the template
8728
  if ( _.isUndefined( this.bottomInfosContainer ) || 1 != this.bottomInfosContainer.length ) {
8729
  _renderTmpl().done( function() {
8730
  $('.czr-note-message', '#czr-bottom-infos').html( _message );
8742
  }
8743
  return ( this.bottomInfosContainer && 1 == this.bottomInfosContainer.length ) ? this.bottomInfosContainer : $( '#czr-bottom-infos' );
8744
  },
8745
+
8746
+
8747
+ //@return html string
8748
+ //a skope is described by the following properties :
8749
+ // color:"rgba(39, 59, 88, 0.28)"
8750
+ // ctx_title:"Home"
8751
+ // dyn_type:"skope_meta"
8752
+ // id:"local_home"
8753
+ // is_forced:false
8754
+ // is_winner:true
8755
+ // level:"home"
8756
+ // long_title:"Options for home"
8757
+ // obj_id:"home"
8758
+ // opt_name:"hueman_czr_home"
8759
+ // skope:"local"
8760
+ // title:"Options for home"
8761
  _getSkopeInfosMessage : function( skope_id ) {
8762
  skope_id = skope_id || api.czr_activeSkopeId();
8763
  var _localSkopeId = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
8764
+
8765
+ //Paranoid but, always bail if :
8766
+ //1) the current skope id is not registered,
8767
+ //2) the skope is not an object
8768
+ //3) the local skope is undefined
8769
  if ( ! api.czr_skope.has( skope_id ) || ! _.isObject( api.czr_skope( skope_id )() ) || _.isUndefined( _localSkopeId ) )
8770
  return '';
8771
 
8821
  _html,
8822
  '</span>'
8823
  ].join(' ') );
8824
+
8825
+ // return $.trim( [
8826
+ // '<span class="czr-skope-bottom-infos">',
8827
+ // serverControlParams.i18n.skope['In this context :'],
8828
+ // _.isEmpty( _inheritedFrom ) ? ' ' : serverControlParams.i18n.skope['inherits from'],
8829
+ // _inheritedFrom,
8830
+ // _.isEmpty( _inheritedFrom ) ? '' : _.isEmpty( _overrides ) ? '.' : [',' , serverControlParams.i18n.skope['and'] ].join(' '),
8831
+ // _.isEmpty( _overrides ) ? ' ' : serverControlParams.i18n.skope['overridden by'],
8832
+ // _overrides,
8833
+ // _.isEmpty( _overrides ) ? '</span>' : '.</span>'
8834
+ // ].join(' ') );
8835
  }
8836
  });//$.extend()
8837
  })( wp.customize , jQuery, _);
8842
  /*****************************************************************************
8843
  * HELPERS
8844
  *****************************************************************************/
8845
+ //@return bool
8846
  isSkopeRegisteredInCollection : function( skope_id, collection ) {
8847
  var self = this;
8848
  collection = collection || api.czr_skopeCollection();
8849
  return ! _.isUndefined( _.findWhere( collection, { id : skope_id } ) );
8850
  },
8851
+
8852
+ //@return bool
8853
  isSkopeRegisteredInCurrentCollection : function( skope_id, collection ) {
8854
  var self = this;
8855
  collection = collection || api.czr_currentSkopesCollection();
8856
  return ! _.isUndefined( _.findWhere( collection, { id : skope_id } ) );
8857
  },
8858
+
8859
+ //@return bool
8860
  isGlobalSkopeRegistered : function() {
8861
  var _model = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'global'} );
8862
  return _.isObject( _model ) && _.has( _model, 'id' );
8863
  },
8864
+
8865
+ //@return string
8866
  getGlobalSkopeId : function() {
8867
  if ( ! _.has(api, 'czr_skope') )
8868
  return '';
8873
  });
8874
  return id;
8875
  },
8876
+
8877
+ //after a saved action, the 'global' option might have changed
8878
+ //=> this method, return only the changed db values
8879
  getChangedGlobalDBSettingValues : function( serverGlobalDBValues ) {
8880
  var _changedDbVal = {};
8881
 
8890
  });
8891
  return _changedDbVal;
8892
  },
8893
+
8894
+
8895
+ //@return the current active skope id
8896
+ //If server send isLocalSkope = true, then try to activate the local skope
8897
+ //Fallbacks on global
8898
  getActiveSkopeId : function( _current_skope_collection ) {
8899
  _current_skope_collection = _current_skope_collection || api.czr_currentSkopesCollection();
8900
 
8914
  if ( _.isUndefined( _skpId ) ) {
8915
  throw new Error( 'No default skope was found in getActiveSkopeId ', _current_skope_collection );
8916
  }
8917
+
8918
+ // _.each( _current_skope_collection, function( _skop ) {
8919
+ // _active_candidates[ _skop.skope ] = _skop.id;
8920
+ // });
8921
+
8922
+ // //Apply a basic skope priority. => @todo refine this treatment
8923
+ // if ( _.has( _active_candidates, 'local' ) )
8924
+ // return _active_candidates.local;
8925
+ // if ( _.has( _active_candidates, 'group' ) )
8926
+ // return _active_candidates.group;
8927
+ // if ( _.has( _active_candidates, 'special_group' ) )
8928
+ // return active_candidates.special_group;
8929
  return _skpId;
8930
+ //return _.findWhere( _current_skope_collection, { skope : 'global' } ).id;
8931
  },
8932
+
8933
+ //@return a skope name string : local, group, special_group, global
8934
  getActiveSkopeName : function() {
8935
  if ( ! api.czr_skope.has( api.czr_activeSkopeId() ) )
8936
  return 'global';
8937
  return api.czr_skope( api.czr_activeSkopeId() )().skope;
8938
  },
8939
+
8940
+
8941
+ //@return boolean
8942
+ //! important : the setId param must be the full name. For example : hu_theme_option[color-1]
8943
  isSettingSkopeEligible : function( setId ) {
8944
  var self = this,
8945
  shortSetId = api.CZR_Helpers.getOptionName( setId );
8948
  api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO SKOPE BECAUSE UNDEFINED OR NOT REGISTERED IN THE API.' );
8949
  return false;
8950
  }
8951
+ //exclude :
8952
+ //widget controls
8953
+ //sidebars
8954
+ //menu settings
8955
+ //active_theme
8956
  if ( self.isExcludedWPBuiltinSetting( setId ) )
8957
  return false;
8958
+ //skopeExcludedSettings look like ( short IDs ) :
8959
+ //{
8960
+ // //short ids of theme settings
8961
+ // 'post-comments',
8962
+ // 'page-comments',
8963
+ // 'layout-home',
8964
+ //
8965
+ // //protected theme settings
8966
+ // 'ver'
8967
+ //
8968
+ // //wp builtins
8969
+ // 'show_on_front',
8970
+ // 'page_on_front',
8971
+ // }
8972
  if ( _.contains( serverControlParams.skopeExcludedSettings, shortSetId ) ) {
8973
+ //api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO SKOPE BECAUSE PART OF THE EXCLUDED LIST.' );
8974
  return false;
8975
  } else if ( self.isThemeSetting( setId ) ) {
8976
  return true;
8977
+ //api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO SKOPE BECAUSE NOT PART OF THE THEME OPTIONS AND NOT WP AUTHORIZED BUILT IN OPTIONS' );
8978
  } else
8979
  return true;
8980
  },
8981
+
8982
+
8983
+ //@return boolean
8984
+ //! important : the setId param must be the full name. For example : hu_theme_option[color-1]
8985
  isSettingResetEligible : function( setId ) {
8986
  var self = this,
8987
  shortSetId = api.CZR_Helpers.getOptionName( setId );
8990
  api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO RESET BECAUSE UNDEFINED OR NOT REGISTERED IN THE API.' );
8991
  return;
8992
  }
8993
+ //exclude widget controls and menu settings and sidebars
8994
  if ( self.isExcludedWPBuiltinSetting( setId ) )
8995
  return;
8996
  if ( ! self.isThemeSetting( setId ) && ! self.isWPAuthorizedSetting( setId ) ) {
8998
  } else
8999
  return true;
9000
  },
9001
+
9002
+ //@return bool
9003
  isThemeSetting : function( setId ) {
9004
  return _.isString( setId ) && -1 !== setId.indexOf( serverControlParams.themeOptions );
9005
  },
9006
+
9007
+ //@return bool
9008
  isWPAuthorizedSetting : function( setId ) {
9009
  return _.isString( setId ) && _.contains( serverControlParams.wpBuiltinSettings, setId );
9010
  },
9011
+
9012
+ //@return boolean
9013
  isExcludedWPBuiltinSetting : function( setId ) {
9014
  var self = this;
9015
  if ( _.isUndefined(setId) )
9016
  return true;
9017
  if ( 'active_theme' == setId )
9018
  return true;
9019
+ //allow the list of server defined settings
9020
  if ( _.contains( serverControlParams.wpBuiltinSettings, setId ) )
9021
  return false;
9022
+
9023
+ //exclude the WP built-in settings like sidebars_widgets*, widget_*, custom_css
9024
+ //specifics for nav_menus:
9025
+ //1) exclude always :
9026
+ //nav_menu[* => each menu created
9027
+ //nav_menu_item => the items of the menus
9028
+ //nav_menus_created_posts
9029
+ //2) exclude maybe :
9030
+ //nav_menu_locations
9031
  var _patterns = [ 'widget_', 'nav_menu', 'sidebars_', 'custom_css', 'nav_menu[', 'nav_menu_item', 'nav_menus_created_posts', 'nav_menu_locations' ],
9032
  _isExcld = false;
9033
  _.each( _patterns, function( _ptrn ) {
9064
  });
9065
  return _isExcld;
9066
  },
9067
+
9068
+ //@return bool
9069
  isExcludedSidebarsWidgets : function() {
9070
  var _servParam = serverControlParams.isSidebarsWigetsSkoped;//can be a boolean or a string "" for false, "1" for true
9071
  return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
9072
  },
9073
+
9074
+ //@return bool
9075
  isExcludedNavMenuLocations : function() {
9076
+ //Nav menu location are not well supported before 4.7 => potential infinite refresh
9077
  if ( ! api.czr_isChangeSetOn() )
9078
  return true;
9079
  var _servParam = serverControlParams.isNavMenuLocationsSkoped;//can be a boolean or a string "" for false, "1" for true
9080
  return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
9081
  },
9082
+
9083
+ //@return bool
9084
  isExcludedWPCustomCss : function() {
9085
  var _servParam = serverControlParams.isWPCustomCssSkoped;//can be a boolean or a string "" for false, "1" for true
9086
  return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
9087
  },
9088
+
9089
+
9090
+ //return the current db value for a pair setId / skope_id
9091
  _getDBSettingVal : function( setId, skope_id ) {
9092
  var shortSetId = api.CZR_Helpers.getOptionName(setId),
9093
  wpSetId = api.CZR_Helpers.build_setId(setId);
9103
  return '_no_db_val';
9104
  }
9105
  },
9106
+
9107
+
9108
+ //@return {} of dirties
9109
+ //@options object { unsaved: boolean } was introduced with the changeset in WP 4.7.
9110
+ //=> the goal is to only get the api dirties that have not yet been saved in the changeset.
9111
  getSkopeDirties : function( skope_id, options ) {
9112
  if ( ! api.czr_skope.has( skope_id ) )
9113
  return {};
9114
+
9115
+ //the already saved settings are excluded from the skope dirties by default
9116
+ //=> the "real" customized values will be re-built server side anyway, by merging $_POST and changeset data, either on refresh or save.
9117
  options = options || {};
9118
  options = _.extend( { unsaved : true }, options );
9119
 
9120
  var values = {};
9121
+ //each skope stores its API dirties in an observable value : dirtyValues()
9122
  _.each( api.czr_skope( skope_id ).dirtyValues(), function( _val, _setId ) {
9123
  var settingRevision;
9124
+ //since 4.7 and the changeset, only the settings not yet saved in the db changeset are returned
9125
  if ( api.czr_isChangeSetOn() ) {
9126
  settingRevision = api._latestSettingRevisions[ _setId ];
9127
+ // Skip including settings that have already been included in the changeset, if only requesting unsaved.
9128
  if ( api.state( 'changesetStatus' ).get() && ( options && options.unsaved ) && ( _.isUndefined( settingRevision ) || settingRevision <= api._lastSavedRevision ) ) {
9129
+ //api.consoleLog( 'DIRTIES : ' + _setId + ' will be excluded from dirties because last revision was : ' + settingRevision + ' == to last saved revision : ' + api._lastSavedRevision );
9130
  return;
9131
  }
9132
  }
9136
  },
9137
 
9138
  getSkopeExcludedDirties : function() {
9139
+ //ARE THERE DIRTIES IN THE WP API ?
9140
  var self = this,
9141
  _wpDirties = {};
9142
  api.each( function ( value, setId ) {
9144
  _wpDirties[ setId ] = value();
9145
  }
9146
  } );
9147
+
9148
+ //ARE THERE DIRTIES IN THE GLOBAL SKOPE
9149
  var _globalSkopeId = self.getGlobalSkopeId(),
9150
  _globalSkpDirties = self.getSkopeDirties( _globalSkopeId );
9151
+
9152
+ //RETURN THE _wpDirties not present in the global skope dirties
9153
  return _.omit( _wpDirties, function( _value, setId ) {
9154
+ //var shortOptName = api.CZR_Helpers.getOptionName( setId );
9155
  return self.isSettingSkopeEligible( setId );
9156
  } );
9157
  },
9171
  parsed.id_base = matches[1];
9172
  parsed.number = parseInt( matches[2], 10 );
9173
  } else {
9174
+ // likely an old single widget
9175
  parsed.id_base = widgetId;
9176
  }
9177
 
9221
  api.errorLog( 'getAppliedPrioritySkopeId : the requested skope id is not registered : ' + skope_id );
9222
  return skope_id;
9223
  }
9224
+
9225
+ //Are we already in the 'local' skope ?
9226
  var self = this,
9227
  _local_skope_id = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
9228
 
9229
  if ( _.isUndefined( _local_skope_id ) || skope_id == _local_skope_id )
9230
  return skope_id;
9231
+
9232
+ //start from local and do the salmon until either :
9233
+ //1) a value is found
9234
+ //2) the requested skope id is reached in the hierarchy
9235
  var _salmonToMatch = function( _skp_id ) {
9236
  var wpSetId = api.CZR_Helpers.build_setId( setId ),
9237
  val_candidate = '___',
9240
 
9241
  if ( _skp_id == skope_id )
9242
  return skope_id;
9243
+
9244
+ //is the setting API dirty ?
9245
  if ( api.czr_skope( _skp_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
9246
  return skope_model.id;
9247
+
9248
+ //is the setting CHANGESET dirty ?
9249
  if ( api.czr_isChangeSetOn() ) {
9250
  if ( api.czr_skope( _skp_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
9251
  return skope_model.id;
9252
  }
9253
+
9254
+ //do we have a db val stored ?
9255
  var _skope_db_val = self._getDBSettingVal( setId, _skp_id);
9256
  if ( _skope_db_val != '_no_db_val' ) {
9257
  return skope_model.id;
9258
  }
9259
+ //if we are already in the final 'local' skope, then let's return its value
9260
  else if( 'global' == skope_model.skope ) {
9261
+ // if ( _.isNull(initial_val) ) {
9262
+ // throw new Error('INITIAL VAL IS NULL FOR SETTING ' + setId + ' CHECK IF IT HAS BEEN DYNAMICALLY ADDED. IF SO, THERE SHOULD BE A DIRTY TO GRAB');
9263
+ // }
9264
  return skope_model.id;
9265
  }
9266
  else {
9267
+ //if not dirty and no db val, then let's recursively apply the inheritance
9268
  return '___' != val_candidate ? skope_model.title : _salmonToMatch( self._getParentSkopeId( skope_model ) );
9269
  }
9270
  };
9271
  return _salmonToMatch( _local_skope_id );
9272
  },
9273
+
9274
+ //@return string : the skope title from which a setting id inherits its current value
9275
  getOverridenSkopeTitles : function() {
9276
  var skope_id = skope_id || api.czr_activeSkopeId();
9277
  if ( ! api.czr_skope.has( skope_id ) ) {
9278
  api.errorLog( 'getInheritedSkopeTitles : the requested skope id is not registered : ' + skope_id );
9279
  return '';
9280
  }
9281
+ //Are we already in the 'local' skope ?
9282
  var self = this,
9283
  _local_skope_id = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
9284
 
9285
  if ( _.isUndefined( _local_skope_id ) || skope_id == _local_skope_id )
9286
  return '';
9287
+
9288
+ //start from local and do the salmon
9289
  var _salmonToMatch = function( _skp_id, _skp_ids ) {
9290
  _skp_ids = _skp_ids || [];
9291
  var skope_model = api.czr_skope( _skp_id )();
9300
  return self.buildSkopeLink( id );
9301
  }).join( ' ' + serverControlParams.i18n.skope['and'] + ' ' );
9302
  },
9303
+
9304
+
9305
+ //@return the skope title from which a setting id inherits its current value
9306
  getInheritedSkopeId : function( setId, skope_id ) {
9307
  if ( ! api.has( api.CZR_Helpers.build_setId(setId) ) ) {
9308
  api.errorLog( 'getInheritedSkopeId : the requested setting id does not exist in the api : ' + api.CZR_Helpers.build_setId(setId) );
9318
  val_candidate = '___',
9319
  skope_model = api.czr_skope( skope_id )(),
9320
  initial_val;
9321
+ //initial val
9322
+ //some settings like widgets may be dynamically added. Therefore their initial val won't be stored in the api.settings.settings
9323
  if ( _.has( api.settings.settings, wpSetId ) )
9324
  initial_val = api.settings.settings[wpSetId].value;
9325
  else
9326
  initial_val = null;
9327
+
9328
+ //is the setting API dirty ?
9329
  if ( api.czr_skope( skope_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
9330
  return skope_id;
9331
+
9332
+ //is the setting CHANGESET dirty ?
9333
  if ( api.czr_isChangeSetOn() ) {
9334
  if ( api.czr_skope( skope_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
9335
  return skope_id;
9336
  }
9337
+
9338
+ //do we have a db val stored ?
9339
  var _skope_db_val = self._getDBSettingVal( setId, skope_id );
9340
  if ( _skope_db_val != '_no_db_val' )
9341
  return skope_id;
9342
+ //if we are already in the final 'global' skope, then let's return its value
9343
  else if( 'global' == skope_model.skope ) {
9344
+ // if ( _.isNull(initial_val) ) {
9345
+ // throw new Error('INITIAL VAL IS NULL FOR SETTING ' + setId + ' CHECK IF IT HAS BEEN DYNAMICALLY ADDED. IF SO, THERE SHOULD BE A DIRTY TO GRAB');
9346
+ // }
9347
  return skope_id;
9348
  }
9349
  else
9350
+ //if not dirty and no db val, then let's recursively apply the inheritance
9351
  return '___' != val_candidate ?skope_id : self.getInheritedSkopeId( setId, self._getParentSkopeId( skope_model ) );
9352
  },
9353
+
9354
+
9355
+ //@return the skope title from which a setting id inherits its current value
9356
+ //@return string
9357
  getInheritedSkopeTitles : function( skope_id, skope_ids ) {
9358
  skope_id = skope_id || api.czr_activeSkopeId();
9359
  if ( ! api.czr_skope.has( skope_id ) ) {
9374
  return self.buildSkopeLink( id );
9375
  }).join(' ' + serverControlParams.i18n.skope['and'] + ' ');
9376
  },
9377
+
9378
+ //@return string
9379
  buildSkopeLink : function( skope_id ) {
9380
  if ( ! api.czr_skope.has( skope_id ) ) {
9381
  api.errorLog( 'buildSkopeLink : the requested skope id is not registered : ' + skope_id );
9388
  '</span>'
9389
  ].join( '' );
9390
  },
9391
+
9392
+
9393
+ //@return boolean
9394
+ //isAllowedWPBuiltinSetting :
9395
+
9396
+ //performs a recursive inheritance to get a setId Val for a given skope
9397
+ //@return an api setting value
9398
  getSkopeSettingVal : function( setId, skope_id ) {
9399
  if ( ! api.has( api.CZR_Helpers.build_setId(setId) ) ) {
9400
  api.errorLog( 'getSkopeSettingVal : the requested setting id does not exist in the api : ' + api.CZR_Helpers.build_setId(setId) );
9410
  val_candidate = '___',
9411
  skope_model = api.czr_skope( skope_id )(),
9412
  initial_val;
9413
+
9414
+ //initial val
9415
+ //some settings like widgets may be dynamically added. Therefore their initial val won't be stored in the api.settings.settings
9416
  if ( _.has( api.settings.settings, wpSetId ) )
9417
  initial_val = api.settings.settings[wpSetId].value;
9418
  else
9419
  initial_val = null;
9420
+
9421
+ //is the setting API dirty ?
9422
  if ( api.czr_skope( skope_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
9423
  return api.czr_skope( skope_id ).dirtyValues()[ wpSetId ];
9424
+
9425
+ //is the setting CHANGESET dirty ?
9426
  if ( api.czr_isChangeSetOn() ) {
9427
  if ( api.czr_skope( skope_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
9428
  return api.czr_skope( skope_id ).changesetValues()[ wpSetId ];
9429
  }
9430
+
9431
+ //do we have a db val stored ?
9432
  var _skope_db_val = self._getDBSettingVal( setId, skope_id );
9433
  if ( _skope_db_val != '_no_db_val' )
9434
  return _skope_db_val;
9435
+ //if we are already in the final 'global' skope, then let's return its value
9436
  else if( 'global' == skope_model.skope ) {
9437
+ // if ( _.isNull(initial_val) ) {
9438
+ // throw new Error('INITIAL VAL IS NULL FOR SETTING ' + setId + ' CHECK IF IT HAS BEEN DYNAMICALLY ADDED. IF SO, THERE SHOULD BE A DIRTY TO GRAB');
9439
+ // }
9440
  return '___' == val_candidate ? initial_val : val_candidate;
9441
  }
9442
  else
9443
+ //if not dirty and no db val, then let's recursively apply the inheritance
9444
  return '___' != val_candidate ? val_candidate : self.getSkopeSettingVal( setId, self._getParentSkopeId( skope_model ) );
9445
  },
9446
+
9447
+
9448
+ //implement the skope inheritance to build the dirtyCustomized
9449
+ //@recursive
9450
  applyDirtyCustomizedInheritance : function( dirtyCustomized, skope_id ) {
9451
  skope_id = skope_id || api.czr_activeSkopeId() || api.czr_skopeBase.getGlobalSkopeId();
9452
  dirtyCustomized = dirtyCustomized || {};
9459
 
9460
  var parent_skope_id = self._getParentSkopeId( skope_model ),
9461
  parent_dirties = api.czr_skope( parent_skope_id ).dirtyValues();
9462
+
9463
+ //use the parent dirty value if the current skope setId is not dirty and has no db val
9464
  _.each( parent_dirties, function( _val, wpSetId ){
9465
  var shortSetId = api.CZR_Helpers.getOptionName( wpSetId );
9466
  if ( _.isUndefined( dirtyCustomized[wpSetId] ) && _.isUndefined( api.czr_skope( skope_model.id ).dbValues()[shortSetId] ) )
9468
  });
9469
  return 'global' == api.czr_skope( parent_skope_id )().skope ? dirtyCustomized : self.applyDirtyCustomizedInheritance( dirtyCustomized, parent_skope_id );
9470
  },
9471
+
9472
+
9473
+
9474
+ //@return the parent skope id of a given skope within the collections of currentSkopes
9475
+ //recursive
9476
  _getParentSkopeId : function( skope_model, _index ) {
9477
  var self = this,
9478
  hierark = ['local', 'group', 'special_group', 'global'],
9482
  if ( _.isUndefined( parent_skope_skope ) ) {
9483
  return _.findWhere( api.czr_currentSkopesCollection(), { skope : 'global' } ).id;
9484
  }
9485
+
9486
+ //=> the inheritance is limited to current set of skopes
9487
  if ( _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), { skope : parent_skope_skope } ) ) ) {
9488
  return self._getParentSkopeId( skope_model, parent_skope_ind + 1 );
9489
  }
9490
  return _.findWhere( api.czr_currentSkopesCollection(), { skope : parent_skope_skope } ).id;
9491
  },
9492
+
9493
+
9494
+ //@return the parent skope id of a given skope within the collections of currentSkopes
9495
+ //recursive
9496
  _getChildSkopeId : function( skope_model, _index ) {
9497
  var self = this,
9498
  hierark = ['local', 'group', 'special_group', 'global'],
9502
  if ( _.isUndefined( child_skope_skope ) ) {
9503
  return _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
9504
  }
9505
+
9506
+ //=> the inheritance is limited to current set of skopes
9507
  if ( _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), { skope : child_skope_skope } ) ) ) {
9508
  return self._getParentSkopeId( skope_model, child_skope_ind - 1 );
9509
  }
9515
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
9516
  ( function ( api, $, _ ) {
9517
  $.extend( CZRSkopeBaseMths, {
9518
+
9519
+ //Fired on 'czr-skopes-synced' triggered by the preview, each time the preview is refreshed.
9520
+ //On a Save Action, api.czr_savedDirties has been populated =>
9521
+ // 1) check if the server sends the same saved values
9522
+ // 2) update the skope db properties with the latests saved ones
9523
+ //
9524
+ //A skope candidate is structured this way :
9525
+ //{
9526
+ // changeset : Object
9527
+ // color:"rgb(255, 255, 255)"
9528
+ // db:Object
9529
+ // dyn_type:"option"
9530
+ // has_db_val:true
9531
+ // id:""
9532
+ // is_forced:false
9533
+ // is_primary:true
9534
+ // is_winner:false
9535
+ // level:"_all_"
9536
+ // long_title:"Site wide options"
9537
+ // obj_id:""
9538
+ // opt_name:"hu_theme_options"
9539
+ // skope:"global"
9540
+ // title:"Site wide options"
9541
+ //}
9542
+ //@see api_overrides
9543
  updateSkopeCollection : function( sent_collection, sent_channel ) {
9544
+ //api.consoleLog('UPDATE SKOPE COLLECTION', sent_collection, sent_channel );
9545
  var self = this;
9546
  _api_ready_collection = [];
9547
+
9548
+ //normalize each sent skopes
9549
  _.each( sent_collection, function( _skope, _key ) {
9550
  var skope_candidate = $.extend( true, {}, _skope );//deep clone to avoid any shared references
9551
  _api_ready_collection.push( self.prepareSkopeForAPI( skope_candidate ) );
9552
  });
9553
+
9554
+ //keep the global skope unchanged
9555
+ //=> this is required because the server always sends an empty set of db options for the global skope, unlike the other skopes
9556
  if ( self.isGlobalSkopeRegistered() ) {
9557
  var _updated_api_ready_collection = [],
9558
  _global_skp_model = $.extend( true, {}, api.czr_skope( self.getGlobalSkopeId() )() );
9565
  });
9566
  _api_ready_collection = _updated_api_ready_collection;
9567
  }
9568
+
9569
+ //set the new collection of current skopes
9570
+ //=> this will instantiate the not instantiated skopes
9571
  api.czr_currentSkopesCollection( _api_ready_collection );
9572
  },
9573
+
9574
+
9575
+ //@param skope_candidate
9576
+ ////A skope candidate is structured this way :
9577
+ //{
9578
+ // changeset : Object
9579
+ // color:"rgb(255, 255, 255)"
9580
+ // db:Object
9581
+ // dyn_type:"option"
9582
+ // has_db_val:true
9583
+ // id:""
9584
+ // is_forced:false
9585
+ // is_primary:true
9586
+ // is_winner:false
9587
+ // level:"_all_"
9588
+ // long_title:"Site wide options"
9589
+ // obj_id:""
9590
+ // opt_name:"hu_theme_options"
9591
+ // skope:"global"
9592
+ // title:"Site wide options"
9593
+ //}
9594
  prepareSkopeForAPI : function( skope_candidate ) {
9595
  if ( ! _.isObject( skope_candidate ) ) {
9596
  throw new Error('prepareSkopeForAPI : a skope must be an object to be API ready');
9661
  }
9662
  api_ready_skope[_key] = _candidate_val;
9663
  break;
9664
+ //when the global db values have been changed, typically on save,
9665
+ //the 'db' property will store the difference between api.settings.settings and the db options server generated
9666
  case 'db' :
9667
  if ( _.isArray( _candidate_val ) || _.isEmpty( _candidate_val ) )
9668
  _candidate_val = {};
9687
  break;
9688
  }//switch
9689
  });
9690
+
9691
+ //Assign a color based on the hiearchy level
9692
  api_ready_skope.color = self.skope_colors[ api_ready_skope.skope ] || 'rgb(255, 255, 255)';
9693
+
9694
+ //Finally, generate the id and the title
9695
  api_ready_skope.id = api_ready_skope.skope + '_' + api_ready_skope.level;
9696
  if ( ! _.isString( api_ready_skope.id ) || _.isEmpty( api_ready_skope.id ) ) {
9697
  throw new Error('prepareSkopeForAPI : a skope id must a string not empty');
9702
  }
9703
  return api_ready_skope;
9704
  },
9705
+
9706
+
9707
+ //cb of api.czr_currentSkopesCollection.callbacks
9708
+ //fired in initialize
9709
  currentSkopesCollectionReact : function( to, from ) {
9710
  var self = this,
9711
  _new_collection = $.extend( true, [], to ) || [],
9712
  _old_collection = $.extend( true, [], from ) || [],
9713
  dfd = $.Deferred();
9714
+
9715
+ //what are the skope to instantiate ?
9716
+ //=>on init, instantiate them all
9717
+ //=>on refresh, instantiate the new ones and remove the non relevant
9718
  var _to_instantiate = [];
9719
  _to_remove = [];
9720
  _to_update = [];
9721
  _instantiateAndEmbed = function( _candidates_ ) {
9722
+ //Instantiate the new skopes
9723
+ //api.consoleLog('SKOPES TO INSTANTIATE?', _to_instantiate );
9724
  _.each( _candidates_, function( _skope ) {
9725
  _skope = $.extend( true, {}, _skope );//use a cloned skop to instantiate : @todo : do we still need that ?
9726
  api.czr_skope.add( _skope.id , new api.CZR_skope( _skope.id , _skope ) );
9727
  });
9728
+
9729
+ //Then embed the not ready ones
9730
+ //=> we need to do that after the instantiaion of the entire new collection, because a skope instance my need to get other skope instances when embedded
9731
  _.each( _candidates_, function( _skope ) {
9732
+ //fire this right after instantiation for the views (we need the model instances in the views)
9733
  if ( ! api.czr_skope.has( _skope.id ) ) {
9734
  throw new Error( 'Skope id : ' + _skope.id + ' has not been instantiated.');
9735
  }
9738
  }
9739
  });
9740
  };
9741
+
9742
+ //BUILD THE CANDIDATES TO INSTANTIATE
9743
  _.each( _new_collection, function( _sent_skope ) {
9744
  if ( ! api.czr_skope.has( _sent_skope.id ) )
9745
  _to_instantiate.push( _sent_skope );
9746
  });
9747
+
9748
+ //TRY TO INSTANTIATE
9749
  try {
9750
  _instantiateAndEmbed( _to_instantiate );
9751
  } catch( er ) {
9752
  api.errorLog( "currentSkopesCollectionReact : " + er );
9753
  return dfd.resolve().promise();
9754
  }
9755
+
9756
+
9757
+ //SET THE CONTEXTUALLY ACTIVE SKOPES VISIBILITY AND LAYOUT WHEN skopeReady and skopeWrapperEmbedded
9758
+ //Which skopes are visible ?
9759
+ //=> the ones sent by the preview
9760
  var _setActiveAndLayout = function() {
9761
  var _activeSkopeNum = _.size( _new_collection ),
9762
  _setLayoutClass = function( _skp_instance ) {
9763
+ //remove previous layout class
9764
  var _newClasses = _skp_instance.container.attr('class').split(' ');
9765
  _.each( _skp_instance.container.attr('class').split(' '), function( _c ) {
9766
  if ( 'width-' == _c.substring( 0, 6) ) {
9769
  });
9770
  $.when( _skp_instance.container.attr('class', _newClasses.join(' ') ) )
9771
  .done( function() {
9772
+ //set new layout class
9773
  _skp_instance.container.addClass( 'width-' + ( Math.round( 100 / _activeSkopeNum ) ) );
9774
  });
9775
  };
9796
  }
9797
  } );
9798
  };
9799
+
9800
+ //SET THE CONTEXTUALLY ACTIVE SKOPES VISIBILITY AND LAYOUT WHEN skopeReady and skopeWrapperEmbedded
9801
  self.skopeWrapperEmbedded.then( function() {
9802
  _setActiveAndLayout();
9803
  });
9804
+
9805
+ //ON INITIAL COLLECTION POPULATE, RESOLVE THE DEFERRED STATE
9806
+ //=> this way we can defer earlier actions.
9807
+ //For example when autofocus is requested, the section might be expanded before the initial skope collection is sent from the preview.
9808
  if ( _.isEmpty( from ) && ! _.isEmpty( to ) )
9809
  api.czr_initialSkopeCollectionPopulated.resolve();
9810
+
9811
+ //MAKE SURE TO SYNCHRONIZE api.settings.settings with the current global skope updated db values
9812
  self.maybeSynchronizeGlobalSkope();
9813
 
9814
  return dfd.resolve( 'changed' ).promise();
9815
  },//listenToSkopeCollection()
9816
+
9817
+
9818
+ //fired in updateSkopeCollection
9819
+ //args can be
9820
+ //{
9821
+ // isGlobalReset : false
9822
+ // isSetting : false,
9823
+ // isSkope : false,
9824
+ // settingIdToReset : '',
9825
+ // skopeIdToReset : ''
9826
+ //}
9827
  maybeSynchronizeGlobalSkope : function( args ) {
9828
  args = args || {};
9829
  if ( ! _.isObject( args ) ) {
9851
  api.settings.settings[setId].value = _val;
9852
  }
9853
  });
9854
+
9855
+ //check if there's theme option removed from the global skope db values that needs to be set to default
9856
  if ( args.isGlobalReset && args.isSetting ) {
9857
  _setIdToReset = args.settingIdToReset;
9858
  shortSetId = api.CZR_Helpers.getOptionName( _setIdToReset );
9864
  api.settings.settings[ _setIdToReset ].value = defaultVal;
9865
  }
9866
  }
9867
+
9868
+ //check if there's theme option removed from the global skope db values that needs to be set to default
9869
  if ( args.isGlobalReset && args.isSkope ) {
9870
  _.each( api.settings.settings, function( _params, _setId ) {
9871
  if ( ! self.isThemeSetting( _setId ) )
9885
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
9886
  ( function ( api, $, _ ) {
9887
  $.extend( CZRSkopeBaseMths, {
9888
+
9889
+ //declared in initialize
9890
+ //cb of api.czr_activeSkopeId.callbacks
9891
+ //react when the active skope has been set to a new value
9892
+ // => change the to and from skope active() state
9893
+ // => silently update each setting values with the skope set of vals
9894
  activeSkopeReact : function( to, from ) {
9895
  var self = this, dfd = $.Deferred();
9896
+ //set the to and from scope state on init and switch
9897
  if ( ! _.isUndefined(from) && api.czr_skope.has(from) )
9898
  api.czr_skope(from).active(false);
9899
  else if ( ! _.isUndefined( from ) )
9903
  api.czr_skope(to).active(true);
9904
  else
9905
  throw new Error('listenToActiveSkope : requested scope ' + to + ' does not exist in the collection');
9906
+
9907
+
9908
+ //BAIL AND RETURN PROMISE HERE IF SWITCHING TO A PANEL OR SECTION WITH ONLY UNSKOPED SETTINGS
9909
+ // => widgets and custom_css
9910
+ //Switch to global skope for not skoped panels
9911
  var _switchBack = function( _title ) {
9912
  api.czr_activeSkopeId( self.getGlobalSkopeId() );
9913
+ //<@4.9compat>
9914
+ if ( ! _.isUndefined( api.notifications ) ) {
9915
+ api.notifications.add( new wp.customize.Notification( _title, {
9916
+ type: 'info',
9917
+ message: [ _title , 'is always customized sitewide.' ].join(' '),
9918
+ dismissible: true
9919
+ } ) );
9920
+
9921
+ // Removed if not dismissed after 5 seconds
9922
+ _.delay( function() {
9923
+ if ( api.notifications.has( _title ) ) {
9924
+ var _notif_ = api.notifications( _title );
9925
+ if ( _notif_.parent ) {
9926
+ _notif_.parent.remove( _notif_.code );
9927
+ } else {
9928
+ _notif_.container.remove();
9929
+ }
9930
+ }
9931
+ }, 5000 );
9932
+ }
9933
+ //</@4.9compat>
9934
+ else {
9935
+ api.czr_serverNotification({
9936
+ status:'success',
9937
+ message : [ _title , 'is always customized sitewide.' ].join(' ')
9938
+ });
9939
+ }
9940
  return dfd.resolve().promise();
9941
  };
9942
+
9943
+
9944
  if ( self.isExcludedSidebarsWidgets() && 'widgets' == api.czr_activePanelId() && to != self.getGlobalSkopeId() ) {
9945
+ //<@4.9compat>
9946
+ if ( ! _.isUndefined( api.notifications ) ) {
9947
+ api.notifications.add( new wp.customize.Notification( 'widgets_are_sidewide', {
9948
+ type: 'info',
9949
+ message: serverControlParams.i18n.skope['Widgets are created sitewide.'],
9950
+ dismissible: true
9951
+ } ) );
9952
+
9953
+ // Removed if not dismissed after 5 seconds
9954
+ _.delay( function() {
9955
+ if ( api.notifications.has( 'widgets_are_sidewide' ) ) {
9956
+ var _notif_ = api.notifications( 'widgets_are_sidewide' );
9957
+ if ( _notif_.parent ) {
9958
+ _notif_.parent.remove( _notif_.code );
9959
+ } else {
9960
+ _notif_.container.remove();
9961
+ }
9962
+ }
9963
+ }, 5000 );
9964
+ }
9965
+ //</@4.9compat>
9966
+ else {
9967
+ api.czr_serverNotification({
9968
+ status:'success',
9969
+ message : [
9970
+ serverControlParams.i18n.skope['Widgets are created sitewide.']
9971
+ ].join(' ')
9972
+ });
9973
+ }
9974
+
9975
+ //return dfd.resolve().promise();// _switchBack( api.panel( api.czr_activePanelId() ).params.title );
9976
  }
9977
+
9978
  if ( self.isExcludedWPCustomCss() && 'custom_css' == api.czr_activeSectionId() && to != self.getGlobalSkopeId() ) {
9979
  return _switchBack( api.section( api.czr_activeSectionId() ).params.title );
9980
  }
9981
  if ( 'admin_sec' == api.czr_activeSectionId() && to != self.getGlobalSkopeId() ) {
9982
  return _switchBack( api.section( api.czr_activeSectionId() ).params.title );
9983
  }
9984
+ if ( 'tc_font_customizer_settings' == api.czr_activeSectionId() && to != self.getGlobalSkopeId() ) {
9985
+ return _switchBack( api.section( api.czr_activeSectionId() ).params.title );
9986
+ }
9987
+
9988
  if ( ( 'nav_menu' == api.czr_activeSectionId().substring( 0, 'nav_menu'.length ) || 'add_menu' == api.czr_activeSectionId() ) && to != self.getGlobalSkopeId() ) {
9989
  api.czr_serverNotification({
9990
  status:'success',
9992
  serverControlParams.i18n.skope['Menus are created sitewide.']
9993
  ].join(' ')
9994
  });
9995
+ //_switchBack( api.section( api.czr_activeSectionId() ).params.title );
9996
  }
9997
+
9998
+
9999
+ //AWAKE NOT CURRENTLY ACTIVE NAV MENUS SECTION
10000
+ //=> this solves the problem of nav menu location not being refreshed on skope switch
10001
  if ( 'nav_menus' == api.czr_activePanelId() ) {
10002
  _.each( api.panel( api.czr_activePanelId() ).sections(), function( _sec ) {
10003
+ //PROCESS SILENT UPDATES
10004
  self.processSilentUpdates( { section_id : _sec.id, awake_if_not_active : true } );
10005
  });
10006
  }
10007
+
10008
+
10009
+ //Set state
10010
  api.state('switching-skope')( true );
10011
+ //write the current skope title
10012
  self._writeCurrentSkopeTitle( to );
10013
+ //paint skope color
10014
  api.trigger( 'czr-paint', { is_skope_switch : true } );
10015
+
10016
+ //CURRENT EXPANDED SECTION DEPENDANT ACTIONS
10017
+ //stop here if the active section is not set yet
10018
+ //=> the silent update will be fired on section expansion anyway
10019
+ //=> refresh now if the previewer is not skope aware, this will post the dyn_type used in the preview to get the proper option if the skope is not 'global'
10020
+ //=> otherwise simply refresh to set the new skope in the query params => needed for the preview frame
10021
  if ( _.isUndefined( api.czr_activeSectionId() ) ) {
10022
+ // if ( 'pending' == api.czr_isPreviewerSkopeAware.state() ) {
10023
+ // api.previewer.refresh();
10024
+ // } else {
10025
+ // api.previewer.refresh();
10026
+ // }
10027
  api.state('switching-skope')( false );
10028
  api.previewer.refresh();
10029
  return dfd.resolve().promise();
10030
  }
10031
+
10032
+ //close the module panel id needed
10033
  if ( _.has( api, 'czrModulePanelState') )
10034
  api.czrModulePanelState(false);
10035
+
10036
+ //PROCESS SILENT UPDATES
10037
+ //Build the silent update candidates array
10038
+ //populates with the current section setting ids or the one provided
10039
  var _silentUpdateCands = self._getSilentUpdateCandidates();
10040
+
10041
+ //add the previous skope dirty settings ids
10042
  if ( ! _.isUndefined( from ) ) {
10043
  _.each( api.czr_skope( from ).dirtyValues(), function( val, _setId ) {
10044
  if ( ! _.contains( _silentUpdateCands, _setId ) )
10051
  _silentUpdateCands.push( _setId );
10052
  } );
10053
  }
10054
+
10055
+ //api.consoleLog('ACTIVE SKOPE REACT', to, from, _silentUpdateCands );
10056
+
10057
+ //Process Silent Updates and
10058
+ //make sure that the visibility is processed after the silent updates
10059
  var _debouncedProcessSilentUpdates = function() {
10060
  self.processSilentUpdates( {
10061
  candidates : _silentUpdateCands,
10073
  dfd.resolve( _updatedSetIds );
10074
  api.state( 'switching-skope' )( false );
10075
  });
10076
+
10077
+ //on first skope reaction ( initialization phase ) , when from is still undefined : no need to refresh if the target skope is global
10078
+ //=> improve speed performance on init
10079
+ // if ( _.isUndefined( from ) && api.czr_skope.has( to ) && 'global' == api.czr_skope( to )().skope ) {
10080
+ // dfd.resolve( _updatedSetIds );
10081
+ // api.state( 'switching-skope' )( false );
10082
+ // } else {
10083
+ // api.previewer.refresh()
10084
+ // .always( function() {
10085
+ // dfd.resolve( _updatedSetIds );
10086
+ // api.state( 'switching-skope' )( false );
10087
+ // });
10088
+ // }
10089
  });
10090
  };
10091
+
10092
+ //Process silent updates
10093
+ //Collapse the current expanded module if any
10094
  if ( _.has(api, 'czr_isModuleExpanded') && false !== api.czr_isModuleExpanded() ) {
10095
  api.czr_isModuleExpanded().setupModuleViewStateListeners(false);
10096
  _debouncedProcessSilentUpdates = _.debounce( _debouncedProcessSilentUpdates, 400 );
10100
  }
10101
  return dfd.promise();
10102
  },//activeSkopeReact
10103
+
10104
+
10105
+
10106
+ //@return void()
10107
+ //Fired in activeSkopeReact()
10108
  _writeCurrentSkopeTitle : function( skope_id ) {
10109
  var self = this,
10110
  current_title = api.czr_skope( skope_id || api.czr_activeSkopeId() )().long_title,
10134
  $('.czr-scope-switcher').find('.spinner').fadeOut();
10135
  }
10136
  };
10137
+
10138
+ //render / update the title
10139
  self.skopeWrapperEmbedded
10140
  .then( function() {
10141
  if ( ! $('.czr-scope-switcher').find('.czr-current-skope-title').length ) {
10170
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
10171
  ( function ( api, $, _ ) {
10172
  $.extend( CZRSkopeBaseMths, {
10173
+ //@param params :
10174
+ // {
10175
+ // candidates : silentUpdateCands,
10176
+ // section_id : section_id,
10177
+ // refresh : true,
10178
+ // awake_if_not_active : false
10179
+ // }
10180
  processSilentUpdates : function( params ) {
10181
+ //api.consoleLog('PROCESS SILENT UPDATES', params );
10182
+ //a setting id can be passed as param instead of an object
10183
  if ( _.isString( params ) )
10184
  params = { candidates : [ params ] };
10185
  else
10195
  dfd = $.Deferred();
10196
 
10197
  params = $.extend( defaultParams, params );
10198
+
10199
+ //Cast the candidates to an array, if only one setId is passed as a string
10200
  if ( _.isString( params.candidates ) ) {
10201
  params.candidates = [ params.candidates ];
10202
  }
10203
+
10204
+ //do we have well defined silent update candidates ?
10205
  if ( _.isEmpty( params.candidates ) )
10206
  params.candidates = self._getSilentUpdateCandidates( params.section_id, params.awake_if_not_active );
10207
  if ( ! _.isArray( params.candidates ) ) {
10208
  throw new Error('processSilentUpdates : the update candidates must be an array.');
10209
  }
10210
+
10211
+ //bail now if we still don't have candidates to update
10212
  if ( _.isEmpty( params.candidates ) )
10213
  return dfd.resolve( [] ).promise();
10214
 
10227
  dfd.resolve( updated_settings );
10228
  });
10229
  };
10230
+
10231
+ //silently update the settings of a the currently active section() to the values of the current skope
10232
+ //silentlyUpdateSettings returns a promise.
10233
  if ( 'resolved' != api.czr_skopeReady.state() ) {
10234
  dfd.resolve( [] );
10235
  api.czr_skopeReady.done( function() {
10248
  /*****************************************************************************
10249
  * UPDATE SETTING VALUES
10250
  *****************************************************************************/
10251
+ //silently update a set of settings or a given setId
10252
+ //1) Build an array of promises for each settings
10253
+ //2) When all asynchronous promises are done(). Refresh()
10254
+ //@return an array of promises. Typically if a setting update has to re-render an image related control, the promise is the ajax request object
10255
  silentlyUpdateSettings : function( _silentUpdateCands, refresh ) {
10256
+ //Declare a new api state
10257
  if ( ! api.state.has( 'silent-update-processing') )
10258
  api.state.create( 'silent-update-processing' )( false );
10259
 
10260
  api.state( 'silent-update-processing' )(true);
10261
+
10262
+ //api.consoleLog('silentlyUpdateSettings', _silentUpdateCands, refresh );
10263
  var self = this,
10264
  _silentUpdatePromises = {},
10265
  dfd = $.Deferred();
10273
  if ( _.isString( _silentUpdateCands ) ) {
10274
  _silentUpdateCands = [ _silentUpdateCands ];
10275
  }
10276
+
10277
+ //api.consoleLog('the silentUpdateCands', _silentUpdateCands );
10278
+
10279
+ //Fire the silent updates promises
10280
  _.each( _silentUpdateCands, function( setId ) {
10281
  if ( api.control.has( setId ) && 'czr_multi_module' == api.control(setId).params.type )
10282
  return;
10286
 
10287
  var _deferred = [],
10288
  _updatedSetIds = [];
10289
+ // _silently_update = function( _silentUpdatePromises ) {
10290
+ // _.each( _silentUpdatePromises, function( _promise_ , setId ) {
10291
+ // //Silently set
10292
+ // var wpSetId = api.CZR_Helpers.build_setId( setId ),
10293
+ // _skopeDirtyness = api.czr_skope( api.czr_activeSkopeId() ).getSkopeSettingDirtyness( setId );
10294
+ // api( wpSetId ).silent_set( obj.val, _skopeDirtyness );
10295
+ // });
10296
+ // };
10297
+
10298
+ //Populates the promises
10299
+ //Silently set each setting when its promise is done.
10300
  _.each( _silentUpdatePromises, function( _promise_ , setId ) {
10301
  _promise_.done( function( _new_setting_val_ ) {
10302
+ //Silently set
10303
  var wpSetId = api.CZR_Helpers.build_setId( setId ),
10304
  _skopeDirtyness = api.czr_skope( api.czr_activeSkopeId() ).getSkopeSettingDirtyness( setId );
10305
  if ( ! _.isEqual( api( wpSetId )(), _new_setting_val_ ) ) {
10310
 
10311
  _deferred.push( _promise_ );
10312
  });
10313
+
10314
+ //Resolve this method deferred when all setting promises are done
10315
  $.when.apply( null, _deferred )
10316
+ // .always( function() {
10317
+ // var _has_rejected_promise = false;
10318
+ // _.each( _deferred, function( _defd ) {
10319
+ // if ( _.isObject( _defd ) && 'rejected' == _defd.state() ) {
10320
+ // _has_rejected_promise = true;
10321
+ // }
10322
+ // //@todo improve this!
10323
+ // $.when( _silently_update() ).done( function() {
10324
+ // api.previewer.refresh();
10325
+ // });
10326
+ // });
10327
+
10328
+ // })
10329
  .fail( function() {
10330
  dfd.reject();
10331
  throw new Error( 'silentlyUpdateSettings FAILED. Candidates : ' + _silentUpdateCands );
10339
  throw new Error( 'a silent update promise is unresolved : ' + _silentUpdateCands );
10340
  }
10341
  });
10342
+ //always refresh by default
10343
  if ( refresh && ! _.isEmpty( _updatedSetIds ) ) {
10344
  api.previewer.refresh()
10345
  .always( function() {
10349
  dfd.resolve( _updatedSetIds );
10350
  }
10351
  });
10352
+
10353
+ //return the collection of update promises
10354
  return dfd.promise();
10355
  },
10356
+
10357
+
10358
+
10359
+
10360
+
10361
+
10362
+ //This method is typically called to update the current active skope settings values
10363
+ //
10364
+ //, therefore @param shortSetId is the only mandatory param
10365
+ //@param setId : the api setting id, might be the short version
10366
+ //@param val : the new val
10367
+ //@return a promise() $ object when an ajax fetch is processed, typically when updating an image.
10368
  getSettingUpdatePromise : function( setId ) {
10369
  if ( _.isUndefined( setId ) ) {
10370
  throw new Error('getSettingUpdatePromise : the provided setId is not defined');
10380
  _promise = false,
10381
  skope_id = api.czr_activeSkopeId(),
10382
  val = api.czr_skopeBase.getSkopeSettingVal( setId, skope_id );
10383
+
10384
+ //resolve here if the setting val was unchanged
10385
  if ( _.isEqual( current_setting_val, val ) ) {
10386
  return dfd.resolve( val ).promise();
10387
  }
10388
+
10389
+ //THE FOLLOWING TREATMENTS ARE ADAPTED TO SETTING WITH A CORRESPONDING CONTROL
10390
+ //header_image_data not concerned for example
10391
  if ( api.control.has( wpSetId ) ) {
10392
+ //The normal way to synchronize the setting api val and the html val is to use
10393
+ //an overridden version of api.Element.synchronizer.val.update
10394
+ //For some specific controls, we need to implement a different way to synchronize
10395
  var control_type = api.control( wpSetId ).params.type,
10396
  _control_data = api.settings.controls[wpSetId],
10397
  _constructor;
10398
 
10399
+ //////////EXPERIMENT
10400
+ // if ( 'widget_form' == control_type ) {
10401
+ // api.control( wpSetId ).container.remove();
10402
+ // api.control.remove( wpSetId );
10403
+ // }
10404
+
10405
  switch ( control_type ) {
10406
+ //CROPPED IMAGE CONTROL
10407
  case 'czr_cropped_image' :
10408
  _promise = self._getCzrCroppedImagePromise( wpSetId, _control_data );
10409
  break;
10411
  case 'czr_module' :
10412
  self._processCzrModuleSilentActions( wpSetId, control_type, skope_id , _control_data);
10413
  break;
10414
+
10415
+ // case 'czr_multi_module' :
10416
+ // _constructor = api.controlConstructor[control_type];
10417
+ // if ( api.control.has( wpSetId ) ) {
10418
+ // //remove the container and its control
10419
+ // api.control( wpSetId ).container.remove();
10420
+ // api.control.remove( wpSetId );
10421
+ // }
10422
+ // //Silently set
10423
+ // api( wpSetId ).silent_set( val, current_skope_instance.getSkopeSettingDirtyness( setId ) );
10424
+ // //re-instantiate the control with the updated _control_data
10425
+ // api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
10426
+ // break;
10427
+
10428
+ // default :
10429
+ // //Silent set
10430
+ // api( wpSetId ).silent_set( val, current_skope_instance.getSkopeSettingDirtyness( setId ) );
10431
+ // break;
10432
  }//switch
10433
  }//end if api.control.has( wpSetId )
10434
+
10435
+
10436
+ //Special case : the header_image control has 2 associated settings : header_image and header_image_data
10437
+ //when switching skope, we want to refresh the control with the right image
10438
+ //This is a setting
10439
  if ( _.has(api.settings.controls, 'header_image') && 'header_image' == wpSetId ) {
10440
  _promise = self._getHeaderImagePromise( wpSetId, skope_id );
10441
  }
10460
  var self = this,
10461
  SilentUpdateCands = [];
10462
  section_id = ( _.isUndefined( section_id ) || _.isNull( section_id ) ) ? api.czr_activeSectionId() : section_id;
10463
+
10464
+ //skope switch when no section expanded
10465
+ //=> Make it possible to "awake" a not active section
10466
+ //=> typically used to awake nav_menu_locations section when in nav_menus panel
10467
  if ( _.isEmpty( api.czr_activeSectionId() ) && ! awake_if_not_active ) {
10468
  return [];
10469
  }
10470
+ //error cases
10471
  if ( _.isUndefined( section_id ) ) {
10472
  api.consoleLog( '_getSilentUpdateCandidates : No active section provided');
10473
  return [];
10475
  if ( ! api.section.has( section_id ) ) {
10476
  throw new Error( '_getSilentUpdateCandidates : The section ' + section_id + ' is not registered in the API.');
10477
  }
10478
+
10479
+ //GET THE CURRENT EXPANDED SECTION SET IDS
10480
  var section_settings = api.CZR_Helpers.getSectionSettingIds( section_id );
10481
+
10482
+ //keep only the skope eligible setIds
10483
  section_settings = _.filter( section_settings, function( setId ) {
10484
  return self.isSettingSkopeEligible( setId );
10485
  });
10486
+
10487
+ //Populates the silent update candidates array
10488
  _.each( section_settings, function( setId ) {
10489
  SilentUpdateCands.push( setId );
10490
  });
10501
  * SILENT ACTIONS for czr_module_type on skope switch
10502
  * ?? @todo : can't we fire this earlier than in getPromises ?
10503
  *****************************************************************************/
10504
+ //@return void()
10505
  _processCzrModuleSilentActions : function( wpSetId, control_type, skope_id, _control_data) {
10506
  var _synced_control_id, _synced_control_val, _synced_control_data, _synced_control_constructor, _syncSektionModuleId,
10507
  _synced_short_id = _.has( api.control( wpSetId ).params, 'syncCollection' ) ? api.control( wpSetId ).params.syncCollection : '',
10508
  _shortSetId = api.CZR_Helpers.build_setId(wpSetId),
10509
  _val = api.czr_skopeBase.getSkopeSettingVal( _shortSetId, skope_id ),
10510
  current_skope_instance = api.czr_skope( api.czr_activeSkopeId() );
10511
+
10512
+ //if in a multimodule context
10513
  if ( ! _.isEmpty( _synced_short_id ) && ! _.isUndefined( _synced_short_id ) ) {
10514
  _synced_control_id = api.CZR_Helpers.build_setId( _synced_short_id );
10515
  _synced_control_val = api.czr_skopeBase.getSkopeSettingVal( _synced_control_id, skope_id );
10516
  _synced_control_data = api.settings.controls[_synced_control_id];
10517
  _synced_control_constructor = api.controlConstructor.czr_multi_module;
10518
  _syncSektionModuleId = api.control( _synced_control_id ).syncSektionModule()().id;
10519
+
10520
+ //remove the container and its control
10521
  api.control( _synced_control_id ).container.remove();
10522
  api.control.remove(_synced_control_id );
10523
+ //Silently set
10524
  api( _synced_control_id ).silent_set( _synced_control_val, current_skope_instance.getSkopeSettingDirtyness( _synced_control_id ) );
10525
+
10526
+ //add the current skope to the control
10527
  $.extend( _synced_control_data, { czr_skope : skope_id });
10528
+
10529
+ //re-instantiate the control with the updated _control_data
10530
  api.control.add( _synced_control_id, new _synced_control_constructor( _synced_control_id, { params : _synced_control_data, previewer : api.previewer }) );
10531
  }
10532
 
10533
  _constructor = api.controlConstructor[control_type];
10534
+
10535
+ //remove the container and its control
10536
  api.control( wpSetId ).container.remove();
10537
  api.control.remove( wpSetId );
10538
+ //Silently set
10539
  api( wpSetId ).silent_set( _val, current_skope_instance.getSkopeSettingDirtyness( _shortSetId ) );
10540
+
10541
+ //add the current skope to the control
10542
  $.extend( _control_data, { czr_skope : skope_id });
10543
+
10544
+ //re-instantiate the control with the updated _control_data
10545
  api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
10546
+
10547
+ //Fire the sektion module if there's a synced sektion
10548
  if ( ! _.isEmpty( _synced_short_id ) && ! _.isUndefined( _synced_short_id ) ) {
10549
  api.consoleLog('FIRE SEKTION MODULE?', _syncSektionModuleId, api.control( wpSetId ).czr_Module( _syncSektionModuleId ).isReady.state() );
10550
  api.control( wpSetId ).czr_Module( _syncSektionModuleId ).fireSektionModule();
10558
  /*****************************************************************************
10559
  * GET PROMISE FOR TYPE : czr_cropped_image
10560
  *****************************************************************************/
10561
+ //@return promise
10562
  _getCzrCroppedImagePromise : function( wpSetId, _control_data ) {
10563
  var _constructor = api.controlConstructor.czr_cropped_image, dfd = $.Deferred(),
10564
  val = api.has(wpSetId) ? api(wpSetId)() : null;
10565
+ //@make sure that the val is not null => won't be accepted in silent set
10566
  val = null === val ? "" : val;
10567
+
10568
+ //re-add the control when the new image has been fetched asynchronously.
10569
+ //if no image can be fetched, for example when in the active skope, the image is not set, then
10570
+ //refresh the control without attachment data
10571
  wp.media.attachment( val ).fetch().done( function() {
10572
+ //remove the container and its control
10573
  api.control( wpSetId ).container.remove();
10574
  api.control.remove( wpSetId );
10575
+ //update the data with the new img attributes
10576
  _control_data.attachment = this.attributes;
10577
+ //instantiate the control with the updated _control_data
10578
  api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
10579
  dfd.resolve();
10580
  } ).fail( function() {
10581
+ //remove the container and its control
10582
  api.control( wpSetId ).container.remove();
10583
  api.control.remove( wpSetId );
10584
+ //update the data : remove the attachment property
10585
  _control_data = _.omit( _control_data, 'attachment' );
10586
+ //instantiate the control with the updated _control_data
10587
  api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
10588
  dfd.reject();
10589
  });
10590
+
10591
+ //set the media fetched as promise to return;
10592
  return dfd.promise();
10593
  },
10594
 
10597
  /*****************************************************************************
10598
  * HEADER IMAGE PROMISE
10599
  *****************************************************************************/
10600
+ //@return promise
10601
  _getHeaderImagePromise : function( wpSetId, skope_id ) {
10602
  var dfd = $.Deferred();
10603
  if ( ! _.has(api.settings.controls, 'header_image') || 'header_image' != wpSetId ) {
10606
 
10607
  var _header_constructor = api.controlConstructor.header,
10608
  _header_control_data = $.extend( true, {}, api.settings.controls.header_image );
10609
+
10610
+ //@make sure that the header_image_data is not null => won't be accepted in silent set
10611
  header_image_data = null === api.czr_skopeBase.getSkopeSettingVal( 'header_image_data', skope_id ) ? "" : api.czr_skopeBase.getSkopeSettingVal( 'header_image_data', skope_id );
10612
 
10613
  var attachment_id;
10614
  var _reset_header_image_crtl = function( _updated_header_control_data ) {
10615
  _updated_header_control_data = _updated_header_control_data || _header_control_data;
10616
+ //remove the container and its control
10617
  api.control( 'header_image' ).container.remove();
10618
  api.control.remove( 'header_image' );
10619
+
10620
+ //reset the HeaderTool objects, captured early
10621
  api.HeaderTool.UploadsList = api.czr_HeaderTool.UploadsList;
10622
  api.HeaderTool.DefaultsList = api.czr_HeaderTool.DefaultsList;
10623
  api.HeaderTool.CombinedList = api.czr_HeaderTool.CombinedList;
10624
  var _render_control = function() {
10625
+ //instantiate the control with the updated _header_control_data
10626
  api.control.add( 'header_image', new _header_constructor( 'header_image', { params : _updated_header_control_data, previewer : api.previewer }) );
10627
  };
10628
  _render_control = _.debounce( _render_control, 800 );
10635
  dfd.resolve();
10636
  } else {
10637
  attachment_id = header_image_data.attachment_id;
10638
+
10639
+ //re-add the control when the new image has been fetched asynchronously.
10640
+ //if no image can be fetched, for example when in the active skope, the image is not set, then
10641
+ //refresh the control without attachment data
10642
  wp.media.attachment( attachment_id ).fetch().done( function() {
10643
+ //update the data with the new img attributes
10644
  _header_control_data.attachment = this.attributes;
10645
  _reset_header_image_crtl( _header_control_data );
10646
  dfd.resolve();
10647
  } ).fail( function() {
10648
+ //update the data : remove the attachment property
10649
  _header_control_data = _.omit( _header_control_data, 'attachment' );
10650
+
10651
+ //remove the container and its control
10652
  api.control( 'header_image' ).container.remove();
10653
  api.control.remove( 'header_image' );
10654
+
10655
+ //reset the HeaderTool objects, captured early
10656
  api.HeaderTool.UploadsList = api.czr_HeaderTool.UploadsList;
10657
  api.HeaderTool.DefaultsList = api.czr_HeaderTool.DefaultsList;
10658
  api.HeaderTool.CombinedList = api.czr_HeaderTool.CombinedList;
10659
+ //instantiate the control with the updated _header_control_data
10660
  api.control.add( 'header_image', new _header_constructor( 'header_image', { params : _header_control_data, previewer : api.previewer }) );
10661
  dfd.reject();
10662
  });
10663
  }//else
10664
+
10665
+ //return the promise
10666
  return dfd.promise();
10667
  }
10668
  });//$.extend
10677
  /*****************************************************************************
10678
  * SETUP CONTROL RESET ON SECTION EXPANSION + SKOPE SWITCH
10679
  *****************************************************************************/
10680
+ //fired on section expansion + skope switch, when silentlyUpdateSettings.done()
10681
+ //@param obj :
10682
+ //{
10683
+ // controls : [] of controls or controlId string
10684
+ // section_id : string
10685
+ //}
10686
+ //@return void()
10687
  setupActiveSkopedControls : function( obj ) {
10688
  var self = this, section_id, controls, setupParams, eligibleCtrls, dfd = $.Deferred();
10689
  defaultSetupParams = {
10708
  }
10709
 
10710
  controls = _.isString( controls ) ? [controls] : controls;
10711
+
10712
+
10713
+ //1) Add CSS classes
10714
+ //2) filter only eligible ctrlIds
10715
  eligibleCtrls = _.filter( controls, function( ctrlId ) {
10716
  var setId = api.CZR_Helpers.getControlSettingId( ctrlId );
10717
  if ( setId && ! self.isSettingSkopeEligible( setId ) ) {
10721
  api.control( ctrlId ).container.addClass('is-wp-authorized-setting');
10722
  }
10723
  return setId && self.isSettingSkopeEligible( setId );
10724
+ //return true;
10725
+ //return self.isSettingSkopeEligible( ctrlId );
10726
+ //return self.isSettingResetEligible( ctrlId );
10727
  });
10728
+
10729
+ //Bail before printing anything if 'nav_menu[' section
10730
  if ( 'nav_menu[' == section_id.substring( 0, 'nav_menu['.length ) )
10731
  return dfd.resolve().promise();
10732
+
10733
+ //Render the reset icon ONLY for eligible controls
10734
+ //Setup the state for all controls, even not eligible ones
10735
  if ( ! _.isEmpty( controls ) ) {
10736
  api.czr_skopeReady.then( function() {
10737
  $.when( self.renderControlsSingleReset( eligibleCtrls ) ).done( function() {
10738
+ //api.consoleLog('RENDER CONTROL SINGLE RESET DONE', controls );
10739
+ //add observable Value(s) to the section control
10740
  _.each( controls, function( ctrlId ) {
10741
  self.listenSkopedControl( ctrlId );
10742
  } );
10743
  dfd.resolve();
10744
  });
10745
  });
10746
+ //paranoid line of code...
10747
  if ( 'rejected' == api.czr_skopeReady.state() )
10748
  dfd.resolve();
10749
  }
10750
+
10751
+ //Prepare skope control notice for all controls, even the non eligible ones
10752
  self.renderCtrlSkpNotIcon( controls );
10753
  return dfd.promise();
10754
  },//setupActiveSkopedControls
10755
+
10756
+
10757
+
10758
+ //@params ctrlId = string control id candidate to setup
10759
  listenSkopedControl : function( ctrlId ) {
10760
  var self = this;
10761
 
10773
  isResetting : false
10774
  },
10775
  initial_states = {};
10776
+
10777
+ //Declare observable Values
10778
+ // + Bind them
10779
  if ( ! _.has( ctrl, 'czr_states' ) ) {
10780
  ctrl.czr_states = new api.Values();
10781
  _.each( defaults, function( _state_val, _state_name ) {
10782
  ctrl.czr_states.create( _state_name );
10783
  ctrl.czr_states( _state_name )( _state_val );
10784
  });
10785
+ //Then listen to their changes
10786
  try { self.bindControlStates( ctrl ); } catch( er ) {
10787
  api.errorLog( 'bindControlStates : ' + er );
10788
  }
10789
  }
10790
+
10791
+ //Set them
10792
+ // initial_states = _.extend(
10793
+ // defaults,
10794
+ // {
10795
+ // hasDBVal : api.czr_skope( api.czr_activeSkopeId() ).hasSkopeSettingDBValues( ctrlId ),
10796
+ // isDirty : api.czr_skope( api.czr_activeSkopeId() ).getSkopeSettingDirtyness( ctrlId )
10797
+ // }
10798
+ // );
10799
  ctrl.czr_states( 'hasDBVal' )( api.czr_skope( api.czr_activeSkopeId() ).hasSkopeSettingDBValues( setId ) );
10800
  ctrl.czr_states( 'isDirty' )( api.czr_skope( api.czr_activeSkopeId() ).getSkopeSettingDirtyness( setId ) );
10801
 
10802
+ //api.consoleLog( 'SETUP CONTROL VALUES ?', ctrlId, api.czr_skope( api.czr_activeSkopeId() ).hasSkopeSettingDBValues( ctrlId ) );
10803
+
10804
 
10805
  if ( ! _.has( ctrl, 'userEventMap' ) ) {
10806
  ctrl.userEventMap = [
10807
+ //toggle reset dialog
10808
  {
10809
  trigger : 'click keydown',
10810
  selector : '.czr-setting-reset, .czr-cancel-button',
10812
  actions : function() {
10813
  if ( ! ctrl.czr_states('isDirty')() && ! ctrl.czr_states( 'hasDBVal' )() )
10814
  return;
10815
+ //close all other warnings expanded in the section
10816
  _.each( _.without( api.CZR_Helpers.getSectionControlIds( ctrl.section() ), ctrlId ) , function( _id ) {
10817
  if ( _.has( api.control(_id), 'czr_states') ) {
10818
  api.control(_id).czr_states( 'resetVisible' )( false );
10819
  }
10820
  });
10821
  ctrl.czr_states( 'resetVisible' )( ! ctrl.czr_states( 'resetVisible' )() );
10822
+ //collapse the control notice expanded if resetting requested
10823
  ctrl.czr_states( 'noticeVisible' )( ! ctrl.czr_states( 'resetVisible' )() );
10824
  }
10825
  },
10826
+ //skope reset : do reset
10827
  {
10828
  trigger : 'click keydown',
10829
  selector : '.czr-control-do-reset',
10832
  self.doResetSetting( ctrlId );
10833
  }
10834
  },
10835
+ //skope switch
10836
  {
10837
  trigger : 'click keydown',
10838
  selector : '.czr-skope-switch',
10843
  api.czr_activeSkopeId( _skopeIdToSwithTo );
10844
  }
10845
  },
10846
+ //Toggle Notice
10847
  {
10848
  trigger : 'click keydown',
10849
  selector : '.czr-toggle-notice',
10850
  name : 'control_toggle_notice',
10851
  actions : function( params ) {
10852
  ctrl.czr_states( 'noticeVisible' )( ! ctrl.czr_states( 'noticeVisible' )() );
10853
+ //collapse the control reset dialog expanded
10854
  if ( ctrl.czr_states( 'noticeVisible' )() ) {
10855
  ctrl.czr_states( 'resetVisible' )( false );
10856
  }
10860
  api.CZR_Helpers.setupDOMListeners( ctrl.userEventMap , { dom_el : ctrl.container }, self );
10861
  }
10862
  },
10863
+
10864
+ //The ctrl.czr_states registered api.Values are :
10865
+ //hasDBVal : false,
10866
+ //isDirty : false,
10867
+ //noticeVisible : false,
10868
+ //resetVisible : false
10869
  bindControlStates : function( ctrl ) {
10870
  if ( ! api.control.has( ctrl.id ) ) {
10871
  throw new Error( 'in bindControlStates, the provided ctrl id is not registered in the api : ' + ctrl.id );
10872
  }
10873
  var self = this,
10874
  setId = api.CZR_Helpers.getControlSettingId( ctrl.id );
10875
+
10876
+ //DB VALS
10877
  ctrl.czr_states( 'hasDBVal' ).bind( function( bool ) {
10878
  ctrl.container.toggleClass( 'has-db-val', bool );
10879
  if ( bool ) {
10885
  }
10886
  ctrl.container.find('.czr-setting-reset').attr( 'title', _title );
10887
  });
10888
+
10889
+ //API DIRTYNESS
10890
  ctrl.czr_states( 'isDirty' ).bind( function( bool ) {
10891
  ctrl.container.toggleClass( 'is-dirty', bool );
10892
  var _title;
10899
  }
10900
  ctrl.container.find('.czr-setting-reset').attr( 'title', _title );
10901
  });
10902
+
10903
+ //NOTICE VISIBILITY
10904
  ctrl.czr_states( 'noticeVisible' ).bind( function( visible ) {
10905
  ctrl.container.toggleClass( 'czr-notice-visible', visible );
10906
  var $noticeContainer = ctrl.getNotificationsContainerElement();
10923
  }
10924
  }
10925
  });
10926
+
10927
+ //RESET VISIBILITY
10928
  ctrl.czr_states( 'resetVisible' ).bind( function( visible ) {
10929
  var section_id = ctrl.section() || api.czr_activeSectionId();
10930
  if ( visible ) {
10931
+ //self.renderControlResetWarningTmpl
10932
+ //returns an object : { container : $(el), is_authorized : is_authorized }
10933
  $.when( self.renderControlResetWarningTmpl( ctrl.id ) ).done( function( _params ) {
10934
  if ( _.isEmpty( _params ) )
10935
  return;
10936
  ctrl.czr_resetDialogContainer = _params.container;
10937
  _params.container.slideToggle('fast');
10938
+ //Close and remove automatically if the user attempted to reset a non authorized setting
10939
+ //The setting can not be reset if :
10940
+ //1) WP setting
10941
+ //2) global skope
10942
+ //3) setting not dirty => db reset
10943
  if ( ! _params.is_authorized ) {
10944
  _.delay( function() {
10945
  $.when( ctrl.czr_resetDialogContainer.slideToggle('fast') ).done( function() {
10965
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
10966
  ( function ( api, $, _ ) {
10967
  $.extend( CZRSkopeBaseMths, {
10968
+ //fired on
10969
+ //1) active section expansion
10970
+ //2) and on skope switch
10971
+ //render each control reset icons with a delay
10972
+ //=> because some control like media upload are re-rendered on section expansion
10973
+ //@params controls = array of skope eligible control ids
10974
  renderControlsSingleReset : function( controls ) {
10975
  var self = this, dfd = $.Deferred();
10976
+ //create the control ids list if not set
10977
  if ( _.isUndefined( controls ) || _.isEmpty( controls ) ) {
10978
  controls = api.CZR_Helpers.getSectionControlIds( api.czr_activeSectionId() );
10979
+ //filter only eligible controlIds
10980
  controls = _.filter( controls, function( _id ) {
10981
  var setId = api.CZR_Helpers.getControlSettingId( _id );
10982
  return setId && self.isSettingSkopeEligible( setId );
10989
  dfd.resolve();
10990
  return;
10991
  }
10992
+ //api.consoleLog('IN RENDER RESET ICONS', ctrlIds );
10993
  _.each( ctrlIds, function( _id ) {
10994
  api.control.when( _id, function() {
10995
  var ctrl = api.control( _id ),
11017
  });//when()
11018
  });//_each
11019
  };
11020
+
11021
+ //debounce because some control like media upload are re-rendered on section expansion
11022
  render_reset_icons = _.debounce( render_reset_icons , 200 );
11023
  render_reset_icons( controlIds );
11024
  return dfd.promise();
11025
  },
11026
+
11027
+
11028
+
11029
+ //Fired in self.bindControlStates()
11030
+ //@uses The ctrl.czr_states('isDirty') value
11031
  renderControlResetWarningTmpl : function( ctrlId ) {
11032
  if ( ! api.control.has( ctrlId ) )
11033
  return {};
11039
  warning_message,
11040
  success_message,
11041
  isWPSetting = ( function() {
11042
+ //exclude the WP built-in settings like blogdescription, show_on_front, etc
11043
  if ( _.contains( serverControlParams.wpBuiltinSettings, api.CZR_Helpers.getOptionName( setId ) ) )
11044
  return true;
11045
  if ( ! _.contains( serverControlParams.themeSettingList, api.CZR_Helpers.getOptionName( setId ) ) )
11065
  success_message = serverControlParams.i18n.skope['The option has been reset'];
11066
  }
11067
  }
11068
+
11069
+ //The setting can not be reset if :
11070
+ //1) WP setting
11071
+ //2) global skope
11072
+ //3) setting not dirty => db reset
11073
  var is_authorized = ! ( isWPSetting && 'global' == api.czr_skope( api.czr_activeSkopeId() )().skope && ! ctrl.czr_states( 'isDirty' )() ),
11074
  _tmpl_data = {
11075
  warning_message : warning_message + '.',
11087
 
11088
  return { container : $( '.czr-ctrl-reset-warning', ctrl.container ), is_authorized : is_authorized };
11089
  },
11090
+
11091
+
11092
+ //Fired on user click
11093
+ //Defined in the ctrl user event map
11094
+ //@uses The ctrl.czr_states values
11095
+ //Will fire a different callback, whether the setting is dirty or has db val
11096
  doResetSetting : function( ctrlId ) {
11097
  var self = this,
11098
  setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
11111
  .fail( function() { api.consoleLog( 'Silent update failed after resetting control : ' + ctrlId ); } )
11112
  .done( function() {
11113
  api.control.when( ctrlId, function() {
11114
+ //the control instance might have changed if it has been re-rendered.
11115
+ //=> make sure we grab the new one
11116
  var ctrl = api.control( ctrlId );
11117
  $.when( $('.czr-crtl-reset-dialog', ctrl.container ).fadeOut('300') ).done( function() {
11118
  $.when( $('.czr-reset-success', ctrl.container ).fadeIn('300') ).done( function( $_el ) {
11131
  });
11132
  });//done()
11133
  };//_silentUpdate
11134
+
11135
+ //Specific case for global :
11136
+ //After a published value reset (not a dirty reset),
11137
+ //we need to re-synchronize the api.settings.settings with the default theme options values
11138
  self[reset_method](ctrlId)
11139
  .done( function() {
11140
  api.consoleLog('REFRESH AFTER A SETTING RESET');
11141
+ //api.previewer.refresh() method is resolved with an object looking like :
11142
+ //{
11143
+ // previewer : api.previewer,
11144
+ // skopesServerData : {
11145
+ // czr_skopes : _wpCustomizeSettings.czr_skopes || [],
11146
+ // isChangesetDirty : boolean
11147
+ // },
11148
+ // }
11149
  api.previewer.refresh()
11150
  .fail( function( refresh_data ) {
11151
  api.errorLog('Setting reset refresh failed.', refresh_data );
11177
  ctrl.czr_states( 'isResetting' )( true );
11178
  ctrl.container.addClass('czr-resetting-control');
11179
 
11180
+ //api.consoleLog('DO RESET SETTING', ctrlId, ctrl.czr_states( 'isDirty' )() );
11181
+
11182
  api.czr_skopeReset[ ctrl.czr_states( 'isDirty' )() ? 'resetChangeset' : 'resetPublished' ](
11183
  { skope_id : skope_id, setId : setId, is_setting : true } )
11184
  .done( function( r ) {
11198
  });
11199
 
11200
  },
11201
+
11202
+ //updates the current skope dirties and the changeset dirties
11203
  _resetControlDirtyness : function( ctrlId ) {
11204
  var setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
11205
  skope_instance = api.czr_skope( api.czr_activeSkopeId() ),
11216
 
11217
  return dfd.resolve().promise();
11218
  },
11219
+
11220
+
11221
+ //@uses The ctrl.czr_states values
11222
+ //updates the current skope dbValues
11223
+ //update the ctrl state
11224
  _resetControlAPIVal : function( ctrlId ) {
11225
  var setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
11226
  current_skope_db = api.czr_skope( api.czr_activeSkopeId() ).dbValues(),
11229
 
11230
  if ( _.has( api.control( ctrlId ), 'czr_states') ) {
11231
  api.control(ctrlId).czr_states( 'hasDBVal' )( false );
11232
+ //update the skope db property and say it
11233
  api.czr_skope( api.czr_activeSkopeId() ).dbValues( _.omit( new_skope_db, setId ) );
11234
  }
11235
  return dfd.resolve().promise();
11243
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
11244
  ( function ( api, $, _ ) {
11245
  $.extend( CZRSkopeBaseMths, {
11246
+
11247
+ //fired when a section is expanded
11248
+ //fired when a setting value is changed
11249
  renderCtrlSkpNotIcon : function( controlIdCandidates ) {
11250
  var self = this,
11251
  controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates];
11254
  api.control.when( _id, function() {
11255
  var ctrl = api.control( _id );
11256
  ctrl.deferred.embedded.then( function() {
11257
+ //RENDER TOGGLE ICON
11258
  if( $('.czr-toggle-notice', ctrl.container ).length )
11259
  return;
11260
 
11273
 
11274
  });
11275
  },
11276
+
11277
+
11278
+ //fired when a control notice is expanded
11279
+ updateCtrlSkpNot : function( controlIdCandidates, visible ) {
11280
  var self = this,
11281
  controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates],
11282
  _isSkoped = function( setId ) {
11291
  _isCustomized,
11292
  _hasDBVal,
11293
  _ctxTitle;
11294
+
11295
+ //////////////////////
11296
+ /// CASE 0 : not skoped
11297
  if ( ! _isSkoped( setId ) ) {
11298
  _html.push( [
11299
  serverControlParams.i18n.skope['This option is always customized sitewide and cannot be reset.']
11300
  ].join(' ') );
11301
  return _html.join(' | ');
11302
  }
11303
+
11304
+ //////////////////////
11305
+ /// CASE 1
11306
  if ( _inheritedFromSkopeId == _overridedBySkopeId && api.czr_skope.has( _inheritedFromSkopeId ) && _currentSkopeId == _inheritedFromSkopeId ) {
11307
+ //is the setId customized in the current skope ?
11308
  _isCustomized = ! _.isUndefined( api.czr_skope( _currentSkopeId ).dirtyValues()[setId] );
11309
  _hasDBVal = ! _.isUndefined( api.czr_skope( _currentSkopeId ).dbValues()[setId] );
11310
 
11341
  }
11342
  }
11343
  }
11344
+
11345
+
11346
+ /////////////////////
11347
+ /// CASE 2 : Skope is different than global, there is an inheritance
11348
  if ( _inheritedFromSkopeId !== _currentSkopeId && api.czr_skope.has( _inheritedFromSkopeId ) ) {
11349
+ //is the setId customized in the current skope ?
11350
  _isCustomized = ! _.isUndefined( api.czr_skope( _inheritedFromSkopeId ).dirtyValues()[setId] );
11351
  _hasDBVal = ! _.isUndefined( api.czr_skope( _inheritedFromSkopeId ).dbValues()[setId] );
11352
 
11373
  );
11374
  }
11375
  }
11376
+
11377
+
11378
+ /////////////////////
11379
+ /// CASE 3
11380
  if ( _overridedBySkopeId !== _currentSkopeId && api.czr_skope.has( _overridedBySkopeId ) ) {
11381
+ //is the setId customized or saved in the winner skope ?
11382
+ //_hasDBVal = ! _.isUndefined( api.czr_skope( _overridedBySkopeId ).dbValues()[setId] );
11383
  _isCustomized = ! _.isUndefined( api.czr_skope( _overridedBySkopeId ).dirtyValues()[setId] );
11384
 
11385
  _ctxTitle = api.czr_skope( _localSkopeId )().ctx_title;
11405
  var ctrl = api.control( _id ),
11406
  setId = api.CZR_Helpers.getControlSettingId( _id ),//get the relevant setting_id for this control
11407
  _visible = _.isUndefined( visible ) ? ( ctrl.czr_states && ctrl.czr_states( 'noticeVisible' )() ) : visible;
11408
+
11409
+ //Bail here if the ctrl notice is not set to visible
11410
  if ( ! _visible )
11411
  return;
11412
 
11436
  });
11437
  });
11438
  },//updateCtrlSkpNot
11439
+
11440
+ // Utility
11441
+ // @return bool
11442
+ // @param ctrlId = string
11443
+ // When do we display the ctrl notice ?
11444
+ // 1) When the current skope is not global
11445
+ // 2) when the current skope is global AND is overriden by a local or group skope
11446
  isCtrlNoticeVisible : function( ctrlId ) {
11447
  if ( ! api.control.has( ctrlId ) )
11448
  return false;
11462
  }
11463
  return false;
11464
  },
11465
+
11466
+
11467
+ //@return void()
11468
  removeCtrlSkpNot : function( controlIdCandidates ) {
11469
  var self = this,
11470
  controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates];
11488
  }
11489
  });//$.extend()
11490
  })( wp.customize , jQuery, _ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11491
  var CZRSkopeResetMths = CZRSkopeResetMths || {};
11492
  ( function ( api, $, _ ) {
11493
  $.extend( CZRSkopeResetMths, {
11499
  $( document.body ).toggleClass( 'czr-resetting', false !== state );
11500
  });
11501
  },
11502
+
11503
+ //args : {
11504
+ // is_setting : false,
11505
+ // is_skope : false,
11506
+ // skope_id : '',
11507
+ // setId : ''
11508
+ //}
11509
  resetChangeset : function( args ) {
11510
  var dfd = $.Deferred(),
11511
  self = this,
11529
 
11530
  if( ! api.czr_isChangeSetOn() )
11531
  return dfd.resolve().promise();
11532
+
11533
+ // => will be set to false always after asynchronous request
11534
+ //skope dependant submit()
11535
  submit_reset = function( skope_id, setId ) {
11536
  if ( _.isUndefined( skope_id ) ) {
11537
  throw new Error( 'RESET: MISSING skope_id');
11538
  }
11539
  api.state( 'czr-resetting' )( true );
11540
+ //the skope reset query takes parameters
11541
  query_params = {
11542
  skope_id : skope_id,
11543
  action : 'reset'
11546
  self.previewer.query( query_params ),
11547
  { nonce: self.previewer.nonce.save }
11548
  );
11549
+
11550
+ //Several cases here :
11551
+ //1) single setting reset
11552
+ //2) entire skope reset
11553
  if ( args.is_setting ) {
11554
  $.extend( query , { setting_id : setId } );
11555
  requestAjaxAction = 'czr_changeset_setting_reset';
11567
  if ( '0' === response ) {
11568
  response = 'not_logged_in';
11569
  } else if ( '-1' === response ) {
11570
+ // Back-compat in case any other check_ajax_referer() call is dying
11571
  response = 'invalid_nonce';
11572
  }
11573
 
11606
 
11607
  return dfd.promise();
11608
  },
11609
+
11610
+
11611
+
11612
+
11613
+
11614
+ //args : {
11615
+ // is_setting : false,
11616
+ // is_skope : false,
11617
+ // skope_id : '',
11618
+ // setId : ''
11619
+ //}
11620
  resetPublished : function( args ) {
11621
  var dfd = $.Deferred(),
11622
  self = this,
11637
  args = _.extend( defaults, args );
11638
  var skope_id = args.skope_id,
11639
  setId = args.setId;
11640
+
11641
+ //skope dependant submit()
11642
  submit_reset = function( skope_id, setId ) {
11643
  if ( _.isUndefined( skope_id ) ) {
11644
  throw new Error( 'RESET: MISSING skope_id');
11645
  }
11646
  api.state( 'czr-resetting' )( true );
11647
+ //the skope reset query takes parameters
11648
  query_params = {
11649
  skope_id : skope_id,
11650
  action : 'reset'
11653
  self.previewer.query( query_params ),
11654
  { nonce: self.previewer.nonce.save }
11655
  );
11656
+
11657
+ //Several cases here :
11658
+ //1) single setting reset
11659
+ //2) entire skope reset
11660
  if ( args.is_setting ) {
11661
  $.extend( query , { setting_id : setId } );
11662
  requestAjaxAction = 'czr_published_setting_reset';
11676
  if ( '0' === response ) {
11677
  response = 'not_logged_in';
11678
  } else if ( '-1' === response ) {
11679
+ // Back-compat in case any other check_ajax_referer() call is dying
11680
  response = 'invalid_nonce';
11681
  }
11682
 
11722
  var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
11723
  ( function ( api, $, _ ) {
11724
  $.extend( CZRSkopeBaseMths, {
11725
+ //fired in skopeBase initialize
11726
  initWidgetSidebarSpecifics : function() {
11727
  var self = this;
11728
  if ( ! self.isExcludedSidebarsWidgets() ) {
11730
  self.forceSidebarDirtyRefresh( api.czr_activeSectionId(), active_skope );
11731
  });
11732
  }
11733
+
11734
+ //WHEN A WIDGET IS ADDED
11735
  $( document ).bind( 'widget-added', function( e, $o ) {
11736
  if ( self.isExcludedSidebarsWidgets() )
11737
  return;
11738
 
11739
  var wgtIdAttr = $o.closest('.customize-control').attr('id'),
11740
+ //get the widget id from the customize-control id attr, and remove 'customize-control-' prefix to get the proper set id
11741
  wdgtSetId = api.czr_skopeBase.widgetIdToSettingId( wgtIdAttr, 'customize-control-' );
11742
  if ( ! api.has( wdgtSetId ) ) {
11743
  throw new Error( 'AN ADDED WIDGET COULD NOT BE BOUND IN SKOPE. ' + wdgtSetId);
11753
  if ( self.isExcludedSidebarsWidgets() )
11754
  return;
11755
  var _save_state = api.state('saved')();
11756
+
11757
+ //Specific for widget sidebars section
11758
  var _debounced = function() {
11759
  if ( api.section.has( active_section ) && "sidebar" == api.section(active_section).params.type ) {
11760
  var active_skope = active_skope || api.czr_activeSkopeId(),
11761
  related_setting_name = 'sidebars_widgets[' + api.section(active_section).params.sidebarId + ']',
11762
  related_setting_val = self.getSkopeSettingVal( related_setting_name, active_skope );
11763
+
11764
+ //api( related_setting_name )( self.getSkopeSettingVal( related_setting_name, api.czr_activeSkopeId() ) );
11765
  api.czr_skope( active_skope ).updateSkopeDirties( related_setting_name, related_setting_val );
11766
 
11767
  api.previewer.refresh( { the_dirties : api.czr_skope( active_skope ).dirtyValues() } )
11778
 
11779
  var CZRSkopeMths = CZRSkopeMths || {};
11780
  ( function ( api, $, _ ) {
11781
+ //The Active state is delegated to the scope base class
11782
  $.extend( CZRSkopeMths, {
11783
  /*****************************************************************************
11784
  * THE SKOPE MODEL
11785
  *****************************************************************************/
11786
+ // 'id' => 'global',
11787
+ // 'level' => '_all_',
11788
+ // 'dyn_type' => 'option',
11789
+ // 'opt_name' => HU_THEME_OPTIONS,
11790
+ // 'is_winner' => false,
11791
+ // 'db' => array(),
11792
+ // 'has_db_val' => false
11793
+ // 'is_forced' => false,
11794
  initialize: function( skope_id, constructor_options ) {
11795
  var skope = this;
11796
  api.Value.prototype.initialize.call( skope, null, constructor_options );
11798
  skope.isReady = $.Deferred();
11799
  skope.embedded = $.Deferred();
11800
  skope.el = 'czr-scope-' + skope_id;//@todo replace with a css selector based on the scope name
11801
+
11802
+ //write the options as properties, skope_id is included
11803
  $.extend( skope, constructor_options || {} );
11804
+
11805
+ //Make it alive with various Values
11806
  skope.visible = new api.Value( true );
11807
  skope.winner = new api.Value( false ); //is this skope the one that will be applied on front end in the current context?
11808
  skope.priority = new api.Value(); //shall this skope always win or respect the default skopes priority
11809
  skope.active = new api.Value( false ); //active, inactive. Are we currently customizing this skope ?
11810
  skope.dirtyness = new api.Value( false ); //true or false : has this skope been customized ?
11811
  skope.skopeResetDialogVisibility = new api.Value( false );
11812
+
11813
+ //setting values are stored in :
11814
  skope.hasDBValues = new api.Value( false );
11815
  skope.dirtyValues = new api.Value({});//stores the current customized value.
11816
  skope.dbValues = new api.Value({});//stores the latest db values => will be updated on each skope synced event
11817
  skope.changesetValues = new api.Value({});//stores the latest changeset values => will be updated on each skope synced eventsynced event
11818
+
11819
+ ////////////////////////////////////////////////////
11820
+ /// MODULE DOM EVENT MAP
11821
+ ////////////////////////////////////////////////////
11822
  skope.userEventMap = new api.Value( [
11823
+ //skope switch
11824
  {
11825
  trigger : 'click keydown',
11826
  selector : '.czr-scope-switch, .czr-skp-switch-link',
11829
  api.czr_activeSkopeId( skope().id );
11830
  }
11831
  },
11832
+ //skope reset : display warning
11833
  {
11834
  trigger : 'click keydown',
11835
  selector : '.czr-scope-reset',
11837
  actions : 'reactOnSkopeResetUserRequest'
11838
  }
11839
  ]);//module.userEventMap
11840
+
11841
+ //Reset actions ( deferred cb )
11842
  skope.skopeResetDialogVisibility.bind( function( to, from ) {
11843
  return skope.skopeResetDialogReact( to );
11844
  }, { deferred : true } );
11845
+
11846
+
11847
+ //LISTEN TO API DIRTYNESS
11848
+ //@to is {setId1 : val1, setId2 : val2, ...}
11849
  skope.dirtyValues.callbacks.add(function() { return skope.dirtyValuesReact.apply(skope, arguments ); } );
11850
+
11851
+ //LISTEN TO CHANGESET VALUES
11852
  skope.changesetValues.callbacks.add(function() { return skope.changesetValuesReact.apply(skope, arguments ); } );
11853
+
11854
+ //LISTEN TO DB VALUES
11855
  skope.dbValues.callbacks.add(function() { return skope.dbValuesReact.apply(skope, arguments ); } );
11856
+
11857
+ //UPDATE global skope collection each time a skope model is populated or updated
11858
  skope.callbacks.add(function() { return skope.skopeReact.apply( skope, arguments ); } );
11859
+
11860
+ //PREPARE THE CONSTRUCTOR OPTIONS AND SET SKOPE MODEL WITH IT
11861
+ //=> we don't need to store the db , has_db_val, and changeset properties in the model statically
11862
+ //because it will be stored as observable values
11863
  skope.set( _.omit( constructor_options, function( _v, _key ) {
11864
  return _.contains( [ 'db', 'changeset', 'has_db_val' ], _key );
11865
  } ) );
11866
+
11867
+
11868
+
11869
+
11870
+
11871
+ ////////////////////////////////////////////////////
11872
+ /// SETUP SKOPE OBSERVABLE VALUES LISTENERS
11873
+ /// => skope embedded dependants
11874
+ ////////////////////////////////////////////////////
11875
  skope.setupObservableViewValuesCallbacks();
11876
+
11877
+ //Now that the values are listened to. Let's set some initial values
11878
  skope.dirtyness( ! _.isEmpty( constructor_options.changeset ) );
11879
  skope.hasDBValues( ! _.isEmpty( constructor_options.db ) );
11880
  skope.winner( constructor_options.is_winner );
11881
+
11882
+
11883
+
11884
+
11885
+ ////////////////////////////////////////////////////
11886
+ /// EMBED + SETUP DOM LISTENERS
11887
+ ////////////////////////////////////////////////////
11888
  skope.embedded
11889
  .fail( function() {
11890
  throw new Error('The container of skope ' + skope().id + ' has not been embededd');
11891
  })
11892
  .done( function() {
11893
+ //api.consoleLog('SKOPE : ' + skope().id + ' EMBEDDED');
11894
+ //Setup the user event listeners
11895
  skope.setupDOMListeners( skope.userEventMap() , { dom_el : skope.container } );
11896
 
11897
  skope.isReady.resolve();
11898
  });
11899
 
11900
  },//initialize
11901
+
11902
+
11903
+
11904
+ //this skope model is instantiated at this point.
11905
  ready : function() {
11906
  var skope = this;
11907
+ //WAIT FOR THE SKOPE WRAPPER TO BE EMBEDDED
11908
+ //=> The skope wrapper is embedded when api.czr_skopeReady.state() == 'resolved'
11909
  api.czr_skopeBase.skopeWrapperEmbedded.done( function() {
11910
+ //EMBED THE SKOPE VIEW : EMBED AND STORE THE CONTAINER
11911
  try {
11912
  $.when( skope.embedSkopeDialogBox() ).done( function( $_container ){
11913
  if ( false !== $_container.length ) {
11914
+ //paint it
11915
  $_container.css('background-color', skope.color );
11916
  skope.container = $_container;
11917
  skope.embedded.resolve( $_container );
11933
  * SKOPE API DIRTIES REACTIONS
11934
  *****************************************************************************/
11935
  dirtyValuesReact : function( to, from ) {
11936
+ //api.consoleLog('IN DIRTY VALUES REACT', this.id, to, from );
11937
  var skope = this;
11938
+
11939
+ //set the skope() dirtyness boolean state value
11940
  skope.dirtyness( ! _.isEmpty( to ) );
11941
+ // skope.dirtyness(
11942
+ // ! _.isEmpty(
11943
+ // 'global' != skope().skope ?
11944
+ // to :
11945
+ // _.omit( to, function( _val, _id ) {
11946
+ // return ! api.czr_skopeBase.isThemeSetting( _id );
11947
+ // })
11948
+ // )
11949
+ // );
11950
+
11951
+ //set the API global dirtyness
11952
  api.czr_dirtyness( ! _.isEmpty(to) );
11953
+
11954
+ //build the collection of control ids for which the dirtyness has to be reset
11955
  var ctrlIdDirtynessToClean = [];
11956
  _.each( from, function( _val, _id ) {
11957
  if ( _.has( to, _id ) )
11958
  return;
11959
  ctrlIdDirtynessToClean.push( _id );
11960
  });
11961
+
11962
+ //SET THE ACTIVE SKOPE CONTROLS DIRTYNESSES
11963
+ //The ctrl.czr_state value looks like :
11964
+ //{
11965
+ // hasDBVal : false,
11966
+ // isDirty : false,
11967
+ // noticeVisible : false,
11968
+ // resetVisible : false
11969
+ //}
11970
  if ( skope().id == api.czr_activeSkopeId() ) {
11971
+ //RESET DIRTYNESS FOR THE CLEAN SETTINGS CONTROLS IN THE ACTIVE SKOPE
11972
  _.each( ctrlIdDirtynessToClean , function( setId ) {
11973
  if ( ! _.has( api.control( setId ), 'czr_states') )
11974
  return;
11975
  api.control( setId ).czr_states( 'isDirty' )( false );
11976
  });
11977
+ //Set control dirtyness for dirty settings
11978
  _.each( to, function( _val, _setId ) {
11979
  if ( ! _.has( api.control( _setId ), 'czr_states') )
11980
  return;
11999
  *****************************************************************************/
12000
  dbValuesReact : function( to, from ) {
12001
  var skope = this;
12002
+
12003
+ //set the skope() db dirtyness boolean state value
12004
  skope.hasDBValues(
12005
  ! _.isEmpty(
12006
  'global' != skope().skope ?
12010
  })
12011
  )
12012
  );
12013
+
12014
+ //RESET DIRTYNESS FOR THE CONTROLS IN THE ACTIVE SKOPE
12015
+ //=> make sure this is set for the active skopes only
12016
  var ctrlIdDbToReset = [];
12017
  _.each( from, function( _val, _id ) {
12018
  if ( _.has( to, _id ) )
12019
  return;
12020
  ctrlIdDbToReset.push( _id );
12021
  });
12022
+ //The ctrl.czr_state value looks like :
12023
+ //{
12024
+ // hasDBVal : false,
12025
+ // isDirty : false,
12026
+ // noticeVisible : false,
12027
+ // resetVisible : false
12028
+ //}
12029
  if ( skope().id == api.czr_activeSkopeId() ) {
12030
  _.each( ctrlIdDbToReset , function( setId ) {
12031
  if ( ! _.has( api.control( setId ), 'czr_states') )
12032
  return;
12033
  api.control( setId ).czr_states( 'hasDBVal' )( false );
12034
  });
12035
+ //Set control db dirtyness for settings with a db value
12036
  _.each( to, function( _val, _setId ) {
12037
  if ( ! _.has( api.control( _setId ), 'czr_states') )
12038
  return;
12046
  /*****************************************************************************
12047
  * SKOPE MODEL CHANGES CALLBACKS
12048
  *****************************************************************************/
12049
+ //cb of skope.callbacks
12050
  skopeReact : function( to, from ) {
12051
  var skope = this,
12052
  _current_collection = [],
12053
  _new_collection = [];
12054
+
12055
+ //INFORM COLLECTION
12056
+ //populate case
12057
  if ( ! api.czr_skopeBase.isSkopeRegisteredInCollection( to.id ) ) {
12058
+ //Add this new skope to the global skope collection
12059
  _current_collection = $.extend( true, [], api.czr_skopeCollection() );
12060
  _current_collection.push( to );
12061
  api.czr_skopeCollection( _current_collection );
12062
  }
12063
+ //update case
12064
  else {
12065
+ //Add this new skope to the global skope collection
12066
  _current_collection = $.extend( true, [], api.czr_skopeCollection() );
12067
  _new_collection = _current_collection;
12068
+ //update the collection with the current new skope model
12069
  _.each( _current_collection, function( _skope, _key ) {
12070
  if ( _skope.id != skope().id )
12071
  return;
12086
  * VALUES CALLBACKS WHEN SKOPE EMBEDDED AND READY
12087
  * => The skope container exists at this stage
12088
  *****************************************************************************/
12089
+ //@fired in initiliaze
12090
  setupObservableViewValuesCallbacks : function() {
12091
  var skope = this;
12092
+ //hide when this skope is not in the current skopes list
12093
  skope.visible.bind( function( is_visible ){
12094
  if ( 'pending' == skope.embedded.state() ) {
12095
  skope.embedded.done( function() {
12100
  }
12101
 
12102
  });
12103
+
12104
+ //How does the view react to model changes ?
12105
+ //When active :
12106
+ //1) add a green point to the view box
12107
+ //2) disable the switch-to icon
12108
  skope.active.bind( function() {
12109
  if ( 'pending' == skope.embedded.state() ) {
12110
  skope.embedded.done( function() {
12145
  }
12146
  });
12147
  },//setupObservableViewValuesCallbacks
12148
+
12149
+ //cb of skope.active.callbacks
12150
  activeStateReact : function( to, from ){
12151
  var skope = this;
12152
  skope.container.toggleClass('inactive', ! to ).toggleClass( 'active', to );
12153
+ //api.consoleLog('in the view : listen for scope state change', this.name, to, from );
12154
  $('.czr-scope-switch', skope.container).toggleClass('fa-toggle-on', to).toggleClass('fa-toggle-off', !to);
12155
  },
12156
+
12157
+ //cb of skope.dirtyness.callbacks
12158
  dirtynessReact : function( to, from ) {
12159
  var skope = this;
12160
  $.when( this.container.toggleClass( 'dirty', to ) ).done( function() {
12164
  $( '.czr-scope-reset', skope.container).fadeOut('fast');
12165
  });
12166
  },
12167
+
12168
+ //cb of skope.hasDBValues.callbacks
12169
  hasDBValuesReact : function( to, from ) {
12170
  var skope = this;
12171
  $.when( skope.container.toggleClass('has-db-val', to ) ).done( function() {
12182
  }
12183
  });
12184
  },
12185
+
12186
+ //cb of skope.winner.callbacks
12187
  winnerReact : function( is_winner ) {
12188
  var skope = this;
12189
  this.container.toggleClass('is_winner', is_winner );
12190
 
12191
  if ( is_winner ) {
12192
+ //make sure there's only one winner in the current skope collection
12193
  _.each( api.czr_currentSkopesCollection(), function( _skope ) {
12194
  if ( _skope.id == skope().id )
12195
  return;
12206
  /*****************************************************************************
12207
  * HELPERS
12208
  *****************************************************************************/
12209
+ //this method updates a given skope instance dirty values
12210
+ //and returns the dirty values object
12211
+ //fired on api setting change and in the ajax query
12212
  updateSkopeDirties : function( setId, new_val ) {
12213
  var skope = this,
12214
  shortSetId = api.CZR_Helpers.getOptionName( setId );
12215
+
12216
+ //for the settings that are excluded from skope, the skope is always the global one
12217
  if ( ! api.czr_skopeBase.isSettingSkopeEligible( setId ) && 'global' != skope().skope )
12218
  return api.czr_skope( api.czr_skopeBase.getGlobalSkopeId() ).updateSkopeDirties( setId, new_val );
12219
 
12224
  skope.dirtyValues.set( $.extend( current_dirties , _dirtyCustomized ) );
12225
  return skope.dirtyValues();
12226
  },
12227
+
12228
+
12229
+
12230
+ //@return the boolean dirtyness state of a given setId for a given skope
12231
  getSkopeSettingDirtyness : function( setId ) {
12232
  var skope = this;
12233
  return skope.getSkopeSettingAPIDirtyness( setId ) || skope.getSkopeSettingChangesetDirtyness( setId );
12234
  },
12235
+
12236
+ //Has this skope already be customized in the API ?
12237
  getSkopeSettingAPIDirtyness : function( setId ) {
12238
  var skope = this;
12239
  return _.has( skope.dirtyValues(), api.CZR_Helpers.build_setId( setId ) );
12240
  },
12241
+
12242
+ //Has this skope already be customized in the API ?
12243
  getSkopeSettingChangesetDirtyness : function( setId ) {
12244
  var skope = this;
12245
  if ( ! api.czr_isChangeSetOn() )
12246
  return skope.getSkopeSettingAPIDirtyness( setId );
12247
  return _.has( skope.changesetValues(), api.CZR_Helpers.build_setId( setId ) );
12248
  },
12249
+
12250
+ //@return boolean
12251
  hasSkopeSettingDBValues : function( setId ) {
12252
  var skope = this,
12253
  _setId = api.CZR_Helpers.build_setId(setId);
12263
  var skope = this,
12264
  skope_model = $.extend( true, {}, skope() ),
12265
  _tmpl = '';
12266
+
12267
+ //@todo will need to be refreshed on scopes change in the future
12268
  if ( ! $('#customize-header-actions').find('.czr-scope-switcher').length ) {
12269
  throw new Error('The skope switcher wrapper is not printed, the skope can not be embedded.');
12270
  }
12281
 
12282
 
12283
 
12284
+
12285
+ // setSkopeSwitcherButtonActive : function( dyn_type ) {
12286
+ // $('.button', '.czr-scope-switcher').each( function( ind ) {
12287
+ // $(this).toggleClass( 'active', dyn_type == $(this).attr('data-dyn-type') );
12288
+ // });
12289
+ // },
12290
+
12291
+
12292
+
12293
  /*****************************************************************************
12294
  * RESET
12295
  *****************************************************************************/
12353
 
12354
  var CZRSkopeMths = CZRSkopeMths || {};
12355
  ( function ( api, $, _ ) {
12356
+ //The Active state is delegated to the skope base class
12357
  $.extend( CZRSkopeMths, {
12358
  /*****************************************************************************
12359
  * RESET
12360
  *****************************************************************************/
12361
+ //Fired when on user click on ".czr-scope-reset", defined in skope model init
12362
+ //Handles several scenarios :
12363
+ //1) a reset ajax request (save, changeset, reset) can be currently processed, we need to wait for completion
12364
+ //2) another skope reset dialog panel might be already opened
12365
  reactOnSkopeResetUserRequest : function() {
12366
  var skope = this,
12367
  _fireReaction = function() {
12380
  });
12381
  }
12382
  };
12383
+
12384
+ //Bail if other process currenty running
12385
  if ( ( api.state( 'czr-resetting')() || 0 !== api.state( 'processing' )() ) ) {
12386
  api.czr_serverNotification( {
12387
  message: 'Slow down, you move too fast !',
12390
  });
12391
  return;
12392
  }
12393
+ //Close the current panel if a reset for a different skope is requested
12394
  if ( api.czr_activeSkopeId() != skope().id && api.czr_skope( api.czr_activeSkopeId() ).skopeResetDialogVisibility() ) {
12395
  api.czr_skope( api.czr_activeSkopeId() ).skopeResetDialogVisibility( false ).done( function() {
12396
  _fireReaction();
12399
  _fireReaction();
12400
  }
12401
  },
12402
+
12403
+
12404
+
12405
+
12406
+
12407
+
12408
+
12409
+
12410
+
12411
+ //cb of skope.skopeResetDialogVisibility.callbacks
12412
+ //Setup user DOM events listeners
12413
+ //Render the dialog box
12414
  skopeResetDialogReact : function( visible ) {
12415
  var skope = this, dfd = $.Deferred();
12416
+ //Are we currently performing a reset or any other processing task ? (reset setting or skope, saving )
12417
+ //=> if so, let's defer the current action when its possible
12418
+ // if ( api.state( 'czr-resetting')() || 0 !== api.state( 'processing' )() ) {
12419
+ // var reactWhenPossible = function () {
12420
+ // if ( 0 === api.state( 'processing' )() && false === api.state( 'czr-resetting' )() ) {
12421
+ // api.state.unbind( 'change', reactWhenPossible );
12422
+ // skope.skopeResetDialogReact( visible );
12423
+ // }
12424
+ // };
12425
+ // api.state.bind( 'change', reactWhenPossible );
12426
+ // return dfd.resolve().promise();
12427
+ // }
12428
+
12429
+ //Event Map for the Reset Panel
12430
  skope.userResetEventMap = skope.userResetEventMap || new api.Value( [
12431
+ //skope reset : display warning
12432
  {
12433
  trigger : 'click keydown',
12434
  selector : '.czr-scope-reset-cancel',
12437
  skope.skopeResetDialogVisibility( ! skope.skopeResetDialogVisibility() );
12438
  }
12439
  },
12440
+ //skope reset : do reset
12441
  {
12442
  trigger : 'click keydown',
12443
  selector : '.czr-scope-do-reset',
12448
  );
12449
 
12450
  if ( visible ) {
12451
+ //inform the api that we are resetting
12452
+ //=> some actions have to be frozen in this state
12453
+ //like for example, resetting another skope
12454
  api.czr_isResettingSkope( skope().id );
12455
+
12456
+ //render reset warning template
12457
  $.when( skope.renderResetWarningTmpl() ).done( function( $_container ) {
12458
  skope.resetPanel = $_container;
12459
+ //add the reset type class
12460
  skope.resetPanel.addClass( skope.dirtyness() ? 'dirty-reset' : 'db-reset' );
12461
  skope.setupDOMListeners( skope.userResetEventMap() , { dom_el : skope.resetPanel } );
12462
+ //$('body').addClass('czr-skope-pane-open');
12463
  }).then( function() {
12464
  setTimeout( function() {
12465
+ //set height
12466
  var _height = $('#customize-preview').height();
12467
  skope.resetPanel.css( 'line-height', _height +'px' ).css( 'height', _height + 'px' );
12468
+ //display
12469
  $('body').addClass('czr-skope-pane-open');
12470
  }, 50 );
12471
  });
12479
  }
12480
  });
12481
  }
12482
+
12483
+ //wait for panel sliding action before resolving
12484
  _.delay( function() { dfd.resolve(); }, 350 );
12485
 
12486
  return dfd.promise();
12487
  },
12488
+
12489
+
12490
+
12491
+ //fired on user click
12492
+ //Is used for both resetting customized and db values, depending on the skope customization state
12493
  doResetSkopeValues : function() {
12494
  var skope = this,
12495
  skope_id = skope().id,
12512
 
12513
  skope[reset_method]()
12514
  .done( function() {
12515
+ //api.previewer.refresh() method is resolved with an object looking like :
12516
+ //{
12517
+ // previewer : api.previewer,
12518
+ // skopesServerData : {
12519
+ // czr_skopes : _wpCustomizeSettings.czr_skopes || [],
12520
+ // isChangesetDirty : boolean
12521
+ // },
12522
+ // }
12523
  api.previewer.refresh()
12524
  .fail( function( refresh_data ) {
12525
  api.consoleLog('SKOPE RESET REFRESH FAILED', refresh_data );
12549
  };//_updateAPI
12550
 
12551
  $('body').addClass('czr-resetting-skope');
12552
+ //$('.czr-reset-warning', skope.resetPanel ).hide();
12553
+
12554
+ //When resetting the db value, wait for the ajax promise to be done before reseting the api values.
12555
  api.czr_skopeReset[ skope.dirtyness() ? 'resetChangeset' : 'resetPublished' ](
12556
  { skope_id : skope().id, is_skope : true } )
12557
  .always( function() {
12565
  api.consoleLog('Skope reset failed', r );
12566
  });
12567
  },
12568
+
12569
+
12570
+ //fired in doResetSkopeValues
12571
+ //@uses The ctrl.czr_states values
12572
  _resetSkopeDirties : function() {
12573
  var skope = this, dfd = $.Deferred();
12574
  skope.dirtyValues({});
12575
  skope.changesetValues({});
12576
  return dfd.resolve().promise();
12577
  },
12578
+
12579
+ //fired in doResetSkopeValues
12580
+ //@uses The ctrl.czr_states values
12581
  _resetSkopeAPIValues : function() {
12582
  var skope = this, dfd = $.Deferred();
12583
+ //update the skope model db property
12584
  skope.dbValues( {} );
12585
  return dfd.resolve().promise();
12586
  }
12587
  });//$.extend(
12588
  })( wp.customize , jQuery, _ );
12589
  ( function ( api, $, _ ) {
12590
+
12591
+ //SKOPE
12592
  $.extend( CZRSkopeBaseMths, api.Events );
12593
  $.extend( CZRSkopeMths, api.Events );
12594
  $.extend( CZRSkopeMths, api.CZR_Helpers );
12595
  api.CZR_skopeBase = api.Class.extend( CZRSkopeBaseMths );
12596
+ //api.CZR_skopeSave = api.Class.extend( CZRSkopeSaveMths );
12597
  api.CZR_skopeReset = api.Class.extend( CZRSkopeResetMths );
12598
  api.CZR_skope = api.Value.extend( CZRSkopeMths ); //=> used as constructor when creating the collection of skopes
12599
+
12600
+ //Skope related :
12601
+ //=> Special case for the header image
12602
+ //Capture objects before they are overridden by WP.
12603
+ //=> needed when regenerating the header_image control.
12604
  if ( _.has(api, 'HeaderTool') ) {
12605
  api.czr_HeaderTool = $.extend( true, {}, api.HeaderTool );
12606
  }
12607
 
12608
  })( wp.customize, jQuery, _ );
12609
  ( function ( api, $, _ ) {
12610
+ //SET THE ACTIVE STATE OF THE THEMES SECTION BASED ON WHAT THE SERVER SENT
12611
  api.bind('ready', function() {
12612
  var _do = function() {
12613
  api.section('themes').active.bind( function( active ) {
12614
  if ( ! _.has( serverControlParams, 'isThemeSwitchOn' ) || ! _.isEmpty( serverControlParams.isThemeSwitchOn ) )
12615
  return;
12616
  api.section('themes').active( serverControlParams.isThemeSwitchOn );
12617
+ //reset the callbacks
12618
  api.section('themes').active.callbacks = $.Callbacks();
12619
  });
12620
  };
12633
  /*****************************************************************************
12634
  * DEFINE SOME USEFUL OBSERVABLE VALUES
12635
  *****************************************************************************/
12636
+ //STORE THE CURRENTLY ACTIVE SECTION AND PANELS IN AN OBSERVABLE VALUE
12637
+ //BIND EXISTING AND FUTURE SECTIONS AND PANELS
12638
  api.czr_activeSectionId = new api.Value('');
12639
  api.czr_activePanelId = new api.Value('');
12640
 
12642
  * OBSERVE UBIQUE CONTROL'S SECTIONS EXPANSION
12643
  *****************************************************************************/
12644
  if ( 'function' === typeof api.Section ) {
12645
+ //move controls back and forth in declared ubique sections
12646
+ //=> implemented in the customizr theme for the social links boolean visibility controls ( socials in header, sidebar, footer )
12647
  api.control.bind( 'add', function( _ctrl ) {
12648
  if ( _ctrl.params.ubq_section && _ctrl.params.ubq_section.section ) {
12649
+ //save original state
12650
  _ctrl.params.original_priority = _ctrl.params.priority;
12651
  _ctrl.params.original_section = _ctrl.params.section;
12652
 
12674
  * OBSERVE UBIQUE CONTROL'S PANELS EXPANSION
12675
  *****************************************************************************/
12676
  if ( 'function' === typeof api.Panel ) {
12677
+ //move section back and forth in declared ubique panels
12678
  api.section.bind( 'add', function( _sec ) {
12679
  if ( _sec.params.ubq_panel && _sec.params.ubq_panel.panel ) {
12680
+ //save original state
12681
  _sec.params.original_priority = _sec.params.priority;
12682
  _sec.params.original_panel = _sec.params.panel;
12683
 
12704
  /*****************************************************************************
12705
  * CLOSE THE MOD OPTION PANEL ( if exists ) ON : section change, panel change, skope switch
12706
  *****************************************************************************/
12707
+ //@return void()
12708
  var _closeModOpt = function() {
12709
  if ( ! _.has( api, 'czr_ModOptVisible') )
12710
  return;
12725
  api.czr_activeSectionId( expanded ? section_id : '' );
12726
  };
12727
  api.section.each( function( _sec ) {
12728
+ //<@4.9compat>
12729
+ // Bail if is 'publish_setting' section
12730
+ if ( 'publish_settings' == _sec.id )
12731
+ return;
12732
+ //</@4.9compat>
12733
  _sec.expanded.bind( function( expanded ) { _storeCurrentSection( expanded, _sec.id ); } );
12734
  });
12735
  api.section.bind( 'add', function( section_instance ) {
12736
+ //<@4.9compat>
12737
+ // Bail if is 'publish_setting' section
12738
+ if ( 'publish_settings' == section_instance.id )
12739
+ return;
12740
+ //</@4.9compat>
12741
  api.trigger('czr-paint', { active_panel_id : section_instance.panel() } );
12742
  section_instance.expanded.bind( function( expanded ) { _storeCurrentSection( expanded, section_instance.id ); } );
12743
  });
12744
 
12745
  var _storeCurrentPanel = function( expanded, panel_id ) {
12746
  api.czr_activePanelId( expanded ? panel_id : '' );
12747
+ //if the expanded panel id becomes empty (typically when switching back to the root panel), make sure that no section is set as currently active
12748
+ //=> fixes the problem of add_menu section staying expanded when switching back to another panel
12749
  if ( _.isEmpty( api.czr_activePanelId() ) ) {
12750
  api.czr_activeSectionId( '' );
12751
  }
12766
  *****************************************************************************/
12767
  if ( serverControlParams.isPro ) {
12768
  _.each( [
12769
+ //WFC
12770
+ 'tc_font_customizer_settings',
12771
+
12772
+ //hueman pro
12773
+ 'header_image_sec',
12774
+ 'content_blog_sec',
12775
+ 'static_front_page',
12776
+ 'content_single_sec',
12777
+
12778
+ //customizr-pro
12779
+ 'tc_fpu',
12780
+ 'nav',
12781
+ 'post_lists_sec',
12782
+ 'galleries_sec',
12783
+ 'footer_customizer_sec',
12784
+ 'custom_scripts_sec'
12785
 
12786
  ], function( _secId ) {
12787
  _.delay( function() {
12793
  }, 1000 );
12794
  });
12795
  _.each( [
12796
+ //hueman pro
12797
+ //'hu-header-panel',
12798
+ //'hu-content-panel',
12799
+
12800
+ //customizr-pro
12801
+ //'tc-header-panel',
12802
+ //'tc-content-panel',
12803
+ //'tc-footer-panel',
12804
+ //'tc-advanced-panel'
12805
  ], function( _secId ) {
12806
  api.panel.when( _secId, function( _sec_ ) {
12807
  if ( 1 >= _sec_.headContainer.length ) {
12818
  if ( ! serverControlParams.isPro && _.isFunction( api.Section ) ) {
12819
  proSectionConstructor = api.Section.extend( {
12820
  active : true,
12821
+ // No events for this type of section.
12822
  attachEvents: function () {},
12823
+ // Always make the section active.
12824
  isContextuallyActive: function () {
12825
  return this.active();
12826
  },
12833
  });
12834
  }
12835
  })( wp.customize , jQuery, _);
12836
+ //extends api.CZRDynModule
12837
  var CZRSocialModuleMths = CZRSocialModuleMths || {};
12838
  ( function ( api, $, _ ) {
12839
  $.extend( CZRSocialModuleMths, {
12840
  initialize: function( id, options ) {
12841
  var module = this;
12842
+ //run the parent initialize
12843
  api.CZRDynModule.prototype.initialize.call( module, id, options );
12844
+
12845
+ //extend the module with new template Selectors
12846
  $.extend( module, {
12847
  itemPreAddEl : 'czr-module-social-pre-add-view-content',
12848
  itemInputList : 'czr-module-social-item-content',
13001
  'youtube-play',
13002
  'youtube-square'
13003
  ];
13004
+ //EXTEND THE DEFAULT CONSTRUCTORS FOR INPUT
13005
  module.inputConstructor = api.CZRInput.extend( module.CZRSocialsInputMths || {} );
13006
+ //EXTEND THE DEFAULT CONSTRUCTORS FOR MONOMODEL
13007
  module.itemConstructor = api.CZRItem.extend( module.CZRSocialsItem || {} );
13008
+
13009
+ //declares a default ModOpt model
13010
  this.defaultModOptModel = {
13011
  is_mod_opt : true,
13012
  module_id : module.id,
13013
  'social-size' : serverControlParams.social_el_params.defaultSocialSize || 14
13014
  };
13015
+
13016
+ //declares a default model
13017
  this.defaultItemModel = {
13018
  id : '',
13019
  title : '' ,
13022
  'social-color' : serverControlParams.social_el_params.defaultSocialColor,
13023
  'social-target' : 1
13024
  };
13025
+
13026
+ //overrides the default success message
13027
  this.itemAddedMessage = serverControlParams.i18n.socialLinkAdded;
13028
+
13029
+ //fired ready :
13030
+ //1) on section expansion
13031
+ //2) or in the case of a module embedded in a regular control, if the module section is already opened => typically when skope is enabled
13032
  if ( _.has( api, 'czr_activeSectionId' ) && module.control.section() == api.czr_activeSectionId() && 'resolved' != module.isReady.state() ) {
13033
  module.ready();
13034
  }
13035
 
13036
  api.section( module.control.section() ).expanded.bind(function(to) {
13037
+ //set module ready on section expansion
13038
  if ( 'resolved' != module.isReady.state() ) {
13039
  module.ready();
13040
  }
13041
  });
13042
 
13043
  module.isReady.then( function() {
13044
+ //specific update for the item preModel on social-icon change
13045
  module.preItem.bind( function( to, from ) {
13046
  if ( ! _.has(to, 'social-icon') )
13047
  return;
13051
  });
13052
  });
13053
  },//initialize
13054
+
13055
+
13056
+ //ACTIONS ON ICON CHANGE
13057
+ //Fired on 'social-icon:changed'
13058
+ //Don't fire in pre item case
13059
+ //@item_instance an be the preItem or an already created item
13060
  updateItemModel : function( item_instance, is_preItem ) {
13061
  var item = item_instance;
13062
  is_preItem = is_preItem || false;
13063
+
13064
+ //check if we are in the pre Item case => if so, the social-icon might be empty
13065
  if ( ! _.has( item(), 'social-icon') || _.isEmpty( item()['social-icon'] ) )
13066
  return;
13067
 
13072
  _new_color = serverControlParams.social_el_params.defaultSocialColor;
13073
  if ( ! is_preItem && item.czr_Input.has( 'social-color' ) )
13074
  _new_color = item.czr_Input('social-color')();
13075
+
13076
+ //add text follow us... to the title
13077
  _new_title = [ serverControlParams.i18n.followUs, _new_title].join(' ');
13078
 
13079
  if ( is_preItem ) {
13081
  item.set( _new_model );
13082
  } else {
13083
  item.czr_Input('title').set( _new_title );
13084
+ //item.czr_Input('social-link').set( '' );
13085
  if ( item.czr_Input('social-color') ) { //optional
13086
  item.czr_Input('social-color').set( _new_color );
13087
  }
13110
  module = input.module,
13111
  socialList = module.social_icons,
13112
  _model = item(),
13113
+ //check if we are in the pre Item case => if so, the id is empty
13114
  is_preItem = _.isEmpty( _model.id );
13115
+
13116
+ //=> add the select text in the pre Item case
13117
  if ( is_preItem ) {
13118
  socialList = _.union( [ serverControlParams.i18n.selectSocialIcon ], socialList );
13119
  }
13120
+
13121
+ //generates the options
13122
  _.each( socialList , function( icon_name, k ) {
13123
+ // in the pre Item case the first select element is the notice "Select a social icon"
13124
+ // doesn't need the fa-* class
13125
  var _value = ( is_preItem && 0 === k ) ? '' : 'fa-' + icon_name.toLowerCase(),
13126
  _attributes = {
13127
  value : _value,
13140
  );
13141
  return $state;
13142
  }
13143
+
13144
+ //fire select2
13145
  $( 'select[data-type="social-icon"]', input.container ).select2( {
13146
  templateResult: addIcon,
13147
  templateSelection: addIcon
13159
  hide:false,
13160
  defaultColor : serverControlParams.social_el_params.defaultSocialColor || 'rgba(255,255,255,0.7)',
13161
  change : function( e, o ) {
13162
+ //if the input val is not updated here, it's not detected right away.
13163
+ //weird
13164
+ //is there a "change complete" kind of event for iris ?
13165
+ //hack to reset the color to default...@todo => use another color picker.
13166
  if ( _.has( o, 'color') && 16777215 == o.color._color )
13167
  $(this).val( serverControlParams.social_el_params.defaultSocialColor || 'rgba(255,255,255,0.7)' );
13168
  else
13171
  $(this).trigger('colorpickerchange').trigger('change');
13172
  }
13173
  });
13174
+
13175
+ //when the picker opens, it might be below the visible viewport.
13176
+ //No built-in event available to react on this in the wpColorPicker unfortunately
13177
  $el.closest('div').on('click keydown', function() {
13178
  module._adjustScrollExpandedBlock( input.container );
13179
  });
13190
 
13191
 
13192
  CZRSocialsItem : {
13193
+ //Fired if the item has been instantiated
13194
+ //The item.callbacks are declared.
13195
  ready : function() {
13196
  var item = this;
13197
  api.CZRItem.prototype.ready.call( item );
13198
+
13199
+ //update the item model on social-icon change
13200
  item.bind('social-icon:changed', function(){
13201
  item.module.updateItemModel( item );
13202
  });
13214
 
13215
  return '<div><span class="fa ' + icon + '" style="color:' + color + '"></span> ' + title + '</div>';
13216
  },
13217
+
13218
+ //overrides the default parent method by a custom one
13219
+ //at this stage, the model passed in the obj is up to date
13220
  writeItemViewTitle : function( model ) {
13221
  var item = this,
13222
  module = item.module,
13238
  var module = this;
13239
 
13240
  api.CZRDynModule.prototype.initialize.call( this, id, constructorOptions );
13241
+
13242
+ //extend the module with new template Selectors
13243
  $.extend( module, {
13244
  itemPreAddEl : 'czr-module-widgets-pre-add-view-content',
13245
  itemInputList : 'czr-module-widgets-item-input-list',
13246
  itemInputListReduced : 'czr-module-widgets-item-input-list-reduced',
13247
  ruItemPart : 'czr-module-widgets-ru-item-part'
13248
  } );
13249
+
13250
+ //EXTEND THE DEFAULT CONSTRUCTORS FOR INPUT
13251
  module.inputConstructor = api.CZRInput.extend( module.CZRWZonesInputMths || {} );
13252
+ //EXTEND THE DEFAULT CONSTRUCTORS FOR MONOMODEL
13253
  module.itemConstructor = api.CZRItem.extend( module.CZRWZonesItem || {} );
13254
 
13255
  module.serverParams = serverControlParams.widget_area_el_params || {};
13256
+
13257
+ //add a shortcut to the server side json properties
13258
  module.contexts = _.has( module.serverParams , 'sidebar_contexts') ? module.serverParams.sidebar_contexts : {};
13259
+
13260
+ //context match map
13261
  module.context_match_map = {
13262
  is_404 : '404',
13263
  is_category : 'archive-category',
13269
 
13270
 
13271
  module.locations = _.has( module.serverParams , 'sidebar_locations') ? module.serverParams.sidebar_locations : {};
13272
+
13273
+ //declares a default model
13274
  module.defaultItemModel = {
13275
  id : '',
13276
  title : serverControlParams.i18n.widgetZone,
13278
  locations : [ module.serverParams.defaultWidgetLocation ],
13279
  description : ''
13280
  };
13281
+
13282
+ //overrides the default success message
13283
  this.itemAddedMessage = serverControlParams.i18n.widgetZoneAdded;
13284
+
13285
+ //Observe and react to sidebar insights from the preview frame
13286
+ // SIDEBAR INSIGHTS => stores and observes the sidebars and widgets settings sent by the preview */
13287
  if ( ! _.has( api, 'sidebar_insights' ) ) {
13288
  api.sidebar_insights = new api.Values();
13289
  api.sidebar_insights.create('candidates');//will store the sidebar candidates on preview refresh
13295
 
13296
 
13297
  this.listenToSidebarInsights();
13298
+
13299
+ //React on 'houston-widget-settings'
13300
+ //actives : data.renderedSidebars,
13301
+ // inactives : _inactives,
13302
+ // registered : _registered,
13303
+ // candidates : _candidates,
13304
+ // available_locations : data.availableWidgetLocations//built server side
13305
  api.czr_widgetZoneSettings = api.czr_widgetZoneSettings || new api.Value();
13306
  api.czr_widgetZoneSettings.bind( function( updated_data_sent_from_preview , from ) {
13307
  module.isReady.then( function() {
13310
  });
13311
  });
13312
  });
13313
+
13314
+
13315
+
13316
+
13317
+ //AVAILABLE LOCATIONS FOR THE PRE MODEL
13318
+ //1) add an observable value to module.preItem to handle the alert visibility
13319
  module.preItem_location_alert_view_state = new api.Value( 'closed');
13320
+ //2) add state listeners
13321
  module.preItem_location_alert_view_state.callbacks.add( function( to, from ) {
13322
  module._toggleLocationAlertExpansion( module.container, to );
13323
  });
13324
+
13325
+
13326
+ //REACT ON ADD / REMOVE ITEMS
13327
  module.bind( 'item-added', function( model ) {
13328
  module.addWidgetSidebar( model );
13329
  });
13331
  module.bind( 'pre_item_api_remove' , function(model) {
13332
  module.removeWidgetSidebar( model );
13333
  });
13334
+
13335
+
13336
+ //records the top margin value of the widgets panel on each expansion
13337
  var fixTopMargin = new api.Values();
13338
  fixTopMargin.create('fixed_for_current_session');
13339
  fixTopMargin.create('value');
13340
 
13341
  api.section(module.serverParams.dynWidgetSection).fixTopMargin = fixTopMargin;
13342
  api.section(module.serverParams.dynWidgetSection).fixTopMargin('fixed_for_current_session').set(false);
13343
+
13344
+
13345
+ //setup reactions on widget section expansion
13346
+ //change the expanded behaviour for the widget zone section
13347
+ //api.section(module.serverParams.dynWidgetSection).expanded.callbacks.add( function() { return module.widgetSectionReact.apply(module, arguments ); } );
13348
+
13349
+ //bind actions on widget panel expansion and widget zone section expansion
13350
+ //Fire the module
13351
  api.panel('widgets').expanded.callbacks.add( function(to, from) {
13352
  module.widgetPanelReact();//setup some visual adjustments, must be ran each time panel is closed or expanded
13353
+
13354
+ //Fire the module if not done already
13355
  if ( 'resolved' == module.isReady.state() )
13356
  return;
13357
  module.ready();
13358
  });
13359
  },//initialize
13360
+
13361
+
13362
+
13363
+
13364
+ //When the control is embedded on the page, this method is fired in api.CZRBaseModuleControl:ready()
13365
+ //=> right after the module is instantiated.
13366
  ready : function() {
13367
  var module = this;
13368
  api.CZRDynModule.prototype.ready.call( module );
13369
+
13370
+ //add state listener on pre Item view
13371
  module.preItemExpanded.callbacks.add( function( to, from ) {
13372
  if ( ! to )
13373
  return;
13374
+ //refresh the location list
13375
  module.preItem.czr_Input('locations')._setupLocationSelect( true );//true for refresh
13376
+ //refresh the location alert message
13377
  module.preItem.czr_Input('locations').mayBeDisplayModelAlert();
13378
  });
13379
  },
13380
+
13381
+
13382
+
13383
+ //overrides parent method
13384
+ //adds the default widget zones in the items
13385
  initializeModuleModel : function( constructorOptions ) {
13386
  var module = this, dfd = $.Deferred();
13387
  constructorOptions.items = _.union( _.has( module.serverParams, 'default_zones' ) ? module.serverParams.default_zones : [], constructorOptions.items );
13413
 
13414
  api.CZRInput.prototype.ready.call( input);
13415
  },
13416
+
13417
+
13418
+
13419
+ //////////////////////////////////////////////////
13420
+ ///SETUP SELECTS
13421
+ //////////////////////////////////////////////////
13422
+ //setup select on view_rendered|item_content_event_map
13423
  setupSelect : function() {
13424
  var input = this;
13425
  if ( 'locations' == this.id )
13428
  this._setupContextSelect();
13429
 
13430
  },
13431
+
13432
+ //helper
13433
  _setupContextSelect : function() {
13434
  var input = this,
13435
  input_contexts = input(),
13436
  item = input.input_parent,
13437
  module = input.module;
13438
+
13439
+ //generates the contexts options
13440
  _.each( module.contexts, function( title, key ) {
13441
  var _attributes = {
13442
  value : key,
13447
 
13448
  $( 'select[data-type="contexts"]', input.container ).append( $('<option>', _attributes) );
13449
  });
13450
+ //fire select2
13451
  $( 'select[data-type="contexts"]', input.container ).select2();
13452
  },
13453
+
13454
+
13455
+ //helper
13456
+ //the refresh param is a bool
13457
  _setupLocationSelect : function(refresh ) {
13458
  var input = this,
13459
  input_locations = input(),
13460
  item = input.input_parent,
13461
  module = input.module,
13462
  available_locs = api.sidebar_insights('available_locations')();
13463
+
13464
+ //generates the locations options
13465
+ //append them if not set yet
13466
  if ( ! $( 'select[data-type="locations"]', input.container ).children().length ) {
13467
  _.each( module.locations, function( title, key ) {
13468
  var _attributes = {
13489
  if ( refresh ) {
13490
  $( 'select[data-type="locations"]', input.container ).select2( 'destroy' );
13491
  }
13492
+
13493
+ //fire select2
13494
  $( 'select[data-type="locations"]', input.container ).select2( {
13495
  templateResult: setAvailability,
13496
  templateSelection: setAvailability
13497
  });
13498
  },
13499
+
13500
+ //fired on view event map : 'locations:changed'
13501
+ //@param obj { dom_el: $() , model : {} )
13502
  mayBeDisplayModelAlert : function() {
13503
  var input = this,
13504
  item = input.input_parent,
13505
  module = input.module;
13506
+
13507
+ //check if we are in the pre Item case => if so, the locations might be empty
13508
  if ( ! _.has( item(), 'locations') || _.isEmpty( item().locations ) )
13509
  return;
13510
 
13513
  _unavailable = _.filter( _selected_locations, function( loc ) {
13514
  return ! _.contains(available_locs, loc);
13515
  });
13516
+
13517
+ //check if we are in the pre Item case => if so, the id is empty
13518
  if ( ! _.has( item(), 'id' ) || _.isEmpty( item().id ) ) {
13519
  module.preItem_location_alert_view_state.set( ! _.isEmpty( _unavailable ) ? 'expanded' : 'closed' );
13520
  } else {
13541
  initialize : function( id, options ) {
13542
  var item = this,
13543
  module = item.module;
13544
+
13545
+ //Add some observable values for this item
13546
  item.czr_itemLocationAlert = new api.Value();
13547
 
13548
  api.CZRItem.prototype.initialize.call( item, null, options );
13549
  },
13550
+
13551
+
13552
+
13553
+ //extend parent setupview
13554
  itemWrapperViewSetup : function() {
13555
  var item = this,
13556
  module = item.module;
13557
 
13558
  api.CZRItem.prototype.itemWrapperViewSetup.call(item);
13559
+
13560
+ /// ALERT FOR NOT AVAILABLE LOCATION
13561
  item.czr_itemLocationAlert.set('closed');
13562
+
13563
+ //add a state listener on expansion change
13564
  item.czr_itemLocationAlert.callbacks.add( function( to, from ) {
13565
  module._toggleLocationAlertExpansion( item.container , to );
13566
  });
13567
+
13568
+ //update item title
13569
  item.writeSubtitleInfos(item());
13570
+
13571
+ //this is fired just after the itemWrapperViewSetupApiListeners
13572
+ //=> add a callback to refresh the availability status of the locations in the select location picker
13573
+ //add a state listener on expansion change
13574
  item.viewState.callbacks.add( function( to, from ) {
13575
  if ( -1 == to.indexOf('expanded') )//can take the expanded_noscroll value !
13576
  return;
13577
+ //don't try to invoke the input instances before the content is actually rendered
13578
+ //=> there might be cases when the content rendering is debounced...
13579
  item.bind('contentRendered', function() {
13580
+ //refresh the location list
13581
  item.czr_Input('locations')._setupLocationSelect( true );//true for refresh
13582
+ //refresh the location alert message
13583
  item.czr_Input('locations').mayBeDisplayModelAlert();
13584
  });
13585
 
13586
  });
13587
  },
13588
+
13589
+
13590
+ //extend parent listener
13591
  itemReact : function(to, from) {
13592
  var item = this;
13593
  api.CZRItem.prototype.itemReact.call(item, to, from);
13595
  item.writeSubtitleInfos(to);
13596
  item.updateSectionTitle(to).setModelUpdateTimer();
13597
  },
13598
+
13599
+
13600
+
13601
+ //Fired in setupItemListeners. Reacts to model change.
13602
+ //Write html informations under the title : location(s) and context(s)
13603
  writeSubtitleInfos : function(model) {
13604
  var item = this,
13605
  module = item.module,
13610
 
13611
  if ( ! item.container.length )
13612
  return this;
13613
+
13614
+ //generate the locations and the contexts text from the json data if exists
13615
  _model.locations =_.isString(_model.locations) ? [_model.locations] : _model.locations;
13616
  _.each( _model.locations, function( loc ) {
13617
  if ( _.has( module.locations , loc ) )
13620
  _locations.push(loc);
13621
  }
13622
  );
13623
+
13624
+ //build the context list
13625
  _model.contexts =_.isString(_model.contexts) ? [_model.contexts] : _model.contexts;
13626
+
13627
+ //all contexts cases ?
13628
  if ( item._hasModelAllContexts( model ) ) {
13629
  _contexts.push(module.contexts._all_);
13630
  } else {
13636
  }
13637
  );
13638
  }
13639
+
13640
+ //Translated strings
13641
  var _locationText = serverControlParams.i18n.locations,
13642
  _contextText = serverControlParams.i18n.contexts,
13643
  _notsetText = serverControlParams.i18n.notset;
13645
  _locations = _.isEmpty( _locations ) ? '<span style="font-weight: bold;">' + _notsetText + '</span>' : _locations.join(', ');
13646
  _contexts = _.isEmpty( _contexts ) ? '<span style="font-weight: bold;">' + _notsetText + '</span>' : _contexts.join(', ');
13647
 
13648
+ //write the description if builtin
13649
+ //else, write the dynamic location
13650
+ // if ( _.has(_model, 'description') && _.has(_model, 'is_builtin') )
13651
+ // _html = _model.description + ' <strong>|</strong> <u>Contexts</u> : ' + _contexts;
13652
+ // else
13653
+
13654
  _html = '<u>' + _locationText + '</u> : ' + _locations + ' <strong>|</strong> <u>' + _contextText + '</u> : ' + _contexts;
13655
 
13656
  if ( ! $('.czr-zone-infos', item.container ).length ) {
13665
 
13666
  return this;
13667
  },//writeSubtitleInfos
13668
+
13669
+
13670
+
13671
+ ////Fired in setupItemListeners
13672
  updateSectionTitle : function(model) {
13673
  var _sidebar_id = 'sidebar-widgets-' + model.id,
13674
  _new_title = model.title;
13675
+ //does this section exists ?
13676
  if ( ! api.section.has(_sidebar_id) )
13677
  return this;
13678
+
13679
+ //update the section title
13680
  $('.accordion-section-title', api.section(_sidebar_id).container ).text(_new_title);
13681
+
13682
+ //update the top title ( visible when inside the expanded section )
13683
  $('.customize-section-title h3', api.section(_sidebar_id).container ).html(
13684
  '<span class="customize-action">' + api.section(_sidebar_id).params.customizeAction + '</span>' + _new_title
13685
  );
13686
+ // $('.customize-section-title h3', api.section(_sidebar_id).container )
13687
+ // .append('<span>', {
13688
+ // class: 'customize-section-back',
13689
+ // html: api.section(_sidebar_id).params.customizeAction
13690
+ // } )
13691
+ // .append(_new_title);
13692
+
13693
+ //remove and re-instanciate
13694
+ //=> works for the section but the controls are not activated anymore.
13695
+ //Should be easy to fix but useless to go further here. Jquery does the job.
13696
+ // var _params = _.clone( api.section(_sidebar_id).params );
13697
+ // _params.title = _new_title;
13698
+ // api.section(_sidebar_id).container.remove();
13699
+ // api.section.remove(_sidebar_id);
13700
+ // api.section.add( _sidebar_id, new api.sectionConstructor[_params.type]( _params.id ,{ params : _params } ) );
13701
  return this;
13702
  },
13703
+
13704
+
13705
+ //fired on model_update
13706
+ //Don't hammer the preview with too many refreshs
13707
+ //2 seconds delay
13708
  setModelUpdateTimer : function() {
13709
  var item = this,
13710
  module = item.module;
13714
  this,
13715
  'modelUpdateTimer',
13716
  setTimeout( function() {
13717
+ //refresh preview
13718
  module.control.refreshPreview();
13719
  } , 1000)
13720
  );//$.data
13721
  },
13722
+
13723
+
13724
+ //@return bool
13725
+ //takes the model unique id
13726
  _hasModelAllContexts : function( model ) {
13727
  var item = this,
13728
  module = item.module,
13735
 
13736
  if ( _.contains( model.contexts, '_all_') )
13737
  return true;
13738
+
13739
+ //case when model does not have _all_ but all the others
13740
  return _.isEmpty( _.difference( _.without(moduleContexts, '_all_') , model.contexts ) );
13741
  },
13742
+
13743
+ //@param contexts = array of contexts
13744
+ //api.czr_wpQueryInfos is refreshed on each preview refresh
13745
  _getMatchingContexts : function( defaults ) {
13746
  var module = this,
13747
  _current = api.czr_wpQueryInfos().conditional_tags || {},
13750
  return _.isEmpty( _matched ) ? defaults : _matched;
13751
  }
13752
  },//CZRWZonesItem
13753
+
13754
+
13755
+
13756
+
13757
+
13758
+
13759
+
13760
+
13761
+
13762
+
13763
+
13764
+
13765
+
13766
+
13767
+ //DEPRECATED : THE CONTROLS TO SYNCHRONIZE HAVE BEEN REMOVED
13768
+
13769
+ //fired on model_added_by_user and from the timer method
13770
+ //1) model_added, before renderItemWrapper action
13771
+ // when a new model is manually added ( isTrigger is undefined )
13772
+ // => refresh the select options of the other controls using this collection
13773
+ //2) model_updated, before updateCollection
13774
+ // addControlOptions : function(obj) {
13775
+ // var _controls = _.where( api.settings.controls, {section:"sidebars_select_sec"});
13776
+ // _.map( _controls, function( _control ) {
13777
+ // var $_select = api.control( _control.settings.default ).container.find('select');
13778
+
13779
+ // //if this option has already been added, simply updates its attributes
13780
+ // if ( 1 === $_select.find('option[value="' + obj.model.id + '"]').length ) {
13781
+ // $_select.find('option[value="' + obj.model.id + '"]').html(obj.model.title);
13782
+ // $_select.selecter("destroy").selecter();
13783
+ // } else {
13784
+ // $_select.append( $('<option>', {value: obj.model.id, html:obj.model.title } ) ).selecter("destroy").selecter();
13785
+ // }
13786
+ // });//map
13787
+ // },
13788
+
13789
+ //fired on model_removed
13790
+ // removeControlOptions : function(obj) {
13791
+ // var _controls = _.where( api.settings.controls, {section:"sidebars_select_sec"});
13792
+
13793
+ // _.map( _controls, function( _control ) {
13794
+ // var $_select = api.control( _control.settings.default ).container.find('select');
13795
+
13796
+ // if ( ! $_select.find('option[value="' + obj.model.id + '"]').length )
13797
+ // return;
13798
+
13799
+ // $( 'option[value="' + obj.model.id +'"]', $_select).remove();
13800
+ // $_select.selecter("destroy").selecter();
13801
+ // });//map
13802
+ // },
13803
+
13804
+
13805
+
13806
+
13807
+
13808
+
13809
+
13810
+
13811
+
13812
+
13813
+
13814
+
13815
+ /////////////////////////////////////////
13816
+ /// ADD / REMOVE WIDGET ZONES
13817
+ ////////////////////////////////////////
13818
+ //fired on model_added_by_user
13819
+ //
13820
+ //can also be called statically when a dynamic sidebar is added in the preview
13821
+ //in this case the parameter are the sidebar data with id and name
13822
  addWidgetSidebar : function( model, sidebar_data ) {
13823
  if ( ! _.isObject(model) && _.isEmpty(sidebar_data) ) {
13824
  throw new Error('No valid input were provided to add a new Widget Zone.');
13825
  }
13826
+
13827
+
13828
+ //ADD the new sidebar to the existing collection
13829
+ //Clone the serverControlParams.defaultWidgetSidebar sidebar
13830
  var module = this,
13831
  _model = ! _.isEmpty(model) ? _.clone(model) : sidebar_data,
13832
  _new_sidebar = _.isEmpty(model) ? sidebar_data : $.extend(
13836
  id : _model.id
13837
  }
13838
  );
13839
+
13840
+ //Add it to the backbone collection
13841
  api.Widgets.registeredSidebars.add( _new_sidebar );
13842
+
13843
+ //test if added:
13844
+ //api.Widgets.registeredSidebars('czr_sidebars_8');
13845
+
13846
+
13847
+ //ADD the sidebar section
13848
  var _params = $.extend(
13849
  _.clone( api.section( "sidebar-widgets-" + module.serverParams.defaultWidgetSidebar ).params ),
13850
  {
13853
  sidebarId: _new_sidebar.id,
13854
  title: _new_sidebar.name,
13855
  description : 'undefined' != typeof(sidebar_data) ? sidebar_data.description : api.section( "sidebar-widgets-" + module.serverParams.defaultWidgetSidebar ).params.description,
13856
+ //always set the new priority to the maximum + 1 ( module.serverParams.dynWidgetSection is excluded from this calculation because it must always be at the bottom )
13857
  priority: _.max( _.omit( api.settings.sections, module.serverParams.dynWidgetSection), function(sec){ return sec.instanceNumber; }).priority + 1,
13858
  }
13859
  );
13860
 
13861
  api.section.add( _params.id, new api.sectionConstructor[ _params.type ]( _params.id ,{ params : _params } ) );
13862
+
13863
+ //add it to the static collection of settings
13864
  api.settings.sections[ _params.id ] = _params.id;
13865
+
13866
+ //ADD A SETTING
13867
+ //Clone the module.serverParams.defaultWidgetSidebar sidebar widget area setting
13868
  var _new_set_id = 'sidebars_widgets['+_model.id+']',
13869
  _new_set = $.extend(
13870
  _.clone( api.settings.settings['sidebars_widgets[' + module.serverParams.defaultWidgetSidebar + ']'] ),
13872
  value:[]
13873
  }
13874
  );
13875
+
13876
+ //add it to the static collection of settings
13877
  api.settings.settings[ _new_set_id ] = _new_set;
13878
+
13879
+ //instanciate it
13880
  api.create( _new_set_id, _new_set_id, _new_set.value, {
13881
  transport: _new_set.transport,
13882
  previewer: api.previewer,
13883
  dirty: false
13884
  } );
13885
+
13886
+
13887
+
13888
+ //ADD A CONTROL
13889
  var _cloned_control = $.extend(
13890
  _.clone( api.settings.controls['sidebars_widgets[' + module.serverParams.defaultWidgetSidebar + ']'] ),
13891
  {
13892
  settings : { default : _new_set_id }
13893
  }),
13894
  _new_control = {};
13895
+
13896
+
13897
+ //replace serverControlParams.defaultWidgetSidebar by the new sidebar id
13898
  _.each( _cloned_control, function( param, key ) {
13899
  if ( 'string' == typeof(param) ) {
13900
  param = param.replace( module.serverParams.defaultWidgetSidebar , _model.id );
13901
  }
13902
  _new_control[key] = param;
13903
  });
13904
+
13905
+ //set the instance number (no sure if needed)
13906
  _new_control.instanceNumber = _.max(api.settings.controls, function(con){ return con.instanceNumber; }).instanceNumber + 1;
13907
+
13908
+ //add it to the static collection of controls
13909
  api.settings.controls[_new_set_id] = _new_control;
13910
+
13911
+ //instanciate it
13912
  api.control.add( _new_set_id, new api.controlConstructor[ _new_control.type ]( _new_set_id, {
13913
  params: _new_control,
13914
  previewer: api.previewer
13915
  } ) );
13916
+
13917
+
13918
+ //say it to the control container
13919
+ //only if we are in an instanciated object => because this method can be accessed statically
13920
  if ( _.has(this, 'container') )
13921
  this.container.trigger( 'widget_zone_created', { model : _model, section_id : "sidebar-widgets-" + _model.id , setting_id : _new_set_id });
13922
  },//addWidgetSidebar
13923
+
13924
+
13925
+ //fired on "after_modelRemoved"
13926
  removeWidgetSidebar : function( model ) {
13927
  var module = this;
13928
  if ( ! _.isObject(model) || _.isEmpty(model) ) {
13929
  throw new Error('No valid data were provided to remove a Widget Zone.');
13930
  }
13931
+
13932
+ //Remove this sidebar from the backbone collection
13933
  api.Widgets.registeredSidebars.remove( model.id );
13934
+
13935
+ //remove the section from the api values and the DOM if exists
13936
  if ( api.section.has("sidebar-widgets-" + model.id) ) {
13937
+ //Remove the section container from the DOM
13938
  api.section("sidebar-widgets-" + model.id).container.remove();
13939
+ //Remove the sidebar section from the api
13940
  api.section.remove( "sidebar-widgets-" + model.id );
13941
+ //Remove this section from the static collection
13942
  delete api.settings.sections[ "sidebar-widgets-" + model.id ];
13943
  }
13944
+
13945
+ //remove the setting from the api if exists
13946
  if ( api.has('sidebars_widgets['+model.id+']') ) {
13947
+ //Remove this setting from the api
13948
  api.remove( 'sidebars_widgets['+model.id+']' );
13949
+ //Remove this setting from the static collection
13950
  delete api.settings.settings['sidebars_widgets['+model.id+']'];
13951
  }
13952
+
13953
+ //remove the widget control of this sidebar from the api and the DOM if exists
13954
  if ( api.control.has('sidebars_widgets['+model.id+']') ) {
13955
+ //Remove the control container from the DOM
13956
  api.control( 'sidebars_widgets['+model.id+']' ).container.remove();
13957
+ //Remove this control from the api
13958
  api.control.remove( 'sidebars_widgets['+model.id+']' );
13959
+ //Remove it to the static collection of controls
13960
  delete api.settings.controls['sidebars_widgets['+model.id+']'];
13961
  }
13962
+
13963
+ //refresh
13964
  var _refresh = function() {
13965
  api.previewer.refresh();
13966
  };
13967
  _refresh = _.debounce( _refresh, 500 );
13968
  $.when( _refresh() ).done( function() {
13969
+ //say it
13970
  module.trigger( 'widget_zone_removed',
13971
  {
13972
  model : model,
13976
  );
13977
  });
13978
  },
13979
+
13980
+
13981
+
13982
+
13983
+
13984
+
13985
+
13986
+
13987
+
13988
+
13989
+
13990
+ /////////////////////////////////////////
13991
+ /// SET EXPANSION CALLBACKS FOR WIDGET PANEL AND WIDGET ZONE CREATION SECTION
13992
+ ////////////////////////////////////////
13993
+ //cb of : api.panel('widgets').expanded.callbacks.add
13994
  widgetPanelReact : function() {
13995
  var module = this;
13996
+ //will be used for adjustments
13997
  var _top_margin = api.panel('widgets').container.find( '.control-panel-content' ).css('margin-top');
13998
 
13999
  api.section(module.serverParams.dynWidgetSection).fixTopMargin('value').set( _top_margin );
14004
  _section_content.css( 'margin-top', '' );
14005
  _panel_content.css('margin-top', api.section(module.serverParams.dynWidgetSection).fixTopMargin('value')() );
14006
  };
14007
+
14008
+ // Fix the top margin after reflow.
14009
  api.bind( 'pane-contents-reflowed', _.debounce( function() {
14010
  _set_margins();
14011
  }, 150 ) );
14012
+
14013
+ //Close all views on widget panel expansion/clos
14014
  module.closeAllItems().closeRemoveDialogs();
14015
+ //Close preItem dialog box if exists
14016
  if ( _.has( module, 'preItemExpanded' ) )
14017
  module.preItemExpanded.set(false);
14018
  },//widgetPanelReact()
14019
+
14020
+
14021
+ //cb of api.section(module.serverParams.dynWidgetSection).expanded.callbacks
14022
  widgetSectionReact : function( to, from ) {
14023
  var module = this,
14024
  section = api.section(module.serverParams.dynWidgetSection),
14033
  if ( to ) {
14034
  overlay.removeClass( 'section-open' );
14035
  content.css( 'height', 'auto' );
14036
+ //section.container.removeClass( 'open' );
14037
  sectionTitle.attr( 'tabindex', '0' );
14038
  content.css( 'margin-top', '' );
14039
  container.scrollTop( 0 );
14043
 
14044
  content.slideToggle();
14045
  },
14046
+
14047
+
14048
+
14049
+
14050
+
14051
+
14052
+
14053
+ /////////////////////////////////////////
14054
+ /// LISTEN TO SIDEBAR INSIGHTS FROM THE PREVIEW FRAME
14055
+ /// REACT TO THEM
14056
+ ////////////////////////////////////////
14057
  listenToSidebarInsights : function() {
14058
  var module = this;
14059
+
14060
+ //VISIBILITY BASED ON THE SIDEBAR INSIGHTS
14061
  api.sidebar_insights('registered').callbacks.add( function( _registered_zones ) {
14062
  var _current_collection = _.clone( module.itemCollection() );
14063
  _.each( _current_collection, function( _model ) {
14067
  module.getViewEl(_model.id).css('display' , _.contains( _registered_zones, _model.id ) ? 'block' : 'none' );
14068
  });
14069
  });
14070
+
14071
+ //OPACITY SIDEBAR INSIGHTS BASED
14072
  api.sidebar_insights('inactives').callbacks.add( function( _inactives_zones ) {
14073
  var _current_collection = _.clone( module.itemCollection() );
14074
  _.each( _current_collection, function( _model ) {
14090
  }
14091
  });
14092
  });
14093
+
14094
+ //WIDGET SIDEBAR CREATION BASED ON SIDEBAR INSIGHTS
14095
+ //react to a new register candidate(s) on preview refresh
14096
  api.sidebar_insights('candidates').callbacks.add( function(_candidates) {
14097
  if ( ! _.isArray(_candidates) )
14098
  return;
14099
  _.each( _candidates, function( _sidebar ) {
14100
  if ( ! _.isObject(_sidebar) )
14101
  return;
14102
+ //add this widget sidebar and the related setting and control.
14103
+ //Only if not added already
14104
  if ( api.section.has("sidebar-widgets-" +_sidebar.id ) )
14105
  return;
14106
+
14107
+ //access the registration method statically
14108
  module.addWidgetSidebar( {}, _sidebar );
14109
+ //activate it if so
14110
  if ( _.has( api.sidebar_insights('actives')(), _sidebar.id ) && api.section.has("sidebar-widgets-" +_sidebar.id ) )
14111
  api.section( "sidebar-widgets-" +_sidebar.id ).activate();
14112
  });
14113
  });
14114
  },//listenToSidebarInsights()
14115
+
14116
+
14117
+
14118
+
14119
+
14120
+
14121
+
14122
+ /////////////////////////////////////////
14123
+ /// OVERRIDEN METHODS
14124
+ ////////////////////////////////////////
14125
+ //fired in toggleItemExpansion()
14126
+ //has to be overridden for the widget zones control because this control is embedded directly in a panel and not in a section
14127
+ //therefore the module to animate the scrollTop is not the section container but $('.wp-full-overlay-sidebar-content')
14128
  _adjustScrollExpandedBlock : function( $_block_el, adjust ) {
14129
  if ( ! $_block_el.length )
14130
  return;
14141
  }
14142
  }, 50);
14143
  },
14144
+
14145
+
14146
+
14147
+ //overrides the parent class default model getter
14148
+ //=> add a dynamic title
14149
  getDefaultItemModel : function( id ) {
14150
  var module = this,
14151
  _current_collection = module.itemCollection(),
14153
  _default_contexts = _default.contexts;
14154
  return $.extend( _default, {
14155
  title : 'Widget Zone ' + ( _.size(_current_collection)*1 + 1 )
14156
+ //contexts : module._getMatchingContexts( _default_contexts )
14157
  });
14158
  },
14159
+
14160
+
14161
+
14162
+ //overrides parent
14163
+ //called before rendering a view. Fired in module::renderItemWrapper()
14164
+ //can be overridden to set a specific view template depending on the model properties
14165
+ //@return string
14166
+ //@type can be
14167
+ //Read Update Delete (rud...)
14168
+ //Read Update (ru)
14169
+ //...
14170
+ //@item_model is an object describing the current item model
14171
  getTemplateEl : function( type, item_model ) {
14172
  var module = this, _el;
14173
+ //force view-content type to ru-item-part if the model is a built-in (primary, secondary, footer-1, ...)
14174
+ //=> user can't delete a built-in model.
14175
  if ( 'rudItemPart' == type ) {
14176
  type = ( _.has(item_model, 'is_builtin') && item_model.is_builtin ) ? 'ruItemPart' : type;
14177
  } else if ( 'itemInputList' == type ) {
14221
  }
14222
  });//$.extend()
14223
  })( wp.customize , jQuery, _ );
14224
+ //extends api.CZRModule
14225
  var CZRBodyBgModuleMths = CZRBodyBgModuleMths || {};
14226
  ( function ( api, $, _ ) {
14227
  $.extend( CZRBodyBgModuleMths, {
14228
  initialize: function( id, options ) {
14229
  var module = this;
14230
+ //run the parent initialize
14231
  api.CZRModule.prototype.initialize.call( module, id, options );
14232
+
14233
+ //extend the module with new template Selectors
14234
  $.extend( module, {
14235
  itemInputList : 'czr-module-bodybg-item-content'
14236
  } );
14237
+
14238
+ //EXTEND THE DEFAULT CONSTRUCTORS FOR INPUT
14239
  module.inputConstructor = api.CZRInput.extend( module.CZRBodyBgInputMths || {} );
14240
+ //EXTEND THE DEFAULT CONSTRUCTORS FOR MONOMODEL
14241
  module.itemConstructor = api.CZRItem.extend( module.CZBodyBgItemMths || {} );
14242
+
14243
+ //declares a default model
14244
  module.defaultItemModel = {
14245
  'background-color' : '#eaeaea',
14246
  'background-image' : '',
14250
  'background-size' : 'cover'
14251
  };
14252
  api.consoleLog('New module instantiated : ', module.id );
14253
+ //fired ready :
14254
+ //1) on section expansion
14255
+ //2) or in the case of a module embedded in a regular control, if the module section is alreay opened => typically when skope is enabled
14256
  if ( _.has( api, 'czr_activeSectionId' ) && module.control.section() == api.czr_activeSectionId() && 'resolved' != module.isReady.state() ) {
14257
  module.ready();
14258
  }
14266
 
14267
 
14268
  CZRBodyBgInputMths : {
14269
+ //////////////////////////////////////////////////
14270
+ ///SETUP SELECTS
14271
+ //////////////////////////////////////////////////
14272
+ //setup select on view_rendered|item_content_event_map
14273
  setupSelect : function() {
14274
  var input = this,
14275
  _id_param_map = {
14290
  options = serverParams[ _id_param_map[input.id] ];
14291
  if ( _.isEmpty(options) )
14292
  return;
14293
+ //generates the options
14294
  _.each( options, function( title, key ) {
14295
  var _attributes = {
14296
  value : key,
14301
 
14302
  $( 'select[data-type]', input.container ).append( $('<option>', _attributes) );
14303
  });
14304
+ //fire select2
14305
  $( 'select[data-type]', input.container ).select2();
14306
  }
14307
  },
14308
 
14309
 
14310
  CZBodyBgItemMths : {
14311
+ //Fired if the item has been instantiated
14312
+ //The item.callbacks are declared.
14313
  ready : function() {
14314
  var item = this;
14315
  api.CZRItem.prototype.ready.call( item );
14324
  });
14325
  };
14326
  set_visibilities( input_instance() );
14327
+ //update the item model on 'background-image' change
14328
  item.bind('background-image:changed', function(){
14329
  set_visibilities( item.czr_Input('background-image')() );
14330
  });
14338
  });//$.extend
14339
  })( wp.customize , jQuery, _ );
14340
  (function ( api, $, _ ) {
14341
+ //provides a description of each module
14342
+ //=> will determine :
14343
+ //1) how to initialize the module model. If not crud, then the initial item(s) model shall be provided
14344
+ //2) which js template(s) to use : if crud, the module template shall include the add new and pre-item elements.
14345
+ // , if crud, the item shall be removable
14346
+ //3) how to render : if multi item, the item content is rendered when user click on edit button.
14347
+ // If not multi item, the single item content is rendered as soon as the item wrapper is rendered.
14348
+ //4) some DOM behaviour. For example, a multi item shall be sortable.
14349
  api.czrModuleMap = api.czrModuleMap || {};
14350
  $.extend( api.czrModuleMap, {
14351
  czr_widget_areas_module : {
14368
  }
14369
  });
14370
  })( wp.customize, jQuery, _ );
14371
+ //named czr_multiple_picker in the php setting map
14372
  var CZRMultiplePickerMths = CZRMultiplePickerMths || {};
14373
  /* Multiple Picker */
14374
  /**
14389
  });
14390
 
14391
  function czrEscapeMarkup(obj) {
14392
+ //trim dashes
14393
  return obj.text.replace(/\u2013|\u2014/g, "");
14394
  }
14395
+
14396
+ //handle case when all choices become unselected
14397
  _select.on('change', function(e){
14398
  if ( 0 === $(this).find("option:selected").length )
14399
  control.setting.set([]);
14401
  }
14402
  });//$.extend
14403
  })( wp.customize , jQuery, _ );
14404
+ //named czr_cropped_image in the php setting map
14405
  var CZRCroppedImageMths = CZRCroppedImageMths || {};
14406
 
14407
  (function (api, $, _) {
14408
  /* IMAGE UPLOADER CONTROL IN THE CUSTOMIZER */
14409
+ //CroppedImageControl is not available before wp 4.3
14410
  if ( 'function' != typeof wp.media.controller.Cropper || 'function' != typeof api.CroppedImageControl )
14411
  return;
14412
 
14497
  onSelect: function() {
14498
  var attachment = this.frame.state().get( 'selection' ).first().toJSON();
14499
  if ( ! ( attachment.mime && attachment.mime.indexOf("image") > -1 ) ){
14500
+ //Todo: better error handling, show some message?
14501
  this.frame.trigger( 'content:error' );
14502
  return;
14503
  }
14511
  },
14512
  });//extend
14513
  })( wp.customize, jQuery, _);
14514
+
14515
+ //named czr_upload in the php setting map
14516
  var CZRUploadMths = CZRUploadMths || {};
14517
  ( function ( api, $, _ ) {
14518
  /**
14531
  this.uploader = $.extend({
14532
  container: this.container,
14533
  browser: this.container.find('.czr-upload'),
14534
+ //dropzone: this.container.find('.upload-dropzone'),
14535
  success: this.success,
14536
  plupload: {},
14537
  params: {}
14574
  }
14575
  });//extend
14576
  })( wp.customize , jQuery, _ );
14577
+ //named czr_layouts in the php setting map
14578
  var CZRLayoutSelectMths = CZRLayoutSelectMths || {};
14579
  ( function ( api, $, _ ) {
14580
  $.extend( CZRLayoutSelectMths , {
14599
  );
14600
  return $state;
14601
  }
14602
+
14603
+ //destroy selected if set
14604
+ //$_select.selecter("destroy");
14605
+
14606
+ //fire select2
14607
  $_select.select2( {
14608
  templateResult: addImg,
14609
  templateSelection: addImg,
14613
  });//$.extend
14614
  })( wp.customize , jQuery, _ );
14615
  ( function ( api, $, _ ) {
14616
+ //THEME CONTROLS
14617
+ //api.CZRBackgroundControl = api.CZRItemControl.extend( CZRBackgroundMths );
14618
+
14619
+ //api.CZRWidgetAreasControl = api.CZRDynModule.extend( CZRWidgetAreasMths );
14620
 
14621
  api.CZRUploadControl = api.Control.extend( CZRUploadMths );
14622
  api.CZRLayoutControl = api.Control.extend( CZRLayoutSelectMths );
14625
 
14626
  $.extend( api.controlConstructor, {
14627
  czr_upload : api.CZRUploadControl,
14628
+ //czr_sidebars : api.CZRWidgetAreasControl,
14629
+ //czr_socials : api.CZRSocialControl,
14630
  czr_multiple_picker : api.CZRMultiplePickerControl,
14631
  czr_layouts : api.CZRLayoutControl
14632
+ //czr_background : api.CZRBackgroundControl
14633
  });
14634
 
14635
  if ( 'function' == typeof api.CroppedImageControl ) {
14640
  });
14641
  }
14642
 
14643
+ if ( 'function' == typeof api.CodeEditorControl ) {
14644
+ $.extend( api.controlConstructor, {
14645
+ czr_code_editor : api.CodeEditorControl
14646
+ });
14647
+ }
14648
+
14649
  })( wp.customize, jQuery, _ );
14650
  ( function (api, $, _) {
14651
  var $_nav_section_container,
14657
  if ( _.has( api, 'czr_ctrlDependencies') )
14658
  return;
14659
  if ( serverControlParams.isSkopOn ) {
14660
+ // If skope is on, we need to wait for the initial setup to be finished
14661
+ // otherwise, we might refer to not instantiated skopes when processing silent updates further in the code
14662
+ //Skope is ready when :
14663
+ //1) the initial skopes collection has been populated
14664
+ //2) the initial skope has been switched to
14665
  if ( 'resolved' != api.czr_skopeReady.state() ) {
14666
  api.czr_skopeReady.done( function() {
14667
  api.czr_ctrlDependencies = new api.CZR_ctrlDependencies();
14688
  actions : null,
14689
  onSectionExpand : true
14690
  };
14691
+
14692
+ //store the default control dependencies
14693
  this.dominiDeps = _.extend( this.dominiDeps, this._getControlDeps() );
14694
  if ( ! _.isArray( self.dominiDeps ) ) {
14695
  throw new Error('Visibilities : the dominos dependency array is not an array.');
14703
  }
14704
  }
14705
  });
14706
+
14707
+
14708
+ //@param target_source is an object :
14709
+ // {
14710
+ // target : section_id to awake
14711
+ // source : section_id from which the request for awaking has been done
14712
+ // }
14713
  api.bind( 'awaken-section', function( target_source ) {
14714
+ //if skope on ( serverControlParams.isSkopOn ), then defer the visibility awakening after the silent updates
14715
  if ( serverControlParams.isSkopOn && _.has( api ,'czr_skopeBase' ) ) {
14716
  api.czr_skopeBase.processSilentUpdates( {
14717
  candidates : {},
14732
  }
14733
  }
14734
  });
14735
+
14736
+ //FAVICON SPECIFICS
14737
+ //@todo => move to the theme ?
14738
+ //favicon note on load and on change(since wp 4.3)
14739
  this._handleFaviconNote();
14740
  },
14741
+
14742
+
14743
+ //Process the visibility callbacks for the controls of a target targetSectionId
14744
+ //@param targetSectionId : string
14745
+ //@param sourceSectionId : string, the section from which the request has been done
14746
  setServiDependencies : function( targetSectionId, sourceSectionId, refresh ) {
14747
  var self = this, params, dfd = $.Deferred();
14748
 
14751
  if ( _.isUndefined( targetSectionId ) || ! api.section.has( targetSectionId ) ) {
14752
  throw new Error( 'Control Dependencies : the targetSectionId is missing or not registered : ' + targetSectionId );
14753
  }
14754
+
14755
+ //Assign a visibility state deferred to the target section
14756
  api.section( targetSectionId ).czr_ctrlDependenciesReady = api.section( targetSectionId ).czr_ctrlDependenciesReady || $.Deferred();
14757
+
14758
+ //Bail here if this section has already been setup for ctrl dependencies
14759
  if ( ! refresh && 'resolved' == api.section( targetSectionId ).czr_ctrlDependenciesReady.state() )
14760
  return dfd.resolve().promise();
14761
+
14762
+ //FIND DOMINI IN THE TARGET SECTION
14763
+ //=> setup their callbacks
14764
  _.each( self.dominiDeps , function( params ) {
14765
  if ( ! _.has( params, 'dominus' ) || ! _.isString( params.dominus ) || _.isEmpty( params.dominus ) ) {
14766
  throw new Error( 'Control Dependencies : a dominus control id must be a not empty string.');
14772
 
14773
  if ( api.control( wpDominusId ).section() != targetSectionId )
14774
  return;
14775
+
14776
+ //Attempt to normalize the params
14777
  params = self._prepareDominusParams( params );
14778
  if ( _.isEmpty(params) )
14779
  return;
14787
  dfd.resolve();
14788
  });
14789
  });
14790
+
14791
+
14792
+ //EXTERNAL DOMINI : AWAKE THE SECTIONS
14793
+ //check if any control of the current section is the servus of a dominus located in another section
14794
  var _secCtrls = api.CZR_Helpers.getSectionControlIds( targetSectionId ),
14795
  _getServusDomini = function( shortServudId ) {
14796
  var _dominiIds = [];
14801
  }
14802
 
14803
  if ( _.contains( params.servi , shortServudId ) && ! _.contains( _dominiIds , params.dominus ) ) {
14804
+ //Attempt to normalize the params
14805
  params = self._prepareDominusParams( params );
14806
  if ( _.isEmpty(params) )
14807
  return;
14812
  return ! _.isArray( _dominiIds ) ? [] : _dominiIds;
14813
  },
14814
  _servusDominiIds = [];
14815
+
14816
+ //Build the domini array
14817
  _.each( _secCtrls, function( servusCandidateId ) {
14818
  if ( _.isEmpty( _getServusDomini( servusCandidateId ) ) )
14819
  return;
14820
 
14821
  _servusDominiIds = _.union( _servusDominiIds, _getServusDomini( servusCandidateId ) );
14822
  });
14823
+
14824
+ //let's loop on the domini ids and check if we need to "awake" an external section
14825
  _.each( _servusDominiIds, function( shortDominusId ){
14826
 
14827
  var wpDominusId = api.CZR_Helpers.build_setId( shortDominusId );
14828
+ //This dominus must be located in another section
14829
  if ( api.control( wpDominusId ).section() == targetSectionId )
14830
  return;
14831
+ //The dominus section can't be the current source if set. => otherwise potential infinite loop scenario.
14832
  if ( sourceSectionId == api.control( wpDominusId ).section() )
14833
  return;
14834
+ //inform the api that a section has to be awaken
14835
+ //=> first silently update the section controls if skope on
14836
+ //=> then fire the visibilities
14837
  api.trigger( 'awaken-section', {
14838
  target : api.control( wpDominusId ).section(),
14839
  source : targetSectionId
14840
  } );
14841
  } );
14842
+
14843
+ //This section has been setup for ctrl dependencies
14844
  dfd.always( function() {
14845
  api.section( targetSectionId ).czr_ctrlDependenciesReady.resolve();
14846
  });
14847
  return dfd.promise();
14848
  },
14849
+
14850
+
14851
+ //This method fires a callback when a control is registered in the api.
14852
+ //If the control is registered, then it fires the callback when it is embedded
14853
+ //If the control is embedeed, it fires the callback
14854
+ //=> typical use case : a control can be both removed from the API and the DOM, and then added back on skope switch
14855
+ //
14856
+ //@param wpCtrlId : string name of the control as registered in the WP API
14857
+ //@param callback : fn callback to fire
14858
+ //@param args : [] or callback arguments
14859
  _deferCallbackForControl : function( wpCrtlId, callback, args ) {
14860
  var dfd = $.Deferred();
14861
  if ( _.isEmpty(wpCrtlId) || ! _.isString(wpCrtlId) ) {
14903
  dominusSetInst = api( wpDominusId ),
14904
  dfd = $.Deferred(),
14905
  hasProcessed = false;
14906
+
14907
+ //loop on the dominus servi and apply + bind the visibility cb
14908
  _.each( dominusParams.servi , function( servusShortSetId ) {
14909
  if ( ! api.control.has( api.CZR_Helpers.build_setId( servusShortSetId ) ) ) {
14910
  return;
14911
  }
14912
+ //set visibility when control is embedded
14913
+ //or when control is added to the api
14914
+ //=> solves the problem of visibility callbacks lost when control are re-rendered
14915
  var _fireDominusCallbacks = function( dominusSetVal, servusShortSetId, dominusParams, refresh ) {
14916
  var _toFire = [],
14917
  _args = arguments;
14939
  .fail( function() { dfd.reject(); })
14940
  .done( function() { dfd.resolve(); });
14941
  };
14942
+
14943
+
14944
+ //APPLY THE DEPENDENCIES
14945
  _deferCallbacks();
14946
+
14947
+ //BIND THE DOMINUS SETTING INSTANCE
14948
+ //store the visibility bound state
14949
  if ( ! _.has( dominusSetInst, 'czr_visibilityServi' ) )
14950
  dominusSetInst.czr_visibilityServi = new api.Value( [] );
14951
+
14952
+ //Maybe bind to react on setting _dirty change
14953
  var _currentDependantBound = dominusSetInst.czr_visibilityServi();
14954
+ //Make sure a dependant visibility action is bound only once for a setting id to another setting control id
14955
  if ( ! _.contains( _currentDependantBound, servusShortSetId ) ) {
14956
  dominusSetInst.bind( function( dominusSetVal ) {
14957
  _deferCallbacks( dominusSetVal );
14963
  return dfd.resolve().promise();
14964
  return dfd.promise();
14965
  },
14966
+
14967
+
14968
+
14969
+ //@return void()
14970
  _setVisibility : function ( dominusSetVal, servusShortSetId, dominusParams, refresh ) {
14971
  var wpServusSetId = api.CZR_Helpers.build_setId( servusShortSetId ),
14972
  visibility = dominusParams.visibility( dominusSetVal, servusShortSetId, dominusParams.dominus );
14973
 
14974
  refresh = refresh || false;
14975
+ //Allows us to filter between visibility callbacks and other actions
14976
+ //a non visibility callback shall return null
14977
  if ( ! _.isBoolean( visibility ) || ( 'unchanged' == visibility && ! refresh ) )
14978
  return;
14979
+
14980
+ //when skope is enabled, we might be doing a silent update
14981
+ //=> this method should be bailed if so
14982
  var _doVisibilitiesWhenPossible = function() {
14983
  if ( api.state.has( 'silent-update-processing' ) && api.state( 'silent-update-processing' )() )
14984
  return;
15030
  _getControlDeps : function() {
15031
  return {};
15032
  },
15033
+
15034
+
15035
+ //@return a visibility ready object of param describing the dependencies between a dominus and its servi.
15036
+ //this.defaultDominusParams = {
15037
+ // dominus : '',
15038
+ // servi : [],
15039
+ // visibility : fn() {},
15040
+ // actions : fn() {},
15041
+ // onSectionExpand : true
15042
+ // };
15043
  _prepareDominusParams : function( params_candidate ) {
15044
  var self = this,
15045
  _ready_params = {};
15046
+
15047
+ //Check mandatory conditions
15048
  if ( ! _.isObject( params_candidate ) ) {
15049
  api.errorLog( 'Visibilities : a dominus param definition must be an object.');
15050
  return _ready_params;
15107
  _handleFaviconNote : function() {
15108
  var self = this,
15109
  _fav_setId = api.CZR_Helpers.build_setId( serverControlParams.faviconOptionName );
15110
+ //do nothing if (||)
15111
+ //1) WP version < 4.3 where site icon has been introduced
15112
+ //2) User had not defined a favicon
15113
+ //3) User has already set WP site icon
15114
  if ( ! api.has('site_icon') || ! api.control('site_icon') || ( api.has( _fav_setId ) && 0 === + api( _fav_setId )() ) || + api('site_icon')() > 0 )
15115
  return;
15116
 
15117
  var _oldDes = api.control('site_icon').params.description;
15118
  _newDes = ['<strong>' , i18n.faviconNote || '' , '</strong><br/><br/>' ].join('') + _oldDes;
15119
+
15120
+ //on api ready
15121
  self._printFaviconNote(_newDes );
15122
+
15123
+ //on site icon change
15124
  api('site_icon').callbacks.add( function(to) {
15125
  if ( +to > 0 ) {
15126
+ //reset the description to default
15127
  api.control('site_icon').container.find('.description').text(_oldDes);
15128
+ //reset the previous favicon setting
15129
  if ( api.has( _fav_setId ) )
15130
  api( _fav_setId ).set("");
15131
  }
15134
  }
15135
  });
15136
  },
15137
+
15138
+ //Add a note to the WP control description if user has already defined a favicon
15139
  _printFaviconNote : function( _newDes ) {
15140
  api.control('site_icon').container.find('.description').html(_newDes);
15141
  }
15142
  }
15143
  );//api.Class.extend() //api.CZR_ctrlDependencies
15144
  })( wp.customize, jQuery, _);
15145
+ //DOM READY :
15146
+ //1) FIRE SPECIFIC INPUT PLUGINS
15147
+ //2) ADD SOME COOL STUFFS
15148
+ //3) SPECIFIC CONTROLS ACTIONS
15149
  ( function ( wp, $ ) {
15150
  $( function($) {
15151
  var api = wp.customize || api;
15152
 
15153
+ //WHAT IS HAPPENING IN THE MESSENGER
15154
+ // $(window.parent).on( 'message', function(e, o) {
15155
+ // api.consoleLog('SENT STUFFS', JSON.parse( e.originalEvent.data), e );
15156
+ // });
15157
+ // $( window ).on( 'message', function(e, o) {
15158
+ // api.consoleLog('INCOMING MESSAGE', JSON.parse( e.originalEvent.data), e );
15159
+ // });
15160
+ // $(window.document).bind("ajaxSend", function(e, o){
15161
+ // api.consoleLog('AJAX SEND', e, arguments );
15162
+ // }).bind("ajaxComplete", function(e, o){
15163
+ // api.consoleLog('AJAX COMPLETE', e, o);
15164
+ // });
15165
+
15166
  /* RECENTER CURRENT SECTIONS */
15167
  $('.accordion-section').not('.control-panel').click( function () {
15168
  _recenter_current_section($(this));
15170
 
15171
  function _recenter_current_section( section ) {
15172
  var $siblings = section.siblings( '.open' );
15173
+ //check if clicked element is above or below sibling with offset.top
15174
  if ( 0 !== $siblings.length && $siblings.offset().top < 0 ) {
15175
  $('.wp-full-overlay-sidebar-content').animate({
15176
  scrollTop: - $('#customize-theme-controls').offset().top - $siblings.height() + section.offset().top + $('.wp-full-overlay-sidebar-content').offset().top
15183
  api.czrSetupCheckbox = function( controlId, refresh ) {
15184
  var _ctrl = api.control( controlId );
15185
  $('input[type=checkbox]', _ctrl.container ).each( function() {
15186
+ //Exclude font customizer
15187
  if ( 'tc_font_customizer_settings' == _ctrl.params.section )
15188
  return;
15189
+ //first fix the checked / unchecked status
15190
  if ( 0 === $(this).val() || '0' == $(this).val() || 'off' == $(this).val() || _.isEmpty($(this).val() ) ) {
15191
  $(this).prop('checked', false);
15192
  } else {
15193
  $(this).prop('checked', true);
15194
  }
15195
+
15196
+ //then render icheck if not done already
15197
  if ( 0 !== $(this).closest('div[class^="icheckbox"]').length )
15198
  return;
15199
 
15200
  $(this).iCheck({
15201
  checkboxClass: 'icheckbox_flat-grey',
15202
+ //checkedClass: 'checked',
15203
  radioClass: 'iradio_flat-grey',
15204
  })
15205
  .on( 'ifChanged', function(e){
15211
 
15212
  /* SELECT INPUT */
15213
  api.czrSetupSelect = function(controlId, refresh) {
15214
+ //Exclude no-selecter-js
15215
  $('select[data-customize-setting-link]', api.control(controlId).container )
15216
  .not('.no-selecter-js')
15217
  .each( function() {
15218
  $(this).selecter({
15219
+ //triggers a change event on the view, passing the newly selected value + index as parameters.
15220
+ // callback : function(value, index) {
15221
+ // self.triggerSettingChange( window.event || {} , value, index); // first param is a null event.
15222
+ // }
15223
  });
15224
  });
15225
  };//api.czrSetupSelect()
15227
 
15228
  /* NUMBER INPUT */
15229
  api.czrSetupStepper = function( controlId, refresh ) {
15230
+ //Exclude no-selecter-js
15231
  var _ctrl = api.control( controlId );
15232
+ $('input[type="number"]', _ctrl.container ).each( function() { $(this).stepper(); });
 
 
 
 
15233
  };//api.czrSetupStepper()
15234
 
15235
+ // LOOP ON EACH CONTROL REGISTERED AND INSTANTIATE THE PLUGINS
15236
+ // @todo => react on control added
15237
+ api.control.each( function( control ){
15238
+ if ( ! _.has( control, 'id' ) )
15239
  return;
15240
+ //exclude widget controls and menu controls for checkboxes
15241
  if ( 'widget_' != control.id.substring(0, 'widget_'.length ) && 'nav_menu' != control.id.substring( 0, 'nav_menu'.length ) ) {
15242
  api.czrSetupCheckbox(control.id);
15243
  }
15244
  if ( 'nav_menu_locations' != control.id.substring( 0, 'nav_menu_locations'.length ) ) {
15245
  api.czrSetupSelect(control.id);
15246
  }
15247
+
15248
+ // Stepper : exclude controls from specific sections
15249
+ var _exclude = [
15250
+ 'publish_settings', //<= the outer section introduced in v4.9 to publish / saved draft / schedule
15251
+ 'tc_font_customizer_settings' //the font customizer plugin has its own way to instantiate the stepper, with custom attributes previously set to the input like step, min, etc...
15252
+ ];
15253
+
15254
+ if ( 0 < control.container.find( 'input[type="number"]' ).length && control.params && control.params.section && ! _.contains( _exclude, control.params.section ) ) {
15255
+ api.czrSetupStepper(control.id);
15256
+ }
15257
  });
15258
 
15259
 
15270
  event.preventDefault();
15271
  })
15272
  .on( 'click.customize-controls-home', function() {
15273
+ //event.preventDefault();
15274
+ //close everything
15275
  if ( api.section.has( api.czr_activeSectionId() ) ) {
15276
  api.section( api.czr_activeSectionId() ).expanded( false );
15277
  } else {
addons/assets/czr/js/czr-control-base.min.js CHANGED
@@ -8,10 +8,17 @@ Array.from||(Array.from=function(){var a=Object.prototype.toString,b=function(b)
8
  "function"!=typeof jQuery.fn.iCheck&&!function(a){function b(a,b,e){var f=a[0],g=/er/.test(e)?p:/bl/.test(e)?n:l,h=e==q?{checked:f[l],disabled:f[n],indeterminate:"true"==a.attr(p)||"false"==a.attr(o)}:f[g];if(/^(ch|di|in)/.test(e)&&!h)c(a,g);else if(/^(un|en|de)/.test(e)&&h)d(a,g);else if(e==q)for(g in h)h[g]?c(a,g,!0):d(a,g,!0);else b&&"toggle"!=e||(b||a[u]("ifClicked"),h?f[r]!==k&&d(a,g):c(a,g))}function c(b,c,e){var q=b[0],u=b.parent(),v=c==l,x=c==p,y=c==n,z=x?o:v?m:"enabled",A=f(b,z+g(q[r])),B=f(b,c+g(q[r]));if(!0!==q[c]){if(!e&&c==l&&q[r]==k&&q.name){var C=b.closest("form"),D='input[name="'+q.name+'"]',D=C.length?C.find(D):a(D);D.each(function(){this!==q&&a(this).data(i)&&d(a(this),c)})}x?(q[c]=!0,q[l]&&d(b,l,"force")):(e||(q[c]=!0),v&&q[p]&&d(b,p,!1)),h(b,v,c,e)}q[n]&&f(b,w,!0)&&u.find("."+j).css(w,"default"),u[s](B||f(b,c)||""),y?u.attr("aria-disabled","true"):u.attr("aria-checked",x?"mixed":"true"),u[t](A||f(b,z)||"")}function d(a,b,c){var d=a[0],e=a.parent(),i=b==l,k=b==p,q=b==n,u=k?o:i?m:"enabled",v=f(a,u+g(d[r])),x=f(a,b+g(d[r]));!1!==d[b]&&((k||!c||"force"==c)&&(d[b]=!1),h(a,i,u,c)),!d[n]&&f(a,w,!0)&&e.find("."+j).css(w,"pointer"),e[t](x||f(a,b)||""),q?e.attr("aria-disabled","false"):e.attr("aria-checked","false"),e[s](v||f(a,u)||"")}function e(b,c){b.data(i)&&(b.parent().html(b.attr("style",b.data(i).s||"")),c&&b[u](c),b.off(".i").unwrap(),a(v+'[for="'+b[0].id+'"]').add(b.closest(v)).off(".i"))}function f(a,b,c){return a.data(i)?a.data(i).o[b+(c?"":"Class")]:void 0}function g(a){return a.charAt(0).toUpperCase()+a.slice(1)}function h(a,b,c,d){d||(b&&a[u]("ifToggled"),a[u]("ifChanged")[u]("if"+g(c)))}var i="iCheck",j=i+"-helper",k="radio",l="checked",m="un"+l,n="disabled",o="determinate",p="in"+o,q="update",r="type",s="addClass",t="removeClass",u="trigger",v="label",w="cursor",x=/ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);a.fn[i]=function(f,g){var h='input[type="checkbox"], input[type="'+k+'"]',m=a(),o=function(b){b.each(function(){var b=a(this);m=b.is(h)?m.add(b):m.add(b.find(h))})};if(/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(f))return f=f.toLowerCase(),o(this),m.each(function(){var c=a(this);"destroy"==f?e(c,"ifDestroyed"):b(c,!0,f),a.isFunction(g)&&g()});if("object"!=typeof f&&f)return this;var w=a.extend({checkedClass:l,disabledClass:n,indeterminateClass:p,labelHover:!0,aria:!1},f),y=w.handle,z=w.hoverClass||"hover",A=w.focusClass||"focus",B=w.activeClass||"active",C=!!w.labelHover,D=w.labelHoverClass||"hover",E=0|(""+w.increaseArea).replace("%","");return("checkbox"==y||y==k)&&(h='input[type="'+y+'"]'),-50>E&&(E=-50),o(this),m.each(function(){var f=a(this);e(f);var g=this,h=g.id,m=-E+"%",o=100+2*E+"%",o={position:"absolute",top:m,left:m,display:"block",width:o,height:o,margin:0,padding:0,background:"#fff",border:0,opacity:0},m=x?{position:"absolute",visibility:"hidden"}:E?o:{position:"absolute",opacity:0},p="checkbox"==g[r]?w.checkboxClass||"icheckbox":w.radioClass||"i"+k,y=a(v+'[for="'+h+'"]').add(f.closest(v)),F=!!w.aria,G=i+"-"+Math.random().toString(36).substr(2,6),H='<div class="'+p+'" '+(F?'role="'+g[r]+'" ':"");F&&y.each(function(){H+='aria-labelledby="',this.id?H+=this.id:(this.id=G,H+=G),H+='"'}),H=f.wrap(H+"/>")[u]("ifCreated").parent().append(w.insert),o=a('<ins class="'+j+'"/>').css(o).appendTo(H),f.data(i,{o:w,s:f.attr("style")}).css(m),w.inheritClass&&H[s](g.className||""),w.inheritID&&h&&H.attr("id",i+"-"+h),"static"==H.css("position")&&H.css("position","relative"),b(f,!0,q),y.length&&y.on("click.i mouseover.i mouseout.i touchbegin.i touchend.i",function(c){var d=c[r],e=a(this);if(!g[n]){if("click"==d){if(a(c.target).is("a"))return;b(f,!1,!0)}else C&&(/ut|nd/.test(d)?(H[t](z),e[t](D)):(H[s](z),e[s](D)));if(!x)return!1;c.stopPropagation()}}),f.on("click.i focus.i blur.i keyup.i keydown.i keypress.i",function(a){var b=a[r];return a=a.keyCode,"click"!=b&&("keydown"==b&&32==a?(g[r]==k&&g[l]||(g[l]?d(f,l):c(f,l)),!1):void("keyup"==b&&g[r]==k?!g[l]&&c(f,l):/us|ur/.test(b)&&H["blur"==b?t:s](A)))}),o.on("click mousedown mouseup mouseover mouseout touchbegin.i touchend.i",function(a){var c=a[r],d=/wn|up/.test(c)?B:z;if(!g[n]){if("click"==c?b(f,!1,!0):(/wn|er|in/.test(c)?H[s](d):H[t](d+" "+B),y.length&&C&&d==z&&y[/ut|nd/.test(c)?t:s](D)),!x)return!1;a.stopPropagation()}})})}}(window.jQuery||window.Zepto),"function"!=typeof jQuery.fn.selecter&&!function(a,b){"use strict";function c(b){b=a.extend({},x,b||{}),null===w&&(w=a("body"));for(var c=a(this),e=0,f=c.length;f>e;e++)d(c.eq(e),b);return c}function d(b,c){if(!b.hasClass("selecter-element")){c=a.extend({},c,b.data("selecter-options")),c.external&&(c.links=!0);var d=b.find("option, optgroup"),g=d.filter("option"),h=g.filter(":selected"),n=""!==c.label?-1:g.index(h),p=c.links?"nav":"div";c.tabIndex=b[0].tabIndex,b[0].tabIndex=-1,c.multiple=b.prop("multiple"),c.disabled=b.is(":disabled");var q="<"+p+' class="selecter '+c.customClass;v?q+=" mobile":c.cover&&(q+=" cover"),q+=c.multiple?" multiple":" closed",c.disabled&&(q+=" disabled"),q+='" tabindex="'+c.tabIndex+'">',c.multiple||(q+='<span class="selecter-selected'+(""!==c.label?" placeholder":"")+'">',q+=a("<span></span").text(r(""!==c.label?c.label:h.text(),c.trim)).html(),q+="</span>"),q+='<div class="selecter-options">',q+="</div>",q+="</"+p+">",b.addClass("selecter-element").after(q);var s=b.next(".selecter"),u=a.extend({$select:b,$allOptions:d,$options:g,$selecter:s,$selected:s.find(".selecter-selected"),$itemsWrapper:s.find(".selecter-options"),index:-1,guid:t++},c);e(u),o(n,u),void 0!==a.fn.scroller&&u.$itemsWrapper.scroller(),u.$selecter.on("touchstart.selecter click.selecter",".selecter-selected",u,f).on("click.selecter",".selecter-item",u,j).on("close.selecter",u,i).data("selecter",u),u.$select.on("change.selecter",u,k),v||(u.$selecter.on("focus.selecter",u,l).on("blur.selecter",u,m),u.$select.on("focus.selecter",u,function(a){a.data.$selecter.trigger("focus")}))}}function e(b){for(var c="",d=b.links?"a":"span",e=0,f=0,g=b.$allOptions.length;g>f;f++){var h=b.$allOptions.eq(f);if("OPTGROUP"===h[0].tagName)c+='<span class="selecter-group',h.is(":disabled")&&(c+=" disabled"),c+='">'+h.attr("label")+"</span>";else{var i=h.val();h.attr("value")||h.attr("value",i),c+="<"+d+' class="selecter-item',h.is(":selected")&&""===b.label&&(c+=" selected"),h.is(":disabled")&&(c+=" disabled"),c+='" ',c+=b.links?'href="'+i+'"':'data-value="'+i+'"',c+=">"+a("<span></span>").text(r(h.text(),b.trim)).html()+"</"+d+">",e++}}b.$itemsWrapper.html(c),b.$items=b.$selecter.find(".selecter-item")}function f(c){c.preventDefault(),c.stopPropagation();var d=c.data;if(!d.$select.is(":disabled"))if(a(".selecter").not(d.$selecter).trigger("close.selecter",[d]),v){var e=d.$select[0];if(b.document.createEvent){var f=b.document.createEvent("MouseEvents");f.initMouseEvent("mousedown",!1,!0,b,0,0,0,0,0,!1,!1,!1,!1,0,null),e.dispatchEvent(f)}else e.fireEvent&&e.fireEvent("onmousedown")}else d.$selecter.hasClass("closed")?g(c):d.$selecter.hasClass("open")&&i(c)}function g(b){b.preventDefault(),b.stopPropagation();var c=b.data;if(!c.$selecter.hasClass("open")){var d=c.$selecter.offset(),e=w.outerHeight(),f=c.$itemsWrapper.outerHeight(!0),g=c.index>=0?c.$items.eq(c.index).position():{left:0,top:0};d.top+f>e&&c.$selecter.addClass("bottom"),c.$itemsWrapper.show(),c.$selecter.removeClass("closed").addClass("open"),w.on("click.selecter-"+c.guid,":not(.selecter-options)",c,h),void 0!==a.fn.scroller?c.$itemsWrapper.scroller("scroll",c.$itemsWrapper.find(".scroller-content").scrollTop()+g.top,0).scroller("reset"):c.$itemsWrapper.scrollTop(c.$itemsWrapper.scrollTop()+g.top)}}function h(b){b.preventDefault(),b.stopPropagation(),0===a(b.currentTarget).parents(".selecter").length&&i(b)}function i(a){a.preventDefault(),a.stopPropagation();var b=a.data;b.$selecter.hasClass("open")&&(b.$itemsWrapper.hide(),b.$selecter.removeClass("open bottom").addClass("closed"),w.off(".selecter-"+b.guid))}function j(b){b.preventDefault(),b.stopPropagation();var c=a(this),d=b.data;if(!d.$select.is(":disabled")){if(d.$itemsWrapper.is(":visible")){var e=d.$items.index(c);o(e,d),p(d)}d.multiple||i(b)}}function k(b,c){var d=a(this),e=b.data;if(!c&&!e.multiple){var f=e.$options.index(e.$options.filter("[value='"+s(d.val())+"']"));o(f,e),p(e)}}function l(b){b.preventDefault(),b.stopPropagation();var c=b.data;c.$select.is(":disabled")||c.multiple||(c.$selecter.addClass("focus").on("keydown.selecter"+c.guid,c,n),a(".selecter").not(c.$selecter).trigger("close.selecter",[c]))}function m(b){b.preventDefault(),b.stopPropagation();var c=b.data;c.$selecter.removeClass("focus").off("keydown.selecter"+c.guid+" keyup.selecter"+c.guid),a(".selecter").not(c.$selecter).trigger("close.selecter",[c])}function n(b){var c=b.data;if(13===b.keyCode)c.$selecter.hasClass("open")&&(i(b),o(c.index,c)),p(c);else if(!(9===b.keyCode||b.metaKey||b.altKey||b.ctrlKey||b.shiftKey)){b.preventDefault(),b.stopPropagation();var d=c.$items.length-1,e=c.index<0?0:c.index;if(a.inArray(b.keyCode,u?[38,40,37,39]:[38,40])>-1)e+=38===b.keyCode||u&&37===b.keyCode?-1:1,0>e&&(e=0),e>d&&(e=d);else{var f,g,h=String.fromCharCode(b.keyCode).toUpperCase();for(g=c.index+1;d>=g;g++)if(f=c.$options.eq(g).text().charAt(0).toUpperCase(),f===h){e=g;break}if(0>e)for(g=0;d>=g;g++)if(f=c.$options.eq(g).text().charAt(0).toUpperCase(),f===h){e=g;break}}e>=0&&o(e,c)}}function o(a,b){var c=b.$items.eq(a),d=c.hasClass("selected"),e=c.hasClass("disabled");if(!e){if(-1===a&&""!==b.label)b.$selected.html(b.label);else if(d)b.multiple&&(b.$options.eq(a).prop("selected",null),c.removeClass("selected"));else{var f=c.html();c.data("value"),b.multiple?b.$options.eq(a).prop("selected",!0):(b.$selected.html(f).removeClass("placeholder"),b.$items.filter(".selected").removeClass("selected"),b.$select[0].selectedIndex=a),c.addClass("selected")}(!d||b.multiple)&&(b.index=a)}}function p(a){a.links?q(a):(a.callback.call(a.$selecter,a.$select.val(),a.index),a.$select.trigger("change",[!0]))}function q(a){var c=a.$select.val();a.external?b.open(c):b.location.href=c}function r(a,b){return 0===b?a:a.length>b?a.substring(0,b)+"...":a}function s(a){return a.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1")}var t=0,u=b.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,v=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(b.navigator.userAgent||b.navigator.vendor||b.opera),w=null,x={callback:a.noop,cover:!1,customClass:"",label:"",external:!1,links:!1,trim:0},y={defaults:function(b){return x=a.extend(x,b||{}),a(this)},disable:function(b){return a(this).each(function(c,d){var e=a(d).next(".selecter").data("selecter");if(e)if("undefined"!=typeof b){var f=e.$items.index(e.$items.filter("[data-value="+b+"]"));e.$items.eq(f).addClass("disabled"),e.$options.eq(f).prop("disabled",!0)}else e.$selecter.hasClass("open")&&e.$selecter.find(".selecter-selected").trigger("click.selecter"),e.$selecter.addClass("disabled"),e.$select.prop("disabled",!0)})},enable:function(b){return a(this).each(function(c,d){var e=a(d).next(".selecter").data("selecter");if(e)if("undefined"!=typeof b){var f=e.$items.index(e.$items.filter("[data-value="+b+"]"));e.$items.eq(f).removeClass("disabled"),e.$options.eq(f).prop("disabled",!1)}else e.$selecter.removeClass("disabled"),e.$select.prop("disabled",!1)})},destroy:function(){return a(this).each(function(b,c){var d=a(c).next(".selecter").data("selecter");d&&(d.$selecter.hasClass("open")&&d.$selecter.find(".selecter-selected").trigger("click.selecter"),void 0!==a.fn.scroller&&d.$selecter.find(".selecter-options").scroller("destroy"),d.$select[0].tabIndex=d.tabIndex,d.$select.off(".selecter").removeClass("selecter-element").show(),d.$selecter.off(".selecter").remove())})},refresh:function(){return a(this).each(function(b,c){var d=a(c).next(".selecter").data("selecter");if(d){var f=d.index;d.$allOptions=d.$select.find("option, optgroup"),d.$options=d.$allOptions.filter("option"),d.index=-1,f=d.$options.index(d.$options.filter(":selected")),e(d),o(f,d)}})}};a.fn.selecter=function(a){return y[a]?y[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:c.apply(this,arguments)},a.selecter=function(a){"defaults"===a&&y.defaults.apply(this,Array.prototype.slice.call(arguments,1))}}(jQuery,window),"function"!=typeof jQuery.fn.stepper&&!function(a){"use strict";function b(b){b=a.extend({},k,b||{});for(var d=a(this),e=0,f=d.length;f>e;e++)c(d.eq(e),b);return d}function c(b,c){if(!b.hasClass("stepper-input")){c=a.extend({},c,b.data("stepper-options"));var e=parseFloat(b.attr("min")),f=parseFloat(b.attr("max")),g=parseFloat(b.attr("step"))||1;b.addClass("stepper-input").wrap('<div class="stepper '+c.customClass+'" />').after('<span class="stepper-arrow up">'+c.labels.up+'</span><span class="stepper-arrow down">'+c.labels.down+"</span>");var h=b.parent(".stepper"),j=a.extend({$stepper:h,$input:b,$arrow:h.find(".stepper-arrow"),min:void 0!==typeof e&&!isNaN(e)&&e,max:void 0!==typeof f&&!isNaN(f)&&f,step:void 0===typeof g||isNaN(g)?1:g,timer:null},c);j.digits=i(j.step),b.is(":disabled")&&h.addClass("disabled"),h.on("touchstart.stepper mousedown.stepper",".stepper-arrow",j,d).data("stepper",j)}}function d(b){b.preventDefault(),b.stopPropagation(),e(b);var c=b.data;if(!c.$input.is(":disabled")&&!c.$stepper.hasClass("disabled")){var d=a(b.target).hasClass("up")?c.step:-c.step;c.timer=g(c.timer,125,function(){f(c,d,!1)}),f(c,d),a("body").on("touchend.stepper mouseup.stepper",c,e)}}function e(b){b.preventDefault(),b.stopPropagation();var c=b.data;h(c.timer),a("body").off(".stepper")}function f(a,b){var c=parseFloat(a.$input.val()),d=b;void 0===typeof c||isNaN(c)?d=a.min!==!1?a.min:0:a.min!==!1&&c<a.min?d=a.min:d+=c;var e=(d-a.min)%a.step;0!==e&&(d-=e),a.min!==!1&&d<a.min&&(d=a.min),a.max!==!1&&d>a.max&&(d-=a.step),d!==c&&(d=j(d,a.digits),a.$input.val(d).trigger("change"))}function g(a,b,c){return h(a),setInterval(c,b)}function h(a){a&&(clearInterval(a),a=null)}function i(a){var b=String(a);return b.indexOf(".")>-1?b.length-b.indexOf(".")-1:0}function j(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c}var k={customClass:"",labels:{up:"Up",down:"Down"}},l={defaults:function(b){return k=a.extend(k,b||{}),a(this)},destroy:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$stepper.off(".stepper").find(".stepper-arrow").remove(),b.$input.unwrap().removeClass("stepper-input"))})},disable:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$input.attr("disabled","disabled"),b.$stepper.addClass("disabled"))})},enable:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$input.attr("disabled",null),b.$stepper.removeClass("disabled"))})}};a.fn.stepper=function(a){return l[a]?l[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:b.apply(this,arguments)},a.stepper=function(a){"defaults"===a&&l.defaults.apply(this,Array.prototype.slice.call(arguments,1))}}(jQuery,this),/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n<c.length;n+=1)if(m=o(c[n],f),k=m.f,"require"===k)u[n]=p.require(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=d?d.apply(q[a],u):void 0,a&&(h&&h.exports!==b&&h.exports!==q[a]?q[a]=h.exports:l===b&&s||(q[a]=l))}else a&&(q[a]=d)},a=c=n=function(a,c,d,e,f){if("string"==typeof a)return p[a]?p[a](c):j(o(a,c).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!c)return;c.splice?(a=c,c=d,d=null):a=b}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?m(b,a,c,d):setTimeout(function(){m(b,a,c,d)},4),n},n.config=function(a){return n(a)},a._defined=q,d=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},d.amd={jQuery:!0}}(),b.requirejs=a,b.require=c,b.define=d}}(),b.define("almond",function(){}),b.define("jquery",[],function(){var b=a||$;return null==b&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),b}),b.define("select2/utils",["jquery"],function(a){function b(a){var b=a.prototype,c=[];for(var d in b){var e=b[d];"function"==typeof e&&"constructor"!==d&&c.push(d)}return c}var c={};c.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},c.Decorate=function(a,c){function d(){var b=Array.prototype.unshift,d=c.prototype.constructor.length,e=a.prototype.constructor;d>0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=a.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){var a=Array.prototype.unshift;return a.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var d=function(){this.listeners={}};return d.prototype.on=function(a,b){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},d.prototype.trigger=function(a){var b=Array.prototype.slice,c=b.call(arguments,1);this.listeners=this.listeners||{},null==c&&(c=[]),0===c.length&&c.push({}),c[0]._type=a,a in this.listeners&&this.invoke(this.listeners[a],b.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},d.prototype.invoke=function(a,b){for(var c=0,d=a.length;d>c;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e<c.length;e++){var f=c[e];f=f.substring(0,1).toLowerCase()+f.substring(1),f in d||(d[f]={}),e==c.length-1&&(d[f]=a[b]),d=d[f]}delete a[b]}}return a},c.hasScroll=function(b,c){var d=a(c),e=c.style.overflowX,f=c.style.overflowY;return(e!==f||"hidden"!==f&&"visible"!==f)&&("scroll"===e||"scroll"===f||(d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth))},c.escapeMarkup=function(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<ul class="select2-results__options" role="tree"></ul>');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('<li role="treeitem" aria-live="assertive" class="select2-results__option"></li>'),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c<a.results.length;c++){var d=a.results[c],e=this.option(d);b.push(e)}this.$results.append(b)},c.prototype.position=function(a,b){var c=b.find(".select2-results");c.append(a)},c.prototype.sort=function(a){var b=this.options.get("sorter");return b(a)},c.prototype.highlightFirstItem=function(){var a=this.$results.find(".select2-results__option[aria-selected]"),b=a.filter("[aria-selected=true]");b.length>0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group",a(h),this.template(b,h);for(var i=[],j=0;j<b.children.length;j++){var k=b.children[j],l=this.option(k);i.push(l)}var m=a("<ul></ul>",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("<span></span>")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){
9
  function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('<ul class="select2-selection__rendered"></ul>'),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">&times;</span></li>');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d<a.length;d++){var e=a[d],f=this.selectionContainer(),g=this.display(e,f);f.append(g),f.prop("title",e.title||e.text),f.data("data",e),b.push(f)}var h=this.$selection.find(".select2-selection__rendered");c.appendMany(h,b)}},d}),b.define("select2/selection/placeholder",["../utils"],function(a){function b(a,b,c){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c)}return b.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},b.prototype.createPlaceholder=function(a,b){var c=this.selectionContainer();return c.html(this.display(b)),c.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),c},b.prototype.update=function(a,b){var c=1==b.length&&b[0].id!=this.placeholder.id,d=b.length>1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e<d.length;e++){var f={data:d[e]};if(this.trigger("unselect",f),f.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},c.prototype._handleKeyboardClear=function(a,c,d){d.isOpen()||(c.which==b.DELETE||c.which==b.BACKSPACE)&&this._handleClear(c)},c.prototype.update=function(b,c){if(b.call(this,c),!(this.$selection.find(".select2-selection__placeholder").length>0||0===c.length)){var d=a('<span class="select2-selection__clear">&times;</span>');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f<a.length;f++){var g=a[f].id;-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")});else{var d=a.id;this.$element.val(d),this.$element.trigger("change")}},d.prototype.unselect=function(a){var b=this;if(this.$element.prop("multiple"))return a.selected=!1,c(a.element).is("option")?(a.element.selected=!1,void this.$element.trigger("change")):void this.current(function(d){for(var e=[],f=0;f<d.length;f++){var g=d[f].id;g!==a.id&&-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")})},d.prototype.bind=function(a,b){var c=this;this.container=a,a.on("select",function(a){c.select(a.data)}),a.on("unselect",function(a){c.unselect(a.data)})},d.prototype.destroy=function(){this.$element.find("*").each(function(){c.removeData(this,"data")})},d.prototype.query=function(a,b){var d=[],e=this,f=this.$element.children();f.each(function(){var b=c(this);if(b.is("option")||b.is("optgroup")){var f=e.item(b),g=e.matches(a,f);null!==g&&d.push(g)}}),b({results:d})},d.prototype.addOptions=function(a){b.appendMany(this.$element,a)},d.prototype.option=function(a){var b;a.children?(b=document.createElement("optgroup"),b.label=a.text):(b=document.createElement("option"),void 0!==b.textContent?b.textContent=a.text:b.innerText=a.text),a.id&&(b.value=a.id),a.disabled&&(b.disabled=!0),a.selected&&(b.selected=!0),a.title&&(b.title=a.title);var d=c(b),e=this._normalizeItem(a);return e.element=b,c.data(b,"data",e),d},d.prototype.item=function(a){var b={};if(b=c.data(a[0],"data"),null!=b)return b;if(a.is("option"))b={id:a.val(),text:a.text(),disabled:a.prop("disabled"),selected:a.prop("selected"),title:a.prop("title")};else if(a.is("optgroup")){b={text:a.prop("label"),children:[],title:a.prop("title")};for(var d=a.children("option"),e=[],f=0;f<d.length;f++){var g=c(d[f]),h=this.item(g);e.push(h)}b.children=e}return b=this._normalizeItem(b),b.element=a[0],c.data(a[0],"data",b),b},d.prototype._normalizeItem=function(a){c.isPlainObject(a)||(a={id:a,text:a}),a=c.extend({},{text:""},a);var b={selected:!1,disabled:!1};return null!=a.id&&(a.id=a.id.toString()),null!=a.text&&(a.text=a.text.toString()),null==a._resultId&&a.id&&null!=this.container&&(a._resultId=this.generateResultId(this.container,a)),c.extend({},b,a)},d.prototype.matches=function(a,b){var c=this.options.get("matcher");return c(a,b)},d}),b.define("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){var c=b.get("data")||[];d.__super__.constructor.call(this,a,b),this.addOptions(this.convertToOptions(c))}return b.Extend(d,a),d.prototype.select=function(a){var b=this.$element.find("option").filter(function(b,c){return c.value==a.id.toString()});0===b.length&&(b=this.option(a),this.addOptions(b)),d.__super__.select.call(this,a)},d.prototype.convertToOptions=function(a){function d(a){return function(){return c(this).val()==a.id}}for(var e=this,f=this.$element.find("option"),g=f.map(function(){return e.item(c(this)).id}).get(),h=[],i=0;i<a.length;i++){var j=this._normalizeItem(a[i]);if(c.inArray(j.id,g)>=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h<e.length;h++){var i=e[h],j=this._normalizeItem(i),k=this.option(j);this.$element.append(k)}}return b.prototype.query=function(a,b,c){function d(a,f){for(var g=a.results,h=0;h<g.length;h++){var i=g[h],j=null!=i.children&&!d({results:i.children},!0),k=i.text===b.term;if(k||j)return!f&&(a.data=g,void c(a))}if(f)return!0;var l=e.createTag(b);if(null!=l){var m=e.option(l);m.attr("data-select2-tag",!0),e.addOptions([m]),e.insertTag(g,l)}a.results=g,c(a)}var e=this;return this._removeOldTags(),null==b.term||null!=b.page?void a.call(this,b,c):void a.call(this,b,d)},b.prototype.createTag=function(b,c){var d=a.trim(c.term);return""===d?null:{id:d,text:d}},b.prototype.insertTag=function(a,b,c){b.unshift(c)},b.prototype._removeOldTags=function(b){var c=(this._lastTag,this.$element.find("option[data-select2-tag]"));c.each(function(){this.selected||a(this).remove()})},b}),b.define("select2/data/tokenizer",["jquery"],function(a){function b(a,b,c){var d=c.get("tokenizer");void 0!==d&&(this.tokenizer=d),a.call(this,b,c)}return b.prototype.bind=function(a,b,c){a.call(this,b,c),this.$search=b.dropdown.$search||b.selection.$search||c.find(".select2-search__field")},b.prototype.query=function(b,c,d){function e(b){var c=g._normalizeItem(b),d=g.$element.find("option").filter(function(){return a(this).val()===c.id});if(!d.length){var e=g.option(c);e.attr("data-select2-tag",!0),g._removeOldTags(),g.addOptions([e])}f(c)}function f(a){g.trigger("select",{data:a})}var g=this;c.term=c.term||"";var h=this.tokenizer(c,this.options,e);h.term!==c.term&&(this.$search.length&&(this.$search.val(h.term),this.$search.focus()),c.term=h.term),b.call(this,c,d)},b.prototype.tokenizer=function(b,c,d,e){for(var f=d.get("tokenSeparators")||[],g=c.term,h=0,i=this.createTag||function(a){return{id:a.term,text:a.term}};h<g.length;){var j=g[h];if(-1!==a.inArray(j,f)){var k=g.substr(0,h),l=a.extend({},c,{term:k}),m=i(l);null!=m?(e(m),g=g.substr(h+1)||"",h=0):h++}else h++}return{term:g}},b}),b.define("select2/data/minimumInputLength",[],function(){function a(a,b,c){this.minimumInputLength=c.get("minimumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",b.term.length<this.minimumInputLength?void this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumInputLength",[],function(){function a(a,b,c){this.maximumInputLength=c.get("maximumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",this.maximumInputLength>0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<span class="select2-dropdown"><span class="select2-results"></span></span>');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('<li class="select2-results__option select2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a("<span></span>"),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.top<f.top-h.height,k=i.bottom>f.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d<b.length;d++){var e=b[d];e.children?c+=a(e.children):c++}return c}function b(a,b,c,d){this.minimumResultsForSearch=c.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),a.call(this,b,c,d)}return b.prototype.showSearch=function(b,c){return!(a(c.data.results)<this.minimumResultsForSearch)&&b.call(this,c)},b}),b.define("select2/dropdown/selectOnClose",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("close",function(a){d._handleSelectOnClose(a)})},a.prototype._handleSelectOnClose=function(a,b){if(b&&null!=b.originalSelect2Event){var c=b.originalSelect2Event;if("select"===c._type||"unselect"===c._type)return}var d=this.getHighlightedResults();if(!(d.length<1)){var e=d.data("data");null!=e.element&&e.element.selected||null==e.element&&e.selected||this.trigger("select",{data:e})}},a}),b.define("select2/dropdown/closeOnSelect",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("select",function(a){d._selectTriggered(a)}),b.on("unselect",function(a){d._selectTriggered(a)})},a.prototype._selectTriggered=function(a,b){var c=b.originalEvent;c&&c.ctrlKey||this.trigger("close",{originalEvent:c,originalSelect2Event:b})},a}),b.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(a){var b=a.input.length-a.maximum,c="Please delete "+b+" character";return 1!=b&&(c+="s"),c},inputTooShort:function(a){var b=a.minimum-a.input.length,c="Please enter "+b+" or more characters";return c},loadingMore:function(){return"Loading more results…"},maximumSelected:function(a){var b="You can only select "+a.maximum+" item";
10
  return 1!=a.maximum&&(b+="s"),b},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),b.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C){function D(){this.reset()}D.prototype.apply=function(l){if(l=a.extend(!0,{},this.defaults,l),null==l.dataAdapter){if(null!=l.ajax?l.dataAdapter=o:null!=l.data?l.dataAdapter=n:l.dataAdapter=m,l.minimumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L<K.length;L++){var M=K[L],N={};try{N=k.loadPath(M)}catch(O){try{M=this.defaults.amdLanguageBase+M,N=k.loadPath(M)}catch(P){l.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+M+'" could not be automatically loaded. A fallback will be used instead.');continue}}J.extend(N)}l.translations=J}else{var Q=k.loadPath(this.defaults.amdLanguageBase+"en"),R=new k(l.language);R.extend(Q),l.translations=R}return l},D.prototype.reset=function(){function b(a){function b(a){return l[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function c(d,e){if(""===a.trim(d.term))return e;if(e.children&&e.children.length>0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e<b.addedNodes.length;e++){var f=b.addedNodes[e];f.selected&&(c=!0)}else b.removedNodes&&b.removedNodes.length>0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},e.prototype.render=function(){var b=a('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("jquery-mousewheel",["jquery"],function(a){return a}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(a,b,c,d){if(null==a.fn.select2){var e=["open","close","destroy"];a.fn.select2=function(b){if(b=b||{},"object"==typeof b)return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,f=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=a(this).data("select2");null==c&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=c[b].apply(c,f)}),a.inArray(b,e)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c}),/*! rangeslider.js - v2.3.0 | (c) 2016 @andreruffert | MIT license | https://github.com/andreruffert/rangeslider.js */
11
- !function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){"use strict";function b(){var a=document.createElement("input");return a.setAttribute("type","range"),"text"!==a.type}function c(a,b){var c=Array.prototype.slice.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)}function d(a,b){return b=b||100,function(){if(!a.debouncing){var c=Array.prototype.slice.apply(arguments);a.lastReturnVal=a.apply(window,c),a.debouncing=!0}return clearTimeout(a.debounceTimeout),a.debounceTimeout=setTimeout(function(){a.debouncing=!1},b),a.lastReturnVal}}function e(a){return a&&(0===a.offsetWidth||0===a.offsetHeight||a.open===!1)}function f(a){for(var b=[],c=a.parentNode;e(c);)b.push(c),c=c.parentNode;return b}function g(a,b){function c(a){"undefined"!=typeof a.open&&(a.open=!a.open)}var d=f(a),e=d.length,g=[],h=a[b];if(e){for(var i=0;i<e;i++)g[i]=d[i].style.cssText,d[i].style.setProperty?d[i].style.setProperty("display","block","important"):d[i].style.cssText+=";display: block !important",d[i].style.height="0",d[i].style.overflow="hidden",d[i].style.visibility="hidden",c(d[i]);h=a[b];for(var j=0;j<e;j++)d[j].style.cssText=g[j],c(d[j])}return h}function h(a,b){var c=parseFloat(a);return Number.isNaN(c)?b:c}function i(a){return a.charAt(0).toUpperCase()+a.substr(1)}function j(b,e){if(this.$window=a(window),this.$document=a(document),this.$element=a(b),this.options=a.extend({},n,e),this.polyfill=this.options.polyfill,this.orientation=this.$element[0].getAttribute("data-orientation")||this.options.orientation,this.onInit=this.options.onInit,this.onSlide=this.options.onSlide,this.onSlideEnd=this.options.onSlideEnd,this.DIMENSION=o.orientation[this.orientation].dimension,this.DIRECTION=o.orientation[this.orientation].direction,this.DIRECTION_STYLE=o.orientation[this.orientation].directionStyle,this.COORDINATE=o.orientation[this.orientation].coordinate,this.polyfill&&m)return!1;this.identifier="js-"+k+"-"+l++,this.startEvent=this.options.startEvent.join("."+this.identifier+" ")+"."+this.identifier,this.moveEvent=this.options.moveEvent.join("."+this.identifier+" ")+"."+this.identifier,this.endEvent=this.options.endEvent.join("."+this.identifier+" ")+"."+this.identifier,this.toFixed=(this.step+"").replace(".","").length-1,this.$fill=a('<div class="'+this.options.fillClass+'" />'),this.$handle=a('<div class="'+this.options.handleClass+'" />'),this.$range=a('<div class="'+this.options.rangeClass+" "+this.options[this.orientation+"Class"]+'" id="'+this.identifier+'" />').insertAfter(this.$element).prepend(this.$fill,this.$handle),this.$element.css({position:"absolute",width:"1px",height:"1px",overflow:"hidden",opacity:"0"}),this.handleDown=a.proxy(this.handleDown,this),this.handleMove=a.proxy(this.handleMove,this),this.handleEnd=a.proxy(this.handleEnd,this),this.init();var f=this;this.$window.on("resize."+this.identifier,d(function(){c(function(){f.update(!1,!1)},300)},20)),this.$document.on(this.startEvent,"#"+this.identifier+":not(."+this.options.disabledClass+")",this.handleDown),this.$element.on("change."+this.identifier,function(a,b){if(!b||b.origin!==f.identifier){var c=a.target.value,d=f.getPositionFromValue(c);f.setPosition(d)}})}Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&a!==a};var k="rangeslider",l=0,m=b(),n={polyfill:!0,orientation:"horizontal",rangeClass:"rangeslider",disabledClass:"rangeslider--disabled",activeClass:"rangeslider--active",horizontalClass:"rangeslider--horizontal",verticalClass:"rangeslider--vertical",fillClass:"rangeslider__fill",handleClass:"rangeslider__handle",startEvent:["mousedown","touchstart","pointerdown"],moveEvent:["mousemove","touchmove","pointermove"],endEvent:["mouseup","touchend","pointerup"]},o={orientation:{horizontal:{dimension:"width",direction:"left",directionStyle:"left",coordinate:"x"},vertical:{dimension:"height",direction:"top",directionStyle:"bottom",coordinate:"y"}}};return j.prototype.init=function(){this.update(!0,!1),this.onInit&&"function"==typeof this.onInit&&this.onInit()},j.prototype.update=function(a,b){a=a||!1,a&&(this.min=h(this.$element[0].getAttribute("min"),0),this.max=h(this.$element[0].getAttribute("max"),100),this.value=h(this.$element[0].value,Math.round(this.min+(this.max-this.min)/2)),this.step=h(this.$element[0].getAttribute("step"),1)),this.handleDimension=g(this.$handle[0],"offset"+i(this.DIMENSION)),this.rangeDimension=g(this.$range[0],"offset"+i(this.DIMENSION)),this.maxHandlePos=this.rangeDimension-this.handleDimension,this.grabPos=this.handleDimension/2,this.position=this.getPositionFromValue(this.value),this.$element[0].disabled?this.$range.addClass(this.options.disabledClass):this.$range.removeClass(this.options.disabledClass),this.setPosition(this.position,b)},j.prototype.handleDown=function(a){if(a.preventDefault(),this.$document.on(this.moveEvent,this.handleMove),this.$document.on(this.endEvent,this.handleEnd),this.$range.addClass(this.options.activeClass),!((" "+a.target.className+" ").replace(/[\n\t]/g," ").indexOf(this.options.handleClass)>-1)){var b=this.getRelativePosition(a),c=this.$range[0].getBoundingClientRect()[this.DIRECTION],d=this.getPositionFromNode(this.$handle[0])-c,e="vertical"===this.orientation?this.maxHandlePos-(b-this.grabPos):b-this.grabPos;this.setPosition(e),b>=d&&b<d+this.handleDimension&&(this.grabPos=b-d)}},j.prototype.handleMove=function(a){a.preventDefault();var b=this.getRelativePosition(a),c="vertical"===this.orientation?this.maxHandlePos-(b-this.grabPos):b-this.grabPos;this.setPosition(c)},j.prototype.handleEnd=function(a){a.preventDefault(),this.$document.off(this.moveEvent,this.handleMove),this.$document.off(this.endEvent,this.handleEnd),this.$range.removeClass(this.options.activeClass),this.$element.trigger("change",{origin:this.identifier}),this.onSlideEnd&&"function"==typeof this.onSlideEnd&&this.onSlideEnd(this.position,this.value)},j.prototype.cap=function(a,b,c){return a<b?b:a>c?c:a},j.prototype.setPosition=function(a,b){var c,d;void 0===b&&(b=!0),c=this.getValueFromPosition(this.cap(a,0,this.maxHandlePos)),d=this.getPositionFromValue(c),this.$fill[0].style[this.DIMENSION]=d+this.grabPos+"px",this.$handle[0].style[this.DIRECTION_STYLE]=d+"px",this.setValue(c),this.position=d,this.value=c,b&&this.onSlide&&"function"==typeof this.onSlide&&this.onSlide(d,c)},j.prototype.getPositionFromNode=function(a){for(var b=0;null!==a;)b+=a.offsetLeft,a=a.offsetParent;return b},j.prototype.getRelativePosition=function(a){var b=i(this.COORDINATE),c=this.$range[0].getBoundingClientRect()[this.DIRECTION],d=0;return"undefined"!=typeof a.originalEvent["client"+b]?d=a.originalEvent["client"+b]:a.originalEvent.touches&&a.originalEvent.touches[0]&&"undefined"!=typeof a.originalEvent.touches[0]["client"+b]?d=a.originalEvent.touches[0]["client"+b]:a.currentPoint&&"undefined"!=typeof a.currentPoint[this.COORDINATE]&&(d=a.currentPoint[this.COORDINATE]),d-c},j.prototype.getPositionFromValue=function(a){var b,c;return b=(a-this.min)/(this.max-this.min),c=Number.isNaN(b)?0:b*this.maxHandlePos},j.prototype.getValueFromPosition=function(a){var b,c;return b=a/(this.maxHandlePos||1),c=this.step*Math.round(b*(this.max-this.min)/this.step)+this.min,Number(c.toFixed(this.toFixed))},j.prototype.setValue=function(a){a===this.value&&""!==this.$element[0].value||this.$element.val(a).trigger("input",{origin:this.identifier})},j.prototype.destroy=function(){this.$document.off("."+this.identifier),this.$window.off("."+this.identifier),this.$element.off("."+this.identifier).removeAttr("style").removeData("plugin_"+k),this.$range&&this.$range.length&&this.$range[0].parentNode.removeChild(this.$range[0])},a.fn[k]=function(b){var c=Array.prototype.slice.call(arguments,1);return this.each(function(){var d=a(this),e=d.data("plugin_"+k);e||d.data("plugin_"+k,e=new j(this,b)),"string"==typeof b&&e[b].apply(e,c)})},"rangeslider.js is available in jQuery context e.g $(selector).rangeslider(options);"}),function(a,b,c){a.bind("ready",function(){a.previewedDevice&&a.previewedDevice.bind(function(b){a.previewer.send("previewed-device",b)})})}(wp.customize,jQuery,_),function(a,b,c){var d=function(a){var b={bgCol:"#5ed1f5",textCol:"#000",consoleArguments:[]};a=c.extend(b,a);var d=Array.from(a.consoleArguments),e=function(a){return c.isString(a)?a.length>150?a.substr(0,149):a:""};return d=c.isEmpty(c.filter(d,function(a){return!c.isString(a)}))?d.join(" "):JSON.stringify(d.join(" ")),["%c "+e(d),["background:"+a.bgCol,"color:"+a.textCol,"display: block;"].join(";")]};a.consoleLog=function(){serverControlParams.isDevMode&&(c.isUndefined(console)&&"function"!=typeof window.console.log||console.log.apply(console,d({consoleArguments:arguments})))},a.errorLog=function(){c.isUndefined(console)&&"function"!=typeof window.console.log||console.log.apply(console,d({bgCol:"#ffd5a0",textCol:"#000",consoleArguments:arguments}))},a.czr_isSkopOn=function(){return serverControlParams.isSkopOn&&c.has(a,"czr_skopeBase")},a.czr_isChangeSetOn=function(){return serverControlParams.isChangeSetOn&&!0}}(wp.customize,jQuery,_),function(a,b,c){a.Value.prototype.set=function(d,e){var f=this._value,g=b.Deferred(),h=this,i=[];return d=this._setter.apply(this,arguments),d=this.validate(d),args=c.extend({silent:!1},c.isObject(e)?e:{}),null===d||c.isEqual(f,d)?g.resolveWith(h,[d,f,e]).promise():(this._value=d,this._dirty=!0,!0===args.silent?g.resolveWith(h,[d,f,e]).promise():this._deferreds?(c.each(h._deferreds,function(a){i.push(a.apply(null,[d,f,e]))}),b.when.apply(null,i).fail(function(){a.errorLog("A deferred callback failed in api.Value::set()")}).then(function(){h.callbacks.fireWith(h,[d,f,e]),g.resolveWith(h,[d,f,e])}),g.promise(h)):(this.callbacks.fireWith(this,[d,f,e]),g.resolveWith(h,[d,f,e]).promise(h)))},a.Value.prototype.bind=function(){var a=this,d=!1,e=[];return b.each(arguments,function(a,b){d||(d=c.isObject(b)&&b.deferred),c.isFunction(b)&&e.push(b)}),d?(a._deferreds=a._deferreds||[],c.each(e,function(b){c.contains(b,a._deferreds)||a._deferreds.push(b)})):a.callbacks.add.apply(a.callbacks,arguments),this},a.Setting.prototype.silent_set=function(b,d){var e=this._value,f=a.state("saved")();return b=this._setter.apply(this,arguments),b=this.validate(b),null===b||c.isEqual(e,b)?this:(this._value=b,this._dirty=c.isUndefined(d)||!c.isBoolean(d)?this._dirty:d,this.callbacks.fireWith(this,[b,e,{silent:!0}]),a.state("saved")(f),this)}}(wp.customize,jQuery,_),function(a,b,c){a.Setting.prototype.initialize=function(b,c,d){var e=this;a.Value.prototype.initialize.call(e,c,d),e.id=b,e.transport=e.transport||"refresh",e._dirty=d.dirty||!1,e.notifications=new a.Values({defaultConstructor:a.Notification}),e.bind(e.preview)},a.Setting.prototype.preview=function(d,e,f){var g,h=this,i=b.Deferred();return g=h.transport,serverControlParams.isSkopOn&&a.czr_isPreviewerSkopeAware&&"pending"==a.czr_isPreviewerSkopeAware.state()?(this.previewer.refresh(),i.resolve(arguments).promise()):c.isUndefined(e)||c.isEmpty(e)||c.isNull(e)||!c.isObject(f)||!0!==f.not_preview_sent?c.has(f,"silent")&&!1!==f.silent?i.resolve(arguments).promise():("postMessage"!==g||a.state("previewerAlive").get()||(g="refresh"),"postMessage"===g?(h.previewer.send("pre_setting",{set_id:h.id,data:f,value:d}),h.previewer.send("setting",[h.id,h()]),i.resolve(arguments)):"refresh"===g&&(serverControlParams.isSkopOn?h.previewer.refresh().always(function(){i.resolve(arguments)}):(h.previewer.refresh(),i.resolve(arguments))),i.promise()):i.resolve(arguments).promise()}}(wp.customize,jQuery,_),function(a,b,c){if("function"==typeof a.Section){var d=a.Section.prototype.initialize;a.Section.prototype.initialize=function(a,e){d.apply(this,[a,e]);var f=this;this.expanded.callbacks.add(function(a){if(a){var d=f.container.closest(".wp-full-overlay-sidebar-content"),e=f.container.find(".accordion-section-content");_resizeContentHeight=function(){e.css("height",d.innerHeight())},_resizeContentHeight(),b(window).on("resize.customizer-section",c.debounce(_resizeContentHeight,110))}})}}}(wp.customize,jQuery,_),function(a,b,c){a.CZR_Helpers=a.CZR_Helpers||{},a.CZR_Helpers=b.extend(a.CZR_Helpers,{getControlSettingId:function(b,d){return d="default",a.control.has(b)?!c.has(a.control(b),"settings")||c.isEmpty(a.control(b).settings)?b:c.has(a.control(b).settings,d)?c.isUndefined(a.control(b).settings[d].id)?(a.consoleLog("getControlSettingId : The requested control_id has no setting id assigned : "+b),b):a.control(b).settings[d].id:(a.consoleLog("getControlSettingId : The requested control_id does not have the requested setting type : "+b+" , "+d),b):(a.consoleLog("getControlSettingId : The requested control_id is not registered in the api yet : "+b),b)},getDocSearchLink:function(a){a=c.isString(a)?a:"";var b=a.replace(/ /g,"+"),d=[serverControlParams.docURL,"search?query=",b].join("");return['<a href="'+d+'" title="'+serverControlParams.i18n.readDocumentation+'" target="_blank">'," ",'<span class="fa fa-question-circle-o"></span>'].join("")},build_setId:function(a){return c.contains(serverControlParams.wpBuiltinSettings,a)?a:c.contains(serverControlParams.themeSettingList,a)&&-1==a.indexOf(serverControlParams.themeOptions)?[serverControlParams.themeOptions+"[",a,"]"].join(""):a},getOptionName:function(a){return-1==a.indexOf(serverControlParams.themeOptions)?a:a.replace(/\[|\]/g,"").replace(serverControlParams.themeOptions,"")},hasPartRefresh:function(b){if(c.has(a,"czr_partials"))return c.contains(c.map(a.czr_partials(),function(a,d){return c.contains(a.settings,b)}),!0)},getSectionControlIds:function(b){return b=b||a.czr_activeSectionId(),a.section.has(b)?c.map(a.section(b).controls(),function(a){return a.id}):[]},getSectionSettingIds:function(b){if(b=b||a.czr_activeSectionId(),a.section.has(b)){var d=this,e=[],f=d.getSectionControlIds(b);return c.each(f,function(b){c.each(a.control(b).settings,function(a,b){e.push(a.id)})}),e}},capitalize:function(a){return c.isString(a)?a.charAt(0).toUpperCase()+a.slice(1):a},truncate:function(a,b,d){if(!c.isString(a))return"";b=b||20;var e=a.length>b,f=e?a.substr(0,b-1):a;return f=d&&e?f.substr(0,f.lastIndexOf(" ")):f,e?f+"...":f},isMultiItemModule:function(b,d){if(!c.isUndefined(b)||c.isObject(d)){if(c.isObject(d)&&c.has(d,"module_type"))b=d.module_type;else if(c.isUndefined(b)||c.isNull(b))return;if(c.has(a.czrModuleMap,b))return a.czrModuleMap[b].crud||a.czrModuleMap[b].multi_item||!1}},isCrudModule:function(b,d){if(!c.isUndefined(b)||c.isObject(d)){if(c.isObject(d)&&c.has(d,"module_type"))b=d.module_type;else if(c.isUndefined(b)||c.isNull(b))return;if(c.has(a.czrModuleMap,b))return a.czrModuleMap[b].crud||!1}},hasModuleModOpt:function(b,d){if(!c.isUndefined(b)||c.isObject(d)){if(c.isObject(d)&&c.has(d,"module_type"))b=d.module_type;else if(c.isUndefined(b)||c.isNull(b))return;if(c.has(a.czrModuleMap,b))return a.czrModuleMap[b].has_mod_opt||!1}},setupInputCollectionFromDOM:function(){var d=this;if(!c.isFunction(d))throw new Error("setupInputCollectionFromDOM : inputParentInst is not valid.");var e=d.module,f=c.has(d(),"is_mod_opt");if(!c.has(d,"czr_Input")||c.isEmpty(d.inputCollection())){d.czr_Input=new a.Values,d.inputConstructor=f?e.inputModOptConstructor:e.inputConstructor;var g=f?d.defaultModOptModel:d.defaultItemModel;if(c.isEmpty(g)||c.isUndefined(g))throw new Error("No default model found in item or mod opt "+d.id+".");var h=b.extend(!0,{},d());h=c.isObject(h)?b.extend(g,h):g;var i={};return b("."+e.control.css_attr.sub_set_wrapper,d.container).each(function(g){var j=b(this).find("[data-type]").attr("data-type"),k=c.has(h,j)?h[j]:"";if(c.isUndefined(j)||c.isEmpty(j))return void a.consoleLog("setupInputCollectionFromDOM : missing data-type for "+e.id);if(!c.has(h,j))throw new Error("The item or mod opt property : "+j+" has been found in the DOM but not in the item or mod opt model : "+d.id+". The input can not be instantiated.");var l=b(this).attr("data-input-type"),m=b(this).attr("data-transport")||"inherit",n=c.has(e.inputOptions,l)?e.inputOptions[l]:{};d.czr_Input.add(j,new d.inputConstructor(j,{id:j,type:l,transport:m,input_value:k,input_options:n,container:b(this),input_parent:d,is_mod_opt:f,module:e})),d.czr_Input(j).ready(),i[j]=k}),d.inputCollection(i),d}},removeInputCollection:function(){var a=this;if(!c.isFunction(a))throw new Error("removeInputCollection : inputParentInst is not valid.");c.has(a,"czr_Input")&&(a.czr_Input.each(function(b){a.czr_Input.remove(b.id)}),a.inputCollection({}))},refreshModuleControl:function(c){var d=a.controlConstructor.czr_module,e=(a.control(c).params.type,a.settings.controls[c]);b.when(a.control(c).container.remove()).done(function(){a.control.remove(c),a.control.add(c,new d(c,{params:e,previewer:a.previewer}))})},hexToRgb:function(b){var c=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;try{b=b.replace(c,function(a,b,c,d){return b+b+c+c+d+d})}catch(d){return a.errorLog("Error in Helpers::hexToRgb : "+d),b}var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(b);return e=e?[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]:[],"rgb("+e.join(",")+")"},rgbToHex:function(a,b,c){var d=function(a){var b=a.toString(16);return 1==b.length?"0"+b:b};return"#"+d(a)+d(b)+d(c)}})}(wp.customize,jQuery,_),function(a,b,c){a.CZR_Helpers=a.CZR_Helpers||{},a.CZR_Helpers=b.extend(a.CZR_Helpers,{addActions:function(a,b,d){var e=this;d=d||e,d[a]=d[a]||[],new_event_map=c.clone(d[a]),d[a]=c.union(new_event_map,c.isArray(b)?b:[b])},doActions:function(a,b,c){b.trigger(a,c)},setupDOMListeners:function(d,e,f){var g=this,h={model:{},dom_el:{}};return f=f||g,c.isArray(d)?c.isObject(e)?(e=c.extend(h,e),!e.dom_el instanceof jQuery||1!=e.dom_el.length?void a.errorLog("setupDomListeners : dom element should be an existing dom element",e):void c.map(d,function(d){return!c.isString(d.selector)||c.isEmpty(d.selector)?void a.errorLog("setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : "+d.actions.join(",")):!c.isString(d.selector)||c.isEmpty(d.selector)?void a.errorLog("setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : "+d.actions.join(",")):void e.dom_el.on(d.trigger,d.selector,function(h,i){if(h.stopPropagation(),!a.utils.isKeydownButNotEnterEvent(h)){h.preventDefault();var j=b.extend(!0,{},e);if(c.has(j,"model")&&c.has(j.model,"id")&&(c.has(f,"get")?j.model=f():j.model=f.getModel(j.model.id)),b.extend(j,{event:d,dom_event:h}),b.extend(j,i),!c.has(j,"event")||!c.has(j.event,"actions"))return void a.errorLog("executeEventActionChain : missing obj.event or obj.event.actions");try{g.executeEventActionChain(j,f)}catch(k){a.errorLog("In setupDOMListeners : problem when trying to fire actions : "+j.event.actions),a.errorLog("Error : "+k)}}})})):void a.errorLog("setupDomListeners : args should be an object",d):void a.errorLog("setupDomListeners : event_map should be an array",e)},executeEventActionChain:function(a,b){var d=this;if("function"==typeof a.event.actions)return a.event.actions.call(b,a);c.isArray(a.event.actions)||(a.event.actions=[a.event.actions]);var e=!1;c.map(a.event.actions,function(f){if(!e){if("function"!=typeof b[f])throw new Error("executeEventActionChain : the action : "+f+" has not been found when firing event : "+a.event.selector);var g=c.has(a,"dom_el")&&-1!=a.dom_el.length?a.dom_el:d.container;g.trigger("before_"+f,c.omit(a,"event"));var h=b[f].call(b,a);!1===h&&(e=!0),g.trigger("after_"+f,c.omit(a,"event"))}})}})}(wp.customize,jQuery,_),function(a,b,c){a.czr_wpQueryDataReady=b.Deferred(),a.czr_wpQueryInfos=a.czr_wpQueryInfos||new a.Value,a.czr_partials=a.czr_partials||new a.Value,a.bind("ready",function(){a.previewer.bind("houston-widget-settings",function(b){var d=c.filter(b.registeredSidebars,function(a){return!c.findWhere(_wpCustomizeWidgetsSettings.registeredSidebars,{id:a.id})}),e=c.filter(b.registeredSidebars,function(a){return!c.has(b.renderedSidebars,a.id)});e=c.map(e,function(a){return a.id});var f=c.map(b.registeredSidebars,function(a){return a.id});a.czr_widgetZoneSettings=a.czr_widgetZoneSettings||new a.Value,a.czr_widgetZoneSettings.set({actives:b.renderedSidebars,inactives:e,registered:f,candidates:d,available_locations:b.availableWidgetLocations})}),a.previewer.bind("czr-query-data-ready",function(b){a.czr_wpQueryInfos(b),"pending"==a.czr_wpQueryDataReady.state()&&a.czr_wpQueryDataReady.resolve(b)}),a.previewer.bind("czr-partial-refresh-data",function(b){a.czr_partials.set(b)}),a.previewer.bind("czr-partial-refresh-done",function(b){if(c.has(b,"set_id")){var d=a.CZR_Helpers.build_setId(b.set_id);if(a.has(d)){var e=a.CZR_Helpers.getControlSettingId(d);a.control.has(e)&&a.control(e).trigger("czr-partial-refresh-done")}}})})}(wp.customize,jQuery,_);var CZRInputMths=CZRInputMths||{};!function(a,b,c){b.extend(CZRInputMths,{initialize:function(d,e){if(c.isUndefined(e.input_parent)||c.isEmpty(e.input_parent))throw new Error("No input_parent assigned to input "+e.id+". Aborting");if(c.isUndefined(e.module))throw new Error("No module assigned to input "+e.id+". Aborting");a.Value.prototype.initialize.call(this,null,e);var f=this;if(b.extend(f,e||{}),f.isReady=b.Deferred(),c.isUndefined(e.input_value)||f.set(e.input_value),a.czrInputMap&&c.has(a.czrInputMap,f.type)){var g=a.czrInputMap[f.type];c.isFunction(f[g])&&f[g](e.input_options||null)}else a.consoleLog("Warning an input : "+f.id+" has no corresponding method defined in api.czrInputMap.");var h={text:"keyup",textarea:"keyup",password:"keyup",color:"colorpickerchange",range:"input propertychange"};f.input_event_map=[{trigger:b.trim(["change",h[f.type]||""].join(" ")),selector:"input[data-type], select[data-type], textarea[data-type]",name:"set_input_value",actions:function(a){if(!c.has(f.input_parent,"syncElements")||!c.has(f.input_parent.syncElements,f.id))throw new Error("WARNING : THE INPUT "+f.id+" HAS NO SYNCED ELEMENT.")}}],f.visible=new a.Value((!0)),f.isReady.done(function(){f.visible.bind(function(a){a?f.container.stop(!0,!0).slideDown(200):f.container.stop(!0,!0).slideUp(200)})}),f.enabled=new a.Value((!0)),f.isReady.done(function(){f.enabled.bind(function(a){f.container.toggleClass("disabled",!a)})})},ready:function(){var a=this;a.setupDOMListeners(a.input_event_map,{dom_el:a.container},a),a.callbacks.add(function(){return a.inputReact.apply(a,arguments)}),b.when(a.setupSynchronizer()).done(function(){a.isReady.resolve(a)})},setupSynchronizer:function(){var b=this,c=b.input_parent,d=b.container.find("[data-type]"),e=b.container.find("[data-type]").is("textarea");if(e)throw new Error("TO DO : THE TEXTAREA INPUT ARE NOT READY IN THE SYNCHRONIZER!");var f=new a.Element(d);c.syncElements=c.syncElements||{},c.syncElements[b.id]=f,f.sync(b),f.set(b())},inputReact:function(a,b,d){var e=this,f=e.input_parent(),g=c.clone(f),h=e.is_preItemInput;e.enabled()&&(g=!c.isObject(g)||c.isEmpty(g)?{}:g,g[e.id]=a,e.input_parent.set(g,{input_changed:e.id,input_transport:e.transport,not_preview_sent:"postMessage"===e.transport}),h||(e.input_parent.trigger(e.id+":changed",a),c.isEmpty(b)&&(c.isUndefined(b)||"postMessage"!==e.transport)||e.module.sendInputToPreview({input_id:e.id,input_parent_id:e.input_parent.id,to:a,from:b})))},setupColorPicker:function(){var a=this;a.container.find("input").iris({palettes:!0,hide:!1,change:function(a,c){b(this).val(c.color.toString()).trigger("colorpickerchange").trigger("change")}})},setupSelect:function(){var a=this;b("select",a.container).not(".no-selecter-js").each(function(){b(this).selecter({})})},setupIcheck:function(a){var c=this;b("input[type=checkbox]",c.container).each(function(a){0===b(this).closest('div[class^="icheckbox"]').length&&b(this).iCheck({checkboxClass:"icheckbox_flat-grey",checkedClass:"checked",radioClass:"iradio_flat-grey"}).on("ifChanged",function(a){b(this).val(!1===b(this).is(":checked")?0:1),b(a.currentTarget).trigger("change")})})},setupStepper:function(a){var c=this;b('input[type="number"]',c.container).each(function(a){b(this).stepper()})},setupRangeSlider:function(a){var c,d=this,e=function(a,b){a.textContent=b+"%"};b(d.container).find("input").rangeslider({polyfill:!1,rangeClass:"rangeslider",disabledClass:"rangeslider--disabled",horizontalClass:"rangeslider--horizontal",verticalClass:"rangeslider--vertical",fillClass:"rangeslider__fill",handleClass:"rangeslider__handle",onInit:function(){c=b(".rangeslider__handle",this.$range),b(".rangeslider__handle",this.$range),e(c[0],this.value)}}).on("input",function(){e(c[0],this.value)})}})}(wp.customize,jQuery,_);var CZRInputMths=CZRInputMths||{};!function(a,b,c){b.extend(CZRInputMths,{setupImageUploader:function(){var a=this,c=a();return a.attachment={},a.container?(this.tmplRendered=b.Deferred(),this.setupContentRendering(c,{}),void this.tmplRendered.done(function(){a.czrImgUploaderBinding()})):this},setupContentRendering:function(a,b){var d,e=this;e.attachment.id!=a&&b!==a?(a||(e.attachment={},e.renderImageUploaderTemplate()),d=wp.media.attachment(a),c.isObject(d)&&c.has(d,"attributes")&&c.has(d.attributes,"sizes")?(e.attachment=d.attributes,e.renderImageUploaderTemplate()):wp.media.attachment(a).fetch().done(function(){e.attachment=this.attributes,e.renderImageUploaderTemplate()})):e.attachment.id&&e.attachment.id!==a||e.renderImageUploaderTemplate()},czrImgUploaderBinding:function(){var a=this;c.bindAll(a,"czrImgUploadRemoveFile","czrImgUploadOpenFrame","czrImgUploadSelect"),a.container.on("click keydown",".upload-button",a.czrImgUploadOpenFrame),a.container.on("click keydown",".thumbnail-image img",a.czrImgUploadOpenFrame),a.container.on("click keydown",".remove-button",a.czrImgUploadRemoveFile),a.bind(a.id+":changed",function(c,d){a.tmplRendered=b.Deferred(),a.setupContentRendering(c,d)})},czrImgUploadOpenFrame:function(b){a.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),this.frame||this.czrImgUploadInitFrame(),this.frame.open())},czrImgUploadInitFrame:function(){var a=this,b=this.getUploaderLabels();a.frame=wp.media({button:{text:b.frame_button},states:[new wp.media.controller.Library({title:b.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1})]}),a.frame.on("select",a.czrImgUploadSelect)},czrImgUploadRemoveFile:function(b){var c=this;a.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),c.attachment={},c.set(""))},czrImgUploadSelect:function(){var a=this,b=a.frame.state().get("selection").first().toJSON();window._wpmejsSettings||{};a.attachment=b,a.set(b.id)},renderImageUploaderTemplate:function(){var a=this;if(0!==b("#tmpl-czr-input-img-uploader-view-content").length){var c=wp.template("czr-input-img-uploader-view-content");if(c&&a.container){var d=a.container.find("."+a.module.control.css_attr.img_upload_container);if(d.length){var e={button_labels:a.getUploaderLabels(),settings:a.id,attachment:a.attachment,canUpload:!0};return d.html(c(e)),a.tmplRendered.resolve(),a.container.trigger(a.id+":content_rendered"),!0}}}},getUploaderLabels:function(){var b=serverControlParams.i18n,d={select:b.select_image,change:b.change_image,remove:b.remove_image,"default":b.default_image,placeholder:b.placeholder_image,frame_title:b.frame_title_image,frame_button:b.frame_button_image};return c.each(d,function(b,d){if(c.isUndefined(b)){var e=this;return a.errorLog("A translated string is missing ( "+d+" ) for the image uploader input in module : "+e.module.id),""}}),d}})}(wp.customize,jQuery,_);var CZRInputMths=CZRInputMths||{};!function(a,b,c){b.extend(CZRInputMths,{setupContentPicker:function(d){var e=this,f=[];b.extend({post:"",taxonomy:""},c.isObject(d)?d:{}),e.wpObjectTypes=d,e.container.find(".czr-input").append('<select data-select-type="content-picker-select" class="js-example-basic-simple"></select>'),f=[{trigger:"change",selector:"select[data-select-type]",name:"set_input_value",actions:function(d){var f=b(d.dom_event.currentTarget,d.dom_el),g=b(f,d.dom_el).select2("data"),h={},i={id:"",type_label:"",title:"",object_type:"",url:""};return g=c.isArray(g)?g[0]:g,!c.isObject(g)||c.isEmpty(g)?void a.errorLog("Content Picker Input : the picked value should be an object not empty."):(c.each(i,function(b,d){return"_custom_"===g.id||c.has(g,d)&&!c.isEmpty(g[d])?void(h[d]=g[d]):void a.errorLog("content_picker : missing input param : "+d)}),void e.set(h))}}],e.setupDOMListeners(f,{dom_el:e.container},e),e.isReady.done(function(){e.setupContentSelecter()})},setupContentSelecter:function(){var a=this;if(!c.isEmpty(a())){var d={value:a().id||"",title:a().title||"",selected:"selected"};a.container.find("select").append(b("<option>",d))}a.container.find("select").select2({placeholder:{id:"-1",title:"Select"},data:a.setupSelectedContents(),ajax:{url:serverControlParams.AjaxUrl,type:"POST",dataType:"json",delay:250,debug:!0,data:function(b){var c=b.page?b.page:0;return c=b.term?b.page:c,{action:b.term?"search-available-content-items-customizer":"load-available-content-items-customizer",search:b.term,wp_customize:"on",page:c,wp_object_types:JSON.stringify(a.wpObjectTypes),CZRCpNonce:serverControlParams.CZRCpNonce}},processResults:function(b,d){if(a.defaultContentPickerOption=a.defaultContentPickerOption||[],!b.success)return{results:a.defaultContentPickerOption};var e=b.data.items,f=[];return c.each(e,function(a){f.push({id:a.id,title:a.title,type_label:a.type_label,object_type:a.object,url:a.url})}),{results:f,pagination:{more:b.data.items.length>=10}}}},templateSelection:a.czrFormatContentSelected,templateResult:a.czrFormatContentSelected,escapeMarkup:function(a){return a}})},czrFormatContentSelected:function(a){if(a.loading)return a.text;var b="<div class='content-picker-item clearfix'><div class='content-item-bar'><span class='czr-picker-item-title'>"+a.title+"</span>";return a.type_label&&(b+="<span class='czr-picker-item-type'>"+a.type_label+"</span>"),b+="</div></div>"},setupSelectedContents:function(){var a=this,b=a();return b}})}(wp.customize,jQuery,_);var CZRInputMths=CZRInputMths||{};!function(a,b,c){b.extend(CZRInputMths,{setupTextEditor:function(){var c=this;c();if(!c.container)throw new Error("The input container is not set for WP text editor in module."+c.module.id);c.czrRenderInputTextEditorTemplate()&&(c.editor=tinyMCE("czr-customize-content_editor"),c.textarea=b("#czr-customize-content_editor"),c.editorPane=b("#czr-customize-content_editor-pane"),c.dragbar=b("#czr-customize-content_editor-dragbar"),c.editorFrame=b("#czr-customize-content_editor_ifr"),c.mceTools=b("#wp-czr-customize-content_editor-tools"),c.mceToolbar=c.editorPane.find(".mce-toolbar-grp"),c.mceStatusbar=c.editorPane.find(".mce-statusbar"),c.preview=b("#customize-preview"),c.collapse=b(".collapse-sidebar"),c.textpreview=c.container.find("textarea"),c.toggleButton=c.container.find("button.text_editor-button"),c.editorExpanded=new a.Value((!1)),c.czrUpdateTextPreview(),c.czrSetToggleButtonText(c.editorExpanded()),c.czrTextEditorBinding(),c.czrResizeEditorOnUserRequest())},czrTextEditorBinding:function(){var d=this,e=d.editor,f=d.textarea,g=d.toggleButton,h=(d.editorExpanded,d.editorPane);d.bind(d.id+":changed",d.czrUpdateTextPreview),c.bindAll(d,"czrOnVisualEditorChange","czrOnTextEditorChange","czrResizeEditorOnWindowResize"),g.on("click",function(){d.editorExpanded.set(!d.editorExpanded()),d.editorExpanded()&&e.focus()}),d.module.czr_ModuleState.bind(function(a){"expanded"!=a&&d.editorExpanded.set(!1)}),d.editorExpanded.bind(function(c){a.consoleLog("in input.editorExpanded",c,d()),e.locker&&e.locker!==d&&(e.locker.editorExpanded.set(!1),e.locker=null),e.locker&&e.locker!==d||(b(document.body).toggleClass("czr-customize-content_editor-pane-open",c),e.locker=d),d.czrSetToggleButtonText(c),c?(e.setContent(wp.editor.autop(d())),e.on("input change keyup",d.czrOnVisualEditorChange),f.on("input",d.czrOnTextEditorChange),d.czrResizeEditor(window.innerHeight-h.height()),b(window).on("resize",d.czrResizeEditorOnWindowResize)):(e.off("input change keyup",d.czrOnVisualEditorChange),f.off("input",d.czrOnTextEditorChange),
12
- b(window).off("resize",d.czrResizeEditorOnWindowResize),d.czrResizeReset())})},czrOnVisualEditorChange:function(){var a,b=this,c=b.editor;a=wp.editor.removep(c.getContent()),b.set(a)},czrOnTextEditorChange:function(){var a,b=this,c=b.textarea;a=c.val(),b.set(a)},czrUpdateTextPreview:function(){var a,b=this,c=b();a=c.replace(/(<([^>]+)>)/gi,""),a.length>30&&(a=a.substring(0,34)+"..."),b.textpreview.val(a)},czrRenderInputTextEditorTemplate:function(){var c=this;if(0===b("#tmpl-czr-input-text_editor-view-content").length)throw new Error("Missing js template for text editor input in module : "+c.module.id);var d=wp.template("czr-input-text_editor-view-content"),e=c.container.find("input");if(d&&c.container)return a.consoleLog("Model injected in text editor tmpl : ",c()),e.after(d(c())),!0},czrIsEditorExpanded:function(){return b(document.body).hasClass("czr-customize-content_editor-pane-open")},czrResizeReset:function(){var a=this,b=a.preview,c=a.collapse,d=a.container.closest("ul.accordion-section-content");d.css("padding-bottom",""),b.css("bottom",""),c.css("bottom","")},czrResizeEditor:function(a){var b=window.innerHeight,d=window.innerWidth,e=40,f=1,g=782,h=56,i=8,j=4,k={},l=this,m=l.container.closest("ul.accordion-section-content"),n=l.mceTools,o=l.mceToolbar,p=l.mceStatusbar,q=l.preview,r=l.collapse,s=l.editorPane,t=l.editorFrame;l.editorExpanded()&&(c.isNaN(a)||(resizeHeight=b-a),k.height=resizeHeight,k.components=n.outerHeight()+o.outerHeight()+p.outerHeight(),resizeHeight<e&&(k.height=e),resizeHeight>b-f&&(k.height=b-f),b<s.outerHeight()&&(k.height=b),q.css("bottom",k.height),s.css("height",k.height),t.css("height",k.height-k.components),r.css("bottom",k.height+i),h>b-k.height&&r.css("bottom",p.outerHeight()+j),d<=g?m.css("padding-bottom",k.height):m.css("padding-bottom",""))},czrResizeEditorOnWindowResize:function(){var a=this,b=50,d=a.editorPane;a.editorExpanded()&&c.delay(function(){a.czrResizeEditor(window.innerHeight-d.height())},b)},czrResizeEditorOnUserRequest:function(){var a=this,c=a.dragbar,d=a.editorFrame;c.on("mousedown",function(){a.editorExpanded()&&b(document).on("mousemove.czr-customize-content_editor",function(c){c.preventDefault(),b(document.body).addClass("czr-customize-content_editor-pane-resize"),d.css("pointer-events","none"),a.czrResizeEditor(c.pageY)})}),c.on("mouseup",function(){a.editorExpanded()&&(b(document).off("mousemove.czr-customize-content_editor"),b(document.body).removeClass("czr-customize-content_editor-pane-resize"),d.css("pointer-events",""))})},czrSetToggleButtonText:function(a){var b=this;b.toggleButton.text(serverControlParams.i18n.mods.textEditor[a?"Close Editor":"Edit"])}})}(wp.customize,jQuery,_);var CZRItemMths=CZRItemMths||{};!function(a,b,c){b.extend(CZRItemMths,{initialize:function(d,e){if(c.isUndefined(e.module)||c.isEmpty(e.module))throw new Error("No module assigned to item "+d+". Aborting");var f=this;a.Value.prototype.initialize.call(f,null,e),f.isReady=b.Deferred(),f.embedded=b.Deferred(),f.container=null,f.contentContainer=null,f.inputCollection=new a.Value({}),f.viewState=new a.Value("closed"),f.removeDialogVisible=new a.Value((!1)),b.extend(f,e||{}),f.defaultItemModel=c.clone(e.defaultItemModel)||{id:"",title:""};var g=b.extend(f.defaultItemModel,e.initial_item_model);f.set(g),f.userEventMap=new a.Value([{trigger:"click keydown",selector:["."+f.module.control.css_attr.display_alert_btn,"."+f.module.control.css_attr.cancel_alert_btn].join(","),name:"toggle_remove_alert",actions:function(){var a=this.removeDialogVisible();this.module.closeRemoveDialogs(),this.removeDialogVisible(!a)}},{trigger:"click keydown",selector:"."+f.module.control.css_attr.remove_view_btn,name:"remove_item",actions:["removeItem"]},{trigger:"click keydown",selector:["."+f.module.control.css_attr.edit_view_btn,"."+f.module.control.css_attr.item_title].join(","),name:"edit_view",actions:["setViewVisibility"]},{trigger:"click keydown",selector:".tabs nav li",name:"tab_nav",actions:function(a){this.module.toggleTabVisibility.call(this,a)}}]),f.isReady.done(function(){f.module.updateItemsCollection({item:f()}),f.callbacks.add(function(){return f.itemReact.apply(f,arguments)}),f.bind("contentRendered",function(){if(!c.has(f,"czr_Input")||c.isEmpty(f.inputCollection()))try{a.CZR_Helpers.setupInputCollectionFromDOM.call(f),f.module.setupTabNav.call(f)}catch(b){a.errorLog("In item.isReady.done : "+b)}}),f.bind("contentRemoved",function(){c.has(f,"czr_Input")&&a.CZR_Helpers.removeInputCollection.call(f)}),f.mayBeRenderItemWrapper(),f.embedded.done(function(){f.itemWrapperViewSetup(g)})})},ready:function(){this.isReady.resolve()},itemReact:function(a,b,c){var d=this,e=d.module;c=c||{},e.updateItemsCollection({item:a,data:c}).done(function(){d.writeItemViewTitle(a,c)})}})}(wp.customize,jQuery,_);var CZRItemMths=CZRItemMths||{};!function(a,b,c){b.extend(CZRItemMths,{_sendItem:function(a,b){var d=this,e=d.module,f=[];c.each(b,function(b,c){b!=a[c]&&f.push(c)}),c.each(f,function(b){e.control.previewer.send("sub_setting",{set_id:e.control.id,id:a.id,changed_prop:b,value:a[b]}),e.trigger("item_sent",{item:a,dom_el:d.container,changed_prop:b})})},removeItem:function(){var a=this,d=this.module,e=c.clone(d.itemCollection());d.trigger("pre_item_dom_remove",a()),a._destroyView(),e=c.without(e,c.findWhere(e,{id:a.id})),d.itemCollection.set(e),d.trigger("pre_item_api_remove",a());var f=b.extend(!0,{},a());d.czr_Item.remove(a.id),d.trigger("item-removed",f)},getModel:function(a){return this()}})}(wp.customize,jQuery,_);var CZRItemMths=CZRItemMths||{};!function(a,b,c){b.extend(CZRItemMths,{mayBeRenderItemWrapper:function(){var a=this;"pending"==a.embedded.state()&&b.when(a.renderItemWrapper()).done(function(b){if(a.container=b,c.isUndefined(a.container)||!a.container.length)throw new Error("In mayBeRenderItemWrapper the Item view has not been rendered : "+a.id);a.embedded.resolve()})},itemWrapperViewSetup:function(d){var e=this,f=this.module;d=e()||e.initial_item_model,e.writeItemViewTitle();var g=function(a,b,d){if(c.isUndefined(a)||!1===a.length)throw new Error("Module : "+e.module.id+", the item content has not been rendered for "+e.id);e.trigger("contentRendered"),e.contentContainer=a,e.toggleItemExpansion(b,d)};e.module.isMultiItem()?e.viewState.callbacks.add(function(d,h){var i=-1!==d.indexOf("expanded");f.hasModOpt()&&i&&a.czr_ModOptVisible(!1),i?c.isObject(e.contentContainer)&&!1!==e.contentContainer.length?e.toggleItemExpansion(d,h):b.when(e.renderItemContent(e()||e.initial_item_model)).done(function(a){(g=c.debounce(g,50))(a,d,h)}):e.toggleItemExpansion(d,h).done(function(){c.isObject(e.contentContainer)&&!1!==e.contentContainer.length&&(e.trigger("beforeContenRemoved"),b("."+f.control.css_attr.item_content,e.container).children().each(function(){b(this).remove()}),b("."+f.control.css_attr.item_content,e.container).html(""),e.contentContainer=null,e.trigger("contentRemoved"))})}):(e.viewState.callbacks.add(function(a,b){e.toggleItemExpansion.apply(e,arguments)}),b.when(e.renderItemContent(d)).done(function(a){g(a,!0)})),a.CZR_Helpers.setupDOMListeners(e.userEventMap(),{model:d,dom_el:e.container},e),e.removeDialogVisible.bind(function(d){var f=e.module,g=b("."+f.control.css_attr.remove_alert_wrapper,e.container).first();if(d&&f.closeAllItems(),d&&f.hasModOpt()&&a.czr_ModOptVisible(!1),d&&c.has(f,"preItem")&&f.preItemExpanded(!1),b("."+f.control.css_attr.remove_alert_wrapper,e.container).not(g).each(function(){b(this).hasClass("open")&&b(this).slideToggle({duration:200,done:function(){b(this).toggleClass("open",!1),b(this).siblings().find("."+f.control.css_attr.display_alert_btn).toggleClass("active",!1)}})}),d){if(!wp.template(f.AlertPart)||!e.container)return void a.consoleLog("No removal alert template available for items in module :"+f.id);g.html(wp.template(f.AlertPart)({title:e().title||e.id}))}var h=function(a){g.toggleClass("open",a),e.container.find("."+f.control.css_attr.display_alert_btn).toggleClass("active",a),a&&f._adjustScrollExpandedBlock(e.container)};d?g.stop(!0,!0).slideDown(200,function(){h(d)}):g.stop(!0,!0).slideUp(200,function(){h(d)})})},renderItemWrapper:function(a){var c=this,d=c.module;if(a=a||c(),$_view_el=b("<li>",{"class":d.control.css_attr.single_item,"data-id":a.id,id:a.id}),d.itemsWrapper.append($_view_el),d.isMultiItem()){var e=d.getTemplateEl("rudItemPart",a);if(0===b("#tmpl-"+e).length)throw new Error("Missing template for item "+c.id+". The provided template script has no been found : #tmpl-"+d.getTemplateEl("rudItemPart",a));$_view_el.append(b(wp.template(e)(a)))}return $_view_el.append(b("<div/>",{"class":d.control.css_attr.item_content})),$_view_el},renderItemContent:function(a){var c=this,d=this.module;if(a=a||c(),0===b("#tmpl-"+d.getTemplateEl("itemInputList",a)).length)throw new Error("No item content template defined for module "+d.id+". The template script id should be : #tmpl-"+d.getTemplateEl("itemInputList",a));var e=wp.template(d.getTemplateEl("itemInputList",a));return e?(b(e(a)).appendTo(b("."+d.control.css_attr.item_content,c.container)),b(b(e(a)),c.container)):this},writeItemViewTitle:function(d){var e=this,f=e.module,g=d||e(),h=c.has(g,"title")?a.CZR_Helpers.capitalize(g.title):g.id;h=a.CZR_Helpers.truncate(h,20),b("."+f.control.css_attr.item_title,e.container).text(h),a.CZR_Helpers.doActions("after_writeViewTitle",e.container,g,e)},setViewVisibility:function(a,b){var d=this,e=this.module;b?d.viewState.set("expanded_noscroll"):(e.closeAllItems(d.id),c.has(e,"preItem")&&e.preItemExpanded.set(!1),d.viewState.set("expanded"==d._getViewState()?"closed":"expanded"))},_getViewState:function(){return-1==this.viewState().indexOf("expanded")?"closed":"expanded"},toggleItemExpansion:function(a,c,d){var e="closed"!=a,f=this,g=this.module,h=b("."+g.control.css_attr.item_content,f.container).first(),i=b.Deferred(),j=function(b){f.container.toggleClass("open",b),b&&g.closeRemoveDialogs();var c=h.siblings().find("."+g.control.css_attr.edit_view_btn);c.toggleClass("active",b),b?c.removeClass("fa-pencil").addClass("fa-minus-square").attr("title",serverControlParams.i18n.close):c.removeClass("fa-minus-square").addClass("fa-pencil").attr("title",serverControlParams.i18n.edit),"expanded"==a&&g._adjustScrollExpandedBlock(f.container),i.resolve()};return e?h.stop(!0,!0).slideDown(d||200,function(){j(e)}):h.stop(!0,!0).slideUp(200,function(){j(e)}),i.promise()},_destroyView:function(a){this.container.fadeOut({duration:a||400,done:function(){b(this).remove()}})}})}(wp.customize,jQuery,_);var CZRModOptMths=CZRModOptMths||{};!function(a,b,c){b.extend(CZRModOptMths,{initialize:function(d){if(c.isUndefined(d.module)||c.isEmpty(d.module))throw new Error("No module assigned to modOpt.");var e=this;a.Value.prototype.initialize.call(e,null,d),e.isReady=b.Deferred(),e.container=null,e.inputCollection=new a.Value({}),b.extend(e,d||{}),e.defaultModOptModel=c.clone(d.defaultModOptModel)||{is_mod_opt:!0};var f=b.extend(e.defaultModOptModel,d.initial_modOpt_model),g=e.module.control;e.set(f),a.czr_ModOptVisible=new a.Value((!1)),a.czr_ModOptVisible.bind(function(d,g,h){h=h||{},d?(e.module.closeRemoveDialogs().closeAllItems(),e.modOptWrapperViewSetup(f).done(function(b){e.container=b;try{a.CZR_Helpers.setupInputCollectionFromDOM.call(e).toggleModPanelView(d)}catch(f){a.consoleLog(f)}h.module&&h.focus&&c.delay(function(){!c.isNull(h.module.czr_ModOpt.container)&&h.module.czr_ModOpt.container.find('[data-tab-id="'+h.focus+'"] a').length&&h.module.czr_ModOpt.container.find('[data-tab-id="'+h.focus+'"] a').trigger("click")},200)})):e.toggleModPanelView(d).done(function(){!1!==e.container.length?b.when(e.container.remove()).done(function(){a.CZR_Helpers.removeInputCollection.call(e)}):a.CZR_Helpers.removeInputCollection.call(e),e.container=null})}),e.isReady.done(function(){b("."+g.css_attr.edit_modopt_icon,g.container).length||b.when(g.container.find(".customize-control-title").first().append(b("<span/>",{"class":[g.css_attr.edit_modopt_icon,"fa fa-cog"].join(" "),title:serverControlParams.i18n.Settings}))).done(function(){b("."+g.css_attr.edit_modopt_icon,g.container).fadeIn(400)}),a.CZR_Helpers.setupDOMListeners([{trigger:"click keydown",selector:"."+g.css_attr.edit_modopt_icon,name:"toggle_mod_option",actions:function(){a.czr_ModOptVisible(!a.czr_ModOptVisible())}}],{dom_el:g.container},e)})},ready:function(){this.isReady.resolve()}})}(wp.customize,jQuery,_);var CZRModOptMths=CZRModOptMths||{};!function(a,b,c){b.extend(CZRModOptMths,{modOptWrapperViewSetup:function(d){var e=this,f=this.module,g=b.Deferred(),h=function(b){a.CZR_Helpers.setupDOMListeners([{trigger:"click keydown",selector:"."+f.control.css_attr.close_modopt_icon,name:"close_mod_option",actions:function(){a.czr_ModOptVisible(!1)}},{trigger:"click keydown",selector:".tabs nav li",name:"tab_nav",actions:function(a){this.module.toggleTabVisibility.call(this,a)}}],{dom_el:b},e)};return d=e()||e.initial_modOpt_model,b.when(e.renderModOptContent(d)).done(function(a){if(c.isUndefined(a)||!1===a.length)throw new Error("Module : "+e.module.id+", the modOpt content has not been rendered");h(a),g.resolve(a)}).then(function(){e.module.setupTabNav.call(e)}),g.promise()},renderModOptContent:function(c){var d=this,e=this.module;if(c=c||d(),0===b("#tmpl-"+e.getTemplateEl("modOptInputList",c)).length)return void a.errorLog("renderModOptContent : No modOpt content template defined for module "+e.id+". The template script id should be : #tmpl-"+e.getTemplateEl("modOptInputList",c));var f=wp.template(e.getTemplateEl("modOptInputList",c));if(!f)return this;var g="";try{g=[serverControlParams.i18n["Options for"],e.control.params.label].join(" ")}catch(h){a.errorLog("In renderModOptContent : "+h),g=serverControlParams.i18n.Settings}return b("#widgets-left").after(b("<div/>",{"class":e.control.css_attr.mod_opt_wrapper,html:[['<h2 class="mod-opt-title">',g,"</h2>"].join(""),'<span class="fa fa-times '+e.control.css_attr.close_modopt_icon+'" title="close"></span>'].join("")})),b("."+e.control.css_attr.mod_opt_wrapper).append(b(f(c))),b("."+e.control.css_attr.mod_opt_wrapper)},toggleModPanelView:function(a){var d=this.module,e=(d.control,b.Deferred());return d.control.container.toggleClass("czr-modopt-visible",a),b("body").toggleClass("czr-editing-modopt",a),c.delay(function(){e.resolve()},200),e.promise()}})}(wp.customize,jQuery,_);var CZRModuleMths=CZRModuleMths||{};!function(a,b,c){b.extend(CZRModuleMths,{initialize:function(d,e){if(c.isUndefined(e.control)||c.isEmpty(e.control))throw new Error("No control assigned to module "+d);var f=this;a.Value.prototype.initialize.call(this,null,e),f.isReady=b.Deferred(),b.extend(f,e||{}),b.extend(f,{crudModulePart:"czr-crud-module-part",rudItemPart:"czr-rud-item-part",ruItemPart:"czr-ru-item-part",itemInputList:"",modOptInputList:"",AlertPart:"czr-rud-item-alert-part"}),f.embedded=b.Deferred(),f.itemsWrapper="",f.isInSektion()||(f.container=b(f.control.selector),f.embedded.resolve()),f.embedded.done(function(){b.when(f.renderModuleParts()).done(function(a){if(!1===a.length)throw new Error("The items wrapper has not been rendered for module : "+f.id);f.itemsWrapper=a})}),f.defaultAPImodOptModel={initial_modOpt_model:{},defaultModOptModel:{},control:{},module:{}},f.defaultModOptModel={},f.modOptConstructor=a.CZRModOpt,f.itemCollection=new a.Value([]),f.defaultAPIitemModel={id:"",initial_item_model:{},defaultItemModel:{},control:{},module:{},is_added_by_user:!1},f.defaultItemModel={id:"",title:""},f.itemConstructor=a.CZRItem,f.czr_Item=new a.Values,f.inputConstructor=a.CZRInput,f.hasModOpt()&&(f.inputModOptConstructor=a.CZRInput),f.inputOptions={},f.isReady.done(function(){f.isDirty=new a.Value(e.dirty||!1),f.initializeModuleModel(e).done(function(a){f.set(a)}).fail(function(b){a.consoleLog("Module : "+f.id+" initialize module model failed : ",b)}).always(function(a){f.callbacks.add(function(){return f.moduleReact.apply(f,arguments)}),f.control.isModuleRegistered(f.id)||f.control.updateModulesCollection({module:e,is_registered:!1}),f.bind("items-collection-populated",function(a){f.itemCollection.callbacks.add(function(){return f.itemCollectionReact.apply(f,arguments)}),f.isMultiItem()&&f._makeItemsSortable()}),f.isInSektion()||f.populateSavedItemCollection(),f.hasModOpt()&&f.instantiateModOpt()})})},ready:function(){var a=this;a.isReady.resolve()},initializeModuleModel:function(a){var d=this,e=b.Deferred();if(!d.isMultiItem()&&!d.isCrud()&&c.isEmpty(a.items)){var f=c.clone(d.defaultItemModel);a.items=[b.extend(f,{id:d.id})]}return e.resolve(a).promise()},itemCollectionReact:function(a,c,d){var e=this,f=e(),g=b.extend(!0,{},f);g.items=a,e.isDirty.set(!0),e.set(g,d||{})},moduleReact:function(a,d,e){var f=this,g=f.control;c.size(d.items)==c.size(a.items)&&!c.isEmpty(c.difference(a.items,d.items)),a.column_id!=d.column_id;g.updateModulesCollection({module:b.extend(!0,{},a),data:e})},getModuleSection:function(){return this.section},isInSektion:function(){var a=this;return c.has(a,"sektion_id")},isMultiItem:function(){return a.CZR_Helpers.isMultiItemModule(null,this)},isCrud:function(){return a.CZR_Helpers.isCrudModule(null,this)},hasModOpt:function(){return a.CZR_Helpers.hasModuleModOpt(null,this)},instantiateModOpt:function(){var a=this,c=a.prepareModOptForAPI(a().modOpt||{});a.czr_ModOpt=new a.modOptConstructor(c),a.czr_ModOpt.ready(),a.czr_ModOpt.callbacks.add(function(c,d,e){var f=a(),g=b.extend(!0,{},f);g.modOpt=c,a.isDirty(!0),a(g,e)})},prepareModOptForAPI:function(a){var b=this,d={};return a=c.isObject(a)?a:{},c.each(b.defaultAPImodOptModel,function(e,f){a[f];switch(f){case"initial_modOpt_model":c.each(b.getDefaultModOptModel(),function(b,d){c.has(a,d)||(a[d]=b)}),d[f]=a;break;case"defaultModOptModel":d[f]=c.clone(b.defaultModOptModel);break;case"control":d[f]=b.control;break;case"module":d[f]=b}}),d},getDefaultModOptModel:function(a){var d=this;return b.extend(c.clone(d.defaultModOptModel),{is_mod_opt:!0})},sendInputToPreview:function(d){var e=this;d=c.extend({input_id:"",input_parent_id:"",to:null,from:null},d),c.isEqual(d.to,d.from)||(e.control.previewer.send("czr_input",{set_id:a.CZR_Helpers.getControlSettingId(e.control.id),module_id:e.id,module:{items:b.extend(!0,{},e().items),modOpt:e.hasModOpt()?b.extend(!0,{},e().modOpt):{}},input_parent_id:d.input_parent_id,input_id:d.input_id,value:d.to,isPartialRefresh:d.isPartialRefresh}),e.trigger("input_sent",{input:d.to,dom_el:e.container}))},sendModuleInputsToPreview:function(a){var d=this,e=function(){var e=this,f=b.extend(!0,{},e());f=c.omit(f,"id"),c.each(f,function(b,c){d.sendInputToPreview({input_id:c,input_parent_id:e.id,to:b,from:null,isPartialRefresh:a.isPartialRefresh})})};d.czr_Item.each(function(a){e.call(a)}),d.hasModOpt()&&e.call(d.czr_ModOpt)}})}(wp.customize,jQuery,_);var CZRModuleMths=CZRModuleMths||{};!function(a,b,c){b.extend(CZRModuleMths,{populateSavedItemCollection:function(){var b=this,d=[];return c.isArray(b().items)?(c.each(b().items,function(a,b){c.has(a,"id")&&!c.has(a,"is_mod_opt")&&d.push(a)}),c.each(d,function(c,d){try{b.instantiateItem(c).ready()}catch(e){a.errorLog("populateSavedItemCollection : "+e)}}),c.each(d,function(a){if(c.isUndefined(c.findWhere(b.itemCollection(),a.id)))throw new Error("populateSavedItemCollection : The saved items have not been properly populated in module : "+b.id)}),void b.trigger("items-collection-populated")):void a.errorLog("populateSavedItemCollection : The saved items collection must be an array in module :"+b.id)},instantiateItem:function(a,b){var d=this;if(item_candidate=d.prepareItemForAPI(a),!c.has(item_candidate,"id"))throw new Error("CZRModule::instantiateItem() : an item has no id and could not be added in the collection of : "+this.id);if(d.czr_Item.has(item_candidate.id))throw new Error("CZRModule::instantiateItem() : the following item id "+item_candidate.id+" already exists in module.czr_Item() for module "+this.id);if(d.czr_Item.add(item_candidate.id,new d.itemConstructor(item_candidate.id,item_candidate)),!d.czr_Item.has(item_candidate.id))throw new Error("CZRModule::instantiateItem() : instantiation failed for item id "+item_candidate.id+" for module "+this.id);return d.czr_Item(item_candidate.id)},prepareItemForAPI:function(a){var b=this,d={};return a=c.isObject(a)?a:{},c.each(b.defaultAPIitemModel,function(e,f){var g=a[f];switch(f){case"id":c.isEmpty(g)?d[f]=b.generateItemId(b.module_type):d[f]=g;break;case"initial_item_model":c.each(b.getDefaultItemModel(),function(b,d){c.has(a,d)||(a[d]=b)}),d[f]=a;break;case"defaultItemModel":d[f]=c.clone(b.defaultItemModel);break;case"control":d[f]=b.control;break;case"module":d[f]=b;break;case"is_added_by_user":d[f]=!!c.isBoolean(g)&&g}}),c.has(d,"id")||(d.id=b.generateItemId(b.module_type)),d.initial_item_model.id=d.id,d},generateItemId:function(a,b,d){if(d=d||1,d>100)throw new Error("Infinite loop when generating of a module id.");var e=this;b=b||e._getNextItemKeyInCollection();var f=a+"_"+b;if(!c.has(e,"itemCollection")||!c.isArray(e.itemCollection()))throw new Error("The item collection does not exist or is not properly set in module : "+e.id);return e.isItemRegistered(f)?(b++,d++,e.generateItemId(a,b,d)):f},_getNextItemKeyInCollection:function(){var a=this,b={},d=0;return c.isEmpty(a.itemCollection())?d:(b=c.isArray(a.itemCollection())&&1===c.size(a.itemCollection())?a.itemCollection()[0]:c.max(a.itemCollection(),function(a){return c.isNumber(a.id.replace(/[^\/\d]/g,""))?parseInt(a.id.replace(/[^\/\d]/g,""),10):0}),!c.isUndefined(b)&&c.isNumber(b.id.replace(/[^\/\d]/g,""))&&(d=parseInt(b.id.replace(/[^\/\d]/g,""),10)+1),d)},isItemRegistered:function(a){var b=this;return!c.isUndefined(c.findWhere(b.itemCollection(),{id:a}))},updateItemsCollection:function(a){var d=this,e=d.itemCollection(),f=c.clone(e),g=b.Deferred();if(c.has(a,"collection"))return void d.itemCollection.set(a.collection);if(!c.has(a,"item"))throw new Error("updateItemsCollection, no item provided "+d.control.id+". Aborting");a=c.extend({data:{}},a);var h=c.clone(a.item);return c.findWhere(f,{id:h.id})?c.each(e,function(a,b){a.id==h.id&&(f[b]=h)}):f.push(h),d.itemCollection.set(f,a.data),g.resolve({collection:f,data:a.data}).promise()},_getSortedDOMItemCollection:function(){var a=this,d=c.clone(a.itemCollection()),e=[],f=b.Deferred();if(b("."+a.control.css_attr.single_item,a.container).each(function(a){var f=c.findWhere(d,{id:b(this).attr("data-id")});f&&(e[a]=f)}),d.length!=e.length)throw new Error("There was a problem when re-building the item collection from the DOM in module : "+a.id);return f.resolve(e).promise()},refreshItemCollection:function(){var c=this;c.czr_Item.each(function(a){b.when(c.czr_Item(a.id).container.remove()).done(function(){c.czr_Item.remove(a.id)})}),c.itemCollection=new a.Value([]),c.populateSavedItemCollection()}})}(wp.customize,jQuery,_);var CZRModuleMths=CZRModuleMths||{};!function(a,b,c){b.extend(CZRModuleMths,{getDefaultItemModel:function(a){var d=this;return b.extend(c.clone(d.defaultItemModel),{id:a||""})},_initNewItem:function(a,d){var e,f=this,g={id:""};return d="undefined"!=typeof d?d:c.size(f.itemCollection()),c.isNumber(d)?e=f.module_type+"_"+d:(e=d,d=0),g=a&&!c.isEmpty(a)?b.extend(a,{id:e}):this.getDefaultItemModel(e),c.has(g,"id")&&f._isItemIdPossible(e)?(c.map(f.getDefaultItemModel(),function(a,b){c.has(g,b)||(g[b]=a)}),g):f._initNewItem(g,d+1)}})}(wp.customize,jQuery,_);var CZRModuleMths=CZRModuleMths||{};!function(a,b,c){b.extend(CZRModuleMths,{renderModuleParts:function(){var a=this,c=a.isInSektion()?b(a.container).find(".czr-mod-content"):b(a.container);if(a.isCrud()){if(0===b("#tmpl-"+a.crudModulePart).length)throw new Error("No crud Module Part template for module "+a.id+". The template script id should be : #tmpl-"+a.crudModulePart);c.append(b(wp.template(a.crudModulePart)({})))}var d=b("<ul/>",{"class":[a.control.css_attr.items_wrapper,a.module_type,a.isMultiItem()?"multi-item-mod":"mono-item-mod",a.isCrud()?"crud-mod":"not-crud-mod"].join(" ")});return c.append(d),b(d,c)},getTemplateEl:function(a,b){var d,e=this;switch(a){case"rudItemPart":d=e.rudItemPart;break;case"ruItemPart":d=e.ruItemPart;break;case"modOptInputList":d=e.modOptInputList;break;case"itemInputList":d=e.itemInputList}if(c.isEmpty(d))throw new Error("No valid template has been found in getTemplateEl() "+e.id+". Aborting");return d},getViewEl:function(a){var c=this;return b('[data-id = "'+a+'"]',c.container)},closeAllItems:function(a){var b=this,d=c.clone(b.itemCollection()),e=c.filter(d,function(b){return b.id!=a});return c.each(e,function(a){b.czr_Item.has(a.id)&&"expanded"==b.czr_Item(a.id)._getViewState(a.id)&&b.czr_Item(a.id).viewState.set("closed")}),this},_adjustScrollExpandedBlock:function(a,d){if(a.length&&!c.isUndefined(this.getModuleSection())){var e,f=this,g=b(".accordion-section-content",f.section.container),h=g.scrollTop(),i=d||90;setTimeout(function(){a.offset().top+a.height()+i>b(window.top).height()&&(e=a.offset().top+a.height()+i-b(window.top).height(),e>0&&g.animate({scrollTop:h+e},500))},50)}},closeRemoveDialogs:function(){var a=this;if(c.isArray(a.itemCollection()))return a.czr_Item.each(function(a){a.removeDialogVisible(!1)}),this},_makeItemsSortable:function(d){if(!wp.media.isTouchDevice&&b.fn.sortable){var e=this;b("."+e.control.css_attr.items_wrapper,e.container).sortable({handle:"."+e.control.css_attr.item_sort_handle,start:function(){c.has(a,"czrModulePanelState")&&a.czrModulePanelState.set(!1),c.has(a,"czrSekSettingsPanelState")&&a.czrSekSettingsPanelState.set(!1)},update:function(b,d){var f=function(){c.has(e,"preItem")&&e.preItemExpanded.set(!1),e.closeAllItems().closeRemoveDialogs();var b=function(){a.previewer.refresh()};"postMessage"!=a(e.control.id).transport||a.CZR_Helpers.hasPartRefresh(e.control.id)||(b=c.debounce(b,500))(),e.trigger("item-collection-sorted")};e._getSortedDOMItemCollection().done(function(a){e.itemCollection.set(a)}).then(function(){f()})}})}},toggleTabVisibility:function(a){var c=this,d=(b(c.container).find("li"),b(c.container).find("section"),b(a.dom_event.currentTarget,a.dom_el).attr("data-tab-id"));b(".tabs nav li",c.container).each(function(){b(this).removeClass("tab-current").addClass("tab-inactive")}),b(c.container).find('li[data-tab-id="'+d+'"]').addClass("tab-current").removeClass("tab-inactive"),b("section",c.container).each(function(){b(this).removeClass("content-current")}),b(c.container).find('section[id="'+d+'"]').addClass("content-current")},setupTabNav:function(){var a=this,c=function(){var c=b.Deferred(),d=b(".tabs nav li",a.container);d.each(function(){b(this).removeClass("tab-current").addClass("tab-inactive")}),d.first().addClass("tab-current").removeClass("tab-inactive"),b("section",a.container).first().addClass("content-current");var e=d.length;return d.each(function(){b(this).addClass(e>0?"cols-"+e:"")}),c.resolve().promise()};setTimeout(function(){c().done(function(){b(".tabs",a.container).fadeIn(450)})},20)}})}(wp.customize,jQuery,_);var CZRDynModuleMths=CZRDynModuleMths||{};!function(a,b,c){b.extend(CZRDynModuleMths,{initialize:function(c,d){var e=this;a.CZRModule.prototype.initialize.call(e,c,d),b.extend(e,{itemPreAddEl:""}),e.preItemsWrapper="",e.itemAddedMessage=serverControlParams.i18n.successMessage,e.userEventMap=new a.Value([{trigger:"click keydown",selector:["."+e.control.css_attr.open_pre_add_btn,"."+e.control.css_attr.cancel_pre_add_btn].join(","),name:"pre_add_item",actions:["closeAllItems","closeRemoveDialogs","renderPreItemView","setPreItemViewVisibility"]},{trigger:"click keydown",selector:"."+e.control.css_attr.add_new_btn,name:"add_item",actions:["closeRemoveDialogs","closeAllItems","addItem"]}])},ready:function(){var c=this;c.setupDOMListeners(c.userEventMap(),{dom_el:c.container}),c.preItem=new a.Value(c.getDefaultItemModel()),c.preItemEmbedded=b.Deferred(),c.preItemEmbedded.done(function(a){c.preItemsWrapper=a,c.setupPreItemInputCollection()}),c.preItemExpanded=new a.Value((!1)),c.preItemExpanded.callbacks.add(function(a,b){c._togglePreItemViewExpansion(a)}),a.CZRModule.prototype.ready.call(c)},setupPreItemInputCollection:function(){var c=this;c.preItem.czr_Input=new a.Values,b("."+c.control.css_attr.pre_add_wrapper,c.container).find("."+c.control.css_attr.sub_set_wrapper).each(function(a){var d=b(this).find("[data-type]").attr("data-type")||"sub_set_"+a;c.preItem.czr_Input.add(d,new c.inputConstructor(d,{id:d,type:b(this).attr("data-input-type"),container:b(this),input_parent:c.preItem,module:c,is_preItemInput:!0})),c.preItem.czr_Input(d).ready()})},addItem:function(d){var e=this,f=e.preItem(),g=function(){e.preItemExpanded.set(!1),e._resetPreItemInputs()},h=b.Deferred();return c.isEmpty(f)||!c.isObject(f)?(a.errorLog("addItem : an item should be an object and not empty. In : "+e.id+". Aborted."),h.resolve().promise()):(g=c.debounce(g,200),e.instantiateItem(f,!0).ready(),function(){return b.Deferred(function(){var b=this;e.czr_Item(f.id).isReady.then(function(){g(),e.trigger("item-added",f),"postMessage"!=a(e.control.id).transport||!c.has(d,"dom_event")||c.has(d.dom_event,"isTrigger")||a.CZR_Helpers.hasPartRefresh(e.control.id)?b.resolve():e.control.previewer.refresh().done(function(){b.resolve()})})}).promise()}().done(function(){e.czr_Item(f.id).viewState("expanded")}).always(function(){h.resolve()}),h.promise())},_resetPreItemInputs:function(){var a=this;a.preItem.set(a.getDefaultItemModel()),a.preItem.czr_Input.each(function(b){var d=b.id;c.has(a.getDefaultItemModel(),d)&&b.set(a.getDefaultItemModel()._input_id)})}})}(wp.customize,jQuery,_);var CZRDynModuleMths=CZRDynModuleMths||{};!function(a,b,c){b.extend(CZRDynModuleMths,{renderPreItemView:function(a){var d=this;if("pending"==d.preItemEmbedded.state()){if(!c.has(d,"itemPreAddEl")||0===b("#tmpl-"+d.itemPreAddEl).length)return this;var e=wp.template(d.itemPreAddEl);if(!e||!d.container)return this;var f=b("."+d.control.css_attr.pre_add_item_content,d.container);f.prepend(e()),d.preItemEmbedded.resolve(f)}},_getPreItemView:function(){var a=this;return b("."+a.control.css_attr.pre_add_item_content,a.container)},setPreItemViewVisibility:function(a){var b=this;b.preItemExpanded.set(!b.preItemExpanded())},_togglePreItemViewExpansion:function(a){var c=this,d=b("."+c.control.css_attr.pre_add_item_content,c.container);d.slideToggle({duration:200,done:function(){var d=b("."+c.control.css_attr.open_pre_add_btn,c.container);b(this).toggleClass("open",a),a?d.find(".fa").removeClass("fa-plus-square").addClass("fa-minus-square"):d.find(".fa").removeClass("fa-minus-square").addClass("fa-plus-square"),d.toggleClass("active",a),b(c.container).toggleClass(c.control.css_attr.adding_new,a),c._adjustScrollExpandedBlock(b(this),120)}})},toggleSuccessMessage:function(a){var c=this,d=c.itemAddedMessage,e=b("."+c.control.css_attr.pre_add_wrapper,c.container);return $_success_wrapper=b("."+c.control.css_attr.pre_add_success,c.container),"on"==a?($_success_wrapper.find("p").text(d),$_success_wrapper.css("z-index",1000001).css("height",e.height()+"px").css("line-height",e.height()+"px")):$_success_wrapper.attr("style",""),c.container.toggleClass("czr-model-added","on"==a),this}})}(wp.customize,jQuery,_);var CZRBaseControlMths=CZRBaseControlMths||{};!function(a,b,c){b.extend(CZRBaseControlMths,{initialize:function(b,d){var e=this;e.css_attr=c.has(serverControlParams,"css_attr")?serverControlParams.css_attr:{},a.Control.prototype.initialize.call(e,b,d),e.bind("czr-partial-refresh-done",function(){c.has(e,"czr_moduleCollection")&&c.each(e.czr_moduleCollection(),function(a){e.czr_Module(a.id)&&e.czr_Module(a.id).sendModuleInputsToPreview({isPartialRefresh:!0})})})},refreshPreview:function(a){this.previewer.refresh()}})}(wp.customize,jQuery,_);var CZRBaseModuleControlMths=CZRBaseModuleControlMths||{};!function(a,b,c){b.extend(CZRBaseModuleControlMths,{initialize:function(d,e){var f=this;f.czr_Module=new a.Values,f.czr_moduleCollection=new a.Value,f.czr_moduleCollection.set([]),f.moduleCollectionReady=b.Deferred(),
13
- f.moduleCollectionReady.done(function(a){!f.isMultiModuleControl(e.params),f.czr_moduleCollection.callbacks.add(function(){return f.moduleCollectionReact.apply(f,arguments)})}),f.isMultiModuleControl(e.params)&&(f.syncSektionModule=new a.Value),a.CZRBaseControl.prototype.initialize.call(f,d,e),a.section(f.section()).expanded.bind(function(a){f.czr_Module.each(function(a){a.closeAllItems().closeRemoveDialogs(),c.has(a,"preItem")&&a.preItemExpanded(!1)})})},ready:function(){var b=this;if(b.isMultiModuleControl())b.syncSektionModule.bind(function(a,c){"resolved"!=b.moduleCollectionReady.state()&&(b.registerModulesOnInit(a),b.moduleCollectionReady.resolve())});else{var d={};c.each(b.getSavedModules(),function(c,e){d=c;try{b.instantiateModule(c,{})}catch(f){return void a.errorLog("Failed to instantiate module "+c.id+" "+f)}b.container.attr("data-module",c.id)}),b.moduleCollectionReady.resolve(d)}b.bind("user-module-candidate",function(c){var d;try{d=b.instantiateModule(c,{})}catch(e){return void a.errorLog("Failed to instantiate module "+c.id+" "+e)}d.ready(c.is_added_by_user)})},getDefaultModuleApiModel:function(){var a={id:"",module_type:"",modOpt:{},items:[],crud:!1,multi_item:!1,sortable:!1,control:{}};return this.isMultiModuleControl()?b.extend(a,{column_id:"",sektion:{},sektion_id:"",is_added_by_user:!1,dirty:!1}):b.extend(a,{section:""})},getDefaultModuleDBModel:function(){var a={items:[]};return this.isMultiModuleControl()?b.extend(a,{id:"",module_type:"",column_id:"",sektion_id:"",dirty:!1}):a},isMultiModuleControl:function(a){return"czr_multi_module"==(a||this.params).type},getSyncCollectionControl:function(){var b=this;if(c.isUndefined(b.params.syncCollection))throw new Error("Control "+b.id+" has no synchronized sektion control defined.");return a.control(a.CZR_Helpers.build_setId(b.params.syncCollection))},getSavedModules:function(){var d=this,e=[],f=d.params.module_type,g=[],h=[],i={};return d.isMultiModuleControl()?e=b.extend(!0,[],a(d.id)()):(!a.CZR_Helpers.isMultiItemModule(f)||c.isEmpty(a(d.id)())||c.isObject(a(d.id)())||a.consoleLog("Module Control Init for "+d.id+" : a mono item module control value should be an object if not empty."),g=c.isArray(a(d.id)())?a(d.id)():[a(d.id)()],c.each(g,function(b,e){a.CZR_Helpers.hasModuleModOpt(f)&&0===e&&(c.has(b,"id")?a.consoleLog("getSavedModules : the module "+f+" in control "+d.id+" has no mod_opt defined while it should."):i=b),c.has(b,"id")&&!c.has(b,"is_mod_opt")&&h.push(b)}),e.push({id:a.CZR_Helpers.getOptionName(d.id)+"_"+d.params.type,module_type:d.params.module_type,section:d.section(),modOpt:b.extend(!0,{},i),items:b.extend(!0,[],h)})),e},isModuleRegistered:function(a){var b=this;return!c.isUndefined(c.findWhere(b.czr_moduleCollection(),{id:a}))}})}(wp.customize,jQuery,_);var CZRBaseModuleControlMths=CZRBaseModuleControlMths||{};!function(a,b,c){b.extend(CZRBaseModuleControlMths,{instantiateModule:function(a,b){if(!c.has(a,"id"))throw new Error("CZRModule::instantiateModule() : a module has no id and could not be added in the collection of : "+this.id+". Aborted.");var d=this;if((c.isUndefined(b)||c.isEmpty(b))&&(b=d.getModuleConstructor(a)),!c.isEmpty(a.id)&&d.czr_Module.has(a.id))throw new Error("The module id already exists in the collection in control : "+d.id);var e=d.prepareModuleForAPI(a);if(d.czr_Module.add(e.id,new b(e.id,e)),!d.czr_Module.has(e.id))throw new Error("instantiateModule() : instantiation failed for module id "+e.id+" in control "+d.id);return d.czr_Module(e.id)},getModuleConstructor:function(b){var d=this,e={},f={};if(!c.has(b,"module_type"))throw new Error("CZRModule::getModuleConstructor : no module type found for module "+b.id);if(!c.has(a.czrModuleMap,b.module_type))throw new Error("Module type "+b.module_type+" is not listed in the module map api.czrModuleMap.");var g=a.czrModuleMap[b.module_type].mthds,h=a.czrModuleMap[b.module_type].crud,i=h?a.CZRDynModule:a.CZRModule;if(c.isEmpty(b.sektion_id)?f=i.extend(g):(e=i.extend(g),f=e.extend(d.getMultiModuleExtender(e))),c.isUndefined(f)||c.isEmpty(f)||!f)throw new Error("CZRModule::getModuleConstructor : no constructor found for module type : "+b.module_type+".");return f},prepareModuleForAPI:function(b){if(!c.isObject(b))throw new Error("prepareModuleForAPI : a module must be an object to be instantiated.");var d=this,e={};return c.each(d.getDefaultModuleApiModel(),function(f,g){var h=b[g];switch(g){case"id":c.isEmpty(h)?e[g]=d.generateModuleId(b.module_type):e[g]=h;break;case"module_type":if(!c.isString(h)||c.isEmpty(h))throw new Error("prepareModuleForAPI : a module type must a string not empty");e[g]=h;break;case"items":if(!c.isArray(h))throw new Error("prepareModuleForAPI : a module item list must be an array");e[g]=h;break;case"modOpt":if(!c.isObject(h))throw new Error("prepareModuleForAPI : a module modOpt property must be an object");e[g]=h;break;case"crud":if(c.has(a.czrModuleMap,b.module_type))h=a.czrModuleMap[b.module_type].crud;else if(!c.isUndefined(h)&&!c.isBoolean(h))throw new Error('prepareModuleForAPI : the module param "crud" must be a boolean');e[g]=h||!1;break;case"multi_item":if(c.has(a.czrModuleMap,b.module_type))h=a.czrModuleMap[b.module_type].crud||a.czrModuleMap[b.module_type].multi_item;else if(!c.isUndefined(h)&&!c.isBoolean(h))throw new Error('prepareModuleForAPI : the module param "multi_item" must be a boolean');e[g]=h||!1;break;case"sortable":if(c.has(a.czrModuleMap,b.module_type))h=a.czrModuleMap[b.module_type].sortable||a.czrModuleMap[b.module_type].crud||a.czrModuleMap[b.module_type].multi_item;else if(!c.isUndefined(h)&&!c.isBoolean(h))throw new Error('prepareModuleForAPI : the module param "sortable" must be a boolean');e[g]=h||!1;break;case"control":e[g]=d;break;case"section":if(!c.isString(h)||c.isEmpty(h))throw new Error("prepareModuleForAPI : a module section must be a string not empty");e[g]=h;break;case"column_id":if(!c.isString(h)||c.isEmpty(h))throw new Error("prepareModuleForAPI : a module column id must a string not empty");e[g]=h;break;case"sektion":if(!c.isObject(h)||c.isEmpty(h))throw new Error("prepareModuleForAPI : a module sektion must be an object not empty");e[g]=h;break;case"sektion_id":if(!c.isString(h)||c.isEmpty(h))throw new Error("prepareModuleForAPI : a module sektion id must be a string not empty");e[g]=h;break;case"is_added_by_user":if(!c.isUndefined(h)&&!c.isBoolean(h))throw new Error('prepareModuleForAPI : the module param "is_added_by_user" must be a boolean');e[g]=h||!1;break;case"dirty":e[g]=h||!1}}),e},generateModuleId:function(a,b,d){if(d=d||1,d>100)throw new Error("Infinite loop when generating of a module id.");var e=this;b=b||e._getNextModuleKeyInCollection();var f=a+"_"+b;if(!c.has(e,"czr_moduleCollection")||!c.isArray(e.czr_moduleCollection()))throw new Error("The module collection does not exist or is not properly set in control : "+e.id);return e.isModuleRegistered(f)?(b++,d++,e.generateModuleId(a,b,d)):f},_getNextModuleKeyInCollection:function(){var a=this,b={},d=0;return c.isEmpty(a.czr_moduleCollection())||(b=c.max(a.czr_moduleCollection(),function(a){return parseInt(a.id.replace(/[^\/\d]/g,""),10)}),d=parseInt(b.id.replace(/[^\/\d]/g,""),10)+1),d}})}(wp.customize,jQuery,_);var CZRBaseModuleControlMths=CZRBaseModuleControlMths||{};!function(a,b,c){b.extend(CZRBaseModuleControlMths,{registerModulesOnInit:function(d){var e=this,f=[];c.each(e.getSavedModules(),function(g,h){if(!d.czr_Item.has(g.sektion_id))return a.errorLog("Warning Module "+g.id+" is orphan : it has no sektion to be embedded to. It Must be removed."),void f.push(g);var i=d.czr_Item(g.sektion_id);if(c.isUndefined(i))throw new Error("sektion instance missing. Impossible to instantiate module : "+g.id);b.extend(g,{sektion:i}),e.updateModulesCollection({module:g})}),e.moduleCollectionReady.then(function(){c.isEmpty(f)||e.moduleCollectionReact(e.czr_moduleCollection(),[],{orphans_module_removal:f})})},updateModulesCollection:function(a){var d=this,e=d.czr_moduleCollection(),f=b.extend(!0,[],e);if(c.has(a,"collection"))return void d.czr_moduleCollection.set(a.collection,a.data||{});if(!c.has(a,"module"))throw new Error("updateModulesCollection, no module provided "+d.id+". Aborting");var g=d.prepareModuleForAPI(c.clone(a.module));c.findWhere(f,{id:g.id})?c.each(e,function(a,b){a.id==g.id&&(f[b]=g)}):f.push(g);var h={};c.has(a,"data")&&(h=b.extend(!0,{},a.data),b.extend(h,{module:g})),d.czr_moduleCollection.set(f,h)},moduleCollectionReact:function(d,e,f){var g=this,h=c.size(d)>c.size(e),i=c.size(e)>c.size(d);c.size(e)==c.size(d);if(is_collection_sorted=!1,i){var j=c.filter(e,function(a){return c.isUndefined(c.findWhere(d,{id:a.id}))});j=j[0],g.czr_Module.remove(j.id)}c.isObject(f)&&c.has(f,"module")&&(f.module_id=f.module.id,f.module=g.prepareModuleForDB(b.extend(!0,{},f.module))),!g.isMultiModuleControl()&&h||a(this.id).set(g.filterModuleCollectionBeforeAjax(d),f)},filterModuleCollectionBeforeAjax:function(a){var d,e=this,f=b.extend(!0,[],a);if(c.each(a,function(a,c){var d=b.extend(!0,{},a);f[c]=e.prepareModuleForDB(d)}),e.isMultiModuleControl())return f;if(c.size(a)>1)throw new Error("There should not be several modules in the collection of control : "+e.id);if(!c.isArray(a)||c.isEmpty(a)||!c.has(a[0],"items"))throw new Error("The setting value could not be populated in control : "+e.id);var g=a[0].id;if(!e.czr_Module.has(g))throw new Error("The single module control ("+e.id+") has no module registered with the id "+g);var h=e.czr_Module(g);if(!c.isArray(h().items))throw new Error("The module "+g+" should be an array in control : "+e.id);return d=h.isMultiItem()?h().items:h().items[0]||[],h.hasModOpt()?c.union([h().modOpt],d):d},prepareModuleForDB:function(a){if(!c.isObject(a))throw new Error("MultiModule Control::prepareModuleForDB : a module must be an object. Aborting.");var b=this,d={};return c.each(b.getDefaultModuleDBModel(),function(e,f){if(!c.has(a,f))throw new Error("MultiModule Control::prepareModuleForDB : a module is missing the property : "+f+" . Aborting.");var g=a[f];switch(f){case"items":if(!c.isArray(g))throw new Error("prepareModuleForDB : a module item list must be an array");d[f]=g;break;case"id":if(!c.isString(g)||c.isEmpty(g))throw new Error("prepareModuleForDB : a module id must a string not empty");d[f]=g;break;case"module_type":if(!c.isString(g)||c.isEmpty(g))throw new Error("prepareModuleForDB : a module type must a string not empty");d[f]=g;break;case"column_id":if(!c.isString(g)||c.isEmpty(g))throw new Error("prepareModuleForDB : a module column id must a string not empty");d[f]=g;break;case"sektion_id":if(!c.isObject(a.sektion)||!c.has(a.sektion,"id"))throw new Error("prepareModuleForDB : a module sektion must be an object with an id.");d[f]=a.sektion.id;break;case"dirty":if(b.czr_Module.has(a.id)?d[f]=b.czr_Module(a.id).isDirty():d[f]=g,!c.isBoolean(d[f]))throw new Error("prepareModuleForDB : a module dirty state must be a boolean.")}}),d}})}(wp.customize,jQuery,_);var CZRMultiModuleControlMths=CZRMultiModuleControlMths||{};!function(a,b,c){b.extend(CZRMultiModuleControlMths,{initialize:function(b,c){var d=this;a.consoleLog("IN MULTI MODULE INITIALIZE ? ",c),a(b).callbacks.add(function(){return d.syncColumn.apply(d,arguments)}),a.CZRBaseModuleControl.prototype.initialize.call(d,b,c)},ready:function(){var b=this;a.consoleLog("MODULE-COLLECTION CONTROL READY",this.id),a.CZRBaseModuleControl.prototype.ready.apply(b,arguments)},syncColumn:function(d,e,f){if(a.consoleLog("IN SYNC COLUMN",d,e,f),(c.isUndefined(f)||!f.silent)&&(a.consoleLog("IN SYNXXX",a.control("hu_theme_options[module-collection]").syncSektionModule()(),this.syncSektionModule()(),this.id),!c.has(f,"orphans_module_removal"))){var g=a.control(this.id),h=c.filter(d,function(a,b){return!c.findWhere(e,{id:a.id})});c.isEmpty(h)||(a.consoleLog("ADDED MODULE?",h),c.each(h,function(a){g.syncSektionModule().czr_Column(a.column_id).updateColumnModuleCollection({module:a})}));var i=c.filter(e,function(a,b){return!c.findWhere(d,{id:a.id})});c.isEmpty(i)||c.each(i,function(a){g.syncSektionModule().czr_Column(a.column_id).removeModuleFromColumnCollection(a)}),c.size(e)==c.size(d)&&c.has(f,"module")&&c.has(f,"source_column")&&c.has(f,"target_column")&&b.when(g.syncSektionModule().moveModuleFromTo(f.module,f.source_column,f.target_column)).done(function(){g.syncSektionModule().control.trigger("module-moved",{module:f.module,source_column:f.source_column,target_column:f.target_column})}),g.trigger("columns-synchronized",d)}},removeModule:function(a){var b=this;b.czr_Module.has(a.id)&&"resolved"==b.czr_Module(a.id).embedded.state()&&b.czr_Module(a.id).container.remove(),b.removeModuleFromCollection(a)},removeModuleFromCollection:function(a){var d=this,e=d.czr_moduleCollection(),f=b.extend(!0,[],e);f=c.filter(f,function(b){return b.id!=a.id}),d.czr_moduleCollection.set(f)}})}(wp.customize,jQuery,_);var CZRMultiModuleControlMths=CZRMultiModuleControlMths||{};!function(a,b,c){b.extend(CZRMultiModuleControlMths,{getMultiModuleExtender:function(d){var e=this;return b.extend(e.CZRModuleExtended,{initialize:function(c,e){var f=this;d.prototype.initialize.call(f,c,e),a.consoleLog("MODULE INSTANTIATED : ",f.id),b.extend(f,{singleModuleWrapper:"czr-single-module-wrapper",sektionModuleTitle:"czr-module-sektion-title-part",ruModuleEl:"czr-ru-module-sektion-content"}),f.czr_ModuleState=new a.Value((!1)),f.isReady.done(function(){f.setupModuleView()}),f.moduleTitleEmbedded=b.Deferred(),f.modColumn=new a.Value,f.modColumn.set(e.column_id),f.modColumn.bind(function(c,d){a.consoleLog("MODULE "+f.id+" HAS BEEN MOVED TO COLUMN",c,f());var e=f(),g=b.extend(!0,{},e);g.column_id=c,f.set(g,{target_column:c,source_column:d})})},ready:function(e){var f=this;a.consoleLog("MODULE READY IN EXTENDED MODULE CLASS : ",f.id),b.when(f.renderModuleWrapper(e)).done(function(a){if(c.isUndefined(a)||!1===a.length)throw new Error("Module container has not been embedded for module :"+f.id);f.container=a,f.embedded.resolve()}),d.prototype.ready.call(f)}}),e.CZRModuleExtended},CZRModuleExtended:{renderModuleWrapper:function(a){var c=this;if("resolved"==c.embedded.state())return c.container;if(0===b("#tmpl-"+c.singleModuleWrapper).length)throw new Error("No template for module "+c.id+". The template script id should be : #tmpl-"+c.singleModuleWrapper);var d=wp.template(c.singleModuleWrapper),e={id:c.id,type:c.module_type},f=b(d(e));return a?b.when(b(".czr-module-collection-wrapper",c._getColumn().container).find(".czr-module-candidate").after(f)).done(function(){b(".czr-module-collection-wrapper",c._getColumn().container).find(".czr-module-candidate").remove()}):b(".czr-module-collection-wrapper",c._getColumn().container).append(f),f},setupModuleView:function(){var b=this;b.view_event_map=[{trigger:"click keydown",selector:[".czr-remove-mod","."+b.control.css_attr.cancel_alert_btn].join(","),name:"toggle_remove_alert",actions:["toggleModuleRemoveAlert"]},{trigger:"click keydown",selector:"."+b.control.css_attr.remove_view_btn,name:"remove_module",actions:["removeModule"]},{trigger:"click keydown",selector:".czr-edit-mod",name:"edit_module",actions:["setModuleViewVisibility","sendEditModule"]},{trigger:"click keydown",selector:".czr-module-back",name:"back_to_column",actions:["setModuleViewVisibility"]},{trigger:"mouseenter",selector:".czr-mod-header",name:"hovering_module",actions:function(a){b.control.previewer.send("start_hovering_module",{id:b.id})}},{trigger:"mouseleave",selector:".czr-mod-header",name:"hovering_module",actions:function(a){b.control.previewer.send("stop_hovering_module",{id:b.id})}}],b.embedded.done(function(){b.czr_ModuleState.callbacks.add(function(){return b.setupModuleViewStateListeners.apply(b,arguments)}),a.CZR_Helpers.setupDOMListeners(b.view_event_map,{module:{id:b.id},dom_el:b.container},b)})},setModuleViewVisibility:function(c,d){var e=this;e.czr_ModuleState(!e.czr_ModuleState()),a.czrModulePanelState.set(!1),a.czrSekSettingsPanelState.set(!1),e.control.syncSektionModule().closeAllOtherSektions(b(c.dom_event.currentTarget,c.dom_el))},sendEditModule:function(a){var b=this;b.control.previewer.send("edit_module",{id:b.id})},setupModuleViewStateListeners:function(c){var d=this;a.czr_isModuleExpanded=a.czr_isModuleExpanded||new a.Value,c?a.czr_isModuleExpanded(d):a.czr_isModuleExpanded(!1),b.when(d.toggleModuleViewExpansion(c)).done(function(){c?(d.renderModuleTitle(),d.populateSavedItemCollection()):d.czr_Item.each(function(a){a.viewState.set("closed"),a._destroyView(0),d.czr_Item.remove(a.id)})})},renderModuleTitle:function(){var a=this;if("resolved"!=a.moduleTitleEmbedded.state()){if(0===b("#tmpl-"+a.sektionModuleTitle).length)throw new Error("No sektion title Module Part template for module "+a.id+". The template script id should be : #tmpl-"+a.sektionModuleTitle);b.when(b(a.container).find(".czr-mod-content").prepend(b(wp.template(a.sektionModuleTitle)({id:a.id})))).done(function(){a.moduleTitleEmbedded.resolve()})}},toggleModuleViewExpansion:function(a,c){var d=this;b(".czr-mod-content",d.container).slideToggle({duration:c||200,done:function(){var b=d.container.closest(".wp-full-overlay"),c=d.container.find(".czr-module-back"),e=d.container.find(".czr-module-title");d.container.toggleClass("open",a),b.toggleClass("czr-module-open",a),e.attr("tabindex",a?"-1":"0"),c.attr("tabindex",a?"0":"-1"),a?c.focus():e.focus(),a&&d._adjustScrollExpandedBlock(d.container)}})},toggleModuleRemoveAlert:function(a){var d=this,e=this.control,f=b("."+d.control.css_attr.remove_alert_wrapper,d.container).first(),g=(a.dom_event,e.syncSektionModule().czr_Column(d.column_id).container);if(c.has(d,"preItem")&&e.syncSektionModule().preItemExpanded.set(!1),b("."+d.control.css_attr.remove_alert_wrapper,g).not(f).each(function(){b(this).hasClass("open")&&b(this).slideToggle({duration:200,done:function(){b(this).toggleClass("open",!1),b(this).siblings().find("."+d.control.css_attr.display_alert_btn).toggleClass("active",!1)}})}),!wp.template(d.AlertPart)||!d.container)throw new Error("No removal alert template available for module :"+d.id);f.html(wp.template(d.AlertPart)({title:d().title||d.id})),f.slideToggle({duration:200,done:function(){var c=!b(this).hasClass("open")&&b(this).is(":visible");b(this).toggleClass("open",c),b(a.dom_el).find("."+d.control.css_attr.display_alert_btn).toggleClass("active",c),c&&d._adjustScrollExpandedBlock(d.container)}})},removeModule:function(a){this.control.removeModule(a.module)},_getColumn:function(){var a=this;return a.control.syncSektionModule().czr_Column(a.modColumn())},_getSektion:function(){}}})}(wp.customize,jQuery,_),function(a,b,c){b.extend(CZRBaseControlMths,a.Events),b.extend(a.Control.prototype,a.Events),b.extend(CZRModuleMths,a.Events),b.extend(CZRItemMths,a.Events),b.extend(CZRModOptMths,a.Events),b.extend(CZRBaseControlMths,a.CZR_Helpers),b.extend(CZRInputMths,a.CZR_Helpers),b.extend(CZRModuleMths,a.CZR_Helpers),a.CZRInput=a.Value.extend(CZRInputMths),a.czrInputMap=a.czrInputMap||{},b.extend(a.czrInputMap,{text:"",textarea:"",check:"setupIcheck",select:"setupSelect",number:"setupStepper",upload:"setupImageUploader",color:"setupColorPicker",content_picker:"setupContentPicker",text_editor:"setupTextEditor",password:"",range_slider:"setupRangeSlider"}),a.CZRItem=a.Value.extend(CZRItemMths),a.CZRModOpt=a.Value.extend(CZRModOptMths),a.CZRModule=a.Value.extend(CZRModuleMths),a.CZRDynModule=a.CZRModule.extend(CZRDynModuleMths),c.isUndefined(window.CZRColumnMths)||(a.CZRColumn=a.Value.extend(CZRColumnMths)),a.CZRBaseControl=a.Control.extend(CZRBaseControlMths),a.CZRBaseModuleControl=a.CZRBaseControl.extend(CZRBaseModuleControlMths),a.CZRMultiModuleControl=a.CZRBaseModuleControl.extend(CZRMultiModuleControlMths),b.extend(a.controlConstructor,{czr_module:a.CZRBaseModuleControl,czr_multi_module:a.CZRMultiModuleControl})}(wp.customize,jQuery,_),function(a,b,c){a.bind("ready",function(){if(serverControlParams.isSkopOn){var d=a.previewer.query;a.previewer.query=function(e){if(!serverControlParams.isSkopOn)return d.apply(this);if(!c.has(a,"czr_skope"))return a.consoleLog("QUERY : SKOPE IS NOT FULLY READY YEY. FALLING BACK ON CORE QUERY"),d.apply(this);if("pending"==a.czr_initialSkopeCollectionPopulated.state())return a.consoleLog("QUERY : INITIAL SKOPE COLLECTION NOT POPULATED YET. FALLING BACK ON CORE QUERY"),d.apply(this);if("pending"==a.czr_isPreviewerSkopeAware.state()&&a.czr_isPreviewerSkopeAware.resolve(),!c.isObject(e)&&"resolved"==a.czr_initialSkopeCollectionPopulated.state()&&"resolved"==a.czr_initialSkopeCollectionPopulated.state())return d.apply(this);!c.isUndefined(e.skope_id)&&c.isString(e.skope_id)||(e.skope_id=a.czr_activeSkopeId()||a.czr_skopeBase.getGlobalSkopeId());var f,g={},h={},i={skope_id:null,action:null,the_dirties:{},dyn_type:null,opt_name:null};if(e=b.extend(i,e),!c.isObject(e.the_dirties))throw a.consoleLog("QUERY PARAMS : ",e),new Error("QUERY DIRTIES MUST BE AN OBJECT. Requested action : "+e.action);if("pending"!=a.czr_isPreviewerSkopeAware.state()&&c.isNull(e.skope_id))throw a.consoleLog("QUERY PARAMS : ",e),new Error("OVERRIDEN QUERY : NO SKOPE ID. FALLING BACK ON CORE QUERY. Requested action : "+e.action);if(!c.contains([null,"refresh","save","reset","changeset_update"],e.action))throw a.consoleLog("QUERY PARAMS : ",e),new Error("A REQUESTED QUERY HAS NO AUTHORIZED ACTION. Requested action : "+e.action);var j=function(){if("pending"==a.czr_initialSkopeCollectionPopulated.state())return{};var b={};return c.each(a.czr_currentSkopesCollection(),function(c){"global"!=c.skope&&(b[c.id]=a.czr_skopeBase.getSkopeDirties(c.id))}),b};switch(c.isNull(e.the_dirties)||c.isEmpty(e.the_dirties)?(g=a.dirtyValues({unsaved:e.excludeCustomizedSaved||!1}),h=j()):"global"==a.czr_skopeBase.getActiveSkopeName()?g=e.the_dirties:h[a.czr_activeSkopeId()]=e.the_dirties,e.action){case null:case"refresh":break;case"changeset_update":if(c.isUndefined(e.opt_name))throw new Error("Missing opt_name param in the changeset_update query for skope : "+e.skope_id);break;case"save":if(c.isNull(e.dyn_type)&&(e.dyn_type=a.czr_skope(e.skope_id)().dyn_type),c.isNull(e.dyn_type)||c.isUndefined(e.dyn_type))throw new Error("QUERY : A SAVE QUERY MUST HAVE A VALID DYN TYPE."+e.skope_id);break;case"reset":if(c.isNull(e.dyn_type)&&(e.dyn_type=a.czr_skope(e.skope_id)().dyn_type),c.isNull(e.dyn_type)||c.isUndefined(e.dyn_type))throw new Error("QUERY : A RESET QUERY MUST HAVE A VALID DYN TYPE."+e.skope_id)}var k={};return c.each(a.czr_currentSkopesCollection(),function(a){k[a.skope]={id:a.id,opt_name:a.opt_name}}),f={wp_customize:"on",customized:"{}"==JSON.stringify(g)?'{"__not_customized__"}':JSON.stringify(g),skopeCustomized:JSON.stringify(h),nonce:this.nonce.preview,skope:a.czr_skope(e.skope_id)().skope,level_id:a.czr_skope(e.skope_id)().level,skope_id:e.skope_id,dyn_type:e.dyn_type,opt_name:c.isNull(e.opt_name)?a.czr_skope(e.skope_id)().opt_name:e.opt_name,obj_id:a.czr_skope(e.skope_id)().obj_id,current_skopes:JSON.stringify(k)||{},channel:this.channel(),revisionIndex:a._latestRevision},f=a.czr_isChangeSetOn()?b.extend(f,{customize_theme:a.settings.theme.stylesheet,customize_changeset_uuid:a.settings.changeset.uuid}):b.extend(f,{theme:a.settings.theme.stylesheet})}}})}(wp.customize,jQuery,_),function(a,b,c){a.bind("czr-skope-started",function(){a.previewer.save=function(b){return a.czr_skopeSave.save()}})}(wp.customize,jQuery,_),function(a,b,c){if(serverControlParams.isSkopOn){a.Element.synchronizer.checkbox.update=function(a){this.element.prop("checked",a),this.element.iCheck("update")};var d=a.Element.synchronizer.val.update;a.Element.synchronizer.val.update=function(b){var c=this,e=function(){c.element.is("select")?c.element.val(b).trigger("change"):c.element.hasClass("wp-color-picker")?c.element.val(b).trigger("change"):c.element.val(b)};if(serverControlParams.isSkopOn){if("resolved"!=a.czr_skopeReady.state())return d.call(c,b);a.czr_skopeReady.then(function(){e()})}else e()},a.Element.synchronizer.val.refresh=function(){var a=this;return this.element.is("select")&&c.isNull(this.element.val())?c.isArray(a())?[]:c.isObject(a())?{}:"":this.element.val()}}}(wp.customize,jQuery,_),function(a,b,c){var d=a.Previewer.prototype.refresh,e=function(e){e=c.extend({waitSkopeSynced:!0,the_dirties:{}},e);var f=this,g=b.Deferred();if(!serverControlParams.isSkopOn)return g.resolve().promise();if(!c.has(a,"czr_activeSkopeId")||c.isUndefined(a.czr_activeSkopeId()))return a.consoleLog("The api.czr_activeSkopeId() is undefined in the api.previewer._new_refresh() method."),d.apply(f),g.resolve().promise();f.send("loading-initiated"),f.abort();var h=a.czr_getSkopeQueryParams({skope_id:a.czr_activeSkopeId(),action:"refresh",the_dirties:e.the_dirties||{}});return f.loading=new a.PreviewFrame({url:f.url(),previewUrl:f.previewUrl(),query:f.query(h)||{},container:f.container,signature:"WP_CUSTOMIZER_SIGNATURE"}),f.settingsModifiedWhileLoading={},onSettingChange=function(a){f.settingsModifiedWhileLoading[a.id]=!0},a.bind("change",onSettingChange),f.loading.always(function(){a.unbind("change",onSettingChange)}),a.czr_isChangeSetOn()||(f._previousPreview=f._previousPreview||f.preview),f.loading.done(function(b){var c,d=this;f.preview=d,f.targetWindow(d.targetWindow()),f.channel(d.channel()),c=function(b){d.unbind("synced",c),d.unbind("czr-skopes-synced",c),f._previousPreview?f._previousPreview.destroy():f.preview&&f.preview.destroy(),f._previousPreview=f.preview,f.deferred.active.resolve(),delete f.loading,a.trigger("pre_refresh_done",{previewer:f,skopesServerData:b||{}}),g.resolve({previewer:f,skopesServerData:b||{}})},a.czr_isChangeSetOn()||f.send("sync",{scroll:f.scroll,settings:a.get()}),e.waitSkopeSynced?d.bind("czr-skopes-synced",c):d.bind("synced",c),f.trigger("ready",b)}),f.loading.fail(function(b,c){a.consoleLog("LOADING FAILED : ",arguments),f.send("loading-failed"),a.czr_isChangeSetOn()||"redirect"===b&&c&&f.previewUrl(c),"logged out"===b&&(f.preview&&(f.preview.destroy(),delete f.preview),f.login().done(f.refresh)),"cheatin"===b&&f.cheatin(),g.reject(b)}),g.promise()};a.bind("czr-skope-started",function(){czr_override_refresh_for_skope(),a.Previewer.prototype.refresh=e}),a.czr_getSkopeQueryParams=function(d){if(!a.czr_isChangeSetOn())return d;d=c.isObject(d)?d:{};var e=d.action||"refresh";switch(e){case"refresh":d=b.extend(d,{excludeCustomizedSaved:!0})}return d},czr_override_refresh_for_skope=function(){serverControlParams.isSkopOn&&(a.previewer.refresh=function(d){var f=b.Deferred(),g=function(b){var c,d=function(){return 0===a.state("processing").get()},g=function(){e.call(a.previewer,b).done(function(a){f.resolve(a)})};d()?g():(c=function(){d()&&(g(),a.state("processing").unbind(c))},a.state("processing").bind(c))};return g=c.debounce(g,a.previewer.refreshBuffer),g(d),f.promise()})}}(wp.customize,jQuery,_),function(a,b,c){serverControlParams.isSkopOn&&(a.dirtyValues=function(b){return a.czr_skopeBase.getSkopeDirties(a.czr_skopeBase.getGlobalSkopeId(),b)})}(wp.customize,jQuery,_),function(a,b,c){if(serverControlParams.isSkopOn&&a.czr_isChangeSetOn()){var d=a.requestChangesetUpdate;a.requestChangesetUpdate=function(e){var f=b.Deferred(),g=[],h=[],i=e||{},j=[],k=[],l=b.Deferred();if(!serverControlParams.isSkopOn)return d();(0===a._lastSavedRevision||c.isEmpty(a.state("changesetStatus")()))&&(i=c.extend(i,{blogname:{dummy_change:"dummy_change"}})),c.each(a.czr_currentSkopesCollection(),function(a){"global"!=a.skope&&g.push(a.id)});var m=function(d){if(c.isUndefined(g[d+1])&&h.length==g.length){if(c.isEmpty(j))l.resolve(k);else{var e=function(){var d=[];return c.each(j,function(b){d.push(a.czr_skopeBase.buildServerResponse(b))}),b.trim(d.join(" | "))};l.reject(e())}return!0}},n=function(b){return(c.isUndefined(b)||0==b)&&a.state("processing").set(1),b=b||0,c.isUndefined(g[b])?(a.consoleLog("Undefined Skope in changeset recursive call ",b,g,g[b]),l.resolve(k).promise()):(a._requestSkopeChangetsetUpdate(e,g[b]).always(function(){h.push(b)}).fail(function(c){j.push(c),a.consoleLog("CHANGESET UPDATE RECURSIVE FAIL FOR SKOPE : ",g[b]),m(b)||n(b+1)}).done(function(a){k.push(a),m(b)||n(b+1)}),l.promise())},o=a._lastSavedRevision;return d(i).fail(function(b){a.consoleLog("WP requestChangesetUpdateFail",b,a.czr_skopeBase.buildServerResponse(b)),a._lastSavedRevision=Math.max(a._latestRevision,a._lastSavedRevision),a.state("processing").set(0),f.reject(b),b=a.czr_skopeBase.buildServerResponse(b),a.czr_serverNotification({message:b,status:"error"})}).done(function(b){"pending"==a.czr_initialSkopeCollectionPopulated.state()&&f.resolve(b),a._lastSavedRevision=o,n().always(function(){a._lastSavedRevision=Math.max(a._latestRevision,a._lastSavedRevision),a.state("processing").set(0)}).fail(function(b){f.reject(b),a.consoleLog("CHANGESET UPDATE RECURSIVE PUSH FAIL",b,k),a.trigger("changeset-error",b),a.czr_serverNotification({message:b,status:"error"})}).done(function(){f.resolve(b)})}),f.promise()},a._requestSkopeChangetsetUpdate=function(d,e){if(c.isUndefined(e)||!a.czr_skope.has(e))throw new Error("In api._requestSkopeChangetsetUpdate() : a valid and registered skope_id must be provided");var f,g=new b.Deferred,h={};if(e=e||a.czr_activeSkopeId(),d&&c.extend(h,d),c.each(a.czr_skopeBase.getSkopeDirties(e),function(a,b){d&&null===d[b]||(h[b]=c.extend({},h[b]||{},{value:a}))}),c.isEmpty(h))return g.resolve({}),g.promise();if(a._latestRevision<=a._lastSavedRevision)return g.resolve({}),g.promise();a.trigger("skope-changeset-save",h);var i={skope_id:e,action:"changeset_update",opt_name:a.czr_skope(e).opt_name};return f=a.previewer.query(c.extend(i,{excludeCustomizedSaved:!0})),delete f.customized,c.extend(f,{nonce:a.settings.nonce.save,customize_changeset_data:JSON.stringify(h)}),wp.ajax.post("customize_skope_changeset_save",f).done(function(a){g.resolve(a)}).fail(function(b){a.consoleLog("SKOPE CHANGESET FAIL FOR SKOPE "+b.skope_id,b),g.reject(b)}).always(function(b){b.setting_validities&&a._handleSettingValidities({settingValidities:b.setting_validities})}),g.promise()}}}(wp.customize,jQuery,_),function(a,b,c){a.czr_skopeReady=b.Deferred(),a.bind("ready",function(){if(serverControlParams.isSkopOn){a.czr_isLoadingSkope=new a.Value((!1)),a.czr_isLoadingSkope.bind(function(a){d(a)}),a.czr_skopeBase=new a.CZR_skopeBase,a.czr_skopeSave=new a.CZR_skopeSave,a.czr_skopeReset=new a.CZR_skopeReset,a.trigger("czr-skope-started");var b=function(){a.czr_skopeBase.toggleTopNote(!0,{title:serverControlParams.i18n.skope["There was a problem when trying to load the customizer."],message:[serverControlParams.i18n.skope["Please refer to"],'<a href="http://docs.presscustomizr.com/article/285-there-was-a-problem-when-trying-to-load-the-customizer" target="_blank">',serverControlParams.i18n.skope["this documentation page"],"</a>",serverControlParams.i18n.skope["to understand how to fix the problem."]].join(" "),selfCloseAfter:4e4})};a.czr_skopeReady.done(function(){a.trigger("czr-skope-ready")}).fail(function(c){a.errorLog("Skope could not be instantiated : "+c),b(),serverControlParams.isSkopOn=!1}).always(function(){a.czr_isLoadingSkope(!1)}),"rejected"!=a.czr_skopeReady.state()&&setTimeout(function(){"pending"==a.czr_skopeReady.state()&&(b(),a.czr_isLoadingSkope(!1))},4e4)}serverControlParams.isChangeSetOn&&(a.settings.timeouts.changesetAutoSave=1e4)}),c.has(a,"_latestRevision")||(a._latestRevision=0,a._latestSettingRevisions={},a.bind("change",function(b){a._latestRevision+=1,a._latestSettingRevisions[b.id]=a._latestRevision}),a.bind("ready",function(){a.bind("add",function(b){b._dirty&&(a._latestRevision+=1,a._latestSettingRevisions[b.id]=a._latestRevision)})}));var d=function(d){d=!!c.isUndefined(d)||d;var e,f=function(){var c=b.Deferred();try{_tmpl=wp.template("czr-skope-pane")({is_skope_loading:!0})}catch(d){a.errorLog("In toggleSkopeLoadPane : error when parsing the the reset skope template : "+d),c.resolve(!1)}return b.when(b("#customize-preview").after(b(_tmpl))).always(function(){c.resolve(b("#czr-skope-pane"));
14
- }),c.promise()},g=function(){c.delay(function(){b.when(b("body").removeClass("czr-skope-pane-open")).done(function(){c.delay(function(){b.when(b("body").removeClass("czr-skop-loading")).done(function(){!1!==b("#czr-skope-pane").length&&setTimeout(function(){b("#czr-skope-pane").remove()},400)})},200)})},50)};"pending"==a.czr_skopeReady.state()&&d&&(b("body").addClass("czr-skop-loading"),f().done(function(a){e=a}).then(function(){e.length&&c.delay(function(){var a=b("#customize-preview").height();e.css("line-height",a+"px").css("height",a+"px"),b("body").addClass("czr-skope-pane-open")},50)})),a.czr_skopeReady.done(function(){g()}),d||g()}}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{globalSettingVal:{},initialize:function(){var d=this;d.skope_colors={global:"rgb(255, 255, 255)",special_group:"rgba(173, 213, 247, 0.55)",group:"rgba(39, 59, 88, 0.12)",local:"rgba(39, 59, 88, 0.28)"},a.czr_isPreviewerSkopeAware=b.Deferred(),a.czr_initialSkopeCollectionPopulated=b.Deferred(),d.skopeWrapperEmbedded=b.Deferred(),a.czr_skope=new a.Values,a.czr_skopeCollection=new a.Value([]),a.czr_currentSkopesCollection=new a.Value([]),a.czr_activeSkopeId=new a.Value,a.czr_dirtyness=new a.Value((!1)),a.czr_isResettingSkope=new a.Value((!1)),a.state.create("switching-skope")(!1),a.czr_dirtyness.callbacks.add(function(){return d.apiDirtynessReact.apply(d,arguments)}),a.czr_isLoadingSkope(!0),d.bindAPISettings(),a.state.bind("change",function(){d.setSaveButtonStates()}),a.czr_skopeReady.then(function(){"pending"==d.skopeWrapperEmbedded.state()&&b.when(d.embedSkopeWrapper()).done(function(){d.skopeWrapperEmbedded.resolve()})}),a.previewer.bind("czr-skopes-synced",function(b){if(serverControlParams.isSkopOn&&"rejected"!=a.czr_skopeReady.state()){var e=this,f=a.czr_currentSkopesCollection();if(!c.has(b,"czr_skopes"))return"resolved"!=a.czr_skopeReady.state()&&a.czr_skopeReady.reject(),void a.errorLog("On 'czr-skopes-synced' : missing skopes in the server data");try{a.czr_skopeBase.updateSkopeCollection(b.czr_skopes,e.channel())}catch(g){return void a.czr_skopeReady.reject(g)}var h=function(){d._writeCurrentSkopeTitle(),a.czr_bottomInfosVisible()?d.renderBottomInfosTmpl():a.czr_bottomInfosVisible(!0)};a.czr_initialSkopeCollectionPopulated.then(function(){var e=c.isUndefined(c.findWhere(a.czr_currentSkopesCollection(),{id:a.czr_activeSkopeId()}));a.czr_skopeBase.reactWhenSkopeSyncedDone(b).done(function(){if(e)try{a.czr_activeSkopeId(d.getActiveSkopeId()).done(function(){"resolved"!=a.czr_skopeReady.state()&&a.czr_skopeReady.resolve(d.getActiveSkopeId()),h()}).fail(function(){throw new Error("Error when trying to set the active skope after skope synced.")})}catch(g){a.errorLog("In reactWhenSkopeSyncedDone => api.czr_activeSkopeId() : "+g)}else if(!c.isEmpty(f)){var i=c.findWhere(f,{skope:"local"}).opt_name,j=c.findWhere(b.czr_skopes,{skope:"local"}).opt_name;j!==i&&"resolved"==a.czr_skopeReady.state()&&h()}})})}}),a.czr_currentSkopesCollection.bind(function(a,b){return d.currentSkopesCollectionReact(a,b)},{deferred:!0}),a.czr_initialSkopeCollectionPopulated.done(function(){a.czr_activeSkopeId.bind(function(b,e){return c.has(a,"czr_ModOptVisible")&&a.czr_ModOptVisible(!1),d.activeSkopeReact(b,e).then(function(c){a.trigger("skope-switched-done",{current_skope_id:b,previous_skope_id:e,updated_setting_ids:c||[]})})},{deferred:!0}),a.czr_activeSectionId.callbacks.add(function(){return d.activeSectionReact.apply(d,arguments)}),a.czr_activePanelId.callbacks.add(function(){return d.activePanelReact.apply(d,arguments)})}),a.bind("skope-switched-done",function(a){return a=c.extend({current_skope_id:"",previous_skope_id:"",updated_setting_ids:[]},a),d.skopeSwitchedDoneReact(a)}),a.czr_serverNotification=new a.Value({status:"success",message:"",expanded:!0}),a.czr_serverNotification.bind(function(a,b){d.toggleServerNotice(a)}),d._setupPreviewNotificationsBlocks(),d.scopeSwitcherEventMap=[{trigger:"click keydown",selector:".czr-dismiss-notification",name:"dismiss-notification",actions:function(){a.czr_serverNotification({expanded:!1})}},{trigger:"click keydown",selector:".czr-toggle-title-notice",name:"toggle-title-notice",actions:function(b){c.isUndefined(d.skopeTitleNoticeVisible)&&(d.skopeTitleNoticeVisible=new a.Value((!1)),d.skopeTitleNoticeVisible.bind(function(a){b.dom_el.find(".czr-skope-title").toggleClass("notice-visible",a)})),d.skopeTitleNoticeVisible(!d.skopeTitleNoticeVisible())}}],d.skopeWrapperEmbedded.then(function(){a.CZR_Helpers.setupDOMListeners(d.scopeSwitcherEventMap,{dom_el:b(".czr-scope-switcher")},d)}),d.refreshedControls=["czr_cropped_image"],d.initWidgetSidebarSpecifics(),a.bind("czr-paint",function(b){a.czr_skopeReady.then(function(){d.wash(b).paint(b)})})},embedSkopeWrapper:function(){var d=this;b("#customize-header-actions").append(b("<div/>",{"class":"czr-scope-switcher",html:'<div class="czr-skopes-wrapper"></div>'})),b("body").addClass("czr-skop-on");var e=[{trigger:"click keydown",selector:".czr-skope-switch",name:"control_skope_switch",actions:function(d){var e=b(d.dom_event.currentTarget,d.dom_el).attr("data-skope-id");!c.isEmpty(e)&&a.czr_skope.has(e)&&a.czr_activeSkopeId(e)}}];a.CZR_Helpers.setupDOMListeners(e,{dom_el:b(".czr-scope-switcher")},d)},apiDirtynessReact:function(c){b("body").toggleClass("czr-api-dirty",c),a.state("saved")(!c)},setSaveButtonStates:function(){a.state.has("saving")||(a.state.create("saving"),a.state("saving").bind(function(a){b(document.body).toggleClass("saving",a)}));var c=b("#save"),d=b(".customize-controls-close"),e=a.state("saved"),f=a.state("saving"),g=a.state("activated"),h=a.state.has("changesetStatus")?a.state("changesetStatus")():"auto-draft";a.czr_dirtyness()||!e()?(c.val(a.l10n.save),d.find(".screen-reader-text").text(a.l10n.cancel)):(c.val(a.l10n.saved),d.find(".screen-reader-text").text(a.l10n.close));var i=!(f()||g()&&e()||"publish"===h);c.prop("disabled",!i)},skopeSwitchedDoneReact:function(d){var e=this,f=function(){a.czr_CrtlDependenciesReady.then(function(){if(!c.isUndefined(a.czr_activeSectionId())&&!c.isEmpty(a.czr_activeSectionId()))try{a.czr_ctrlDependencies.setServiDependencies(a.czr_activeSectionId(),null,!0)}catch(b){a.errorLog("On skope-switched-done : "+b)}}),e.updateCtrlSkpNot(a.CZR_Helpers.getSectionControlIds()),a.czr_skope.has(d.previous_skope_id)&&b("#customize-controls").removeClass(["czr-",a.czr_skope(d.previous_skope_id)().skope,"-skope-level"].join("")),a.czr_skope.has(d.current_skope_id)&&b("#customize-controls").addClass(["czr-",a.czr_skope(d.current_skope_id)().skope,"-skope-level"].join(""));var f=function(){if(!c.isUndefined(a.czr_activeSectionId())&&!c.isEmpty(a.czr_activeSectionId())){var b=a.CZR_Helpers.getSectionControlIds(a.czr_activeSectionId());c.each(b,function(b){a.control.when(b,function(){var d=a.control(b);c.has(d,"czr_states")&&d.deferred.embedded.then(function(){d.czr_states("noticeVisible")(e.isCtrlNoticeVisible(b)),d.czr_states("resetVisible")(!1)})})})}};a.czr_bottomInfosVisible()?e.renderBottomInfosTmpl():a.czr_bottomInfosVisible(!0),c.delay(function(){f()},500)};a.czr_skopeReady.then(function(){f()})},_setupPreviewNotificationsBlocks:function(){var d=this;a.czr_topNoteVisible=new a.Value((!1)),a.czr_skopeReady.then(function(){a.czr_topNoteVisible.bind(function(c){var e={},f={title:"",message:"",actions:"",selfCloseAfter:2e4};e=b.extend(f,serverControlParams.topNoteParams),e.actions=function(){var c=b.extend(a.previewer.query(),{nonce:a.previewer.nonce.save});wp.ajax.post("czr_dismiss_top_note",c).always(function(){}).fail(function(b){a.consoleLog("czr_dismiss_top_note failed",c,b)}).done(function(a){})},d.toggleTopNote(c,e)}),c.delay(function(){a.czr_topNoteVisible(!c.isEmpty(serverControlParams.isTopNoteOn)||1==serverControlParams.isTopNoteOn)},2e3)}),a.czr_bottomInfosVisible=new a.Value((!1)),a.czr_skopeReady.then(function(){a.czr_bottomInfosVisible.bind(function(a){var c={},e={title:"",message:"",actions:"",selfCloseAfter:2e4};return c=b.extend(e,{}),d.toggleBottomInfos(a,c)},{deferred:!0});var e=a.CZR_Helpers.build_setId("show-skope-infos");a.when(e,function(b){a.czr_bottomInfosVisible.validate=function(a){var c=b(),d=0!==c&&"0"!==c&&!1!==c&&"off"!==c;return!!d&&a},b.bind(function(b){a.czr_bottomInfosVisible(0!==b&&"0"!==b&&!1!==b&&"off"!==b)})}),c.delay(function(){a.czr_bottomInfosVisible(!0)},2e3)})}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{toggleServerNotice:function(d){if(d=c.isObject(d)?d:{},d=c.extend({status:"success",expanded:!0,message:"",auto_collapse:!1},d),"changeset_already_published"!=d.message&&serverControlParams.isDevMode){this.serverNoticeEmbedded=this.serverNoticeEmbedded||b.Deferred();var e=this,f=function(){b(".czr-scope-switcher").prepend(b("<div/>",{"class":"czr-server-notice",html:'<span class="czr-server-message"></span><span class="fa fa-times-circle czr-dismiss-notification"></span>'}))},g=function(){var a,f,g=b(".czr-server-notice",".czr-scope-switcher"),h=b(".wp-full-overlay-header"),i=(b(".wp-full-overlay-sidebar .wp-full-overlay-sidebar-content"),function(a){return!0});e.skopeTitleNoticeVisible&&e.skopeTitleNoticeVisible(!1),d.expanded?(g.toggleClass("czr-server-error","error"==d.status),"error"==d.status?b(".czr-server-message",g).html(c.isEmpty(d.message)?"Server Problem.":d.message):b(".czr-server-message",g).html(c.isEmpty(d.message)?"Success.":d.message),f=b(".czr-server-notice",".czr-scope-switcher").outerHeight(),a=h.outerHeight()+f,setTimeout(function(){b.when(i(a)).done(function(){g.fadeIn({duration:200,complete:function(){b(this).css("height","auto")}})})},400)):(g.fadeOut({duration:200,complete:function(){}}),setTimeout(function(){i()},200))};"pending"==e.serverNoticeEmbedded.state()?b.when(f()).done(function(){setTimeout(function(){e.serverNoticeEmbedded.resolve(),g()},200)}):g(),c.delay(function(){a.czr_serverNotification({expanded:!1})},"success"==d.status||!1!==d.auto_collapse?4e3:5e3)}},buildServerResponse:function(a){var b=!1;if(c.isObject(a)&&(!c.has(a,"responseJSON")||c.isUndefined(a.responseJSON.data)||c.isEmpty(a.responseJSON.data)?c.has(a,"statusText")&&!c.isEmpty(a.statusText)&&(b=a.statusText):b=a.responseJSON.data),c.isObject(a)&&!b)try{JSON.stringify(a)}catch(d){b="Server Error"}else b?"-1"===a&&(b="Identification issue detected, please refresh your page."):b="0"===a?"Not logged in.":a;return b}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{toggleTopNote:function(d,e){e=c.isObject(e)?e:{};var f=this,g={title:"",message:"",actions:"",selfCloseAfter:2e4},h=function(){b.when(f.renderTopNoteTmpl(e)).done(function(d){f.welcomeNote=d,c.delay(function(){b("body").addClass("czr-top-note-open")},200),a.CZR_Helpers.setupDOMListeners([{trigger:"click keydown",selector:".czr-preview-note-close",actions:function(){i().done(function(){a.czr_topNoteVisible(!1),c.isFunction(e.actions)&&e.actions()})}}],{dom_el:f.welcomeNote},f)})},i=function(){var a=b.Deferred();return b("body").removeClass("czr-top-note-open"),f.welcomeNote.length?c.delay(function(){f.welcomeNote.remove(),a.resolve()},300):a.resolve(),a.promise()};e=b.extend(g,e),d?h():i().done(function(){a.czr_topNoteVisible(!1)}),c.delay(function(){a.czr_topNoteVisible(!1)},e.selfCloseAfter||2e4)},renderTopNoteTmpl:function(c){if(b("#czr-top-note").length)return b("#czr-top-note");var d="",e=c.title||"",f=c.message||"";try{d=wp.template("czr-top-note")({title:e})}catch(g){return a.errorLog("Error when parsing the the top note template : "+g),!1}return b("#customize-preview").after(b(d)),b(".czr-note-message","#czr-top-note").html(f),b("#czr-top-note")}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{bindAPISettings:function(b){var d=this,e=function(b,e,f){var g,h=this.id;serverControlParams.isSkopOn&&(c.has(a,"czr_activeSkopeId")&&!c.isUndefined(a.czr_activeSkopeId())||a.errorLog("The api.czr_activeSkopeId() is undefined in the api.czr_skopeBase.bindAPISettings method."),a(h)._dirty&&(g=d.isSettingSkopeEligible(h)?a.czr_activeSkopeId():d.getGlobalSkopeId(),a.czr_skope(g).updateSkopeDirties(h,b)),c.has(a.control(h),"czr_states")&&!a.control(h).czr_states("isResetting")()&&a.control(h).czr_states("resetVisible")(!1),d.isSettingSkopeEligible(h)&&d.updateCtrlSkpNot(h))};c.isUndefined(b)?a.each(function(a){a.bind(e)}):a(b).bind(e);var f=function(a){a.callbacks.has(e)||a.bind(e)};a.topics.change.has(f)||a.bind("change",f)}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{reactWhenSkopeSyncedDone:function(d){var e=b.Deferred();if(!c.has(d,"czr_skopes")||c.isEmpty(d.czr_skopes))return a.errorLog("Missing skope data after refresh",d),e.resolve().promise();a.czr_dirtyness()||a.czr_dirtyness(!!c.isBoolean(d.isChangesetDirty)&&d.isChangesetDirty);var f=d.czr_skopes;return c.each(a.czr_skopeCollection(),function(b){var d=c.findWhere(f,{opt_name:b.opt_name});if(!c.isUndefined(d)){var e=c.isEmpty(d.changeset||{})?{}:d.changeset,g={};c.each(e,function(b,c){a.has(c)||a.consoleLog("In reactWhenSkopeSyncedDone : attempting to update the changeset with a non registered setting : "+c),g[c]=b}),a.czr_skope(b.id).changesetValues(g)}}),c.each(a.czr_skopeCollection(),function(d){var e=c.findWhere(f,{opt_name:d.opt_name});if(!c.isUndefined(e)){var g=b.extend(!0,{},a.czr_skope(d.id).dbValues()),h=b.extend(g,e.db||{}),i={};c.each(h,function(b,c){a.has(c)||a.consoleLog("In reactWhenSkopeSyncedDone : attempting to update the db values with a non registered setting : "+c),i[c]=b}),a.czr_skope(d.id).dbValues(i)}}),c.delay(function(){e.resolve()},500),e.promise()}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{_maybeSetupAssignedMenuLocations:function(b){(c.isUndefined(b)||c.isEmpty(b)||!a.section.has(b.id))&&a.consoleLog("In _maybeSetupAssignedMenuLocations : no valid section_id provided.");if(b.assignedLocations){var d=function(a){};b.assignedLocations.callbacks.has(d)||b.assignedLocations.bind(d)}},activeSectionReact:function(b,d){"add_menu"!=b&&a.trigger("czr-paint",{active_section_id:b});var e=this,f=function(b){var d=a.CZR_Helpers.getSectionControlIds(b);c.each(d,function(b){if(a.has(b)&&!c.isUndefined(a.control(b))){var d=a.control(b);c.has(d,"czr_states")&&d.czr_states("resetVisible")(!1)}})},g=function(b,d){e.setupActiveSkopedControls({section_id:d}),e.processSilentUpdates({section_id:d}).fail(function(){throw new Error("Fail to process silent updates after initial skope collection has been populated")}).done(function(){var b=function(){var b=a.CZR_Helpers.getSectionControlIds(d);c.each(b,function(b){if(a.has(b)&&!c.isUndefined(a.control(b))){var d=a.control(b);c.has(d,"czr_states")&&d.czr_states("noticeVisible")(e.isCtrlNoticeVisible(b))}})};c.delay(function(){b()},700),e.isExcludedSidebarsWidgets()||e.forceSidebarDirtyRefresh(d,a.czr_activeSkopeId())}),c.has(a.topics,"active-section-setup")||a.bind("active-section-setup",function(a){var b={controls:[],section_id:""};a=c.extend(b,a),e._maybeSetupAssignedMenuLocations(a)}),a.czr_skopeReady.then(function(){var b=function(b){a.czr_serverNotification({status:"success",message:[b,serverControlParams.i18n.skope["can only be customized sitewide."]].join(" ")}),a.czr_activeSkopeId(e.getGlobalSkopeId())};"global"!=a.czr_skope(a.czr_activeSkopeId())().skope&&(!e.isExcludedWPCustomCss()||"custom_css"!=d&&"admin_sec"!=d||b(a.section(d).params.title),"nav_menu["!=d.substring(0,"nav_menu[".length)&&"add_menu"!=d||a.czr_serverNotification({status:"success",message:[serverControlParams.i18n.skope["Menus are created sitewide."]].join(" ")}))}),a.trigger("active-section-setup",b)};a.czr_initialSkopeCollectionPopulated.then(function(){a.section.when(b,function(c){c.deferred.embedded.then(function(){try{g(c,b)}catch(d){a.errorLog("activeSectionReact => _doReactActive : "+d)}})}),!c.isEmpty(d)&&a.section.has(d)&&f(d)})},activePanelReact:function(b,d){var e=this;a.czr_initialSkopeCollectionPopulated.then(function(){a.trigger("czr-paint",{active_panel_id:b});a.czr_skopeReady.then(function(){"global"!=a.czr_skope(a.czr_activeSkopeId())().skope&&e.isExcludedSidebarsWidgets()&&"widgets"==b&&a.czr_serverNotification({status:"success",message:[serverControlParams.i18n.skope["Widgets are created sitewide."]].join(" ")})}),a.czr_skopeReady.then(function(){"nav_menus"==b&&c.each(a.panel(b).sections(),function(a){e.processSilentUpdates({section_id:a.id,awake_if_not_active:!0})})})})}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{wash:function(d){var e=function(a){c.has(a,"el")&&a.el.length&&b.when(a.el.removeClass("czr-painted")).done(function(){b(this).css("background","").css("color","")})};return a.czr_skopeBase.paintedElements&&(c.each(a.czr_skopeBase.paintedElements(),function(a){e(a)}),a.czr_skopeBase.paintedElements([])),this},paint:function(d){var e="inherit",f={active_panel_id:a.czr_activePanelId(),active_section_id:a.czr_activeSectionId(),is_skope_switch:!1},g=[];d=b.extend(f,d),!c.isUndefined(a.czr_activeSkopeId())&&a.czr_skope.has(a.czr_activeSkopeId())&&(e=a.czr_skope(a.czr_activeSkopeId()).color);var h=function(f){c.has(f,"el")&&f.el.length&&(d.is_skope_switch?b.when(f.el.addClass("czr-painted")).done(function(){b(this).css("background",f.bgColor||e)}):f.el.css("background",f.bgColor||e),"global"!=a.czr_skope(a.czr_activeSkopeId())().skope&&f.el.css("color","#000"))};return a.czr_skopeBase.paintedElements=a.czr_skopeBase.paintedElements||new a.Value([]),c.isEmpty(d.active_panel_id)&&c.isEmpty(d.active_section_id)&&(g.push({el:b("#customize-info").find(".accordion-section-title").first()}),a.panel.each(function(a){g.push({el:a.container.find(".accordion-section-title").first()})}),a.section.each(function(a){c.isEmpty(a.panel())&&g.push({el:a.container.find(".accordion-section-title").first()})})),!c.isEmpty(d.active_panel_id)&&c.isEmpty(d.active_section_id)&&a.panel.when(d.active_panel_id,function(a){a.deferred.embedded.then(function(){g.push({el:a.container.find(".accordion-section-title, .customize-panel-back")})})}),c.isEmpty(d.active_section_id)||a.section.when(d.active_section_id,function(b){b.deferred.embedded.then(function(){g.push({el:b.container.find(".customize-section-title, .customize-section-back"),bgColor:"inherit"},{el:b.container}),a.czr_isChangeSetOn()||g.push({el:b.container.find(".accordion-section-content")})})}),c.each(g,function(a){h(a)}),a.czr_skopeBase.paintedElements(g),this}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{toggleBottomInfos:function(d,e){e=c.isObject(e)?e:{};var f=this,g=b.Deferred(),h={title:"",message:"",actions:"",selfCloseAfter:2e4},i=a.CZR_Helpers.build_setId("show-skope-infos"),j=function(){var d=b.Deferred();return b.when(f.renderBottomInfosTmpl(e)).done(function(g){f.bottomInfosContainer=g,c.delay(function(){b("body").addClass("czr-bottom-infos-open"),d.resolve()},200),a.CZR_Helpers.setupDOMListeners([{trigger:"click keydown",selector:".czr-preview-note-close",actions:function(){k().done(function(){a.czr_bottomInfosVisible(!1),c.isFunction(e.actions)&&e.actions()})}},{trigger:"click keydown",selector:".czr-skope-switch",actions:function(d){var e=b(d.dom_event.currentTarget,d.dom_el).attr("data-skope-id");!c.isEmpty(e)&&a.czr_skope.has(e)&&a.czr_activeSkopeId(e)}},{trigger:"click keydown",selector:".czr-disable-bottom-infos",actions:function(b){a.control.has(i)&&a.control(i).focus()}}],{dom_el:f.bottomInfosContainer},f)}).fail(function(){d.resolve()}),d.promise()},k=function(){return b.Deferred(function(){var a=this;b("body").removeClass("czr-bottom-infos-open"),f.bottomInfosContainer.length?c.delay(function(){f.bottomInfosContainer.remove(),f.bottomInfosContainer=!1,a.resolve()},300):a.resolve()})};return e=b.extend(h,e),d?j().always(function(){g.resolve()}):k().done(function(){a.czr_bottomInfosVisible(!1),g.resolve()}),g.promise()},renderBottomInfosTmpl:function(d){d=d||{};var e=this,f="",g=a.czr_activeSkopeId();if(!a.czr_skope.has(g)||!c.isObject(a.czr_skope(g)()))return!1;var h=a.czr_skope(g)().long_title,i=a.czr_skope(g)().ctx_title;h=c.isString(h)?h:"",i=c.isString(i)?i:"";var j=d.title||["Customizing",i.toLowerCase()].join(" "),k=d.message||e._getSkopeInfosMessage(g),l=function(){return b.Deferred(function(){var c=this;try{f=wp.template("czr-bottom-infos")({title:j}),b("#customize-preview").after(b(f)),c.resolve()}catch(d){a.errorLog("Error when parsing the the bottom infos template : "+d),c.reject(d)}})};return c.isUndefined(this.bottomInfosContainer)||1!=this.bottomInfosContainer.length?l().done(function(){b(".czr-note-message","#czr-bottom-infos").html(k)}):b(".czr-note-content",e.bottomInfosContainer).fadeOut({duration:"fast",complete:function(){b("h2",e.bottomInfosContainer).html(["&middot;",j,"&middot;"].join(" ")),b(".czr-note-message",e.bottomInfosContainer).html(k),b(this).fadeIn("fast")}}),this.bottomInfosContainer&&1==this.bottomInfosContainer.length?this.bottomInfosContainer:b("#czr-bottom-infos")},_getSkopeInfosMessage:function(d){d=d||a.czr_activeSkopeId();var e=c.findWhere(a.czr_currentSkopesCollection(),{skope:"local"}).id;if(!a.czr_skope.has(d)||!c.isObject(a.czr_skope(d)())||c.isUndefined(e))return"";var f,g=this,h=a.czr_skope(d)().skope,i=g.getInheritedSkopeTitles(),j=g.getOverridenSkopeTitles(),k=a.czr_skope(e)().ctx_title;a.czr_skope(d)().long_title;switch(h){case"global":f=[serverControlParams.i18n.skope["The customizations made site wide are inherited by all other levels of customization."],"<br/>",serverControlParams.i18n.skope["The current context"],["(",k,")"].join(" "),serverControlParams.i18n.skope["can be customized more specifically at the following level"]+"(s)",":",j+"."].join(" ");break;case"group":f=[serverControlParams.i18n.skope["The current customizations will be applied to"],a.czr_skope(d)().ctx_title.toLowerCase()+".","<br/>",serverControlParams.i18n.skope["The options not customized at this level will inherit their value from"],i,".<br/>",serverControlParams.i18n.skope["The current context"],["(",k,")"].join(" "),serverControlParams.i18n.skope["can be customized more specifically at the following level"],":",j+"."].join(" ");break;case"local":f=[serverControlParams.i18n.skope["The current context"],["(",k,")"].join(" "),serverControlParams.i18n.skope["can be customized with a specific set of options."],"<br/>",serverControlParams.i18n.skope["The options not customized at this level will inherit their value from"],i+"."].join(" ")}return b.trim(['<span class="czr-skope-bottom-infos">',f,"</span>"].join(" "))}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{isSkopeRegisteredInCollection:function(b,d){return d=d||a.czr_skopeCollection(),!c.isUndefined(c.findWhere(d,{id:b}))},isSkopeRegisteredInCurrentCollection:function(b,d){return d=d||a.czr_currentSkopesCollection(),!c.isUndefined(c.findWhere(d,{id:b}))},isGlobalSkopeRegistered:function(){var b=c.findWhere(a.czr_currentSkopesCollection(),{skope:"global"});return c.isObject(b)&&c.has(b,"id")},getGlobalSkopeId:function(){if(!c.has(a,"czr_skope"))return"";var b="";return a.czr_skope.each(function(a){"global"==a().skope&&(b=a().id)}),b},getChangedGlobalDBSettingValues:function(b){var d={};return c.each(b,function(b,e){_wpSetId=a.CZR_Helpers.build_setId(e),c.has(a.settings.settings,_wpSetId)&&(c.isEqual(b,a.settings.settings[_wpSetId].value)||(d[e]=b))}),d},getActiveSkopeId:function(b){b=b||a.czr_currentSkopesCollection();var d,e,f;if(d=!c.isEmpty(a.czr_activeSkopeId())&&a.czr_skope.has(a.czr_activeSkopeId())?a.czr_skope(a.czr_activeSkopeId())().skope:serverControlParams.isLocalSkope?"local":"global",e=c.findWhere(b,{skope:d}),f=c.isUndefined(e)?c.findWhere(b,{skope:"global"}).id:e.id,c.isUndefined(f))throw new Error("No default skope was found in getActiveSkopeId ",b);return f},getActiveSkopeName:function(){return a.czr_skope.has(a.czr_activeSkopeId())?a.czr_skope(a.czr_activeSkopeId())().skope:"global"},isSettingSkopeEligible:function(b){var d=this,e=a.CZR_Helpers.getOptionName(b);return c.isUndefined(b)||!a.has(b)?(a.consoleLog("THE SETTING "+b+" IS NOT ELIGIBLE TO SKOPE BECAUSE UNDEFINED OR NOT REGISTERED IN THE API."),!1):!d.isExcludedWPBuiltinSetting(b)&&(!c.contains(serverControlParams.skopeExcludedSettings,e)&&(d.isThemeSetting(b),!0))},isSettingResetEligible:function(b){var d=this;a.CZR_Helpers.getOptionName(b);if(c.isUndefined(b)||!a.has(b))return void a.consoleLog("THE SETTING "+b+" IS NOT ELIGIBLE TO RESET BECAUSE UNDEFINED OR NOT REGISTERED IN THE API.");if(!d.isExcludedWPBuiltinSetting(b))return!(!d.isThemeSetting(b)&&!d.isWPAuthorizedSetting(b))||void a.consoleLog("THE SETTING "+b+" IS NOT ELIGIBLE TO RESET BECAUSE NOT PART OF THE THEME OPTIONS AND NOT WP AUTHORIZED BUILT IN OPTIONS")},isThemeSetting:function(a){return c.isString(a)&&-1!==a.indexOf(serverControlParams.themeOptions)},isWPAuthorizedSetting:function(a){return c.isString(a)&&c.contains(serverControlParams.wpBuiltinSettings,a)},isExcludedWPBuiltinSetting:function(a){var b=this;if(c.isUndefined(a))return!0;if("active_theme"==a)return!0;if(c.contains(serverControlParams.wpBuiltinSettings,a))return!1;var d=["widget_","nav_menu","sidebars_","custom_css","nav_menu[","nav_menu_item","nav_menus_created_posts","nav_menu_locations"],e=!1;return c.each(d,function(c){switch(c){case"widget_":case"sidebars_":c==a.substring(0,c.length)&&(e=b.isExcludedSidebarsWidgets());break;case"nav_menu[":case"nav_menu_item":case"nav_menus_created_posts":c==a.substring(0,c.length)&&(e=!0);break;case"nav_menu_locations":c==a.substring(0,c.length)&&(e=b.isExcludedNavMenuLocations());break;case"custom_css":c==a.substring(0,c.length)&&(e=b.isExcludedWPCustomCss())}}),e},isExcludedSidebarsWidgets:function(){var a=serverControlParams.isSidebarsWigetsSkoped;return!(!c.isUndefined(a)&&!c.isEmpty(a)&&!1!==a)},isExcludedNavMenuLocations:function(){if(!a.czr_isChangeSetOn())return!0;var b=serverControlParams.isNavMenuLocationsSkoped;return!(!c.isUndefined(b)&&!c.isEmpty(b)&&!1!==b)},isExcludedWPCustomCss:function(){var a=serverControlParams.isWPCustomCssSkoped;return!(!c.isUndefined(a)&&!c.isEmpty(a)&&!1!==a)},_getDBSettingVal:function(b,d){var e=a.CZR_Helpers.getOptionName(b),f=a.CZR_Helpers.build_setId(b);return a.czr_skope.has(d)?c.has(a.czr_skope(d).dbValues(),f)?a.czr_skope(d).dbValues()[f]:c.has(a.czr_skope(d).dbValues(),e)?a.czr_skope(d).dbValues()[e]:"_no_db_val":(a.consoleLog("_getDBSettingVal : the requested skope id is not registered : "+d),"_no_db_val")},getSkopeDirties:function(b,d){if(!a.czr_skope.has(b))return{};d=d||{},d=c.extend({unsaved:!0},d);var e={};return c.each(a.czr_skope(b).dirtyValues(),function(b,f){var g;a.czr_isChangeSetOn()&&(g=a._latestSettingRevisions[f],a.state("changesetStatus").get()&&d&&d.unsaved&&(c.isUndefined(g)||g<=a._lastSavedRevision))||(e[f]=b)}),e},getSkopeExcludedDirties:function(){var b=this,d={};a.each(function(a,b){a._dirty&&(d[b]=a())});var e=b.getGlobalSkopeId();b.getSkopeDirties(e);return c.omit(d,function(a,c){return b.isSettingSkopeEligible(c)})},parseWidgetId:function(a,b){var d,e={number:null,id_base:null};return d=a.match(/^(.+)-(\d+)$/),d?(e.id_base=d[1],e.number=parseInt(d[2],10)):e.id_base=a,c.isUndefined(b)||(e.id_base=e.id_base.replace(b,"")),e},widgetIdToSettingId:function(a,b){var c,d=this.parseWidgetId(a,b);return c=d.id_base,d.number&&(c+="["+d.number+"]"),c},isWidgetRegisteredGlobally:function(a){var b=this;return registered=!1,c.each(_wpCustomizeWidgetsSettings.registeredWidgets,function(c,d){registered||"widget_"+b.widgetIdToSettingId(d)!=a||(registered=!0)}),registered}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{getAppliedPrioritySkopeId:function(b,d){if(!a.has(a.CZR_Helpers.build_setId(b)))return a.errorLog("getAppliedPrioritySkopeId : the requested setting id does not exist in the api : "+a.CZR_Helpers.build_setId(b)),d;if(!a.czr_skope.has(d))return a.errorLog("getAppliedPrioritySkopeId : the requested skope id is not registered : "+d),d;var e=this,f=c.findWhere(a.czr_currentSkopesCollection(),{skope:"local"}).id;if(c.isUndefined(f)||d==f)return d;var g=function(c){var f=a.CZR_Helpers.build_setId(b),h="___",i=a.czr_skope(c)();if(c==d)return d;if(a.czr_skope(c).getSkopeSettingAPIDirtyness(f))return i.id;if(a.czr_isChangeSetOn()&&a.czr_skope(c).getSkopeSettingChangesetDirtyness(f))return i.id;var j=e._getDBSettingVal(b,c);return"_no_db_val"!=j?i.id:"global"==i.skope?i.id:"___"!=h?i.title:g(e._getParentSkopeId(i))};return g(f)},getOverridenSkopeTitles:function(){var b=b||a.czr_activeSkopeId();if(!a.czr_skope.has(b))return a.errorLog("getInheritedSkopeTitles : the requested skope id is not registered : "+b),"";var d=this,e=c.findWhere(a.czr_currentSkopesCollection(),{skope:"local"}).id;if(c.isUndefined(e)||b==e)return"";var f=function(c,e){e=e||[];var g=a.czr_skope(c)();return c==b?e:(e.unshift(c),f(d._getParentSkopeId(g),e))};return c.map(f(e),function(a){return d.buildSkopeLink(a)}).join(" "+serverControlParams.i18n.skope.and+" ")},getInheritedSkopeId:function(b,d){if(!a.has(a.CZR_Helpers.build_setId(b)))return a.errorLog("getInheritedSkopeId : the requested setting id does not exist in the api : "+a.CZR_Helpers.build_setId(b)),d;if(!a.czr_skope.has(d))return a.errorLog("getInheritedSkopeId : the requested skope id is not registered : "+d),d;var e,f=this,g=a.CZR_Helpers.build_setId(b),h="___",i=a.czr_skope(d)();if(e=c.has(a.settings.settings,g)?a.settings.settings[g].value:null,a.czr_skope(d).getSkopeSettingAPIDirtyness(g))return d;if(a.czr_isChangeSetOn()&&a.czr_skope(d).getSkopeSettingChangesetDirtyness(g))return d;var j=f._getDBSettingVal(b,d);return"_no_db_val"!=j?d:"global"==i.skope?d:"___"!=h?d:f.getInheritedSkopeId(b,f._getParentSkopeId(i))},getInheritedSkopeTitles:function(b,d){if(b=b||a.czr_activeSkopeId(),!a.czr_skope.has(b))return a.errorLog("getInheritedSkopeTitles : the requested skope id is not registered : "+b),"";d=d||[];var e=this,f=a.czr_skope(b)();return b!==a.czr_activeSkopeId()&&d.unshift(b),"global"!==f.skope?e.getInheritedSkopeTitles(e._getParentSkopeId(f),d):c.map(d,function(a){return e.buildSkopeLink(a)}).join(" "+serverControlParams.i18n.skope.and+" ")},buildSkopeLink:function(b){if(!a.czr_skope.has(b))return a.errorLog("buildSkopeLink : the requested skope id is not registered : "+b),"";var c=[serverControlParams.i18n.skope["Switch to scope"],a.czr_skope(b)().title].join(" : ");return['<span class="czr-skope-switch" title=" '+c+'" data-skope-id="'+b+'">',a.czr_skope(b)().title,"</span>"].join("")},getSkopeSettingVal:function(b,d){if(!a.has(a.CZR_Helpers.build_setId(b)))return a.errorLog("getSkopeSettingVal : the requested setting id does not exist in the api : "+a.CZR_Helpers.build_setId(b)),null;if(!a.czr_skope.has(d))return a.errorLog("getSkopeSettingVal : the requested skope id is not registered : "+d),null;var e,f=this,g=a.CZR_Helpers.build_setId(b),h="___",i=a.czr_skope(d)();if(e=c.has(a.settings.settings,g)?a.settings.settings[g].value:null,a.czr_skope(d).getSkopeSettingAPIDirtyness(g))return a.czr_skope(d).dirtyValues()[g];if(a.czr_isChangeSetOn()&&a.czr_skope(d).getSkopeSettingChangesetDirtyness(g))return a.czr_skope(d).changesetValues()[g];var j=f._getDBSettingVal(b,d);return"_no_db_val"!=j?j:"global"==i.skope?"___"==h?e:h:"___"!=h?h:f.getSkopeSettingVal(b,f._getParentSkopeId(i))},applyDirtyCustomizedInheritance:function(b,d){d=d||a.czr_activeSkopeId()||a.czr_skopeBase.getGlobalSkopeId(),b=b||{};var e=this,f=a.czr_skope(d)();if("global"==f.skope)return b;var g=e._getParentSkopeId(f),h=a.czr_skope(g).dirtyValues();return c.each(h,function(d,e){var g=a.CZR_Helpers.getOptionName(e);
15
- c.isUndefined(b[e])&&c.isUndefined(a.czr_skope(f.id).dbValues()[g])&&(b[e]=d)}),"global"==a.czr_skope(g)().skope?b:e.applyDirtyCustomizedInheritance(b,g)},_getParentSkopeId:function(b,d){var e=this,f=["local","group","special_group","global"],g=d||1*(c.findIndex(f,function(a){return b.skope==a})+1),h=f[g];return c.isUndefined(h)?c.findWhere(a.czr_currentSkopesCollection(),{skope:"global"}).id:c.isUndefined(c.findWhere(a.czr_currentSkopesCollection(),{skope:h}))?e._getParentSkopeId(b,g+1):c.findWhere(a.czr_currentSkopesCollection(),{skope:h}).id},_getChildSkopeId:function(b,d){var e=this,f=["local","group","special_group","global"],g=d||1*(c.findIndex(f,function(a){return b.skope==a})-1),h=f[g];return c.isUndefined(h)?c.findWhere(a.czr_currentSkopesCollection(),{skope:"local"}).id:c.isUndefined(c.findWhere(a.czr_currentSkopesCollection(),{skope:h}))?e._getParentSkopeId(b,g-1):c.findWhere(a.czr_currentSkopesCollection(),{skope:h}).id}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{updateSkopeCollection:function(d,e){var f=this;if(_api_ready_collection=[],c.each(d,function(a,c){var d=b.extend(!0,{},a);_api_ready_collection.push(f.prepareSkopeForAPI(d))}),f.isGlobalSkopeRegistered()){var g=[],h=b.extend(!0,{},a.czr_skope(f.getGlobalSkopeId())());c.each(_api_ready_collection,function(a,b){"global"==a.skope?g.push(h):g.push(a)}),_api_ready_collection=g}a.czr_currentSkopesCollection(_api_ready_collection)},prepareSkopeForAPI:function(a){if(!c.isObject(a))throw new Error("prepareSkopeForAPI : a skope must be an object to be API ready");var b=this,d={};if(c.each(serverControlParams.defaultSkopeModel,function(b,e){var f=a[e];switch(e){case"title":if(!c.isString(f))throw new Error("prepareSkopeForAPI : a skope title property must a string");d[e]=f;break;case"long_title":if(!c.isString(f))throw new Error("prepareSkopeForAPI : a skope title property must a string");d[e]=f;break;case"ctx_title":if(!c.isString(f))throw new Error("prepareSkopeForAPI : a skope context title property must a string");d[e]=f;break;case"skope":if(!c.isString(f)||c.isEmpty(f))throw new Error('prepareSkopeForAPI : a skope "skope" property must a string not empty');d[e]=f;break;case"level":if(!c.isString(f)||c.isEmpty(f))throw new Error("prepareSkopeForAPI : a skope level must a string not empty for skope "+f.skope);d[e]=f;break;case"dyn_type":if(!c.isString(f)||!c.contains(serverControlParams.skopeDynTypes,f))throw new Error("prepareSkopeForAPI : missing or invalid dyn type for skope "+a);d[e]=f;break;case"opt_name":if(!c.isString(f)||c.isEmpty(f))throw new Error('prepareSkopeForAPI : invalid "opt_name" property for skope '+f.skope);d[e]=f;break;case"obj_id":if(!c.isString(f))throw new Error('prepareSkopeForAPI : invalid "obj_id" for skope '+f.skope);d[e]=f;break;case"is_winner":if(!c.isUndefined(f)&&!c.isBoolean(f))throw new Error('prepareSkopeForAPI : skope property "is_winner" must be a boolean');d[e]=f;break;case"is_forced":if(!c.isUndefined(f)&&!c.isBoolean(f))throw new Error('prepareSkopeForAPI : skope property "is_primary" must be a boolean');d[e]=f;break;case"db":if((c.isArray(f)||c.isEmpty(f))&&(f={}),c.isUndefined(f)||!c.isObject(f))throw new Error('prepareSkopeForAPI : skope property "db" must be an object');d[e]=f;break;case"changeset":if((c.isArray(f)||c.isEmpty(f))&&(f={}),c.isUndefined(f)||!c.isObject(f))throw new Error('prepareSkopeForAPI : skope property "changeset" must be an object');d[e]=f;break;case"has_db_val":if(!c.isUndefined(f)&&!c.isBoolean(f))throw new Error('prepareSkopeForAPI : skope property "has_db_val" must be a boolean');d[e]=f}}),d.color=b.skope_colors[d.skope]||"rgb(255, 255, 255)",d.id=d.skope+"_"+d.level,!c.isString(d.id)||c.isEmpty(d.id))throw new Error("prepareSkopeForAPI : a skope id must a string not empty");return c.isString(d.title)&&!c.isEmpty(d.title)||(d.title=id,d.long_title=id),d},currentSkopesCollectionReact:function(d,e){var f=this,g=b.extend(!0,[],d)||[],h=(b.extend(!0,[],e)||[],b.Deferred()),i=[];_to_remove=[],_to_update=[],_instantiateAndEmbed=function(d){c.each(d,function(c){c=b.extend(!0,{},c),a.czr_skope.add(c.id,new a.CZR_skope(c.id,c))}),c.each(d,function(b){if(!a.czr_skope.has(b.id))throw new Error("Skope id : "+b.id+" has not been instantiated.");"pending"==a.czr_skope(b.id).isReady.state()&&a.czr_skope(b.id).ready()})},c.each(g,function(b){a.czr_skope.has(b.id)||i.push(b)});try{_instantiateAndEmbed(i)}catch(j){return a.errorLog("currentSkopesCollectionReact : "+j),h.resolve().promise()}var k=function(){var d=c.size(g),e=function(a){var e=a.container.attr("class").split(" ");c.each(a.container.attr("class").split(" "),function(a){"width-"==a.substring(0,6)&&(e=c.without(e,a))}),b.when(a.container.attr("class",e.join(" "))).done(function(){a.container.addClass("width-"+Math.round(100/d))})};a.czr_skope.each(function(a){if(c.isUndefined(c.findWhere(g,{id:a().id})))a.visible(!1),a.isReady.then(function(){a.container.toggleClass("active-collection",!1)});else{a.visible(!0);var b=function(){e(a),a.container.toggleClass("active-collection",!0)};"pending"==a.isReady.state()?a.isReady.then(function(){b()}):b()}})};return f.skopeWrapperEmbedded.then(function(){k()}),c.isEmpty(e)&&!c.isEmpty(d)&&a.czr_initialSkopeCollectionPopulated.resolve(),f.maybeSynchronizeGlobalSkope(),h.resolve("changed").promise()},maybeSynchronizeGlobalSkope:function(d){if(d=d||{},!c.isObject(d))throw new Error("maybeSynchronizeGlobalSkope : args must be an object");var e,f,g,h=this,i=b.Deferred();c.extend({isGlobalReset:!1,isSetting:!1,settingIdToReset:"",isSkope:!1,skopeIdToReset:""},d);if(h.isGlobalSkopeRegistered()){var j=a.czr_skope(h.getGlobalSkopeId()).dbValues();if(c.each(j,function(b,d){a.has(d)&&!c.isEqual(a.settings.settings[d].value,b)&&(a.settings.settings[d].value=b)}),d.isGlobalReset&&d.isSetting){if(e=d.settingIdToReset,f=a.CZR_Helpers.getOptionName(e),g=serverControlParams.defaultOptionsValues[f],c.isUndefined(a.settings.settings[e])||c.isUndefined(g))return;g!=a.settings.settings[e].value&&(a.settings.settings[e].value=g)}d.isGlobalReset&&d.isSkope&&c.each(a.settings.settings,function(b,d){h.isThemeSetting(d)&&(f=a.CZR_Helpers.getOptionName(d),c.has(serverControlParams.defaultOptionsValues,f)&&(a.settings.settings[d].value=serverControlParams.defaultOptionsValues[f]))})}return i.resolve().promise()}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{activeSkopeReact:function(d,e){var f=this,g=b.Deferred();if(!c.isUndefined(e)&&a.czr_skope.has(e))a.czr_skope(e).active(!1);else if(!c.isUndefined(e))throw new Error("listenToActiveSkope : previous scope does not exist in the collection",e);if(c.isUndefined(d)||!a.czr_skope.has(d))throw new Error("listenToActiveSkope : requested scope "+d+" does not exist in the collection");a.czr_skope(d).active(!0);var h=function(b){return a.czr_activeSkopeId(f.getGlobalSkopeId()),a.czr_serverNotification({status:"success",message:[b,"can only be customized sitewide."].join(" ")}),g.resolve().promise()};if(f.isExcludedSidebarsWidgets()&&"widgets"==a.czr_activePanelId()&&d!=f.getGlobalSkopeId()&&a.czr_serverNotification({status:"success",message:[serverControlParams.i18n.skope["Widgets are created sitewide."]].join(" ")}),f.isExcludedWPCustomCss()&&"custom_css"==a.czr_activeSectionId()&&d!=f.getGlobalSkopeId())return h(a.section(a.czr_activeSectionId()).params.title);if("admin_sec"==a.czr_activeSectionId()&&d!=f.getGlobalSkopeId())return h(a.section(a.czr_activeSectionId()).params.title);if("nav_menu"!=a.czr_activeSectionId().substring(0,"nav_menu".length)&&"add_menu"!=a.czr_activeSectionId()||d==f.getGlobalSkopeId()||a.czr_serverNotification({status:"success",message:[serverControlParams.i18n.skope["Menus are created sitewide."]].join(" ")}),"nav_menus"==a.czr_activePanelId()&&c.each(a.panel(a.czr_activePanelId()).sections(),function(a){f.processSilentUpdates({section_id:a.id,awake_if_not_active:!0})}),a.state("switching-skope")(!0),f._writeCurrentSkopeTitle(d),a.trigger("czr-paint",{is_skope_switch:!0}),c.isUndefined(a.czr_activeSectionId()))return a.state("switching-skope")(!1),a.previewer.refresh(),g.resolve().promise();c.has(a,"czrModulePanelState")&&a.czrModulePanelState(!1);var i=f._getSilentUpdateCandidates();c.isUndefined(e)||c.each(a.czr_skope(e).dirtyValues(),function(a,b){c.contains(i,b)||i.push(b)}),c.isUndefined(d)||c.each(a.czr_skope(d).dirtyValues(),function(a,b){c.contains(i,b)||i.push(b)});var j=function(){f.processSilentUpdates({candidates:i,section_id:null,refresh:!1}).fail(function(){throw g.reject(),a.state("switching-skope")(!1),new Error("Fail to process silent updates in _debouncedProcessSilentUpdates")}).done(function(b){a.previewer.refresh().always(function(){g.resolve(b),a.state("switching-skope")(!1)})})};return c.has(a,"czr_isModuleExpanded")&&!1!==a.czr_isModuleExpanded()?(a.czr_isModuleExpanded().setupModuleViewStateListeners(!1),(j=c.debounce(j,400))()):j(),g.promise()},_writeCurrentSkopeTitle:function(d){var e=this,f=a.czr_skope(d||a.czr_activeSkopeId())().long_title,g=function(){var g=e.getInheritedSkopeTitles(),h=e.getOverridenSkopeTitles();return b.trim(['<span class="czr-main-title"><span class="czr-toggle-title-notice fa fa-info-circle"></span>',"global"==a.czr_skope(d||a.czr_activeSkopeId())().skope?f:["Customizing",f].join(" "),"</span>",'<span class="czr-skope-inherits-from">',serverControlParams.i18n.skope["In this context :"],c.isEmpty(g)?" ":serverControlParams.i18n.skope["inherits from"],g,c.isEmpty(g)?"":c.isEmpty(h)?".":[",",serverControlParams.i18n.skope.and].join(" "),c.isEmpty(h)?" ":serverControlParams.i18n.skope["overridden by"],h,c.isEmpty(h)?"":".","</span>"].join(" "))},h=function(a){a?b(".czr-scope-switcher").find(".spinner").fadeIn():b(".czr-scope-switcher").find(".spinner").fadeOut()};e.skopeWrapperEmbedded.then(function(){b(".czr-scope-switcher").find(".czr-current-skope-title").length?b.when(b(".czr-scope-switcher").find(".czr-skope-title").fadeOut(200)).done(function(){b(this).html(g()).fadeIn(200)}):b(".czr-scope-switcher").prepend(b("<h2/>",{"class":"czr-current-skope-title",html:['<span class="czr-skope-title">','<span class="spinner">',g(),"</span>","</span>"].join("")})),c.isUndefined(a.state("switching-skope").isBound)&&(a.state("switching-skope").bind(h),a.state("switching-skope").isBound=!0)})}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{processSilentUpdates:function(d){d=c.isString(d)?{candidates:[d]}:d||{};var e=this,f={candidates:[],section_id:a.czr_activeSectionId(),refresh:!0,awake_if_not_active:!1},g=b.Deferred();if(d=b.extend(f,d),c.isString(d.candidates)&&(d.candidates=[d.candidates]),c.isEmpty(d.candidates)&&(d.candidates=e._getSilentUpdateCandidates(d.section_id,d.awake_if_not_active)),!c.isArray(d.candidates))throw new Error("processSilentUpdates : the update candidates must be an array.");if(c.isEmpty(d.candidates))return g.resolve([]).promise();var h=function(){e.silentlyUpdateSettings(d.candidates,d.refresh).fail(function(){g.reject()}).done(function(a){c.delay(function(){e.setupActiveSkopedControls({section_id:d.section_id})},1e3),g.resolve(a)})};return"resolved"!=a.czr_skopeReady.state()?(g.resolve([]),a.czr_skopeReady.done(function(){h()})):h(),g.promise()},silentlyUpdateSettings:function(d,e){a.state.has("silent-update-processing")||a.state.create("silent-update-processing")(!1),a.state("silent-update-processing")(!0);var f=this,g={},h=b.Deferred();e=!!c.isUndefined(e)||e,(c.isUndefined(d)||c.isEmpty(d))&&(d=f._getSilentUpdateCandidates()),c.isString(d)&&(d=[d]),c.each(d,function(b){a.control.has(b)&&"czr_multi_module"==a.control(b).params.type||(g[b]=f.getSettingUpdatePromise(b))});var i=[],j=[];return c.each(g,function(b,d){b.done(function(b){var e=a.CZR_Helpers.build_setId(d),f=a.czr_skope(a.czr_activeSkopeId()).getSkopeSettingDirtyness(d);c.isEqual(a(e)(),b)||j.push(d),a(e).silent_set(b,f)}),i.push(b)}),b.when.apply(null,i).fail(function(){throw h.reject(),new Error("silentlyUpdateSettings FAILED. Candidates : "+d)}).always(function(){a.state("silent-update-processing")(!1)}).then(function(){c.each(i,function(a){if(c.isObject(a)&&"resolved"!==a.state())throw new Error("a silent update promise is unresolved : "+d)}),e&&!c.isEmpty(j)?a.previewer.refresh().always(function(){h.resolve(j)}):h.resolve(j)}),h.promise()},getSettingUpdatePromise:function(d){if(c.isUndefined(d))throw new Error("getSettingUpdatePromise : the provided setId is not defined");if(!a.has(a.CZR_Helpers.build_setId(d)))throw new Error("getSettingUpdatePromise : the provided wpSetId is not registered : "+a.CZR_Helpers.build_setId(d));var e=this,f=a.CZR_Helpers.build_setId(d),g=a(f)(),h=b.Deferred(),i=!1,j=a.czr_activeSkopeId(),k=a.czr_skopeBase.getSkopeSettingVal(d,j);if(c.isEqual(g,k))return h.resolve(k).promise();if(a.control.has(f)){var l=a.control(f).params.type,m=a.settings.controls[f];switch(l){case"czr_cropped_image":i=e._getCzrCroppedImagePromise(f,m);break;case"czr_module":e._processCzrModuleSilentActions(f,l,j,m)}}return c.has(a.settings.controls,"header_image")&&"header_image"==f&&(i=e._getHeaderImagePromise(f,j)),i&&c.isObject(i)?i.always(function(){h.resolve(k)}):h.resolve(k),h.promise()},_getSilentUpdateCandidates:function(b,d){var e=this,f=[];if(b=c.isUndefined(b)||c.isNull(b)?a.czr_activeSectionId():b,c.isEmpty(a.czr_activeSectionId())&&!d)return[];if(c.isUndefined(b))return a.consoleLog("_getSilentUpdateCandidates : No active section provided"),[];if(!a.section.has(b))throw new Error("_getSilentUpdateCandidates : The section "+b+" is not registered in the API.");var g=a.CZR_Helpers.getSectionSettingIds(b);return g=c.filter(g,function(a){return e.isSettingSkopeEligible(a)}),c.each(g,function(a){f.push(a)}),f}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{_processCzrModuleSilentActions:function(d,e,f,g){var h,i,j,k,l,m=c.has(a.control(d).params,"syncCollection")?a.control(d).params.syncCollection:"",n=a.CZR_Helpers.build_setId(d),o=a.czr_skopeBase.getSkopeSettingVal(n,f),p=a.czr_skope(a.czr_activeSkopeId());c.isEmpty(m)||c.isUndefined(m)||(h=a.CZR_Helpers.build_setId(m),i=a.czr_skopeBase.getSkopeSettingVal(h,f),j=a.settings.controls[h],k=a.controlConstructor.czr_multi_module,l=a.control(h).syncSektionModule()().id,a.control(h).container.remove(),a.control.remove(h),a(h).silent_set(i,p.getSkopeSettingDirtyness(h)),b.extend(j,{czr_skope:f}),a.control.add(h,new k(h,{params:j,previewer:a.previewer}))),_constructor=a.controlConstructor[e],a.control(d).container.remove(),a.control.remove(d),a(d).silent_set(o,p.getSkopeSettingDirtyness(n)),b.extend(g,{czr_skope:f}),a.control.add(d,new _constructor(d,{params:g,previewer:a.previewer})),c.isEmpty(m)||c.isUndefined(m)||(a.consoleLog("FIRE SEKTION MODULE?",l,a.control(d).czr_Module(l).isReady.state()),a.control(d).czr_Module(l).fireSektionModule())},_getCzrCroppedImagePromise:function(d,e){var f=a.controlConstructor.czr_cropped_image,g=b.Deferred(),h=a.has(d)?a(d)():null;return h=null===h?"":h,wp.media.attachment(h).fetch().done(function(){a.control(d).container.remove(),a.control.remove(d),e.attachment=this.attributes,a.control.add(d,new f(d,{params:e,previewer:a.previewer})),g.resolve()}).fail(function(){a.control(d).container.remove(),a.control.remove(d),e=c.omit(e,"attachment"),a.control.add(d,new f(d,{params:e,previewer:a.previewer})),g.reject()}),g.promise()},_getHeaderImagePromise:function(d,e){var f=b.Deferred();if(!c.has(a.settings.controls,"header_image")||"header_image"!=d)return f.resolve().promise();var g=a.controlConstructor.header,h=b.extend(!0,{},a.settings.controls.header_image);header_image_data=null===a.czr_skopeBase.getSkopeSettingVal("header_image_data",e)?"":a.czr_skopeBase.getSkopeSettingVal("header_image_data",e);var i,j=function(b){b=b||h,a.control("header_image").container.remove(),a.control.remove("header_image"),a.HeaderTool.UploadsList=a.czr_HeaderTool.UploadsList,a.HeaderTool.DefaultsList=a.czr_HeaderTool.DefaultsList,a.HeaderTool.CombinedList=a.czr_HeaderTool.CombinedList;var d=function(){a.control.add("header_image",new g("header_image",{params:b,previewer:a.previewer}))};(d=c.debounce(d,800))()};return c.has(header_image_data,"attachment_id")?(i=header_image_data.attachment_id,wp.media.attachment(i).fetch().done(function(){h.attachment=this.attributes,j(h),f.resolve()}).fail(function(){h=c.omit(h,"attachment"),a.control("header_image").container.remove(),a.control.remove("header_image"),a.HeaderTool.UploadsList=a.czr_HeaderTool.UploadsList,a.HeaderTool.DefaultsList=a.czr_HeaderTool.DefaultsList,a.HeaderTool.CombinedList=a.czr_HeaderTool.CombinedList,a.control.add("header_image",new g("header_image",{params:h,previewer:a.previewer})),f.reject()})):(j(),f.resolve()),f.promise()}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{setupActiveSkopedControls:function(d){var e,f,g,h,i=this,j=b.Deferred();if(defaultSetupParams={controls:[],section_id:a.czr_activeSectionId()},g=b.extend(defaultSetupParams,d),!c.isObject(g)||!c.has(g,"controls")||!c.has(g,"section_id"))throw new Error("setupActiveSkopedControls : the setupParams param must be an object with properties controls and section_id.");return e=g.section_id,f=g.controls,h=[],!c.isEmpty(e)&&c.isString(e)||(e=a.czr_activeSectionId()),c.isEmpty(f)&&(f=a.CZR_Helpers.getSectionControlIds(e)),f=c.isString(f)?[f]:f,h=c.filter(f,function(b){var c=a.CZR_Helpers.getControlSettingId(b);return c&&!i.isSettingSkopeEligible(c)&&a.control(b).container.addClass("czr-not-skoped"),c&&i.isWPAuthorizedSetting(c)&&a.control(b).container.addClass("is-wp-authorized-setting"),c&&i.isSettingSkopeEligible(c)}),"nav_menu["==e.substring(0,"nav_menu[".length)?j.resolve().promise():(c.isEmpty(f)||(a.czr_skopeReady.then(function(){b.when(i.renderControlsSingleReset(h)).done(function(){c.each(f,function(a){i.listenSkopedControl(a)}),j.resolve()})}),"rejected"==a.czr_skopeReady.state()&&j.resolve()),i.renderCtrlSkpNotIcon(f),j.promise())},listenSkopedControl:function(d){var e=this;if(a.has(d)&&!c.isUndefined(a.control(d))){var f=a.control(d),g=a.CZR_Helpers.getControlSettingId(d),h=(a.CZR_Helpers.getOptionName(g),{hasDBVal:!1,isDirty:!1,noticeVisible:!1,resetVisible:!1,isResetting:!1});if(!c.has(f,"czr_states")){f.czr_states=new a.Values,c.each(h,function(a,b){f.czr_states.create(b),f.czr_states(b)(a)});try{e.bindControlStates(f)}catch(i){a.errorLog("bindControlStates : "+i)}}f.czr_states("hasDBVal")(a.czr_skope(a.czr_activeSkopeId()).hasSkopeSettingDBValues(g)),f.czr_states("isDirty")(a.czr_skope(a.czr_activeSkopeId()).getSkopeSettingDirtyness(g)),c.has(f,"userEventMap")||(f.userEventMap=[{trigger:"click keydown",selector:".czr-setting-reset, .czr-cancel-button",name:"control_reset_warning",actions:function(){(f.czr_states("isDirty")()||f.czr_states("hasDBVal")())&&(c.each(c.without(a.CZR_Helpers.getSectionControlIds(f.section()),d),function(b){c.has(a.control(b),"czr_states")&&a.control(b).czr_states("resetVisible")(!1)}),f.czr_states("resetVisible")(!f.czr_states("resetVisible")()),f.czr_states("noticeVisible")(!f.czr_states("resetVisible")()))}},{trigger:"click keydown",selector:".czr-control-do-reset",name:"control_do_reset",actions:function(){e.doResetSetting(d)}},{trigger:"click keydown",selector:".czr-skope-switch",name:"control_skope_switch",actions:function(d){var e=b(d.dom_event.currentTarget,d.dom_el).attr("data-skope-id");!c.isEmpty(e)&&a.czr_skope.has(e)&&a.czr_activeSkopeId(e)}},{trigger:"click keydown",selector:".czr-toggle-notice",name:"control_toggle_notice",actions:function(a){f.czr_states("noticeVisible")(!f.czr_states("noticeVisible")()),f.czr_states("noticeVisible")()&&f.czr_states("resetVisible")(!1)}}],a.CZR_Helpers.setupDOMListeners(f.userEventMap,{dom_el:f.container},e))}},bindControlStates:function(d){if(!a.control.has(d.id))throw new Error("in bindControlStates, the provided ctrl id is not registered in the api : "+d.id);var e=this;a.CZR_Helpers.getControlSettingId(d.id);d.czr_states("hasDBVal").bind(function(a){d.container.toggleClass("has-db-val",a),a?_title=serverControlParams.i18n.skope["Reset your customized ( and published ) value"]:d.czr_states("isDirty")()?_title=serverControlParams.i18n.skope["Reset your customized ( but not yet published ) value"]:_title=serverControlParams.i18n.skope["Not customized yet, nothing to reset"],d.container.find(".czr-setting-reset").attr("title",_title)}),d.czr_states("isDirty").bind(function(a){d.container.toggleClass("is-dirty",a);var b;b=a?serverControlParams.i18n.skope["Reset your customized ( but not yet published ) value"]:d.czr_states("hasDBVal")()?serverControlParams.i18n.skope["Reset your customized ( and published ) value"]:serverControlParams.i18n.skope["Not customized yet, nothing to reset"],d.container.find(".czr-setting-reset").attr("title",b)}),d.czr_states("noticeVisible").bind(function(a){d.container.toggleClass("czr-notice-visible",a);var c=d.getNotificationsContainerElement();!1!==c&&!1!==c.length&&(a?(e.updateCtrlSkpNot(d.id,!0),c.stop().slideDown("fast",null,function(){b(this).css("height","auto")})):b.when(c.stop().slideUp("fast",null,function(){b(this).css("height","auto")})).done(function(){e.removeCtrlSkpNot(d.id)}))}),d.czr_states("resetVisible").bind(function(f){d.section()||a.czr_activeSectionId();f?b.when(e.renderControlResetWarningTmpl(d.id)).done(function(a){c.isEmpty(a)||(d.czr_resetDialogContainer=a.container,a.container.slideToggle("fast"),a.is_authorized||c.delay(function(){b.when(d.czr_resetDialogContainer.slideToggle("fast")).done(function(){d.czr_resetDialogContainer.remove()})},3e3))}):c.has(d,"czr_resetDialogContainer")&&d.czr_resetDialogContainer.length&&b.when(d.czr_resetDialogContainer.slideToggle("fast")).done(function(){d.czr_resetDialogContainer.remove()})})}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{renderControlsSingleReset:function(d){var e=this,f=b.Deferred();(c.isUndefined(d)||c.isEmpty(d))&&(d=a.CZR_Helpers.getSectionControlIds(a.czr_activeSectionId()),d=c.filter(d,function(b){var c=a.CZR_Helpers.getControlSettingId(b);return c&&e.isSettingSkopeEligible(c)}));var g=c.isArray(d)?d:[d],h=function(d){return c.isEmpty(d)?void f.resolve():void c.each(d,function(c){a.control.when(c,function(){var d=a.control(c);a.CZR_Helpers.getControlSettingId(c);return b(".czr-setting-reset",d.container).length?void f.resolve():void d.deferred.embedded.then(function(){b.when(d.container.find(".customize-control-title").first().prepend(b("<span/>",{"class":"czr-setting-reset fa fa-refresh",title:""}))).done(function(){d.container.addClass("czr-skoped"),b(".czr-setting-reset",d.container).fadeIn(400),f.resolve()})})})})};return h=c.debounce(h,200),h(g),f.promise()},renderControlResetWarningTmpl:function(d){if(!a.control.has(d))return{};var e,f,g=a.control(d),h=a.CZR_Helpers.getControlSettingId(d),i="",j=function(){return!!c.contains(serverControlParams.wpBuiltinSettings,a.CZR_Helpers.getOptionName(h))||!c.contains(serverControlParams.themeSettingList,a.CZR_Helpers.getOptionName(h))}(),k=a.czr_skope(a.czr_activeSkopeId())();g.czr_states("isDirty")()?(e=["global"==k.skope?serverControlParams.i18n.skope["Please confirm that you want to reset your current customizations for this option"]:serverControlParams.i18n.skope["Please confirm that you want to reset your current customizations for this option in"],"global"==k.skope?serverControlParams.i18n.skope.sitewide:k.ctx_title].join(" "),f=serverControlParams.i18n.skope["Your customizations have been reset"]):j&&"global"==k.skope?e=serverControlParams.i18n.skope["This WordPress setting can not be reset sitewide"]:(e=["global"==k.skope?serverControlParams.i18n.skope["Please confirm that you want to reset this option"]:serverControlParams.i18n.skope["Please confirm that you want to reset this option in"],"global"==k.skope?serverControlParams.i18n.skope.sitewide:k.ctx_title].join(" "),f=serverControlParams.i18n.skope["The option has been reset"]);var l=!(j&&"global"==a.czr_skope(a.czr_activeSkopeId())().skope&&!g.czr_states("isDirty")()),m={warning_message:e+".",success_message:f+".",is_authorized:l};try{i=wp.template("czr-reset-control")(m)}catch(n){return a.errorLog("Error when parsing the the reset control template : "+n),{container:!1,is_authorized:!1}}return b(".customize-control-title",g.container).first().after(b(i)),{container:b(".czr-ctrl-reset-warning",g.container),is_authorized:l}},doResetSetting:function(d){var e=this,f=a.CZR_Helpers.getControlSettingId(d),g=a.control(d),h=a.czr_activeSkopeId(),i=g.czr_states("isDirty")()?"_resetControlDirtyness":"_resetControlAPIVal",j=function(){var a=this;a.czr_states("resetVisible")(!1),a.czr_states("isResetting")(!1),a.container.removeClass("czr-resetting-control")},k=function(d){var g=function(){a.czr_skopeBase.processSilentUpdates({candidates:d,refresh:!1}).fail(function(){a.consoleLog("Silent update failed after resetting control : "+d)}).done(function(){a.control.when(d,function(){var f=a.control(d);b.when(b(".czr-crtl-reset-dialog",f.container).fadeOut("300")).done(function(){b.when(b(".czr-reset-success",f.container).fadeIn("300")).done(function(a){c.delay(function(){b.when(a.fadeOut("300")).done(function(){e.setupActiveSkopedControls({controls:[d]}).done(function(){f.czr_states&&(j.call(f),f.czr_states("noticeVisible")(e.isCtrlNoticeVisible(d)))})})},500)})})})})};e[i](d).done(function(){a.consoleLog("REFRESH AFTER A SETTING RESET"),a.previewer.refresh().fail(function(b){a.errorLog("Setting reset refresh failed.",b)}).done(function(b){if("global"==a.czr_skope(h)().skope&&"_resetControlAPIVal"==i){var d,e={},j=a.czr_skope(h)().opt_name;!c.isUndefined(b.skopesServerData)&&c.has(b.skopesServerData,"czr_skopes")&&(d=b.skopesServerData.czr_skopes,c.isUndefined(c.findWhere(d,{opt_name:j}))&&(e=c.findWhere(d,{opt_name:j}).db||{})),a.czr_skopeBase.maybeSynchronizeGlobalSkope({isGlobalReset:!0,isSetting:!0,settingIdToReset:f}).done(function(){g()})}else g()})})};g.czr_states("isResetting")(!0),g.container.addClass("czr-resetting-control"),a.czr_skopeReset[g.czr_states("isDirty")()?"resetChangeset":"resetPublished"]({skope_id:h,setId:f,is_setting:!0}).done(function(a){k(d)}).fail(function(f){a.errorLog("Reset failed",f),b.when(b(".czr-crtl-reset-dialog",g.container).fadeOut("300")).done(function(){b.when(b(".czr-reset-fail",g.container).fadeIn("300")).done(function(){b(".czr-reset-fail",g.container).append("<p>"+f+"</p>"),c.delay(function(){j.call(g),e.setupActiveSkopedControls({controls:[d]})},2e3)})})})},_resetControlDirtyness:function(d){var e=a.CZR_Helpers.getControlSettingId(d),f=a.czr_skope(a.czr_activeSkopeId()),g=b.extend(!0,{},f.dirtyValues()),h={},i=b.extend(!0,{},f.changesetValues()),j={},k=b.Deferred();return h=c.omit(g,e),j=c.omit(i,e),f.dirtyValues(h),f.changesetValues(h),k.resolve().promise()},_resetControlAPIVal:function(d){var e=a.CZR_Helpers.getControlSettingId(d),f=a.czr_skope(a.czr_activeSkopeId()).dbValues(),g=b.extend(!0,{},f),h=b.Deferred();return c.has(a.control(d),"czr_states")&&(a.control(d).czr_states("hasDBVal")(!1),a.czr_skope(a.czr_activeSkopeId()).dbValues(c.omit(g,e))),h.resolve().promise()}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{renderCtrlSkpNotIcon:function(d){var e=c.isArray(d)?d:[d];c.each(e,function(c){a.control.when(c,function(){var d=a.control(c);d.deferred.embedded.then(function(){b(".czr-toggle-notice",d.container).length||b.when(d.container.find(".customize-control-title").first().append(b("<span/>",{"class":"czr-toggle-notice fa fa-info-circle",title:serverControlParams.i18n.skope["Display informations about the scope of this option."]}))).done(function(){b(".czr-toggle-notice",d.container).fadeIn(400)})})})})},updateCtrlSkpNot:function(d,e){var f=this,g=c.isArray(d)?d:[d],h=function(a){return a&&f.isSettingSkopeEligible(a)},i=function(b,d){var e,g,i,j=a.czr_activeSkopeId(),k=f.getInheritedSkopeId(b,j),l=f.getAppliedPrioritySkopeId(b,j),m=[];return h(b)?(k==l&&a.czr_skope.has(k)&&j==k&&(e=!c.isUndefined(a.czr_skope(j).dirtyValues()[b]),g=!c.isUndefined(a.czr_skope(j).dbValues()[b]),i=a.czr_skope(k)().ctx_title,i=(c.isString(i)?i:"").toLowerCase(),e?"global"==a.czr_skope(k)().skope?m.push([serverControlParams.i18n.skope["Customized. Will be applied sitewide once published."]].join(" ")):m.push([serverControlParams.i18n.skope["Customized. Will be applied to"],"<strong>"+i+"</strong>",serverControlParams.i18n.skope["once published."]].join(" ")):g?"global"==a.czr_skope(k)().skope?m.push([serverControlParams.i18n.skope["Customized and applied sitewide."]].join(" ")):m.push([serverControlParams.i18n.skope["Customized and applied to"],"<strong>"+i+".</strong>"].join(" ")):m.push(serverControlParams.i18n.skope["Default website value applied sitewide."])),k!==j&&a.czr_skope.has(k)&&(e=!c.isUndefined(a.czr_skope(k).dirtyValues()[b]),g=!c.isUndefined(a.czr_skope(k).dbValues()[b]),i=a.czr_skope(j)().ctx_title,i=(c.isString(i)?i:"").toLowerCase(),e||g?m.push([serverControlParams.i18n.skope["Currently inherited from"],f.buildSkopeLink(k)+".",serverControlParams.i18n.skope["You can customize this specifically for"],"<strong>"+i+".</strong>"].join(" ")):m.push([serverControlParams.i18n.skope["Default website value."],serverControlParams.i18n.skope["You can customize this specifically for"],"<strong>"+i+".</strong>"].join(" "))),l!==j&&a.czr_skope.has(l)&&(e=!c.isUndefined(a.czr_skope(l).dirtyValues()[b]),i=a.czr_skope(d)().ctx_title,i=(c.isString(i)?i:"").toLowerCase(),m.push([e?serverControlParams.i18n.skope["The value that will be applied to"]:serverControlParams.i18n.skope["The value currently applied to"],"<strong>"+i+"</strong>",e?serverControlParams.i18n.skope["is customized in"]:serverControlParams.i18n.skope["is set in"],f.buildSkopeLink(l),serverControlParams.i18n.skope["which has a higher priority than the current option scope"],"<strong>( "+a.czr_skope(j)().title+" ).</strong>"].join(" "))),m.join(" | ")):(m.push([serverControlParams.i18n.skope["This option is always customized sitewide and cannot be reset."]].join(" ")),m.join(" | "))};c.each(g,function(d){a.control.when(d,function(){var f=a.control(d),g=a.CZR_Helpers.getControlSettingId(d),h=c.isUndefined(e)?f.czr_states&&f.czr_states("noticeVisible")():e;h&&f.deferred.embedded.then(function(){var d=c.findWhere(a.czr_currentSkopesCollection(),{skope:"local"}).id,e=f.getNotificationsContainerElement();if(e&&e.length&&!c.isUndefined(d)){try{_html=i(g,d)}catch(h){a.errorLog("_generateControlNotice : "+h)}var j=b(".czr-skope-notice",e);j.length?j.html(_html):e.append(['<span class="czr-notice czr-skope-notice">',_html,"</span>"].join(""))}})})})},isCtrlNoticeVisible:function(b){if(!a.control.has(b))return!1;var c=this,d=a.CZR_Helpers.getControlSettingId(b),e=a.czr_activeSkopeId(),f=c.getAppliedPrioritySkopeId(d,e);return"global"!=a.czr_skope(e)().skope||!(f===e||!a.czr_skope.has(f))},removeCtrlSkpNot:function(d){var e=c.isArray(d)?d:[d];c.each(e,function(c){a.control.when(c,function(){var d=a.control(c);d.deferred.embedded.then(function(){var a=d.getNotificationsContainerElement();if(a&&a.length){var c=b(".czr-skope-notice",a);c.length&&c.remove()}})})})}})}(wp.customize,jQuery,_);var CZRSkopeSaveMths=CZRSkopeSaveMths||{};!function(a,b,c){b.extend(CZRSkopeSaveMths,{initialize:function(){this.changesetStatus="publish",this.saveBtn=b("#save")},save:function(d){var e,f=this,g=a.state("processing"),h=new a.Messenger({url:a.settings.url.parent,channel:"loader"});f.globalSaveDeferred=b.Deferred(),f.previewer=a.previewer,f.globalSkopeId=a.czr_skopeBase.getGlobalSkopeId(),f.saveArgs=d,d&&d.status&&(f.changesetStatus=d.status),a.state("saving")()&&f.globalSaveDeferred.reject("already_saving");
16
- var i=function(b,d){a.state("saving")(!1),a.state("processing").set(0),f.saveBtn.prop("disabled",!1),!c.isUndefined(b)&&b.setting_validities&&a._handleSettingValidities({settingValidities:b.setting_validities,focusInvalidControl:!0}),"pending"==d&&a.czr_serverNotification({message:b,status:"error"})},j=function(d){var e,g=b.Deferred();return a.state("saving")(!0),f.fireAllSubmission(d).always(function(a){e=a.response,i(e,this.state())}).fail(function(b){e=b.response,a.consoleLog("ALL SUBMISSIONS FAILED",e),f.globalSaveDeferred.reject(e),a.trigger("error",e),g.resolve(b.hasNewMenu)}).done(function(b){e=b.response,a.previewer.refresh({waitSkopeSynced:!0}).fail(function(b){f.globalSaveDeferred.reject(f.previewer,[e]),a.consoleLog("SAVE REFRESH FAIL",b)}).done(function(d){if(a.previewer.send("saved",e),e=c.extend({changeset_status:"publish"},e||{}),a.czr_isChangeSetOn()){var i=a._latestRevision;a.state("changesetStatus").set(e.changeset_status),"publish"===e.changeset_status&&(a.each(function(b){b._dirty&&(c.isUndefined(a._latestSettingRevisions[b.id])||a._latestSettingRevisions[b.id]<=i)&&(b._dirty=!1)}),a.state("changesetStatus").set(""),a.settings.changeset.uuid=e.next_changeset_uuid,h.send("changeset-uuid",a.settings.changeset.uuid))}else a.each(function(a){a._dirty=!1});d=c.extend({previewer:d.previewer||f.previewer,skopesServerData:d.skopesServerData||{}},d),f.reactWhenSaveDone(d.skopesServerData),f.globalSaveDeferred.resolveWith(f.previewer,[e]),a.trigger("saved",e||{}),g.resolve(b.hasNewMenu)})}),g.promise()};return 0===g()?j().done(function(a){a&&j({saveGlobal:!1,saveSkopes:!0})}):(e=function(){0===g()&&(a.state.unbind("change",e),j())},a.state.bind("change",e)),f.globalSaveDeferred.promise()}})}(wp.customize,jQuery,_);var CZRSkopeSaveMths=CZRSkopeSaveMths||{};!function(a,b,c){b.extend(CZRSkopeSaveMths,{getSubmitPromise:function(d){var e=this,f=b.Deferred(),g={};if(c.isEmpty(d)||!a.czr_skope.has(d))return a.consoleLog("getSubmitPromise : no skope id requested OR skope_id not registered : "+d),f.resolve().promise();var h=a.czr_skope(d)();return a.czr_skope(d).dirtyness()||d===e.globalSkopeId?(c.each(a.czr_skopeBase.getSkopeDirties(d),function(a,b){g[b]=c.extend({value:a})}),this.submit({skope_id:d,customize_changeset_data:g,dyn_type:h.dyn_type}).done(function(a){f.resolve(a)}).fail(function(b){a.consoleLog("GETSUBMIT FAILED PROMISE FOR SKOPE : ",d,b),f.reject(b)}),f.promise()):f.resolve().promise()},submit:function(d){var e,f=this,g={skope_id:null,the_dirties:{},customize_changeset_data:{},dyn_type:null,opt_name:null},h=[],i=[],j=b.Deferred();if(d=b.extend(g,d),c.isNull(d.skope_id))throw new Error("OVERRIDEN SAVE::submit : MISSING skope_id");if(c.isNull(d.the_dirties))throw new Error("OVERRIDEN SAVE::submit : MISSING the_dirties");if(c.has(a,"Notification")&&(a.each(function(b){b.notifications.each(function(c){"error"===c.type&&a.consoleLog("NOTIFICATION ERROR on SUBMIT SAVE",c),"error"!==c.type||c.data&&c.data.from_server||(h.push(b.id),i[b.id]||(i[b.id]={}),i[b.id][c.code]=c)})}),e=a.findControlsForSettings(h),!c.isEmpty(e)))return c.values(e)[0][0].focus(),j.rejectWith(f.previewer,[{setting_invalidities:i}]).promise();var k={skope_id:d.skope_id,action:"save",the_dirties:d.the_dirties,dyn_type:d.dyn_type,opt_name:d.opt_name};a.czr_isChangeSetOn()&&b.extend(k,{excludeCustomizedSaved:!1});var l=b.extend(f.previewer.query(k),{nonce:f.previewer.nonce.save,customize_changeset_status:f.changesetStatus,customize_changeset_data:JSON.stringify(d.customize_changeset_data)});a.czr_isChangeSetOn()&&(f.saveArgs&&f.saveArgs.date&&(l.customize_changeset_date=f.saveArgs.date),f.saveArgs&&f.saveArgs.title&&(l.customize_changeset_title=f.saveArgs.title));var m=wp.ajax.post("global"!==l.skope?"customize_skope_changeset_save":"customize_save",l);return f.saveBtn.prop("disabled",!0),a.trigger("save",m),m.fail(function(b){a.consoleLog("SUBMIT REQUEST FAIL",d.skope_id,b),"0"===b?b="not_logged_in":"-1"===b&&(b="invalid_nonce"),"invalid_nonce"===b?f.previewer.cheatin():"not_logged_in"===b&&(f.previewer.preview.iframe.hide(),f.previewer.login().done(function(){f.previewer.save(),f.previewer.preview.iframe.show()})),a.trigger("error",b),j.reject(b)}),m.done(function(a){j.resolve(a)}),j.promise()}})}(wp.customize,jQuery,_);var CZRSkopeSaveMths=CZRSkopeSaveMths||{};!function(a,b,c){b.extend(CZRSkopeSaveMths,{fireAllSubmission:function(d){var e=this,f=b.Deferred(),g=[],h=b.Deferred(),i={},j=[],k=[],l={saveGlobal:!0,saveSkopes:!0};d=b.extend(l,d),c.each(a.czr_skopeCollection(),function(a){"global"!==a.skope&&g.push(a.id)});var m=function(d){if(c.isUndefined(g[d+1])&&j.length==g.length){if(c.isEmpty(k))h.resolve(i);else{var e=function(){var d=[];return c.each(k,function(b){d.push(a.czr_skopeBase.buildServerResponse(b))}),b.trim(d.join(" | "))};h.reject(e())}return!0}},n=function(d){return d=d||0,c.isUndefined(g[d])&&(a.consoleLog("Undefined Skope in Save recursive call ",d,_skopesToUpdate,_skopesToUpdate[d]),h.resolve(i)),e.getSubmitPromise(g[d]).always(function(){j.push(d)}).fail(function(b){k.push(b),a.consoleLog("RECURSIVE PUSH FAIL FOR SKOPE : ",g[d]),m(d)||n(d+1)}).done(function(a){a=a||{},i=c.isEmpty(i)?a||{}:b.extend(i,a),m(d)||n(d+1)}),h.promise()},o=!1;c.each(a.czr_skope("global__all_").dirtyValues(),function(a,b){"nav_menu["==b.substring(0,"nav_menu[".length)&&(o=!0)});var p=function(){e.getSubmitPromise(e.globalSkopeId).fail(function(b){a.consoleLog("GLOBAL SAVE SUBMIT FAIL",b),b=a.czr_skopeBase.buildServerResponse(b),f.reject(b)}).done(function(a){i=c.isEmpty(i)?a||{}:b.extend(i,a),f.resolve({response:i,hasNewMenu:o})})};return o&&d.saveGlobal?p():d.saveGlobal&&d.saveSkopes?n().fail(function(b){a.consoleLog("RECURSIVE SAVE CALL FAIL",b),f.reject(b)}).done(function(a){e.cleanSkopeChangesetMetas().always(function(){p()})}):d.saveGlobal&&!d.saveSkopes?p():!d.saveGlobal&&d.saveSkopes&&n().fail(function(b){a.consoleLog("RECURSIVE SAVE CALL FAIL",b),f.reject(b)}).done(function(a){i=c.isEmpty(i)?a||{}:b.extend(i,a),e.cleanSkopeChangesetMetas().always(function(){f.resolve({response:i,hasNewMenu:o})})}),f.promise()},cleanSkopeChangesetMetas:function(){var c=b.Deferred();return _query=b.extend(a.previewer.query(),{nonce:a.previewer.nonce.save}),wp.ajax.post("czr_clean_skope_changeset_metas_after_publish",_query).always(function(){c.resolve()}).fail(function(b){a.consoleLog("cleanSkopeChangesetMetas failed",_query,b)}).done(function(b){a.consoleLog("cleanSkopeChangesetMetas done",_query,b)}),c.promise()}})}(wp.customize,jQuery,_);var CZRSkopeSaveMths=CZRSkopeSaveMths||{};!function(a,b,c){b.extend(CZRSkopeSaveMths,{reactWhenSaveDone:function(b){var d={};b=c.extend({czr_skopes:[],isChangesetDirty:!1},b),c.each(a.czr_skopeCollection(),function(b){d[b.opt_name]=a.czr_skopeBase.getSkopeDirties(b.id),a.czr_skope(b.id).dirtyValues({}),a.czr_skope(b.id).changesetValues({})});var e=[],f=b.czr_skopes;a.consoleLog("REACT WHEN SAVE DONE",d,f),c.each(d,function(b,d){c.each(b,function(b,g){if(!c.isUndefined(c.findWhere(f,{opt_name:d}))&&a.czr_skopeBase.isSettingSkopeEligible(g)){var h=c.findWhere(f,{opt_name:d}).db,i=c.findWhere(f,{opt_name:d}).skope,j=a.CZR_Helpers.build_setId(g),k=a.CZR_Helpers.getOptionName(g),l=h[j];c.isUndefined(l)&&"global"==i&&b===serverControlParams.defaultOptionsValues[k]||!c.isUndefined(l)&&c.isEqual(l,b)||e.push({opt_name:d,setId:j,server_val:l,api_val:b})}})}),c.isEmpty(e)?a.consoleLog("ALL RIGHT, SERVER AND API ARE SYNCHRONIZED AFTER SAVE"):a.consoleLog("SOME SETTINGS HAVE NOT BEEN PROPERLY SAVED : ",e),a.czr_skopeBase.maybeSynchronizeGlobalSkope(),a.czr_skopeBase.updateCtrlSkpNot(a.CZR_Helpers.getSectionControlIds())}})}(wp.customize,jQuery,_);var CZRSkopeResetMths=CZRSkopeResetMths||{};!function(a,b,c){b.extend(CZRSkopeResetMths,{initialize:function(){var c=this;c.previewer=a.previewer,a.state.create("czr-resetting")(!1),a.state("czr-resetting").bind(function(a){b(document.body).toggleClass("czr-resetting",!1!==a)})},resetChangeset:function(d){var e,f,g,h,i,j=b.Deferred(),k=this,l=a.state("processing"),m={is_setting:!1,is_skope:!1,skope_id:a.czr_activeSkopeId()||"",setId:""};d=c.extend(m,d);var n=d.skope_id,o=d.setId;return a.czr_isChangeSetOn()?(f=function(e,f){if(c.isUndefined(e))throw new Error("RESET: MISSING skope_id");if(a.state("czr-resetting")(!0),h={skope_id:e,action:"reset"},i=b.extend(k.previewer.query(h),{nonce:k.previewer.nonce.save}),d.is_setting)b.extend(i,{setting_id:f}),g="czr_changeset_setting_reset";else{if(!d.is_skope)return j.reject("reset_ajax_action_not_specified").promise();g="czr_changeset_skope_reset"}wp.ajax.post(g,i).always(function(){a.state("czr-resetting")(!1)}).fail(function(b){"0"===b?b="not_logged_in":"-1"===b&&(b="invalid_nonce"),"invalid_nonce"===b?k.previewer.cheatin():"not_logged_in"===b&&(k.previewer.preview.iframe.hide(),k.previewer.login().done(function(){k.resetChangeset(d),k.previewer.preview.iframe.show()})),a.consoleLog(g+" failed ",i,b),b=a.czr_skopeBase.buildServerResponse(b),a.trigger("error",b),a.czr_serverNotification({message:b,status:"error"}),j.reject(b)}).done(function(a){j.resolve(a)})},0===l()&&!1===a.state("czr-resetting")()?f(n,o):(e=function(){0===l()&&!1===a.state("czr-resetting")()&&(a.state.unbind("change",e),f(n,o))},a.state.bind("change",e)),j.promise()):j.resolve().promise()},resetPublished:function(d){var e,f,g,h,i,j=b.Deferred(),k=this,l=a.state("processing"),m={is_setting:!1,is_skope:!1,skope_id:a.czr_activeSkopeId()||"",setId:""};d=c.extend(m,d);var n=d.skope_id,o=d.setId;return f=function(e,f){if(c.isUndefined(e))throw new Error("RESET: MISSING skope_id");if(a.state("czr-resetting")(!0),h={skope_id:e,action:"reset"},i=b.extend(k.previewer.query(h),{nonce:k.previewer.nonce.save}),d.is_setting)b.extend(i,{setting_id:f}),g="czr_published_setting_reset";else{if(!d.is_skope)return j.reject("reset_ajax_action_not_specified").promise();g="czr_published_skope_reset"}a.consoleLog("in czr_reset submit : ",e,i),wp.ajax.post(g,i).always(function(){a.state("czr-resetting")(!1)}).fail(function(b){"0"===b?b="not_logged_in":"-1"===b&&(b="invalid_nonce"),"invalid_nonce"===b?k.previewer.cheatin():"not_logged_in"===b&&(k.previewer.preview.iframe.hide(),k.previewer.login().done(function(){k.resetChangeset(d),k.previewer.preview.iframe.show()})),a.consoleLog(g+" failed ",i,b),b=a.czr_skopeBase.buildServerResponse(b),a.trigger("error",b),a.czr_serverNotification({message:b,status:"error"}),j.reject(b)}).done(function(a){j.resolve(a)})},0===l()&&!1===a.state("czr-resetting")()?f(n,o):(e=function(){0===l()&&!1===a.state("czr-resetting")()&&(a.state.unbind("change",e),f(n,o))},a.state.bind("change",e)),j.promise()}})}(wp.customize,jQuery,_);var CZRSkopeBaseMths=CZRSkopeBaseMths||{};!function(a,b,c){b.extend(CZRSkopeBaseMths,{initWidgetSidebarSpecifics:function(){var c=this;c.isExcludedSidebarsWidgets()||a.czr_activeSkopeId.bind(function(b){c.forceSidebarDirtyRefresh(a.czr_activeSectionId(),b)}),b(document).bind("widget-added",function(b,d){if(!c.isExcludedSidebarsWidgets()){var e=d.closest(".customize-control").attr("id"),f=a.czr_skopeBase.widgetIdToSettingId(e,"customize-control-");if(!a.has(f))throw new Error("AN ADDED WIDGET COULD NOT BE BOUND IN SKOPE. "+f);c.listenAPISettings(f)}})},forceSidebarDirtyRefresh:function(b,d){var e=this;if(!e.isExcludedSidebarsWidgets()){var f=a.state("saved")(),g=function(){if(a.section.has(b)&&"sidebar"==a.section(b).params.type){var c=c||a.czr_activeSkopeId(),d="sidebars_widgets["+a.section(b).params.sidebarId+"]",g=e.getSkopeSettingVal(d,c);a.czr_skope(c).updateSkopeDirties(d,g),a.previewer.refresh({the_dirties:a.czr_skope(c).dirtyValues()}).done(function(){a.state("saved")(f)})}};g=c.debounce(g,500),g()}}})}(wp.customize,jQuery,_);var CZRSkopeMths=CZRSkopeMths||{};!function(a,b,c){b.extend(CZRSkopeMths,{initialize:function(d,e){var f=this;a.Value.prototype.initialize.call(f,null,e),f.isReady=b.Deferred(),f.embedded=b.Deferred(),f.el="czr-scope-"+d,b.extend(f,e||{}),f.visible=new a.Value((!0)),f.winner=new a.Value((!1)),f.priority=new a.Value,f.active=new a.Value((!1)),f.dirtyness=new a.Value((!1)),f.skopeResetDialogVisibility=new a.Value((!1)),f.hasDBValues=new a.Value((!1)),f.dirtyValues=new a.Value({}),f.dbValues=new a.Value({}),f.changesetValues=new a.Value({}),f.userEventMap=new a.Value([{trigger:"click keydown",selector:".czr-scope-switch, .czr-skp-switch-link",name:"skope_switch",actions:function(){a.czr_activeSkopeId(f().id)}},{trigger:"click keydown",selector:".czr-scope-reset",name:"skope_reset_warning",actions:"reactOnSkopeResetUserRequest"}]),f.skopeResetDialogVisibility.bind(function(a,b){return f.skopeResetDialogReact(a)},{deferred:!0}),f.dirtyValues.callbacks.add(function(){return f.dirtyValuesReact.apply(f,arguments)}),f.changesetValues.callbacks.add(function(){return f.changesetValuesReact.apply(f,arguments)}),f.dbValues.callbacks.add(function(){return f.dbValuesReact.apply(f,arguments)}),f.callbacks.add(function(){return f.skopeReact.apply(f,arguments)}),f.set(c.omit(e,function(a,b){return c.contains(["db","changeset","has_db_val"],b)})),f.setupObservableViewValuesCallbacks(),f.dirtyness(!c.isEmpty(e.changeset)),f.hasDBValues(!c.isEmpty(e.db)),f.winner(e.is_winner),f.embedded.fail(function(){throw new Error("The container of skope "+f().id+" has not been embededd")}).done(function(){f.setupDOMListeners(f.userEventMap(),{dom_el:f.container}),f.isReady.resolve()})},ready:function(){var c=this;a.czr_skopeBase.skopeWrapperEmbedded.done(function(){try{b.when(c.embedSkopeDialogBox()).done(function(a){!1!==a.length?(a.css("background-color",c.color),c.container=a,c.embedded.resolve(a)):c.embedded.reject()})}catch(d){a.errorLog("In skope base : "+d),c.embedded.reject()}})},dirtyValuesReact:function(b,d){var e=this;e.dirtyness(!c.isEmpty(b)),a.czr_dirtyness(!c.isEmpty(b));var f=[];c.each(d,function(a,d){c.has(b,d)||f.push(d)}),e().id==a.czr_activeSkopeId()&&(c.each(f,function(b){c.has(a.control(b),"czr_states")&&a.control(b).czr_states("isDirty")(!1)}),c.each(b,function(b,d){c.has(a.control(d),"czr_states")&&a.control(d).czr_states("isDirty")(!0)}))},changesetValuesReact:function(a,c){var d=this,e=b.extend(!0,{},d.dirtyValues());d.dirtyValues(b.extend(e,a))},dbValuesReact:function(b,d){var e=this;e.hasDBValues(!c.isEmpty("global"!=e().skope?b:c.omit(b,function(b,c){return!a.czr_skopeBase.isThemeSetting(c)})));var f=[];c.each(d,function(a,d){c.has(b,d)||f.push(d)}),e().id==a.czr_activeSkopeId()&&(c.each(f,function(b){c.has(a.control(b),"czr_states")&&a.control(b).czr_states("hasDBVal")(!1)}),c.each(b,function(b,d){c.has(a.control(d),"czr_states")&&a.control(d).czr_states("hasDBVal")(!0)}))},skopeReact:function(d,e){var f=this,g=[],h=[];a.czr_skopeBase.isSkopeRegisteredInCollection(d.id)?(g=b.extend(!0,[],a.czr_skopeCollection()),h=g,c.each(g,function(a,b){a.id==f().id&&(h[b]=d)}),a.czr_skopeCollection(h)):(g=b.extend(!0,[],a.czr_skopeCollection()),g.push(d),a.czr_skopeCollection(g))},setupObservableViewValuesCallbacks:function(){var a=this;a.visible.bind(function(b){"pending"==a.embedded.state()?a.embedded.done(function(){a.container.toggle(b)}):a.container.toggle(b)}),a.active.bind(function(){"pending"==a.embedded.state()?a.embedded.done(function(){a.activeStateReact.apply(a,arguments)}):a.activeStateReact.apply(a,arguments)}),a.dirtyness.bind(function(){"pending"==a.embedded.state()?a.embedded.done(function(){a.dirtynessReact.apply(a,arguments)}):a.dirtynessReact.apply(a,arguments)}),a.hasDBValues.bind(function(){"pending"==a.embedded.state()?a.embedded.done(function(){a.hasDBValuesReact.apply(a,arguments)}):a.hasDBValuesReact.apply(a,arguments)}),a.winner.bind(function(){"pending"==a.embedded.state()?a.embedded.done(function(){a.winnerReact.apply(a,arguments)}):a.winnerReact.apply(a,arguments)})},activeStateReact:function(a,c){var d=this;d.container.toggleClass("inactive",!a).toggleClass("active",a),b(".czr-scope-switch",d.container).toggleClass("fa-toggle-on",a).toggleClass("fa-toggle-off",!a)},dirtynessReact:function(a,c){var d=this;b.when(this.container.toggleClass("dirty",a)).done(function(){a?b(".czr-scope-reset",d.container).fadeIn("slow").attr("title",[serverControlParams.i18n.skope["Reset the current customizations for"],d().title].join(" ")):d.hasDBValues()||b(".czr-scope-reset",d.container).fadeOut("fast")})},hasDBValuesReact:function(a,c){var d=this;b.when(d.container.toggleClass("has-db-val",a)).done(function(){a?b(".czr-scope-reset",d.container).fadeIn("slow").attr("title",["global"==d().skope?serverControlParams.i18n.skope["Reset the theme options published sitewide"]:serverControlParams.i18n.skope["Reset your website published options for"],"global"==d().skope?"":d().title].join(" ")):d.dirtyness()||b(".czr-scope-reset",d.container).fadeOut("fast")})},winnerReact:function(d){var e=this;this.container.toggleClass("is_winner",d),d&&c.each(a.czr_currentSkopesCollection(),function(c){if(c.id!=e().id){var d=b.extend(!0,{},c);b.extend(d,{is_winner:!1}),a.czr_skope(c.id)(d)}})},updateSkopeDirties:function(c,d){var e=this;a.CZR_Helpers.getOptionName(c);if(!a.czr_skopeBase.isSettingSkopeEligible(c)&&"global"!=e().skope)return a.czr_skope(a.czr_skopeBase.getGlobalSkopeId()).updateSkopeDirties(c,d);var f=b.extend(!0,{},e.dirtyValues()),g={};return g[c]=d,e.dirtyValues.set(b.extend(f,g)),e.dirtyValues()},getSkopeSettingDirtyness:function(a){var b=this;return b.getSkopeSettingAPIDirtyness(a)||b.getSkopeSettingChangesetDirtyness(a)},getSkopeSettingAPIDirtyness:function(b){var d=this;return c.has(d.dirtyValues(),a.CZR_Helpers.build_setId(b))},getSkopeSettingChangesetDirtyness:function(b){var d=this;return a.czr_isChangeSetOn()?c.has(d.changesetValues(),a.CZR_Helpers.build_setId(b)):d.getSkopeSettingAPIDirtyness(b)},hasSkopeSettingDBValues:function(b){var d=a.CZR_Helpers.build_setId(b);return!c.isUndefined(a.czr_skope(a.czr_activeSkopeId()).dbValues()[d])}})}(wp.customize,jQuery,_);var CZRSkopeMths=CZRSkopeMths||{};!function(a,b,c){b.extend(CZRSkopeMths,{embedSkopeDialogBox:function(){var d=this,e=b.extend(!0,{},d()),f="";if(!b("#customize-header-actions").find(".czr-scope-switcher").length)throw new Error("The skope switcher wrapper is not printed, the skope can not be embedded.");try{f=wp.template("czr-skope")(c.extend(e,{el:d.el}))}catch(g){return a.errorLog("Error when parsing the template of a skope"+g),!1}return b(".czr-skopes-wrapper","#customize-header-actions").append(b(f)),b("."+d.el,".czr-skopes-wrapper")},renderResetWarningTmpl:function(){var d,e,f=this,g=b.extend(!0,{},f()),h="";f.dirtyness()?(d=[serverControlParams.i18n.skope["Please confirm that you want to reset your current ( not published ) customizations for"],f().ctx_title].join(" "),e=[serverControlParams.i18n.skope["Your customizations have been reset for"],f().ctx_title].join(" ")):(d=["global"==f().skope?serverControlParams.i18n.skope["Please confirm that you want to reset your sitewide published customizations. Note : this will not reset the customizations made in other option scopes"]:serverControlParams.i18n.skope["Please confirm that you want to reset your published customizations for"],"global"==f().skope?"":f().ctx_title].join(" "),e=[serverControlParams.i18n.skope["Your published customizations have been reset for"],f().title].join(" "));try{h=wp.template("czr-skope-pane")(c.extend(g,{el:f.el,warning_message:d+".",success_message:e+"."}))}catch(i){return a.errorLog("Error when parsing the the reset skope template : "+i),!1}return b("#customize-preview").after(b(h)),b("#czr-skope-pane")},getEl:function(){var a=this;return b(a.el,"#customize-header-actions")}})}(wp.customize,jQuery,_);var CZRSkopeMths=CZRSkopeMths||{};!function(a,b,c){b.extend(CZRSkopeMths,{reactOnSkopeResetUserRequest:function(){var b=this,c=function(){a.state("czr-resetting")(!0),a.czr_activeSkopeId()!=b().id?a.czr_activeSkopeId(b().id).done(function(){b.skopeResetDialogVisibility(!b.skopeResetDialogVisibility()).done(function(){a.state("czr-resetting")(!1)})}):b.skopeResetDialogVisibility(!b.skopeResetDialogVisibility()).done(function(){a.state("czr-resetting")(!1)})};return a.state("czr-resetting")()||0!==a.state("processing")()?void a.czr_serverNotification({message:"Slow down, you move too fast !",status:"success",auto_collapse:!0}):void(a.czr_activeSkopeId()!=b().id&&a.czr_skope(a.czr_activeSkopeId()).skopeResetDialogVisibility()?a.czr_skope(a.czr_activeSkopeId()).skopeResetDialogVisibility(!1).done(function(){c()}):c())},skopeResetDialogReact:function(d){var e=this,f=b.Deferred();return e.userResetEventMap=e.userResetEventMap||new a.Value([{trigger:"click keydown",selector:".czr-scope-reset-cancel",name:"skope_reset_cancel",actions:function(){e.skopeResetDialogVisibility(!e.skopeResetDialogVisibility())}},{trigger:"click keydown",selector:".czr-scope-do-reset",name:"skope_do_reset",actions:"doResetSkopeValues"}]),d?(a.czr_isResettingSkope(e().id),b.when(e.renderResetWarningTmpl()).done(function(a){e.resetPanel=a,e.resetPanel.addClass(e.dirtyness()?"dirty-reset":"db-reset"),e.setupDOMListeners(e.userResetEventMap(),{dom_el:e.resetPanel})}).then(function(){setTimeout(function(){var a=b("#customize-preview").height();e.resetPanel.css("line-height",a+"px").css("height",a+"px"),b("body").addClass("czr-skope-pane-open")},50)})):b.when(b("body").removeClass("czr-skope-pane-open")).done(function(){c.has(e,"resetPanel")&&!1!==e.resetPanel.length&&setTimeout(function(){e.resetPanel.remove(),a.czr_isResettingSkope(!1)},300)}),c.delay(function(){f.resolve()},350),f.promise()},doResetSkopeValues:function(){var d=this,e=d().id,f=d.dirtyness()?"_resetSkopeDirties":"_resetSkopeAPIValues",g=function(){var g=function(){a.czr_skopeBase.processSilentUpdates({refresh:!1}).fail(function(){a.consoleLog("Silent update failed after resetting skope : "+e)}).done(function(){b.when(b(".czr-reset-warning",d.resetPanel).fadeOut("300")).done(function(){b.when(b(".czr-reset-success",d.resetPanel).fadeIn("300")).done(function(){c.delay(function(){a.czr_isResettingSkope(!1),d.skopeResetDialogVisibility(!1)},2e3)})})})};d[f]().done(function(){a.previewer.refresh().fail(function(b){a.consoleLog("SKOPE RESET REFRESH FAILED",b)}).done(function(b){if("global"==a.czr_skope(e)().skope&&"_resetSkopeAPIValues"==f){var d,h={},i=a.czr_skope(e)().opt_name;!c.isUndefined(b.skopesServerData)&&c.has(b.skopesServerData,"czr_skopes")&&(d=b.skopesServerData.czr_skopes,c.isUndefined(c.findWhere(d,{opt_name:i}))&&(h=c.findWhere(d,{opt_name:i}).db||{})),a.czr_skopeBase.maybeSynchronizeGlobalSkope({isGlobalReset:!0,isSkope:!0,skopeIdToReset:e}).done(function(){g()})}else g()})})};b("body").addClass("czr-resetting-skope"),a.czr_skopeReset[d.dirtyness()?"resetChangeset":"resetPublished"]({skope_id:d().id,is_skope:!0}).always(function(){b("body").removeClass("czr-resetting-skope")}).done(function(a){g()}).fail(function(b){d.skopeResetDialogVisibility(!1),a.consoleLog("Skope reset failed",b)})},_resetSkopeDirties:function(){var a=this,c=b.Deferred();return a.dirtyValues({}),a.changesetValues({}),c.resolve().promise()},_resetSkopeAPIValues:function(){var a=this,c=b.Deferred();return a.dbValues({}),c.resolve().promise()}})}(wp.customize,jQuery,_),function(a,b,c){b.extend(CZRSkopeBaseMths,a.Events),b.extend(CZRSkopeMths,a.Events),b.extend(CZRSkopeMths,a.CZR_Helpers),a.CZR_skopeBase=a.Class.extend(CZRSkopeBaseMths),a.CZR_skopeSave=a.Class.extend(CZRSkopeSaveMths),a.CZR_skopeReset=a.Class.extend(CZRSkopeResetMths),a.CZR_skope=a.Value.extend(CZRSkopeMths),c.has(a,"HeaderTool")&&(a.czr_HeaderTool=b.extend(!0,{},a.HeaderTool))}(wp.customize,jQuery,_),function(a,b,c){a.bind("ready",function(){var d=function(){a.section("themes").active.bind(function(d){c.has(serverControlParams,"isThemeSwitchOn")&&c.isEmpty(serverControlParams.isThemeSwitchOn)&&(a.section("themes").active(serverControlParams.isThemeSwitchOn),a.section("themes").active.callbacks=b.Callbacks())})};a.section.has("themes")?d():a.section.when("themes",function(a){d()})})}(wp.customize,jQuery,_),function(a,b,c){a.czr_activeSectionId=new a.Value(""),a.czr_activePanelId=new a.Value(""),"function"==typeof a.Section&&a.control.bind("add",function(b){b.params.ubq_section&&b.params.ubq_section.section&&(b.params.original_priority=b.params.priority,b.params.original_section=b.params.section,a.section.when(b.params.ubq_section.section,function(a){a.expanded.bind(function(a){a?(b.params.ubq_section.priority&&b.priority(b.params.ubq_section.priority),b.section(b.params.ubq_section.section)):(b.priority(b.params.original_priority),b.section(b.params.original_section))})}))}),"function"==typeof a.Panel&&a.section.bind("add",function(b){b.params.ubq_panel&&b.params.ubq_panel.panel&&(b.params.original_priority=b.params.priority,b.params.original_panel=b.params.panel,a.panel.when(b.params.ubq_panel.panel,function(a){a.expanded.bind(function(a){a?(b.params.ubq_panel.priority&&b.priority(b.params.ubq_panel.priority),b.panel(b.params.ubq_panel.panel)):(b.priority(b.params.original_priority),b.panel(b.params.original_panel))})}))});var d=function(){c.has(a,"czr_ModOptVisible")&&a.czr_ModOptVisible(!1)};a.czr_activeSectionId.bind(d),a.czr_activePanelId.bind(d),a.bind("ready",function(){if("function"!=typeof a.Section)throw new Error("Your current version of WordPress does not support the customizer sections needed for this theme. Please upgrade WordPress to the latest version.");var b=function(b,c){a.czr_activeSectionId(b?c:"")};a.section.each(function(a){a.expanded.bind(function(c){b(c,a.id)})}),a.section.bind("add",function(c){a.trigger("czr-paint",{active_panel_id:c.panel()}),c.expanded.bind(function(a){b(a,c.id)})});var d=function(b,d){a.czr_activePanelId(b?d:""),c.isEmpty(a.czr_activePanelId())&&a.czr_activeSectionId("")};a.panel.each(function(a){a.expanded.bind(function(b){d(b,a.id)})}),a.panel.bind("add",function(a){a.expanded.bind(function(b){d(b,a.id)})})})}(wp.customize,jQuery,_),function(a,b,c){serverControlParams.isPro&&(c.each(["tc_font_customizer_settings","header_image_sec","content_blog_sec","static_front_page","content_single_sec","tc_fpu","nav","post_lists_sec"],function(b){c.delay(function(){a.section.when(b,function(a){1>=a.headContainer.length&&a.headContainer.find(".accordion-section-title").prepend('<span class="pro-title-block">Pro</span>')})},1e3)}),c.each(["hu-header-panel","hu-content-panel","tc-header-panel","tc-content-panel","tc-footer-panel"],function(b){a.panel.when(b,function(a){1>=a.headContainer.length&&a.headContainer.find(".accordion-section-title").prepend('<span class="pro-title-block">Pro</span>')})})),!serverControlParams.isPro&&c.isFunction(a.Section)&&(proSectionConstructor=a.Section.extend({active:!0,attachEvents:function(){},isContextuallyActive:function(){return this.active()},_toggleActive:function(){return!0}}),b.extend(a.sectionConstructor,{"czr-customize-section-pro":proSectionConstructor}))}(wp.customize,jQuery,_);var CZRSocialModuleMths=CZRSocialModuleMths||{};!function(a,b,c){b.extend(CZRSocialModuleMths,{initialize:function(d,e){var f=this;a.CZRDynModule.prototype.initialize.call(f,d,e),b.extend(f,{itemPreAddEl:"czr-module-social-pre-add-view-content",itemInputList:"czr-module-social-item-content",modOptInputList:"czr-module-social-mod-opt"}),this.social_icons=["500px","adn","amazon","android","angellist","apple","behance","behance-square","bitbucket","bitbucket-square","black-tie","btc","buysellads","chrome","codepen","codiepie","connectdevelop","contao","dashcube","delicious","deviantart","digg","dribbble","dropbox","drupal","edge","empire","envelope","envelope-o","envelope-square","expeditedssl","facebook","facebook-f (alias)","facebook-official","facebook-square","firefox","flickr","fonticons","fort-awesome","forumbee","foursquare","get-pocket","gg","gg-circle","git","github","github-alt","github-square","gitlab","git-square","google","google-plus","google-plus-circle","google-plus-official","google-plus-square","google-wallet","gratipay","hacker-news","houzz","instagram","internet-explorer","ioxhost","joomla","jsfiddle","lastfm","lastfm-square","leanpub","linkedin","linkedin-square","linux","maxcdn","meanpath","medium","mixcloud","mobile","modx","odnoklassniki","odnoklassniki-square","opencart","openid","opera","optin-monster","pagelines","paypal","phone","phone-square","pied-piper","pied-piper-alt","pinterest","pinterest-p","pinterest-square","product-hunt","qq","rebel","reddit","reddit-alien","reddit-square","renren","rss","rss-square","safari","scribd","sellsy","share-alt","share-alt-square","shirtsinbulk","simplybuilt","skyatlas","skype","slack","slideshare","snapchat","soundcloud","spotify","stack-exchange","stack-overflow","steam","steam-square","stumbleupon","stumbleupon-circle","telegram","tencent-weibo","trello","tripadvisor","tumblr","tumblr-square","twitch","twitter","twitter-square","usb","viacoin","vimeo","vimeo-square","vine","vk","weibo","weixin","whatsapp","wikipedia-w","windows","wordpress","xing","xing-square","yahoo","y-combinator","yelp","youtube","youtube-play","youtube-square"],f.inputConstructor=a.CZRInput.extend(f.CZRSocialsInputMths||{}),f.itemConstructor=a.CZRItem.extend(f.CZRSocialsItem||{}),this.defaultModOptModel={is_mod_opt:!0,module_id:f.id,"social-size":serverControlParams.social_el_params.defaultSocialSize||14},this.defaultItemModel={id:"",title:"","social-icon":"","social-link":"","social-color":serverControlParams.social_el_params.defaultSocialColor,"social-target":1},this.itemAddedMessage=serverControlParams.i18n.socialLinkAdded,c.has(a,"czr_activeSectionId")&&f.control.section()==a.czr_activeSectionId()&&"resolved"!=f.isReady.state()&&f.ready(),a.section(f.control.section()).expanded.bind(function(a){"resolved"!=f.isReady.state()&&f.ready()}),f.isReady.then(function(){f.preItem.bind(function(a,b){c.has(a,"social-icon")&&(c.isEqual(a["social-icon"],b["social-icon"])||f.updateItemModel(f.preItem,!0))})})},updateItemModel:function(a,d){var e=a;if(d=d||!1,c.has(e(),"social-icon")&&!c.isEmpty(e()["social-icon"])){var f,g,h;f=b.extend(!0,{},e()),g=this.getTitleFromIcon(f["social-icon"]),h=serverControlParams.social_el_params.defaultSocialColor,!d&&e.czr_Input.has("social-color")&&(h=e.czr_Input("social-color")()),g=[serverControlParams.i18n.followUs,g].join(" "),d?(f=b.extend(f,{title:g,"social-color":h}),e.set(f)):(e.czr_Input("title").set(g),e.czr_Input("social-color")&&e.czr_Input("social-color").set(h))}},getTitleFromIcon:function(b){return a.CZR_Helpers.capitalize(b.replace("fa-","").replace("envelope","email"))},getIconFromTitle:function(a){return"fa-".title.toLowerCase().replace("envelope","email")},CZRSocialsInputMths:{setupSelect:function(){function a(a){if(!a.id)return a.text;var c=b('<span class="fa '+a.element.value.toLowerCase()+'">&nbsp;&nbsp;'+a.text+"</span>");return c}var d=this,e=d.input_parent,f=d.module,g=f.social_icons,h=e(),i=c.isEmpty(h.id);i&&(g=c.union([serverControlParams.i18n.selectSocialIcon],g)),c.each(g,function(a,c){var e=i&&0===c?"":"fa-"+a.toLowerCase(),g={value:e,html:f.getTitleFromIcon(a)};e==h["social-icon"]&&b.extend(g,{selected:"selected"}),b('select[data-type="social-icon"]',d.container).append(b("<option>",g))}),b('select[data-type="social-icon"]',d.container).select2({templateResult:a,templateSelection:a})},setupColorPicker:function(a){var d=this,e=(d.input_parent,d.module),f=b('input[data-type="social-color"]',d.container);f.iris({palettes:!0,hide:!1,defaultColor:serverControlParams.social_el_params.defaultSocialColor||"rgba(255,255,255,0.7)",change:function(a,d){c.has(d,"color")&&16777215==d.color._color?b(this).val(serverControlParams.social_el_params.defaultSocialColor||"rgba(255,255,255,0.7)"):b(this).val(d.color.toString()),b(this).trigger("colorpickerchange").trigger("change")}}),f.closest("div").on("click keydown",function(){e._adjustScrollExpandedBlock(d.container)})}},CZRSocialsItem:{ready:function(){var b=this;a.CZRItem.prototype.ready.call(b),b.bind("social-icon:changed",function(){b.module.updateItemModel(b)})},_buildTitle:function(b,c,d){
17
- var e=this,f=e.module;return b=b||("string"==typeof c?a.CZR_Helpers.capitalize(c.replace("fa-","")):""),b=a.CZR_Helpers.truncate(b,20),c=c||"fa-"+f.social_icons[0],d=d||serverControlParams.social_el_params.defaultSocialColor,'<div><span class="fa '+c+'" style="color:'+d+'"></span> '+b+"</div>"},writeItemViewTitle:function(a){var c=this,d=c.module,e=a||c(),f=d.getTitleFromIcon(e["social-icon"]);b("."+d.control.css_attr.item_title,c.container).html(c._buildTitle(f,e["social-icon"],e["social-color"]))}}})}(wp.customize,jQuery,_);var CZRWidgetAreaModuleMths=CZRWidgetAreaModuleMths||{};!function(a,b,c){b.extend(CZRWidgetAreaModuleMths,{initialize:function(d,e){var f=this;a.CZRDynModule.prototype.initialize.call(this,d,e),b.extend(f,{itemPreAddEl:"czr-module-widgets-pre-add-view-content",itemInputList:"czr-module-widgets-item-input-list",itemInputListReduced:"czr-module-widgets-item-input-list-reduced",ruItemPart:"czr-module-widgets-ru-item-part"}),f.inputConstructor=a.CZRInput.extend(f.CZRWZonesInputMths||{}),f.itemConstructor=a.CZRItem.extend(f.CZRWZonesItem||{}),f.serverParams=serverControlParams.widget_area_el_params||{},f.contexts=c.has(f.serverParams,"sidebar_contexts")?f.serverParams.sidebar_contexts:{},f.context_match_map={is_404:"404",is_category:"archive-category",is_home:"home",is_page:"page",is_search:"search",is_single:"single"},f.locations=c.has(f.serverParams,"sidebar_locations")?f.serverParams.sidebar_locations:{},f.defaultItemModel={id:"",title:serverControlParams.i18n.widgetZone,contexts:c.without(c.keys(f.contexts),"_all_"),locations:[f.serverParams.defaultWidgetLocation],description:""},this.itemAddedMessage=serverControlParams.i18n.widgetZoneAdded,c.has(a,"sidebar_insights")||(a.sidebar_insights=new a.Values,a.sidebar_insights.create("candidates"),a.sidebar_insights.create("actives"),a.sidebar_insights.create("inactives"),a.sidebar_insights.create("registered"),a.sidebar_insights.create("available_locations")),this.listenToSidebarInsights(),a.czr_widgetZoneSettings=a.czr_widgetZoneSettings||new a.Value,a.czr_widgetZoneSettings.bind(function(b,d){f.isReady.then(function(){c.each(b,function(b,c){a.sidebar_insights(c).set(b)})})}),f.preItem_location_alert_view_state=new a.Value("closed"),f.preItem_location_alert_view_state.callbacks.add(function(a,b){f._toggleLocationAlertExpansion(f.container,a)}),f.bind("item-added",function(a){f.addWidgetSidebar(a)}),f.bind("pre_item_api_remove",function(a){f.removeWidgetSidebar(a)});var g=new a.Values;g.create("fixed_for_current_session"),g.create("value"),a.section(f.serverParams.dynWidgetSection).fixTopMargin=g,a.section(f.serverParams.dynWidgetSection).fixTopMargin("fixed_for_current_session").set(!1),a.panel("widgets").expanded.callbacks.add(function(a,b){f.widgetPanelReact(),"resolved"!=f.isReady.state()&&f.ready()})},ready:function(){var b=this;a.CZRDynModule.prototype.ready.call(b),b.preItemExpanded.callbacks.add(function(a,c){a&&(b.preItem.czr_Input("locations")._setupLocationSelect(!0),b.preItem.czr_Input("locations").mayBeDisplayModelAlert())})},initializeModuleModel:function(a){var d=this,e=b.Deferred();return a.items=c.union(c.has(d.serverParams,"default_zones")?d.serverParams.default_zones:[],a.items),e.resolve(a).promise()},CZRWZonesInputMths:{ready:function(){var b=this;b.bind("locations:changed",function(){b.mayBeDisplayModelAlert()}),a.CZRInput.prototype.ready.call(b)},setupSelect:function(){"locations"==this.id&&this._setupLocationSelect(),"contexts"==this.id&&this._setupContextSelect()},_setupContextSelect:function(){var a=this,d=a(),e=(a.input_parent,a.module);c.each(e.contexts,function(e,f){var g={value:f,html:e};(f==d||c.contains(d,f))&&b.extend(g,{selected:"selected"}),b('select[data-type="contexts"]',a.container).append(b("<option>",g))}),b('select[data-type="contexts"]',a.container).select2()},_setupLocationSelect:function(d){function e(a){if(!a.id)return a.text;if(c.contains(i,a.element.value))return a.text;var d=b('<span class="czr-unavailable-location fa fa-ban" title="'+serverControlParams.i18n.unavailableLocation+'">&nbsp;&nbsp;'+a.text+"</span>");return d}var f=this,g=f(),h=(f.input_parent,f.module),i=a.sidebar_insights("available_locations")();b('select[data-type="locations"]',f.container).children().length||c.each(h.locations,function(a,d){var e={value:d,html:a};(d==g||c.contains(g,d))&&b.extend(e,{selected:"selected"}),b('select[data-type="locations"]',f.container).append(b("<option>",e))}),d&&b('select[data-type="locations"]',f.container).select2("destroy"),b('select[data-type="locations"]',f.container).select2({templateResult:e,templateSelection:e})},mayBeDisplayModelAlert:function(){var d=this,e=d.input_parent,f=d.module;if(c.has(e(),"locations")&&!c.isEmpty(e().locations)){var g=b('select[data-type="locations"]',d.container).val(),h=a.sidebar_insights("available_locations")(),i=c.filter(g,function(a){return!c.contains(h,a)});!c.has(e(),"id")||c.isEmpty(e().id)?f.preItem_location_alert_view_state.set(c.isEmpty(i)?"closed":"expanded"):e.czr_itemLocationAlert.set(c.isEmpty(i)?"closed":"expanded")}}},CZRWZonesItem:{initialize:function(b,c){var d=this;d.module;d.czr_itemLocationAlert=new a.Value,a.CZRItem.prototype.initialize.call(d,null,c)},itemWrapperViewSetup:function(){var b=this,c=b.module;a.CZRItem.prototype.itemWrapperViewSetup.call(b),b.czr_itemLocationAlert.set("closed"),b.czr_itemLocationAlert.callbacks.add(function(a,d){c._toggleLocationAlertExpansion(b.container,a)}),b.writeSubtitleInfos(b()),b.viewState.callbacks.add(function(a,c){-1!=a.indexOf("expanded")&&b.bind("contentRendered",function(){b.czr_Input("locations")._setupLocationSelect(!0),b.czr_Input("locations").mayBeDisplayModelAlert()})})},itemReact:function(b,c){var d=this;a.CZRItem.prototype.itemReact.call(d,b,c),d.writeSubtitleInfos(b),d.updateSectionTitle(b).setModelUpdateTimer()},writeSubtitleInfos:function(a){var d=this,e=d.module,f=c.clone(a||d()),g=[],h=[],i="";if(!d.container.length)return this;f.locations=c.isString(f.locations)?[f.locations]:f.locations,c.each(f.locations,function(a){c.has(e.locations,a)?g.push(e.locations[a]):g.push(a)}),f.contexts=c.isString(f.contexts)?[f.contexts]:f.contexts,d._hasModelAllContexts(a)?h.push(e.contexts._all_):c.each(f.contexts,function(a){c.has(e.contexts,a)?h.push(e.contexts[a]):h.push(a)});var j=serverControlParams.i18n.locations,k=serverControlParams.i18n.contexts,l=serverControlParams.i18n.notset;if(g=c.isEmpty(g)?'<span style="font-weight: bold;">'+l+"</span>":g.join(", "),h=c.isEmpty(h)?'<span style="font-weight: bold;">'+l+"</span>":h.join(", "),i="<u>"+j+"</u> : "+g+" <strong>|</strong> <u>"+k+"</u> : "+h,b(".czr-zone-infos",d.container).length)b(".czr-zone-infos",d.container).html(i);else{var m=b("<div/>",{"class":["czr-zone-infos",e.control.css_attr.item_sort_handle].join(" "),html:i});b("."+e.control.css_attr.item_btns,d.container).after(m)}return this},updateSectionTitle:function(c){var d="sidebar-widgets-"+c.id,e=c.title;return a.section.has(d)?(b(".accordion-section-title",a.section(d).container).text(e),b(".customize-section-title h3",a.section(d).container).html('<span class="customize-action">'+a.section(d).params.customizeAction+"</span>"+e),this):this},setModelUpdateTimer:function(){var a=this,c=a.module;clearTimeout(b.data(this,"modelUpdateTimer")),b.data(this,"modelUpdateTimer",setTimeout(function(){c.control.refreshPreview()},1e3))},_hasModelAllContexts:function(a){var b=this,d=b.module,e=c.keys(d.contexts);if(a=a||this(),c.has(a,"contexts"))return!!c.contains(a.contexts,"_all_")||c.isEmpty(c.difference(c.without(e,"_all_"),a.contexts))},_getMatchingContexts:function(b){var d=this,e=a.czr_wpQueryInfos().conditional_tags||{},f=c.filter(d.context_match_map,function(a,b){return!0===e[b]});return c.isEmpty(f)?b:f}},addWidgetSidebar:function(d,e){if(!c.isObject(d)&&c.isEmpty(e))throw new Error("No valid input were provided to add a new Widget Zone.");var f=this,g=c.isEmpty(d)?e:c.clone(d),h=c.isEmpty(d)?e:b.extend(c.clone(c.findWhere(a.Widgets.data.registeredSidebars,{id:f.serverParams.defaultWidgetSidebar})),{name:g.title,id:g.id});a.Widgets.registeredSidebars.add(h);var i=b.extend(c.clone(a.section("sidebar-widgets-"+f.serverParams.defaultWidgetSidebar).params),{id:"sidebar-widgets-"+g.id,instanceNumber:c.max(a.settings.sections,function(a){return a.instanceNumber}).instanceNumber+1,sidebarId:h.id,title:h.name,description:"undefined"!=typeof e?e.description:a.section("sidebar-widgets-"+f.serverParams.defaultWidgetSidebar).params.description,priority:c.max(c.omit(a.settings.sections,f.serverParams.dynWidgetSection),function(a){return a.instanceNumber}).priority+1});a.section.add(i.id,new a.sectionConstructor[i.type](i.id,{params:i})),a.settings.sections[i.id]=i.id;var j="sidebars_widgets["+g.id+"]",k=b.extend(c.clone(a.settings.settings["sidebars_widgets["+f.serverParams.defaultWidgetSidebar+"]"]),{value:[]});a.settings.settings[j]=k,a.create(j,j,k.value,{transport:k.transport,previewer:a.previewer,dirty:!1});var l=b.extend(c.clone(a.settings.controls["sidebars_widgets["+f.serverParams.defaultWidgetSidebar+"]"]),{settings:{"default":j}}),m={};c.each(l,function(a,b){"string"==typeof a&&(a=a.replace(f.serverParams.defaultWidgetSidebar,g.id)),m[b]=a}),m.instanceNumber=c.max(a.settings.controls,function(a){return a.instanceNumber}).instanceNumber+1,a.settings.controls[j]=m,a.control.add(j,new a.controlConstructor[m.type](j,{params:m,previewer:a.previewer})),c.has(this,"container")&&this.container.trigger("widget_zone_created",{model:g,section_id:"sidebar-widgets-"+g.id,setting_id:j})},removeWidgetSidebar:function(d){var e=this;if(!c.isObject(d)||c.isEmpty(d))throw new Error("No valid data were provided to remove a Widget Zone.");a.Widgets.registeredSidebars.remove(d.id),a.section.has("sidebar-widgets-"+d.id)&&(a.section("sidebar-widgets-"+d.id).container.remove(),a.section.remove("sidebar-widgets-"+d.id),delete a.settings.sections["sidebar-widgets-"+d.id]),a.has("sidebars_widgets["+d.id+"]")&&(a.remove("sidebars_widgets["+d.id+"]"),delete a.settings.settings["sidebars_widgets["+d.id+"]"]),a.control.has("sidebars_widgets["+d.id+"]")&&(a.control("sidebars_widgets["+d.id+"]").container.remove(),a.control.remove("sidebars_widgets["+d.id+"]"),delete a.settings.controls["sidebars_widgets["+d.id+"]"]);var f=function(){a.previewer.refresh()};f=c.debounce(f,500),b.when(f()).done(function(){e.trigger("widget_zone_removed",{model:d,section_id:"sidebar-widgets-"+d.id,setting_id:"sidebars_widgets["+d.id+"]"})})},widgetPanelReact:function(){var b=this,d=a.panel("widgets").container.find(".control-panel-content").css("margin-top");a.section(b.serverParams.dynWidgetSection).fixTopMargin("value").set(d);var e=a.section(b.serverParams.dynWidgetSection).container.find(".accordion-section-content"),f=a.panel("widgets").container.find(".control-panel-content"),g=function(){e.css("margin-top",""),f.css("margin-top",a.section(b.serverParams.dynWidgetSection).fixTopMargin("value")())};a.bind("pane-contents-reflowed",c.debounce(function(){g()},150)),b.closeAllItems().closeRemoveDialogs(),c.has(b,"preItemExpanded")&&b.preItemExpanded.set(!1)},widgetSectionReact:function(c,d){var e=this,f=a.section(e.serverParams.dynWidgetSection),g=f.container.closest(".wp-full-overlay-sidebar-content"),h=f.container.find(".accordion-section-content"),i=f.container.closest(".wp-full-overlay"),j=(f.container.find(".customize-section-back"),f.container.find(".accordion-section-title").first());b("#customize-header-actions").height();c&&(i.removeClass("section-open"),h.css("height","auto"),j.attr("tabindex","0"),h.css("margin-top",""),g.scrollTop(0)),e.closeAllItems().closeRemoveDialogs(),h.slideToggle()},listenToSidebarInsights:function(){var d=this;a.sidebar_insights("registered").callbacks.add(function(a){var b=c.clone(d.itemCollection());c.each(b,function(b){d.getViewEl(b.id).length&&d.getViewEl(b.id).css("display",c.contains(a,b.id)?"block":"none")})}),a.sidebar_insights("inactives").callbacks.add(function(a){var e=c.clone(d.itemCollection());c.each(e,function(e){d.getViewEl(e.id).length&&(c.contains(a,e.id)?(d.getViewEl(e.id).addClass("inactive"),d.getViewEl(e.id).find(".czr-inactive-alert").length||d.getViewEl(e.id).find(".czr-item-title").append(b("<span/>",{"class":"czr-inactive-alert",html:" [ "+serverControlParams.i18n.inactiveWidgetZone+" ]"}))):(d.getViewEl(e.id).removeClass("inactive"),d.getViewEl(e.id).find(".czr-inactive-alert").length&&d.getViewEl(e.id).find(".czr-inactive-alert").remove()))})}),a.sidebar_insights("candidates").callbacks.add(function(b){c.isArray(b)&&c.each(b,function(b){c.isObject(b)&&(a.section.has("sidebar-widgets-"+b.id)||(d.addWidgetSidebar({},b),c.has(a.sidebar_insights("actives")(),b.id)&&a.section.has("sidebar-widgets-"+b.id)&&a.section("sidebar-widgets-"+b.id).activate()))})})},_adjustScrollExpandedBlock:function(a,c){if(a.length){var d,e=b(".wp-full-overlay-sidebar-content").scrollTop(),f=c||90;setTimeout(function(){a.offset().top+a.height()+f>b(window.top).height()&&(d=a.offset().top+a.height()+f-b(window.top).height(),b(".wp-full-overlay-sidebar-content").animate({scrollTop:e+d},600))},50)}},getDefaultItemModel:function(a){var d=this,e=d.itemCollection(),f=c.clone(d.defaultItemModel);f.contexts;return b.extend(f,{title:"Widget Zone "+(1*c.size(e)+1)})},getTemplateEl:function(a,b){var d,e=this;switch("rudItemPart"==a?a=c.has(b,"is_builtin")&&b.is_builtin?"ruItemPart":a:"itemInputList"==a&&(a=c.has(b,"is_builtin")&&b.is_builtin?"itemInputListReduced":a),a){case"rudItemPart":d=e.rudItemPart;break;case"ruItemPart":d=e.ruItemPart;break;case"itemInputList":d=e.itemInputList;break;case"itemInputListReduced":d=e.itemInputListReduced}if(c.isEmpty(d))throw new Error("No valid template has been found in getTemplateEl()");return d},_toggleLocationAlertExpansion:function(c,d){var e=c.find(".czr-location-alert");if(!e.length){var f=["<span>"+serverControlParams.i18n.locationWarning+"</span>",a.CZR_Helpers.getDocSearchLink(serverControlParams.i18n.locationWarning)].join("");e=b("<div/>",{"class":"czr-location-alert",html:f,style:"display:none"}),b('select[data-type="locations"]',c).closest("div").after(e)}e.toggle("expanded"==d)}})}(wp.customize,jQuery,_);var CZRBodyBgModuleMths=CZRBodyBgModuleMths||{};!function(a,b,c){b.extend(CZRBodyBgModuleMths,{initialize:function(d,e){var f=this;a.CZRModule.prototype.initialize.call(f,d,e),b.extend(f,{itemInputList:"czr-module-bodybg-item-content"}),f.inputConstructor=a.CZRInput.extend(f.CZRBodyBgInputMths||{}),f.itemConstructor=a.CZRItem.extend(f.CZBodyBgItemMths||{}),f.defaultItemModel={"background-color":"#eaeaea","background-image":"","background-repeat":"no-repeat","background-attachment":"fixed","background-position":"center center","background-size":"cover"},a.consoleLog("New module instantiated : ",f.id),c.has(a,"czr_activeSectionId")&&f.control.section()==a.czr_activeSectionId()&&"resolved"!=f.isReady.state()&&f.ready(),a.section(f.control.section()).expanded.bind(function(a){"resolved"!=f.isReady.state()&&f.ready()})},CZRBodyBgInputMths:{setupSelect:function(){var a=this,d={"background-repeat":"bg_repeat_options","background-attachment":"bg_attachment_options","background-position":"bg_position_options"},e=(a.input_parent,serverControlParams.body_bg_module_params),f={};a.module;c.has(d,a.id)&&(c.isUndefined(e)||c.isUndefined(e[d[a.id]])||(f=e[d[a.id]],c.isEmpty(f)||(c.each(f,function(d,e){var f={value:e,html:d};(e==a()||c.contains(a(),e))&&b.extend(f,{selected:"selected"}),b("select[data-type]",a.container).append(b("<option>",f))}),b("select[data-type]",a.container).select2())))}},CZBodyBgItemMths:{ready:function(){var b=this;a.CZRItem.prototype.ready.call(b),b.inputCollection.bind(function(a){!c.isEmpty(_col)&&b.czr_Input&&b.czr_Input.has("background-image")&&b.czr_Input("background-image").isReady.done(function(a){var d=function(a){var d=!c.isEmpty(a)||c.isNumber(a);c.each(["background-repeat","background-attachment","background-position","background-size"],function(a){b.czr_Input(a).container.toggle(d||!1)})};d(a()),b.bind("background-image:changed",function(){d(b.czr_Input("background-image")())})})})}}})}(wp.customize,jQuery,_),function(a,b,c){a.czrModuleMap=a.czrModuleMap||{},b.extend(a.czrModuleMap,{czr_widget_areas_module:{mthds:CZRWidgetAreaModuleMths,crud:!0,sektion_allowed:!1,name:"Widget Areas"},czr_social_module:{mthds:CZRSocialModuleMths,crud:!0,name:"Social Icons",has_mod_opt:!0},czr_background:{mthds:CZRBodyBgModuleMths,crud:!1,multi_item:!1,name:"Slider"}})}(wp.customize,jQuery,_);var CZRMultiplePickerMths=CZRMultiplePickerMths||{};!function(a,b,c){b.extend(CZRMultiplePickerMths,{ready:function(){function a(a){return a.text.replace(/\u2013|\u2014/g,"")}var c=this,d=this.container.find("select");d.select2({closeOnSelect:!1,templateSelection:a}),d.on("change",function(a){0===b(this).find("option:selected").length&&c.setting.set([])})}})}(wp.customize,jQuery,_);var CZRCroppedImageMths=CZRCroppedImageMths||{};!function(a,b,c){"function"==typeof wp.media.controller.Cropper&&"function"==typeof a.CroppedImageControl&&(wp.media.controller.CZRCustomizeImageCropper=wp.media.controller.Cropper.extend({doCrop:function(a){var b=a.get("cropDetails"),c=this.get("control");return b.dst_width=c.params.dst_width,b.dst_height=c.params.dst_height,wp.ajax.post("crop-image",{wp_customize:"on",nonce:a.get("nonces").edit,id:a.get("id"),context:c.id,cropDetails:b})}}),b.extend(CZRCroppedImageMths,{initFrame:function(){var a=_wpMediaViewsL10n;this.frame=wp.media({button:{text:a.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.CZRCustomizeImageCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var a=this.frame.state().get("selection").first().toJSON();return a.mime&&a.mime.indexOf("image")>-1?void(c.contains(["image/svg+xml","image/gif"],a.mime)||this.params.width===a.width&&this.params.height===a.height&&!this.params.flex_width&&!this.params.flex_height?(this.setImageFromAttachment(a),this.frame.close()):this.frame.setState("cropper")):void this.frame.trigger("content:error")}}))}(wp.customize,jQuery,_);var CZRUploadMths=CZRUploadMths||{};!function(a,b,c){b.extend(CZRUploadMths,{ready:function(){var c=this;this.params.removed=this.params.removed||"",this.success=b.proxy(this.success,this),this.uploader=b.extend({container:this.container,browser:this.container.find(".czr-upload"),success:this.success,plupload:{},params:{}},this.uploader||{}),c.params.extensions&&(c.uploader.plupload.filters=[{title:a.l10n.allowedFiles,extensions:c.params.extensions}]),c.params.context&&(c.uploader.params["post_data[context]"]=this.params.context),a.settings.theme.stylesheet&&(c.uploader.params["post_data[theme]"]=a.settings.theme.stylesheet),this.uploader=new wp.Uploader(this.uploader),this.remover=this.container.find(".remove"),this.remover.on("click keydown",function(a){"keydown"===a.type&&13!==a.which||(c.setting.set(c.params.removed),a.preventDefault())}),this.removerVisibility=b.proxy(this.removerVisibility,this),this.setting.bind(this.removerVisibility),this.removerVisibility(this.setting())},success:function(a){this.setting.set(a.get("id"))},removerVisibility:function(a){this.remover.toggle(a!=this.params.removed)}})}(wp.customize,jQuery,_);var CZRLayoutSelectMths=CZRLayoutSelectMths||{};!function(a,b,c){b.extend(CZRLayoutSelectMths,{ready:function(){this.setupSelect()},setupSelect:function(a){function d(a){if(!a.id)return a.text;if(c.has(e.params.layouts,a.element.value)){var d=e.params.layouts[a.element.value],f=d.src,g=d.label,h=b('<img src="'+f+'" class="czr-layout-img" title="'+g+'" /><span class="czr-layout-title">'+g+"</span>");return h}}var e=this;$_select=this.container.find("select"),$_select.select2({templateResult:d,templateSelection:d,minimumResultsForSearch:1/0})}})}(wp.customize,jQuery,_),function(a,b,c){a.CZRUploadControl=a.Control.extend(CZRUploadMths),a.CZRLayoutControl=a.Control.extend(CZRLayoutSelectMths),a.CZRMultiplePickerControl=a.Control.extend(CZRMultiplePickerMths),b.extend(a.controlConstructor,{czr_upload:a.CZRUploadControl,czr_multiple_picker:a.CZRMultiplePickerControl,czr_layouts:a.CZRLayoutControl}),"function"==typeof a.CroppedImageControl&&(a.CZRCroppedImageControl=a.CroppedImageControl.extend(CZRCroppedImageMths),b.extend(a.controlConstructor,{czr_cropped_image:a.CZRCroppedImageControl}))}(wp.customize,jQuery,_),function(a,b,c){var d=serverControlParams.i18n||{};a.czr_CrtlDependenciesReady=b.Deferred(),a.bind("ready",function(){c.has(a,"czr_ctrlDependencies")||(serverControlParams.isSkopOn?"resolved"!=a.czr_skopeReady.state()&&a.czr_skopeReady.done(function(){a.czr_ctrlDependencies=new a.CZR_ctrlDependencies,a.czr_CrtlDependenciesReady.resolve()}):(a.czr_ctrlDependencies=new a.CZR_ctrlDependencies,a.czr_CrtlDependenciesReady.resolve()))}),a.CZR_ctrlDependencies=a.Class.extend({dominiDeps:[],initialize:function(){var b=this;if(this.defaultDominusParams={dominus:"",servi:[],visibility:null,actions:null,onSectionExpand:!0},this.dominiDeps=c.extend(this.dominiDeps,this._getControlDeps()),!c.isArray(b.dominiDeps))throw new Error("Visibilities : the dominos dependency array is not an array.");a.czr_activeSectionId.bind(function(d){if(!c.isEmpty(d)&&a.section.has(d))try{b.setServiDependencies(d)}catch(e){a.errorLog("In api.CZR_ctrlDependencies : "+e)}}),a.bind("awaken-section",function(d){if(serverControlParams.isSkopOn&&c.has(a,"czr_skopeBase"))a.czr_skopeBase.processSilentUpdates({candidates:{},section_id:d.target,refresh:!1}).then(function(){try{b.setServiDependencies(d.target,d.source)}catch(c){a.errorLog("On awaken-section, ctrl deps : "+c)}});else try{b.setServiDependencies(d.target,d.source)}catch(e){a.errorLog("On awaken-section, ctrl deps : "+e)}}),this._handleFaviconNote()},setServiDependencies:function(d,e,f){var g=this,h=b.Deferred();if(f=f||!1,c.isUndefined(d)||!a.section.has(d))throw new Error("Control Dependencies : the targetSectionId is missing or not registered : "+d);if(a.section(d).czr_ctrlDependenciesReady=a.section(d).czr_ctrlDependenciesReady||b.Deferred(),!f&&"resolved"==a.section(d).czr_ctrlDependenciesReady.state())return h.resolve().promise();c.each(g.dominiDeps,function(b){if(!c.has(b,"dominus")||!c.isString(b.dominus)||c.isEmpty(b.dominus))throw new Error("Control Dependencies : a dominus control id must be a not empty string.");var e=a.CZR_Helpers.build_setId(b.dominus);a.control.has(e)&&a.control(e).section()==d&&(b=g._prepareDominusParams(b),c.isEmpty(b)||g._processDominusCallbacks(b.dominus,b,f).fail(function(){a.consoleLog("self._processDominusCallbacks fail for section "+d),h.reject()}).done(function(){h.resolve()}))});var i=a.CZR_Helpers.getSectionControlIds(d),j=function(b){var d=[];return c.each(g.dominiDeps,function(e){if(!c.has(e,"servi")||!c.isArray(e.servi)||!c.has(e,"dominus")||c.isEmpty(e.dominus))return void a.errorLog("Control Dependencies : wrong params in _getServusDomini.");if(c.contains(e.servi,b)&&!c.contains(d,e.dominus)){if(e=g._prepareDominusParams(e),c.isEmpty(e))return;d.push(e.dominus)}}),c.isArray(d)?d:[]},k=[];return c.each(i,function(a){c.isEmpty(j(a))||(k=c.union(k,j(a)))}),c.each(k,function(b){var c=a.CZR_Helpers.build_setId(b);a.control(c).section()!=d&&e!=a.control(c).section()&&a.trigger("awaken-section",{target:a.control(c).section(),source:d})}),h.always(function(){a.section(d).czr_ctrlDependenciesReady.resolve()}),h.promise()},_deferCallbackForControl:function(d,e,f){var g=b.Deferred();if(c.isEmpty(d)||!c.isString(d))throw new Error("_deferCallbackForControl : the control id is missing.");if(!c.isFunction(e))throw new Error("_deferCallbackForControl : callback must be a funtion.");return f=c.isUndefined(f)||!c.isArray(f)?[]:f,a.control.has(d)?"resolved"==a.control(d).deferred.embedded.state()?b.when(e.apply(null,f)).fail(function(){g.reject()}).done(function(){g.resolve()}):a.control(d).deferred.embedded.then(function(){b.when(e.apply(null,f)).fail(function(){g.reject()}).done(function(){g.resolve()})}):a.control.when(d,function(){a.control(d).deferred.embedded.then(function(){b.when(e.apply(null,f)).fail(function(){g.reject()}).done(function(){g.resolve()})})}),g.promise()},_processDominusCallbacks:function(d,e,f){var g=this,h=a.CZR_Helpers.build_setId(d),i=a(h),j=b.Deferred(),k=!1;return c.each(e.servi,function(b){if(a.control.has(a.CZR_Helpers.build_setId(b))){var d=function(a,b,d,e){var f=arguments;c.each(d,function(a,b){switch(b){case"visibility":g._setVisibility.apply(null,f);break;case"actions":c.isFunction(a)&&a.apply(null,f)}})},f=function(c){c=c||i();var f=a.CZR_Helpers.build_setId(b);g._deferCallbackForControl(f,d,[c,b,e]).always(function(){k=!0}).fail(function(){j.reject()}).done(function(){j.resolve()})};f(),c.has(i,"czr_visibilityServi")||(i.czr_visibilityServi=new a.Value([]));var h=i.czr_visibilityServi();c.contains(h,b)||(i.bind(function(a){f(a)}),i.czr_visibilityServi(c.union(h,[b])))}}),k?j.promise():j.resolve().promise()},_setVisibility:function(b,d,e,f){var g=a.CZR_Helpers.build_setId(d),h=e.visibility(b,d,e.dominus);if(f=f||!1,c.isBoolean(h)&&("unchanged"!=h||f)){var i=function(){a.state.has("silent-update-processing")&&a.state("silent-update-processing")()||(a.control(g,function(a){var b={duration:"fast",completeCallback:function(){},unchanged:!1};c.has(a,"active")&&(h=h&&a.active()),c.has(a,"defaultActiveArguments")&&(b=control.defaultActiveArguments),a.onChangeActive(h,a.defaultActiveArguments)}),a.state.has("silent-update-processing")&&a.state("silent-update-processing").unbind(i))};a.state.has("silent-update-processing")&&a.state("silent-update-processing")()?a.state("silent-update-processing").bind(i):i()}},_getControlDeps:function(){return{}},_prepareDominusParams:function(b){var d=this,e={};if(!c.isObject(b))return a.errorLog("Visibilities : a dominus param definition must be an object."),e;if(!c.has(b,"visibility")&&!c.has(b,"actions"))return a.errorLog("Visibilities : a dominus definition must include a visibility or an actions callback."),e;if(!c.has(b,"dominus")||!c.isString(b.dominus)||c.isEmpty(b.dominus))return a.errorLog("Visibilities : a dominus control id must be a not empty string."),e;var f=a.CZR_Helpers.build_setId(b.dominus);return a.control.has(f)?!c.has(b,"servi")||c.isUndefined(b.servi)||!c.isArray(b.servi)||c.isEmpty(b.servi)?(a.errorLog("Visibilities : servi must be set as an array not empty."),e):(c.each(d.defaultDominusParams,function(a,d){var f=b[d];switch(d){case"visibility":if(!c.isUndefined(f)&&!c.isEmpty(f)&&!c.isFunction(f))throw new Error("Visibilities : a dominus visibility callback must be a function : "+b.dominus);break;case"actions":if(!c.isUndefined(f)&&!c.isEmpty(f)&&!c.isFunction(f))throw new Error("Visibilities : a dominus actions callback must be a function : "+b.dominus);break;case"onSectionExpand":if(!c.isUndefined(f)&&!c.isEmpty(f)&&!c.isBoolean(f))throw new Error("Visibilities : a dominus onSectionExpand param must be a boolean : "+b.dominus)}e[d]=f}),e):(a.errorLog("Visibilities : a dominus control id is not registered : "+f),e)},_handleFaviconNote:function(){var b=this,c=a.CZR_Helpers.build_setId(serverControlParams.faviconOptionName);if(!(!a.has("site_icon")||!a.control("site_icon")||a.has(c)&&0===+a(c)()||+a("site_icon")()>0)){var e=a.control("site_icon").params.description;_newDes=["<strong>",d.faviconNote||"","</strong><br/><br/>"].join("")+e,b._printFaviconNote(_newDes),a("site_icon").callbacks.add(function(d){+d>0?(a.control("site_icon").container.find(".description").text(e),a.has(c)&&a(c).set("")):b._printFaviconNote(_newDes)})}},_printFaviconNote:function(b){a.control("site_icon").container.find(".description").html(b)}})}(wp.customize,jQuery,_),function(a,b){b(function(b){function c(a){var c=a.siblings(".open");0!==c.length&&c.offset().top<0&&b(".wp-full-overlay-sidebar-content").animate({scrollTop:-b("#customize-theme-controls").offset().top-c.height()+a.offset().top+b(".wp-full-overlay-sidebar-content").offset().top},700)}var d=a.customize||d;b(".accordion-section").not(".control-panel").click(function(){c(b(this))}),d.czrSetupCheckbox=function(a,c){var e=d.control(a);b("input[type=checkbox]",e.container).each(function(){"tc_font_customizer_settings"!=e.params.section&&(0===b(this).val()||"0"==b(this).val()||"off"==b(this).val()||_.isEmpty(b(this).val())?b(this).prop("checked",!1):b(this).prop("checked",!0),0===b(this).closest('div[class^="icheckbox"]').length&&b(this).iCheck({checkboxClass:"icheckbox_flat-grey",radioClass:"iradio_flat-grey"}).on("ifChanged",function(a){b(this).val(!1===b(this).is(":checked")?0:1),b(a.currentTarget).trigger("change")}))})},d.czrSetupSelect=function(a,c){b("select[data-customize-setting-link]",d.control(a).container).not(".no-selecter-js").each(function(){b(this).selecter({})})},d.czrSetupStepper=function(a,c){var e=d.control(a);b('input[type="number"]',e.container).each(function(){"tc_font_customizer_settings"!=e.params.section&&b(this).stepper()})},d.control.each(function(a){_.has(a,"id")&&("widget_"!=a.id.substring(0,"widget_".length)&&"nav_menu"!=a.id.substring(0,"nav_menu".length)&&d.czrSetupCheckbox(a.id),"nav_menu_locations"!=a.id.substring(0,"nav_menu_locations".length)&&d.czrSetupSelect(a.id),d.czrSetupStepper(a.id))});var e=function(){var a=b("<span/>",{"class":"customize-controls-home fa fa-home",html:'<span class="screen-reader-text">Home</span>'});b.when(b("#customize-header-actions").append(a)).done(function(){a.keydown(function(a){9!==a.which&&(13===a.which&&this.click(),a.preventDefault())}).on("click.customize-controls-home",function(){d.section.has(d.czr_activeSectionId())?d.section(d.czr_activeSectionId()).expanded(!1):d.section.each(function(a){a.expanded(!1)}),d.panel.each(function(a){a.expanded(!1)})})})};e()})}(wp,jQuery);
8
  "function"!=typeof jQuery.fn.iCheck&&!function(a){function b(a,b,e){var f=a[0],g=/er/.test(e)?p:/bl/.test(e)?n:l,h=e==q?{checked:f[l],disabled:f[n],indeterminate:"true"==a.attr(p)||"false"==a.attr(o)}:f[g];if(/^(ch|di|in)/.test(e)&&!h)c(a,g);else if(/^(un|en|de)/.test(e)&&h)d(a,g);else if(e==q)for(g in h)h[g]?c(a,g,!0):d(a,g,!0);else b&&"toggle"!=e||(b||a[u]("ifClicked"),h?f[r]!==k&&d(a,g):c(a,g))}function c(b,c,e){var q=b[0],u=b.parent(),v=c==l,x=c==p,y=c==n,z=x?o:v?m:"enabled",A=f(b,z+g(q[r])),B=f(b,c+g(q[r]));if(!0!==q[c]){if(!e&&c==l&&q[r]==k&&q.name){var C=b.closest("form"),D='input[name="'+q.name+'"]',D=C.length?C.find(D):a(D);D.each(function(){this!==q&&a(this).data(i)&&d(a(this),c)})}x?(q[c]=!0,q[l]&&d(b,l,"force")):(e||(q[c]=!0),v&&q[p]&&d(b,p,!1)),h(b,v,c,e)}q[n]&&f(b,w,!0)&&u.find("."+j).css(w,"default"),u[s](B||f(b,c)||""),y?u.attr("aria-disabled","true"):u.attr("aria-checked",x?"mixed":"true"),u[t](A||f(b,z)||"")}function d(a,b,c){var d=a[0],e=a.parent(),i=b==l,k=b==p,q=b==n,u=k?o:i?m:"enabled",v=f(a,u+g(d[r])),x=f(a,b+g(d[r]));!1!==d[b]&&((k||!c||"force"==c)&&(d[b]=!1),h(a,i,u,c)),!d[n]&&f(a,w,!0)&&e.find("."+j).css(w,"pointer"),e[t](x||f(a,b)||""),q?e.attr("aria-disabled","false"):e.attr("aria-checked","false"),e[s](v||f(a,u)||"")}function e(b,c){b.data(i)&&(b.parent().html(b.attr("style",b.data(i).s||"")),c&&b[u](c),b.off(".i").unwrap(),a(v+'[for="'+b[0].id+'"]').add(b.closest(v)).off(".i"))}function f(a,b,c){return a.data(i)?a.data(i).o[b+(c?"":"Class")]:void 0}function g(a){return a.charAt(0).toUpperCase()+a.slice(1)}function h(a,b,c,d){d||(b&&a[u]("ifToggled"),a[u]("ifChanged")[u]("if"+g(c)))}var i="iCheck",j=i+"-helper",k="radio",l="checked",m="un"+l,n="disabled",o="determinate",p="in"+o,q="update",r="type",s="addClass",t="removeClass",u="trigger",v="label",w="cursor",x=/ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);a.fn[i]=function(f,g){var h='input[type="checkbox"], input[type="'+k+'"]',m=a(),o=function(b){b.each(function(){var b=a(this);m=b.is(h)?m.add(b):m.add(b.find(h))})};if(/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(f))return f=f.toLowerCase(),o(this),m.each(function(){var c=a(this);"destroy"==f?e(c,"ifDestroyed"):b(c,!0,f),a.isFunction(g)&&g()});if("object"!=typeof f&&f)return this;var w=a.extend({checkedClass:l,disabledClass:n,indeterminateClass:p,labelHover:!0,aria:!1},f),y=w.handle,z=w.hoverClass||"hover",A=w.focusClass||"focus",B=w.activeClass||"active",C=!!w.labelHover,D=w.labelHoverClass||"hover",E=0|(""+w.increaseArea).replace("%","");return("checkbox"==y||y==k)&&(h='input[type="'+y+'"]'),-50>E&&(E=-50),o(this),m.each(function(){var f=a(this);e(f);var g=this,h=g.id,m=-E+"%",o=100+2*E+"%",o={position:"absolute",top:m,left:m,display:"block",width:o,height:o,margin:0,padding:0,background:"#fff",border:0,opacity:0},m=x?{position:"absolute",visibility:"hidden"}:E?o:{position:"absolute",opacity:0},p="checkbox"==g[r]?w.checkboxClass||"icheckbox":w.radioClass||"i"+k,y=a(v+'[for="'+h+'"]').add(f.closest(v)),F=!!w.aria,G=i+"-"+Math.random().toString(36).substr(2,6),H='<div class="'+p+'" '+(F?'role="'+g[r]+'" ':"");F&&y.each(function(){H+='aria-labelledby="',this.id?H+=this.id:(this.id=G,H+=G),H+='"'}),H=f.wrap(H+"/>")[u]("ifCreated").parent().append(w.insert),o=a('<ins class="'+j+'"/>').css(o).appendTo(H),f.data(i,{o:w,s:f.attr("style")}).css(m),w.inheritClass&&H[s](g.className||""),w.inheritID&&h&&H.attr("id",i+"-"+h),"static"==H.css("position")&&H.css("position","relative"),b(f,!0,q),y.length&&y.on("click.i mouseover.i mouseout.i touchbegin.i touchend.i",function(c){var d=c[r],e=a(this);if(!g[n]){if("click"==d){if(a(c.target).is("a"))return;b(f,!1,!0)}else C&&(/ut|nd/.test(d)?(H[t](z),e[t](D)):(H[s](z),e[s](D)));if(!x)return!1;c.stopPropagation()}}),f.on("click.i focus.i blur.i keyup.i keydown.i keypress.i",function(a){var b=a[r];return a=a.keyCode,"click"!=b&&("keydown"==b&&32==a?(g[r]==k&&g[l]||(g[l]?d(f,l):c(f,l)),!1):void("keyup"==b&&g[r]==k?!g[l]&&c(f,l):/us|ur/.test(b)&&H["blur"==b?t:s](A)))}),o.on("click mousedown mouseup mouseover mouseout touchbegin.i touchend.i",function(a){var c=a[r],d=/wn|up/.test(c)?B:z;if(!g[n]){if("click"==c?b(f,!1,!0):(/wn|er|in/.test(c)?H[s](d):H[t](d+" "+B),y.length&&C&&d==z&&y[/ut|nd/.test(c)?t:s](D)),!x)return!1;a.stopPropagation()}})})}}(window.jQuery||window.Zepto),"function"!=typeof jQuery.fn.selecter&&!function(a,b){"use strict";function c(b){b=a.extend({},x,b||{}),null===w&&(w=a("body"));for(var c=a(this),e=0,f=c.length;f>e;e++)d(c.eq(e),b);return c}function d(b,c){if(!b.hasClass("selecter-element")){c=a.extend({},c,b.data("selecter-options")),c.external&&(c.links=!0);var d=b.find("option, optgroup"),g=d.filter("option"),h=g.filter(":selected"),n=""!==c.label?-1:g.index(h),p=c.links?"nav":"div";c.tabIndex=b[0].tabIndex,b[0].tabIndex=-1,c.multiple=b.prop("multiple"),c.disabled=b.is(":disabled");var q="<"+p+' class="selecter '+c.customClass;v?q+=" mobile":c.cover&&(q+=" cover"),q+=c.multiple?" multiple":" closed",c.disabled&&(q+=" disabled"),q+='" tabindex="'+c.tabIndex+'">',c.multiple||(q+='<span class="selecter-selected'+(""!==c.label?" placeholder":"")+'">',q+=a("<span></span").text(r(""!==c.label?c.label:h.text(),c.trim)).html(),q+="</span>"),q+='<div class="selecter-options">',q+="</div>",q+="</"+p+">",b.addClass("selecter-element").after(q);var s=b.next(".selecter"),u=a.extend({$select:b,$allOptions:d,$options:g,$selecter:s,$selected:s.find(".selecter-selected"),$itemsWrapper:s.find(".selecter-options"),index:-1,guid:t++},c);e(u),o(n,u),void 0!==a.fn.scroller&&u.$itemsWrapper.scroller(),u.$selecter.on("touchstart.selecter click.selecter",".selecter-selected",u,f).on("click.selecter",".selecter-item",u,j).on("close.selecter",u,i).data("selecter",u),u.$select.on("change.selecter",u,k),v||(u.$selecter.on("focus.selecter",u,l).on("blur.selecter",u,m),u.$select.on("focus.selecter",u,function(a){a.data.$selecter.trigger("focus")}))}}function e(b){for(var c="",d=b.links?"a":"span",e=0,f=0,g=b.$allOptions.length;g>f;f++){var h=b.$allOptions.eq(f);if("OPTGROUP"===h[0].tagName)c+='<span class="selecter-group',h.is(":disabled")&&(c+=" disabled"),c+='">'+h.attr("label")+"</span>";else{var i=h.val();h.attr("value")||h.attr("value",i),c+="<"+d+' class="selecter-item',h.is(":selected")&&""===b.label&&(c+=" selected"),h.is(":disabled")&&(c+=" disabled"),c+='" ',c+=b.links?'href="'+i+'"':'data-value="'+i+'"',c+=">"+a("<span></span>").text(r(h.text(),b.trim)).html()+"</"+d+">",e++}}b.$itemsWrapper.html(c),b.$items=b.$selecter.find(".selecter-item")}function f(c){c.preventDefault(),c.stopPropagation();var d=c.data;if(!d.$select.is(":disabled"))if(a(".selecter").not(d.$selecter).trigger("close.selecter",[d]),v){var e=d.$select[0];if(b.document.createEvent){var f=b.document.createEvent("MouseEvents");f.initMouseEvent("mousedown",!1,!0,b,0,0,0,0,0,!1,!1,!1,!1,0,null),e.dispatchEvent(f)}else e.fireEvent&&e.fireEvent("onmousedown")}else d.$selecter.hasClass("closed")?g(c):d.$selecter.hasClass("open")&&i(c)}function g(b){b.preventDefault(),b.stopPropagation();var c=b.data;if(!c.$selecter.hasClass("open")){var d=c.$selecter.offset(),e=w.outerHeight(),f=c.$itemsWrapper.outerHeight(!0),g=c.index>=0?c.$items.eq(c.index).position():{left:0,top:0};d.top+f>e&&c.$selecter.addClass("bottom"),c.$itemsWrapper.show(),c.$selecter.removeClass("closed").addClass("open"),w.on("click.selecter-"+c.guid,":not(.selecter-options)",c,h),void 0!==a.fn.scroller?c.$itemsWrapper.scroller("scroll",c.$itemsWrapper.find(".scroller-content").scrollTop()+g.top,0).scroller("reset"):c.$itemsWrapper.scrollTop(c.$itemsWrapper.scrollTop()+g.top)}}function h(b){b.preventDefault(),b.stopPropagation(),0===a(b.currentTarget).parents(".selecter").length&&i(b)}function i(a){a.preventDefault(),a.stopPropagation();var b=a.data;b.$selecter.hasClass("open")&&(b.$itemsWrapper.hide(),b.$selecter.removeClass("open bottom").addClass("closed"),w.off(".selecter-"+b.guid))}function j(b){b.preventDefault(),b.stopPropagation();var c=a(this),d=b.data;if(!d.$select.is(":disabled")){if(d.$itemsWrapper.is(":visible")){var e=d.$items.index(c);o(e,d),p(d)}d.multiple||i(b)}}function k(b,c){var d=a(this),e=b.data;if(!c&&!e.multiple){var f=e.$options.index(e.$options.filter("[value='"+s(d.val())+"']"));o(f,e),p(e)}}function l(b){b.preventDefault(),b.stopPropagation();var c=b.data;c.$select.is(":disabled")||c.multiple||(c.$selecter.addClass("focus").on("keydown.selecter"+c.guid,c,n),a(".selecter").not(c.$selecter).trigger("close.selecter",[c]))}function m(b){b.preventDefault(),b.stopPropagation();var c=b.data;c.$selecter.removeClass("focus").off("keydown.selecter"+c.guid+" keyup.selecter"+c.guid),a(".selecter").not(c.$selecter).trigger("close.selecter",[c])}function n(b){var c=b.data;if(13===b.keyCode)c.$selecter.hasClass("open")&&(i(b),o(c.index,c)),p(c);else if(!(9===b.keyCode||b.metaKey||b.altKey||b.ctrlKey||b.shiftKey)){b.preventDefault(),b.stopPropagation();var d=c.$items.length-1,e=c.index<0?0:c.index;if(a.inArray(b.keyCode,u?[38,40,37,39]:[38,40])>-1)e+=38===b.keyCode||u&&37===b.keyCode?-1:1,0>e&&(e=0),e>d&&(e=d);else{var f,g,h=String.fromCharCode(b.keyCode).toUpperCase();for(g=c.index+1;d>=g;g++)if(f=c.$options.eq(g).text().charAt(0).toUpperCase(),f===h){e=g;break}if(0>e)for(g=0;d>=g;g++)if(f=c.$options.eq(g).text().charAt(0).toUpperCase(),f===h){e=g;break}}e>=0&&o(e,c)}}function o(a,b){var c=b.$items.eq(a),d=c.hasClass("selected"),e=c.hasClass("disabled");if(!e){if(-1===a&&""!==b.label)b.$selected.html(b.label);else if(d)b.multiple&&(b.$options.eq(a).prop("selected",null),c.removeClass("selected"));else{var f=c.html();c.data("value"),b.multiple?b.$options.eq(a).prop("selected",!0):(b.$selected.html(f).removeClass("placeholder"),b.$items.filter(".selected").removeClass("selected"),b.$select[0].selectedIndex=a),c.addClass("selected")}(!d||b.multiple)&&(b.index=a)}}function p(a){a.links?q(a):(a.callback.call(a.$selecter,a.$select.val(),a.index),a.$select.trigger("change",[!0]))}function q(a){var c=a.$select.val();a.external?b.open(c):b.location.href=c}function r(a,b){return 0===b?a:a.length>b?a.substring(0,b)+"...":a}function s(a){return a.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1")}var t=0,u=b.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,v=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(b.navigator.userAgent||b.navigator.vendor||b.opera),w=null,x={callback:a.noop,cover:!1,customClass:"",label:"",external:!1,links:!1,trim:0},y={defaults:function(b){return x=a.extend(x,b||{}),a(this)},disable:function(b){return a(this).each(function(c,d){var e=a(d).next(".selecter").data("selecter");if(e)if("undefined"!=typeof b){var f=e.$items.index(e.$items.filter("[data-value="+b+"]"));e.$items.eq(f).addClass("disabled"),e.$options.eq(f).prop("disabled",!0)}else e.$selecter.hasClass("open")&&e.$selecter.find(".selecter-selected").trigger("click.selecter"),e.$selecter.addClass("disabled"),e.$select.prop("disabled",!0)})},enable:function(b){return a(this).each(function(c,d){var e=a(d).next(".selecter").data("selecter");if(e)if("undefined"!=typeof b){var f=e.$items.index(e.$items.filter("[data-value="+b+"]"));e.$items.eq(f).removeClass("disabled"),e.$options.eq(f).prop("disabled",!1)}else e.$selecter.removeClass("disabled"),e.$select.prop("disabled",!1)})},destroy:function(){return a(this).each(function(b,c){var d=a(c).next(".selecter").data("selecter");d&&(d.$selecter.hasClass("open")&&d.$selecter.find(".selecter-selected").trigger("click.selecter"),void 0!==a.fn.scroller&&d.$selecter.find(".selecter-options").scroller("destroy"),d.$select[0].tabIndex=d.tabIndex,d.$select.off(".selecter").removeClass("selecter-element").show(),d.$selecter.off(".selecter").remove())})},refresh:function(){return a(this).each(function(b,c){var d=a(c).next(".selecter").data("selecter");if(d){var f=d.index;d.$allOptions=d.$select.find("option, optgroup"),d.$options=d.$allOptions.filter("option"),d.index=-1,f=d.$options.index(d.$options.filter(":selected")),e(d),o(f,d)}})}};a.fn.selecter=function(a){return y[a]?y[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:c.apply(this,arguments)},a.selecter=function(a){"defaults"===a&&y.defaults.apply(this,Array.prototype.slice.call(arguments,1))}}(jQuery,window),"function"!=typeof jQuery.fn.stepper&&!function(a){"use strict";function b(b){b=a.extend({},k,b||{});for(var d=a(this),e=0,f=d.length;f>e;e++)c(d.eq(e),b);return d}function c(b,c){if(!b.hasClass("stepper-input")){c=a.extend({},c,b.data("stepper-options"));var e=parseFloat(b.attr("min")),f=parseFloat(b.attr("max")),g=parseFloat(b.attr("step"))||1;b.addClass("stepper-input").wrap('<div class="stepper '+c.customClass+'" />').after('<span class="stepper-arrow up">'+c.labels.up+'</span><span class="stepper-arrow down">'+c.labels.down+"</span>");var h=b.parent(".stepper"),j=a.extend({$stepper:h,$input:b,$arrow:h.find(".stepper-arrow"),min:void 0!==typeof e&&!isNaN(e)&&e,max:void 0!==typeof f&&!isNaN(f)&&f,step:void 0===typeof g||isNaN(g)?1:g,timer:null},c);j.digits=i(j.step),b.is(":disabled")&&h.addClass("disabled"),h.on("touchstart.stepper mousedown.stepper",".stepper-arrow",j,d).data("stepper",j)}}function d(b){b.preventDefault(),b.stopPropagation(),e(b);var c=b.data;if(!c.$input.is(":disabled")&&!c.$stepper.hasClass("disabled")){var d=a(b.target).hasClass("up")?c.step:-c.step;c.timer=g(c.timer,125,function(){f(c,d,!1)}),f(c,d),a("body").on("touchend.stepper mouseup.stepper",c,e)}}function e(b){b.preventDefault(),b.stopPropagation();var c=b.data;h(c.timer),a("body").off(".stepper")}function f(a,b){var c=parseFloat(a.$input.val()),d=b;void 0===typeof c||isNaN(c)?d=a.min!==!1?a.min:0:a.min!==!1&&c<a.min?d=a.min:d+=c;var e=(d-a.min)%a.step;0!==e&&(d-=e),a.min!==!1&&d<a.min&&(d=a.min),a.max!==!1&&d>a.max&&(d-=a.step),d!==c&&(d=j(d,a.digits),a.$input.val(d).trigger("change"))}function g(a,b,c){return h(a),setInterval(c,b)}function h(a){a&&(clearInterval(a),a=null)}function i(a){var b=String(a);return b.indexOf(".")>-1?b.length-b.indexOf(".")-1:0}function j(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c}var k={customClass:"",labels:{up:"Up",down:"Down"}},l={defaults:function(b){return k=a.extend(k,b||{}),a(this)},destroy:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$stepper.off(".stepper").find(".stepper-arrow").remove(),b.$input.unwrap().removeClass("stepper-input"))})},disable:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$input.attr("disabled","disabled"),b.$stepper.addClass("disabled"))})},enable:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$input.attr("disabled",null),b.$stepper.removeClass("disabled"))})}};a.fn.stepper=function(a){return l[a]?l[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:b.apply(this,arguments)},a.stepper=function(a){"defaults"===a&&l.defaults.apply(this,Array.prototype.slice.call(arguments,1))}}(jQuery,this),/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n<c.length;n+=1)if(m=o(c[n],f),k=m.f,"require"===k)u[n]=p.require(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=d?d.apply(q[a],u):void 0,a&&(h&&h.exports!==b&&h.exports!==q[a]?q[a]=h.exports:l===b&&s||(q[a]=l))}else a&&(q[a]=d)},a=c=n=function(a,c,d,e,f){if("string"==typeof a)return p[a]?p[a](c):j(o(a,c).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!c)return;c.splice?(a=c,c=d,d=null):a=b}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?m(b,a,c,d):setTimeout(function(){m(b,a,c,d)},4),n},n.config=function(a){return n(a)},a._defined=q,d=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},d.amd={jQuery:!0}}(),b.requirejs=a,b.require=c,b.define=d}}(),b.define("almond",function(){}),b.define("jquery",[],function(){var b=a||$;return null==b&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),b}),b.define("select2/utils",["jquery"],function(a){function b(a){var b=a.prototype,c=[];for(var d in b){var e=b[d];"function"==typeof e&&"constructor"!==d&&c.push(d)}return c}var c={};c.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},c.Decorate=function(a,c){function d(){var b=Array.prototype.unshift,d=c.prototype.constructor.length,e=a.prototype.constructor;d>0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=a.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){var a=Array.prototype.unshift;return a.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var d=function(){this.listeners={}};return d.prototype.on=function(a,b){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},d.prototype.trigger=function(a){var b=Array.prototype.slice,c=b.call(arguments,1);this.listeners=this.listeners||{},null==c&&(c=[]),0===c.length&&c.push({}),c[0]._type=a,a in this.listeners&&this.invoke(this.listeners[a],b.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},d.prototype.invoke=function(a,b){for(var c=0,d=a.length;d>c;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e<c.length;e++){var f=c[e];f=f.substring(0,1).toLowerCase()+f.substring(1),f in d||(d[f]={}),e==c.length-1&&(d[f]=a[b]),d=d[f]}delete a[b]}}return a},c.hasScroll=function(b,c){var d=a(c),e=c.style.overflowX,f=c.style.overflowY;return(e!==f||"hidden"!==f&&"visible"!==f)&&("scroll"===e||"scroll"===f||(d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth))},c.escapeMarkup=function(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<ul class="select2-results__options" role="tree"></ul>');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('<li role="treeitem" aria-live="assertive" class="select2-results__option"></li>'),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c<a.results.length;c++){var d=a.results[c],e=this.option(d);b.push(e)}this.$results.append(b)},c.prototype.position=function(a,b){var c=b.find(".select2-results");c.append(a)},c.prototype.sort=function(a){var b=this.options.get("sorter");return b(a)},c.prototype.highlightFirstItem=function(){var a=this.$results.find(".select2-results__option[aria-selected]"),b=a.filter("[aria-selected=true]");b.length>0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group",a(h),this.template(b,h);for(var i=[],j=0;j<b.children.length;j++){var k=b.children[j],l=this.option(k);i.push(l)}var m=a("<ul></ul>",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("<span></span>")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){
9
  function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('<ul class="select2-selection__rendered"></ul>'),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">&times;</span></li>');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d<a.length;d++){var e=a[d],f=this.selectionContainer(),g=this.display(e,f);f.append(g),f.prop("title",e.title||e.text),f.data("data",e),b.push(f)}var h=this.$selection.find(".select2-selection__rendered");c.appendMany(h,b)}},d}),b.define("select2/selection/placeholder",["../utils"],function(a){function b(a,b,c){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c)}return b.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},b.prototype.createPlaceholder=function(a,b){var c=this.selectionContainer();return c.html(this.display(b)),c.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),c},b.prototype.update=function(a,b){var c=1==b.length&&b[0].id!=this.placeholder.id,d=b.length>1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e<d.length;e++){var f={data:d[e]};if(this.trigger("unselect",f),f.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},c.prototype._handleKeyboardClear=function(a,c,d){d.isOpen()||(c.which==b.DELETE||c.which==b.BACKSPACE)&&this._handleClear(c)},c.prototype.update=function(b,c){if(b.call(this,c),!(this.$selection.find(".select2-selection__placeholder").length>0||0===c.length)){var d=a('<span class="select2-selection__clear">&times;</span>');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f<a.length;f++){var g=a[f].id;-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")});else{var d=a.id;this.$element.val(d),this.$element.trigger("change")}},d.prototype.unselect=function(a){var b=this;if(this.$element.prop("multiple"))return a.selected=!1,c(a.element).is("option")?(a.element.selected=!1,void this.$element.trigger("change")):void this.current(function(d){for(var e=[],f=0;f<d.length;f++){var g=d[f].id;g!==a.id&&-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")})},d.prototype.bind=function(a,b){var c=this;this.container=a,a.on("select",function(a){c.select(a.data)}),a.on("unselect",function(a){c.unselect(a.data)})},d.prototype.destroy=function(){this.$element.find("*").each(function(){c.removeData(this,"data")})},d.prototype.query=function(a,b){var d=[],e=this,f=this.$element.children();f.each(function(){var b=c(this);if(b.is("option")||b.is("optgroup")){var f=e.item(b),g=e.matches(a,f);null!==g&&d.push(g)}}),b({results:d})},d.prototype.addOptions=function(a){b.appendMany(this.$element,a)},d.prototype.option=function(a){var b;a.children?(b=document.createElement("optgroup"),b.label=a.text):(b=document.createElement("option"),void 0!==b.textContent?b.textContent=a.text:b.innerText=a.text),a.id&&(b.value=a.id),a.disabled&&(b.disabled=!0),a.selected&&(b.selected=!0),a.title&&(b.title=a.title);var d=c(b),e=this._normalizeItem(a);return e.element=b,c.data(b,"data",e),d},d.prototype.item=function(a){var b={};if(b=c.data(a[0],"data"),null!=b)return b;if(a.is("option"))b={id:a.val(),text:a.text(),disabled:a.prop("disabled"),selected:a.prop("selected"),title:a.prop("title")};else if(a.is("optgroup")){b={text:a.prop("label"),children:[],title:a.prop("title")};for(var d=a.children("option"),e=[],f=0;f<d.length;f++){var g=c(d[f]),h=this.item(g);e.push(h)}b.children=e}return b=this._normalizeItem(b),b.element=a[0],c.data(a[0],"data",b),b},d.prototype._normalizeItem=function(a){c.isPlainObject(a)||(a={id:a,text:a}),a=c.extend({},{text:""},a);var b={selected:!1,disabled:!1};return null!=a.id&&(a.id=a.id.toString()),null!=a.text&&(a.text=a.text.toString()),null==a._resultId&&a.id&&null!=this.container&&(a._resultId=this.generateResultId(this.container,a)),c.extend({},b,a)},d.prototype.matches=function(a,b){var c=this.options.get("matcher");return c(a,b)},d}),b.define("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){var c=b.get("data")||[];d.__super__.constructor.call(this,a,b),this.addOptions(this.convertToOptions(c))}return b.Extend(d,a),d.prototype.select=function(a){var b=this.$element.find("option").filter(function(b,c){return c.value==a.id.toString()});0===b.length&&(b=this.option(a),this.addOptions(b)),d.__super__.select.call(this,a)},d.prototype.convertToOptions=function(a){function d(a){return function(){return c(this).val()==a.id}}for(var e=this,f=this.$element.find("option"),g=f.map(function(){return e.item(c(this)).id}).get(),h=[],i=0;i<a.length;i++){var j=this._normalizeItem(a[i]);if(c.inArray(j.id,g)>=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h<e.length;h++){var i=e[h],j=this._normalizeItem(i),k=this.option(j);this.$element.append(k)}}return b.prototype.query=function(a,b,c){function d(a,f){for(var g=a.results,h=0;h<g.length;h++){var i=g[h],j=null!=i.children&&!d({results:i.children},!0),k=i.text===b.term;if(k||j)return!f&&(a.data=g,void c(a))}if(f)return!0;var l=e.createTag(b);if(null!=l){var m=e.option(l);m.attr("data-select2-tag",!0),e.addOptions([m]),e.insertTag(g,l)}a.results=g,c(a)}var e=this;return this._removeOldTags(),null==b.term||null!=b.page?void a.call(this,b,c):void a.call(this,b,d)},b.prototype.createTag=function(b,c){var d=a.trim(c.term);return""===d?null:{id:d,text:d}},b.prototype.insertTag=function(a,b,c){b.unshift(c)},b.prototype._removeOldTags=function(b){var c=(this._lastTag,this.$element.find("option[data-select2-tag]"));c.each(function(){this.selected||a(this).remove()})},b}),b.define("select2/data/tokenizer",["jquery"],function(a){function b(a,b,c){var d=c.get("tokenizer");void 0!==d&&(this.tokenizer=d),a.call(this,b,c)}return b.prototype.bind=function(a,b,c){a.call(this,b,c),this.$search=b.dropdown.$search||b.selection.$search||c.find(".select2-search__field")},b.prototype.query=function(b,c,d){function e(b){var c=g._normalizeItem(b),d=g.$element.find("option").filter(function(){return a(this).val()===c.id});if(!d.length){var e=g.option(c);e.attr("data-select2-tag",!0),g._removeOldTags(),g.addOptions([e])}f(c)}function f(a){g.trigger("select",{data:a})}var g=this;c.term=c.term||"";var h=this.tokenizer(c,this.options,e);h.term!==c.term&&(this.$search.length&&(this.$search.val(h.term),this.$search.focus()),c.term=h.term),b.call(this,c,d)},b.prototype.tokenizer=function(b,c,d,e){for(var f=d.get("tokenSeparators")||[],g=c.term,h=0,i=this.createTag||function(a){return{id:a.term,text:a.term}};h<g.length;){var j=g[h];if(-1!==a.inArray(j,f)){var k=g.substr(0,h),l=a.extend({},c,{term:k}),m=i(l);null!=m?(e(m),g=g.substr(h+1)||"",h=0):h++}else h++}return{term:g}},b}),b.define("select2/data/minimumInputLength",[],function(){function a(a,b,c){this.minimumInputLength=c.get("minimumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",b.term.length<this.minimumInputLength?void this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumInputLength",[],function(){function a(a,b,c){this.maximumInputLength=c.get("maximumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",this.maximumInputLength>0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<span class="select2-dropdown"><span class="select2-results"></span></span>');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('<li class="select2-results__option select2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a("<span></span>"),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.top<f.top-h.height,k=i.bottom>f.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d<b.length;d++){var e=b[d];e.children?c+=a(e.children):c++}return c}function b(a,b,c,d){this.minimumResultsForSearch=c.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),a.call(this,b,c,d)}return b.prototype.showSearch=function(b,c){return!(a(c.data.results)<this.minimumResultsForSearch)&&b.call(this,c)},b}),b.define("select2/dropdown/selectOnClose",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("close",function(a){d._handleSelectOnClose(a)})},a.prototype._handleSelectOnClose=function(a,b){if(b&&null!=b.originalSelect2Event){var c=b.originalSelect2Event;if("select"===c._type||"unselect"===c._type)return}var d=this.getHighlightedResults();if(!(d.length<1)){var e=d.data("data");null!=e.element&&e.element.selected||null==e.element&&e.selected||this.trigger("select",{data:e})}},a}),b.define("select2/dropdown/closeOnSelect",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("select",function(a){d._selectTriggered(a)}),b.on("unselect",function(a){d._selectTriggered(a)})},a.prototype._selectTriggered=function(a,b){var c=b.originalEvent;c&&c.ctrlKey||this.trigger("close",{originalEvent:c,originalSelect2Event:b})},a}),b.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(a){var b=a.input.length-a.maximum,c="Please delete "+b+" character";return 1!=b&&(c+="s"),c},inputTooShort:function(a){var b=a.minimum-a.input.length,c="Please enter "+b+" or more characters";return c},loadingMore:function(){return"Loading more results…"},maximumSelected:function(a){var b="You can only select "+a.maximum+" item";
10
  return 1!=a.maximum&&(b+="s"),b},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),b.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C){function D(){this.reset()}D.prototype.apply=function(l){if(l=a.extend(!0,{},this.defaults,l),null==l.dataAdapter){if(null!=l.ajax?l.dataAdapter=o:null!=l.data?l.dataAdapter=n:l.dataAdapter=m,l.minimumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L<K.length;L++){var M=K[L],N={};try{N=k.loadPath(M)}catch(O){try{M=this.defaults.amdLanguageBase+M,N=k.loadPath(M)}catch(P){l.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+M+'" could not be automatically loaded. A fallback will be used instead.');continue}}J.extend(N)}l.translations=J}else{var Q=k.loadPath(this.defaults.amdLanguageBase+"en"),R=new k(l.language);R.extend(Q),l.translations=R}return l},D.prototype.reset=function(){function b(a){function b(a){return l[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function c(d,e){if(""===a.trim(d.term))return e;if(e.children&&e.children.length>0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e<b.addedNodes.length;e++){var f=b.addedNodes[e];f.selected&&(c=!0)}else b.removedNodes&&b.removedNodes.length>0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},e.prototype.render=function(){var b=a('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("jquery-mousewheel",["jquery"],function(a){return a}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(a,b,c,d){if(null==a.fn.select2){var e=["open","close","destroy"];a.fn.select2=function(b){if(b=b||{},"object"==typeof b)return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,f=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=a(this).data("select2");null==c&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=c[b].apply(c,f)}),a.inArray(b,e)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c}),/*! rangeslider.js - v2.3.0 | (c) 2016 @andreruffert | MIT license | https://github.com/andreruffert/rangeslider.js */
11
+ !function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){"use strict";function b(){var a=document.createElement("input");return a.setAttribute("type","range"),"text"!==a.type}function c(a,b){var c=Array.prototype.slice.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)}function d(a,b){return b=b||100,function(){if(!a.debouncing){var c=Array.prototype.slice.apply(arguments);a.lastReturnVal=a.apply(window,c),a.debouncing=!0}return clearTimeout(a.debounceTimeout),a.debounceTimeout=setTimeout(function(){a.debouncing=!1},b),a.lastReturnVal}}function e(a){return a&&(0===a.offsetWidth||0===a.offsetHeight||a.open===!1)}function f(a){for(var b=[],c=a.parentNode;e(c);)b.push(c),c=c.parentNode;return b}function g(a,b){function c(a){"undefined"!=typeof a.open&&(a.open=!a.open)}var d=f(a),e=d.length,g=[],h=a[b];if(e){for(var i=0;i<e;i++)g[i]=d[i].style.cssText,d[i].style.setProperty?d[i].style.setProperty("display","block","important"):d[i].style.cssText+=";display: block !important",d[i].style.height="0",d[i].style.overflow="hidden",d[i].style.visibility="hidden",c(d[i]);h=a[b];for(var j=0;j<e;j++)d[j].style.cssText=g[j],c(d[j])}return h}function h(a,b){var c=parseFloat(a);return Number.isNaN(c)?b:c}function i(a){return a.charAt(0).toUpperCase()+a.substr(1)}function j(b,e){if(this.$window=a(window),this.$document=a(document),this.$element=a(b),this.options=a.extend({},n,e),this.polyfill=this.options.polyfill,this.orientation=this.$element[0].getAttribute("data-orientation")||this.options.orientation,this.onInit=this.options.onInit,this.onSlide=this.options.onSlide,this.onSlideEnd=this.options.onSlideEnd,this.DIMENSION=o.orientation[this.orientation].dimension,this.DIRECTION=o.orientation[this.orientation].direction,this.DIRECTION_STYLE=o.orientation[this.orientation].directionStyle,this.COORDINATE=o.orientation[this.orientation].coordinate,this.polyfill&&m)return!1;this.identifier="js-"+k+"-"+l++,this.startEvent=this.options.startEvent.join("."+this.identifier+" ")+"."+this.identifier,this.moveEvent=this.options.moveEvent.join("."+this.identifier+" ")+"."+this.identifier,this.endEvent=this.options.endEvent.join("."+this.identifier+" ")+"."+this.identifier,this.toFixed=(this.step+"").replace(".","").length-1,this.$fill=a('<div class="'+this.options.fillClass+'" />'),this.$handle=a('<div class="'+this.options.handleClass+'" />'),this.$range=a('<div class="'+this.options.rangeClass+" "+this.options[this.orientation+"Class"]+'" id="'+this.identifier+'" />').insertAfter(this.$element).prepend(this.$fill,this.$handle),this.$element.css({position:"absolute",width:"1px",height:"1px",overflow:"hidden",opacity:"0"}),this.handleDown=a.proxy(this.handleDown,this),this.handleMove=a.proxy(this.handleMove,this),this.handleEnd=a.proxy(this.handleEnd,this),this.init();var f=this;this.$window.on("resize."+this.identifier,d(function(){c(function(){f.update(!1,!1)},300)},20)),this.$document.on(this.startEvent,"#"+this.identifier+":not(."+this.options.disabledClass+")",this.handleDown),this.$element.on("change."+this.identifier,function(a,b){if(!b||b.origin!==f.identifier){var c=a.target.value,d=f.getPositionFromValue(c);f.setPosition(d)}})}Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&a!==a};var k="rangeslider",l=0,m=b(),n={polyfill:!0,orientation:"horizontal",rangeClass:"rangeslider",disabledClass:"rangeslider--disabled",activeClass:"rangeslider--active",horizontalClass:"rangeslider--horizontal",verticalClass:"rangeslider--vertical",fillClass:"rangeslider__fill",handleClass:"rangeslider__handle",startEvent:["mousedown","touchstart","pointerdown"],moveEvent:["mousemove","touchmove","pointermove"],endEvent:["mouseup","touchend","pointerup"]},o={orientation:{horizontal:{dimension:"width",direction:"left",directionStyle:"left",coordinate:"x"},vertical:{dimension:"height",direction:"top",directionStyle:"bottom",coordinate:"y"}}};return j.prototype.init=function(){this.update(!0,!1),this.onInit&&"function"==typeof this.onInit&&this.onInit()},j.prototype.update=function(a,b){a=a||!1,a&&(this.min=h(this.$element[0].getAttribute("min"),0),this.max=h(this.$element[0].getAttribute("max"),100),this.value=h(this.$element[0].value,Math.round(this.min+(this.max-this.min)/2)),this.step=h(this.$element[0].getAttribute("step"),1)),this.handleDimension=g(this.$handle[0],"offset"+i(this.DIMENSION)),this.rangeDimension=g(this.$range[0],"offset"+i(this.DIMENSION)),this.maxHandlePos=this.rangeDimension-this.handleDimension,this.grabPos=this.handleDimension/2,this.position=this.getPositionFromValue(this.value),this.$element[0].disabled?this.$range.addClass(this.options.disabledClass):this.$range.removeClass(this.options.disabledClass),this.setPosition(this.position,b)},j.prototype.handleDown=function(a){if(a.preventDefault(),this.$document.on(this.moveEvent,this.handleMove),this.$document.on(this.endEvent,this.handleEnd),this.$range.addClass(this.options.activeClass),!((" "+a.target.className+" ").replace(/[\n\t]/g," ").indexOf(this.options.handleClass)>-1)){var b=this.getRelativePosition(a),c=this.$range[0].getBoundingClientRect()[this.DIRECTION],d=this.getPositionFromNode(this.$handle[0])-c,e="vertical"===this.orientation?this.maxHandlePos-(b-this.grabPos):b-this.grabPos;this.setPosition(e),b>=d&&b<d+this.handleDimension&&(this.grabPos=b-d)}},j.prototype.handleMove=function(a){a.preventDefault();var b=this.getRelativePosition(a),c="vertical"===this.orientation?this.maxHandlePos-(b-this.grabPos):b-this.grabPos;this.setPosition(c)},j.prototype.handleEnd=function(a){a.preventDefault(),this.$document.off(this.moveEvent,this.handleMove),this.$document.off(this.endEvent,this.handleEnd),this.$range.removeClass(this.options.activeClass),this.$element.trigger("change",{origin:this.identifier}),this.onSlideEnd&&"function"==typeof this.onSlideEnd&&this.onSlideEnd(this.position,this.value)},j.prototype.cap=function(a,b,c){return a<b?b:a>c?c:a},j.prototype.setPosition=function(a,b){var c,d;void 0===b&&(b=!0),c=this.getValueFromPosition(this.cap(a,0,this.maxHandlePos)),d=this.getPositionFromValue(c),this.$fill[0].style[this.DIMENSION]=d+this.grabPos+"px",this.$handle[0].style[this.DIRECTION_STYLE]=d+"px",this.setValue(c),this.position=d,this.value=c,b&&this.onSlide&&"function"==typeof this.onSlide&&this.onSlide(d,c)},j.prototype.getPositionFromNode=function(a){for(var b=0;null!==a;)b+=a.offsetLeft,a=a.offsetParent;return b},j.prototype.getRelativePosition=function(a){var b=i(this.COORDINATE),c=this.$range[0].getBoundingClientRect()[this.DIRECTION],d=0;return"undefined"!=typeof a.originalEvent["client"+b]?d=a.originalEvent["client"+b]:a.originalEvent.touches&&a.originalEvent.touches[0]&&"undefined"!=typeof a.originalEvent.touches[0]["client"+b]?d=a.originalEvent.touches[0]["client"+b]:a.currentPoint&&"undefined"!=typeof a.currentPoint[this.COORDINATE]&&(d=a.currentPoint[this.COORDINATE]),d-c},j.prototype.getPositionFromValue=function(a){var b,c;return b=(a-this.min)/(this.max-this.min),c=Number.isNaN(b)?0:b*this.maxHandlePos},j.prototype.getValueFromPosition=function(a){var b,c;return b=a/(this.maxHandlePos||1),c=this.step*Math.round(b*(this.max-this.min)/this.step)+this.min,Number(c.toFixed(this.toFixed))},j.prototype.setValue=function(a){a===this.value&&""!==this.$element[0].value||this.$element.val(a).trigger("input",{origin:this.identifier})},j.prototype.destroy=function(){this.$document.off("."+this.identifier),this.$window.off("."+this.identifier),this.$element.off("."+this.identifier).removeAttr("style").removeData("plugin_"+k),this.$range&&this.$range.length&&this.$range[0].parentNode.removeChild(this.$range[0])},a.fn[k]=function(b){var c=Array.prototype.slice.call(arguments,1);return this.each(function(){var d=a(this),e=d.data("plugin_"+k);e||d.data("plugin_"+k,e=new j(this,b)),"string"==typeof b&&e[b].apply(e,c)})},"rangeslider.js is available in jQuery context e.g $(selector).rangeslider(options);"}),function(a,b,c){a.bind("ready",function(){a.previewedDevice&&a.previewedDevice.bind(function(b){a.previewer.send("previewed-device",b)})})}(wp.customize,jQuery,_),function(a,b,c){a.czr_skopeReady=b.Deferred(),!c.isUndefined(serverControlParams.isSkopOn)&&serverControlParams.isSkopOn||a.czr_skopeReady.resolve();var d=function(a){var b={bgCol:"#5ed1f5",textCol:"#000",consoleArguments:[]};a=c.extend(b,a);var d=Array.from(a.consoleArguments),e=function(a){return c.isString(a)?a.length>150?a.substr(0,149):a:""};return d=c.isEmpty(c.filter(d,function(a){return!c.isString(a)}))?d.join(" "):JSON.stringify(d.join(" ")),["%c "+e(d),["background:"+a.bgCol,"color:"+a.textCol,"display: block;"].join(";")]};a.consoleLog=function(){serverControlParams.isDevMode&&(c.isUndefined(console)&&"function"!=typeof window.console.log||console.log.apply(console,d({consoleArguments:arguments})))},a.errorLog=function(){c.isUndefined(console)&&"function"!=typeof window.console.log||console.log.apply(console,d({bgCol:"#ffd5a0",textCol:"#000",consoleArguments:arguments}))},a.czr_isSkopOn=function(){return!c.isUndefined(serverControlParams.isSkopOn)&&serverControlParams.isSkopOn&&c.has(a,"czr_skopeBase")},a.czr_isChangeSetOn=function(){return serverControlParams.isChangeSetOn&&!0}}(wp.customize,jQuery,_),function(a,b,c){a.Value.prototype.set=function(d,e){var f=this._value,g=b.Deferred(),h=this,i=[];return d=this._setter.apply(this,arguments),d=this.validate(d),args=c.extend({silent:!1},c.isObject(e)?e:{}),null===d||c.isEqual(f,d)?g.resolveWith(h,[d,f,e]).promise():(this._value=d,this._dirty=!0,!0===args.silent?g.resolveWith(h,[d,f,e]).promise():this._deferreds?(c.each(h._deferreds,function(a){i.push(a.apply(null,[d,f,e]))}),b.when.apply(null,i).fail(function(){a.errorLog("A deferred callback failed in api.Value::set()")}).then(function(){h.callbacks.fireWith(h,[d,f,e]),g.resolveWith(h,[d,f,e])}),g.promise(h)):(this.callbacks.fireWith(this,[d,f,e]),g.resolveWith(h,[d,f,e]).promise(h)))},a.Value.prototype.bind=function(){var a=this,d=!1,e=[];return b.each(arguments,function(a,b){d||(d=c.isObject(b)&&b.deferred),c.isFunction(b)&&e.push(b)}),d?(a._deferreds=a._deferreds||[],c.each(e,function(b){c.contains(b,a._deferreds)||a._deferreds.push(b)})):a.callbacks.add.apply(a.callbacks,arguments),this},a.Setting.prototype.silent_set=function(b,d){var e=this._value,f=a.state("saved")();return b=this._setter.apply(this,arguments),b=this.validate(b),null===b||c.isEqual(e,b)?this:(this._value=b,this._dirty=c.isUndefined(d)||!c.isBoolean(d)?this._dirty:d,this.callbacks.fireWith(this,[b,e,{silent:!0}]),a.state("saved")(f),this)}}(wp.customize,jQuery,_),function(a,b,c){a.Setting.prototype.initialize=function(b,c,d){var e=this;a.Value.prototype.initialize.call(e,c,d),e.id=b,e.transport=e.transport||"refresh",e._dirty=d.dirty||!1,e.notifications=new a.Values({defaultConstructor:a.Notification}),e.bind(e.preview)},a.Setting.prototype.preview=function(d,e,f){var g,h=this,i=b.Deferred();return g=h.transport,serverControlParams.isSkopOn&&a.czr_isPreviewerSkopeAware&&"pending"==a.czr_isPreviewerSkopeAware.state()?(this.previewer.refresh(),i.resolve(arguments).promise()):c.isUndefined(e)||c.isEmpty(e)||c.isNull(e)||!c.isObject(f)||!0!==f.not_preview_sent?c.has(f,"silent")&&!1!==f.silent?i.resolve(arguments).promise():("postMessage"!==g||a.state("previewerAlive").get()||(g="refresh"),"postMessage"===g?(h.previewer.send("pre_setting",{set_id:h.id,data:f,value:d}),h.previewer.send("setting",[h.id,h()]),i.resolve(arguments)):"refresh"===g&&(serverControlParams.isSkopOn?h.previewer.refresh().always(function(){i.resolve(arguments)}):(h.previewer.refresh(),i.resolve(arguments))),i.promise()):i.resolve(arguments).promise()}}(wp.customize,jQuery,_),function(a,b,c){if("function"==typeof a.Section){var d=a.Section.prototype.initialize;a.Section.prototype.initialize=function(a,e){d.apply(this,[a,e]);var f=this;this.expanded.callbacks.add(function(a){if(a){var d=f.container.closest(".wp-full-overlay-sidebar-content"),e=f.container.find(".accordion-section-content");_resizeContentHeight=function(){e.css("height",d.innerHeight())},_resizeContentHeight(),b(window).on("resize.customizer-section",c.debounce(_resizeContentHeight,110))}})}}}(wp.customize,jQuery,_),function(a,b,c){a.CZR_Helpers=a.CZR_Helpers||{},a.CZR_Helpers=b.extend(a.CZR_Helpers,{getControlSettingId:function(b,d){return d="default",a.control.has(b)?!c.has(a.control(b),"settings")||c.isEmpty(a.control(b).settings)?b:c.has(a.control(b).settings,d)?c.isUndefined(a.control(b).settings[d].id)?(a.consoleLog("getControlSettingId : The requested control_id has no setting id assigned : "+b),b):a.control(b).settings[d].id:(a.consoleLog("getControlSettingId : The requested control_id does not have the requested setting type : "+b+" , "+d),b):(a.consoleLog("getControlSettingId : The requested control_id is not registered in the api yet : "+b),b)},getDocSearchLink:function(a){a=c.isString(a)?a:"";var b=a.replace(/ /g,"+"),d=[serverControlParams.docURL,"search?query=",b].join("");return['<a href="'+d+'" title="'+serverControlParams.i18n.readDocumentation+'" target="_blank">'," ",'<span class="fa fa-question-circle-o"></span>'].join("")},build_setId:function(a){return c.contains(serverControlParams.wpBuiltinSettings,a)?a:c.contains(serverControlParams.themeSettingList,a)&&-1==a.indexOf(serverControlParams.themeOptions)?[serverControlParams.themeOptions+"[",a,"]"].join(""):a},getOptionName:function(a){return-1==a.indexOf(serverControlParams.themeOptions)?a:a.replace(/\[|\]/g,"").replace(serverControlParams.themeOptions,"")},hasPartRefresh:function(b){if(c.has(a,"czr_partials"))return c.contains(c.map(a.czr_partials(),function(a,d){return c.contains(a.settings,b)}),!0)},getSectionControlIds:function(b){return b=b||a.czr_activeSectionId(),a.section.has(b)?c.map(a.section(b).controls(),function(a){return a.id}):[]},getSectionSettingIds:function(b){if(b=b||a.czr_activeSectionId(),a.section.has(b)){var d=this,e=[],f=d.getSectionControlIds(b);return c.each(f,function(b){c.each(a.control(b).settings,function(a,b){e.push(a.id)})}),e}},capitalize:function(a){return c.isString(a)?a.charAt(0).toUpperCase()+a.slice(1):a},truncate:function(a,b,d){if(!c.isString(a))return"";b=b||20;var e=a.length>b,f=e?a.substr(0,b-1):a;return f=d&&e?f.substr(0,f.lastIndexOf(" ")):f,e?f+"...":f},isMultiItemModule:function(b,d){if(!c.isUndefined(b)||c.isObject(d)){if(c.isObject(d)&&c.has(d,"module_type"))b=d.module_type;else if(c.isUndefined(b)||c.isNull(b))return;if(c.has(a.czrModuleMap,b))return a.czrModuleMap[b].crud||a.czrModuleMap[b].multi_item||!1}},isCrudModule:function(b,d){if(!c.isUndefined(b)||c.isObject(d)){if(c.isObject(d)&&c.has(d,"module_type"))b=d.module_type;else if(c.isUndefined(b)||c.isNull(b))return;if(c.has(a.czrModuleMap,b))return a.czrModuleMap[b].crud||!1}},hasModuleModOpt:function(b,d){if(!c.isUndefined(b)||c.isObject(d)){if(c.isObject(d)&&c.has(d,"module_type"))b=d.module_type;else if(c.isUndefined(b)||c.isNull(b))return;if(c.has(a.czrModuleMap,b))return a.czrModuleMap[b].has_mod_opt||!1}},setupInputCollectionFromDOM:function(){var d=this;if(!c.isFunction(d))throw new Error("setupInputCollectionFromDOM : inputParentInst is not valid.");var e=d.module,f=c.has(d(),"is_mod_opt");if(!c.has(d,"czr_Input")||c.isEmpty(d.inputCollection())){d.czr_Input=new a.Values,d.inputConstructor=f?e.inputModOptConstructor:e.inputConstructor;var g=f?d.defaultModOptModel:d.defaultItemModel;if(c.isEmpty(g)||c.isUndefined(g))throw new Error("No default model found in item or mod opt "+d.id+".");var h=b.extend(!0,{},d());h=c.isObject(h)?b.extend(g,h):g;var i={};return b("."+e.control.css_attr.sub_set_wrapper,d.container).each(function(g){var j=b(this).find("[data-type]").attr("data-type"),k=c.has(h,j)?h[j]:"";if(c.isUndefined(j)||c.isEmpty(j))return void a.consoleLog("setupInputCollectionFromDOM : missing data-type for "+e.id);if(!c.has(h,j))throw new Error("The item or mod opt property : "+j+" has been found in the DOM but not in the item or mod opt model : "+d.id+". The input can not be instantiated.");var l=b(this).attr("data-input-type"),m=b(this).attr("data-transport")||"inherit",n=c.has(e.inputOptions,l)?e.inputOptions[l]:{};d.czr_Input.add(j,new d.inputConstructor(j,{id:j,type:l,transport:m,input_value:k,input_options:n,container:b(this),input_parent:d,is_mod_opt:f,module:e})),d.czr_Input(j).ready(),i[j]=k}),d.inputCollection(i),d}},removeInputCollection:function(){var a=this;if(!c.isFunction(a))throw new Error("removeInputCollection : inputParentInst is not valid.");c.has(a,"czr_Input")&&(a.czr_Input.each(function(b){a.czr_Input.remove(b.id)}),a.inputCollection({}))},refreshModuleControl:function(c){var d=a.controlConstructor.czr_module,e=(a.control(c).params.type,a.settings.controls[c]);b.when(a.control(c).container.remove()).done(function(){a.control.remove(c),a.control.add(c,new d(c,{params:e,previewer:a.previewer}))})},hexToRgb:function(b){var c=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;try{b=b.replace(c,function(a,b,c,d){return b+b+c+c+d+d})}catch(d){return a.errorLog("Error in Helpers::hexToRgb : "+d),b}var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(b);return e=e?[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]:[],"rgb("+e.join(",")+")"},rgbToHex:function(a,b,c){var d=function(a){var b=a.toString(16);return 1==b.length?"0"+b:b};return"#"+d(a)+d(b)+d(c)}})}(wp.customize,jQuery,_),function(a,b,c){a.CZR_Helpers=a.CZR_Helpers||{},a.CZR_Helpers=b.extend(a.CZR_Helpers,{addActions:function(a,b,d){var e=this;d=d||e,d[a]=d[a]||[],new_event_map=c.clone(d[a]),d[a]=c.union(new_event_map,c.isArray(b)?b:[b])},doActions:function(a,b,c){b.trigger(a,c)},setupDOMListeners:function(d,e,f){var g=this,h={model:{},dom_el:{}};return f=f||g,c.isArray(d)?c.isObject(e)?(e=c.extend(h,e),!e.dom_el instanceof jQuery||1!=e.dom_el.length?void a.errorLog("setupDomListeners : dom element should be an existing dom element",e):void c.map(d,function(d){return!c.isString(d.selector)||c.isEmpty(d.selector)?void a.errorLog("setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : "+d.actions.join(",")):!c.isString(d.selector)||c.isEmpty(d.selector)?void a.errorLog("setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : "+d.actions.join(",")):void e.dom_el.on(d.trigger,d.selector,function(h,i){if(h.stopPropagation(),!a.utils.isKeydownButNotEnterEvent(h)){h.preventDefault();var j=b.extend(!0,{},e);if(c.has(j,"model")&&c.has(j.model,"id")&&(c.has(f,"get")?j.model=f():j.model=f.getModel(j.model.id)),b.extend(j,{event:d,dom_event:h}),b.extend(j,i),!c.has(j,"event")||!c.has(j.event,"actions"))return void a.errorLog("executeEventActionChain : missing obj.event or obj.event.actions");try{g.executeEventActionChain(j,f)}catch(k){a.errorLog("In setupDOMListeners : problem when trying to fire actions : "+j.event.actions),a.errorLog("Error : "+k)}}})})):void a.errorLog("setupDomListeners : args should be an object",d):void a.errorLog("setupDomListeners : event_map should be an array",e)},executeEventActionChain:function(a,b){var d=this;if("function"==typeof a.event.actions)return a.event.actions.call(b,a);c.isArray(a.event.actions)||(a.event.actions=[a.event.actions]);var e=!1;c.map(a.event.actions,function(f){if(!e){if("function"!=typeof b[f])throw new Error("executeEventActionChain : the action : "+f+" has not been found when firing event : "+a.event.selector);var g=c.has(a,"dom_el")&&-1!=a.dom_el.length?a.dom_el:d.container;g.trigger("before_"+f,c.omit(a,"event"));var h=b[f].call(b,a);!1===h&&(e=!0),g.trigger("after_"+f,c.omit(a,"event"))}})}})}(wp.customize,jQuery,_),function(a,b,c){a.czr_wpQueryDataReady=b.Deferred(),a.czr_wpQueryInfos=a.czr_wpQueryInfos||new a.Value,a.czr_partials=a.czr_partials||new a.Value,a.bind("ready",function(){a.previewer.bind("houston-widget-settings",function(b){var d=c.filter(b.registeredSidebars,function(a){return!c.findWhere(_wpCustomizeWidgetsSettings.registeredSidebars,{id:a.id})}),e=c.filter(b.registeredSidebars,function(a){return!c.has(b.renderedSidebars,a.id)});e=c.map(e,function(a){return a.id});var f=c.map(b.registeredSidebars,function(a){return a.id});a.czr_widgetZoneSettings=a.czr_widgetZoneSettings||new a.Value,a.czr_widgetZoneSettings.set({actives:b.renderedSidebars,inactives:e,registered:f,candidates:d,available_locations:b.availableWidgetLocations})}),a.previewer.bind("czr-query-data-ready",function(b){a.czr_wpQueryInfos(b),"pending"==a.czr_wpQueryDataReady.state()&&a.czr_wpQueryDataReady.resolve(b)}),a.previewer.bind("czr-partial-refresh-data",function(b){a.czr_partials.set(b)}),a.previewer.bind("czr-partial-refresh-done",function(b){if(c.has(b,"set_id")){var d=a.CZR_Helpers.build_setId(b.set_id);if(a.has(d)){var e=a.CZR_Helpers.getControlSettingId(d);a.control.has(e)&&a.control(e).trigger("czr-partial-refresh-done")}}})})}(wp.customize,jQuery,_);var CZRInputMths=CZRInputMths||{};!function(a,b,c){b.extend(CZRInputMths,{initialize:function(d,e){if(c.isUndefined(e.input_parent)||c.isEmpty(e.input_parent))throw new Error("No input_parent assigned to input "+e.id+". Aborting");if(c.isUndefined(e.module))throw new Error("No module assigned to input "+e.id+". Aborting");a.Value.prototype.initialize.call(this,null,e);var f=this;if(b.extend(f,e||{}),f.isReady=b.Deferred(),c.isUndefined(e.input_value)||f.set(e.input_value),a.czrInputMap&&c.has(a.czrInputMap,f.type)){var g=a.czrInputMap[f.type];c.isFunction(f[g])&&f[g](e.input_options||null)}else a.consoleLog("Warning an input : "+f.id+" has no corresponding method defined in api.czrInputMap.");var h={text:"keyup",textarea:"keyup",password:"keyup",color:"colorpickerchange",range:"input propertychange"};f.input_event_map=[{trigger:b.trim(["change",h[f.type]||""].join(" ")),selector:"input[data-type], select[data-type], textarea[data-type]",name:"set_input_value",actions:function(a){if(!c.has(f.input_parent,"syncElements")||!c.has(f.input_parent.syncElements,f.id))throw new Error("WARNING : THE INPUT "+f.id+" HAS NO SYNCED ELEMENT.")}}],f.visible=new a.Value((!0)),f.isReady.done(function(){f.visible.bind(function(a){a?f.container.stop(!0,!0).slideDown(200):f.container.stop(!0,!0).slideUp(200)})}),f.enabled=new a.Value((!0)),f.isReady.done(function(){f.enabled.bind(function(a){f.container.toggleClass("disabled",!a)})})},ready:function(){var a=this;a.setupDOMListeners(a.input_event_map,{dom_el:a.container},a),a.callbacks.add(function(){return a.inputReact.apply(a,arguments)}),b.when(a.setupSynchronizer()).done(function(){a.isReady.resolve(a)})},setupSynchronizer:function(){var b=this,c=b.input_parent,d=b.container.find("[data-type]"),e=b.container.find("[data-type]").is("textarea");if(e)throw new Error("TO DO : THE TEXTAREA INPUT ARE NOT READY IN THE SYNCHRONIZER!");var f=new a.Element(d);c.syncElements=c.syncElements||{},c.syncElements[b.id]=f,f.sync(b),f.set(b())},inputReact:function(a,b,d){var e=this,f=e.input_parent(),g=c.clone(f),h=e.is_preItemInput;e.enabled()&&(g=!c.isObject(g)||c.isEmpty(g)?{}:g,g[e.id]=a,e.input_parent.set(g,{input_changed:e.id,input_transport:e.transport,not_preview_sent:"postMessage"===e.transport}),h||(e.input_parent.trigger(e.id+":changed",a),c.isEmpty(b)&&(c.isUndefined(b)||"postMessage"!==e.transport)||e.module.sendInputToPreview({input_id:e.id,input_parent_id:e.input_parent.id,to:a,from:b})))},setupColorPicker:function(){var a=this;a.container.find("input").iris({palettes:!0,hide:!1,change:function(a,c){b(this).val(c.color.toString()).trigger("colorpickerchange").trigger("change")}})},setupSelect:function(){var a=this;b("select",a.container).not(".no-selecter-js").each(function(){b(this).selecter({})})},setupIcheck:function(a){var c=this;b("input[type=checkbox]",c.container).each(function(a){0===b(this).closest('div[class^="icheckbox"]').length&&b(this).iCheck({checkboxClass:"icheckbox_flat-grey",checkedClass:"checked",radioClass:"iradio_flat-grey"}).on("ifChanged",function(a){b(this).val(!1===b(this).is(":checked")?0:1),b(a.currentTarget).trigger("change")})})},setupStepper:function(a){var c=this;b('input[type="number"]',c.container).each(function(a){b(this).stepper()})},setupRangeSlider:function(a){var c,d=this,e=function(a,b){a.textContent=b+"%"};b(d.container).find("input").rangeslider({polyfill:!1,rangeClass:"rangeslider",disabledClass:"rangeslider--disabled",horizontalClass:"rangeslider--horizontal",verticalClass:"rangeslider--vertical",fillClass:"rangeslider__fill",handleClass:"rangeslider__handle",onInit:function(){c=b(".rangeslider__handle",this.$range),b(".rangeslider__handle",this.$range),e(c[0],this.value)}}).on("input",function(){e(c[0],this.value)})}})}(wp.customize,jQuery,_);var CZRInputMths=CZRInputMths||{};!function(a,b,c){b.extend(CZRInputMths,{setupImageUploader:function(){var a=this,c=a();return a.attachment={},a.container?(this.tmplRendered=b.Deferred(),this.setupContentRendering(c,{}),void this.tmplRendered.done(function(){a.czrImgUploaderBinding()})):this},setupContentRendering:function(a,b){var d,e=this;e.attachment.id!=a&&b!==a?(a||(e.attachment={},e.renderImageUploaderTemplate()),d=wp.media.attachment(a),c.isObject(d)&&c.has(d,"attributes")&&c.has(d.attributes,"sizes")?(e.attachment=d.attributes,e.renderImageUploaderTemplate()):wp.media.attachment(a).fetch().done(function(){e.attachment=this.attributes,e.renderImageUploaderTemplate()})):e.attachment.id&&e.attachment.id!==a||e.renderImageUploaderTemplate()},czrImgUploaderBinding:function(){var a=this;c.bindAll(a,"czrImgUploadRemoveFile","czrImgUploadOpenFrame","czrImgUploadSelect"),a.container.on("click keydown",".upload-button",a.czrImgUploadOpenFrame),a.container.on("click keydown",".thumbnail-image img",a.czrImgUploadOpenFrame),a.container.on("click keydown",".remove-button",a.czrImgUploadRemoveFile),a.bind(a.id+":changed",function(c,d){a.tmplRendered=b.Deferred(),a.setupContentRendering(c,d)})},czrImgUploadOpenFrame:function(b){a.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),this.frame||this.czrImgUploadInitFrame(),this.frame.open())},czrImgUploadInitFrame:function(){var a=this,b=this.getUploaderLabels();a.frame=wp.media({button:{text:b.frame_button},states:[new wp.media.controller.Library({title:b.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1})]}),a.frame.on("select",a.czrImgUploadSelect)},czrImgUploadRemoveFile:function(b){var c=this;a.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),c.attachment={},c.set(""))},czrImgUploadSelect:function(){var a=this,b=a.frame.state().get("selection").first().toJSON();window._wpmejsSettings||{};a.attachment=b,a.set(b.id)},renderImageUploaderTemplate:function(){var a=this;if(0!==b("#tmpl-czr-input-img-uploader-view-content").length){var c=wp.template("czr-input-img-uploader-view-content");if(c&&a.container){var d=a.container.find("."+a.module.control.css_attr.img_upload_container);if(d.length){var e={button_labels:a.getUploaderLabels(),settings:a.id,attachment:a.attachment,canUpload:!0};return d.html(c(e)),a.tmplRendered.resolve(),a.container.trigger(a.id+":content_rendered"),!0}}}},getUploaderLabels:function(){var b=serverControlParams.i18n,d={select:b.select_image,change:b.change_image,remove:b.remove_image,"default":b.default_image,placeholder:b.placeholder_image,frame_title:b.frame_title_image,frame_button:b.frame_button_image};return c.each(d,function(b,d){if(c.isUndefined(b)){var e=this;return a.errorLog("A translated string is missing ( "+d+" ) for the image uploader input in module : "+e.module.id),""}}),d}})}(wp.customize,jQuery,_);var CZRInputMths=CZRInputMths||{};!function(a,b,c){b.extend(CZRInputMths,{setupContentPicker:function(d){var e=this,f=[];b.extend({post:"",taxonomy:""},c.isObject(d)?d:{}),e.wpObjectTypes=d,e.container.find(".czr-input").append('<select data-select-type="content-picker-select" class="js-example-basic-simple"></select>'),f=[{trigger:"change",selector:"select[data-select-type]",name:"set_input_value",actions:function(d){var f=b(d.dom_event.currentTarget,d.dom_el),g=b(f,d.dom_el).select2("data"),h={},i={id:"",type_label:"",title:"",object_type:"",url:""};return g=c.isArray(g)?g[0]:g,!c.isObject(g)||c.isEmpty(g)?void a.errorLog("Content Picker Input : the picked value should be an object not empty."):(c.each(i,function(b,d){return"_custom_"===g.id||c.has(g,d)&&!c.isEmpty(g[d])?void(h[d]=g[d]):void a.errorLog("content_picker : missing input param : "+d)}),void e.set(h))}}],e.setupDOMListeners(f,{dom_el:e.container},e),e.isReady.done(function(){e.setupContentSelecter()})},setupContentSelecter:function(){var a=this;if(!c.isEmpty(a())){var d={value:a().id||"",title:a().title||"",selected:"selected"};a.container.find("select").append(b("<option>",d))}a.container.find("select").select2({placeholder:{id:"-1",title:"Select"},data:a.setupSelectedContents(),ajax:{url:serverControlParams.AjaxUrl,type:"POST",dataType:"json",delay:250,debug:!0,data:function(b){var c=b.page?b.page:0;return c=b.term?b.page:c,{action:b.term?"search-available-content-items-customizer":"load-available-content-items-customizer",search:b.term,wp_customize:"on",page:c,wp_object_types:JSON.stringify(a.wpObjectTypes),CZRCpNonce:serverControlParams.CZRCpNonce}},processResults:function(b,d){if(a.defaultContentPickerOption=a.defaultContentPickerOption||[],!b.success)return{results:a.defaultContentPickerOption};var e=b.data.items,f=[];return c.each(e,function(a){f.push({id:a.id,title:a.title,type_label:a.type_label,object_type:a.object,url:a.url})}),{results:f,pagination:{more:b.data.items.length>=10}}}},templateSelection:a.czrFormatContentSelected,templateResult:a.czrFormatContentSelected,escapeMarkup:function(a){return a}})},czrFormatContentSelected:function(a){if(a.loading)return a.text;var b="<div class='content-picker-item clearfix'><div class='content-item-bar'><span class='czr-picker-item-title'>"+a.title+"</span>";return