woocommerce/assets/js/admin/meta-boxes.min.js

2 lines
36 KiB
JavaScript
Raw Normal View History

jQuery(function(a){function b(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}function c(){var b=a("select#product-type").val(),c=a("input#_virtual:checked").size(),d=a("input#_downloadable:checked").size(),e=".hide_if_downloadable, .hide_if_virtual",f=".show_if_downloadable, .show_if_virtual, .show_if_external";a.each(woocommerce_admin_meta_boxes.product_types,function(a,b){e=e+", .hide_if_"+b,f=f+", .show_if_"+b}),a(e).show(),a(f).hide(),d&&a(".show_if_downloadable").show(),c&&a(".show_if_virtual").show(),a(".show_if_"+b).show(),d&&a(".hide_if_downloadable").hide(),c&&a(".hide_if_virtual").hide(),a(".hide_if_"+b).hide(),a("input#_manage_stock").change()}function d(){a(".product_attributes .woocommerce_attribute").each(function(b,c){a(".attribute_position",c).val(parseInt(a(c).index(".product_attributes .woocommerce_attribute")))})}b(),a("#titlediv #title").keyup(function(b){var c=b.keyCode||b.which;return"9"==c&&a("#woocommerce-coupon-description").size()>0?(b.stopPropagation(),a("#woocommerce-coupon-description").focus(),!1):void 0}),a("select#discount_type").change(function(){var b=a(this).val();"fixed_product"==b||"percent_product"==b?a(".limit_usage_to_x_items_field").show():a(".limit_usage_to_x_items_field").hide()}).change(),a(function(){a('[id$="-all"] > ul.categorychecklist').each(function(){var b=a(this),c=b.find(":checked").first();if(c.length){var d=b.find("input").position().top,e=c.position().top;b.closest(".tabs-panel").scrollTop(e-d+5)}})}),a("#upsell_product_data").bind("keypress",function(a){return 13==a.keyCode?!1:void 0}),a(".type_box").appendTo("#woocommerce-product-data h3.hndle span"),a(function(){a("#woocommerce-product-data h3.hndle").unbind("click.postboxes"),jQuery("#woocommerce-product-data").on("click","h3.hndle",function(b){a(b.target).filter("input, option, label, select").length||a("#woocommerce-product-data").toggleClass("closed")})}),a(function(){jQuery(".wc-metabox > h3").click(function(){a(this).parent(".wc-metabox").toggleClass("closed").toggleClass("open")})}),a("#order-emails a.show-order-emails").click(function(){return a("#order-emails-select").is(":hidden")&&(a("#order-emails-select").slideDown("fast"),a(this).hide()),!1}),a("#order-emails a.hide-order-emails").click(function(){return a('input[name="order_email[]"]').each(function(){a(this).attr("checked",!1)}),a("#order-emails-select").is(":visible")&&(a("#order-emails-select").slideUp("fast"),a("#order-emails a.show-order-emails").show()),!1}),a("#catalog-visibility .edit-catalog-visibility").click(function(){return a("#catalog-visibility-select").is(":hidden")&&(a("#catalog-visibility-select").slideDown("fast"),a(this).hide()),!1}),a("#catalog-visibility .save-post-visibility").click(function(){a("#catalog-visibility-select").slideUp("fast"),a("#catalog-visibility .edit-catalog-visibility").show();var b=(a("input[name=_visibility]:checked").val(),a("input[name=_visibility]:checked").attr("data-label"));return a("input[name=_featured]").is(":checked")&&(b=b+", "+woocommerce_admin_meta_boxes.featured_label,a("input[name=_featured]").attr("checked","checked")),a("#catalog-visibility-display").text(b),!1}),a("#catalog-visibility .cancel-post-visibility").click(function(){a("#catalog-visibility-select").slideUp("fast"),a("#catalog-visibility .edit-catalog-visibility").show();var b=a("#current_visibility").val(),c=a("#current_featured").val();a("input[name=_visibility]").removeAttr("checked"),a("input[name=_visibility][value="+b+"]").attr("checked","checked");var d=a("input[name=_visibility]:checked").attr("data-label");return"yes"==c?(d=d+", "+woocommerce_admin_meta_boxes.featured_label,a("input[name=_featured]").attr("checked","checked")):a("input[name=_featured]").removeAttr("checked"),a("#catalog-visibility-display").text(d),!1}),a("ul.wc-tabs").show(),a("div.panel-wrap").each(function(){a(this).find("div.panel:not(:first)").hide()}),a("ul.wc-tabs a").click(function(){var b=a(this).closest("div.panel-wrap");return a("ul.wc
2014-03-17 10:53:17 +00:00
}),a(".product_attributes").on("click","button.remove_row",function(){var b=confirm(woocommerce_admin_meta_boxes.remove_attribute);if(b){var c=a(this).parent().parent();c.is(".taxonomy")?(c.find("select, input[type=text]").val(""),c.hide()):(c.find("select, input[type=text]").val(""),c.hide(),d())}return!1}),a(".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(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style"),d()}}),a(".product_attributes").on("click","button.add_new_attribute",function(){a(".product_attributes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b=a(this).attr("data-attribute"),c=a(this).closest(".woocommerce_attribute_data"),d=prompt(woocommerce_admin_meta_boxes.new_attribute_prompt);if(d){var e={action:"woocommerce_add_new_attribute",taxonomy:b,term:d,security:woocommerce_admin_meta_boxes.add_attribute_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,e,function(b){b.error?alert(b.error):b.slug&&(c.find("select.attribute_values").append('<option value="'+b.slug+'" selected="selected">'+b.name+"</option>"),c.find("select.attribute_values").trigger("chosen:updated")),a(".product_attributes").unblock()})}else a(".product_attributes").unblock();return!1}),a(".save_attributes").on("click",function(){a(".product_attributes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b={post_id:woocommerce_admin_meta_boxes.post_id,data:a(".product_attributes").find("input, select, textarea").serialize(),action:"woocommerce_save_attributes",security:woocommerce_admin_meta_boxes.save_attributes_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,b,function(){var b=window.location.toString();b=b.replace("post-new.php?","post.php?post="+woocommerce_admin_meta_boxes.post_id+"&action=edit&"),a("#variable_product_options").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a("#variable_product_options").load(b+" #variable_product_options_inner",function(){a("#variable_product_options").unblock()}),a(".product_attributes").unblock()})});var g,h;jQuery(document).on("click",".upload_file_button",function(b){var c=a(this);if(h=c.closest("tr").find("td.file_url input"),b.preventDefault(),g)return void g.open();var d=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:c.data("choose"),priority:20,filterable:"uploaded"})];g=wp.media.frames.downloadable_file=wp.media({title:c.data("choose"),library:{type:""},button:{text:c.data("update")},multiple:!0,states:d}),g.on("select",function(){var a="",b=g.state().get("selection");b.map(function(b){b=b.toJSON(),b.url&&(a=b.url)}),h.val(a)}),g.on("ready",function(){g.uploader.options.uploader.params={type:"downloadable_product"}}),g.open()}),jQuery(".downloadable_files tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65});var i,j=a("#product_image_gallery"),k=a("#product_images_container ul.product_images");jQuery(".add_product_images").on("click","a",function(b){var c=a(this),d=j.val();return b.preventDefault(),i?void i.open():(i=wp.media.frames.product_gallery=wp.media({title:c.data("choose"),button:{text:c.data("update")},states:[new wp.media.controller.Library({title:c.data("choose"),filterable:"all",multiple:!0})]}),i.on("select",function(){var a=i.state().get("selection");a.map(function(a){a=a.toJSON(),a.id&&(d=d?d+","+a.id:a.id,k.append(' <li class="image" data-attachment_id="'+a.id+'"> <img src="'+a.url+'" /> <ul class="actions"> <li><a href="#" class="delete" title="'+c.data("delete")+'">'+c.da