plugin updates
This commit is contained in:
@@ -230,7 +230,7 @@
|
||||
* 2nd parameter `precision` can be an object matching `settings.number`
|
||||
*/
|
||||
var formatNumber = lib.formatNumber = lib.format = function(number, precision, thousand, decimal) {
|
||||
// Resursively format arrays:
|
||||
// Recursively format arrays:
|
||||
if (isArray(number)) {
|
||||
return map(number, function(val) {
|
||||
return formatNumber(val, precision, thousand, decimal);
|
||||
@@ -275,7 +275,7 @@
|
||||
* To do: tidy up the parameters
|
||||
*/
|
||||
var formatMoney = lib.formatMoney = function(number, symbol, precision, thousand, decimal, format) {
|
||||
// Resursively format arrays:
|
||||
// Recursively format arrays:
|
||||
if (isArray(number)) {
|
||||
return map(number, function(val){
|
||||
return formatMoney(val, symbol, precision, thousand, decimal, format);
|
||||
@@ -315,7 +315,7 @@
|
||||
* List should be an array of numbers
|
||||
* Second parameter can be an object containing keys that match the params
|
||||
*
|
||||
* Returns array of accouting-formatted number strings of same length
|
||||
* Returns array of accounting-formatted number strings of the same length
|
||||
*
|
||||
* NB: `white-space:pre` CSS rule is required on the list container to prevent
|
||||
* browsers from collapsing the whitespace in the output strings.
|
||||
|
||||
@@ -39,7 +39,7 @@ jQuery(function( $ ) {
|
||||
},
|
||||
|
||||
/**
|
||||
* Insert generate coupon code buttom HTML.
|
||||
* Insert generate coupon code button HTML.
|
||||
*/
|
||||
insert_generate_coupon_code_button: function() {
|
||||
$( '.post-type-shop_coupon' ).find( '#title' ).after(
|
||||
|
||||
@@ -98,9 +98,10 @@
|
||||
event
|
||||
) {
|
||||
// Toggling WP List Table checkboxes should not trigger navigation warnings.
|
||||
// Theses checkboxes only select/unselect rows, they don't change the form.
|
||||
if (
|
||||
$check_column.length &&
|
||||
$check_column.has( event.target )
|
||||
$check_column.has( event.target ).length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,94 @@
|
||||
/* global wc_enhanced_select_params */
|
||||
/* global wpApiSettings */
|
||||
jQuery( function( $ ) {
|
||||
|
||||
function getEnhancedSelectFormatString() {
|
||||
return {
|
||||
'language': {
|
||||
errorLoading: function() {
|
||||
// Workaround for https://github.com/select2/select2/issues/4355 instead of i18n_ajax_error.
|
||||
return wc_enhanced_select_params.i18n_searching;
|
||||
},
|
||||
inputTooLong: function( args ) {
|
||||
var overChars = args.input.length - args.maximum;
|
||||
|
||||
if ( 1 === overChars ) {
|
||||
return wc_enhanced_select_params.i18n_input_too_long_1;
|
||||
}
|
||||
|
||||
return wc_enhanced_select_params.i18n_input_too_long_n.replace( '%qty%', overChars );
|
||||
},
|
||||
inputTooShort: function( args ) {
|
||||
var remainingChars = args.minimum - args.input.length;
|
||||
|
||||
if ( 1 === remainingChars ) {
|
||||
return wc_enhanced_select_params.i18n_input_too_short_1;
|
||||
}
|
||||
|
||||
return wc_enhanced_select_params.i18n_input_too_short_n.replace( '%qty%', remainingChars );
|
||||
},
|
||||
loadingMore: function() {
|
||||
return wc_enhanced_select_params.i18n_load_more;
|
||||
},
|
||||
maximumSelected: function( args ) {
|
||||
if ( args.maximum === 1 ) {
|
||||
return wc_enhanced_select_params.i18n_selection_too_long_1;
|
||||
}
|
||||
|
||||
return wc_enhanced_select_params.i18n_selection_too_long_n.replace( '%qty%', args.maximum );
|
||||
},
|
||||
noResults: function() {
|
||||
return wc_enhanced_select_params.i18n_no_matches;
|
||||
},
|
||||
searching: function() {
|
||||
return wc_enhanced_select_params.i18n_searching;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
$( document.body )
|
||||
.on( 'wc-enhanced-select-init', function() {
|
||||
// Ajax category search boxes
|
||||
$( ':input.wc-brands-search' ).filter( ':not(.enhanced)' ).each( function() {
|
||||
var select2_args = $.extend( {
|
||||
allowClear : $( this ).data( 'allow_clear' ) ? true : false,
|
||||
placeholder : $( this ).data( 'placeholder' ),
|
||||
minimumInputLength: $( this ).data( 'minimum_input_length' ) ? $( this ).data( 'minimum_input_length' ) : 3,
|
||||
escapeMarkup : function( m ) {
|
||||
return m;
|
||||
},
|
||||
ajax: {
|
||||
url: wpApiSettings.root + 'wc/v3/products/brands',
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
headers: {
|
||||
'X-WP-Nonce': wpApiSettings.nonce
|
||||
},
|
||||
data: function( params ) {
|
||||
return {
|
||||
hide_empty: 1,
|
||||
search: params.term
|
||||
};
|
||||
},
|
||||
processResults: function( data ) {
|
||||
const results = data
|
||||
.map( term => ({ id: term.slug, text: term.name + ' (' + term.count + ')' }) )
|
||||
return {
|
||||
results
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
}
|
||||
}, getEnhancedSelectFormatString() );
|
||||
|
||||
$( this ).selectWoo( select2_args ).addClass( 'enhanced' );
|
||||
});
|
||||
})
|
||||
.trigger( 'wc-enhanced-select-init' );
|
||||
} catch( err ) {
|
||||
// If select2 failed (conflict?) log the error but don't stop other scripts breaking.
|
||||
window.console.log( err );
|
||||
}
|
||||
});
|
||||
1
wp/wp-content/plugins/woocommerce/assets/js/admin/wc-brands-enhanced-select.min.js
vendored
Normal file
1
wp/wp-content/plugins/woocommerce/assets/js/admin/wc-brands-enhanced-select.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
jQuery(function(n){try{n(document.body).on("wc-enhanced-select-init",function(){n(":input.wc-brands-search").filter(":not(.enhanced)").each(function(){var e=n.extend({allowClear:!!n(this).data("allow_clear"),placeholder:n(this).data("placeholder"),minimumInputLength:n(this).data("minimum_input_length")?n(this).data("minimum_input_length"):3,escapeMarkup:function(n){return n},ajax:{url:wpApiSettings.root+"wc/v3/products/brands",dataType:"json",delay:250,headers:{"X-WP-Nonce":wpApiSettings.nonce},data:function(n){return{hide_empty:1,search:n.term}},processResults:function(n){return{results:n.map(n=>({id:n.slug,text:n.name+" ("+n.count+")"}))}},cache:!0}},{language:{errorLoading:function(){return wc_enhanced_select_params.i18n_searching},inputTooLong:function(n){var e=n.input.length-n.maximum;return 1===e?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",e)},inputTooShort:function(n){var e=n.minimum-n.input.length;return 1===e?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",e)},loadingMore:function(){return wc_enhanced_select_params.i18n_load_more},maximumSelected:function(n){return 1===n.maximum?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",n.maximum)},noResults:function(){return wc_enhanced_select_params.i18n_no_matches},searching:function(){return wc_enhanced_select_params.i18n_searching}}});n(this).selectWoo(e).addClass("enhanced")})}).trigger("wc-enhanced-select-init")}catch(e){window.console.log(e)}});
|
||||
@@ -995,7 +995,7 @@
|
||||
|
||||
// update slider.slides
|
||||
slider.slides = $(slider.vars.selector + ':not(.clone)', slider);
|
||||
// re-setup the slider to accomdate new slide
|
||||
// re-setup the slider to accommodate new slide
|
||||
slider.setup();
|
||||
|
||||
//FlexSlider: added() Callback
|
||||
@@ -1021,7 +1021,7 @@
|
||||
|
||||
// update slider.slides
|
||||
slider.slides = $(slider.vars.selector + ':not(.clone)', slider);
|
||||
// re-setup the slider to accomdate new slide
|
||||
// re-setup the slider to accommodate new slide
|
||||
slider.setup();
|
||||
|
||||
// FlexSlider: removed() Callback
|
||||
@@ -1091,7 +1091,7 @@
|
||||
itemWidth: 0, //{NEW} Integer: Box-model width of individual carousel items, including horizontal borders and padding.
|
||||
itemMargin: 0, //{NEW} Integer: Margin between carousel items.
|
||||
minItems: 1, //{NEW} Integer: Minimum number of carousel items that should be visible. Items will resize fluidly when below this.
|
||||
maxItems: 0, //{NEW} Integer: Maxmimum number of carousel items that should be visible. Items will resize fluidly when above this limit.
|
||||
maxItems: 0, //{NEW} Integer: Maximum number of carousel items that should be visible. Items will resize fluidly when above this limit.
|
||||
move: 0, //{NEW} Integer: Number of carousel items that should move on animation. If 0, slider will move all visible items.
|
||||
allowOneSlide: true, //{NEW} Boolean: Whether or not to allow a slider comprised of a single slide
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ jQuery( function ( $ ) {
|
||||
// Remove errors
|
||||
if ( ! preserve_notices ) {
|
||||
$(
|
||||
'.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success'
|
||||
'.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success, .coupon-error-notice'
|
||||
).remove();
|
||||
}
|
||||
|
||||
@@ -135,12 +135,30 @@ jQuery( function ( $ ) {
|
||||
if ( $( '.woocommerce-checkout' ).length ) {
|
||||
$( document.body ).trigger( 'update_checkout' );
|
||||
}
|
||||
|
||||
// Store the old coupon error message and value before the
|
||||
// .woocommerce-cart-form is replaced with the new form.
|
||||
var $old_coupon_field_val = $( '#coupon_code' ).val();
|
||||
var $old_coupon_error_msg = $( '#coupon_code' )
|
||||
.closest( '.coupon' )
|
||||
.find( '.coupon-error-notice' );
|
||||
|
||||
$( '.woocommerce-cart-form' ).replaceWith( $new_form );
|
||||
$( '.woocommerce-cart-form' )
|
||||
.find( ':input[name="update_cart"]' )
|
||||
.prop( 'disabled', true );
|
||||
|
||||
if ( preserve_notices && $old_coupon_error_msg.length > 0 ) {
|
||||
var $new_coupon_field = $( '.woocommerce-cart-form' ).find( '#coupon_code' );
|
||||
var $new_coupon_field_wrapper = $new_coupon_field.closest( '.coupon' );
|
||||
|
||||
$new_coupon_field.val( $old_coupon_field_val );
|
||||
// The coupon input with error needs to be focused before adding the live region
|
||||
// with the error message, otherwise the screen reader won't read it.
|
||||
$new_coupon_field.focus();
|
||||
show_coupon_error( $old_coupon_error_msg, $new_coupon_field_wrapper, true );
|
||||
}
|
||||
|
||||
if ( $notices.length > 0 ) {
|
||||
show_notice( $notices );
|
||||
}
|
||||
@@ -176,6 +194,43 @@ jQuery( function ( $ ) {
|
||||
$target.prepend( html_element );
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows coupon form errors.
|
||||
*
|
||||
* @param {string|object} html_element The HTML string response after applying an invalid coupon or a jQuery element.
|
||||
* @param {Object} $target Coupon field wrapper jQuery element.
|
||||
* @param {boolean} is_live_region Whether role="alert" should be added or not.
|
||||
*/
|
||||
var show_coupon_error = function ( html_element, $target, is_live_region ) {
|
||||
if ( $target.length === 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $coupon_error_el = '';
|
||||
|
||||
if ( typeof html_element === 'string' ) {
|
||||
var msg = $( $.parseHTML( html_element ) ).text().trim();
|
||||
|
||||
if ( msg === '' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$coupon_error_el = $( '<p class="coupon-error-notice" id="coupon-error-notice">' + msg + '</p>' );
|
||||
} else {
|
||||
$coupon_error_el = html_element;
|
||||
}
|
||||
|
||||
if ( is_live_region ) {
|
||||
$coupon_error_el.attr( 'role', 'alert' );
|
||||
}
|
||||
|
||||
$target.find( '#coupon_code' )
|
||||
.addClass( 'has-error' )
|
||||
.attr( 'aria-invalid', 'true' )
|
||||
.attr( 'aria-describedby', 'coupon-error-notice' );
|
||||
$target.append( $coupon_error_el );
|
||||
};
|
||||
|
||||
/**
|
||||
* Object to handle AJAX calls for cart shipping changes.
|
||||
*/
|
||||
@@ -315,6 +370,7 @@ jQuery( function ( $ ) {
|
||||
this.apply_coupon = this.apply_coupon.bind( this );
|
||||
this.remove_coupon_clicked =
|
||||
this.remove_coupon_clicked.bind( this );
|
||||
this.remove_coupon_error = this.remove_coupon_error.bind( this );
|
||||
this.quantity_update = this.quantity_update.bind( this );
|
||||
this.item_remove_clicked = this.item_remove_clicked.bind( this );
|
||||
this.item_restore_clicked = this.item_restore_clicked.bind( this );
|
||||
@@ -358,6 +414,11 @@ jQuery( function ( $ ) {
|
||||
'.woocommerce-cart-form .cart_item :input',
|
||||
this.input_changed
|
||||
);
|
||||
$( document ).on(
|
||||
'blur change input',
|
||||
'#coupon_code',
|
||||
this.remove_coupon_error
|
||||
);
|
||||
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop(
|
||||
'disabled',
|
||||
@@ -525,16 +586,28 @@ jQuery( function ( $ ) {
|
||||
dataType: 'html',
|
||||
success: function ( response ) {
|
||||
$(
|
||||
'.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success'
|
||||
'.woocommerce-error, .woocommerce-message, .woocommerce-info, ' +
|
||||
'.is-error, .is-info, .is-success, .coupon-error-notice'
|
||||
).remove();
|
||||
show_notice( response );
|
||||
|
||||
// We only want to show coupon notices if they are not errors.
|
||||
// Coupon errors are shown under the input.
|
||||
if ( response.indexOf( 'woocommerce-error' ) === -1 && response.indexOf( 'is-error' ) === -1 ) {
|
||||
show_notice( response );
|
||||
} else {
|
||||
var $coupon_wrapper = $text_field.closest( '.coupon' );
|
||||
|
||||
if ( $coupon_wrapper.length > 0 ) {
|
||||
show_coupon_error( response, $coupon_wrapper, false );
|
||||
}
|
||||
}
|
||||
|
||||
$( document.body ).trigger( 'applied_coupon', [
|
||||
coupon_code,
|
||||
] );
|
||||
},
|
||||
complete: function () {
|
||||
unblock( $form );
|
||||
$text_field.val( '' );
|
||||
cart.update_cart( true );
|
||||
},
|
||||
} );
|
||||
@@ -578,6 +651,21 @@ jQuery( function ( $ ) {
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle when the coupon input loses focus.
|
||||
*
|
||||
* @param {Object} evt The JQuery event
|
||||
*/
|
||||
remove_coupon_error: function ( evt ) {
|
||||
$( evt.currentTarget )
|
||||
.removeClass( 'has-error' )
|
||||
.removeAttr( 'aria-invalid' )
|
||||
.removeAttr( 'aria-describedby' )
|
||||
.closest( '.coupon' )
|
||||
.find( '.coupon-error-notice' )
|
||||
.remove();
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle a cart Quantity Update
|
||||
*
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -535,7 +535,8 @@ jQuery( function( $ ) {
|
||||
wc_checkout_form.detachUnloadEventsOnSubmit();
|
||||
|
||||
try {
|
||||
if ( 'success' === result.result && $form.triggerHandler( 'checkout_place_order_success', [ result, wc_checkout_form ] ) !== false ) {
|
||||
if ( 'success' === result.result &&
|
||||
$form.triggerHandler( 'checkout_place_order_success', [ result, wc_checkout_form ] ) !== false ) {
|
||||
if ( -1 === result.redirect.indexOf( 'https://' ) || -1 === result.redirect.indexOf( 'http://' ) ) {
|
||||
window.location = result.redirect;
|
||||
} else {
|
||||
@@ -614,7 +615,8 @@ jQuery( function( $ ) {
|
||||
init: function() {
|
||||
$( document.body ).on( 'click', 'a.showcoupon', this.show_coupon_form );
|
||||
$( document.body ).on( 'click', '.woocommerce-remove-coupon', this.remove_coupon );
|
||||
$( 'form.checkout_coupon' ).hide().on( 'submit', this.submit );
|
||||
$( document.body ).on( 'blur change input', '#coupon_code', this.remove_coupon_error );
|
||||
$( 'form.checkout_coupon' ).hide().on( 'submit', this.submit.bind( this ) );
|
||||
},
|
||||
show_coupon_form: function() {
|
||||
$( '.checkout_coupon' ).slideToggle( 400, function() {
|
||||
@@ -622,8 +624,36 @@ jQuery( function( $ ) {
|
||||
});
|
||||
return false;
|
||||
},
|
||||
submit: function() {
|
||||
var $form = $( this );
|
||||
show_coupon_error: function( html_element, $target ) {
|
||||
if ( $target.length === 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var msg = $( $.parseHTML( html_element ) ).text().trim();
|
||||
|
||||
if ( msg === '' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$target.find( '#coupon_code' )
|
||||
.focus()
|
||||
.addClass( 'has-error' )
|
||||
.attr( 'aria-invalid', 'true' )
|
||||
.attr( 'aria-describedby', 'coupon-error-notice' );
|
||||
$target.append( '<span class="coupon-error-notice" id="coupon-error-notice" role="alert">' + msg + '</span>' );
|
||||
},
|
||||
remove_coupon_error: function( evt ) {
|
||||
$( evt.currentTarget )
|
||||
.removeClass( 'has-error' )
|
||||
.removeAttr( 'aria-invalid' )
|
||||
.removeAttr( 'aria-describedby' )
|
||||
.next( '.coupon-error-notice' )
|
||||
.remove();
|
||||
},
|
||||
submit: function( evt ) {
|
||||
var $form = $( evt.currentTarget );
|
||||
var $coupon_field = $form.find( '#coupon_code' );
|
||||
var self = this;
|
||||
|
||||
if ( $form.is( '.processing' ) ) {
|
||||
return false;
|
||||
@@ -647,13 +677,20 @@ jQuery( function( $ ) {
|
||||
type: 'POST',
|
||||
url: wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'apply_coupon' ),
|
||||
data: data,
|
||||
success: function( code ) {
|
||||
success: function( response ) {
|
||||
$( '.woocommerce-error, .woocommerce-message, .is-error, .is-success' ).remove();
|
||||
$form.removeClass( 'processing' ).unblock();
|
||||
|
||||
if ( code ) {
|
||||
$form.before( code );
|
||||
$form.slideUp();
|
||||
if ( response ) {
|
||||
// We only want to show coupon notices if they are no errors.
|
||||
// Coupon errors are shown under the input.
|
||||
if ( response.indexOf( 'woocommerce-error' ) === -1 && response.indexOf( 'is-error' ) === -1 ) {
|
||||
$form.slideUp( 400, function() {
|
||||
$form.before( response );
|
||||
} );
|
||||
} else {
|
||||
self.show_coupon_error( response, $coupon_field.parent() );
|
||||
}
|
||||
|
||||
$( document.body ).trigger( 'applied_coupon_in_checkout', [ data.coupon_code ] );
|
||||
$( document.body ).trigger( 'update_checkout', { update_shipping_method: false } );
|
||||
@@ -699,6 +736,7 @@ jQuery( function( $ ) {
|
||||
|
||||
// Remove coupon code from coupon field
|
||||
$( 'form.checkout_coupon' ).find( 'input[name="coupon_code"]' ).val( '' );
|
||||
$( 'form.checkout_coupon' ).slideUp();
|
||||
}
|
||||
},
|
||||
error: function ( jqXHR ) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -57,7 +57,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Determin whether sourcebuster.js is available.
|
||||
* Determine whether sourcebuster.js is available.
|
||||
*
|
||||
* @returns {boolean} Whether sourcebuster.js is available.
|
||||
*/
|
||||
|
||||
@@ -127,6 +127,8 @@ jQuery( function( $ ) {
|
||||
this.onResetSlidePosition = this.onResetSlidePosition.bind( this );
|
||||
this.getGalleryItems = this.getGalleryItems.bind( this );
|
||||
this.openPhotoswipe = this.openPhotoswipe.bind( this );
|
||||
this.trapFocusPhotoswipe = this.trapFocusPhotoswipe.bind( this );
|
||||
this.handlePswpTrapFocus = this.handlePswpTrapFocus.bind( this );
|
||||
|
||||
if ( this.flexslider_enabled ) {
|
||||
this.initFlexslider( args.flexslider );
|
||||
@@ -307,8 +309,10 @@ jQuery( function( $ ) {
|
||||
e.preventDefault();
|
||||
|
||||
var pswpElement = $( '.pswp' )[0],
|
||||
items = this.getGalleryItems(),
|
||||
eventTarget = $( e.target ),
|
||||
items = this.getGalleryItems(),
|
||||
eventTarget = $( e.target ),
|
||||
currentTarget = e.currentTarget,
|
||||
self = this,
|
||||
clicked;
|
||||
|
||||
if ( 0 < eventTarget.closest( '.woocommerce-product-gallery__trigger' ).length ) {
|
||||
@@ -326,14 +330,73 @@ jQuery( function( $ ) {
|
||||
}
|
||||
captionEl.children[0].textContent = item.title;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
timeToIdle: 0, // Ensure the gallery controls are always visible to avoid keyboard navigation issues.
|
||||
}, wc_single_product_params.photoswipe_options );
|
||||
|
||||
// Initializes and opens PhotoSwipe.
|
||||
var photoswipe = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options );
|
||||
|
||||
photoswipe.listen( 'afterInit', function() {
|
||||
self.trapFocusPhotoswipe( true );
|
||||
});
|
||||
|
||||
photoswipe.listen( 'close', function() {
|
||||
self.trapFocusPhotoswipe( false );
|
||||
currentTarget.focus();
|
||||
});
|
||||
|
||||
photoswipe.init();
|
||||
};
|
||||
|
||||
/**
|
||||
* Control focus in photoswipe modal.
|
||||
*
|
||||
* @param {boolean} trapFocus - Whether to trap focus or not.
|
||||
*/
|
||||
ProductGallery.prototype.trapFocusPhotoswipe = function( trapFocus ) {
|
||||
var pswp = document.querySelector( '.pswp' );
|
||||
|
||||
if ( ! pswp ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( trapFocus ) {
|
||||
pswp.addEventListener( 'keydown', this.handlePswpTrapFocus );
|
||||
} else {
|
||||
pswp.removeEventListener( 'keydown', this.handlePswpTrapFocus );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle keydown event in photoswipe modal.
|
||||
*/
|
||||
ProductGallery.prototype.handlePswpTrapFocus = function( e ) {
|
||||
var allFocusablesEls = e.currentTarget.querySelectorAll( 'button:not([disabled])' );
|
||||
var filteredFocusablesEls = Array.from( allFocusablesEls ).filter( function( btn ) {
|
||||
return btn.style.display !== 'none' && window.getComputedStyle( btn ).display !== 'none';
|
||||
} );
|
||||
|
||||
if ( 1 >= filteredFocusablesEls.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var firstTabStop = filteredFocusablesEls[0];
|
||||
var lastTabStop = filteredFocusablesEls[filteredFocusablesEls.length - 1];
|
||||
|
||||
if ( e.key === 'Tab' ) {
|
||||
if ( e.shiftKey ) {
|
||||
if ( document.activeElement === firstTabStop ) {
|
||||
e.preventDefault();
|
||||
lastTabStop.focus();
|
||||
}
|
||||
} else if ( document.activeElement === lastTabStop ) {
|
||||
e.preventDefault();
|
||||
firstTabStop.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to call wc_product_gallery on jquery selector.
|
||||
*/
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -148,7 +148,14 @@ jQuery( function ( $ ) {
|
||||
} );
|
||||
});
|
||||
|
||||
document.addEventListener( 'DOMContentLoaded' , function() {
|
||||
/**
|
||||
* Focus on the first notice element on the page.
|
||||
*
|
||||
* Populated live regions don't always are announced by screen readers.
|
||||
* This function focus on the first notice message with the role="alert"
|
||||
* attribute to make sure it's announced.
|
||||
*/
|
||||
function focus_populate_live_region() {
|
||||
var noticeClasses = [ 'woocommerce-message', 'woocommerce-error', 'wc-block-components-notice-banner' ];
|
||||
var noticeSelectors = noticeClasses.map( function( className ) {
|
||||
return '.' + className + '[role="alert"]';
|
||||
@@ -168,4 +175,28 @@ document.addEventListener( 'DOMContentLoaded' , function() {
|
||||
firstNotice.focus();
|
||||
clearTimeout( delayFocusNoticeId );
|
||||
}, 500 );
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the sorted by live region.
|
||||
*/
|
||||
function refresh_sorted_by_live_region () {
|
||||
var sorted_by_live_region = document.querySelector( '.woocommerce-result-count[data-is-sorted-by="true"]' );
|
||||
|
||||
if ( sorted_by_live_region ) {
|
||||
var text = sorted_by_live_region.innerHTML;
|
||||
|
||||
var sorted_by_live_region_id = setTimeout( function() {
|
||||
sorted_by_live_region.innerHTML = '';
|
||||
sorted_by_live_region.innerHTML = text;
|
||||
clearTimeout( sorted_by_live_region_id );
|
||||
}, 1000 );
|
||||
}
|
||||
}
|
||||
|
||||
function on_document_ready() {
|
||||
focus_populate_live_region();
|
||||
refresh_sorted_by_live_region();
|
||||
}
|
||||
|
||||
document.addEventListener( 'DOMContentLoaded' , on_document_ready );
|
||||
|
||||
@@ -1 +1 @@
|
||||
jQuery(function(o){o(".woocommerce-ordering").on("change","select.orderby",function(){o(this).closest("form").trigger("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)});var e="store_notice"+(o(".woocommerce-store-notice").data("noticeId")||"");"hidden"===Cookies.get(e)?o(".woocommerce-store-notice").hide():o(".woocommerce-store-notice").show(),o(".woocommerce-store-notice__dismiss-link").on("click",function(t){Cookies.set(e,"hidden",{path:"/"}),o(".woocommerce-store-notice").hide(),t.preventDefault()}),o(".woocommerce-input-wrapper span.description").length&&o(document.body).on("click",function(){o(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),o(".woocommerce-input-wrapper").on("click",function(o){o.stopPropagation()}),o(".woocommerce-input-wrapper :input").on("keydown",function(e){var t=o(this).parent().find("span.description");if(27===e.which&&t.length&&t.is(":visible"))return t.prop("aria-hidden",!0).slideUp(250),e.preventDefault(),!1}).on("click focus",function(){var e=o(this).parent(),t=e.find("span.description");e.addClass("currentTarget"),o(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),t.length&&t.is(":hidden")&&t.prop("aria-hidden",!1).slideDown(250),e.removeClass("currentTarget")}),o.scroll_to_notices=function(e){e.length&&o("html, body").animate({scrollTop:e.offset().top-100},1e3)},o('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'),o(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),o(".password-input").append('<span class="show-password-input"></span>'),o(".show-password-input").on("click",function(){o(this).hasClass("display-password")?o(this).removeClass("display-password"):o(this).addClass("display-password"),o(this).hasClass("display-password")?o(this).siblings(['input[type="password"]']).prop("type","text"):o(this).siblings('input[type="text"]').prop("type","password")}),o("a.coming-soon-footer-banner-dismiss").on("click",function(e){var t=o(e.target);o.ajax({type:"post",url:t.data("rest-url"),data:{woocommerce_meta:{coming_soon_banner_dismissed:"yes"}},beforeSend:function(o){o.setRequestHeader("X-WP-Nonce",t.data("rest-nonce"))},complete:function(){o("#coming-soon-footer-banner").hide()}})})}),document.addEventListener("DOMContentLoaded",function(){var o=["woocommerce-message","woocommerce-error","wc-block-components-notice-banner"].map(function(o){return"."+o+'[role="alert"]'}).join(", "),e=document.querySelectorAll(o);if(0!==e.length){var t=e[0];t.setAttribute("tabindex","-1");var n=setTimeout(function(){t.focus(),clearTimeout(n)},500)}});
|
||||
function focus_populate_live_region(){var e=["woocommerce-message","woocommerce-error","wc-block-components-notice-banner"].map(function(e){return"."+e+'[role="alert"]'}).join(", "),o=document.querySelectorAll(e);if(0!==o.length){var t=o[0];t.setAttribute("tabindex","-1");var n=setTimeout(function(){t.focus(),clearTimeout(n)},500)}}function refresh_sorted_by_live_region(){var e=document.querySelector('.woocommerce-result-count[data-is-sorted-by="true"]');if(e)var o=e.innerHTML,t=setTimeout(function(){e.innerHTML="",e.innerHTML=o,clearTimeout(t)},1e3)}function on_document_ready(){focus_populate_live_region(),refresh_sorted_by_live_region()}jQuery(function(e){e(".woocommerce-ordering").on("change","select.orderby",function(){e(this).closest("form").trigger("submit")}),e("input.qty:not(.product-quantity input.qty)").each(function(){var o=parseFloat(e(this).attr("min"));o>=0&&parseFloat(e(this).val())<o&&e(this).val(o)});var o="store_notice"+(e(".woocommerce-store-notice").data("noticeId")||"");"hidden"===Cookies.get(o)?e(".woocommerce-store-notice").hide():e(".woocommerce-store-notice").show(),e(".woocommerce-store-notice__dismiss-link").on("click",function(t){Cookies.set(o,"hidden",{path:"/"}),e(".woocommerce-store-notice").hide(),t.preventDefault()}),e(".woocommerce-input-wrapper span.description").length&&e(document.body).on("click",function(){e(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),e(".woocommerce-input-wrapper").on("click",function(e){e.stopPropagation()}),e(".woocommerce-input-wrapper :input").on("keydown",function(o){var t=e(this).parent().find("span.description");if(27===o.which&&t.length&&t.is(":visible"))return t.prop("aria-hidden",!0).slideUp(250),o.preventDefault(),!1}).on("click focus",function(){var o=e(this).parent(),t=o.find("span.description");o.addClass("currentTarget"),e(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),t.length&&t.is(":hidden")&&t.prop("aria-hidden",!1).slideDown(250),o.removeClass("currentTarget")}),e.scroll_to_notices=function(o){o.length&&e("html, body").animate({scrollTop:o.offset().top-100},1e3)},e('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'),e(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),e(".password-input").append('<span class="show-password-input"></span>'),e(".show-password-input").on("click",function(){e(this).hasClass("display-password")?e(this).removeClass("display-password"):e(this).addClass("display-password"),e(this).hasClass("display-password")?e(this).siblings(['input[type="password"]']).prop("type","text"):e(this).siblings('input[type="text"]').prop("type","password")}),e("a.coming-soon-footer-banner-dismiss").on("click",function(o){var t=e(o.target);e.ajax({type:"post",url:t.data("rest-url"),data:{woocommerce_meta:{coming_soon_banner_dismissed:"yes"}},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",t.data("rest-nonce"))},complete:function(){e("#coming-soon-footer-banner").hide()}})})}),document.addEventListener("DOMContentLoaded",on_document_ready);
|
||||
@@ -191,7 +191,7 @@
|
||||
// enable if you want key and mouse events to be disabled for content that is blocked
|
||||
bindEvents: true,
|
||||
|
||||
// be default blockUI will supress tab navigation from leaving blocking content
|
||||
// by default blockUI will suppress tab navigation from leaving blocking content
|
||||
// (if bindEvents is true)
|
||||
constrainTabKey: true,
|
||||
|
||||
@@ -286,7 +286,7 @@
|
||||
var z = opts.baseZ;
|
||||
|
||||
// blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
|
||||
// layer1 is the iframe layer which is used to supress bleed through of underlying content
|
||||
// layer1 is the iframe layer which is used to suppress bleed through of underlying content
|
||||
// layer2 is the overlay layer which has opacity and a wait cursor (by default)
|
||||
// layer3 is the message content that is displayed while blocking
|
||||
var lyr1, lyr2, lyr3, s;
|
||||
|
||||
@@ -705,7 +705,7 @@ var PhotoSwipeUI_Default =
|
||||
}, 50);
|
||||
}
|
||||
|
||||
// toogle pswp--fs class on root element
|
||||
// toggle pswp--fs class on root element
|
||||
framework[ (_fullscrenAPI.isFullscreen() ? 'add' : 'remove') + 'Class' ](pswp.template, 'pswp--fs');
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user