plugin updates
This commit is contained in:
@@ -66,5 +66,37 @@ jQuery(function( $ ) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles warning about coupons using password protection.
|
||||
*/
|
||||
const wc_coupon_password_warning = {
|
||||
init: function() {
|
||||
const $warning = $( '#wc-password-protected-coupon-warning' );
|
||||
// Bail out early if necessary.
|
||||
if ( 0 === $warning.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $visibility = $( 'input[name="visibility"]' ),
|
||||
$password_visibility = $( '#visibility-radio-password' ),
|
||||
$password_label = $( 'label[for="visibility-radio-password"]' );
|
||||
|
||||
// For coupons without password, prevent setting it.
|
||||
if ( ! $password_visibility.is( ':checked' ) ) {
|
||||
$password_visibility.prop( 'disabled', true );
|
||||
$password_label.css( 'text-decoration', 'line-through' );
|
||||
return;
|
||||
}
|
||||
|
||||
$visibility.on(
|
||||
'change',
|
||||
function() {
|
||||
$warning.toggleClass( 'hidden', ! $password_visibility.is( ':checked' ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
wc_meta_boxes_coupon_actions.init();
|
||||
wc_coupon_password_warning.init();
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
jQuery(function(e){({init:function(){e("select#discount_type").on("change",this.type_options).trigger("change"),this.insert_generate_coupon_code_button(),e(".button.generate-coupon-code").on("click",this.generate_coupon_code)},type_options:function(){var o=e(this).val();"percent"===o?e("#coupon_amount").removeClass("wc_input_price").addClass("wc_input_decimal"):e("#coupon_amount").removeClass("wc_input_decimal").addClass("wc_input_price"),"fixed_cart"!==o?e(".limit_usage_to_x_items_field").show():e(".limit_usage_to_x_items_field").hide()},insert_generate_coupon_code_button:function(){e(".post-type-shop_coupon").find("#title").after('<a href="#" class="button generate-coupon-code">'+woocommerce_admin_meta_boxes_coupon.generate_button_text+"</a>")},generate_coupon_code:function(o){o.preventDefault();for(var t=e("#title"),n=e("#title-prompt-text"),_="",c=0;c<woocommerce_admin_meta_boxes_coupon.char_length;c++)_+=woocommerce_admin_meta_boxes_coupon.characters.charAt(Math.floor(Math.random()*woocommerce_admin_meta_boxes_coupon.characters.length));_=woocommerce_admin_meta_boxes_coupon.prefix+_+woocommerce_admin_meta_boxes_coupon.suffix,t.trigger("focus").val(_),n.addClass("screen-reader-text")}}).init()});
|
||||
jQuery(function(e){const o=function(){const o=e("#wc-password-protected-coupon-warning");if(0===o.length)return;const t=e('input[name="visibility"]'),n=e("#visibility-radio-password"),c=e('label[for="visibility-radio-password"]');if(!n.is(":checked"))return n.prop("disabled",!0),void c.css("text-decoration","line-through");t.on("change",function(){o.toggleClass("hidden",!n.is(":checked"))})};({init:function(){e("select#discount_type").on("change",this.type_options).trigger("change"),this.insert_generate_coupon_code_button(),e(".button.generate-coupon-code").on("click",this.generate_coupon_code)},type_options:function(){var o=e(this).val();"percent"===o?e("#coupon_amount").removeClass("wc_input_price").addClass("wc_input_decimal"):e("#coupon_amount").removeClass("wc_input_decimal").addClass("wc_input_price"),"fixed_cart"!==o?e(".limit_usage_to_x_items_field").show():e(".limit_usage_to_x_items_field").hide()},insert_generate_coupon_code_button:function(){e(".post-type-shop_coupon").find("#title").after('<a href="#" class="button generate-coupon-code">'+woocommerce_admin_meta_boxes_coupon.generate_button_text+"</a>")},generate_coupon_code:function(o){o.preventDefault();for(var t=e("#title"),n=e("#title-prompt-text"),c="",i=0;i<woocommerce_admin_meta_boxes_coupon.char_length;i++)c+=woocommerce_admin_meta_boxes_coupon.characters.charAt(Math.floor(Math.random()*woocommerce_admin_meta_boxes_coupon.characters.length));c=woocommerce_admin_meta_boxes_coupon.prefix+c+woocommerce_admin_meta_boxes_coupon.suffix,t.trigger("focus").val(c),n.addClass("screen-reader-text")}}).init(),o()});
|
||||
@@ -636,6 +636,7 @@ jQuery( function ( $ ) {
|
||||
} else {
|
||||
window.alert( response.data.error );
|
||||
}
|
||||
wc_meta_boxes_order.init_tiptip();
|
||||
wc_meta_boxes_order_items.unblock();
|
||||
});
|
||||
}
|
||||
@@ -664,6 +665,7 @@ jQuery( function ( $ ) {
|
||||
} else {
|
||||
window.alert( response.data.error );
|
||||
}
|
||||
wc_meta_boxes_order.init_tiptip();
|
||||
wc_meta_boxes_order_items.unblock();
|
||||
});
|
||||
|
||||
@@ -1435,6 +1437,12 @@ jQuery( function ( $ ) {
|
||||
.on( 'click', '#copy-download-link', this.copy_link )
|
||||
.on( 'aftercopy', '#copy-download-link', this.copy_success )
|
||||
.on( 'aftercopyfailure', '#copy-download-link', this.copy_fail );
|
||||
|
||||
// Work around WP's callback for '.handlediv' hiding the containing WP metabox instead of just the WC one.
|
||||
$( '.order_download_permissions .wc-metabox .handlediv' ).on( 'click', function( e ) {
|
||||
e.stopImmediatePropagation();
|
||||
$( this ).closest( 'h3' ).trigger( 'click' );
|
||||
} );
|
||||
},
|
||||
|
||||
grant_access: function() {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -90,11 +90,11 @@
|
||||
} );
|
||||
|
||||
// Edit prompt
|
||||
$( function () {
|
||||
function editPrompt () {
|
||||
var changed = false;
|
||||
let $check_column = $( '.wp-list-table .check-column' );
|
||||
|
||||
$( 'input, textarea, select, checkbox' ).on( 'change', function (
|
||||
$( 'input, textarea, select, checkbox' ).on( 'change input', function (
|
||||
event
|
||||
) {
|
||||
// Toggling WP List Table checkboxes should not trigger navigation warnings.
|
||||
@@ -110,6 +110,14 @@
|
||||
return params.i18n_nav_warning;
|
||||
};
|
||||
changed = true;
|
||||
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.iris-picker' ).on( 'click', function () {
|
||||
if ( ! changed ) {
|
||||
changed = true;
|
||||
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -119,8 +127,35 @@
|
||||
window.onbeforeunload = '';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$( editPrompt );
|
||||
|
||||
const nodeListContainsFormElements = ( nodes ) => {
|
||||
if ( ! nodes.length ) {
|
||||
return false;
|
||||
}
|
||||
return Array.from( nodes ).some( ( element ) => {
|
||||
return $( element ).find( 'input, textarea, select, checkbox' ).length;
|
||||
} );
|
||||
}
|
||||
|
||||
const form = document.querySelector( '#mainform' );
|
||||
const observer = new MutationObserver( ( mutationsList ) => {
|
||||
for ( const mutation of mutationsList ) {
|
||||
if ( mutation.type === 'childList' ) {
|
||||
if ( nodeListContainsFormElements( mutation.addedNodes ) ) {
|
||||
editPrompt();
|
||||
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
|
||||
} else if ( nodeListContainsFormElements( mutation.removedNodes ) ) {
|
||||
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
observer.observe( form, { childList: true, subtree: true } );
|
||||
|
||||
// Sorting
|
||||
$( 'table.wc_gateways tbody, table.wc_shipping tbody' ).sortable( {
|
||||
items: 'tr',
|
||||
@@ -140,7 +175,7 @@
|
||||
},
|
||||
stop: function ( event, ui ) {
|
||||
ui.item.removeAttr( 'style' );
|
||||
ui.item.trigger( 'updateMoveButtons' );
|
||||
ui.item.trigger( 'updateMoveButtons', { isInitialLoad: false } );
|
||||
},
|
||||
} );
|
||||
|
||||
@@ -192,12 +227,12 @@
|
||||
}
|
||||
|
||||
moveBtn.trigger( 'focus' ); // Re-focus after the container was moved.
|
||||
moveBtn.closest( 'table' ).trigger( 'updateMoveButtons' );
|
||||
moveBtn.closest( 'table' ).trigger( 'updateMoveButtons', { isInitialLoad: false } );
|
||||
} );
|
||||
|
||||
$( '.wc-item-reorder-nav' )
|
||||
.closest( 'table' )
|
||||
.on( 'updateMoveButtons', function () {
|
||||
.on( 'updateMoveButtons', function ( event, data ) {
|
||||
var table = $( this ),
|
||||
lastRow = $( this ).find( 'tbody tr:last' ),
|
||||
firstRow = $( this ).find( 'tbody tr:first' );
|
||||
@@ -214,11 +249,14 @@
|
||||
.find( '.wc-item-reorder-nav .wc-move-down' )
|
||||
.addClass( 'wc-move-disabled' )
|
||||
.attr( { tabindex: '-1', 'aria-hidden': 'true' } );
|
||||
if ( ! data.isInitialLoad ) {
|
||||
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.wc-item-reorder-nav' )
|
||||
.closest( 'table' )
|
||||
.trigger( 'updateMoveButtons' );
|
||||
.trigger( 'updateMoveButtons', { isInitialLoad: true } );
|
||||
|
||||
$( '.submit button' ).on( 'click', function () {
|
||||
if (
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -292,16 +292,49 @@
|
||||
'i18n_sale_less_than_regular_error',
|
||||
] );
|
||||
} else {
|
||||
$(
|
||||
document.body
|
||||
).triggerHandler( 'wc_remove_error_tip', [
|
||||
$( this ),
|
||||
'i18n_sale_less_than_regular_error',
|
||||
] );
|
||||
$( document.body ).triggerHandler(
|
||||
'wc_remove_error_tip',
|
||||
[ $( this ), 'i18n_sale_less_than_regular_error' ]
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
.on(
|
||||
'keyup',
|
||||
'input[type=text][name*=_global_unique_id]',
|
||||
function () {
|
||||
var global_unique_id = $( this ).val();
|
||||
|
||||
if ( /[^0-9\-]/.test( global_unique_id ) ) {
|
||||
$( document.body ).triggerHandler( 'wc_add_error_tip', [
|
||||
$( this ),
|
||||
'i18n_global_unique_id_error',
|
||||
] );
|
||||
} else {
|
||||
$( document.body ).triggerHandler(
|
||||
'wc_remove_error_tip',
|
||||
[ $( this ), 'i18n_global_unique_id_error' ]
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
.on(
|
||||
'change',
|
||||
'input[type=text][name*=_global_unique_id]',
|
||||
function () {
|
||||
var global_unique_id = $( this ).val();
|
||||
$( this ).val(
|
||||
global_unique_id.replace( /[^0-9\-]/g, '' )
|
||||
);
|
||||
$( document.body ).triggerHandler(
|
||||
'wc_remove_error_tip',
|
||||
[ $( this ), 'i18n_global_unique_id_error' ]
|
||||
);
|
||||
}
|
||||
)
|
||||
|
||||
.on( 'init_tooltips', function () {
|
||||
$( '.tips, .help_tip, .woocommerce-help-tip' ).tipTip( {
|
||||
attribute: 'data-tip',
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user