File "meta-boxes-product.min.js"
Full Path: /home/jlklyejr/public_html/wp-content/test/wp-content/plugins/woocommerce/assets/js/admin/meta-boxes-product.min.js
File size: 17.73 KB
MIME-type: text/plain
Charset: utf-8
jQuery(function(t){let e=!1;function o(e){var o=t("select#product-type").val(),a=t("input#_virtual:checked").length,i=t("input#_downloadable:checked").length,r=".hide_if_downloadable, .hide_if_virtual",c=".show_if_downloadable, .show_if_virtual";t.each(woocommerce_admin_meta_boxes.product_types,function(t,e){r=r+", .hide_if_"+e,c=c+", .show_if_"+e}),t(r,e).show(),t(c,e).hide(),i&&t(".show_if_downloadable",e).show(),a&&t(".show_if_virtual",e).show(),t(".show_if_"+o,e).show(),i&&t(".hide_if_downloadable",e).hide(),a&&t(".hide_if_virtual",e).hide(),t(".hide_if_"+o,e).hide()}function a(){o(),t("input#_manage_stock").trigger("change"),t(".woocommerce_options_panel").each(function(){var e=t(this).children(".options_group");if(0!==e.length&&e.filter(function(){return"none"===t(this).css("display")}).length===e.length){var o=t(this).prop("id");t(".product_data_tabs").find('li a[href="#'+o+'"]').parent().hide()}})}function i(e){var o=t(e).next().is(".hasDatepicker")?"minDate":"maxDate",a="minDate"===o?t(e).next():t(e).prev(),i=t(e).datepicker("getDate");t(a).datepicker("option",o,i),t(e).trigger("change")}t(window).on("beforeunload",function(){e=!0}),t(function(){t('[id$="-all"] > ul.categorychecklist').each(function(){var e=t(this),o=e.find(":checked").first();if(o.length){var a=e.find("input").position().top,i=o.position().top;e.closest(".tabs-panel").scrollTop(i-a+5)}})}),t("#upsell_product_data").on("keypress",function(t){if(13===t.keyCode)return!1}),t("body").hasClass("wc-wp-version-gte-55")?t(".type_box").appendTo("#woocommerce-product-data .hndle"):t(".type_box").appendTo("#woocommerce-product-data .hndle span"),t(function(){var e=t("#woocommerce-product-data");e.find(".hndle").off("click.postboxes"),e.on("click",".hndle",function(o){t(o.target).filter("input, option, label, select").length||(e.hasClass("closed")?e.removeClass("closed"):e.addClass("closed"))})}),t("#catalog-visibility").find(".edit-catalog-visibility").on("click",function(){return t("#catalog-visibility-select").is(":hidden")&&(t("#catalog-visibility-select").slideDown("fast"),t(this).hide()),!1}),t("#catalog-visibility").find(".save-post-visibility").on("click",function(){t("#catalog-visibility-select").slideUp("fast"),t("#catalog-visibility").find(".edit-catalog-visibility").show();var e=t("input[name=_visibility]:checked").attr("data-label");return t("input[name=_featured]").is(":checked")&&(e=e+", "+woocommerce_admin_meta_boxes.featured_label,t("input[name=_featured]").attr("checked","checked")),t("#catalog-visibility-display").text(e),!1}),t("#catalog-visibility").find(".cancel-post-visibility").on("click",function(){t("#catalog-visibility-select").slideUp("fast"),t("#catalog-visibility").find(".edit-catalog-visibility").show();var e=t("#current_visibility").val(),o=t("#current_featured").val();t("input[name=_visibility]").prop("checked",!1),t("input[name=_visibility][value="+e+"]").attr("checked","checked");var a=t("input[name=_visibility]:checked").attr("data-label");return"yes"===o?(a=a+", "+woocommerce_admin_meta_boxes.featured_label,t("input[name=_featured]").attr("checked","checked")):t("input[name=_featured]").prop("checked",!1),t("#catalog-visibility-display").text(a),!1}),t("select#product-type").on("change",function(){var e,o=t(this).val();"variable"===o?(t("input#_manage_stock").trigger("change"),t("input#_downloadable").prop("checked",!1),t("input#_virtual").prop("checked",!1)):"grouped"===o?(t("input#_downloadable").prop("checked",!1),t("input#_virtual").prop("checked",!1)):"external"===o&&(t("input#_downloadable").prop("checked",!1),t("input#_virtual").prop("checked",!1)),a(),e=function(t){switch(t){case"simple":return woocommerce_admin_meta_boxes.i18n_product_simple_tip;case"grouped":return woocommerce_admin_meta_boxes.i18n_product_grouped_tip;case"external":return woocommerce_admin_meta_boxes.i18n_product_external_tip;case"variable":return woocommerce_admin_meta_boxes.i18n_product_variable_tip;default:return woocommerce_admin_meta_boxes.i18n_product_other_tip}}(o),t("#tiptip_holder").removeAttr("style"),t("#tiptip_arrow").removeAttr("style"),t(".woocommerce-product-type-tip").attr("tabindex","0").attr("aria-label",t("<div />").html(e).text()).tipTip({attribute:"data-tip",content:e,fadeIn:50,fadeOut:50,delay:200,keepAlive:!0}),t("ul.wc-tabs li:visible").eq(0).find("a").trigger("click"),t(document.body).trigger("woocommerce-product-type-change",o,t(this))}).trigger("change"),t("input#_downloadable").on("change",function(){a()}),t("input#_virtual").on("change",function(){a(),t(this).is(":checked")&&t(".shipping_options.shipping_tab").hasClass("active")&&t(".general_options.general_tab > a").trigger("click")}),t(".sale_price_dates_fields").each(function(){var e=t(this),o=!1,a=e.closest("div, table");e.find("input").each(function(){""!==t(this).val()&&(o=!0)}),o?(a.find(".sale_schedule").hide(),a.find(".sale_price_dates_fields").show()):(a.find(".sale_schedule").show(),a.find(".sale_price_dates_fields").hide())}),t("#woocommerce-product-data").on("click",".sale_schedule",function(){var e=t(this).closest("div, table");return t(this).hide(),e.find(".cancel_sale_schedule").show(),e.find(".sale_price_dates_fields").show(),!1}),t("#woocommerce-product-data").on("click",".cancel_sale_schedule",function(){var e=t(this).closest("div, table");return t(this).hide(),e.find(".sale_schedule").show(),e.find(".sale_price_dates_fields").hide(),e.find(".sale_price_dates_fields").find("input").val(""),!1}),t("#woocommerce-product-data").on("click",".downloadable_files a.insert",function(){return t(this).closest(".downloadable_files").find("tbody").append(t(this).data("row")),!1}),t("#woocommerce-product-data").on("click",".downloadable_files a.delete",function(){return t(this).closest("tr").remove(),!1}),t("input#_manage_stock").on("change",function(){!function(e,o){const a=t(".stock_fields"),i=t(".stock_status_field");a.toggle(e),i.toggle(!e&&!i.is(".hide_if_"+o))}(t(this).is(":checked"),t("select#product-type").val()),t("input.variable_manage_stock").trigger("change")}).trigger("change"),t(".sale_price_dates_fields").each(function(){t(this).find("input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,onSelect:function(){i(t(this))}}),t(this).find("input").each(function(){i(t(this))})});const r=t(".product_attributes");if(1===r.length){t("#product_attributes").on("woocommerce_tab_shown",function(){m(),0===r.find(".woocommerce_attribute").get().length&&p()});const e=r.find(".woocommerce_attribute").get();e.sort(function(e,o){var a=parseInt(t(e).attr("rel"),10),i=parseInt(t(o).attr("rel"),10);return a<i?-1:a>i?1:0}),t(e).each(function(t,e){r.append(e)})}function c(){t(".product_attributes .woocommerce_attribute").each(function(e,o){t(".attribute_position",o).val(parseInt(t(o).index(".product_attributes .woocommerce_attribute"),10))})}var n,s,d,l=[];function u(t){var e=t.find("input.woocommerce_attribute_used_for_variations");e.length&&e.is(":checked")?t.find("textarea").attr("placeholder",woocommerce_admin_meta_boxes.i18n_attributes_used_for_variations_placeholder):t.find("textarea").attr("placeholder",woocommerce_admin_meta_boxes.i18n_attributes_default_placeholder)}async function _(a){try{t("#product_attributes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});const r=t(".product_attributes .woocommerce_attribute").length,n=await function(e,o){return new Promise(function(a,i){t.post({url:woocommerce_admin_meta_boxes.ajax_url,data:{action:"woocommerce_add_attribute",product_type:t("#product-type").val(),taxonomy:o||"",i:e,security:woocommerce_admin_meta_boxes.add_attribute_nonce},success:function(t){a(t)},error:function(t,e,o){i({jqXHR:t,textStatus:e,errorThrown:o})}})})}(r,a),s=t("#product_attributes .product_attributes"),d=t(n).appendTo(s);o(d),t(document.body).trigger("wc-enhanced-select-init"),c(),d.find("h3").trigger("click"),void 0===a&&(u(d),t(".woocommerce_attribute input.woocommerce_attribute_used_for_variations").on("change",function(){u(t(this).closest(".woocommerce_attribute"))})),t(document.body).trigger("woocommerce_added_attribute"),jQuery.maybe_disable_save_button()}catch(i){if(e)return;throw alert(woocommerce_admin_meta_boxes.i18n_add_attribute_error_notice),i}finally{t("#product_attributes").unblock()}}function p(){_()}function m(){const e=t(".product_attributes .woocommerce_attribute");if(1===e.length){const t=e.first(),o=t.find('input[name="attribute_names[0]"]'),a=t.find('input[name="attribute_values[0]"]');o.val()||a.val()||t.remove()}}t(".product_attributes .woocommerce_attribute").each(function(e,o){"none"!==t(o).css("display")&&t(o).is(".taxonomy")&&(l.push(t(o).data("taxonomy")),t("select.attribute_taxonomy").find('option[value="'+t(o).data("taxonomy")+'"]').attr("disabled","disabled")),"undefined"!==t(o).attr("data-taxonomy")&&!1!==t(o).attr("data-taxonomy")&&""!==t(o).attr("data-taxonomy")||(u(t(o)),t(".woocommerce_attribute input.woocommerce_attribute_used_for_variations").on("change",function(){u(t(o))}))}),t("select.wc-attribute-search").data("disabled-items",l),localStorage.getItem("attributes-notice-dismissed")&&t("#product_attributes .notice").hide(),t("#product_attributes .notice.woocommerce-message button").on("click",function(e){t("#product_attributes .notice").hide(),localStorage.setItem("attributes-notice-dismissed","true")}),t("select.wc-attribute-search").on("select2:select",function(e){const o=e&&e.params&&e.params.data&&e.params.data.id;var a,i;return o&&(m(),_(o),i=o,function(e){t("select.wc-attribute-search").data("disabled-items",e)}(l=(a=l).includes(i)?attr:[...a,i])),t(this).val(null),t(this).trigger("change"),!1}),t("button.add_custom_attribute").on("click",function(){return p(),!1}),t(".product_attributes").on("blur","input.attribute_name",function(){var e=t(this),o=e.val(),a=e.closest(".woocommerce_attribute").find("strong.attribute_name");""===o?a.addClass("placeholder").text(woocommerce_admin_meta_boxes.i18n_attribute_name_placeholder):a.removeClass("placeholder").text(o)}),t(".product_attributes").on("click","button.select_all_attributes",function(){t(".product_attributes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e=t(this).closest(".woocommerce_attribute"),o={action:"woocommerce_json_search_taxonomy_terms",taxonomy:e.data("taxonomy"),security:wc_enhanced_select_params.search_taxonomy_terms_nonce};return t.get(woocommerce_admin_meta_boxes.ajax_url,o,function(o){o.errors?window.alert(o.errors):o&&o.length>0&&(o.forEach(function(t){const o=e.find('select.attribute_values option[value="'+t.term_id+'"]');o&&o.length>0?o.prop("selected","selected"):e.find("select.attribute_values").append('<option value="'+t.term_id+'" selected="selected">'+t.name+"</option>")}),e.find("select.attribute_values").trigger("change")),t(".product_attributes").unblock()}),!1}),t(".product_attributes").on("click","button.select_no_attributes",function(){return t(this).closest("td").find("select option").prop("selected",!1),t(this).closest("td").find("select").trigger("change"),!1}),t("#product_attributes").on("click",".product_attributes .remove_row",function(){var e=t(this).parent().parent();return e.find('input[name^="attribute_variation"]').is(":visible:checked")&&!window.confirm(woocommerce_admin_meta_boxes.i18n_remove_used_attribute_confirmation_message)||(e.is(".taxonomy")?(e.find("select, input[type=text]").val(""),e.hide(),t("select.attribute_taxonomy").find('option[value="'+e.data("taxonomy")+'"]').prop("disabled",!1),l=l.filter(t=>t!==e.data("taxonomy")),t("select.wc-attribute-search").data("disabled-items",l)):(e.find("select, input[type=text]").val(""),e.hide(),c()),e.remove(),window.wcTracks.recordEvent("product_attributes_buttons",{action:"remove_attribute"}),jQuery.maybe_disable_save_button()),!1}),t(".product_attributes").sortable({items:".woocommerce_attribute",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style"),c()}}),t(".product_attributes").on("click","button.add_new_attribute",function(e){e.preventDefault(),t(".product_attributes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var o=t(this).closest(".woocommerce_attribute"),a=o.data("taxonomy"),i=window.prompt(woocommerce_admin_meta_boxes.new_attribute_prompt);if(i){var r={action:"woocommerce_add_new_attribute",taxonomy:a,term:i,security:woocommerce_admin_meta_boxes.add_attribute_nonce};t.post(woocommerce_admin_meta_boxes.ajax_url,r,function(e){e.error?window.alert(e.error):e.slug&&(o.find("select.attribute_values").append('<option value="'+e.term_id+'" selected="selected">'+e.name+"</option>"),o.find("select.attribute_values").trigger("change")),t(".product_attributes").unblock()})}else t(".product_attributes").unblock()}),t(".save_attributes").on("click",function(e){if(t(this).hasClass("disabled"))e.preventDefault();else{t(".product_attributes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var o=t(".product_attributes").find("input, select, textarea"),i={post_id:woocommerce_admin_meta_boxes.post_id,product_type:t("#product-type").val(),data:o.serialize(),action:"woocommerce_save_attributes",security:woocommerce_admin_meta_boxes.save_attributes_nonce};t.post(woocommerce_admin_meta_boxes.ajax_url,i,function(e){if(e.error)window.alert(e.error);else if(e.data){t(".product_attributes").html(e.data.html),t(".product_attributes").unblock(),a(),t("select.attribute_taxonomy").find("option").prop("disabled",!1);var o=[];t(".product_attributes .woocommerce_attribute").each(function(e,a){"none"!==t(a).css("display")&&t(a).is(".taxonomy")&&(o.push(t(a).data("taxonomy")),t("select.attribute_taxonomy").find('option[value="'+t(a).data("taxonomy")+'"]').prop("disabled",!0))}),l=o,t("select.wc-attribute-search").data("disabled-items",o);var i=window.location.toString();i=i.replace("post-new.php?","post.php?post="+woocommerce_admin_meta_boxes.post_id+"&action=edit&"),t("#variable_product_options").load(i+" #variable_product_options_inner",function(){t("#variable_product_options").trigger("reload")}),t(document.body).trigger("woocommerce_attributes_saved")}})}}),t(document.body).on("click",'#variable_product_options .add-attributes-message a[href="#product_attributes"]',function(){return t('#woocommerce-product-data .attribute_tab a[href="#product_attributes"]').trigger("click"),!1}),t(document.body).on("click",".upload_file_button",function(e){var o=t(this);if(s=o.closest("tr").find("td.file_url input"),e.preventDefault(),n)n.open();else{var a=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:o.data("choose"),priority:20,filterable:"uploaded"})];(n=wp.media.frames.downloadable_file=wp.media({title:o.data("choose"),library:{type:""},button:{text:o.data("update")},multiple:!0,states:a})).on("select",function(){var t="";n.state().get("selection").map(function(e){(e=e.toJSON()).url&&(t=e.url)}),s.val(t).trigger("change")}),n.on("ready",function(){n.uploader.options.uploader.params={type:"downloadable_product"}}),n.open()}}),t(".downloadable_files tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65});var b=t("#product_image_gallery"),f=t("#product_images_container").find("ul.product_images");t(".add_product_images").on("click","a",function(e){var o=t(this);e.preventDefault(),d?d.open():((d=wp.media.frames.product_gallery=wp.media({title:o.data("choose"),button:{text:o.data("update")},states:[new wp.media.controller.Library({title:o.data("choose"),filterable:"all",multiple:!0})]})).on("select",function(){var t=d.state().get("selection"),e=b.val();t.map(function(t){if((t=t.toJSON()).id){e=e?e+","+t.id:t.id;var a=t.sizes&&t.sizes.thumbnail?t.sizes.thumbnail.url:t.url;f.append('<li class="image" data-attachment_id="'+t.id+'"><img src="'+a+'" /><ul class="actions"><li><a href="#" class="delete" title="'+o.data("delete")+'">'+o.data("text")+"</a></li></ul></li>")}}),b.val(e)}),d.open())}),f.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style")},update:function(){var e="";t("#product_images_container").find("ul li.image").css("cursor","default").each(function(){var o=t(this).attr("data-attachment_id");e=e+o+","}),b.val(e)}}),t("#product_images_container").on("click","a.delete",function(){t(this).closest("li.image").remove();var e="";return t("#product_images_container").find("ul li.image").css("cursor","default").each(function(){var o=t(this).attr("data-attachment_id");e=e+o+","}),b.val(e),t("#tiptip_holder").removeAttr("style"),t("#tiptip_arrow").removeAttr("style"),!1}),t("#wp-content-media-buttons").append('<span class="woocommerce-help-tip" tabindex="0"></span>').find(".woocommerce-help-tip").attr("tabindex","0").attr("for","content").attr("aria-label",woocommerce_admin_meta_boxes.i18n_product_description_tip).tipTip({attribute:"data-tip",content:woocommerce_admin_meta_boxes.i18n_product_description_tip,fadeIn:50,fadeOut:50,delay:200,keepAlive:!0}),t("#postexcerpt > .postbox-header > .hndle").append('<span class="woocommerce-help-tip"></span>').find(".woocommerce-help-tip").attr("tabindex","0").attr("aria-label",woocommerce_admin_meta_boxes.i18n_product_short_description_tip).tipTip({attribute:"data-tip",content:woocommerce_admin_meta_boxes.i18n_product_short_description_tip,fadeIn:50,fadeOut:50,delay:200,keepAlive:!0});const h=t("#set-post-thumbnail"),v=`<span class="woocommerce-help-tip" tabindex="0" aria-label="${woocommerce_admin_meta_boxes.i18n_product_image_tip}"></span>`,w={attribute:"data-tip",content:woocommerce_admin_meta_boxes.i18n_product_image_tip,fadeIn:50,fadeOut:50,delay:200,keepAlive:!0};h&&t(v).insertAfter(h).tipTip(w);const g=t(".add_product_images > a");g&&t(v).insertAfter(g).tipTip(w)});