"use strict"; // noinspection JSUnresolvedVariable /**! * WooFeed Pro Scripts * @version 1.0.0 * @package WooFeed * @copyright 2020 WebAppick * */ (function ($, window, document, wf, wpAjax, opts) { "use strict"; /* global ajaxurl, wpAjax, postboxes, pagenow, alert, deleteUserSetting, typenow, adminpage, thousandsSeparator, decimalPoint, isRtl */ $(window).on('load', function () { var __idx__ = 0, srt = $('#wf_str_replace tbody'); $(document).on('change', "#custom2_attribute", function (e) { // Custom 2 template attribute name $("#custom2_attribute_value").val(`{${$(this).val().trim()}}`); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html }).on('change', '#is_variations', function (e) { let is_variations = $(this).val(); if ('both' === is_variations || 'n' === is_variations) { $(".WFVariablePriceTR").show(); } else { $(".WFVariablePriceTR").hide(); } }).on('change', '#wpf_ptitle', function () { // Variation Product Title let selectize = $(this)[0].selectize, titleEl = $("textarea[name='ptitle_show']"), title = titleEl.val().trim().split('|'); title.push($(this).val()); // Show Title titleEl.val(title.filter(x => '' !== x).join('|')); selectize.clear(true); // reset the select value silently. selectize.refreshOptions(false); // reset selectize scroll position silently. }).on('click', '#wf_new_str_replace', function () { if (0 === __idx__) { __idx__ = srt.find('tr').length; } else { __idx__++; } srt.append($('#wf_str_replace_template').text().trim().replace(/__idx__/g, __idx__)); }).on('click', '.wf-add-row', function (e) { e.preventDefault(); var self = $(this), __idx__ = parseInt(self.data('idx') || 0) + 1, template = (/^ 0) { wf.helper.sortable(); } }); // Document events $(document) .on('feedEditor.init', function () { wf.helper.fancySelect($('#wf_product_post_status, .filter_mode'), { maxItemShow: 2 }); }) // filter tab functionality .one('click', 'label[for="wf-tab-content-filter"]', function (e) { var filterData = { action: 'woo_feed_filter_count', //callback function nonce: wpf_ajax_obj.ajax.nonce, }; // AJAX call $.ajax({ method: "GET", url: wpf_ajax_obj.wpf_ajax_url, data: filterData, success: function (message) { if (message.data.backorder) { var singularOrPluralText = message.data.backorder === 1 ? 'product is' : 'products are'; $('#wf-tab-content-filter table tr:nth-of-type(1)').find('.help').after('