woocommerce/assets/js/admin/write-panels.min.js

2 lines
33 KiB
JavaScript
Raw Normal View History

2013-04-16 12:49:49 +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_writepanel_params.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(".woocommerce_attributes .woocommerce_attribute").each(function(t,n){e(".attribute_position",n).val(parseInt(e(n).index(".woocommerce_attributes .woocommerce_attribute")))})}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(":checkbox").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("#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_writepanel_params.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_writepanel_params.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_select").chosen();jQuery("select.chosen_select_nostd").chosen({allow_single_deselect:"true"});jQuery("select.ajax_chosen_select_products").ajaxChosen({method:"GET",url:woocommerce_writepanel_params.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products",security:woocommerce_writepanel_params.search_products_nonce}},function(t){var n={};e.each(t,function(e,t){n[e]=t});return n});jQuery("select.ajax_chosen_select_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_writ
.abs(e||0),c),10)+"",g=3<m.length?m.length%3:0;return h+(g?m.substr(0,g)+l.thousand:"")+m.substr(g).replace(/(\d{3})(?=\d)/g,"$1"+l.thousand)+(c?l.decimal+d(Math.abs(e),c).split(".")[1]:"")},m=f.formatMoney=function(e,t,n,l,c,h){if(r(e))return o(e,function(e){return m(e,t,n,l,c,h)});var e=p(e),d=s(i(t)?t:{symbol:t,precision:n,thousand:l,decimal:c,format:h},f.settings.currency),g=a(d.format);return(0<e?g.pos:0>e?g.neg:g.zero).replace("%s",d.symbol).replace("%v",v(Math.abs(e),u(d.precision),d.thousand,d.decimal))};f.formatColumn=function(e,t,l,c,h,d){if(!e)return[];var m=s(i(t)?t:{symbol:t,precision:l,thousand:c,decimal:h,format:d},f.settings.currency),g=a(m.format),y=g.pos.indexOf("%s")<g.pos.indexOf("%v")?!0:!1,b=0,e=o(e,function(e){if(r(e))return f.formatColumn(e,m);e=p(e);e=(0<e?g.pos:0>e?g.neg:g.zero).replace("%s",m.symbol).replace("%v",v(Math.abs(e),u(m.precision),m.thousand,m.decimal));e.length>b&&(b=e.length);return e});return o(e,function(e){return n(e)&&e.length<b?y?e.replace(m.symbol,m.symbol+Array(b-e.length+1).join(" ")):Array(b-e.length+1).join(" ")+e:e})};if("undefined"!=typeof exports){"undefined"!=typeof module&&module.exports&&(exports=module.exports=f);exports.accounting=f}else"function"==typeof define&&define.amd?define([],function(){return f}):(f.noConflict=function(n){return function(){e.accounting=n;f.noConflict=t;return f}}(e.accounting),e.accounting=f)})(this);