2013-11-28 13:39:42 +00:00
|
|
|
jQuery(function(e){function t(){var t=e("select#product-type").val(),n=e("input#_virtual:checked").size(),r=e("input#_downloadable:checked").size(),i=".hide_if_downloadable, .hide_if_virtual",s=".show_if_downloadable, .show_if_virtual, .show_if_external";e.each(woocommerce_admin_meta_boxes.product_types,function(e,t){i=i+", .hide_if_"+t;s=s+", .show_if_"+t});e(i).show();e(s).hide();r&&e(".show_if_downloadable").show();n&&e(".show_if_virtual").show();e(".show_if_"+t).show();r&&e(".hide_if_downloadable").hide();n&&e(".hide_if_virtual").hide();e(".hide_if_"+t).hide();e("input#_manage_stock").change()}function i(){e(".product_attributes .woocommerce_attribute").each(function(t,n){e(".attribute_position",n).val(parseInt(e(n).index(".product_attributes .woocommerce_attribute")))})}e("#titlediv #title").keyup(function(t){var n=t.keyCode||t.which;if(n=="9"&&e("#woocommerce-coupon-description").size()>0){t.stopPropagation();e("#woocommerce-coupon-description").focus();return!1}});e("select#discount_type").change(function(){var t=e(this).val();t=="fixed_product"||t=="percent_product"?e(".limit_usage_to_x_items_field").show():e(".limit_usage_to_x_items_field").hide()}).change();e(function(){e('[id$="-all"] > ul.categorychecklist').each(function(){var t=e(this),n=t.find(":checked").first();if(!n.length)return;var r=t.find("input").position().top,i=n.position().top;t.closest(".tabs-panel").scrollTop(i-r+5)})});e("#upsell_product_data").bind("keypress",function(e){if(e.keyCode==13)return!1});e(".type_box").appendTo("#woocommerce-product-data h3.hndle span");e(function(){e("#woocommerce-product-data h3.hndle").unbind("click.postboxes");jQuery("#woocommerce-product-data").on("click","h3.hndle",function(t){if(e(t.target).filter("input, option, label, select").length)return;e("#woocommerce-product-data").toggleClass("closed")})});e(function(){jQuery(".wc-metabox > h3").click(function(t){e(this).parent(".wc-metabox").toggleClass("closed").toggleClass("open")})});e("#order-emails a.show-order-emails").click(function(){if(e("#order-emails-select").is(":hidden")){e("#order-emails-select").slideDown("fast");e(this).hide()}return!1});e("#order-emails a.hide-order-emails").click(function(){e('input[name="order_email[]"]').each(function(){e(this).attr("checked",!1)});if(e("#order-emails-select").is(":visible")){e("#order-emails-select").slideUp("fast");e("#order-emails a.show-order-emails").show()}return!1});e("#catalog-visibility .edit-catalog-visibility").click(function(){if(e("#catalog-visibility-select").is(":hidden")){e("#catalog-visibility-select").slideDown("fast");e(this).hide()}return!1});e("#catalog-visibility .save-post-visibility").click(function(){e("#catalog-visibility-select").slideUp("fast");e("#catalog-visibility .edit-catalog-visibility").show();var t=e("input[name=_visibility]:checked").val(),n=e("input[name=_visibility]:checked").attr("data-label");if(e("input[name=_featured]").is(":checked")){n=n+", "+woocommerce_admin_meta_boxes.featured_label;e("input[name=_featured]").attr("checked","checked")}e("#catalog-visibility-display").text(n);return!1});e("#catalog-visibility .cancel-post-visibility").click(function(){e("#catalog-visibility-select").slideUp("fast");e("#catalog-visibility .edit-catalog-visibility").show();var t=e("#current_visibility").val(),n=e("#current_featured").val();e("input[name=_visibility]").removeAttr("checked");e("input[name=_visibility][value="+t+"]").attr("checked","checked");var r=e("input[name=_visibility]:checked").attr("data-label");if(n=="yes"){r=r+", "+woocommerce_admin_meta_boxes.featured_label;e("input[name=_featured]").attr("checked","checked")}else e("input[name=_featured]").removeAttr("checked");e("#catalog-visibility-display").text(r);return!1});e("ul.wc-tabs").show();e("div.panel-wrap").each(function(){e(this).find("div.panel:not(:first)").hide()});e("ul.wc-tabs a").click(function(){var t=e(this).closest("div.panel-wrap");e("ul.wc-tabs li",t).removeClass("active");e(this).parent().addClass("active");e("div.panel",t).hide();e(e(this).attr("href")).show();return!1});jQuery("select.chosen_sel
|
|
|
|
);else if(t.slug){n.find("select.attribute_values").append('<option value="'+t.slug+'" selected="selected">'+t.name+"</option>");n.find("select.attribute_values").trigger("chosen:updated")}e(".product_attributes").unblock()})}else e(".product_attributes").unblock();return!1});e(".save_attributes").on("click",function(){e(".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 t={post_id:woocommerce_admin_meta_boxes.post_id,data:e(".product_attributes").find("input, select, textarea").serialize(),action:"woocommerce_save_attributes",security:woocommerce_admin_meta_boxes.save_attributes_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(t){var n=window.location.toString();n=n.replace("post-new.php?","post.php?post="+woocommerce_admin_meta_boxes.post_id+"&action=edit&");e("#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}});e("#variable_product_options").load(n+" #variable_product_options_inner",function(){e("#variable_product_options").unblock()});e(".product_attributes").unblock()})});var s,o;jQuery(document).on("click",".upload_file_button",function(t){var n=e(this);o=n.closest("tr").find("td.file_url input");t.preventDefault();if(s){s.open();return}var r=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:n.data("choose"),priority:20,filterable:"uploaded"})];s=wp.media.frames.downloadable_file=wp.media({title:n.data("choose"),library:{type:""},button:{text:n.data("update")},multiple:!0,states:r});s.on("select",function(){var e="",t=s.state().get("selection");t.map(function(t){t=t.toJSON();t.url&&(e=t.url)});o.val(e)});s.on("ready",function(){s.uploader.options.uploader.params={type:"downloadable_product"}});s.open()});jQuery(".downloadable_files tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65});var u,a=e("#product_image_gallery"),f=e("#product_images_container ul.product_images");jQuery(".add_product_images").on("click","a",function(t){var n=e(this),r=a.val();t.preventDefault();if(u){u.open();return}u=wp.media.frames.downloadable_file=wp.media({title:n.data("choose"),button:{text:n.data("update")},multiple:!0});u.on("select",function(){var e=u.state().get("selection");e.map(function(e){e=e.toJSON();if(e.id){r=r?r+","+e.id:e.id;f.append(' <li class="image" data-attachment_id="'+e.id+'"> <img src="'+e.url+'" /> <ul class="actions"> <li><a href="#" class="delete" title="'+n.data("delete")+'">'+n.data("text")+"</a></li> </ul> </li>")}});a.val(r)});u.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(e,t){t.item.css("background-color","#f6f6f6")},stop:function(e,t){t.item.removeAttr("style")},update:function(t,n){var r="";e("#product_images_container ul li.image").css("cursor","default").each(function(){var e=jQuery(this).attr("data-attachment_id");r=r+e+","});a.val(r)}});e("#product_images_container").on("click","a.delete",function(){e(this).closest("li.image").remove();var t="";e("#product_images_container ul li.image").css("cursor","default").each(function(){var e=jQuery(this).attr("data-attachment_id");t=t+e+","});a.val(t);return!1})});
|