variations panel cleanup

This commit is contained in:
Mike Jolley 2012-02-13 15:08:54 +00:00
parent 57f5dc3296
commit 81c0a0eeaa
3 changed files with 91 additions and 49 deletions

View File

@ -47,7 +47,9 @@ function variable_product_type_options() {
<div class="inline updated"><p><?php _e('Before you can start adding variations you must set up and save some variable attributes via the <strong>Attributes</strong> tab.', 'woocommerce'); ?></p></div>
<?php else : ?>
<p class="bulk_edit"><strong><?php _e('Bulk edit:', 'woocommerce'); ?></strong> <a class="button set set_all_prices" href="#"><?php _e('Prices', 'woocommerce'); ?></a> <a class="button set set_all_sale_prices" href="#"><?php _e('Sale prices', 'woocommerce'); ?></a> <a class="button set set_all_stock" href="#"><?php _e('Stock', 'woocommerce'); ?></a> <a class="button toggle toggle_downloadable" href="#"><?php _e('Downloadable', 'woocommerce'); ?></a> <a class="button toggle toggle_virtual" href="#"><?php _e('Virtual', 'woocommerce'); ?></a> <a class="button toggle toggle_enabled" href="#"><?php _e('Enabled', 'woocommerce'); ?></a> <a class="button set set_all_paths" href="#"><?php _e('File paths', 'woocommerce'); ?></a> <a class="button set set_all_limits" href="#"><?php _e('Download limits', 'woocommerce'); ?></a></p>
<p class="toolbar">
<strong><?php _e('Bulk edit:', 'woocommerce'); ?></strong> <a class="button set set_all_prices" href="#"><?php _e('Prices', 'woocommerce'); ?></a> <a class="button set set_all_sale_prices" href="#"><?php _e('Sale prices', 'woocommerce'); ?></a> <a class="button set set_all_stock" href="#"><?php _e('Stock', 'woocommerce'); ?></a> <a class="button toggle toggle_downloadable" href="#"><?php _e('Downloadable', 'woocommerce'); ?></a> <a class="button toggle toggle_virtual" href="#"><?php _e('Virtual', 'woocommerce'); ?></a> <a class="button toggle toggle_enabled" href="#"><?php _e('Enabled', 'woocommerce'); ?></a> <a class="button set set_all_paths" href="#"><?php _e('File paths', 'woocommerce'); ?></a> <a class="button set set_all_limits" href="#"><?php _e('Download limits', 'woocommerce'); ?></a> <a href="#" class="button delete_variations"><?php _e('Delete all variations', 'woocommerce'); ?></a>
</p>
<div class="woocommerce_variations">
<?php
@ -77,10 +79,11 @@ function variable_product_type_options() {
$classes = get_the_terms( $variation->ID, 'product_shipping_class' );
if ($classes && !is_wp_error($classes)) $current_shipping_class = current($classes)->term_id; else $current_shipping_class = '';
?>
<div class="woocommerce_variation">
<p>
<div class="woocommerce_variation closed">
<h3>
<button type="button" class="remove_variation button" rel="<?php echo $variation->ID; ?>"><?php _e('Remove', 'woocommerce'); ?></button>
<strong>#<?php echo $variation->ID; ?> &mdash; <?php _e('Variation:', 'woocommerce'); ?></strong>
<div class="handlediv" title="<?php _e('Click to toggle'); ?>"></div>
<strong>#<?php echo $variation->ID; ?> &mdash; </strong>
<?php
foreach ($attributes as $attribute) :
@ -111,7 +114,7 @@ function variable_product_type_options() {
endforeach;
?>
<input type="hidden" name="variable_post_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $variation->ID ); ?>" />
</p>
</h3>
<table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes">
<tbody>
<tr>
@ -174,8 +177,13 @@ function variable_product_type_options() {
<?php $loop++; endforeach; ?>
</div>
<p class="default_variation">
<strong><?php _e('Default variation selections:', 'woocommerce'); ?></strong>
<p class="toolbar">
<button type="button" class="button button-primary add_variation" <?php disabled($variation_attribute_found, false); ?>><?php _e('Add Variation', 'woocommerce'); ?></button>
<button type="button" class="button link_all_variations" <?php disabled($variation_attribute_found, false); ?>><?php _e('Link all variations', 'woocommerce'); ?></button>
<strong><?php _e('Default selections:', 'woocommerce'); ?></strong>
<?php
$default_attributes = (array) maybe_unserialize(get_post_meta( $post->ID, '_default_attributes', true ));
foreach ($attributes as $attribute) :
@ -207,14 +215,7 @@ function variable_product_type_options() {
endforeach;
?>
</p>
<button type="button" class="button button-primary add_variation" <?php disabled($variation_attribute_found, false); ?>><?php _e('Add Variation', 'woocommerce'); ?></button>
<button type="button" class="button link_all_variations" <?php disabled($variation_attribute_found, false); ?>><?php _e('Link all variations', 'woocommerce'); ?></button>
<a href="#" class="delete delete_variations"><?php _e('Delete all variations', 'woocommerce'); ?></a>
<p class="description"><?php _e('Add (optional) information for product variations. If you modify your product attributes you must save the product before they will be selectable.', 'woocommerce'); ?></p>
<?php endif; ?>
<div class="clear"></div>
@ -229,7 +230,7 @@ function variable_product_type_options() {
<?php if (!$attributes || (is_array($attributes) && sizeof($attributes)==0)) : ?>
jQuery('button.link_all_variations, button.add_variation').live('click', function(){
jQuery('#variable_product_options').on('click', 'button.link_all_variations, button.add_variation', function(){
alert('<?php _e('You must add some attributes via the "Product Data" panel and save before adding a new variation.', 'woocommerce'); ?>');
@ -239,7 +240,17 @@ function variable_product_type_options() {
<?php else : ?>
jQuery('button.add_variation').live('click', function(){
// Open/close
jQuery('#variable_product_options').on('click', '.woocommerce_variation h3', function(){
jQuery(this).next('table.woocommerce_variable_attributes').toggle();
});
jQuery('.woocommerce_variation.closed').each(function(){
jQuery(this).find('table.woocommerce_variable_attributes').hide();
});
// Add a variation
jQuery('#variable_product_options').on('click', 'button.add_variation', function(){
jQuery('.woocommerce_variations').block({ message: null, overlayCSS: { background: '#fff url(<?php echo $woocommerce->plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
@ -256,9 +267,10 @@ function variable_product_type_options() {
var loop = jQuery('.woocommerce_variation').size();
jQuery('.woocommerce_variations').append('<div class="woocommerce_variation">\
<p>\
<h3 class="handle">\
<button type="button" class="remove_variation button" rel="' + variation_id + '"><?php _e('Remove', 'woocommerce'); ?></button>\
<strong>#' + variation_id + ' &mdash; <?php _e('Variation:', 'woocommerce'); ?></strong>\
<div class="handlediv" title="<?php _e('Click to toggle'); ?>"></div>\
<strong>#' + variation_id + ' &mdash; </strong>\
<?php
if ($attributes) foreach ($attributes as $attribute) :
@ -282,7 +294,7 @@ function variable_product_type_options() {
echo '</select>';
endforeach;
?><input type="hidden" name="variable_post_id[' + loop + ']" value="' + variation_id + '" /></p>\
?><input type="hidden" name="variable_post_id[' + loop + ']" value="' + variation_id + '" /></h3>\
<table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes">\
<tbody>\
<tr>\
@ -348,7 +360,7 @@ function variable_product_type_options() {
});
jQuery('button.link_all_variations').live('click', function(){
jQuery('#variable_product_options').on('click', 'button.link_all_variations', function(){
var answer = confirm('<?php _e('Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max 50 per run).', 'woocommerce'); ?>');
@ -385,7 +397,8 @@ function variable_product_type_options() {
return false;
});
jQuery('button.remove_variation').live('click', function(){
jQuery('#variable_product_options').on('click', 'button.remove_variation', function(e){
e.preventDefault();
var answer = confirm('<?php _e('Are you sure you want to remove this variation?', 'woocommerce'); ?>');
if (answer){
@ -420,7 +433,7 @@ function variable_product_type_options() {
return false;
});
jQuery('a.delete_variations').live('click', function(){
jQuery('#variable_product_options').on('click', 'a.delete_variations', function(){
var answer = confirm('<?php _e('Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce'); ?>');
if (answer){
@ -507,7 +520,7 @@ function variable_product_type_options() {
return false;
});
jQuery('input.variable_is_downloadable').live('change', function(){
jQuery('#variable_product_options').on('change', 'input.variable_is_downloadable', function(){
jQuery(this).parent().parent().find('.show_if_variation_downloadable').hide();
@ -515,7 +528,9 @@ function variable_product_type_options() {
jQuery(this).parent().parent().find('.show_if_variation_downloadable').show();
}
}).change();
});
jQuery('input.variable_is_downloadable').change();
<?php endif; ?>
@ -523,7 +538,7 @@ function variable_product_type_options() {
window.send_to_editor_default = window.send_to_editor;
jQuery('.upload_image_button').live('click', function(){
jQuery('#variable_product_options').on('click', '.upload_image_button', function(){
var post_id = jQuery(this).attr('rel');
var parent = jQuery(this).parent();

View File

@ -191,7 +191,7 @@ table.wc_gateways .radio,table.wc_shipping .radio{text-align:center;}
.woocommerce_options_panel .options_group{border-top:1px solid white;border-bottom:1px solid #DFDFDF;}
.woocommerce_options_panel .options_group:first-child{border-top:0;}
table 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{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%;position:relative;}
table.woocommerce_attributes thead th,table.woocommerce_variable_attributes thead th{background:#ececec;padding:7px 9px;font-size:11px;text-align:left;}
@ -203,7 +203,6 @@ table.woocommerce_attributes .taxonomy td.name{padding:10px 15px;font-size:14px;
table.woocommerce_attributes .taxonomy td.values{position:relative;}table.woocommerce_attributes .taxonomy td.values .chzn-container{width:100% !important;margin:0 1px;display:block;}table.woocommerce_attributes .taxonomy td.values .chzn-container .chzn-drop{width:100% !important;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}
table.woocommerce_attributes .center{text-align:center;}
#woocommerce_attributes select.attribute_taxonomy,button.add_attribute,button.add_variable_attribute,button.add_variation,button.link_all_variations{float:right;}
a.delete_variations{float:right;line-height:23px;margin-right:3px;color:#999;}a.delete_variations:hover{color:red;}
#upsells_and_crosssells_product_data{padding:0 9px 9px;}
div.multi_select_products_wrapper{float:left;width:49%;padding:0;}
div.multi_select_products_wrapper-alt{float:right;}
@ -216,11 +215,18 @@ div.multi_select_products_wrapper-alt{float:right;}
#woocommerce-product-data input.dp-applied{float:left;}
#grouped_product_options,#virtual_product_options,#simple_product_options{padding:12px;font-style:italic;color:#666;}
#variable_product_options p.description{float:left;padding:0;margin:0;line-height:23px;}
#variable_product_options p.bulk_edit,#variable_product_options p.default_variation{background:#ececec;padding:6px !important;margin:0 0 8px !important;overflow:hidden;zoom:1;}#variable_product_options p.bulk_edit strong,#variable_product_options p.default_variation strong{margin:0 6px 0 0;float:left;line-height:23px;}
#variable_product_options p.bulk_edit .button,#variable_product_options p.default_variation .button,#variable_product_options p.bulk_edit select,#variable_product_options p.default_variation select{margin:0 6px 0 0;float:left;}
#variable_product_options p.bulk_edit a.set,#variable_product_options p.default_variation a.set{padding-left:20px;background:#fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat 7px 5px;}
#variable_product_options p.bulk_edit a.toggle,#variable_product_options p.default_variation a.toggle{padding-left:20px;background:#fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAWUlEQVQYGY3QAQrAIAgFUB07mrfWu7kc+2JRsiA0fJnE7k5m5tQsEWFS1WGduh3mahpNLx3hOs4WAr2zfU8mRBGxorAJ4wAU+boS1g41x4UbScQdQJ3/fvgDtStDiI0qoDcAAAAASUVORK5CYII=) no-repeat 7px 5px;}
.woocommerce_variation{background:#ececec;border:1px solid #ececec;margin:0 0 8px !important;}.woocommerce_variation p{margin:0 !important;padding:6px !important;}.woocommerce_variation p button{float:right;}
#variable_product_options p.toolbar{margin:0 !important;overflow:hidden;zoom:1;border-top:1px solid white;border-bottom:1px solid #DFDFDF;padding:9px 12px !important;}#variable_product_options p.toolbar strong{margin:0 6px 0 0;float:left;line-height:23px;}
#variable_product_options p.toolbar .button,#variable_product_options p.toolbar select{margin:0 6px 0 0;float:left;}
#variable_product_options p.toolbar a.set{padding-left:20px;background:#fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat 7px 5px;}
#variable_product_options p.toolbar a.toggle{padding-left:20px;background:#fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAWUlEQVQYGY3QAQrAIAgFUB07mrfWu7kc+2JRsiA0fJnE7k5m5tQsEWFS1WGduh3mahpNLx3hOs4WAr2zfU8mRBGxorAJ4wAU+boS1g41x4UbScQdQJ3/fvgDtStDiI0qoDcAAAAASUVORK5CYII=) no-repeat 7px 5px;}
#variable_product_options p.toolbar a.delete_variations{padding-left:20px;background:#fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAKUlEQVQYlWP8//8/Az7AhFeWGAUsDAwMDHv27MFqj4uLCyNBExhp70gAohwKC5KJ+HQAAAAASUVORK5CYII=) no-repeat 7px 6px;}
#variable_product_options p.toolbar .add_variation,#variable_product_options p.toolbar .link_all_variations{float:right;}
#variable_product_options .woocommerce_variations{border-top:1px solid white;border-bottom:1px solid #DFDFDF;padding:9px 12px 0;}
.woocommerce_variation{background:#ececec;border:1px solid #ececec;margin:0 0 9px !important;}.woocommerce_variation h3{margin:0 !important;padding:6px !important;font-size:1em !important;cursor:pointer;}.woocommerce_variation h3 button{float:right;}
.woocommerce_variation h3 strong{font-weight:normal;}
.woocommerce_variation h3 select{font-family:sans-serif;}
.woocommerce_variation h3 .handlediv{background-position:6px 5px !important;display:none;}
.woocommerce_variation:hover h3 .handlediv{display:block;}
.woocommerce_variation table td{background:#fff;padding:6px 6px;vertical-align:middle;width:16.66%;}.woocommerce_variation table td label{color:#999;font-size:10px;text-transform:uppercase;text-align:left;display:block;line-height:16px;}
.woocommerce_variation table td input{float:left;width:100%;}
.woocommerce_variation table td.dimensions_field input{width:32%;margin-right:2%;}

View File

@ -1161,7 +1161,7 @@ table td.handle {
cursor: move;
padding-right: 0;
}
#woocommerce_attributes, #variable_product_options {
#woocommerce_attributes {
padding: 12px;
}
.woocommerce_attributes_wrapper, .woocommerce_variable_attributes_wrapper {
@ -1222,15 +1222,6 @@ table.woocommerce_attributes .center {
#woocommerce_attributes select.attribute_taxonomy, button.add_attribute, button.add_variable_attribute, button.add_variation, button.link_all_variations {
float: right;
}
a.delete_variations {
float: right;
line-height: 23px;
margin-right: 3px;
color: #999;
&:hover {
color: red;
}
}
#upsells_and_crosssells_product_data {
padding: 0 9px 9px;
@ -1293,12 +1284,15 @@ div.multi_select_products_wrapper-alt {
margin: 0;
line-height: 23px;
}
p.bulk_edit, p.default_variation {
background: #ececec;
padding: 6px !important;
margin: 0 0 8px !important;
p.toolbar {
margin: 0 !important;
overflow: hidden;
zoom: 1;
border-top: 1px solid white;
border-bottom: 1px solid #DFDFDF;
padding: 9px 12px !important;
strong {
margin: 0 6px 0 0;
float: left;
@ -1316,18 +1310,45 @@ div.multi_select_products_wrapper-alt {
padding-left: 20px;
background: #fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAWUlEQVQYGY3QAQrAIAgFUB07mrfWu7kc+2JRsiA0fJnE7k5m5tQsEWFS1WGduh3mahpNLx3hOs4WAr2zfU8mRBGxorAJ4wAU+boS1g41x4UbScQdQJ3/fvgDtStDiI0qoDcAAAAASUVORK5CYII=) no-repeat 7px 5px;
}
a.delete_variations {
padding-left: 20px;
background: #fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAKUlEQVQYlWP8//8/Az7AhFeWGAUsDAwMDHv27MFqj4uLCyNBExhp70gAohwKC5KJ+HQAAAAASUVORK5CYII=) no-repeat 7px 6px;
}
.add_variation, .link_all_variations {
float: right;
}
}
.woocommerce_variations {
border-top: 1px solid white;
border-bottom: 1px solid #DFDFDF;
padding: 9px 12px 0;
}
}
.woocommerce_variation {
background: #ececec;
border: 1px solid #ececec;
margin: 0 0 8px !important;
p {
margin: 0 0 9px !important;
h3 {
margin: 0 !important;
padding: 6px !important;
font-size: 1em !important;
cursor: pointer;
button {
float: right;
}
strong {
font-weight: normal;
}
select {
font-family: sans-serif;
}
.handlediv {
background-position: 6px 5px !important;
display: none;
}
}
&:hover h3 .handlediv {
display: block;
}
table td {
background: #fff;