From 0d74014d4aa70ad20d93e1905c224e85956d11ec Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 7 Nov 2011 14:13:04 +0000 Subject: [PATCH] Added handles. Closes #137. --- admin/writepanels/writepanel-product_data.php | 3 +++ assets/css/admin.css | 5 +++-- assets/css/admin.less | 9 ++++++++- assets/images/handle.png | Bin 0 -> 224 bytes assets/js/admin/write-panels.js | 4 +++- assets/js/admin/write-panels.min.js | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 assets/images/handle.png diff --git a/admin/writepanels/writepanel-product_data.php b/admin/writepanels/writepanel-product_data.php index ad11efbb8e9..99986efb7c5 100644 --- a/admin/writepanels/writepanel-product_data.php +++ b/admin/writepanels/writepanel-product_data.php @@ -185,6 +185,7 @@ function woocommerce_product_data_box() { + @@ -221,6 +222,7 @@ function woocommerce_product_data_box() { $has_terms = (is_wp_error($post_terms) || !$post_terms || sizeof($post_terms)==0) ? 0 : 1; ?>> + + '); + $('table.woocommerce_attributes tbody').append(''); } else { @@ -335,11 +335,13 @@ jQuery( function($){ items:'tr', cursor:'move', axis:'y', + handle: '.handle', scrollSensitivity:40, helper:function(e,ui){ ui.children().each(function(){ $(this).width($(this).width()); }); + ui.css('left', '0'); return ui; }, start:function(event,ui){ diff --git a/assets/js/admin/write-panels.min.js b/assets/js/admin/write-panels.min.js index 35fdcf8f576..8c26993caa1 100644 --- a/assets/js/admin/write-panels.min.js +++ b/assets/js/admin/write-panels.min.js @@ -1 +1 @@ -jQuery(function(d){d("#upsell_product_data").bind("keypress",function(g){if(g.keyCode==13){return false}});d("ul.tabs").show();d("div.panel-wrap").each(function(){d("div.panel:not(div.panel:first)",this).hide()});d("ul.tabs a").click(function(){var g=d(this).closest("div.panel-wrap");d("ul.tabs li",g).removeClass("active");d(this).parent().addClass("active");d("div.panel",g).hide();d(d(this).attr("href")).show();return false});d("#order_items_list button.remove_row").live("click",function(){var g=confirm(woocommerce_writepanel_params.remove_item_notice);if(g){d(this).closest("tr.item").hide();d("input",d(this).closest("tr.item")).val("")}return false});d("button.calc_totals").live("click",function(){var p=confirm(woocommerce_writepanel_params.cart_total);if(p){var h=d("#order_items_list tr.item").size();var n=0;var o=d("input#_order_discount").val();var g=d("input#_order_shipping").val();var k=parseFloat(d("input#_order_shipping_tax").val());var l=0;var j=0;var m=0;if(!o){o=0}if(!g){g=0}if(!k){k=0}if(h>0){for(i=0;i0){taxRate=itemTax/100;itemTaxAmount=((itemCost*taxRate)*100);itemTaxAmount=itemTaxAmount.toFixed(2);totalItemTax=Math.round(itemTaxAmount)/100;totalItemTax=totalItemTax*itemQty}j=j+totalItemCost;l=l+totalItemTax}}n=j;m=parseFloat(n)+parseFloat(l)-parseFloat(o)+parseFloat(g)+parseFloat(k);if(m<0){m=0}d("input#_order_subtotal").val(n.toFixed(2));d("input#_order_tax").val(l.toFixed(2));d("input#_order_shipping_tax").val(k.toFixed(2));d("input#_order_total").val(m.toFixed(2))}return false});d("button.add_shop_order_item").click(function(){var j=d("select.add_item_id").val();if(j){d("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});var g=d("table.woocommerce_order_items tbody tr.item").size();var h={action:"woocommerce_add_order_item",item_to_add:d("select.add_item_id").val(),index:g,security:woocommerce_writepanel_params.add_order_item_nonce};d.post(woocommerce_writepanel_params.ajax_url,h,function(k){d("table.woocommerce_order_items tbody#order_items_list").append(k);d("table.woocommerce_order_items").unblock();d("select.add_item_id").css("border-color","").val("");d(".tips").easyTooltip()})}else{d("select.add_item_id").css("border-color","red")}});d("button.add_meta").live("click",function(){var g=d(this).closest("tr.item").attr("rel");d(this).closest("table.meta").find(".meta_items").append('');return false});d("button.remove_meta").live("click",function(){var g=confirm("Remove this meta key?");if(g){d(this).closest("tr").remove()}return false});d("button.billing-same-as-shipping").live("click",function(){var g=confirm(woocommerce_writepanel_params.copy_billing);if(g){d("input#shipping_first_name").val(d("input#billing_first_name").val());d("input#shipping_last_name").val(d("input#billing_last_name").val());d("input#shipping_company").val(d("input#billing_company").val());d("input#shipping_address_1").val(d("input#billing_address_1").val());d("input#shipping_address_2").val(d("input#billing_address_2").val());d("input#shipping_city").val(d("input#billing_city").val());d("input#shipping_postcode").val(d("input#billing_postcode").val());d("input#shipping_country").val(d("input#billing_country").val());d("input#shipping_state").val(d("input#billing_state").val())}return false});d("select#product-type").change(function(){var g=d(this).val();d(".show_if_simple, .show_if_variable, .show_if_grouped").hide();if(g=="simple"){d(".show_if_simple").show()}else{if(g=="variable"){d(".show_if_variable").show()}else{if(g=="grouped"){d(".show_if_grouped").show();d("input#downloadable").removeAttr("checked").change()}}}d("ul.tabs li:visible").eq(0).find("a").click();d("input#manage_stock").change();d("body").trigger("woocommerce-product-type-change",g,d(this))}).change();d("input#downloadable").change(function(){d(".show_if_downloadable").hide();if(d("input#downloadable").is(":checked")){d(".show_if_downloadable").show()}if(d(".downloads_tab").is(".active")){d("ul.tabs li:visible").eq(0).find("a").click()}}).change();d("input#virtual").change(function(){d(".show_if_virtual").hide();if(d("input#virtual").is(":checked")){d(".show_if_virtual").show()}}).change();d("input#manage_stock").change(function(){if(d(this).is(":checked")){d("div.stock_fields").show()}else{d("div.stock_fields").hide()}}).change();var e=d("#sale_price_dates_from, #sale_price_dates_to").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:true,showOn:"button",buttonImage:woocommerce_writepanel_params.calendar_image,buttonImageOnly:true,onSelect:function(j){var k=this.id=="sale_price_dates_from"?"minDate":"maxDate",g=d(this).data("datepicker"),h=d.datepicker.parseDate(g.settings.dateFormat||d.datepicker._defaults.dateFormat,j,g.settings);e.not(this).datepicker("option",k,h)}});d(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:true,showOn:"button",buttonImage:woocommerce_writepanel_params.calendar_image,buttonImageOnly:true});d("#attributes_list select.multiselect").multiselect({noneSelectedText:woocommerce_writepanel_params.select_terms,selectedList:4});var c=d("#attributes_list").children("tr").get();c.sort(function(h,g){var k=d(h).attr("rel");var j=d(g).attr("rel");return(kj)?1:0});d(c).each(function(g,h){d("#attributes_list").append(h)});function a(){d("table.woocommerce_attributes, table.woocommerce_variable_attributes").each(function(){if(d("tbody tr",this).size()==0){d(this).parent().hide()}else{d(this).parent().show()}})}a();function b(){d("#attributes_list tr").each(function(g,h){d(".attribute_position",h).val(parseInt(d(h).index("#attributes_list tr")))})}d("button.add_attribute").click(function(){var h=d("table.woocommerce_attributes tbody tr").size();var j=d("select.attribute_taxonomy").val();if(!j){var k=d("select#product-type").val();if(k!="variable"){enable_variation='style="display:none;"'}else{enable_variation=""}d("table.woocommerce_attributes tbody").append('')}else{var g=d("table.woocommerce_attributes tbody tr."+j);d("table.woocommerce_attributes tbody").append(d(g));d(g).show();b()}a()});d("button.hide_row").live("click",function(){var g=confirm("Remove this attribute?");if(g){d(this).parent().parent().find("select, input[type=text]").val("");d(this).parent().parent().hide();a()}return false});d("#attributes_list button.remove_row").live("click",function(){var g=confirm("Remove this attribute?");if(g){d(this).parent().parent().remove();a();b()}return false});d("table.woocommerce_attributes tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,helper:function(h,g){g.children().each(function(){d(this).width(d(this).width())});return g},start:function(g,h){h.item.css("background-color","#f6f6f6")},stop:function(g,h){h.item.removeAttr("style");b()}});d(".multi_select_products button").live("click",function(){var n=d(this).parent().parent().parent().parent();var g=d(this);var j=g.parent().parent();if(j.is(".multi_select_products_target_upsell")||j.is(".multi_select_products_target_crosssell")){g.parent().remove()}else{if(g.is(".add_upsell")){var l=d(".multi_select_products_target_upsell",d(n));var m="upsell_ids[]"}else{var l=d(".multi_select_products_target_crosssell",d(n));var m="crosssell_ids[]"}var h=d("li[rel="+g.parent().attr("rel")+"]",l);if(d(h).size()>0){return false}var k=g.parent().clone();k.find("button:eq(0)").html("×");k.find("button:eq(1)").remove();k.find("input").val(g.parent().attr("rel"));k.find(".product_id").attr("name",m);k.appendTo(l)}});var f;d(".multi_select_products #product_search").bind("keyup click",function(){d(".multi_select_products_source").addClass("loading");d(".multi_select_products_source li:not(.product_search)").remove();if(f){f.abort()}var j=d(this).val();var g=this;var h=d(this).attr("rel");if(j.length<3){d(".multi_select_products_source").removeClass("loading");return}var k={name:h,search:encodeURI(j),action:"woocommerce_upsell_crosssell_search_products",security:woocommerce_writepanel_params.upsell_crosssell_search_products_nonce};f=d.ajax({url:woocommerce_writepanel_params.ajax_url,data:k,type:"POST",success:function(l){d(".multi_select_products_source").removeClass("loading");d(".multi_select_products_source li:not(.product_search)").remove();d(g).parent().parent().append(l)}})})}); \ No newline at end of file +jQuery(function(d){d("#upsell_product_data").bind("keypress",function(g){if(g.keyCode==13){return false}});d("ul.tabs").show();d("div.panel-wrap").each(function(){d("div.panel:not(div.panel:first)",this).hide()});d("ul.tabs a").click(function(){var g=d(this).closest("div.panel-wrap");d("ul.tabs li",g).removeClass("active");d(this).parent().addClass("active");d("div.panel",g).hide();d(d(this).attr("href")).show();return false});d("#order_items_list button.remove_row").live("click",function(){var g=confirm(woocommerce_writepanel_params.remove_item_notice);if(g){d(this).closest("tr.item").hide();d("input",d(this).closest("tr.item")).val("")}return false});d("button.calc_totals").live("click",function(){var p=confirm(woocommerce_writepanel_params.cart_total);if(p){var h=d("#order_items_list tr.item").size();var n=0;var o=d("input#_order_discount").val();var g=d("input#_order_shipping").val();var k=parseFloat(d("input#_order_shipping_tax").val());var l=0;var j=0;var m=0;if(!o){o=0}if(!g){g=0}if(!k){k=0}if(h>0){for(i=0;i0){taxRate=itemTax/100;itemTaxAmount=((itemCost*taxRate)*100);itemTaxAmount=itemTaxAmount.toFixed(2);totalItemTax=Math.round(itemTaxAmount)/100;totalItemTax=totalItemTax*itemQty}j=j+totalItemCost;l=l+totalItemTax}}n=j;m=parseFloat(n)+parseFloat(l)-parseFloat(o)+parseFloat(g)+parseFloat(k);if(m<0){m=0}d("input#_order_subtotal").val(n.toFixed(2));d("input#_order_tax").val(l.toFixed(2));d("input#_order_shipping_tax").val(k.toFixed(2));d("input#_order_total").val(m.toFixed(2))}return false});d("button.add_shop_order_item").click(function(){var j=d("select.add_item_id").val();if(j){d("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:0.6}});var g=d("table.woocommerce_order_items tbody tr.item").size();var h={action:"woocommerce_add_order_item",item_to_add:d("select.add_item_id").val(),index:g,security:woocommerce_writepanel_params.add_order_item_nonce};d.post(woocommerce_writepanel_params.ajax_url,h,function(k){d("table.woocommerce_order_items tbody#order_items_list").append(k);d("table.woocommerce_order_items").unblock();d("select.add_item_id").css("border-color","").val("");d(".tips").easyTooltip()})}else{d("select.add_item_id").css("border-color","red")}});d("button.add_meta").live("click",function(){var g=d(this).closest("tr.item").attr("rel");d(this).closest("table.meta").find(".meta_items").append('');return false});d("button.remove_meta").live("click",function(){var g=confirm("Remove this meta key?");if(g){d(this).closest("tr").remove()}return false});d("button.billing-same-as-shipping").live("click",function(){var g=confirm(woocommerce_writepanel_params.copy_billing);if(g){d("input#shipping_first_name").val(d("input#billing_first_name").val());d("input#shipping_last_name").val(d("input#billing_last_name").val());d("input#shipping_company").val(d("input#billing_company").val());d("input#shipping_address_1").val(d("input#billing_address_1").val());d("input#shipping_address_2").val(d("input#billing_address_2").val());d("input#shipping_city").val(d("input#billing_city").val());d("input#shipping_postcode").val(d("input#billing_postcode").val());d("input#shipping_country").val(d("input#billing_country").val());d("input#shipping_state").val(d("input#billing_state").val())}return false});d("select#product-type").change(function(){var g=d(this).val();d(".show_if_simple, .show_if_variable, .show_if_grouped").hide();if(g=="simple"){d(".show_if_simple").show()}else{if(g=="variable"){d(".show_if_variable").show()}else{if(g=="grouped"){d(".show_if_grouped").show();d("input#downloadable").removeAttr("checked").change()}}}d("ul.tabs li:visible").eq(0).find("a").click();d("input#manage_stock").change();d("body").trigger("woocommerce-product-type-change",g,d(this))}).change();d("input#downloadable").change(function(){d(".show_if_downloadable").hide();if(d("input#downloadable").is(":checked")){d(".show_if_downloadable").show()}if(d(".downloads_tab").is(".active")){d("ul.tabs li:visible").eq(0).find("a").click()}}).change();d("input#virtual").change(function(){d(".show_if_virtual").hide();if(d("input#virtual").is(":checked")){d(".show_if_virtual").show()}}).change();d("input#manage_stock").change(function(){if(d(this).is(":checked")){d("div.stock_fields").show()}else{d("div.stock_fields").hide()}}).change();var e=d("#sale_price_dates_from, #sale_price_dates_to").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:true,showOn:"button",buttonImage:woocommerce_writepanel_params.calendar_image,buttonImageOnly:true,onSelect:function(j){var k=this.id=="sale_price_dates_from"?"minDate":"maxDate",g=d(this).data("datepicker"),h=d.datepicker.parseDate(g.settings.dateFormat||d.datepicker._defaults.dateFormat,j,g.settings);e.not(this).datepicker("option",k,h)}});d(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:true,showOn:"button",buttonImage:woocommerce_writepanel_params.calendar_image,buttonImageOnly:true});d("#attributes_list select.multiselect").multiselect({noneSelectedText:woocommerce_writepanel_params.select_terms,selectedList:4});var c=d("#attributes_list").children("tr").get();c.sort(function(h,g){var k=d(h).attr("rel");var j=d(g).attr("rel");return(kj)?1:0});d(c).each(function(g,h){d("#attributes_list").append(h)});function a(){d("table.woocommerce_attributes, table.woocommerce_variable_attributes").each(function(){if(d("tbody tr",this).size()==0){d(this).parent().hide()}else{d(this).parent().show()}})}a();function b(){d("#attributes_list tr").each(function(g,h){d(".attribute_position",h).val(parseInt(d(h).index("#attributes_list tr")))})}d("button.add_attribute").click(function(){var h=d("table.woocommerce_attributes tbody tr").size();var j=d("select.attribute_taxonomy").val();if(!j){var k=d("select#product-type").val();if(k!="variable"){enable_variation='style="display:none;"'}else{enable_variation=""}d("table.woocommerce_attributes tbody").append('')}else{var g=d("table.woocommerce_attributes tbody tr."+j);d("table.woocommerce_attributes tbody").append(d(g));d(g).show();b()}a()});d("button.hide_row").live("click",function(){var g=confirm("Remove this attribute?");if(g){d(this).parent().parent().find("select, input[type=text]").val("");d(this).parent().parent().hide();a()}return false});d("#attributes_list button.remove_row").live("click",function(){var g=confirm("Remove this attribute?");if(g){d(this).parent().parent().remove();a();b()}return false});d("table.woocommerce_attributes tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:".handle",scrollSensitivity:40,helper:function(h,g){g.children().each(function(){d(this).width(d(this).width())});g.css("left","0");return g},start:function(g,h){h.item.css("background-color","#f6f6f6")},stop:function(g,h){h.item.removeAttr("style");b()}});d(".multi_select_products button").live("click",function(){var n=d(this).parent().parent().parent().parent();var g=d(this);var j=g.parent().parent();if(j.is(".multi_select_products_target_upsell")||j.is(".multi_select_products_target_crosssell")){g.parent().remove()}else{if(g.is(".add_upsell")){var l=d(".multi_select_products_target_upsell",d(n));var m="upsell_ids[]"}else{var l=d(".multi_select_products_target_crosssell",d(n));var m="crosssell_ids[]"}var h=d("li[rel="+g.parent().attr("rel")+"]",l);if(d(h).size()>0){return false}var k=g.parent().clone();k.find("button:eq(0)").html("×");k.find("button:eq(1)").remove();k.find("input").val(g.parent().attr("rel"));k.find(".product_id").attr("name",m);k.appendTo(l)}});var f;d(".multi_select_products #product_search").bind("keyup click",function(){d(".multi_select_products_source").addClass("loading");d(".multi_select_products_source li:not(.product_search)").remove();if(f){f.abort()}var j=d(this).val();var g=this;var h=d(this).attr("rel");if(j.length<3){d(".multi_select_products_source").removeClass("loading");return}var k={name:h,search:encodeURI(j),action:"woocommerce_upsell_crosssell_search_products",security:woocommerce_writepanel_params.upsell_crosssell_search_products_nonce};f=d.ajax({url:woocommerce_writepanel_params.ajax_url,data:k,type:"POST",success:function(l){d(".multi_select_products_source").removeClass("loading");d(".multi_select_products_source li:not(.product_search)").remove();d(g).parent().parent().append(l)}})})}); \ No newline at end of file
   [?]  [?]
attribute_label) ? $tax->attribute_label : $tax->attribute_name; ?> @@ -271,6 +273,7 @@ function woocommerce_product_data_box() { $position = (isset($attribute['position'])) ? $attribute['position'] : 0; ?>
diff --git a/assets/css/admin.css b/assets/css/admin.css index 679338b6015..3a44154d5c8 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -131,11 +131,12 @@ div.taxrows .taxrow label.checkbox{line-height:1.5em;margin:0 8px;}div.taxrows . .woocommerce_options_panel .short{width:20%;} .woocommerce_options_panel .sized{width:auto !important;margin-right:6px;} .woocommerce_options_panel .options_group{border-top:1px solid white;border-bottom:1px solid #DFDFDF;} +#woocommerce_attributes td.handle{vertical-align:middle;width:14px;background:url(../images/handle.png) no-repeat right center;cursor:move;padding-right:0;} #woocommerce_attributes,#variable_product_options{padding:12px;} .woocommerce_attributes_wrapper,.woocommerce_variable_attributes_wrapper{margin-bottom:7px;border:1px solid #ececec;} -table.woocommerce_attributes,table.woocommerce_variable_attributes{width:100%;} +table.woocommerce_attributes,table.woocommerce_variable_attributes{width:100%;position:relative;} table.woocommerce_attributes thead th,table.woocommerce_variable_attributes thead th{background:#ececec;padding:7px 9px;font-size:11px;text-align:left;} -table.woocommerce_attributes td,table.woocommerce_variable_attributes td{padding:2px 9px;text-align:left;vertical-align:middle;border-bottom:1px dotted #ececec;cursor:move;} +table.woocommerce_attributes td,table.woocommerce_variable_attributes td{padding:2px 9px;text-align:left;vertical-align:middle;border-bottom:1px dotted #ececec;} table.woocommerce_attributes td input,table.woocommerce_variable_attributes td input,table.woocommerce_variable_attributes td textarea{width:100%;} table.woocommerce_attributes td select{width:100%;} table.woocommerce_attributes td select.multiselect{height:8em !important;} diff --git a/assets/css/admin.less b/assets/css/admin.less index 66e2f888af9..b1c77251f4c 100644 --- a/assets/css/admin.less +++ b/assets/css/admin.less @@ -745,6 +745,13 @@ div.taxrows { border-bottom: 1px solid #DFDFDF; } +#woocommerce_attributes td.handle { + vertical-align: middle; + width: 14px; + background: url(../images/handle.png) no-repeat right center; + cursor: move; + padding-right: 0; +} #woocommerce_attributes, #variable_product_options { padding: 12px; } @@ -754,6 +761,7 @@ div.taxrows { } table.woocommerce_attributes, table.woocommerce_variable_attributes { width: 100%; + position: relative; } table.woocommerce_attributes thead th, table.woocommerce_variable_attributes thead th { background: #ececec; @@ -766,7 +774,6 @@ table.woocommerce_attributes td, table.woocommerce_variable_attributes td { text-align: left; vertical-align: middle; border-bottom: 1px dotted #ececec; - cursor: move; } table.woocommerce_attributes td input, table.woocommerce_variable_attributes td input, table.woocommerce_variable_attributes td textarea { width: 100%; diff --git a/assets/images/handle.png b/assets/images/handle.png new file mode 100644 index 0000000000000000000000000000000000000000..5a7adbf02215d51d67e2541abdd41087067a3997 GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp@K+MO)3?w@R>l}d;bFq_W2nPqp?T7vkfLzW1pAgso z|NmdTdiBhiGmN57_JP!t1o;Is{QvI~a7_`Urobbzn1O*?2!t6g-L3lr6qG4(jVKAu zPb(=;EJ|f?Ovz75RdCBJN-fVX$}U!L4mK^^`q&JpP86ihxhOTUBr`uxAtW<5mBC!! z&=82sIf9P?6^MDdIEHY{Oio~63=It};?ULA-B8BHu(O2KB_rYcf1nBmPgg&ebxsLQ E08kJ?Q~&?~ literal 0 HcmV?d00001 diff --git a/assets/js/admin/write-panels.js b/assets/js/admin/write-panels.js index 269ad037756..27499cdba8d 100644 --- a/assets/js/admin/write-panels.js +++ b/assets/js/admin/write-panels.js @@ -295,7 +295,7 @@ jQuery( function($){ if (product_type!='variable') enable_variation = 'style="display:none;"'; else enable_variation = ''; // Add custom attribute row - $('table.woocommerce_attributes tbody').append('