Hueman Addons - Version 2.0.12

Version Description

October 14th 2017 = * fix : customizer preview not working in hueman pro when the hueman addons plugin activated. fixes #35. * improved : various minor improvements in the customizer control javascript * added : a search doc field to the welcome page

Download this release

Release Info

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

Code changes from version 2.0.11 to 2.0.12

addons/admin/ha-hs-doc.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ add_action( 'current_screen', 'ha_schedule_welcome_page_actions');
3
+ function ha_schedule_welcome_page_actions() {
4
+ $screen = get_current_screen();
5
+ //@see hueman/functions/admin/class-admin-page.php
6
+ if ( 'appearance_page_welcome' != $screen-> id )
7
+ return;
8
+
9
+ add_filter( 'hu_display_doc_support_content', '__return_false' );
10
+ add_filter( 'hu_after_welcome_admin_intro', 'ha_print_hs_doc_content');
11
+ add_action( 'admin_enqueue_scripts', 'ha_enqueue_hs_doc_js' );
12
+ add_action( 'admin_head', 'ha_write_hs_js_style' );
13
+ }
14
+
15
+ //hook : hu_after_welcome_admin_intro
16
+ function ha_print_hs_doc_content() {
17
+ ?>
18
+ <form enctype="multipart/form-data" method="post" class="frm-show-form " id="form_m3j26q22">
19
+ <div class="frm_form_fields ">
20
+ <fieldset>
21
+ <div id="frm_field_335_container" class="frm_form_field form-field frm_top_container helpscout-docs">
22
+ <label for="field_6woxqa" class="frm_primary_label">
23
+ <h2>Search the knowledge base</h2>
24
+ <h4 style="text-align:center;font-style: italic;font-weight: normal;">In a few keywords, describe your issue or the information you are looking for.</h4>
25
+ <span class="frm_required"></span>
26
+ </label>
27
+ <input type="text" id="field_6woxqa" name="item_meta[335]" value="" placeholder="Ex. Logo upload" autocomplete="off">
28
+
29
+ <div class="frm_description"><u>Search tips</u> : If you get too many results, try to narrow down your search by prefixing it with the words "Hueman" or "Hueman Pro" for example. If there's no results, try different keywords and / or spelling variations </div>
30
+ </div>
31
+ </fieldset>
32
+ </div>
33
+ </form>
34
+ <?php
35
+ }
36
+
37
+ //hook : admin_enqueue_scripts
38
+ function ha_enqueue_hs_doc_js() {
39
+ $screen = get_current_screen();
40
+ if ( 'appearance_page_welcome' != $screen-> id )
41
+ return;
42
+
43
+ wp_enqueue_script(
44
+ 'hs-search',
45
+ sprintf('%1$saddons/assets/back/js/hs-search.min.js' , HA_BASE_URL ),
46
+ array( 'jquery', 'underscore' ),
47
+ null,
48
+ $in_footer = false
49
+ );
50
+ $script_settings = array(
51
+ 'debug' => false, // Print debug logs or not
52
+ 'searchDelay' => 750, // Delay time in ms after a user stops typing and before search is performed
53
+ 'minLength' => 3, // Minimum number of characters required to trigger search
54
+ 'limit' => 25, // Max limit for # of results to show
55
+ 'text' => array(
56
+ 'result_found' => __('We found {count} article that may help:'),
57
+ 'results_found' => __('We found {count} articles that may help:'),
58
+ 'no_results_found' => __('No results found&hellip;'),
59
+ 'enter_search' => __('Please enter a search term.'),
60
+ 'not_long_enough' => __('Search must be at least {minLength} characters.'),
61
+ 'error' => __('There was an error fetching search results.'),
62
+ ),
63
+ 'template' => array(
64
+ 'wrap_class' => 'docs-search-wrap',
65
+ 'before' => '<ul class="docs-search-results">',
66
+ //'item' => '<li class="article"><a href="{url}" title="{preview}" target="_blank">{name}</a></li>',
67
+ //'item' => '<li class="article"><a data-beacon-article="{id}" href="#" title="{preview}">{name}</a><a href="{url}" class="article--open-original" title="Open the article in a new window" rel="noopener noreferrer" target="_blank"></a></li>',
68
+ // 'item' => '<li class="article"><a data-beacon-article="{id}" href="#" title="Read the full article">{name}</a><a href="{url}" class="article--open-original" title="Open the article in a new window" rel="noopener noreferrer" target="_blank"></a><p class="article-preview">{preview} ... <a data-beacon-article="{id}" href="#" title="Read the full article">read more</a></p></li>',
69
+ 'item' => '<li class="article"><a href="{url}" title="Read the full article" target="_blank">{name}<span class="article--open-original" ></span></a><p class="article-preview">{preview} ... <a href="{url}" title="Read the full article" target="_blank">read more</a></p></li>',
70
+ 'after' => '</ul>',
71
+ 'results_found' => '<span class="{css_class}">{text}</span>',
72
+ ),
73
+ 'collections' => array(), // The collection IDs to search in
74
+
75
+ // Do not modify
76
+ '_subdomain' => 'presscustomizr',
77
+ );
78
+
79
+ wp_localize_script( 'hs-search', 'GF_HS_Settings', $script_settings );
80
+ }
81
+
82
+ //hook : admin_head
83
+ function ha_write_hs_js_style() {
84
+ $screen = get_current_screen();
85
+ if ( 'appearance_page_welcome' != $screen-> id )
86
+ return;
87
+ ?>
88
+ <style type="text/css" id="hs-doc-style">
89
+ body { background:white!important;}
90
+ .about-wrap h1 {
91
+ font-size: 2em;
92
+ }
93
+ .helpscout-docs input[type="text"] {
94
+ font-size: 1.5em!important;
95
+ padding: 15px!important;
96
+ color: #444444;
97
+ background-color: #eeeeee;
98
+ border-color: #dddddd;
99
+ border-width: 1px;
100
+ border-style: solid;
101
+ -moz-border-radius: 0px;
102
+ -webkit-border-radius: 0px;
103
+ border-radius: 0px;
104
+ width: 100%;
105
+ max-width: 100%;
106
+ font-size: 13px;
107
+ padding: 2px;
108
+ -webkit-box-sizing: border-box;
109
+ -moz-box-sizing: border-box;
110
+ box-sizing: border-box;
111
+ outline: none;
112
+ font-weight: normal;
113
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
114
+ }
115
+ .helpscout-docs div.frm_description {
116
+ margin: 0;
117
+ padding: 0;
118
+ font-family: "Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif;
119
+ font-size: 11px;
120
+ color: #666666;
121
+ font-weight: normal;
122
+ text-align: left;
123
+ font-style: normal;
124
+ max-width: 100%;
125
+ font-style: italic;
126
+ margin-top: 1em;
127
+ }
128
+ span.results-found {
129
+ font-size: 18px;
130
+ display: block;
131
+ padding-top: 10px;
132
+ margin: 0 auto;
133
+ color: #999;
134
+ }
135
+ .docs-search-results {
136
+ text-align: left;
137
+ padding-left: 0;
138
+ border: 3px solid #eaeaea;
139
+ border-radius: 4px;
140
+ margin: 30px auto !important;
141
+ max-width: 700px;
142
+ }
143
+ .docs-search-results:before {
144
+ content: "Please review our complete list of suggestions to proceed.";
145
+ display: block;
146
+ background: #f7f7f7;
147
+ color: #999;
148
+ font-size: 16px;
149
+ text-transform: uppercase;
150
+ padding: 10px 20px;
151
+ border-bottom: 3px solid #f1f1f1;
152
+ }
153
+ .docs-search-results li.article {
154
+ border-bottom: 1px solid #f1f1f1;
155
+ margin: 0;
156
+ position: relative;
157
+ }
158
+ .docs-search-results li {
159
+ list-style: none !important;
160
+ }
161
+ .docs-search-results li.article a {
162
+ display: inline-block;
163
+ position: relative;
164
+ font-size: 18px;
165
+ padding: 15px 20px 0px 20px;
166
+ }
167
+ .docs-search-results li.article:hover {
168
+ background: #f7f7f7;
169
+ /*color: #2849ff;*/
170
+ }
171
+ .gf-hs-spinner {
172
+ background: url( "<?php echo admin_url( 'images/spinner.gif' ); ?>" ) no-repeat;
173
+ -webkit-background-size: 20px 20px;
174
+ background-size: 20px 20px;
175
+ display: inline-block;
176
+ opacity: 0.7;
177
+ filter: alpha(opacity=70);
178
+ width: 20px;
179
+ height: 20px;
180
+ margin: 0;
181
+ vertical-align: middle;
182
+ }
183
+ .article--open-original {
184
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAQtJREFUSA3tlLEOgkAMhjljfAP1IdTJJ3DVGR4SBidcnRzd5CV0cmU5/164pFyAXhU2SciV0n7/tb1ckkz8GOLneV4aY459WtbaB/7tsyyreYyQ90zTdD2jhCE4ByrtFcXPeRIUXUXcN2SjopP/j2qW2OgV3xvvo9VVwB3f2AG84oyfBUI45nUYTaALjra9RhGIgZNQa8hceciW4GjTBfmWGGoBCU5QfrpUQ46BkwB/VAJIPOOlc17RaQkHysHe1gq8Ab7FwklENQPeW7/DrhWtXJAf8bVKoAvW47s3/t0kAriTtl5YOwOfF73+BcRWTd6i1ikqisJdUOK2FAGugub2U6TJoWCWctQIER9Yb3NkxwQ6WgAAAABJRU5ErkJggg==) no-repeat;
185
+ background-size: 100%;
186
+ display: inline-block;
187
+ height: 16px;
188
+ opacity: 1;
189
+ position: relative;
190
+ top: 2px;
191
+ width: 16px;
192
+ margin: 0 5px
193
+ }
194
+ .article--open-original:hover {
195
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAQtJREFUSA3tlLEOgkAMhjljfAP1IdTJJ3DVGR4SBidcnRzd5CV0cmU5/164pFyAXhU2SciV0n7/tb1ckkz8GOLneV4aY459WtbaB/7tsyyreYyQ90zTdD2jhCE4ByrtFcXPeRIUXUXcN2SjopP/j2qW2OgV3xvvo9VVwB3f2AG84oyfBUI45nUYTaALjra9RhGIgZNQa8hceciW4GjTBfmWGGoBCU5QfrpUQ46BkwB/VAJIPOOlc17RaQkHysHe1gq8Ab7FwklENQPeW7/DrhWtXJAf8bVKoAvW47s3/t0kAriTtl5YOwOfF73+BcRWTd6i1ikqisJdUOK2FAGugub2U6TJoWCWctQIER9Yb3NkxwQ6WgAAAABJRU5ErkJggg==) no-repeat!important;
196
+ opacity: 0.5;
197
+ background-size: 100%!important;
198
+ }
199
+ .docs-search-results .article-preview {
200
+ padding: 4px 20px;
201
+ font-size: 0.8em;
202
+ line-height: 1.4em;
203
+ font-style: italic;
204
+ color: #808080
205
+ }
206
+ .docs-search-results .article-preview a {
207
+ display: inline!important;
208
+ font-size: inherit!important;
209
+ padding: 0!important;
210
+ }
211
+ </style>
212
+ <?php
213
+ }
addons/assets/back/js/hs-search.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var HS_Search;jQuery(function(a){HS_Search=a.extend(GF_HS_Settings,{searching:!1,cancelled:!1,has_searched:!1,count:0,query:"",timeout:null,wrap:a(".frm_form_fields .helpscout-docs"),form:a(".frm_form_fields .helpscout-docs").closest(".frm-show-form"),field:a(".frm_form_fields .helpscout-docs").find('input[type="text"]'),onclick:"",keypress:"",results:{},performed_search:0,has_searched_enough:function(){return a.Deferred(function(){var a=this,b=function(){_.delay(function(){HS_Search.performed_search>0?a.resolve():b()},2e4)};return b(),a.promise()})}(),init:function(){HS_Search.form.find(".go-next-step").hide(),HS_Search.has_searched_enough.done(function(){HS_Search.form.find(".go-next-step").show()}),HS_Search.form.on("keypress",function(b){var c=b.which||b.keyCode;if(HS_Search.field.is(":focus"))return 13!=c||a(b.target).is('textarea,input[type="submit"],input[type="button"]')?void 0:(b.preventDefault(),!1)}),HS_Search.wrap.append('<div class="'+GF_HS_Settings.template.wrap_class+'" style="display:none;" />'),HS_Search.field.attr("autocomplete","off").on("keydown keyup change",HS_Search.search_changed)},search_changed:function(b){if(!_.isUndefined(b.which)||_.isEmpty(HS_Search.results)){var c=[9,13,16,17,18,20,32,33,34,37,38,91,93];if(c.indexOf(b.which)>-1)return void HS_Search.log("Ignored key press",b.which);HS_Search.log("Starting search countdown in %d ms",parseInt(GF_HS_Settings.searchDelay,10));var d=a(this);clearTimeout(HS_Search.timeout),HS_Search.timeout=setTimeout(function(){return HS_Search.log("Performing search",b.which),HS_Search.query=d.val(),HS_Search.query.length<GF_HS_Settings.minLength||(8===b.which||46===b.which)&&0===HS_Search.query.length?(HS_Search.cancelled=!0,void HS_Search.set_results({})):void(HS_Search.searching||HS_Search.perform_search())},parseInt(GF_HS_Settings.searchDelay,10))}},perform_search:function(){HS_Search.results={},HS_Search.cancelled=!1,HS_Search.fetch_results(),HS_Search.performed_search++},log:function(a,b){HS_Search.debug&&console&&console.log&&console.log(a,b)},get_results_html:function(){var b="",c=0;return"undefined"!=typeof HS_Search.results.articles&&HS_Search.results.articles.results.length?(HS_Search.form.find(".go-next-step").show(),b=GF_HS_Settings.template.before,a.each(HS_Search.results.articles.results,function(d,e){var f=!0;GF_HS_Settings.collections.length>0&&(f=!1,a.each(GF_HS_Settings.collections,function(a,b){var c=new RegExp("^/docs/"+b);c.exec(e.docsUrl)&&(f=!0)})),c<HS_Search.limit&&f&&(c++,b+=HS_Search.get_article_html(e))}),b+=GF_HS_Settings.template.after):4<=HS_Search.performed_search||"resolved"==HS_Search.has_searched_enough.state()?HS_Search.form.find(".go-next-step").show():HS_Search.form.find(".go-next-step").hide(),HS_Search.get_results_found(c)+b},get_article_html:function(a){var b=GF_HS_Settings.template.item;for(var c in a)a.hasOwnProperty(c)&&(b=b.replace(RegExp("{"+c+"}","g"),a[c]));return b},get_results_found:function(a){var b="",c="results-found";return 0===HS_Search.query.length?(b=GF_HS_Settings.text.enter_search,c+=" message-enter_search"):HS_Search.query.length<HS_Search.minLength?(b=GF_HS_Settings.text.not_long_enough.replace("{minLength}",HS_Search.minLength),c+=" message-minlength"):0===a?(b=GF_HS_Settings.text.no_results_found,c+=" message-no_results"):(b=1===a?GF_HS_Settings.text.result_found:GF_HS_Settings.text.results_found,c+=" message-results"),GF_HS_Settings.template.results_found.replace("{css_class}",c).replace("{text}",b).replace("{count}",a)},set_results:function(a){HS_Search.log("Adding results:",a),HS_Search.results=a,HS_Search.wrap.find(".docs-search-wrap").html(HS_Search.get_results_html()).not(":visible").slideDown()},sanitize_query:function(a){return a=a.replace(/[\{\}\[\]]/g," "),HS_Search.log("Searching for %s",a),a},fetch_results:function(){query=HS_Search.sanitize_query(HS_Search.query),$search_wrap=HS_Search.wrap.find(".docs-search-wrap"),a.ajax({url:"https://"+GF_HS_Settings._subdomain+".helpscoutdocs.com/search/ajax?ref=support&query="+encodeURIComponent(query),async:!0,dataType:"json",beforeSend:function(){HS_Search.searching=!0,$search_wrap.addClass("docs-searching"),HS_Search.wrap.find(".docs-search-wrap").show().html('<span class="gf-hs-spinner"></span>'),a("body").trigger("gf_hs_search_started")},success:function(b){HS_Search.cancelled||(HS_Search.set_results(b),a("body").trigger("gf_hs_search_results_found"),HS_Search.has_searched=!0)},error:function(b){HS_Search.log("Error: %s",b),a("body").trigger("gf_hs_search_error")}}).always(function(){HS_Search.searching=!1,$search_wrap.removeClass("docs-searching")})}})}),jQuery(function(a){_.delay(function(){HS_Search.init()},300)}),jQuery(function(a){_.isUndefined(window.HS)||HS.beacon.ready(function(){a(".entry-content").on("click","a[data-beacon-article]",function(){var b=a(this).attr("data-beacon-article");_.delay(function(){HS.beacon.show(b)},500),_.delay(function(){HS.beacon.show(b)},1e3)})})});
addons/assets/czr/css/czr-control-base.css CHANGED
@@ -370,7 +370,7 @@ input:-ms-input-placeholder {
370
  /* text-shadow: 0 1px 0 #FFF; */
371
  margin: 1em 0em 5px 0em;
372
  font-size: 15px!important;
373
- border-bottom: 1px dotted #00a0d2;
374
  padding-bottom: 5px;
375
  text-align: center;
376
  }
@@ -577,11 +577,23 @@ li#customize-control-tc_theme_options-tc_custom_css textarea {
577
  #customize-theme-controls #accordion-panel-hu-advanced-panel {
578
  border-top: 1px solid #ddd;
579
  }
580
- #customize-theme-controls #accordion-panel-hu-general-panel {
 
581
  margin-bottom: 10px;
582
  }
583
 
584
- #customize-theme-controls #accordion-section-static_front_page {
 
 
 
 
 
 
 
 
 
 
 
585
  margin-bottom: 10px;
586
  }
587
 
370
  /* text-shadow: 0 1px 0 #FFF; */
371
  margin: 1em 0em 5px 0em;
372
  font-size: 15px!important;
373
+ border-bottom: 1px dotted #555;
374
  padding-bottom: 5px;
375
  text-align: center;
376
  }
577
  #customize-theme-controls #accordion-panel-hu-advanced-panel {
578
  border-top: 1px solid #ddd;
579
  }
580
+ #customize-theme-controls #accordion-panel-hu-general-panel,
581
+ #customize-theme-controls #accordion-panel-tc-global-panel {
582
  margin-bottom: 10px;
583
  }
584
 
585
+ #customize-theme-controls #accordion-section-static_front_page,
586
+ #customize-theme-controls #accordion-section-frontpage_sec {
587
+ margin-bottom: 10px;
588
+ }
589
+
590
+ /* FPU */
591
+ #customize-theme-controls #accordion-section-tc_fpu {
592
+ margin-bottom: 10px;
593
+ }
594
+
595
+ /* WFC */
596
+ #customize-theme-controls #accordion-section-tc_font_customizer_settings {
597
  margin-bottom: 10px;
598
  }
599
 
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 #00a0d2;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-section-static_front_page{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}.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}
addons/assets/czr/js/czr-control-base.js CHANGED
@@ -30,12 +30,19 @@ if ( 'function' != typeof(jQuery.fn.stepper) ) {
30
  }/*! 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?!0:d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth:!1},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){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");
31
  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?!1:(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?!1: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";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;
32
  },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 */
33
- !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);"});var czr_debug = {
34
- log: function(o) {debug.queue.push(['log', arguments, debug.stack.slice(0)]); if (window.console && typeof window.console.log == 'function') {window.console.log(o);}},
35
- error: function(o) {debug.queue.push(['error', arguments, debug.stack.slice(0)]); if (window.console && typeof window.console.error == 'function') {window.console.error(o);}},
36
- queue: [],
37
- stack: []
38
- };
 
 
 
 
 
 
 
39
  ( function ( api, $, _ ) {
40
  var _prettyPrintLog = function( args ) {
41
  var _defaults = {
@@ -84,4296 +91,3562 @@ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push
84
  return serverControlParams.isChangeSetOn && true === true;//&& true === true is just there to hackily cast the returned value as boolean.
85
  };
86
 
87
-
88
-
89
  /*****************************************************************************
90
- * DEFINE SOME USEFUL OBSERVABLE VALUES
91
  *****************************************************************************/
92
- api.czr_activeSectionId = new api.Value('');
93
- api.czr_activePanelId = new api.Value('');
 
 
 
 
 
 
 
 
94
 
95
- /*****************************************************************************
96
- * OBSERVE UBIQUE CONTROL'S SECTIONS EXPANSION
97
- *****************************************************************************/
98
- if ( 'function' === typeof api.Section ) {
99
- api.control.bind( 'add', function( _ctrl ) {
100
- if ( _ctrl.params.ubq_section && _ctrl.params.ubq_section.section ) {
101
- _ctrl.params.original_priority = _ctrl.params.priority;
102
- _ctrl.params.original_section = _ctrl.params.section;
103
 
104
- api.section.when( _ctrl.params.ubq_section.section, function( _section_instance ) {
105
- _section_instance.expanded.bind( function( expanded ) {
106
- if ( expanded ) {
107
- if ( _ctrl.params.ubq_section.priority ) {
108
- _ctrl.priority( _ctrl.params.ubq_section.priority );
109
- }
110
- _ctrl.section( _ctrl.params.ubq_section.section );
111
- }
112
- else {
113
- _ctrl.priority( _ctrl.params.original_priority );
114
- _ctrl.section( _ctrl.params.original_section );
115
- }
116
- });
117
 
118
- } );
119
- }
120
- });
121
- }
122
 
123
- /*****************************************************************************
124
- * CLOSE THE MOD OPTION PANEL ( if exists ) ON : section change, panel change, skope switch
125
- *****************************************************************************/
126
- var _closeModOpt = function() {
127
- if ( ! _.has( api, 'czr_ModOptVisible') )
128
- return;
129
- api.czr_ModOptVisible(false);
 
 
 
 
130
  };
131
- api.czr_activeSectionId.bind( _closeModOpt );
132
- api.czr_activePanelId.bind( _closeModOpt );
 
 
133
 
134
- /*****************************************************************************
135
- * OBSERVE SECTIONS AND PANEL EXPANSION
136
- * /store the current expanded section and panel
137
- *****************************************************************************/
138
- api.bind('ready', function() {
139
- if ( 'function' != typeof api.Section ) {
140
- 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.' );
141
- }
142
- var _storeCurrentSection = function( expanded, section_id ) {
143
- api.czr_activeSectionId( expanded ? section_id : '' );
144
- };
145
- api.section.each( function( _sec ) {
146
- _sec.expanded.bind( function( expanded ) { _storeCurrentSection( expanded, _sec.id ); } );
147
- });
148
- api.section.bind( 'add', function( section_instance ) {
149
- api.trigger('czr-paint', { active_panel_id : section_instance.panel() } );
150
- section_instance.expanded.bind( function( expanded ) { _storeCurrentSection( expanded, section_instance.id ); } );
151
- });
152
 
153
- var _storeCurrentPanel = function( expanded, panel_id ) {
154
- api.czr_activePanelId( expanded ? panel_id : '' );
155
- if ( _.isEmpty( api.czr_activePanelId() ) ) {
156
- api.czr_activeSectionId( '' );
157
- }
158
- };
159
- api.panel.each( function( _panel ) {
160
- _panel.expanded.bind( function( expanded ) { _storeCurrentPanel( expanded, _panel.id ); } );
161
- });
162
- api.panel.bind( 'add', function( panel_instance ) {
163
- panel_instance.expanded.bind( function( expanded ) { _storeCurrentPanel( expanded, panel_instance.id ); } );
164
- });
165
- });
166
- api.bind('ready', function() {
167
- var _do = function() {
168
- api.section('themes').active.bind( function( active ) {
169
- if ( ! _.has( serverControlParams, 'isThemeSwitchOn' ) || ! _.isEmpty( serverControlParams.isThemeSwitchOn ) )
170
- return;
171
- api.section('themes').active( serverControlParams.isThemeSwitchOn );
172
- api.section('themes').active.callbacks = $.Callbacks();
173
- });
174
- };
175
- if ( api.section.has( 'themes') )
176
- _do();
177
- else
178
- api.section.when( 'themes', function( _s ) {
179
- _do();
180
  });
181
- });
182
-
 
 
 
183
 
184
  /*****************************************************************************
185
- * FIRE SKOPE ON READY
 
 
 
 
186
  *****************************************************************************/
187
- api.czr_skopeReady = $.Deferred();
188
- api.bind( 'ready' , function() {
189
- if ( serverControlParams.isSkopOn ) {
190
- api.czr_isLoadingSkope = new api.Value( false );
191
- api.czr_isLoadingSkope.bind( function( loading ) {
192
- toggleSkopeLoadPane( loading );
193
- });
194
- api.czr_skopeBase = new api.CZR_skopeBase();
195
- api.czr_skopeSave = new api.CZR_skopeSave();
196
- api.czr_skopeReset = new api.CZR_skopeReset();
197
 
198
- api.trigger('czr-skope-started');
199
- var _toggleTopFailureNote = function() {
200
- api.czr_skopeBase.toggleTopNote( true, {
201
- title : serverControlParams.i18n.skope['There was a problem when trying to load the customizer.'],
202
- message : [
203
- serverControlParams.i18n.skope['Please refer to'],
204
- '<a href="http://docs.presscustomizr.com/article/285-there-was-a-problem-when-trying-to-load-the-customizer" target="_blank">',
205
- serverControlParams.i18n.skope['this documentation page'],
206
- '</a>',
207
- serverControlParams.i18n.skope['to understand how to fix the problem.']
208
- ].join(' '),
209
- selfCloseAfter : 40000
210
- });
211
- };
212
 
 
 
213
 
214
- api.czr_skopeReady
215
- .done( function() {
216
- api.trigger('czr-skope-ready');
217
- })
218
- .fail( function( error ) {
219
- api.errorLog( 'Skope could not be instantiated : ' + error );
220
- _toggleTopFailureNote();
221
- serverControlParams.isSkopOn = false;
222
- })
223
- .always( function() {
224
- api.czr_isLoadingSkope( false );
225
- });
226
- if ( 'rejected' != api.czr_skopeReady.state() ) {
227
- setTimeout( function() {
228
- if ( 'pending' == api.czr_skopeReady.state() ) {
229
- _toggleTopFailureNote();
230
 
231
- api.czr_isLoadingSkope( false );
232
- }
233
- }, 40000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  }
235
  }
236
- if ( serverControlParams.isChangeSetOn ) {
237
- api.settings.timeouts.changesetAutoSave = 10000;
 
 
238
  }
239
- } );
240
- if ( ! _.has( api, '_latestRevision') ) {
241
- /**
242
- * Current change count.
243
- */
244
- api._latestRevision = 0;
245
 
246
- /**
247
- * Latest revisions associated with the updated setting.
248
- */
249
- api._latestSettingRevisions = {};
250
-
251
- /*
252
- * Keep track of the revision associated with each updated setting so that
253
- * requestChangesetUpdate knows which dirty settings to include. Also, once
254
- * ready is triggered and all initial settings have been added, increment
255
- * revision for each newly-created initially-dirty setting so that it will
256
- * also be included in changeset update requests.
257
- */
258
- api.bind( 'change', function incrementChangedSettingRevision( setting ) {
259
- api._latestRevision += 1;
260
- api._latestSettingRevisions[ setting.id ] = api._latestRevision;
261
- } );
262
- api.bind( 'ready', function() {
263
- api.bind( 'add', function incrementCreatedSettingRevision( setting ) {
264
- if ( setting._dirty ) {
265
- api._latestRevision += 1;
266
- api._latestSettingRevisions[ setting.id ] = api._latestRevision;
267
- }
268
- } );
269
- } );
270
- }
271
- var toggleSkopeLoadPane = function( loading ) {
272
- loading = _.isUndefined( loading ) ? true : loading;
273
- var self = this, $skopeLoadingPanel,
274
- _render = function() {
275
- var dfd = $.Deferred();
276
- try {
277
- _tmpl = wp.template( 'czr-skope-pane' )({ is_skope_loading : true });
278
- } catch( er ) {
279
- api.errorLog( 'In toggleSkopeLoadPane : error when parsing the the reset skope template : ' + er );
280
- dfd.resolve( false );
281
- }
282
- $.when( $('#customize-preview').after( $( _tmpl ) ) )
283
- .always( function() {
284
- dfd.resolve( $( '#czr-skope-pane' ) );
285
- });
286
 
287
- return dfd.promise();
288
- },
289
- _destroy = function() {
290
- _.delay( function() {
291
- $.when( $('body').removeClass('czr-skope-pane-open') ).done( function() {
292
- _.delay( function() {
293
- $.when( $('body').removeClass('czr-skop-loading') ).done( function() {
294
- if ( false !== $( '#czr-skope-pane' ).length ) {
295
- setTimeout( function() {
296
- $( '#czr-skope-pane' ).remove();
297
- }, 400 );
298
- }
299
- });
300
- }, 200);
301
- });
302
- }, 50);
303
- };
304
- if ( 'pending' == api.czr_skopeReady.state() && loading ) {
305
- $('body').addClass('czr-skop-loading');
306
- _render()
307
- .done( function( $_el ) {
308
- $skopeLoadingPanel = $_el;
309
- })
310
- .then( function() {
311
- if ( ! $skopeLoadingPanel.length )
312
- return;
313
 
314
- _.delay( function() {
315
- var _height = $('#customize-preview').height();
316
- $skopeLoadingPanel.css( 'line-height', _height +'px' ).css( 'height', _height + 'px' );
317
- $('body').addClass('czr-skope-pane-open');
318
- }, 50 );
319
  });
 
 
 
 
320
  }
321
 
322
- api.czr_skopeReady.done( function() {
323
- _destroy();
324
- });
325
- if ( ! loading ) {
326
- _destroy();
327
- }
328
- };//toggleSkopeLoadPane
329
-
 
 
330
 
331
- /*****************************************************************************
332
- * REACT TO PREVIEW DEVICE SWITCH => send device to preview
333
- *****************************************************************************/
334
- api.bind( 'ready' , function() {
335
- if ( api.previewedDevice ) {
336
- api.previewedDevice.bind( function( device ) {
337
- api.previewer.send( 'previewed-device', device );
338
- });
339
- }
340
- });
341
 
342
- /*****************************************************************************
343
- * ADD PRO BEFORE SPECIFIC SECTIONS AND PANELS
344
- *****************************************************************************/
345
- if ( serverControlParams.isPro ) {
346
- _.each( [ 'tc_font_customizer_settings', 'header_image_sec', 'content_blog_sec', 'static_front_page' ], function( _secId ) {
347
- _.delay( function() {
348
- api.section.when( _secId, function( _sec_ ) {
349
- if ( 1 >= _sec_.headContainer.length ) {
350
- _sec_.headContainer.find('.accordion-section-title').prepend( '<span class="pro-title-block">Pro</span>' );
351
- }
352
- });
353
- }, 1000 );
354
- });
355
- _.each( ['hu-header-panel', 'hu-content-panel' ], function( _secId ) {
356
- api.panel.when( _secId, function( _sec_ ) {
357
- if ( 1 >= _sec_.headContainer.length ) {
358
- _sec_.headContainer.find('.accordion-section-title').prepend( '<span class="pro-title-block">Pro</span>' );
359
- }
360
  });
361
- });
362
  }
 
 
 
 
 
 
 
 
 
 
 
 
363
 
364
-
365
- /*****************************************************************************
366
- * ADD PRO BEFORE SPECIFIC SECTIONS AND PANELS
367
- *****************************************************************************/
368
- if ( ! serverControlParams.isPro && _.isFunction( api.Section ) ) {
369
- proSectionConstructor = api.Section.extend( {
370
- active : true,
371
- attachEvents: function () {},
372
- isContextuallyActive: function () {
373
- return this.active();
374
- },
375
- _toggleActive: function(){ return true; },
376
-
377
- } );
378
-
379
- $.extend( api.sectionConstructor, {
380
- 'czr-customize-section-pro' : proSectionConstructor
381
- });
382
- }
383
- })( wp.customize , jQuery, _);
384
-
385
-
386
-
387
-
388
- /*****************************************************************************
389
- * THE SKOPE BASE OBJECT
390
- *****************************************************************************/
391
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
392
- (function ( api, $, _ ) {
393
- $.extend( CZRSkopeBaseMths, {
394
-
395
- globalSettingVal : {},//will store the global setting val. Populated on init.
396
-
397
- initialize: function() {
398
- var self = this;
399
- self.skope_colors = {
400
- global : 'rgb(255, 255, 255)',
401
- special_group : 'rgba(173, 213, 247, 0.55)',
402
- group : 'rgba(39, 59, 88, 0.12)',// 'rgba(173, 213, 247, 0.55)',
403
- local : 'rgba(39, 59, 88, 0.28)'// 'rgba(78, 122, 199, 0.35)'
404
- };
405
- api.czr_isPreviewerSkopeAware = $.Deferred();
406
- api.czr_initialSkopeCollectionPopulated = $.Deferred();
407
- self.skopeWrapperEmbedded = $.Deferred();
408
- api.czr_skope = new api.Values();
409
- api.czr_skopeCollection = new api.Value([]);//all available skope, including the current skopes
410
- api.czr_currentSkopesCollection = new api.Value([]);
411
- api.czr_activeSkopeId = new api.Value();
412
- api.czr_dirtyness = new api.Value( false );
413
- api.czr_isResettingSkope = new api.Value( false );
414
- api.state.create('switching-skope')( false );
415
- api.czr_dirtyness.callbacks.add( function() { return self.apiDirtynessReact.apply(self, arguments ); } );
416
- api.czr_isLoadingSkope( true );
417
- self.bindAPISettings();
418
- api.state.bind( 'change', function() {
419
- self.setSaveButtonStates();
420
- });
421
- api.czr_skopeReady.then( function() {
422
- if ( 'pending' == self.skopeWrapperEmbedded.state() ) {
423
- $.when( self.embedSkopeWrapper() ).done( function() {
424
- self.skopeWrapperEmbedded.resolve();
425
- });
426
- }
427
- });
428
- api.previewer.bind( 'czr-skopes-synced', function( data ) {
429
- if ( ! serverControlParams.isSkopOn || 'rejected' == api.czr_skopeReady.state() ) {
430
- return;
431
- }
432
- var preview = this,
433
- previousSkopeCollection = api.czr_currentSkopesCollection();
434
- if ( ! _.has( data, 'czr_skopes') ) {
435
- if ( 'resolved' != api.czr_skopeReady.state() ) {
436
- api.czr_skopeReady.reject();
437
- }
438
- api.errorLog( "On 'czr-skopes-synced' : missing skopes in the server data" );
439
- return;
440
- }
441
- try {
442
- api.czr_skopeBase.updateSkopeCollection( data.czr_skopes , preview.channel() );
443
- } catch ( er ) {
444
- api.czr_skopeReady.reject( er );
445
- return;
446
- }
447
- var _refreshSkopeInfosNotices = function() {
448
- self._writeCurrentSkopeTitle();
449
- if ( api.czr_bottomInfosVisible() ) {
450
- self.renderBottomInfosTmpl();//<= will build a new bottom skope message infos in the preview based on the new active skopes
451
- } else {
452
- api.czr_bottomInfosVisible( true );
453
- }
454
- };
455
- api.czr_initialSkopeCollectionPopulated.then( function() {
456
- var refreshActiveSkope = _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), {id : api.czr_activeSkopeId() } ) );
457
- api.czr_skopeBase.reactWhenSkopeSyncedDone( data ).done( function() {
458
- if ( refreshActiveSkope ) {
459
- try {
460
- api.czr_activeSkopeId( self.getActiveSkopeId() )
461
- .done( function() {
462
- if ( 'resolved' != api.czr_skopeReady.state() ) {
463
- api.czr_skopeReady.resolve( self.getActiveSkopeId() );
464
- }
465
- _refreshSkopeInfosNotices();
466
- })
467
- .fail( function() {
468
- throw new Error( 'Error when trying to set the active skope after skope synced.' );
469
- });
470
- } catch ( er ) {
471
- api.errorLog( 'In reactWhenSkopeSyncedDone => api.czr_activeSkopeId() : ' + er );
472
- }
473
- } else if ( ! _.isEmpty( previousSkopeCollection ) ) { //Rewrite the title when the local skope has changed
474
- var _prevLoc = _.findWhere( previousSkopeCollection , { skope : 'local' } ).opt_name,
475
- _newLoc =_.findWhere( data.czr_skopes, { skope : 'local' } ).opt_name;
476
-
477
- if ( _newLoc !== _prevLoc && 'resolved' == api.czr_skopeReady.state() ) {
478
- _refreshSkopeInfosNotices();
479
- }
480
- }
481
- });
482
- });
483
- });
484
- api.czr_currentSkopesCollection.bind( function( to, from ) {
485
- return self.currentSkopesCollectionReact( to, from );
486
- }, { deferred : true });
487
- api.czr_initialSkopeCollectionPopulated.done( function() {
488
- api.czr_activeSkopeId.bind( function( to, from ) {
489
- if ( _.has( api, 'czr_ModOptVisible') ) {
490
- api.czr_ModOptVisible( false );
491
- }
492
- return self.activeSkopeReact( to, from ).then( function( _updatedSetIds ) {
493
- api.trigger( 'skope-switched-done',
494
- {
495
- current_skope_id : to,
496
- previous_skope_id : from,
497
- updated_setting_ids : _updatedSetIds || []
498
- }
499
- );
500
- });
501
- }, { deferred : true } );
502
- api.czr_activeSectionId.callbacks.add( function() { return self.activeSectionReact.apply(self, arguments ); } );
503
- api.czr_activePanelId.callbacks.add( function() { return self.activePanelReact.apply(self, arguments ); } );
504
- });
505
- api.bind( 'skope-switched-done', function( args ) {
506
- args = _.extend(
507
- {
508
- current_skope_id : '',
509
- previous_skope_id : '',
510
- updated_setting_ids : []
511
- },
512
- args
513
- );
514
- return self.skopeSwitchedDoneReact( args );
515
- });
516
- api.czr_serverNotification = new api.Value( {status : 'success', message : '', expanded : true} );
517
- api.czr_serverNotification.bind( function( to, from ) {
518
- self.toggleServerNotice( to );
519
- });
520
- self._setupPreviewNotificationsBlocks();//top note and bottom skope infos
521
- self.scopeSwitcherEventMap = [
522
- {
523
- trigger : 'click keydown',
524
- selector : '.czr-dismiss-notification',
525
- name : 'dismiss-notification',
526
- actions : function() {
527
- api.czr_serverNotification( { expanded : false } );
528
- }
529
- },
530
- {
531
- trigger : 'click keydown',
532
- selector : '.czr-toggle-title-notice',
533
- name : 'toggle-title-notice',
534
- actions : function( params ) {
535
- if ( _.isUndefined( self.skopeTitleNoticeVisible ) ) {
536
- self.skopeTitleNoticeVisible = new api.Value( false );
537
- self.skopeTitleNoticeVisible.bind( function( to ) {
538
- params.dom_el.find( '.czr-skope-title')
539
- .toggleClass( 'notice-visible', to );
540
- });
541
- }
542
-
543
- self.skopeTitleNoticeVisible( ! self.skopeTitleNoticeVisible() );
544
- }
545
- }
546
- ];
547
- self.skopeWrapperEmbedded.then( function() {
548
- api.CZR_Helpers.setupDOMListeners( self.scopeSwitcherEventMap , { dom_el : $('.czr-scope-switcher') }, self );
549
- });
550
- self.refreshedControls = [ 'czr_cropped_image'];// [ 'czr_cropped_image', 'czr_multi_module', 'czr_module' ];
551
- self.initWidgetSidebarSpecifics();
552
- api.bind( 'czr-paint', function( params ) {
553
- api.czr_skopeReady.then( function() {
554
- self.wash( params ).paint( params );
555
- });
556
- });
557
- },//initialize
558
-
559
-
560
-
561
-
562
-
563
-
564
-
565
 
566
 
567
 
 
 
 
 
 
 
 
 
 
 
568
 
569
 
 
 
 
 
 
 
 
 
 
570
 
 
 
571
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
 
 
 
 
 
 
 
 
 
 
 
 
 
573
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
 
575
- /*****************************************************************************
576
- * EMBED WRAPPER
577
- *****************************************************************************/
578
- embedSkopeWrapper : function() {
579
- var self = this;
580
- $('#customize-header-actions').append( $('<div/>', {class:'czr-scope-switcher', html:'<div class="czr-skopes-wrapper"></div>'}) );
581
- $('body').addClass('czr-skop-on');
582
- var _eventMap = [
583
- {
584
- trigger : 'click keydown',
585
- selector : '.czr-skope-switch',
586
- name : 'control_skope_switch',
587
- actions : function( params ) {
588
- var _skopeIdToSwithTo = $( params.dom_event.currentTarget, params.dom_el ).attr('data-skope-id');
589
- if ( ! _.isEmpty( _skopeIdToSwithTo ) && api.czr_skope.has( _skopeIdToSwithTo ) )
590
- api.czr_activeSkopeId( _skopeIdToSwithTo );
591
- }
592
- }
593
- ];
594
- api.CZR_Helpers.setupDOMListeners( _eventMap , { dom_el : $('.czr-scope-switcher') }, self );
595
- },
596
-
597
 
 
 
 
 
 
 
 
 
 
 
 
598
 
 
 
 
 
 
 
 
 
 
 
 
 
 
599
 
 
600
 
 
 
 
 
601
 
 
 
 
 
602
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
 
 
 
 
 
 
 
 
 
 
 
 
604
 
605
- /*****************************************************************************
606
- * API DIRTYNESS REACTIONS
607
- *****************************************************************************/
608
- apiDirtynessReact : function( is_dirty ) {
609
- $('body').toggleClass('czr-api-dirty', is_dirty );
610
- api.state( 'saved')( ! is_dirty );
611
- },
 
612
 
 
 
 
 
 
 
 
613
 
 
 
 
 
 
 
 
 
 
 
 
 
614
 
 
 
 
 
 
 
 
 
 
615
 
 
 
 
 
 
 
 
 
 
616
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
617
 
 
 
 
 
618
 
 
 
 
 
 
 
 
 
 
 
619
 
 
 
 
 
 
 
 
 
 
 
 
620
 
621
- /*****************************************************************************
622
- * OVERRIDE SAVE BUTTON STATES : api.state.bind( 'change') callback
623
- *****************************************************************************/
624
- setSaveButtonStates : function() {
625
- if ( ! api.state.has('saving') ) {
626
- api.state.create('saving');
627
- api.state('saving').bind( function( isSaving ) {
628
- $( document.body ).toggleClass( 'saving', isSaving );
629
- } );
630
- }
631
- var saveBtn = $( '#save' ),
632
- closeBtn = $( '.customize-controls-close' ),
633
- saved = api.state( 'saved'),
634
- saving = api.state( 'saving'),
635
- activated = api.state( 'activated' ),
636
- changesetStatus = api.state.has('changesetStatus' ) ? api.state( 'changesetStatus' )() : 'auto-draft';
637
 
638
- if ( api.czr_dirtyness() || ! saved() ) {
639
- saveBtn.val( api.l10n.save );
640
- closeBtn.find( '.screen-reader-text' ).text( api.l10n.cancel );
641
- } else {
642
- saveBtn.val( api.l10n.saved );
643
- closeBtn.find( '.screen-reader-text' ).text( api.l10n.close );
644
- }
645
- var canSave = ! saving() && ( ! activated() || ! saved() ) && 'publish' !== changesetStatus;
646
- saveBtn.prop( 'disabled', ! canSave );
647
- },
648
- skopeSwitchedDoneReact : function( args ) {
649
- var self = this,
650
- _doWhenSkopeReady = function() {
651
- api.czr_CrtlDependenciesReady.then( function() {
652
- if ( ! _.isUndefined( api.czr_activeSectionId() ) && ! _.isEmpty( api.czr_activeSectionId() ) ) {
653
- try {
654
- api.czr_ctrlDependencies.setServiDependencies( api.czr_activeSectionId(), null, true );//target sec id, source sec id, refresh
655
- } catch( er ) {
656
- api.errorLog( 'On skope-switched-done : ' + er );
657
- }
658
- }
659
- });
660
- self.updateCtrlSkpNot( api.CZR_Helpers.getSectionControlIds() );
661
- if ( api.czr_skope.has( args.previous_skope_id ) ) {
662
- $( '#customize-controls' ).removeClass( [ 'czr-', api.czr_skope( args.previous_skope_id )().skope, '-skope-level'].join('') );
663
- }
664
- if ( api.czr_skope.has( args.current_skope_id ) ) {
665
- $( '#customize-controls' ).addClass( [ 'czr-', api.czr_skope( args.current_skope_id )().skope, '-skope-level'].join('') );
666
- }
667
- var _setupSectionControlDialogs = function() {
668
- if ( _.isUndefined( api.czr_activeSectionId() ) || _.isEmpty( api.czr_activeSectionId() ) )
669
- return;
670
- var ctrls = api.CZR_Helpers.getSectionControlIds( api.czr_activeSectionId() );
671
- _.each( ctrls, function( ctrlId ) {
672
- api.control.when( ctrlId, function() {
673
- var ctrl = api.control( ctrlId );
674
- if ( ! _.has( ctrl, 'czr_states' ) )
675
- return;
676
 
677
- ctrl.deferred.embedded.then( function() {
678
- ctrl.czr_states( 'noticeVisible' )( self.isCtrlNoticeVisible( ctrlId ) );
679
- ctrl.czr_states( 'resetVisible' )( false );
680
- });
681
- });
682
- });
683
- };
684
- if ( api.czr_bottomInfosVisible() ) {
685
- self.renderBottomInfosTmpl();//<= will build a new bottom skope message infos in the preview based on the new active skopes
686
- } else {
687
- api.czr_bottomInfosVisible( true );
688
- }
689
- _.delay( function() {
690
- _setupSectionControlDialogs();
691
- }, 500 );
692
- };
693
- api.czr_skopeReady.then( function() {
694
- _doWhenSkopeReady();
695
- });
696
- },
697
- _setupPreviewNotificationsBlocks : function() {
698
- var self = this;
699
- api.czr_topNoteVisible = new api.Value( false );
700
- api.czr_skopeReady.then( function() {
701
- api.czr_topNoteVisible.bind( function( visible ) {
702
- var noteParams = {},
703
- _defaultParams = {
704
- title : '',
705
- message : '',
706
- actions : '',
707
- selfCloseAfter : 20000
708
- };
709
- noteParams = $.extend( _defaultParams , serverControlParams.topNoteParams );
710
- noteParams.actions = function() {
711
- var _query = $.extend(
712
- api.previewer.query(),
713
- { nonce: api.previewer.nonce.save }
714
- );
715
- wp.ajax.post( 'czr_dismiss_top_note' , _query )
716
- .always( function () {})
717
- .fail( function ( response ) { api.consoleLog( 'czr_dismiss_top_note failed', _query, response ); })
718
- .done( function( response ) {});
719
- };
720
-
721
- self.toggleTopNote( visible, noteParams );
722
- });
723
- _.delay( function() {
724
- api.czr_topNoteVisible( ! _.isEmpty( serverControlParams.isTopNoteOn ) || 1 == serverControlParams.isTopNoteOn );
725
- }, 2000 );
726
- });
727
- api.czr_bottomInfosVisible = new api.Value( false );
728
- api.czr_skopeReady.then( function() {
729
- api.czr_bottomInfosVisible.bind( function( visible ) {
730
- var noteParams = {},
731
- _defaultParams = {
732
- title : '',
733
- message : '',
734
- actions : '',
735
- selfCloseAfter : 20000
736
- };
737
- noteParams = $.extend( _defaultParams , {} );
738
 
739
- return self.toggleBottomInfos( visible, noteParams );//returns a promise()
740
- }, { deferred : true } );
741
- var _skopeInfosSetId = api.CZR_Helpers.build_setId( 'show-skope-infos' );
742
- api.when( _skopeInfosSetId, function( _set_ ){
743
- api.czr_bottomInfosVisible.validate = function( value ) {
744
- var _v = _set_(),
745
- _isChecked = 0 !== _v && '0' !== _v && false !== _v && 'off' !== _v;
746
 
747
- return _isChecked ? value : false;
748
- };
749
- _set_.bind( function( visible ) {
750
- api.czr_bottomInfosVisible( 0 !== visible && '0' !== visible && false !== visible && 'off' !== visible );
751
- });
752
- });
753
- _.delay( function() {
754
- api.czr_bottomInfosVisible( true );
755
- }, 2000 );
756
- });//api.czr_skopeReady.then()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
757
  }
758
- });//$.extend()
759
- })( wp.customize , jQuery, _);
760
 
761
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
762
- (function ( api, $, _ ) {
763
- $.extend( CZRSkopeBaseMths, {
764
- toggleServerNotice : function( notice ) {
765
- notice = _.isObject( notice ) ? notice : {};
766
- notice = _.extend( {
767
- status : 'success',
768
- expanded : true,
769
- message : '',
770
- auto_collapse : false
771
- }, notice );
772
- if ( 'changeset_already_published' == notice.message )
773
- return;
774
- if ( ! serverControlParams.isDevMode )
775
- return;
776
 
777
- this.serverNoticeEmbedded = this.serverNoticeEmbedded || $.Deferred();
 
 
 
 
 
 
 
 
 
 
 
 
 
778
 
779
- var self = this,
780
- _embed = function() {
781
- $('.czr-scope-switcher').prepend(
782
- $( '<div/>', {
783
- class:'czr-server-notice',
784
- html:'<span class="czr-server-message"></span><span class="fa fa-times-circle czr-dismiss-notification"></span>'
785
- } )
786
- );
787
- },
788
- _toggleNotice = function() {
789
- var $notif_wrap = $( '.czr-server-notice', '.czr-scope-switcher' ),
790
- $header = $('.wp-full-overlay-header'),
791
- $sidebar = $('.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content'),
792
- _header_height,
793
- _notif_wrap_height,
794
- _set_height = function( _h ) {
795
- return true;
796
- };
797
- if ( self.skopeTitleNoticeVisible )
798
- self.skopeTitleNoticeVisible( false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
 
800
- if ( ! notice.expanded ) {
801
- $notif_wrap
802
- .fadeOut( {
803
- duration : 200,
804
- complete : function() {
805
- } } );
806
- setTimeout( function() {
807
- _set_height();
808
- } , 200 );
809
 
810
- } else {
811
- $notif_wrap.toggleClass( 'czr-server-error', 'error' == notice.status );
812
- if ( 'error' == notice.status ) {
813
- $('.czr-server-message', $notif_wrap )
814
- .html( _.isEmpty( notice.message ) ? 'Server Problem.' : notice.message );
815
- } else {
816
- $('.czr-server-message', $notif_wrap )
817
- .html( _.isEmpty( notice.message ) ? 'Success.' : notice.message );
818
- }
819
- _notif_wrap_height = $( '.czr-server-notice', '.czr-scope-switcher' ).outerHeight();
820
- _header_height = $header.outerHeight() + _notif_wrap_height;
821
 
822
- setTimeout( function() {
823
- $.when( _set_height( _header_height ) ).done( function() {
824
- $notif_wrap
825
- .fadeIn( {
826
- duration : 200,
827
- complete : function() {
828
- $( this ).css( 'height', 'auto' );
829
- } } );
830
- } );
831
- }, 400 );
832
- }
833
- };
834
- if ( 'pending' == self.serverNoticeEmbedded.state() ) {
835
- $.when( _embed() ).done( function() {
836
- setTimeout( function() {
837
- self.serverNoticeEmbedded.resolve();
838
- _toggleNotice();
839
- }, 200 );
840
- });
841
- } else {
842
- _toggleNotice();
843
- }
844
- _.delay( function() {
845
- api.czr_serverNotification( { expanded : false } );
846
- },
847
- ( 'success' == notice.status || false !== notice.auto_collapse ) ? 4000 : 5000
848
- );
849
- },
850
- buildServerResponse : function( _r ) {
851
- var resp = false;
852
- if ( _.isObject( _r ) ) {
853
- if ( _.has( _r, 'responseJSON') && ! _.isUndefined( _r.responseJSON.data ) && ! _.isEmpty( _r.responseJSON.data ) ) {
854
- resp = _r.responseJSON.data;
855
- }
856
- else if ( _.has( _r , 'statusText' ) && ! _.isEmpty( _r.statusText ) ) {
857
- resp = _r.statusText;
858
- }
859
- }
860
- if ( _.isObject( _r ) && ! resp ) {
861
- try {
862
- JSON.stringify( _r );
863
- } catch( e ) {
864
- resp = 'Server Error';
865
- }
866
- } else if ( ! resp ) {
867
- resp = '0' === _r ? 'Not logged in.' : _r;
868
- } else if ( '-1' === _r ) {
869
- resp = 'Identification issue detected, please refresh your page.';
870
- }
871
- return resp;
872
- }
873
- });//$.extend()
874
- })( wp.customize , jQuery, _);
875
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
876
- (function ( api, $, _ ) {
877
- $.extend( CZRSkopeBaseMths, {
878
- toggleTopNote : function( visible, noteParams ) {
879
- noteParams = _.isObject( noteParams ) ? noteParams : {};
880
- var self = this,
881
- _defaultParams = {
882
- title : '',
883
- message : '',
884
- actions : '',
885
- selfCloseAfter : 20000
886
- },
887
- _renderAndSetup = function() {
888
- $.when( self.renderTopNoteTmpl( noteParams ) ).done( function( $_el ) {
889
- self.welcomeNote = $_el;
890
- _.delay( function() {
891
- $('body').addClass('czr-top-note-open');
892
- }, 200 );
893
- api.CZR_Helpers.setupDOMListeners(
894
- [ {
895
- trigger : 'click keydown',
896
- selector : '.czr-preview-note-close',
897
- actions : function() {
898
- _hideAndDestroy().done( function() {
899
- api.czr_topNoteVisible( false );
900
- if ( _.isFunction( noteParams.actions ) ) {
901
- noteParams.actions();
902
- }
903
- });
904
- }
905
- } ] ,
906
- { dom_el : self.welcomeNote },
907
- self
908
- );
909
- });
910
- },
911
- _hideAndDestroy = function() {
912
- var dfd = $.Deferred();
913
- $('body').removeClass('czr-top-note-open');
914
- if ( self.welcomeNote.length ) {
915
- _.delay( function() {
916
- self.welcomeNote.remove();
917
- dfd.resolve();
918
- }, 300 );
919
- } else {
920
- dfd.resolve();
921
- }
922
- return dfd.promise();
923
- };
924
-
925
- noteParams = $.extend( _defaultParams , noteParams);
926
 
927
- if ( visible ) {
928
- _renderAndSetup();
929
- } else {
930
- _hideAndDestroy().done( function() {
931
- api.czr_topNoteVisible( false );//should be already false
932
- });
933
- }
934
- _.delay( function() {
935
- api.czr_topNoteVisible( false );
936
- },
937
- noteParams.selfCloseAfter || 20000
938
- );
939
- },
940
- renderTopNoteTmpl : function( params ) {
941
- if ( $( '#czr-top-note' ).length )
942
- return $( '#czr-top-note' );
943
 
944
- var self = this,
945
- _tmpl = '',
946
- _title = params.title || '',
947
- _message = params.message || '';
 
948
 
949
- try {
950
- _tmpl = wp.template( 'czr-top-note' )( { title : _title } );
951
- } catch( er ) {
952
- api.errorLog( 'Error when parsing the the top note template : ' + er );
953
- return false;
954
  }
955
- $('#customize-preview').after( $( _tmpl ) );
956
- $('.czr-note-message', '#czr-top-note').html( _message );
957
- return $( '#czr-top-note' );
958
- }
959
- });//$.extend()
960
- })( wp.customize , jQuery, _);
961
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
962
- (function ( api, $, _ ) {
963
- $.extend( CZRSkopeBaseMths, {
964
- /*****************************************************************************
965
- * WORDPRESS API ACTIONS ON INIT
966
- *****************************************************************************/
967
- bindAPISettings : function( requestedSetId ) {
968
- var self = this,
969
- _settingChangeReact = function( new_val, old_val, o ) {
970
- var setId = this.id,
971
- skope_id;
972
- if ( ! serverControlParams.isSkopOn )
973
- return;
974
 
975
- if ( ! _.has( api, 'czr_activeSkopeId') || _.isUndefined( api.czr_activeSkopeId() ) ) {
976
- api.errorLog( 'The api.czr_activeSkopeId() is undefined in the api.czr_skopeBase.bindAPISettings method.');
977
- }
978
- if ( api( setId )._dirty ) {
979
- skope_id = self.isSettingSkopeEligible( setId ) ? api.czr_activeSkopeId() : self.getGlobalSkopeId();
980
- api.czr_skope( skope_id ).updateSkopeDirties( setId, new_val );
981
- }
982
- if ( _.has( api.control(setId), 'czr_states' ) && ! api.control(setId).czr_states( 'isResetting' )() ) {
983
- api.control( setId ).czr_states( 'resetVisible' )( false );
984
- }
985
- if ( self.isSettingSkopeEligible( setId ) ) {
986
- self.updateCtrlSkpNot( setId );
987
- }
988
- };//_settingChangeReact()
989
- if ( ! _.isUndefined( requestedSetId ) ) {
990
- api( requestedSetId ).bind( _settingChangeReact );
991
- }
992
- else {
993
- api.each( function ( _setting ) {
994
- _setting.bind( _settingChangeReact );
995
- });
996
- }
997
- var _dynamicallyAddedSettingsReact = function( setting_instance ) {
998
- if ( setting_instance.callbacks.has( _settingChangeReact ) )
999
- return;
1000
- setting_instance.bind( _settingChangeReact );
1001
- };
1002
 
1003
- if ( ! api.topics.change.has( _dynamicallyAddedSettingsReact ) ) {
1004
- api.bind( 'change', _dynamicallyAddedSettingsReact );
1005
- }
1006
- }
1007
- });//$.extend()
1008
- })( wp.customize , jQuery, _ );
1009
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
1010
- ( function ( api, $, _ ) {
1011
- $.extend( CZRSkopeBaseMths, {
1012
 
1013
- /*****************************************************************************
1014
- * REACT ON SKOPE SYNCED
1015
- *****************************************************************************/
1016
- reactWhenSkopeSyncedDone : function( server_params ) {
1017
- var self = this, dfd = $.Deferred();
1018
- if ( ! _.has( server_params, 'czr_skopes' ) || _.isEmpty( server_params.czr_skopes ) ) {
1019
- api.errorLog( 'Missing skope data after refresh', server_params );
1020
- return dfd.resolve().promise();
1021
- }
1022
- if ( ! api.czr_dirtyness() ) {
1023
- api.czr_dirtyness( _.isBoolean( server_params.isChangesetDirty ) ? server_params.isChangesetDirty : false );
1024
- }
1025
-
1026
- var _sentSkopeCollection = server_params.czr_skopes;
1027
- _.each( api.czr_skopeCollection(), function( _skp ) {
1028
- var _sent_skope = _.findWhere( _sentSkopeCollection, { opt_name : _skp.opt_name } );
1029
- if ( _.isUndefined( _sent_skope ) )
1030
- return;
1031
- var _changeset_candidate = _.isEmpty( _sent_skope.changeset || {} ) ? {} : _sent_skope.changeset,
1032
- _api_ready_chgset = {};
1033
- _.each( _changeset_candidate, function( _val, _setId ) {
1034
- if ( ! api.has( _setId ) ) {
1035
- api.consoleLog( 'In reactWhenSkopeSyncedDone : attempting to update the changeset with a non registered setting : ' + _setId );
1036
- }
1037
- _api_ready_chgset[_setId] = _val;
1038
- });
1039
- api.czr_skope( _skp.id ).changesetValues( _api_ready_chgset );
1040
- });
1041
- _.each( api.czr_skopeCollection(), function( _skp ) {
1042
- var _sent_skope = _.findWhere( _sentSkopeCollection, { opt_name : _skp.opt_name } );
1043
- if ( _.isUndefined( _sent_skope ) )
1044
- return;
1045
- var _current_db_vals = $.extend( true, {}, api.czr_skope( _skp.id ).dbValues() ),
1046
- _dbVals_candidate = $.extend( _current_db_vals , _sent_skope.db || {} ),
1047
- _api_ready_dbvals = {};
1048
- _.each( _dbVals_candidate, function( _val, _setId ) {
1049
- if ( ! api.has( _setId ) ) {
1050
- api.consoleLog( 'In reactWhenSkopeSyncedDone : attempting to update the db values with a non registered setting : ' + _setId );
1051
- }
1052
- _api_ready_dbvals[_setId] = _val;
1053
- });
1054
 
 
 
 
 
 
 
 
 
 
 
 
1055
 
1056
- api.czr_skope( _skp.id ).dbValues( _api_ready_dbvals );
 
 
 
1057
  });
1058
- _.delay( function() {
1059
- dfd.resolve();
1060
- }, 500 );
1061
- return dfd.promise();
1062
- }
1063
- });//$.extend()
1064
- })( wp.customize , jQuery, _ );
1065
 
1066
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1067
  ( function ( api, $, _ ) {
1068
- $.extend( CZRSkopeBaseMths, {
1069
-
1070
- /*****************************************************************************
1071
- * REACT ON ACTIVE SECTION SETUP DONE
1072
- *****************************************************************************/
1073
- _maybeSetupAssignedMenuLocations : function( active_section ) {
1074
- if ( _.isUndefined( active_section ) || _.isEmpty( active_section ) || ! api.section.has( active_section.id ) ) {
1075
- api.consoleLog( 'In _maybeSetupAssignedMenuLocations : no valid section_id provided.');
1076
- }
1077
- var self = this;
1078
- if ( ! active_section.assignedLocations )
1079
- return;
1080
- var _assignedLocReact = function( locations ) {};
1081
 
1082
- if ( ! active_section.assignedLocations.callbacks.has( _assignedLocReact ) ) {
1083
- active_section.assignedLocations.bind( _assignedLocReact );
1084
- }
1085
- },
 
 
1086
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1087
 
 
 
 
 
 
 
1088
 
1089
- /*****************************************************************************
1090
- * REACT TO ACTIVE SECTION EXPANSION
1091
- *****************************************************************************/
1092
- activeSectionReact : function( active_sec_id , previous_sec_id ) {
1093
- if ( 'add_menu' != active_sec_id ) {
1094
- api.trigger('czr-paint', { active_section_id : active_sec_id } );
1095
- }
 
 
 
 
 
1096
 
1097
- var self = this,
1098
- _doReactPrevious = function( previous_sec_id ) {
1099
- var controls = api.CZR_Helpers.getSectionControlIds( previous_sec_id );
1100
- _.each( controls, function( ctrlId ) {
1101
- if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
1102
- return;
1103
- var ctrl = api.control( ctrlId );
1104
- if ( ! _.has( ctrl, 'czr_states' ) )
1105
- return;
1106
 
1107
- ctrl.czr_states( 'resetVisible' )( false );
1108
- });
1109
- },
1110
- _doReactActive = function( active_section, active_sec_id ) {
1111
- self.setupActiveSkopedControls( {
1112
- section_id : active_sec_id
1113
- });
1114
- self.processSilentUpdates( { section_id : active_sec_id } )
1115
- .fail( function() {
1116
- throw new Error( 'Fail to process silent updates after initial skope collection has been populated' );
1117
- })
1118
- .done( function() {
1119
- var _setupSectionCtrlNotices = function() {
1120
- var controls = api.CZR_Helpers.getSectionControlIds( active_sec_id );
1121
- _.each( controls, function( ctrlId ) {
1122
- if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
1123
- return;
1124
- var ctrl = api.control( ctrlId );
1125
- if ( ! _.has( ctrl, 'czr_states' ) )
1126
- return;
1127
- ctrl.czr_states( 'noticeVisible' )( self.isCtrlNoticeVisible( ctrlId ) );
1128
- });
1129
- };
1130
- _.delay( function() {
1131
- _setupSectionCtrlNotices();
1132
- }, 700 );
1133
- if ( ! self.isExcludedSidebarsWidgets() ) {
1134
- self.forceSidebarDirtyRefresh( active_sec_id , api.czr_activeSkopeId() );
1135
- }
1136
- });
1137
- if ( ! _.has( api.topics, 'active-section-setup' ) ) {
1138
- api.bind( 'active-section-setup', function( params ) {
1139
- var defaults = {
1140
- controls : [],
1141
- section_id : ''
1142
- };
1143
- params = _.extend( defaults, params );
1144
- self._maybeSetupAssignedMenuLocations( params );
1145
- });
1146
- }
1147
- api.czr_skopeReady.then( function() {
1148
- var _switchBack = function( _title ) {
1149
- api.czr_serverNotification({
1150
- status:'success',
1151
- message : [ _title, serverControlParams.i18n.skope['can only be customized sitewide.'] ].join(' ')
1152
- });
1153
- api.czr_activeSkopeId( self.getGlobalSkopeId() );
1154
- };
1155
- if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
1156
- if (
1157
- self.isExcludedWPCustomCss() &&
1158
- ( 'custom_css' == active_sec_id || 'admin_sec' == active_sec_id )
1159
- ) {
1160
- _switchBack( api.section( active_sec_id ).params.title );
1161
- }
1162
 
1163
- if ( 'nav_menu[' == active_sec_id.substring( 0, 'nav_menu['.length ) || 'add_menu' == active_sec_id ) {
1164
- api.czr_serverNotification({
1165
- status:'success',
1166
- message : [
1167
- serverControlParams.i18n.skope['Menus are created sitewide.']
1168
- ].join(' ')
1169
- });
1170
- }
1171
- }
1172
- });
1173
- api.trigger('active-section-setup', active_section );
1174
- };
1175
- api.czr_initialSkopeCollectionPopulated.then( function() {
1176
- api.section.when( active_sec_id , function( active_section ) {
1177
- active_section.deferred.embedded.then( function() {
1178
- try { _doReactActive( active_section, active_sec_id ); } catch( er ) {
1179
- api.errorLog( 'activeSectionReact => _doReactActive : ' + er );
1180
- }
1181
 
1182
- });
1183
- });
1184
- if ( ! _.isEmpty( previous_sec_id ) && api.section.has( previous_sec_id ) ) {
1185
- _doReactPrevious( previous_sec_id );
1186
- }
1187
- });
1188
- },
1189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1190
 
1191
- /*****************************************************************************
1192
- * REACT TO ACTIVE PANEL EXPANSION
1193
- *****************************************************************************/
1194
- activePanelReact : function( active_panel_id , previous_panel_id ) {
1195
- var self = this;
1196
- api.czr_initialSkopeCollectionPopulated.then( function() {
1197
- api.trigger('czr-paint', { active_panel_id : active_panel_id } );
1198
- var _switchBack = function( _title ) {
1199
- api.czr_serverNotification({
1200
- status:'success',
1201
- message : [ _title, serverControlParams.i18n.skope['can only be customized sitewide.'] ].join(' ')
1202
- });
1203
- api.czr_activeSkopeId( self.getGlobalSkopeId() );
1204
- };
1205
- api.czr_skopeReady.then( function() {
1206
- if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
1207
- if ( self.isExcludedSidebarsWidgets() && 'widgets' == active_panel_id ) {
1208
- api.czr_serverNotification({
1209
- status:'success',
1210
- message : [
1211
- serverControlParams.i18n.skope['Widgets are created sitewide.']
1212
- ].join(' ')
1213
- });
1214
- }
1215
- }
1216
- });
1217
- api.czr_skopeReady.then( function() {
1218
- if ( 'nav_menus' == active_panel_id ) {
1219
- _.each( api.panel( active_panel_id ).sections(), function( _sec ) {
1220
- self.processSilentUpdates( { section_id : _sec.id, awake_if_not_active : true } );
1221
- });
1222
- }
1223
- });
1224
- });
1225
- }
1226
- });//$.extend()
1227
- })( wp.customize , jQuery, _ );
1228
- /*****************************************************************************
1229
- * THE SKOPE BASE OBJECT
1230
- *****************************************************************************/
1231
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
1232
- ( function ( api, $, _ ) {
1233
- $.extend( CZRSkopeBaseMths, {
1234
 
1235
- /*****************************************************************************
1236
- * PAINT AND WASH
1237
- *****************************************************************************/
1238
- wash : function( params ) {
1239
- var self = this,
1240
- _do_wash = function( element ) {
1241
- if ( ! _.has( element, 'el') || ! element.el.length )
1242
- return;
1243
- $.when( element.el.removeClass('czr-painted') ).done( function() {
1244
- $(this).css( 'background', '' ).css('color', '');
1245
- });
1246
- };
1247
- if ( api.czr_skopeBase.paintedElements ) {
1248
- _.each( api.czr_skopeBase.paintedElements(), function( _el ) { _do_wash( _el ); } );
1249
- api.czr_skopeBase.paintedElements( [] );
1250
- }
1251
- return this;
1252
- },
1253
- paint : function( params ) {
1254
- var _bgColor = 'inherit',
1255
- defaults = {
1256
- active_panel_id : api.czr_activePanelId(),
1257
- active_section_id : api.czr_activeSectionId(),
1258
- is_skope_switch : false
1259
- },
1260
- _paint_candidates = [];
1261
- params = $.extend( defaults, params );
1262
 
1263
- if ( ! _.isUndefined( api.czr_activeSkopeId() ) && api.czr_skope.has( api.czr_activeSkopeId() ) ) {
1264
- _bgColor = api.czr_skope( api.czr_activeSkopeId() ).color;
1265
- }
1266
- var _do_paint = function( element ) {
1267
- if ( ! _.has( element, 'el') || ! element.el.length )
1268
- return;
1269
- if ( params.is_skope_switch ) {
1270
- $.when( element.el.addClass('czr-painted') ).done( function() {
1271
- $(this).css( 'background', element.bgColor || _bgColor );
1272
- });
1273
- } else {
1274
- element.el.css( 'background', element.bgColor || _bgColor );
1275
- }
1276
- if ( 'global' != api.czr_skope( api.czr_activeSkopeId() )().skope ) {
1277
- element.el.css( 'color', '#000');
1278
- }
1279
 
1280
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1281
 
1282
- api.czr_skopeBase.paintedElements = api.czr_skopeBase.paintedElements || new api.Value( [] );
1283
- if ( _.isEmpty( params.active_panel_id ) && _.isEmpty( params.active_section_id ) ) {
1284
- _paint_candidates.push( {
1285
- el : $( '#customize-info' ).find('.accordion-section-title').first()
1286
- });
1287
- api.panel.each( function( _panel ) {
1288
- _paint_candidates.push( {
1289
- el : _panel.container.find( '.accordion-section-title').first()
1290
- });
1291
- });
1292
- api.section.each( function( _section ) {
1293
- if ( ! _.isEmpty( _section.panel() ) )
1294
- return;
1295
- _paint_candidates.push( {
1296
- el : _section.container.find( '.accordion-section-title').first()
1297
- });
1298
- });
1299
- }
1300
- if ( ! _.isEmpty( params.active_panel_id ) && _.isEmpty( params.active_section_id ) ) {
1301
- api.panel.when( params.active_panel_id , function( active_panel ) {
1302
- active_panel.deferred.embedded.then( function() {
1303
- _paint_candidates.push( {
1304
- el : active_panel.container.find( '.accordion-section-title, .customize-panel-back' )
1305
- });
1306
- });
1307
- });
1308
- }
1309
- if ( ! _.isEmpty( params.active_section_id ) ) {
1310
- api.section.when( params.active_section_id , function( active_section ) {
1311
- active_section.deferred.embedded.then( function() {
1312
- _paint_candidates.push(
1313
- {
1314
- el : active_section.container.find( '.customize-section-title, .customize-section-back' ),
1315
- bgColor : 'inherit'
1316
- },
1317
- {
1318
- el : active_section.container
1319
- }
1320
- );
1321
- if ( ! api.czr_isChangeSetOn() ) {
1322
- _paint_candidates.push(
1323
- {
1324
- el : active_section.container.find('.accordion-section-content')
1325
- }
1326
- );
1327
- }
1328
- });
1329
- });
1330
- }
1331
- _.each( _paint_candidates, function( _el ) { _do_paint( _el ); } );
1332
- api.czr_skopeBase.paintedElements( _paint_candidates );
1333
- return this;
1334
- }
1335
- });//$.extend()
1336
- })( wp.customize , jQuery, _ );
1337
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
1338
- (function ( api, $, _ ) {
1339
- $.extend( CZRSkopeBaseMths, {
1340
- toggleBottomInfos : function( visible, noteParams ) {
1341
- noteParams = _.isObject( noteParams ) ? noteParams : {};
1342
- var self = this,
1343
- dfd = $.Deferred(),
1344
- _defaultParams = {
1345
- title : '',
1346
- message : '',
1347
- actions : '',
1348
- selfCloseAfter : 20000
1349
- },
1350
- _skopeInfosSetId = api.CZR_Helpers.build_setId('show-skope-infos'),
1351
- _renderAndSetup = function() {
1352
- var _dfd = $.Deferred();
1353
- $.when( self.renderBottomInfosTmpl( noteParams ) )
1354
- .done( function( $_el ) {
1355
- self.bottomInfosContainer = $_el;
1356
- _.delay( function() {
1357
- $('body').addClass('czr-bottom-infos-open');
1358
- _dfd.resolve();
1359
- }, 200 );
1360
- api.CZR_Helpers.setupDOMListeners(
1361
- [
1362
- {
1363
- trigger : 'click keydown',
1364
- selector : '.czr-preview-note-close',
1365
- actions : function() {
1366
- _hideAndDestroy().done( function() {
1367
- api.czr_bottomInfosVisible( false );
1368
- if ( _.isFunction( noteParams.actions ) ) {
1369
- noteParams.actions();
1370
- }
1371
- });
1372
- }
1373
- },
1374
- {
1375
- trigger : 'click keydown',
1376
- selector : '.czr-skope-switch',
1377
- actions : function( params ) {
1378
- var _skopeIdToSwithTo = $( params.dom_event.currentTarget, params.dom_el ).attr('data-skope-id');
1379
- if ( ! _.isEmpty( _skopeIdToSwithTo ) && api.czr_skope.has( _skopeIdToSwithTo ) )
1380
- api.czr_activeSkopeId( _skopeIdToSwithTo );
1381
- }
1382
- },
1383
- {
1384
- trigger : 'click keydown',
1385
- selector : '.czr-disable-bottom-infos',
1386
- actions : function( params ) {
1387
- if ( api.control.has( _skopeInfosSetId ) ) {
1388
- api.control( _skopeInfosSetId ).focus();
1389
- }
1390
- }
1391
- }
1392
- ] ,
1393
- { dom_el : self.bottomInfosContainer },
1394
- self
1395
- );
1396
- })
1397
- .fail( function() {
1398
- _dfd.resolve();
1399
- });
1400
- return _dfd.promise();
1401
- },
1402
- _hideAndDestroy = function() {
1403
- return $.Deferred( function() {
1404
- var _dfd_ = this;
1405
- $('body').removeClass('czr-bottom-infos-open');
1406
- if ( self.bottomInfosContainer.length ) {
1407
- _.delay( function() {
1408
- self.bottomInfosContainer.remove();
1409
- self.bottomInfosContainer = false;
1410
- _dfd_.resolve();
1411
- }, 300 );
1412
- } else {
1413
- _dfd_.resolve();
1414
- }
1415
- });
1416
- };
1417
 
 
1418
 
1419
- noteParams = $.extend( _defaultParams , noteParams);
 
1420
 
1421
- if ( visible ) {
1422
- _renderAndSetup().always( function() {
1423
- dfd.resolve();
1424
- });
1425
- } else {
1426
- _hideAndDestroy().done( function() {
1427
- api.czr_bottomInfosVisible( false );//should be already false
1428
- dfd.resolve();
1429
- });
1430
- }
1431
- return dfd.promise();
1432
- },
1433
- renderBottomInfosTmpl : function( params ) {
1434
- params = params || {};
1435
- var self = this,
1436
- _tmpl = '',
1437
- _skope_id = api.czr_activeSkopeId();
1438
- if ( ! api.czr_skope.has( _skope_id ) || ! _.isObject( api.czr_skope( _skope_id )() ) )
1439
- return false;
1440
-
1441
- var _skope_title = api.czr_skope( _skope_id )().long_title,
1442
- _ctxTitle = api.czr_skope( _skope_id )().ctx_title;
1443
-
1444
- _skope_title = _.isString( _skope_title ) ? _skope_title : '';
1445
- _ctxTitle = _.isString( _ctxTitle ) ? _ctxTitle : '';
1446
 
1447
- var _title = params.title || ['Customizing', _ctxTitle.toLowerCase() ].join(' '),
1448
- _message = params.message || self._getSkopeInfosMessage( _skope_id ),
1449
- _renderTmpl = function() {
1450
- return $.Deferred( function() {
1451
- var dfd = this;
1452
- try {
1453
- _tmpl = wp.template( 'czr-bottom-infos' )( { title : _title } );
1454
- $('#customize-preview').after( $( _tmpl ) );
1455
- dfd.resolve();
1456
- } catch( er ) {
1457
- api.errorLog( 'Error when parsing the the bottom infos template : ' + er );
1458
- dfd.reject( er );
1459
- }
1460
- });
1461
- };
1462
- if ( _.isUndefined( this.bottomInfosContainer ) || 1 != this.bottomInfosContainer.length ) {
1463
- _renderTmpl().done( function() {
1464
- $('.czr-note-message', '#czr-bottom-infos').html( _message );
1465
- });
1466
- } else {
1467
- $('.czr-note-content', self.bottomInfosContainer ).fadeOut({
1468
- duration : 'fast',
1469
- complete : function() {
1470
- $( 'h2', self.bottomInfosContainer ).html( [ '&middot;', _title, '&middot;' ].join(' ') );
1471
- $('.czr-note-message', self.bottomInfosContainer ).html( _message );
1472
- $(this).fadeIn('fast');
1473
- }
1474
- });
1475
 
1476
- }
1477
- return ( this.bottomInfosContainer && 1 == this.bottomInfosContainer.length ) ? this.bottomInfosContainer : $( '#czr-bottom-infos' );
1478
- },
1479
- _getSkopeInfosMessage : function( skope_id ) {
1480
- skope_id = skope_id || api.czr_activeSkopeId();
1481
- var _localSkopeId = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
1482
- if ( ! api.czr_skope.has( skope_id ) || ! _.isObject( api.czr_skope( skope_id )() ) || _.isUndefined( _localSkopeId ) )
1483
- return '';
1484
 
1485
- var self = this,
1486
- _skpLevel = api.czr_skope( skope_id )().skope,
1487
- _inheritedFrom = self.getInheritedSkopeTitles(),
1488
- _overrides = self.getOverridenSkopeTitles(),
1489
- _localCtxTitle = api.czr_skope( _localSkopeId )().ctx_title,//<= the context title is always the one of the local skope
1490
- current_title = api.czr_skope( skope_id )().long_title,//ex : Options for home
1491
- _html;
1492
 
1493
- switch( _skpLevel ) {
1494
- case 'global' :
1495
- _html = [
1496
- serverControlParams.i18n.skope['The customizations made site wide are inherited by all other levels of customization.'],
1497
- '<br/>',
1498
- serverControlParams.i18n.skope['The current context'],
1499
- ['(', _localCtxTitle, ')'].join(' '),
1500
- serverControlParams.i18n.skope['can be customized more specifically at the following level'] + '(s)',
1501
- ':',
1502
- _overrides + '.'
1503
- ].join(' ');
1504
- break;
1505
- case 'group' :
1506
- _html = [
1507
- serverControlParams.i18n.skope['The current customizations will be applied to'],
1508
- api.czr_skope( skope_id )().ctx_title.toLowerCase() + '.',
1509
- '<br/>',
1510
- serverControlParams.i18n.skope['The options not customized at this level will inherit their value from'],
1511
- _inheritedFrom,
1512
- '.<br/>',
1513
- serverControlParams.i18n.skope['The current context'],
1514
- ['(', _localCtxTitle, ')'].join(' '),
1515
- serverControlParams.i18n.skope['can be customized more specifically at the following level'],
1516
- ':',
1517
- _overrides + '.'
1518
- ].join(' ');
1519
- break;
1520
- case 'local' :
1521
- _html = [
1522
- serverControlParams.i18n.skope['The current context'],
1523
- ['(', _localCtxTitle, ')'].join(' '),
1524
- serverControlParams.i18n.skope['can be customized with a specific set of options.'],
1525
- '<br/>',
1526
- serverControlParams.i18n.skope['The options not customized at this level will inherit their value from'],
1527
- _inheritedFrom + '.'
1528
- ].join(' ');
1529
- break;
1530
- }
1531
 
1532
- return $.trim( [
1533
- '<span class="czr-skope-bottom-infos">',
1534
- _html,
1535
- '</span>'
1536
- ].join(' ') );
1537
- }
1538
- });//$.extend()
1539
- })( wp.customize , jQuery, _);
1540
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
1541
  ( function ( api, $, _ ) {
1542
- $.extend( CZRSkopeBaseMths, {
1543
-
1544
- /*****************************************************************************
1545
- * HELPERS
1546
- *****************************************************************************/
1547
- isSkopeRegisteredInCollection : function( skope_id, collection ) {
1548
- var self = this;
1549
- collection = collection || api.czr_skopeCollection();
1550
- return ! _.isUndefined( _.findWhere( collection, { id : skope_id } ) );
1551
- },
1552
- isSkopeRegisteredInCurrentCollection : function( skope_id, collection ) {
1553
- var self = this;
1554
- collection = collection || api.czr_currentSkopesCollection();
1555
- return ! _.isUndefined( _.findWhere( collection, { id : skope_id } ) );
1556
- },
1557
- isGlobalSkopeRegistered : function() {
1558
- var _model = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'global'} );
1559
- return _.isObject( _model ) && _.has( _model, 'id' );
1560
- },
1561
- getGlobalSkopeId : function() {
1562
- if ( ! _.has(api, 'czr_skope') )
1563
- return '';
1564
- var id = '';
1565
- api.czr_skope.each( function(skp){
1566
- if ( 'global' == skp().skope )
1567
- id = skp().id;
1568
- });
1569
- return id;
1570
- },
1571
- getChangedGlobalDBSettingValues : function( serverGlobalDBValues ) {
1572
- var _changedDbVal = {};
1573
 
1574
- _.each( serverGlobalDBValues, function( _val, _setId ){
1575
- _wpSetId = api.CZR_Helpers.build_setId( _setId);
 
 
 
1576
 
1577
- if ( ! _.has( api.settings.settings, _wpSetId ) )
1578
- return;
1579
- if ( _.isEqual( _val , api.settings.settings[ _wpSetId ].value ) )
1580
- return;
1581
- _changedDbVal[_setId] = _val;
1582
- });
1583
- return _changedDbVal;
1584
- },
1585
- getActiveSkopeId : function( _current_skope_collection ) {
1586
- _current_skope_collection = _current_skope_collection || api.czr_currentSkopesCollection();
1587
 
1588
- var _currentSkopeLevel, _newSkopeCandidate, _skpId;
1589
- if ( ! _.isEmpty( api.czr_activeSkopeId() ) && api.czr_skope.has( api.czr_activeSkopeId() ) ) {
1590
- _currentSkopeLevel = api.czr_skope( api.czr_activeSkopeId() )().skope;
1591
- } else if ( serverControlParams.isLocalSkope ) {
1592
- _currentSkopeLevel = 'local';
1593
- } else {
1594
- _currentSkopeLevel = 'global';
1595
- }
 
 
 
 
 
 
 
 
 
 
1596
 
1597
- _newSkopeCandidate = _.findWhere( _current_skope_collection, { skope : _currentSkopeLevel } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1598
 
1599
- _skpId = ! _.isUndefined( _newSkopeCandidate ) ? _newSkopeCandidate.id : _.findWhere( _current_skope_collection, { skope : 'global' } ).id;
 
 
 
1600
 
1601
- if ( _.isUndefined( _skpId ) ) {
1602
- throw new Error( 'No default skope was found in getActiveSkopeId ', _current_skope_collection );
1603
- }
1604
- return _skpId;
1605
- },
1606
- getActiveSkopeName : function() {
1607
- if ( ! api.czr_skope.has( api.czr_activeSkopeId() ) )
1608
- return 'global';
1609
- return api.czr_skope( api.czr_activeSkopeId() )().skope;
1610
- },
1611
- isSettingSkopeEligible : function( setId ) {
1612
- var self = this,
1613
- shortSetId = api.CZR_Helpers.getOptionName( setId );
1614
 
1615
- if( _.isUndefined( setId ) || ! api.has( setId ) ) {
1616
- api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO SKOPE BECAUSE UNDEFINED OR NOT REGISTERED IN THE API.' );
1617
- return false;
1618
- }
1619
- if ( self.isExcludedWPBuiltinSetting( setId ) )
1620
- return false;
1621
- if ( _.contains( serverControlParams.skopeExcludedSettings, shortSetId ) ) {
1622
- return false;
1623
- } else if ( self.isThemeSetting( setId ) ) {
1624
- return true;
1625
- } else
1626
- return true;
1627
- },
1628
- isSettingResetEligible : function( setId ) {
1629
- var self = this,
1630
- shortSetId = api.CZR_Helpers.getOptionName( setId );
 
 
 
 
 
 
 
 
 
 
1631
 
1632
- if( _.isUndefined( setId ) || ! api.has( setId ) ) {
1633
- api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO RESET BECAUSE UNDEFINED OR NOT REGISTERED IN THE API.' );
1634
- return;
1635
- }
1636
- if ( self.isExcludedWPBuiltinSetting( setId ) )
1637
- return;
1638
- if ( ! self.isThemeSetting( setId ) && ! self.isWPAuthorizedSetting( setId ) ) {
1639
- api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO RESET BECAUSE NOT PART OF THE THEME OPTIONS AND NOT WP AUTHORIZED BUILT IN OPTIONS' );
1640
- } else
1641
- return true;
1642
- },
1643
- isThemeSetting : function( setId ) {
1644
- return _.isString( setId ) && -1 !== setId.indexOf( serverControlParams.themeOptions );
1645
- },
1646
- isWPAuthorizedSetting : function( setId ) {
1647
- return _.isString( setId ) && _.contains( serverControlParams.wpBuiltinSettings, setId );
1648
- },
1649
- isExcludedWPBuiltinSetting : function( setId ) {
1650
- var self = this;
1651
- if ( _.isUndefined(setId) )
1652
- return true;
1653
- if ( 'active_theme' == setId )
1654
- return true;
1655
- if ( _.contains( serverControlParams.wpBuiltinSettings, setId ) )
1656
- return false;
1657
- var _patterns = [ 'widget_', 'nav_menu', 'sidebars_', 'custom_css', 'nav_menu[', 'nav_menu_item', 'nav_menus_created_posts', 'nav_menu_locations' ],
1658
- _isExcld = false;
1659
- _.each( _patterns, function( _ptrn ) {
1660
- switch( _ptrn ) {
1661
- case 'widget_' :
1662
- case 'sidebars_' :
1663
- if ( _ptrn == setId.substring( 0, _ptrn.length ) ) {
1664
- _isExcld = self.isExcludedSidebarsWidgets();
1665
- }
1666
- break;
1667
 
1668
- case 'nav_menu[' :
1669
- case 'nav_menu_item' :
1670
- case 'nav_menus_created_posts' :
1671
- if ( _ptrn == setId.substring( 0, _ptrn.length ) ) {
1672
- _isExcld = true;
1673
- }
1674
- break;
1675
 
1676
- case 'nav_menu_locations' :
1677
- if ( _ptrn == setId.substring( 0, _ptrn.length ) ) {
1678
- _isExcld = self.isExcludedNavMenuLocations();
1679
- }
1680
- break;
1681
 
1682
- case 'custom_css' :
1683
- if ( _ptrn == setId.substring( 0, _ptrn.length ) ) {
1684
- _isExcld = self.isExcludedWPCustomCss();
1685
- }
1686
- break;
1687
 
 
 
1688
 
1689
- }
1690
- });
1691
- return _isExcld;
1692
- },
1693
- isExcludedSidebarsWidgets : function() {
1694
- var _servParam = serverControlParams.isSidebarsWigetsSkoped;//can be a boolean or a string "" for false, "1" for true
1695
- return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
1696
- },
1697
- isExcludedNavMenuLocations : function() {
1698
- if ( ! api.czr_isChangeSetOn() )
1699
- return true;
1700
- var _servParam = serverControlParams.isNavMenuLocationsSkoped;//can be a boolean or a string "" for false, "1" for true
1701
- return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
1702
- },
1703
- isExcludedWPCustomCss : function() {
1704
- var _servParam = serverControlParams.isWPCustomCssSkoped;//can be a boolean or a string "" for false, "1" for true
1705
- return ! ( ! _.isUndefined( _servParam ) && ! _.isEmpty( _servParam ) && false !== _servParam );
1706
- },
1707
- _getDBSettingVal : function( setId, skope_id ) {
1708
- var shortSetId = api.CZR_Helpers.getOptionName(setId),
1709
- wpSetId = api.CZR_Helpers.build_setId(setId);
1710
- if ( ! api.czr_skope.has( skope_id ) ) {
1711
- api.consoleLog( '_getDBSettingVal : the requested skope id is not registered : ' + skope_id );
1712
- return '_no_db_val';
1713
- }
1714
- if ( _.has( api.czr_skope( skope_id ).dbValues(), wpSetId ) ) {
1715
- return api.czr_skope( skope_id ).dbValues()[wpSetId];
1716
- } else if ( _.has( api.czr_skope( skope_id ).dbValues(), shortSetId ) ) {
1717
- return api.czr_skope( skope_id ).dbValues()[shortSetId];
1718
- } else {
1719
- return '_no_db_val';
1720
- }
1721
- },
1722
- getSkopeDirties : function( skope_id, options ) {
1723
- if ( ! api.czr_skope.has( skope_id ) )
1724
- return {};
1725
- options = options || {};
1726
- options = _.extend( { unsaved : true }, options );
1727
 
1728
- var values = {};
1729
- _.each( api.czr_skope( skope_id ).dirtyValues(), function( _val, _setId ) {
1730
- var settingRevision;
1731
- if ( api.czr_isChangeSetOn() ) {
1732
- settingRevision = api._latestSettingRevisions[ _setId ];
1733
- if ( api.state( 'changesetStatus' ).get() && ( options && options.unsaved ) && ( _.isUndefined( settingRevision ) || settingRevision <= api._lastSavedRevision ) ) {
1734
- return;
1735
- }
1736
- }
1737
- values[ _setId ] = _val;
1738
- } );
1739
- return values;
1740
- },
1741
 
1742
- getSkopeExcludedDirties : function() {
1743
- var self = this,
1744
- _wpDirties = {};
1745
- api.each( function ( value, setId ) {
1746
- if ( value._dirty ) {
1747
- _wpDirties[ setId ] = value();
1748
- }
1749
- } );
1750
- var _globalSkopeId = self.getGlobalSkopeId(),
1751
- _globalSkpDirties = self.getSkopeDirties( _globalSkopeId );
1752
- return _.omit( _wpDirties, function( _value, setId ) {
1753
- return self.isSettingSkopeEligible( setId );
1754
- } );
1755
- },
1756
 
1757
- /**
1758
- * @param {String} widgetId
1759
- * @returns {Object}
1760
- */
1761
- parseWidgetId : function( widgetId, prefixToRemove ) {
1762
- var matches, parsed = {
1763
- number: null,
1764
- id_base: null
1765
- };
1766
 
1767
- matches = widgetId.match( /^(.+)-(\d+)$/ );
1768
- if ( matches ) {
1769
- parsed.id_base = matches[1];
1770
- parsed.number = parseInt( matches[2], 10 );
1771
- } else {
1772
- parsed.id_base = widgetId;
1773
- }
1774
 
1775
- if ( ! _.isUndefined( prefixToRemove ) )
1776
- parsed.id_base = parsed.id_base.replace( prefixToRemove , '');
1777
- return parsed;
1778
- },
 
 
 
 
 
 
 
 
1779
 
1780
- /**
1781
- * @param {String} widgetId
1782
- * @returns {String} settingId
1783
- */
1784
- widgetIdToSettingId: function( widgetId , prefixToRemove ) {
1785
- var parsed = this.parseWidgetId( widgetId, prefixToRemove ), settingId;
1786
-
1787
- settingId = parsed.id_base;
1788
- if ( parsed.number ) {
1789
- settingId += '[' + parsed.number + ']';
1790
- }
1791
- return settingId;
1792
- },
1793
 
 
 
 
 
 
 
 
 
1794
 
 
 
1795
 
 
 
 
 
 
1796
 
1797
- isWidgetRegisteredGlobally : function( widgetId ) {
1798
- var self = this;
1799
- registered = false;
1800
- _.each( _wpCustomizeWidgetsSettings.registeredWidgets, function( _val, _short_id ) {
1801
- if ( ! registered && 'widget_' + self.widgetIdToSettingId(_short_id) == widgetId )
1802
- registered = true;
1803
- } );
1804
- return registered;
1805
- }
1806
- });//$.extend
1807
- })( wp.customize , jQuery, _ );
1808
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
1809
- ( function ( api, $, _ ) {
1810
- $.extend( CZRSkopeBaseMths, {
1811
 
1812
- getAppliedPrioritySkopeId : function( setId, skope_id ) {
1813
- if ( ! api.has( api.CZR_Helpers.build_setId(setId) ) ) {
1814
- api.errorLog( 'getAppliedPrioritySkopeId : the requested setting id does not exist in the api : ' + api.CZR_Helpers.build_setId(setId) );
1815
- return skope_id;
1816
- }
1817
- if ( ! api.czr_skope.has( skope_id ) ) {
1818
- api.errorLog( 'getAppliedPrioritySkopeId : the requested skope id is not registered : ' + skope_id );
1819
- return skope_id;
1820
- }
1821
- var self = this,
1822
- _local_skope_id = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
1823
 
1824
- if ( _.isUndefined( _local_skope_id ) || skope_id == _local_skope_id )
1825
- return skope_id;
1826
- var _salmonToMatch = function( _skp_id ) {
1827
- var wpSetId = api.CZR_Helpers.build_setId( setId ),
1828
- val_candidate = '___',
1829
- skope_model = api.czr_skope( _skp_id )(),
1830
- initial_val;
1831
 
1832
- if ( _skp_id == skope_id )
1833
- return skope_id;
1834
- if ( api.czr_skope( _skp_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
1835
- return skope_model.id;
1836
- if ( api.czr_isChangeSetOn() ) {
1837
- if ( api.czr_skope( _skp_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
1838
- return skope_model.id;
1839
- }
1840
- var _skope_db_val = self._getDBSettingVal( setId, _skp_id);
1841
- if ( _skope_db_val != '_no_db_val' ) {
1842
- return skope_model.id;
1843
- }
1844
- else if( 'global' == skope_model.skope ) {
1845
- return skope_model.id;
1846
- }
1847
- else {
1848
- return '___' != val_candidate ? skope_model.title : _salmonToMatch( self._getParentSkopeId( skope_model ) );
1849
- }
1850
- };
1851
- return _salmonToMatch( _local_skope_id );
1852
- },
1853
- getOverridenSkopeTitles : function() {
1854
- var skope_id = skope_id || api.czr_activeSkopeId();
1855
- if ( ! api.czr_skope.has( skope_id ) ) {
1856
- api.errorLog( 'getInheritedSkopeTitles : the requested skope id is not registered : ' + skope_id );
1857
- return '';
1858
- }
1859
- var self = this,
1860
- _local_skope_id = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
1861
 
1862
- if ( _.isUndefined( _local_skope_id ) || skope_id == _local_skope_id )
1863
- return '';
1864
- var _salmonToMatch = function( _skp_id, _skp_ids ) {
1865
- _skp_ids = _skp_ids || [];
1866
- var skope_model = api.czr_skope( _skp_id )();
1867
 
1868
- if ( _skp_id == skope_id )
1869
- return _skp_ids;
1870
- _skp_ids.unshift( _skp_id );
1871
- return _salmonToMatch( self._getParentSkopeId( skope_model ), _skp_ids );
1872
- };
1873
 
1874
- return _.map( _salmonToMatch( _local_skope_id ), function( id ) {
1875
- return self.buildSkopeLink( id );
1876
- }).join( ' ' + serverControlParams.i18n.skope['and'] + ' ' );
1877
- },
1878
- getInheritedSkopeId : function( setId, skope_id ) {
1879
- if ( ! api.has( api.CZR_Helpers.build_setId(setId) ) ) {
1880
- api.errorLog( 'getInheritedSkopeId : the requested setting id does not exist in the api : ' + api.CZR_Helpers.build_setId(setId) );
1881
- return skope_id;
1882
- }
1883
- if ( ! api.czr_skope.has( skope_id ) ) {
1884
- api.errorLog( 'getInheritedSkopeId : the requested skope id is not registered : ' + skope_id );
1885
- return skope_id;
1886
- }
1887
 
1888
- var self = this,
1889
- wpSetId = api.CZR_Helpers.build_setId( setId ),
1890
- val_candidate = '___',
1891
- skope_model = api.czr_skope( skope_id )(),
1892
- initial_val;
1893
- if ( _.has( api.settings.settings, wpSetId ) )
1894
- initial_val = api.settings.settings[wpSetId].value;
1895
- else
1896
- initial_val = null;
1897
- if ( api.czr_skope( skope_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
1898
- return skope_id;
1899
- if ( api.czr_isChangeSetOn() ) {
1900
- if ( api.czr_skope( skope_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
1901
- return skope_id;
1902
- }
1903
- var _skope_db_val = self._getDBSettingVal( setId, skope_id );
1904
- if ( _skope_db_val != '_no_db_val' )
1905
- return skope_id;
1906
- else if( 'global' == skope_model.skope ) {
1907
- return skope_id;
1908
- }
1909
- else
1910
- return '___' != val_candidate ?skope_id : self.getInheritedSkopeId( setId, self._getParentSkopeId( skope_model ) );
1911
- },
1912
- getInheritedSkopeTitles : function( skope_id, skope_ids ) {
1913
- skope_id = skope_id || api.czr_activeSkopeId();
1914
- if ( ! api.czr_skope.has( skope_id ) ) {
1915
- api.errorLog( 'getInheritedSkopeTitles : the requested skope id is not registered : ' + skope_id );
1916
- return '';
1917
- }
1918
- skope_ids = skope_ids || [];
1919
- var self = this,
1920
- skope_model = api.czr_skope( skope_id )();
1921
 
1922
- if ( skope_id !== api.czr_activeSkopeId() )
1923
- skope_ids.unshift( skope_id );
 
 
 
 
 
 
 
 
 
 
1924
 
1925
- if ( 'global' !== skope_model.skope )
1926
- return self.getInheritedSkopeTitles( self._getParentSkopeId( skope_model ), skope_ids );
 
 
 
 
1927
 
1928
- return _.map( skope_ids, function( id ) {
1929
- return self.buildSkopeLink( id );
1930
- }).join(' ' + serverControlParams.i18n.skope['and'] + ' ');
1931
- },
1932
- buildSkopeLink : function( skope_id ) {
1933
- if ( ! api.czr_skope.has( skope_id ) ) {
1934
- api.errorLog( 'buildSkopeLink : the requested skope id is not registered : ' + skope_id );
1935
- return '';
1936
- }
1937
- var _link_title = [ serverControlParams.i18n.skope['Switch to scope'], api.czr_skope( skope_id )().title ].join(' : ');
1938
- return [
1939
- '<span class="czr-skope-switch" title=" ' + _link_title + '" data-skope-id="' + skope_id + '">',
1940
- api.czr_skope( skope_id )().title,
1941
- '</span>'
1942
- ].join( '' );
1943
- },
1944
- getSkopeSettingVal : function( setId, skope_id ) {
1945
- if ( ! api.has( api.CZR_Helpers.build_setId(setId) ) ) {
1946
- api.errorLog( 'getSkopeSettingVal : the requested setting id does not exist in the api : ' + api.CZR_Helpers.build_setId(setId) );
1947
- return null;
1948
- }
1949
- if ( ! api.czr_skope.has( skope_id ) ) {
1950
- api.errorLog( 'getSkopeSettingVal : the requested skope id is not registered : ' + skope_id );
1951
- return null;
1952
- }
1953
 
1954
- var self = this,
1955
- wpSetId = api.CZR_Helpers.build_setId( setId ),
1956
- val_candidate = '___',
1957
- skope_model = api.czr_skope( skope_id )(),
1958
- initial_val;
1959
- if ( _.has( api.settings.settings, wpSetId ) )
1960
- initial_val = api.settings.settings[wpSetId].value;
1961
- else
1962
- initial_val = null;
1963
- if ( api.czr_skope( skope_id ).getSkopeSettingAPIDirtyness( wpSetId ) )
1964
- return api.czr_skope( skope_id ).dirtyValues()[ wpSetId ];
1965
- if ( api.czr_isChangeSetOn() ) {
1966
- if ( api.czr_skope( skope_id ).getSkopeSettingChangesetDirtyness( wpSetId ) )
1967
- return api.czr_skope( skope_id ).changesetValues()[ wpSetId ];
1968
- }
1969
- var _skope_db_val = self._getDBSettingVal( setId, skope_id );
1970
- if ( _skope_db_val != '_no_db_val' )
1971
- return _skope_db_val;
1972
- else if( 'global' == skope_model.skope ) {
1973
- return '___' == val_candidate ? initial_val : val_candidate;
1974
- }
1975
- else
1976
- return '___' != val_candidate ? val_candidate : self.getSkopeSettingVal( setId, self._getParentSkopeId( skope_model ) );
1977
- },
1978
- applyDirtyCustomizedInheritance : function( dirtyCustomized, skope_id ) {
1979
- skope_id = skope_id || api.czr_activeSkopeId() || api.czr_skopeBase.getGlobalSkopeId();
1980
- dirtyCustomized = dirtyCustomized || {};
1981
 
1982
- var self = this,
1983
- skope_model = api.czr_skope( skope_id )();
 
1984
 
1985
- if ( 'global' == skope_model.skope )
1986
- return dirtyCustomized;
 
 
1987
 
1988
- var parent_skope_id = self._getParentSkopeId( skope_model ),
1989
- parent_dirties = api.czr_skope( parent_skope_id ).dirtyValues();
1990
- _.each( parent_dirties, function( _val, wpSetId ){
1991
- var shortSetId = api.CZR_Helpers.getOptionName( wpSetId );
1992
- if ( _.isUndefined( dirtyCustomized[wpSetId] ) && _.isUndefined( api.czr_skope( skope_model.id ).dbValues()[shortSetId] ) )
1993
- dirtyCustomized[wpSetId] = _val;
1994
- });
1995
- return 'global' == api.czr_skope( parent_skope_id )().skope ? dirtyCustomized : self.applyDirtyCustomizedInheritance( dirtyCustomized, parent_skope_id );
1996
- },
1997
- _getParentSkopeId : function( skope_model, _index ) {
1998
- var self = this,
1999
- hierark = ['local', 'group', 'special_group', 'global'],
2000
- parent_skope_ind = _index || ( _.findIndex( hierark, function( _skp ) { return skope_model.skope == _skp; } ) + 1 ) * 1,
2001
- parent_skope_skope = hierark[ parent_skope_ind ];
2002
 
2003
- if ( _.isUndefined( parent_skope_skope ) ) {
2004
- return _.findWhere( api.czr_currentSkopesCollection(), { skope : 'global' } ).id;
2005
- }
2006
- if ( _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), { skope : parent_skope_skope } ) ) ) {
2007
- return self._getParentSkopeId( skope_model, parent_skope_ind + 1 );
2008
- }
2009
- return _.findWhere( api.czr_currentSkopesCollection(), { skope : parent_skope_skope } ).id;
2010
- },
2011
- _getChildSkopeId : function( skope_model, _index ) {
2012
- var self = this,
2013
- hierark = ['local', 'group', 'special_group', 'global'],
2014
- child_skope_ind = _index || ( _.findIndex( hierark, function( _skp ) { return skope_model.skope == _skp; } ) - 1 ) * 1,
2015
- child_skope_skope = hierark[ child_skope_ind ];
2016
 
2017
- if ( _.isUndefined( child_skope_skope ) ) {
2018
- return _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id;
2019
- }
2020
- if ( _.isUndefined( _.findWhere( api.czr_currentSkopesCollection(), { skope : child_skope_skope } ) ) ) {
2021
- return self._getParentSkopeId( skope_model, child_skope_ind - 1 );
2022
- }
2023
- return _.findWhere( api.czr_currentSkopesCollection(), { skope : child_skope_skope } ).id;
2024
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2026
  });//$.extend
2027
- })( wp.customize , jQuery, _ );
2028
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
2029
- ( function ( api, $, _ ) {
2030
- $.extend( CZRSkopeBaseMths, {
2031
- updateSkopeCollection : function( sent_collection, sent_channel ) {
2032
- var self = this;
2033
- _api_ready_collection = [];
2034
- _.each( sent_collection, function( _skope, _key ) {
2035
- var skope_candidate = $.extend( true, {}, _skope );//deep clone to avoid any shared references
2036
- _api_ready_collection.push( self.prepareSkopeForAPI( skope_candidate ) );
2037
- });
2038
- if ( self.isGlobalSkopeRegistered() ) {
2039
- var _updated_api_ready_collection = [],
2040
- _global_skp_model = $.extend( true, {}, api.czr_skope( self.getGlobalSkopeId() )() );
2041
 
2042
- _.each( _api_ready_collection, function( _skp, _k ) {
2043
- if ( 'global' == _skp.skope )
2044
- _updated_api_ready_collection.push( _global_skp_model );
2045
- else
2046
- _updated_api_ready_collection.push( _skp );
2047
- });
2048
- _api_ready_collection = _updated_api_ready_collection;
2049
- }
2050
- api.czr_currentSkopesCollection( _api_ready_collection );
2051
- },
2052
- prepareSkopeForAPI : function( skope_candidate ) {
2053
- if ( ! _.isObject( skope_candidate ) ) {
2054
- throw new Error('prepareSkopeForAPI : a skope must be an object to be API ready');
2055
- }
2056
- var self = this,
2057
- api_ready_skope = {};
2058
-
2059
- _.each( serverControlParams.defaultSkopeModel , function( _value, _key ) {
2060
- var _candidate_val = skope_candidate[_key];
2061
- switch( _key ) {
2062
- case 'title' :
2063
- if ( ! _.isString( _candidate_val ) ) {
2064
- throw new Error('prepareSkopeForAPI : a skope title property must a string');
2065
- }
2066
- api_ready_skope[_key] = _candidate_val;
2067
- break;
2068
- case 'long_title' :
2069
- if ( ! _.isString( _candidate_val ) ) {
2070
- throw new Error('prepareSkopeForAPI : a skope title property must a string');
2071
- }
2072
- api_ready_skope[_key] = _candidate_val;
2073
- break;
2074
- case 'ctx_title' :
2075
- if ( ! _.isString( _candidate_val ) ) {
2076
- throw new Error('prepareSkopeForAPI : a skope context title property must a string');
2077
- }
2078
- api_ready_skope[_key] = _candidate_val;
2079
- break;
2080
- case 'skope' :
2081
- if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
2082
- throw new Error('prepareSkopeForAPI : a skope "skope" property must a string not empty');
2083
- }
2084
- api_ready_skope[_key] = _candidate_val;
2085
- break;
2086
- case 'level' :
2087
- if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
2088
- throw new Error('prepareSkopeForAPI : a skope level must a string not empty for skope ' + _candidate_val.skope );
2089
- }
2090
- api_ready_skope[_key] = _candidate_val;
2091
- break;
2092
- case 'dyn_type' :
2093
- if ( ! _.isString( _candidate_val ) || ! _.contains( serverControlParams.skopeDynTypes, _candidate_val ) ) {
2094
- throw new Error('prepareSkopeForAPI : missing or invalid dyn type for skope ' + skope_candidate );
2095
- }
2096
- api_ready_skope[_key] = _candidate_val;
2097
- break;
2098
- case 'opt_name' :
2099
- if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
2100
- throw new Error('prepareSkopeForAPI : invalid "opt_name" property for skope ' + _candidate_val.skope );
2101
- }
2102
- api_ready_skope[_key] = _candidate_val;
2103
- break;
2104
- case 'obj_id' :
2105
- if ( ! _.isString( _candidate_val ) ) {
2106
- throw new Error('prepareSkopeForAPI : invalid "obj_id" for skope ' + _candidate_val.skope );
2107
- }
2108
- api_ready_skope[_key] = _candidate_val;
2109
- break;
2110
- case 'is_winner' :
2111
- if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
2112
- throw new Error('prepareSkopeForAPI : skope property "is_winner" must be a boolean');
2113
- }
2114
- api_ready_skope[_key] = _candidate_val;
2115
- break;
2116
- case 'is_forced' :
2117
- if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
2118
- throw new Error('prepareSkopeForAPI : skope property "is_primary" must be a boolean');
2119
- }
2120
- api_ready_skope[_key] = _candidate_val;
2121
- break;
2122
- case 'db' :
2123
- if ( _.isArray( _candidate_val ) || _.isEmpty( _candidate_val ) )
2124
- _candidate_val = {};
2125
- if ( _.isUndefined( _candidate_val) || ! _.isObject( _candidate_val ) ) {
2126
- throw new Error('prepareSkopeForAPI : skope property "db" must be an object');
2127
- }
2128
- api_ready_skope[_key] = _candidate_val;
2129
- break;
2130
- case 'changeset' :
2131
- if ( _.isArray( _candidate_val ) || _.isEmpty( _candidate_val ) )
2132
- _candidate_val = {};
2133
- if ( _.isUndefined( _candidate_val) || ! _.isObject( _candidate_val ) ) {
2134
- throw new Error('prepareSkopeForAPI : skope property "changeset" must be an object');
2135
- }
2136
- api_ready_skope[_key] = _candidate_val;
2137
- break;
2138
- case 'has_db_val' :
2139
- if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
2140
- throw new Error('prepareSkopeForAPI : skope property "has_db_val" must be a boolean');
2141
- }
2142
- api_ready_skope[_key] = _candidate_val;
2143
- break;
2144
- }//switch
2145
- });
2146
- api_ready_skope.color = self.skope_colors[ api_ready_skope.skope ] || 'rgb(255, 255, 255)';
2147
- api_ready_skope.id = api_ready_skope.skope + '_' + api_ready_skope.level;
2148
- if ( ! _.isString( api_ready_skope.id ) || _.isEmpty( api_ready_skope.id ) ) {
2149
- throw new Error('prepareSkopeForAPI : a skope id must a string not empty');
2150
- }
2151
- if ( ! _.isString( api_ready_skope.title ) || _.isEmpty( api_ready_skope.title ) ) {
2152
- api_ready_skope.title = id;
2153
- api_ready_skope.long_title = id;
2154
- }
2155
- return api_ready_skope;
2156
- },
2157
- currentSkopesCollectionReact : function( to, from ) {
2158
- var self = this,
2159
- _new_collection = $.extend( true, [], to ) || [],
2160
- _old_collection = $.extend( true, [], from ) || [],
2161
- dfd = $.Deferred();
2162
- var _to_instantiate = [];
2163
- _to_remove = [];
2164
- _to_update = [];
2165
- _instantiateAndEmbed = function( _candidates_ ) {
2166
- _.each( _candidates_, function( _skope ) {
2167
- _skope = $.extend( true, {}, _skope );//use a cloned skop to instantiate : @todo : do we still need that ?
2168
- api.czr_skope.add( _skope.id , new api.CZR_skope( _skope.id , _skope ) );
2169
- });
2170
- _.each( _candidates_, function( _skope ) {
2171
- if ( ! api.czr_skope.has( _skope.id ) ) {
2172
- throw new Error( 'Skope id : ' + _skope.id + ' has not been instantiated.');
2173
- }
2174
- if ( 'pending' == api.czr_skope( _skope.id ).isReady.state() ) {
2175
- api.czr_skope( _skope.id ).ready();
2176
- }
2177
- });
2178
- };
2179
- _.each( _new_collection, function( _sent_skope ) {
2180
- if ( ! api.czr_skope.has( _sent_skope.id ) )
2181
- _to_instantiate.push( _sent_skope );
2182
- });
2183
- try {
2184
- _instantiateAndEmbed( _to_instantiate );
2185
- } catch( er ) {
2186
- api.errorLog( "currentSkopesCollectionReact : " + er );
2187
- return dfd.resolve().promise();
2188
- }
2189
- var _setActiveAndLayout = function() {
2190
- var _activeSkopeNum = _.size( _new_collection ),
2191
- _setLayoutClass = function( _skp_instance ) {
2192
- var _newClasses = _skp_instance.container.attr('class').split(' ');
2193
- _.each( _skp_instance.container.attr('class').split(' '), function( _c ) {
2194
- if ( 'width-' == _c.substring( 0, 6) ) {
2195
- _newClasses = _.without( _newClasses, _c );
2196
- }
2197
- });
2198
- $.when( _skp_instance.container.attr('class', _newClasses.join(' ') ) )
2199
- .done( function() {
2200
- _skp_instance.container.addClass( 'width-' + ( Math.round( 100 / _activeSkopeNum ) ) );
2201
- });
2202
- };
2203
- api.czr_skope.each( function( _skp_instance ) {
2204
- if ( _.isUndefined( _.findWhere( _new_collection, { id : _skp_instance().id } ) ) ) {
2205
- _skp_instance.visible( false );
2206
- _skp_instance.isReady.then( function() {
2207
- _skp_instance.container.toggleClass( 'active-collection', false );
2208
- });
2209
- }
2210
- else {
2211
- _skp_instance.visible( true );
2212
- var _activeSkpDomPostProcess = function() {
2213
- _setLayoutClass( _skp_instance );
2214
- _skp_instance.container.toggleClass( 'active-collection', true );
2215
- };
2216
- if ( 'pending' == _skp_instance.isReady.state() ) {
2217
- _skp_instance.isReady.then( function() {
2218
- _activeSkpDomPostProcess();
2219
- });
2220
- } else {
2221
- _activeSkpDomPostProcess();
2222
- }
2223
- }
2224
- } );
2225
- };
2226
- self.skopeWrapperEmbedded.then( function() {
2227
- _setActiveAndLayout();
2228
- });
2229
- if ( _.isEmpty( from ) && ! _.isEmpty( to ) )
2230
- api.czr_initialSkopeCollectionPopulated.resolve();
2231
- self.maybeSynchronizeGlobalSkope();
2232
-
2233
- return dfd.resolve( 'changed' ).promise();
2234
- },//listenToSkopeCollection()
2235
- maybeSynchronizeGlobalSkope : function( args ) {
2236
- args = args || {};
2237
- if ( ! _.isObject( args ) ) {
2238
- throw new Error('maybeSynchronizeGlobalSkope : args must be an object');
2239
- }
2240
- var self = this,
2241
- dfd = $.Deferred(),
2242
- defaults = _.extend({
2243
- isGlobalReset : false,
2244
- isSetting : false,
2245
- settingIdToReset : '',
2246
- isSkope : false,
2247
- skopeIdToReset : ''
2248
- },
2249
- args
2250
- ),
2251
- _setIdToReset,
2252
- shortSetId,
2253
- defaultVal;
2254
-
2255
- if ( self.isGlobalSkopeRegistered() ) {
2256
- var _global_skp_db_values = api.czr_skope( self.getGlobalSkopeId() ).dbValues();
2257
- _.each( _global_skp_db_values, function( _val, setId ){
2258
- if ( api.has( setId ) && ! _.isEqual( api.settings.settings[setId].value, _val ) ) {
2259
- api.settings.settings[setId].value = _val;
2260
- }
2261
- });
2262
- if ( args.isGlobalReset && args.isSetting ) {
2263
- _setIdToReset = args.settingIdToReset;
2264
- shortSetId = api.CZR_Helpers.getOptionName( _setIdToReset );
2265
- defaultVal = serverControlParams.defaultOptionsValues[ shortSetId ];
2266
-
2267
- if ( _.isUndefined( api.settings.settings[ _setIdToReset ] ) || _.isUndefined( defaultVal ) )
2268
- return;
2269
- if ( defaultVal != api.settings.settings[ _setIdToReset ].value ) {
2270
- api.settings.settings[ _setIdToReset ].value = defaultVal;
2271
- }
2272
- }
2273
- if ( args.isGlobalReset && args.isSkope ) {
2274
- _.each( api.settings.settings, function( _params, _setId ) {
2275
- if ( ! self.isThemeSetting( _setId ) )
2276
- return;
2277
-
2278
- shortSetId = api.CZR_Helpers.getOptionName( _setId );
2279
- if ( ! _.has( serverControlParams.defaultOptionsValues, shortSetId ) )
2280
- return;
2281
- api.settings.settings[_setId].value = serverControlParams.defaultOptionsValues[ shortSetId ];
2282
- });
2283
- }
2284
- }
2285
- return dfd.resolve().promise();
2286
- }
2287
- });//$.extend
2288
- })( wp.customize , jQuery, _ );
2289
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
2290
- ( function ( api, $, _ ) {
2291
- $.extend( CZRSkopeBaseMths, {
2292
- activeSkopeReact : function( to, from ) {
2293
- var self = this, dfd = $.Deferred();
2294
- if ( ! _.isUndefined(from) && api.czr_skope.has(from) )
2295
- api.czr_skope(from).active(false);
2296
- else if ( ! _.isUndefined( from ) )
2297
- throw new Error('listenToActiveSkope : previous scope does not exist in the collection', from );
2298
-
2299
- if ( ! _.isUndefined(to) && api.czr_skope.has(to) )
2300
- api.czr_skope(to).active(true);
2301
- else
2302
- throw new Error('listenToActiveSkope : requested scope ' + to + ' does not exist in the collection');
2303
- var _switchBack = function( _title ) {
2304
- api.czr_activeSkopeId( self.getGlobalSkopeId() );
2305
- api.czr_serverNotification({
2306
- status:'success',
2307
- message : [ _title , 'can only be customized sitewide.' ].join(' ')
2308
- });
2309
- return dfd.resolve().promise();
2310
- };
2311
- if ( self.isExcludedSidebarsWidgets() && 'widgets' == api.czr_activePanelId() && to != self.getGlobalSkopeId() ) {
2312
- api.czr_serverNotification({
2313
- status:'success',
2314
- message : [
2315
- serverControlParams.i18n.skope['Widgets are created sitewide.']
2316
- ].join(' ')
2317
- });
2318
- }
2319
- if ( self.isExcludedWPCustomCss() && 'custom_css' == api.czr_activeSectionId() && to != self.getGlobalSkopeId() ) {
2320
- return _switchBack( api.section( api.czr_activeSectionId() ).params.title );
2321
- }
2322
- if ( 'admin_sec' == api.czr_activeSectionId() && to != self.getGlobalSkopeId() ) {
2323
- return _switchBack( api.section( api.czr_activeSectionId() ).params.title );
2324
- }
2325
- if ( ( 'nav_menu' == api.czr_activeSectionId().substring( 0, 'nav_menu'.length ) || 'add_menu' == api.czr_activeSectionId() ) && to != self.getGlobalSkopeId() ) {
2326
- api.czr_serverNotification({
2327
- status:'success',
2328
- message : [
2329
- serverControlParams.i18n.skope['Menus are created sitewide.']
2330
- ].join(' ')
2331
- });
2332
- }
2333
- if ( 'nav_menus' == api.czr_activePanelId() ) {
2334
- _.each( api.panel( api.czr_activePanelId() ).sections(), function( _sec ) {
2335
- self.processSilentUpdates( { section_id : _sec.id, awake_if_not_active : true } );
2336
- });
2337
- }
2338
- api.state('switching-skope')( true );
2339
- self._writeCurrentSkopeTitle( to );
2340
- api.trigger( 'czr-paint', { is_skope_switch : true } );
2341
- if ( _.isUndefined( api.czr_activeSectionId() ) ) {
2342
- api.state('switching-skope')( false );
2343
- api.previewer.refresh();
2344
- return dfd.resolve().promise();
2345
- }
2346
- if ( _.has( api, 'czrModulePanelState') )
2347
- api.czrModulePanelState(false);
2348
- var _silentUpdateCands = self._getSilentUpdateCandidates();
2349
- if ( ! _.isUndefined( from ) ) {
2350
- _.each( api.czr_skope( from ).dirtyValues(), function( val, _setId ) {
2351
- if ( ! _.contains( _silentUpdateCands, _setId ) )
2352
- _silentUpdateCands.push( _setId );
2353
- } );
2354
- }
2355
- if ( ! _.isUndefined( to ) ) {
2356
- _.each( api.czr_skope( to ).dirtyValues(), function( val, _setId ) {
2357
- if ( ! _.contains( _silentUpdateCands, _setId ) )
2358
- _silentUpdateCands.push( _setId );
2359
- } );
2360
- }
2361
- var _debouncedProcessSilentUpdates = function() {
2362
- self.processSilentUpdates( {
2363
- candidates : _silentUpdateCands,
2364
- section_id : null,
2365
- refresh : false//will be done on done()
2366
- })
2367
- .fail( function() {
2368
- dfd.reject();
2369
- api.state('switching-skope')( false );
2370
- throw new Error( 'Fail to process silent updates in _debouncedProcessSilentUpdates');
2371
- })
2372
- .done( function( _updatedSetIds ) {
2373
- api.previewer.refresh()
2374
- .always( function() {
2375
- dfd.resolve( _updatedSetIds );
2376
- api.state( 'switching-skope' )( false );
2377
- });
2378
- });
2379
- };
2380
- if ( _.has(api, 'czr_isModuleExpanded') && false !== api.czr_isModuleExpanded() ) {
2381
- api.czr_isModuleExpanded().setupModuleViewStateListeners(false);
2382
- _debouncedProcessSilentUpdates = _.debounce( _debouncedProcessSilentUpdates, 400 );
2383
- _debouncedProcessSilentUpdates();
2384
- } else {
2385
- _debouncedProcessSilentUpdates();
2386
- }
2387
- return dfd.promise();
2388
- },//activeSkopeReact
2389
- _writeCurrentSkopeTitle : function( skope_id ) {
2390
- var self = this,
2391
- current_title = api.czr_skope( skope_id || api.czr_activeSkopeId() )().long_title,
2392
- _buildTitleHtml = function() {
2393
- var _inheritedFrom = self.getInheritedSkopeTitles(),
2394
- _overrides = self.getOverridenSkopeTitles();
2395
-
2396
- return $.trim( [
2397
- '<span class="czr-main-title"><span class="czr-toggle-title-notice fa fa-info-circle"></span>',
2398
- 'global' == api.czr_skope( skope_id || api.czr_activeSkopeId() )().skope ? current_title : ['Customizing', current_title ].join(' '),
2399
- '</span>',
2400
- '<span class="czr-skope-inherits-from">',
2401
- serverControlParams.i18n.skope['In this context :'],
2402
- _.isEmpty( _inheritedFrom ) ? ' ' : serverControlParams.i18n.skope['inherits from'],
2403
- _inheritedFrom,
2404
- _.isEmpty( _inheritedFrom ) ? '' : _.isEmpty( _overrides ) ? '.' : [',' , serverControlParams.i18n.skope['and'] ].join(' '),
2405
- _.isEmpty( _overrides ) ? ' ' : serverControlParams.i18n.skope['overridden by'],
2406
- _overrides,
2407
- _.isEmpty( _overrides ) ? '' : '.',
2408
- '</span>'
2409
- ].join(' ') );
2410
- },
2411
- _toggle_spinner = function( visible ) {
2412
- if ( visible ) {
2413
- $('.czr-scope-switcher').find('.spinner').fadeIn();
2414
- } else {
2415
- $('.czr-scope-switcher').find('.spinner').fadeOut();
2416
- }
2417
- };
2418
- self.skopeWrapperEmbedded
2419
- .then( function() {
2420
- if ( ! $('.czr-scope-switcher').find('.czr-current-skope-title').length ) {
2421
- $('.czr-scope-switcher').prepend(
2422
- $( '<h2/>', {
2423
- class : 'czr-current-skope-title',
2424
- html : [
2425
- '<span class="czr-skope-title">',
2426
- '<span class="spinner">',
2427
- _buildTitleHtml(),
2428
- '</span>',
2429
- '</span>'
2430
- ].join('')
2431
- })
2432
- );
2433
- } else {
2434
- $.when( $('.czr-scope-switcher').find('.czr-skope-title').fadeOut(200) ).done( function() {
2435
- $(this)
2436
- .html( _buildTitleHtml() )
2437
- .fadeIn(200);
2438
- });
2439
- }
2440
-
2441
- if ( _.isUndefined( api.state( 'switching-skope' ).isBound ) ) {
2442
- api.state('switching-skope').bind( _toggle_spinner );
2443
- api.state( 'switching-skope' ).isBound = true;
2444
- }
2445
- });
2446
- }//_writeCurrentSkopeTitle
2447
- });//$.extend
2448
- })( wp.customize , jQuery, _ );
2449
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
2450
- ( function ( api, $, _ ) {
2451
- $.extend( CZRSkopeBaseMths, {
2452
- processSilentUpdates : function( params ) {
2453
- if ( _.isString( params ) )
2454
- params = { candidates : [ params ] };
2455
- else
2456
- params = params || {};
2457
-
2458
- var self = this,
2459
- defaultParams = {
2460
- candidates : [],
2461
- section_id : api.czr_activeSectionId(),
2462
- refresh : true,
2463
- awake_if_not_active : false
2464
- },
2465
- dfd = $.Deferred();
2466
-
2467
- params = $.extend( defaultParams, params );
2468
- if ( _.isString( params.candidates ) ) {
2469
- params.candidates = [ params.candidates ];
2470
- }
2471
- if ( _.isEmpty( params.candidates ) )
2472
- params.candidates = self._getSilentUpdateCandidates( params.section_id, params.awake_if_not_active );
2473
- if ( ! _.isArray( params.candidates ) ) {
2474
- throw new Error('processSilentUpdates : the update candidates must be an array.');
2475
- }
2476
- if ( _.isEmpty( params.candidates ) )
2477
- return dfd.resolve( [] ).promise();
2478
-
2479
-
2480
- var _enjoyTheSilence = function() {
2481
- self.silentlyUpdateSettings( params.candidates, params.refresh )
2482
- .fail( function() {
2483
- dfd.reject();
2484
- })
2485
- .done( function( updated_settings ) {
2486
- _.delay( function() {
2487
- self.setupActiveSkopedControls( {
2488
- section_id : params.section_id
2489
- });
2490
- }, 1000 );
2491
- dfd.resolve( updated_settings );
2492
- });
2493
- };
2494
- if ( 'resolved' != api.czr_skopeReady.state() ) {
2495
- dfd.resolve( [] );
2496
- api.czr_skopeReady.done( function() {
2497
- _enjoyTheSilence();
2498
- });
2499
- } else {
2500
- _enjoyTheSilence();
2501
- }
2502
-
2503
- return dfd.promise();
2504
- },
2505
-
2506
-
2507
-
2508
-
2509
- /*****************************************************************************
2510
- * UPDATE SETTING VALUES
2511
- *****************************************************************************/
2512
- silentlyUpdateSettings : function( _silentUpdateCands, refresh ) {
2513
- if ( ! api.state.has( 'silent-update-processing') )
2514
- api.state.create( 'silent-update-processing' )( false );
2515
-
2516
- api.state( 'silent-update-processing' )(true);
2517
- var self = this,
2518
- _silentUpdatePromises = {},
2519
- dfd = $.Deferred();
2520
-
2521
- refresh = _.isUndefined( refresh ) ? true : refresh;
2522
-
2523
- if ( _.isUndefined( _silentUpdateCands ) || _.isEmpty( _silentUpdateCands ) ) {
2524
- _silentUpdateCands = self._getSilentUpdateCandidates();
2525
- }
2526
-
2527
- if ( _.isString( _silentUpdateCands ) ) {
2528
- _silentUpdateCands = [ _silentUpdateCands ];
2529
- }
2530
- _.each( _silentUpdateCands, function( setId ) {
2531
- if ( api.control.has( setId ) && 'czr_multi_module' == api.control(setId).params.type )
2532
- return;
2533
- _silentUpdatePromises[setId] = self.getSettingUpdatePromise( setId );
2534
- });
2535
-
2536
-
2537
- var _deferred = [],
2538
- _updatedSetIds = [];
2539
- _.each( _silentUpdatePromises, function( _promise_ , setId ) {
2540
- _promise_.done( function( _new_setting_val_ ) {
2541
- var wpSetId = api.CZR_Helpers.build_setId( setId ),
2542
- _skopeDirtyness = api.czr_skope( api.czr_activeSkopeId() ).getSkopeSettingDirtyness( setId );
2543
- if ( ! _.isEqual( api( wpSetId )(), _new_setting_val_ ) ) {
2544
- _updatedSetIds.push( setId );
2545
- }
2546
- api( wpSetId ).silent_set( _new_setting_val_ , _skopeDirtyness );
2547
- });
2548
-
2549
- _deferred.push( _promise_ );
2550
- });
2551
- $.when.apply( null, _deferred )
2552
- .fail( function() {
2553
- dfd.reject();
2554
- throw new Error( 'silentlyUpdateSettings FAILED. Candidates : ' + _silentUpdateCands );
2555
- })
2556
- .always( function() {
2557
- api.state( 'silent-update-processing' )( false );
2558
- })
2559
- .then( function() {
2560
- _.each( _deferred, function( prom ){
2561
- if ( _.isObject( prom ) && 'resolved' !== prom.state() ) {
2562
- throw new Error( 'a silent update promise is unresolved : ' + _silentUpdateCands );
2563
- }
2564
- });
2565
- if ( refresh && ! _.isEmpty( _updatedSetIds ) ) {
2566
- api.previewer.refresh()
2567
- .always( function() {
2568
- dfd.resolve( _updatedSetIds );
2569
- });
2570
- } else {
2571
- dfd.resolve( _updatedSetIds );
2572
- }
2573
- });
2574
- return dfd.promise();
2575
- },
2576
- getSettingUpdatePromise : function( setId ) {
2577
- if ( _.isUndefined( setId ) ) {
2578
- throw new Error('getSettingUpdatePromise : the provided setId is not defined');
2579
- }
2580
- if ( ! api.has( api.CZR_Helpers.build_setId( setId ) ) ) {
2581
- throw new Error('getSettingUpdatePromise : the provided wpSetId is not registered : ' + api.CZR_Helpers.build_setId( setId ) );
2582
- }
2583
-
2584
- var self = this,
2585
- wpSetId = api.CZR_Helpers.build_setId( setId ),
2586
- current_setting_val = api( wpSetId )(),//typically the previous skope val
2587
- dfd = $.Deferred(),
2588
- _promise = false,
2589
- skope_id = api.czr_activeSkopeId(),
2590
- val = api.czr_skopeBase.getSkopeSettingVal( setId, skope_id );
2591
- if ( _.isEqual( current_setting_val, val ) ) {
2592
- return dfd.resolve( val ).promise();
2593
- }
2594
- if ( api.control.has( wpSetId ) ) {
2595
- var control_type = api.control( wpSetId ).params.type,
2596
- _control_data = api.settings.controls[wpSetId],
2597
- _constructor;
2598
-
2599
- switch ( control_type ) {
2600
- case 'czr_cropped_image' :
2601
- _promise = self._getCzrCroppedImagePromise( wpSetId, _control_data );
2602
- break;
2603
-
2604
- case 'czr_module' :
2605
- self._processCzrModuleSilentActions( wpSetId, control_type, skope_id , _control_data);
2606
- break;
2607
- }//switch
2608
- }//end if api.control.has( wpSetId )
2609
- if ( _.has(api.settings.controls, 'header_image') && 'header_image' == wpSetId ) {
2610
- _promise = self._getHeaderImagePromise( wpSetId, skope_id );
2611
- }
2612
- if ( ! _promise || ! _.isObject( _promise ) ) {
2613
- dfd.resolve( val );
2614
- } else {
2615
- _promise.always( function() {
2616
- dfd.resolve( val );
2617
- });
2618
- }
2619
-
2620
- return dfd.promise();
2621
- },//getSettingUpdatePromise()
2622
-
2623
-
2624
-
2625
-
2626
- /*****************************************************************************
2627
- * GET SILENT UPDATE CANDIDATE FROM A SECTION. FALLS BACK ON THE CURRENT ONE
2628
- *****************************************************************************/
2629
- _getSilentUpdateCandidates : function( section_id, awake_if_not_active ) {
2630
- var self = this,
2631
- SilentUpdateCands = [];
2632
- section_id = ( _.isUndefined( section_id ) || _.isNull( section_id ) ) ? api.czr_activeSectionId() : section_id;
2633
- if ( _.isEmpty( api.czr_activeSectionId() ) && ! awake_if_not_active ) {
2634
- return [];
2635
- }
2636
- if ( _.isUndefined( section_id ) ) {
2637
- api.consoleLog( '_getSilentUpdateCandidates : No active section provided');
2638
- return [];
2639
- }
2640
- if ( ! api.section.has( section_id ) ) {
2641
- throw new Error( '_getSilentUpdateCandidates : The section ' + section_id + ' is not registered in the API.');
2642
- }
2643
- var section_settings = api.CZR_Helpers.getSectionSettingIds( section_id );
2644
- section_settings = _.filter( section_settings, function( setId ) {
2645
- return self.isSettingSkopeEligible( setId );
2646
- });
2647
- _.each( section_settings, function( setId ) {
2648
- SilentUpdateCands.push( setId );
2649
- });
2650
-
2651
- return SilentUpdateCands;
2652
- }
2653
-
2654
- });//$.extend
2655
- })( wp.customize , jQuery, _ );
2656
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
2657
- ( function ( api, $, _ ) {
2658
- $.extend( CZRSkopeBaseMths, {
2659
- /*****************************************************************************
2660
- * SILENT ACTIONS for czr_module_type on skope switch
2661
- * ?? @todo : can't we fire this earlier than in getPromises ?
2662
- *****************************************************************************/
2663
- _processCzrModuleSilentActions : function( wpSetId, control_type, skope_id, _control_data) {
2664
- var _synced_control_id, _synced_control_val, _synced_control_data, _synced_control_constructor, _syncSektionModuleId,
2665
- _synced_short_id = _.has( api.control( wpSetId ).params, 'syncCollection' ) ? api.control( wpSetId ).params.syncCollection : '',
2666
- _shortSetId = api.CZR_Helpers.build_setId(wpSetId),
2667
- _val = api.czr_skopeBase.getSkopeSettingVal( _shortSetId, skope_id ),
2668
- current_skope_instance = api.czr_skope( api.czr_activeSkopeId() );
2669
- if ( ! _.isEmpty( _synced_short_id ) && ! _.isUndefined( _synced_short_id ) ) {
2670
- _synced_control_id = api.CZR_Helpers.build_setId( _synced_short_id );
2671
- _synced_control_val = api.czr_skopeBase.getSkopeSettingVal( _synced_control_id, skope_id );
2672
- _synced_control_data = api.settings.controls[_synced_control_id];
2673
- _synced_control_constructor = api.controlConstructor.czr_multi_module;
2674
- _syncSektionModuleId = api.control( _synced_control_id ).syncSektionModule()().id;
2675
- api.control( _synced_control_id ).container.remove();
2676
- api.control.remove(_synced_control_id );
2677
- api( _synced_control_id ).silent_set( _synced_control_val, current_skope_instance.getSkopeSettingDirtyness( _synced_control_id ) );
2678
- $.extend( _synced_control_data, { czr_skope : skope_id });
2679
- api.control.add( _synced_control_id, new _synced_control_constructor( _synced_control_id, { params : _synced_control_data, previewer : api.previewer }) );
2680
- }
2681
-
2682
- _constructor = api.controlConstructor[control_type];
2683
- api.control( wpSetId ).container.remove();
2684
- api.control.remove( wpSetId );
2685
- api( wpSetId ).silent_set( _val, current_skope_instance.getSkopeSettingDirtyness( _shortSetId ) );
2686
- $.extend( _control_data, { czr_skope : skope_id });
2687
- api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
2688
- if ( ! _.isEmpty( _synced_short_id ) && ! _.isUndefined( _synced_short_id ) ) {
2689
- api.consoleLog('FIRE SEKTION MODULE?', _syncSektionModuleId, api.control( wpSetId ).czr_Module( _syncSektionModuleId ).isReady.state() );
2690
- api.control( wpSetId ).czr_Module( _syncSektionModuleId ).fireSektionModule();
2691
- }
2692
- },
2693
-
2694
-
2695
-
2696
-
2697
-
2698
- /*****************************************************************************
2699
- * GET PROMISE FOR TYPE : czr_cropped_image
2700
- *****************************************************************************/
2701
- _getCzrCroppedImagePromise : function( wpSetId, _control_data ) {
2702
- var _constructor = api.controlConstructor.czr_cropped_image, dfd = $.Deferred(),
2703
- val = api.has(wpSetId) ? api(wpSetId)() : null;
2704
- val = null === val ? "" : val;
2705
- wp.media.attachment( val ).fetch().done( function() {
2706
- api.control( wpSetId ).container.remove();
2707
- api.control.remove( wpSetId );
2708
- _control_data.attachment = this.attributes;
2709
- api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
2710
- dfd.resolve();
2711
- } ).fail( function() {
2712
- api.control( wpSetId ).container.remove();
2713
- api.control.remove( wpSetId );
2714
- _control_data = _.omit( _control_data, 'attachment' );
2715
- api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
2716
- dfd.reject();
2717
- });
2718
- return dfd.promise();
2719
- },
2720
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2721
 
 
 
 
 
 
 
 
2722
 
2723
- /*****************************************************************************
2724
- * HEADER IMAGE PROMISE
2725
- *****************************************************************************/
2726
- _getHeaderImagePromise : function( wpSetId, skope_id ) {
2727
- var dfd = $.Deferred();
2728
- if ( ! _.has(api.settings.controls, 'header_image') || 'header_image' != wpSetId ) {
2729
- return dfd.resolve().promise();
2730
- }
2731
 
2732
- var _header_constructor = api.controlConstructor.header,
2733
- _header_control_data = $.extend( true, {}, api.settings.controls.header_image );
2734
- header_image_data = null === api.czr_skopeBase.getSkopeSettingVal( 'header_image_data', skope_id ) ? "" : api.czr_skopeBase.getSkopeSettingVal( 'header_image_data', skope_id );
 
 
 
 
 
 
 
 
2735
 
2736
- var attachment_id;
2737
- var _reset_header_image_crtl = function( _updated_header_control_data ) {
2738
- _updated_header_control_data = _updated_header_control_data || _header_control_data;
2739
- api.control( 'header_image' ).container.remove();
2740
- api.control.remove( 'header_image' );
2741
- api.HeaderTool.UploadsList = api.czr_HeaderTool.UploadsList;
2742
- api.HeaderTool.DefaultsList = api.czr_HeaderTool.DefaultsList;
2743
- api.HeaderTool.CombinedList = api.czr_HeaderTool.CombinedList;
2744
- var _render_control = function() {
2745
- api.control.add( 'header_image', new _header_constructor( 'header_image', { params : _updated_header_control_data, previewer : api.previewer }) );
2746
- };
2747
- _render_control = _.debounce( _render_control, 800 );
2748
- _render_control();
2749
- };
 
 
 
 
 
2750
 
 
 
 
 
 
 
 
2751
 
2752
- if ( ! _.has( header_image_data, 'attachment_id' ) ) {
2753
- _reset_header_image_crtl();
2754
- dfd.resolve();
2755
- } else {
2756
- attachment_id = header_image_data.attachment_id;
2757
- wp.media.attachment( attachment_id ).fetch().done( function() {
2758
- _header_control_data.attachment = this.attributes;
2759
- _reset_header_image_crtl( _header_control_data );
2760
- dfd.resolve();
2761
- } ).fail( function() {
2762
- _header_control_data = _.omit( _header_control_data, 'attachment' );
2763
- api.control( 'header_image' ).container.remove();
2764
- api.control.remove( 'header_image' );
2765
- api.HeaderTool.UploadsList = api.czr_HeaderTool.UploadsList;
2766
- api.HeaderTool.DefaultsList = api.czr_HeaderTool.DefaultsList;
2767
- api.HeaderTool.CombinedList = api.czr_HeaderTool.CombinedList;
2768
- api.control.add( 'header_image', new _header_constructor( 'header_image', { params : _header_control_data, previewer : api.previewer }) );
2769
- dfd.reject();
2770
- });
2771
- }//else
2772
- return dfd.promise();
2773
- }
2774
  });//$.extend
2775
  })( wp.customize , jQuery, _ );
2776
-
2777
- /*****************************************************************************
2778
- * THE SKOPE BASE OBJECT
2779
- *****************************************************************************/
2780
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
2781
  ( function ( api, $, _ ) {
2782
- $.extend( CZRSkopeBaseMths, {
2783
- /*****************************************************************************
2784
- * SETUP CONTROL RESET ON SECTION EXPANSION + SKOPE SWITCH
2785
- *****************************************************************************/
2786
- setupActiveSkopedControls : function( obj ) {
2787
- var self = this, section_id, controls, setupParams, eligibleCtrls, dfd = $.Deferred();
2788
- defaultSetupParams = {
2789
- controls : [],
2790
- section_id : api.czr_activeSectionId()
2791
- };
2792
- setupParams = $.extend( defaultSetupParams, obj );
2793
-
2794
- if ( ! _.isObject( setupParams ) || ! _.has( setupParams, 'controls' ) || ! _.has( setupParams, 'section_id' ) ) {
2795
- throw new Error( 'setupActiveSkopedControls : the setupParams param must be an object with properties controls and section_id.');
2796
- }
2797
-
2798
- section_id = setupParams.section_id;
2799
- controls = setupParams.controls;
2800
- eligibleCtrls = [];
2801
-
2802
- if ( _.isEmpty( section_id ) || ! _.isString( section_id ) ) {
2803
- section_id = api.czr_activeSectionId();
2804
- }
2805
- if ( _.isEmpty( controls ) ) {
2806
- controls = api.CZR_Helpers.getSectionControlIds( section_id );
2807
- }
2808
 
2809
- controls = _.isString( controls ) ? [controls] : controls;
2810
- eligibleCtrls = _.filter( controls, function( ctrlId ) {
2811
- var setId = api.CZR_Helpers.getControlSettingId( ctrlId );
2812
- if ( setId && ! self.isSettingSkopeEligible( setId ) ) {
2813
- api.control( ctrlId ).container.addClass('czr-not-skoped');
2814
- }
2815
- if ( setId && self.isWPAuthorizedSetting( setId ) ) {
2816
- api.control( ctrlId ).container.addClass('is-wp-authorized-setting');
2817
- }
2818
- return setId && self.isSettingSkopeEligible( setId );
2819
- });
2820
- if ( 'nav_menu[' == section_id.substring( 0, 'nav_menu['.length ) )
2821
- return dfd.resolve().promise();
2822
- if ( ! _.isEmpty( controls ) ) {
2823
- api.czr_skopeReady.then( function() {
2824
- $.when( self.renderControlsSingleReset( eligibleCtrls ) ).done( function() {
2825
- _.each( controls, function( ctrlId ) {
2826
- self.listenSkopedControl( ctrlId );
2827
- } );
2828
- dfd.resolve();
2829
- });
2830
- });
2831
- if ( 'rejected' == api.czr_skopeReady.state() )
2832
- dfd.resolve();
2833
- }
2834
- self.renderCtrlSkpNotIcon( controls );
2835
- return dfd.promise();
2836
- },//setupActiveSkopedControls
2837
- listenSkopedControl : function( ctrlId ) {
2838
- var self = this;
2839
 
2840
- if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
2841
- return;
 
 
 
 
 
 
 
 
 
 
2842
 
2843
- var ctrl = api.control( ctrlId ),
2844
- setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
2845
- shortSetId = api.CZR_Helpers.getOptionName( setId ),
2846
- defaults = {
2847
- hasDBVal : false,
2848
- isDirty : false,
2849
- noticeVisible : false,
2850
- resetVisible : false,
2851
- isResetting : false
2852
- },
2853
- initial_states = {};
2854
- if ( ! _.has( ctrl, 'czr_states' ) ) {
2855
- ctrl.czr_states = new api.Values();
2856
- _.each( defaults, function( _state_val, _state_name ) {
2857
- ctrl.czr_states.create( _state_name );
2858
- ctrl.czr_states( _state_name )( _state_val );
2859
- });
2860
- try { self.bindControlStates( ctrl ); } catch( er ) {
2861
- api.errorLog( 'bindControlStates : ' + er );
2862
- }
2863
- }
2864
- ctrl.czr_states( 'hasDBVal' )( api.czr_skope( api.czr_activeSkopeId() ).hasSkopeSettingDBValues( setId ) );
2865
- ctrl.czr_states( 'isDirty' )( api.czr_skope( api.czr_activeSkopeId() ).getSkopeSettingDirtyness( setId ) );
2866
 
 
 
 
 
 
 
2867
 
2868
- if ( ! _.has( ctrl, 'userEventMap' ) ) {
2869
- ctrl.userEventMap = [
2870
- {
2871
- trigger : 'click keydown',
2872
- selector : '.czr-setting-reset, .czr-cancel-button',
2873
- name : 'control_reset_warning',
2874
- actions : function() {
2875
- if ( ! ctrl.czr_states('isDirty')() && ! ctrl.czr_states( 'hasDBVal' )() )
2876
- return;
2877
- _.each( _.without( api.CZR_Helpers.getSectionControlIds( ctrl.section() ), ctrlId ) , function( _id ) {
2878
- if ( _.has( api.control(_id), 'czr_states') ) {
2879
- api.control(_id).czr_states( 'resetVisible' )( false );
2880
- }
2881
- });
2882
- ctrl.czr_states( 'resetVisible' )( ! ctrl.czr_states( 'resetVisible' )() );
2883
- ctrl.czr_states( 'noticeVisible' )( ! ctrl.czr_states( 'resetVisible' )() );
2884
- }
2885
- },
2886
- {
2887
- trigger : 'click keydown',
2888
- selector : '.czr-control-do-reset',
2889
- name : 'control_do_reset',
2890
- actions : function() {
2891
- self.doResetSetting( ctrlId );
2892
- }
2893
- },
2894
- {
2895
- trigger : 'click keydown',
2896
- selector : '.czr-skope-switch',
2897
- name : 'control_skope_switch',
2898
- actions : function( params ) {
2899
- var _skopeIdToSwithTo = $( params.dom_event.currentTarget, params.dom_el ).attr('data-skope-id');
2900
- if ( ! _.isEmpty( _skopeIdToSwithTo ) && api.czr_skope.has( _skopeIdToSwithTo ) )
2901
- api.czr_activeSkopeId( _skopeIdToSwithTo );
2902
- }
2903
- },
2904
- {
2905
- trigger : 'click keydown',
2906
- selector : '.czr-toggle-notice',
2907
- name : 'control_toggle_notice',
2908
- actions : function( params ) {
2909
- ctrl.czr_states( 'noticeVisible' )( ! ctrl.czr_states( 'noticeVisible' )() );
2910
- if ( ctrl.czr_states( 'noticeVisible' )() ) {
2911
- ctrl.czr_states( 'resetVisible' )( false );
2912
- }
2913
- }
2914
- }
2915
- ];
2916
- api.CZR_Helpers.setupDOMListeners( ctrl.userEventMap , { dom_el : ctrl.container }, self );
2917
- }
2918
- },
2919
- bindControlStates : function( ctrl ) {
2920
- if ( ! api.control.has( ctrl.id ) ) {
2921
- throw new Error( 'in bindControlStates, the provided ctrl id is not registered in the api : ' + ctrl.id );
2922
- }
2923
- var self = this,
2924
- setId = api.CZR_Helpers.getControlSettingId( ctrl.id );
2925
- ctrl.czr_states( 'hasDBVal' ).bind( function( bool ) {
2926
- ctrl.container.toggleClass( 'has-db-val', bool );
2927
- if ( bool ) {
2928
- _title = serverControlParams.i18n.skope['Reset your customized ( and published ) value'];
2929
- } else if ( ctrl.czr_states('isDirty')() ) {
2930
- _title = serverControlParams.i18n.skope['Reset your customized ( but not yet published ) value'];
2931
- } else {
2932
- _title = serverControlParams.i18n.skope['Not customized yet, nothing to reset'];
2933
- }
2934
- ctrl.container.find('.czr-setting-reset').attr( 'title', _title );
2935
- });
2936
- ctrl.czr_states( 'isDirty' ).bind( function( bool ) {
2937
- ctrl.container.toggleClass( 'is-dirty', bool );
2938
- var _title;
2939
- if ( bool ) {
2940
- _title = serverControlParams.i18n.skope['Reset your customized ( but not yet published ) value'];
2941
- } else if ( ctrl.czr_states('hasDBVal')() ) {
2942
- _title = serverControlParams.i18n.skope['Reset your customized ( and published ) value'];
2943
- } else {
2944
- _title = serverControlParams.i18n.skope['Not customized yet, nothing to reset'];
2945
- }
2946
- ctrl.container.find('.czr-setting-reset').attr( 'title', _title );
2947
- });
2948
- ctrl.czr_states( 'noticeVisible' ).bind( function( visible ) {
2949
- ctrl.container.toggleClass( 'czr-notice-visible', visible );
2950
- var $noticeContainer = ctrl.getNotificationsContainerElement();
2951
- if ( false !== $noticeContainer && false !== $noticeContainer.length ) {
2952
- if ( ! visible ) {
2953
- $.when( $noticeContainer
2954
- .stop()
2955
- .slideUp( 'fast', null, function() {
2956
- $( this ).css( 'height', 'auto' );
2957
- } ) ).done( function() {
2958
- self.removeCtrlSkpNot( ctrl.id );
2959
- });
2960
- } else {
2961
- self.updateCtrlSkpNot( ctrl.id, true );//<= True for visible
2962
- $noticeContainer
2963
- .stop()
2964
- .slideDown( 'fast', null, function() {
2965
- $( this ).css( 'height', 'auto' );
2966
- } );
2967
- }
2968
- }
2969
- });
2970
- ctrl.czr_states( 'resetVisible' ).bind( function( visible ) {
2971
- var section_id = ctrl.section() || api.czr_activeSectionId();
2972
- if ( visible ) {
2973
- $.when( self.renderControlResetWarningTmpl( ctrl.id ) ).done( function( _params ) {
2974
- if ( _.isEmpty( _params ) )
2975
  return;
2976
- ctrl.czr_resetDialogContainer = _params.container;
2977
- _params.container.slideToggle('fast');
2978
- if ( ! _params.is_authorized ) {
2979
- _.delay( function() {
2980
- $.when( ctrl.czr_resetDialogContainer.slideToggle('fast') ).done( function() {
2981
- ctrl.czr_resetDialogContainer.remove();
2982
- });
2983
- }, 3000 );
2984
- }
2985
- });
2986
- } else {
2987
- if ( _.has( ctrl, 'czr_resetDialogContainer' ) && ctrl.czr_resetDialogContainer.length )
2988
- $.when( ctrl.czr_resetDialogContainer.slideToggle('fast') ).done( function() {
2989
- ctrl.czr_resetDialogContainer.remove();
2990
- });
2991
- }
2992
- });
2993
- }
2994
- });//$.extend()
2995
- })( wp.customize , jQuery, _ );
2996
 
2997
- /*****************************************************************************
2998
- * THE SKOPE BASE OBJECT
2999
- *****************************************************************************/
3000
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
3001
- ( function ( api, $, _ ) {
3002
- $.extend( CZRSkopeBaseMths, {
3003
- renderControlsSingleReset : function( controls ) {
3004
- var self = this, dfd = $.Deferred();
3005
- if ( _.isUndefined( controls ) || _.isEmpty( controls ) ) {
3006
- controls = api.CZR_Helpers.getSectionControlIds( api.czr_activeSectionId() );
3007
- controls = _.filter( controls, function( _id ) {
3008
- var setId = api.CZR_Helpers.getControlSettingId( _id );
3009
- return setId && self.isSettingSkopeEligible( setId );
3010
- });
3011
- }
 
 
3012
 
3013
- var controlIds = _.isArray(controls) ? controls : [controls],
3014
- render_reset_icons = function( ctrlIds ) {
3015
- if ( _.isEmpty( ctrlIds ) ) {
3016
- dfd.resolve();
3017
- return;
3018
- }
3019
- _.each( ctrlIds, function( _id ) {
3020
- api.control.when( _id, function() {
3021
- var ctrl = api.control( _id ),
3022
- setId = api.CZR_Helpers.getControlSettingId( _id );
 
3023
 
3024
- if( $('.czr-setting-reset', ctrl.container ).length ) {
3025
- dfd.resolve();
3026
- return;
3027
- }
 
3028
 
3029
- ctrl.deferred.embedded.then( function() {
3030
- $.when(
3031
- ctrl.container
3032
- .find('.customize-control-title').first()//was.find('.customize-control-title')
3033
- .prepend( $( '<span/>', {
3034
- class : 'czr-setting-reset fa fa-refresh',
3035
- title : ''
3036
- } ) ) )
3037
- .done( function(){
3038
- ctrl.container.addClass('czr-skoped');
3039
- $('.czr-setting-reset', ctrl.container).fadeIn( 400 );
3040
- dfd.resolve();
3041
- });
3042
- });//then()
3043
- });//when()
3044
- });//_each
3045
- };
3046
- render_reset_icons = _.debounce( render_reset_icons , 200 );
3047
- render_reset_icons( controlIds );
3048
- return dfd.promise();
3049
- },
3050
- renderControlResetWarningTmpl : function( ctrlId ) {
3051
- if ( ! api.control.has( ctrlId ) )
3052
- return {};
3053
 
3054
- var self = this,
3055
- ctrl = api.control( ctrlId ),
3056
- setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
3057
- _tmpl = '',
3058
- warning_message,
3059
- success_message,
3060
- isWPSetting = ( function() {
3061
- if ( _.contains( serverControlParams.wpBuiltinSettings, api.CZR_Helpers.getOptionName( setId ) ) )
3062
- return true;
3063
- if ( ! _.contains( serverControlParams.themeSettingList, api.CZR_Helpers.getOptionName( setId ) ) )
3064
- return true;
3065
- return false;
3066
- })(),
3067
- _currentSkopeModel = api.czr_skope( api.czr_activeSkopeId() )();
3068
 
3069
- if ( ctrl.czr_states( 'isDirty' )() ) {
3070
- warning_message = [
3071
- 'global' == _currentSkopeModel.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'],
3072
- 'global' == _currentSkopeModel.skope ? serverControlParams.i18n.skope['sitewide'] : _currentSkopeModel.ctx_title
3073
- ].join(' ');
3074
- success_message = serverControlParams.i18n.skope['Your customizations have been reset'];
3075
- } else {
3076
- if ( isWPSetting && 'global' == _currentSkopeModel.skope ) {
3077
- warning_message = serverControlParams.i18n.skope['This WordPress setting can not be reset sitewide'];
3078
- } else {
3079
- warning_message = [
3080
- 'global' == _currentSkopeModel.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'],
3081
- 'global' == _currentSkopeModel.skope ? serverControlParams.i18n.skope['sitewide'] : _currentSkopeModel.ctx_title
3082
- ].join(' ');
3083
- success_message = serverControlParams.i18n.skope['The option has been reset'];
3084
- }
3085
- }
3086
- var is_authorized = ! ( isWPSetting && 'global' == api.czr_skope( api.czr_activeSkopeId() )().skope && ! ctrl.czr_states( 'isDirty' )() ),
3087
- _tmpl_data = {
3088
- warning_message : warning_message + '.',
3089
- success_message : success_message + '.',
3090
- is_authorized : is_authorized
3091
- };
3092
- try {
3093
- _tmpl = wp.template('czr-reset-control')( _tmpl_data );
3094
- } catch( er ) {
3095
- api.errorLog( 'Error when parsing the the reset control template : ' + er );
3096
- return { container : false, is_authorized : false };
3097
- }
3098
 
3099
- $('.customize-control-title', ctrl.container).first().after( $( _tmpl ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3100
 
3101
- return { container : $( '.czr-ctrl-reset-warning', ctrl.container ), is_authorized : is_authorized };
3102
- },
3103
- doResetSetting : function( ctrlId ) {
3104
- var self = this,
3105
- setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
3106
- ctrl = api.control( ctrlId ),
3107
- skope_id = api.czr_activeSkopeId(),
3108
- reset_method = ctrl.czr_states( 'isDirty' )() ? '_resetControlDirtyness' : '_resetControlAPIVal',
3109
- _setResetDialogVisibility = function() {
3110
- var ctrl = this;//<= fired with .call( ctrlInstance )
3111
- ctrl.czr_states( 'resetVisible' )( false );
3112
- ctrl.czr_states( 'isResetting' )( false);
3113
- ctrl.container.removeClass('czr-resetting-control');
3114
- },
3115
- _updateAPI = function( ctrlId ) {
3116
- var _silentUpdate = function() {
3117
- api.czr_skopeBase.processSilentUpdates( { candidates : ctrlId, refresh : false } )
3118
- .fail( function() { api.consoleLog( 'Silent update failed after resetting control : ' + ctrlId ); } )
3119
- .done( function() {
3120
- api.control.when( ctrlId, function() {
3121
- var ctrl = api.control( ctrlId );
3122
- $.when( $('.czr-crtl-reset-dialog', ctrl.container ).fadeOut('300') ).done( function() {
3123
- $.when( $('.czr-reset-success', ctrl.container ).fadeIn('300') ).done( function( $_el ) {
3124
- _.delay( function() {
3125
- $.when( $_el.fadeOut('300') ).done( function() {
3126
- self.setupActiveSkopedControls( { controls : [ ctrlId ] } ).done( function() {
3127
- if ( ctrl.czr_states ) {
3128
- _setResetDialogVisibility.call( ctrl );
3129
- ctrl.czr_states( 'noticeVisible' )( self.isCtrlNoticeVisible( ctrlId ) );
3130
- }
3131
- });
3132
- });
3133
- }, 500 );
3134
- });
3135
- });
3136
- });
3137
- });//done()
3138
- };//_silentUpdate
3139
- self[reset_method](ctrlId)
3140
- .done( function() {
3141
- api.consoleLog('REFRESH AFTER A SETTING RESET');
3142
- api.previewer.refresh()
3143
- .fail( function( refresh_data ) {
3144
- api.errorLog('Setting reset refresh failed.', refresh_data );
3145
- })
3146
- .done( function( refresh_data ) {
3147
- if ( 'global' == api.czr_skope( skope_id )().skope && '_resetControlAPIVal' == reset_method ) {
3148
- var _sentSkopeCollection,
3149
- _serverGlobalDbValues = {},
3150
- _skope_opt_name = api.czr_skope( skope_id )().opt_name;
3151
 
3152
- if ( ! _.isUndefined( refresh_data.skopesServerData ) && _.has( refresh_data.skopesServerData, 'czr_skopes' ) ) {
3153
- _sentSkopeCollection = refresh_data.skopesServerData.czr_skopes;
3154
- if ( _.isUndefined( _.findWhere( _sentSkopeCollection, { opt_name : _skope_opt_name } ) ) ) {
3155
- _serverGlobalDbValues = _.findWhere( _sentSkopeCollection, { opt_name : _skope_opt_name } ).db || {};
3156
- }
3157
- }
3158
- api.czr_skopeBase.maybeSynchronizeGlobalSkope( { isGlobalReset : true, isSetting : true, settingIdToReset : setId } )
3159
- .done( function() {
3160
- _silentUpdate();
3161
- });
3162
- } else {
3163
- _silentUpdate();
3164
- }
3165
- });
3166
- });
3167
- };//_updateAPI
 
 
 
 
 
 
3168
 
 
 
3169
 
3170
- ctrl.czr_states( 'isResetting' )( true );
3171
- ctrl.container.addClass('czr-resetting-control');
 
 
3172
 
3173
- api.czr_skopeReset[ ctrl.czr_states( 'isDirty' )() ? 'resetChangeset' : 'resetPublished' ](
3174
- { skope_id : skope_id, setId : setId, is_setting : true } )
3175
- .done( function( r ) {
3176
- _updateAPI( ctrlId );
3177
- })
3178
- .fail( function( r ) {
3179
- api.errorLog( 'Reset failed', r );
3180
- $.when( $('.czr-crtl-reset-dialog', ctrl.container ).fadeOut('300') ).done( function() {
3181
- $.when( $('.czr-reset-fail', ctrl.container ).fadeIn('300') ).done( function() {
3182
- $('.czr-reset-fail', ctrl.container ).append('<p>' + r + '</p>');
3183
- _.delay( function() {
3184
- _setResetDialogVisibility.call( ctrl );
3185
- self.setupActiveSkopedControls( { controls : [ ctrlId ] } );
3186
- }, 2000 );
3187
- });
3188
- });
3189
- });
3190
 
3191
- },
3192
- _resetControlDirtyness : function( ctrlId ) {
3193
- var setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
3194
- skope_instance = api.czr_skope( api.czr_activeSkopeId() ),
3195
- current_dirties = $.extend( true, {}, skope_instance.dirtyValues() ),
3196
- new_dirties = {},
3197
- current_changeset = $.extend( true, {}, skope_instance.changesetValues() ),
3198
- new_changeset = {},
3199
- dfd = $.Deferred();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3200
 
3201
- new_dirties = _.omit( current_dirties, setId );
3202
- new_changeset = _.omit( current_changeset, setId );
3203
- skope_instance.dirtyValues( new_dirties );
3204
- skope_instance.changesetValues( new_dirties );
 
 
 
 
 
 
 
 
 
 
 
3205
 
3206
- return dfd.resolve().promise();
3207
- },
3208
- _resetControlAPIVal : function( ctrlId ) {
3209
- var setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
3210
- current_skope_db = api.czr_skope( api.czr_activeSkopeId() ).dbValues(),
3211
- new_skope_db = $.extend( true, {}, current_skope_db ),
3212
- dfd = $.Deferred();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3213
 
3214
- if ( _.has( api.control( ctrlId ), 'czr_states') ) {
3215
- api.control(ctrlId).czr_states( 'hasDBVal' )( false );
3216
- api.czr_skope( api.czr_activeSkopeId() ).dbValues( _.omit( new_skope_db, setId ) );
3217
- }
3218
- return dfd.resolve().promise();
3219
- }
3220
- });//$.extend()
3221
- })( wp.customize , jQuery, _ );
3222
 
3223
- /*****************************************************************************
3224
- * THE SKOPE BASE OBJECT
3225
- *****************************************************************************/
3226
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
3227
  ( function ( api, $, _ ) {
3228
- $.extend( CZRSkopeBaseMths, {
3229
- renderCtrlSkpNotIcon : function( controlIdCandidates ) {
3230
- var self = this,
3231
- controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3232
 
3233
- _.each( controlIds, function( _id ) {
3234
- api.control.when( _id, function() {
3235
- var ctrl = api.control( _id );
3236
- ctrl.deferred.embedded.then( function() {
3237
- if( $('.czr-toggle-notice', ctrl.container ).length )
3238
- return;
 
 
 
 
 
 
 
 
3239
 
3240
- $.when( ctrl.container
3241
- .find('.customize-control-title').first()//was.find('.customize-control-title')
3242
- .append( $( '<span/>', {
3243
- class : 'czr-toggle-notice fa fa-info-circle',
3244
- title : serverControlParams.i18n.skope['Display informations about the scope of this option.']
3245
- } ) ) )
3246
- .done( function(){
3247
- $('.czr-toggle-notice', ctrl.container).fadeIn( 400 );
3248
- });
3249
- });
3250
 
3251
- });
 
 
 
 
 
 
 
3252
 
3253
- });
3254
- },
3255
- updateCtrlSkpNot : function( controlIdCandidates, visible ) {
3256
- var self = this,
3257
- controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates],
3258
- _isSkoped = function( setId ) {
3259
- return setId && self.isSettingSkopeEligible( setId );
3260
- },//filter only eligible ctrlIds
3261
 
3262
- _generateControlNotice = function( setId, _localSkopeId ) {
3263
- var _currentSkopeId = api.czr_activeSkopeId(),
3264
- _inheritedFromSkopeId = self.getInheritedSkopeId( setId, _currentSkopeId ),
3265
- _overridedBySkopeId = self.getAppliedPrioritySkopeId( setId, _currentSkopeId ),
3266
- _html = [],
3267
- _isCustomized,
3268
- _hasDBVal,
3269
- _ctxTitle;
3270
- if ( ! _isSkoped( setId ) ) {
3271
- _html.push( [
3272
- serverControlParams.i18n.skope['This option is always customized sitewide and cannot be reset.']
3273
- ].join(' ') );
3274
- return _html.join(' | ');
3275
- }
3276
- if ( _inheritedFromSkopeId == _overridedBySkopeId && api.czr_skope.has( _inheritedFromSkopeId ) && _currentSkopeId == _inheritedFromSkopeId ) {
3277
- _isCustomized = ! _.isUndefined( api.czr_skope( _currentSkopeId ).dirtyValues()[setId] );
3278
- _hasDBVal = ! _.isUndefined( api.czr_skope( _currentSkopeId ).dbValues()[setId] );
3279
 
3280
- _ctxTitle = api.czr_skope( _inheritedFromSkopeId )().ctx_title;
 
3281
 
3282
- _ctxTitle = ( _.isString( _ctxTitle ) ? _ctxTitle : '' ).toLowerCase();
3283
 
3284
- if ( _isCustomized ) {
3285
- if ( 'global' == api.czr_skope( _inheritedFromSkopeId )().skope ) {
3286
- _html.push( [
3287
- serverControlParams.i18n.skope['Customized. Will be applied sitewide once published.'],
3288
- ].join(' ') );
3289
- } else {
3290
- _html.push( [
3291
- serverControlParams.i18n.skope['Customized. Will be applied to'],
3292
- '<strong>' + _ctxTitle + '</strong>',
3293
- serverControlParams.i18n.skope['once published.']
3294
- ].join(' ') );
3295
- }
3296
- } else {
3297
- if ( _hasDBVal ) {
3298
- if ( 'global' == api.czr_skope( _inheritedFromSkopeId )().skope ) {
3299
- _html.push( [
3300
- serverControlParams.i18n.skope['Customized and applied sitewide.'],
3301
- ].join(' ') );
3302
- } else {
3303
- _html.push( [
3304
- serverControlParams.i18n.skope['Customized and applied to'],
3305
- '<strong>' + _ctxTitle + '.' + '</strong>'
3306
- ].join(' ') );
3307
- }
3308
- } else {
3309
- _html.push( serverControlParams.i18n.skope['Default website value applied sitewide.'] );
3310
- }
3311
- }
3312
- }
3313
- if ( _inheritedFromSkopeId !== _currentSkopeId && api.czr_skope.has( _inheritedFromSkopeId ) ) {
3314
- _isCustomized = ! _.isUndefined( api.czr_skope( _inheritedFromSkopeId ).dirtyValues()[setId] );
3315
- _hasDBVal = ! _.isUndefined( api.czr_skope( _inheritedFromSkopeId ).dbValues()[setId] );
3316
 
3317
- _ctxTitle = api.czr_skope( _currentSkopeId )().ctx_title;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3318
 
3319
- _ctxTitle = ( _.isString( _ctxTitle ) ? _ctxTitle : '' ).toLowerCase();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3320
 
3321
- if ( ! _isCustomized && ! _hasDBVal ) {
3322
- _html.push(
3323
- [
3324
- serverControlParams.i18n.skope['Default website value.'],
3325
- serverControlParams.i18n.skope['You can customize this specifically for'],
3326
- '<strong>' + _ctxTitle + '.' + '</strong>'
3327
- ].join(' ')
3328
- );
3329
- } else {
3330
- _html.push(
3331
- [
3332
- serverControlParams.i18n.skope['Currently inherited from'],
3333
- self.buildSkopeLink( _inheritedFromSkopeId ) + '.',
3334
- serverControlParams.i18n.skope['You can customize this specifically for'],
3335
- '<strong>' + _ctxTitle + '.' + '</strong>'
3336
- ].join(' ')
3337
- );
3338
- }
3339
- }
3340
- if ( _overridedBySkopeId !== _currentSkopeId && api.czr_skope.has( _overridedBySkopeId ) ) {
3341
- _isCustomized = ! _.isUndefined( api.czr_skope( _overridedBySkopeId ).dirtyValues()[setId] );
3342
 
3343
- _ctxTitle = api.czr_skope( _localSkopeId )().ctx_title;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3344
 
3345
- _ctxTitle = ( _.isString( _ctxTitle ) ? _ctxTitle : '' ).toLowerCase();
3346
 
3347
- _html.push( [
3348
- ! _isCustomized ? serverControlParams.i18n.skope['The value currently applied to'] : serverControlParams.i18n.skope['The value that will be applied to'],
3349
- '<strong>' + _ctxTitle + '</strong>',
3350
- ! _isCustomized ? serverControlParams.i18n.skope['is set in'] : serverControlParams.i18n.skope['is customized in'],
3351
- self.buildSkopeLink( _overridedBySkopeId ),
3352
- serverControlParams.i18n.skope['which has a higher priority than the current option scope'],
3353
- '<strong>( ' + api.czr_skope( _currentSkopeId )().title + ' ).</strong>'
3354
- ].join(' ') );
3355
- }
3356
 
3357
- return _html.join(' | ');
3358
- };//_generateControlNotice
3359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3360
 
3361
- _.each( controlIds, function( _id ) {
3362
- api.control.when( _id, function() {
3363
- var ctrl = api.control( _id ),
3364
- setId = api.CZR_Helpers.getControlSettingId( _id ),//get the relevant setting_id for this control
3365
- _visible = _.isUndefined( visible ) ? ( ctrl.czr_states && ctrl.czr_states( 'noticeVisible' )() ) : visible;
3366
- if ( ! _visible )
3367
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3368
 
3369
- ctrl.deferred.embedded.then( function() {
3370
- var _localSkopeId = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id,
3371
- $noticeContainer = ctrl.getNotificationsContainerElement();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3372
 
3373
- if ( ! $noticeContainer || ! $noticeContainer.length || _.isUndefined( _localSkopeId ) )
3374
- return;
 
 
 
 
 
 
 
3375
 
3376
- try {
3377
- _html = _generateControlNotice( setId, _localSkopeId );
3378
- } catch ( er ) {
3379
- api.errorLog( '_generateControlNotice : ' + er );
3380
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3381
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3382
 
3383
- var $skopeNoticeEl = $( '.czr-skope-notice', $noticeContainer );
3384
- if ( $skopeNoticeEl.length ) {
3385
- $skopeNoticeEl.html( _html );
3386
- } else {
3387
- $noticeContainer.append(
3388
- [ '<span class="czr-notice czr-skope-notice">', _html ,'</span>' ].join('')
3389
- );
3390
- }
3391
  });
3392
- });
3393
- });
3394
- },//updateCtrlSkpNot
3395
- isCtrlNoticeVisible : function( ctrlId ) {
3396
- if ( ! api.control.has( ctrlId ) )
3397
- return false;
3398
 
3399
- var self = this,
3400
- setId = api.CZR_Helpers.getControlSettingId( ctrlId ),//get the relevant setting_id for this control
3401
- _currentSkopeId = api.czr_activeSkopeId(),
3402
- _overridedBySkopeId = self.getAppliedPrioritySkopeId( setId, _currentSkopeId ),
3403
- _isSkoped = function( setId ) {
3404
- return setId && self.isSettingSkopeEligible( setId );
3405
- };//filter only eligible ctrlIds
3406
 
3407
- if ( 'global' != api.czr_skope( _currentSkopeId )().skope ) {
3408
- return true;
3409
- } else if ( _overridedBySkopeId !== _currentSkopeId && api.czr_skope.has( _overridedBySkopeId ) ) {
3410
- return true;
3411
- }
3412
- return false;
3413
- },
3414
- removeCtrlSkpNot : function( controlIdCandidates ) {
3415
- var self = this,
3416
- controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates];
3417
 
3418
- _.each( controlIds, function( _id ) {
3419
- api.control.when( _id, function() {
3420
- var ctrl = api.control( _id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3421
 
3422
- ctrl.deferred.embedded.then( function() {
3423
- var $noticeContainer = ctrl.getNotificationsContainerElement();
3424
 
3425
- if ( ! $noticeContainer || ! $noticeContainer.length )
3426
- return;
3427
 
3428
- var $skopeNoticeEl = $( '.czr-skope-notice', $noticeContainer );
3429
- if ( $skopeNoticeEl.length )
3430
- $skopeNoticeEl.remove();
3431
- });
3432
- });
3433
- });
3434
- }
3435
- });//$.extend()
3436
- })( wp.customize , jQuery, _ );
3437
- var CZRSkopeSaveMths = CZRSkopeSaveMths || {};
3438
- ( function ( api, $, _ ) {
3439
- $.extend( CZRSkopeSaveMths, {
3440
- initialize: function() {
3441
- var self = this;
3442
- this.changesetStatus = 'publish';
3443
- this.saveBtn = $( '#save' );
3444
- },
3445
 
 
 
 
 
 
 
 
 
 
3446
 
3447
- save: function( args ) {
3448
- var self = this,
3449
- processing = api.state( 'processing' ),
3450
- submitWhenDoneProcessing,
3451
- parent = new api.Messenger({
3452
- url: api.settings.url.parent,
3453
- channel: 'loader',
3454
- });//this has to be reinstantiated because not accessible from core
3455
- self.globalSaveDeferred = $.Deferred();
3456
- self.previewer = api.previewer;
3457
- self.globalSkopeId = api.czr_skopeBase.getGlobalSkopeId();
3458
- self.saveArgs = args;
 
 
 
 
3459
 
3460
- if ( args && args.status ) {
3461
- self.changesetStatus = args.status;
3462
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3463
 
3464
- if ( api.state( 'saving' )() ) {
3465
- self.globalSaveDeferred.reject( 'already_saving' );
3466
- }
3467
- var alwaysAfterSubmission = function( response, state ) {
3468
- api.state( 'saving' )( false );
3469
- api.state( 'processing' ).set( 0 );
3470
- self.saveBtn.prop( 'disabled', false );
3471
- if ( ! _.isUndefined( response ) && response.setting_validities ) {
3472
- api._handleSettingValidities( {
3473
- settingValidities: response.setting_validities,
3474
- focusInvalidControl: true
3475
- } );
3476
- }
3477
- if ( 'pending' == state ) {
3478
- api.czr_serverNotification( { message: response, status : 'error' } );
3479
- } else {
3480
- }
3481
- },
3482
- resolveSave = function( params ) {
3483
- var response, resolveSaveDfd = $.Deferred();
3484
- api.state( 'saving' )( true );
3485
- self.fireAllSubmission( params )
3486
- .always( function( _response_ ) {
3487
- response = _response_.response;
3488
- alwaysAfterSubmission( response , this.state() );
3489
- })
3490
- .fail( function( _response_ ) {
3491
- response = _response_.response;
3492
- api.consoleLog('ALL SUBMISSIONS FAILED', response );
3493
- self.globalSaveDeferred.reject( response );
3494
- api.trigger( 'error', response );
3495
- resolveSaveDfd.resolve( _response_.hasNewMenu );
3496
- })
3497
- .done( function( _response_ ) {
3498
- response = _response_.response;
3499
- api.previewer.refresh( { waitSkopeSynced : true } )
3500
- .fail( function( refresh_data ) {
3501
- self.globalSaveDeferred.reject( self.previewer, [ response ] );
3502
- api.consoleLog('SAVE REFRESH FAIL', refresh_data );
3503
- })
3504
- .done( function( refresh_data ) {
3505
- api.previewer.send( 'saved', response );
3506
- response = _.extend( { changeset_status : 'publish' }, response || {} );
3507
- if ( api.czr_isChangeSetOn() ) {
3508
- var latestRevision = api._latestRevision;
3509
- api.state( 'changesetStatus' ).set( response.changeset_status );
3510
- if ( 'publish' === response.changeset_status ) {
3511
- api.each( function( setting ) {
3512
- /*
3513
- * Note that the setting revision will be undefined in the case of setting
3514
- * values that are marked as dirty when the customizer is loaded, such as
3515
- * when applying starter content. All other dirty settings will have an
3516
- * associated revision due to their modification triggering a change event.
3517
- */
3518
- if ( setting._dirty && ( _.isUndefined( api._latestSettingRevisions[ setting.id ] ) || api._latestSettingRevisions[ setting.id ] <= latestRevision ) ) {
3519
- setting._dirty = false;
3520
- }
3521
- } );
3522
 
3523
- api.state( 'changesetStatus' ).set( '' );
3524
- api.settings.changeset.uuid = response.next_changeset_uuid;
3525
- parent.send( 'changeset-uuid', api.settings.changeset.uuid );
3526
- }
3527
- } else {
3528
- api.each( function ( value ) {
3529
- value._dirty = false;
3530
- } );
3531
- }
3532
- refresh_data = _.extend( {
3533
- previewer : refresh_data.previewer || self.previewer,
3534
- skopesServerData : refresh_data.skopesServerData || {},
3535
- },
3536
- refresh_data
3537
- );
3538
- self.reactWhenSaveDone( refresh_data.skopesServerData );
3539
- self.globalSaveDeferred.resolveWith( self.previewer, [ response ] );
3540
 
3541
- api.trigger( 'saved', response || {} );
3542
- resolveSaveDfd.resolve( _response_.hasNewMenu );
3543
- });
3544
- });
3545
- return resolveSaveDfd.promise();
3546
- };//resolveSave
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3547
 
3548
- if ( 0 === processing() ) {
3549
- resolveSave().done( function( hasNewMenu ) {
3550
- if ( hasNewMenu ) {
3551
- resolveSave( { saveGlobal :false, saveSkopes : true } );
3552
- }
3553
- } );
3554
- } else {
3555
- submitWhenDoneProcessing = function () {
3556
- if ( 0 === processing() ) {
3557
- api.state.unbind( 'change', submitWhenDoneProcessing );
3558
- resolveSave();
3559
- }
3560
- };
3561
- api.state.bind( 'change', submitWhenDoneProcessing );
3562
- }
3563
- return self.globalSaveDeferred.promise();
3564
- }//save
3565
- });//$.extend
3566
- })( wp.customize , jQuery, _ );
3567
- var CZRSkopeSaveMths = CZRSkopeSaveMths || {};
3568
- ( function ( api, $, _ ) {
3569
- $.extend( CZRSkopeSaveMths, {
3570
- getSubmitPromise : function( skope_id ) {
3571
- var self = this,
3572
- dfd = $.Deferred(),
3573
- submittedChanges = {};
3574
 
3575
- if ( _.isEmpty( skope_id ) || ! api.czr_skope.has( skope_id ) ) {
3576
- api.consoleLog( 'getSubmitPromise : no skope id requested OR skope_id not registered : ' + skope_id );
3577
- return dfd.resolve().promise();
3578
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
3579
 
3580
- var skopeObjectToSubmit = api.czr_skope( skope_id )();
3581
- if ( ! api.czr_skope( skope_id ).dirtyness() && skope_id !== self.globalSkopeId ) {
3582
- return dfd.resolve().promise();
3583
- }
3584
- _.each( api.czr_skopeBase.getSkopeDirties( skope_id ) , function( dirtyValue, settingId ) {
3585
- submittedChanges[ settingId ] = _.extend(
3586
- { value: dirtyValue }
3587
- );
3588
- } );
 
 
 
3589
 
3590
- this.submit(
3591
- {
3592
- skope_id : skope_id,
3593
- customize_changeset_data : submittedChanges,//{}
3594
- dyn_type : skopeObjectToSubmit.dyn_type
3595
- })
3596
- .done( function(_resp) {
3597
- dfd.resolve( _resp );
3598
- } )
3599
- .fail( function( _resp ) {
3600
- api.consoleLog('GETSUBMIT FAILED PROMISE FOR SKOPE : ', skope_id, _resp );
3601
- dfd.reject( _resp );
3602
- } );
3603
 
3604
- return dfd.promise();
3605
- },//getSubmitPromise
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3607
 
 
3608
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3609
 
3610
- submit : function( params ) {
3611
- var self = this,
3612
- default_params = {
3613
- skope_id : null,
3614
- the_dirties : {},
3615
- customize_changeset_data : {},
3616
- dyn_type : null,
3617
- opt_name : null
3618
- },
3619
- invalidSettings = [],
3620
- settingInvalidities = [],
3621
- modifiedWhileSaving = {},
3622
- invalidControls,
3623
- submit_dfd = $.Deferred();
3624
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3625
 
3626
- params = $.extend( default_params, params );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3627
 
3628
- if ( _.isNull( params.skope_id ) ) {
3629
- throw new Error( 'OVERRIDEN SAVE::submit : MISSING skope_id');
3630
- }
3631
- if ( _.isNull( params.the_dirties ) ) {
3632
- throw new Error( 'OVERRIDEN SAVE::submit : MISSING the_dirties');
3633
- }
 
 
3634
 
3635
- /*
3636
- * Block saving if there are any settings that are marked as
3637
- * invalid from the client (not from the server). Focus on
3638
- * the control.
3639
- */
3640
- if ( _.has( api, 'Notification') ) {
3641
- api.each( function( setting ) {
3642
- setting.notifications.each( function( notification ) {
3643
- if ( 'error' === notification.type ) {
3644
- api.consoleLog('NOTIFICATION ERROR on SUBMIT SAVE' , notification );
3645
- }
3646
- if ( 'error' === notification.type && ( ! notification.data || ! notification.data.from_server ) ) {
3647
- invalidSettings.push( setting.id );
3648
- if ( ! settingInvalidities[ setting.id ] ) {
3649
- settingInvalidities[ setting.id ] = {};
3650
- }
3651
- settingInvalidities[ setting.id ][ notification.code ] = notification;
3652
- }
3653
- } );
3654
- } );
3655
- invalidControls = api.findControlsForSettings( invalidSettings );
3656
- if ( ! _.isEmpty( invalidControls ) ) {
3657
- _.values( invalidControls )[0][0].focus();
3658
- return submit_dfd.rejectWith( self.previewer, [
3659
- { setting_invalidities: settingInvalidities }
3660
- ] ).promise();
3661
  }
3662
- }
3663
- var query_params = {
3664
- skope_id : params.skope_id,
3665
- action : 'save',
3666
- the_dirties : params.the_dirties,
3667
- dyn_type : params.dyn_type,
3668
- opt_name : params.opt_name
3669
- };
3670
- if ( api.czr_isChangeSetOn() ) {
3671
- $.extend( query_params, { excludeCustomizedSaved: false } );
3672
- }
3673
 
3674
- /*
3675
- * Note that excludeCustomizedSaved is intentionally false so that the entire
3676
- * set of customized data will be included if bypassed changeset update.
3677
- */
3678
- var query = $.extend( self.previewer.query( query_params ), {
3679
- nonce: self.previewer.nonce.save,
3680
- customize_changeset_status: self.changesetStatus,
3681
- customize_changeset_data : JSON.stringify( params.customize_changeset_data )
3682
- } );
3683
- if ( api.czr_isChangeSetOn() ) {
3684
- if ( self.saveArgs && self.saveArgs.date ) {
3685
- query.customize_changeset_date = self.saveArgs.date;
3686
- }
3687
- if ( self.saveArgs && self.saveArgs.title ) {
3688
- query.customize_changeset_title = self.saveArgs.title;
3689
- }
3690
- }
3691
 
3692
- /*
3693
- * Note that the dirty customized values will have already been set in the
3694
- * changeset and so technically query.customized could be deleted. However,
3695
- * it is remaining here to make sure that any settings that got updated
3696
- * quietly which may have not triggered an update request will also get
3697
- * included in the values that get saved to the changeset. This will ensure
3698
- * that values that get injected via the saved event will be included in
3699
- * the changeset. This also ensures that setting values that were invalid
3700
- * will get re-validated, perhaps in the case of settings that are invalid
3701
- * due to dependencies on other settings.
3702
- */
3703
- var request = wp.ajax.post(
3704
- 'global' !== query.skope ? 'customize_skope_changeset_save' : 'customize_save',
3705
- query
3706
- );
3707
- self.saveBtn.prop( 'disabled', true );
3708
 
3709
- api.trigger( 'save', request );
 
 
 
 
 
 
 
3710
 
3711
- request.fail( function ( response ) {
3712
- api.consoleLog('SUBMIT REQUEST FAIL', params.skope_id, response );
3713
- if ( '0' === response ) {
3714
- response = 'not_logged_in';
3715
- } else if ( '-1' === response ) {
3716
- response = 'invalid_nonce';
3717
- }
3718
 
3719
- if ( 'invalid_nonce' === response ) {
3720
- self.previewer.cheatin();
3721
- } else if ( 'not_logged_in' === response ) {
3722
- self.previewer.preview.iframe.hide();
3723
- self.previewer.login().done( function() {
3724
- self.previewer.save();
3725
- self.previewer.preview.iframe.show();
3726
- } );
3727
- }
3728
- api.trigger( 'error', response );
3729
- submit_dfd.reject( response );
3730
- } );
3731
 
3732
- request.done( function( response ) {
3733
- submit_dfd.resolve( response );
3734
- } );
3735
- return submit_dfd.promise();
3736
- }//submit()
3737
- });//$.extend
3738
- })( wp.customize , jQuery, _ );
3739
- var CZRSkopeSaveMths = CZRSkopeSaveMths || {};
3740
- ( function ( api, $, _ ) {
3741
- $.extend( CZRSkopeSaveMths, {
3742
- fireAllSubmission : function( params ) {
3743
- var self = this,
3744
- dfd = $.Deferred(),
3745
- skopesToSave = [],
3746
- _recursiveCallDeferred = $.Deferred(),
3747
- _responses_ = {},
3748
- _promises = [],
3749
- failedPromises = [],
3750
- _defaultParams = {
3751
- saveGlobal : true,
3752
- saveSkopes : true
3753
  };
3754
- params = $.extend( _defaultParams, params );
3755
- _.each( api.czr_skopeCollection(), function( _skp_ ) {
3756
- if ( 'global' !== _skp_.skope ) {
3757
- skopesToSave.push( _skp_.id );
3758
- }
3759
- });
 
 
 
 
 
3760
 
3761
- var _mayBeresolve = function( _index ) {
3762
- if ( ! _.isUndefined( skopesToSave[ _index + 1 ] ) || _promises.length != skopesToSave.length )
3763
- return;
 
 
 
 
 
 
3764
 
3765
- if ( _.isEmpty( failedPromises ) ) {
3766
- _recursiveCallDeferred.resolve( _responses_ );
3767
- } else {
3768
- var _buildResponse = function() {
3769
- var _failedResponse = [];
3770
- _.each( failedPromises, function( _r ) {
3771
- _failedResponse.push( api.czr_skopeBase.buildServerResponse( _r ) );
3772
- } );
3773
- return $.trim( _failedResponse.join( ' | ') );
3774
- };
3775
- _recursiveCallDeferred.reject( _buildResponse() );
3776
- }
3777
- return true;
3778
- };
3779
- var recursiveCall = function( _index ) {
3780
- _index = _index || 0;
3781
- if ( _.isUndefined( skopesToSave[_index] ) ) {
3782
- api.consoleLog( 'Undefined Skope in Save recursive call ', _index, _skopesToUpdate, _skopesToUpdate[_index] );
3783
- _recursiveCallDeferred.resolve( _responses_ );
3784
- }
3785
- self.getSubmitPromise( skopesToSave[ _index ] )
3786
- .always( function() { _promises.push( _index ); } )
3787
- .fail( function( response ) {
3788
- failedPromises.push( response );
3789
- api.consoleLog('RECURSIVE PUSH FAIL FOR SKOPE : ', skopesToSave[_index] );
3790
- if ( ! _mayBeresolve( _index ) )
3791
- recursiveCall( _index + 1 );
3792
- } )
3793
- .done( function( response ) {
3794
- response = response || {};
3795
- if ( _.isEmpty( _responses_ ) ) {
3796
- _responses_ = response || {};
3797
- } else {
3798
- _responses_ = $.extend( _responses_ , response );
3799
- }
3800
- if ( ! _mayBeresolve( _index ) )
3801
- recursiveCall( _index + 1 );
3802
- } );
3803
 
3804
- return _recursiveCallDeferred.promise();
3805
- };
3806
- var _globalHasNewMenu = false;
3807
- _.each( api.czr_skope('global__all_').dirtyValues(), function( _setDirtVal , _setId ) {
3808
- if ( 'nav_menu[' != _setId.substring( 0, 'nav_menu['.length ) )
3809
- return;
3810
- _globalHasNewMenu = true;
3811
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3812
 
3813
- var _submitGlobal = function() {
3814
- self.getSubmitPromise( self.globalSkopeId )
3815
- .fail( function( r ) {
3816
- api.consoleLog('GLOBAL SAVE SUBMIT FAIL', r );
3817
- r = api.czr_skopeBase.buildServerResponse( r );
3818
- dfd.reject( r );
3819
- })
3820
- .done( function( r ) {
3821
- if ( _.isEmpty( _responses_ ) ) {
3822
- _responses_ = r || {};
3823
- } else {
3824
- _responses_ = $.extend( _responses_ , r );
3825
- }
3826
- dfd.resolve( { response : _responses_, hasNewMenu : _globalHasNewMenu } );
3827
- });
3828
- };
3829
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3830
 
3831
- if ( _globalHasNewMenu && params.saveGlobal ) {
3832
- _submitGlobal();
3833
- } else {
3834
- if ( params.saveGlobal && params.saveSkopes ) {
3835
- recursiveCall()
3836
- .fail( function( r ) {
3837
- api.consoleLog('RECURSIVE SAVE CALL FAIL', r );
3838
- dfd.reject( r );
3839
- })
3840
- .done( function( r ) {
3841
- self.cleanSkopeChangesetMetas().always( function() { _submitGlobal(); } );
3842
- });
3843
- } else if ( params.saveGlobal && ! params.saveSkopes ) {
3844
- _submitGlobal();
3845
- } else if ( ! params.saveGlobal && params.saveSkopes ) {
3846
- recursiveCall()
3847
- .fail( function( r ) {
3848
- api.consoleLog('RECURSIVE SAVE CALL FAIL', r );
3849
- dfd.reject( r );
3850
- })
3851
- .done( function( r ) {
3852
- if ( _.isEmpty( _responses_ ) ) {
3853
- _responses_ = r || {};
3854
- } else {
3855
- _responses_ = $.extend( _responses_ , r );
3856
- }
3857
- self.cleanSkopeChangesetMetas().always( function() {
3858
- dfd.resolve( { response : _responses_, hasNewMenu : _globalHasNewMenu } );
3859
- });
3860
- });
3861
- }
3862
- }//else
3863
 
3864
- return dfd.promise();
3865
- },//fireAllSubmissions
3866
- cleanSkopeChangesetMetas : function() {
3867
- var self = this,
3868
- dfd = $.Deferred();
3869
- _query = $.extend(
3870
- api.previewer.query(),
3871
- { nonce: api.previewer.nonce.save }
3872
- );
3873
- wp.ajax.post( 'czr_clean_skope_changeset_metas_after_publish' , _query )
3874
- .always( function () { dfd.resolve(); })
3875
- .fail( function ( response ) { api.consoleLog( 'cleanSkopeChangesetMetas failed', _query, response ); })
3876
- .done( function( response ) { api.consoleLog( 'cleanSkopeChangesetMetas done', _query, response ); });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3877
 
3878
- return dfd.promise();
3879
- }
3880
- });//$.extend
3881
- })( wp.customize , jQuery, _ );
3882
- var CZRSkopeSaveMths = CZRSkopeSaveMths || {};
3883
- ( function ( api, $, _ ) {
3884
- $.extend( CZRSkopeSaveMths, {
3885
- reactWhenSaveDone : function( skopesServerData ) {
3886
- var saved_dirties = {};
3887
- skopesServerData = _.extend(
3888
- {
3889
- czr_skopes : [],
3890
- isChangesetDirty : false
3891
- },
3892
- skopesServerData
3893
- );
3894
- _.each( api.czr_skopeCollection(), function( _skp_ ) {
3895
- saved_dirties[ _skp_.opt_name ] = api.czr_skopeBase.getSkopeDirties( _skp_.id );
3896
- api.czr_skope( _skp_.id ).dirtyValues( {} );
3897
- api.czr_skope( _skp_.id ).changesetValues( {} );
3898
- });
3899
- var _notSyncedSettings = [],
3900
- _sentSkopeCollection = skopesServerData.czr_skopes;
3901
 
3902
- api.consoleLog('REACT WHEN SAVE DONE', saved_dirties, _sentSkopeCollection );
 
 
 
 
3903
 
3904
- _.each( saved_dirties, function( skp_data, _saved_opt_name ) {
3905
- _.each( skp_data, function( _val, _setId ) {
3906
- if ( _.isUndefined( _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ) ) )
3907
- return;
3908
- if ( ! api.czr_skopeBase.isSettingSkopeEligible( _setId ) )
3909
- return;
 
 
 
 
 
 
 
3910
 
3911
- var sent_skope_db_values = _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ).db,
3912
- sent_skope_level = _.findWhere( _sentSkopeCollection, { opt_name : _saved_opt_name } ).skope,
3913
- wpSetId = api.CZR_Helpers.build_setId( _setId ),
3914
- shortSetId = api.CZR_Helpers.getOptionName( _setId ),
3915
- sent_set_val = sent_skope_db_values[wpSetId];
3916
- if ( _.isUndefined( sent_set_val ) && 'global' == sent_skope_level && _val === serverControlParams.defaultOptionsValues[shortSetId] )
3917
- return;
 
 
 
 
 
3918
 
3919
- if ( _.isUndefined( sent_set_val ) || ! _.isEqual( sent_set_val, _val ) ) {
3920
- _notSyncedSettings.push( { opt_name : _saved_opt_name, setId : wpSetId, server_val : sent_set_val, api_val : _val } );
3921
- }
3922
- });
3923
  });
3924
-
3925
- if ( ! _.isEmpty( _notSyncedSettings ) ) {
3926
- api.consoleLog('SOME SETTINGS HAVE NOT BEEN PROPERLY SAVED : ', _notSyncedSettings );
3927
- } else {
3928
- api.consoleLog('ALL RIGHT, SERVER AND API ARE SYNCHRONIZED AFTER SAVE' );
3929
- }
3930
- api.czr_skopeBase.maybeSynchronizeGlobalSkope();
3931
- api.czr_skopeBase.updateCtrlSkpNot( api.CZR_Helpers.getSectionControlIds() );
3932
- var _setupSectionCtrlNotices = function() {
3933
- var sectionCtrls = api.CZR_Helpers.getSectionControlIds( api.czr_activeSectionId() );
3934
- _.each( sectionCtrls, function( ctrlId ) {
3935
- if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
3936
- return;
3937
- var ctrl = api.control( ctrlId );
3938
- if ( ! _.has( ctrl, 'czr_states' ) )
3939
- return;
3940
- ctrl.czr_states( 'noticeVisible' )( api.czr_skopeBase.isCtrlNoticeVisible( ctrlId ) );
3941
- });
3942
- };
3943
  }
3944
- });//$.extend
3945
  })( wp.customize , jQuery, _ );
3946
- var CZRSkopeResetMths = CZRSkopeResetMths || {};
3947
  ( function ( api, $, _ ) {
3948
- $.extend( CZRSkopeResetMths, {
3949
- initialize: function() {
3950
- var self = this;
3951
- self.previewer = api.previewer;
3952
- api.state.create('czr-resetting')(false);
3953
- api.state('czr-resetting').bind( function( state ) {
3954
- $( document.body ).toggleClass( 'czr-resetting', false !== state );
3955
- });
3956
- },
3957
- resetChangeset : function( args ) {
3958
- var dfd = $.Deferred(),
3959
- self = this,
3960
- processing = api.state( 'processing' ),
3961
- submitWhenPossible,
3962
- submit_reset,
3963
- request,
3964
- requestAjaxAction,
3965
- query_params,
3966
- query,
3967
- defaults = {
3968
- is_setting : false,
3969
- is_skope : false,
3970
- skope_id : api.czr_activeSkopeId() || '',
3971
- setId : ''
3972
- };
3973
 
3974
- args = _.extend( defaults, args );
3975
- var skope_id = args.skope_id,
3976
- setId = args.setId;
 
 
 
 
 
 
 
 
 
3977
 
3978
- if( ! api.czr_isChangeSetOn() )
3979
- return dfd.resolve().promise();
3980
- submit_reset = function( skope_id, setId ) {
3981
- if ( _.isUndefined( skope_id ) ) {
3982
- throw new Error( 'RESET: MISSING skope_id');
3983
- }
3984
- api.state( 'czr-resetting' )( true );
3985
- query_params = {
3986
- skope_id : skope_id,
3987
- action : 'reset'
3988
- };
3989
- query = $.extend(
3990
- self.previewer.query( query_params ),
3991
- { nonce: self.previewer.nonce.save }
3992
- );
3993
- if ( args.is_setting ) {
3994
- $.extend( query , { setting_id : setId } );
3995
- requestAjaxAction = 'czr_changeset_setting_reset';
3996
- } else if ( args.is_skope ) {
3997
- requestAjaxAction = 'czr_changeset_skope_reset';
3998
- } else {
3999
- return dfd.reject( 'reset_ajax_action_not_specified' ).promise();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4000
  }
 
4001
 
4002
- wp.ajax.post( requestAjaxAction , query )
4003
- .always( function () {
4004
- api.state( 'czr-resetting' )( false );
4005
- })
4006
- .fail( function ( response ) {
4007
- if ( '0' === response ) {
4008
- response = 'not_logged_in';
4009
- } else if ( '-1' === response ) {
4010
- response = 'invalid_nonce';
4011
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4012
 
4013
- if ( 'invalid_nonce' === response ) {
4014
- self.previewer.cheatin();
4015
- } else if ( 'not_logged_in' === response ) {
4016
- self.previewer.preview.iframe.hide();
4017
- self.previewer.login().done( function() {
4018
- self.resetChangeset( args );
4019
- self.previewer.preview.iframe.show();
4020
- } );
4021
- }
4022
- api.consoleLog( requestAjaxAction + ' failed ', query, response );
4023
- response = api.czr_skopeBase.buildServerResponse( response );
4024
- api.trigger( 'error', response );
4025
 
4026
- api.czr_serverNotification( { message: response, status : 'error' } );
4027
- dfd.reject( response );
4028
- })
4029
- .done( function( response ) {
4030
- dfd.resolve( response );
4031
- });
4032
- };//submit_reset()
 
 
4033
 
4034
- if ( 0 === processing() && false === api.state( 'czr-resetting' )() ) {
4035
- submit_reset( skope_id, setId );
4036
- } else {
4037
- submitWhenPossible = function () {
4038
- if ( 0 === processing() && false === api.state( 'czr-resetting' )() ) {
4039
- api.state.unbind( 'change', submitWhenPossible );
4040
- submit_reset( skope_id, setId );
4041
- }
4042
- };
4043
- api.state.bind( 'change', submitWhenPossible );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4044
  }
4045
 
4046
- return dfd.promise();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4047
  },
4048
- resetPublished : function( args ) {
4049
- var dfd = $.Deferred(),
4050
- self = this,
4051
- processing = api.state( 'processing' ),
4052
- submitWhenPossible,
4053
- submit_reset,
4054
- request,
4055
- requestAjaxAction,
4056
- query_params,
4057
- query,
4058
- defaults = {
4059
- is_setting : false,
4060
- is_skope : false,
4061
- skope_id : api.czr_activeSkopeId() || '',
4062
- setId : ''
4063
- };
4064
 
4065
- args = _.extend( defaults, args );
4066
- var skope_id = args.skope_id,
4067
- setId = args.setId;
4068
- submit_reset = function( skope_id, setId ) {
4069
- if ( _.isUndefined( skope_id ) ) {
4070
- throw new Error( 'RESET: MISSING skope_id');
4071
- }
4072
- api.state( 'czr-resetting' )( true );
4073
- query_params = {
4074
- skope_id : skope_id,
4075
- action : 'reset'
4076
- };
4077
- query = $.extend(
4078
- self.previewer.query( query_params ),
4079
- { nonce: self.previewer.nonce.save }
4080
- );
4081
- if ( args.is_setting ) {
4082
- $.extend( query , { setting_id : setId } );
4083
- requestAjaxAction = 'czr_published_setting_reset';
4084
- } else if ( args.is_skope ) {
4085
- requestAjaxAction = 'czr_published_skope_reset';
4086
- } else {
4087
- return dfd.reject( 'reset_ajax_action_not_specified' ).promise();
4088
- }
4089
 
4090
- api.consoleLog('in czr_reset submit : ', skope_id, query );
 
 
 
 
 
4091
 
4092
- wp.ajax.post( requestAjaxAction , query )
4093
- .always( function () {
4094
- api.state( 'czr-resetting' )( false );
4095
- })
4096
- .fail( function ( response ) {
4097
- if ( '0' === response ) {
4098
- response = 'not_logged_in';
4099
- } else if ( '-1' === response ) {
4100
- response = 'invalid_nonce';
4101
- }
4102
 
4103
- if ( 'invalid_nonce' === response ) {
4104
- self.previewer.cheatin();
4105
- } else if ( 'not_logged_in' === response ) {
4106
- self.previewer.preview.iframe.hide();
4107
- self.previewer.login().done( function() {
4108
- self.resetChangeset( args );
4109
- self.previewer.preview.iframe.show();
4110
- } );
4111
- }
4112
- api.consoleLog( requestAjaxAction + ' failed ', query, response );
4113
- response = api.czr_skopeBase.buildServerResponse( response );
4114
- api.trigger( 'error', response );
 
 
 
 
 
 
 
 
4115
 
4116
- api.czr_serverNotification( { message: response, status : 'error' } );
4117
- dfd.reject( response );
4118
- })
4119
- .done( function( response ) {
4120
- dfd.resolve( response );
4121
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4122
 
4123
- };//submit_reset()
 
 
 
 
 
 
 
 
 
 
 
 
 
4124
 
4125
- if ( 0 === processing() && false === api.state( 'czr-resetting' )() ) {
4126
- submit_reset( skope_id, setId );
4127
- } else {
4128
- submitWhenPossible = function () {
4129
- if ( 0 === processing() && false === api.state( 'czr-resetting' )() ) {
4130
- api.state.unbind( 'change', submitWhenPossible );
4131
- submit_reset( skope_id, setId );
4132
- }
4133
- };
4134
- api.state.bind( 'change', submitWhenPossible );
 
 
 
 
4135
  }
 
 
4136
 
4137
- return dfd.promise();
4138
- }
4139
- });//$.extend
4140
- })( wp.customize , jQuery, _ );
4141
 
4142
- var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4143
  ( function ( api, $, _ ) {
4144
- $.extend( CZRSkopeBaseMths, {
4145
- initWidgetSidebarSpecifics : function() {
4146
- var self = this;
4147
- if ( ! self.isExcludedSidebarsWidgets() ) {
4148
- api.czr_activeSkopeId.bind( function( active_skope ) {
4149
- self.forceSidebarDirtyRefresh( api.czr_activeSectionId(), active_skope );
4150
- });
4151
- }
4152
- $( document ).bind( 'widget-added', function( e, $o ) {
4153
- if ( self.isExcludedSidebarsWidgets() )
4154
- return;
4155
 
4156
- var wgtIdAttr = $o.closest('.customize-control').attr('id'),
4157
- wdgtSetId = api.czr_skopeBase.widgetIdToSettingId( wgtIdAttr, 'customize-control-' );
4158
- if ( ! api.has( wdgtSetId ) ) {
4159
- throw new Error( 'AN ADDED WIDGET COULD NOT BE BOUND IN SKOPE. ' + wdgtSetId);
4160
- } else {
4161
- self.listenAPISettings( wdgtSetId );
4162
- }
4163
- });
4164
  },
4165
 
4166
 
4167
- forceSidebarDirtyRefresh : function( active_section, active_skope ) {
4168
- var self = this;
4169
- if ( self.isExcludedSidebarsWidgets() )
 
 
 
 
 
4170
  return;
4171
- var _save_state = api.state('saved')();
4172
- var _debounced = function() {
4173
- if ( api.section.has( active_section ) && "sidebar" == api.section(active_section).params.type ) {
4174
- var active_skope = active_skope || api.czr_activeSkopeId(),
4175
- related_setting_name = 'sidebars_widgets[' + api.section(active_section).params.sidebarId + ']',
4176
- related_setting_val = self.getSkopeSettingVal( related_setting_name, active_skope );
4177
- api.czr_skope( active_skope ).updateSkopeDirties( related_setting_name, related_setting_val );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4178
 
4179
- api.previewer.refresh( { the_dirties : api.czr_skope( active_skope ).dirtyValues() } )
4180
- .done( function() {
4181
- api.state('saved')( _save_state );
4182
- });
4183
- }
4184
- };
4185
- _debounced = _.debounce( _debounced, 500 );
4186
- _debounced();
 
 
4187
  }
4188
- } );//$.extend
4189
  })( wp.customize , jQuery, _ );
4190
-
4191
- var CZRSkopeMths = CZRSkopeMths || {};
4192
  ( function ( api, $, _ ) {
4193
- $.extend( CZRSkopeMths, {
4194
- /*****************************************************************************
4195
- * THE SKOPE MODEL
4196
- *****************************************************************************/
4197
- initialize: function( skope_id, constructor_options ) {
4198
- var skope = this;
4199
- api.Value.prototype.initialize.call( skope, null, constructor_options );
4200
 
4201
- skope.isReady = $.Deferred();
4202
- skope.embedded = $.Deferred();
4203
- skope.el = 'czr-scope-' + skope_id;//@todo replace with a css selector based on the scope name
4204
- $.extend( skope, constructor_options || {} );
4205
- skope.visible = new api.Value( true );
4206
- skope.winner = new api.Value( false ); //is this skope the one that will be applied on front end in the current context?
4207
- skope.priority = new api.Value(); //shall this skope always win or respect the default skopes priority
4208
- skope.active = new api.Value( false ); //active, inactive. Are we currently customizing this skope ?
4209
- skope.dirtyness = new api.Value( false ); //true or false : has this skope been customized ?
4210
- skope.skopeResetDialogVisibility = new api.Value( false );
4211
- skope.hasDBValues = new api.Value( false );
4212
- skope.dirtyValues = new api.Value({});//stores the current customized value.
4213
- skope.dbValues = new api.Value({});//stores the latest db values => will be updated on each skope synced event
4214
- skope.changesetValues = new api.Value({});//stores the latest changeset values => will be updated on each skope synced eventsynced event
4215
- skope.userEventMap = new api.Value( [
4216
- {
4217
- trigger : 'click keydown',
4218
- selector : '.czr-scope-switch, .czr-skp-switch-link',
4219
- name : 'skope_switch',
4220
- actions : function() {
4221
- api.czr_activeSkopeId( skope().id );
4222
- }
4223
  },
4224
- {
4225
- trigger : 'click keydown',
4226
- selector : '.czr-scope-reset',
4227
- name : 'skope_reset_warning',
4228
- actions : 'reactOnSkopeResetUserRequest'
 
 
 
 
 
 
4229
  }
4230
- ]);//module.userEventMap
4231
- skope.skopeResetDialogVisibility.bind( function( to, from ) {
4232
- return skope.skopeResetDialogReact( to );
4233
- }, { deferred : true } );
4234
- skope.dirtyValues.callbacks.add(function() { return skope.dirtyValuesReact.apply(skope, arguments ); } );
4235
- skope.changesetValues.callbacks.add(function() { return skope.changesetValuesReact.apply(skope, arguments ); } );
4236
- skope.dbValues.callbacks.add(function() { return skope.dbValuesReact.apply(skope, arguments ); } );
4237
- skope.callbacks.add(function() { return skope.skopeReact.apply( skope, arguments ); } );
4238
- skope.set( _.omit( constructor_options, function( _v, _key ) {
4239
- return _.contains( [ 'db', 'changeset', 'has_db_val' ], _key );
4240
- } ) );
4241
- skope.setupObservableViewValuesCallbacks();
4242
- skope.dirtyness( ! _.isEmpty( constructor_options.changeset ) );
4243
- skope.hasDBValues( ! _.isEmpty( constructor_options.db ) );
4244
- skope.winner( constructor_options.is_winner );
4245
- skope.embedded
4246
- .fail( function() {
4247
- throw new Error('The container of skope ' + skope().id + ' has not been embededd');
4248
- })
4249
- .done( function() {
4250
- skope.setupDOMListeners( skope.userEventMap() , { dom_el : skope.container } );
4251
 
4252
- skope.isReady.resolve();
4253
- });
4254
-
4255
- },//initialize
4256
- ready : function() {
4257
- var skope = this;
4258
- api.czr_skopeBase.skopeWrapperEmbedded.done( function() {
4259
- try {
4260
- $.when( skope.embedSkopeDialogBox() ).done( function( $_container ){
4261
- if ( false !== $_container.length ) {
4262
- $_container.css('background-color', skope.color );
4263
- skope.container = $_container;
4264
- skope.embedded.resolve( $_container );
4265
- } else {
4266
- skope.embedded.reject();
4267
- }
4268
- });
4269
- } catch( er ) {
4270
- api.errorLog( "In skope base : " + er );
4271
- skope.embedded.reject();
4272
- }
4273
  });
 
4274
  },
 
 
 
 
 
 
 
 
4275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4276
 
 
 
4277
 
4278
 
4279
- /*****************************************************************************
4280
- * SKOPE API DIRTIES REACTIONS
4281
- *****************************************************************************/
4282
- dirtyValuesReact : function( to, from ) {
4283
- var skope = this;
4284
- skope.dirtyness( ! _.isEmpty( to ) );
4285
- api.czr_dirtyness( ! _.isEmpty(to) );
4286
- var ctrlIdDirtynessToClean = [];
4287
- _.each( from, function( _val, _id ) {
4288
- if ( _.has( to, _id ) )
4289
- return;
4290
- ctrlIdDirtynessToClean.push( _id );
4291
- });
4292
- if ( skope().id == api.czr_activeSkopeId() ) {
4293
- _.each( ctrlIdDirtynessToClean , function( setId ) {
4294
- if ( ! _.has( api.control( setId ), 'czr_states') )
4295
- return;
4296
- api.control( setId ).czr_states( 'isDirty' )( false );
4297
- });
4298
- _.each( to, function( _val, _setId ) {
4299
- if ( ! _.has( api.control( _setId ), 'czr_states') )
4300
- return;
4301
- api.control( _setId ).czr_states( 'isDirty' )( true );
4302
- });
4303
- }
4304
- },
4305
-
4306
-
4307
- /*****************************************************************************
4308
- * SKOPE API CHANGESET REACTIONS
4309
- *****************************************************************************/
4310
- changesetValuesReact : function( to, from ) {
4311
- var skope = this,
4312
- _currentServerDirties = $.extend( true, {}, skope.dirtyValues() );
4313
- skope.dirtyValues( $.extend( _currentServerDirties, to ) );
4314
- },
4315
-
4316
 
4317
- /*****************************************************************************
4318
- * SKOPE DB VALUES REACTIONS
4319
- *****************************************************************************/
4320
- dbValuesReact : function( to, from ) {
4321
- var skope = this;
4322
- skope.hasDBValues(
4323
- ! _.isEmpty(
4324
- 'global' != skope().skope ?
4325
- to :
4326
- _.omit( to, function( _val, _id ) {
4327
- return ! api.czr_skopeBase.isThemeSetting( _id );
4328
- })
4329
- )
4330
- );
4331
- var ctrlIdDbToReset = [];
4332
- _.each( from, function( _val, _id ) {
4333
- if ( _.has( to, _id ) )
4334
- return;
4335
- ctrlIdDbToReset.push( _id );
4336
- });
4337
- if ( skope().id == api.czr_activeSkopeId() ) {
4338
- _.each( ctrlIdDbToReset , function( setId ) {
4339
- if ( ! _.has( api.control( setId ), 'czr_states') )
4340
- return;
4341
- api.control( setId ).czr_states( 'hasDBVal' )( false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4342
  });
4343
- _.each( to, function( _val, _setId ) {
4344
- if ( ! _.has( api.control( _setId ), 'czr_states') )
4345
- return;
 
4346
 
4347
- api.control( _setId ).czr_states( 'hasDBVal' )( true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4348
  });
4349
- }
4350
- },
4351
 
4352
 
4353
- /*****************************************************************************
4354
- * SKOPE MODEL CHANGES CALLBACKS
4355
- *****************************************************************************/
4356
- skopeReact : function( to, from ) {
4357
- var skope = this,
4358
- _current_collection = [],
4359
- _new_collection = [];
4360
- if ( ! api.czr_skopeBase.isSkopeRegisteredInCollection( to.id ) ) {
4361
- _current_collection = $.extend( true, [], api.czr_skopeCollection() );
4362
- _current_collection.push( to );
4363
- api.czr_skopeCollection( _current_collection );
4364
- }
4365
- else {
4366
- _current_collection = $.extend( true, [], api.czr_skopeCollection() );
4367
- _new_collection = _current_collection;
4368
- _.each( _current_collection, function( _skope, _key ) {
4369
- if ( _skope.id != skope().id )
4370
- return;
4371
- _new_collection[_key] = to;
4372
  });
4373
- api.czr_skopeCollection( _new_collection );
4374
- }
4375
- },
 
 
 
 
 
 
 
 
 
 
 
4376
 
 
 
 
 
 
 
 
 
 
 
4377
 
4378
 
4379
 
@@ -4381,5667 +3654,6501 @@ $.extend( CZRSkopeMths, {
4381
 
4382
 
4383
 
4384
- /*****************************************************************************
4385
- * VALUES CALLBACKS WHEN SKOPE EMBEDDED AND READY
4386
- * => The skope container exists at this stage
4387
- *****************************************************************************/
4388
- setupObservableViewValuesCallbacks : function() {
4389
- var skope = this;
4390
- skope.visible.bind( function( is_visible ){
4391
- if ( 'pending' == skope.embedded.state() ) {
4392
- skope.embedded.done( function() {
4393
- skope.container.toggle( is_visible );
4394
- });
4395
- } else {
4396
- skope.container.toggle( is_visible );
4397
- }
4398
 
4399
- });
4400
- skope.active.bind( function() {
4401
- if ( 'pending' == skope.embedded.state() ) {
4402
- skope.embedded.done( function() {
4403
- skope.activeStateReact.apply( skope, arguments );
4404
- });
4405
- } else {
4406
- skope.activeStateReact.apply( skope, arguments );
4407
- }
4408
- });
4409
 
4410
- skope.dirtyness.bind( function() {
4411
- if ( 'pending' == skope.embedded.state() ) {
4412
- skope.embedded.done( function() {
4413
- skope.dirtynessReact.apply( skope, arguments );
4414
- });
4415
- } else {
4416
- skope.dirtynessReact.apply( skope, arguments );
4417
- }
4418
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4419
 
4420
- skope.hasDBValues.bind( function() {
4421
- if ( 'pending' == skope.embedded.state() ) {
4422
- skope.embedded.done( function() {
4423
- skope.hasDBValuesReact.apply( skope, arguments );
4424
- });
4425
- } else {
4426
- skope.hasDBValuesReact.apply( skope, arguments );
4427
- }
4428
- });
4429
 
4430
- skope.winner.bind( function() {
4431
- if ( 'pending' == skope.embedded.state() ) {
4432
- skope.embedded.done( function() {
4433
- skope.winnerReact.apply( skope, arguments );
4434
- });
4435
- } else {
4436
- skope.winnerReact.apply( skope, arguments );
4437
- }
4438
- });
4439
- },//setupObservableViewValuesCallbacks
4440
- activeStateReact : function( to, from ){
4441
- var skope = this;
4442
- skope.container.toggleClass('inactive', ! to ).toggleClass( 'active', to );
4443
- $('.czr-scope-switch', skope.container).toggleClass('fa-toggle-on', to).toggleClass('fa-toggle-off', !to);
4444
- },
4445
- dirtynessReact : function( to, from ) {
4446
- var skope = this;
4447
- $.when( this.container.toggleClass( 'dirty', to ) ).done( function() {
4448
- if ( to )
4449
- $( '.czr-scope-reset', skope.container).fadeIn('slow').attr('title', [ serverControlParams.i18n.skope['Reset the current customizations for'], skope().title ].join(' ') );
4450
- else if ( ! skope.hasDBValues() )
4451
- $( '.czr-scope-reset', skope.container).fadeOut('fast');
4452
- });
4453
- },
4454
- hasDBValuesReact : function( to, from ) {
4455
- var skope = this;
4456
- $.when( skope.container.toggleClass('has-db-val', to ) ).done( function() {
4457
- if ( to ) {
4458
- $( '.czr-scope-reset', skope.container)
4459
- .fadeIn( 'slow')
4460
- .attr( 'title', [
4461
- 'global' == skope().skope ? serverControlParams.i18n.skope['Reset the theme options published sitewide'] : serverControlParams.i18n.skope['Reset your website published options for'],
4462
- 'global' == skope().skope ? '' : skope().title
4463
- ].join(' ') );
4464
- }
4465
- else if ( ! skope.dirtyness() ) {
4466
- $( '.czr-scope-reset', skope.container ).fadeOut('fast');
4467
- }
4468
- });
4469
- },
4470
- winnerReact : function( is_winner ) {
4471
- var skope = this;
4472
- this.container.toggleClass('is_winner', is_winner );
4473
 
4474
- if ( is_winner ) {
4475
- _.each( api.czr_currentSkopesCollection(), function( _skope ) {
4476
- if ( _skope.id == skope().id )
4477
- return;
4478
- var _current_model = $.extend( true, {}, _skope );
4479
- $.extend( _current_model, { is_winner : false } );
4480
- api.czr_skope( _skope.id )( _current_model );
4481
- });
4482
- }
4483
- },
4484
 
4485
 
4486
 
4487
 
4488
- /*****************************************************************************
4489
- * HELPERS
4490
- *****************************************************************************/
4491
- updateSkopeDirties : function( setId, new_val ) {
4492
- var skope = this,
4493
- shortSetId = api.CZR_Helpers.getOptionName( setId );
4494
- if ( ! api.czr_skopeBase.isSettingSkopeEligible( setId ) && 'global' != skope().skope )
4495
- return api.czr_skope( api.czr_skopeBase.getGlobalSkopeId() ).updateSkopeDirties( setId, new_val );
4496
 
4497
- var current_dirties = $.extend( true, {}, skope.dirtyValues() ),
4498
- _dirtyCustomized = {};
4499
 
4500
- _dirtyCustomized[ setId ] = new_val;
4501
- skope.dirtyValues.set( $.extend( current_dirties , _dirtyCustomized ) );
4502
- return skope.dirtyValues();
4503
- },
4504
- getSkopeSettingDirtyness : function( setId ) {
4505
- var skope = this;
4506
- return skope.getSkopeSettingAPIDirtyness( setId ) || skope.getSkopeSettingChangesetDirtyness( setId );
4507
- },
4508
- getSkopeSettingAPIDirtyness : function( setId ) {
4509
- var skope = this;
4510
- return _.has( skope.dirtyValues(), api.CZR_Helpers.build_setId( setId ) );
4511
- },
4512
- getSkopeSettingChangesetDirtyness : function( setId ) {
4513
- var skope = this;
4514
- if ( ! api.czr_isChangeSetOn() )
4515
- return skope.getSkopeSettingAPIDirtyness( setId );
4516
- return _.has( skope.changesetValues(), api.CZR_Helpers.build_setId( setId ) );
4517
- },
4518
- hasSkopeSettingDBValues : function( setId ) {
4519
- var skope = this,
4520
- _setId = api.CZR_Helpers.build_setId(setId);
4521
 
4522
- return ! _.isUndefined( api.czr_skope( api.czr_activeSkopeId() ).dbValues()[_setId] );
 
 
 
 
 
 
 
 
 
4523
  }
4524
- });//$.extend(
4525
  })( wp.customize , jQuery, _ );
4526
- var CZRSkopeMths = CZRSkopeMths || {};
4527
  ( function ( api, $, _ ) {
4528
- $.extend( CZRSkopeMths, {
4529
- embedSkopeDialogBox : function() {
4530
- var skope = this,
4531
- skope_model = $.extend( true, {}, skope() ),
4532
- _tmpl = '';
4533
- if ( ! $('#customize-header-actions').find('.czr-scope-switcher').length ) {
4534
- throw new Error('The skope switcher wrapper is not printed, the skope can not be embedded.');
4535
- }
4536
- try {
4537
- _tmpl = wp.template('czr-skope')( _.extend( skope_model, { el : skope.el } ) );
4538
- } catch( er ) {
4539
- api.errorLog( 'Error when parsing the template of a skope' + er );
4540
- return false;
4541
- }
4542
-
4543
- $('.czr-skopes-wrapper', '#customize-header-actions').append( $( _tmpl ) );
4544
- return $( '.' + skope.el , '.czr-skopes-wrapper' );
4545
- },
4546
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4547
 
 
 
 
 
4548
 
 
 
4549
  /*****************************************************************************
4550
- * RESET
4551
  *****************************************************************************/
4552
- renderResetWarningTmpl : function() {
4553
- var skope = this,
4554
- skope_model = $.extend( true, {}, skope() ),
4555
- _tmpl = '',
4556
- warning_message,
4557
- success_message;
4558
 
4559
- if ( skope.dirtyness() ) {
4560
- warning_message = [
4561
- serverControlParams.i18n.skope['Please confirm that you want to reset your current ( not published ) customizations for'],
4562
- skope().ctx_title
4563
- ].join(' ');
4564
- success_message = [
4565
- serverControlParams.i18n.skope['Your customizations have been reset for'],
4566
- skope().ctx_title
4567
- ].join(' ');
4568
- } else {
4569
- warning_message = [
4570
- 'global' == skope().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'],
4571
- 'global' == skope().skope ? '' : skope().ctx_title
4572
- ].join(' ');
4573
- success_message = [
4574
- serverControlParams.i18n.skope['Your published customizations have been reset for'],
4575
- skope().title
4576
- ].join(' ');
4577
- }
 
 
 
 
 
 
 
 
4578
 
4579
- try {
4580
- _tmpl = wp.template( 'czr-skope-pane' )(
4581
- _.extend( skope_model, {
4582
- el : skope.el,
4583
- warning_message : warning_message + '.',
4584
- success_message : success_message + '.'
4585
- } )
4586
- );
4587
- } catch( er ) {
4588
- api.errorLog( 'Error when parsing the the reset skope template : ' + er );
4589
- return false;
4590
- }
4591
 
4592
- $('#customize-preview').after( $( _tmpl ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4593
 
4594
- return $( '#czr-skope-pane' );
4595
- },
 
 
 
4596
 
4597
 
 
 
 
 
 
 
 
4598
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4599
 
4600
- /*****************************************************************************
4601
- * HELPERS
4602
- *****************************************************************************/
4603
- getEl : function() {
4604
- var skope = this;
4605
- return $( skope.el, '#customize-header-actions');
4606
- }
4607
- });//$.extend()
4608
  })( wp.customize , jQuery, _ );
4609
-
4610
- var CZRSkopeMths = CZRSkopeMths || {};
4611
  ( function ( api, $, _ ) {
4612
- $.extend( CZRSkopeMths, {
 
 
 
 
 
 
 
 
 
4613
  /*****************************************************************************
4614
- * RESET
4615
  *****************************************************************************/
4616
- reactOnSkopeResetUserRequest : function() {
4617
- var skope = this,
4618
- _fireReaction = function() {
4619
- api.state( 'czr-resetting')( true );
4620
- if ( api.czr_activeSkopeId() != skope().id ) {
4621
- api.czr_activeSkopeId( skope().id )
4622
- .done( function() {
4623
- skope.skopeResetDialogVisibility( ! skope.skopeResetDialogVisibility() ).done( function() {
4624
- api.state( 'czr-resetting')( false );
4625
- });
4626
 
4627
- });
4628
- } else {
4629
- skope.skopeResetDialogVisibility( ! skope.skopeResetDialogVisibility() ).done( function() {
4630
- api.state( 'czr-resetting')( false );
4631
- });
 
 
 
 
 
 
4632
  }
4633
  };
4634
- if ( ( api.state( 'czr-resetting')() || 0 !== api.state( 'processing' )() ) ) {
4635
- api.czr_serverNotification( {
4636
- message: 'Slow down, you move too fast !',
4637
- status : 'success',
4638
- auto_collapse : true
4639
- });
4640
- return;
 
 
 
4641
  }
4642
- if ( api.czr_activeSkopeId() != skope().id && api.czr_skope( api.czr_activeSkopeId() ).skopeResetDialogVisibility() ) {
4643
- api.czr_skope( api.czr_activeSkopeId() ).skopeResetDialogVisibility( false ).done( function() {
4644
- _fireReaction();
4645
- });
 
 
 
 
 
 
 
4646
  } else {
4647
- _fireReaction();
4648
  }
4649
- },
4650
- skopeResetDialogReact : function( visible ) {
4651
- var skope = this, dfd = $.Deferred();
4652
- skope.userResetEventMap = skope.userResetEventMap || new api.Value( [
4653
- {
4654
- trigger : 'click keydown',
4655
- selector : '.czr-scope-reset-cancel',
4656
- name : 'skope_reset_cancel',
4657
- actions : function() {
4658
- skope.skopeResetDialogVisibility( ! skope.skopeResetDialogVisibility() );
4659
- }
4660
  },
4661
- {
4662
- trigger : 'click keydown',
4663
- selector : '.czr-scope-do-reset',
4664
- name : 'skope_do_reset',
4665
- actions : 'doResetSkopeValues'
4666
- }
4667
- ]
4668
  );
4669
 
4670
- if ( visible ) {
4671
- api.czr_isResettingSkope( skope().id );
4672
- $.when( skope.renderResetWarningTmpl() ).done( function( $_container ) {
4673
- skope.resetPanel = $_container;
4674
- skope.resetPanel.addClass( skope.dirtyness() ? 'dirty-reset' : 'db-reset' );
4675
- skope.setupDOMListeners( skope.userResetEventMap() , { dom_el : skope.resetPanel } );
4676
- }).then( function() {
4677
- setTimeout( function() {
4678
- var _height = $('#customize-preview').height();
4679
- skope.resetPanel.css( 'line-height', _height +'px' ).css( 'height', _height + 'px' );
4680
- $('body').addClass('czr-skope-pane-open');
4681
- }, 50 );
4682
- });
4683
- } else {
4684
- $.when( $('body').removeClass('czr-skope-pane-open') ).done( function() {
4685
- if ( _.has( skope, 'resetPanel') && false !== skope.resetPanel.length ) {
4686
- setTimeout( function() {
4687
- skope.resetPanel.remove();
4688
- api.czr_isResettingSkope( false );
4689
- }, 300 );
4690
- }
4691
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4692
  }
4693
- _.delay( function() { dfd.resolve(); }, 350 );
4694
 
4695
- return dfd.promise();
4696
- },
4697
- doResetSkopeValues : function() {
4698
- var skope = this,
4699
- skope_id = skope().id,
4700
- reset_method = skope.dirtyness() ? '_resetSkopeDirties' : '_resetSkopeAPIValues',
4701
- _updateAPI = function() {
4702
- var _silentUpdate = function() {
4703
- api.czr_skopeBase.processSilentUpdates( { refresh : false } )
4704
- .fail( function() { api.consoleLog( 'Silent update failed after resetting skope : ' + skope_id ); } )
4705
- .done( function() {
4706
- $.when( $('.czr-reset-warning', skope.resetPanel ).fadeOut('300') ).done( function() {
4707
- $.when( $('.czr-reset-success', skope.resetPanel ).fadeIn('300') ).done( function() {
4708
- _.delay( function() {
4709
- api.czr_isResettingSkope( false );
4710
- skope.skopeResetDialogVisibility( false );
4711
- }, 2000 );
4712
- });
4713
- });
4714
- });
4715
- };
4716
 
4717
- skope[reset_method]()
4718
- .done( function() {
4719
- api.previewer.refresh()
4720
- .fail( function( refresh_data ) {
4721
- api.consoleLog('SKOPE RESET REFRESH FAILED', refresh_data );
4722
- })
4723
- .done( function( refresh_data ) {
4724
- if ( 'global' == api.czr_skope( skope_id )().skope && '_resetSkopeAPIValues' == reset_method ) {
4725
- var _sentSkopeCollection,
4726
- _serverGlobalDbValues = {},
4727
- _skope_opt_name = api.czr_skope( skope_id )().opt_name;
4728
 
4729
- if ( ! _.isUndefined( refresh_data.skopesServerData ) && _.has( refresh_data.skopesServerData, 'czr_skopes' ) ) {
4730
- _sentSkopeCollection = refresh_data.skopesServerData.czr_skopes;
4731
- if ( _.isUndefined( _.findWhere( _sentSkopeCollection, { opt_name : _skope_opt_name } ) ) ) {
4732
- _serverGlobalDbValues = _.findWhere( _sentSkopeCollection, { opt_name : _skope_opt_name } ).db || {};
4733
- }
4734
- }
4735
- api.czr_skopeBase.maybeSynchronizeGlobalSkope( { isGlobalReset : true, isSkope : true, skopeIdToReset : skope_id } )
4736
- .done( function() {
4737
- _silentUpdate();
4738
- });
4739
- } else {
4740
- _silentUpdate();
4741
- }
4742
- });
4743
 
4744
- });
4745
- };//_updateAPI
 
4746
 
4747
- $('body').addClass('czr-resetting-skope');
4748
- api.czr_skopeReset[ skope.dirtyness() ? 'resetChangeset' : 'resetPublished' ](
4749
- { skope_id : skope().id, is_skope : true } )
4750
- .always( function() {
4751
- $('body').removeClass('czr-resetting-skope');//hides the spinner
4752
- })
4753
- .done( function( r ) {
4754
- _updateAPI();
4755
- })
4756
- .fail( function( r ) {
4757
- skope.skopeResetDialogVisibility( false );
4758
- api.consoleLog('Skope reset failed', r );
4759
- });
4760
- },
4761
- _resetSkopeDirties : function() {
4762
- var skope = this, dfd = $.Deferred();
4763
- skope.dirtyValues({});
4764
- skope.changesetValues({});
4765
- return dfd.resolve().promise();
4766
- },
4767
- _resetSkopeAPIValues : function() {
4768
- var skope = this, dfd = $.Deferred();
4769
- skope.dbValues( {} );
4770
- return dfd.resolve().promise();
4771
- }
4772
- });//$.extend(
4773
- })( wp.customize , jQuery, _ );
4774
- ( function ( api, $, _ ) {
4775
- /*****************************************************************************
4776
- * A "CONTEXT AWARE" SET METHD
4777
- *****************************************************************************/
4778
- /**
4779
- * OVERRIDES BASE api.Value method
4780
- * => adds the o {} param, allowing to pass additional contextual informations.
4781
- *
4782
- * Set the value and trigger all bound callbacks.
4783
- *
4784
- * @param {object} to New value.
4785
- */
4786
- api.Value.prototype.set = function( to, o ) {
4787
- var from = this._value, dfd = $.Deferred(), self = this, _promises = [];
4788
 
4789
- to = this._setter.apply( this, arguments );
4790
- to = this.validate( to );
4791
- args = _.extend( { silent : false }, _.isObject( o ) ? o : {} );
4792
- if ( null === to || _.isEqual( from, to ) ) {
4793
- return dfd.resolveWith( self, [ to, from, o ] ).promise();
4794
- }
 
 
 
 
 
 
 
 
 
4795
 
4796
- this._value = to;
4797
- this._dirty = true;
4798
- if ( true === args.silent ) {
4799
- return dfd.resolveWith( self, [ to, from, o ] ).promise();
4800
- }
4801
 
4802
- if ( this._deferreds ) {
4803
- _.each( self._deferreds, function( _prom ) {
4804
- _promises.push( _prom.apply( null, [ to, from, o ] ) );
4805
- });
4806
 
4807
- $.when.apply( null, _promises )
4808
- .fail( function() { api.errorLog( 'A deferred callback failed in api.Value::set()'); })
4809
- .then( function() {
4810
- self.callbacks.fireWith( self, [ to, from, o ] );
4811
- dfd.resolveWith( self, [ to, from, o ] );
4812
- });
4813
- } else {
4814
- this.callbacks.fireWith( this, [ to, from, o ] );
4815
- return dfd.resolveWith( self, [ to, from, o ] ).promise( self );
 
 
 
 
 
 
 
 
 
 
 
 
4816
  }
4817
- return dfd.promise( self );
4818
  };
4819
- api.Value.prototype.bind = function() {
4820
- var self = this,
4821
- _isDeferred = false,
4822
- _cbs = [];
4823
 
4824
- $.each( arguments, function( _key, _arg ) {
4825
- if ( ! _isDeferred )
4826
- _isDeferred = _.isObject( _arg ) && _arg.deferred;
4827
- if ( _.isFunction( _arg ) )
4828
- _cbs.push( _arg );
4829
- });
4830
 
4831
- if ( _isDeferred ) {
4832
- self._deferreds = self._deferreds || [];
4833
- _.each( _cbs, function( _cb ) {
4834
- if ( ! _.contains( _cb, self._deferreds ) )
4835
- self._deferreds.push( _cb );
4836
- });
4837
- } else {
4838
- self.callbacks.add.apply( self.callbacks, arguments );
4839
- }
4840
- return this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4841
  };
4842
 
4843
- /*****************************************************************************
4844
- * A SILENT SET METHOD :
4845
- * => keep the dirtyness param unchanged
4846
- * => stores the api state before callback calls, and reset it after
4847
- * => add an object param to the callback to inform that this is a silent process
4848
- * , this is typically used in the overridden api.Setting.preview method
4849
- *****************************************************************************/
4850
- api.Setting.prototype.silent_set =function( to, dirtyness ) {
4851
- var from = this._value,
4852
- _save_state = api.state('saved')();
4853
 
4854
- to = this._setter.apply( this, arguments );
4855
- to = this.validate( to );
4856
- if ( null === to || _.isEqual( from, to ) ) {
4857
- return this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4858
  }
 
 
 
 
 
 
 
 
 
 
4859
 
4860
- this._value = to;
4861
- this._dirty = ( _.isUndefined( dirtyness ) || ! _.isBoolean( dirtyness ) ) ? this._dirty : dirtyness;
4862
-
4863
- this.callbacks.fireWith( this, [ to, from, { silent : true } ] );
4864
- api.state('saved')( _save_state );
4865
- return this;
4866
- };
4867
- })( wp.customize , jQuery, _ );
4868
- ( function ( api, $, _ ) {
4869
- /*****************************************************************************
4870
- * A SKOPE AWARE PREVIEWER QUERY
4871
- *****************************************************************************/
4872
- api.bind('ready', function() {
4873
- if ( ! serverControlParams.isSkopOn )
4874
- return;
4875
 
4876
- /**
4877
- * Build the query to send along with the Preview request.
4878
- *
4879
- * @return {object}
4880
- */
4881
- var _coreQuery = api.previewer.query;
4882
- api.previewer.query = function( queryVars ) {
4883
- if ( ! serverControlParams.isSkopOn ) {
4884
- return _coreQuery.apply( this );
4885
- }
4886
- if ( ! _.has( api, 'czr_skope') ) {
4887
- api.consoleLog('QUERY : SKOPE IS NOT FULLY READY YEY. FALLING BACK ON CORE QUERY');
4888
- return _coreQuery.apply( this );
4889
- }
4890
- if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() ) {
4891
- api.consoleLog('QUERY : INITIAL SKOPE COLLECTION NOT POPULATED YET. FALLING BACK ON CORE QUERY');
4892
- return _coreQuery.apply( this );
4893
- }
4894
- if ( 'pending' == api.czr_isPreviewerSkopeAware.state() ) {
4895
- api.czr_isPreviewerSkopeAware.resolve();
4896
  }
4897
- if ( ! _.isObject( queryVars ) && 'resolved' == api.czr_initialSkopeCollectionPopulated.state() && 'resolved' == api.czr_initialSkopeCollectionPopulated.state() ) {
4898
- return _coreQuery.apply( this );
 
 
 
4899
  }
4900
- if ( _.isUndefined( queryVars.skope_id ) || ! _.isString( queryVars.skope_id ) ) {
4901
- queryVars.skope_id = api.czr_activeSkopeId() || api.czr_skopeBase.getGlobalSkopeId();
 
 
 
4902
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
4903
 
4904
- var globalCustomized = {},
4905
- skopeCustomized = {},
4906
- _defaults = {
4907
- skope_id : null,
4908
- action : null,
4909
- the_dirties : {},
4910
- dyn_type : null,
4911
- opt_name : null
4912
- },
4913
- _to_return;
4914
 
4915
- queryVars = $.extend( _defaults, queryVars );
4916
- if ( ! _.isObject( queryVars.the_dirties ) ) {
4917
- api.consoleLog('QUERY PARAMS : ', queryVars );
4918
- throw new Error( 'QUERY DIRTIES MUST BE AN OBJECT. Requested action : ' + queryVars.action );
4919
- }
4920
- if ( 'pending' != api.czr_isPreviewerSkopeAware.state() && _.isNull( queryVars.skope_id ) ) {
4921
- api.consoleLog('QUERY PARAMS : ', queryVars );
4922
- throw new Error( 'OVERRIDEN QUERY : NO SKOPE ID. FALLING BACK ON CORE QUERY. Requested action : ' + queryVars.action );
4923
- }
4924
- if ( ! _.contains( [ null, 'refresh', 'save', 'reset', 'changeset_update' ], queryVars.action ) ) {
4925
- api.consoleLog('QUERY PARAMS : ', queryVars );
4926
- throw new Error( 'A REQUESTED QUERY HAS NO AUTHORIZED ACTION. Requested action : ' + queryVars.action );
4927
- }
4928
- var _getSkopesCustomized = function() {
4929
  if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() )
4930
- return {};
4931
- var _skpCust = {};
4932
- _.each( api.czr_currentSkopesCollection(), function( _skp ) {
4933
- if ( 'global' == _skp.skope )
4934
- return;
4935
- _skpCust[_skp.id] = api.czr_skopeBase.getSkopeDirties( _skp.id );
4936
- } );
4937
- return _skpCust;
4938
- };
4939
- if ( _.isNull( queryVars.the_dirties ) || _.isEmpty( queryVars.the_dirties ) ) {
4940
- globalCustomized = api.dirtyValues( { unsaved: queryVars.excludeCustomizedSaved || false } );
4941
- skopeCustomized = _getSkopesCustomized();
4942
- } else {
4943
- if ( 'global' == api.czr_skopeBase.getActiveSkopeName() )
4944
- globalCustomized = queryVars.the_dirties;
4945
- else
4946
- skopeCustomized[ api.czr_activeSkopeId() ] = queryVars.the_dirties;
4947
- }
4948
- switch( queryVars.action ) {
4949
- case null :
4950
- case 'refresh' :
4951
- break;
4952
 
4953
- case 'changeset_update' :
4954
- if ( _.isUndefined( queryVars.opt_name ) ) {
4955
- throw new Error('Missing opt_name param in the changeset_update query for skope : ' + queryVars.skope_id );
4956
- }
4957
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4958
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4959
 
4960
- case 'save' :
4961
- if ( _.isNull( queryVars.dyn_type ) )
4962
- queryVars.dyn_type = api.czr_skope( queryVars.skope_id )().dyn_type;//post_meta, term_meta, user_meta, trans, option
4963
- if ( _.isNull( queryVars.dyn_type ) || _.isUndefined( queryVars.dyn_type ) ) {
4964
- throw new Error( 'QUERY : A SAVE QUERY MUST HAVE A VALID DYN TYPE.' + queryVars.skope_id );
4965
- }
4966
- break;
4967
 
4968
- case 'reset' :
4969
- if ( _.isNull( queryVars.dyn_type ) )
4970
- queryVars.dyn_type = api.czr_skope( queryVars.skope_id )().dyn_type;//post_meta, term_meta, user_meta, trans, option
4971
- if ( _.isNull( queryVars.dyn_type ) || _.isUndefined( queryVars.dyn_type ) ) {
4972
- throw new Error( 'QUERY : A RESET QUERY MUST HAVE A VALID DYN TYPE.' + queryVars.skope_id );
4973
- }
4974
- break;
4975
- }
4976
- var _current_skopes = {};
4977
- _.each( api.czr_currentSkopesCollection(), function( _skp ) {
4978
- _current_skopes[_skp.skope] = { id : _skp.id, opt_name : _skp.opt_name };
4979
- });
4980
- _to_return = {
4981
- wp_customize: 'on',
4982
- customized: '{}' == JSON.stringify( globalCustomized ) ? '{\"__not_customized__\"}' : JSON.stringify( globalCustomized ),
4983
- skopeCustomized: JSON.stringify( skopeCustomized ),
4984
- nonce: this.nonce.preview,
4985
- skope: api.czr_skope( queryVars.skope_id )().skope,
4986
- level_id: api.czr_skope( queryVars.skope_id )().level,
4987
- skope_id: queryVars.skope_id,
4988
- dyn_type: queryVars.dyn_type,
4989
- opt_name: ! _.isNull( queryVars.opt_name ) ? queryVars.opt_name : api.czr_skope( queryVars.skope_id )().opt_name,
4990
- obj_id: api.czr_skope( queryVars.skope_id )().obj_id,
4991
- current_skopes: JSON.stringify( _current_skopes ) || {},
4992
- channel: this.channel(),
4993
- revisionIndex: api._latestRevision
4994
- };
4995
- if ( api.czr_isChangeSetOn() ) {
4996
- _to_return = $.extend( _to_return , {
4997
- customize_theme: api.settings.theme.stylesheet,
4998
- customize_changeset_uuid: api.settings.changeset.uuid
4999
- });
5000
- }
5001
- else {
5002
- _to_return = $.extend( _to_return , {
5003
- theme: api.settings.theme.stylesheet
5004
- });
5005
- }
5006
- return _to_return;
5007
 
5008
- };//api.previewer.query
5009
- });//api.bind('ready')
5010
  })( wp.customize , jQuery, _ );
5011
  ( function ( api, $, _ ) {
5012
- api.bind( 'czr-skope-started', function() {
5013
- api.previewer.save = function( args ) {
5014
- return api.czr_skopeSave.save();
5015
- };
5016
- });//api.bind('ready')
5017
- })( wp.customize , jQuery, _ );
5018
- (function (api, $, _) {
5019
- if ( ! serverControlParams.isSkopOn )
5020
- return;
5021
-
5022
  /*****************************************************************************
5023
- * SYNCHRONIZER AUGMENTED
5024
  *****************************************************************************/
5025
- api.Element.synchronizer.checkbox.update = function( to ) {
5026
- this.element.prop( 'checked', to );
5027
- this.element.iCheck('update');
5028
- };
5029
-
5030
- var _original = api.Element.synchronizer.val.update;
5031
- api.Element.synchronizer.val.update = function(to) {
5032
- var self = this,
5033
- _modifySynchronizer = function() {
5034
- if ( self.element.is('select') ) {
5035
- self.element.val(to).trigger('change');
5036
- } else if ( self.element.hasClass('wp-color-picker') ) {
5037
- self.element.val(to).trigger('change');
5038
- }
5039
- else {
5040
- self.element.val( to );
5041
- }
5042
- };
5043
  if ( serverControlParams.isSkopOn ) {
5044
- if ( 'resolved' != api.czr_skopeReady.state() ) {
5045
- return _original.call( self, to );
5046
- } else {
5047
- api.czr_skopeReady.then( function () {
5048
- _modifySynchronizer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5049
  });
 
 
 
 
 
 
 
 
5050
  }
5051
- } else {
5052
- _modifySynchronizer();
5053
  }
5054
- };
5055
-
5056
- api.Element.synchronizer.val.refresh = function() {
5057
- var syncApiInstance = this;
5058
- if ( this.element.is('select') && _.isNull( this.element.val() ) ) {
5059
- if ( _.isArray( syncApiInstance() ) )
5060
- return [];
5061
- else if ( _.isObject( syncApiInstance() ) )
5062
- return {};
5063
- else
5064
- return '';
5065
- } else {
5066
- return this.element.val();
5067
  }
5068
- };
5069
- })( wp.customize , jQuery, _ );
5070
- ( function ( api, $, _ ) {
5071
- var coreRefresh = api.Previewer.prototype.refresh;
5072
- var _new_refresh = function( params ) {
5073
- params = _.extend({
5074
- waitSkopeSynced : true,
5075
- the_dirties : {}
5076
- },
5077
- params
5078
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5079
 
5080
- var previewer = this, dfd = $.Deferred();
5081
- if ( ! serverControlParams.isSkopOn ) {
5082
- return dfd.resolve().promise();
5083
- }
5084
- if ( ! _.has( api, 'czr_activeSkopeId') || _.isUndefined( api.czr_activeSkopeId() ) ) {
5085
- api.consoleLog( 'The api.czr_activeSkopeId() is undefined in the api.previewer._new_refresh() method.');
5086
- coreRefresh.apply( previewer );
5087
- return dfd.resolve().promise();
5088
  }
5089
- previewer.send( 'loading-initiated' );
5090
-
5091
- previewer.abort();
5092
-
5093
- var query_params = api.czr_getSkopeQueryParams({
5094
- skope_id : api.czr_activeSkopeId(),
5095
- action : 'refresh',
5096
- the_dirties : params.the_dirties || {}
5097
- });
5098
 
5099
- previewer.loading = new api.PreviewFrame({
5100
- url: previewer.url(),
5101
- previewUrl: previewer.previewUrl(),
5102
- query: previewer.query( query_params ) || {},
5103
- container: previewer.container,
5104
- signature: 'WP_CUSTOMIZER_SIGNATURE'//will be deprecated in 4.7
5105
  });
5106
-
5107
-
5108
- previewer.settingsModifiedWhileLoading = {};
5109
- onSettingChange = function( setting ) {
5110
- previewer.settingsModifiedWhileLoading[ setting.id ] = true;
5111
- };
5112
- api.bind( 'change', onSettingChange );
5113
-
5114
- previewer.loading.always( function() {
5115
- api.unbind( 'change', onSettingChange );
5116
- } );
5117
- if ( ! api.czr_isChangeSetOn() ) {
5118
- previewer._previousPreview = previewer._previousPreview || previewer.preview;
5119
  }
 
5120
 
5121
- previewer.loading.done( function( readyData ) {
5122
- var loadingFrame = this, onceSynced;
5123
 
5124
- previewer.preview = loadingFrame;
5125
- previewer.targetWindow( loadingFrame.targetWindow() );
5126
- previewer.channel( loadingFrame.channel() );
5127
- onceSynced = function( skopesServerData ) {
5128
- loadingFrame.unbind( 'synced', onceSynced );
5129
- loadingFrame.unbind( 'czr-skopes-synced', onceSynced );
5130
 
5131
- if ( previewer._previousPreview ) {
5132
- previewer._previousPreview.destroy();
5133
- } //before WP 4.7
5134
- else {
5135
- if ( previewer.preview )
5136
- previewer.preview.destroy();
5137
- }
5138
 
5139
- previewer._previousPreview = previewer.preview;
5140
- previewer.deferred.active.resolve();
5141
- delete previewer.loading;
5142
 
5143
- api.trigger( 'pre_refresh_done', { previewer : previewer, skopesServerData : skopesServerData || {} } );
5144
- dfd.resolve( { previewer : previewer, skopesServerData : skopesServerData || {} } );
5145
- };
5146
- if ( ! api.czr_isChangeSetOn() ) {
5147
- previewer.send( 'sync', {
5148
- scroll: previewer.scroll,
5149
- settings: api.get()
5150
- });
5151
- }
5152
 
5153
- if ( params.waitSkopeSynced ) {
5154
- loadingFrame.bind( 'czr-skopes-synced', onceSynced );
5155
- } else {
5156
- loadingFrame.bind( 'synced', onceSynced );
5157
- }
5158
- previewer.trigger( 'ready', readyData );
5159
- });
5160
- previewer.loading.fail( function( reason, location ) {
5161
- api.consoleLog('LOADING FAILED : ' , arguments );
5162
- previewer.send( 'loading-failed' );
5163
- if ( ! api.czr_isChangeSetOn() ) {
5164
- if ( 'redirect' === reason && location ) {
5165
- previewer.previewUrl( location );
5166
- }
5167
- }
5168
 
5169
- if ( 'logged out' === reason ) {
5170
- if ( previewer.preview ) {
5171
- previewer.preview.destroy();
5172
- delete previewer.preview;
5173
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5174
 
5175
- previewer.login().done( previewer.refresh );
5176
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5177
 
5178
- if ( 'cheatin' === reason ) {
5179
- previewer.cheatin();
5180
- }
5181
- dfd.reject( reason );
5182
- });
 
 
 
 
 
 
 
 
 
 
5183
 
5184
- return dfd.promise();
5185
- };//_new_refresh()
5186
- api.bind( 'czr-skope-started' , function() {
5187
- czr_override_refresh_for_skope();
5188
- api.Previewer.prototype.refresh = _new_refresh;
5189
- });
5190
- api.czr_getSkopeQueryParams = function( params ) {
5191
- if ( ! api.czr_isChangeSetOn() )
5192
- return params;
5193
- params = ! _.isObject(params) ? {} : params;
5194
- var _action = params.action || 'refresh';
5195
- switch( _action ) {
5196
- case 'refresh' :
5197
- params = $.extend( params, { excludeCustomizedSaved: true } );
5198
- break;
5199
- }
5200
- return params;
5201
- };
5202
- czr_override_refresh_for_skope = function() {
5203
- if ( ! serverControlParams.isSkopOn )
5204
- return;
5205
 
5206
 
5207
- /**
5208
- * Refresh the preview.
5209
- */
5210
- api.previewer.refresh = function( _params_ ) {
5211
- var dfd = $.Deferred();
5212
- var _refresh_ = function( params ) {
5213
- var refreshOnceProcessingComplete,
5214
- isProcessingComplete = function() {
5215
- return 0 === api.state( 'processing' ).get();
5216
- },
5217
- resolveRefresh = function() {
5218
- _new_refresh.call( api.previewer, params ).done( function( refresh_data ) {
5219
- dfd.resolve( refresh_data );
5220
- });
5221
- };
5222
- if ( isProcessingComplete() ) {
5223
- resolveRefresh();
5224
- } else {
5225
- refreshOnceProcessingComplete = function() {
5226
- if ( isProcessingComplete() ) {
5227
- resolveRefresh();
5228
- api.state( 'processing' ).unbind( refreshOnceProcessingComplete );
5229
- }
5230
- };
5231
- api.state( 'processing' ).bind( refreshOnceProcessingComplete );
5232
- }
5233
- };
5234
- _refresh_ = _.debounce( _refresh_, api.previewer.refreshBuffer );
5235
- _refresh_( _params_ );
5236
- return dfd.promise();
5237
- };
5238
- };//czr_override_refresh_for_skope
5239
- })( wp.customize , jQuery, _ );
5240
- ( function ( api, $, _ ) {
5241
- if ( ! serverControlParams.isSkopOn )
5242
- return;
5243
 
5244
- /**
5245
- * Get the dirty setting values.
5246
- * Overrides the default method introduced in 4.7
5247
- * !! This method only returns the dirties of the global skope !!
5248
- *
5249
- * @param {object} [options] Options.
5250
- * @param {boolean} [options.unsaved=false] Whether only values not saved yet into a changeset will be returned (differential changes).
5251
- * @returns {object} Dirty setting values.
5252
- */
5253
- api.dirtyValues = function dirtyValues( options ) {
5254
- return api.czr_skopeBase.getSkopeDirties( api.czr_skopeBase.getGlobalSkopeId(), options );
5255
- };
5256
 
5257
- })( wp.customize , jQuery, _ );
5258
- ( function ( api, $, _ ) {
5259
- if ( ! serverControlParams.isSkopOn || ! api.czr_isChangeSetOn() )
5260
- return;
5261
- var _original_requestChangesetUpdate = api.requestChangesetUpdate;
5262
 
5263
- /**
5264
- * Request updates to the changeset.
5265
- * Always calls the original method when the first promise (the skope changeset save) has been executed.
5266
- * Returns the $ promise with the set of data from the original method
5267
- *
5268
- * @param {object} [changes] Mapping of setting IDs to setting params each normally including a value property, or mapping to null.
5269
- * If not provided, then the changes will still be obtained from unsaved dirty settings.
5270
- * @returns {jQuery.Promise}
5271
- */
5272
- api.requestChangesetUpdate = function( changes ) {
5273
- var self = this,
5274
- dfd = $.Deferred(),
5275
- data,
5276
- _skopesToUpdate = [],
5277
- _promises = [],
5278
- _global_skope_changes = changes || {},
5279
- failedPromises = [],
5280
- _all_skopes_data_ = [],
5281
- _recursiveCallDeferred = $.Deferred();
5282
- if ( ! serverControlParams.isSkopOn ) {
5283
- return _original_requestChangesetUpdate();
5284
- }
5285
- if ( 0 === api._lastSavedRevision || _.isEmpty( api.state( 'changesetStatus' )() ) ) {
5286
- _global_skope_changes = _.extend( _global_skope_changes, {
5287
- blogname : { dummy_change : 'dummy_change' }
5288
- } );
5289
- }
5290
- _.each( api.czr_currentSkopesCollection(), function( _skp ) {
5291
- if ( 'global' == _skp.skope )
5292
- return;
5293
- _skopesToUpdate.push( _skp.id );
5294
- } );
5295
 
5296
- var _mayBeresolve = function( _index ) {
5297
- if ( ! _.isUndefined( _skopesToUpdate[ _index + 1 ] ) || _promises.length != _skopesToUpdate.length )
5298
- return;
5299
 
5300
- if ( _.isEmpty( failedPromises ) ) {
5301
- _recursiveCallDeferred.resolve( _all_skopes_data_ );
5302
- } else {
5303
- var _buildResponse = function() {
5304
- var _failedResponse = [];
5305
- _.each( failedPromises, function( _r ) {
5306
- _failedResponse.push( api.czr_skopeBase.buildServerResponse( _r ) );
5307
- } );
5308
- return $.trim( _failedResponse.join( ' | ') );
5309
- };
5310
- _recursiveCallDeferred.reject( _buildResponse() );
5311
- }
5312
- return true;
5313
- };
5314
- var recursiveCall = function( _index ) {
5315
- if ( _.isUndefined( _index ) || ( ( 0 * 0 ) == _index ) ) {
5316
- api.state( 'processing' ).set( 1 );
5317
- }
5318
 
5319
- _index = _index || 0;
5320
- if ( _.isUndefined( _skopesToUpdate[_index] ) ) {
5321
- api.consoleLog( 'Undefined Skope in changeset recursive call ', _index, _skopesToUpdate, _skopesToUpdate[_index] );
5322
- return _recursiveCallDeferred.resolve( _all_skopes_data_ ).promise();
5323
- }
5324
- api._requestSkopeChangetsetUpdate( changes, _skopesToUpdate[_index] )
5325
- .always( function() { _promises.push( _index ); } )
5326
- .fail( function( response ) {
5327
- failedPromises.push( response );
5328
- api.consoleLog('CHANGESET UPDATE RECURSIVE FAIL FOR SKOPE : ', _skopesToUpdate[_index] );
5329
- if ( ! _mayBeresolve( _index ) )
5330
- recursiveCall( _index + 1 );
5331
- } )
5332
- .done( function( _skope_data_ ) {
5333
- _all_skopes_data_.push( _skope_data_ );
5334
- if ( ! _mayBeresolve( _index ) )
5335
- recursiveCall( _index + 1 );
5336
- } );
5337
 
5338
- return _recursiveCallDeferred.promise();
5339
- };
5340
- var _lastSavedRevisionBefore = api._lastSavedRevision;
5341
- _original_requestChangesetUpdate( _global_skope_changes )
5342
- .fail( function( r ) {
5343
- api.consoleLog( 'WP requestChangesetUpdateFail', r, api.czr_skopeBase.buildServerResponse(r) );
5344
- api._lastSavedRevision = Math.max( api._latestRevision, api._lastSavedRevision );
5345
- api.state( 'processing' ).set( 0 );
5346
 
5347
- dfd.reject( r );
5348
- r = api.czr_skopeBase.buildServerResponse(r);
5349
- api.czr_serverNotification( { message: r, status : 'error' } );
5350
- })
5351
- .done( function( wp_original_response ) {
5352
- if ( 'pending' == api.czr_initialSkopeCollectionPopulated.state() )
5353
- dfd.resolve( wp_original_response );
5354
 
5355
- api._lastSavedRevision = _lastSavedRevisionBefore;
5356
- recursiveCall()
5357
- .always( function() {
5358
- api._lastSavedRevision = Math.max( api._latestRevision, api._lastSavedRevision );
5359
- api.state( 'processing' ).set( 0 );
5360
- })
5361
- .fail( function( r ) {
5362
- dfd.reject( r );
5363
- api.consoleLog( 'CHANGESET UPDATE RECURSIVE PUSH FAIL', r , _all_skopes_data_ );
5364
- api.trigger( 'changeset-error', r );
5365
- api.czr_serverNotification( { message: r, status : 'error' } );
5366
- } )
5367
- .done( function() {
5368
- dfd.resolve( wp_original_response );
5369
- });
5370
- });
5371
 
5372
- return dfd.promise();
5373
- };
5374
- api._requestSkopeChangetsetUpdate = function( changes, skope_id ) {
5375
- if ( _.isUndefined( skope_id ) || ! api.czr_skope.has( skope_id ) ) {
5376
- throw new Error( 'In api._requestSkopeChangetsetUpdate() : a valid and registered skope_id must be provided' );
5377
- }
5378
 
5379
- var deferred = new $.Deferred(),
5380
- request,
5381
- submittedChanges = {},
5382
- data;
5383
- skope_id = skope_id || api.czr_activeSkopeId();
5384
 
5385
- if ( changes ) {
5386
- _.extend( submittedChanges, changes );
5387
- }
5388
- _.each( api.czr_skopeBase.getSkopeDirties( skope_id ) , function( dirtyValue, settingId ) {
5389
- if ( ! changes || null !== changes[ settingId ] ) {
5390
- submittedChanges[ settingId ] = _.extend(
5391
- {},
5392
- submittedChanges[ settingId ] || {},
5393
- { value: dirtyValue }
5394
- );
5395
- }
5396
- } );
5397
- if ( _.isEmpty( submittedChanges ) ) {
5398
- deferred.resolve( {} );
5399
- return deferred.promise();
5400
- }
5401
 
5402
- if ( api._latestRevision <= api._lastSavedRevision ) {
5403
- deferred.resolve( {} );
5404
- return deferred.promise();
5405
- }
5406
- api.trigger( 'skope-changeset-save', submittedChanges );
5407
 
5408
- var queryVars = {
5409
- skope_id : skope_id,
5410
- action : 'changeset_update',
5411
- opt_name : api.czr_skope( skope_id ).opt_name
5412
- };
5413
- data = api.previewer.query( _.extend( queryVars, { excludeCustomizedSaved: true } ) );
5414
- delete data.customized; // Being sent in customize_changeset_data instead.
5415
- _.extend( data, {
5416
- nonce: api.settings.nonce.save,
5417
- customize_changeset_data: JSON.stringify( submittedChanges )
5418
- } );
5419
- wp.ajax.post( 'customize_skope_changeset_save', data )
5420
- .done( function requestChangesetUpdateDone( _data_ ) {
5421
- deferred.resolve( _data_ );
5422
- } )
5423
- .fail( function requestChangesetUpdateFail( _data_ ) {
5424
- api.consoleLog('SKOPE CHANGESET FAIL FOR SKOPE ' + _data_.skope_id, _data_ );
5425
- deferred.reject( _data_ );
5426
- } )
5427
- .always( function( _data_ ) {
5428
- if ( _data_.setting_validities ) {
5429
- api._handleSettingValidities( {
5430
- settingValidities: _data_.setting_validities
5431
- } );
5432
- }
5433
- } );
5434
 
5435
- return deferred.promise();
5436
- };
5437
- })( wp.customize , jQuery, _ );
5438
- ( function ( api, $, _ ) {
5439
- api.Setting.prototype.initialize = function( id, value, options ) {
5440
- var setting = this;
5441
- api.Value.prototype.initialize.call( setting, value, options );
5442
 
5443
- setting.id = id;
5444
- setting.transport = setting.transport || 'refresh';
5445
- setting._dirty = options.dirty || false;
5446
- setting.notifications = new api.Values({ defaultConstructor: api.Notification });
5447
- setting.bind( setting.preview );
5448
- };
5449
- api.Setting.prototype.preview = function( to, from , data ) {
5450
- var setting = this, transport, dfd = $.Deferred();
5451
 
5452
- transport = setting.transport;
5453
 
5454
- if ( serverControlParams.isSkopOn && api.czr_isPreviewerSkopeAware && 'pending' == api.czr_isPreviewerSkopeAware.state() ) {
5455
- this.previewer.refresh();
5456
- return dfd.resolve( arguments ).promise();
5457
- }
5458
- if ( ! _.isUndefined( from ) && ! _.isEmpty( from ) && ! _.isNull( from ) ) {
5459
- if ( _.isObject( data ) && true === data.not_preview_sent ) {
5460
- return dfd.resolve( arguments ).promise();
5461
- }
5462
- }
5463
- if ( _.has( data, 'silent' ) && false !== data.silent )
5464
- return dfd.resolve( arguments ).promise();
5465
- if ( 'postMessage' === transport && ! api.state( 'previewerAlive' ).get() ) {
5466
- transport = 'refresh';
5467
- }
5468
 
5469
- if ( 'postMessage' === transport ) {
5470
- setting.previewer.send( 'pre_setting', {
5471
- set_id : setting.id,
5472
- data : data,//<= { module_id : 'string', module : {} } which typically includes the module_id and the module model ( items, mod options )
5473
- value : to
5474
- });
5475
- setting.previewer.send( 'setting', [ setting.id, setting() ] );
5476
 
5477
- dfd.resolve( arguments );
5478
 
5479
- } else if ( 'refresh' === transport ) {
5480
- if ( serverControlParams.isSkopOn ) {
5481
- setting.previewer.refresh().always( function() {
5482
- dfd.resolve( arguments );
5483
- });
5484
- } else {
5485
- setting.previewer.refresh();
5486
- dfd.resolve( arguments );
5487
- }
5488
- }
5489
 
5490
- return dfd.promise();
5491
- };//api.Setting.prototype.preview
5492
- })( wp.customize , jQuery, _ );
5493
- ( function ( api, $, _ ) {
5494
- /* monkey patch for the content height set */
5495
- if ( 'function' == typeof api.Section ) {
5496
- var _original_section_initialize = api.Section.prototype.initialize;
5497
- api.Section.prototype.initialize = function( id, options ) {
5498
- _original_section_initialize.apply( this, [id, options] );
5499
- var section = this;
5500
 
5501
- this.expanded.callbacks.add( function( _expanded ) {
5502
- if ( ! _expanded )
5503
- return;
 
 
 
 
5504
 
5505
- var container = section.container.closest( '.wp-full-overlay-sidebar-content' ),
5506
- content = section.container.find( '.accordion-section-content' );
5507
- _resizeContentHeight = function() {
5508
- content.css( 'height', container.innerHeight() );
5509
- };
5510
- _resizeContentHeight();
5511
- $( window ).on( 'resize.customizer-section', _.debounce( _resizeContentHeight, 110 ) );
5512
- });
5513
- };
5514
- }
5515
- })( wp.customize , jQuery, _ );
5516
- (function (api, $, _) {
5517
- api.CZR_Helpers = api.CZR_Helpers || {};
5518
- api.CZR_Helpers = $.extend( api.CZR_Helpers, {
5519
- getControlSettingId : function( control_id, setting_type ) {
5520
- setting_type = 'default' || setting_type;
5521
- if ( ! api.control.has( control_id ) ) {
5522
- api.consoleLog( 'getControlSettingId : The requested control_id is not registered in the api yet : ' + control_id );
5523
- return control_id;
5524
- }
5525
- if ( ! _.has( api.control( control_id ), 'settings' ) || _.isEmpty( api.control( control_id ).settings ) )
5526
- return control_id;
5527
 
5528
- if ( ! _.has( api.control( control_id ).settings, setting_type ) ) {
5529
- api.consoleLog( 'getControlSettingId : The requested control_id does not have the requested setting type : ' + control_id + ' , ' + setting_type );
5530
- return control_id;
5531
- }
5532
- if ( _.isUndefined( api.control( control_id ).settings[setting_type].id ) ) {
5533
- api.consoleLog( 'getControlSettingId : The requested control_id has no setting id assigned : ' + control_id );
5534
- return control_id;
5535
- }
5536
- return api.control( control_id ).settings[setting_type].id;
5537
- },
5538
 
5539
 
5540
 
5541
- getDocSearchLink : function( text ) {
5542
- text = ! _.isString(text) ? '' : text;
5543
- var _searchtext = text.replace( / /g, '+'),
5544
- _url = [ serverControlParams.docURL, 'search?query=', _searchtext ].join('');
5545
- return [
5546
- '<a href="' + _url + '" title="' + serverControlParams.i18n.readDocumentation + '" target="_blank">',
5547
- ' ',
5548
- '<span class="fa fa-question-circle-o"></span>'
5549
- ].join('');
5550
- },
5551
 
5552
 
5553
- /*
5554
- * @return string
5555
- * simple helper to build the setting wp api ready id
5556
- */
5557
- build_setId : function ( setId ) {
5558
- if ( _.contains( serverControlParams.wpBuiltinSettings, setId ) )
5559
- return setId;
5560
- if ( ! _.contains( serverControlParams.themeSettingList, setId ) )
5561
- return setId;
5562
 
5563
- return -1 == setId.indexOf( serverControlParams.themeOptions ) ? [ serverControlParams.themeOptions +'[' , setId , ']' ].join('') : setId;
5564
- },
5565
 
5566
- /*
5567
- * @return string
5568
- * simple helper to extract the option name from a setting id
5569
- */
5570
- getOptionName : function(name) {
5571
- var self = this;
5572
- if ( -1 == name.indexOf(serverControlParams.themeOptions) )
5573
- return name;
5574
- return name.replace(/\[|\]/g, '').replace(serverControlParams.themeOptions, '');
5575
- },
5576
- hasPartRefresh : function( setId ) {
5577
- if ( ! _.has( api, 'czr_partials') )
5578
- return;
5579
- return _.contains( _.map( api.czr_partials(), function( partial, key ) {
5580
- return _.contains( partial.settings, setId );
5581
- }), true );
5582
- },
5583
- getSectionControlIds : function( section_id ) {
5584
- section_id = section_id || api.czr_activeSectionId();
5585
- return ! api.section.has( section_id ) ?
5586
- [] :
5587
- _.map( api.section( section_id ).controls(), function( _ctrl ) {
5588
- return _ctrl.id;
5589
- });
5590
- },
5591
- getSectionSettingIds : function( section_id ) {
5592
- section_id = section_id || api.czr_activeSectionId();
5593
- if ( ! api.section.has( section_id) )
5594
- return;
5595
- var self = this,
5596
- _sec_settings = [],
5597
- _sec_controls = self.getSectionControlIds( section_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5598
 
5599
- _.each( _sec_controls, function( ctrlId ) {
5600
- _.each( api.control(ctrlId).settings, function( _instance, _k ) {
5601
- _sec_settings.push( _instance.id );
5602
- });
5603
- });
5604
- return _sec_settings;
5605
- },
5606
- capitalize : function( string ) {
5607
- if( ! _.isString(string) )
5608
- return string;
5609
- return string.charAt(0).toUpperCase() + string.slice(1);
5610
- },
 
 
 
 
 
5611
 
5612
- truncate : function( string, n, useWordBoundary ){
5613
- if ( ! _.isString( string ) )
5614
- return '';
5615
- n = n || 20;
5616
- var isTooLong = string.length > n,
5617
- s_ = isTooLong ? string.substr(0,n-1) : string;
5618
- s_ = (useWordBoundary && isTooLong) ? s_.substr(0,s_.lastIndexOf(' ')) : s_;
5619
- return isTooLong ? s_ + '...' : s_;
5620
- },
5621
- isMultiItemModule : function( module_type, moduleInst ) {
5622
- if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
5623
- return;
5624
- if ( _.isObject( moduleInst ) && _.has( moduleInst, 'module_type' ) )
5625
- module_type = moduleInst.module_type;
5626
- else if ( _.isUndefined( module_type ) || _.isNull( module_type ) )
5627
- return;
5628
- if ( ! _.has( api.czrModuleMap, module_type ) )
5629
- return;
5630
 
5631
- return api.czrModuleMap[module_type].crud || api.czrModuleMap[module_type].multi_item || false;
5632
- },
5633
- isCrudModule : function( module_type, moduleInst ) {
5634
- if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
5635
- return;
5636
- if ( _.isObject( moduleInst ) && _.has( moduleInst, 'module_type' ) )
5637
- module_type = moduleInst.module_type;
5638
- else if ( _.isUndefined( module_type ) || _.isNull( module_type ) )
5639
- return;
5640
- if ( ! _.has( api.czrModuleMap, module_type ) )
5641
- return;
 
 
5642
 
5643
- return api.czrModuleMap[module_type].crud || false;
5644
- },
5645
- hasModuleModOpt : function( module_type, moduleInst ) {
5646
- if ( _.isUndefined( module_type ) && ! _.isObject( moduleInst ) )
5647
- return;
5648
- if ( _.isObject( moduleInst ) && _.has( moduleInst, 'module_type' ) )
5649
- module_type = moduleInst.module_type;
5650
- else if ( _.isUndefined( module_type ) || _.isNull( module_type ) )
5651
- return;
5652
- if ( ! _.has( api.czrModuleMap, module_type ) )
 
 
5653
  return;
5654
-
5655
- return api.czrModuleMap[module_type].has_mod_opt || false;
5656
- },
5657
- setupInputCollectionFromDOM : function() {
5658
- var inputParentInst = this;//<= because fired with .call( inputParentInst )
5659
- if ( ! _.isFunction( inputParentInst ) ) {
5660
- throw new Error( 'setupInputCollectionFromDOM : inputParentInst is not valid.' );
5661
- }
5662
- var module = inputParentInst.module,
5663
- is_mod_opt = _.has( inputParentInst() , 'is_mod_opt' );
5664
- if ( _.has( inputParentInst, 'czr_Input') && ! _.isEmpty( inputParentInst.inputCollection() ) )
5665
  return;
5666
- inputParentInst.czr_Input = new api.Values();
5667
- inputParentInst.inputConstructor = is_mod_opt ? module.inputModOptConstructor : module.inputConstructor;
5668
 
5669
- var _defaultInputParentModel = is_mod_opt ? inputParentInst.defaultModOptModel : inputParentInst.defaultItemModel;
5670
 
5671
- if ( _.isEmpty( _defaultInputParentModel ) || _.isUndefined( _defaultInputParentModel ) ) {
5672
- throw new Error( 'No default model found in item or mod opt ' + inputParentInst.id + '.' );
5673
- }
5674
- var inputParentInst_model = $.extend( true, {}, inputParentInst() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5675
 
5676
- if ( ! _.isObject( inputParentInst_model ) )
5677
- inputParentInst_model = _defaultInputParentModel;
5678
- else
5679
- inputParentInst_model = $.extend( _defaultInputParentModel, inputParentInst_model );
 
 
 
 
 
5680
 
5681
- var dom_inputParentInst_model = {};
5682
- $( '.' + module.control.css_attr.sub_set_wrapper, inputParentInst.container).each( function( _index ) {
5683
- var _id = $(this).find('[data-type]').attr( 'data-type' ),
5684
- _value = _.has( inputParentInst_model, _id ) ? inputParentInst_model[ _id ] : '';
5685
- if ( _.isUndefined( _id ) || _.isEmpty( _id ) ) {
5686
- api.consoleLog( 'setupInputCollectionFromDOM : missing data-type for ' + module.id );
5687
- return;
5688
- }
5689
- if ( ! _.has( inputParentInst_model, _id ) ) {
5690
- 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.');
5691
- }
5692
- var _inputType = $(this).attr( 'data-input-type' ),
5693
- _inputTransport = $(this).attr( 'data-transport' ) || 'inherit',//<= if no specific transport ( refresh or postMessage ) has been defined in the template, inherits the control transport
5694
- _inputOptions = _.has( module.inputOptions, _inputType ) ? module.inputOptions[ _inputType ] : {};
5695
- inputParentInst.czr_Input.add( _id, new inputParentInst.inputConstructor( _id, {
5696
- id : _id,
5697
- type : _inputType,
5698
- transport : _inputTransport,
5699
- input_value : _value,
5700
- input_options : _inputOptions,//<= a module can define a specific set of option
5701
- container : $(this),
5702
- input_parent : inputParentInst,
5703
- is_mod_opt : is_mod_opt,
5704
- module : module
5705
- } ) );
5706
- inputParentInst.czr_Input( _id ).ready();
5707
- dom_inputParentInst_model[ _id ] = _value;
5708
- });//each
5709
- inputParentInst.inputCollection( dom_inputParentInst_model );
5710
- return inputParentInst;
5711
- },
5712
- removeInputCollection : function() {
5713
- var inputParentInst = this;//<= because fired with .call( inputParentInst )
5714
- if ( ! _.isFunction( inputParentInst ) ) {
5715
- throw new Error( 'removeInputCollection : inputParentInst is not valid.' );
5716
- }
5717
- if ( ! _.has( inputParentInst, 'czr_Input') )
5718
- return;
5719
- inputParentInst.czr_Input.each( function( _input ) {
5720
- inputParentInst.czr_Input.remove( _input.id );
5721
- });
5722
- inputParentInst.inputCollection({});
5723
- },
5724
- refreshModuleControl : function( wpSetId ) {
5725
- var _constructor = api.controlConstructor.czr_module,
5726
- _control_type = api.control( wpSetId ).params.type,
5727
- _control_data = api.settings.controls[wpSetId];
5728
- $.when( api.control( wpSetId ).container.remove() ).done( function() {
5729
- api.control.remove( wpSetId );
5730
- api.control.add( wpSetId, new _constructor( wpSetId, { params : _control_data, previewer : api.previewer }) );
5731
- });
5732
 
5733
- },
5734
- hexToRgb : function( hex ) {
5735
- var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
5736
- try {
5737
- hex = hex.replace(shorthandRegex, function(m, r, g, b) {
5738
- return r + r + g + g + b + b;
 
 
 
 
 
 
 
 
 
 
 
 
5739
  });
5740
- } catch( er ) {
5741
- api.errorLog( 'Error in Helpers::hexToRgb : ' + er );
5742
- return hex;
5743
  }
5744
-
5745
- var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec( hex );
5746
- result = result ? [
5747
- parseInt(result[1], 16),//r
5748
- parseInt(result[2], 16),//g
5749
- parseInt(result[3], 16)//b
5750
- ] : [];
5751
- return 'rgb(' + result.join(',') + ')';
5752
  },
5753
-
5754
- rgbToHex : function ( r, g, b ) {
5755
- var componentToHex = function(c) {
5756
- var hex = c.toString(16);
5757
- return hex.length == 1 ? "0" + hex : hex;
5758
- };
5759
- return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5760
  }
5761
-
5762
- });//$.extend
5763
  })( wp.customize , jQuery, _);
5764
- (function (api, $, _) {
5765
- api.CZR_Helpers = api.CZR_Helpers || {};
5766
- api.CZR_Helpers = $.extend( api.CZR_Helpers, {
5767
- addActions : function( event_map, new_events, instance ) {
5768
- var control = this;
5769
- instance = instance || control;
5770
- instance[event_map] = instance[event_map] || [];
5771
- new_event_map = _.clone( instance[event_map] );
5772
- instance[event_map] = _.union( new_event_map, ! _.isArray(new_events) ? [new_events] : new_events );
5773
- },
5774
-
5775
- doActions : function( action, $dom_el, obj ) {
5776
- $dom_el.trigger( action, obj );
5777
- },
5778
- setupDOMListeners : function( event_map , args, instance ) {
5779
- var control = this,
5780
- _defaultArgs = {
5781
- model : {},
5782
- dom_el : {}
5783
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5784
 
5785
- instance = instance || control;
5786
- if ( ! _.isArray( event_map ) ) {
5787
- api.errorLog( 'setupDomListeners : event_map should be an array', args );
5788
- return;
5789
- }
5790
- if ( ! _.isObject( args ) ) {
5791
- api.errorLog( 'setupDomListeners : args should be an object', event_map );
5792
- return;
5793
- }
5794
 
5795
- args = _.extend( _defaultArgs, args );
5796
- if ( ! args.dom_el instanceof jQuery || 1 != args.dom_el.length ) {
5797
- api.errorLog( 'setupDomListeners : dom element should be an existing dom element', args );
5798
- return;
5799
- }
5800
- _.map( event_map , function( _event ) {
5801
- if ( ! _.isString( _event.selector ) || _.isEmpty( _event.selector ) ) {
5802
- api.errorLog( 'setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : ' + _event.actions.join(',') );
5803
- return;
5804
- }
5805
- if ( ! _.isString( _event.selector ) || _.isEmpty( _event.selector ) ) {
5806
- api.errorLog( 'setupDOMListeners : selector must be a string not empty. Aborting setup of action(s) : ' + _event.actions.join(',') );
5807
- return;
5808
- }
5809
- args.dom_el.on( _event.trigger , _event.selector, function( e, event_params ) {
5810
- e.stopPropagation();
5811
- if ( api.utils.isKeydownButNotEnterEvent( e ) ) {
5812
- return;
5813
- }
5814
- e.preventDefault(); // Keep this AFTER the key filter above
5815
- var actionsParams = $.extend( true, {}, args );
5816
- if ( _.has( actionsParams, 'model') && _.has( actionsParams.model, 'id') ) {
5817
- if ( _.has( instance, 'get' ) )
5818
- actionsParams.model = instance();
5819
- else
5820
- actionsParams.model = instance.getModel( actionsParams.model.id );
5821
- }
5822
- $.extend( actionsParams, { event : _event, dom_event : e } );
5823
- $.extend( actionsParams, event_params );
5824
- if ( ! _.has( actionsParams, 'event' ) || ! _.has( actionsParams.event, 'actions' ) ) {
5825
- api.errorLog( 'executeEventActionChain : missing obj.event or obj.event.actions' );
5826
- return;
5827
- }
5828
- try { control.executeEventActionChain( actionsParams, instance ); } catch( er ) {
5829
- api.errorLog( 'In setupDOMListeners : problem when trying to fire actions : ' + actionsParams.event.actions );
5830
- api.errorLog( 'Error : ' + er );
5831
- }
5832
- });//.on()
5833
- });//_.map()
5834
- },//setupDomListeners
5835
- executeEventActionChain : function( args, instance ) {
5836
- var control = this;
5837
- if ( 'function' === typeof( args.event.actions ) )
5838
- return args.event.actions.call( instance, args );
5839
- if ( ! _.isArray( args.event.actions ) )
5840
- args.event.actions = [ args.event.actions ];
5841
- var _break = false;
5842
- _.map( args.event.actions, function( _cb ) {
5843
- if ( _break )
5844
- return;
5845
 
5846
- if ( 'function' != typeof( instance[ _cb ] ) ) {
5847
- throw new Error( 'executeEventActionChain : the action : ' + _cb + ' has not been found when firing event : ' + args.event.selector );
5848
- }
5849
- var $_dom_el = ( _.has(args, 'dom_el') && -1 != args.dom_el.length ) ? args.dom_el : control.container;
5850
 
5851
- $_dom_el.trigger( 'before_' + _cb, _.omit( args, 'event' ) );
5852
- var _cb_return = instance[ _cb ].call( instance, args );
5853
- if ( false === _cb_return )
5854
- _break = true;
5855
- $_dom_el.trigger( 'after_' + _cb, _.omit( args, 'event' ) );
5856
- });//_.map
 
 
 
5857
  }
5858
- });//$.extend
5859
- })( wp.customize , jQuery, _);
5860
- (function (api, $, _) {
5861
-
5862
- api.czr_wpQueryDataReady = $.Deferred();
5863
- api.czr_wpQueryInfos = api.czr_wpQueryInfos || new api.Value();
5864
- api.czr_partials = api.czr_partials || new api.Value();
5865
- /*****************************************************************************
5866
- * CAPTURE PREVIEW INFORMATIONS ON REFRESH + REACT TO THEM
5867
- *****************************************************************************/
5868
- api.bind( 'ready', function() {
5869
- api.previewer.bind('houston-widget-settings', function(data) {
5870
- var _candidates = _.filter( data.registeredSidebars, function( sb ) {
5871
- return ! _.findWhere( _wpCustomizeWidgetsSettings.registeredSidebars, { id: sb.id } );
5872
- });
5873
-
5874
- var _inactives = _.filter( data.registeredSidebars, function( sb ) {
5875
- return ! _.has( data.renderedSidebars, sb.id );
5876
- });
5877
-
5878
- _inactives = _.map( _inactives, function(obj) {
5879
- return obj.id;
5880
- });
5881
-
5882
- var _registered = _.map( data.registeredSidebars, function(obj) {
5883
- return obj.id;
5884
- });
5885
- api.czr_widgetZoneSettings = api.czr_widgetZoneSettings || new api.Value();//will store all widget zones data sent by preview as an observable object
5886
- api.czr_widgetZoneSettings.set( {
5887
- actives : data.renderedSidebars,
5888
- inactives : _inactives,
5889
- registered : _registered,
5890
- candidates : _candidates,
5891
- available_locations : data.availableWidgetLocations//built server side
5892
- } );
5893
-
5894
- });
5895
 
5896
- /* WP CONDITIONAL TAGS => stores and observes the WP conditional tags sent by the preview */
5897
- api.previewer.bind( 'czr-query-data-ready', function( data ) {
5898
- api.czr_wpQueryInfos( data );
5899
- if ( 'pending' == api.czr_wpQueryDataReady.state() ) {
5900
- api.czr_wpQueryDataReady.resolve( data );
5901
- }
5902
- });
5903
- api.previewer.bind( 'czr-partial-refresh-data', function( data ) {
5904
- api.czr_partials.set( data );
5905
- });
5906
- api.previewer.bind( 'czr-partial-refresh-done', function( data ) {
5907
- if ( ! _.has( data, 'set_id' ) )
5908
- return;
5909
- var setId = api.CZR_Helpers.build_setId( data.set_id );
5910
- if ( ! api.has( setId ) )
5911
- return;
5912
- var ctrlId = api.CZR_Helpers.getControlSettingId( setId );
5913
- if ( ! api.control.has( ctrlId ) )
5914
- return;
5915
- api.control( ctrlId ).trigger( 'czr-partial-refresh-done' );
5916
- });
5917
- });//api.bind('ready')
5918
- })( wp.customize , jQuery, _ );var CZRInputMths = CZRInputMths || {};
5919
- ( function ( api, $, _ ) {
5920
- $.extend( CZRInputMths , {
5921
- initialize: function( name, options ) {
5922
- if ( _.isUndefined( options.input_parent ) || _.isEmpty(options.input_parent) ) {
5923
- throw new Error('No input_parent assigned to input ' + options.id + '. Aborting');
5924
  }
5925
- if ( _.isUndefined(options.module ) ) {
5926
- throw new Error('No module assigned to input ' + options.id + '. Aborting');
 
 
5927
  }
 
 
 
 
 
5928
 
5929
- api.Value.prototype.initialize.call( this, null, options );
 
 
 
 
 
 
 
 
5930
 
5931
- var input = this;
5932
- $.extend( input, options || {} );
5933
- input.isReady = $.Deferred();
5934
- if ( ! _.isUndefined(options.input_value) ) {
5935
- input.set( options.input_value );
 
 
 
5936
  }
5937
- if ( api.czrInputMap && _.has( api.czrInputMap, input.type ) ) {
5938
- var _meth = api.czrInputMap[ input.type ];
5939
- if ( _.isFunction( input[_meth]) ) {
5940
- input[_meth]( options.input_options || null );
5941
- }
5942
- } else {
5943
- api.consoleLog('Warning an input : ' + input.id + ' has no corresponding method defined in api.czrInputMap.');
5944
  }
5945
 
5946
- var trigger_map = {
5947
- text : 'keyup',
5948
- textarea : 'keyup',
5949
- password : 'keyup',
5950
- color : 'colorpickerchange',
5951
- range : 'input propertychange'
5952
- };
5953
- input.input_event_map = [
5954
- {
5955
- 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
5956
- selector : 'input[data-type], select[data-type], textarea[data-type]',
5957
- name : 'set_input_value',
5958
- actions : function( obj ) {
5959
- if ( ! _.has( input.input_parent, 'syncElements') || ! _.has( input.input_parent.syncElements, input.id ) ) {
5960
- throw new Error('WARNING : THE INPUT ' + input.id + ' HAS NO SYNCED ELEMENT.');
5961
- }
5962
- }//was 'updateInput'
5963
- }
5964
- ];
5965
- input.visible = new api.Value( true );
5966
- input.isReady.done( function() {
5967
- input.visible.bind( function( visible ) {
5968
- if ( visible )
5969
- input.container.stop( true, true ).slideDown( 200 );
5970
- else
5971
- input.container.stop( true, true ).slideUp( 200 );
5972
  });
 
5973
  });
5974
- input.enabled = new api.Value( true );
5975
- input.isReady.done( function() {
5976
- input.enabled.bind( function( enabled ) {
5977
- input.container.toggleClass( 'disabled', ! enabled );
 
 
 
 
 
 
 
 
5978
  });
5979
- });
5980
-
5981
- },
5982
- ready : function() {
5983
- var input = this;
5984
- input.setupDOMListeners( input.input_event_map , { dom_el : input.container }, input );
5985
- input.callbacks.add( function() { return input.inputReact.apply( input, arguments ); } );
5986
- $.when( input.setupSynchronizer() ).done( function() {
5987
- input.isReady.resolve( input );
5988
- } );
5989
-
5990
- },
5991
- setupSynchronizer: function() {
5992
- var input = this,
5993
- input_parent = input.input_parent,
5994
- $_input_el = input.container.find('[data-type]'),
5995
- is_textarea = input.container.find('[data-type]').is('textarea');
5996
- if ( is_textarea ) {
5997
- throw new Error('TO DO : THE TEXTAREA INPUT ARE NOT READY IN THE SYNCHRONIZER!');
5998
- }
5999
-
6000
- var syncElement = new api.Element( $_input_el );
6001
- input_parent.syncElements = input_parent.syncElements || {};
6002
- input_parent.syncElements[input.id] = syncElement;//adds the input syncElement to the collection
6003
- syncElement.sync( input );//sync with the input instance
6004
- syncElement.set( input() );
6005
- },
6006
- inputReact : function( to, from, data ) {
6007
- var input = this,
6008
- _current_input_parent = input.input_parent(),
6009
- _new_model = _.clone( _current_input_parent ),//initialize it to the current value
6010
- _isPreItemInput = input.is_preItemInput;
6011
- if ( ! input.enabled() )
6012
- return;
6013
- _new_model = ( ! _.isObject(_new_model) || _.isEmpty(_new_model) ) ? {} : _new_model;
6014
- _new_model[ input.id ] = to;
6015
- input.input_parent.set( _new_model, {
6016
- input_changed : input.id,
6017
- input_transport : input.transport,
6018
- 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.
6019
- } );
6020
- if ( ! _isPreItemInput ) {
6021
- input.input_parent.trigger( input.id + ':changed', to );
6022
- if ( ! _.isEmpty( from ) || ! _.isUndefined( from ) && 'postMessage' === input.transport ) {
6023
- input.module.sendInputToPreview( {
6024
- input_id : input.id,
6025
- input_parent_id : input.input_parent.id,
6026
- to : to,
6027
- from : from
6028
- } );
6029
- }
6030
- }
6031
- },
6032
-
6033
-
6034
- /*-----------------------------------------
6035
- SOME DEFAULT CALLBACKS
6036
- ------------------------------------------*/
6037
- setupColorPicker : function() {
6038
- var input = this;
6039
-
6040
- input.container.find('input').iris( {
6041
- palettes: true,
6042
- hide:false,
6043
- change : function( e, o ) {
6044
- $(this).val( o.color.toString() ).trigger('colorpickerchange').trigger('change');
6045
- }
6046
- });
6047
- },
6048
-
6049
- setupSelect : function() {
6050
- var input = this;
6051
- $('select', input.container ).not('.no-selecter-js')
6052
- .each( function() {
6053
- $(this).selecter({
6054
- });
6055
- });
6056
- },
6057
-
6058
- setupIcheck : function( obj ) {
6059
- var input = this;
6060
-
6061
- $( 'input[type=checkbox]', input.container ).each( function(e) {
6062
- if ( 0 !== $(this).closest('div[class^="icheckbox"]').length )
6063
- return;
6064
 
6065
- $(this).iCheck({
6066
- checkboxClass: 'icheckbox_flat-grey',
6067
- checkedClass: 'checked',
6068
- radioClass: 'iradio_flat-grey',
6069
- })
6070
- .on( 'ifChanged', function(e){
6071
- $(this).val( false === $(this).is(':checked') ? 0 : 1 );
6072
- $(e.currentTarget).trigger('change');
6073
- });
6074
- });
6075
- },
6076
 
6077
- setupStepper : function( obj ) {
6078
- var input = this;
6079
- $('input[type="number"]',input.container ).each( function( e ) {
6080
- $(this).stepper();
6081
  });
6082
- },
6083
- setupRangeSlider : function( options ) {
6084
- var input = this,
6085
- $handle,
6086
- _updateHandle = function(el, val) {
6087
- el.textContent = val + "%";
6088
- };
6089
 
6090
- $( input.container ).find('input').rangeslider( {
6091
- polyfill: false,
6092
- rangeClass: 'rangeslider',
6093
- disabledClass: 'rangeslider--disabled',
6094
- horizontalClass: 'rangeslider--horizontal',
6095
- verticalClass: 'rangeslider--vertical',
6096
- fillClass: 'rangeslider__fill',
6097
- handleClass: 'rangeslider__handle',
6098
- onInit: function() {
6099
- $handle = $('.rangeslider__handle', this.$range);
6100
- $('.rangeslider__handle', this.$range);
6101
- _updateHandle( $handle[0], this.value );
6102
- },
6103
- } ).on('input', function() {
6104
- _updateHandle( $handle[0], this.value );
6105
- });
6106
- }
6107
- });//$.extend
6108
- })( wp.customize , jQuery, _ );var CZRInputMths = CZRInputMths || {};
6109
  ( function ( api, $, _ ) {
6110
- $.extend( CZRInputMths , {
6111
- setupImageUploader : function() {
6112
- var input = this,
6113
- _model = input();
6114
- input.attachment = {};
6115
- if ( ! input.container )
6116
- return this;
6117
 
6118
- this.tmplRendered = $.Deferred();
6119
- this.setupContentRendering( _model, {} );
6120
- this.tmplRendered.done( function(){
6121
- input.czrImgUploaderBinding();
6122
- });
6123
- },
 
 
 
 
 
6124
 
6125
- setupContentRendering : function( to, from) {
6126
- var input = this, _attachment;
6127
- if ( ( input.attachment.id != to ) && from !== to ) {
6128
- if ( ! to ) {
6129
- input.attachment = {};
6130
- input.renderImageUploaderTemplate();
6131
- }
6132
- _attachment = wp.media.attachment( to );
6133
- if ( _.isObject( _attachment ) && _.has( _attachment, 'attributes' ) && _.has( _attachment.attributes, 'sizes' ) ) {
6134
- input.attachment = _attachment.attributes;
6135
- input.renderImageUploaderTemplate();
6136
- } else {
6137
- wp.media.attachment( to ).fetch().done( function() {
6138
- input.attachment = this.attributes;
6139
- input.renderImageUploaderTemplate();
6140
- });
6141
- }
6142
- }//Standard reaction, the image has been updated by the user or init
6143
- else if ( ! input.attachment.id || input.attachment.id === to ) {
6144
- input.renderImageUploaderTemplate();
6145
- }
6146
- },
6147
 
6148
- czrImgUploaderBinding : function() {
6149
- var input = this;
6150
- _.bindAll( input, 'czrImgUploadRemoveFile', 'czrImgUploadOpenFrame', 'czrImgUploadSelect');
6151
- input.container.on( 'click keydown', '.upload-button', input.czrImgUploadOpenFrame );
6152
- input.container.on( 'click keydown', '.thumbnail-image img', input.czrImgUploadOpenFrame );
6153
- input.container.on( 'click keydown', '.remove-button', input.czrImgUploadRemoveFile );
6154
 
6155
- input.bind( input.id + ':changed', function( to, from ){
6156
- input.tmplRendered = $.Deferred();
6157
- input.setupContentRendering(to,from);
6158
- });
6159
- },
6160
- /**
6161
- * Open the media modal.
6162
- */
6163
- czrImgUploadOpenFrame: function( event ) {
6164
- if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
6165
- return;
6166
- }
6167
 
6168
- event.preventDefault();
 
 
 
 
 
 
6169
 
6170
- if ( ! this.frame ) {
6171
- this.czrImgUploadInitFrame();
6172
- }
 
 
 
 
 
 
6173
 
6174
- this.frame.open();
6175
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6176
 
6177
- /**
6178
- * Create a media modal select frame, and store it so the instance can be reused when needed.
6179
- */
6180
- czrImgUploadInitFrame: function() {
6181
- var input = this,
6182
- button_labels = this.getUploaderLabels();
 
 
 
 
 
 
 
 
 
 
 
 
6183
 
6184
- input.frame = wp.media({
6185
- button: {
6186
- text: button_labels.frame_button
6187
- },
6188
- states: [
6189
- new wp.media.controller.Library({
6190
- title: button_labels.frame_title,
6191
- library: wp.media.query({ type: 'image' }),
6192
- multiple: false,
6193
- date: false
6194
- })
6195
- ]
6196
- });
6197
- input.frame.on( 'select', input.czrImgUploadSelect );
6198
- },
6199
 
6200
- /**
6201
- * Called when the "Remove" link is clicked. Empties the setting.
6202
- *
6203
- * @param {object} event jQuery Event object
6204
- */
6205
- czrImgUploadRemoveFile: function( event ) {
6206
- var input = this;
6207
 
6208
- if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
6209
- return;
6210
- }
6211
- event.preventDefault();
6212
- input.attachment = {};
6213
- input.set('');
6214
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6216
 
6217
- /**
6218
- * Callback handler for when an attachment is selected in the media modal.
6219
- * Gets the selected image information, and sets it within the input.
6220
- */
6221
- czrImgUploadSelect: function() {
6222
- var node,
6223
- input = this,
6224
- attachment = input.frame.state().get( 'selection' ).first().toJSON(), // Get the attachment from the modal frame.
6225
- mejsSettings = window._wpmejsSettings || {};
6226
- input.attachment = attachment;
6227
- input.set(attachment.id);
6228
- },
6229
- renderImageUploaderTemplate: function() {
6230
- var input = this;
6231
- if ( 0 === $( '#tmpl-czr-input-img-uploader-view-content' ).length )
6232
- return;
6233
 
6234
- var view_template = wp.template('czr-input-img-uploader-view-content');
6235
- if ( ! view_template || ! input.container )
6236
- return;
6237
 
6238
- var $_view_el = input.container.find('.' + input.module.control.css_attr.img_upload_container );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6239
 
6240
- if ( ! $_view_el.length )
6241
- return;
6242
 
6243
- var _template_params = {
6244
- button_labels : input.getUploaderLabels(),
6245
- settings : input.id,
6246
- attachment : input.attachment,
6247
- canUpload : true
6248
- };
6249
 
6250
- $_view_el.html( view_template( _template_params) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6251
 
6252
- input.tmplRendered.resolve();
6253
- input.container.trigger( input.id + ':content_rendered' );
6254
 
6255
- return true;
6256
- },
6257
 
6258
- getUploaderLabels : function() {
6259
- var _ts = serverControlParams.i18n,
6260
- _map = {
6261
- 'select' : _ts.select_image,
6262
- 'change' : _ts.change_image,
6263
- 'remove' : _ts.remove_image,
6264
- 'default' : _ts.default_image,
6265
- 'placeholder' : _ts.placeholder_image,
6266
- 'frame_title' : _ts.frame_title_image,
6267
- 'frame_button': _ts.frame_button_image
6268
- };
6269
- _.each( _map, function( ts_string, key ) {
6270
- if ( _.isUndefined( ts_string ) ) {
6271
- var input = this;
6272
- api.errorLog( 'A translated string is missing ( ' + key + ' ) for the image uploader input in module : ' + input.module.id );
6273
- return '';
6274
- }
6275
- });
 
 
 
 
 
 
 
 
 
 
6276
 
6277
- return _map;
6278
- }
6279
- });//$.extend
6280
- })( wp.customize , jQuery, _ );/* Fix caching, select2 default one seems to not correctly work, or it doesn't what I think it should */
6281
- var CZRInputMths = CZRInputMths || {};
6282
- ( function ( api, $, _ ) {
6283
- $.extend( CZRInputMths , {
6284
- setupContentPicker: function( wpObjectTypes ) {
6285
- var input = this,
6286
- _event_map = [];
6287
 
6288
- /* Dummy for the prototype purpose */
6289
- $.extend( {
6290
- post : '',
6291
- taxonomy : ''
6292
- }, _.isObject( wpObjectTypes ) ? wpObjectTypes : {} );
 
 
6293
 
6294
- input.wpObjectTypes = wpObjectTypes;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6295
 
6296
- /* Methodize this or use a template */
6297
- input.container.find('.czr-input').append('<select data-select-type="content-picker-select" class="js-example-basic-simple"></select>');
6298
- _event_map = [
6299
- {
6300
- trigger : 'change',
6301
- selector : 'select[data-select-type]',
6302
- name : 'set_input_value',
6303
- actions : function( obj ){
6304
- var $_changed_input = $( obj.dom_event.currentTarget, obj.dom_el ),
6305
- _raw_val = $( $_changed_input, obj.dom_el ).select2( 'data' ),
6306
- _val_candidate = {},
6307
- _default = {
6308
- id : '',
6309
- type_label : '',
6310
- title : '',
6311
- object_type : '',
6312
- url : ''
6313
- };
6314
 
6315
- _raw_val = _.isArray( _raw_val ) ? _raw_val[0] : _raw_val;
6316
- if ( ! _.isObject( _raw_val ) || _.isEmpty( _raw_val ) ) {
6317
- api.errorLog( 'Content Picker Input : the picked value should be an object not empty.');
6318
- return;
6319
- }
6320
- _.each( _default, function( val, k ){
6321
- if ( '_custom_' !== _raw_val.id ) {
6322
- if ( ! _.has( _raw_val, k ) || _.isEmpty( _raw_val[ k ] ) ) {
6323
- api.errorLog( 'content_picker : missing input param : ' + k );
6324
- return;
6325
- }
6326
- }
6327
- _val_candidate[ k ] = _raw_val[ k ];
6328
- } );
6329
- input.set( _val_candidate );
6330
- }
6331
- }
6332
- ];
 
 
 
 
 
 
 
 
 
 
 
6333
 
6334
- input.setupDOMListeners( _event_map , { dom_el : input.container }, input );
6335
- input.isReady.done( function() {
6336
- input.setupContentSelecter();
6337
- });
6338
 
6339
- },
6340
- setupContentSelecter : function() {
6341
- var input = this;
6342
- if ( ! _.isEmpty( input() ) ) {
6343
- var _attributes = {
6344
- value : input().id || '',
6345
- title : input().title || '',
6346
- selected : "selected"
6347
- };
6348
- input.container.find('select').append( $( '<option>', _attributes ) );
6349
- }
6350
 
6351
- input.container.find( 'select' ).select2( {
6352
- placeholder: {
6353
- id: '-1', // the value of the option
6354
- title: 'Select'
6355
- },
6356
- data : input.setupSelectedContents(),
6357
- ajax: {
6358
- url: serverControlParams.AjaxUrl,
6359
- type: 'POST',
6360
- dataType: 'json',
6361
- delay: 250,
6362
- debug: true,
6363
- data: function ( params ) {
6364
- var page = params.page ? params.page : 0;
6365
- page = params.term ? params.page : page;
6366
- return {
6367
- action : params.term ? "search-available-content-items-customizer" : "load-available-content-items-customizer",
6368
- search : params.term,
6369
- wp_customize : 'on',
6370
- page : page,
6371
- wp_object_types : JSON.stringify( input.wpObjectTypes ),
6372
- CZRCpNonce : serverControlParams.CZRCpNonce
6373
- };
6374
- },
6375
- /* transport: function (params, success, failure) {
6376
- var $request = $.ajax(params);
6377
 
6378
- $request.then(success);
6379
- $request.fail(failure);
6380
 
6381
- return $request;
6382
- },*/
6383
- processResults: function ( data, params ) {
6384
- input.defaultContentPickerOption = input.defaultContentPickerOption || [];
6385
 
6386
- if ( ! data.success )
6387
- return { results: input.defaultContentPickerOption };
 
 
 
 
 
 
 
 
 
 
 
6388
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6389
 
6390
- var items = data.data.items,
6391
- _results = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6392
 
6393
- _.each( items, function( item ) {
6394
- _results.push({
6395
- id : item.id,
6396
- title : item.title,
6397
- type_label : item.type_label,
6398
- object_type : item.object,
6399
- url : item.url
6400
- });
6401
- });
6402
- return {
6403
- results: _results,
6404
- 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
6405
- };
6406
- },
6407
- },//ajax
6408
- templateSelection: input.czrFormatContentSelected,
6409
- templateResult: input.czrFormatContentSelected,
6410
- escapeMarkup: function ( markup ) { return markup; },
6411
- });//select2 setup
6412
- },
6413
- czrFormatContentSelected: function ( item ) {
6414
- if ( item.loading ) return item.text;
6415
- var markup = "<div class='content-picker-item clearfix'>" +
6416
- "<div class='content-item-bar'>" +
6417
- "<span class='czr-picker-item-title'>" + item.title + "</span>";
6418
 
6419
- if ( item.type_label ) {
6420
- markup += "<span class='czr-picker-item-type'>" + item.type_label + "</span>";
6421
- }
 
 
6422
 
6423
- markup += "</div></div>";
 
 
 
 
6424
 
6425
- return markup;
6426
- },
6427
 
6428
- setupSelectedContents : function() {
6429
- var input = this,
6430
- _model = input();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6431
 
6432
- return _model;
6433
- }
6434
- });//$.extend
6435
- })( wp.customize , jQuery, _ );var CZRInputMths = CZRInputMths || {};
6436
- ( function ( api, $, _ ) {
6437
- $.extend( CZRInputMths , {
6438
- setupTextEditor : function() {
6439
- var input = this,
6440
- _model = input();
6441
- if ( ! input.container ) {
6442
- throw new Error( 'The input container is not set for WP text editor in module.' + input.module.id );
6443
- }
 
6444
 
6445
- if ( ! input.czrRenderInputTextEditorTemplate() )
6446
- return;
 
 
 
 
 
 
 
 
 
 
 
 
6447
 
6448
- input.editor = tinyMCE( 'czr-customize-content_editor' );
6449
- input.textarea = $( '#czr-customize-content_editor' );
6450
- input.editorPane = $( '#czr-customize-content_editor-pane' );
6451
- input.dragbar = $( '#czr-customize-content_editor-dragbar' );
6452
- input.editorFrame = $( '#czr-customize-content_editor_ifr' );
6453
- input.mceTools = $( '#wp-czr-customize-content_editor-tools' );
6454
- input.mceToolbar = input.editorPane.find( '.mce-toolbar-grp' );
6455
- input.mceStatusbar = input.editorPane.find( '.mce-statusbar' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6456
 
6457
- input.preview = $( '#customize-preview' );
6458
- input.collapse = $( '.collapse-sidebar' );
6459
 
6460
- input.textpreview = input.container.find('textarea');
6461
- input.toggleButton = input.container.find('button.text_editor-button');
6462
- input.editorExpanded = new api.Value( false );
6463
- input.czrUpdateTextPreview();
6464
- input.czrSetToggleButtonText( input.editorExpanded() );
6465
 
6466
- input.czrTextEditorBinding();
6467
 
6468
- input.czrResizeEditorOnUserRequest();
6469
- },
 
 
 
 
 
 
 
 
 
 
 
 
6470
 
6471
- czrTextEditorBinding : function() {
6472
- var input = this,
6473
- editor = input.editor,
6474
- textarea = input.textarea,
6475
- toggleButton = input.toggleButton,
6476
- editorExpanded = input.editorExpanded,
6477
- editorPane = input.editorPane;
 
 
 
 
6478
 
 
 
 
 
 
 
 
6479
 
6480
- input.bind( input.id + ':changed', input.czrUpdateTextPreview );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6481
 
6482
- _.bindAll( input, 'czrOnVisualEditorChange', 'czrOnTextEditorChange', 'czrResizeEditorOnWindowResize' );
 
 
 
 
6483
 
6484
- toggleButton.on( 'click', function() {
6485
- input.editorExpanded.set( ! input.editorExpanded() );
6486
- if ( input.editorExpanded() ) {
6487
- editor.focus();
6488
- }
6489
- });
6490
- input.module.czr_ModuleState.bind(
6491
- function( state ) {
6492
- if ( 'expanded' != state )
6493
- input.editorExpanded.set( false );
6494
- });
6495
 
6496
- input.editorExpanded.bind( function (expanded) {
 
 
 
 
 
 
 
 
 
 
 
 
6497
 
6498
- api.consoleLog('in input.editorExpanded', expanded, input() );
6499
- /*
6500
- * Ensure only the latest input is bound
6501
- */
6502
- if ( editor.locker && editor.locker !== input ) {
6503
- editor.locker.editorExpanded.set(false);
6504
- editor.locker = null;
6505
- }if ( ! editor.locker || editor.locker === input ) {
6506
- $(document.body).toggleClass('czr-customize-content_editor-pane-open', expanded);
6507
- editor.locker = input;
6508
- }
6509
- input.czrSetToggleButtonText( expanded );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6510
 
6511
- if ( expanded ) {
6512
- editor.setContent( wp.editor.autop( input() ) );
6513
- editor.on( 'input change keyup', input.czrOnVisualEditorChange );
6514
- textarea.on( 'input', input.czrOnTextEditorChange );
6515
- input.czrResizeEditor( window.innerHeight - editorPane.height() );
6516
- $( window ).on('resize', input.czrResizeEditorOnWindowResize );
6517
 
6518
- } else {
6519
- editor.off( 'input change keyup', input.czrOnVisualEditorChange );
6520
- textarea.off( 'input', input.czrOnTextEditorChange );
6521
- $( window ).off('resize', input.czrResizeEditorOnWindowResize );
6522
- input.czrResizeReset();
6523
- }
6524
- } );
6525
- },
6526
 
6527
- czrOnVisualEditorChange : function() {
6528
- var input = this,
6529
- editor = input.editor,
6530
- value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6531
 
6532
- value = wp.editor.removep( editor.getContent() );
6533
- input.set(value);
6534
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6535
 
6536
- czrOnTextEditorChange : function() {
6537
- var input = this,
6538
- textarea = input.textarea,
6539
- value;
6540
 
6541
- value = textarea.val();
6542
- input.set(value);
6543
- },
6544
- czrUpdateTextPreview: function() {
6545
- var input = this,
6546
- input_model = input(),
6547
- value;
6548
- value = input_model.replace(/(<([^>]+)>)/ig,"");
6549
- if ( value.length > 30 )
6550
- value = value.substring(0, 34) + '...';
 
 
 
 
 
 
 
6551
 
6552
- input.textpreview.val( value );
6553
- },
6554
- czrRenderInputTextEditorTemplate: function() {
6555
- var input = this;
6556
- if ( 0 === $( '#tmpl-czr-input-text_editor-view-content' ).length ) {
6557
- throw new Error('Missing js template for text editor input in module : ' + input.module.id );
6558
- }
 
 
 
 
 
 
6559
 
6560
- var view_template = wp.template('czr-input-text_editor-view-content'),
6561
- $_view_el = input.container.find('input');
6562
- if ( ! view_template || ! input.container )
6563
- return;
 
 
 
 
6564
 
6565
- api.consoleLog('Model injected in text editor tmpl : ', input() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6566
 
6567
- $_view_el.after( view_template( input() ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6568
 
6569
- return true;
6570
- },
6571
- czrIsEditorExpanded : function() {
6572
- return $( document.body ).hasClass('czr-customize-content_editor-pane-open');
6573
- },
6574
- czrResizeReset : function() {
6575
- var input = this,
6576
- preview = input.preview,
6577
- collapse = input.collapse,
6578
- sectionContent = input.container.closest('ul.accordion-section-content');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6579
 
6580
- sectionContent.css( 'padding-bottom', '' );
6581
- preview.css( 'bottom', '' );
6582
- collapse.css( 'bottom', '' );
6583
- },
6584
- czrResizeEditor : function( position ) {
6585
- var windowHeight = window.innerHeight,
6586
- windowWidth = window.innerWidth,
6587
- minScroll = 40,
6588
- maxScroll = 1,
6589
- mobileWidth = 782,
6590
- collapseMinSpacing = 56,
6591
- collapseBottomOutsideEditor = 8,
6592
- collapseBottomInsideEditor = 4,
6593
- args = {},
6594
- input = this,
6595
- sectionContent = input.container.closest('ul.accordion-section-content'),
6596
- mceTools = input.mceTools,
6597
- mceToolbar = input.mceToolbar,
6598
- mceStatusbar = input.mceStatusbar,
6599
- preview = input.preview,
6600
- collapse = input.collapse,
6601
- editorPane = input.editorPane,
6602
- editorFrame = input.editorFrame;
6603
 
6604
- if ( ! input.editorExpanded() ) {
6605
- return;
6606
- }
 
 
 
 
 
 
 
 
6607
 
6608
- if ( ! _.isNaN( position ) ) {
6609
- resizeHeight = windowHeight - position;
6610
- }
 
 
 
 
 
 
 
6611
 
6612
- args.height = resizeHeight;
6613
- args.components = mceTools.outerHeight() + mceToolbar.outerHeight() + mceStatusbar.outerHeight();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6614
 
6615
- if ( resizeHeight < minScroll ) {
6616
- args.height = minScroll;
6617
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6618
 
6619
- if ( resizeHeight > windowHeight - maxScroll ) {
6620
- args.height = windowHeight - maxScroll;
6621
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6622
 
6623
- if ( windowHeight < editorPane.outerHeight() ) {
6624
- args.height = windowHeight;
6625
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
6626
 
6627
- preview.css( 'bottom', args.height );
6628
- editorPane.css( 'height', args.height );
6629
- editorFrame.css( 'height', args.height - args.components );
6630
- collapse.css( 'bottom', args.height + collapseBottomOutsideEditor );
 
 
 
 
6631
 
6632
- if ( collapseMinSpacing > windowHeight - args.height ) {
6633
- collapse.css( 'bottom', mceStatusbar.outerHeight() + collapseBottomInsideEditor );
6634
- }
 
 
 
 
 
 
 
 
6635
 
6636
- if ( windowWidth <= mobileWidth ) {
6637
- sectionContent.css( 'padding-bottom', args.height );
6638
- } else {
6639
- sectionContent.css( 'padding-bottom', '' );
6640
- }
6641
- },
6642
- czrResizeEditorOnWindowResize : function() {
6643
- var input = this,
6644
- resizeDelay = 50,
6645
- editorPane = input.editorPane;
6646
 
6647
- if ( ! input.editorExpanded() ) {
6648
- return;
6649
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6650
 
6651
- _.delay( function() {
6652
- input.czrResizeEditor( window.innerHeight - editorPane.height() );
6653
- }, resizeDelay );
6654
 
6655
- },
6656
- czrResizeEditorOnUserRequest : function() {
6657
- var input = this,
6658
- dragbar = input.dragbar,
6659
- editorFrame = input.editorFrame;
6660
 
6661
- dragbar.on( 'mousedown', function() {
6662
- if ( ! input.editorExpanded() )
6663
- return;
6664
 
6665
- $( document ).on( 'mousemove.czr-customize-content_editor', function( event ) {
6666
- event.preventDefault();
6667
- $( document.body ).addClass( 'czr-customize-content_editor-pane-resize' );
6668
- editorFrame.css( 'pointer-events', 'none' );
6669
- input.czrResizeEditor( event.pageY );
6670
- } );
6671
- } );
6672
 
6673
- dragbar.on( 'mouseup', function() {
6674
- if ( ! input.editorExpanded() )
6675
- return;
 
 
 
6676
 
6677
- $( document ).off( 'mousemove.czr-customize-content_editor' );
6678
- $( document.body ).removeClass( 'czr-customize-content_editor-pane-resize' );
6679
- editorFrame.css( 'pointer-events', '' );
6680
- } );
6681
 
6682
- },
6683
- czrSetToggleButtonText : function( $_expanded ) {
6684
- var input = this;
6685
 
6686
- input.toggleButton.text( serverControlParams.i18n.mods.textEditor[ ! $_expanded ? 'Edit' : 'Close Editor' ] );
6687
- }
6688
- });//$.extend
6689
- })( wp.customize , jQuery, _ );//extends api.Value
6690
 
6691
- var CZRItemMths = CZRItemMths || {};
6692
- ( function ( api, $, _ ) {
6693
- $.extend( CZRItemMths , {
6694
- initialize: function( id, options ) {
6695
- if ( _.isUndefined(options.module) || _.isEmpty(options.module) ) {
6696
- throw new Error('No module assigned to item ' + id + '. Aborting');
6697
- }
 
6698
 
6699
- var item = this;
6700
- api.Value.prototype.initialize.call( item, null, options );
6701
- item.isReady = $.Deferred();
6702
- item.embedded = $.Deferred();
6703
- item.container = null;//will store the item $ dom element
6704
- item.contentContainer = null;//will store the item content $ dom element
6705
- item.inputCollection = new api.Value({});
6706
- item.viewState = new api.Value( 'closed' );
6707
- item.removeDialogVisible = new api.Value( false );
6708
- $.extend( item, options || {} );
6709
- item.defaultItemModel = _.clone( options.defaultItemModel ) || { id : '', title : '' };
6710
- var _initial_model = $.extend( item.defaultItemModel, options.initial_item_model );
6711
- item.set( _initial_model );
6712
- item.userEventMap = new api.Value( [
6713
- {
6714
- trigger : 'click keydown',
6715
- selector : [ '.' + item.module.control.css_attr.display_alert_btn, '.' + item.module.control.css_attr.cancel_alert_btn ].join(','),
6716
- name : 'toggle_remove_alert',
6717
- actions : function() {
6718
- var _isVisible = this.removeDialogVisible();
6719
- this.module.closeRemoveDialogs();
6720
- this.removeDialogVisible( ! _isVisible );
6721
- }
6722
- },
6723
- {
6724
- trigger : 'click keydown',
6725
- selector : '.' + item.module.control.css_attr.remove_view_btn,
6726
- name : 'remove_item',
6727
- actions : ['removeItem']
6728
- },
6729
- {
6730
- trigger : 'click keydown',
6731
- selector : [ '.' + item.module.control.css_attr.edit_view_btn, '.' + item.module.control.css_attr.item_title ].join(','),
6732
- name : 'edit_view',
6733
- actions : [ 'setViewVisibility' ]
6734
- },
6735
- {
6736
- trigger : 'click keydown',
6737
- selector : '.tabs nav li',
6738
- name : 'tab_nav',
6739
- actions : function( args ) {
6740
- this.module.toggleTabVisibility.call( this, args );
6741
- }
6742
- }
6743
- ]);
6744
- item.isReady.done( function() {
6745
- item.module.updateItemsCollection( { item : item() } );
6746
- item.callbacks.add( function() { return item.itemReact.apply(item, arguments ); } );
6747
- item.bind( 'contentRendered', function() {
6748
- if ( ! _.has( item, 'czr_Input' ) || _.isEmpty( item.inputCollection() ) ) {
6749
- try {
6750
- api.CZR_Helpers.setupInputCollectionFromDOM.call( item );
6751
- item.module.setupTabNav.call( item );
6752
- } catch( er ) {
6753
- api.errorLog( 'In item.isReady.done : ' + er );
6754
- }
6755
- }
6756
- });
6757
- item.bind( 'contentRemoved', function() {
6758
- if ( _.has(item, 'czr_Input') )
6759
- api.CZR_Helpers.removeInputCollection.call( item );
6760
- });
6761
- item.mayBeRenderItemWrapper();
6762
- item.embedded.done( function() {
6763
- item.itemWrapperViewSetup( _initial_model );
6764
- });
6765
- });//item.isReady.done()
6766
 
6767
- },//initialize
6768
- ready : function() {
6769
- this.isReady.resolve();
6770
- },
6771
- itemReact : function( to, from, data ) {
6772
- var item = this,
6773
- module = item.module;
 
 
 
 
6774
 
6775
- data = data || {};
6776
- module.updateItemsCollection( { item : to, data : data } ).done( function() {
6777
- item.writeItemViewTitle( to, data );
6778
- });
6779
- }
6780
- });//$.extend
6781
- })( wp.customize , jQuery, _ );//extends api.CZRBaseControl
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6782
 
6783
- var CZRItemMths = CZRItemMths || {};
6784
- ( function ( api, $, _ ) {
6785
- $.extend( CZRItemMths , {
6786
- _sendItem : function( to, from ) {
6787
- var item = this,
6788
- module = item.module,
6789
- _changed_props = [];
6790
- _.each( from, function( _val, _key ) {
6791
- if ( _val != to[_key] )
6792
- _changed_props.push(_key);
6793
- });
 
 
 
6794
 
6795
- _.each( _changed_props, function( _prop ) {
6796
- module.control.previewer.send( 'sub_setting', {
6797
- set_id : module.control.id,
6798
- id : to.id,
6799
- changed_prop : _prop,
6800
- value : to[_prop]
6801
- });
6802
- module.trigger('item_sent', { item : to , dom_el: item.container, changed_prop : _prop } );
6803
- });
6804
- },
6805
- removeItem : function() {
6806
- var item = this,
6807
- module = this.module,
6808
- _new_collection = _.clone( module.itemCollection() );
6809
- module.trigger('pre_item_dom_remove', item() );
6810
- item._destroyView();
6811
- _new_collection = _.without( _new_collection, _.findWhere( _new_collection, {id: item.id }) );
6812
- module.itemCollection.set( _new_collection );
6813
- module.trigger('pre_item_api_remove', item() );
6814
 
6815
- var _item_ = $.extend( true, {}, item() );
6816
- module.czr_Item.remove( item.id );
6817
- module.trigger( 'item-removed', _item_ );
6818
- },
6819
- getModel : function(id) {
6820
- return this();
6821
- }
 
 
 
 
 
 
 
 
6822
 
6823
- });//$.extend
6824
- })( wp.customize , jQuery, _ );
6825
- var CZRItemMths = CZRItemMths || {};
6826
- ( function ( api, $, _ ) {
6827
- $.extend( CZRItemMths , {
6828
- mayBeRenderItemWrapper : function() {
6829
- var item = this;
6830
 
6831
- if ( 'pending' != item.embedded.state() )
6832
- return;
6833
 
6834
- $.when( item.renderItemWrapper() ).done( function( $_container ) {
6835
- item.container = $_container;
6836
- if ( _.isUndefined(item.container) || ! item.container.length ) {
6837
- throw new Error( 'In mayBeRenderItemWrapper the Item view has not been rendered : ' + item.id );
6838
- } else {
6839
- item.embedded.resolve();
6840
- }
6841
- });
6842
- },
6843
- itemWrapperViewSetup : function( item_model ) {
6844
- var item = this,
6845
- module = this.module;
6846
 
6847
- item_model = item() || item.initial_item_model;//could not be set yet
6848
- item.writeItemViewTitle();
6849
- var _updateItemContentDeferred = function( $_content, to, from ) {
6850
- if ( ! _.isUndefined( $_content ) && false !== $_content.length ) {
6851
- item.trigger( 'contentRendered' );
6852
- item.contentContainer = $_content;
6853
- item.toggleItemExpansion( to, from );
6854
- }
6855
- else {
6856
- throw new Error( 'Module : ' + item.module.id + ', the item content has not been rendered for ' + item.id );
6857
- }
6858
- };
6859
 
6860
- if ( item.module.isMultiItem() ) {
6861
- item.viewState.callbacks.add( function( to, from ) {
6862
- var _isExpanded = -1 !== to.indexOf( 'expanded' );
6863
- if ( module.hasModOpt() && _isExpanded ) {
6864
- api.czr_ModOptVisible( false );
6865
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6866
 
6867
- if ( _isExpanded ) {
6868
- if ( _.isObject( item.contentContainer ) && false !== item.contentContainer.length ) {
6869
- item.toggleItemExpansion(to, from );
6870
- } else {
6871
- $.when( item.renderItemContent( item() || item.initial_item_model ) ).done( function( $_item_content ) {
6872
- _updateItemContentDeferred = _.debounce(_updateItemContentDeferred, 50 );
6873
- _updateItemContentDeferred( $_item_content, to, from );
6874
- });
6875
- }
6876
- } else {
6877
- item.toggleItemExpansion( to, from ).done( function() {
6878
- if ( _.isObject( item.contentContainer ) && false !== item.contentContainer.length ) {
6879
- item.trigger( 'beforeContenRemoved' );
6880
- $( '.' + module.control.css_attr.item_content, item.container ).children().each( function() {
6881
- $(this).remove();
6882
- });
6883
- $( '.' + module.control.css_attr.item_content, item.container ).html('');
6884
- item.contentContainer = null;
6885
- item.trigger( 'contentRemoved' );
6886
- }
6887
- });
6888
- }
6889
- });
6890
- } else {
6891
- item.viewState.callbacks.add( function( to, from ) {
6892
- item.toggleItemExpansion.apply(item, arguments );
6893
- });
6894
- $.when( item.renderItemContent( item_model ) ).done( function( $_item_content ) {
6895
- _updateItemContentDeferred( $_item_content, true );
6896
- });
6897
- }
6898
- api.CZR_Helpers.setupDOMListeners(
6899
- item.userEventMap(),//actions to execute
6900
- { model:item_model, dom_el:item.container },//model + dom scope
6901
- item //instance where to look for the cb methods
6902
- );
6903
- item.removeDialogVisible.bind( function( visible ) {
6904
- var module = item.module,
6905
- $_alert_el = $( '.' + module.control.css_attr.remove_alert_wrapper, item.container ).first();
6906
- if ( visible )
6907
- module.closeAllItems();
6908
- if ( visible && module.hasModOpt() ) {
6909
- api.czr_ModOptVisible( false );
6910
- }
6911
- if ( visible && _.has( module, 'preItem' ) ) {
6912
- module.preItemExpanded(false);
6913
- }
6914
- $('.' + module.control.css_attr.remove_alert_wrapper, item.container ).not( $_alert_el ).each( function() {
6915
- if ( $(this).hasClass( 'open' ) ) {
6916
- $(this).slideToggle( {
6917
- duration : 200,
6918
- done : function() {
6919
- $(this).toggleClass('open' , false );
6920
- $(this).siblings().find('.' + module.control.css_attr.display_alert_btn).toggleClass( 'active' , false );
6921
- }
6922
- } );
6923
- }
6924
- });
6925
- if ( visible ) {
6926
- if ( ! wp.template( module.AlertPart ) || ! item.container ) {
6927
- api.consoleLog( 'No removal alert template available for items in module :' + module.id );
6928
- return;
6929
- }
6930
 
6931
- $_alert_el.html( wp.template( module.AlertPart )( { title : ( item().title || item.id ) } ) );
6932
- }
6933
- var _slideComplete = function( visible ) {
6934
- $_alert_el.toggleClass( 'open' , visible );
6935
- item.container.find('.' + module.control.css_attr.display_alert_btn ).toggleClass( 'active', visible );
6936
- if ( visible )
6937
- module._adjustScrollExpandedBlock( item.container );
6938
- };
6939
- if ( visible )
6940
- $_alert_el.stop( true, true ).slideDown( 200, function() { _slideComplete( visible ); } );
6941
- else
6942
- $_alert_el.stop( true, true ).slideUp( 200, function() { _slideComplete( visible ); } );
6943
- });//item.removeDialogVisible.bind()
6944
- },//itemWrapperViewSetup
6945
- renderItemWrapper : function( item_model ) {
6946
- var item = this,
6947
- module = item.module;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6948
 
6949
- item_model = item_model || item();
6950
- $_view_el = $('<li>', { class : module.control.css_attr.single_item, 'data-id' : item_model.id, id : item_model.id } );
6951
- module.itemsWrapper.append( $_view_el );
6952
- if ( module.isMultiItem() ) {
6953
- var _template_selector = module.getTemplateEl( 'rudItemPart', item_model );
6954
- if ( 0 === $( '#tmpl-' + _template_selector ).length ) {
6955
- throw new Error('Missing template for item ' + item.id + '. The provided template script has no been found : #tmpl-' + module.getTemplateEl( 'rudItemPart', item_model ) );
6956
- }
6957
- $_view_el.append( $( wp.template( _template_selector )( item_model ) ) );
6958
- }
6959
- $_view_el.append( $( '<div/>', { class: module.control.css_attr.item_content } ) );
6960
 
6961
- return $_view_el;
6962
- },
6963
- renderItemContent : function( item_model ) {
6964
- var item = this,
6965
- module = this.module;
6966
 
6967
- item_model = item_model || item();
6968
- if ( 0 === $( '#tmpl-' + module.getTemplateEl( 'itemInputList', item_model ) ).length ) {
6969
- throw new Error('No item content template defined for module ' + module.id + '. The template script id should be : #tmpl-' + module.getTemplateEl( 'itemInputList', item_model ) );
6970
- }
6971
 
6972
- var item_content_template = wp.template( module.getTemplateEl( 'itemInputList', item_model ) );
6973
- if ( ! item_content_template )
6974
- return this;
6975
- $( item_content_template( item_model )).appendTo( $('.' + module.control.css_attr.item_content, item.container ) );
6976
 
6977
- return $( $( item_content_template( item_model )), item.container );
6978
- },
6979
- writeItemViewTitle : function( item_model ) {
6980
- var item = this,
6981
- module = item.module,
6982
- _model = item_model || item(),
6983
- _title = _.has( _model, 'title')? api.CZR_Helpers.capitalize( _model.title ) : _model.id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6984
 
6985
- _title = api.CZR_Helpers.truncate( _title, 20 );
6986
- $( '.' + module.control.css_attr.item_title , item.container ).text( _title );
6987
- api.CZR_Helpers.doActions('after_writeViewTitle', item.container , _model, item );
6988
- },
6989
- setViewVisibility : function( obj, is_added_by_user ) {
6990
- var item = this,
6991
- module = this.module;
6992
- if ( is_added_by_user ) {
6993
- item.viewState.set( 'expanded_noscroll' );
6994
- } else {
6995
- module.closeAllItems( item.id );
6996
- if ( _.has(module, 'preItem') ) {
6997
- module.preItemExpanded.set(false);
6998
- }
6999
- item.viewState.set( 'expanded' == item._getViewState() ? 'closed' : 'expanded' );
7000
- }
7001
- },
7002
 
7003
 
7004
- _getViewState : function() {
7005
- return -1 == this.viewState().indexOf('expanded') ? 'closed' : 'expanded';
7006
- },
7007
- toggleItemExpansion : function( status, from, duration ) {
7008
- var visible = 'closed' != status,
7009
- item = this,
7010
- module = this.module,
7011
- $el = $( '.' + module.control.css_attr.item_content , item.container ).first(),
7012
- dfd = $.Deferred(),
7013
- _slideComplete = function( visible ) {
7014
- item.container.toggleClass( 'open' , visible );
7015
- if ( visible )
7016
- module.closeRemoveDialogs();
7017
- var $_edit_icon = $el.siblings().find('.' + module.control.css_attr.edit_view_btn );
7018
 
7019
- $_edit_icon.toggleClass('active' , visible );
7020
- if ( visible )
7021
- $_edit_icon.removeClass('fa-pencil').addClass('fa-minus-square').attr('title', serverControlParams.i18n.close );
7022
- else
7023
- $_edit_icon.removeClass('fa-minus-square').addClass('fa-pencil').attr('title', serverControlParams.i18n.edit );
7024
- if ( 'expanded' == status )
7025
- module._adjustScrollExpandedBlock( item.container );
7026
 
7027
- dfd.resolve();
 
 
 
 
 
 
 
 
 
7028
  };
 
 
 
7029
 
7030
- if ( visible )
7031
- $el.stop( true, true ).slideDown( duration || 200, function() { _slideComplete( visible ); } );
7032
- else
7033
- $el.stop( true, true ).slideUp( 200, function() { _slideComplete( visible ); } );
7034
 
7035
- return dfd.promise();
7036
- },
7037
- _destroyView : function ( duration ) {
7038
- this.container.fadeOut( {
7039
- duration : duration ||400,
7040
- done : function() {
7041
- $(this).remove();
7042
- }
7043
- });
7044
- }
 
 
 
 
 
 
 
 
 
 
 
 
7045
  });//$.extend
7046
- })( wp.customize , jQuery, _ );//extends api.Value
7047
 
7048
- var CZRModOptMths = CZRModOptMths || {};
 
 
 
7049
  ( function ( api, $, _ ) {
7050
- $.extend( CZRModOptMths , {
7051
- initialize: function( options ) {
7052
- if ( _.isUndefined(options.module) || _.isEmpty(options.module) ) {
7053
- throw new Error('No module assigned to modOpt.');
7054
- }
7055
-
7056
- var modOpt = this;
7057
- api.Value.prototype.initialize.call( modOpt, null, options );
7058
- modOpt.isReady = $.Deferred();
7059
- modOpt.container = null;//will store the modOpt $ dom element
7060
- modOpt.inputCollection = new api.Value({});
7061
- $.extend( modOpt, options || {} );
7062
- modOpt.defaultModOptModel = _.clone( options.defaultModOptModel ) || { is_mod_opt : true };
7063
- var _initial_model = $.extend( modOpt.defaultModOptModel, options.initial_modOpt_model );
7064
- var ctrl = modOpt.module.control;
7065
- modOpt.set( _initial_model );
7066
- api.czr_ModOptVisible = new api.Value( false );
7067
- api.czr_ModOptVisible.bind( function( visible, from, args ) {
7068
- args = args || {};
7069
- if ( visible ) {
7070
- modOpt.module.closeRemoveDialogs().closeAllItems();
7071
-
7072
- modOpt.modOptWrapperViewSetup( _initial_model ).done( function( $_container ) {
7073
- modOpt.container = $_container;
7074
- try {
7075
- api.CZR_Helpers.setupInputCollectionFromDOM.call( modOpt ).toggleModPanelView( visible );
7076
- } catch(e) {
7077
- api.consoleLog(e);
7078
- }
7079
- if ( args.module && args.focus ) {
7080
- _.delay( function() {
7081
- if ( _.isNull( args.module.czr_ModOpt.container ) || ! args.module.czr_ModOpt.container.find('[data-tab-id="' + args.focus + '"] a').length )
7082
- return;
7083
- args.module.czr_ModOpt.container.find('[data-tab-id="' + args.focus + '"] a').trigger('click');
7084
- }, 200 );
7085
- }
7086
- });
7087
-
7088
- } else {
7089
- modOpt.toggleModPanelView( visible ).done( function() {
7090
- if ( false !== modOpt.container.length ) {
7091
- $.when( modOpt.container.remove() ).done( function() {
7092
- api.CZR_Helpers.removeInputCollection.call( modOpt );
7093
- });
7094
- } else {
7095
- api.CZR_Helpers.removeInputCollection.call( modOpt );
7096
- }
7097
- modOpt.container = null;
7098
- });
7099
- }
7100
- } );
7101
- modOpt.isReady.done( function() {
7102
- if( ! $( '.' + ctrl.css_attr.edit_modopt_icon, ctrl.container ).length ) {
7103
- $.when( ctrl.container
7104
- .find('.customize-control-title').first()//was.find('.customize-control-title')
7105
- .append( $( '<span/>', {
7106
- class : [ ctrl.css_attr.edit_modopt_icon, 'fa fa-cog' ].join(' '),
7107
- title : serverControlParams.i18n['Settings']
7108
- } ) ) )
7109
- .done( function(){
7110
- $( '.' + ctrl.css_attr.edit_modopt_icon, ctrl.container ).fadeIn( 400 );
7111
- });
7112
- }
7113
- api.CZR_Helpers.setupDOMListeners(
7114
- [
7115
- {
7116
- trigger : 'click keydown',
7117
- selector : '.' + ctrl.css_attr.edit_modopt_icon,
7118
- name : 'toggle_mod_option',
7119
- actions : function() {
7120
- api.czr_ModOptVisible( ! api.czr_ModOptVisible() );
7121
- }
7122
- }
7123
- ],//actions to execute
7124
- { dom_el: ctrl.container },//dom scope
7125
- modOpt //instance where to look for the cb methods
7126
- );
7127
- });//modOpt.isReady.done()
7128
 
7129
- },//initialize
7130
- ready : function() {
7131
- this.isReady.resolve();
7132
- }
7133
- });//$.extend
7134
- })( wp.customize , jQuery, _ );//extends api.CZRBaseControl
7135
 
7136
- var CZRModOptMths = CZRModOptMths || {};
7137
- ( function ( api, $, _ ) {
7138
- $.extend( CZRModOptMths , {
7139
- modOptWrapperViewSetup : function( modOpt_model ) {
7140
- var modOpt = this,
7141
- module = this.module,
7142
- dfd = $.Deferred(),
7143
- _setupDOMListeners = function( $_container ) {
7144
- api.CZR_Helpers.setupDOMListeners(
7145
- [
7146
- {
7147
- trigger : 'click keydown',
7148
- selector : '.' + module.control.css_attr.close_modopt_icon,
7149
- name : 'close_mod_option',
7150
- actions : function() {
7151
- api.czr_ModOptVisible( false );
7152
- }
7153
- },
7154
- {
7155
- trigger : 'click keydown',
7156
- selector : '.tabs nav li',
7157
- name : 'tab_nav',
7158
- actions : function( args ) {
7159
- this.module.toggleTabVisibility.call( this, args );
7160
- }
7161
- }
7162
- ],//actions to execute
7163
- { dom_el: $_container },//model + dom scope
7164
- modOpt //instance where to look for the cb methods
7165
- );
7166
- };
7167
 
7168
- modOpt_model = modOpt() || modOpt.initial_modOpt_model;//could not be set yet
7169
- $.when( modOpt.renderModOptContent( modOpt_model ) )
7170
- .done( function( $_container ) {
7171
- if ( ! _.isUndefined( $_container ) && false !== $_container.length ) {
7172
- _setupDOMListeners( $_container );
7173
- dfd.resolve( $_container );
7174
- }
7175
- else {
7176
- throw new Error( 'Module : ' + modOpt.module.id + ', the modOpt content has not been rendered' );
7177
- }
7178
- })
7179
- .then( function() {
7180
- modOpt.module.setupTabNav.call( modOpt );
7181
- });
7182
 
7183
- return dfd.promise();
7184
- },
7185
- renderModOptContent : function( modOpt_model ) {
7186
- var modOpt = this,
7187
- module = this.module;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7188
 
7189
- modOpt_model = modOpt_model || modOpt();
7190
- if ( 0 === $( '#tmpl-' + module.getTemplateEl( 'modOptInputList', modOpt_model ) ).length ) {
7191
- api.errorLog('renderModOptContent : No modOpt content template defined for module ' + module.id + '. The template script id should be : #tmpl-' + module.getTemplateEl( 'modOptInputList', modOpt_model ) );
7192
- return;
7193
- }
7194
- var modOpt_content_template = wp.template( module.getTemplateEl( 'modOptInputList', modOpt_model ) );
7195
- if ( ! modOpt_content_template )
7196
- return this;
7197
 
7198
- var _ctrlLabel = '';
7199
- try {
7200
- _ctrlLabel = [ serverControlParams.i18n['Options for'], module.control.params.label ].join(' ');
7201
- } catch( er ) {
7202
- api.errorLog( 'In renderModOptContent : ' + er );
7203
- _ctrlLabel = serverControlParams.i18n['Settings'];
7204
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7205
 
7206
- $('#widgets-left').after( $( '<div/>', {
7207
- class : module.control.css_attr.mod_opt_wrapper,
7208
- html : [
7209
- [ '<h2 class="mod-opt-title">', _ctrlLabel , '</h2>' ].join(''),
7210
- '<span class="fa fa-times ' + module.control.css_attr.close_modopt_icon + '" title="close"></span>'
7211
- ].join('')
7212
- } ) );
7213
- $( '.' + module.control.css_attr.mod_opt_wrapper ).append( $( modOpt_content_template( modOpt_model ) ) );
7214
 
7215
- return $( '.' + module.control.css_attr.mod_opt_wrapper );
7216
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7218
 
 
 
 
 
 
 
 
 
 
 
7219
 
7220
- toggleModPanelView : function( visible ) {
7221
- var modOpt = this,
7222
- module = this.module,
7223
- ctrl = module.control,
7224
- dfd = $.Deferred();
7225
 
7226
- module.control.container.toggleClass( 'czr-modopt-visible', visible );
7227
- $('body').toggleClass('czr-editing-modopt', visible );
7228
- _.delay( function() {
7229
- dfd.resolve();
7230
- }, 200 );
7231
- return dfd.promise();
7232
- }
7233
- });//$.extend
7234
- })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
7235
- var CZRModuleMths = CZRModuleMths || {};
7236
- ( function ( api, $, _ ) {
7237
- $.extend( CZRModuleMths, {
7238
- initialize: function( id, constructorOptions ) {
7239
- if ( _.isUndefined(constructorOptions.control) || _.isEmpty(constructorOptions.control) ) {
7240
- throw new Error('No control assigned to module ' + id );
7241
- }
7242
- var module = this;
7243
- api.Value.prototype.initialize.call( this, null, constructorOptions );
7244
- module.isReady = $.Deferred();
7245
- $.extend( module, constructorOptions || {} );
7246
- $.extend( module, {
7247
- crudModulePart : 'czr-crud-module-part',//create, read, update, delete
7248
- rudItemPart : 'czr-rud-item-part',//read, update, delete
7249
- ruItemPart : 'czr-ru-item-part',//read, update
7250
- itemInputList : '',//is specific for each crud module
7251
- modOptInputList : '',//is specific for each module
7252
- AlertPart : 'czr-rud-item-alert-part',//used both for items and modules removal
7253
 
7254
- } );
7255
- module.embedded = $.Deferred();
7256
- module.itemsWrapper = '';//will store the $ item container
7257
- if ( ! module.isInSektion() ) {
7258
- module.container = $( module.control.selector );
7259
- module.embedded.resolve();
7260
- }
7261
- module.embedded.done( function() {
7262
- $.when( module.renderModuleParts() ).done(function( $_module_items_wrapper ){
7263
- if ( false === $_module_items_wrapper.length ) {
7264
- throw new Error( 'The items wrapper has not been rendered for module : ' + module.id );
7265
- }
7266
- module.itemsWrapper = $_module_items_wrapper;
7267
- });
7268
- });
7269
 
7270
- /*-----------------------------------------------
7271
- * MODULE OPTIONS
7272
- ------------------------------------------------*/
7273
- module.defaultAPImodOptModel = {
7274
- initial_modOpt_model : {},
7275
- defaultModOptModel : {},
7276
- control : {},//control instance
7277
- module : {}//module instance
7278
- };
7279
- module.defaultModOptModel = {};
7280
- module.modOptConstructor = api.CZRModOpt;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7281
 
7282
- /*-----------------------------------------------
7283
- * ITEMS
7284
- ------------------------------------------------*/
7285
- module.itemCollection = new api.Value( [] );
7286
- module.defaultAPIitemModel = {
7287
- id : '',
7288
- initial_item_model : {},
7289
- defaultItemModel : {},
7290
- control : {},//control instance
7291
- module : {},//module instance
7292
- is_added_by_user : false
7293
- };
7294
- module.defaultItemModel = { id : '', title : '' };
7295
- module.itemConstructor = api.CZRItem;
7296
- module.czr_Item = new api.Values();
7297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7298
 
7299
- /*-----------------------------------------------
7300
- * SET THE DEFAULT INPUT CONSTRUCTOR AND INPUT OPTIONS
7301
- ------------------------------------------------*/
7302
- module.inputConstructor = api.CZRInput;//constructor for the items input
7303
- if ( module.hasModOpt() ) {
7304
- module.inputModOptConstructor = api.CZRInput;//constructor for the modOpt input
7305
- }
7306
- module.inputOptions = {};//<= can be set by each module specifically
 
 
 
 
 
 
 
 
7307
 
7308
 
7309
- /*-----------------------------------------------
7310
- * FIRE ON isReady
7311
- ------------------------------------------------*/
7312
- module.isReady.done( function() {
7313
- module.isDirty = new api.Value( constructorOptions.dirty || false );
7314
- module.initializeModuleModel( constructorOptions )
7315
- .done( function( initialModuleValue ) {
7316
- module.set( initialModuleValue );
7317
- })
7318
- .fail( function( response ){ api.consoleLog( 'Module : ' + module.id + ' initialize module model failed : ', response ); })
7319
- .always( function( initialModuleValue ) {
7320
- module.callbacks.add( function() { return module.moduleReact.apply( module, arguments ); } );
7321
- if ( ! module.control.isModuleRegistered( module.id ) ) {
7322
- module.control.updateModulesCollection( { module : constructorOptions, is_registered : false } );
7323
- }
7324
 
7325
- module.bind('items-collection-populated', function( collection ) {
7326
- module.itemCollection.callbacks.add( function() { return module.itemCollectionReact.apply( module, arguments ); } );
7327
- if ( module.isMultiItem() ) {
7328
- module._makeItemsSortable();
7329
- }
 
 
 
 
 
 
 
 
 
 
7330
  });
7331
- if ( ! module.isInSektion() )
7332
- module.populateSavedItemCollection();
7333
- if ( module.hasModOpt() ) {
7334
- module.instantiateModOpt();
7335
- }
7336
- });
7337
- });//module.isReady.done()
7338
- },
7339
- ready : function() {
7340
- var module = this;
7341
- module.isReady.resolve();
7342
- },
7343
- initializeModuleModel : function( constructorOptions ) {
7344
- var module = this, dfd = $.Deferred();
7345
- if ( ! module.isMultiItem() && ! module.isCrud() ) {
7346
- if ( _.isEmpty( constructorOptions.items ) ) {
7347
- var def = _.clone( module.defaultItemModel );
7348
- constructorOptions.items = [ $.extend( def, { id : module.id } ) ];
7349
- }
7350
- }
7351
- return dfd.resolve( constructorOptions ).promise();
7352
- },
7353
- itemCollectionReact : function( to, from, data ) {
7354
- var module = this,
7355
- _current_model = module(),
7356
- _new_model = $.extend( true, {}, _current_model );
7357
- _new_model.items = to;
7358
- module.isDirty.set(true);
7359
- module.set( _new_model, data || {} );
7360
- },
7361
- moduleReact : function( to, from, data ) {
7362
- var module = this,
7363
- control = module.control,
7364
- isItemUpdate = ( _.size( from.items ) == _.size( to.items ) ) && ! _.isEmpty( _.difference( to.items, from.items ) ),
7365
- isColumnUpdate = to.column_id != from.column_id,
7366
- refreshPreview = function() {
7367
- module.control.previewer.refresh();
7368
- };
7369
- control.updateModulesCollection( {
7370
- module : $.extend( true, {}, to ),
7371
- data : data//useful to pass contextual info when a change happens
7372
- } );
7373
- },
7374
- getModuleSection : function() {
7375
- return this.section;
7376
- },
7377
- isInSektion : function() {
7378
- var module = this;
7379
- return _.has( module, 'sektion_id' );
7380
- },
7381
- isMultiItem : function() {
7382
- return api.CZR_Helpers.isMultiItemModule( null, this );
7383
- },
7384
- isCrud : function() {
7385
- return api.CZR_Helpers.isCrudModule( null, this );
7386
- },
7387
 
7388
- hasModOpt : function() {
7389
- return api.CZR_Helpers.hasModuleModOpt( null, this );
7390
- },
7391
- instantiateModOpt : function() {
7392
- var module = this;
7393
- var modOpt_candidate = module.prepareModOptForAPI( module().modOpt || {} );
7394
- module.czr_ModOpt = new module.modOptConstructor( modOpt_candidate );
7395
- module.czr_ModOpt.ready();
7396
- module.czr_ModOpt.callbacks.add( function( to, from, data ) {
7397
- var _current_model = module(),
7398
- _new_model = $.extend( true, {}, _current_model );
7399
- _new_model.modOpt = to;
7400
- module.isDirty(true);
7401
- module( _new_model, data );
7402
- });
7403
- },
7404
- prepareModOptForAPI : function( modOpt_candidate ) {
7405
- var module = this,
7406
- api_ready_modOpt = {};
7407
- modOpt_candidate = _.isObject( modOpt_candidate ) ? modOpt_candidate : {};
7408
 
7409
- _.each( module.defaultAPImodOptModel, function( _value, _key ) {
7410
- var _candidate_val = modOpt_candidate[_key];
7411
- switch( _key ) {
7412
- case 'initial_modOpt_model' :
7413
- _.each( module.getDefaultModOptModel() , function( _value, _property ) {
7414
- if ( ! _.has( modOpt_candidate, _property) )
7415
- modOpt_candidate[_property] = _value;
7416
- });
7417
- api_ready_modOpt[_key] = modOpt_candidate;
7418
 
7419
- break;
7420
- case 'defaultModOptModel' :
7421
- api_ready_modOpt[_key] = _.clone( module.defaultModOptModel );
7422
- break;
7423
- case 'control' :
7424
- api_ready_modOpt[_key] = module.control;
7425
- break;
7426
- case 'module' :
7427
- api_ready_modOpt[_key] = module;
7428
- break;
7429
- }//switch
7430
- });
7431
- return api_ready_modOpt;
7432
- },
7433
- getDefaultModOptModel : function( id ) {
7434
- var module = this;
7435
- return $.extend( _.clone( module.defaultModOptModel ), { is_mod_opt : true } );
7436
- },
7437
- sendInputToPreview : function( args ) {
7438
- var module = this;
7439
- args = _.extend(
7440
- {
7441
- input_id : '',
7442
- input_parent_id : '',//<= can be the mod opt or an item
7443
- to : null,
7444
- from : null
7445
- } , args );
7446
 
7447
- if ( _.isEqual( args.to, args.from ) )
7448
- return;
7449
- module.control.previewer.send( 'czr_input', {
7450
- set_id : api.CZR_Helpers.getControlSettingId( module.control.id ),
7451
- module_id : module.id,//<= will allow us to target the right dom element on front end
7452
- module : { items : $.extend( true, {}, module().items ) , modOpt : module.hasModOpt() ? $.extend( true, {}, module().modOpt ): {} },
7453
- input_parent_id : args.input_parent_id,//<= can be the mod opt or the item
7454
- input_id : args.input_id,
7455
- value : args.to,
7456
- isPartialRefresh : args.isPartialRefresh//<= let us know if it is a full wrapper refresh or a single input update ( true when fired from sendModuleInputsToPreview )
7457
- });
7458
- module.trigger( 'input_sent', { input : args.to , dom_el: module.container } );
7459
- },
7460
- sendModuleInputsToPreview : function( args ) {
7461
- var module = this,
7462
- _sendInputData = function() {
7463
- var inputParent = this,//this is the input parent : item or modOpt
7464
- inputParentModel = $.extend( true, {}, inputParent() );
7465
- inputParentModel = _.omit( inputParentModel, 'id' );
7466
 
7467
- _.each( inputParentModel, function( inputVal, inputId ) {
7468
- module.sendInputToPreview( {
7469
- input_id : inputId,
7470
- input_parent_id : inputParent.id,
7471
- to : inputVal,
7472
- from : null,
7473
- isPartialRefresh : args.isPartialRefresh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7474
  });
7475
  });
7476
- };
7477
 
7478
- module.czr_Item.each( function( _itm_ ) {
7479
- _sendInputData.call( _itm_ );
7480
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7481
 
7482
- if ( module.hasModOpt() ) {
7483
- _sendInputData.call( module.czr_ModOpt );
7484
- }
7485
- }
7486
- });//$.extend//CZRBaseControlMths
7487
- })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
7488
 
7489
- var CZRModuleMths = CZRModuleMths || {};
7490
- ( function ( api, $, _ ) {
7491
- $.extend( CZRModuleMths, {
7492
- populateSavedItemCollection : function() {
7493
- var module = this, _saved_items = [];
7494
- if ( ! _.isArray( module().items ) ) {
7495
- api.errorLog( 'populateSavedItemCollection : The saved items collection must be an array in module :' + module.id );
7496
- return;
7497
- }
7498
- _.each( module().items, function( item_candidate , key ) {
7499
- if ( _.has( item_candidate, 'id') && ! _.has( item_candidate, 'is_mod_opt' ) ) {
7500
- _saved_items.push( item_candidate );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7501
  }
7502
- });
7503
- _.each( _saved_items, function( item_candidate , key ) {
7504
- try { module.instantiateItem( item_candidate ).ready(); } catch( er ) {
7505
- api.errorLog( 'populateSavedItemCollection : ' + er );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7506
  }
7507
- });
7508
- _.each( _saved_items, function( _item ) {
7509
- if ( _.isUndefined( _.findWhere( module.itemCollection(), _item.id ) ) ) {
7510
- throw new Error( 'populateSavedItemCollection : The saved items have not been properly populated in module : ' + module.id );
 
 
 
 
 
 
 
 
 
 
 
7511
  }
7512
- });
7513
 
7514
- module.trigger( 'items-collection-populated' );
7515
- },
7516
 
7517
 
7518
- instantiateItem : function( item, is_added_by_user ) {
7519
- var module = this;
7520
- item_candidate = module.prepareItemForAPI( item );
7521
- if ( ! _.has( item_candidate, 'id' ) ) {
7522
- throw new Error('CZRModule::instantiateItem() : an item has no id and could not be added in the collection of : ' + this.id );
7523
- }
7524
- if ( module.czr_Item.has( item_candidate.id ) ) {
7525
- throw new Error('CZRModule::instantiateItem() : the following item id ' + item_candidate.id + ' already exists in module.czr_Item() for module ' + this.id );
7526
- }
7527
- module.czr_Item.add( item_candidate.id, new module.itemConstructor( item_candidate.id, item_candidate ) );
7528
 
7529
- if ( ! module.czr_Item.has( item_candidate.id ) ) {
7530
- throw new Error('CZRModule::instantiateItem() : instantiation failed for item id ' + item_candidate.id + ' for module ' + this.id );
7531
- }
7532
- return module.czr_Item( item_candidate.id );
7533
- },
7534
- prepareItemForAPI : function( item_candidate ) {
7535
- var module = this,
7536
- api_ready_item = {};
7537
- item_candidate = _.isObject( item_candidate ) ? item_candidate : {};
7538
 
7539
- _.each( module.defaultAPIitemModel, function( _value, _key ) {
7540
- var _candidate_val = item_candidate[_key];
7541
- switch( _key ) {
7542
- case 'id' :
7543
- if ( _.isEmpty( _candidate_val ) ) {
7544
- api_ready_item[_key] = module.generateItemId( module.module_type );
7545
- } else {
7546
- api_ready_item[_key] = _candidate_val;
7547
- }
7548
- break;
7549
- case 'initial_item_model' :
7550
- _.each( module.getDefaultItemModel() , function( _value, _property ) {
7551
- if ( ! _.has( item_candidate, _property) )
7552
- item_candidate[_property] = _value;
7553
- });
7554
- api_ready_item[_key] = item_candidate;
7555
 
7556
- break;
7557
- case 'defaultItemModel' :
7558
- api_ready_item[_key] = _.clone( module.defaultItemModel );
7559
- break;
7560
- case 'control' :
7561
- api_ready_item[_key] = module.control;
7562
- break;
7563
- case 'module' :
7564
- api_ready_item[_key] = module;
7565
- break;
7566
- case 'is_added_by_user' :
7567
- api_ready_item[_key] = _.isBoolean( _candidate_val ) ? _candidate_val : false;
7568
- break;
7569
- }//switch
7570
- });
7571
- if ( ! _.has( api_ready_item, 'id' ) ) {
7572
- api_ready_item.id = module.generateItemId( module.module_type );
7573
- }
7574
- api_ready_item.initial_item_model.id = api_ready_item.id;
7575
 
7576
- return api_ready_item;
7577
- },
7578
- generateItemId : function( module_type, key, i ) {
7579
- i = i || 1;
7580
- if ( i > 100 ) {
7581
- throw new Error( 'Infinite loop when generating of a module id.' );
7582
- }
7583
- var module = this;
7584
- key = key || module._getNextItemKeyInCollection();
7585
- var id_candidate = module_type + '_' + key;
7586
- if ( ! _.has(module, 'itemCollection') || ! _.isArray( module.itemCollection() ) ) {
7587
- throw new Error('The item collection does not exist or is not properly set in module : ' + module.id );
7588
- }
7589
- if ( module.isItemRegistered( id_candidate ) ) {
7590
- key++; i++;
7591
- return module.generateItemId( module_type, key, i );
7592
- }
7593
- return id_candidate;
7594
- },
7595
- _getNextItemKeyInCollection : function() {
7596
- var module = this,
7597
- _maxItem = {},
7598
- _next_key = 0;
7599
- if ( _.isEmpty( module.itemCollection() ) )
7600
- return _next_key;
7601
- if ( _.isArray( module.itemCollection() ) && 1 === _.size( module.itemCollection() ) ) {
7602
- _maxItem = module.itemCollection()[0];
7603
- } else {
7604
- _maxItem = _.max( module.itemCollection(), function( _item ) {
7605
- if ( ! _.isNumber( _item.id.replace(/[^\/\d]/g,'') ) )
7606
- return 0;
7607
- return parseInt( _item.id.replace( /[^\/\d]/g, '' ), 10 );
7608
- });
7609
- }
7610
- if ( ! _.isUndefined( _maxItem ) && _.isNumber( _maxItem.id.replace(/[^\/\d]/g,'') ) ) {
7611
- _next_key = parseInt( _maxItem.id.replace(/[^\/\d]/g,''), 10 ) + 1;
7612
- }
7613
- return _next_key;
7614
- },
7615
- isItemRegistered : function( id_candidate ) {
7616
- var module = this;
7617
- return ! _.isUndefined( _.findWhere( module.itemCollection(), { id : id_candidate}) );
7618
- },
7619
- updateItemsCollection : function( args ) {
7620
- var module = this,
7621
- _current_collection = module.itemCollection(),
7622
- _new_collection = _.clone(_current_collection),
7623
- dfd = $.Deferred();
7624
- if ( _.has( args, 'collection' ) ) {
7625
- module.itemCollection.set( args.collection );
7626
- return;
7627
- }
7628
 
7629
- if ( ! _.has( args, 'item' ) ) {
7630
- throw new Error('updateItemsCollection, no item provided ' + module.control.id + '. Aborting');
7631
- }
7632
- args = _.extend( { data : {} }, args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7633
 
7634
- var item = _.clone( args.item );
7635
- if ( _.findWhere( _new_collection, { id : item.id } ) ) {
7636
- _.each( _current_collection , function( _item, _ind ) {
7637
- if ( _item.id != item.id )
7638
- return;
7639
- _new_collection[_ind] = item;
7640
- });
7641
- }
7642
- else {
7643
- _new_collection.push(item);
7644
- }
7645
- module.itemCollection.set( _new_collection, args.data );
7646
- return dfd.resolve( { collection : _new_collection, data : args.data } ).promise();
7647
- },
7648
- _getSortedDOMItemCollection : function( ) {
7649
- var module = this,
7650
- _old_collection = _.clone( module.itemCollection() ),
7651
- _new_collection = [],
7652
- dfd = $.Deferred();
7653
- $( '.' + module.control.css_attr.single_item, module.container ).each( function( _index ) {
7654
- var _item = _.findWhere( _old_collection, {id: $(this).attr('data-id') });
7655
- if ( ! _item )
7656
- return;
7657
 
7658
- _new_collection[_index] = _item;
7659
- });
 
7660
 
7661
- if ( _old_collection.length != _new_collection.length ) {
7662
- throw new Error('There was a problem when re-building the item collection from the DOM in module : ' + module.id );
7663
- }
7664
- return dfd.resolve( _new_collection ).promise();
7665
- },
7666
- refreshItemCollection : function() {
7667
- var module = this;
7668
- module.czr_Item.each( function( _itm ) {
7669
- $.when( module.czr_Item( _itm.id ).container.remove() ).done( function() {
7670
- module.czr_Item.remove( _itm.id );
7671
- });
7672
- });
7673
- module.itemCollection = new api.Value( [] );
7674
- module.populateSavedItemCollection();
7675
- }
7676
- });//$.extend//CZRBaseControlMths
7677
- })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
7678
 
7679
- var CZRModuleMths = CZRModuleMths || {};
 
 
 
 
 
 
 
 
 
 
 
 
7680
  ( function ( api, $, _ ) {
7681
- $.extend( CZRModuleMths, {
7682
- getDefaultItemModel : function( id ) {
7683
- var module = this;
7684
- return $.extend( _.clone( module.defaultItemModel ), { id : id || '' } );
 
7685
  },
7686
- _initNewItem : function( _item , _next_key ) {
7687
- var module = this,
7688
- _new_item = { id : '' },
7689
- _id;
7690
- _next_key = 'undefined' != typeof(_next_key) ? _next_key : _.size( module.itemCollection() );
7691
-
7692
- if ( _.isNumber(_next_key) ) {
7693
- _id = module.module_type + '_' + _next_key;
7694
- }
7695
- else {
7696
- _id = _next_key;
7697
- _next_key = 0;
7698
- }
7699
 
7700
- if ( _item && ! _.isEmpty( _item) )
7701
- _new_item = $.extend( _item, { id : _id } );
7702
- else
7703
- _new_item = this.getDefaultItemModel( _id );
7704
- if ( _.has(_new_item, 'id') && module._isItemIdPossible(_id) ) {
7705
- _.map( module.getDefaultItemModel() , function( value, property ){
7706
- if ( ! _.has(_new_item, property) )
7707
- _new_item[property] = value;
7708
- });
7709
 
7710
- return _new_item;
7711
- }
7712
- return module._initNewItem( _new_item, _next_key + 1);
7713
- }
7714
- });//$.extend
7715
- })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
 
 
 
 
 
 
7716
 
7717
- var CZRModuleMths = CZRModuleMths || {};
7718
- ( function ( api, $, _ ) {
7719
- $.extend( CZRModuleMths, {
7720
- renderModuleParts : function() {
7721
- var module = this,
7722
- $_moduleContentEl = module.isInSektion() ? $( module.container ).find('.czr-mod-content') : $( module.container );
7723
- if ( module.isCrud() ) {
7724
- if ( 0 === $( '#tmpl-' + module.crudModulePart ).length ) {
7725
- throw new Error('No crud Module Part template for module ' + module.id + '. The template script id should be : #tmpl-' + module.crudModulePart );
7726
- }
7727
- $_moduleContentEl.append( $( wp.template( module.crudModulePart )( {} ) ) );
7728
- }
7729
- var $_module_items_wrapper = $(
7730
- '<ul/>',
7731
- {
7732
- class : [
7733
- module.control.css_attr.items_wrapper,
7734
- module.module_type,
7735
- module.isMultiItem() ? 'multi-item-mod' : 'mono-item-mod',
7736
- module.isCrud() ? 'crud-mod' : 'not-crud-mod'
7737
- ].join(' ')
7738
- }
7739
- );
7740
 
7741
- $_moduleContentEl.append($_module_items_wrapper);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7742
 
7743
- return $( $_module_items_wrapper, $_moduleContentEl );
7744
- },
7745
- getTemplateEl : function( type, item_model ) {
7746
- var module = this, _el;
7747
- switch(type) {
7748
- case 'rudItemPart' :
7749
- _el = module.rudItemPart;
7750
- break;
7751
- case 'ruItemPart' :
7752
- _el = module.ruItemPart;
7753
- break;
7754
- case 'modOptInputList' :
7755
- _el = module.modOptInputList;
7756
- break;
7757
- case 'itemInputList' :
7758
- _el = module.itemInputList;
7759
- break;
7760
- }
7761
- if ( _.isEmpty(_el) ) {
7762
- throw new Error('No valid template has been found in getTemplateEl() ' + module.id + '. Aborting');
7763
- } else {
7764
- return _el;
7765
- }
7766
- },
7767
- getViewEl : function( id ) {
7768
- var module = this;
7769
- return $( '[data-id = "' + id + '"]', module.container );
7770
- },
7771
- closeAllItems : function( id ) {
7772
- var module = this,
7773
- _current_collection = _.clone( module.itemCollection() ),
7774
- _filtered_collection = _.filter( _current_collection , function( mod) { return mod.id != id; } );
7775
 
7776
- _.each( _filtered_collection, function( _item ) {
7777
- if ( module.czr_Item.has(_item.id) && 'expanded' == module.czr_Item(_item.id)._getViewState(_item.id) )
7778
- module.czr_Item( _item.id ).viewState.set( 'closed' ); // => will fire the cb toggleItemExpansion
7779
- } );
7780
- return this;
7781
- },
7782
- _adjustScrollExpandedBlock : function( $_block_el, adjust ) {
7783
- if ( ! $_block_el.length || _.isUndefined( this.getModuleSection() ) )
7784
- return;
7785
- var module = this,
7786
- $_moduleSection = $( '.accordion-section-content', module.section.container ),//was api.section( control.section() )
7787
- _currentScrollTopVal = $_moduleSection.scrollTop(),
7788
- _scrollDownVal,
7789
- _adjust = adjust || 90;
7790
 
7791
- setTimeout( function() {
7792
- if ( ( $_block_el.offset().top + $_block_el.height() + _adjust ) > $(window.top).height() ) {
7793
- _scrollDownVal = $_block_el.offset().top + $_block_el.height() + _adjust - $(window.top).height();
7794
- if ( _scrollDownVal > 0 ) {
7795
- $_moduleSection.animate({
7796
- scrollTop: _currentScrollTopVal + _scrollDownVal
7797
- }, 500);
7798
  }
7799
- }
7800
- }, 50);
7801
- },
7802
- closeRemoveDialogs : function() {
7803
- var module = this;
7804
- if ( ! _.isArray( module.itemCollection() ) )
7805
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7806
 
7807
- module.czr_Item.each( function( _item_ ) {
7808
- _item_.removeDialogVisible( false );
7809
- });
7810
- return this;
7811
- },
7812
- _makeItemsSortable : function(obj) {
7813
- if ( wp.media.isTouchDevice || ! $.fn.sortable )
7814
- return;
7815
- var module = this;
7816
- $( '.' + module.control.css_attr.items_wrapper, module.container ).sortable( {
7817
- handle: '.' + module.control.css_attr.item_sort_handle,
7818
- start: function() {
7819
- if ( _.has(api, 'czrModulePanelState' ) )
7820
- api.czrModulePanelState.set(false);
7821
- if ( _.has(api, 'czrSekSettingsPanelState' ) )
7822
- api.czrSekSettingsPanelState.set(false);
7823
- },
7824
- update: function( event, ui ) {
7825
- var _sortedCollectionReact = function() {
7826
- if ( _.has(module, 'preItem') ) {
7827
- module.preItemExpanded.set(false);
7828
- }
7829
 
7830
- module.closeAllItems().closeRemoveDialogs();
7831
- var refreshPreview = function() {
7832
- api.previewer.refresh();
7833
- };
7834
- if ( 'postMessage' == api(module.control.id).transport && ! api.CZR_Helpers.hasPartRefresh( module.control.id ) ) {
7835
- refreshPreview = _.debounce( refreshPreview, 500 );//500ms are enough
7836
- refreshPreview();
7837
- }
 
7838
 
7839
- module.trigger( 'item-collection-sorted' );
7840
- };
7841
- module._getSortedDOMItemCollection()
7842
- .done( function( _collection_ ) {
7843
- module.itemCollection.set( _collection_ );
7844
- })
7845
- .then( function() {
7846
- _sortedCollectionReact();
7847
- });
7848
- }//update
7849
- }
7850
- );
7851
- },
7852
 
 
 
7853
 
7854
 
7855
- /*-----------------------------------------------
7856
- * TABS NAVIGATION IN ITEMS AND MODOPT
7857
- ------------------------------------------------*/
7858
- toggleTabVisibility : function( args ) {
7859
- var inputParent = this,
7860
- tabs = $( inputParent.container ).find('li'),
7861
- content_items = $( inputParent.container ).find('section'),
7862
- tabIdSwitchedTo = $( args.dom_event.currentTarget, args.dom_el ).attr('data-tab-id');
7863
 
7864
- $( '.tabs nav li', inputParent.container ).each( function() {
7865
- $(this).removeClass('tab-current').addClass('tab-inactive');
7866
- });
7867
- $( inputParent.container ).find('li[data-tab-id="' + tabIdSwitchedTo + '"]').addClass('tab-current').removeClass('tab-inactive');
7868
 
7869
- $( 'section', inputParent.container ).each( function() {
7870
- $(this).removeClass('content-current');
7871
- });
7872
- $( inputParent.container ).find('section[id="' + tabIdSwitchedTo + '"]').addClass('content-current');
7873
- },
7874
- setupTabNav : function() {
7875
- var inputParent = this,
7876
- preProcessTabs = function() {
7877
- var dfd = $.Deferred(),
7878
- $tabs = $( '.tabs nav li', inputParent.container );
 
 
 
 
7879
 
7880
- $tabs.each( function() {
7881
- $(this).removeClass('tab-current').addClass('tab-inactive');
7882
- });
7883
- $tabs.first().addClass( 'tab-current' ).removeClass('tab-inactive');
7884
- $( 'section', inputParent.container ).first().addClass( 'content-current' );
7885
- var _nb = $tabs.length;
7886
- $tabs.each( function() {
7887
- $(this).addClass( _nb > 0 ? 'cols-' + _nb : '' );
7888
- });
7889
- return dfd.resolve().promise();
7890
- };
7891
- setTimeout(
7892
- function() {
7893
- preProcessTabs().done( function() {
7894
- $('.tabs', inputParent.container ).fadeIn( 450 );
7895
- });
7896
- },
7897
- 20//<= introducing a small delay to let jQuery do its preprocessing job
7898
- );
7899
- }
7900
- });//$.extend
7901
- })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
7902
 
7903
- var CZRDynModuleMths = CZRDynModuleMths || {};
7904
- ( function ( api, $, _ ) {
7905
- $.extend( CZRDynModuleMths, {
7906
- initialize: function( id, options ) {
7907
- var module = this;
7908
- api.CZRModule.prototype.initialize.call( module, id, options );
7909
- $.extend( module, {
7910
- itemPreAddEl : ''//is specific for each crud module
7911
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7912
 
7913
- module.preItemsWrapper = '';//will store the pre items wrapper
7914
- module.itemAddedMessage = serverControlParams.i18n.successMessage;
7915
- module.userEventMap = new api.Value( [
7916
- {
7917
- trigger : 'click keydown',
7918
- selector : [ '.' + module.control.css_attr.open_pre_add_btn, '.' + module.control.css_attr.cancel_pre_add_btn ].join(','),
7919
- name : 'pre_add_item',
7920
- actions : [ 'closeAllItems', 'closeRemoveDialogs', 'renderPreItemView','setPreItemViewVisibility' ],
7921
- },
7922
- {
7923
- trigger : 'click keydown',
7924
- selector : '.' + module.control.css_attr.add_new_btn, //'.czr-add-new',
7925
- name : 'add_item',
7926
- actions : [ 'closeRemoveDialogs', 'closeAllItems', 'addItem' ],
7927
- }
7928
- ]);//module.userEventMap
7929
- },
7930
- ready : function() {
7931
- var module = this;
7932
- module.setupDOMListeners( module.userEventMap() , { dom_el : module.container } );
7933
- module.preItem = new api.Value( module.getDefaultItemModel() );
7934
- module.preItemEmbedded = $.Deferred();//was module.czr_preItem.create('item_content');
7935
- module.preItemEmbedded.done( function( $preWrapper ) {
7936
- module.preItemsWrapper = $preWrapper;
7937
- module.setupPreItemInputCollection();
7938
- });
7939
- module.preItemExpanded = new api.Value(false);
7940
- module.preItemExpanded.callbacks.add( function( to, from ) {
7941
- module._togglePreItemViewExpansion( to );
7942
- });
7943
 
7944
- api.CZRModule.prototype.ready.call( module );//fires the parent
7945
- },//ready()
7946
- setupPreItemInputCollection : function() {
7947
- var module = this;
7948
- module.preItem.czr_Input = new api.Values();
7949
- $('.' + module.control.css_attr.pre_add_wrapper, module.container)
7950
- .find( '.' + module.control.css_attr.sub_set_wrapper)
7951
- .each( function( _index ) {
7952
- var _id = $(this).find('[data-type]').attr('data-type') || 'sub_set_' + _index;
7953
- module.preItem.czr_Input.add( _id, new module.inputConstructor( _id, {//api.CZRInput;
7954
- id : _id,
7955
- type : $(this).attr('data-input-type'),
7956
- container : $(this),
7957
- input_parent : module.preItem,
7958
- module : module,
7959
- is_preItemInput : true
7960
- } ) );
7961
- module.preItem.czr_Input(_id).ready();
7962
- });//each
7963
- },
7964
- addItem : function(obj) {
7965
- var module = this,
7966
- item = module.preItem(),
7967
- collapsePreItem = function() {
7968
- module.preItemExpanded.set(false);
7969
- module._resetPreItemInputs();
7970
- },
7971
- dfd = $.Deferred();
7972
 
7973
- if ( _.isEmpty(item) || ! _.isObject(item) ) {
7974
- api.errorLog( 'addItem : an item should be an object and not empty. In : ' + module.id +'. Aborted.' );
7975
- return dfd.resolve().promise();
7976
- }
7977
- collapsePreItem = _.debounce( collapsePreItem, 200 );
7978
- module.instantiateItem( item, true ).ready(); //true == Added by user
7979
- ( function() {
7980
- return $.Deferred( function() {
7981
- var _dfd_ = this;
7982
- module.czr_Item( item.id ).isReady.then( function() {
7983
- collapsePreItem();
7984
 
7985
- module.trigger('item-added', item );
7986
- if ( 'postMessage' == api(module.control.id).transport && _.has( obj, 'dom_event') && ! _.has( obj.dom_event, 'isTrigger' ) && ! api.CZR_Helpers.hasPartRefresh( module.control.id ) ) {
7987
- module.control.previewer.refresh().done( function() {
7988
- _dfd_.resolve();
7989
- });
7990
- } else {
7991
- _dfd_.resolve();
7992
- }
7993
- });
7994
- }).promise();
7995
- })().done( function() {
7996
- module.czr_Item( item.id ).viewState( 'expanded' );
7997
- }).always( function() {
7998
- dfd.resolve();
7999
- });
8000
- return dfd.promise();
8001
- },
8002
 
8003
- _resetPreItemInputs : function() {
8004
- var module = this;
8005
- module.preItem.set( module.getDefaultItemModel() );
8006
- module.preItem.czr_Input.each( function( input_instance ) {
8007
- var _input_id = input_instance.id;
8008
- if ( ! _.has( module.getDefaultItemModel(), _input_id ) )
8009
- return;
8010
- input_instance.set( module.getDefaultItemModel()._input_id );
8011
- });
8012
- }
8013
  });//$.extend
8014
- })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
8015
-
8016
- var CZRDynModuleMths = CZRDynModuleMths || {};
8017
  ( function ( api, $, _ ) {
8018
- $.extend( CZRDynModuleMths, {
8019
- renderPreItemView : function( obj ) {
8020
- var module = this;
8021
- if ( 'pending' != module.preItemEmbedded.state() ) //was ! _.isEmpty( module.czr_preItem('item_content')() ) )
8022
- return;
8023
- if ( ! _.has(module, 'itemPreAddEl') || 0 === $( '#tmpl-' + module.itemPreAddEl ).length )
8024
- return this;
8025
- var pre_add_template = wp.template( module.itemPreAddEl );
8026
- if ( ! pre_add_template || ! module.container )
8027
- return this;
 
 
 
 
 
 
 
 
 
8028
 
8029
- var $_pre_add_el = $('.' + module.control.css_attr.pre_add_item_content, module.container );
8030
- $_pre_add_el.prepend( pre_add_template() );
8031
- module.preItemEmbedded.resolve( $_pre_add_el );
8032
- },
8033
- _getPreItemView : function() {
8034
- var module = this;
8035
- return $('.' + module.control.css_attr.pre_add_item_content, module.container );
8036
- },
8037
- setPreItemViewVisibility : function(obj) {
8038
- var module = this;
8039
- module.preItemExpanded.set( ! module.preItemExpanded() );
8040
- },
8041
- _togglePreItemViewExpansion : function( _is_expanded ) {
8042
- var module = this,
8043
- $_pre_add_el = $( '.' + module.control.css_attr.pre_add_item_content, module.container );
8044
- $_pre_add_el.slideToggle( {
8045
- duration : 200,
8046
- done : function() {
8047
- var $_btn = $( '.' + module.control.css_attr.open_pre_add_btn, module.container );
8048
 
8049
- $(this).toggleClass('open' , _is_expanded );
8050
- if ( _is_expanded )
8051
- $_btn.find('.fa').removeClass('fa-plus-square').addClass('fa-minus-square');
8052
- else
8053
- $_btn.find('.fa').removeClass('fa-minus-square').addClass('fa-plus-square');
8054
- $_btn.toggleClass( 'active', _is_expanded );
8055
- $( module.container ).toggleClass( module.control.css_attr.adding_new, _is_expanded );
8056
- module._adjustScrollExpandedBlock( $(this), 120 );
8057
- }//done
8058
- } );
8059
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8060
 
 
 
 
 
 
 
 
 
8061
 
8062
- toggleSuccessMessage : function( status ) {
8063
- var module = this,
8064
- _message = module.itemAddedMessage,
8065
- $_pre_add_wrapper = $('.' + module.control.css_attr.pre_add_wrapper, module.container );
8066
- $_success_wrapper = $('.' + module.control.css_attr.pre_add_success, module.container );
 
 
 
 
 
 
 
 
 
 
 
8067
 
8068
- if ( 'on' == status ) {
8069
- $_success_wrapper.find('p').text(_message);
8070
- $_success_wrapper.css('z-index', 1000001 )
8071
- .css('height', $_pre_add_wrapper.height() + 'px' )
8072
- .css('line-height', $_pre_add_wrapper.height() + 'px');
8073
- } else {
8074
- $_success_wrapper.attr('style','');
8075
- }
8076
- module.container.toggleClass('czr-model-added', 'on' == status );
8077
- return this;
8078
- }
8079
- });//$.extend//CZRBaseControlMths
8080
- })( wp.customize , jQuery, _ );
8081
- var CZRSocialModuleMths = CZRSocialModuleMths || {};
8082
- ( function ( api, $, _ ) {
8083
- $.extend( CZRSocialModuleMths, {
8084
- initialize: function( id, options ) {
8085
- var module = this;
8086
- api.CZRDynModule.prototype.initialize.call( module, id, options );
8087
- $.extend( module, {
8088
- itemPreAddEl : 'czr-module-social-pre-add-view-content',
8089
- itemInputList : 'czr-module-social-item-content',
8090
- modOptInputList : 'czr-module-social-mod-opt'
8091
- } );
8092
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8093
 
8094
- this.social_icons = [
8095
- '500px',
8096
- 'adn',
8097
- 'amazon',
8098
- 'android',
8099
- 'angellist',
8100
- 'apple',
8101
- 'behance',
8102
- 'behance-square',
8103
- 'bitbucket',
8104
- 'bitbucket-square',
8105
- 'black-tie',
8106
- 'btc',
8107
- 'buysellads',
8108
- 'chrome',
8109
- 'codepen',
8110
- 'codiepie',
8111
- 'connectdevelop',
8112
- 'contao',
8113
- 'dashcube',
8114
- 'delicious',
8115
- 'deviantart',
8116
- 'digg',
8117
- 'dribbble',
8118
- 'dropbox',
8119
- 'drupal',
8120
- 'edge',
8121
- 'empire',
8122
- 'envelope',
8123
- 'envelope-o',
8124
- 'envelope-square',
8125
- 'expeditedssl',
8126
- 'facebook',
8127
- 'facebook-f (alias)',
8128
- 'facebook-official',
8129
- 'facebook-square',
8130
- 'firefox',
8131
- 'flickr',
8132
- 'fonticons',
8133
- 'fort-awesome',
8134
- 'forumbee',
8135
- 'foursquare',
8136
- 'get-pocket',
8137
- 'gg',
8138
- 'gg-circle',
8139
- 'git',
8140
- 'github',
8141
- 'github-alt',
8142
- 'github-square',
8143
- 'gitlab',
8144
- 'git-square',
8145
- 'google',
8146
- 'google-plus',
8147
- 'google-plus-circle',
8148
- 'google-plus-official',
8149
- 'google-plus-square',
8150
- 'google-wallet',
8151
- 'gratipay',
8152
- 'hacker-news',
8153
- 'houzz',
8154
- 'instagram',
8155
- 'internet-explorer',
8156
- 'ioxhost',
8157
- 'joomla',
8158
- 'jsfiddle',
8159
- 'lastfm',
8160
- 'lastfm-square',
8161
- 'leanpub',
8162
- 'linkedin',
8163
- 'linkedin-square',
8164
- 'linux',
8165
- 'maxcdn',
8166
- 'meanpath',
8167
- 'medium',
8168
- 'mixcloud',
8169
- 'mobile',
8170
- 'modx',
8171
- 'odnoklassniki',
8172
- 'odnoklassniki-square',
8173
- 'opencart',
8174
- 'openid',
8175
- 'opera',
8176
- 'optin-monster',
8177
- 'pagelines',
8178
- 'paypal',
8179
- 'phone',
8180
- 'phone-square',
8181
- 'pied-piper',
8182
- 'pied-piper-alt',
8183
- 'pinterest',
8184
- 'pinterest-p',
8185
- 'pinterest-square',
8186
- 'product-hunt',
8187
- 'qq',
8188
- 'rebel',
8189
- 'reddit',
8190
- 'reddit-alien',
8191
- 'reddit-square',
8192
- 'renren',
8193
- 'rss',
8194
- 'rss-square',
8195
- 'safari',
8196
- 'scribd',
8197
- 'sellsy',
8198
- 'share-alt',
8199
- 'share-alt-square',
8200
- 'shirtsinbulk',
8201
- 'simplybuilt',
8202
- 'skyatlas',
8203
- 'skype',
8204
- 'slack',
8205
- 'slideshare',
8206
- 'snapchat',
8207
- 'soundcloud',
8208
- 'spotify',
8209
- 'stack-exchange',
8210
- 'stack-overflow',
8211
- 'steam',
8212
- 'steam-square',
8213
- 'stumbleupon',
8214
- 'stumbleupon-circle',
8215
- 'telegram',
8216
- 'tencent-weibo',
8217
- 'trello',
8218
- 'tripadvisor',
8219
- 'tumblr',
8220
- 'tumblr-square',
8221
- 'twitch',
8222
- 'twitter',
8223
- 'twitter-square',
8224
- 'usb',
8225
- 'viacoin',
8226
- 'vimeo',
8227
- 'vimeo-square',
8228
- 'vine',
8229
- 'vk',
8230
- 'weibo',
8231
- 'weixin',
8232
- 'whatsapp',
8233
- 'wikipedia-w',
8234
- 'windows',
8235
- 'wordpress',
8236
- 'xing',
8237
- 'xing-square',
8238
- 'yahoo',
8239
- 'y-combinator',
8240
- 'yelp',
8241
- 'youtube',
8242
- 'youtube-play',
8243
- 'youtube-square'
8244
- ];
8245
- module.inputConstructor = api.CZRInput.extend( module.CZRSocialsInputMths || {} );
8246
- module.itemConstructor = api.CZRItem.extend( module.CZRSocialsItem || {} );
8247
- this.defaultModOptModel = {
8248
- is_mod_opt : true,
8249
- module_id : module.id,
8250
- 'social-size' : serverControlParams.social_el_params.defaultSocialSize || 14
8251
- };
8252
- this.defaultItemModel = {
8253
- id : '',
8254
- title : '' ,
8255
- 'social-icon' : '',
8256
- 'social-link' : '',
8257
- 'social-color' : serverControlParams.social_el_params.defaultSocialColor,
8258
- 'social-target' : 1
8259
- };
8260
- this.itemAddedMessage = serverControlParams.i18n.socialLinkAdded;
8261
- if ( _.has( api, 'czr_activeSectionId' ) && module.control.section() == api.czr_activeSectionId() && 'resolved' != module.isReady.state() ) {
8262
- module.ready();
8263
- }
8264
 
8265
- api.section( module.control.section() ).expanded.bind(function(to) {
8266
- if ( 'resolved' != module.isReady.state() ) {
8267
- module.ready();
8268
- }
8269
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8270
 
8271
- module.isReady.then( function() {
8272
- module.preItem.bind( function( to, from ) {
8273
- if ( ! _.has(to, 'social-icon') )
8274
- return;
8275
- if ( _.isEqual( to['social-icon'], from['social-icon'] ) )
8276
- return;
8277
- module.updateItemModel( module.preItem, true );
8278
- });
8279
- });
8280
- },//initialize
8281
- updateItemModel : function( item_instance, is_preItem ) {
8282
- var item = item_instance;
8283
- is_preItem = is_preItem || false;
8284
- if ( ! _.has( item(), 'social-icon') || _.isEmpty( item()['social-icon'] ) )
8285
- return;
8286
 
8287
- var _new_model, _new_title, _new_color;
 
 
 
 
 
8288
 
8289
- _new_model = $.extend( true, {}, item() );//always safer to deep clone ( alternative to _.clone() ) => we don't know how nested this object might be in the future
8290
- _new_title = this.getTitleFromIcon( _new_model['social-icon'] );
8291
- _new_color = serverControlParams.social_el_params.defaultSocialColor;
8292
- if ( ! is_preItem && item.czr_Input.has( 'social-color' ) )
8293
- _new_color = item.czr_Input('social-color')();
8294
- _new_title = [ serverControlParams.i18n.followUs, _new_title].join(' ');
 
8295
 
8296
- if ( is_preItem ) {
8297
- _new_model = $.extend( _new_model, { title : _new_title, 'social-color' : _new_color } );
8298
- item.set( _new_model );
8299
- } else {
8300
- item.czr_Input('title').set( _new_title );
8301
- if ( item.czr_Input('social-color') ) { //optional
8302
- item.czr_Input('social-color').set( _new_color );
8303
- }
8304
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8305
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8306
 
8307
- /* Helpers */
8308
- getTitleFromIcon : function( icon ) {
8309
- return api.CZR_Helpers.capitalize( icon.replace('fa-', '').replace('envelope', 'email') );
8310
- },
 
 
 
 
 
 
 
 
8311
 
8312
- getIconFromTitle : function( title ) {
8313
- return 'fa-' . title.toLowerCase().replace('envelope', 'email');
8314
- },
 
 
 
8315
 
 
8316
 
 
 
 
 
 
 
 
 
 
 
 
8317
 
 
 
 
 
8318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8319
 
 
 
 
 
 
 
 
 
 
8320
 
8321
 
8322
- CZRSocialsInputMths : {
8323
- setupSelect : function() {
8324
- var input = this,
8325
- item = input.input_parent,
8326
- module = input.module,
8327
- socialList = module.social_icons,
8328
- _model = item
30
  }/*! 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?!0:d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth:!1},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){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");
31
  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?!1:(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?!1: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";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;
32
  },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 */
33
+ !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);"});
34
+ ( function ( api, $, _ ) {
35
+ /*****************************************************************************
36
+ * REACT TO PREVIEW DEVICE SWITCH => send device to preview
37
+ *****************************************************************************/
38
+ api.bind( 'ready' , function() {
39
+ if ( api.previewedDevice ) {
40
+ api.previewedDevice.bind( function( device ) {
41
+ api.previewer.send( 'previewed-device', device );
42
+ });
43
+ }
44
+ });
45
+ })( wp.customize , jQuery, _);//NOT USED YET
46
  ( function ( api, $, _ ) {
47
  var _prettyPrintLog = function( args ) {
48
  var _defaults = {
91
  return serverControlParams.isChangeSetOn && true === true;//&& true === true is just there to hackily cast the returned value as boolean.
92
  };
93
 
94
+ })( wp.customize , jQuery, _);
95
+ ( function ( api, $, _ ) {
96
  /*****************************************************************************
97
+ * A "CONTEXT AWARE" SET METHD
98
  *****************************************************************************/
99
+ /**
100
+ * OVERRIDES BASE api.Value method
101
+ * => adds the o {} param, allowing to pass additional contextual informations.
102
+ *
103
+ * Set the value and trigger all bound callbacks.
104
+ *
105
+ * @param {object} to New value.
106
+ */
107
+ api.Value.prototype.set = function( to, o ) {
108
+ var from = this._value, dfd = $.Deferred(), self = this, _promises = [];
109
 
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
+ }
 
 
116
 
117
+ this._value = to;
118
+ this._dirty = true;
119
+ if ( true === args.silent ) {
120
+ return dfd.resolveWith( self, [ to, from, o ] ).promise();
121
+ }
 
 
 
 
 
 
 
 
122
 
123
+ if ( this._deferreds ) {
124
+ _.each( self._deferreds, function( _prom ) {
125
+ _promises.push( _prom.apply( null, [ to, from, o ] ) );
126
+ });
127
 
128
+ $.when.apply( null, _promises )
129
+ .fail( function() { api.errorLog( 'A deferred callback failed in api.Value::set()'); })
130
+ .then( function() {
131
+ self.callbacks.fireWith( self, [ to, from, o ] );
132
+ dfd.resolveWith( self, [ to, from, o ] );
133
+ });
134
+ } else {
135
+ this.callbacks.fireWith( this, [ to, from, o ] );
136
+ return dfd.resolveWith( self, [ to, from, o ] ).promise( self );
137
+ }
138
+ return dfd.promise( self );
139
  };
140
+ api.Value.prototype.bind = function() {
141
+ var self = this,
142
+ _isDeferred = false,
143
+ _cbs = [];
144
 
145
+ $.each( arguments, function( _key, _arg ) {
146
+ if ( ! _isDeferred )
147
+ _isDeferred = _.isObject( _arg ) && _arg.deferred;
148
+ if ( _.isFunction( _arg ) )
149
+ _cbs.push( _arg );
150
+ });
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
+ if ( _isDeferred ) {
153
+ self._deferreds = self._deferreds || [];
154
+ _.each( _cbs, function( _cb ) {
155
+ if ( ! _.contains( _cb, self._deferreds ) )
156
+ self._deferreds.push( _cb );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  });
158
+ } else {
159
+ self.callbacks.add.apply( self.callbacks, arguments );
160
+ }
161
+ return this;
162
+ };
163
 
164
  /*****************************************************************************
165
+ * A SILENT SET METHOD :
166
+ * => keep the dirtyness param unchanged
167
+ * => stores the api state before callback calls, and reset it after
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
+ }
 
 
 
 
 
 
 
 
 
180
 
181
+ this._value = to;
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 );
 
 
 
 
 
 
 
193
 
194
+ setting.id = id;
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
+
203
+ transport = setting.transport;
204
+
205
+ if ( serverControlParams.isSkopOn && api.czr_isPreviewerSkopeAware && 'pending' == api.czr_isPreviewerSkopeAware.state() ) {
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 );
 
234
  });
235
+ } else {
236
+ setting.previewer.refresh();
237
+ dfd.resolve( arguments );
238
+ }
239
  }
240
 
241
+ return dfd.promise();
242
+ };//api.Setting.prototype.preview
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
 
252
+ this.expanded.callbacks.add( function( _expanded ) {
253
+ if ( ! _expanded )
254
+ return;
 
 
 
 
 
 
 
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
+ };
265
  }
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 ) ) {
273
+ api.consoleLog( 'getControlSettingId : The requested control_id is not registered in the api yet : ' + control_id );
274
+ return control_id;
275
+ }
276
+ if ( ! _.has( api.control( control_id ), 'settings' ) || _.isEmpty( api.control( control_id ).settings ) )
277
+ return control_id;
278
 
279
+ if ( ! _.has( api.control( control_id ).settings, setting_type ) ) {
280
+ api.consoleLog( 'getControlSettingId : The requested control_id does not have the requested setting type : ' + control_id + ' , ' + setting_type );
281
+ return control_id;
282
+ }
283
+ if ( _.isUndefined( api.control( control_id ).settings[setting_type].id ) ) {
284
+ api.consoleLog( 'getControlSettingId : The requested control_id has no setting id assigned : ' + control_id );
285
+ return control_id;
286
+ }
287
+ return api.control( control_id ).settings[setting_type].id;
288
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
 
291
 
292
+ getDocSearchLink : function( text ) {
293
+ text = ! _.isString(text) ? '' : text;
294
+ var _searchtext = text.replace( / /g, '+'),
295
+ _url = [ serverControlParams.docURL, 'search?query=', _searchtext ].join('');
296
+ return [
297
+ '<a href="' + _url + '" title="' + serverControlParams.i18n.readDocumentation + '" target="_blank">',
298
+ ' ',
299
+ '<span class="fa fa-question-circle-o"></span>'
300
+ ].join('');
301
+ },
302
 
303
 
304
+ /*
305
+ * @return string
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
 
314
+ return -1 == setId.indexOf( serverControlParams.themeOptions ) ? [ serverControlParams.themeOptions +'[' , setId , ']' ].join('') : setId;
315
+ },
316
 
317
+ /*
318
+ * @return string
319
+ * simple helper to extract the option name from a setting id
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;
330
+ return _.contains( _.map( api.czr_partials(), function( partial, key ) {
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 ) ?
337
+ [] :
338
+ _.map( api.section( section_id ).controls(), function( _ctrl ) {
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) )
345
+ return;
346
+ var self = this,
347
+ _sec_settings = [],
348
+ _sec_controls = self.getSectionControlIds( section_id );
349
 
350
+ _.each( _sec_controls, function( ctrlId ) {
351
+ _.each( api.control(ctrlId).settings, function( _instance, _k ) {
352
+ _sec_settings.push( _instance.id );
353
+ });
354
+ });
355
+ return _sec_settings;
356
+ },
357
+ capitalize : function( string ) {
358
+ if( ! _.isString(string) )
359
+ return string;
360
+ return string.charAt(0).toUpperCase() + string.slice(1);
361
+ },
362
 
363
+ truncate : function( string, n, useWordBoundary ){
364
+ if ( ! _.isString( string ) )
365
+ return '';
366
+ n = n || 20;
367
+ var isTooLong = string.length > n,
368
+ s_ = isTooLong ? string.substr(0,n-1) : string;
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;
375
+ if ( _.isObject( moduleInst ) && _.has( moduleInst, 'module_type' ) )
376
+ module_type = moduleInst.module_type;
377
+ else if ( _.isUndefined( module_type ) || _.isNull( module_type ) )
378
+ return;
379
+ if ( ! _.has( api.czrModuleMap, module_type ) )
380
+ return;
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;
387
+ if ( _.isObject( moduleInst ) && _.has( moduleInst, 'module_type' ) )
388
+ module_type = moduleInst.module_type;
389
+ else if ( _.isUndefined( module_type ) || _.isNull( module_type ) )
390
+ return;
391
+ if ( ! _.has( api.czrModuleMap, module_type ) )
392
+ return;
 
 
 
 
 
 
 
 
 
 
 
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;
399
+ if ( _.isObject( moduleInst ) && _.has( moduleInst, 'module_type' ) )
400
+ module_type = moduleInst.module_type;
401
+ else if ( _.isUndefined( module_type ) || _.isNull( module_type ) )
402
+ return;
403
+ if ( ! _.has( api.czrModuleMap, module_type ) )
404
+ return;
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 ) ) {
411
+ throw new Error( 'setupInputCollectionFromDOM : inputParentInst is not valid.' );
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;
421
 
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 ) )
428
+ inputParentInst_model = _defaultInputParentModel;
429
+ else
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,
449
+ transport : _inputTransport,
450
+ input_value : _value,
451
+ input_options : _inputOptions,//<= a module can define a specific set of option
452
+ container : $(this),
453
+ input_parent : inputParentInst,
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 ) ) {
466
+ throw new Error( 'removeInputCollection : inputParentInst is not valid.' );
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) {
489
+ return r + r + g + g + b + b;
490
+ });
491
+ } catch( er ) {
492
+ api.errorLog( 'Error in Helpers::hexToRgb : ' + er );
493
+ return hex;
494
+ }
495
 
496
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec( hex );
497
+ result = result ? [
498
+ parseInt(result[1], 16),//r
499
+ parseInt(result[2], 16),//g
500
+ parseInt(result[3], 16)//b
501
+ ] : [];
502
+ return 'rgb(' + result.join(',') + ')';
503
+ },
504
 
505
+ rgbToHex : function ( r, g, b ) {
506
+ var componentToHex = function(c) {
507
+ var hex = c.toString(16);
508
+ return hex.length == 1 ? "0" + hex : hex;
509
+ };
510
+ return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
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;
520
+ instance = instance || control;
521
+ instance[event_map] = instance[event_map] || [];
522
+ new_event_map = _.clone( instance[event_map] );
523
+ instance[event_map] = _.union( new_event_map, ! _.isArray(new_events) ? [new_events] : new_events );
524
+ },
525
 
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 = {
532
+ model : {},
533
+ dom_el : {}
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;
578
+ }
579
+ try { control.executeEventActionChain( actionsParams, instance ); } catch( er ) {
580
+ api.errorLog( 'In setupDOMListeners : problem when trying to fire actions : ' + actionsParams.event.actions );
581
+ api.errorLog( 'Error : ' + er );
582
+ }
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 )
595
+ return;
596
 
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();
615
+ api.czr_partials = api.czr_partials || new api.Value();
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
+ });
624
 
625
+ var _inactives = _.filter( data.registeredSidebars, function( sb ) {
626
+ return ! _.has( data.renderedSidebars, sb.id );
627
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
628
 
629
+ _inactives = _.map( _inactives, function(obj) {
630
+ return obj.id;
631
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
 
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,
639
+ inactives : _inactives,
640
+ registered : _registered,
641
+ candidates : _candidates,
642
+ available_locations : data.availableWidgetLocations//built server side
643
+ } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
 
645
+ });
 
 
 
 
 
 
646
 
647
+ /* WP CONDITIONAL TAGS => stores and observes the WP conditional tags sent by the preview */
648
+ api.previewer.bind( 'czr-query-data-ready', function( data ) {
649
+ api.czr_wpQueryInfos( data );
650
+ if ( 'pending' == api.czr_wpQueryDataReady.state() ) {
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;
666
+ api.control( ctrlId ).trigger( 'czr-partial-refresh-done' );
667
+ });
668
+ });//api.bind('ready')
669
+ })( wp.customize , jQuery, _ );var CZRInputMths = CZRInputMths || {};
670
+ ( function ( api, $, _ ) {
671
+ $.extend( CZRInputMths , {
672
+ initialize: function( name, options ) {
673
+ if ( _.isUndefined( options.input_parent ) || _.isEmpty(options.input_parent) ) {
674
+ throw new Error('No input_parent assigned to input ' + options.id + '. Aborting');
675
+ }
676
+ if ( _.isUndefined(options.module ) ) {
677
+ throw new Error('No module assigned to input ' + options.id + '. Aborting');
678
  }
 
 
679
 
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]) ) {
691
+ input[_meth]( options.input_options || null );
692
+ }
693
+ } else {
694
+ api.consoleLog('Warning an input : ' + input.id + ' has no corresponding method defined in api.czrInputMap.');
695
+ }
696
 
697
+ var trigger_map = {
698
+ text : 'keyup',
699
+ textarea : 'keyup',
700
+ password : 'keyup',
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]',
708
+ name : 'set_input_value',
709
+ actions : function( obj ) {
710
+ if ( ! _.has( input.input_parent, 'syncElements') || ! _.has( input.input_parent.syncElements, input.id ) ) {
711
+ throw new Error('WARNING : THE INPUT ' + input.id + ' HAS NO SYNCED ELEMENT.');
712
+ }
713
+ }//was 'updateInput'
714
+ }
715
+ ];
716
+ input.visible = new api.Value( true );
717
+ input.isReady.done( function() {
718
+ input.visible.bind( function( visible ) {
719
+ if ( visible )
720
+ input.container.stop( true, true ).slideDown( 200 );
721
+ else
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 ) {
728
+ input.container.toggleClass( 'disabled', ! enabled );
729
+ });
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
+ }
 
 
750
 
751
+ var syncElement = new api.Element( $_input_el );
752
+ input_parent.syncElements = input_parent.syncElements || {};
753
+ input_parent.syncElements[input.id] = syncElement;//adds the input syncElement to the collection
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,
776
+ input_parent_id : input.input_parent.id,
777
+ to : to,
778
+ from : from
779
+ } );
780
+ }
781
+ }
782
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
784
 
785
+ /*-----------------------------------------
786
+ SOME DEFAULT CALLBACKS
787
+ ------------------------------------------*/
788
+ setupColorPicker : function() {
789
+ var input = this;
790
 
791
+ input.container.find('input').iris( {
792
+ palettes: true,
793
+ hide:false,
794
+ change : function( e, o ) {
795
+ $(this).val( o.color.toString() ).trigger('colorpickerchange').trigger('change');
796
  }
797
+ });
798
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
 
800
+ setupSelect : function() {
801
+ var input = this;
802
+ $('select', input.container ).not('.no-selecter-js')
803
+ .each( function() {
804
+ $(this).selecter({
805
+ });
806
+ });
807
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808
 
809
+ setupIcheck : function( obj ) {
810
+ var input = this;
 
 
 
 
 
 
 
811
 
812
+ $( 'input[type=checkbox]', input.container ).each( function(e) {
813
+ if ( 0 !== $(this).closest('div[class^="icheckbox"]').length )
814
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815
 
816
+ $(this).iCheck({
817
+ checkboxClass: 'icheckbox_flat-grey',
818
+ checkedClass: 'checked',
819
+ radioClass: 'iradio_flat-grey',
820
+ })
821
+ .on( 'ifChanged', function(e){
822
+ $(this).val( false === $(this).is(':checked') ? 0 : 1 );
823
+ $(e.currentTarget).trigger('change');
824
+ });
825
+ });
826
+ },
827
 
828
+ setupStepper : function( obj ) {
829
+ var input = this;
830
+ $('input[type="number"]',input.container ).each( function( e ) {
831
+ $(this).stepper();
832
  });
833
+ },
834
+ setupRangeSlider : function( options ) {
835
+ var input = this,
836
+ $handle,
837
+ _updateHandle = function(el, val) {
838
+ el.textContent = val + "%";
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
+ });
857
+ }
858
+ });//$.extend
859
+ })( wp.customize , jQuery, _ );var CZRInputMths = CZRInputMths || {};
860
  ( function ( api, $, _ ) {
861
+ $.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
+ });
874
+ },
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;
886
+ input.renderImageUploaderTemplate();
887
+ } else {
888
+ wp.media.attachment( to ).fetch().done( function() {
889
+ input.attachment = this.attributes;
890
+ input.renderImageUploaderTemplate();
891
+ });
892
+ }
893
+ }//Standard reaction, the image has been updated by the user or init
894
+ else if ( ! input.attachment.id || input.attachment.id === to ) {
895
+ input.renderImageUploaderTemplate();
896
+ }
897
+ },
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 );
905
 
906
+ input.bind( input.id + ':changed', function( to, from ){
907
+ input.tmplRendered = $.Deferred();
908
+ input.setupContentRendering(to,from);
909
+ });
910
+ },
911
+ /**
912
+ * Open the media modal.
913
+ */
914
+ czrImgUploadOpenFrame: function( event ) {
915
+ if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
916
+ return;
917
+ }
918
 
919
+ event.preventDefault();
 
 
 
 
 
 
 
 
920
 
921
+ if ( ! this.frame ) {
922
+ this.czrImgUploadInitFrame();
923
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
924
 
925
+ this.frame.open();
926
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
927
 
928
+ /**
929
+ * Create a media modal select frame, and store it so the instance can be reused when needed.
930
+ */
931
+ czrImgUploadInitFrame: function() {
932
+ var input = this,
933
+ button_labels = this.getUploaderLabels();
 
934
 
935
+ input.frame = wp.media({
936
+ button: {
937
+ text: button_labels.frame_button
938
+ },
939
+ states: [
940
+ new wp.media.controller.Library({
941
+ title: button_labels.frame_title,
942
+ library: wp.media.query({ type: 'image' }),
943
+ multiple: false,
944
+ date: false
945
+ })
946
+ ]
947
+ });
948
+ input.frame.on( 'select', input.czrImgUploadSelect );
949
+ },
950
 
951
+ /**
952
+ * Called when the "Remove" link is clicked. Empties the setting.
953
+ *
954
+ * @param {object} event jQuery Event object
955
+ */
956
+ czrImgUploadRemoveFile: function( event ) {
957
+ var input = this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
958
 
959
+ if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
960
+ return;
961
+ }
962
+ event.preventDefault();
963
+ input.attachment = {};
964
+ input.set('');
965
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
966
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
967
 
968
+ /**
969
+ * Callback handler for when an attachment is selected in the media modal.
970
+ * Gets the selected image information, and sets it within the input.
971
+ */
972
+ czrImgUploadSelect: function() {
973
+ var node,
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
 
989
+ var $_view_el = input.container.find('.' + input.module.control.css_attr.img_upload_container );
990
 
991
+ if ( ! $_view_el.length )
992
+ return;
993
 
994
+ var _template_params = {
995
+ button_labels : input.getUploaderLabels(),
996
+ settings : input.id,
997
+ attachment : input.attachment,
998
+ canUpload : true
999
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1000
 
1001
+ $_view_el.html( view_template( _template_params) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1002
 
1003
+ input.tmplRendered.resolve();
1004
+ input.container.trigger( input.id + ':content_rendered' );
 
 
 
 
 
 
1005
 
1006
+ return true;
1007
+ },
 
 
 
 
 
1008
 
1009
+ getUploaderLabels : function() {
1010
+ var _ts = serverControlParams.i18n,
1011
+ _map = {
1012
+ 'select' : _ts.select_image,
1013
+ 'change' : _ts.change_image,
1014
+ 'remove' : _ts.remove_image,
1015
+ 'default' : _ts.default_image,
1016
+ 'placeholder' : _ts.placeholder_image,
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;
1023
+ api.errorLog( 'A translated string is missing ( ' + key + ' ) for the image uploader input in module : ' + input.module.id );
1024
+ return '';
1025
+ }
1026
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1027
 
1028
+ return _map;
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 , {
1035
+ setupContentPicker: function( wpObjectTypes ) {
1036
+ var input = this,
1037
+ _event_map = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1038
 
1039
+ /* Dummy for the prototype purpose */
1040
+ $.extend( {
1041
+ post : '',
1042
+ taxonomy : ''
1043
+ }, _.isObject( wpObjectTypes ) ? wpObjectTypes : {} );
1044
 
1045
+ input.wpObjectTypes = wpObjectTypes;
 
 
 
 
 
 
 
 
 
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]',
1053
+ name : 'set_input_value',
1054
+ actions : function( obj ){
1055
+ var $_changed_input = $( obj.dom_event.currentTarget, obj.dom_el ),
1056
+ _raw_val = $( $_changed_input, obj.dom_el ).select2( 'data' ),
1057
+ _val_candidate = {},
1058
+ _default = {
1059
+ id : '',
1060
+ type_label : '',
1061
+ title : '',
1062
+ object_type : '',
1063
+ url : ''
1064
+ };
1065
 
1066
+ _raw_val = _.isArray( _raw_val ) ? _raw_val[0] : _raw_val;
1067
+ if ( ! _.isObject( _raw_val ) || _.isEmpty( _raw_val ) ) {
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 ] ) ) {
1074
+ api.errorLog( 'content_picker : missing input param : ' + k );
1075
+ return;
1076
+ }
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
 
1102
+ input.container.find( 'select' ).select2( {
1103
+ placeholder: {
1104
+ id: '-1', // the value of the option
1105
+ title: 'Select'
1106
+ },
1107
+ data : input.setupSelectedContents(),
1108
+ ajax: {
1109
+ url: serverControlParams.AjaxUrl,
1110
+ type: 'POST',
1111
+ dataType: 'json',
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 {
1118
+ action : params.term ? "search-available-content-items-customizer" : "load-available-content-items-customizer",
1119
+ search : params.term,
1120
+ wp_customize : 'on',
1121
+ page : page,
1122
+ wp_object_types : JSON.stringify( input.wpObjectTypes ),
1123
+ CZRCpNonce : serverControlParams.CZRCpNonce
1124
+ };
1125
+ },
1126
+ /* transport: function (params, success, failure) {
1127
+ var $request = $.ajax(params);
1128
 
1129
+ $request.then(success);
1130
+ $request.fail(failure);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1131
 
1132
+ return $request;
1133
+ },*/
1134
+ processResults: function ( data, params ) {
1135
+ input.defaultContentPickerOption = input.defaultContentPickerOption || [];
 
 
 
1136
 
1137
+ if ( ! data.success )
1138
+ return { results: input.defaultContentPickerOption };
 
 
 
1139
 
 
 
 
 
 
1140
 
1141
+ var items = data.data.items,
1142
+ _results = [];
1143
 
1144
+ _.each( items, function( item ) {
1145
+ _results.push({
1146
+ id : item.id,
1147
+ title : item.title,
1148
+ type_label : item.type_label,
1149
+ object_type : item.object,
1150
+ url : item.url
1151
+ });
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
+ },
1158
+ },//ajax
1159
+ templateSelection: input.czrFormatContentSelected,
1160
+ templateResult: input.czrFormatContentSelected,
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'>" +
1167
+ "<div class='content-item-bar'>" +
1168
+ "<span class='czr-picker-item-title'>" + item.title + "</span>";
 
 
 
 
 
 
 
 
 
 
 
 
 
1169
 
1170
+ if ( item.type_label ) {
1171
+ markup += "<span class='czr-picker-item-type'>" + item.type_label + "</span>";
1172
+ }
 
 
 
 
 
 
 
 
 
 
1173
 
1174
+ markup += "</div></div>";
 
 
 
 
 
 
 
 
 
 
 
 
 
1175
 
1176
+ return markup;
1177
+ },
 
 
 
 
 
 
 
1178
 
1179
+ setupSelectedContents : function() {
1180
+ var input = this,
1181
+ _model = input();
 
 
 
 
1182
 
1183
+ return _model;
1184
+ }
1185
+ });//$.extend
1186
+ })( wp.customize , jQuery, _ );var CZRInputMths = CZRInputMths || {};
1187
+ ( function ( api, $, _ ) {
1188
+ $.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
+ }
1195
 
1196
+ if ( ! input.czrRenderInputTextEditorTemplate() )
1197
+ return;
 
 
 
 
 
 
 
 
 
 
 
1198
 
1199
+ input.editor = tinyMCE( 'czr-customize-content_editor' );
1200
+ input.textarea = $( '#czr-customize-content_editor' );
1201
+ input.editorPane = $( '#czr-customize-content_editor-pane' );
1202
+ input.dragbar = $( '#czr-customize-content_editor-dragbar' );
1203
+ input.editorFrame = $( '#czr-customize-content_editor_ifr' );
1204
+ input.mceTools = $( '#wp-czr-customize-content_editor-tools' );
1205
+ input.mceToolbar = input.editorPane.find( '.mce-toolbar-grp' );
1206
+ input.mceStatusbar = input.editorPane.find( '.mce-statusbar' );
1207
 
1208
+ input.preview = $( '#customize-preview' );
1209
+ input.collapse = $( '.collapse-sidebar' );
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
 
1217
+ input.czrTextEditorBinding();
 
 
 
 
 
 
 
 
 
 
 
 
 
1218
 
1219
+ input.czrResizeEditorOnUserRequest();
1220
+ },
 
 
 
 
 
 
 
 
 
1221
 
1222
+ czrTextEditorBinding : function() {
1223
+ var input = this,
1224
+ editor = input.editor,
1225
+ textarea = input.textarea,
1226
+ toggleButton = input.toggleButton,
1227
+ editorExpanded = input.editorExpanded,
1228
+ editorPane = input.editorPane;
1229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1230
 
1231
+ input.bind( input.id + ':changed', input.czrUpdateTextPreview );
 
 
 
 
1232
 
1233
+ _.bindAll( input, 'czrOnVisualEditorChange', 'czrOnTextEditorChange', 'czrResizeEditorOnWindowResize' );
 
 
 
 
1234
 
1235
+ toggleButton.on( 'click', function() {
1236
+ input.editorExpanded.set( ! input.editorExpanded() );
1237
+ if ( input.editorExpanded() ) {
1238
+ editor.focus();
1239
+ }
1240
+ });
1241
+ input.module.czr_ModuleState.bind(
1242
+ function( state ) {
1243
+ if ( 'expanded' != state )
1244
+ input.editorExpanded.set( false );
1245
+ });
 
 
1246
 
1247
+ input.editorExpanded.bind( function (expanded) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1248
 
1249
+ api.consoleLog('in input.editorExpanded', expanded, input() );
1250
+ /*
1251
+ * Ensure only the latest input is bound
1252
+ */
1253
+ if ( editor.locker && editor.locker !== input ) {
1254
+ editor.locker.editorExpanded.set(false);
1255
+ editor.locker = null;
1256
+ }if ( ! editor.locker || editor.locker === input ) {
1257
+ $(document.body).toggleClass('czr-customize-content_editor-pane-open', expanded);
1258
+ editor.locker = input;
1259
+ }
1260
+ input.czrSetToggleButtonText( expanded );
1261
 
1262
+ if ( expanded ) {
1263
+ editor.setContent( wp.editor.autop( input() ) );
1264
+ editor.on( 'input change keyup', input.czrOnVisualEditorChange );
1265
+ textarea.on( 'input', input.czrOnTextEditorChange );
1266
+ input.czrResizeEditor( window.innerHeight - editorPane.height() );
1267
+ $( window ).on('resize', input.czrResizeEditorOnWindowResize );
1268
 
1269
+ } else {
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
+ } );
1276
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1277
 
1278
+ czrOnVisualEditorChange : function() {
1279
+ var input = this,
1280
+ editor = input.editor,
1281
+ value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1282
 
1283
+ value = wp.editor.removep( editor.getContent() );
1284
+ input.set(value);
1285
+ },
1286
 
1287
+ czrOnTextEditorChange : function() {
1288
+ var input = this,
1289
+ textarea = input.textarea,
1290
+ value;
1291
 
1292
+ value = textarea.val();
1293
+ input.set(value);
1294
+ },
1295
+ czrUpdateTextPreview: function() {
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
+
1316
+ api.consoleLog('Model injected in text editor tmpl : ', input() );
1317
+
1318
+ $_view_el.after( view_template( input() ) );
1319
+
1320
+ return true;
1321
+ },
1322
+ czrIsEditorExpanded : function() {
1323
+ return $( document.body ).hasClass('czr-customize-content_editor-pane-open');
1324
+ },
1325
+ czrResizeReset : function() {
1326
+ var input = this,
1327
+ preview = input.preview,
1328
+ collapse = input.collapse,
1329
+ sectionContent = input.container.closest('ul.accordion-section-content');
1330
+
1331
+ sectionContent.css( 'padding-bottom', '' );
1332
+ preview.css( 'bottom', '' );
1333
+ collapse.css( 'bottom', '' );
1334
+ },
1335
+ czrResizeEditor : function( position ) {
1336
+ var windowHeight = window.innerHeight,
1337
+ windowWidth = window.innerWidth,
1338
+ minScroll = 40,
1339
+ maxScroll = 1,
1340
+ mobileWidth = 782,
1341
+ collapseMinSpacing = 56,
1342
+ collapseBottomOutsideEditor = 8,
1343
+ collapseBottomInsideEditor = 4,
1344
+ args = {},
1345
+ input = this,
1346
+ sectionContent = input.container.closest('ul.accordion-section-content'),
1347
+ mceTools = input.mceTools,
1348
+ mceToolbar = input.mceToolbar,
1349
+ mceStatusbar = input.mceStatusbar,
1350
+ preview = input.preview,
1351
+ collapse = input.collapse,
1352
+ editorPane = input.editorPane,
1353
+ editorFrame = input.editorFrame;
1354
+
1355
+ if ( ! input.editorExpanded() ) {
1356
+ return;
1357
+ }
1358
+
1359
+ if ( ! _.isNaN( position ) ) {
1360
+ resizeHeight = windowHeight - position;
1361
+ }
1362
+
1363
+ args.height = resizeHeight;
1364
+ args.components = mceTools.outerHeight() + mceToolbar.outerHeight() + mceStatusbar.outerHeight();
1365
+
1366
+ if ( resizeHeight < minScroll ) {
1367
+ args.height = minScroll;
1368
+ }
1369
+
1370
+ if ( resizeHeight > windowHeight - maxScroll ) {
1371
+ args.height = windowHeight - maxScroll;
1372
+ }
1373
+
1374
+ if ( windowHeight < editorPane.outerHeight() ) {
1375
+ args.height = windowHeight;
1376
+ }
1377
 
1378
+ preview.css( 'bottom', args.height );
1379
+ editorPane.css( 'height', args.height );
1380
+ editorFrame.css( 'height', args.height - args.components );
1381
+ collapse.css( 'bottom', args.height + collapseBottomOutsideEditor );
1382
+
1383
+ if ( collapseMinSpacing > windowHeight - args.height ) {
1384
+ collapse.css( 'bottom', mceStatusbar.outerHeight() + collapseBottomInsideEditor );
1385
+ }
1386
+
1387
+ if ( windowWidth <= mobileWidth ) {
1388
+ sectionContent.css( 'padding-bottom', args.height );
1389
+ } else {
1390
+ sectionContent.css( 'padding-bottom', '' );
1391
+ }
1392
+ },
1393
+ czrResizeEditorOnWindowResize : function() {
1394
+ var input = this,
1395
+ resizeDelay = 50,
1396
+ editorPane = input.editorPane;
1397
+
1398
+ if ( ! input.editorExpanded() ) {
1399
+ return;
1400
+ }
1401
+
1402
+ _.delay( function() {
1403
+ input.czrResizeEditor( window.innerHeight - editorPane.height() );
1404
+ }, resizeDelay );
1405
+
1406
+ },
1407
+ czrResizeEditorOnUserRequest : function() {
1408
+ var input = this,
1409
+ dragbar = input.dragbar,
1410
+ editorFrame = input.editorFrame;
1411
+
1412
+ dragbar.on( 'mousedown', function() {
1413
+ if ( ! input.editorExpanded() )
1414
+ return;
1415
+
1416
+ $( document ).on( 'mousemove.czr-customize-content_editor', function( event ) {
1417
+ event.preventDefault();
1418
+ $( document.body ).addClass( 'czr-customize-content_editor-pane-resize' );
1419
+ editorFrame.css( 'pointer-events', 'none' );
1420
+ input.czrResizeEditor( event.pageY );
1421
+ } );
1422
+ } );
1423
+
1424
+ dragbar.on( 'mouseup', function() {
1425
+ if ( ! input.editorExpanded() )
1426
+ return;
1427
+
1428
+ $( document ).off( 'mousemove.czr-customize-content_editor' );
1429
+ $( document.body ).removeClass( 'czr-customize-content_editor-pane-resize' );
1430
+ editorFrame.css( 'pointer-events', '' );
1431
+ } );
1432
+
1433
+ },
1434
+ czrSetToggleButtonText : function( $_expanded ) {
1435
+ var input = this;
1436
+
1437
+ input.toggleButton.text( serverControlParams.i18n.mods.textEditor[ ! $_expanded ? 'Edit' : 'Close Editor' ] );
1438
+ }
1439
  });//$.extend
1440
+ })( wp.customize , jQuery, _ );//extends api.Value
 
 
 
 
 
 
 
 
 
 
 
 
 
1441
 
1442
+ var CZRItemMths = CZRItemMths || {};
1443
+ ( function ( api, $, _ ) {
1444
+ $.extend( CZRItemMths , {
1445
+ initialize: function( id, options ) {
1446
+ if ( _.isUndefined(options.module) || _.isEmpty(options.module) ) {
1447
+ throw new Error('No module assigned to item ' + id + '. Aborting');
1448
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(','),
1467
+ name : 'toggle_remove_alert',
1468
+ actions : function() {
1469
+ var _isVisible = this.removeDialogVisible();
1470
+ this.module.closeRemoveDialogs();
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
 
1533
 
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
 
1582
+ if ( 'pending' != item.embedded.state() )
1583
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1584
 
1585
+ $.when( item.renderItemWrapper() ).done( function( $_container ) {
1586
+ item.container = $_container;
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;
1604
+ item.toggleItemExpansion( to, from );
1605
+ }
1606
+ else {
1607
+ throw new Error( 'Module : ' + item.module.id + ', the item content has not been rendered for ' + item.id );
1608
+ }
1609
+ };
 
 
 
 
 
 
 
 
 
 
 
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;
1680
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ };
1690
+ if ( visible )
1691
+ $_alert_el.stop( true, true ).slideDown( 200, function() { _slideComplete( visible ); } );
1692
+ else
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,
1733
+ _model = item_model || item(),
1734
+ _title = _.has( _model, 'title')? api.CZR_Helpers.capitalize( _model.title ) : _model.id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
1743
+ if ( is_added_by_user ) {
1744
+ item.viewState.set( 'expanded_noscroll' );
1745
+ } else {
1746
+ module.closeAllItems( item.id );
1747
+ if ( _.has(module, 'preItem') ) {
1748
+ module.preItemExpanded.set(false);
1749
+ }
1750
+ item.viewState.set( 'expanded' == item._getViewState() ? 'closed' : 'expanded' );
1751
+ }
1752
+ },
1753
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1754
 
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,
1761
+ module = this.module,
1762
+ $el = $( '.' + module.control.css_attr.item_content , item.container ).first(),
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 );
1771
+ if ( visible )
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
 
1778
+ dfd.resolve();
1779
+ };
1780
 
1781
+ if ( visible )
1782
+ $el.stop( true, true ).slideDown( duration || 200, function() { _slideComplete( visible ); } );
1783
+ else
1784
+ $el.stop( true, true ).slideUp( 200, function() { _slideComplete( visible ); } );
1785
 
1786
+ return dfd.promise();
1787
+ },
1788
+ _destroyView : function ( duration ) {
1789
+ this.container.fadeOut( {
1790
+ duration : duration ||400,
1791
+ done : function() {
1792
+ $(this).remove();
1793
+ }
1794
+ });
1795
+ }
1796
+ });//$.extend
1797
+ })( wp.customize , jQuery, _ );//extends api.Value
 
 
 
 
 
1798
 
1799
+ var CZRModOptMths = CZRModOptMths || {};
1800
+ ( function ( api, $, _ ) {
1801
+ $.extend( CZRModOptMths , {
1802
+ initialize: function( options ) {
1803
+ if ( _.isUndefined(options.module) || _.isEmpty(options.module) ) {
1804
+ throw new Error('No module assigned to modOpt.');
1805
+ }
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 ) {
1824
+ modOpt.container = $_container;
1825
+ try {
1826
+ api.CZR_Helpers.setupInputCollectionFromDOM.call( modOpt ).toggleModPanelView( visible );
1827
+ } catch(e) {
1828
+ api.consoleLog(e);
1829
+ }
1830
+ if ( args.module && args.focus ) {
1831
+ _.delay( function() {
1832
+ if ( _.isNull( args.module.czr_ModOpt.container ) || ! args.module.czr_ModOpt.container.find('[data-tab-id="' + args.focus + '"] a').length )
1833
+ return;
1834
+ args.module.czr_ModOpt.container.find('[data-tab-id="' + args.focus + '"] a').trigger('click');
1835
+ }, 200 );
1836
+ }
1837
+ });
1838
 
1839
+ } else {
1840
+ modOpt.toggleModPanelView( visible ).done( function() {
1841
+ if ( false !== modOpt.container.length ) {
1842
+ $.when( modOpt.container.remove() ).done( function() {
1843
+ api.CZR_Helpers.removeInputCollection.call( modOpt );
1844
+ });
1845
+ } else {
1846
+ api.CZR_Helpers.removeInputCollection.call( modOpt );
1847
+ }
1848
+ modOpt.container = null;
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')
1856
+ .append( $( '<span/>', {
1857
+ class : [ ctrl.css_attr.edit_modopt_icon, 'fa fa-cog' ].join(' '),
1858
+ title : serverControlParams.i18n['Settings']
1859
+ } ) ) )
1860
+ .done( function(){
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,
1869
+ name : 'toggle_mod_option',
1870
+ actions : function() {
1871
+ api.czr_ModOptVisible( ! api.czr_ModOptVisible() );
1872
+ }
1873
+ }
1874
+ ],//actions to execute
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
+ }
1884
+ });//$.extend
1885
+ })( wp.customize , jQuery, _ );//extends api.CZRBaseControl
 
 
1886
 
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,
1900
+ name : 'close_mod_option',
1901
+ actions : function() {
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
+ }
1913
+ ],//actions to execute
1914
+ { dom_el: $_container },//model + dom scope
1915
+ modOpt //instance where to look for the cb methods
1916
+ );
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 );
1925
+ }
1926
+ else {
1927
+ throw new Error( 'Module : ' + modOpt.module.id + ', the modOpt content has not been rendered' );
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
 
1949
+ var _ctrlLabel = '';
1950
+ try {
1951
+ _ctrlLabel = [ serverControlParams.i18n['Options for'], module.control.params.label ].join(' ');
1952
+ } catch( er ) {
1953
+ api.errorLog( 'In renderModOptContent : ' + er );
1954
+ _ctrlLabel = serverControlParams.i18n['Settings'];
1955
+ }
 
1956
 
1957
+ $('#widgets-left').after( $( '<div/>', {
1958
+ class : module.control.css_attr.mod_opt_wrapper,
1959
+ html : [
1960
+ [ '<h2 class="mod-opt-title">', _ctrlLabel , '</h2>' ].join(''),
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 );
1967
+ },
1968
 
 
1969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1970
 
1971
+ toggleModPanelView : function( visible ) {
1972
+ var modOpt = this,
1973
+ module = this.module,
1974
+ ctrl = module.control,
1975
+ dfd = $.Deferred();
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 );
1982
+ return dfd.promise();
1983
+ }
1984
+ });//$.extend
1985
+ })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
1986
+ var CZRModuleMths = CZRModuleMths || {};
1987
+ ( function ( api, $, _ ) {
1988
+ $.extend( CZRModuleMths, {
1989
+ initialize: function( id, constructorOptions ) {
1990
+ if ( _.isUndefined(constructorOptions.control) || _.isEmpty(constructorOptions.control) ) {
1991
+ throw new Error('No control assigned to module ' + id );
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
2000
+ ruItemPart : 'czr-ru-item-part',//read, update
2001
+ itemInputList : '',//is specific for each crud module
2002
+ modOptInputList : '',//is specific for each module
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
+ });
2020
 
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 : {},
2040
+ defaultItemModel : {},
2041
+ control : {},//control instance
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
 
2050
+ /*-----------------------------------------------
2051
+ * SET THE DEFAULT INPUT CONSTRUCTOR AND INPUT OPTIONS
2052
+ ------------------------------------------------*/
2053
+ module.inputConstructor = api.CZRInput;//constructor for the items input
2054
+ if ( module.hasModOpt() ) {
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 } ) ];
2100
+ }
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
+ },
2138
 
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;
2167
+ });
2168
+ api_ready_modOpt[_key] = modOpt_candidate;
2169
 
2170
+ break;
2171
+ case 'defaultModOptModel' :
2172
+ api_ready_modOpt[_key] = _.clone( module.defaultModOptModel );
2173
+ break;
2174
+ case 'control' :
2175
+ api_ready_modOpt[_key] = module.control;
2176
+ break;
2177
+ case 'module' :
2178
+ api_ready_modOpt[_key] = module;
2179
+ break;
2180
+ }//switch
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 : '',
2193
+ input_parent_id : '',//<= can be the mod opt or an item
2194
+ to : null,
2195
+ from : null
2196
+ } , args );
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 ): {} },
2204
+ input_parent_id : args.input_parent_id,//<= can be the mod opt or the item
2205
+ input_id : args.input_id,
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 ) {
2219
+ module.sendInputToPreview( {
2220
+ input_id : inputId,
2221
+ input_parent_id : inputParent.id,
2222
+ to : inputVal,
2223
+ from : null,
2224
+ isPartialRefresh : args.isPartialRefresh
2225
+ });
2226
  });
2227
+ };
 
 
 
 
 
2228
 
2229
+ module.czr_Item.each( function( _itm_ ) {
2230
+ _sendInputData.call( _itm_ );
2231
+ });
 
 
 
 
2232
 
2233
+ if ( module.hasModOpt() ) {
2234
+ _sendInputData.call( module.czr_ModOpt );
2235
+ }
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 );
2262
+ }
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 ) {
2291
+ var _candidate_val = item_candidate[_key];
2292
+ switch( _key ) {
2293
+ case 'id' :
2294
+ if ( _.isEmpty( _candidate_val ) ) {
2295
+ api_ready_item[_key] = module.generateItemId( module.module_type );
2296
+ } else {
2297
+ api_ready_item[_key] = _candidate_val;
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;
2304
+ });
2305
+ api_ready_item[_key] = item_candidate;
2306
 
2307
+ break;
2308
+ case 'defaultItemModel' :
2309
+ api_ready_item[_key] = _.clone( module.defaultItemModel );
2310
+ break;
2311
+ case 'control' :
2312
+ api_ready_item[_key] = module.control;
2313
+ break;
2314
+ case 'module' :
2315
+ api_ready_item[_key] = module;
2316
+ break;
2317
+ case 'is_added_by_user' :
2318
+ api_ready_item[_key] = _.isBoolean( _candidate_val ) ? _candidate_val : false;
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.' );
2333
+ }
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() ) ) {
2353
+ _maxItem = module.itemCollection()[0];
2354
+ } else {
2355
+ _maxItem = _.max( module.itemCollection(), function( _item ) {
2356
+ if ( ! _.isNumber( _item.id.replace(/[^\/\d]/g,'') ) )
2357
+ return 0;
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
+ }
 
 
 
 
 
 
2379
 
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
 
2409
+ _new_collection[_index] = _item;
2410
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2411
 
2412
+ if ( _old_collection.length != _new_collection.length ) {
2413
+ throw new Error('There was a problem when re-building the item collection from the DOM in module : ' + module.id );
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) ) {
2444
+ _id = module.module_type + '_' + _next_key;
2445
+ }
2446
+ else {
2447
+ _id = _next_key;
2448
+ _next_key = 0;
2449
+ }
 
 
 
 
 
 
2450
 
2451
+ if ( _item && ! _.isEmpty( _item) )
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;
2459
+ });
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 = $(
2481
+ '<ul/>',
2482
+ {
2483
+ class : [
2484
+ module.control.css_attr.items_wrapper,
2485
+ module.module_type,
2486
+ module.isMultiItem() ? 'multi-item-mod' : 'mono-item-mod',
2487
+ module.isCrud() ? 'crud-mod' : 'not-crud-mod'
2488
+ ].join(' ')
2489
+ }
2490
+ );
2491
 
2492
+ $_moduleContentEl.append($_module_items_wrapper);
2493
 
2494
+ return $( $_module_items_wrapper, $_moduleContentEl );
2495
+ },
2496
+ getTemplateEl : function( type, item_model ) {
2497
+ var module = this, _el;
2498
+ switch(type) {
2499
+ case 'rudItemPart' :
2500
+ _el = module.rudItemPart;
2501
+ break;
2502
+ case 'ruItemPart' :
2503
+ _el = module.ruItemPart;
2504
+ break;
2505
+ case 'modOptInputList' :
2506
+ _el = module.modOptInputList;
2507
+ break;
2508
+ case 'itemInputList' :
2509
+ _el = module.itemInputList;
2510
+ break;
2511
+ }
2512
+ if ( _.isEmpty(_el) ) {
2513
+ throw new Error('No valid template has been found in getTemplateEl() ' + module.id + '. Aborting');
2514
+ } else {
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() ),
2525
+ _filtered_collection = _.filter( _current_collection , function( mod) { return mod.id != id; } );
2526
 
2527
+ _.each( _filtered_collection, function( _item ) {
2528
+ if ( module.czr_Item.has(_item.id) && 'expanded' == module.czr_Item(_item.id)._getViewState(_item.id) )
2529
+ module.czr_Item( _item.id ).viewState.set( 'closed' ); // => will fire the cb toggleItemExpansion
2530
+ } );
2531
+ return this;
2532
+ },
2533
+ _adjustScrollExpandedBlock : function( $_block_el, adjust ) {
2534
+ if ( ! $_block_el.length || _.isUndefined( this.getModuleSection() ) )
2535
+ return;
2536
+ var module = this,
2537
+ $_moduleSection = $( '.accordion-section-content', module.section.container ),//was api.section( control.section() )
2538
+ _currentScrollTopVal = $_moduleSection.scrollTop(),
2539
+ _scrollDownVal,
2540
+ _adjust = adjust || 90;
2541
 
2542
+ setTimeout( function() {
2543
+ if ( ( $_block_el.offset().top + $_block_el.height() + _adjust ) > $(window.top).height() ) {
2544
+ _scrollDownVal = $_block_el.offset().top + $_block_el.height() + _adjust - $(window.top).height();
2545
+ if ( _scrollDownVal > 0 ) {
2546
+ $_moduleSection.animate({
2547
+ scrollTop: _currentScrollTopVal + _scrollDownVal
2548
+ }, 500);
2549
+ }
2550
+ }
2551
+ }, 50);
2552
+ },
2553
+ closeRemoveDialogs : function() {
2554
+ var module = this;
2555
+ if ( ! _.isArray( module.itemCollection() ) )
2556
+ return;
2557
 
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;
2566
+ var module = this;
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
+ },
2575
+ update: function( event, ui ) {
2576
+ var _sortedCollectionReact = function() {
2577
+ if ( _.has(module, 'preItem') ) {
2578
+ module.preItemExpanded.set(false);
2579
+ }
2580
 
2581
+ module.closeAllItems().closeRemoveDialogs();
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();
2588
+ }
2589
 
2590
+ module.trigger( 'item-collection-sorted' );
2591
+ };
2592
+ module._getSortedDOMItemCollection()
2593
+ .done( function( _collection_ ) {
2594
+ module.itemCollection.set( _collection_ );
2595
+ })
2596
+ .then( function() {
2597
+ _sortedCollectionReact();
2598
+ });
2599
+ }//update
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2600
  }
2601
+ );
2602
+ },
 
 
 
 
 
 
 
 
 
2603
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2604
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2605
 
2606
+ /*-----------------------------------------------
2607
+ * TABS NAVIGATION IN ITEMS AND MODOPT
2608
+ ------------------------------------------------*/
2609
+ toggleTabVisibility : function( args ) {
2610
+ var inputParent = this,
2611
+ tabs = $( inputParent.container ).find('li'),
2612
+ content_items = $( inputParent.container ).find('section'),
2613
+ tabIdSwitchedTo = $( args.dom_event.currentTarget, args.dom_el ).attr('data-tab-id');
2614
 
2615
+ $( '.tabs nav li', inputParent.container ).each( function() {
2616
+ $(this).removeClass('tab-current').addClass('tab-inactive');
2617
+ });
2618
+ $( inputParent.container ).find('li[data-tab-id="' + tabIdSwitchedTo + '"]').addClass('tab-current').removeClass('tab-inactive');
 
 
 
2619
 
2620
+ $( 'section', inputParent.container ).each( function() {
2621
+ $(this).removeClass('content-current');
2622
+ });
2623
+ $( inputParent.container ).find('section[id="' + tabIdSwitchedTo + '"]').addClass('content-current');
2624
+ },
2625
+ setupTabNav : function() {
2626
+ var inputParent = this,
2627
+ preProcessTabs = function() {
2628
+ var dfd = $.Deferred(),
2629
+ $tabs = $( '.tabs nav li', inputParent.container );
 
 
2630
 
2631
+ $tabs.each( function() {
2632
+ $(this).removeClass('tab-current').addClass('tab-inactive');
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 : '' );
2639
+ });
2640
+ return dfd.resolve().promise();
 
 
 
 
 
 
 
 
 
 
 
2641
  };
2642
+ setTimeout(
2643
+ function() {
2644
+ preProcessTabs().done( function() {
2645
+ $('.tabs', inputParent.container ).fadeIn( 450 );
2646
+ });
2647
+ },
2648
+ 20//<= introducing a small delay to let jQuery do its preprocessing job
2649
+ );
2650
+ }
2651
+ });//$.extend
2652
+ })( wp.customize , jQuery, _ );//MULTI CONTROL CLASS
2653
 
2654
+ var CZRDynModuleMths = CZRDynModuleMths || {};
2655
+ ( function ( api, $, _ ) {
2656
+ $.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',
2676
+ name : 'add_item',
2677
+ actions : [ 'closeRemoveDialogs', 'closeAllItems', 'addItem' ],
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'),
2707
+ container : $(this),
2708
+ input_parent : module.preItem,
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
 
2724
+ if ( _.isEmpty(item) || ! _.isObject(item) ) {
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 {
2742
+ _dfd_.resolve();
2743
+ }
2744
+ });
2745
+ }).promise();
2746
+ })().done( function() {
2747
+ module.czr_Item( item.id ).viewState( 'expanded' );
2748
+ }).always( function() {
2749
+ dfd.resolve();
2750
+ });
2751
+ return dfd.promise();
2752
+ },
2753
 
2754
+ _resetPreItemInputs : function() {
2755
+ var module = this;
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 );
2762
+ });
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
+ } );
2810
+ },
2811
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2812
 
2813
+ toggleSuccessMessage : function( status ) {
2814
+ var module = this,
2815
+ _message = module.itemAddedMessage,
2816
+ $_pre_add_wrapper = $('.' + module.control.css_attr.pre_add_wrapper, module.container );
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');
2824
+ } else {
2825
+ $_success_wrapper.attr('style','');
2826
+ }
2827
+ module.container.toggleClass('czr-model-added', 'on' == status );
2828
+ return this;
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_ ) {
2843
+ if ( ! control.czr_Module( _mod_.id ) )
2844
+ return;
2845
 
2846
+ control.czr_Module( _mod_.id ).sendModuleInputsToPreview( { isPartialRefresh : true } );
2847
+ });
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, {
2859
+ initialize: function( id, options ) {
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();
2879
+ if ( _.has( _mod, 'preItem' ) ) {
2880
+ _mod.preItemExpanded(false);
2881
+ }
2882
+ });
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,
2922
+ modOpt : {},//the module modOpt property, typically high level properties that area applied to all items of the module
2923
+ items : [],//$.extend( true, {}, module.items ),
2924
+ crud : false,
2925
+ multi_item : false,
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
2932
+ } );
2933
+ } else {
2934
+ return $.extend( commonAPIModel, {
2935
+ column_id : '',//a string like col_7
2936
+ sektion : {},// => the sektion instance
2937
+ sektion_id : '',
2938
+ is_added_by_user : false,
2939
+ dirty : false
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 : '',
2950
+ module_type : '',
2951
+ column_id : '',
2952
+ sektion_id : '',
2953
+ dirty : false
2954
+ } );
2955
+ } else {
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 ) ) {
2965
+ throw new Error( 'Control ' + control.id + ' has no synchronized sektion control defined.');
2966
+ }
2967
+ return api.control( api.CZR_Helpers.build_setId( control.params.syncCollection ) );
2968
+ },
2969
+ getSavedModules : function() {
2970
+ var control = this,
2971
+ _savedModulesCandidates = [],
2972
+ _module_type = control.params.module_type,
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 {
2989
+ _saved_modOpt = item_or_mod_opt_candidate;
 
 
 
2990
  }
2991
+ }
2992
+ if ( _.has( item_or_mod_opt_candidate, 'id') && ! _.has( item_or_mod_opt_candidate, 'is_mod_opt' ) ) {
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,
2999
+ module_type : control.params.module_type,
3000
+ section : control.section(),
3001
+ modOpt : $.extend( true, {} , _saved_modOpt ),//disconnect with a deep cloning
3002
+ items : $.extend( true, [] , _saved_items )//disconnect with a deep cloning
3003
+ }
3004
+ );
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 = {},
3040
+ constructor = {};
3041
 
3042
+ if ( ! _.has( module, 'module_type' ) ) {
3043
+ throw new Error('CZRModule::getModuleConstructor : no module type found for module ' + module.id );
3044
+ }
3045
+ if ( ! _.has( api.czrModuleMap, module.module_type ) ) {
3046
+ throw new Error('Module type ' + module.module_type + ' is not listed in the module map api.czrModuleMap.' );
3047
+ }
3048
+
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
+
3059
+ if ( _.isUndefined(constructor) || _.isEmpty(constructor) || ! constructor ) {
3060
+ throw new Error('CZRModule::getModuleConstructor : no constructor found for module type : ' + module.module_type +'.' );
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.');
3067
  }
3068
 
3069
+ var control = this,
3070
+ api_ready_module = {};
3071
+
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 );
3078
+ } else {
3079
+ api_ready_module[_key] = _candidate_val;
3080
+ }
3081
+ break;
3082
+ case 'module_type' :
3083
+ if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
3084
+ throw new Error('prepareModuleForAPI : a module type must a string not empty');
3085
+ }
3086
+ api_ready_module[_key] = _candidate_val;
3087
+ break;
3088
+ case 'items' :
3089
+ if ( ! _.isArray( _candidate_val ) ) {
3090
+ throw new Error('prepareModuleForAPI : a module item list must be an array');
3091
+ }
3092
+ api_ready_module[_key] = _candidate_val;
3093
+ break;
3094
+ case 'modOpt' :
3095
+ if ( ! _.isObject( _candidate_val ) ) {
3096
+ throw new Error('prepareModuleForAPI : a module modOpt property must be an object');
3097
+ }
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 ) ) {
3104
+ throw new Error('prepareModuleForAPI : the module param "crud" must be a boolean');
3105
+ }
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 ) ) {
3112
+ throw new Error('prepareModuleForAPI : the module param "multi_item" must be a boolean');
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 ) ) {
3120
+ throw new Error('prepareModuleForAPI : the module param "sortable" must be a boolean');
3121
+ }
3122
+ api_ready_module[_key] = _candidate_val || false;
3123
+ break;
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');
3136
+ }
3137
+ api_ready_module[_key] = _candidate_val;
3138
+ break;
3139
+ case 'sektion' :
3140
+ if ( ! _.isObject( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
3141
+ throw new Error('prepareModuleForAPI : a module sektion must be an object not empty');
3142
+ }
3143
+ api_ready_module[_key] = _candidate_val;
3144
+ break;
3145
+ case 'sektion_id' :
3146
+ if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
3147
+ throw new Error('prepareModuleForAPI : a module sektion id must be a string not empty');
3148
+ }
3149
+ api_ready_module[_key] = _candidate_val;
3150
+ break;
3151
+ case 'is_added_by_user' :
3152
+ if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
3153
+ throw new Error('prepareModuleForAPI : the module param "is_added_by_user" must be a boolean');
3154
+ }
3155
+ api_ready_module[_key] = _candidate_val || false;
3156
+ break;
3157
+ case 'dirty' :
3158
+ api_ready_module[_key] = _candidate_val || false;
3159
+ break;
3160
+ }//switch
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.');
3168
+ }
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 );
3178
+ }
 
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 );
3189
+ });
3190
+ _next_key = parseInt( _max_mod_key.id.replace(/[^\/\d]/g,''), 10 ) + 1;
3191
+ }
3192
+ return _next_key;
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
+ }
3232
 
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 ),
3282
+ _to_return;
3283
 
3284
+ _.each( collection , function( _mod, _key ) {
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
+ }
3294
+ if ( ! _.isArray( collection ) || _.isEmpty( collection ) || ! _.has( collection[0], 'items' ) ) {
3295
+ throw new Error('The setting value could not be populated in control : ' + control.id );
3296
+ }
3297
+ var module_id = collection[0].id;
3298
 
3299
+ if ( ! control.czr_Module.has( module_id ) ) {
3300
+ throw new Error('The single module control (' + control.id + ') has no module registered with the id ' + module_id );
3301
+ }
3302
+ var module_instance = control.czr_Module( module_id );
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.');
3313
  }
3314
+ var control = this,
3315
+ db_ready_module = {};
3316
 
3317
+ _.each( control.getDefaultModuleDBModel() , function( _value, _key ) {
3318
+ if ( ! _.has( module_db_candidate, _key ) ) {
3319
+ throw new Error('MultiModule Control::prepareModuleForDB : a module is missing the property : ' + _key + ' . Aborting.');
3320
+ }
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');
3333
+ }
3334
+ db_ready_module[ _key ] = _candidate_val;
3335
+ break;
3336
+ case 'module_type' :
3337
+ if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
3338
+ throw new Error('prepareModuleForDB : a module type must a string not empty');
3339
+ }
3340
+ db_ready_module[ _key ] = _candidate_val;
3341
+ break;
3342
+ case 'column_id' :
3343
+ if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
3344
+ throw new Error('prepareModuleForDB : a module column id must a string not empty');
3345
+ }
3346
+ db_ready_module[ _key ] = _candidate_val;
3347
+ break;
3348
+ case 'sektion_id' :
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' :
3355
+ if ( control.czr_Module.has( module_db_candidate.id ) )
3356
+ db_ready_module[ _key ] = control.czr_Module( module_db_candidate.id ).isDirty();
3357
+ else
3358
+ db_ready_module[ _key ] = _candidate_val;
3359
+ if ( ! _.isBoolean( db_ready_module[ _key ] ) ) {
3360
+ throw new Error('prepareModuleForDB : a module dirty state must be a boolean.');
3361
+ }
3362
+ break;
3363
+ }//switch
3364
+ });
3365
+ return db_ready_module;
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
 
3380
 
3381
+ ready : function() {
3382
+ var control = this;
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
+ } );
3397
+ if ( ! _.isEmpty( added_mod ) ) {
3398
+ api.consoleLog('ADDED MODULE?', added_mod );
3399
+ _.each( added_mod, function( _mod ) {
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
+ } );
3406
+ if ( ! _.isEmpty( removed_mod ) ) {
3407
+ _.each( removed_mod, function( _mod ) {
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 });
3414
+ } );
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
 
3425
+
3426
+ removeModuleFromCollection : function( module ) {
3427
+ var control = this,
3428
+ _current_collection = control.czr_moduleCollection(),
3429
+ _new_collection = $.extend( true, [], _current_collection);
3430
+
3431
+ _new_collection = _.filter( _new_collection, function( _mod ) {
3432
+ return _mod.id != module.id;
3433
+ } );
3434
+ control.czr_moduleCollection.set( _new_collection );
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 );
3473
+ $.when( module.renderModuleWrapper( is_added_by_user ) ).done( function( $_module_container ) {
3474
+ if ( _.isUndefined($_module_container) || false === $_module_container.length ) {
3475
+ throw new Error( 'Module container has not been embedded for module :' + module.id );
3476
+ }
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
+ }
3494
 
3495
+ var module_wrapper_tmpl = wp.template( module.singleModuleWrapper ),
3496
+ tmpl_data = {
3497
+ id : module.id,
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() {
3504
+ $( '.czr-module-collection-wrapper' , module._getColumn().container ).find( '.czr-module-candidate').remove();
3505
+ });
3506
+ } else {
3507
+ $( '.czr-module-collection-wrapper' , module._getColumn().container).append( $_module_el );
3508
+ }
3509
 
3510
+ return $_module_el;
3511
+ },
3512
 
3513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3514
 
3515
+
3516
+
3517
+ setupModuleView : function() {
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',
3536
+ name : 'edit_module',
3537
+ actions : ['setModuleViewVisibility', 'sendEditModule']
3538
+ },
3539
+ {
3540
+ trigger : 'click keydown',
3541
+ selector : '.czr-module-back',
3542
+ name : 'back_to_column',
3543
+ actions : ['setModuleViewVisibility']
3544
+ },
3545
+ {
3546
+ trigger : 'mouseenter',
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
+ }
3554
+ },
3555
+ {
3556
+ trigger : 'mouseleave',
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
3571
+ module //instance where to look for the cb methods
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
+ }
3609
  });
3610
+ },
 
3611
 
3612
 
3613
+ renderModuleTitle : function() {
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() {
3631
+ var $_overlay = module.container.closest( '.wp-full-overlay' ),
3632
+ $_backBtn = module.container.find( '.czr-module-back' ),
3633
+ $_modTitle = module.container.find('.czr-module-title');
3634
+
3635
+ module.container.toggleClass('open' , expanded );
3636
+ $_overlay.toggleClass('czr-module-open', expanded );
3637
+ $_modTitle.attr( 'tabindex', expanded ? '-1' : '0' );
3638
+ $_backBtn.attr( 'tabindex', expanded ? '0' : '-1' );
3639
 
3640
+ if( expanded ) {
3641
+ $_backBtn.focus();
3642
+ } else {
3643
+ $_modTitle.focus();
3644
+ }
3645
+ if ( expanded )
3646
+ module._adjustScrollExpandedBlock( module.container );
3647
+ }//done callback
3648
+ } );
3649
+ },
3650
 
3651
 
3652
 
3654
 
3655
 
3656
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3657
 
 
 
 
 
 
 
 
 
 
 
3658
 
3659
+ toggleModuleRemoveAlert : function( obj ) {
3660
+ var module = this,
3661
+ control = this.control,
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
+ },
3698
+
3699
+
3700
 
 
 
 
 
 
 
 
 
 
3701
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3702
 
 
 
 
 
 
 
 
 
 
 
3703
 
3704
 
3705
 
3706
 
 
 
 
 
 
 
 
 
3707
 
 
 
3708
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3709
 
3710
+
3711
+
3712
+ _getColumn : function() {
3713
+ var module = this;
3714
+ return module.control.syncSektionModule().czr_Column( module.modColumn() );
3715
+ },
3716
+
3717
+ _getSektion : function() {
3718
+
3719
+ }
3720
  }
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 : '',
3737
+ check : 'setupIcheck',
3738
+ select : 'setupSelect',
3739
+ number : 'setupStepper',
3740
+ upload : 'setupImageUploader',
3741
+ color : 'setupColorPicker',
3742
+ content_picker : 'setupContentPicker',
3743
+ text_editor : 'setupTextEditor',
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 );
3757
 
3758
+ $.extend( api.controlConstructor, {
3759
+ czr_module : api.CZRBaseModuleControl,
3760
+ czr_multi_module : api.CZRMultiModuleControl,
3761
+ });
3762
 
3763
+ })( wp.customize, jQuery, _ );
3764
+ ( function ( api, $, _ ) {
3765
  /*****************************************************************************
3766
+ * A SKOPE AWARE PREVIEWER QUERY
3767
  *****************************************************************************/
3768
+ api.bind('ready', function() {
3769
+ if ( ! serverControlParams.isSkopOn )
3770
+ return;
 
 
 
3771
 
3772
+ /**
3773
+ * Build the query to send along with the Preview request.
3774
+ *
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
+ }
3799
 
3800
+ var globalCustomized = {},
3801
+ skopeCustomized = {},
3802
+ _defaults = {
3803
+ skope_id : null,
3804
+ action : null,
3805
+ the_dirties : {},
3806
+ dyn_type : null,
3807
+ opt_name : null
3808
+ },
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;
3831
+ _skpCust[_skp.id] = api.czr_skopeBase.getSkopeDirties( _skp.id );
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();
3838
+ } else {
3839
+ if ( 'global' == api.czr_skopeBase.getActiveSkopeName() )
3840
+ globalCustomized = queryVars.the_dirties;
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' :
3850
+ if ( _.isUndefined( queryVars.opt_name ) ) {
3851
+ throw new Error('Missing opt_name param in the changeset_update query for skope : ' + queryVars.skope_id );
3852
+ }
3853
+ break;
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 ) ) {
3868
+ throw new Error( 'QUERY : A RESET QUERY MUST HAVE A VALID DYN TYPE.' + queryVars.skope_id );
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,
3881
+ skope: api.czr_skope( queryVars.skope_id )().skope,
3882
+ level_id: api.czr_skope( queryVars.skope_id )().level,
3883
+ skope_id: queryVars.skope_id,
3884
+ dyn_type: queryVars.dyn_type,
3885
+ opt_name: ! _.isNull( queryVars.opt_name ) ? queryVars.opt_name : api.czr_skope( queryVars.skope_id )().opt_name,
3886
+ obj_id: api.czr_skope( queryVars.skope_id )().obj_id,
3887
+ current_skopes: JSON.stringify( _current_skopes ) || {},
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
3905
+ });//api.bind('ready')
 
 
 
 
 
 
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, $, _) {
3915
+ if ( ! serverControlParams.isSkopOn )
3916
+ return;
3917
+
3918
  /*****************************************************************************
3919
+ * SYNCHRONIZER AUGMENTED
3920
  *****************************************************************************/
3921
+ api.Element.synchronizer.checkbox.update = function( to ) {
3922
+ this.element.prop( 'checked', to );
3923
+ this.element.iCheck('update');
3924
+ };
 
 
 
 
 
 
3925
 
3926
+ var _original = api.Element.synchronizer.val.update;
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 );
3942
+ } else {
3943
+ api.czr_skopeReady.then( function () {
3944
+ _modifySynchronizer();
3945
+ });
3946
+ }
3947
+ } else {
3948
+ _modifySynchronizer();
3949
  }
3950
+ };
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 [];
3957
+ else if ( _.isObject( syncApiInstance() ) )
3958
+ return {};
3959
+ else
3960
+ return '';
3961
  } else {
3962
+ return this.element.val();
3963
  }
3964
+ };
3965
+ })( wp.customize , jQuery, _ );
3966
+ ( function ( api, $, _ ) {
3967
+ var coreRefresh = api.Previewer.prototype.refresh;
3968
+ var _new_refresh = function( params ) {
3969
+ params = _.extend({
3970
+ waitSkopeSynced : true,
3971
+ the_dirties : {}
 
 
 
3972
  },
3973
+ params
 
 
 
 
 
 
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();
3988
+
3989
+ var query_params = api.czr_getSkopeQueryParams({
3990
+ skope_id : api.czr_activeSkopeId(),
3991
+ action : 'refresh',
3992
+ the_dirties : params.the_dirties || {}
3993
+ });
3994
+
3995
+ previewer.loading = new api.PreviewFrame({
3996
+ url: previewer.url(),
3997
+ previewUrl: previewer.previewUrl(),
3998
+ query: previewer.query( query_params ) || {},
3999
+ container: previewer.container,
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;
4007
+ };
4008
+ api.bind( 'change', onSettingChange );
4009
+
4010
+ previewer.loading.always( function() {
4011
+ api.unbind( 'change', onSettingChange );
4012
+ } );
4013
+ if ( ! api.czr_isChangeSetOn() ) {
4014
+ previewer._previousPreview = previewer._previousPreview || previewer.preview;
4015
  }
 
4016
 
4017
+ previewer.loading.done( function( readyData ) {
4018
+ var loadingFrame = this, onceSynced;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4019
 
4020
+ previewer.preview = loadingFrame;
4021
+ previewer.targetWindow( loadingFrame.targetWindow() );
4022
+ previewer.channel( loadingFrame.channel() );
4023
+ onceSynced = function( skopesServerData ) {
4024
+ loadingFrame.unbind( 'synced', onceSynced );
4025
+ loadingFrame.unbind( 'czr-skopes-synced', onceSynced );
 
 
 
 
 
4026
 
4027
+ if ( previewer._previousPreview ) {
4028
+ previewer._previousPreview.destroy();
4029
+ } //before WP 4.7
4030
+ else {
4031
+ if ( previewer.preview )
4032
+ previewer.preview.destroy();
4033
+ }
 
 
 
 
 
 
 
4034
 
4035
+ previewer._previousPreview = previewer.preview;
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,
4045
+ settings: api.get()
4046
+ });
4047
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4048
 
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 );
4062
+ }
4063
+ }
4064
 
4065
+ if ( 'logged out' === reason ) {
4066
+ if ( previewer.preview ) {
4067
+ previewer.preview.destroy();
4068
+ delete previewer.preview;
4069
+ }
4070
 
4071
+ previewer.login().done( previewer.refresh );
4072
+ }
 
 
4073
 
4074
+ if ( 'cheatin' === reason ) {
4075
+ previewer.cheatin();
4076
+ }
4077
+ dfd.reject( reason );
4078
+ });
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;
4089
+ params = ! _.isObject(params) ? {} : params;
4090
+ var _action = params.action || 'refresh';
4091
+ switch( _action ) {
4092
+ case 'refresh' :
4093
+ params = $.extend( params, { excludeCustomizedSaved: true } );
4094
+ break;
4095
  }
4096
+ return params;
4097
  };
4098
+ czr_override_refresh_for_skope = function() {
4099
+ if ( ! serverControlParams.isSkopOn )
4100
+ return;
 
4101
 
 
 
 
 
 
 
4102
 
4103
+ /**
4104
+ * Refresh the preview.
4105
+ */
4106
+ api.previewer.refresh = function( _params_ ) {
4107
+ var dfd = $.Deferred();
4108
+ var _refresh_ = function( params ) {
4109
+ var refreshOnceProcessingComplete,
4110
+ isProcessingComplete = function() {
4111
+ return 0 === api.state( 'processing' ).get();
4112
+ },
4113
+ resolveRefresh = function() {
4114
+ _new_refresh.call( api.previewer, params ).done( function( refresh_data ) {
4115
+ dfd.resolve( refresh_data );
4116
+ });
4117
+ };
4118
+ if ( isProcessingComplete() ) {
4119
+ resolveRefresh();
4120
+ } else {
4121
+ refreshOnceProcessingComplete = function() {
4122
+ if ( isProcessingComplete() ) {
4123
+ resolveRefresh();
4124
+ api.state( 'processing' ).unbind( refreshOnceProcessingComplete );
4125
+ }
4126
+ };
4127
+ api.state( 'processing' ).bind( refreshOnceProcessingComplete );
4128
+ }
4129
+ };
4130
+ _refresh_ = _.debounce( _refresh_, api.previewer.refreshBuffer );
4131
+ _refresh_( _params_ );
4132
+ return dfd.promise();
4133
+ };
4134
+ };//czr_override_refresh_for_skope
4135
+ })( wp.customize , jQuery, _ );
4136
+ ( function ( api, $, _ ) {
4137
+ if ( ! serverControlParams.isSkopOn )
4138
+ return;
4139
+
4140
+ /**
4141
+ * Get the dirty setting values.
4142
+ * Overrides the default method introduced in 4.7
4143
+ * !! This method only returns the dirties of the global skope !!
4144
+ *
4145
+ * @param {object} [options] Options.
4146
+ * @param {boolean} [options.unsaved=false] Whether only values not saved yet into a changeset will be returned (differential changes).
4147
+ * @returns {object} Dirty setting values.
4148
+ */
4149
+ api.dirtyValues = function dirtyValues( options ) {
4150
+ return api.czr_skopeBase.getSkopeDirties( api.czr_skopeBase.getGlobalSkopeId(), options );
4151
  };
4152
 
4153
+ })( wp.customize , jQuery, _ );
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,
4172
+ _skopesToUpdate = [],
4173
+ _promises = [],
4174
+ _global_skope_changes = changes || {},
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;
4189
+ _skopesToUpdate.push( _skp.id );
4190
+ } );
4191
 
4192
+ var _mayBeresolve = function( _index ) {
4193
+ if ( ! _.isUndefined( _skopesToUpdate[ _index + 1 ] ) || _promises.length != _skopesToUpdate.length )
4194
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
4195
 
4196
+ if ( _.isEmpty( failedPromises ) ) {
4197
+ _recursiveCallDeferred.resolve( _all_skopes_data_ );
4198
+ } else {
4199
+ var _buildResponse = function() {
4200
+ var _failedResponse = [];
4201
+ _.each( failedPromises, function( _r ) {
4202
+ _failedResponse.push( api.czr_skopeBase.buildServerResponse( _r ) );
4203
+ } );
4204
+ return $.trim( _failedResponse.join( ' | ') );
4205
+ };
4206
+ _recursiveCallDeferred.reject( _buildResponse() );
 
 
 
 
 
 
 
 
 
4207
  }
4208
+ return true;
4209
+ };
4210
+ var recursiveCall = function( _index ) {
4211
+ if ( _.isUndefined( _index ) || ( ( 0 * 0 ) == _index ) ) {
4212
+ api.state( 'processing' ).set( 1 );
4213
  }
4214
+
4215
+ _index = _index || 0;
4216
+ if ( _.isUndefined( _skopesToUpdate[_index] ) ) {
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 );
4224
+ api.consoleLog('CHANGESET UPDATE RECURSIVE FAIL FOR SKOPE : ', _skopesToUpdate[_index] );
4225
+ if ( ! _mayBeresolve( _index ) )
4226
+ recursiveCall( _index + 1 );
4227
+ } )
4228
+ .done( function( _skope_data_ ) {
4229
+ _all_skopes_data_.push( _skope_data_ );
4230
+ if ( ! _mayBeresolve( _index ) )
4231
+ recursiveCall( _index + 1 );
4232
+ } );
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 ) {
4258
+ dfd.reject( r );
4259
+ api.consoleLog( 'CHANGESET UPDATE RECURSIVE PUSH FAIL', r , _all_skopes_data_ );
4260
+ api.trigger( 'changeset-error', r );
4261
+ api.czr_serverNotification( { message: r, status : 'error' } );
4262
+ } )
4263
+ .done( function() {
4264
+ dfd.resolve( wp_original_response );
4265
+ });
4266
+ });
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
+ }
4274
+
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(
4287
+ {},
4288
+ submittedChanges[ settingId ] || {},
4289
+ { value: dirtyValue }
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 = {
4305
+ skope_id : skope_id,
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
+ } );
 
 
 
 
 
 
 
 
 
 
 
 
 
4330
 
4331
+ return deferred.promise();
4332
+ };
4333
  })( wp.customize , jQuery, _ );
4334
  ( function ( api, $, _ ) {
 
 
 
 
 
 
 
 
 
 
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 );
4342
+ api.czr_isLoadingSkope.bind( function( loading ) {
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.'],
4353
+ message : [
4354
+ serverControlParams.i18n.skope['Please refer to'],
4355
+ '<a href="http://docs.presscustomizr.com/article/285-there-was-a-problem-when-trying-to-load-the-customizer" target="_blank">',
4356
+ serverControlParams.i18n.skope['this documentation page'],
4357
+ '</a>',
4358
+ serverControlParams.i18n.skope['to understand how to fix the problem.']
4359
+ ].join(' '),
4360
+ selfCloseAfter : 40000
4361
+ });
4362
+ };
4363
+
4364
+
4365
+ api.czr_skopeReady
4366
+ .done( function() {
4367
+ api.trigger('czr-skope-ready');
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 );
4383
+ }
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.
4394
+ */
4395
+ api._latestRevision = 0;
4396
+
4397
+ /**
4398
+ * Latest revisions associated with the updated setting.
4399
+ */
4400
+ api._latestSettingRevisions = {};
4401
+
4402
+ /*
4403
+ * Keep track of the revision associated with each updated setting so that
4404
+ * requestChangesetUpdate knows which dirty settings to include. Also, once
4405
+ * ready is triggered and all initial settings have been added, increment
4406
+ * revision for each newly-created initially-dirty setting so that it will
4407
+ * also be included in changeset update requests.
4408
+ */
4409
+ api.bind( 'change', function incrementChangedSettingRevision( setting ) {
4410
+ api._latestRevision += 1;
4411
+ api._latestSettingRevisions[ setting.id ] = api._latestRevision;
4412
+ } );
4413
+ api.bind( 'ready', function() {
4414
+ api.bind( 'add', function incrementCreatedSettingRevision( setting ) {
4415
+ if ( setting._dirty ) {
4416
+ api._latestRevision += 1;
4417
+ api._latestSettingRevisions[ setting.id ] = api._latestRevision;
4418
+ }
4419
+ } );
4420
+ } );
4421
+ }
4422
+ var toggleSkopeLoadPane = function( loading ) {
4423
+ loading = _.isUndefined( loading ) ? true : loading;
4424
+ var self = this, $skopeLoadingPanel,
4425
+ _render = function() {
4426
+ var dfd = $.Deferred();
4427
+ try {
4428
+ _tmpl = wp.template( 'czr-skope-pane' )({ is_skope_loading : true });
4429
+ } catch( er ) {
4430
+ api.errorLog( 'In toggleSkopeLoadPane : error when parsing the the reset skope template : ' + er );
4431
+ dfd.resolve( false );
4432
+ }
4433
+ $.when( $('#customize-preview').after( $( _tmpl ) ) )
4434
+ .always( function() {
4435
+ dfd.resolve( $( '#czr-skope-pane' ) );
4436
+ });
4437
+
4438
+ return dfd.promise();
4439
+ },
4440
+ _destroy = function() {
4441
+ _.delay( function() {
4442
+ $.when( $('body').removeClass('czr-skope-pane-open') ).done( function() {
4443
+ _.delay( function() {
4444
+ $.when( $('body').removeClass('czr-skop-loading') ).done( function() {
4445
+ if ( false !== $( '#czr-skope-pane' ).length ) {
4446
+ setTimeout( function() {
4447
+ $( '#czr-skope-pane' ).remove();
4448
+ }, 400 );
4449
+ }
4450
+ });
4451
+ }, 200);
4452
+ });
4453
+ }, 50);
4454
+ };
4455
+ if ( 'pending' == api.czr_skopeReady.state() && loading ) {
4456
+ $('body').addClass('czr-skop-loading');
4457
+ _render()
4458
+ .done( function( $_el ) {
4459
+ $skopeLoadingPanel = $_el;
4460
+ })
4461
+ .then( function() {
4462
+ if ( ! $skopeLoadingPanel.length )
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
+ });
 
 
4471
  }
 
 
 
 
 
 
 
 
 
4472
 
4473
+ api.czr_skopeReady.done( function() {
4474
+ _destroy();
 
 
 
 
4475
  });
4476
+ if ( ! loading ) {
4477
+ _destroy();
 
 
 
 
 
 
 
 
 
 
 
4478
  }
4479
+ };//toggleSkopeLoadPane
4480
 
4481
+ })( wp.customize , jQuery, _);
 
4482
 
 
 
 
 
 
 
4483
 
 
 
 
 
 
 
 
4484
 
 
 
 
4485
 
4486
+ /*****************************************************************************
4487
+ * THE SKOPE BASE OBJECT
4488
+ *****************************************************************************/
4489
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4490
+ (function ( api, $, _ ) {
4491
+ $.extend( CZRSkopeBaseMths, {
 
 
 
4492
 
4493
+ globalSettingVal : {},//will store the global setting val. Populated on init.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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() {
4522
+ self.skopeWrapperEmbedded.resolve();
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();
4535
+ }
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() )
4559
+ .done( function() {
4560
+ if ( 'resolved' != api.czr_skopeReady.state() ) {
4561
+ api.czr_skopeReady.resolve( self.getActiveSkopeId() );
4562
+ }
4563
+ _refreshSkopeInfosNotices();
4564
+ })
4565
+ .fail( function() {
4566
+ throw new Error( 'Error when trying to set the active skope after skope synced.' );
4567
+ });
4568
+ } catch ( er ) {
4569
+ api.errorLog( 'In reactWhenSkopeSyncedDone => api.czr_activeSkopeId() : ' + er );
4570
+ }
4571
+ } else if ( ! _.isEmpty( previousSkopeCollection ) ) { //Rewrite the title when the local skope has changed
4572
+ var _prevLoc = _.findWhere( previousSkopeCollection , { skope : 'local' } ).opt_name,
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
+ }
4590
+ return self.activeSkopeReact( to, from ).then( function( _updatedSetIds ) {
4591
+ api.trigger( 'skope-switched-done',
4592
+ {
4593
+ current_skope_id : to,
4594
+ previous_skope_id : from,
4595
+ updated_setting_ids : _updatedSetIds || []
4596
+ }
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
+ {
4606
+ current_skope_id : '',
4607
+ previous_skope_id : '',
4608
+ updated_setting_ids : []
4609
+ },
4610
+ args
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',
4623
+ name : 'dismiss-notification',
4624
+ actions : function() {
4625
+ api.czr_serverNotification( { expanded : false } );
4626
+ }
4627
+ },
4628
+ {
4629
+ trigger : 'click keydown',
4630
+ selector : '.czr-toggle-title-notice',
4631
+ name : 'toggle-title-notice',
4632
+ actions : function( params ) {
4633
+ if ( _.isUndefined( self.skopeTitleNoticeVisible ) ) {
4634
+ self.skopeTitleNoticeVisible = new api.Value( false );
4635
+ self.skopeTitleNoticeVisible.bind( function( to ) {
4636
+ params.dom_el.find( '.czr-skope-title')
4637
+ .toggleClass( 'notice-visible', to );
4638
+ });
4639
+ }
4640
 
4641
+ self.skopeTitleNoticeVisible( ! self.skopeTitleNoticeVisible() );
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 );
4653
+ });
4654
+ });
4655
+ },//initialize
4656
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4657
 
4658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4659
 
 
 
 
 
 
 
 
 
 
 
 
 
4660
 
 
 
 
 
 
4661
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4662
 
 
 
 
4663
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4665
 
 
 
 
 
 
 
 
 
4666
 
 
 
 
 
 
 
 
4667
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4668
 
 
 
 
 
 
 
4669
 
 
 
 
 
 
4670
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4671
 
 
 
 
 
 
4672
 
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',
4684
+ name : 'control_skope_switch',
4685
+ actions : function( params ) {
4686
+ var _skopeIdToSwithTo = $( params.dom_event.currentTarget, params.dom_el ).attr('data-skope-id');
4687
+ if ( ! _.isEmpty( _skopeIdToSwithTo ) && api.czr_skope.has( _skopeIdToSwithTo ) )
4688
+ api.czr_activeSkopeId( _skopeIdToSwithTo );
4689
+ }
4690
+ }
4691
+ ];
4692
+ api.CZR_Helpers.setupDOMListeners( _eventMap , { dom_el : $('.czr-scope-switcher') }, self );
4693
+ },
 
 
 
 
 
4694
 
 
 
 
 
 
 
 
4695
 
 
 
 
 
 
 
 
 
4696
 
 
4697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4698
 
 
 
 
 
 
 
 
4699
 
 
4700
 
 
 
 
 
 
 
 
 
 
 
4701
 
 
 
 
 
 
 
 
 
 
 
4702
 
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 );
4709
+ },
4710
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4711
 
 
 
 
 
 
 
 
 
 
 
4712
 
4713
 
4714
 
 
 
 
 
 
 
 
 
 
 
4715
 
4716
 
 
 
 
 
 
 
 
 
 
4717
 
 
 
4718
 
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 ) {
4726
+ $( document.body ).toggleClass( 'saving', isSaving );
4727
+ } );
4728
+ }
4729
+ var saveBtn = $( '#save' ),
4730
+ closeBtn = $( '.customize-controls-close' ),
4731
+ saved = api.state( 'saved'),
4732
+ saving = api.state( 'saving'),
4733
+ activated = api.state( 'activated' ),
4734
+ changesetStatus = api.state.has('changesetStatus' ) ? api.state( 'changesetStatus' )() : 'auto-draft';
4735
+
4736
+ if ( api.czr_dirtyness() || ! saved() ) {
4737
+ saveBtn.val( api.l10n.save );
4738
+ closeBtn.find( '.screen-reader-text' ).text( api.l10n.cancel );
4739
+ } else {
4740
+ saveBtn.val( api.l10n.saved );
4741
+ closeBtn.find( '.screen-reader-text' ).text( api.l10n.close );
4742
+ }
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 {
4752
+ api.czr_ctrlDependencies.setServiDependencies( api.czr_activeSectionId(), null, true );//target sec id, source sec id, refresh
4753
+ } catch( er ) {
4754
+ api.errorLog( 'On skope-switched-done : ' + er );
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;
4768
+ var ctrls = api.CZR_Helpers.getSectionControlIds( api.czr_activeSectionId() );
4769
+ _.each( ctrls, function( ctrlId ) {
4770
+ api.control.when( ctrlId, function() {
4771
+ var ctrl = api.control( ctrlId );
4772
+ if ( ! _.has( ctrl, 'czr_states' ) )
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 ) {
4800
+ var noteParams = {},
4801
+ _defaultParams = {
4802
+ title : '',
4803
+ message : '',
4804
+ actions : '',
4805
+ selfCloseAfter : 20000
4806
+ };
4807
+ noteParams = $.extend( _defaultParams , serverControlParams.topNoteParams );
4808
+ noteParams.actions = function() {
4809
+ var _query = $.extend(
4810
+ api.previewer.query(),
4811
+ { nonce: api.previewer.nonce.save }
4812
+ );
4813
+ wp.ajax.post( 'czr_dismiss_top_note' , _query )
4814
+ .always( function () {})
4815
+ .fail( function ( response ) { api.consoleLog( 'czr_dismiss_top_note failed', _query, response ); })
4816
+ .done( function( response ) {});
4817
+ };
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 = {
4830
+ title : '',
4831
+ message : '',
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 ) {
4842
+ var _v = _set_(),
4843
+ _isChecked = 0 !== _v && '0' !== _v && false !== _v && 'off' !== _v;
 
 
 
 
 
 
 
 
 
 
 
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( {
4865
+ status : 'success',
4866
+ expanded : true,
4867
+ message : '',
4868
+ auto_collapse : false
4869
+ }, notice );
4870
+ if ( 'changeset_already_published' == notice.message )
4871
  return;
4872
+ if ( ! serverControlParams.isDevMode )
 
 
 
 
 
 
 
 
 
 
4873
  return;
 
 
4874
 
4875
+ this.serverNoticeEmbedded = this.serverNoticeEmbedded || $.Deferred();
4876
 
4877
+ var self = this,
4878
+ _embed = function() {
4879
+ $('.czr-scope-switcher').prepend(
4880
+ $( '<div/>', {
4881
+ class:'czr-server-notice',
4882
+ html:'<span class="czr-server-message"></span><span class="fa fa-times-circle czr-dismiss-notification"></span>'
4883
+ } )
4884
+ );
4885
+ },
4886
+ _toggleNotice = function() {
4887
+ var $notif_wrap = $( '.czr-server-notice', '.czr-scope-switcher' ),
4888
+ $header = $('.wp-full-overlay-header'),
4889
+ $sidebar = $('.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content'),
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
 
4898
+ if ( ! notice.expanded ) {
4899
+ $notif_wrap
4900
+ .fadeOut( {
4901
+ duration : 200,
4902
+ complete : function() {
4903
+ } } );
4904
+ setTimeout( function() {
4905
+ _set_height();
4906
+ } , 200 );
4907
 
4908
+ } else {
4909
+ $notif_wrap.toggleClass( 'czr-server-error', 'error' == notice.status );
4910
+ if ( 'error' == notice.status ) {
4911
+ $('.czr-server-message', $notif_wrap )
4912
+ .html( _.isEmpty( notice.message ) ? 'Server Problem.' : notice.message );
4913
+ } else {
4914
+ $('.czr-server-message', $notif_wrap )
4915
+ .html( _.isEmpty( notice.message ) ? 'Success.' : notice.message );
4916
+ }
4917
+ _notif_wrap_height = $( '.czr-server-notice', '.czr-scope-switcher' ).outerHeight();
4918
+ _header_height = $header.outerHeight() + _notif_wrap_height;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4919
 
4920
+ setTimeout( function() {
4921
+ $.when( _set_height( _header_height ) ).done( function() {
4922
+ $notif_wrap
4923
+ .fadeIn( {
4924
+ duration : 200,
4925
+ complete : function() {
4926
+ $( this ).css( 'height', 'auto' );
4927
+ } } );
4928
+ } );
4929
+ }, 400 );
4930
+ }
4931
+ };
4932
+ if ( 'pending' == self.serverNoticeEmbedded.state() ) {
4933
+ $.when( _embed() ).done( function() {
4934
+ setTimeout( function() {
4935
+ self.serverNoticeEmbedded.resolve();
4936
+ _toggleNotice();
4937
+ }, 200 );
4938
  });
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
+ }
4957
+ }
4958
+ if ( _.isObject( _r ) && ! resp ) {
4959
+ try {
4960
+ JSON.stringify( _r );
4961
+ } catch( e ) {
4962
+ resp = 'Server Error';
4963
+ }
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;
4970
  }
4971
+ });//$.extend()
 
4972
  })( wp.customize , jQuery, _);
4973
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
4974
+ (function ( api, $, _ ) {
4975
+ $.extend( CZRSkopeBaseMths, {
4976
+ toggleTopNote : function( visible, noteParams ) {
4977
+ noteParams = _.isObject( noteParams ) ? noteParams : {};
4978
+ var self = this,
4979
+ _defaultParams = {
4980
+ title : '',
4981
+ message : '',
4982
+ actions : '',
4983
+ selfCloseAfter : 20000
4984
+ },
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 );
4991
+ api.CZR_Helpers.setupDOMListeners(
4992
+ [ {
4993
+ trigger : 'click keydown',
4994
+ selector : '.czr-preview-note-close',
4995
+ actions : function() {
4996
+ _hideAndDestroy().done( function() {
4997
+ api.czr_topNoteVisible( false );
4998
+ if ( _.isFunction( noteParams.actions ) ) {
4999
+ noteParams.actions();
5000
+ }
5001
+ });
5002
+ }
5003
+ } ] ,
5004
+ { dom_el : self.welcomeNote },
5005
+ self
5006
+ );
5007
+ });
5008
+ },
5009
+ _hideAndDestroy = function() {
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();
5016
+ }, 300 );
5017
+ } else {
5018
+ dfd.resolve();
5019
+ }
5020
+ return dfd.promise();
5021
+ };
5022
 
5023
+ noteParams = $.extend( _defaultParams , noteParams);
 
 
 
 
 
 
 
 
5024
 
5025
+ if ( visible ) {
5026
+ _renderAndSetup();
5027
+ } else {
5028
+ _hideAndDestroy().done( function() {
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' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5041
 
5042
+ var self = this,
5043
+ _tmpl = '',
5044
+ _title = params.title || '',
5045
+ _message = params.message || '';
5046
 
5047
+ try {
5048
+ _tmpl = wp.template( 'czr-top-note' )( { title : _title } );
5049
+ } catch( er ) {
5050
+ api.errorLog( 'Error when parsing the the top note template : ' + er );
5051
+ return false;
5052
+ }
5053
+ $('#customize-preview').after( $( _tmpl ) );
5054
+ $('.czr-note-message', '#czr-top-note').html( _message );
5055
+ return $( '#czr-top-note' );
5056
  }
5057
+ });//$.extend()
5058
+ })( wp.customize , jQuery, _);
5059
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
5060
+ (function ( api, $, _ ) {
5061
+ $.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;
5098
+ setting_instance.bind( _settingChangeReact );
5099
+ };
5100
 
5101
+ if ( ! api.topics.change.has( _dynamicallyAddedSettingsReact ) ) {
5102
+ api.bind( 'change', _dynamicallyAddedSettingsReact );
5103
+ }
5104
+ }
5105
+ });//$.extend()
5106
+ })( wp.customize , jQuery, _ );
5107
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
5108
+ ( function ( api, $, _ ) {
5109
+ $.extend( CZRSkopeBaseMths, {
5110
 
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 );
5149
+ }
5150
+ _api_ready_dbvals[_setId] = _val;
5151
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5152
 
 
 
 
 
 
 
 
 
 
 
 
5153
 
5154
+ api.czr_skope( _skp.id ).dbValues( _api_ready_dbvals );
 
 
 
5155
  });
5156
+ _.delay( function() {
5157
+ dfd.resolve();
5158
+ }, 500 );
5159
+ return dfd.promise();
5160
+ }
5161
+ });//$.extend()
5162
+ })( wp.customize , jQuery, _ );
5163
 
5164
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5165
  ( function ( api, $, _ ) {
5166
+ $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
5167
 
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 ) ) {
5181
+ active_section.assignedLocations.bind( _assignedLocReact );
5182
+ }
5183
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5184
 
 
 
 
 
 
 
5185
 
 
 
 
 
 
 
 
 
 
 
 
 
5186
 
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 ) ) )
5200
+ return;
5201
+ var ctrl = api.control( ctrlId );
5202
+ if ( ! _.has( ctrl, 'czr_states' ) )
5203
+ return;
5204
 
5205
+ ctrl.czr_states( 'resetVisible' )( false );
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 ) {
5220
+ if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
5221
+ return;
5222
+ var ctrl = api.control( ctrlId );
5223
+ if ( ! _.has( ctrl, 'czr_states' ) )
5224
+ return;
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 = {
5238
+ controls : [],
5239
+ section_id : ''
5240
+ };
5241
+ params = _.extend( defaults, params );
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 );
5278
+ }
5279
 
5280
+ });
5281
+ });
5282
+ if ( ! _.isEmpty( previous_sec_id ) && api.section.has( previous_sec_id ) ) {
5283
+ _doReactPrevious( previous_sec_id );
5284
+ }
5285
+ });
5286
+ },
 
 
 
 
 
 
 
 
5287
 
 
 
 
 
 
 
 
5288
 
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
+ }
5321
+ });
5322
+ });
5323
+ }
5324
+ });//$.extend()
5325
+ })( wp.customize , jQuery, _ );
5326
+ /*****************************************************************************
5327
+ * THE SKOPE BASE OBJECT
5328
+ *****************************************************************************/
5329
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
5330
+ ( function ( api, $, _ ) {
5331
+ $.extend( CZRSkopeBaseMths, {
5332
 
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;
5341
+ $.when( element.el.removeClass('czr-painted') ).done( function() {
5342
+ $(this).css( 'background', '' ).css('color', '');
5343
+ });
5344
+ };
5345
+ if ( api.czr_skopeBase.paintedElements ) {
5346
+ _.each( api.czr_skopeBase.paintedElements(), function( _el ) { _do_wash( _el ); } );
5347
+ api.czr_skopeBase.paintedElements( [] );
5348
+ }
5349
+ return this;
5350
+ },
5351
+ paint : function( params ) {
5352
+ var _bgColor = 'inherit',
5353
+ defaults = {
5354
+ active_panel_id : api.czr_activePanelId(),
5355
+ active_section_id : api.czr_activeSectionId(),
5356
+ is_skope_switch : false
5357
+ },
5358
+ _paint_candidates = [];
5359
+ params = $.extend( defaults, params );
5360
 
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 );
5370
+ });
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
+ }
5377
 
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;
5393
+ _paint_candidates.push( {
5394
+ el : _section.container.find( '.accordion-section-title').first()
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() {
5410
+ _paint_candidates.push(
5411
+ {
5412
+ el : active_section.container.find( '.customize-section-title, .customize-section-back' ),
5413
+ bgColor : 'inherit'
5414
+ },
5415
+ {
5416
+ el : active_section.container
5417
+ }
5418
+ );
5419
+ if ( ! api.czr_isChangeSetOn() ) {
5420
+ _paint_candidates.push(
5421
+ {
5422
+ el : active_section.container.find('.accordion-section-content')
5423
+ }
5424
+ );
5425
+ }
5426
+ });
5427
+ });
5428
+ }
5429
+ _.each( _paint_candidates, function( _el ) { _do_paint( _el ); } );
5430
+ api.czr_skopeBase.paintedElements( _paint_candidates );
5431
+ return this;
5432
+ }
5433
+ });//$.extend()
5434
+ })( wp.customize , jQuery, _ );
5435
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
5436
+ (function ( api, $, _ ) {
5437
+ $.extend( CZRSkopeBaseMths, {
5438
+ toggleBottomInfos : function( visible, noteParams ) {
5439
+ noteParams = _.isObject( noteParams ) ? noteParams : {};
5440
+ var self = this,
5441
+ dfd = $.Deferred(),
5442
+ _defaultParams = {
5443
+ title : '',
5444
+ message : '',
5445
+ actions : '',
5446
+ selfCloseAfter : 20000
5447
+ },
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
+ {
5461
+ trigger : 'click keydown',
5462
+ selector : '.czr-preview-note-close',
5463
+ actions : function() {
5464
+ _hideAndDestroy().done( function() {
5465
+ api.czr_bottomInfosVisible( false );
5466
+ if ( _.isFunction( noteParams.actions ) ) {
5467
+ noteParams.actions();
5468
+ }
5469
+ });
5470
+ }
5471
+ },
5472
+ {
5473
+ trigger : 'click keydown',
5474
+ selector : '.czr-skope-switch',
5475
+ actions : function( params ) {
5476
+ var _skopeIdToSwithTo = $( params.dom_event.currentTarget, params.dom_el ).attr('data-skope-id');
5477
+ if ( ! _.isEmpty( _skopeIdToSwithTo ) && api.czr_skope.has( _skopeIdToSwithTo ) )
5478
+ api.czr_activeSkopeId( _skopeIdToSwithTo );
5479
+ }
5480
+ },
5481
+ {
5482
+ trigger : 'click keydown',
5483
+ selector : '.czr-disable-bottom-infos',
5484
+ actions : function( params ) {
5485
+ if ( api.control.has( _skopeInfosSetId ) ) {
5486
+ api.control( _skopeInfosSetId ).focus();
5487
+ }
5488
+ }
5489
+ }
5490
+ ] ,
5491
+ { dom_el : self.bottomInfosContainer },
5492
+ self
5493
+ );
5494
+ })
5495
+ .fail( function() {
5496
+ _dfd.resolve();
5497
+ });
5498
+ return _dfd.promise();
5499
+ },
5500
+ _hideAndDestroy = function() {
5501
+ return $.Deferred( function() {
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;
5508
+ _dfd_.resolve();
5509
+ }, 300 );
5510
+ } else {
5511
+ _dfd_.resolve();
5512
+ }
5513
+ });
5514
+ };
5515
 
 
 
5516
 
5517
+ noteParams = $.extend( _defaultParams , noteParams);
 
 
 
 
 
5518
 
5519
+ if ( visible ) {
5520
+ _renderAndSetup().always( function() {
5521
+ dfd.resolve();
5522
+ });
5523
+ } else {
5524
+ _hideAndDestroy().done( function() {
5525
+ api.czr_bottomInfosVisible( false );//should be already false
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
 
5539
+ var _skope_title = api.czr_skope( _skope_id )().long_title,
5540
+ _ctxTitle = api.czr_skope( _skope_id )().ctx_title;
5541
 
5542
+ _skope_title = _.isString( _skope_title ) ? _skope_title : '';
5543
+ _ctxTitle = _.isString( _ctxTitle ) ? _ctxTitle : '';
5544
 
5545
+ var _title = params.title || ['Customizing', _ctxTitle.toLowerCase() ].join(' '),
5546
+ _message = params.message || self._getSkopeInfosMessage( _skope_id ),
5547
+ _renderTmpl = function() {
5548
+ return $.Deferred( function() {
5549
+ var dfd = this;
5550
+ try {
5551
+ _tmpl = wp.template( 'czr-bottom-infos' )( { title : _title } );
5552
+ $('#customize-preview').after( $( _tmpl ) );
5553
+ dfd.resolve();
5554
+ } catch( er ) {
5555
+ api.errorLog( 'Error when parsing the the bottom infos template : ' + er );
5556
+ dfd.reject( er );
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 );
5563
+ });
5564
+ } else {
5565
+ $('.czr-note-content', self.bottomInfosContainer ).fadeOut({
5566
+ duration : 'fast',
5567
+ complete : function() {
5568
+ $( 'h2', self.bottomInfosContainer ).html( [ '&middot;', _title, '&middot;' ].join(' ') );
5569
+ $('.czr-note-message', self.bottomInfosContainer ).html( _message );
5570
+ $(this).fadeIn('fast');
5571
+ }
5572
+ });
5573
 
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
 
5583
+ var self = this,
5584
+ _skpLevel = api.czr_skope( skope_id )().skope,
5585
+ _inheritedFrom = self.getInheritedSkopeTitles(),
5586
+ _overrides = self.getOverridenSkopeTitles(),
5587
+ _localCtxTitle = api.czr_skope( _localSkopeId )().ctx_title,//<= the context title is always the one of the local skope
5588
+ current_title = api.czr_skope( skope_id )().long_title,//ex : Options for home
5589
+ _html;
5590
 
5591
+ switch( _skpLevel ) {
5592
+ case 'global' :
5593
+ _html = [
5594
+ serverControlParams.i18n.skope['The customizations made site wide are inherited by all other levels of customization.'],
5595
+ '<br/>',
5596
+ serverControlParams.i18n.skope['The current context'],
5597
+ ['(', _localCtxTitle, ')'].join(' '),
5598
+ serverControlParams.i18n.skope['can be customized more specifically at the following level'] + '(s)',
5599
+ ':',
5600
+ _overrides + '.'
5601
+ ].join(' ');
5602
+ break;
5603
+ case 'group' :
5604
+ _html = [
5605
+ serverControlParams.i18n.skope['The current customizations will be applied to'],
5606
+ api.czr_skope( skope_id )().ctx_title.toLowerCase() + '.',
5607
+ '<br/>',
5608
+ serverControlParams.i18n.skope['The options not customized at this level will inherit their value from'],
5609
+ _inheritedFrom,
5610
+ '.<br/>',
5611
+ serverControlParams.i18n.skope['The current context'],
5612
+ ['(', _localCtxTitle, ')'].join(' '),
5613
+ serverControlParams.i18n.skope['can be customized more specifically at the following level'],
5614
+ ':',
5615
+ _overrides + '.'
5616
+ ].join(' ');
5617
+ break;
5618
+ case 'local' :
5619
+ _html = [
5620
+ serverControlParams.i18n.skope['The current context'],
5621
+ ['(', _localCtxTitle, ')'].join(' '),
5622
+ serverControlParams.i18n.skope['can be customized with a specific set of options.'],
5623
+ '<br/>',
5624
+ serverControlParams.i18n.skope['The options not customized at this level will inherit their value from'],
5625
+ _inheritedFrom + '.'
5626
+ ].join(' ');
5627
+ break;
5628
+ }
5629
 
5630
+ return $.trim( [
5631
+ '<span class="czr-skope-bottom-infos">',
5632
+ _html,
5633
+ '</span>'
5634
+ ].join(' ') );
5635
+ }
5636
+ });//$.extend()
5637
+ })( wp.customize , jQuery, _);
5638
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
5639
+ ( function ( api, $, _ ) {
5640
+ $.extend( CZRSkopeBaseMths, {
 
 
 
 
 
 
 
5641
 
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 '';
5662
+ var id = '';
5663
+ api.czr_skope.each( function(skp){
5664
+ if ( 'global' == skp().skope )
5665
+ id = skp().id;
5666
+ });
5667
+ return id;
5668
+ },
5669
+ getChangedGlobalDBSettingValues : function( serverGlobalDBValues ) {
5670
+ var _changedDbVal = {};
5671
 
5672
+ _.each( serverGlobalDBValues, function( _val, _setId ){
5673
+ _wpSetId = api.CZR_Helpers.build_setId( _setId);
 
 
5674
 
5675
+ if ( ! _.has( api.settings.settings, _wpSetId ) )
5676
+ return;
5677
+ if ( _.isEqual( _val , api.settings.settings[ _wpSetId ].value ) )
5678
+ return;
5679
+ _changedDbVal[_setId] = _val;
5680
+ });
5681
+ return _changedDbVal;
5682
+ },
5683
+ getActiveSkopeId : function( _current_skope_collection ) {
5684
+ _current_skope_collection = _current_skope_collection || api.czr_currentSkopesCollection();
 
5685
 
5686
+ var _currentSkopeLevel, _newSkopeCandidate, _skpId;
5687
+ if ( ! _.isEmpty( api.czr_activeSkopeId() ) && api.czr_skope.has( api.czr_activeSkopeId() ) ) {
5688
+ _currentSkopeLevel = api.czr_skope( api.czr_activeSkopeId() )().skope;
5689
+ } else if ( serverControlParams.isLocalSkope ) {
5690
+ _currentSkopeLevel = 'local';
5691
+ } else {
5692
+ _currentSkopeLevel = 'global';
5693
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5694
 
5695
+ _newSkopeCandidate = _.findWhere( _current_skope_collection, { skope : _currentSkopeLevel } );
 
5696
 
5697
+ _skpId = ! _.isUndefined( _newSkopeCandidate ) ? _newSkopeCandidate.id : _.findWhere( _current_skope_collection, { skope : 'global' } ).id;
 
 
 
5698
 
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 );
5712
 
5713
+ if( _.isUndefined( setId ) || ! api.has( setId ) ) {
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 );
5729
 
5730
+ if( _.isUndefined( setId ) || ! api.has( setId ) ) {
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 ) ) {
5737
+ api.consoleLog( 'THE SETTING ' + setId + ' IS NOT ELIGIBLE TO RESET BECAUSE NOT PART OF THE THEME OPTIONS AND NOT WP AUTHORIZED BUILT IN OPTIONS' );
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 ) {
5758
+ switch( _ptrn ) {
5759
+ case 'widget_' :
5760
+ case 'sidebars_' :
5761
+ if ( _ptrn == setId.substring( 0, _ptrn.length ) ) {
5762
+ _isExcld = self.isExcludedSidebarsWidgets();
5763
+ }
5764
+ break;
5765
 
5766
+ case 'nav_menu[' :
5767
+ case 'nav_menu_item' :
5768
+ case 'nav_menus_created_posts' :
5769
+ if ( _ptrn == setId.substring( 0, _ptrn.length ) ) {
5770
+ _isExcld = true;
5771
+ }
5772
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5773
 
5774
+ case 'nav_menu_locations' :
5775
+ if ( _ptrn == setId.substring( 0, _ptrn.length ) ) {
5776
+ _isExcld = self.isExcludedNavMenuLocations();
5777
+ }
5778
+ break;
5779
 
5780
+ case 'custom_css' :
5781
+ if ( _ptrn == setId.substring( 0, _ptrn.length ) ) {
5782
+ _isExcld = self.isExcludedWPCustomCss();
5783
+ }
5784
+ break;
5785
 
 
 
5786
 
5787
+ }
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);
5808
+ if ( ! api.czr_skope.has( skope_id ) ) {
5809
+ api.consoleLog( '_getDBSettingVal : the requested skope id is not registered : ' + skope_id );
5810
+ return '_no_db_val';
5811
+ }
5812
+ if ( _.has( api.czr_skope( skope_id ).dbValues(), wpSetId ) ) {
5813
+ return api.czr_skope( skope_id ).dbValues()[wpSetId];
5814
+ } else if ( _.has( api.czr_skope( skope_id ).dbValues(), shortSetId ) ) {
5815
+ return api.czr_skope( skope_id ).dbValues()[shortSetId];
5816
+ } else {
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
+ }
5835
+ values[ _setId ] = _val;
5836
+ } );
5837
+ return values;
5838
+ },
5839
 
5840
+ getSkopeExcludedDirties : function() {
5841
+ var self = this,
5842
+ _wpDirties = {};
5843
+ api.each( function ( value, setId ) {
5844
+ if ( value._dirty ) {
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
+ },
5854
 
5855
+ /**
5856
+ * @param {String} widgetId
5857
+ * @returns {Object}
5858
+ */
5859
+ parseWidgetId : function( widgetId, prefixToRemove ) {
5860
+ var matches, parsed = {
5861
+ number: null,
5862
+ id_base: null
5863
+ };
5864
+
5865
+ matches = widgetId.match( /^(.+)-(\d+)$/ );
5866
+ if ( matches ) {
5867
+ parsed.id_base = matches[1];
5868
+ parsed.number = parseInt( matches[2], 10 );
5869
+ } else {
5870
+ parsed.id_base = widgetId;
5871
+ }
5872
+
5873
+ if ( ! _.isUndefined( prefixToRemove ) )
5874
+ parsed.id_base = parsed.id_base.replace( prefixToRemove , '');
5875
+ return parsed;
5876
+ },
5877
+
5878
+ /**
5879
+ * @param {String} widgetId
5880
+ * @returns {String} settingId
5881
+ */
5882
+ widgetIdToSettingId: function( widgetId , prefixToRemove ) {
5883
+ var parsed = this.parseWidgetId( widgetId, prefixToRemove ), settingId;
5884
+
5885
+ settingId = parsed.id_base;
5886
+ if ( parsed.number ) {
5887
+ settingId += '[' + parsed.number + ']';
5888
+ }
5889
+ return settingId;
5890
+ },
5891
 
 
 
5892
 
 
 
 
 
 
5893
 
 
5894
 
5895
+ isWidgetRegisteredGlobally : function( widgetId ) {
5896
+ var self = this;
5897
+ registered = false;
5898
+ _.each( _wpCustomizeWidgetsSettings.registeredWidgets, function( _val, _short_id ) {
5899
+ if ( ! registered && 'widget_' + self.widgetIdToSettingId(_short_id) == widgetId )
5900
+ registered = true;
5901
+ } );
5902
+ return registered;
5903
+ }
5904
+ });//$.extend
5905
+ })( wp.customize , jQuery, _ );
5906
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
5907
+ ( function ( api, $, _ ) {
5908
+ $.extend( CZRSkopeBaseMths, {
5909
 
5910
+ getAppliedPrioritySkopeId : function( setId, skope_id ) {
5911
+ if ( ! api.has( api.CZR_Helpers.build_setId(setId) ) ) {
5912
+ api.errorLog( 'getAppliedPrioritySkopeId : the requested setting id does not exist in the api : ' + api.CZR_Helpers.build_setId(setId) );
5913
+ return skope_id;
5914
+ }
5915
+ if ( ! api.czr_skope.has( skope_id ) ) {
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 = '___',
5927
+ skope_model = api.czr_skope( _skp_id )(),
5928
+ initial_val;
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 )();
5965
 
5966
+ if ( _skp_id == skope_id )
5967
+ return _skp_ids;
5968
+ _skp_ids.unshift( _skp_id );
5969
+ return _salmonToMatch( self._getParentSkopeId( skope_model ), _skp_ids );
5970
+ };
 
 
 
 
 
 
5971
 
5972
+ return _.map( _salmonToMatch( _local_skope_id ), function( id ) {
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) );
5979
+ return skope_id;
5980
+ }
5981
+ if ( ! api.czr_skope.has( skope_id ) ) {
5982
+ api.errorLog( 'getInheritedSkopeId : the requested skope id is not registered : ' + skope_id );
5983
+ return skope_id;
5984
+ }
5985
 
5986
+ var self = this,
5987
+ wpSetId = api.CZR_Helpers.build_setId( setId ),
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 ) ) {
6013
+ api.errorLog( 'getInheritedSkopeTitles : the requested skope id is not registered : ' + skope_id );
6014
+ return '';
6015
+ }
6016
+ skope_ids = skope_ids || [];
6017
+ var self = this,
6018
+ skope_model = api.czr_skope( skope_id )();
6019
 
6020
+ if ( skope_id !== api.czr_activeSkopeId() )
6021
+ skope_ids.unshift( skope_id );
 
 
 
 
6022
 
6023
+ if ( 'global' !== skope_model.skope )
6024
+ return self.getInheritedSkopeTitles( self._getParentSkopeId( skope_model ), skope_ids );
 
 
 
 
 
 
6025
 
6026
+ return _.map( skope_ids, function( id ) {
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 );
6033
+ return '';
6034
+ }
6035
+ var _link_title = [ serverControlParams.i18n.skope['Switch to scope'], api.czr_skope( skope_id )().title ].join(' : ');
6036
+ return [
6037
+ '<span class="czr-skope-switch" title=" ' + _link_title + '" data-skope-id="' + skope_id + '">',
6038
+ api.czr_skope( skope_id )().title,
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) );
6045
+ return null;
6046
+ }
6047
+ if ( ! api.czr_skope.has( skope_id ) ) {
6048
+ api.errorLog( 'getSkopeSettingVal : the requested skope id is not registered : ' + skope_id );
6049
+ return null;
6050
+ }
6051
 
6052
+ var self = this,
6053
+ wpSetId = api.CZR_Helpers.build_setId( setId ),
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 || {};
6079
 
6080
+ var self = this,
6081
+ skope_model = api.czr_skope( skope_id )();
 
 
6082
 
6083
+ if ( 'global' == skope_model.skope )
6084
+ return dirtyCustomized;
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] ) )
6091
+ dirtyCustomized[wpSetId] = _val;
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'],
6098
+ parent_skope_ind = _index || ( _.findIndex( hierark, function( _skp ) { return skope_model.skope == _skp; } ) + 1 ) * 1,
6099
+ parent_skope_skope = hierark[ parent_skope_ind ];
6100
 
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'],
6112
+ child_skope_ind = _index || ( _.findIndex( hierark, function( _skp ) { return skope_model.skope == _skp; } ) - 1 ) * 1,
6113
+ child_skope_skope = hierark[ child_skope_ind ];
6114
 
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
+ }
6121
+ return _.findWhere( api.czr_currentSkopesCollection(), { skope : child_skope_skope } ).id;
6122
+ }
6123
 
6124
+ });//$.extend
6125
+ })( wp.customize , jQuery, _ );
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() )() );
6139
 
6140
+ _.each( _api_ready_collection, function( _skp, _k ) {
6141
+ if ( 'global' == _skp.skope )
6142
+ _updated_api_ready_collection.push( _global_skp_model );
6143
+ else
6144
+ _updated_api_ready_collection.push( _skp );
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');
6153
+ }
6154
+ var self = this,
6155
+ api_ready_skope = {};
6156
 
6157
+ _.each( serverControlParams.defaultSkopeModel , function( _value, _key ) {
6158
+ var _candidate_val = skope_candidate[_key];
6159
+ switch( _key ) {
6160
+ case 'title' :
6161
+ if ( ! _.isString( _candidate_val ) ) {
6162
+ throw new Error('prepareSkopeForAPI : a skope title property must a string');
6163
+ }
6164
+ api_ready_skope[_key] = _candidate_val;
6165
+ break;
6166
+ case 'long_title' :
6167
+ if ( ! _.isString( _candidate_val ) ) {
6168
+ throw new Error('prepareSkopeForAPI : a skope title property must a string');
6169
+ }
6170
+ api_ready_skope[_key] = _candidate_val;
6171
+ break;
6172
+ case 'ctx_title' :
6173
+ if ( ! _.isString( _candidate_val ) ) {
6174
+ throw new Error('prepareSkopeForAPI : a skope context title property must a string');
6175
+ }
6176
+ api_ready_skope[_key] = _candidate_val;
6177
+ break;
6178
+ case 'skope' :
6179
+ if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
6180
+ throw new Error('prepareSkopeForAPI : a skope "skope" property must a string not empty');
6181
+ }
6182
+ api_ready_skope[_key] = _candidate_val;
6183
+ break;
6184
+ case 'level' :
6185
+ if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
6186
+ throw new Error('prepareSkopeForAPI : a skope level must a string not empty for skope ' + _candidate_val.skope );
6187
+ }
6188
+ api_ready_skope[_key] = _candidate_val;
6189
+ break;
6190
+ case 'dyn_type' :
6191
+ if ( ! _.isString( _candidate_val ) || ! _.contains( serverControlParams.skopeDynTypes, _candidate_val ) ) {
6192
+ throw new Error('prepareSkopeForAPI : missing or invalid dyn type for skope ' + skope_candidate );
6193
+ }
6194
+ api_ready_skope[_key] = _candidate_val;
6195
+ break;
6196
+ case 'opt_name' :
6197
+ if ( ! _.isString( _candidate_val ) || _.isEmpty( _candidate_val ) ) {
6198
+ throw new Error('prepareSkopeForAPI : invalid "opt_name" property for skope ' + _candidate_val.skope );
6199
+ }
6200
+ api_ready_skope[_key] = _candidate_val;
6201
+ break;
6202
+ case 'obj_id' :
6203
+ if ( ! _.isString( _candidate_val ) ) {
6204
+ throw new Error('prepareSkopeForAPI : invalid "obj_id" for skope ' + _candidate_val.skope );
6205
+ }
6206
+ api_ready_skope[_key] = _candidate_val;
6207
+ break;
6208
+ case 'is_winner' :
6209
+ if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
6210
+ throw new Error('prepareSkopeForAPI : skope property "is_winner" must be a boolean');
6211
+ }
6212
+ api_ready_skope[_key] = _candidate_val;
6213
+ break;
6214
+ case 'is_forced' :
6215
+ if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
6216
+ throw new Error('prepareSkopeForAPI : skope property "is_primary" must be a boolean');
6217
+ }
6218
+ api_ready_skope[_key] = _candidate_val;
6219
+ break;
6220
+ case 'db' :
6221
+ if ( _.isArray( _candidate_val ) || _.isEmpty( _candidate_val ) )
6222
+ _candidate_val = {};
6223
+ if ( _.isUndefined( _candidate_val) || ! _.isObject( _candidate_val ) ) {
6224
+ throw new Error('prepareSkopeForAPI : skope property "db" must be an object');
6225
+ }
6226
+ api_ready_skope[_key] = _candidate_val;
6227
+ break;
6228
+ case 'changeset' :
6229
+ if ( _.isArray( _candidate_val ) || _.isEmpty( _candidate_val ) )
6230
+ _candidate_val = {};
6231
+ if ( _.isUndefined( _candidate_val) || ! _.isObject( _candidate_val ) ) {
6232
+ throw new Error('prepareSkopeForAPI : skope property "changeset" must be an object');
6233
+ }
6234
+ api_ready_skope[_key] = _candidate_val;
6235
+ break;
6236
+ case 'has_db_val' :
6237
+ if ( ! _.isUndefined( _candidate_val) && ! _.isBoolean( _candidate_val ) ) {
6238
+ throw new Error('prepareSkopeForAPI : skope property "has_db_val" must be a boolean');
6239
+ }
6240
+ api_ready_skope[_key] = _candidate_val;
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');
6248
+ }
6249
+ if ( ! _.isString( api_ready_skope.title ) || _.isEmpty( api_ready_skope.title ) ) {
6250
+ api_ready_skope.title = id;
6251
+ api_ready_skope.long_title = id;
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
+ }
6272
+ if ( 'pending' == api.czr_skope( _skope.id ).isReady.state() ) {
6273
+ api.czr_skope( _skope.id ).ready();
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) ) {
6293
+ _newClasses = _.without( _newClasses, _c );
6294
+ }
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
+ };
6301
+ api.czr_skope.each( function( _skp_instance ) {
6302
+ if ( _.isUndefined( _.findWhere( _new_collection, { id : _skp_instance().id } ) ) ) {
6303
+ _skp_instance.visible( false );
6304
+ _skp_instance.isReady.then( function() {
6305
+ _skp_instance.container.toggleClass( 'active-collection', false );
6306
+ });
6307
+ }
6308
+ else {
6309
+ _skp_instance.visible( true );
6310
+ var _activeSkpDomPostProcess = function() {
6311
+ _setLayoutClass( _skp_instance );
6312
+ _skp_instance.container.toggleClass( 'active-collection', true );
6313
+ };
6314
+ if ( 'pending' == _skp_instance.isReady.state() ) {
6315
+ _skp_instance.isReady.then( function() {
6316
+ _activeSkpDomPostProcess();
6317
+ });
6318
+ } else {
6319
+ _activeSkpDomPostProcess();
6320
+ }
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 ) ) {
6336
+ throw new Error('maybeSynchronizeGlobalSkope : args must be an object');
6337
+ }
6338
+ var self = this,
6339
+ dfd = $.Deferred(),
6340
+ defaults = _.extend({
6341
+ isGlobalReset : false,
6342
+ isSetting : false,
6343
+ settingIdToReset : '',
6344
+ isSkope : false,
6345
+ skopeIdToReset : ''
6346
+ },
6347
+ args
6348
+ ),
6349
+ _setIdToReset,
6350
+ shortSetId,
6351
+ defaultVal;
 
 
6352
 
6353
+ if ( self.isGlobalSkopeRegistered() ) {
6354
+ var _global_skp_db_values = api.czr_skope( self.getGlobalSkopeId() ).dbValues();
6355
+ _.each( _global_skp_db_values, function( _val, setId ){
6356
+ if ( api.has( setId ) && ! _.isEqual( api.settings.settings[setId].value, _val ) ) {
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 );
6363
+ defaultVal = serverControlParams.defaultOptionsValues[ shortSetId ];
6364
 
6365
+ if ( _.isUndefined( api.settings.settings[ _setIdToReset ] ) || _.isUndefined( defaultVal ) )
6366
+ return;
6367
+ if ( defaultVal != api.settings.settings[ _setIdToReset ].value ) {
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 ) )
6374
+ return;
6375
 
6376
+ shortSetId = api.CZR_Helpers.getOptionName( _setId );
6377
+ if ( ! _.has( serverControlParams.defaultOptionsValues, shortSetId ) )
6378
+ return;
6379
+ api.settings.settings[_setId].value = serverControlParams.defaultOptionsValues[ shortSetId ];
6380
+ });
6381
+ }
6382
+ }
6383
+ return dfd.resolve().promise();
6384
+ }
6385
+ });//$.extend
6386
+ })( wp.customize , jQuery, _ );
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 ) )
6395
+ throw new Error('listenToActiveSkope : previous scope does not exist in the collection', from );
6396
 
6397
+ if ( ! _.isUndefined(to) && api.czr_skope.has(to) )
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',
6426
+ message : [
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 ) )
6450
+ _silentUpdateCands.push( _setId );
6451
+ } );
6452
+ }
6453
+ if ( ! _.isUndefined( to ) ) {
6454
+ _.each( api.czr_skope( to ).dirtyValues(), function( val, _setId ) {
6455
+ if ( ! _.contains( _silentUpdateCands, _setId ) )
6456
+ _silentUpdateCands.push( _setId );
6457
+ } );
6458
+ }
6459
+ var _debouncedProcessSilentUpdates = function() {
6460
+ self.processSilentUpdates( {
6461
+ candidates : _silentUpdateCands,
6462
+ section_id : null,
6463
+ refresh : false//will be done on done()
6464
+ })
6465
+ .fail( function() {
6466
+ dfd.reject();
6467
+ api.state('switching-skope')( false );
6468
+ throw new Error( 'Fail to process silent updates in _debouncedProcessSilentUpdates');
6469
+ })
6470
+ .done( function( _updatedSetIds ) {
6471
+ api.previewer.refresh()
6472
+ .always( function() {
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 );
6481
+ _debouncedProcessSilentUpdates();
6482
+ } else {
6483
+ _debouncedProcessSilentUpdates();
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,
6490
+ _buildTitleHtml = function() {
6491
+ var _inheritedFrom = self.getInheritedSkopeTitles(),
6492
+ _overrides = self.getOverridenSkopeTitles();
6493
 
6494
+ return $.trim( [
6495
+ '<span class="czr-main-title"><span class="czr-toggle-title-notice fa fa-info-circle"></span>',
6496
+ 'global' == api.czr_skope( skope_id || api.czr_activeSkopeId() )().skope ? current_title : ['Customizing', current_title ].join(' '),
6497
+ '</span>',
6498
+ '<span class="czr-skope-inherits-from">',
6499
+ serverControlParams.i18n.skope['In this context :'],
6500
+ _.isEmpty( _inheritedFrom ) ? ' ' : serverControlParams.i18n.skope['inherits from'],
6501
+ _inheritedFrom,
6502
+ _.isEmpty( _inheritedFrom ) ? '' : _.isEmpty( _overrides ) ? '.' : [',' , serverControlParams.i18n.skope['and'] ].join(' '),
6503
+ _.isEmpty( _overrides ) ? ' ' : serverControlParams.i18n.skope['overridden by'],
6504
+ _overrides,
6505
+ _.isEmpty( _overrides ) ? '' : '.',
6506
+ '</span>'
6507
+ ].join(' ') );
6508
+ },
6509
+ _toggle_spinner = function( visible ) {
6510
+ if ( visible ) {
6511
+ $('.czr-scope-switcher').find('.spinner').fadeIn();
6512
+ } else {
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 ) {
6519
+ $('.czr-scope-switcher').prepend(
6520
+ $( '<h2/>', {
6521
+ class : 'czr-current-skope-title',
6522
+ html : [
6523
+ '<span class="czr-skope-title">',
6524
+ '<span class="spinner">',
6525
+ _buildTitleHtml(),
6526
+ '</span>',
6527
+ '</span>'
6528
+ ].join('')
6529
+ })
6530
+ );
6531
+ } else {
6532
+ $.when( $('.czr-scope-switcher').find('.czr-skope-title').fadeOut(200) ).done( function() {
6533
+ $(this)
6534
+ .html( _buildTitleHtml() )
6535
+ .fadeIn(200);
6536
+ });
6537
+ }
6538
 
6539
+ if ( _.isUndefined( api.state( 'switching-skope' ).isBound ) ) {
6540
+ api.state('switching-skope').bind( _toggle_spinner );
6541
+ api.state( 'switching-skope' ).isBound = true;
6542
+ }
6543
+ });
6544
+ }//_writeCurrentSkopeTitle
6545
+ });//$.extend
6546
+ })( wp.customize , jQuery, _ );
6547
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
6548
+ ( function ( api, $, _ ) {
6549
+ $.extend( CZRSkopeBaseMths, {
6550
+ processSilentUpdates : function( params ) {
6551
+ if ( _.isString( params ) )
6552
+ params = { candidates : [ params ] };
6553
+ else
6554
+ params = params || {};
6555
 
6556
+ var self = this,
6557
+ defaultParams = {
6558
+ candidates : [],
6559
+ section_id : api.czr_activeSectionId(),
6560
+ refresh : true,
6561
+ awake_if_not_active : false
6562
+ },
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
 
 
 
 
 
 
 
 
 
 
 
6577
 
6578
+ var _enjoyTheSilence = function() {
6579
+ self.silentlyUpdateSettings( params.candidates, params.refresh )
6580
+ .fail( function() {
6581
+ dfd.reject();
6582
+ })
6583
+ .done( function( updated_settings ) {
6584
+ _.delay( function() {
6585
+ self.setupActiveSkopedControls( {
6586
+ section_id : params.section_id
6587
+ });
6588
+ }, 1000 );
6589
+ dfd.resolve( updated_settings );
6590
+ });
6591
+ };
6592
+ if ( 'resolved' != api.czr_skopeReady.state() ) {
6593
+ dfd.resolve( [] );
6594
+ api.czr_skopeReady.done( function() {
6595
+ _enjoyTheSilence();
6596
+ });
6597
+ } else {
6598
+ _enjoyTheSilence();
6599
+ }
6600
 
6601
+ return dfd.promise();
6602
+ },
 
6603
 
 
 
 
 
 
6604
 
 
 
 
6605
 
 
 
 
 
 
 
 
6606
 
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();
6618
 
6619
+ refresh = _.isUndefined( refresh ) ? true : refresh;
 
 
6620
 
6621
+ if ( _.isUndefined( _silentUpdateCands ) || _.isEmpty( _silentUpdateCands ) ) {
6622
+ _silentUpdateCands = self._getSilentUpdateCandidates();
6623
+ }
 
6624
 
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;
6631
+ _silentUpdatePromises[setId] = self.getSettingUpdatePromise( setId );
6632
+ });
6633
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_ ) ) {
6642
+ _updatedSetIds.push( setId );
6643
+ }
6644
+ api( wpSetId ).silent_set( _new_setting_val_ , _skopeDirtyness );
6645
+ });
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 );
6653
+ })
6654
+ .always( function() {
6655
+ api.state( 'silent-update-processing' )( false );
6656
+ })
6657
+ .then( function() {
6658
+ _.each( _deferred, function( prom ){
6659
+ if ( _.isObject( prom ) && 'resolved' !== prom.state() ) {
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() {
6666
+ dfd.resolve( _updatedSetIds );
6667
+ });
6668
+ } else {
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');
6677
+ }
6678
+ if ( ! api.has( api.CZR_Helpers.build_setId( setId ) ) ) {
6679
+ throw new Error('getSettingUpdatePromise : the provided wpSetId is not registered : ' + api.CZR_Helpers.build_setId( setId ) );
6680
+ }
6681
 
6682
+ var self = this,
6683
+ wpSetId = api.CZR_Helpers.build_setId( setId ),
6684
+ current_setting_val = api( wpSetId )(),//typically the previous skope val
6685
+ dfd = $.Deferred(),
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;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6701
 
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
+ }
6710
+ if ( ! _promise || ! _.isObject( _promise ) ) {
6711
+ dfd.resolve( val );
6712
+ } else {
6713
+ _promise.always( function() {
6714
+ dfd.resolve( val );
6715
+ });
6716
+ }
6717
 
6718
+ return dfd.promise();
6719
+ },//getSettingUpdatePromise()
 
 
 
 
 
6720
 
 
 
6721
 
 
 
 
 
 
 
 
 
 
 
 
 
6722
 
 
 
 
 
 
 
 
 
 
 
 
 
6723
 
6724
+ /*****************************************************************************
6725
+ * GET SILENT UPDATE CANDIDATE FROM A SECTION. FALLS BACK ON THE CURRENT ONE
6726
+ *****************************************************************************/
6727
+ _getSilentUpdateCandidates : function( section_id, awake_if_not_active ) {
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 [];
6737
+ }
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
+ });
6748
 
6749
+ return SilentUpdateCands;
6750
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6751
 
6752
+ });//$.extend
6753
+ })( wp.customize , jQuery, _ );
6754
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
6755
+ ( function ( api, $, _ ) {
6756
+ $.extend( CZRSkopeBaseMths, {
6757
+ /*****************************************************************************
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();
6789
+ }
6790
+ },
6791
 
 
 
 
 
 
 
 
 
 
 
 
6792
 
 
 
 
 
 
6793
 
 
 
 
 
6794
 
 
 
 
 
6795
 
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6819
 
6820
 
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 ) {
6827
+ return dfd.resolve().promise();
6828
+ }
 
 
 
 
 
 
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 );
6846
+ _render_control();
6847
+ };
6848
 
 
 
 
 
6849
 
6850
+ if ( ! _.has( header_image_data, 'attachment_id' ) ) {
6851
+ _reset_header_image_crtl();
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
6873
+ })( wp.customize , jQuery, _ );
6874
 
6875
+ /*****************************************************************************
6876
+ * THE SKOPE BASE OBJECT
6877
+ *****************************************************************************/
6878
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
6879
  ( function ( api, $, _ ) {
6880
+ $.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 = {
6887
+ controls : [],
6888
+ section_id : api.czr_activeSectionId()
6889
+ };
6890
+ setupParams = $.extend( defaultSetupParams, obj );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6891
 
6892
+ if ( ! _.isObject( setupParams ) || ! _.has( setupParams, 'controls' ) || ! _.has( setupParams, 'section_id' ) ) {
6893
+ throw new Error( 'setupActiveSkopedControls : the setupParams param must be an object with properties controls and section_id.');
6894
+ }
 
 
 
6895
 
6896
+ section_id = setupParams.section_id;
6897
+ controls = setupParams.controls;
6898
+ eligibleCtrls = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6899
 
6900
+ if ( _.isEmpty( section_id ) || ! _.isString( section_id ) ) {
6901
+ section_id = api.czr_activeSectionId();
6902
+ }
6903
+ if ( _.isEmpty( controls ) ) {
6904
+ controls = api.CZR_Helpers.getSectionControlIds( section_id );
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 ) ) {
6911
+ api.control( ctrlId ).container.addClass('czr-not-skoped');
6912
+ }
6913
+ if ( setId && self.isWPAuthorizedSetting( setId ) ) {
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
 
6938
+ if ( ! api.has( ctrlId ) || _.isUndefined( api.control( ctrlId ) ) )
6939
+ return;
 
 
 
 
 
 
6940
 
6941
+ var ctrl = api.control( ctrlId ),
6942
+ setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
6943
+ shortSetId = api.CZR_Helpers.getOptionName( setId ),
6944
+ defaults = {
6945
+ hasDBVal : false,
6946
+ isDirty : false,
6947
+ noticeVisible : false,
6948
+ resetVisible : false,
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',
6971
+ name : 'control_reset_warning',
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',
6987
+ name : 'control_do_reset',
6988
+ actions : function() {
6989
+ self.doResetSetting( ctrlId );
6990
+ }
6991
+ },
6992
+ {
6993
+ trigger : 'click keydown',
6994
+ selector : '.czr-skope-switch',
6995
+ name : 'control_skope_switch',
6996
+ actions : function( params ) {
6997
+ var _skopeIdToSwithTo = $( params.dom_event.currentTarget, params.dom_el ).attr('data-skope-id');
6998
+ if ( ! _.isEmpty( _skopeIdToSwithTo ) && api.czr_skope.has( _skopeIdToSwithTo ) )
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
+ }
7011
+ }
7012
+ }
7013
+ ];
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 ) {
7026
+ _title = serverControlParams.i18n.skope['Reset your customized ( and published ) value'];
7027
+ } else if ( ctrl.czr_states('isDirty')() ) {
7028
+ _title = serverControlParams.i18n.skope['Reset your customized ( but not yet published ) value'];
7029
+ } else {
7030
+ _title = serverControlParams.i18n.skope['Not customized yet, nothing to reset'];
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;
7037
+ if ( bool ) {
7038
+ _title = serverControlParams.i18n.skope['Reset your customized ( but not yet published ) value'];
7039
+ } else if ( ctrl.czr_states('hasDBVal')() ) {
7040
+ _title = serverControlParams.i18n.skope['Reset your customized ( and published ) value'];
7041
+ } else {
7042
+ _title = serverControlParams.i18n.skope['Not customized yet, nothing to reset'];
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();
7049
+ if ( false !== $noticeContainer && false !== $noticeContainer.length ) {
7050
+ if ( ! visible ) {
7051
+ $.when( $noticeContainer
7052
+ .stop()
7053
+ .slideUp( 'fast', null, function() {
7054
+ $( this ).css( 'height', 'auto' );
7055
+ } ) ).done( function() {
7056
+ self.removeCtrlSkpNot( ctrl.id );
7057
+ });
7058
+ } else {
7059
+ self.updateCtrlSkpNot( ctrl.id, true );//<= True for visible
7060
+ $noticeContainer
7061
+ .stop()
7062
+ .slideDown( 'fast', null, function() {
7063
+ $( this ).css( 'height', 'auto' );
7064
+ } );
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() {
7079
+ ctrl.czr_resetDialogContainer.remove();
7080
+ });
7081
+ }, 3000 );
7082
+ }
7083
+ });
7084
+ } else {
7085
+ if ( _.has( ctrl, 'czr_resetDialogContainer' ) && ctrl.czr_resetDialogContainer.length )
7086
+ $.when( ctrl.czr_resetDialogContainer.slideToggle('fast') ).done( function() {
7087
+ ctrl.czr_resetDialogContainer.remove();
7088
+ });
7089
+ }
7090
+ });
7091
+ }
7092
+ });//$.extend()
7093
+ })( wp.customize , jQuery, _ );
7094
 
7095
+ /*****************************************************************************
7096
+ * THE SKOPE BASE OBJECT
7097
+ *****************************************************************************/
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 );
7108
+ });
7109
+ }
7110
 
7111
+ var controlIds = _.isArray(controls) ? controls : [controls],
7112
+ render_reset_icons = function( ctrlIds ) {
7113
+ if ( _.isEmpty( ctrlIds ) ) {
7114
+ dfd.resolve();
7115
+ return;
7116
+ }
7117
+ _.each( ctrlIds, function( _id ) {
7118
+ api.control.when( _id, function() {
7119
+ var ctrl = api.control( _id ),
7120
+ setId = api.CZR_Helpers.getControlSettingId( _id );
7121
 
7122
+ if( $('.czr-setting-reset', ctrl.container ).length ) {
7123
+ dfd.resolve();
7124
+ return;
7125
+ }
 
7126
 
7127
+ ctrl.deferred.embedded.then( function() {
7128
+ $.when(
7129
+ ctrl.container
7130
+ .find('.customize-control-title').first()//was.find('.customize-control-title')
7131
+ .prepend( $( '<span/>', {
7132
+ class : 'czr-setting-reset fa fa-refresh',
7133
+ title : ''
7134
+ } ) ) )
7135
+ .done( function(){
7136
+ ctrl.container.addClass('czr-skoped');
7137
+ $('.czr-setting-reset', ctrl.container).fadeIn( 400 );
7138
+ dfd.resolve();
7139
+ });
7140
+ });//then()
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 {};
 
 
 
7151
 
7152
+ var self = this,
7153
+ ctrl = api.control( ctrlId ),
7154
+ setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
7155
+ _tmpl = '',
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 ) ) )
7162
+ return true;
7163
+ return false;
7164
+ })(),
7165
+ _currentSkopeModel = api.czr_skope( api.czr_activeSkopeId() )();
 
7166
 
7167
+ if ( ctrl.czr_states( 'isDirty' )() ) {
7168
+ warning_message = [
7169
+ 'global' == _currentSkopeModel.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'],
7170
+ 'global' == _currentSkopeModel.skope ? serverControlParams.i18n.skope['sitewide'] : _currentSkopeModel.ctx_title
7171
+ ].join(' ');
7172
+ success_message = serverControlParams.i18n.skope['Your customizations have been reset'];
7173
+ } else {
7174
+ if ( isWPSetting && 'global' == _currentSkopeModel.skope ) {
7175
+ warning_message = serverControlParams.i18n.skope['This WordPress setting can not be reset sitewide'];
7176
+ } else {
7177
+ warning_message = [
7178
+ 'global' == _currentSkopeModel.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'],
7179
+ 'global' == _currentSkopeModel.skope ? serverControlParams.i18n.skope['sitewide'] : _currentSkopeModel.ctx_title
7180
+ ].join(' ');
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 + '.',
7187
+ success_message : success_message + '.',
7188
+ is_authorized : is_authorized
7189
+ };
7190
+ try {
7191
+ _tmpl = wp.template('czr-reset-control')( _tmpl_data );
7192
+ } catch( er ) {
7193
+ api.errorLog( 'Error when parsing the the reset control template : ' + er );
7194
+ return { container : false, is_authorized : false };
7195
+ }
7196
 
7197
+ $('.customize-control-title', ctrl.container).first().after( $( _tmpl ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ),
7204
+ ctrl = api.control( ctrlId ),
7205
+ skope_id = api.czr_activeSkopeId(),
7206
+ reset_method = ctrl.czr_states( 'isDirty' )() ? '_resetControlDirtyness' : '_resetControlAPIVal',
7207
+ _setResetDialogVisibility = function() {
7208
+ var ctrl = this;//<= fired with .call( ctrlInstance )
7209
+ ctrl.czr_states( 'resetVisible' )( false );
7210
+ ctrl.czr_states( 'isResetting' )( false);
7211
+ ctrl.container.removeClass('czr-resetting-control');
7212
+ },
7213
+ _updateAPI = function( ctrlId ) {
7214
+ var _silentUpdate = function() {
7215
+ api.czr_skopeBase.processSilentUpdates( { candidates : ctrlId, refresh : false } )
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 ) {
7222
+ _.delay( function() {
7223
+ $.when( $_el.fadeOut('300') ).done( function() {
7224
+ self.setupActiveSkopedControls( { controls : [ ctrlId ] } ).done( function() {
7225
+ if ( ctrl.czr_states ) {
7226
+ _setResetDialogVisibility.call( ctrl );
7227
+ ctrl.czr_states( 'noticeVisible' )( self.isCtrlNoticeVisible( ctrlId ) );
7228
+ }
7229
+ });
7230
+ });
7231
+ }, 500 );
7232
+ });
7233
+ });
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 );
7243
+ })
7244
+ .done( function( refresh_data ) {
7245
+ if ( 'global' == api.czr_skope( skope_id )().skope && '_resetControlAPIVal' == reset_method ) {
7246
+ var _sentSkopeCollection,
7247
+ _serverGlobalDbValues = {},
7248
+ _skope_opt_name = api.czr_skope( skope_id )().opt_name;
7249
 
7250
+ if ( ! _.isUndefined( refresh_data.skopesServerData ) && _.has( refresh_data.skopesServerData, 'czr_skopes' ) ) {
7251
+ _sentSkopeCollection = refresh_data.skopesServerData.czr_skopes;
7252
+ if ( _.isUndefined( _.findWhere( _sentSkopeCollection, { opt_name : _skope_opt_name } ) ) ) {
7253
+ _serverGlobalDbValues = _.findWhere( _sentSkopeCollection, { opt_name : _skope_opt_name } ).db || {};
7254
+ }
7255
+ }
7256
+ api.czr_skopeBase.maybeSynchronizeGlobalSkope( { isGlobalReset : true, isSetting : true, settingIdToReset : setId } )
7257
+ .done( function() {
7258
+ _silentUpdate();
7259
+ });
7260
+ } else {
7261
+ _silentUpdate();
7262
+ }
7263
+ });
7264
+ });
7265
+ };//_updateAPI
7266
 
7267
 
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 ) {
7274
+ _updateAPI( ctrlId );
7275
+ })
7276
+ .fail( function( r ) {
7277
+ api.errorLog( 'Reset failed', r );
7278
+ $.when( $('.czr-crtl-reset-dialog', ctrl.container ).fadeOut('300') ).done( function() {
7279
+ $.when( $('.czr-reset-fail', ctrl.container ).fadeIn('300') ).done( function() {
7280
+ $('.czr-reset-fail', ctrl.container ).append('<p>' + r + '</p>');
7281
+ _.delay( function() {
7282
+ _setResetDialogVisibility.call( ctrl );
7283
+ self.setupActiveSkopedControls( { controls : [ ctrlId ] } );
7284
+ }, 2000 );
7285
+ });
7286
  });
7287
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7288
 
7289
+ },
7290
+ _resetControlDirtyness : function( ctrlId ) {
7291
+ var setId = api.CZR_Helpers.getControlSettingId( ctrlId ),
7292
+ skope_instance = api.czr_skope( api.czr_activeSkopeId() ),
7293
+ current_dirties = $.extend( true, {}, skope_instance.dirtyValues() ),
7294
+ new_dirties = {},
7295
+ current_changeset = $.extend( true, {}, skope_instance.changesetValues() ),
7296
+ new_changeset = {},
7297
+ dfd = $.Deferred();
 
 
 
 
 
 
 
 
 
 
 
7298
 
7299
+ new_dirties = _.omit( current_dirties, setId );
7300
+ new_changeset = _.omit( current_changeset, setId );
7301
+ skope_instance.dirtyValues( new_dirties );
7302
+ skope_instance.changesetValues( new_dirties );
 
 
 
 
 
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(),
7309
+ new_skope_db = $.extend( true, {}, current_skope_db ),
7310
+ dfd = $.Deferred();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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();
7317
+ }
7318
+ });//$.extend()
7319
+ })( wp.customize , jQuery, _ );
 
 
 
 
 
 
 
 
 
 
 
7320
 
7321
+ /*****************************************************************************
7322
+ * THE SKOPE BASE OBJECT
7323
+ *****************************************************************************/
7324
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
7325
+ ( function ( api, $, _ ) {
7326
+ $.extend( CZRSkopeBaseMths, {
7327
+ renderCtrlSkpNotIcon : function( controlIdCandidates ) {
7328
+ var self = this,
7329
+ controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates];
7330
+
7331
+ _.each( controlIds, function( _id ) {
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
+
7338
+ $.when( ctrl.container
7339
+ .find('.customize-control-title').first()//was.find('.customize-control-title')
7340
+ .append( $( '<span/>', {
7341
+ class : 'czr-toggle-notice fa fa-info-circle',
7342
+ title : serverControlParams.i18n.skope['Display informations about the scope of this option.']
7343
+ } ) ) )
7344
+ .done( function(){
7345
+ $('.czr-toggle-notice', ctrl.container).fadeIn( 400 );
7346
  });
7347
  });
 
7348
 
7349
+ });
7350
+
7351
+ });
7352
+ },
7353
+ updateCtrlSkpNot : function( controlIdCandidates, visible ) {
7354
+ var self = this,
7355
+ controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates],
7356
+ _isSkoped = function( setId ) {
7357
+ return setId && self.isSettingSkopeEligible( setId );
7358
+ },//filter only eligible ctrlIds
7359
+
7360
+ _generateControlNotice = function( setId, _localSkopeId ) {
7361
+ var _currentSkopeId = api.czr_activeSkopeId(),
7362
+ _inheritedFromSkopeId = self.getInheritedSkopeId( setId, _currentSkopeId ),
7363
+ _overridedBySkopeId = self.getAppliedPrioritySkopeId( setId, _currentSkopeId ),
7364
+ _html = [],
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
+
7378
+ _ctxTitle = api.czr_skope( _inheritedFromSkopeId )().ctx_title;
7379
 
7380
+ _ctxTitle = ( _.isString( _ctxTitle ) ? _ctxTitle : '' ).toLowerCase();
 
 
 
 
 
7381
 
7382
+ if ( _isCustomized ) {
7383
+ if ( 'global' == api.czr_skope( _inheritedFromSkopeId )().skope ) {
7384
+ _html.push( [
7385
+ serverControlParams.i18n.skope['Customized. Will be applied sitewide once published.'],
7386
+ ].join(' ') );
7387
+ } else {
7388
+ _html.push( [
7389
+ serverControlParams.i18n.skope['Customized. Will be applied to'],
7390
+ '<strong>' + _ctxTitle + '</strong>',
7391
+ serverControlParams.i18n.skope['once published.']
7392
+ ].join(' ') );
7393
+ }
7394
+ } else {
7395
+ if ( _hasDBVal ) {
7396
+ if ( 'global' == api.czr_skope( _inheritedFromSkopeId )().skope ) {
7397
+ _html.push( [
7398
+ serverControlParams.i18n.skope['Customized and applied sitewide.'],
7399
+ ].join(' ') );
7400
+ } else {
7401
+ _html.push( [
7402
+ serverControlParams.i18n.skope['Customized and applied to'],
7403
+ '<strong>' + _ctxTitle + '.' + '</strong>'
7404
+ ].join(' ') );
7405
+ }
7406
+ } else {
7407
+ _html.push( serverControlParams.i18n.skope['Default website value applied sitewide.'] );
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
+
7415
+ _ctxTitle = api.czr_skope( _currentSkopeId )().ctx_title;
7416
+
7417
+ _ctxTitle = ( _.isString( _ctxTitle ) ? _ctxTitle : '' ).toLowerCase();
7418
+
7419
+ if ( ! _isCustomized && ! _hasDBVal ) {
7420
+ _html.push(
7421
+ [
7422
+ serverControlParams.i18n.skope['Default website value.'],
7423
+ serverControlParams.i18n.skope['You can customize this specifically for'],
7424
+ '<strong>' + _ctxTitle + '.' + '</strong>'
7425
+ ].join(' ')
7426
+ );
7427
+ } else {
7428
+ _html.push(
7429
+ [
7430
+ serverControlParams.i18n.skope['Currently inherited from'],
7431
+ self.buildSkopeLink( _inheritedFromSkopeId ) + '.',
7432
+ serverControlParams.i18n.skope['You can customize this specifically for'],
7433
+ '<strong>' + _ctxTitle + '.' + '</strong>'
7434
+ ].join(' ')
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;
7442
+
7443
+ _ctxTitle = ( _.isString( _ctxTitle ) ? _ctxTitle : '' ).toLowerCase();
7444
+
7445
+ _html.push( [
7446
+ ! _isCustomized ? serverControlParams.i18n.skope['The value currently applied to'] : serverControlParams.i18n.skope['The value that will be applied to'],
7447
+ '<strong>' + _ctxTitle + '</strong>',
7448
+ ! _isCustomized ? serverControlParams.i18n.skope['is set in'] : serverControlParams.i18n.skope['is customized in'],
7449
+ self.buildSkopeLink( _overridedBySkopeId ),
7450
+ serverControlParams.i18n.skope['which has a higher priority than the current option scope'],
7451
+ '<strong>( ' + api.czr_skope( _currentSkopeId )().title + ' ).</strong>'
7452
+ ].join(' ') );
7453
  }
 
7454
 
7455
+ return _html.join(' | ');
7456
+ };//_generateControlNotice
7457
 
7458
 
7459
+ _.each( controlIds, function( _id ) {
7460
+ api.control.when( _id, function() {
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
 
7467
+ ctrl.deferred.embedded.then( function() {
7468
+ var _localSkopeId = _.findWhere( api.czr_currentSkopesCollection(), { skope : 'local' } ).id,
7469
+ $noticeContainer = ctrl.getNotificationsContainerElement();
 
 
 
 
 
 
7470
 
7471
+ if ( ! $noticeContainer || ! $noticeContainer.length || _.isUndefined( _localSkopeId ) )
7472
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7473
 
7474
+ try {
7475
+ _html = _generateControlNotice( setId, _localSkopeId );
7476
+ } catch ( er ) {
7477
+ api.errorLog( '_generateControlNotice : ' + er );
7478
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7479
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7480
 
7481
+ var $skopeNoticeEl = $( '.czr-skope-notice', $noticeContainer );
7482
+ if ( $skopeNoticeEl.length ) {
7483
+ $skopeNoticeEl.html( _html );
7484
+ } else {
7485
+ $noticeContainer.append(
7486
+ [ '<span class="czr-notice czr-skope-notice">', _html ,'</span>' ].join('')
7487
+ );
7488
+ }
7489
+ });
7490
+ });
7491
+ });
7492
+ },//updateCtrlSkpNot
7493
+ isCtrlNoticeVisible : function( ctrlId ) {
7494
+ if ( ! api.control.has( ctrlId ) )
7495
+ return false;
7496
+
7497
+ var self = this,
7498
+ setId = api.CZR_Helpers.getControlSettingId( ctrlId ),//get the relevant setting_id for this control
7499
+ _currentSkopeId = api.czr_activeSkopeId(),
7500
+ _overridedBySkopeId = self.getAppliedPrioritySkopeId( setId, _currentSkopeId ),
7501
+ _isSkoped = function( setId ) {
7502
+ return setId && self.isSettingSkopeEligible( setId );
7503
+ };//filter only eligible ctrlIds
7504
 
7505
+ if ( 'global' != api.czr_skope( _currentSkopeId )().skope ) {
7506
+ return true;
7507
+ } else if ( _overridedBySkopeId !== _currentSkopeId && api.czr_skope.has( _overridedBySkopeId ) ) {
7508
+ return true;
7509
+ }
7510
+ return false;
7511
+ },
7512
+ removeCtrlSkpNot : function( controlIdCandidates ) {
7513
+ var self = this,
7514
+ controlIds = _.isArray(controlIdCandidates) ? controlIdCandidates : [controlIdCandidates];
 
 
 
 
 
 
 
 
 
 
 
 
 
7515
 
7516
+ _.each( controlIds, function( _id ) {
7517
+ api.control.when( _id, function() {
7518
+ var ctrl = api.control( _id );
7519
 
7520
+ ctrl.deferred.embedded.then( function() {
7521
+ var $noticeContainer = ctrl.getNotificationsContainerElement();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7522
 
7523
+ if ( ! $noticeContainer || ! $noticeContainer.length )
7524
+ return;
7525
+
7526
+ var $skopeNoticeEl = $( '.czr-skope-notice', $noticeContainer );
7527
+ if ( $skopeNoticeEl.length )
7528
+ $skopeNoticeEl.remove();
7529
+ });
7530
+ });
7531
+ });
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, {
8047
+ initialize: function() {
8048
+ var self = this;
8049
+ self.previewer = api.previewer;
8050
+ api.state.create('czr-resetting')(false);
8051
+ api.state('czr-resetting').bind( function( state ) {
8052
+ $( document.body ).toggleClass( 'czr-resetting', false !== state );
8053
+ });
8054
+ },
8055
+ resetChangeset : function( args ) {
8056
+ var dfd = $.Deferred(),
8057
+ self = this,
8058
+ processing = api.state( 'processing' ),
8059
+ submitWhenPossible,
8060
+ submit_reset,
8061
+ request,
8062
+ requestAjaxAction,
8063
+ query_params,
8064
+ query,
8065
+ defaults = {
8066
+ is_setting : false,
8067
+ is_skope : false,
8068
+ skope_id : api.czr_activeSkopeId() || '',
8069
+ setId : ''
8070
+ };
8071
+
8072
+ args = _.extend( defaults, args );
8073
+ var skope_id = args.skope_id,
8074
+ setId = args.setId;
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'
8086
+ };
8087
+ query = $.extend(
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';
8094
+ } else if ( args.is_skope ) {
8095
+ requestAjaxAction = 'czr_changeset_skope_reset';
8096
+ } else {
8097
+ return dfd.reject( 'reset_ajax_action_not_specified' ).promise();
8098
+ }
8099
+
8100
+ wp.ajax.post( requestAjaxAction , query )
8101
+ .always( function () {
8102
+ api.state( 'czr-resetting' )( false );
8103
+ })
8104
+ .fail( function ( response ) {
8105
+ if ( '0' === response ) {
8106
+ response = 'not_logged_in';
8107
+ } else if ( '-1' === response ) {
8108
+ response = 'invalid_nonce';
8109
+ }
8110
+
8111
+ if ( 'invalid_nonce' === response ) {
8112
+ self.previewer.cheatin();
8113
+ } else if ( 'not_logged_in' === response ) {
8114
+ self.previewer.preview.iframe.hide();
8115
+ self.previewer.login().done( function() {
8116
+ self.resetChangeset( args );
8117
+ self.previewer.preview.iframe.show();
8118
+ } );
8119
+ }
8120
+ api.consoleLog( requestAjaxAction + ' failed ', query, response );
8121
+ response = api.czr_skopeBase.buildServerResponse( response );
8122
+ api.trigger( 'error', response );
8123
+
8124
+ api.czr_serverNotification( { message: response, status : 'error' } );
8125
+ dfd.reject( response );
8126
+ })
8127
+ .done( function( response ) {
8128
+ dfd.resolve( response );
8129
+ });
8130
+ };//submit_reset()
8131
+
8132
+ if ( 0 === processing() && false === api.state( 'czr-resetting' )() ) {
8133
+ submit_reset( skope_id, setId );
8134
+ } else {
8135
+ submitWhenPossible = function () {
8136
+ if ( 0 === processing() && false === api.state( 'czr-resetting' )() ) {
8137
+ api.state.unbind( 'change', submitWhenPossible );
8138
+ submit_reset( skope_id, setId );
8139
+ }
8140
+ };
8141
+ api.state.bind( 'change', submitWhenPossible );
8142
+ }
8143
+
8144
+ return dfd.promise();
8145
  },
8146
+ resetPublished : function( args ) {
8147
+ var dfd = $.Deferred(),
8148
+ self = this,
8149
+ processing = api.state( 'processing' ),
8150
+ submitWhenPossible,
8151
+ submit_reset,
8152
+ request,
8153
+ requestAjaxAction,
8154
+ query_params,
8155
+ query,
8156
+ defaults = {
8157
+ is_setting : false,
8158
+ is_skope : false,
8159
+ skope_id : api.czr_activeSkopeId() || '',
8160
+ setId : ''
8161
+ };
8162
+
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'
8174
+ };
8175
+ query = $.extend(
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';
8182
+ } else if ( args.is_skope ) {
8183
+ requestAjaxAction = 'czr_published_skope_reset';
8184
+ } else {
8185
+ return dfd.reject( 'reset_ajax_action_not_specified' ).promise();
8186
+ }
8187
+
8188
+ api.consoleLog('in czr_reset submit : ', skope_id, query );
8189
+
8190
+ wp.ajax.post( requestAjaxAction , query )
8191
+ .always( function () {
8192
+ api.state( 'czr-resetting' )( false );
8193
+ })
8194
+ .fail( function ( response ) {
8195
+ if ( '0' === response ) {
8196
+ response = 'not_logged_in';
8197
+ } else if ( '-1' === response ) {
8198
+ response = 'invalid_nonce';
8199
+ }
8200
 
8201
+ if ( 'invalid_nonce' === response ) {
8202
+ self.previewer.cheatin();
8203
+ } else if ( 'not_logged_in' === response ) {
8204
+ self.previewer.preview.iframe.hide();
8205
+ self.previewer.login().done( function() {
8206
+ self.resetChangeset( args );
8207
+ self.previewer.preview.iframe.show();
8208
+ } );
8209
+ }
8210
+ api.consoleLog( requestAjaxAction + ' failed ', query, response );
8211
+ response = api.czr_skopeBase.buildServerResponse( response );
8212
+ api.trigger( 'error', response );
8213
 
8214
+ api.czr_serverNotification( { message: response, status : 'error' } );
8215
+ dfd.reject( response );
8216
+ })
8217
+ .done( function( response ) {
8218
+ dfd.resolve( response );
8219
+ });
8220
 
8221
+ };//submit_reset()
8222
 
8223
+ if ( 0 === processing() && false === api.state( 'czr-resetting' )() ) {
8224
+ submit_reset( skope_id, setId );
8225
+ } else {
8226
+ submitWhenPossible = function () {
8227
+ if ( 0 === processing() && false === api.state( 'czr-resetting' )() ) {
8228
+ api.state.unbind( 'change', submitWhenPossible );
8229
+ submit_reset( skope_id, setId );
8230
+ }
8231
+ };
8232
+ api.state.bind( 'change', submitWhenPossible );
8233
+ }
8234
 
8235
+ return dfd.promise();
8236
+ }
8237
+ });//$.extend
8238
+ })( wp.customize , jQuery, _ );
8239
 
8240
+ var CZRSkopeBaseMths = CZRSkopeBaseMths || {};
8241
+ ( function ( api, $, _ ) {
8242
+ $.extend( CZRSkopeBaseMths, {
8243
+ initWidgetSidebarSpecifics : function() {
8244
+ var self = this;
8245
+ if ( ! self.isExcludedSidebarsWidgets() ) {
8246
+ api.czr_activeSkopeId.bind( function( active_skope ) {
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);
8258
+ } else {
8259
+ self.listenAPISettings( wdgtSetId );
8260
+ }
8261
+ });
8262
+ },
8263
 
8264