2 lines
30 KiB
JavaScript
2 lines
30 KiB
JavaScript
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,o){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var o=0;o<t.length;o++){var a=t[o];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,_toPropertyKey(a.key),a)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0===o)return("string"===t?String:Number)(e);o=o.call(e,t||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(s,c,l,i,r){s.fn.disabled=function(o){return s(this).each(function(){var e=s(this),t="disabled";void 0!==e.prop(t)?e.prop(t,void 0===o||!0===o):!0===o?e.addClass(t):e.removeClass(t)}),self},s.fn.isDisabled=function(){var e=s(this),t="disabled";return void 0!==e.prop(t)?e.prop(t):e.hasClass(t)};function e(e){s(e.currentTarget).removeClass(function(e,t){return(t.match(/\btooltipped-\S+/g)||[]).join(" ")}).removeClass("tooltipped").removeAttr("aria-label")}function o(e,t){s(e).addClass("tooltipped tooltipped-s").attr("aria-label",t)}function d(e,t){return s.extend(!0,{},e,t)}function t(){a=s(".toClipboard"),!ClipboardJS.isSupported()||/iPhone|iPad/i.test(navigator.userAgent)?a.find("img").hide(0):(a.each(function(){s(this).on("mouseleave",e).on("blur",e)}),new ClipboardJS(".toClipboard").on("error",function(e){var t;o(e.trigger,(e=e.action,t="cut"===e?"X":"C",t=/iPhone|iPad/i.test(navigator.userAgent)?"No support :(":/Mac/i.test(navigator.userAgent)?"Press ⌘-"+t+" to "+e:"Press Ctrl-"+t+" to "+e))}).on("success",function(e){o(e.trigger,"Copied")}))}var a,f,p,n=function(){function a(e,t,o){_classCallCheck(this,a),this.productCustomFields(e,t,o)}return _createClass(a,[{key:"cacheClear",value:function(){var e={action:"woo_feed_product_attribute_cache_remove",nonce:wpf_ajax_obj.ajax.nonce};s.ajax({method:"POST",url:wpf_ajax_obj.wpf_ajax_url,data:e})}},{key:"productCustomFields",value:function(t){var o=this,e={action:"woo_feed_custom_fields_status_change",nonce:wpf_ajax_obj.ajax.nonce,field:t,status:1<arguments.length&&void 0!==arguments[1]&&arguments[1],isTaxonomy:2<arguments.length?arguments[2]:void 0};s.ajax({method:"POST",url:wpf_ajax_obj.wpf_ajax_url,data:e,success:function(e){e.success?o.cacheClear():console.log(e),s("#"+t+"-switcher").closest("td").find(".switch-loader").hide()}})}}]),a}(),_=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"wooFeed_get_google_categories",value:function(){i.send("get_google_categories",{type:"GET",data:{_ajax_nonce:r.nonce,action:"get_google_categories"}}).then(function(e){s(".selectize-google-category").selectize({valueField:"value",labelField:"text",placeholder:"Select a category",searchField:["value","text"],options:e,render:{option:function(e,t){return'<div class="item wapk-selectize-item">'.concat(t(e.value+" - "+e.text),"</div>")},item:function(e,t){return'<div class="item wapk-selectize-item">'.concat(t(e.value+" - "+e.text),"</div>")}}}),s(".woo-feed-cat-map-spinner").remove()}).fail(u.ajax_fail)}},{key:"wooFeed_get_facebook_categories",value:function(){i.send("get_facebook_categories",{type:"GET",data:{_ajax_nonce:r.nonce,action:"get_facebook_categories"}}).then(function(e){s(".selectize-google-category").selectize({valueField:"value",labelField:"text",placeholder:"Select a Facebook category",searchField:["value","text"],options:e,render:{option:function(e,t){return'<div class="item wapk-selectize-item">'.concat(t(e.value+" - "+e.text),"</div>")},item:function(e,t){return'<div class="item wapk-selectize-item">'.concat(t(e.value+" - "+e.text),"</div>")}}}),s(".woo-feed-cat-map-spinner").remove()}).fail(u.ajax_fail)}}]),e}(),u={in_array:function(e,t){try{return-1!==t.indexOf(e)}catch(e){return!1}},selectize_render_item:function(e,t){return'<div class="item wapk-selectize-item">'.concat(t(e.text),"</div>")},ajax_fail:function(e){console.warn(e),alert(e.hasOwnProperty("statusText")&&e.hasOwnProperty("status")?r.ajax.error+"\n"+e.statusText+" ("+e.status+")":e)},sortable:function(e,o,a,n){return(e||s(".sorted_table")).each(function(){var e=s(this),t=e.find("tbody > tr:eq(0) > td").length||a||9;e.wf_sortable(d({containerSelector:"table",itemPath:"> tbody",itemSelector:"tr",handle:"i.wf_sortedtable",placeholder:'<tr class="placeholder"><td colspan="'.concat(t,'"></td></tr>'),onDrop:function(e,t,o,a){e.removeClass(t.group.options.draggedClass).removeAttr("style"),s("body").removeClass(t.group.options.bodyClass),e.find("input.wf_attributes").attr("name","default["+numb+"]"),n&&"function"==typeof n&&n(e,t,o,a)}},o))})},selectize:function(e,t){return(e||s("select.selectize")).not(".selectized").not(".selectize-google-category").each(function(){var e=s(this);e.selectize(d({create:e.data("create")||!1,plugins:e.data("plugins")?e.data("plugins").split(",").map(function(e){return e.trim()}):[],render:{item:u.selectize_render_item}},t))})},fancySelect:function(e,t){return(e||s("select.fancySelect")).not(".FancySelectInit").each(function(){s(this).fancySelect(d({maxItemShow:3},t))})},reindex_config_table:function(){s("#table-1").find("tbody tr").each(function(o,e){s(e).find("[name]").each(function(e,t){s(t).attr("name",s(t).attr("name").replace(/(\[\d\])/g,"[".concat(o,"]")))})})},common:function(){u.sortable(s(".sorted_table"),{},9,u.reindex_config_table),u.selectize(),u.fancySelect(s(".outputType")),wp.hooks.addAction("init_fancy_select","fancy_select",function(){u.fancySelect(s(".ctx-outputType"));u.fancySelect(s(".ctx-postStatus"))})},setLocalStorage:function(e,t){var o=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],a=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],n=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"ctxFeedData";o&&(t=JSON.stringify(t)),a?null!==(a=c.localStorage.getItem(n))?((a=JSON.parse(c.localStorage.getItem(n)))[e]=t,c.localStorage.setItem(n,JSON.stringify(a))):c.localStorage.setItem(n,JSON.stringify(_defineProperty({},e,t))):o?c.localStorage.setItem(e,JSON.stringify(t)):c.localStorage.setItem(e,t)},clearLocalStorage:function(e){var t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],a=null,n=!1;if(!(2<arguments.length&&void 0!==arguments[2])||arguments[2]){if(!(a=c.localStorage.getItem(3<arguments.length&&void 0!==arguments[3]?arguments[3]:"ctxFeedData")))return n;(a=JSON.parse(a)).hasOwnProperty(e)&&(o.length?(t=JSON.parse(a[e]),o.map(function(e){t.hasOwnProperty(e)&&(delete t[e],n=!0)}),u.setLocalStorage(e,t)):(delete a[e],n=!0,u.setLocalStorage(e,null)))}else c.localStorage.removeItem(e),n=!0;return n}},g={form:null,init:function(){this.form=s(".generateFeed"),this.form.length&&(u.common(),s(l).trigger("feed_editor_init"),s(l).trigger(new jQuery.Event("feedEditor.init",{target:this.form})))},renderMerchantInfo:function(o,a,n){for(var e in n)!function(e){var t;n.hasOwnProperty(e)&&(o.find(".merchant-info-section."+e+" .data").html(n[e]),"feed_file_type"===e)&&((t=n[e].split(",").map(function(e){return e.trim().toLowerCase()}).filter(function(e){return""!==e&&e!==r.na.toLowerCase()})).length?(a.find("option").removeAttr("selected").each(function(){var e=s(this);e.val()&&!u.in_array(e.val(),t)?e.disabled(!0):e.disabled(!1)}),1===t.length&&a.find('option[value="'+t[0]+'"]').attr("selected","selected")):a.find("option").disabled(!1))}(e);o.find(".spinner").removeClass("is-active"),a.disabled(!1),a.trigger("change"),s(l).trigger("woo_feed_config_loaded"),a.parent().find(".spinner").removeClass("is-active")},renderMerchantTemplate:function(o,a){for(var e in a)!function(t){var e;a.hasOwnProperty(t)&&("tabs"===t?o.html(a[t]):(e=s('[name="'+t+'"]')).length&&e.each(function(){var e=s(this);e.is("select")?e.find('[value="'+a[t]+'"]').prop("selected",!0):(e.is("[type=checkbox]")||e.is("[type=radio]"))&&e.val()===a[t]?e.prop("checked",!0):e.val(a[t])}).trigger("change"))}(e);g.init()}},h=function(){function e(){_classCallCheck(this,e),this._feed=r.generator.feed,this._limit=r.generator.limit,this._progress=0,this._timer=null,this._color=!1,this._total_batch=0,this._current_batch=0,this._product_ids=[],this._progress_per_batch=0,this._refresh=!0,this._regenerate=r.generator.regenerate,c.isRegenerating=!1,this._all_btn=s(".wpf_regenerate"),this._current_btn=s("#".concat(this._feed.replace("wf_config","wf_feed_"))),this._current_btn_label=""}return _createClass(e,[{key:"init",value:function(){var t=this,e=(""!==this._feed&&this._regenerate&&!1===c.isRegenerating&&this.generate(),c.location.search);return"webappick-manage-feeds"===new URLSearchParams(e).get("page")&&s("body").addClass("woo-import-popup-body"),s(l).on("click",".woo-feed-campaign-close-button",function(e){e.preventDefault(),s(this).parent(".woo-feed-promotion").hide();e=s(this).data("condition");1===e&&i.post("woo_feed_hide_promotion",{_ajax_nonce:r.nonce,condition:e}).then(function(e){t._log(e)}).fail(function(e){t._log(e),t._updateProgressStatus(e.message),t._color="red"})}),s(l).on("click",".wpf_regenerate",function(e){e.preventDefault(),t._current_btn=s(this),t._current_btn.hasClass("disabled")||!0===c.isRegenerating||(t._feed=t._current_btn.attr("id").replace("wf_feed_","wf_config"),""!==t._feed&&t.generate())}),this}},{key:"_block_button",value:function(){this._all_btn.length&&this._all_btn.addClass("disabled"),this._current_btn.length&&(this._current_btn.find("span").addClass("wpf_spin reverse_spin"),this._current_btn_label=this._current_btn.attr("title"),this._current_btn.attr("aria-label",r.regenerate).attr("title",r.regenerate))}},{key:"_unblock_button",value:function(){this._all_btn.length&&this._all_btn.removeClass("disabled"),this._current_btn.length&&(this._current_btn.find("span").removeClass("wpf_spin"),this._current_btn.find("span").removeClass("reverse_spin"),this._current_btn.attr("aria-label",this._current_btn_label).attr("title",this._current_btn_label))}},{key:"generate",value:function(){var t=this,o=this;c.isRegenerating=!0,this._block_button(),this._resetProgressBar(),this._progressBarActive(),this._log("Counting Total Products"),this._updateProgressStatus("Fetching products."),this._get_product_ids().then(function(e){t._progress=10,o._log({response:e}),e.success?(o._log("Total ".concat(e.total," Products found.")),o._product_ids=e.product,o._total_batch=t._product_ids.length,o._current_batch=0,o._progress_per_batch=(90-t._progress)/t._total_batch,o._process_batch(),o._updateProgressStatus("Processing Products...")):o._updateProgressStatus(e.data.message)}).fail(function(e){o._log(e),o._updateProgressStatus(e.message),o._color="red",setTimeout(function(){o._stopProgressBar(),o._unblock_button()},1500)})}},{key:"_get_product_ids",value:function(){return this._progress=5,i.post("get_product_information",{_ajax_nonce:r.nonce,feed:this._feed,limit:this._limit})}},{key:"_process_batch",value:function(){var t=this,e="Processing Batch ".concat(this._current_batch+1," of ").concat(this._total_batch);this._updateProgressStatus(e),this._log(e),i.post("make_batch_feed",{_ajax_nonce:r.nonce,feed:this._feed,products:this._product_ids[this._current_batch],loop:this._current_batch}).then(function(e){t._current_batch++,t._log("Batch ".concat(t._current_batch," Completed")),t._log(e),t._current_batch<t._total_batch&&(t._process_batch(),t._progress+=t._progress_per_batch),t._current_batch===t._total_batch&&t._save_feed_file()}).fail(function(e){t._log(e),t._updateProgressStatus(e.message),t._color="red",setTimeout(function(){t._stopProgressBar(),t._unblock_button()},1500)})}},{key:"_save_feed_file",value:function(){var t=this;this._log("Saving feed file"),this._updateProgressStatus("Saving feed file"),i.post("save_feed_file",{_ajax_nonce:r.nonce,feed:this._feed}).then(function(e){t._log(e),t._progress=100,t._refresh&&(c.location.href="".concat(r.pages.list.feed,"&link=").concat(e.url,"&cat=").concat(e.cat)),setTimeout(function(){t._stopProgressBar(),setTimeout(function(){t._resetProgressBar(!0),t._unblock_button()},3e3)},2500)}).fail(function(e){t._log(e),t._updateProgressStatus(e.message),t._color="red",setTimeout(function(){t._stopProgressBar(),t._unblock_button()},1500)})}},{key:"_log",value:function(e){return r.wpf_debug&&console.log(e),this}},{key:"_progressBarActive",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=this;return this._toggleProgressBar(!0),this._timer=setInterval(function(){t._updateProgressBar()},e||1e3),this}},{key:"_stopProgressBar",value:function(){return clearInterval(this._timer),this}},{key:"_resetProgressBar",value:function(e){return this._toggleProgressBar(!1),this._updateProgressStatus(""),clearInterval(this._timer),this._color=!1,this._timer=null,this._progress=0,e&&this._updateProgressBar(),this}},{key:"_toggleProgressBar",value:function(e){var t=s("#feed_progress_table");return e?t.show():t.hide(),this}},{key:"_updateProgressStatus",value:function(e){return s(".feed-progress-status").html(e),this}},{key:"_getErrorMessageByCode",value:function(e){s(".feed-progress-status").css({color:this._color}),s(".feed-progress-percentage").css({color:this._color}),s(".wpf_spin").css({color:this._color});var t=e.status+" : "+e.statusText+". ";500===e.status&&(t+="Please increase your PHP max_execution_time. Please <a target='_blank' href='https://webappick.com/docs/woo-feed/faq-for-woocommerce-product-feed/how-to-solve-processing-10-feed-generation-stuck-error/'>read this doc</a>."),this._updateProgressStatus(t)}},{key:"_updateProgressBar",value:function(){var e=s(".feed-progress-percentage"),t=s(".feed-progress-bar-fill"),o="".concat(Math.round(this._progress),"%");t.css({width:o}),e.text(o)}}]),e}();c.wf={helper:u,feedEditor:g,generator:h},s(c).on("load",function(){null!==s(location).attr("href").match(/webappick.*feed/g)&&s("#wpbody-content").addClass("woofeed-body-content"),t(),postboxes.add_postbox_toggles(pagenow),(new h).init(),""!==r.generator.feed&&r.generator.regenerate,g.init(),u.common(),s(".wfmasterTooltip").hover(function(){var e=s(this),t=e.attr("wftitle");e.data("tipText",t).removeAttr("wftitle"),s('<p class="wftooltip"></p>').text(t).appendTo("body").fadeIn("slow")},function(){var e=s(this);e.attr("wftitle",e.data("tipText")),s(".wftooltip").remove()}).mousemove(function(e){s(".wftooltip").css({top:e.pageY+10,left:e.pageX+20})}),s(".generateFeed").validate(),s(l).on("blur",'input[name="wfDAttributeName"]',function(e){e.preventDefault();e=s(this).val();e=(e=e.toLowerCase()).split(" ").join("_"),s("#wfDAttributeCode").val(e)}).on("click","[data-toggle_slide]",function(e){e.preventDefault(),s(s(this).data("toggle_slide")).slideToggle("fast")}).on("click","#wf_newRow",function(){var e=s("#table-1 tbody"),t=s("#feed_config_template").text().trim().replace(/__idx__/g,e.find("tr").length);e.append(t),u.fancySelect(s(".outputType")),u.fancySelect(s(".ctx-outputType"))}).on("click",".single-feed-delete",function(e){e.preventDefault(),confirm(r.form.del_confirm)&&(c.location.href=s(this).attr("val"))}).on("click",".wf_clean_cache_wrapper",function(e){e.preventDefault();for(var o=s(".woo-feed-clean-cache-nonce").val(),a=s(".woo-feed-cache-loader"),n=["woo_feed_attributes","woo_feed_category_mapping","woo_feed_dynamic_attributes","woo_feed_attribute_mapping","woo_feed_wp_options"],t=(a.show(),0);t<n.length;t++)!function(t){i.post("clear_cache_data",{_ajax_clean_nonce:o,type:n[t]}).then(function(e){e.success&&(i.post("pressmodo_dismiss_notice",{id:n[t],nonce:e.nonce}),a.hide(),location.reload())}).fail(function(){console.log("something wrong")})}(t)}).on("click",".ctx-notice-cache-clear",function(e){e.preventDefault();for(var o=s(this).data("id"),a=(console.log(o),s(".loadingio-spinner-reload-5t7io14g51q")),n=(s(this).attr("id"),a.show(),["woo_feed_attributes","woo_feed_category_mapping","woo_feed_dynamic_attributes","woo_feed_attribute_mapping","woo_feed_wp_options"]),t=(u.clearLocalStorage("options",["product_attributes"]),0);t<n.length;t++)!function(t){i.post("clear_cache_data",{_ajax_clean_nonce:o,type:n[t]}).then(function(e){e.success&&(i.post("pressmodo_dismiss_notice",{id:n[t],nonce:e.nonce}),a.hide(),location.reload())}).fail(function(){console.log("something wrong")})}(t)}).on("click","#woo-feed-copy-status-btn",function(e){e.preventDefault();var e=s("#woo-feed-copy-status-btn"),t=s("#woo-feed-status-area");e.val("Copied"),t.css("visibility","visible"),t.select(),l.execCommand("copy")}).on("change",".ctx-wf_attr.ctx-wf_attributes",function(e){e.preventDefault();var t,e=s(this).val(),o=s(this).parents("tr").find(".ctx-outputType"),a=s(this).parents("tr").find(".fancy-picker-content"),n=(['<div class="fancy-picker-option" data-value="0">Select Attribute</div>','<div class="fancy-picker-option selected" data-value="1"> Default </div>','<div class="fancy-picker-option" data-value="2"> Strip Tags </div>','<div class="fancy-picker-option" data-value="3"> UTF-8 Encode </div>','<div class="fancy-picker-option" data-value="4"> htmlentities </div>','<div class="fancy-picker-option" data-value="5"> Integer </div>','<div class="fancy-picker-option" data-value="6"> Price </div>','<div class="fancy-picker-option" data-value="7"> Rounded Price </div>','<div class="fancy-picker-option" data-value="8"> Remove Space </div>','<div class="fancy-picker-option" data-value="9"> CDATA </div>','<div class="fancy-picker-option" data-value="10"> Remove Special Character </div>','<div class="fancy-picker-option" data-value="11"> Remove ShortCodes </div>','<div class="fancy-picker-option" data-value="12"> ucwords </div>','<div class="fancy-picker-option" data-value="13"> ucfirst </div>','<div class="fancy-picker-option" data-value="14"> strtoupper </div>','<div class="fancy-picker-option" data-value="15"> strtolower </div>','<div class="fancy-picker-option" data-value="16"> urlToSecure </div>','<div class="fancy-picker-option" data-value="17"> urlToUnsecure </div>','<div class="fancy-picker-option" data-value="18"> only_parent </div>','<div class="fancy-picker-option" data-value="19"> parent </div>','<div class="fancy-picker-option" data-value="20"> parent_if_empty </div>','<div class="fancy-picker-option" data-value="21"> </div>','<div class="fancy-picker-option" data-value="22"> </div>'].map(function(e){a.append(e)}),s(this).parents("tr").find(".fancy-picker-data")),i=["price","current_price","sale_price","price_with_tax","current_price_with_tax","sale_price_with_tax","shipping_cost"].includes(e)?(t="for_price","Price"):""!==e&&-1!==e.indexOf("wf_taxo")?(t="for_custom_taxo","parent_if_empty"):(t="for_all","Default");s(a).find(".fancy-picker-option").removeClass("selected"),"for_custom_taxo"===t||"for_price"===t?(s(a).find(".fancy-picker-option").each(function(){i===s(this).text().trim()&&(n.html("<span>".concat(i,"</span>")),o.find("option").text(i),o.find("option").val(s(this).data("value")),s(this).addClass("selected"))}),"for_price"===t&&(t=null!=(e=s("#feedCurrency").val())?e:wpf_ajax_obj.woocommerce.currency,s(this).closest("tr").find("td:eq(5) input").val(" "+t))):(a.each(function(){i===s(this).text()&&(s(this).addClass("selected"),n.text(i),o.find("option").text(i),o.find("option").val(s(this).data("value")))}),s(this).closest("tr").find("td:eq(5) input").val(""))}).on("click","#doaction, #doaction2",function(){return confirm(r.form.del_confirm_multi)}).on("change",".dType",function(){var e=s(this),t=e.val(),e=e.closest("tr");"pattern"===t?(e.find(".value_attribute").hide(),e.find(".value_pattern").show()):"attribute"===t?(e.find(".value_attribute").show(),e.find(".value_pattern").hide()):"remove"===t&&(e.find(".value_attribute").hide(),e.find(".value_pattern").hide())}).on("click",".delRow",function(e){e.preventDefault(),s(this).closest("tr").remove(),u.reindex_config_table()}).on("submit","#generateFeed",function(){s(this).validate(),s(this).valid()&&s(".makeFeedResponse").show().html('<b style="color: darkblue;"><i class="dashicons dashicons-sos wpf_spin"></i> '.concat(r.form.generate,"</b>"))}).on("submit","#updatefeed",function(e,t){s(this).validate(),s(this).valid()&&s(".makeFeedResponse").show().html('<b style="color: darkblue;"><i class="dashicons dashicons-sos wpf_spin"></i> '.concat(t&&t.save?r.form.save:r.form.generate,"</b>"))}).on("ready woo_feed_config_loaded",function(){"0"===s("#ftpenabled").val()?(s(".google-merchant-message").hide("slow"),s(".woo-feed-ftp .ftpconfig tr:not(.ftpcontroller) input, .woo-feed-ftp .ftpconfig tr:not(.ftpcontroller) select").attr("disabled","disabled")):("google"===s("#provider").val()?s(".google-merchant-message").show("slow"):s(".google-merchant-message").hide("slow"),s(".woo-feed-ftp .ftpconfig tr:not(.ftpcontroller) input, .woo-feed-ftp .ftpconfig tr:not(.ftpcontroller) select").removeAttr("disabled")),s("#ftpenabled").on("change",function(){"0"===s("#ftpenabled").val()?(s(".google-merchant-message").hide("slow"),s(".woo-feed-ftp .ftpconfig tr:not(.ftpcontroller) input, .woo-feed-ftp .ftpconfig tr:not(.ftpcontroller) select").attr("disabled","disabled")):(s(".woo-feed-ftp .ftpconfig tr:not(.ftpcontroller) input, .woo-feed-ftp .ftpconfig tr:not(.ftpcontroller) select").removeAttr("disabled"),"google"===s("#provider").val()?s(".google-merchant-message").show("slow"):s(".google-merchant-message").hide("slow"))})}).on("change",".ftporsftp",function(){var e=s(this).val(),t=s(".ssh2_status");"sftp"===e?(t.show().css("color","dodgerblue").text(r.form.sftp_checking),i.post("get_ssh2_status",{_ajax_nonce:r.nonce,server:e}).then(function(e){"exists"===e?(t.css("color","#2CC185").text(r.form.sftp_available),setTimeout(function(){t.hide()},1500)):t.show().css("color","red").text(r.form.sftp_warning)}).fail(function(e){t.hide(),u.ajax_fail(e)})):t.hide()}).on("click",'[name="save_feed_config"]',function(e){e.preventDefault(),s("#updatefeed").trigger("submit",{save:!0})}).on("change",".woo_feed_status_input",function(){var e=s(this);i.post("update_feed_status",{_ajax_nonce:r.nonce,feedName:e.val(),status:e[0].checked?1:0})}),s(l).on("change",'[name="is_outOfStock"], [name="product_visibility"]',function(){var e=s(".out-of-stock-visibility");"n"===s('[name="is_outOfStock"]:checked').val()&&"1"===s('[name="product_visibility"]:checked').val()?e.show():e.hide()}).on("change",".attr_type",function(){var e=s(this),t=e.val(),e=e.closest("tr");"pattern"===t?(e.find(".wf_attr").hide(),e.find(".wf_attr").val(""),e.find(".wf_default").show()):(e.find(".wf_attr").show(),e.find(".wf_default").hide(),e.find(".wf_default").val(""))}).on("change",".wf_mattributes, .attr_type",function(){var e=s(this).closest("tr"),o=e.find(".wf_mattributes"),t=e.find(".attr_type"),a=e.find("td:eq(4)"),n=s("#provider").val();r.form.google_category.hasOwnProperty(o.val())&&"pattern"===t.val()&&u.in_array(n,r.form.google_category[o.val()])?0===a.find("select.selectize").length&&(a.find("input.wf_default").remove(),a.append('<span class="wf_default wf_attributes"><select name="default[]" class="selectize"></select></span>'),a.append('<span style="font-size:x-small;"><a style="color: red" href="https://webappick.com/docs/woo-feed/feed-configuration/how-to-map-store-category-with-merchant-category/" target="_blank">'.concat(r.learn_more,"</a></span>")),f&&p||a.append('<span class="spinner is-active" style="margin: 0;"></span>'),e=a.find(".wf_attributes select"),u.selectize(e,{preload:!0,placeholder:r.form.select_category,load:function(e,t){f?t(f):i.send("get_google_categories",{type:"GET",data:{_ajax_nonce:r.nonce,action:"get_google_categories",provider:n}}).then(function(e){t(f=e),a.find(".spinner").remove()}).fail(u.ajax_fail),p||"facebook"!==n||"fb_product_category"!==o.val()?t(p):i.send("get_facebook_categories",{type:"GET",data:{_ajax_nonce:r.nonce,action:"get_facebook_categories",provider:n}}).then(function(e){t(p=e),a.find(".spinner").remove()}).fail(u.ajax_fail)}})):"current_category"!==o.val()&&0===a.find("input.wf_default").length&&(a.find("span").remove(),a.append('<input autocomplete="off" class="wf_default wf_attributes" type="text" name="default[]" value="">'),"pattern"!==t.val())&&a.find("input.wf_default").hide()}).on("change","#feedType,#provider",function(e){var t=s("#feedType").val(),o=s("#provider").val(),a=s(".itemWrapper"),n=s(".wf_csvtxt");""!==t&&u.in_array(o,r.form.item_wrapper_hidden)&&a.hide(),"feedType"===e.target.id&&("csv"===t||"txt"===t||"tsv"===t?(n.show(),a.hide(),"tsv"===t?s("#delimiter option:last").prop("selected","selected"):"csv"===t&&s("#delimiter option:first").prop("selected","selected")):"xml"===t&&"custom"===o?(a.show(),n.hide()):"json"===t&&n.hide()),"custom"!==o&&a.hide()}).trigger("change"),s(l).on("click",'.woofeed-custom-fields [id*="-switcher"]',function(){s(this).closest("td").find(".switch-loader").show();var e=s(this).attr("id").split("-")[0],t=s(this).data("taxonomy"),o=s(this).prop("checked");new n(e,o,t)}).ready(function(){var e=s(".wapk-feed-buy-now-container");s(c).scroll(function(){s(c).scrollTop()<=5e3?e.addClass("fixed"):e.removeClass("fixed")})})}),s(l).on("click","#woo-feed-debug-log-download",function(e){e.preventDefault(),s("<a />",{download:new Date+".log",href:URL.createObjectURL(new Blob([s("#woo-feed-debug-log").val()],{type:"text/plain"}))}).appendTo("body")[0].click()}).on("keyup","#filename",function(){var e=s("#filename").val();s("#utm_campaign").val(e)}).on("click",".wf-tab-name",function(e){s(".wf-tab-name.activate").removeClass("activate"),s(this).addClass("activate");var t=s(this).attr("for");s(".wf_tabs li.active").removeClass("active"),s(".wf_tabs .wf-tab-content#"+t).parent().addClass("active")}).on("change","#category-mapping-form #providers",function(){var e,t=s(this).find(":selected").val();s(".woo-feed-category-mapping-config-table").prepend('<div class="woo-feed-cat-map-spinner"><h3><span style="float:none;margin: -3px 0 0;" class="spinner is-active"></span> Loading Mapping...</h3></div>'),-1!==["google","facebook","pinterest","bing","bing_local_inventory","snapchat","tiktok"].indexOf(t)?(s('input[id*="cat_mapping_"]').css("display","none"),s(".wf_default.wf_attributes").css("display","block").css("width","100%"),e=new _,"facebook"===t?e.wooFeed_get_facebook_categories():e.wooFeed_get_google_categories()):(s('input[id*="cat_mapping_"]').css("display","block"),s(".wf_default.wf_attributes").css("display","none").css("width","100%"),s(".woo-feed-category-mapping-config-table .woo-feed-cat-map-spinner").css("display","none"))}).on("click",'span[id*="cat-map-"]',function(e){e.preventDefault();var o,e=s("#category-mapping-form #providers").val(),t=s(this).attr("id").replace(/[^\d.]/g,""),a="group-child-"+t;-1!==["google","facebook","pinterest","bing","bing_local_inventory","snapchat","tiktok"].indexOf(e)?(o=s(this).parents("tr").find(".selectized").val())&&s("."+a).parents("tr").find("select").each(function(e,t){s(t).data("selectize").setValue(o)}):(e=s("#cat_mapping_"+t).val(),s("."+a).parents("tr").find("input").val(e))}),s(l).ready(function(){var e=s("#providers").val(),t=new _;"edit-mapping"===new URL(c.location.href).searchParams.get("action")&&(s(".woo-feed-category-mapping-config-table").prepend('<div class="woo-feed-cat-map-spinner"><h3><span style="float:none;margin: -3px 0 0;" class="spinner is-active"></span> Loading Mapping...</h3></div>'),"facebook"===e?t.wooFeed_get_facebook_categories():t.wooFeed_get_google_categories())}),s(l).on("feed_editor_init",function(){var t=s(".merchant-info-section.feed_file_type .data").html().split(",").map(function(e){return e.trim().toLowerCase()}),e=s("#feedType");t.length?(e.find("option").each(function(){var e=s(this);e.val()&&!u.in_array(e.val(),t)?e.disabled(!0):e.disabled(!1)}),1===t.length&&e.find('option[value="'+t[0]+'"]').attr("selected","selected")):e.find("option").disabled(!1)}),s(l).on("ready",function(){s(l).on("feedEditor.init",function(){var i,t,r,e=s(this).find(":selected").val();-1!==["google","facebook","pinterest","bing","bing_local_inventory","snapchat","tiktok"].indexOf(e)&&(t={price:wpf_ajax_obj.woocommerce.currency,current_price:wpf_ajax_obj.woocommerce.currency,sale_price:wpf_ajax_obj.woocommerce.currency,price_with_tax:wpf_ajax_obj.woocommerce.currency,current_price_with_tax:wpf_ajax_obj.woocommerce.currency,sale_price_with_tax:wpf_ajax_obj.woocommerce.currency,weight:wpf_ajax_obj.woocommerce.weight,weight_unit:wpf_ajax_obj.woocommerce.weight,height:wpf_ajax_obj.woocommerce.dimension,length:wpf_ajax_obj.woocommerce.dimension,width:wpf_ajax_obj.woocommerce.dimension},void 0!==wpf_ajax_obj.feed_rules&&null!==wpf_ajax_obj.feed_rules&&(i=wpf_ajax_obj.feed_rules.feedCurrency),e=c.location.search,r=new URLSearchParams(e).get("action"),s(".wf_attr.wf_attributes").each(function(o,e){var a=s(e).val(),n=s('input[name^="suffix"]').eq(parseInt(o)).val();-1!==s.inArray(n,[" "+wpf_ajax_obj.woocommerce.currency," "+wpf_ajax_obj.woocommerce.weight," "+wpf_ajax_obj.woocommerce.dimension])&&s('input[name^="suffix"]').eq(parseInt(o)).val(""),s.each(t,function(e,t){a===e&&(t=null!=i?i:t,"undefined"!==r&&"edit-feed"!==r?s('input[name^="suffix"]').eq(parseInt(o)).val(" "+t):s('input[name^="suffix"]').eq(parseInt(o)).val(n))})}),s(l).trigger("feedEditor.after.free.postfix.update"))}),s("#wpf_import_file").on("change",function(e){"wpf"!==e.target.value.split("\\").pop().split(".").pop()&&(e.target.value="",alert("Please select a .wpf extension file"))}),wp.hooks.addAction("init_codemirror","codemirror",function(){var e=l.getElementById("editor_react");e&&((e=CodeMirror.fromTextArea(e,{lineNumbers:!0,mode:"xml",matchBrackets:!0})).setSize(null,620),e.on("change",function(e,t){c.localStorage.setItem("ctx_codemirror",e.getValue())}))})})}(jQuery,window,document,wp.ajax,wpf_ajax_obj);
|
|
//# sourceMappingURL=woo-feed-admin.min.js.map
|