From 88f2e690bb788d8fe8690ef088d7dddbfc0f0114 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Fri, 3 Apr 2015 14:21:47 +0200 Subject: [PATCH] Changing all inefficient selectors of $('body') to $(document.body), which is about 80% faster (and even more on mobile, see https://jsperf.com/jquery-body-vs-document-body-selector/2 ). --- assets/js/admin/meta-boxes-order.js | 8 ++--- assets/js/admin/meta-boxes-product.js | 10 +++---- assets/js/admin/meta-boxes.js | 4 +-- assets/js/admin/order-backbone-modal.js | 12 ++++---- assets/js/admin/users.js | 4 +-- assets/js/admin/woocommerce_admin.js | 14 ++++----- assets/js/chosen/chosen.jquery.js | 2 +- assets/js/frontend/add-payment-method.js | 2 +- assets/js/frontend/add-to-cart.js | 6 ++-- assets/js/frontend/cart-fragments.js | 8 ++--- assets/js/frontend/cart.js | 2 +- assets/js/frontend/checkout.js | 30 +++++++++---------- assets/js/frontend/country-select.js | 14 ++++----- assets/js/frontend/price-slider.js | 10 +++---- assets/js/jquery-blockui/jquery.blockUI.js | 2 +- assets/js/prettyPhoto/jquery.prettyPhoto.js | 2 +- .../views/html-admin-page-status-report.php | 2 +- .../assets/js/simplify-commerce.js | 2 +- 18 files changed, 67 insertions(+), 67 deletions(-) diff --git a/assets/js/admin/meta-boxes-order.js b/assets/js/admin/meta-boxes-order.js index c399785b2db..a0f83c8ca5f 100644 --- a/assets/js/admin/meta-boxes-order.js +++ b/assets/js/admin/meta-boxes-order.js @@ -14,7 +14,7 @@ jQuery( function ( $ ) { $( '.js_field-country' ).select2().change( this.change_country ); $( '.js_field-country' ).trigger( 'change', [ true ] ); - $( 'body' ).on( 'change', 'select.js_field-state', this.change_state ); + $(document.body).on( 'change', 'select.js_field-state', this.change_state ); $( '#woocommerce-order-actions input, #woocommerce-order-actions a' ).click(function() { window.onbeforeunload = ''; }); @@ -70,7 +70,7 @@ jQuery( function ( $ ) { $state.replaceWith( '' ); } - $( 'body' ).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] ); + $(document.body).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] ); }, change_state: function() { @@ -992,7 +992,7 @@ jQuery( function ( $ ) { init: function( e, target ) { if ( '#wc-modal-add-products' === target ) { - $( 'body' ).trigger( 'wc-enhanced-select-init' ); + $(document.body).trigger( 'wc-enhanced-select-init' ); } }, @@ -1213,7 +1213,7 @@ jQuery( function ( $ ) { window.alert( woocommerce_admin_meta_boxes.i18n_download_permission_fail ); } - $('body').trigger( 'wc-init-datepickers' ); + $(document.body).trigger( 'wc-init-datepickers' ); $( '#grant_access_id' ).val( '' ).change(); $( '.order_download_permissions' ).unblock(); }); diff --git a/assets/js/admin/meta-boxes-product.js b/assets/js/admin/meta-boxes-product.js index 72518108b8f..8f2fe7abdeb 100644 --- a/assets/js/admin/meta-boxes-product.js +++ b/assets/js/admin/meta-boxes-product.js @@ -107,12 +107,12 @@ jQuery( function( $ ){ $( 'ul.wc-tabs li:visible' ).eq(0).find( 'a' ).click(); - $( 'body' ).trigger( 'woocommerce-product-type-change', select_val, $( this ) ); + $(document.body).trigger( 'woocommerce-product-type-change', select_val, $( this ) ); }).change(); - $( 'body' ).on( 'woocommerce-product-type-change', function( e, select_val ) { - if ( 'variable' !== select_val && 0 < $( '#variable_product_options input[name^=variable_sku]' ).length && $( 'body' ).triggerHandler( 'woocommerce-display-product-type-alert', select_val ) !== false ) { + $(document.body).on( 'woocommerce-product-type-change', function( e, select_val ) { + if ( 'variable' !== select_val && 0 < $( '#variable_product_options input[name^=variable_sku]' ).length && $(document.body).triggerHandler( 'woocommerce-display-product-type-alert', select_val ) !== false ) { window.alert( woocommerce_admin_meta_boxes.i18n_product_type_alert ); } }); @@ -293,11 +293,11 @@ jQuery( function( $ ){ $wrapper.find( '.enable_variation' ).hide(); } - $('body').trigger( 'wc-enhanced-select-init' ); + $(document.body).trigger( 'wc-enhanced-select-init' ); attribute_row_indexes(); $wrapper.unblock(); - $('body').trigger( 'woocommerce_added_attribute' ); + $(document.body).trigger( 'woocommerce_added_attribute' ); }); if ( attribute ) { diff --git a/assets/js/admin/meta-boxes.js b/assets/js/admin/meta-boxes.js index 9797c347805..9c59d6d62d1 100644 --- a/assets/js/admin/meta-boxes.js +++ b/assets/js/admin/meta-boxes.js @@ -48,7 +48,7 @@ jQuery( function ( $ ) { }); $('ul.wc-tabs li:visible').eq(0).find('a').click(); - $('body').on( 'wc-init-datepickers', function() { + $(document.body).on( 'wc-init-datepickers', function() { $( ".date-picker-field, .date-picker" ).datepicker({ dateFormat: "yy-mm-dd", numberOfMonths: 1, @@ -56,7 +56,7 @@ jQuery( function ( $ ) { }); }); - $('body').trigger( 'wc-init-datepickers' ); + $(document.body).trigger( 'wc-init-datepickers' ); // META BOXES - Open/close $('.wc-metaboxes-wrapper').on('click', '.wc-metabox h3', function(event){ diff --git a/assets/js/admin/order-backbone-modal.js b/assets/js/admin/order-backbone-modal.js index 71819753e12..f8896bc517f 100644 --- a/assets/js/admin/order-backbone-modal.js +++ b/assets/js/admin/order-backbone-modal.js @@ -61,7 +61,7 @@ render: function() { this.$el.attr( 'tabindex' , '0' ).append( $( this._target ).html() ); - $( 'body' ).css({ + $(document.body).css({ 'overflow': 'hidden' }).append( this.$el ); @@ -89,21 +89,21 @@ 'margin-top': '-' + ( $( '.wc-backbone-modal-content' ).height() / 2 ) + 'px' }); - $( 'body' ).trigger( 'wc_backbone_modal_loaded', this._target ); + $(document.body).trigger( 'wc_backbone_modal_loaded', this._target ); }, closeButton: function( e ) { e.preventDefault(); - $( 'body' ).trigger( 'wc_backbone_modal_before_remove', this._target ); + $(document.body).trigger( 'wc_backbone_modal_before_remove', this._target ); this.undelegateEvents(); $( document ).off( 'focusin' ); - $( 'body' ).css({ + $(document.body).css({ 'overflow': 'auto' }); this.remove(); - $( 'body' ).trigger( 'wc_backbone_modal_removed', this._target ); + $(document.body).trigger( 'wc_backbone_modal_removed', this._target ); }, addButton: function( e ) { - $( 'body' ).trigger( 'wc_backbone_modal_response', [ this._target, this.getFormData() ] ); + $(document.body).trigger( 'wc_backbone_modal_response', [ this._target, this.getFormData() ] ); this.closeButton( e ); }, getFormData: function() { diff --git a/assets/js/admin/users.js b/assets/js/admin/users.js index 73811110e8c..12f790f98a5 100644 --- a/assets/js/admin/users.js +++ b/assets/js/admin/users.js @@ -14,7 +14,7 @@ jQuery( function ( $ ) { $( '.js_field-country' ).select2().change( this.change_country ); $( '.js_field-country' ).trigger( 'change', [ true ] ); - $( 'body' ).on( 'change', 'select.js_field-state', this.change_state ); + $(document.body).on( 'change', 'select.js_field-state', this.change_state ); }, change_country: function( e, stickValue ) { @@ -63,7 +63,7 @@ jQuery( function ( $ ) { $state.replaceWith( '' ); } - $( 'body' ).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] ); + $(document.body).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] ); }, change_state: function() { diff --git a/assets/js/admin/woocommerce_admin.js b/assets/js/admin/woocommerce_admin.js index b64e7184179..4f54b800638 100644 --- a/assets/js/admin/woocommerce_admin.js +++ b/assets/js/admin/woocommerce_admin.js @@ -6,12 +6,12 @@ jQuery( function ( $ ) { // Price input validation - $('body').on( 'blur', '.wc_input_decimal[type=text], .wc_input_price[type=text], .wc_input_country_iso[type=text]', function() { + $(document.body).on( 'blur', '.wc_input_decimal[type=text], .wc_input_price[type=text], .wc_input_country_iso[type=text]', function() { $('.wc_error_tip').fadeOut('100', function(){ $(this).remove(); } ); return this; }); - $('body').on('keyup change', '.wc_input_price[type=text]', function(){ + $(document.body).on('keyup change', '.wc_input_price[type=text]', function(){ var value = $(this).val(); var regex = new RegExp( "[^\-0-9\%.\\" + woocommerce_admin.mon_decimal_point + "]+", "gi" ); var newvalue = value.replace( regex, '' ); @@ -30,7 +30,7 @@ jQuery( function ( $ ) { return this; }); - $('body').on('keyup change', '.wc_input_decimal[type=text]', function(){ + $(document.body).on('keyup change', '.wc_input_decimal[type=text]', function(){ var value = $(this).val(); var regex = new RegExp( "[^\-0-9\%.\\" + woocommerce_admin.decimal_point + "]+", "gi" ); var newvalue = value.replace( regex, '' ); @@ -49,7 +49,7 @@ jQuery( function ( $ ) { return this; }); - $('body').on( 'keyup', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){ + $(document.body).on( 'keyup', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){ var sale_price_field = $(this); if( sale_price_field.attr('name').indexOf('variable') !== -1 ) { @@ -75,7 +75,7 @@ jQuery( function ( $ ) { } return this; }); - $('body').on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){ + $(document.body).on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function(){ var sale_price_field = $(this); if( sale_price_field.attr('name').indexOf('variable') !== -1 ) { @@ -95,7 +95,7 @@ jQuery( function ( $ ) { return this; }); - $('body').on('keyup change', '.wc_input_country_iso[type=text]', function(){ + $(document.body).on('keyup change', '.wc_input_country_iso[type=text]', function(){ var value = $(this).val(); var regex = new RegExp( '^([A-Z])?([A-Z])$' ); @@ -222,7 +222,7 @@ jQuery( function ( $ ) { }).change(); // Show order items on orders page - $('body').on( 'click', '.show_order_items', function() { + $(document.body).on( 'click', '.show_order_items', function() { $(this).closest('td').find('table').toggle(); return false; }); diff --git a/assets/js/chosen/chosen.jquery.js b/assets/js/chosen/chosen.jquery.js index 10fa0e55879..1c9c9cd82f8 100644 --- a/assets/js/chosen/chosen.jquery.js +++ b/assets/js/chosen/chosen.jquery.js @@ -1146,7 +1146,7 @@ 'style': style_block }); div.text(this.search_field.val()); - $('body').append(div); + $(document.body).append(div); w = div.width() + 25; div.remove(); f_width = this.container.outerWidth(); diff --git a/assets/js/frontend/add-payment-method.js b/assets/js/frontend/add-payment-method.js index 65f70e688a0..85cc64f8ba9 100644 --- a/assets/js/frontend/add-payment-method.js +++ b/assets/js/frontend/add-payment-method.js @@ -29,6 +29,6 @@ jQuery( function( $ ) { $( '#add_payment_method' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } }); }); - $( 'body' ).trigger( 'init_add_payment_method' ); + $(document.body).trigger( 'init_add_payment_method' ); }); diff --git a/assets/js/frontend/add-to-cart.js b/assets/js/frontend/add-to-cart.js index 383975bce92..20343fc7606 100644 --- a/assets/js/frontend/add-to-cart.js +++ b/assets/js/frontend/add-to-cart.js @@ -25,7 +25,7 @@ jQuery( function( $ ) { }); // Trigger event - $( 'body' ).trigger( 'adding_to_cart', [ $thisbutton, data ] ); + $(document.body).trigger( 'adding_to_cart', [ $thisbutton, data ] ); // Ajax action $.post( wc_add_to_cart_params.wc_ajax_url + 'add_to_cart', data, function( response ) { @@ -94,7 +94,7 @@ jQuery( function( $ ) { $( '.shop_table.cart' ).stop( true ).css( 'opacity', '1' ).unblock(); - $( 'body' ).trigger( 'cart_page_refreshed' ); + $(document.body).trigger( 'cart_page_refreshed' ); }); $( '.cart_totals' ).load( this_page + ' .cart_totals:eq(0) > *', function() { @@ -102,7 +102,7 @@ jQuery( function( $ ) { }); // Trigger event so themes can refresh other areas - $( 'body' ).trigger( 'added_to_cart', [ fragments, cart_hash, $thisbutton ] ); + $(document.body).trigger( 'added_to_cart', [ fragments, cart_hash, $thisbutton ] ); } }); diff --git a/assets/js/frontend/cart-fragments.js b/assets/js/frontend/cart-fragments.js index 62c99561b84..9784393a216 100644 --- a/assets/js/frontend/cart-fragments.js +++ b/assets/js/frontend/cart-fragments.js @@ -30,14 +30,14 @@ jQuery( function( $ ) { sessionStorage.setItem( 'wc_cart_hash', data.cart_hash ); } - $( 'body' ).trigger( 'wc_fragments_refreshed' ); + $(document.body).trigger( 'wc_fragments_refreshed' ); } } }; if ( $supports_html5_storage ) { - $( 'body' ).bind( 'added_to_cart', function( event, fragments, cart_hash ) { + $(document.body).bind( 'added_to_cart', function( event, fragments, cart_hash ) { sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( fragments ) ); sessionStorage.setItem( 'wc_cart_hash', cart_hash ); }); @@ -61,7 +61,7 @@ jQuery( function( $ ) { $( key ).replaceWith(value); }); - $( 'body' ).trigger( 'wc_fragments_loaded' ); + $(document.body).trigger( 'wc_fragments_loaded' ); } else { throw 'No fragment'; @@ -82,7 +82,7 @@ jQuery( function( $ ) { $( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).hide(); } - $( 'body' ).bind( 'adding_to_cart', function() { + $(document.body).bind( 'adding_to_cart', function() { $( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show(); } ); diff --git a/assets/js/frontend/cart.js b/assets/js/frontend/cart.js index 76e38f145af..2c6e07cb368 100644 --- a/assets/js/frontend/cart.js +++ b/assets/js/frontend/cart.js @@ -34,7 +34,7 @@ jQuery( function( $ ) { $.post( wc_cart_params.wc_ajax_url + 'update_shipping_method', data, function( response ) { $( 'div.cart_totals' ).replaceWith( response ); - $( 'body' ).trigger( 'updated_shipping_method' ); + $(document.body).trigger( 'updated_shipping_method' ); }); }); diff --git a/assets/js/frontend/checkout.js b/assets/js/frontend/checkout.js index 1dec159c798..3f99839884e 100644 --- a/assets/js/frontend/checkout.js +++ b/assets/js/frontend/checkout.js @@ -14,9 +14,9 @@ jQuery( function( $ ) { $order_review: $( '#order_review' ), $checkout_form: $( 'form.checkout' ), init: function() { - $( 'body' ).bind( 'update_checkout', this.reset_update_checkout_timer ); - $( 'body' ).bind( 'update_checkout', this.update_checkout ); - $( 'body' ).bind( 'init_checkout', this.init_checkout ); + $( document.body ).bind( 'update_checkout', this.reset_update_checkout_timer ); + $( document.body ).bind( 'update_checkout', this.update_checkout ); + $( document.body ).bind( 'init_checkout', this.init_checkout ); // Payment methods this.$order_review.on( 'click', 'input[name=payment_method]', this.payment_method_selected ); @@ -42,7 +42,7 @@ jQuery( function( $ ) { // Update on page load if ( wc_checkout_params.is_checkout === '1' ) { - $( 'body' ).trigger( 'init_checkout' ); + $(document.body).trigger( 'init_checkout' ); } if ( wc_checkout_params.option_guest_checkout === 'yes' ) { $( 'input#createaccount' ).change( this.toggle_create_account ).change(); @@ -57,7 +57,7 @@ jQuery( function( $ ) { }, init_checkout: function( e ) { $( '#billing_country, #shipping_country, .country_to_state' ).change(); - $( 'body' ).trigger( 'update_checkout' ); + $(document.body).trigger( 'update_checkout' ); }, maybe_input_changed: function( e ) { if ( wc_checkout_form.dirtyInput ) { @@ -82,13 +82,13 @@ jQuery( function( $ ) { trigger_update_checkout: function( e ) { wc_checkout_form.reset_update_checkout_timer(); wc_checkout_form.dirtyInput = false; - $( 'body' ).trigger( 'update_checkout' ); + $(document.body).trigger( 'update_checkout' ); }, maybe_update_checkout: function() { var update_totals = true; if ( $( wc_checkout_form.dirtyInput ).size() ) { - $required_inputs = $( wc_checkout_form.dirtyInput ).closest( 'div' ).find( '.address-field.validate-required' ); + var $required_inputs = $( wc_checkout_form.dirtyInput ).closest( 'div' ).find( '.address-field.validate-required' ); if ( $required_inputs.size() ) { $required_inputs.each( function( e ) { @@ -287,7 +287,7 @@ jQuery( function( $ ) { $( '.woocommerce-checkout' ).find( 'input[name=payment_method]:checked' ).eq(0).trigger( 'click' ); // Fire updated_checkout e - $( 'body' ).trigger( 'updated_checkout' ); + $(document.body).trigger( 'updated_checkout' ); } }); @@ -378,10 +378,10 @@ jQuery( function( $ ) { // Trigger update in case we need a fresh nonce if ( result.refresh === 'true' ) { - $( 'body' ).trigger( 'update_checkout' ); + $(document.body).trigger( 'update_checkout' ); } - $( 'body' ).trigger( 'checkout_error' ); + $(document.body).trigger( 'checkout_error' ); } }, dataType: 'html' @@ -395,8 +395,8 @@ jQuery( function( $ ) { var wc_checkout_coupons = { init: function() { - $( 'body' ).on( 'click', 'a.showcoupon', this.show_coupon_form ); - $( 'body' ).on( 'click', '.woocommerce-remove-coupon', this.remove_coupon ); + $( document.body ).on( 'click', 'a.showcoupon', this.show_coupon_form ); + $( document.body ).on( 'click', '.woocommerce-remove-coupon', this.remove_coupon ); $( 'form.checkout_coupon' ).hide().submit( this.submit ); }, show_coupon_form: function( e ) { @@ -435,7 +435,7 @@ jQuery( function( $ ) { $form.before( code ); $form.slideUp(); - $( 'body' ).trigger( 'update_checkout' ); + $(document.body).trigger( 'update_checkout' ); } }, dataType: 'html' @@ -473,7 +473,7 @@ jQuery( function( $ ) { if ( code ) { $( 'form.woocommerce-checkout' ).before( code ); - $( 'body' ).trigger( 'update_checkout' ); + $(document.body).trigger( 'update_checkout' ); // remove coupon code from coupon field $( 'form.checkout_coupon' ).find( 'input[name="coupon_code"]' ).val( '' ); @@ -491,7 +491,7 @@ jQuery( function( $ ) { var wc_checkout_login_form = { init: function() { - $( 'body' ).on( 'click', 'a.showlogin', this.show_login_form ); + $(document.body).on( 'click', 'a.showlogin', this.show_login_form ); }, show_login_form: function( e ) { $( 'form.login' ).slideToggle(); diff --git a/assets/js/frontend/country-select.js b/assets/js/frontend/country-select.js index dd36aaed338..4ab3449a7c1 100644 --- a/assets/js/frontend/country-select.js +++ b/assets/js/frontend/country-select.js @@ -74,7 +74,7 @@ jQuery( function( $ ) { wc_country_select_select2(); - $( 'body' ).bind( 'country_to_state_changed', function() { + $(document.body).bind( 'country_to_state_changed', function() { wc_country_select_select2(); }); } @@ -83,7 +83,7 @@ jQuery( function( $ ) { var states_json = wc_country_select_params.countries.replace( /"/g, '"' ), states = $.parseJSON( states_json ); - $( 'body' ).on( 'change', 'select.country_to_state, input.country_to_state', function() { + $(document.body).on( 'change', 'select.country_to_state, input.country_to_state', function() { var country = $( this ).val(), $statebox = $( this ).closest( 'div' ).find( '#billing_state, #shipping_state, #calc_shipping_state' ), @@ -99,7 +99,7 @@ jQuery( function( $ ) { $statebox.parent().hide().find( '.select2-container' ).remove(); $statebox.replaceWith( '' ); - $( 'body' ).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] ); + $(document.body).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] ); } else { @@ -123,7 +123,7 @@ jQuery( function( $ ) { $statebox.html( '' + options ); $statebox.val( value ).change(); - $( 'body' ).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] ); + $(document.body).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] ); } } else { @@ -132,19 +132,19 @@ jQuery( function( $ ) { $parent.show().find( '.select2-container' ).remove(); $statebox.replaceWith( '' ); - $( 'body' ).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] ); + $(document.body).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] ); } else if ( $statebox.is( '.hidden' ) ) { $parent.show().find( '.select2-container' ).remove(); $statebox.replaceWith( '' ); - $( 'body' ).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] ); + $(document.body).trigger( 'country_to_state_changed', [country, $( this ).closest( 'div' )] ); } } - $( 'body' ).trigger( 'country_to_state_changing', [country, $( this ).closest( 'div' )] ); + $(document.body).trigger( 'country_to_state_changing', [country, $( this ).closest( 'div' )] ); }); diff --git a/assets/js/frontend/price-slider.js b/assets/js/frontend/price-slider.js index 1ff7a82f681..c472520417a 100644 --- a/assets/js/frontend/price-slider.js +++ b/assets/js/frontend/price-slider.js @@ -19,7 +19,7 @@ jQuery( function( $ ) { if ( woocommerce_price_slider_params.min_price ) current_min_price = parseInt( woocommerce_price_slider_params.min_price, 10 ); if ( woocommerce_price_slider_params.max_price ) current_max_price = parseInt( woocommerce_price_slider_params.max_price, 10 ); - $( 'body' ).bind( 'price_slider_create price_slider_slide', function( event, min, max ) { + $(document.body).bind( 'price_slider_create price_slider_slide', function( event, min, max ) { if ( woocommerce_price_slider_params.currency_pos === 'left' ) { $( '.price_slider_amount span.from' ).html( woocommerce_price_slider_params.currency_symbol + min ); @@ -42,7 +42,7 @@ jQuery( function( $ ) { } - $( 'body' ).trigger( 'price_slider_updated', min, max ); + $(document.body).trigger( 'price_slider_updated', min, max ); }); $( '.price_slider' ).slider({ @@ -56,18 +56,18 @@ jQuery( function( $ ) { $( '.price_slider_amount #min_price' ).val( current_min_price ); $( '.price_slider_amount #max_price' ).val( current_max_price ); - $( 'body' ).trigger( 'price_slider_create', [ current_min_price, current_max_price ] ); + $(document.body).trigger( 'price_slider_create', [ current_min_price, current_max_price ] ); }, slide: function( event, ui ) { $( 'input#min_price' ).val( ui.values[0] ); $( 'input#max_price' ).val( ui.values[1] ); - $( 'body' ).trigger( 'price_slider_slide', [ ui.values[0], ui.values[1] ] ); + $(document.body).trigger( 'price_slider_slide', [ ui.values[0], ui.values[1] ] ); }, change: function( event, ui ) { - $( 'body' ).trigger( 'price_slider_change', [ ui.values[0], ui.values[1] ] ); + $(document.body).trigger( 'price_slider_change', [ ui.values[0], ui.values[1] ] ); }, }); diff --git a/assets/js/jquery-blockui/jquery.blockUI.js b/assets/js/jquery-blockui/jquery.blockUI.js index 064ed34cda6..561c50a0825 100644 --- a/assets/js/jquery-blockui/jquery.blockUI.js +++ b/assets/js/jquery-blockui/jquery.blockUI.js @@ -473,7 +473,7 @@ var els; if (full) // crazy selector to handle odd field errors in ie6/7 - els = $('body').children().filter('.blockUI').add('body > .blockUI'); + els = $(document.body).children().filter('.blockUI').add('body > .blockUI'); else els = $el.find('>.blockUI'); diff --git a/assets/js/prettyPhoto/jquery.prettyPhoto.js b/assets/js/prettyPhoto/jquery.prettyPhoto.js index 0a71d25cb32..3c159041bfc 100644 --- a/assets/js/prettyPhoto/jquery.prettyPhoto.js +++ b/assets/js/prettyPhoto/jquery.prettyPhoto.js @@ -751,7 +751,7 @@ settings.markup = settings.markup.replace('{pp_social}',''); - $('body').append(settings.markup); // Inject the markup + $(document.body).append(settings.markup); // Inject the markup $pp_pic_holder = $('.pp_pic_holder') , $ppt = $('.ppt'), $pp_overlay = $('div.pp_overlay'); // Set my global selectors diff --git a/includes/admin/views/html-admin-page-status-report.php b/includes/admin/views/html-admin-page-status-report.php index 7ff8b42ea1c..adf5afb3f9f 100644 --- a/includes/admin/views/html-admin-page-status-report.php +++ b/includes/admin/views/html-admin-page-status-report.php @@ -779,7 +779,7 @@ if ( ! defined( 'ABSPATH' ) ) { 'delay': 0 }); - $( 'body' ).on( 'copy', '#copy-for-support', function ( e ) { + $(document.body).on( 'copy', '#copy-for-support', function ( e ) { e.clipboardData.clearData(); e.clipboardData.setData( 'text/plain', $( '#debug-report textarea' ).val() ); e.preventDefault(); diff --git a/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js b/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js index 5fa4678d88e..b935965f8c0 100644 --- a/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js +++ b/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js @@ -75,7 +75,7 @@ $( function () { - $( 'body' ).on( 'checkout_error', function () { + $(document.body).on( 'checkout_error', function () { $( '.simplify-token' ).remove(); });