File "wc-enhanced-select.min.js"
Full Path: /home/jovision/public_html/wp/wp-content/plugins/woocommerce/assets/js/admin/wc-enhanced-select.min.js
File size: 9.16 KB
MIME-type: application/javascript
Charset: utf-8
jQuery(function(e){function t(e){const t=(a=e.visual).type&&a.value?"image"===a.type?"background-image:url('"+String(a.value).replace(/'/g,"%27")+"')":"color"===a.type?"background-color:"+a.value:"":"";var a;const n="wc-admin-color-swatch"+(t?"":" is-empty"),c=document.createElement("span");c.className="wc-admin-visual-attribute-term-option";const i=document.createElement("span");i.className=n,t&&i.setAttribute("style",t),i.setAttribute("aria-hidden","true");const s=document.createElement("span");return s.className="wc-admin-visual-attribute-term-label",s.textContent=e.text,c.appendChild(i),c.appendChild(s),c}function a(a){var n=a.next(".select2-container");n.length&&n.find(".select2-selection__choice").each(function(){const n=e(this),c=n.data("data");if(!c)return;const i=n.find(".select2-selection__choice__remove").detach(),s=function(t,a){if(a.visual)return a;const n=t.find("option").filter(function(){return e(this).val()===String(a.id)});if(!n.length)return a;const c=n.data("visual");return c?Object.assign({},a,{visual:c}):a}(a,c);n.empty().append(i).append(t(s)),n.prop("title",s.title||s.text)})}function n(){return{language:{errorLoading:function(){return wc_enhanced_select_params.i18n_searching},inputTooLong:function(e){var t=e.input.length-e.maximum;return 1===t?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",t)},inputTooShort:function(e){var t=e.minimum-e.input.length;return 1===t?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",t)},loadingMore:function(){return wc_enhanced_select_params.i18n_load_more},maximumSelected:function(e){return 1===e.maximum?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",e.maximum)},noResults:function(){return wc_enhanced_select_params.i18n_no_matches},searching:function(){return wc_enhanced_select_params.i18n_searching}}}}try{e(document.body).on("wc-enhanced-select-init",function(){e(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var t=e.extend({minimumResultsForSearch:10,allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder")},n());e(this).selectWoo(t).addClass("enhanced")}),e(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var t=e.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:e(this).data("placeholder")},n());e(this).selectWoo(t).addClass("enhanced")}),e(":input.wc-product-search").filter(":not(.enhanced)").each(function(){!function(t,a){if(a=e.extend(a,n()),e(t).selectWoo(a).addClass("enhanced"),e(t).data("sortable")){var c=e(t),i=e(t).next(".select2-container").find("ul.select2-selection__rendered");i.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){e(i.find(".select2-selection__choice").get().reverse()).each(function(){var t=e(this).data("data").id,a=c.find('option[value="'+t+'"]')[0];c.prepend(a)})}})}else e(t).prop("multiple")&&e(t).on("change",function(){var a=e(t).children();a.sort(function(e,t){var a=e.text.toLowerCase(),n=t.text.toLowerCase();return a>n?1:a<n?-1:0}),e(t).html(a)})}(this,{allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(t){let a=e(this).data("exclude");const n=e(this).val();if(Array.isArray(n)&&e(this).prop("multiple")){a=[...a?String(a).split(","):[],...n]}return{term:t.term,action:e(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:a,exclude_type:e(this).data("exclude_type"),include:e(this).data("include"),limit:e(this).data("limit"),display_stock:e(this).data("display_stock")}},processResults:function(t){var a=[];return t&&e.each(t,function(e,t){a.push({id:e,text:t})}),{results:a}},cache:!0}})}),e(":input.wc-page-search").filter(":not(.enhanced)").each(function(){var t={allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(t){return{term:t.term,action:e(this).data("action")||"woocommerce_json_search_pages",security:wc_enhanced_select_params.search_pages_nonce,exclude:e(this).data("exclude"),post_status:e(this).data("post_status"),limit:e(this).data("limit")}},processResults:function(t){var a=[];return t&&e.each(t,function(e,t){a.push({id:e,text:t})}),{results:a}},cache:!0}};e(this).selectWoo(t).addClass("enhanced")}),e(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var t={allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"1",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:1e3,data:function(t){return{term:t.term,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:e(this).data("exclude")}},processResults:function(t){var a=[];return t&&e.each(t,function(e,t){a.push({id:e,text:t})}),{results:a}},cache:!0}};if(t=e.extend(t,n()),e(this).selectWoo(t).addClass("enhanced"),e(this).data("sortable")){var a=e(this),c=e(this).next(".select2-container").find("ul.select2-selection__rendered");c.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){e(c.find(".select2-selection__choice").get().reverse()).each(function(){var t=e(this).data("data").id,n=a.find('option[value="'+t+'"]')[0];a.prepend(n)})}})}}),e(":input.wc-category-search").filter(":not(.enhanced)").each(function(){var t=e(this).data("return_id")?"id":"slug",a=e.extend({allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(e){return{term:e.term,action:"woocommerce_json_search_categories",security:wc_enhanced_select_params.search_categories_nonce}},processResults:function(a){var n=[];return a&&e.each(a,function(e,a){n.push({id:"id"===t?a.term_id:a.slug,text:a.formatted_name})}),{results:n}},cache:!0}},n());e(this).selectWoo(a).addClass("enhanced")}),e(":input.wc-taxonomy-term-search").filter(":not(.enhanced)").each(function(){var c=e(this).data("return_id")?"id":"slug",i="yes"===e(this).data("isVisualAttribute"),s=e.extend({allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:null!==e(this).data("minimum_input_length")&&e(this).data("minimum_input_length")!==undefined?e(this).data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(t){return{taxonomy:e(this).data("taxonomy"),limit:e(this).data("limit"),orderby:e(this).data("orderby"),term:t.term,action:"woocommerce_json_search_taxonomy_terms",security:wc_enhanced_select_params.search_taxonomy_terms_nonce}},processResults:function(t){var a=[];return t&&e.each(t,function(e,t){var n={id:"id"===c?t.term_id:t.slug,text:t.name};i&&(n.visual=t.visual||{type:"none",value:""}),a.push(n)}),{results:a}},cache:!0}},n());i&&(s.templateResult=function(e){return e.loading?e.text:t(e)});var r=e(this);r.selectWoo(s).addClass("enhanced"),i&&(a(r),r.on("change.wcVisualAttributeTerms select2:select.wcVisualAttributeTerms",function(){a(r)}))}),e(":input.wc-attribute-search").filter(":not(.enhanced)").each(function(){var t=this,a=e.extend({allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:null!==e(this).data("minimum_input_length")&&e(this).data("minimum_input_length")!==undefined?e(this).data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(e){return{term:e.term,action:"woocommerce_json_search_product_attributes",security:wc_enhanced_select_params.search_product_attributes_nonce}},processResults:function(a){var n=e(t).data("disabled-items")||[],c=[];return a&&e.each(a,function(e,t){c.push({id:t.slug,text:t.name,disabled:n.includes(t.slug)})}),{results:c}},cache:!0}},n());e(this).selectWoo(a).addClass("enhanced")})}).on("wc_backbone_modal_before_remove",function(){e(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").selectWoo("close")}).trigger("wc-enhanced-select-init"),e("html").on("click",function(t){this===t.target&&e(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").selectWoo("close")})}catch(c){window.console.log(c)}});