Merge pull request #19699 from woocommerce/fix/19685
Added scroll to notices to cart page
This commit is contained in:
commit
736e713b0b
|
@ -329,6 +329,7 @@ jQuery( function( $ ) {
|
|||
complete: function() {
|
||||
unblock( $form );
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
$.scroll_to_notices( $( '[role="alert"]' ) );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
@ -512,6 +513,7 @@ jQuery( function( $ ) {
|
|||
complete: function() {
|
||||
unblock( $form );
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
$.scroll_to_notices( $( '[role="alert"]' ) );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
@ -540,6 +542,7 @@ jQuery( function( $ ) {
|
|||
complete: function() {
|
||||
unblock( $form );
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
$.scroll_to_notices( $( '[role="alert"]' ) );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -512,24 +512,12 @@ jQuery( function( $ ) {
|
|||
$( document.body ).trigger( 'checkout_error' );
|
||||
},
|
||||
scroll_to_notices: function() {
|
||||
var scrollElement = $( '.woocommerce-NoticeGroup-updateOrderReview, .woocommerce-NoticeGroup-checkout' ),
|
||||
isSmoothScrollSupported = 'scrollBehavior' in document.documentElement.style;
|
||||
var scrollElement = $( '.woocommerce-NoticeGroup-updateOrderReview, .woocommerce-NoticeGroup-checkout' );
|
||||
|
||||
if ( ! scrollElement.length ) {
|
||||
scrollElement = $( '.form.checkout' );
|
||||
}
|
||||
|
||||
if ( scrollElement.length ) {
|
||||
if ( isSmoothScrollSupported ) {
|
||||
scrollElement[0].scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
});
|
||||
} else {
|
||||
$( 'html, body' ).animate( {
|
||||
scrollTop: ( scrollElement.offset().top - 100 )
|
||||
}, 1000 );
|
||||
}
|
||||
}
|
||||
$.scroll_to_notices( scrollElement );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -26,4 +26,21 @@ jQuery( function( $ ) {
|
|||
} else {
|
||||
jQuery( '.woocommerce-store-notice' ).show();
|
||||
}
|
||||
|
||||
// Common scroll to element code.
|
||||
$.scroll_to_notices = function( scrollElement ) {
|
||||
var isSmoothScrollSupported = 'scrollBehavior' in document.documentElement.style;
|
||||
|
||||
if ( scrollElement.length ) {
|
||||
if ( isSmoothScrollSupported ) {
|
||||
scrollElement[0].scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
});
|
||||
} else {
|
||||
$( 'html, body' ).animate( {
|
||||
scrollTop: ( scrollElement.offset().top - 100 )
|
||||
}, 1000 );
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(o){o(".woocommerce-ordering").on("change","select.orderby",function(){o(this).closest("form").submit()}),o("input.qty:not(.product-quantity input.qty)").each(function(){var e=parseFloat(o(this).attr("min"));e>=0&&parseFloat(o(this).val())<e&&o(this).val(e)}),jQuery(".woocommerce-store-notice__dismiss-link").click(function(){Cookies.set("store_notice","hidden",{path:"/"}),jQuery(".woocommerce-store-notice").hide()}),"hidden"===Cookies.get("store_notice")?jQuery(".woocommerce-store-notice").hide():jQuery(".woocommerce-store-notice").show()});
|
||||
jQuery(function(o){o(".woocommerce-ordering").on("change","select.orderby",function(){o(this).closest("form").submit()}),o("input.qty:not(.product-quantity input.qty)").each(function(){var e=parseFloat(o(this).attr("min"));e>=0&&parseFloat(o(this).val())<e&&o(this).val(e)}),jQuery(".woocommerce-store-notice__dismiss-link").click(function(){Cookies.set("store_notice","hidden",{path:"/"}),jQuery(".woocommerce-store-notice").hide()}),"hidden"===Cookies.get("store_notice")?jQuery(".woocommerce-store-notice").hide():jQuery(".woocommerce-store-notice").show(),o.scroll_to_notices=function(e){var t="scrollBehavior"in document.documentElement.style;e.length&&(t?e[0].scrollIntoView({behavior:"smooth"}):o("html, body").animate({scrollTop:e.offset().top-100},1e3))}});
|
|
@ -231,7 +231,7 @@ class WC_Frontend_Scripts {
|
|||
),
|
||||
'wc-cart' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/cart' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'wc-country-select', 'wc-address-i18n' ),
|
||||
'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ),
|
||||
'version' => WC_VERSION,
|
||||
),
|
||||
'wc-cart-fragments' => array(
|
||||
|
|
Loading…
Reference in New Issue