PluginProbe ʕ •ᴥ•ʔ
YITH WooCommerce Wishlist / 3.18.0
YITH WooCommerce Wishlist v3.18.0
4.16.0 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.25 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.10.0 3.11.0 3.12.0 3.13.0 3.14.0 3.15.0 3.16.0 3.17.0 3.18.0 3.19.0 3.2.0 3.20.0 3.21.0 3.22.0 3.23.0 3.24.0 3.25.0 3.26.0 3.27.0 3.28.0 3.29.0 3.3.0 3.30.0 3.31.0 3.32.0 3.33.0 3.34.0 3.35.0 3.36.0 3.37.0 3.38.0 3.4.0 3.5.0 3.6.0 3.7.0 3.8.0 3.9.0 4.0.0 4.0.1 4.1.0 4.10.0 4.10.1 4.10.2 4.11.0 4.12.0 4.13.0 4.14.0 4.15.0 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.8.0 4.9.0
yith-woocommerce-wishlist / assets / js / unminified / admin / yith-wcwl.js
yith-woocommerce-wishlist / assets / js / unminified / admin Last commit date
yith-wcwl.js 3 years ago
yith-wcwl.js
413 lines
1 /**
2 * Admin YITH WooCommerce Wishlist JS
3 *
4 * @author YITH
5 * @package YITH WooCommerce Wishlist
6 * @version 3.0.0
7 */
8
9 jQuery( function( $ ) {
10
11 /* === CUSTOM DEPENDENCIES HANDLER === */
12
13 $.fn.dependency = function (deps, test, complete, args) {
14 var t = $(this);
15
16 t.on('change', function () {
17 var val = test(t);
18
19 $.each(deps, function (i, v) {
20 var elem = $(v);
21
22 if (!elem.length) {
23 return;
24 }
25
26 var target = elem.closest('tr');
27
28 if (!target.length) {
29 return;
30 }
31
32 if( val ){
33 target.show().fadeTo("slow", 1);
34 }
35 else{
36 target.is( ':visible' ) ? target.fadeTo("slow", 0, function(){ target.hide() }) : target.css('opacity', 0).hide();
37 }
38
39 // val ? target.removeClass('yith-disabled') : target.addClass('yith-disabled');
40 });
41
42 if (typeof complete != 'undefined') {
43 complete(t, args);
44 }
45 }).change();
46 };
47
48 /* === UTILITY FUNCTIONS === */
49
50 var isRadioYes = function (t) {
51 if( ! t.is( 'input[type="radio"]' ) ){
52 t = t.find( 'input[type="radio"]:checked' );
53 }
54
55 return t.val() === 'yes';
56 },
57 isRadioNo = function (t) {
58 if( ! t.is( 'input[type="radio"]' ) ){
59 t = t.find( 'input[type="radio"]:checked' );
60 }
61
62 return t.val() === 'no';
63 },
64 isChecked = function (t) {
65 return t.is(':checked');
66 };
67
68 /* === SETTINGS HANDLING === */
69
70 var disable_wishlist_for_unauthenticated_users = $('#yith_wcwl_disable_wishlist_for_unauthenticated_users'),
71 multi_wishlist_enable = $('#yith_wcwl_multi_wishlist_enable'),
72 enable_multi_wishlist_for_unauthenticated_users = $('#yith_wcwl_enable_multi_wishlist_for_unauthenticated_users'),
73 modal_enable = $('#yith_wcwl_modal_enable'),
74 loop_position = $('#yith_wcwl_loop_position'),
75 icon_select = $('.icon-select'),
76 add_to_cart_style = $('[name="yith_wcwl_add_to_cart_style"]'),
77 add_to_cart_icon = $('#yith_wcwl_add_to_cart_icon'),
78 ask_an_estimate_style = $('[name="yith_wcwl_ask_an_estimate_style"]'),
79 ask_an_estimate_icon = $('#yith_wcwl_ask_an_estimate_icon'),
80 enable_share = $('#yith_wcwl_enable_share'),
81 share_facebook = $('#yith_wcwl_share_fb'),
82 share_facebook_icon = $('#yith_wcwl_fb_button_icon'),
83 share_twitter = $('#yith_wcwl_share_twitter'),
84 share_twitter_icon = $('#yith_wcwl_tw_button_icon'),
85 share_pinterest = $('#yith_wcwl_share_pinterest'),
86 share_pinterest_icon = $('#yith_wcwl_pr_button_icon'),
87 share_email = $('#yith_wcwl_share_email'),
88 share_email_icon = $('#yith_wcwl_em_button_icon'),
89 share_whatsapp = $('#yith_wcwl_share_whatsapp'),
90 share_whatsapp_icon = $('#yith_wcwl_wa_button_icon'),
91 show_estimate_button = $('#yith_wcwl_show_estimate_button'),
92 show_additional_info_textarea = $('#yith_wcwl_show_additional_info_textarea'),
93 ask_an_estimate_fields = $('#yith_wcwl_ask_an_estimate_fields'),
94 promotion_mail_type = $('#woocommerce_promotion_mail_settings\\[email_type\\]'),
95 back_in_stock_mail_enabled = $('#woocommerce_yith_wcwl_back_in_stock_settings\\[enabled\\]'),
96 back_in_stock_mail_type = $('#woocommerce_yith_wcwl_back_in_stock_settings\\[email_type\\]'),
97 on_sale_item_mail_enabled = $('#woocommerce_yith_wcwl_on_sale_item_settings\\[enabled\\]'),
98 on_sale_item_mail_type = $('#woocommerce_yith_wcwl_on_sale_item_settings\\[email_type\\]'),
99 ask_an_estimate_type = $('[id^="type_"]');
100
101 loop_position.add('select#yith_wcwl_button_position').on('change', function () {
102 var t = $(this),
103 v = t.val();
104
105 if ('shortcode' === v) {
106 t.parent().next().find('.addon').show();
107 } else {
108 t.parent().next().find('.addon').hide();
109 }
110 }).change();
111
112 ask_an_estimate_type.on( 'change', function(){
113 var t = $(this),
114 v = t.val(),
115 options_field = t.closest( '.yith-toggle-content-row' ).next();
116
117 if( v === 'radio' || v === 'select' ){
118 options_field.show().fadeTo('slow' , 1);
119 }
120 else{
121 options_field.is( ':visible' ) ? options_field.fadeTo('slow', 0, function(){ options_field.hide() }) : options_field.css('opacity', 0).hide();
122 }
123 } ).change();
124
125 add_to_cart_style.on( 'change', function(){
126 add_to_cart_icon.change();
127 } );
128
129 ask_an_estimate_style.on( 'change', function(){
130 ask_an_estimate_icon.change();
131 } );
132
133 icon_select.each( function(){
134 var t = $(this),
135 renderOption = function (state) {
136 if ( ! state.id ) {
137 return state.text;
138 }
139 return $(
140 '<span><i class="option-icon fa ' + state.element.value.toLowerCase() + '" ></i> ' + state.text + '</span>'
141 );
142 };
143
144 t.select2({
145 templateResult: renderOption
146 });
147 } );
148
149 disable_wishlist_for_unauthenticated_users.dependency([
150 '#yith_wcwl_enable_multi_wishlist_for_unauthenticated_users-yes'
151 ], function(){
152 return isRadioNo( disable_wishlist_for_unauthenticated_users ) && isChecked( multi_wishlist_enable );
153 }, function(){
154 enable_multi_wishlist_for_unauthenticated_users.change();
155 } );
156
157 multi_wishlist_enable.dependency([
158 '#yith_wcwl_enable_multi_wishlist_for_unauthenticated_users-yes'
159 ], function(){
160 return isRadioNo( disable_wishlist_for_unauthenticated_users ) && isChecked( multi_wishlist_enable );
161 }, function(){
162 enable_multi_wishlist_for_unauthenticated_users.change();
163 } );
164
165 enable_multi_wishlist_for_unauthenticated_users.dependency([
166 '#yith_wcwl_show_login_notice',
167 '#yith_wcwl_login_anchor_text'
168 ], function(){
169 return isChecked( multi_wishlist_enable ) && isRadioNo( disable_wishlist_for_unauthenticated_users ) && isRadioNo( enable_multi_wishlist_for_unauthenticated_users );
170 });
171
172 modal_enable.dependency([
173 '#yith_wcwl_show_exists_in_a_wishlist'
174 ], function(){
175 var res = modal_enable.find( ':checked' ).val() !== 'default';
176
177 if( ! res ){
178 $('#yith_wcwl_show_exists_in_a_wishlist').prop( 'checked', true );
179 }
180
181 return res;
182 } );
183
184 add_to_cart_icon.dependency([
185 '#yith_wcwl_add_to_cart_custom_icon'
186 ], function(){
187 return 'custom' === add_to_cart_icon.val() && 'button_custom' === add_to_cart_style.filter(':checked').val();
188 } );
189
190 ask_an_estimate_icon.dependency([
191 '#yith_wcwl_ask_an_estimate_custom_icon'
192 ], function(){
193 return 'custom' === ask_an_estimate_icon.val() && 'button_custom' === ask_an_estimate_style.filter(':checked').val();
194 } );
195
196 enable_share.dependency([
197 '#yith_wcwl_share_fb'
198 ], isChecked, function(){
199 share_facebook.change();
200 share_facebook_icon.change();
201 share_twitter.change();
202 share_twitter_icon.change();
203 share_pinterest.change();
204 share_pinterest_icon.change();
205 share_email.change();
206 share_email_icon.change();
207 share_whatsapp.change();
208 share_whatsapp_icon.change();
209 } );
210
211 share_facebook.dependency([
212 '#yith_wcwl_fb_button_icon',
213 '#yith_wcwl_color_fb_button_background'
214 ], function(){
215 return isChecked( share_facebook ) && isChecked( enable_share )
216 }, function(){
217 share_facebook_icon.change();
218 } );
219
220 share_facebook_icon.dependency([
221 '#yith_wcwl_fb_button_custom_icon'
222 ], function(){
223 return isChecked( share_facebook ) && isChecked( enable_share ) && 'custom' === share_facebook_icon.val();
224 } );
225
226 share_twitter.dependency([
227 '#yith_wcwl_tw_button_icon',
228 '#yith_wcwl_color_tw_button_background'
229 ], function(){
230 return isChecked( share_twitter ) && isChecked( enable_share )
231 }, function(){
232 share_twitter_icon.change();
233 } );
234
235 share_twitter_icon.dependency([
236 '#yith_wcwl_tw_button_custom_icon'
237 ], function(){
238 return isChecked( share_twitter ) && isChecked( enable_share ) && 'custom' === share_twitter_icon.val();
239 } );
240
241 share_pinterest.dependency([
242 '#yith_wcwl_socials_image_url',
243 '#yith_wcwl_pr_button_icon',
244 '#yith_wcwl_color_pr_button_background'
245 ], function(){
246 return isChecked( share_pinterest ) && isChecked( enable_share )
247 }, function(){
248 share_pinterest_icon.change();
249 } );
250
251 share_pinterest_icon.dependency([
252 '#yith_wcwl_pr_button_custom_icon'
253 ], function(){
254 return isChecked( share_pinterest ) && isChecked( enable_share ) && 'custom' === share_pinterest_icon.val();
255 } );
256
257 share_email.dependency([
258 '#yith_wcwl_em_button_icon',
259 '#yith_wcwl_color_em_button_background'
260 ], function(){
261 return isChecked( share_email ) && isChecked( enable_share )
262 }, function(){
263 share_email_icon.change();
264 } );
265
266 share_email_icon.dependency([
267 '#yith_wcwl_em_button_custom_icon'
268 ], function(){
269 return isChecked( share_email ) && isChecked( enable_share ) && 'custom' === share_email_icon.val();
270 } );
271
272 share_whatsapp.dependency([
273 '#yith_wcwl_wa_button_icon',
274 '#yith_wcwl_wa_button_custom_icon',
275 '#yith_wcwl_color_wa_button_background'
276 ], function(){
277 return isChecked( share_whatsapp ) && isChecked( enable_share )
278 }, function(){
279 share_whatsapp_icon.change();
280 } );
281
282 share_whatsapp_icon.dependency([
283 '#yith_wcwl_wa_button_custom_icon'
284 ], function(){
285 return isChecked( share_whatsapp ) && isChecked( enable_share ) && 'custom' === share_whatsapp_icon.val();
286 } );
287
288 share_twitter.add( share_pinterest ).dependency([
289 '#yith_wcwl_socials_title',
290 '#yith_wcwl_socials_text'
291 ], function(){
292 return ( isChecked( share_twitter ) || isChecked( share_pinterest ) ) && isChecked( enable_share )
293 });
294
295 show_estimate_button.dependency([
296 '#yith_wcwl_show_additional_info_textarea'
297 ], isChecked, function(){
298 show_additional_info_textarea.change()
299 } );
300
301 show_estimate_button.on( 'change', function(){
302 show_additional_info_textarea.change();
303 } );
304
305 show_additional_info_textarea.dependency([
306 '#yith_wcwl_additional_info_textarea_label'
307 ], function(){
308 return isChecked( show_estimate_button ) && isChecked( show_additional_info_textarea )
309 } );
310
311 show_additional_info_textarea.on( 'change', function(){
312 var t = $(this);
313
314 if( t.is(':checked') && show_estimate_button.is(':checked') ){
315 ask_an_estimate_fields.removeClass( 'yith-disabled' );
316 }
317 else {
318 ask_an_estimate_fields.addClass( 'yith-disabled' );
319 }
320 } );
321
322 promotion_mail_type.dependency([
323 '#woocommerce_promotion_mail_settings\\[content_html\\]'
324 ], function(){
325 return 'multipart' === promotion_mail_type.val() || 'html' === promotion_mail_type.val()
326 } );
327
328 promotion_mail_type.dependency([
329 '#woocommerce_promotion_mail_settings\\[content_text\\]'
330 ], function(){
331 return 'multipart' === promotion_mail_type.val() || 'plain' === promotion_mail_type.val()
332 } );
333
334 back_in_stock_mail_enabled.dependency([
335 '#woocommerce_yith_wcwl_back_in_stock_settings\\[product_exclusions\\]',
336 '#woocommerce_yith_wcwl_back_in_stock_settings\\[category_exclusions\\]',
337 '#woocommerce_yith_wcwl_back_in_stock_settings\\[email_type\\]',
338 '#woocommerce_yith_wcwl_back_in_stock_settings\\[heading\\]',
339 '#woocommerce_yith_wcwl_back_in_stock_settings\\[subject\\]',
340 '#woocommerce_yith_wcwl_back_in_stock_settings\\[content_html\\]',
341 '#woocommerce_yith_wcwl_back_in_stock_settings\\[content_text\\]'
342 ], function(){
343 return isChecked( back_in_stock_mail_enabled )
344 }, function(){
345 back_in_stock_mail_type.change();
346 } );
347
348 back_in_stock_mail_type.dependency([
349 '#woocommerce_yith_wcwl_back_in_stock_settings\\[content_html\\]'
350 ], function(){
351 return ( 'multipart' === back_in_stock_mail_type.val() || 'html' === back_in_stock_mail_type.val() ) && isChecked( back_in_stock_mail_enabled )
352 } );
353
354 back_in_stock_mail_type.dependency([
355 '#woocommerce_yith_wcwl_back_in_stock_settings\\[content_text\\]'
356 ], function(){
357 return ( 'multipart' === back_in_stock_mail_type.val() || 'plain' === back_in_stock_mail_type.val() ) && isChecked( back_in_stock_mail_enabled )
358 } );
359
360 on_sale_item_mail_enabled.dependency([
361 '#woocommerce_yith_wcwl_on_sale_item_settings\\[product_exclusions\\]',
362 '#woocommerce_yith_wcwl_on_sale_item_settings\\[category_exclusions\\]',
363 '#woocommerce_yith_wcwl_on_sale_item_settings\\[email_type\\]',
364 '#woocommerce_yith_wcwl_on_sale_item_settings\\[heading\\]',
365 '#woocommerce_yith_wcwl_on_sale_item_settings\\[subject\\]',
366 '#woocommerce_yith_wcwl_on_sale_item_settings\\[content_html\\]',
367 '#woocommerce_yith_wcwl_on_sale_item_settings\\[content_text\\]'
368 ], function(){
369 return isChecked( on_sale_item_mail_enabled )
370 }, function(){
371 on_sale_item_mail_type.change();
372 } );
373
374 on_sale_item_mail_type.dependency([
375 '#woocommerce_yith_wcwl_on_sale_item_settings\\[content_html\\]'
376 ], function(){
377 return ( 'multipart' === on_sale_item_mail_type.val() || 'html' === on_sale_item_mail_type.val() ) && isChecked( on_sale_item_mail_enabled )
378 } );
379
380 on_sale_item_mail_type.dependency([
381 '#woocommerce_yith_wcwl_on_sale_item_settings\\[content_text\\]'
382 ], function(){
383 return ( 'multipart' === on_sale_item_mail_type.val() || 'plain' === on_sale_item_mail_type.val() ) && isChecked( on_sale_item_mail_enabled )
384 } );
385
386 /* === DATEPICKER === */
387
388 // commissions filter
389 $( ".date-picker-field, .date-picker" ).datepicker ({
390 dateFormat: "yy-mm-dd",
391 numberOfMonths: 1,
392 showButtonPanel: true
393 } );
394
395 /* === TOGGLE BOX HANDLING === */
396
397 $(document).on( 'yith-add-box-button-toggle', function(){
398 var ask_an_estimate_type_new = $('#new_type'),
399 ask_an_estimate_options_new = $('#new_options'),
400 target = ask_an_estimate_options_new.closest('.yith-add-box-row');
401
402 ask_an_estimate_type_new.on( 'change', function(){
403 var v = ask_an_estimate_type_new.val();
404
405 if( v === 'radio' || v === 'select' ){
406 target.show().fadeTo('slow', 1);
407 }
408 else{
409 target.is( ':visible' ) ? target.fadeTo('slow', 0, function(){ $(this).hide() }) : target.css('opacity', 0).hide();
410 }
411 } ).change();
412 } );
413 } );