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

1 line
9.4 KiB
JavaScript

jQuery(function(d){jQuery("ul.tabs").show();jQuery("div.panel-wrap").each(function(){jQuery("div.panel:not(div.panel:first)",this).hide()});jQuery("ul.tabs a").click(function(){var e=jQuery(this).closest("div.panel-wrap");jQuery("ul.tabs li",e).removeClass("active");jQuery(this).parent().addClass("active");jQuery("div.panel",e).hide();jQuery(jQuery(this).attr("href")).show();return false});jQuery("#order_items_list button.remove_row").live("click",function(){var e=confirm(params.remove_item_notice);if(e){jQuery(this).closest("tr.item").hide();jQuery("input",jQuery(this).closest("tr.item")).val("")}return false});jQuery("button.calc_totals").live("click",function(){var n=confirm(params.cart_total);if(n){var f=jQuery("#order_items_list tr.item").size();var l=0;var m=jQuery("input#order_discount").val();var e=jQuery("input#order_shipping").val();var h=parseFloat(jQuery("input#order_shipping_tax").val());var j=0;var g=0;var k=0;if(!m){m=0}if(!e){e=0}if(!h){h=0}if(f>0){for(i=0;i<f;i++){itemCost=jQuery("input[name^=item_cost]:eq("+i+")").val();itemQty=parseInt(jQuery("input[name^=item_quantity]:eq("+i+")").val());itemTax=jQuery("input[name^=item_tax_rate]:eq("+i+")").val();if(!itemCost){itemCost=0}if(!itemTax){itemTax=0}totalItemTax=0;totalItemCost=itemCost*itemQty;if(itemTax&&itemTax>0){taxRate=itemTax/100;itemTaxAmount=((itemCost*taxRate)*100);itemTaxAmount=itemTaxAmount.toFixed(2);totalItemTax=Math.round(itemTaxAmount)/100;totalItemTax=totalItemTax*itemQty}g=g+totalItemCost;j=j+totalItemTax}}l=g;k=parseFloat(l)+parseFloat(j)-parseFloat(m)+parseFloat(e)+parseFloat(h);if(k<0){k=0}jQuery("input#order_subtotal").val(l.toFixed(2));jQuery("input#order_tax").val(j.toFixed(2));jQuery("input#order_shipping_tax").val(h.toFixed(2));jQuery("input#order_total").val(k.toFixed(2))}return false});jQuery("button.add_shop_order_item").click(function(){var g=jQuery("select.add_item_id").val();if(g){jQuery("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});var e=jQuery("table.woocommerce_order_items tbody tr.item").size();var f={action:"woocommerce_add_order_item",item_to_add:jQuery("select.add_item_id").val(),index:e,security:params.add_order_item_nonce};jQuery.post(params.ajax_url,f,function(h){jQuery("table.woocommerce_order_items tbody#order_items_list").append(h);jQuery("table.woocommerce_order_items").unblock();jQuery("select.add_item_id").css("border-color","").val("");jQuery(".tips").easyTooltip()})}else{jQuery("select.add_item_id").css("border-color","red")}});jQuery("button.add_meta").live("click",function(){var e=jQuery(this).closest("tr.item").attr("rel");jQuery(this).closest("table.meta").find(".meta_items").append('<tr><td><input type="text" name="meta_name['+e+'][]" placeholder="'+params.meta_name+'" /></td><td><input type="text" name="meta_value['+e+'][]" placeholder="'+params.meta_value+'" /></td><td><button class="remove_meta button">&times;</button></td></tr>');return false});jQuery("button.remove_meta").live("click",function(){var e=confirm("Remove this meta key?");if(e){jQuery(this).closest("tr").remove()}return false});jQuery("button.billing-same-as-shipping").live("click",function(){var e=confirm(params.copy_billing);if(e){jQuery("input#shipping_first_name").val(jQuery("input#billing_first_name").val());jQuery("input#shipping_last_name").val(jQuery("input#billing_last_name").val());jQuery("input#shipping_company").val(jQuery("input#billing_company").val());jQuery("input#shipping_address_1").val(jQuery("input#billing_address_1").val());jQuery("input#shipping_address_2").val(jQuery("input#billing_address_2").val());jQuery("input#shipping_city").val(jQuery("input#billing_city").val());jQuery("input#shipping_postcode").val(jQuery("input#billing_postcode").val());jQuery("input#shipping_country").val(jQuery("input#billing_country").val());jQuery("input#shipping_state").val(jQuery("input#billing_state").val())}return false});d("select#product-type").change(function(){var e=jQuery(this).val();d("#woocommerce-product-type-options .inside > div").hide();d("#"+e+"_product_options").show();if(e=="variable"){jQuery(".stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing").show();jQuery(".options_group.grouping").val("").hide();jQuery("td.enable_variation, th.enable_variation").show()}else{if(e=="simple"){jQuery(".stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing").show();jQuery(".options_group.grouping").show();jQuery("td.enable_variation, th.enable_variation").hide()}else{if(e=="grouped"){jQuery(".stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing").hide();jQuery(".options_group.grouping").val("").hide();jQuery("td.enable_variation, th.enable_variation").hide()}else{if(e=="downloadable"){jQuery(".stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing").show();jQuery(".options_group.grouping").show();jQuery("td.enable_variation, th.enable_variation").hide()}else{if(e=="virtual"){jQuery(".stock_fields, .manage_stock_field, .tax_tab, .options_group.pricing").show();jQuery(".options_group.grouping").show();jQuery("td.enable_variation, th.enable_variation").hide()}}}}}d("body").trigger("woocommerce-product-type-change",e,d(this))}).change();jQuery("input#manage_stock").change(function(){if(jQuery(this).is(":checked")){jQuery("div.stock_fields").show()}else{jQuery("div.stock_fields").hide()}}).change();Date.firstDayOfWeek=1;Date.format="yyyy-mm-dd";jQuery(".date-pick").datePicker();jQuery("#sale_price_dates_from").bind("dpClosed",function(g,f){var h=f[0];if(h){h=new Date(h);jQuery("#sale_price_dates_to").dpSetStartDate(h.addDays(1).asString())}});jQuery("#sale_price_dates_to").bind("dpClosed",function(g,f){var h=f[0];if(h){h=new Date(h);jQuery("#sale_price_dates_from").dpSetEndDate(h.addDays(-1).asString())}});jQuery("#attributes_list select.multiselect").multiselect({noneSelectedText:params.select_terms,selectedList:4});var c=jQuery("#attributes_list").children("tr").get();c.sort(function(f,e){var h=jQuery(f).attr("rel");var g=jQuery(e).attr("rel");return(h<g)?-1:(h>g)?1:0});jQuery(c).each(function(e,f){jQuery("#attributes_list").append(f)});function a(){jQuery("table.woocommerce_attributes, table.woocommerce_variable_attributes").each(function(){if(jQuery("tbody tr",this).size()==0){jQuery(this).parent().hide()}else{jQuery(this).parent().show()}})}a();function b(){jQuery("#attributes_list tr").each(function(e,f){jQuery(".attribute_position",f).val(parseInt(jQuery(f).index("#attributes_list tr")))})}jQuery("button.add_attribute").click(function(){var f=jQuery("table.woocommerce_attributes tbody tr").size();var g=jQuery("select.attribute_taxonomy").val();if(!g){var h=jQuery("select#product-type").val();if(h!="variable"){enable_variation='style="display:none;"'}else{enable_variation=""}jQuery("table.woocommerce_attributes tbody").append('<tr><td class="center"><button type="button" class="button move_up">&uarr;</button><button type="button" class="move_down button">&darr;</button><input type="hidden" name="attribute_position['+f+']" class="attribute_position" value="'+f+'" /></td><td><input type="text" name="attribute_names['+f+']" /><input type="hidden" name="attribute_is_taxonomy['+f+']" value="0" /></td><td><input type="text" name="attribute_values['+f+']" /></td><td class="center"><input type="checkbox" checked="checked" name="attribute_visibility['+f+']" value="1" /></td><td class="center enable_variation" '+enable_variation+'><input type="checkbox" name="attribute_variation['+f+']" value="1" /></td><td class="center"><button type="button" class="remove_row button">&times;</button></td></tr>')}else{var e=jQuery("table.woocommerce_attributes tbody tr."+g);jQuery("table.woocommerce_attributes tbody").append(jQuery(e));jQuery(e).show();b()}a()});jQuery("button.hide_row").live("click",function(){var e=confirm("Remove this attribute?");if(e){jQuery(this).parent().parent().find("select, input[type=text]").val("");jQuery(this).parent().parent().hide();a()}return false});jQuery("#attributes_list button.remove_row").live("click",function(){var e=confirm("Remove this attribute?");if(e){jQuery(this).parent().parent().remove();a();b()}return false});jQuery("button.move_up").live("click",function(){var f=jQuery(this).parent().parent();var e=jQuery(f).prev("tr");jQuery(f).after(e);b()});jQuery("button.move_down").live("click",function(){var f=jQuery(this).parent().parent();var e=jQuery(f).next("tr");jQuery(f).before(e);b()});jQuery(".multi_select_products button").live("click",function(){var g=jQuery(this).parent().parent().parent().parent();if(jQuery(this).parent().parent().is(".multi_select_products_target")){jQuery(this).parent().remove()}else{var f=jQuery(".multi_select_products_target",jQuery(g));var e=jQuery("li[rel="+jQuery(this).parent().attr("rel")+"]",f);if(jQuery(e).size()>0){return false}jQuery(this).parent().clone().appendTo(f).find("button").html("X").parent().find("input").val(jQuery(this).parent().attr("rel"))}});jQuery(".multi_select_products #product_search").bind("keyup click",function(){jQuery(".multi_select_products_source li:not(.product_search)").remove();var g=encodeURI(jQuery(this).val());var e=this;var f=jQuery(this).attr("rel");if(g.length<3){return}var h={name:f,search:g,action:"woocommerce_upsell_crosssell_search_products",security:params.upsell_crosssell_search_products_nonce};jQuery.post(params.ajax_url,h,function(j){jQuery(".multi_select_products_source li:not(.product_search)").remove();jQuery(e).parent().parent().append(j)})})});