PluginProbe ʕ •ᴥ•ʔ
YITH WooCommerce Wishlist / 3.0.17
YITH WooCommerce Wishlist v3.0.17
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 5 years ago
yith-wcwl.js
747 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 /* === PROMOTION WIZARD HANDLER === */
49
50 var Wizard = function( el, args ){
51 var self = this;
52
53 self.settings = {};
54
55 self.modal = null;
56
57 self._init = function(){
58 self.settings = $.extend( {
59 template: el.data('template'),
60 template_data: {},
61 container: '.yith-wcwl-wizard-modal',
62 events: {}
63 }, args );
64
65 if( typeof self.settings.events['init'] === 'function' ){
66 self.settings.events.init( el, args );
67 }
68
69 self._initOpener();
70 };
71
72 self._initOpener = function(){
73 el.on( 'click', function( ev ){
74 var t = $(this),
75 settings = self.settings.template_data;
76
77 ev.preventDefault();
78
79 // init opener-specific template data
80 if( typeof settings === 'function' ){
81 settings = ( settings )( t );
82 }
83
84 t.WCBackboneModal({
85 template: self.settings.template,
86 variable: settings
87 });
88
89 var container = $( self.settings.container );
90
91 self._initEditor( container );
92 self._initEnhancedSelect( container );
93 self._initTabs( container );
94 self._initSteps( container );
95 self._initOptions( container, settings );
96 self._initEvents( container, self.settings.events );
97 } );
98 };
99
100 self._initEditor = function( modal ){
101 modal.find( '.with-editor' ).each( function(){
102 var t = $(this),
103 id = t.attr('id');
104
105 // Destroy any existing editor so that it can be re-initialized when popup opens.
106 if ( tinymce.get( id ) ) {
107 restoreTextMode = tinymce.get( id ).isHidden();
108 wp.editor.remove( id );
109 }
110
111 wp.editor.initialize( id, {
112 tinymce: {
113 wpautop: true,
114 init_instance_callback: function (editor) {
115 editor.on('Change', function (e) {
116 t.val( editor.getContent() ).change();
117 });
118 }
119 },
120 quicktags: true,
121 mediaButtons: true
122 } );
123 } )
124 };
125
126 self._initEnhancedSelect = function( modal ){
127 $(document.body).trigger( 'wc-enhanced-select-init' );
128 };
129
130 self._initTabs = function( modal ){
131 modal.find( '.tabs' ).on( 'click', 'a', function( ev ){
132 var t = $(this),
133 ul = t.closest('ul'),
134 a = ul.find( 'a' ),
135 p = ul.parent(),
136 tabs = p.find( '.tab' ),
137 target = t.data( 'target' ),
138 tab = $( target ),
139 changed = false;
140
141 ev.preventDefault();
142
143 if( ! t.hasClass( 'active' ) ){
144 changed = true;
145 }
146
147 a.attr( 'aria-selected', 'false' ).removeClass( 'active' );
148 t.attr( 'aria-selected', 'true' ).addClass( 'active' );
149
150 tabs.attr( 'aria-expanded', 'false' ).removeClass( 'active' ).hide();
151 tab.attr( 'aria-expanded', 'true' ).addClass( 'active' ).show();
152
153 if( changed ){
154 t.trigger( 'tabChange' );
155 }
156 } );
157 };
158
159 self._initOptions = function( modal, values ){
160 $.each( values, function( i, v ){
161 var field = modal.find( '[name="' + i + '"]' );
162
163 if( ! field.length || v === field.val() ){
164 return;
165 }
166
167 if( field.is( 'select' ) && ! field.find( 'option[value="' + v + '"]' ).length ){
168 field.append( '<option value="' + v + '" selected="selected">' + v + ' </option>' );
169 }
170 else {
171 field.val(v);
172 }
173 } );
174 };
175
176 self._initSteps = function( modal ){
177 // show only first step by default
178 modal.find( '.step' ).hide().first().show();
179
180 // init continue button
181 modal.find( '.continue-button' ).on( 'click', function( ev ){
182 var t = $(this),
183 current_step = t.closest( '.step' ),
184 next_step = current_step.next( '.step' );
185
186 ev.preventDefault();
187
188 if( next_step.length ) {
189 self._changeStep( modal, current_step, next_step );
190 }
191 } );
192
193 // init back button
194 modal.find( '.back-button' ).on( 'click', function( ev ){
195 var t = $(this),
196 current_step = t.closest( '.step' ),
197 prev_step = current_step.prev( '.step' );
198
199 ev.preventDefault();
200
201 if( prev_step.length ) {
202 self._changeStep( modal, current_step, prev_step );
203 }
204 } );
205 };
206
207 self._initEvents = function( modal, events ){
208 if( typeof self.settings.events['open'] === 'function' ){
209 self.settings.events.open( el, modal );
210 }
211
212 $.each( events, function( i, v ){
213 var target = null;
214
215 // exclude general events
216 if( i === 'init' || i === 'open' ){
217 return;
218 }
219
220 // tab events
221 else if( i === 'tabChange' ){
222 target = modal.find( '.tabs' );
223 }
224
225 // step events
226 else if( i === 'stepChange' ){
227 target = modal.find( '.step' );
228 }
229
230 // input changes
231 else{
232 target = modal.find( ':input' );
233 }
234
235 target.on( i, function( ev ){
236 return ( v )( $(this), modal, ev );
237 } );
238 } );
239 };
240
241 self._changeStep = function( modal, current, next ){
242 current.animate( {
243 opacity: 0
244 }, {
245 duration: 200,
246 complete: function(){
247 var modalContent = modal.find( 'article' ),
248 modalContentWidth = modalContent.outerWidth(),
249 modalContentHeight = modalContent.outerHeight();
250
251 // calculate step size
252 modalContent.outerWidth( 'auto' );
253 modalContent.outerHeight( 'auto' );
254
255 current.hide();
256 next.show();
257
258 var nextWidth = next.outerWidth(),
259 nextHeight = next.outerHeight();
260
261 next.hide();
262 current.css( 'opacity', 1 );
263
264 // fix modal size
265 modalContent.outerWidth( modalContentWidth );
266 modalContent.outerHeight( modalContentHeight );
267
268 modalContent.animate( {
269 width: nextWidth,
270 height: nextHeight
271 }, {
272 duration: 200,
273 complete: function(){
274 next.fadeIn( 200 );
275 }
276 } );
277 }
278 } );
279
280 next.trigger( 'stepChange' );
281 };
282
283 self._init();
284 },
285 updatePreviewXHR = null,
286 updatePreview = function( el, modal, ev ){
287 var preview = modal.find( '.email-preview' ),
288 template = modal.find('#template').val();
289
290 if( updatePreviewXHR ){
291 updatePreviewXHR.abort();
292 }
293
294 updatePreviewXHR = $.ajax( {
295 url: ajaxurl + '?action=preview_promotion_email',
296 data: modal.find('form').serialize(),
297 method: 'POST',
298 beforeSend: function(){
299 preview.block({
300 message: null,
301 overlayCSS: {
302 background: 'transparent',
303 opacity: 0.6
304 }
305 });
306 },
307 complete: function(){
308 preview.unblock();
309 },
310 success: function( data ){
311 preview.removeClass( 'html plain' ).addClass( template ).find('.no-interactions').html( data );
312 }
313 } );
314 },
315 getPromotionWizardData = function(){
316 return {
317 template: 'yith-wcwl-promotion-wizard',
318 template_data: function( el ){
319 var data;
320
321 if( el.hasClass( 'restore-draft' ) ) {
322 data = el.data( 'draft' );
323 }
324 else{
325 data = $.extend( data, {
326 product_id: el.data('product_id'),
327 user_id : el.data('user_id')
328 } );
329 }
330
331 return data;
332 },
333 events: {
334 change: updatePreview,
335 open: function( el, modal, ev ){
336 modal.find( '#content_html-tmce' ).click();
337 updatePreview( el, modal, ev );
338 },
339 tabChange: function( el, modal, ev ){
340 modal.find( '#template' ).val( el.find( '.active' ).data( 'template' ) );
341 updatePreview( el, modal, ev );
342 },
343 stepChange: function( el, modal, ev ){
344 var counter = el.find( '.receivers-count' ),
345 additional_info = el.find( '.show-on-long-queue' ),
346 threshold = additional_info.data('threshold');
347
348 if( ! counter.length ){
349 return;
350 }
351
352 $.ajax({
353 url: ajaxurl + '?action=calculate_promotion_email_receivers',
354 data: modal.find('form').serialize(),
355 method: 'post',
356 beforeSend: function(){
357 counter.css( 'opacity', 0.3 );
358
359 if( additional_info.length ){
360 additional_info.hide();
361 }
362 },
363 complete: function(){
364 counter.css( 'opacity', 1 );
365 },
366 success: function( data ){
367 if( typeof data.label === 'undefined' ){
368 return;
369 }
370
371 counter.html( data.label );
372
373 if( additional_info.length && typeof data.count !== 'undefined' && data.count > threshold ){
374 additional_info.show();
375 }
376 }
377 });
378 }
379 }
380 }
381 };
382
383 $.fn.wizard = function ( args ) {
384 var t = $(this),
385 w = new Wizard( t, args );
386 };
387
388 $('.create-promotion').wizard( getPromotionWizardData() );
389 $('.restore-draft').wizard( getPromotionWizardData() );
390
391 /* === UTILITY FUNCTIONS === */
392
393 var isRadioYes = function (t) {
394 if( ! t.is( 'input[type="radio"]' ) ){
395 t = t.find( 'input[type="radio"]:checked' );
396 }
397
398 return t.val() === 'yes';
399 },
400 isRadioNo = function (t) {
401 if( ! t.is( 'input[type="radio"]' ) ){
402 t = t.find( 'input[type="radio"]:checked' );
403 }
404
405 return t.val() === 'no';
406 },
407 isChecked = function (t) {
408 return t.is(':checked');
409 };
410
411 /* === SETTINGS HANDLING === */
412
413 var disable_wishlist_for_unauthenticated_users = $('#yith_wcwl_disable_wishlist_for_unauthenticated_users'),
414 multi_wishlist_enable = $('#yith_wcwl_multi_wishlist_enable'),
415 enable_multi_wishlist_for_unauthenticated_users = $('#yith_wcwl_enable_multi_wishlist_for_unauthenticated_users'),
416 modal_enable = $('#yith_wcwl_modal_enable'),
417 loop_position = $('#yith_wcwl_loop_position'),
418 icon_select = $('.icon-select'),
419 add_to_cart_style = $('[name="yith_wcwl_add_to_cart_style"]'),
420 add_to_cart_icon = $('#yith_wcwl_add_to_cart_icon'),
421 ask_an_estimate_style = $('[name="yith_wcwl_ask_an_estimate_style"]'),
422 ask_an_estimate_icon = $('#yith_wcwl_ask_an_estimate_icon'),
423 enable_share = $('#yith_wcwl_enable_share'),
424 share_facebook = $('#yith_wcwl_share_fb'),
425 share_facebook_icon = $('#yith_wcwl_fb_button_icon'),
426 share_twitter = $('#yith_wcwl_share_twitter'),
427 share_twitter_icon = $('#yith_wcwl_tw_button_icon'),
428 share_pinterest = $('#yith_wcwl_share_pinterest'),
429 share_pinterest_icon = $('#yith_wcwl_pr_button_icon'),
430 share_email = $('#yith_wcwl_share_email'),
431 share_email_icon = $('#yith_wcwl_em_button_icon'),
432 share_whatsapp = $('#yith_wcwl_share_whatsapp'),
433 share_whatsapp_icon = $('#yith_wcwl_wa_button_icon'),
434 show_estimate_button = $('#yith_wcwl_show_estimate_button'),
435 show_additional_info_textarea = $('#yith_wcwl_show_additional_info_textarea'),
436 ask_an_estimate_fields = $('#yith_wcwl_ask_an_estimate_fields'),
437 promotion_mail_type = $('#woocommerce_promotion_mail_settings\\[email_type\\]'),
438 back_in_stock_mail_enabled = $('#woocommerce_yith_wcwl_back_in_stock_settings\\[enabled\\]'),
439 back_in_stock_mail_type = $('#woocommerce_yith_wcwl_back_in_stock_settings\\[email_type\\]'),
440 on_sale_item_mail_enabled = $('#woocommerce_yith_wcwl_on_sale_item_settings\\[enabled\\]'),
441 on_sale_item_mail_type = $('#woocommerce_yith_wcwl_on_sale_item_settings\\[email_type\\]'),
442 ask_an_estimate_type = $('[id^="type_"]');
443
444 loop_position.add('select#yith_wcwl_button_position').on('change', function () {
445 var t = $(this),
446 v = t.val();
447
448 if ('shortcode' === v) {
449 t.parent().next().find('.addon').show();
450 } else {
451 t.parent().next().find('.addon').hide();
452 }
453 }).change();
454
455 ask_an_estimate_type.on( 'change', function(){
456 var t = $(this),
457 v = t.val(),
458 options_field = t.closest( '.yith-toggle-content-row' ).next();
459
460 if( v === 'radio' || v === 'select' ){
461 options_field.show().fadeTo('slow' , 1);
462 }
463 else{
464 options_field.is( ':visible' ) ? options_field.fadeTo('slow', 0, function(){ options_field.hide() }) : options_field.css('opacity', 0).hide();
465 }
466 } ).change();
467
468 add_to_cart_style.on( 'change', function(){
469 add_to_cart_icon.change();
470 } );
471
472 ask_an_estimate_style.on( 'change', function(){
473 ask_an_estimate_icon.change();
474 } );
475
476 icon_select.each( function(){
477 var t = $(this),
478 renderOption = function (state) {
479 if ( ! state.id ) {
480 return state.text;
481 }
482 return $(
483 '<span><i class="option-icon fa ' + state.element.value.toLowerCase() + '" ></i> ' + state.text + '</span>'
484 );
485 };
486
487 t.select2({
488 templateResult: renderOption
489 });
490 } );
491
492 disable_wishlist_for_unauthenticated_users.dependency([
493 '#yith_wcwl_enable_multi_wishlist_for_unauthenticated_users-yes'
494 ], function(){
495 return isRadioNo( disable_wishlist_for_unauthenticated_users ) && isChecked( multi_wishlist_enable );
496 }, function(){
497 enable_multi_wishlist_for_unauthenticated_users.change();
498 } );
499
500 multi_wishlist_enable.dependency([
501 '#yith_wcwl_enable_multi_wishlist_for_unauthenticated_users-yes'
502 ], function(){
503 return isRadioNo( disable_wishlist_for_unauthenticated_users ) && isChecked( multi_wishlist_enable );
504 }, function(){
505 enable_multi_wishlist_for_unauthenticated_users.change();
506 } );
507
508 enable_multi_wishlist_for_unauthenticated_users.dependency([
509 '#yith_wcwl_show_login_notice',
510 '#yith_wcwl_login_anchor_text'
511 ], function(){
512 return isChecked( multi_wishlist_enable ) && isRadioNo( disable_wishlist_for_unauthenticated_users ) && isRadioNo( enable_multi_wishlist_for_unauthenticated_users );
513 });
514
515 modal_enable.dependency([
516 '#yith_wcwl_show_exists_in_a_wishlist'
517 ], function(){
518 var res = modal_enable.find( ':checked' ).val() !== 'default';
519
520 if( ! res ){
521 $('#yith_wcwl_show_exists_in_a_wishlist').prop( 'checked', true );
522 }
523
524 return res;
525 } );
526
527 add_to_cart_icon.dependency([
528 '#yith_wcwl_add_to_cart_custom_icon'
529 ], function(){
530 return 'custom' === add_to_cart_icon.val() && 'button_custom' === add_to_cart_style.filter(':checked').val();
531 } );
532
533 ask_an_estimate_icon.dependency([
534 '#yith_wcwl_ask_an_estimate_custom_icon'
535 ], function(){
536 return 'custom' === ask_an_estimate_icon.val() && 'button_custom' === ask_an_estimate_style.filter(':checked').val();
537 } );
538
539 enable_share.dependency([
540 '#yith_wcwl_share_fb'
541 ], isChecked, function(){
542 share_facebook.change();
543 share_facebook_icon.change();
544 share_twitter.change();
545 share_twitter_icon.change();
546 share_pinterest.change();
547 share_pinterest_icon.change();
548 share_email.change();
549 share_email_icon.change();
550 share_whatsapp.change();
551 share_whatsapp_icon.change();
552 } );
553
554 share_facebook.dependency([
555 '#yith_wcwl_fb_button_icon',
556 '#yith_wcwl_color_fb_button_background'
557 ], function(){
558 return isChecked( share_facebook ) && isChecked( enable_share )
559 }, function(){
560 share_facebook_icon.change();
561 } );
562
563 share_facebook_icon.dependency([
564 '#yith_wcwl_fb_button_custom_icon'
565 ], function(){
566 return isChecked( share_facebook ) && isChecked( enable_share ) && 'custom' === share_facebook_icon.val();
567 } );
568
569 share_twitter.dependency([
570 '#yith_wcwl_tw_button_icon',
571 '#yith_wcwl_color_tw_button_background'
572 ], function(){
573 return isChecked( share_twitter ) && isChecked( enable_share )
574 }, function(){
575 share_twitter_icon.change();
576 } );
577
578 share_twitter_icon.dependency([
579 '#yith_wcwl_tw_button_custom_icon'
580 ], function(){
581 return isChecked( share_twitter ) && isChecked( enable_share ) && 'custom' === share_twitter_icon.val();
582 } );
583
584 share_pinterest.dependency([
585 '#yith_wcwl_socials_image_url',
586 '#yith_wcwl_pr_button_icon',
587 '#yith_wcwl_color_pr_button_background'
588 ], function(){
589 return isChecked( share_pinterest ) && isChecked( enable_share )
590 }, function(){
591 share_pinterest_icon.change();
592 } );
593
594 share_pinterest_icon.dependency([
595 '#yith_wcwl_pr_button_custom_icon'
596 ], function(){
597 return isChecked( share_pinterest ) && isChecked( enable_share ) && 'custom' === share_pinterest_icon.val();
598 } );
599
600 share_email.dependency([
601 '#yith_wcwl_em_button_icon',
602 '#yith_wcwl_color_em_button_background'
603 ], function(){
604 return isChecked( share_email ) && isChecked( enable_share )
605 }, function(){
606 share_email_icon.change();
607 } );
608
609 share_email_icon.dependency([
610 '#yith_wcwl_em_button_custom_icon'
611 ], function(){
612 return isChecked( share_email ) && isChecked( enable_share ) && 'custom' === share_email_icon.val();
613 } );
614
615 share_whatsapp.dependency([
616 '#yith_wcwl_wa_button_icon',
617 '#yith_wcwl_wa_button_custom_icon',
618 '#yith_wcwl_color_wa_button_background'
619 ], function(){
620 return isChecked( share_whatsapp ) && isChecked( enable_share )
621 }, function(){
622 share_whatsapp_icon.change();
623 } );
624
625 share_whatsapp_icon.dependency([
626 '#yith_wcwl_wa_button_custom_icon'
627 ], function(){
628 return isChecked( share_whatsapp ) && isChecked( enable_share ) && 'custom' === share_whatsapp_icon.val();
629 } );
630
631 share_twitter.add( share_pinterest ).dependency([
632 '#yith_wcwl_socials_title',
633 '#yith_wcwl_socials_text'
634 ], function(){
635 return ( isChecked( share_twitter ) || isChecked( share_pinterest ) ) && isChecked( enable_share )
636 });
637
638 show_estimate_button.dependency([
639 '#yith_wcwl_show_additional_info_textarea'
640 ], isChecked, function(){
641 show_additional_info_textarea.change()
642 } );
643
644 show_estimate_button.on( 'change', function(){
645 show_additional_info_textarea.change();
646 } );
647
648 show_additional_info_textarea.dependency([
649 '#yith_wcwl_additional_info_textarea_label'
650 ], function(){
651 return isChecked( show_estimate_button ) && isChecked( show_additional_info_textarea )
652 } );
653
654 show_additional_info_textarea.on( 'change', function(){
655 var t = $(this);
656
657 if( t.is(':checked') && show_estimate_button.is(':checked') ){
658 ask_an_estimate_fields.removeClass( 'yith-disabled' );
659 }
660 else {
661 ask_an_estimate_fields.addClass( 'yith-disabled' );
662 }
663 } );
664
665 promotion_mail_type.dependency([
666 '#woocommerce_promotion_mail_settings\\[content_html\\]'
667 ], function(){
668 return 'multipart' === promotion_mail_type.val() || 'html' === promotion_mail_type.val()
669 } );
670
671 promotion_mail_type.dependency([
672 '#woocommerce_promotion_mail_settings\\[content_text\\]'
673 ], function(){
674 return 'multipart' === promotion_mail_type.val() || 'plain' === promotion_mail_type.val()
675 } );
676
677 back_in_stock_mail_enabled.dependency([
678 '#woocommerce_yith_wcwl_back_in_stock_settings\\[product_exclusions\\]',
679 '#woocommerce_yith_wcwl_back_in_stock_settings\\[category_exclusions\\]',
680 '#woocommerce_yith_wcwl_back_in_stock_settings\\[email_type\\]',
681 '#woocommerce_yith_wcwl_back_in_stock_settings\\[heading\\]',
682 '#woocommerce_yith_wcwl_back_in_stock_settings\\[subject\\]',
683 '#woocommerce_yith_wcwl_back_in_stock_settings\\[content_html\\]',
684 '#woocommerce_yith_wcwl_back_in_stock_settings\\[content_text\\]'
685 ], function(){
686 return isChecked( back_in_stock_mail_enabled )
687 }, function(){
688 back_in_stock_mail_type.change();
689 } );
690
691 back_in_stock_mail_type.dependency([
692 '#woocommerce_yith_wcwl_back_in_stock_settings\\[content_html\\]'
693 ], function(){
694 return ( 'multipart' === back_in_stock_mail_type.val() || 'html' === back_in_stock_mail_type.val() ) && isChecked( back_in_stock_mail_enabled )
695 } );
696
697 back_in_stock_mail_type.dependency([
698 '#woocommerce_yith_wcwl_back_in_stock_settings\\[content_text\\]'
699 ], function(){
700 return ( 'multipart' === back_in_stock_mail_type.val() || 'plain' === back_in_stock_mail_type.val() ) && isChecked( back_in_stock_mail_enabled )
701 } );
702
703 on_sale_item_mail_enabled.dependency([
704 '#woocommerce_yith_wcwl_on_sale_item_settings\\[product_exclusions\\]',
705 '#woocommerce_yith_wcwl_on_sale_item_settings\\[category_exclusions\\]',
706 '#woocommerce_yith_wcwl_on_sale_item_settings\\[email_type\\]',
707 '#woocommerce_yith_wcwl_on_sale_item_settings\\[heading\\]',
708 '#woocommerce_yith_wcwl_on_sale_item_settings\\[subject\\]',
709 '#woocommerce_yith_wcwl_on_sale_item_settings\\[content_html\\]',
710 '#woocommerce_yith_wcwl_on_sale_item_settings\\[content_text\\]'
711 ], function(){
712 return isChecked( on_sale_item_mail_enabled )
713 }, function(){
714 on_sale_item_mail_type.change();
715 } );
716
717 on_sale_item_mail_type.dependency([
718 '#woocommerce_yith_wcwl_on_sale_item_settings\\[content_html\\]'
719 ], function(){
720 return ( 'multipart' === on_sale_item_mail_type.val() || 'html' === on_sale_item_mail_type.val() ) && isChecked( on_sale_item_mail_enabled )
721 } );
722
723 on_sale_item_mail_type.dependency([
724 '#woocommerce_yith_wcwl_on_sale_item_settings\\[content_text\\]'
725 ], function(){
726 return ( 'multipart' === on_sale_item_mail_type.val() || 'plain' === on_sale_item_mail_type.val() ) && isChecked( on_sale_item_mail_enabled )
727 } );
728
729 /* === TOGGLE BOX HANDLING === */
730
731 $(document).on( 'yith-add-box-button-toggle', function(){
732 var ask_an_estimate_type_new = $('#new_type'),
733 ask_an_estimate_options_new = $('#new_options'),
734 target = ask_an_estimate_options_new.closest('.yith-add-box-row');
735
736 ask_an_estimate_type_new.on( 'change', function(){
737 var v = ask_an_estimate_type_new.val();
738
739 if( v === 'radio' || v === 'select' ){
740 target.show().fadeTo('slow', 1);
741 }
742 else{
743 target.is( ':visible' ) ? target.fadeTo('slow', 0, function(){ $(this).hide() }) : target.css('opacity', 0).hide();
744 }
745 } ).change();
746 } );
747 } );