Fixed coding standards
This commit is contained in:
parent
cd1d68323c
commit
8c4d406866
|
@ -18,23 +18,23 @@ jQuery( function( $ ) {
|
|||
});
|
||||
});
|
||||
|
||||
// Prevent enter submitting post form
|
||||
// Prevent enter submitting post form.
|
||||
$( '#upsell_product_data' ).bind( 'keypress', function( e ) {
|
||||
if ( e.keyCode === 13 ) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Type box
|
||||
// Type box.
|
||||
$( '.type_box' ).appendTo( '#woocommerce-product-data .hndle span' );
|
||||
|
||||
$( function() {
|
||||
// Prevent inputs in meta box headings opening/closing contents
|
||||
// Prevent inputs in meta box headings opening/closing contents.
|
||||
$( '#woocommerce-product-data' ).find( '.hndle' ).unbind( 'click.postboxes' );
|
||||
|
||||
jQuery( '#woocommerce-product-data' ).on( 'click', '.hndle', function( event ) {
|
||||
$( '#woocommerce-product-data' ).on( 'click', '.hndle', function( event ) {
|
||||
|
||||
// If the user clicks on some form input inside the h3 the box should not be toggled
|
||||
// If the user clicks on some form input inside the h3 the box should not be toggled.
|
||||
if ( $( event.target ).filter( 'input, option, label, select' ).length ) {
|
||||
return;
|
||||
}
|
||||
|
@ -43,15 +43,15 @@ jQuery( function( $ ) {
|
|||
});
|
||||
});
|
||||
|
||||
// Catalog Visibility
|
||||
$( '#catalog-visibility' ).find( '.edit-catalog-visibility' ).click( function () {
|
||||
// Catalog Visibility.
|
||||
$( '#catalog-visibility' ).find( '.edit-catalog-visibility' ).click( function() {
|
||||
if ( $( '#catalog-visibility-select' ).is( ':hidden' ) ) {
|
||||
$( '#catalog-visibility-select' ).slideDown( 'fast' );
|
||||
$( this ).hide();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$( '#catalog-visibility' ).find( '.save-post-visibility' ).click( function () {
|
||||
$( '#catalog-visibility' ).find( '.save-post-visibility' ).click( function() {
|
||||
$( '#catalog-visibility-select' ).slideUp( 'fast' );
|
||||
$( '#catalog-visibility' ).find( '.edit-catalog-visibility' ).show();
|
||||
|
||||
|
@ -65,7 +65,7 @@ jQuery( function( $ ) {
|
|||
$( '#catalog-visibility-display' ).text( label );
|
||||
return false;
|
||||
});
|
||||
$( '#catalog-visibility' ).find( '.cancel-post-visibility' ).click( function () {
|
||||
$( '#catalog-visibility' ).find( '.cancel-post-visibility' ).click( function() {
|
||||
$( '#catalog-visibility-select' ).slideUp( 'fast' );
|
||||
$( '#catalog-visibility' ).find( '.edit-catalog-visibility' ).show();
|
||||
|
||||
|
@ -88,10 +88,10 @@ jQuery( function( $ ) {
|
|||
return false;
|
||||
});
|
||||
|
||||
// PRODUCT TYPE SPECIFIC OPTIONS
|
||||
$( 'select#product-type' ).change( function () {
|
||||
// PRODUCT TYPE SPECIFIC OPTIONS.
|
||||
$( 'select#product-type' ).change( function() {
|
||||
|
||||
// Get value
|
||||
// Get value.
|
||||
var select_val = $( this ).val();
|
||||
|
||||
if ( 'variable' === select_val ) {
|
||||
|
@ -129,7 +129,7 @@ jQuery( function( $ ) {
|
|||
var is_virtual = $( 'input#_virtual:checked' ).length;
|
||||
var is_downloadable = $( 'input#_downloadable:checked' ).length;
|
||||
|
||||
// Hide/Show all with rules
|
||||
// Hide/Show all with rules.
|
||||
var hide_classes = '.hide_if_downloadable, .hide_if_virtual';
|
||||
var show_classes = '.show_if_downloadable, .show_if_virtual';
|
||||
|
||||
|
@ -141,7 +141,7 @@ jQuery( function( $ ) {
|
|||
$( hide_classes ).show();
|
||||
$( show_classes ).hide();
|
||||
|
||||
// Shows rules
|
||||
// Shows rules.
|
||||
if ( is_downloadable ) {
|
||||
$( '.show_if_downloadable' ).show();
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ jQuery( function( $ ) {
|
|||
|
||||
$( '.show_if_' + product_type ).show();
|
||||
|
||||
// Hide rules
|
||||
// Hide rules.
|
||||
if ( is_downloadable ) {
|
||||
$( '.hide_if_downloadable' ).hide();
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ jQuery( function( $ ) {
|
|||
|
||||
$( 'input#_manage_stock' ).change();
|
||||
|
||||
// Hide empty panels/tabs after display
|
||||
// Hide empty panels/tabs after display.
|
||||
$( '.woocommerce_options_panel' ).each( function() {
|
||||
var $children = $( this ).children( '.options_group' );
|
||||
|
||||
|
@ -171,24 +171,26 @@ jQuery( function( $ ) {
|
|||
return;
|
||||
}
|
||||
|
||||
var $invisble = $children.filter( function() { return 'none' === $( this ).css( 'display' ); } );
|
||||
var $invisble = $children.filter( function() {
|
||||
return 'none' === $( this ).css( 'display' );
|
||||
});
|
||||
|
||||
// Hide panel
|
||||
// Hide panel.
|
||||
if ( $invisble.length === $children.length ) {
|
||||
var $id = $( this ).prop( 'id' );
|
||||
$( '.product_data_tabs' ).find( 'li a[href="#' + $id + '"]' ).parent().hide();
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
// Sale price schedule
|
||||
// Sale price schedule.
|
||||
$( '.sale_price_dates_fields' ).each( function() {
|
||||
var $these_sale_dates = $( this );
|
||||
var sale_schedule_set = false;
|
||||
var $wrap = $these_sale_dates.closest( 'div, table' );
|
||||
|
||||
$these_sale_dates.find( 'input' ).each( function() {
|
||||
if ( $( this ).val() !== '' ) {
|
||||
if ( '' !== $( this ).val() ) {
|
||||
sale_schedule_set = true;
|
||||
}
|
||||
});
|
||||
|
@ -222,7 +224,7 @@ jQuery( function( $ ) {
|
|||
return false;
|
||||
});
|
||||
|
||||
// File inputs
|
||||
// File inputs.
|
||||
$( '#woocommerce-product-data' ).on( 'click','.downloadable_files a.insert', function() {
|
||||
$( this ).closest( '.downloadable_files' ).find( 'tbody' ).append( $( this ).data( 'row' ) );
|
||||
return false;
|
||||
|
@ -232,7 +234,7 @@ jQuery( function( $ ) {
|
|||
return false;
|
||||
});
|
||||
|
||||
// STOCK OPTIONS
|
||||
// STOCK OPTIONS.
|
||||
$( 'input#_manage_stock' ).change( function() {
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
$( 'div.stock_fields' ).show();
|
||||
|
@ -241,7 +243,7 @@ jQuery( function( $ ) {
|
|||
}
|
||||
}).change();
|
||||
|
||||
// DATE PICKER FIELDS
|
||||
// DATE PICKER FIELDS.
|
||||
$( '.sale_price_dates_fields' ).each( function() {
|
||||
var dates = $( this ).find( 'input' ).datepicker({
|
||||
defaultDate: '',
|
||||
|
@ -257,18 +259,18 @@ jQuery( function( $ ) {
|
|||
});
|
||||
});
|
||||
|
||||
// ATTRIBUTE TABLES
|
||||
// ATTRIBUTE TABLES.
|
||||
|
||||
// Initial order
|
||||
var woocommerce_attribute_items = $('.product_attributes').find('.woocommerce_attribute').get();
|
||||
// Initial order.
|
||||
var woocommerce_attribute_items = $( '.product_attributes' ).find( '.woocommerce_attribute' ).get();
|
||||
|
||||
woocommerce_attribute_items.sort(function(a, b) {
|
||||
woocommerce_attribute_items.sort( function( a, b ) {
|
||||
var compA = parseInt( $( a ).attr( 'rel' ), 10 );
|
||||
var compB = parseInt( $( b ).attr( 'rel' ), 10 );
|
||||
return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
|
||||
return ( compA < compB ) ? -1 : ( compA > compB ) ? 1 : 0;
|
||||
});
|
||||
$( woocommerce_attribute_items ).each( function( idx, itm ) {
|
||||
$( '.product_attributes' ).append(itm);
|
||||
$( woocommerce_attribute_items ).each( function( index, el ) {
|
||||
$( '.product_attributes' ).append( el );
|
||||
});
|
||||
|
||||
function attribute_row_indexes() {
|
||||
|
@ -283,7 +285,7 @@ jQuery( function( $ ) {
|
|||
}
|
||||
});
|
||||
|
||||
// Add rows
|
||||
// Add rows.
|
||||
$( 'button.add_attribute' ).on( 'click', function() {
|
||||
var size = $( '.product_attributes .woocommerce_attribute' ).length;
|
||||
var attribute = $( 'select.attribute_taxonomy' ).val();
|
||||
|
@ -308,7 +310,7 @@ jQuery( function( $ ) {
|
|||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
|
||||
$attributes.append( response );
|
||||
|
||||
if ( product_type !== 'variable' ) {
|
||||
if ( 'variable' !== product_type ) {
|
||||
$attributes.find( '.enable_variation' ).hide();
|
||||
}
|
||||
|
||||
|
@ -339,7 +341,7 @@ jQuery( function( $ ) {
|
|||
|
||||
$( '.product_attributes' ).on( 'click', 'button.select_no_attributes', function() {
|
||||
$( this ).closest( 'td' ).find( 'select option' ).removeAttr( 'selected' );
|
||||
$( this ).closest( 'td' ).find( 'select').change();
|
||||
$( this ).closest( 'td' ).find( 'select' ).change();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
@ -348,11 +350,11 @@ jQuery( function( $ ) {
|
|||
var $parent = $( this ).parent().parent();
|
||||
|
||||
if ( $parent.is( '.taxonomy' ) ) {
|
||||
$parent.find( 'select, input[type=text]' ).val('');
|
||||
$parent.find( 'select, input[type=text]' ).val( '' );
|
||||
$parent.hide();
|
||||
$( 'select.attribute_taxonomy' ).find( 'option[value="' + $parent.data( 'taxonomy' ) + '"]' ).removeAttr( 'disabled' );
|
||||
} else {
|
||||
$parent.find( 'select, input[type=text]' ).val('');
|
||||
$parent.find( 'select, input[type=text]' ).val( '' );
|
||||
$parent.hide();
|
||||
attribute_row_indexes();
|
||||
}
|
||||
|
@ -360,7 +362,7 @@ jQuery( function( $ ) {
|
|||
return false;
|
||||
});
|
||||
|
||||
// Attribute ordering
|
||||
// Attribute ordering.
|
||||
$( '.product_attributes' ).sortable({
|
||||
items: '.woocommerce_attribute',
|
||||
cursor: 'move',
|
||||
|
@ -380,10 +382,16 @@ jQuery( function( $ ) {
|
|||
}
|
||||
});
|
||||
|
||||
// Add a new attribute (via ajax)
|
||||
// Add a new attribute (via ajax).
|
||||
$( '.product_attributes' ).on( 'click', 'button.add_new_attribute', function() {
|
||||
|
||||
$( '.product_attributes' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } });
|
||||
$( '.product_attributes' ).block({
|
||||
message: null,
|
||||
overlayCSS: {
|
||||
background: '#fff',
|
||||
opacity: 0.6
|
||||
}
|
||||
});
|
||||
|
||||
var $wrapper = $( this ).closest( '.woocommerce_attribute' );
|
||||
var attribute = $wrapper.data( 'taxonomy' );
|
||||
|
@ -401,10 +409,10 @@ jQuery( function( $ ) {
|
|||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
|
||||
|
||||
if ( response.error ) {
|
||||
// Error
|
||||
// Error.
|
||||
window.alert( response.error );
|
||||
} else if ( response.slug ) {
|
||||
// Success
|
||||
// Success.
|
||||
$wrapper.find( 'select.attribute_values' ).append( '<option value="' + response.slug + '" selected="selected">' + response.name + '</option>' );
|
||||
$wrapper.find( 'select.attribute_values' ).change();
|
||||
}
|
||||
|
@ -419,7 +427,7 @@ jQuery( function( $ ) {
|
|||
return false;
|
||||
});
|
||||
|
||||
// Save attributes and update variations
|
||||
// Save attributes and update variations.
|
||||
$( '.save_attributes' ).on( 'click', function() {
|
||||
|
||||
$( '#woocommerce-product-data' ).block({
|
||||
|
@ -438,22 +446,22 @@ jQuery( function( $ ) {
|
|||
};
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function() {
|
||||
// Reload variations panel
|
||||
// Reload variations panel.
|
||||
var this_page = window.location.toString();
|
||||
this_page = this_page.replace( 'post-new.php?', 'post.php?post=' + woocommerce_admin_meta_boxes.post_id + '&action=edit&' );
|
||||
|
||||
// Load variations panel
|
||||
// Load variations panel.
|
||||
$( '#variable_product_options' ).load( this_page + ' #variable_product_options_inner', function() {
|
||||
$( '#variable_product_options' ).trigger( 'reload' );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Uploading files
|
||||
// Uploading files.
|
||||
var downloadable_file_frame;
|
||||
var file_path_field;
|
||||
|
||||
jQuery( document.body ).on( 'click', '.upload_file_button', function( event ) {
|
||||
$( document.body ).on( 'click', '.upload_file_button', function( event ) {
|
||||
var $el = $( this );
|
||||
|
||||
file_path_field = $el.closest( 'tr' ).find( 'td.file_url input' );
|
||||
|
@ -506,7 +514,7 @@ jQuery( function( $ ) {
|
|||
file_path_field.val( file_path ).change();
|
||||
});
|
||||
|
||||
// Set post to 0 and set our custom type
|
||||
// Set post to 0 and set our custom type.
|
||||
downloadable_file_frame.on( 'ready', function() {
|
||||
downloadable_file_frame.uploader.options.uploader.params = {
|
||||
type: 'downloadable_product'
|
||||
|
@ -517,8 +525,8 @@ jQuery( function( $ ) {
|
|||
downloadable_file_frame.open();
|
||||
});
|
||||
|
||||
// Download ordering
|
||||
jQuery( '.downloadable_files tbody' ).sortable({
|
||||
// Download ordering.
|
||||
$( '.downloadable_files tbody' ).sortable({
|
||||
items: 'tr',
|
||||
cursor: 'move',
|
||||
axis: 'y',
|
||||
|
@ -529,12 +537,12 @@ jQuery( function( $ ) {
|
|||
opacity: 0.65
|
||||
});
|
||||
|
||||
// Product gallery file uploads
|
||||
// Product gallery file uploads.
|
||||
var product_gallery_frame;
|
||||
var $image_gallery_ids = $( '#product_image_gallery' );
|
||||
var $product_images = $( '#product_images_container' ).find( 'ul.product_images' );
|
||||
|
||||
jQuery( '.add_product_images' ).on( 'click', 'a', function( event ) {
|
||||
$( '.add_product_images' ).on( 'click', 'a', function( event ) {
|
||||
var $el = $( this );
|
||||
|
||||
event.preventDefault();
|
||||
|
@ -584,7 +592,7 @@ jQuery( function( $ ) {
|
|||
product_gallery_frame.open();
|
||||
});
|
||||
|
||||
// Image ordering
|
||||
// Image ordering.
|
||||
$product_images.sortable({
|
||||
items: 'li.image',
|
||||
cursor: 'move',
|
||||
|
@ -604,7 +612,7 @@ jQuery( function( $ ) {
|
|||
var attachment_ids = '';
|
||||
|
||||
$( '#product_images_container' ).find( 'ul li.image' ).css( 'cursor', 'default' ).each( function() {
|
||||
var attachment_id = jQuery( this ).attr( 'data-attachment_id' );
|
||||
var attachment_id = $( this ).attr( 'data-attachment_id' );
|
||||
attachment_ids = attachment_ids + attachment_id + ',';
|
||||
});
|
||||
|
||||
|
@ -612,20 +620,20 @@ jQuery( function( $ ) {
|
|||
}
|
||||
});
|
||||
|
||||
// Remove images
|
||||
// Remove images.
|
||||
$( '#product_images_container' ).on( 'click', 'a.delete', function() {
|
||||
$( this ).closest( 'li.image' ).remove();
|
||||
|
||||
var attachment_ids = '';
|
||||
|
||||
$( '#product_images_container' ).find( 'ul li.image' ).css( 'cursor', 'default' ).each( function() {
|
||||
var attachment_id = jQuery( this ).attr( 'data-attachment_id' );
|
||||
var attachment_id = $( this ).attr( 'data-attachment_id' );
|
||||
attachment_ids = attachment_ids + attachment_id + ',';
|
||||
});
|
||||
|
||||
$image_gallery_ids.val( attachment_ids );
|
||||
|
||||
// remove any lingering tooltips
|
||||
// Remove any lingering tooltips.
|
||||
$( '#tiptip_holder' ).removeAttr( 'style' );
|
||||
$( '#tiptip_arrow' ).removeAttr( 'style' );
|
||||
|
||||
|
|
Loading…
Reference in New Issue