"use strict";

var iwbvelOpenFullScreenIcon = '<i class="iwbvel-icon-enlarge"></i>';
var iwbvelCloseFullScreenIcon = '<i class="iwbvel-icon-shrink"></i>';

function iwbvelGetUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
        }
    }
    return false;
};

function iwbvelRemoveParamFromURL(url, param) {
    const [path, searchParams] = url.split('?'); const newSearchParams = searchParams
        ?.split('&')
        .filter((p) => !(p === param || p.startsWith(`${param}=`)))
        .join('&'); return newSearchParams ? `${path}?${newSearchParams}` : path;
}

function openFullscreen() {
    if (document.documentElement.requestFullscreen) {
        document.documentElement.requestFullscreen();
    } else if (document.documentElement.webkitRequestFullscreen) {
        document.documentElement.webkitRequestFullscreen();
    } else if (document.documentElement.msRequestFullscreen) {
        document.documentElement.msRequestFullscreen();
    }
}

function iwbvelDataTableFixSize() {
    if (jQuery('html').attr('dir') == 'rtl') {
        jQuery('#iwbvel-main').css({
            top: jQuery('#wpadminbar').height() + 'px',
            "padding-right": (jQuery('#adminmenu:visible').length) ? jQuery('#adminmenu').width() + 'px' : 0
        });
    } else {
        jQuery('#iwbvel-main').css({
            top: jQuery('#wpadminbar').height() + 'px',
            "padding-left": (jQuery('#adminmenu:visible').length) ? jQuery('#adminmenu').width() + 'px' : 0
        });
    }

    jQuery('#iwbvel-loading').css({
        top: jQuery('#wpadminbar').height() + 'px',
    });

    let height = parseInt(jQuery(window).height()) - parseInt(jQuery('#iwbvel-header').height() + 85);

    jQuery('.iwbvel-table').css({
        "max-height": height + 'px'
    });
}

function exitFullscreen() {
    if (document.exitFullscreen) {
        document.exitFullscreen();
    } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
    }
}

function iwbvelFullscreenHandler() {
    if (!document.webkitIsFullScreen && !document.mozFullScreen && !document.msFullscreenElement) {
        jQuery('#iwbvel-full-screen').html(iwbvelOpenFullScreenIcon).attr('title', 'Full screen');
        jQuery('#adminmenuback, #adminmenuwrap').show();
        jQuery('#wpcontent, #wpfooter').css({ "margin-left": "160px" });
        jQuery('.iwbvel-processing-loading').css({ width: 'calc(100% - 160px)' });
    } else {
        jQuery('#iwbvel-full-screen').html(iwbvelCloseFullScreenIcon).attr('title', 'Exit Full screen');
        jQuery('#adminmenuback, #adminmenuwrap').hide();
        jQuery('#wpcontent, #wpfooter').css({ "margin-left": 0 });
        jQuery('.iwbvel-processing-loading').css({ width: '100%' });
    }

    iwbvelDataTableFixSize();
}

function iwbvelOpenTab(item) {
    let iwbvelTabItem = item;
    let iwbvelParentContent = iwbvelTabItem.closest(".iwbvel-tabs-list");
    let iwbvelParentContentID = iwbvelParentContent.attr("data-content-id");
    let iwbvelDataBox = iwbvelTabItem.attr("data-content");
    iwbvelParentContent.find("li a.selected").removeClass("selected");
    if (iwbvelTabItem.closest('.iwbvel-sub-tab').length > 0) {
        iwbvelTabItem.closest('li.iwbvel-has-sub-tab').find('a').first().addClass("selected");
    } else {
        iwbvelTabItem.addClass("selected");
    }

    if (item.closest('.iwbvel-tabs-list').attr('data-content-id') && item.closest('.iwbvel-tabs-list').attr('data-content-id') == 'iwbvel-main-tabs-contents') {
        jQuery('.iwbvel-tabs-list[data-content-id="iwbvel-main-tabs-contents"] li[data-depend] a').not('.iwbvel-tab-item').addClass('disabled');
        jQuery('.iwbvel-tabs-list[data-content-id="iwbvel-main-tabs-contents"] li[data-depend="' + iwbvelDataBox + '"] a').removeClass('disabled');
    }

    jQuery("#" + iwbvelParentContentID).children("div.selected").removeClass("selected");
    jQuery("#" + iwbvelParentContentID + " div[data-content=" + iwbvelDataBox + "]").addClass("selected");

    if (item.attr("data-type") === "main-tab") {
        iwbvelFilterFormClose();
    }
}

function iwbvelFixModalHeight(modal) {
    let footerHeight = 0;
    let search = 0;
    let contentHeight = parseInt(modal.find(".iwbvel-modal-content").height());
    let titleHeight = parseInt(modal.find(".iwbvel-modal-title").height());
    if (modal.find(".iwbvel-modal-footer").length > 0) {
        footerHeight = parseInt(modal.find(".iwbvel-modal-footer").height()) + 20;
    }

    if (modal.find('.iwbvel-modal-top-search').length > 0) {
        search = parseInt(parseInt(modal.find('.iwbvel-modal-top-search').height()) + 14);
    }

    let modalMargin = parseInt((parseInt(jQuery('body').height()) * 20) / 100);
    let bodyHeight = (modal.find(".iwbvel-modal-body-content").length) ? parseInt(parseInt(modal.find(".iwbvel-modal-body-content").height()) + 30) : contentHeight;
    let bodyMaxHeight = parseInt(jQuery('body').height()) - (titleHeight + search + footerHeight + modalMargin);

    modal.find(".iwbvel-modal-content").css({
        "height": parseInt(titleHeight + search + footerHeight + bodyHeight) + 'px'
    });
    modal.find(".iwbvel-modal-body").css({
        "height": parseInt(bodyHeight + search) + 'px',
        'max-height': parseInt(bodyMaxHeight + search) + 'px'
    });
    modal.find(".iwbvel-modal-box").css({
        "height": parseInt(titleHeight + search + footerHeight + bodyHeight) + 'px'
    });
    modal.attr('data-height-fixed', 'true');
}

function iwbvelOpenFloatSideModal(targetId) {
    let modal = jQuery(targetId);
    modal.fadeIn(20);
    modal.find(".iwbvel-float-side-modal-box").animate({
        right: 0
    }, 180);
}

function iwbvelCloseFloatSideModal() {
    // fix conflict with "Woo Invoice Pro" plugin
    jQuery('body').removeClass('_winvoice-modal-open');
    jQuery('._winvoice-modal-backdrop').remove();

    jQuery('.iwbvel-float-side-modal-box').animate({
        right: "-80%"
    }, 180);
    jQuery('.iwbvel-float-side-modal').fadeOut(200);
}

function iwbvelCloseModal() {
    // fix conflict with "Woo Invoice Pro" plugin
    jQuery('body').removeClass('_winvoice-modal-open');
    jQuery('._winvoice-modal-backdrop').remove();

    let lastModalOpened = jQuery('#iwbvel-last-modal-opened');
    let modal = jQuery(lastModalOpened.val());
    if (lastModalOpened.val() !== '') {
        modal.find(' .iwbvel-modal-box').fadeOut();
        modal.fadeOut();
        lastModalOpened.val('');
    } else {
        let lastModal = jQuery('.iwbvel-modal:visible').last();
        lastModal.find('.iwbvel-modal-box').fadeOut();
        lastModal.fadeOut();
    }

    setTimeout(function () {
        modal.find('.iwbvel-modal-box').css({
            height: 'auto',
            "max-height": '80%'
        });
        modal.find('.iwbvel-modal-body').css({
            height: 'auto',
            "max-height": '90%'
        });
        modal.find('.iwbvel-modal-content').css({
            height: 'auto',
            "max-height": '92%'
        });
    }, 400);
}

function iwbvelOpenModal(targetId) {
    let modal = jQuery(targetId);
    modal.fadeIn();
    modal.find(".iwbvel-modal-box").fadeIn();
    jQuery("#iwbvel-last-modal-opened").val(targetId);

    // set height for modal body
    setTimeout(function () {
        iwbvelFixModalHeight(modal);
    }, 150)
}

function iwbvelReInitColorPicker() {
    if (jQuery('.iwbvel-color-picker').length > 0) {
        jQuery('.iwbvel-color-picker').wpColorPicker();
    }
    if (jQuery('.iwbvel-color-picker-field').length > 0) {
        jQuery('.iwbvel-color-picker-field').wpColorPicker();
    }
}

function iwbvelReInitDatePicker() {
    if (jQuery.fn.datetimepicker) {
        jQuery('.iwbvel-datepicker-with-dash').datetimepicker('destroy');
        jQuery('.iwbvel-datepicker').datetimepicker('destroy');
        jQuery('.iwbvel-timepicker').datetimepicker('destroy');
        jQuery('.iwbvel-datetimepicker').datetimepicker('destroy');

        jQuery('.iwbvel-datepicker').datetimepicker({
            timepicker: false,
            format: 'Y/m/d',
            scrollMonth: false,
            scrollInput: false
        });

        jQuery('.iwbvel-datepicker-with-dash').datetimepicker({
            timepicker: false,
            format: 'Y-m-d',
            scrollMonth: false,
            scrollInput: false
        });

        jQuery('.iwbvel-timepicker').datetimepicker({
            datepicker: false,
            format: 'H:i',
            scrollMonth: false,
            scrollInput: false
        });

        jQuery('.iwbvel-datetimepicker').datetimepicker({
            format: 'Y/m/d H:i',
            scrollMonth: false,
            scrollInput: false
        });
    }

}

function iwbvelPaginationLoadingStart() {
    jQuery('.iwbvel-pagination-loading').show();
}

function iwbvelPaginationLoadingEnd() {
    jQuery('.iwbvel-pagination-loading').hide();
}

function iwbvelLoadingStart() {
    jQuery('#iwbvel-loading').removeClass('iwbvel-loading-error').removeClass('iwbvel-loading-success').text('Loading ...').slideDown(300);
}

function iwbvelLoadingSuccess(message = 'Success !') {
    jQuery('#iwbvel-loading').removeClass('iwbvel-loading-error').addClass('iwbvel-loading-success').text(message).delay(1500).slideUp(200);
}

function iwbvelLoadingProcessingStart(message = 'Processing ...', stop_button = true, tasks = {}) {
    jQuery('#iwbvel-loading').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="loading"]').show();
    if (tasks.total) {
        setTimeout(function () {
            jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').show();
            jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').find('[data-type="total"]').text(tasks.total);
            jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').find('[data-type="completed"]').text((tasks.completed > 0) ? "+" + tasks.completed : tasks.completed);
        }, 10);
    } else {
        jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').hide();
    }
    jQuery('#iwbvel-processing-loading').find('[data-type="result_icon"]').hide();
    if (stop_button === true) {
        jQuery('#iwbvel-processing-loading').find('.iwbvel-processing-loading-stop-button').show();
    } else {
        jQuery('#iwbvel-processing-loading').find('.iwbvel-processing-loading-stop-button').hide();
    }
    jQuery('#iwbvel-processing-loading').find('[data-type="message"]').html(message).ready(function () {
        jQuery('#iwbvel-processing-loading').find('[data-type="message"]').show();
        jQuery('#iwbvel-processing-loading').fadeIn(150);
    });
}

function iwbvelLoadingProcessingPrepare(total_tasks = 0) {
    jQuery('#iwbvel-loading').hide();
    jQuery('#iwbvel-processing-loading').find('.iwbvel-processing-loading-stop-button').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="result_icon"]').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="loading"]').show();
    jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').find('[data-type="total"]').text(0);
    jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').find('[data-type="completed"]').text(0);
    if (total_tasks > 0) {
        jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').show();
        jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').find('[data-type="total"]').text(total_tasks);
        jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').find('[data-type="completed"]').text(0);
    } else {
        jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').hide();
    }
    jQuery('#iwbvel-processing-loading').find('[data-type="message"]').html("Your operation is being prepared. Please do not close the current tab.").ready(function () {
        jQuery('#iwbvel-processing-loading').find('[data-type="message"]').show();
        jQuery('#iwbvel-processing-loading').fadeIn(150);
    });
}

function iwbvelCheckSelectAllStatus() {
    if (parseInt(jQuery('input.iwbvel-check-item:visible:checkbox:checked').length) === parseInt(jQuery('input.iwbvel-check-item:visible:checkbox').length)) {
        if (jQuery('.iwbvel-check-item-main[value="all"]').prop('checked') === true) {
            jQuery('.iwbvel-check-item-main[value="all"]').prop("checked", true);
        } else {
            jQuery('.iwbvel-check-item-main[value="visible"]').prop("checked", true);
        }
        jQuery(".iwbvel-table-item-selector-checkbox").prop("checked", true);

    } else {
        jQuery(".iwbvel-check-item-main").prop("checked", false);
        jQuery(".iwbvel-table-item-selector-checkbox").prop("checked", false);
    }
}

function iwbvelLoadingProcessingSuccess(message = 'Success') {
    jQuery('#iwbvel-processing-loading').find('[data-type="loading"]').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="result_icon"]').show();
    jQuery('#iwbvel-processing-loading').find('.iwbvel-processing-loading-stop-button').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="result_icon"] i').attr('class', 'iwbvel-icon-check-circle');
    jQuery('#iwbvel-processing-loading').find('[data-type="message"]').html(message).ready(function () {
        jQuery('#iwbvel-processing-loading').find('[data-type="message"]').show();
        jQuery('#iwbvel-processing-loading').delay(2000).fadeOut(150);
    });
}

function iwbvelLoadingProcessingComplete(message = 'Your changes have been applied', icon = 'iwbvel-icon-check-circle') {
    jQuery('#iwbvel-processing-loading').find('[data-type="loading"]').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="result_icon"]').show();
    jQuery('#iwbvel-processing-loading').find('.iwbvel-processing-loading-stop-button').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="result_icon"] i').attr('class', icon);
    jQuery('#iwbvel-processing-loading').find('[data-type="message"]').html(message).ready(function () {
        jQuery('#iwbvel-processing-loading').find('[data-type="message"]').show();
        jQuery('#iwbvel-processing-loading').delay(3000).fadeOut(150);
    });
}

function iwbvelLoadingProcessingError(message = 'Error') {
    jQuery('#iwbvel-processing-loading').find('[data-type="loading"]').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="tasks"]').hide();
    jQuery('#iwbvel-processing-loading').find('.iwbvel-processing-loading-stop-button').hide();
    jQuery('#iwbvel-processing-loading').find('[data-type="result_icon"]').show();
    jQuery('#iwbvel-processing-loading').find('[data-type="result_icon"] i').attr('class', 'iwbvel-icon-x');
    jQuery('#iwbvel-processing-loading').find('[data-type="message"]').html(message).ready(function () {
        jQuery('#iwbvel-processing-loading').find('[data-type="message"]').show();
        jQuery('#iwbvel-processing-loading').delay(2000).fadeOut(150);
    });
}

function iwbvelLoadingError(message = 'Error !') {
    jQuery('#iwbvel-loading').removeClass('iwbvel-loading-success').removeClass('iwbvel-loading-processing').addClass('iwbvel-loading-error').text(message).delay(1500).slideUp(200);
}

function iwbvelSetColorPickerTitle() {
    jQuery('.iwbvel-column-manager-right-item .wp-picker-container').each(function () {
        let title = jQuery(this).find('.iwbvel-column-manager-color-field input').attr('title');
        jQuery(this).attr('title', title);
        iwbvelSetTipsyTooltip();
    });
}

function iwbvelFilterFormClose() {
    if (jQuery('#iwbvel-filter-form-content').attr('data-visibility') === 'visible') {
        jQuery('.iwbvel-filter-form-icon').addClass('iwbvel-icon-chevron-down').removeClass('iwbvel-icon-chevron-up');
        jQuery('#iwbvel-filter-form-content').slideUp(200).attr('data-visibility', 'hidden');
    }
}

function iwbvelSetTipsyTooltip() {
    jQuery('[title]').tipsy({
        html: true,
        arrowWidth: 10, //arrow css border-width * 2, default is 5 * 2
        attr: 'data-tipsy',
        cls: null,
        duration: 150,
        offset: 7,
        position: 'top-center',
        trigger: 'hover',
        onShow: null,
        onHide: null
    });
}

function iwbvelCheckUndoRedoStatus(reverted, history) {
    if (reverted) {
        iwbvelEnableRedo();
    } else {
        iwbvelDisableRedo();
    }
    if (history) {
        iwbvelEnableUndo();
    } else {
        iwbvelDisableUndo();
    }
}

function iwbvelDisableUndo() {
    jQuery('#iwbvel-bulk-edit-undo').prop('disabled', true);
}

function iwbvelEnableUndo() {
    jQuery('#iwbvel-bulk-edit-undo').prop('disabled', false);
}

function iwbvelDisableRedo() {
    jQuery('#iwbvel-bulk-edit-redo').prop('disabled', true);
}

function iwbvelEnableRedo() {
    jQuery('#iwbvel-bulk-edit-redo').prop('disabled', false);
}

function iwbvelHideSelectionTools() {
    jQuery('.iwbvel-bulk-edit-form-selection-tools').hide();
    jQuery('#iwbvel-bulk-edit-trash-restore').hide();
}

function iwbvelShowSelectionTools() {
    jQuery('.iwbvel-bulk-edit-form-selection-tools').show();
    jQuery('#iwbvel-bulk-edit-trash-restore').show();
}

function iwbvelSetColorPickerTitle() {
    jQuery('.iwbvel-column-manager-right-item .wp-picker-container').each(function () {
        let title = jQuery(this).find('.iwbvel-column-manager-color-field input').attr('title');
        jQuery(this).attr('title', title);
        iwbvelSetTipsyTooltip();
    });
}

function iwbvelColumnManagerAddField(fieldName, fieldLabel, action) {
    jQuery.ajax({
        url: IWBVEL_DATA.ajax_url,
        type: 'post',
        dataType: 'html',
        data: {
            action: 'iwbvel_column_manager_add_field',
            nonce: IWBVEL_DATA.ajax_nonce,
            field_name: fieldName,
            field_label: fieldLabel,
            field_action: action
        },
        success: function (response) {
            jQuery('.iwbvel-box-loading').hide();
            jQuery('.iwbvel-column-manager-added-fields[data-action=' + action + '] .items').append(response);
            fieldName.forEach(function (name) {
                jQuery('.iwbvel-column-manager-available-fields[data-action=' + action + '] input:checkbox[data-name=' + name + ']').prop('checked', false).closest('li').attr('data-added', 'true').hide();
            });
            iwbvelReInitColorPicker();
            jQuery('.iwbvel-column-manager-check-all-fields-btn[data-action=' + action + '] input:checkbox').prop('checked', false);
            jQuery('.iwbvel-column-manager-check-all-fields-btn[data-action=' + action + '] span').removeClass('selected').text('Select All');
            setTimeout(function () {
                iwbvelSetColorPickerTitle();
            }, 250);
        },
        error: function () {
        }
    })
}

function iwbvelAddMetaKeysManual(meta_key_name) {
    jQuery('#iwbvel-add-meta-field-manual').attr('disabled', true);

    iwbvelLoadingStart();
    jQuery.ajax({
        url: IWBVEL_DATA.ajax_url,
        type: 'post',
        dataType: 'html',
        data: {
            action: 'iwbvel_add_meta_keys_manual',
            nonce: IWBVEL_DATA.ajax_nonce,
            meta_key_name: meta_key_name,
        },
        success: function (response) {
            if (jQuery('.iwbvel-meta-fields-items').length) {
                jQuery('.iwbvel-meta-fields-items').append(response);
            } else {
                jQuery('#iwbvel-meta-fields-items').append(response);
            }
            iwbvelLoadingSuccess();
        },
        error: function () {
            iwbvelLoadingError();
        }
    })
}

function iwbvelAddACFMetaField(field_name, field_label, field_type) {
    iwbvelLoadingStart();
    jQuery.ajax({
        url: IWBVEL_DATA.ajax_url,
        type: 'post',
        dataType: 'html',
        data: {
            action: 'iwbvel_add_acf_meta_field',
            nonce: IWBVEL_DATA.ajax_nonce,
            field_name: field_name,
            field_label: field_label,
            field_type: field_type
        },
        success: function (response) {
            jQuery('#iwbvel-meta-fields-items').append(response);
            iwbvelLoadingSuccess();
        },
        error: function () {
            iwbvelLoadingError();
        }
    })
}

function iwbvelCheckFilterFormChanges() {
    let isChanged = false;
    jQuery('#iwbvel-filter-form-content [data-field="value"]').each(function () {
        if (jQuery.isArray(jQuery(this).val())) {
            if (jQuery(this).val().length > 0) {
                isChanged = true;
            }
        } else {
            if (jQuery(this).val()) {
                isChanged = true;
            }
        }
    });
    jQuery('#iwbvel-filter-form-content [data-field="from"]').each(function () {
        if (jQuery(this).val()) {
            isChanged = true;
        }
    });
    jQuery('#iwbvel-filter-form-content [data-field="to"]').each(function () {
        if (jQuery(this).val()) {
            isChanged = true;
        }
    });

    jQuery('#filter-form-changed').val(isChanged);

    if (isChanged === true) {
        jQuery('#iwbvel-bulk-edit-reset-filter').show();
    } else {
        jQuery('.iwbvel-top-nav-status-filter a[data-status="all"]').addClass('active');
    }
}

function iwbvelGetCheckedItem() {
    let itemIds;
    let itemsChecked = jQuery("input.iwbvel-check-item:checkbox:checked");
    if (itemsChecked.length > 0) {
        itemIds = itemsChecked.map(function (i) {
            return jQuery(this).val();
        }).get();
    }

    return itemIds;
}

function iwbvelGetTableCount(countPerPage, currentPage, total) {
    currentPage = (currentPage) ? currentPage : 1;
    let showingTo = parseInt(currentPage * countPerPage);
    let showingFrom = (total > 0) ? parseInt(showingTo - countPerPage) + 1 : 0;
    showingTo = (showingTo < total) ? showingTo : total;
    return "Showing " + showingFrom + " to " + showingTo + " of " + total + " entries";
}

function iwbvelSelectAllChecked() {
    return (jQuery('.iwbvel-check-item-main[value="all"]').prop('checked') === true);
}

function iwbvelSelectVisibleChecked() {
    return (jQuery('.iwbvel-check-item-main[value="visible"]').prop('checked') === true);
}

function iwbvelBulkNewTabsInit() {
    jQuery.ajax({
        url: IWBVEL_DATA.ajax_url,
        type: "post",
        dataType: "json",
        data: {
            action: "iwbvel_get_bulk_new_tabs_content",
            nonce: IWBVEL_DATA.ajax_nonce,
        },
        success: function (response) {
            if (response.success) {
                jQuery('[data-target="#iwbvel-float-side-modal-bulk-new-products"]').attr("data-tabs-loaded", "true");

                jQuery('#iwbvel-float-side-modal-bulk-new-products .iwbvel-tab-content-item[data-content="general"]').html(response.general);
                jQuery('#iwbvel-float-side-modal-bulk-new-products .iwbvel-tab-content-item[data-content="taxonomies"]').html(response.taxonomies);
                jQuery('#iwbvel-float-side-modal-bulk-new-products .iwbvel-tab-content-item[data-content="type"]').html(response.type);
                jQuery('#iwbvel-float-side-modal-bulk-new-products .iwbvel-tab-content-item[data-content="stock"]').html(response.stock);
                jQuery('#iwbvel-float-side-modal-bulk-new-products .iwbvel-tab-content-item[data-content="pricing"]').html(response.pricing);
                jQuery('#iwbvel-float-side-modal-bulk-new-products .iwbvel-tab-content-item[data-content="shipping"]').html(response.shipping);
                jQuery('#iwbvel-float-side-modal-bulk-new-products .iwbvel-tab-content-item[data-content="compatibles"]').html(response.compatibles);
                jQuery('#iwbvel-float-side-modal-bulk-new-products .iwbvel-tab-content-item[data-content="custom_fields"]')
                    .html(response.custom_fields)
                    .ready(function () {
                        iwbvelSelect2TaxonomiesInit();
                        iwbvelReInitDatePicker();
                        iwbvelSelect2UsersInit();
                        iwbvelSelect2ProductsInit();
                        iwbvelSelect2Init();
                    });
            }
        },
        error: function () { },
    });
}