HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/unminified.tar
add-to-wishlist-gutenberg.js000064400000000466151550137750012115 0ustar00jQuery( $ => {
	wp.hooks.addAction( 'yith_plugin_fw_gutenberg_success_do_shortcode', 'yith-woocommerce-wishlist', ( shortcode, shortcodeHash, ajaxResponse ) => {
		if ( 0 === shortcode.indexOf( '[yith_wcwl_add_to_wishlist' ) ) {
			wp.hooks.doAction( 'yith_wcwl_init_add_to_wishlist_components' );
		}
	} )
} )admin/rendering-methods.js000064400000002700151550137750011620 0ustar00jQuery( $ => {
	const Modal = {
			instance: false,
			handleClick: ( e ) => {
				e.preventDefault();
				Modal.open();
			},
			open: ( options = {} ) => {
				Modal.instance = yith.ui.modal( {
					...yithWcwlRenderingMethods.modals.updateRenderingMethod,
					classes: {
						main: 'yith-wcwl-rendering-methods-modal',
						title: 'yith-wcwl-rendering-methods-modal__title',
						content: 'yith-wcwl-rendering-methods-modal__content',
						footer: 'yith-wcwl-rendering-methods-modal__footer',
					},
					onClose: () => (Modal.instance = false),
					...options
				} )
			},
			close: () => {
				Modal?.instance?.close();
				Modal.instance = false;
			},
			openFromReactOnlyOptionNotice: () => {
				Modal.open( {
					title: yithWcwlRenderingMethods.i18n.reactOnlyOptionModalTitle
				} )
			}
		},
		initReactOnlyOptionsButtons = () => {
			$( '.yith-plugin-fw__panel__option.yith-wcwl-react-only-option' ).each( ( i, el ) => {
				const $optionRow = $( el );
				if ( ! $optionRow?.next()?.hasClass( 'yith-wcwl-react-only-option' ) ) {
					$optionRow.append( yithWcwlRenderingMethods.templates.reactOnlyOptionNotice );
				}
			} )
		}

	$( document ).on( 'click', 'a#yith-wcwl-open-rendering-methods-modal', Modal.open );
	$( document ).on( 'click', 'a#yith-wcwl-rendering-method-close-modal', Modal.close );
	$( document ).on( 'click', '.yith-wcwl-react-only-option__notice a', Modal.openFromReactOnlyOptionNotice );
	initReactOnlyOptionsButtons();
} );admin/yith-wcwl.js000064400000032317151550137750010140 0ustar00/**
 * Admin YITH WooCommerce Wishlist JS
 *
 * @author YITH <plugins@yithemes.com>
 * @package YITH WooCommerce Wishlist
 * @version 3.0.0
 *
 * global yith_wcwl_admin
 */

jQuery( function ( $ ) {

	/* === CUSTOM DEPENDENCIES HANDLER === */

	$.fn.dependency = function ( deps, test, complete, args ) {
		var t = $( this );

		t.on( 'change', function () {
			var val = test( t );

			$.each( deps, function ( i, v ) {
				var elem = $( v );

				if ( ! elem.length ) {
					return;
				}

				var target = elem.closest( '.yith-plugin-fw__panel__option' );

				if ( ! target.length ) {
					return;
				}

				if ( val ) {
					target.show();
				} else {
					target.hide();
				}
			} );

			if ( typeof complete !== 'undefined' ) {
				complete( t, args );
			}
		} ).change();
	};

	/* === UTILITY FUNCTIONS === */

	var getRadioValue = function ( t ) {
			if ( ! t.is( 'input[type="radio"]' ) ) {
				t = t.find( 'input[type="radio"]:checked' );
			}

			return t?.val();
		},
		isRadioYes = function ( t ) {
			return getRadioValue( t ) === 'yes';
		},
		isRadioNo = function ( t ) {
			return getRadioValue( t ) === 'no';
		},
		isChecked = function ( t ) {
			return t.is( ':checked' );
		};

	/* === SETTINGS HANDLING === */

	var disable_wishlist_for_unauth_users = $( '#yith_wcwl_disable_wishlist_for_unauthenticated_users' ),
		multi_wishlist_enable = $( '#yith_wcwl_multi_wishlist_enable' ),
		modal_enable = $( '#yith_wcwl_modal_enable' ),
		loop_position = $( '#yith_wcwl_loop_position' ),
		icon_select = $( '.icon-select' ),
		ask_an_estimate_style = $( '[name="yith_wcwl_ask_an_estimate_style"]' ),
		ask_an_estimate_icon = $( '#yith_wcwl_ask_an_estimate_icon' ),
		enable_share = $( '#yith_wcwl_enable_share' ),
		share_facebook = $( '#yith_wcwl_share_fb' ),
		share_facebook_icon = $( '#yith_wcwl_fb_button_icon' ),
		share_twitter = $( '#yith_wcwl_share_twitter' ),
		share_twitter_icon = $( '#yith_wcwl_tw_button_icon' ),
		share_pinterest = $( '#yith_wcwl_share_pinterest' ),
		share_pinterest_icon = $( '#yith_wcwl_pr_button_icon' ),
		share_email = $( '#yith_wcwl_share_email' ),
		share_email_icon = $( '#yith_wcwl_em_button_icon' ),
		share_whatsapp = $( '#yith_wcwl_share_whatsapp' ),
		share_whatsapp_icon = $( '#yith_wcwl_wa_button_icon' ),
		show_estimate_button = $( '#yith_wcwl_show_estimate_button' ),
		show_additional_info_textarea = $( '#yith_wcwl_show_additional_info_textarea' ),
		ask_an_estimate_fields = $( '#yith_wcwl_ask_an_estimate_fields' ),
		promotion_mail_type = $( '#woocommerce_promotion_mail_settings\\[email_type\\]' ),
		back_in_stock_mail_enabled = $( '#woocommerce_yith_wcwl_back_in_stock_settings\\[enabled\\]' ),
		back_in_stock_mail_type = $( '#woocommerce_yith_wcwl_back_in_stock_settings\\[email_type\\]' ),
		on_sale_item_mail_enabled = $( '#woocommerce_yith_wcwl_on_sale_item_settings\\[enabled\\]' ),
		on_sale_item_mail_type = $( '#woocommerce_yith_wcwl_on_sale_item_settings\\[email_type\\]' ),
		ask_an_estimate_type = $( '[id^="type_"]' ),
		add_to_wishlist_icon_types = $( '#yith_wcwl_add_to_wishlist_icon_type, #yith_wcwl_added_to_wishlist_icon_type' ),
		show_add_to_wishlist_in_loop = $( '#yith_wcwl_show_on_loop' );

	loop_position.add( 'select#yith_wcwl_button_position' ).on( 'change', function () {
		var t = $( this ),
			v = t.val();

		if ( 'shortcode' === v ) {
			t.parent().parent().next().find( '.addon' ).show();
		} else {
			t.parent().parent().next().find( '.addon' ).hide();
		}
	} ).change();

	ask_an_estimate_type.on( 'change', function () {
		var t = $( this ),
			v = t.val(),
			options_field = t.closest( '.yith-toggle-content-row' ).next();

		if ( v === 'radio' || v === 'select' ) {
			options_field.show().fadeTo( 'slow', 1 );
		} else {
			options_field.is( ':visible' ) ? options_field.fadeTo( 'slow', 0, function () {
				options_field.hide();
			} ) : options_field.css( 'opacity', 0 ).hide();
		}
	} ).change();

	ask_an_estimate_style.on( 'change', function () {
		ask_an_estimate_icon.change();
	} );

	icon_select.each( function () {
		var t = $( this ),
			renderOption = function ( state ) {
				if ( ! state.id ) {
					return state.text;
				}
				return $(
					'<span class="yith-wcwl-icon-option-container">' + yith_wcwl_admin.plugin_icons[ state.element.value.toLowerCase() ] + state.text + '</span>'
				);
			};

		t.select2( {
			templateResult: renderOption
		} );
	} );

	disable_wishlist_for_unauth_users.dependency( [
		'#yith_wcwl_enable_multi_wishlist_for_unauthenticated_users',
	], function () {
		return isChecked( multi_wishlist_enable ) && 'no' === getRadioValue(disable_wishlist_for_unauth_users);
	} );

	modal_enable.dependency( [
		'#yith_wcwl_show_exists_in_a_wishlist'
	], function () {
		var res = modal_enable.find( ':checked' ).val() !== 'default';

		if ( ! res ) {
			$( '#yith_wcwl_show_exists_in_a_wishlist' ).prop( 'checked', true );
		}

		return res;
	} );

	ask_an_estimate_icon.dependency( [
		'#yith_wcwl_ask_an_estimate_custom_icon'
	], function () {
		return 'custom' === ask_an_estimate_icon.val() && 'button_custom' === ask_an_estimate_style.filter( ':checked' ).val();
	} );

	enable_share.dependency( [
		'#yith_wcwl_share_fb'
	], isChecked, function () {
		share_facebook.change();
		share_facebook_icon.change();
		share_twitter.change();
		share_twitter_icon.change();
		share_pinterest.change();
		share_pinterest_icon.change();
		share_email.change();
		share_email_icon.change();
		share_whatsapp.change();
		share_whatsapp_icon.change();
	} );

	show_estimate_button.dependency( [
		'#yith_wcwl_show_additional_info_textarea'
	], isChecked, function () {
		show_additional_info_textarea.change();
	} );

	show_estimate_button.on( 'change', function () {
		show_additional_info_textarea.change();
	} );

	show_additional_info_textarea.dependency( [
		'#yith_wcwl_additional_info_textarea_label'
	], function () {
		return isChecked( show_estimate_button ) && isChecked( show_additional_info_textarea );
	} );

	show_additional_info_textarea.on( 'change', function () {
		var t = $( this );

		if ( t.is( ':checked' ) && show_estimate_button.is( ':checked' ) ) {
			ask_an_estimate_fields.removeClass( 'yith-disabled' );
		} else {
			ask_an_estimate_fields.addClass( 'yith-disabled' );
		}
	} );

	promotion_mail_type.dependency( [
		'#woocommerce_promotion_mail_settings\\[content_html\\]'
	], function () {
		return 'multipart' === promotion_mail_type.val() || 'html' === promotion_mail_type.val();
	} );

	promotion_mail_type.dependency( [
		'#woocommerce_promotion_mail_settings\\[content_text\\]'
	], function () {
		return 'multipart' === promotion_mail_type.val() || 'plain' === promotion_mail_type.val();
	} );

	back_in_stock_mail_enabled.dependency( [
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[product_exclusions\\]',
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[category_exclusions\\]',
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[email_type\\]',
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[heading\\]',
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[subject\\]',
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[content_html\\]',
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[content_text\\]'
	], function () {
		return isChecked( back_in_stock_mail_enabled );
	}, function () {
		back_in_stock_mail_type.change();
	} );

	back_in_stock_mail_type.dependency( [
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[content_html\\]'
	], function () {
		return ('multipart' === back_in_stock_mail_type.val() || 'html' === back_in_stock_mail_type.val()) && isChecked( back_in_stock_mail_enabled );
	} );

	back_in_stock_mail_type.dependency( [
		'#woocommerce_yith_wcwl_back_in_stock_settings\\[content_text\\]'
	], function () {
		return ('multipart' === back_in_stock_mail_type.val() || 'plain' === back_in_stock_mail_type.val()) && isChecked( back_in_stock_mail_enabled );
	} );

	on_sale_item_mail_enabled.dependency( [
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[product_exclusions\\]',
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[category_exclusions\\]',
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[email_type\\]',
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[heading\\]',
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[subject\\]',
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[content_html\\]',
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[content_text\\]'
	], function () {
		return isChecked( on_sale_item_mail_enabled );
	}, function () {
		on_sale_item_mail_type.change();
	} );

	on_sale_item_mail_type.dependency( [
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[content_html\\]'
	], function () {
		return ('multipart' === on_sale_item_mail_type.val() || 'html' === on_sale_item_mail_type.val()) && isChecked( on_sale_item_mail_enabled );
	} );

	on_sale_item_mail_type.dependency( [
		'#woocommerce_yith_wcwl_on_sale_item_settings\\[content_text\\]'
	], function () {
		return ('multipart' === on_sale_item_mail_type.val() || 'plain' === on_sale_item_mail_type.val()) && isChecked( on_sale_item_mail_enabled );
	} );

	add_to_wishlist_icon_types.dependency(
		[ '#yith_wcwl_added_to_wishlist_icon_color' ],
		function () {
			const addType = getRadioValue( $( '#yith_wcwl_add_to_wishlist_icon_type' ) ),
				addedType = getRadioValue( $( '#yith_wcwl_added_to_wishlist_icon_type' ) );

			return 'default' === addedType || ('same' === addedType && 'default' === addType);
		}
	);

	show_add_to_wishlist_in_loop.dependency(
		[ '#yith_wcwl_position_over_image_in_loop', '#yith_wcwl_button_over_image_style' ],
		function () {
			const showAddToWishlistInLoop = $( '#yith_wcwl_show_on_loop' ).val();
			const loopPosition = $( '#yith_wcwl_loop_position' ).val();

			return 'yes' === showAddToWishlistInLoop && 'before_image' === loopPosition;
		}
	);

	ask_an_estimate_style.dependency(
		[ '#yith_wcwl_ask_an_estimate_custom_icon' ],
		function () {
			const askAnEstimateButtonStyle = $( '#yith_wcwl_ask_an_estimate_style' ).val();
			const iconType = $('#yith_wcwl_ask_an_estimate_icon_type').val();

			return 'button_custom' === askAnEstimateButtonStyle && 'custom' === iconType;
		}
	);

	ask_an_estimate_style.dependency(
		[ '#yith_wcwl_ask_an_estimate_icon' ],
		function () {
			const askAnEstimateButtonStyle = $( '#yith_wcwl_ask_an_estimate_style' ).val();
			const iconType = $('#yith_wcwl_ask_an_estimate_icon_type').val();

			return 'button_custom' === askAnEstimateButtonStyle && 'default' === iconType;
		}
	);

	/* === DATEPICKER === */

	// commissions filter
	$( '.date-picker-field, .date-picker' ).datepicker( {
		dateFormat: 'yy-mm-dd',
		numberOfMonths: 1,
		showButtonPanel: true
	} );

	/* === TOGGLE BOX HANDLING === */

	$( document ).on( 'yith-add-box-button-toggle', function () {
		var ask_an_estimate_type_new = $( '#new_type' ),
			ask_an_estimate_options_new = $( '#new_options' ),
			target = ask_an_estimate_options_new.closest( '.yith-add-box-row' );

		ask_an_estimate_type_new.on( 'change', function () {
			var v = ask_an_estimate_type_new.val();

			if ( v === 'radio' || v === 'select' ) {
				target.show().fadeTo( 'slow', 1 );
			} else {
				target.is( ':visible' ) ? target.fadeTo( 'slow', 0, function () {
					$( this ).hide()
				} ) : target.css( 'opacity', 0 ).hide();
			}
		} ).change();
	} );

	// Email settings actions
	$( document ).on( 'click', '.toggle-settings', function ( e ) {
		e.preventDefault();
		$( this ).closest( '.yith-wcwl-row' ).toggleClass( 'active' );
		const target = $( this ).data( 'target' );
		$( '#' + target ).slideToggle();
	} );

	$( document ).on( 'click', '.yith-wcwl-save-settings', function ( e ) {
		e.preventDefault();
		$( this ).closest( 'form' ).find( '.wp-switch-editor.switch-html' ).trigger( 'click' );
		const email_key = $( this.closest( '.email-settings' ) ).attr( 'id' );
		const data = {
			'action': 'yith_wcwl_save_email_settings',
			'params': $( this ).closest( 'form' ).serialize(),
			'email_key': email_key,
		};
		$.ajax( {
			type: 'POST',
			data: data,
			url: ajaxurl,
			success: function () {
				const row_active = $( '.yith-wcwl-row.active' );
				row_active.find( '.email-settings' ).slideToggle();
				row_active.toggleClass( 'active' );
			},
		} );
	} );

	$( document ).on( 'change', '#yith-wcwl-email-status', function () {

		const data = {
			'action': 'yith_wcwl_save_mail_status',
			'enabled': $( this ).val(),
			'email_key': $( this ).closest( '.yith-plugin-fw-onoff-container ' ).data( 'email_key' ),
		};

		$.ajax( {
			type: 'POST',
			data: data,
			url: ajaxurl,
			success: function () {
				console.log( 'Email status updated' );
			}
		} );

	} );

	$( '#popular-filter .tablenav #post-query-submit' ).on( 'click', function () {
		window.onbeforeunload = null;
	} );

	$( document ).on( 'click', '#wishlist-filter table.wishlists .yith-plugin-fw__action-button--delete-action a', function ( e ) {
		e.preventDefault();
		e.stopPropagation();

		var url = $( this ).attr( 'href' ),
			wishlistName = $( this ).closest( 'tr' ).find( 'td.name a' ).text();

		yith.ui.confirm( {
			title: yith_wcwl_admin.i18n.deleteWishlistConfirmModal.title,
			message: yith_wcwl_admin.i18n.deleteWishlistConfirmModal.message.replace( '%s', `<b>"${ wishlistName }"</b>` ),
			confirmButtonType: 'delete',
			confirmButton: yith_wcwl_admin.i18n.deleteWishlistConfirmModal.confirmButton,
			closeAfterConfirm: false,
			onConfirm: function () {
				window.location.href = url;
			},
			closeWhenClickingOnOverlay: true,
		} );
	} );
} );
jquery.selectBox.js000064400000113400151550137750010360 0ustar00/*
 * jQuery selectBox - A cosmetic, styleable replacement for SELECT elements
 *
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
 *
 * v1.2.0
 *
 * https://github.com/marcj/jquery-selectBox
 */
;(function ($) {

    /**
     * SelectBox class.
     *
     * @param {HTMLElement|jQuery} select If it's a jQuery object, we use the first element.
     * @param {Object}             options
     * @constructor
     */
    var SelectBox = this.SelectBox = function (select, options) {
        if (select instanceof jQuery) {
            if (select.length > 0) {
                select = select[0];
            } else {
                return;
            }
        }

        this.typeTimer     = null;
        this.typeSearch    = '';
        this.isMac         = navigator.platform.match(/mac/i);
        options            = 'object' === typeof options ? options :  {};
        this.selectElement = select;

        // Disable for iOS devices (their native controls are more suitable for a touch device)
        if (!options.mobile && navigator.userAgent.match(/iPad|iPhone|Android|IEMobile|BlackBerry/i)) {
            return false;
        }

        // Element must be a select control
        if ('select' !== select.tagName.toLowerCase()) {
            return false;
        }

        this.init(options);
    }

    /**
     * @type {String}
     */
    SelectBox.prototype.version = '1.2.0';

    /**
     * @param {Object} options
     *
     * @returns {Boolean}
     */
    SelectBox.prototype.init = function (options) {
        var select = $(this.selectElement);
        if (select.data('selectBox-control')) {
            return false;
        }

        var control    = $('<a class="selectBox" />')
            , inline   = select.attr('multiple') || parseInt(select.attr('size')) > 1
            , settings = options || {}
            , tabIndex = parseInt(select.prop('tabindex')) || 0
            , self     = this;

        control
            .width(select.outerWidth())
            .addClass(select.attr('class'))
            .attr('title', select.attr('title') || '')
            .attr('tabindex', tabIndex)
            .css('display', 'inline-block')
            .bind('focus.selectBox', function () {
                if (this !== document.activeElement && document.body !== document.activeElement) {
                    $(document.activeElement).blur();
                }
                if (control.hasClass('selectBox-active')) {
                    return;
                }
                control.addClass('selectBox-active');
                select.trigger('focus');
            })
            .bind('blur.selectBox', function () {
                if (!control.hasClass('selectBox-active')) {
                    return;
                }
                control.removeClass('selectBox-active');
                select.trigger('blur');
            });

        if (!$(window).data('selectBox-bindings')) {
            $(window)
                .data('selectBox-bindings', true)
                .bind('scroll.selectBox', this.hideMenus)
                .bind('resize.selectBox', this.hideMenus);
        }

        if (select.attr('disabled')) {
            control.addClass('selectBox-disabled');
        }

        // Focus on control when label is clicked
        select.bind('click.selectBox', function (event) {
            control.focus();
            event.preventDefault();
        });

        // Generate control
        if (inline) {
            // Inline controls
            options = this.getOptions('inline');

            control
                .append(options)
                .data('selectBox-options', options).addClass('selectBox-inline selectBox-menuShowing')
                .bind('keydown.selectBox', function (event) {
                    self.handleKeyDown(event);
                })
                .bind('keypress.selectBox',function (event) {
                    self.handleKeyPress(event);
                })
                .bind('mousedown.selectBox',function (event) {
                    if (1 !== event.which) {
                        return;
                    }
                    if ($(event.target).is('A.selectBox-inline')) {
                        event.preventDefault();
                    }
                    if (!control.hasClass('selectBox-focus')) {
                        control.focus();
                    }
                })
                .insertAfter(select);

            // Auto-height based on size attribute
            if (!select[0].style.height) {
                var size = select.attr('size') ? parseInt(select.attr('size')) : 5;
                // Draw a dummy control off-screen, measure, and remove it
                var tmp = control
                    .clone()
                    .removeAttr('id')
                    .css({
                        position: 'absolute',
                        top: '-9999em'
                    })
                    .show()
                    .appendTo('body');
                tmp.find('.selectBox-options').html('<li><a>\u00A0</a></li>');
                var optionHeight = parseInt(tmp.find('.selectBox-options A:first').html('&nbsp;').outerHeight());
                tmp.remove();
                control.height(optionHeight * size);
            }
            this.disableSelection(control);
        } else {
            // Dropdown controls
            var label = $('<span class="selectBox-label" />'),
                arrow = $('<span class="selectBox-arrow" />');

            // Update label
            label.attr('class', this.getLabelClass()).text(this.getLabelText());
            options = this.getOptions('dropdown');
            options.appendTo('BODY');

            control
                .data('selectBox-options', options)
                .addClass('selectBox-dropdown')
                .append(label)
                .append(arrow)
                .bind('mousedown.selectBox', function (event) {
                    if (1 === event.which) {
                        if (control.hasClass('selectBox-menuShowing')) {
                            self.hideMenus();
                        } else {
                            event.stopPropagation();
                            // Webkit fix to prevent premature selection of options
                            options
                                .data('selectBox-down-at-x', event.screenX)
                                .data('selectBox-down-at-y', event.screenY);
                            self.showMenu();
                        }
                    }
                })
                .bind('keydown.selectBox', function (event) {
                    self.handleKeyDown(event);
                })
                .bind('keypress.selectBox', function (event) {
                    self.handleKeyPress(event);
                })
                .bind('open.selectBox',function (event, triggerData) {
                    if (triggerData && triggerData._selectBox === true) {
                        return;
                    }
                    self.showMenu();
                })
                .bind('close.selectBox', function (event, triggerData) {
                    if (triggerData && triggerData._selectBox === true) {
                        return;
                    }
                    self.hideMenus();
                })
                .insertAfter(select);

            // Set label width
            var labelWidth =
                    control.width()
                  - arrow.outerWidth()
                  - parseInt(label.css('paddingLeft')) || 0
                  - parseInt(label.css('paddingRight')) || 0;

            label.width(labelWidth);
            this.disableSelection(control);
        }
        // Store data for later use and show the control
        select
            .addClass('selectBox')
            .data('selectBox-control', control)
            .data('selectBox-settings', settings)
            .hide();
    };

    /**
     * @param {String} type 'inline'|'dropdown'
     * @returns {jQuery}
     */
    SelectBox.prototype.getOptions = function (type) {
        var options;
        var select = $(this.selectElement);
        var self   = this;
        // Private function to handle recursion in the getOptions function.
        var _getOptions = function (select, options) {
            // Loop through the set in order of element children.
            select.children('OPTION, OPTGROUP').each(function () {
                // If the element is an option, add it to the list.
                if ($(this).is('OPTION')) {
                    // Check for a value in the option found.
                    if ($(this).length > 0) {
                        // Create an option form the found element.
                        self.generateOptions($(this), options);
                    } else {
                        // No option information found, so add an empty.
                        options.append('<li>\u00A0</li>');
                    }
                } else {
                    // If the element is an option group, add the group and call this function on it.
                    var optgroup = $('<li class="selectBox-optgroup" />');
                    optgroup.text($(this).attr('label'));
                    options.append(optgroup);
                    options = _getOptions($(this), options);
                }
            });
            // Return the built strin
            return options;
        };

        switch (type) {
            case 'inline':
                options = $('<ul class="selectBox-options" />');
                options = _getOptions(select, options);
                options
                    .find('A')
                    .bind('mouseover.selectBox', function (event) {
                        self.addHover($(this).parent());
                    })
                    .bind('mouseout.selectBox',function (event) {
                        self.removeHover($(this).parent());
                    })
                    .bind('mousedown.selectBox',function (event) {
                        if (1 !== event.which) {
                            return
                        }
                        event.preventDefault(); // Prevent options from being "dragged"
                        if (!select.selectBox('control').hasClass('selectBox-active')) {
                            select.selectBox('control').focus();
                        }
                    })
                    .bind('mouseup.selectBox', function (event) {
                        if (1 !== event.which) {
                            return;
                        }
                        self.hideMenus();
                        self.selectOption($(this).parent(), event);
                    });

                this.disableSelection(options);
                return options;
            case 'dropdown':
                options = $('<ul class="selectBox-dropdown-menu selectBox-options" />');
                options = _getOptions(select, options);

                options
                    .data('selectBox-select', select)
                    .css('display', 'none')
                    .appendTo('BODY')
                    .find('A')
                    .bind('mousedown.selectBox', function (event) {
                        if (event.which === 1) {
                            event.preventDefault(); // Prevent options from being "dragged"
                            if (event.screenX === options.data('selectBox-down-at-x') &&
                                event.screenY === options.data('selectBox-down-at-y')) {
                                options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');
                                self.hideMenus();
                            }
                        }
                    })
                    .bind('mouseup.selectBox', function (event) {
                        if (1 !== event.which) {
                            return;
                        }
                        if (event.screenX === options.data('selectBox-down-at-x') &&
                            event.screenY === options.data('selectBox-down-at-y')) {
                            return;
                        } else {
                            options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');
                        }
                        self.selectOption($(this).parent());
                        self.hideMenus();
                    })
                    .bind('mouseover.selectBox', function (event) {
                        self.addHover($(this).parent());
                    })
                    .bind('mouseout.selectBox', function (event) {
                        self.removeHover($(this).parent());
                    });

                // Inherit classes for dropdown menu
                var classes = select.attr('class') || '';
                if ('' !== classes) {
                    classes = classes.split(' ');
                    for (var i in classes) {
                        options.addClass(classes[i] + '-selectBox-dropdown-menu');
                    }
                }
                this.disableSelection(options);
                return options;
        }
    };

    /**
     * Returns the current class of the selected option.
     *
     * @returns {String}
     */
    SelectBox.prototype.getLabelClass = function () {
        var selected = $(this.selectElement).find('OPTION:selected');
        return ('selectBox-label ' + (selected.attr('class') || '')).replace(/\s+$/, '');
    };

    /**
     * Returns the current label of the selected option.
     *
     * @returns {String}
     */
    SelectBox.prototype.getLabelText = function () {
        var selected = $(this.selectElement).find('OPTION:selected');
        return selected.text() || '\u00A0';
    };

    /**
     * Sets the label.
     * This method uses the getLabelClass() and getLabelText() methods.
     */
    SelectBox.prototype.setLabel = function () {
        var select = $(this.selectElement);
        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }

        control
            .find('.selectBox-label')
            .attr('class', this.getLabelClass())
            .text(this.getLabelText());
    };

    /**
     * Destroys the SelectBox instance and shows the origin select element.
     *
     */
    SelectBox.prototype.destroy = function () {
        var select = $(this.selectElement);
        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }

        var options = control.data('selectBox-options');
        options.remove();
        control.remove();
        select
            .removeClass('selectBox')
            .removeData('selectBox-control')
            .data('selectBox-control', null)
            .removeData('selectBox-settings')
            .data('selectBox-settings', null)
            .show();
    };

    /**
     * Refreshes the option elements.
     */
    SelectBox.prototype.refresh = function () {
        var select = $(this.selectElement),
            control = select.data('selectBox-control'),
            dropdown = control.hasClass('selectBox-dropdown'),
            menuOpened = control.hasClass('selectBox-menuShowing');
        select.selectBox('options', select.html());
        // Restore opened dropdown state (original menu was trashed)
        if (dropdown && menuOpened) {
            this.showMenu();
        }
    };

    /**
     * Shows the dropdown menu.
     */
    SelectBox.prototype.showMenu = function () {
        var self = this
            , select   = $(this.selectElement)
            , control  = select.data('selectBox-control')
            , settings = select.data('selectBox-settings')
            , options  = control.data('selectBox-options');

        if (control.hasClass('selectBox-disabled')) {
            return false;
        }

        this.hideMenus();
        var borderBottomWidth = parseInt(control.css('borderBottomWidth')) || 0;

        // Menu position
        options
            .width(control.innerWidth())
            .css({
                top: control.offset().top + control.outerHeight() - borderBottomWidth,
                left: control.offset().left
            });


        if (select.triggerHandler('beforeopen')) {
            return false;
        }

        var dispatchOpenEvent = function () {
            select.triggerHandler('open', {
                _selectBox: true
            });
        };

        // Show menu
        switch (settings.menuTransition) {
            case 'fade':
                options.fadeIn(settings.menuSpeed, dispatchOpenEvent);
                break;
            case 'slide':
                options.slideDown(settings.menuSpeed, dispatchOpenEvent);
                break;
            default:
                options.show(settings.menuSpeed, dispatchOpenEvent);
                break;
        }

        if (!settings.menuSpeed) {
            dispatchOpenEvent();
        }

        // Center on selected option
        var li = options.find('.selectBox-selected:first');
        this.keepOptionInView(li, true);
        this.addHover(li);
        control.addClass('selectBox-menuShowing');

        $(document).bind('mousedown.selectBox', function (event) {
            if (1 === event.which) {
                if ($(event.target).parents().andSelf().hasClass('selectBox-options')) {
                    return;
                }
                self.hideMenus();
            }
        });
    };

    /**
     * Hides the menu of all instances.
     */
    SelectBox.prototype.hideMenus = function () {
        if ($(".selectBox-dropdown-menu:visible").length === 0) {
            return;
        }

        $(document).unbind('mousedown.selectBox');
        $(".selectBox-dropdown-menu").each(function () {
            var options = $(this)
                , select = options.data('selectBox-select')
                , control = select.data('selectBox-control')
                , settings = select.data('selectBox-settings');

            if (select.triggerHandler('beforeclose')) {
                return false;
            }

            var dispatchCloseEvent = function () {
                select.triggerHandler('close', {
                    _selectBox: true
                });
            };

            if (settings) {
                switch (settings.menuTransition) {
                    case 'fade':
                        options.fadeOut(settings.menuSpeed, dispatchCloseEvent);
                        break;
                    case 'slide':
                        options.slideUp(settings.menuSpeed, dispatchCloseEvent);
                        break;
                    default:
                        options.hide(settings.menuSpeed, dispatchCloseEvent);
                        break;
                }
                if (!settings.menuSpeed) {
                    dispatchCloseEvent();
                }
                control.removeClass('selectBox-menuShowing');
            } else {
                $(this).hide();
                $(this).triggerHandler('close', {
                    _selectBox: true
                });
                $(this).removeClass('selectBox-menuShowing');
            }
        });
    };

    /**
     * Selects an option.
     *
     * @param {HTMLElement} li
     * @param {DOMEvent}    event
     * @returns {Boolean}
     */
    SelectBox.prototype.selectOption = function (li, event) {
        var select = $(this.selectElement);
        li         = $(li);

        var control    = select.data('selectBox-control')
            , settings = select.data('selectBox-settings');

        if (control.hasClass('selectBox-disabled')) {
            return false;
        }

        if (0 === li.length || li.hasClass('selectBox-disabled')) {
            return false;
        }

        if (select.attr('multiple')) {
            // If event.shiftKey is true, this will select all options between li and the last li selected
            if (event.shiftKey && control.data('selectBox-last-selected')) {
                li.toggleClass('selectBox-selected');
                var affectedOptions;
                if (li.index() > control.data('selectBox-last-selected').index()) {
                    affectedOptions = li
                        .siblings()
                        .slice(control.data('selectBox-last-selected').index(), li.index());
                } else {
                    affectedOptions = li
                        .siblings()
                        .slice(li.index(), control.data('selectBox-last-selected').index());
                }
                affectedOptions = affectedOptions.not('.selectBox-optgroup, .selectBox-disabled');
                if (li.hasClass('selectBox-selected')) {
                    affectedOptions.addClass('selectBox-selected');
                } else {
                    affectedOptions.removeClass('selectBox-selected');
                }
            } else if ((this.isMac && event.metaKey) || (!this.isMac && event.ctrlKey)) {
                li.toggleClass('selectBox-selected');
            } else {
                li.siblings().removeClass('selectBox-selected');
                li.addClass('selectBox-selected');
            }
        } else {
            li.siblings().removeClass('selectBox-selected');
            li.addClass('selectBox-selected');
        }

        if (control.hasClass('selectBox-dropdown')) {
            control.find('.selectBox-label').text(li.text());
        }

        // Update original control's value
        var i = 0, selection = [];
        if (select.attr('multiple')) {
            control.find('.selectBox-selected A').each(function () {
                selection[i++] = $(this).attr('rel');
            });
        } else {
            selection = li.find('A').attr('rel');
        }

        // Remember most recently selected item
        control.data('selectBox-last-selected', li);

        // Change callback
        if (select.val() !== selection) {
            select.val(selection);
            this.setLabel();
            select.trigger('change');
        }

        return true;
    };

    /**
     * Adds the hover class.
     *
     * @param {HTMLElement} li
     */
    SelectBox.prototype.addHover = function (li) {
        li = $(li);
        var select = $(this.selectElement)
            , control   = select.data('selectBox-control')
            , options = control.data('selectBox-options');

        options.find('.selectBox-hover').removeClass('selectBox-hover');
        li.addClass('selectBox-hover');
    };

    /**
     * Returns the original HTML select element.
     *
     * @returns {HTMLElement}
     */
    SelectBox.prototype.getSelectElement = function () {
        return this.selectElement;
    };

    /**
     * Remove the hover class.
     *
     * @param {HTMLElement} li
     */
    SelectBox.prototype.removeHover = function (li) {
        li = $(li);
        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , options = control.data('selectBox-options');

        options.find('.selectBox-hover').removeClass('selectBox-hover');
    };

    /**
     * Checks if the widget is in the view.
     *
     * @param {jQuery}      li
     * @param {Boolean}     center
     */
    SelectBox.prototype.keepOptionInView = function (li, center) {
        if (!li || li.length === 0) {
            return;
        }

        var select = $(this.selectElement)
            , control     = select.data('selectBox-control')
            , options   = control.data('selectBox-options')
            , scrollBox = control.hasClass('selectBox-dropdown') ? options : options.parent()
            , top       = parseInt(li.offset().top -scrollBox.position().top)
            , bottom    = parseInt(top + li.outerHeight());

        if (center) {
            scrollBox.scrollTop(li.offset().top - scrollBox.offset().top + scrollBox.scrollTop() -
                (scrollBox.height() / 2));
        } else {
            if (top < 0) {
                scrollBox.scrollTop(li.offset().top - scrollBox.offset().top + scrollBox.scrollTop());
            }
            if (bottom > scrollBox.height()) {
                scrollBox.scrollTop((li.offset().top + li.outerHeight()) - scrollBox.offset().top +
                    scrollBox.scrollTop() - scrollBox.height());
            }
        }
    };

    /**
     * Handles the keyDown event.
     * Handles open/close and arrow key functionality
     *
     * @param {DOMEvent}    event
     */
    SelectBox.prototype.handleKeyDown = function (event) {
        var select = $(this.selectElement)
            , control        = select.data('selectBox-control')
            , options      = control.data('selectBox-options')
            , settings     = select.data('selectBox-settings')
            , totalOptions = 0, i = 0;

        if (control.hasClass('selectBox-disabled')) {
            return;
        }

        switch (event.keyCode) {
            case 8:
                // backspace
                event.preventDefault();
                this.typeSearch = '';
                break;
            case 9:
            // tab
            case 27:
                // esc
                this.hideMenus();
                this.removeHover();
                break;
            case 13:
                // enter
                if (control.hasClass('selectBox-menuShowing')) {
                    this.selectOption(options.find('LI.selectBox-hover:first'), event);
                    if (control.hasClass('selectBox-dropdown')) {
                        this.hideMenus();
                    }
                } else {
                    this.showMenu();
                }
                break;
            case 38:
            // up
            case 37:
                // left
                event.preventDefault();
                if (control.hasClass('selectBox-menuShowing')) {
                    var prev = options.find('.selectBox-hover').prev('LI');
                    totalOptions = options.find('LI:not(.selectBox-optgroup)').length;
                    i = 0;
                    while (prev.length === 0 || prev.hasClass('selectBox-disabled') ||
                        prev.hasClass('selectBox-optgroup')) {
                        prev = prev.prev('LI');
                        if (prev.length === 0) {
                            if (settings.loopOptions) {
                                prev = options.find('LI:last');
                            } else {
                                prev = options.find('LI:first');
                            }
                        }
                        if (++i >= totalOptions) {
                            break;
                        }
                    }
                    this.addHover(prev);
                    this.selectOption(prev, event);
                    this.keepOptionInView(prev);
                } else {
                    this.showMenu();
                }
                break;
            case 40:
            // down
            case 39:
                // right
                event.preventDefault();
                if (control.hasClass('selectBox-menuShowing')) {
                    var next = options.find('.selectBox-hover').next('LI');
                    totalOptions = options.find('LI:not(.selectBox-optgroup)').length;
                    i = 0;
                    while (0 === next.length || next.hasClass('selectBox-disabled') ||
                        next.hasClass('selectBox-optgroup')) {
                        next = next.next('LI');
                        if (next.length === 0) {
                            if (settings.loopOptions) {
                                next = options.find('LI:first');
                            } else {
                                next = options.find('LI:last');
                            }
                        }
                        if (++i >= totalOptions) {
                            break;
                        }
                    }
                    this.addHover(next);
                    this.selectOption(next, event);
                    this.keepOptionInView(next);
                } else {
                    this.showMenu();
                }
                break;
        }
    };

    /**
     * Handles the keyPress event.
     * Handles type-to-find functionality
     *
     * @param {DOMEvent}    event
     */
    SelectBox.prototype.handleKeyPress = function (event) {
        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , options = control.data('selectBox-options');

        if (control.hasClass('selectBox-disabled')) {
            return;
        }

        switch (event.keyCode) {
            case 9:
            // tab
            case 27:
            // esc
            case 13:
            // enter
            case 38:
            // up
            case 37:
            // left
            case 40:
            // down
            case 39:
                // right
                // Don't interfere with the keydown event!
                break;
            default:
                // Type to find
                if (!control.hasClass('selectBox-menuShowing')) {
                    this.showMenu();
                }
                event.preventDefault();
                clearTimeout(this.typeTimer);
                this.typeSearch += String.fromCharCode(event.charCode || event.keyCode);
                options.find('A').each(function () {
                    if ($(this).text().substr(0, this.typeSearch.length).toLowerCase() === this.typeSearch.toLowerCase()) {
                        this.addHover($(this).parent());
                        this.selectOption($(this).parent(), event);
                        this.keepOptionInView($(this).parent());
                        return false;
                    }
                });
                // Clear after a brief pause
                this.typeTimer = setTimeout(function () {
                    this.typeSearch = '';
                }, 1000);
                break;
        }
    };

    /**
     * Enables the selectBox.
     */
    SelectBox.prototype.enable = function () {
        var select = $(this.selectElement);
        select.prop('disabled', false);
        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }
        control.removeClass('selectBox-disabled');
    };

    /**
     * Disables the selectBox.
     */
    SelectBox.prototype.disable = function () {
        var select = $(this.selectElement);
        select.prop('disabled', true);
        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }
        control.addClass('selectBox-disabled');
    };

    /**
     * Sets the current value.
     *
     * @param {String}      value
     */
    SelectBox.prototype.setValue = function (value) {
        var select = $(this.selectElement);
        select.val(value);
        value = select.val(); // IE9's select would be null if it was set with a non-exist options value

        if (null === value) { // So check it here and set it with the first option's value if possible
            value = select.children().first().val();
            select.val(value);
        }

        var control = select.data('selectBox-control');
        if (!control) {
            return;
        }

        var settings = select.data('selectBox-settings')
            , options = control.data('selectBox-options');

        // Update label
        this.setLabel();

        // Update control values
        options.find('.selectBox-selected').removeClass('selectBox-selected');
        options.find('A').each(function () {
            if (typeof(value) === 'object') {
                for (var i = 0; i < value.length; i++) {
                    if ($(this).attr('rel') == value[i]) {
                        $(this).parent().addClass('selectBox-selected');
                    }
                }
            } else {
                if ($(this).attr('rel') == value) {
                    $(this).parent().addClass('selectBox-selected');
                }
            }
        });

        if (settings.change) {
            settings.change.call(select);
        }
    };

    /**
     * Sets the option elements.
     *
     * @param {String|Object} options
     */
    SelectBox.prototype.setOptions = function (options) {
        var select = $(this.selectElement)
            , control = select.data('selectBox-control')
            , settings = select.data('selectBox-settings')
            , type;

        switch (typeof(options)) {
            case 'string':
                select.html(options);
                break;
            case 'object':
                select.html('');
                for (var i in options) {
                    if (options[i] === null) {
                        continue;
                    }
                    if (typeof(options[i]) === 'object') {
                        var optgroup = $('<optgroup label="' + i + '" />');
                        for (var j in options[i]) {
                            optgroup.append('<option value="' + j + '">' + options[i][j] + '</option>');
                        }
                        select.append(optgroup);
                    } else {
                        var option = $('<option value="' + i + '">' + options[i] + '</option>');
                        select.append(option);
                    }
                }
                break;
        }

        if (!control) {
            return;
        }

        // Remove old options
        control.data('selectBox-options').remove();

        // Generate new options
        type     = control.hasClass('selectBox-dropdown') ? 'dropdown' : 'inline';
        options  = this.getOptions(type);
        control.data('selectBox-options', options);

        switch (type) {
            case 'inline':
                control.append(options);
                break;
            case 'dropdown':
                // Update label
                this.setLabel();
                $("BODY").append(options);
                break;
        }
    };

    /**
     * Disables the selection.
     *
     * @param {*} selector
     */
    SelectBox.prototype.disableSelection = function (selector) {
        $(selector).css('MozUserSelect', 'none').bind('selectstart', function (event) {
            event.preventDefault();
        });
    };

    /**
     * Generates the options.
     *
     * @param {jQuery} self
     * @param {jQuery} options
     */
    SelectBox.prototype.generateOptions = function (self, options) {
        var li = $('<li />'), a = $('<a />');
        li.addClass(self.attr('class'));
        li.data(self.data());
        a.attr('rel', self.val()).text(self.text());
        li.append(a);
        if (self.attr('disabled')) {
            li.addClass('selectBox-disabled');
        }
        if (self.attr('selected')) {
            li.addClass('selectBox-selected');
        }
        options.append(li);
    };

    /**
     * Extends the jQuery.fn object.
     */
    $.extend($.fn, {
        selectBox: function (method, options) {
            var selectBox;

            switch (method) {
                case 'control':
                    return $(this).data('selectBox-control');
                case 'settings':
                    if (!options) {
                        return $(this).data('selectBox-settings');
                    }
                    $(this).each(function () {
                        $(this).data('selectBox-settings', $.extend(true, $(this).data('selectBox-settings'), options));
                    });
                    break;
                case 'options':
                    // Getter
                    if (undefined === options) {
                        return $(this).data('selectBox-control').data('selectBox-options');
                    }
                    // Setter
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.setOptions(options);
                        }
                    });
                    break;
                case 'value':
                    // Empty string is a valid value
                    if (undefined === options) {
                        return $(this).val();
                    }
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.setValue(options);
                        }
                    });
                    break;
                case 'refresh':
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.refresh();
                        }
                    });
                    break;
                case 'enable':
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.enable(this);
                        }
                    });
                    break;
                case 'disable':
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.disable();
                        }
                    });
                    break;
                case 'destroy':
                    $(this).each(function () {
                        if (selectBox = $(this).data('selectBox')) {
                            selectBox.destroy();
                            $(this).data('selectBox', null);
                        }
                    });
                    break;
                case 'instance':
                    return $(this).data('selectBox');
                default:
                    $(this).each(function (idx, select) {
                        if (!$(select).data('selectBox')) {
                            $(select).data('selectBox', new SelectBox(select, method));
                        }
                    });
                    break;
            }
            return $(this);
        }
    });
})(jQuery);jquery.yith-wcwl.js000064400000135733151550137750010374 0ustar00/**
 * Main YITH WooCommerce Wishlist JS
 *
 * @author YITH <plugins@yithemes.com>
 * @package YITH WooCommerce Wishlist
 * @version 3.0.0
 */

/* globals yith_wcwl_l10n, wc_add_to_cart_params, yith_wccl_general */

jQuery( function ( $ ) {

	/* === MAIN INIT === */

	$( document ).on( 'yith_wcwl_init', function () {
		var t = $( this ),
			cart_redirect_after_add = (typeof (wc_add_to_cart_params) !== 'undefined' && wc_add_to_cart_params !== null) ? wc_add_to_cart_params.cart_redirect_after_add : '';

		t.on( 'click', '.add_to_wishlist', function ( ev ) {
			var t = $( this ),
				product_id = t.attr( 'data-product-id' ),
				el_wrap = $( '.add-to-wishlist-' + product_id ),
				filtered_data = null,
				data = {
					action: yith_wcwl_l10n.actions.add_to_wishlist_action,
					nonce: yith_wcwl_l10n.nonce.add_to_wishlist_nonce,
					context: 'frontend',
					add_to_wishlist: product_id,
					product_type: t.data( 'product-type' ),
					wishlist_id: t.data( 'wishlist-id' ),
					fragments: retrieve_fragments( product_id )
				};

			// allow third party code to filter data
			if ( filtered_data = $( document ).triggerHandler( 'yith_wcwl_add_to_wishlist_data', [ t, data ] ) ) {
				data = filtered_data;
			}

			ev.preventDefault();

			jQuery( document.body ).trigger( 'adding_to_wishlist' );

			if ( yith_wcwl_l10n.multi_wishlist && yith_wcwl_l10n.modal_enable ) {
				var wishlist_popup_container = t.parents( '.yith-wcwl-popup-footer' ).prev( '.yith-wcwl-popup-content' ),
					wishlist_popup_select = wishlist_popup_container.find( '.wishlist-select' ),
					wishlist_popup_name = wishlist_popup_container.find( '.wishlist-name' ),
					wishlist_popup_visibility = wishlist_popup_container.find( '.wishlist-visibility' ).filter( ':checked' );

				data.wishlist_id = wishlist_popup_select.is( ':visible' ) ? wishlist_popup_select.val() : 'new';
				data.wishlist_name = wishlist_popup_name.val();
				data.wishlist_visibility = wishlist_popup_visibility.val();

				if ( 'new' === data.wishlist_id && ! data.wishlist_name ) {
					wishlist_popup_name.closest( 'p' ).addClass( 'woocommerce-invalid' );
					return false;
				} else {
					wishlist_popup_name.closest( 'p' ).removeClass( 'woocommerce-invalid' );
				}
			}

			if ( ! is_cookie_enabled() ) {
				window.alert( yith_wcwl_l10n.labels.cookie_disabled );
				return;
			}

			$.ajax( {
				type: 'POST',
				url: yith_wcwl_l10n.ajax_url,
				data: data,
				dataType: 'json',
				beforeSend: function () {
					block( t );
				},
				complete: function () {
					unblock( t );
				},
				success: function ( response ) {
					var response_result = response.result,
						response_message = response.message;

					if ( yith_wcwl_l10n.multi_wishlist && yith_wcwl_l10n.modal_enable ) {
						// close PrettyPhoto popup
						close_pretty_photo( response_message, response_result );

						// update options for all wishlist selects
						if ( typeof (response.user_wishlists) !== 'undefined' ) {
							update_wishlists( response.user_wishlists );
						}
					} else {
						print_message( response_message );
					}

					if ( response_result === 'true' || response_result === 'exists' ) {
						if ( typeof response.fragments !== 'undefined' ) {
							replace_fragments( response.fragments );
						}

						if ( ! yith_wcwl_l10n.multi_wishlist || yith_wcwl_l10n.hide_add_button ) {
							el_wrap.find( '.yith-wcwl-add-button' ).remove();
						}

						el_wrap.addClass( 'exists' );
					}

					init_handling_after_ajax();

					$( 'body' ).trigger( 'added_to_wishlist', [ t, el_wrap ] );
				}

			} );

			return false;
		} );

		t.on( 'click', '.wishlist_table .remove_from_wishlist', function ( ev ) {
			var t = $( this );

			ev.preventDefault();

			remove_item_from_wishlist( t );

			return false;
		} );

		t.on( 'adding_to_cart', 'body', function ( ev, button, data ) {
			if ( typeof button !== 'undefined' && typeof data !== 'undefined' && button.closest( '.wishlist_table' ).length ) {
				data.remove_from_wishlist_after_add_to_cart = button.closest( '[data-row-id]' ).data( 'row-id' );
				data.wishlist_id = button.closest( '.wishlist_table' ).data( 'id' );
				typeof wc_add_to_cart_params !== 'undefined' && (wc_add_to_cart_params.cart_redirect_after_add = yith_wcwl_l10n.redirect_to_cart);
				typeof yith_wccl_general !== 'undefined' && (yith_wccl_general.cart_redirect = isTrue( yith_wcwl_l10n.redirect_to_cart ));
			}
		} );

		t.on( 'added_to_cart', 'body', function ( ev, fragments, carthash, button ) {
			if ( typeof button !== 'undefined' && button.closest( '.wishlist_table' ).length ) {
				typeof wc_add_to_cart_params !== 'undefined' && (wc_add_to_cart_params.cart_redirect_after_add = cart_redirect_after_add);
				typeof yith_wccl_general !== 'undefined' && (yith_wccl_general.cart_redirect = isTrue( cart_redirect_after_add ));

				var tr = button.closest( '[data-row-id]' ),
					table = tr.closest( '.wishlist-fragment' ),
					options = table.data( 'fragment-options' );

				button.removeClass( 'added' );
				tr.find( '.added_to_cart' ).remove();

				if ( yith_wcwl_l10n.remove_from_wishlist_after_add_to_cart && options.is_user_owner ) {
					tr.remove();
				}
			}
		} );

		t.on( 'added_to_cart', 'body', function () {
			var messages = $( '.woocommerce-message' );

			if ( messages.length === 0 ) {
				$( '#yith-wcwl-form' ).prepend( yith_wcwl_l10n.labels.added_to_cart_message );
			} else {
				messages.fadeOut( 300, function () {
					$( this ).replaceWith( yith_wcwl_l10n.labels.added_to_cart_message ).fadeIn();
				} );
			}
		} );

		t.on( 'cart_page_refreshed', 'body', init_handling_after_ajax );

		t.on( 'click', '.show-title-form', show_title_form );

		t.on( 'click', '.wishlist-title-with-form h2', show_title_form );

		t.on( 'click', '.remove_from_all_wishlists', function ( ev ) {
			var t = $( this ),
				prod_id = t.attr( 'data-product-id' ),
				wishlist_id = t.data( 'wishlist-id' ),
				content = t.closest( '.content' ),
				data = {
					action: yith_wcwl_l10n.actions.remove_from_all_wishlists,
					nonce: yith_wcwl_l10n.nonce.remove_from_all_wishlists_nonce,
					context: 'frontend',
					prod_id: prod_id,
					wishlist_id: wishlist_id,
					fragments: retrieve_fragments( prod_id )
				};

			ev.preventDefault();

			$.ajax( {
				beforeSend: function () {
					block( content );
				},
				complete: function () {
					unblock( content );
				},
				data: data,
				dataType: 'json',
				method: 'post',
				success: function ( data ) {
					if ( typeof data.fragments !== 'undefined' ) {
						replace_fragments( data.fragments );
					}

					init_handling_after_ajax();
				},
				url: yith_wcwl_l10n.ajax_url
			} );
		} );

		t.on( 'click', '.hide-title-form', hide_title_form );

		t.on( 'click', '.save-title-form', submit_title_form );

		t.on( 'change', '.wishlist_manage_table .wishlist-visibility', save_privacy );

		t.on( 'change', '.change-wishlist', function () {
			var t = $( this ),
				table = t.parents( '.cart.wishlist_table' ),
				wishlist_token = table.data( 'token' ),
				item_id = t.parents( '[data-row-id]' ).data( 'row-id' ),
				to_token = t.val();

			call_ajax_move_item_to_another_wishlist(
				{
					wishlist_token: wishlist_token,
					destination_wishlist_token: to_token,
					item_id: item_id,
					fragments: retrieve_fragments()
				},
				function () {
					block( table );
				},
				function ( data ) {
					if ( typeof data.fragments !== 'undefined' ) {
						replace_fragments( data.fragments );
					}

					unblock( table );
				}
			);
		} );

		t.on( 'click', '.yith-wcwl-popup-footer .move_to_wishlist', function () {
			var t = $( this ),
				product_id = t.attr( 'data-product-id' ),
				wishlist_token = t.data( 'origin-wishlist-id' ),
				form = t.closest( 'form' ),
				to_token = form.find( '.wishlist-select' ).val(),
				wishlist_name_field = form.find( '.wishlist-name' ),
				wishlist_name = wishlist_name_field.val(),
				wishlist_visibility = form.find( '.wishlist-visibility' ).filter( ':checked' ).val();

			if ( 'new' === to_token && ! wishlist_name ) {
				wishlist_name_field.closest( 'p' ).addClass( 'woocommerce-invalid' );
				return false;
			} else {
				wishlist_name_field.closest( 'p' ).removeClass( 'woocommerce-invalid' );
			}

			call_ajax_move_item_to_another_wishlist(
				{
					wishlist_token: wishlist_token,
					destination_wishlist_token: to_token,
					item_id: product_id,
					wishlist_name: wishlist_name,
					wishlist_visibility: wishlist_visibility,
					fragments: retrieve_fragments( product_id )
				},
				function () {
					block( t );
				},
				function ( response ) {
					var response_message = response.message;

					if ( yith_wcwl_l10n.multi_wishlist ) {
						close_pretty_photo( response_message );

						if ( typeof (response.user_wishlists) !== 'undefined' ) {
							update_wishlists( response.user_wishlists );
						}
					} else {
						print_message( response_message );
					}

					if ( typeof response.fragments !== 'undefined' ) {
						replace_fragments( response.fragments );
					}

					init_handling_after_ajax();

					unblock( t );
				}
			);
		} );

		t.on( 'click', '.delete_item', function () {
			var t = $( this ),
				product_id = t.attr( 'data-product-id' ),
				item_id = t.data( 'item-id' ),
				el_wrap = $( '.add-to-wishlist-' + product_id ),
				data = {
					action: yith_wcwl_l10n.actions.delete_item_action,
					nonce: yith_wcwl_l10n.nonce.delete_item_nonce,
					context: 'frontend',
					item_id: item_id,
					fragments: retrieve_fragments( product_id )
				};

			$.ajax( {
				url: yith_wcwl_l10n.ajax_url,
				data: data,
				dataType: 'json',
				beforeSend: function () {
					block( t );
				},
				complete: function () {
					unblock( t );
				},
				method: 'post',
				success: function ( response ) {
					var fragments = response.fragments,
						response_message = response.message;

					if ( yith_wcwl_l10n.multi_wishlist ) {
						close_pretty_photo( response_message );
					}

					if ( ! t.closest( '.yith-wcwl-remove-button' ).length ) {
						print_message( response_message );
					}

					if ( typeof fragments !== 'undefined' ) {
						replace_fragments( fragments );
					}

					init_handling_after_ajax();

					$( 'body' ).trigger( 'removed_from_wishlist', [ t, el_wrap ] );
				}
			} );

			return false;
		} );

		t.on( 'change', '.yith-wcwl-popup-content .wishlist-select', function () {
			var t = $( this );

			if ( t.val() === 'new' ) {
				t.parents( '.yith-wcwl-first-row' ).next( '.yith-wcwl-second-row' ).show();
			} else {
				t.parents( '.yith-wcwl-first-row' ).next( '.yith-wcwl-second-row' ).hide();
			}
		} );

		t.on( 'change', '#bulk_add_to_cart', function () {
			var t = $( this ),
				checkboxes = t.closest( '.wishlist_table' ).find( '[data-row-id]' ).find( 'input[type="checkbox"]:not(:disabled)' );

			if ( t.is( ':checked' ) ) {
				checkboxes.prop( 'checked', 'checked' ).change();
			} else {
				checkboxes.prop( 'checked', false ).change();
			}
		} );

		t.on( 'submit', '.wishlist-ask-an-estimate-popup', function () {
			var t = $( this ),
				form = t.closest( 'form' ),
				pp_content = t.closest( '.pp_content' ),
				data = form.serializeArray().reduce( ( data, field ) => {
					data[ field.name ] = field.value;
					return data;
				}, {} );

			data.action = yith_wcwl_l10n.actions.ask_an_estimate;
			data.nonce = yith_wcwl_l10n.nonce.ask_an_estimate_nonce;
			data.context = 'frontend';

			$.ajax( {
				beforeSend: function () {
					block( form );
				},
				complete: function () {
					unblock( form );
				},
				data: data,
				dataType: 'json',
				method: 'post',
				success: function ( data ) {
					if ( typeof data.result !== 'undefined' && data.result ) {
						var template = data.template;

						if ( typeof template !== 'undefined' ) {
							form.replaceWith( template );
							pp_content.css( 'height', 'auto' );

							setTimeout( close_pretty_photo, yith_wcwl_l10n.time_to_close_prettyphoto );
						}
					} else if ( typeof data.message !== 'undefined' ) {
						form.find( '.woocommerce-error' ).remove();
						form.find( '.popup-description' ).after( $( '<div>', {
							'text': data.message,
							'class': 'woocommerce-error'
						} ) );
					}
				},
				url: yith_wcwl_l10n.ajax_url
			} );

			return false;
		} );

		t.on( 'click', '.yith-wfbt-add-wishlist', function ( e ) {
			e.preventDefault();
			var t = $( this ),
				form = $( '#yith-wcwl-form' );

			$( 'html, body' ).animate( {
				scrollTop: (form.offset().top)
			}, 500 );

			// ajax call
			reload_wishlist_and_adding_elem( t, form );
		} );

		t.on( 'submit', '.yith-wcwl-popup-form', function () {
			return false;
		} );

		t.on( 'yith_infs_added_elem', function () {
			init_wishlist_pretty_photo();
		} );

		t.on( 'found_variation', function ( ev, variation ) {
			var t = $( ev.target ),
				product_id = t.data( 'product_id' ),
				variation_id = variation.variation_id,
				target1 = $( '.yith-wcwl-add-to-wishlist' )
					.find( '[data-product-id="' + product_id + '"]' ),
				target2 = $( '.yith-wcwl-add-to-wishlist' )
					.find( '[data-original-product-id="' + product_id + '"]' ),
				targets = target1.add( target2 ),
				fragments = targets.closest( '.wishlist-fragment' ).filter( ':visible' );

			if ( ! product_id || ! variation_id || ! targets.length ) {
				return;
			}

			targets.each( function () {
				var t = $( this ),
					container = t.closest( '.yith-wcwl-add-to-wishlist' ),
					options;

				t.attr( 'data-original-product-id', product_id );
				t.attr( 'data-product-id', variation_id );

				if ( container.length ) {
					options = container.data( 'fragment-options' );

					if ( typeof options !== 'undefined' ) {
						options.product_id = variation_id;
						container.data( 'fragment-options', options );
					}

					container
						.removeClass( function ( i, classes ) {
							return classes.match( /add-to-wishlist-\S+/g ).join( ' ' );
						} )
						.addClass( 'add-to-wishlist-' + variation_id )
						.attr( 'data-fragment-ref', variation_id );
				}
			} );

			if ( ! yith_wcwl_l10n.reload_on_found_variation ) {
				return;
			}

			block( fragments );

			load_fragments( {
				fragments: fragments,
				firstLoad: false
			} );
		} );

		t.on( 'reset_data', function ( ev ) {
			var t = $( ev.target ),
				product_id = t.data( 'product_id' ),
				targets = $( '[data-original-product-id="' + product_id + '"]' ),
				fragments = targets.closest( '.wishlist-fragment' ).filter( ':visible' );

			if ( ! product_id || ! targets.length ) {
				return;
			}

			targets.each( function () {
				var t = $( this ),
					container = t.closest( '.yith-wcwl-add-to-wishlist' ),
					variation_id = t.attr( 'data-product-id' ),
					options;

				t.attr( 'data-product-id', product_id );
				t.attr( 'data-original-product-id', '' );

				if ( container.length ) {
					options = container.data( 'fragment-options' );

					if ( typeof options !== 'undefined' ) {
						options.product_id = product_id;
						container.data( 'fragment-options', options );
					}

					container
						.removeClass( 'add-to-wishlist-' + variation_id )
						.addClass( 'add-to-wishlist-' + product_id )
						.attr( 'data-fragment-ref', product_id );
				}
			} );

			if ( ! yith_wcwl_l10n.reload_on_found_variation ) {
				return;
			}

			block( fragments );

			load_fragments( {
				fragments: fragments,
				firstLoad: false
			} );

		} );

		t.on( 'yith_wcwl_reload_fragments', ( event, data ) => load_fragments( data ) );

		t.on( 'yith_wcwl_reload_after_ajax', init_handling_after_ajax );

		t.on( 'yith_infs_added_elem', function ( ev, elem ) {
			load_fragments( {
				container: elem,
				firstLoad: false
			} );
		} );

		t.on( 'yith_wcwl_fragments_loaded', function ( ev, original, update, firstLoad ) {
			if ( ! firstLoad ) {
				return;
			}

			$( '.variations_form' ).find( '.variations select' ).last().change();
		} );

		t.on( 'click', '.yith-wcwl-popup-feedback .close-popup', function ( ev ) {
			ev.preventDefault();

			close_pretty_photo();
		} );

		init_wishlist_popup();

		init_wishlist_tooltip();

		init_wishlist_dropdown();

		init_wishlist_drag_n_drop();

		init_quantity();

		init_wishlist_details_popup();

		init_wishlist_popup_tabs();

		init_select_box();

		init_checkbox_handling();

		init_wishlist_pretty_photo();

		init_add_to_cart_icon();

		init_wishlist_responsive();

		init_copy_wishlist_link();

		if ( yith_wcwl_l10n.enable_ajax_loading ) {
			load_fragments();
		}

	} ).trigger( 'yith_wcwl_init' );

	// Avoid pressing the enter key in the qty input.
	$( 'form#yith-wcwl-form .wishlist_table .product-quantity input' ).on( 'keypress', function ( e ) {
		if ( e.keyCode == '13' ) {
			e.preventDefault();
			return false;
		}
	} );

	// Move the Add to Wishlist button under the gallery
	$( document ).ready( function () {
		if ( yith_wcwl_l10n.yith_wcwl_button_position === 'thumbnails' ) {
			$( '.woocommerce-product-gallery + div.yith-wcwl-add-to-wishlist' ).appendTo( '.woocommerce-product-gallery' );
		}
	} );

	$( document ).on( 'keydown', '#yith-wcwl-form input[name="wishlist_name"]', function ( event ) {
		const key = event.key;
		if ( [ 'Enter', 'Escape' ].includes( key ) ) {
			const $container = $( this ).closest( '.wishlist-title-container' );
			if ( 'Enter' === key ) {
				$container.find( 'a.save-title-form' ).trigger( 'click' );
			} else {
				$container.find( 'a.hide-title-form' ).trigger( 'click' );
			}

			event.preventDefault();
		}
	} )


	/* === INIT FUNCTIONS === */

	/**
	 * Adds selectbox where needed
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_select_box() {
		if ( typeof $.fn.selectBox !== 'undefined' ) {
			$( 'select.selectBox' ).filter( ':visible' ).not( '.enhanced' ).selectBox().addClass( 'enhanced' );
		}
	}

	/**
	 * Init PrettyPhoto for all links withi the plugin that open a popup
	 *
	 * @return void
	 * @since 2.0.16
	 */
	function init_wishlist_pretty_photo() {
		if ( typeof $.prettyPhoto === 'undefined' ) {
			return;
		}

		var ppParams = {
			hook: 'data-rel',
			social_tools: false,
			theme: 'pp_woocommerce yith-wcwl-pp-modal',
			horizontal_padding: 20,
			opacity: 0.8,
			deeplinking: false,
			overlay_gallery: false,
			keyboard_shortcuts: false,
			default_width: 500,
			changepicturecallback: function () {
				init_select_box();

				$( '.wishlist-select' ).filter( ':visible' ).change();
				$( document ).trigger( 'yith_wcwl_popup_opened', [ this ] );
			},
			markup: '<div class="pp_pic_holder">' +
				'<div class="pp_content_container">' +
				'<div class="pp_content">' +
				'<div class="pp_loaderIcon"></div>' +
				'<div class="pp_fade">' +
				'<a href="#" class="pp_expand" title="Expand the image">Expand</a>' +
				'<div class="pp_hoverContainer">' +
				'<a class="pp_next" href="#">next</a>' +
				'<a class="pp_previous" href="#">previous</a>' +
				'</div>' +
				'<div id="pp_full_res"></div>' +
				'<div class="pp_details">' +
				'<a class="pp_close" href="#">Close</a>' +
				'</div>' +
				'</div>' +
				'</div>' +
				'</div>' +
				'</div>' +
				'<div class="pp_overlay yith-wcwl-overlay"></div>'
		};

		$( 'a[data-rel^="prettyPhoto[add_to_wishlist_"]' )
			.add( 'a[data-rel="prettyPhoto[ask_an_estimate]"]' )
			.add( 'a[data-rel="prettyPhoto[create_wishlist]"]' )
			.off( 'click' )
			.prettyPhoto( ppParams );

		$( 'a[data-rel="prettyPhoto[move_to_another_wishlist]"]' ).on( 'click', function () {
			var t = $( this ),
				popup = $( '#move_to_another_wishlist' ),
				form = popup.find( 'form' ),
				row_id = form.find( '.row-id' ),
				id = t.closest( '[data-row-id]' ).data( 'row-id' );

			if ( row_id.length ) {
				row_id.remove();
			}

			form.append( '<input type="hidden" name="row_id" class="row-id" value="' + id + '"/>' );
		} ).prettyPhoto( ppParams );

		// add & remove class to body when popup is opened
		var callback = function ( node, op ) {
				if ( typeof node.classList !== 'undefined' && node.classList.contains( 'yith-wcwl-overlay' ) ) {
					var method = 'remove' === op ? 'removeClass' : 'addClass';

					$( 'body' )[ method ]( 'yith-wcwl-with-pretty-photo' );
				}
			},
			callbackAdd = function ( node ) {
				callback( node, 'add' );
			},
			callbackRemove = function ( node ) {
				callback( node, 'remove' );
			},
			observer = new MutationObserver( function ( mutationsList ) {
				for ( var i in mutationsList ) {
					var mutation = mutationsList[ i ];
					if ( mutation.type === 'childList' ) {
						typeof mutation.addedNodes !== 'undefined' && typeof mutation.addedNodes.forEach === 'function' && mutation.addedNodes.forEach( callbackAdd );
						typeof mutation.removedNodes !== 'undefined' && typeof mutation.addedNodes.forEach === 'function' && mutation.removedNodes.forEach( callbackRemove );
					}
				}
			} );

		observer.observe( document.body, {
			childList: true
		} );
	}

	/**
	 * Init checkbox handling
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_checkbox_handling() {
		var checkboxes = $( '.wishlist_table' ).find( '.product-checkbox input[type="checkbox"]' );

		checkboxes.off( 'change' ).on( 'change', function () {
			var t = $( this ),
				p = t.parent();

			p
				.removeClass( 'checked' )
				.removeClass( 'unchecked' )
				.addClass( t.is( ':checked' ) ? 'checked' : 'unchecked' );
		} ).trigger( 'change' );
	}

	/**
	 * Show icon on Add to Cart button
	 *
	 * @return void
	 */
	function init_add_to_cart_icon() {
		$( '.add_to_cart' ).filter( '[data-icon]' ).not( '.icon-added' ).each( function () {
			var t = $( this ),
				data = t.data( 'icon' ),
				icon;

			if ( data.match( /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi ) ) {
				icon = $( '<img/>', { 'src': data } );
			} else {
				icon = $( '<i/>', { 'class': 'fa ' + data } );
			}

			t.prepend( icon ).addClass( 'icon-added' );
		} );
	}

	/**
	 * Init js handling on wishlist table items after ajax update
	 *
	 * @return void
	 * @since 2.0.7
	 */
	function init_handling_after_ajax() {
		init_select_box();
		init_wishlist_pretty_photo();
		init_checkbox_handling();
		init_add_to_cart_icon();
		init_wishlist_dropdown();
		init_wishlist_tooltip();
		init_wishlist_details_popup();
		init_wishlist_drag_n_drop();
		init_quantity();
		init_copy_wishlist_link();

		$( document ).trigger( 'yith_wcwl_init_after_ajax' );
	}

	/**
	 * Add tooltip to Add to Wishlist buttons
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_wishlist_tooltip() {
		if ( ! yith_wcwl_l10n.enable_tooltip ) {
			return;
		}

		$( '.yith-wcwl-add-to-wishlist' ).find( '[data-title]' ).each( function () {
			var t = $( this );

			if ( t.hasClass( 'tooltip-added' ) ) {
				return;
			}

			t
				.on( 'mouseenter', function () {
					var t = $( this );

					var tooltip = $( '<span>', { 'class': 'yith-wcwl-tooltip', 'text': t.data( 'title' ) } );

					t.append( tooltip );

					var width = tooltip.outerWidth() + 6;
					tooltip.outerWidth( width );

					tooltip.fadeIn( 200 );

					t.addClass( 'with-tooltip' );
				} )
				.on( 'mouseleave', function () {
					var t = $( this );

					t.find( '.yith-wcwl-tooltip' ).fadeOut( 200, function () {
						t.removeClass( 'with-tooltip' ).find( '.yith-wcwl-tooltip' ).remove();
					} );
				} );

			t.addClass( 'tooltip-added' );
		} );
	}

	/**
	 * Add wishlist popup message
	 *
	 * @return void
	 * @since 2.0.0
	 */
	function init_wishlist_popup() {
		if ( typeof yith_wcwl_l10n.enable_notices !== 'undefined' && ! yith_wcwl_l10n.enable_notices ) {
			return;
		}

		if ( $( '.yith-wcwl-add-to-wishlist' ).length && ! $( '#yith-wcwl-popup-message' ).length ) {
			var message_div = $( '<div>' )
					.attr( 'id', 'yith-wcwl-message' ),
				popup_div = $( '<div>' )
					.attr( 'id', 'yith-wcwl-popup-message' )
					.html( message_div )
					.hide();

			$( 'body' ).prepend( popup_div );
		}
	}

	/**
	 * Add Dropdown to Add to Wishlist when modal is disabled and Multi Wishlist enabled
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_wishlist_dropdown() {
		$( '.yith-wcwl-add-button' ).filter( '.with-dropdown' )
			.on( 'mouseleave', function () {
				var t = $( this ),
					dropdown = t.find( '.yith-wcwl-dropdown' );

				if ( dropdown.length ) {
					dropdown.fadeOut( 200 );
				}
			} )
			.children( 'a' )
			.on( 'mouseenter', function () {
				var t = $( this ),
					el_wrap = t.closest( '.with-dropdown' ),
					dropdown = el_wrap.find( '.yith-wcwl-dropdown' );

				if ( dropdown.length && dropdown.children().length ) {
					el_wrap.find( '.yith-wcwl-dropdown' ).fadeIn( 200 );
				}
			} );
	}

	/**
	 * Handle Drag & Drop of wishlist items for sorting
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_wishlist_drag_n_drop() {
		if ( typeof yith_wcwl_l10n.enable_drag_n_drop === 'undefined' || ! yith_wcwl_l10n.enable_drag_n_drop ) {
			return;
		}

		$( '.wishlist_table' ).filter( '.sortable' ).not( '.no-interactions' ).each( function () {
			var t = $( this ),
				jqxhr = false;

			t.sortable( {
				items: '[data-row-id]',
				scroll: true,
				helper: function ( e, ui ) {
					ui.children().each( function () {
						$( this ).width( $( this ).width() );
					} );
					return ui;
				},
				update: function () {
					var row = t.find( '[data-row-id]' ),
						positions = [],
						i = 0;

					if ( ! row.length ) {
						return;
					}

					if ( jqxhr ) {
						jqxhr.abort();
					}

					row.each( function () {
						var t = $( this );

						t.find( 'input[name*="[position]"]' ).val( i++ );

						positions.push( t.data( 'row-id' ) );
					} );

					jqxhr = $.ajax( {
						data: {
							action: yith_wcwl_l10n.actions.sort_wishlist_items,
							nonce: yith_wcwl_l10n.nonce.sort_wishlist_items_nonce,
							context: 'frontend',
							positions: positions,
							wishlist_token: t.data( 'token' ),
							page: t.data( 'page' ),
							per_page: t.data( 'per-page' )
						},
						method: 'POST',
						url: yith_wcwl_l10n.ajax_url
					} );
				}
			} );
		} );
	}

	/**
	 * Handle quantity input change for each wishlist item
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_quantity() {
		var jqxhr,
			timeout;

		$( '.wishlist_table' ).on( 'change', '.product-quantity :input', function () {
			var t = $( this ),
				row = t.closest( '[data-row-id]' ),
				product_id = row.data( 'row-id' ),
				table = t.closest( '.wishlist_table' ),
				token = table.data( 'token' );

			clearTimeout( timeout );

			// set add to cart link to add specific qty to cart
			row.find( '.add_to_cart' ).attr( 'data-quantity', t.val() );

			timeout = setTimeout( function () {
				if ( jqxhr ) {
					jqxhr.abort();
				}

				jqxhr = $.ajax( {
					beforeSend: function () {
						block( table );
					},
					complete: function () {
						unblock( table );
					},
					data: {
						action: yith_wcwl_l10n.actions.update_item_quantity,
						nonce: yith_wcwl_l10n.nonce.update_item_quantity_nonce,
						context: 'frontend',
						product_id: product_id,
						wishlist_token: token,
						quantity: t.val()
					},
					method: 'POST',
					url: yith_wcwl_l10n.ajax_url
				} );
			}, 1000 );
		} );
	}

	/**
	 * Init handling for copy button
	 *
	 * @return void
	 * @since 2.2.11
	 */
	function init_copy_wishlist_link() {
		$( '.copy-trigger' ).on( 'click', function () {

			var obj_to_copy = $( '.copy-target' );

			if ( obj_to_copy.length > 0 ) {
				if ( obj_to_copy.is( 'input' ) ) {

					if ( isOS() ) {

						obj_to_copy[ 0 ].setSelectionRange( 0, 9999 );
					} else {
						obj_to_copy.select();
					}
					document.execCommand( 'copy' );
				} else {

					var hidden = $( '<input/>', {
						val: obj_to_copy.text(),
						type: 'text'
					} );

					$( 'body' ).append( hidden );

					if ( isOS() ) {
						hidden[ 0 ].setSelectionRange( 0, 9999 );
					} else {
						hidden.select();
					}
					document.execCommand( 'copy' );

					hidden.remove();
				}
			}
		} );
	}

	/**
	 * Handle popup for images grid layout
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_wishlist_details_popup() {

		$( '.wishlist_table' ).filter( '.images_grid' ).not( '.enhanced' )
			.on( 'click', '[data-row-id] .product-thumbnail a', function ( ev ) {
				if ( ! yith_wcwl_l10n.disable_popup_grid_view ) {
					var t = $( this ),
						item = t.closest( '[data-row-id]' ),
						items = item.siblings( '[data-row-id]' ),
						popup = item.find( '.item-details' );

					ev.preventDefault();

					if ( popup.length ) {
						items.removeClass( 'show' );
						item.toggleClass( 'show' );
					}
				}
			} )
			.on( 'click', '[data-row-id] a.close', function ( ev ) {
				var t = $( this ),
					item = t.closest( '[data-row-id]' ),
					popup = item.find( '.item-details' );

				ev.preventDefault();

				if ( popup.length ) {
					item.removeClass( 'show' );
				}
			} )
			.on( 'click', '[data-row-id] a.remove_from_wishlist', function ( ev ) {
				var t = $( this );

				ev.stopPropagation();

				remove_item_from_wishlist( t );

				return false;
			} )
			.addClass( 'enhanced' );


		$( document )
			.on( 'click', function ( ev ) {
				if ( ! $( ev.target ).closest( '[data-row-id]' ).length ) {
					$( '.wishlist_table' ).filter( '.images_grid' ).find( '.show' ).removeClass( 'show' );
				}
			} )
			.on( 'added_to_cart', function () {
				$( '.wishlist_table' ).filter( '.images_grid' ).find( '.show' ).removeClass( 'show' );
			} );
	}

	/**
	 * Handle tabs inside wishlist popups
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_wishlist_popup_tabs() {
		$( document ).on( 'click', '.show-tab', function ( ev ) {
			var t = $( this ),
				container = t.closest( '.yith-wcwl-popup-content' ),
				tab = t.data( 'tab' ),
				target = container.find( '.tab' ).filter( '.' + tab );

			ev.preventDefault();

			if ( ! target.length ) {
				return false;
			}

			t.addClass( 'active' ).siblings( '.show-tab' ).removeClass( 'active' );

			target.show().siblings( '.tab' ).hide();

			if ( 'create' === tab ) {
				container.prepend( '<input type="hidden" id="new_wishlist_selector" class="wishlist-select" value="new">' );
			} else {
				container.find( '#new_wishlist_selector' ).remove();
			}

			$( document ).trigger( 'yith_wcwl_tab_selected', [ tab, target ] );
		} );

		$( document ).on( 'change', '.wishlist-select', function () {
			var t = $( this ),
				container = t.closest( '.yith-wcwl-popup-content' ),
				tab = t.closest( '.tab' ),
				createTab = container.find( '.tab.create' ),
				showTab = container.find( '.show-tab' ),
				createShowTab = showTab.filter( '[data-tab="create"]' ),
				val = t.val();

			if ( val === 'new' && createTab.length ) {
				tab.hide();
				createTab.show();

				showTab.removeClass( 'active' );
				createShowTab.addClass( 'active' );
				t.find( 'option:selected' ).prop( 'selected', false );
				t.change();
			}
		} );
	}

	/**
	 * Init responsive behaviour of the wishlist
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function init_wishlist_responsive() {
		var jqxhr = false;

		if ( ! yith_wcwl_l10n.is_wishlist_responsive ) {
			return;
		}

		$( window ).on( 'resize', function () {
			var table = $( '.wishlist_table.responsive' ),
				mobile = table.is( '.mobile' ),
				media = window.matchMedia( '(max-width: ' + yith_wcwl_l10n.mobile_media_query + 'px)' ),
				form = table.closest( 'form' ),
				id = form.attr( 'class' ),
				options = form.data( 'fragment-options' ),
				fragments = {},
				load = false;

			if ( ! table.length ) {
				return;
			}

			if ( media.matches && table && ! mobile ) {
				options.is_mobile = 'yes';
				load = true;
			} else if ( ! media.matches && table && mobile ) {
				options.is_mobile = 'no';
				load = true;
			}

			if ( load ) {
				if ( jqxhr ) {
					jqxhr.abort();
				}

				fragments[ id.split( ' ' ).join( yith_wcwl_l10n.fragments_index_glue ) ] = options;

				jqxhr = $.ajax( {
					beforeSend: function () {
						block( table );
					},
					complete: function () {
						unblock( table );
					},
					data: {
						action: yith_wcwl_l10n.actions.load_mobile_action,
						nonce: yith_wcwl_l10n.nonce.load_mobile_nonce,
						context: 'frontend',
						fragments: fragments
					},
					method: 'post',
					success: function ( data ) {
						if ( typeof data.fragments !== 'undefined' ) {
							replace_fragments( data.fragments );

							init_handling_after_ajax();

							$( document ).trigger( 'yith_wcwl_responsive_template', [ mobile, data.fragments ] );
						}
					},
					url: yith_wcwl_l10n.ajax_url
				} );
			}
		} );
	}

	/* === EVENT HANDLING === */

	/**
	 * Move item to another wishlist
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function call_ajax_move_item_to_another_wishlist( data, beforeSend, complete ) {
		data.action = yith_wcwl_l10n.actions.move_to_another_wishlist_action;
		data.nonce = yith_wcwl_l10n.nonce.move_to_another_wishlist_nonce;
		data.context = 'frontend';

		if ( data.wishlist_token === '' || data.destination_wishlist_token === '' || data.item_id === '' ) {
			return;
		}

		$.ajax( {
			beforeSend: beforeSend,
			url: yith_wcwl_l10n.ajax_url,
			data: data,
			dataType: 'json',
			method: 'post',
			success: function ( response ) {
				complete( response );

				init_handling_after_ajax();

				$( 'body' ).trigger( 'moved_to_another_wishlist', [ $( this ), data.item_id ] );
			}
		} );
	}

	/**
	 * Remove a product from the wishlist.
	 *
	 * @param el
	 * @return void
	 * @since 1.0.0
	 */
	function remove_item_from_wishlist( el ) {
		var table = el.parents( '.cart.wishlist_table' ),
			row = el.parents( '[data-row-id]' ),
			data_row_id = row.data( 'row-id' ),
			wishlist_id = table.data( 'id' ),
			wishlist_token = table.data( 'token' ),
			data = {
				action: yith_wcwl_l10n.actions.remove_from_wishlist_action,
				nonce: yith_wcwl_l10n.nonce.remove_from_wishlist_nonce,
				context: 'frontend',
				remove_from_wishlist: data_row_id,
				wishlist_id: wishlist_id,
				wishlist_token: wishlist_token,
				fragments: retrieve_fragments( data_row_id )
			};

		$.ajax( {
			beforeSend: function () {
				block( table );
			},
			complete: function () {
				unblock( table );
			},
			data: data,
			method: 'post',
			success: function ( data ) {
				if ( typeof data.fragments !== 'undefined' ) {
					replace_fragments( data.fragments );
				}

				init_handling_after_ajax();

				$( 'body' ).trigger( 'removed_from_wishlist', [ el, row ] );
			},
			url: yith_wcwl_l10n.ajax_url
		} );
	}

	/**
	 * Remove a product from the wishlist.
	 *
	 * @param el
	 * @param form
	 * @return void
	 * @since 1.0.0
	 */
	function reload_wishlist_and_adding_elem( el, form ) {

		var product_id = el.attr( 'data-product-id' ),
			table = $( document ).find( '.cart.wishlist_table' ),
			pagination = table.data( 'pagination' ),
			per_page = table.data( 'per-page' ),
			wishlist_id = table.data( 'id' ),
			wishlist_token = table.data( 'token' ),
			data = {
				action: yith_wcwl_l10n.actions.reload_wishlist_and_adding_elem_action,
				nonce: yith_wcwl_l10n.nonce.reload_wishlist_and_adding_elem_nonce,
				context: 'frontend',
				pagination: pagination,
				per_page: per_page,
				wishlist_id: wishlist_id,
				wishlist_token: wishlist_token,
				add_to_wishlist: product_id,
				product_type: el.data( 'product-type' )
			};

		if ( ! is_cookie_enabled() ) {
			window.alert( yith_wcwl_l10n.labels.cookie_disabled );
			return;
		}

		$.ajax( {
			type: 'POST',
			url: yith_wcwl_l10n.ajax_url,
			data: data,
			dataType: 'html',
			beforeSend: function () {
				block( table );
			},
			complete: function () {
				unblock( table );
			},
			success: function ( res ) {
				var obj = $( res ),
					new_form = obj.find( '#yith-wcwl-form' ), // get new form
					shortcode = obj.find( '.yith-wfbt-slider-wrapper' ); // get new form

				form.replaceWith( new_form );
				$( '.yith-wfbt-slider-wrapper' ).replaceWith( shortcode );
				init_handling_after_ajax();

				$( document ).trigger( 'yith_wcwl_reload_wishlist_from_frequently' );
			}
		} );
	}

	/**
	 * Show form to edit wishlist title
	 *
	 * @param ev event
	 * @return void
	 * @since 2.0.0
	 */
	function show_title_form( ev ) {
		var t = $( this ),
			table = t.closest( '.wishlist_table' ),
			title = null;
		ev.preventDefault();

		// if button is in table
		if ( table.length ) {
			title = t.closest( '[data-wishlist-id]' ).find( '.wishlist-title' );
		} else {
			title = t.parents( '.wishlist-title' );
		}

		title.next().css( 'display', 'inline-block' ).find( 'input[type="text"]' ).focus();
		title.hide();
	}

	/**
	 * Hide form to edit wishlist title
	 *
	 * @param ev event
	 * @return void
	 * @since 2.0.0
	 */
	function hide_title_form( ev ) {
		var t = $( this );
		ev.preventDefault();

		t.parents( '.hidden-title-form' ).hide();
		t.parents( '.hidden-title-form' ).prev().show();
	}

	/**
	 * Submit form to save a new wishlist title
	 *
	 * @param ev event
	 * @return void
	 * @since 2.0.7
	 */
	function submit_title_form( ev ) {
		var t = $( this ),
			form = t.closest( '.hidden-title-form' ),
			row = t.closest( '[data-wishlist-id]' ),
			wishlist_id = row.data( 'wishlist-id' ),
			title_input = form.find( 'input[type="text"]' ),
			new_title = title_input.val(),
			data = {};

		ev.preventDefault();

		if ( ! new_title ) {
			form.addClass( 'woocommerce-invalid' );
			title_input.focus();
			return;
		}

		if ( ! wishlist_id ) {
			wishlist_id = $( '#wishlist_id' ).val();
		}

		data = {
			action: yith_wcwl_l10n.actions.save_title_action,
			nonce: yith_wcwl_l10n.nonce.save_title_nonce,
			context: 'frontend',
			wishlist_id: wishlist_id,
			title: new_title,
			fragments: retrieve_fragments()
		};

		$.ajax( {
			type: 'POST',
			url: yith_wcwl_l10n.ajax_url,
			data: data,
			dataType: 'json',
			beforeSend: function () {
				block( form );
			},
			complete: function () {
				unblock( form );
			},
			success: function ( response ) {
				var fragments = response.fragments,
					status = response.result;

				if ( status ) {
					form.hide();
					form.prev().find( '.wishlist-anchor, h1, h2' ).text( new_title ).end().show();
				} else {
					form.addClass( 'woocommerce-invalid' );
					title_input.focus();
				}

				if ( typeof fragments !== 'undefined' ) {
					replace_fragments( fragments );
				}

				init_handling_after_ajax();
			}
		} );
	}

	/**
	 * Submit form to save a new wishlist privacy
	 *
	 * @return void
	 * @since 2.0.7
	 */
	function save_privacy() {
		var t = $( this ),
			new_privacy = t.val(),
			row = t.closest( '[data-wishlist-id]' ),
			wishlist_id = row.data( 'wishlist-id' ),
			data = {
				action: yith_wcwl_l10n.actions.save_privacy_action,
				nonce: yith_wcwl_l10n.nonce.save_privacy_nonce,
				context: 'frontend',
				wishlist_id: wishlist_id,
				privacy: new_privacy,
				fragments: retrieve_fragments()
			};

		$.ajax( {
			type: 'POST',
			url: yith_wcwl_l10n.ajax_url,
			data: data,
			dataType: 'json',
			success: function ( response ) {
				var fragments = response.fragments;

				if ( typeof fragments !== 'undefined' ) {
					replace_fragments( fragments );
				}
			}
		} );
	}

	/* === UTILS === */

	/**
	 * Closes pretty photo popup, if any
	 *
	 * @return void
	 * @since 3.0.0
	 */
	function close_pretty_photo( message, status ) {
		if ( typeof $.prettyPhoto !== 'undefined' && typeof $.prettyPhoto.close !== 'undefined' ) {
			if ( typeof message !== 'undefined' ) {
				var container = $( '.pp_content_container' ),
					content = container.find( '.pp_content' ),
					form = container.find( '.yith-wcwl-popup-form' ),
					popup = form.closest( '.pp_pic_holder' );

				if ( form.length ) {
					var new_content = $( '<div/>', {
						'class': 'yith-wcwl-popup-feedback'
					} );

					new_content.append( $( '<i/>', { 'class': 'fa heading-icon ' + ('error' === status ? 'fa-exclamation-triangle' : 'fa-check') } ) );
					new_content.append( $( '<p/>', { 'class': 'feedback', 'html': message } ) );
					new_content.css( 'display', 'none' );

					content.css( 'height', 'auto' );

					form.after( new_content );
					form.fadeOut( 200, function () {
						new_content.fadeIn();
					} );

					popup.addClass( 'feedback' );
					popup.css( 'left', (($( window ).innerWidth() / 2) - (popup.outerWidth() / 2)) + 'px' );

					if ( typeof yith_wcwl_l10n.auto_close_popup === 'undefined' || yith_wcwl_l10n.auto_close_popup ) {
						setTimeout( close_pretty_photo, yith_wcwl_l10n.popup_timeout );
					}
				}
			} else {
				try {
					$.prettyPhoto.close();

					if ( yith_wcwl_l10n.redirect_after_ask_estimate ) {
						window.location.replace( yith_wcwl_l10n.ask_estimate_redirect_url );
					}
				} catch ( e ) { /* do nothing, no popup to close */
				}
			}
		}
	}

	/**
	 * Print wishlist message for the user
	 *
	 * @var response_message string Message to print
	 * @return void
	 * @since 3.0.0
	 */
	function print_message( response_message ) {
		var msgPopup = $( '#yith-wcwl-popup-message' ),
			msg = $( '#yith-wcwl-message' ),
			timeout = typeof yith_wcwl_l10n.popup_timeout !== 'undefined' ? yith_wcwl_l10n.popup_timeout : 3000;

		if ( typeof yith_wcwl_l10n.enable_notices !== 'undefined' && ! yith_wcwl_l10n.enable_notices ) {
			return;
		}

		msg.html( response_message );
		msgPopup.css( 'margin-left', '-' + $( msgPopup ).width() + 'px' ).fadeIn();
		window.setTimeout( function () {
			msgPopup.fadeOut();
		}, timeout );
	}

	/**
	 * Update lists after a new list is added
	 *
	 * @param wishlists array Array of wishlists
	 * @return void
	 * @since 3.0.0
	 */
	function update_wishlists( wishlists ) {
		var wishlist_select = $( 'select.wishlist-select' ),
			wishilst_dropdown = $( 'ul.yith-wcwl-dropdown' );

		// update options for all wishlist selects
		wishlist_select.each( function () {
			var t = $( this ),
				wishlist_options = t.find( 'option' ),
				new_option = wishlist_options.filter( '[value="new"]' );

			wishlist_options.not( new_option ).remove();

			$.each( wishlists, function ( i, v ) {
				$( '<option>', { value: v.id, html: v.wishlist_name } ).appendTo( t );
			} );

			t.append( new_option );
		} );

		// update options for all wishlist dropdown
		wishilst_dropdown.each( function () {
			var t = $( this ),
				wishlist_options = t.find( 'li' ),
				container = t.closest( '.yith-wcwl-add-button' ),
				default_button = container.children( 'a.add_to_wishlist' ),
				product_id = default_button.attr( 'data-product-id' ),
				product_type = default_button.attr( 'data-product-type' );

			wishlist_options.remove();
			$.each( wishlists, function ( i, v ) {
				if ( v[ 'default' ] ) {
					return;
				}

				$( '<li>' ).append( $( '<a>', {
					'rel': 'nofollow',
					'html': v.wishlist_name,
					'class': 'add_to_wishlist',
					'href': v.add_to_this_wishlist_url,
					'data-product-id': product_id,
					'data-product-type': product_type,
					'data-wishlist-id': v.id
				} ) ).appendTo( t );
			} );
		} );
	}

	/**
	 * Block item if possible
	 *
	 * @param item jQuery object
	 * @return void
	 * @since 3.0.0
	 */
	function block( item ) {
		if ( typeof $.fn.block !== 'undefined' ) {
			item.fadeTo( '400', '0.6' ).block( {
				message: null,
				overlayCSS: {
					background: 'transparent url(' + yith_wcwl_l10n.ajax_loader_url + ') no-repeat center',
					backgroundSize: '40px 40px',
					opacity: 1
				}
			} );
		}
	}

	/**
	 * Unblock item if possible
	 *
	 * @param item jQuery object
	 * @return void
	 * @since 3.0.0
	 */
	function unblock( item ) {
		if ( typeof $.fn.unblock !== 'undefined' ) {
			item.stop( true ).css( 'opacity', '1' ).unblock();
		}
	}

	/**
	 * Check if cookies are enabled
	 *
	 * @return bool
	 * @since 2.0.0
	 */
	function is_cookie_enabled() {
		if ( navigator.cookieEnabled ) {
			return true;
		}

		// set and read cookie
		document.cookie = 'cookietest=1';
		var ret = document.cookie.indexOf( 'cookietest=' ) !== -1;

		// delete cookie
		document.cookie = 'cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT';

		return ret;
	}

	/**
	 * Retrieve fragments that need to be refreshed in the page
	 *
	 * @param search string Ref to search among all fragments in the page
	 * @return object Object containing a property for each fragments that matches search
	 * @since 3.0.0
	 */
	function retrieve_fragments( search ) {
		var options = {},
			fragments = null;

		if ( search ) {
			if ( typeof search === 'object' ) {
				search = $.extend( {
					fragments: null,
					s: '',
					container: $( document ),
					firstLoad: false
				}, search );

				if ( ! search.fragments ) {
					fragments = search.container.find( '.wishlist-fragment' );
				} else {
					fragments = search.fragments;
				}

				if ( search.s ) {
					fragments = fragments.not( '[data-fragment-ref]' ).add( fragments.filter( '[data-fragment-ref="' + search.s + '"]' ) );
				}

				if ( search.firstLoad ) {
					fragments = fragments.filter( '.on-first-load' );
				}
			} else {
				fragments = $( '.wishlist-fragment' );

				if ( typeof search === 'string' || typeof search === 'number' ) {
					fragments = fragments.not( '[data-fragment-ref]' ).add( fragments.filter( '[data-fragment-ref="' + search + '"]' ) );
				}
			}
		} else {
			fragments = $( '.wishlist-fragment' );
		}

		if ( fragments.length ) {
			fragments.each( function () {
				var t = $( this ),
					id = t.attr( 'class' ).split( ' ' ).filter( ( val ) => {
						return val.length && val !== 'exists';
					} ).join( yith_wcwl_l10n.fragments_index_glue );

				options[ id ] = t.data( 'fragment-options' );
			} );
		} else {
			return null;
		}

		return options;
	}

	/**
	 * Load fragments on page loading
	 *
	 * @param search string Ref to search among all fragments in the page
	 * @since 3.0.0
	 */
	function load_fragments( search ) {
		search = $.extend( {
			firstLoad: true
		}, search );

		var fragments = retrieve_fragments( search );

		if ( ! fragments ) {
			return;
		}

		$.ajax( {
			data: {
				action: yith_wcwl_l10n.actions.load_fragments,
				nonce: yith_wcwl_l10n.nonce.load_fragments_nonce,
				context: 'frontend',
				fragments: fragments
			},
			method: 'post',
			success: function ( data ) {
				if ( typeof data.fragments !== 'undefined' ) {
					replace_fragments( data.fragments, search );

					init_handling_after_ajax();

					$( document ).trigger( 'yith_wcwl_fragments_loaded', [ fragments, data.fragments, search.firstLoad ] );

				}
			},
			url: yith_wcwl_l10n.ajax_url
		} );
	}

	/**
	 * Replace fragments with template received
	 *
	 * @param fragments array Array of fragments to replace
	 * @param data additional data passed to the trigger
	 * @since 3.0.0
	 */
	function replace_fragments( fragments, data = {} ) {
		$.each( fragments, function ( i, v ) {
			var itemSelector = '.' + i.split( yith_wcwl_l10n.fragments_index_glue ).filter( ( val ) => {
					return val.length && val !== 'exists' && val !== 'with-count';
				} ).join( '.' ),
				toReplace = $( itemSelector );

			// find replace template
			var replaceWith = $( v ).filter( itemSelector );

			if ( ! replaceWith.length ) {
				replaceWith = $( v ).find( itemSelector );
			}

			if ( toReplace.length && replaceWith.length ) {
				toReplace.replaceWith( replaceWith );
			}
		} );

		$( document.body ).trigger( 'yith_wcwl_fragments_replaced', { fragments, data } );
	}

	(() => {
		var applyBulkButton = $( 'input[name="apply_bulk_actions"]' );

		function maybeDisableApplyBulkButton() {
			var buttons = $( '.product-checkbox input:checked' );
			applyBulkButton.prop( 'disabled', ! buttons.length );
		};

		$( document ).on( 'change', '.product-checkbox input', maybeDisableApplyBulkButton );
		maybeDisableApplyBulkButton();
	})();

	/**
	 * Check if device is an IOS device
	 * @since 2.2.11
	 */
	function isOS() {
		return navigator.userAgent.match( /ipad|iphone/i );
	}

	/**
	 * Check if passed value could be considered true
	 * @since 3.0.14
	 */
	function isTrue( value ) {
		return true === value || 'yes' === value || '1' === value || 1 === value;
	}
} );
rendering-methods.js000064400000001036151550137750010531 0ustar00jQuery( $ => {
	const reactPreviewToggle = {
		toggle: function ( event ) {
			if ( 'click' === event?.type || ('keydown' === event?.type && 13 === event?.keyCode) ) {
				const $wrapper = $( this ).closest( '.yith-wcwl-react-preview-toggle__wrapper' ),
					$content = $wrapper.find( '.yith-wcwl-react-preview-toggle__content' );
				$wrapper.toggleClass( 'collapsed' );
				$content.slideToggle( 300 );
			}
		}
	}

	$( document ).on( 'click keydown', '.yith-wcwl-react-preview-toggle__header-toggle-button', reactPreviewToggle.toggle )
} )