Merge pull request #15792 from woocommerce/update/selectwoo
Integrate selectWoo
This commit is contained in:
commit
4c08be9320
|
@ -33,5 +33,6 @@ exclude_paths:
|
|||
- assets/js/prettyPhoto/*
|
||||
- assets/js/round/*
|
||||
- assets/js/select2/*
|
||||
- assets/js/selectWoo/*
|
||||
- assets/js/stupidtable/*
|
||||
- assets/js/zeroclipboard/*
|
||||
|
|
|
@ -85,7 +85,6 @@ module.exports = function( grunt ) {
|
|||
'<%= dirs.js %>/photoswipe/photoswipe.min.js': ['<%= dirs.js %>/photoswipe/photoswipe.js'],
|
||||
'<%= dirs.js %>/photoswipe/photoswipe-ui-default.min.js': ['<%= dirs.js %>/photoswipe/photoswipe-ui-default.js'],
|
||||
'<%= dirs.js %>/round/round.min.js': ['<%= dirs.js %>/round/round.js'],
|
||||
'<%= dirs.js %>/select2/select2.min.js': ['<%= dirs.js %>/select2/select2.js'],
|
||||
'<%= dirs.js %>/stupidtable/stupidtable.min.js': ['<%= dirs.js %>/stupidtable/stupidtable.js'],
|
||||
'<%= dirs.js %>/zeroclipboard/jquery.zeroclipboard.min.js': ['<%= dirs.js %>/zeroclipboard/jquery.zeroclipboard.js']
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -70,6 +70,7 @@
|
|||
padding: 6px;
|
||||
user-select: none;
|
||||
-webkit-user-select: none; }
|
||||
.select2-results__option[data-selected],
|
||||
.select2-results__option[aria-selected] {
|
||||
cursor: pointer; }
|
||||
|
||||
|
@ -264,6 +265,7 @@
|
|||
.select2-container--default .select2-results__option[aria-disabled=true] {
|
||||
color: #999; }
|
||||
|
||||
.select2-container--default .select2-results__option[data-selected=true],
|
||||
.select2-container--default .select2-results__option[aria-selected=true] {
|
||||
background-color: #ddd; }
|
||||
|
||||
|
@ -287,6 +289,7 @@
|
|||
margin-left: -5em;
|
||||
padding-left: 6em; }
|
||||
|
||||
.select2-container--default .select2-results__option--highlighted[data-selected],
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected] {
|
||||
background-color: #0073aa;
|
||||
color: white; }
|
||||
|
@ -463,6 +466,7 @@
|
|||
.select2-container--classic .select2-results__option[aria-disabled=true] {
|
||||
color: grey; }
|
||||
|
||||
.select2-container--classic .select2-results__option--highlighted[data-selected],
|
||||
.select2-container--classic .select2-results__option--highlighted[aria-selected] {
|
||||
background-color: #3875d7;
|
||||
color: white; }
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1014,7 +1014,7 @@ button.pswp__button--zoom:hover {
|
|||
.select2-results__options {
|
||||
background:#333;
|
||||
}
|
||||
.select2-results__option[aria-selected="true"]{
|
||||
.select2-results__option[data-selected="true"]{
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,7 @@ jQuery( function ( $ ) {
|
|||
this.states = $.parseJSON( woocommerce_admin_meta_boxes_order.countries.replace( /"/g, '"' ) );
|
||||
}
|
||||
|
||||
$( '.js_field-country' ).select2().change( this.change_country );
|
||||
$( '.js_field-country' ).selectWoo().change( this.change_country );
|
||||
$( '.js_field-country' ).trigger( 'change', [ true ] );
|
||||
$( document.body ).on( 'change', 'select.js_field-state', this.change_state );
|
||||
$( '#woocommerce-order-actions input, #woocommerce-order-actions a' ).click(function() {
|
||||
|
@ -66,7 +66,7 @@ jQuery( function ( $ ) {
|
|||
|
||||
$state.replaceWith( $states_select );
|
||||
|
||||
$states_select.show().select2().hide().change();
|
||||
$states_select.show().selectWoo().hide().change();
|
||||
} else {
|
||||
$state.replaceWith( '<input type="text" class="js_field-state" name="' + input_name + '" id="' + input_id + '" value="' + value + '" placeholder="' + placeholder + '" />' );
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,7 @@ jQuery( function ( $ ) {
|
|||
this.states = $.parseJSON( wc_users_params.countries.replace( /"/g, '"' ) );
|
||||
}
|
||||
|
||||
$( '.js_field-country' ).select2().change( this.change_country );
|
||||
$( '.js_field-country' ).selectWoo().change( this.change_country );
|
||||
$( '.js_field-country' ).trigger( 'change', [ true ] );
|
||||
$( document.body ).on( 'change', 'select.js_field-state', this.change_state );
|
||||
|
||||
|
@ -59,7 +59,7 @@ jQuery( function ( $ ) {
|
|||
|
||||
$state.replaceWith( $states_select );
|
||||
|
||||
$states_select.show().select2().hide().change();
|
||||
$states_select.show().selectWoo().hide().change();
|
||||
} else {
|
||||
$state.replaceWith( '<input type="text" class="js_field-state" name="' + input_name + '" id="' + input_id + '" value="' + value + '" />' );
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(e){var t={states:null,init:function(){"undefined"!=typeof wc_users_params.countries&&(this.states=e.parseJSON(wc_users_params.countries.replace(/"/g,'"'))),e(".js_field-country").select2().change(this.change_country),e(".js_field-country").trigger("change",[!0]),e(document.body).on("change","select.js_field-state",this.change_state),e(document.body).on("click","button.js_copy-billing",this.copy_billing)},change_country:function(a,n){if(void 0===n&&(n=!1),null!==t.states){var i=e(this),c=i.val(),s=i.parents(".form-table").find(":input.js_field-state"),o=s.parent(),l=s.attr("name"),r=s.attr("id"),u=i.data("woocommerce.stickState-"+c)?i.data("woocommerce.stickState-"+c):s.val();if(n&&i.data("woocommerce.stickState-"+c,u),o.show().find(".select2-container").remove(),e.isEmptyObject(t.states[c]))s.replaceWith('<input type="text" class="js_field-state" name="'+l+'" id="'+r+'" value="'+u+'" />');else{var d=e('<select name="'+l+'" id="'+r+'" class="js_field-state" style="width: 25em;"></select>'),p=t.states[c];d.append(e('<option value="">'+wc_users_params.i18n_select_state_text+"</option>")),e.each(p,function(t){d.append(e('<option value="'+t+'">'+p[t]+"</option>"))}),d.val(u),s.replaceWith(d),d.show().select2().hide().change()}e(document.body).trigger("contry-change.woocommerce",[c,e(this).closest("div")]),e(document.body).trigger("country-change.woocommerce",[c,e(this).closest("div")])}},change_state:function(){var t=e(this),a=t.val(),n=t.parents(".form-table").find(":input.js_field-country"),i=n.val();n.data("woocommerce.stickState-"+i,a)},copy_billing:function(t){t.preventDefault(),e("#fieldset-billing").find("input, select").each(function(t,a){var n=a.name.replace(/^billing_/,"shipping_"),i=e('[name="'+n+'"]');i.length&&i.val(a.value).trigger("change")})}};t.init()});
|
||||
jQuery(function(e){var t={states:null,init:function(){"undefined"!=typeof wc_users_params.countries&&(this.states=e.parseJSON(wc_users_params.countries.replace(/"/g,'"'))),e(".js_field-country").selectWoo().change(this.change_country),e(".js_field-country").trigger("change",[!0]),e(document.body).on("change","select.js_field-state",this.change_state),e(document.body).on("click","button.js_copy-billing",this.copy_billing)},change_country:function(a,n){if(void 0===n&&(n=!1),null!==t.states){var i=e(this),c=i.val(),s=i.parents(".form-table").find(":input.js_field-state"),o=s.parent(),l=s.attr("name"),r=s.attr("id"),u=i.data("woocommerce.stickState-"+c)?i.data("woocommerce.stickState-"+c):s.val();if(n&&i.data("woocommerce.stickState-"+c,u),o.show().find(".select2-container").remove(),e.isEmptyObject(t.states[c]))s.replaceWith('<input type="text" class="js_field-state" name="'+l+'" id="'+r+'" value="'+u+'" />');else{var d=e('<select name="'+l+'" id="'+r+'" class="js_field-state" style="width: 25em;"></select>'),p=t.states[c];d.append(e('<option value="">'+wc_users_params.i18n_select_state_text+"</option>")),e.each(p,function(t){d.append(e('<option value="'+t+'">'+p[t]+"</option>"))}),d.val(u),s.replaceWith(d),d.show().selectWoo().hide().change()}e(document.body).trigger("contry-change.woocommerce",[c,e(this).closest("div")]),e(document.body).trigger("country-change.woocommerce",[c,e(this).closest("div")])}},change_state:function(){var t=e(this),a=t.val(),n=t.parents(".form-table").find(":input.js_field-country"),i=n.val();n.data("woocommerce.stickState-"+i,a)},copy_billing:function(t){t.preventDefault(),e("#fieldset-billing").find("input, select").each(function(t,a){var n=a.name.replace(/^billing_/,"shipping_"),i=e('[name="'+n+'"]');i.length&&i.val(a.value).trigger("change")})}};t.init()});
|
|
@ -59,7 +59,7 @@ jQuery( function( $ ) {
|
|||
placeholder: $( this ).data( 'placeholder' )
|
||||
}, getEnhancedSelectFormatString() );
|
||||
|
||||
$( this ).select2( select2_args ).addClass( 'enhanced' );
|
||||
$( this ).selectWoo( select2_args ).addClass( 'enhanced' );
|
||||
});
|
||||
|
||||
$( ':input.wc-enhanced-select-nostd, :input.chosen_select_nostd' ).filter( ':not(.enhanced)' ).each( function() {
|
||||
|
@ -69,7 +69,7 @@ jQuery( function( $ ) {
|
|||
placeholder: $( this ).data( 'placeholder' )
|
||||
}, getEnhancedSelectFormatString() );
|
||||
|
||||
$( this ).select2( select2_args ).addClass( 'enhanced' );
|
||||
$( this ).selectWoo( select2_args ).addClass( 'enhanced' );
|
||||
});
|
||||
|
||||
// Ajax product search box
|
||||
|
@ -112,7 +112,7 @@ jQuery( function( $ ) {
|
|||
|
||||
select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
|
||||
|
||||
$( this ).select2( select2_args ).addClass( 'enhanced' );
|
||||
$( this ).selectWoo( select2_args ).addClass( 'enhanced' );
|
||||
|
||||
if ( $( this ).data( 'sortable' ) ) {
|
||||
var $select = $(this);
|
||||
|
@ -175,7 +175,7 @@ jQuery( function( $ ) {
|
|||
|
||||
select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
|
||||
|
||||
$( this ).select2( select2_args ).addClass( 'enhanced' );
|
||||
$( this ).selectWoo( select2_args ).addClass( 'enhanced' );
|
||||
|
||||
if ( $( this ).data( 'sortable' ) ) {
|
||||
var $select = $(this);
|
||||
|
@ -200,14 +200,14 @@ jQuery( function( $ ) {
|
|||
|
||||
// WooCommerce Backbone Modal
|
||||
.on( 'wc_backbone_modal_before_remove', function() {
|
||||
$( '.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search' ).filter( '.select2-hidden-accessible' ).select2( 'close' );
|
||||
$( '.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search' ).filter( '.select2-hidden-accessible' ).selectWoo( 'close' );
|
||||
})
|
||||
|
||||
.trigger( 'wc-enhanced-select-init' );
|
||||
|
||||
$( 'html' ).on( 'click', function( event ) {
|
||||
if ( this === event.target ) {
|
||||
$( '.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search' ).filter( '.select2-hidden-accessible' ).select2( 'close' );
|
||||
$( '.wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search' ).filter( '.select2-hidden-accessible' ).selectWoo( 'close' );
|
||||
}
|
||||
} );
|
||||
} catch( err ) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(e){function t(){return{language:{errorLoading:function(){return wc_enhanced_select_params.i18n_searching},inputTooLong:function(e){var t=e.input.length-e.maximum;return 1===t?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",t)},inputTooShort:function(e){var t=e.minimum-e.input.length;return 1===t?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",t)},loadingMore:function(){return wc_enhanced_select_params.i18n_load_more},maximumSelected:function(e){return 1===e.maximum?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",e.maximum)},noResults:function(){return wc_enhanced_select_params.i18n_no_matches},searching:function(){return wc_enhanced_select_params.i18n_searching}}}}try{e(document.body).on("wc-enhanced-select-init",function(){e(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var n=e.extend({minimumResultsForSearch:10,allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder")},t());e(this).select2(n).addClass("enhanced")}),e(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var n=e.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:e(this).data("placeholder")},t());e(this).select2(n).addClass("enhanced")}),e(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var n={allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(t){return{term:t.term,action:e(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:e(this).data("exclude"),include:e(this).data("include"),limit:e(this).data("limit")}},processResults:function(t){var n=[];return t&&e.each(t,function(e,t){n.push({id:e,text:t})}),{results:n}},cache:!0}};if(n=e.extend(n,t()),e(this).select2(n).addClass("enhanced"),e(this).data("sortable")){var c=e(this),a=e(this).next(".select2-container").find("ul.select2-selection__rendered");a.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){e(a.find(".select2-selection__choice").get().reverse()).each(function(){var t=e(this).data("data").id,n=c.find('option[value="'+t+'"]')[0];c.prepend(n)})}})}}),e(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var n={allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"1",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(t){return{term:t.term,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:e(this).data("exclude")}},processResults:function(t){var n=[];return t&&e.each(t,function(e,t){n.push({id:e,text:t})}),{results:n}},cache:!0}};if(n=e.extend(n,t()),e(this).select2(n).addClass("enhanced"),e(this).data("sortable")){var c=e(this),a=e(this).next(".select2-container").find("ul.select2-selection__rendered");a.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){e(a.find(".select2-selection__choice").get().reverse()).each(function(){var t=e(this).data("data").id,n=c.find('option[value="'+t+'"]')[0];c.prepend(n)})}})}})}).on("wc_backbone_modal_before_remove",function(){e(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").select2("close")}).trigger("wc-enhanced-select-init"),e("html").on("click",function(t){this===t.target&&e(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").select2("close")})}catch(n){window.console.log(n)}});
|
||||
jQuery(function(e){function t(){return{language:{errorLoading:function(){return wc_enhanced_select_params.i18n_searching},inputTooLong:function(e){var t=e.input.length-e.maximum;return 1===t?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",t)},inputTooShort:function(e){var t=e.minimum-e.input.length;return 1===t?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",t)},loadingMore:function(){return wc_enhanced_select_params.i18n_load_more},maximumSelected:function(e){return 1===e.maximum?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",e.maximum)},noResults:function(){return wc_enhanced_select_params.i18n_no_matches},searching:function(){return wc_enhanced_select_params.i18n_searching}}}}try{e(document.body).on("wc-enhanced-select-init",function(){e(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var n=e.extend({minimumResultsForSearch:10,allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder")},t());e(this).selectWoo(n).addClass("enhanced")}),e(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var n=e.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:e(this).data("placeholder")},t());e(this).selectWoo(n).addClass("enhanced")}),e(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var n={allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(t){return{term:t.term,action:e(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:e(this).data("exclude"),include:e(this).data("include"),limit:e(this).data("limit")}},processResults:function(t){var n=[];return t&&e.each(t,function(e,t){n.push({id:e,text:t})}),{results:n}},cache:!0}};if(n=e.extend(n,t()),e(this).selectWoo(n).addClass("enhanced"),e(this).data("sortable")){var c=e(this),a=e(this).next(".select2-container").find("ul.select2-selection__rendered");a.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){e(a.find(".select2-selection__choice").get().reverse()).each(function(){var t=e(this).data("data").id,n=c.find('option[value="'+t+'"]')[0];c.prepend(n)})}})}}),e(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var n={allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"1",escapeMarkup:function(e){return e},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",delay:250,data:function(t){return{term:t.term,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:e(this).data("exclude")}},processResults:function(t){var n=[];return t&&e.each(t,function(e,t){n.push({id:e,text:t})}),{results:n}},cache:!0}};if(n=e.extend(n,t()),e(this).selectWoo(n).addClass("enhanced"),e(this).data("sortable")){var c=e(this),a=e(this).next(".select2-container").find("ul.select2-selection__rendered");a.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){e(a.find(".select2-selection__choice").get().reverse()).each(function(){var t=e(this).data("data").id,n=c.find('option[value="'+t+'"]')[0];c.prepend(n)})}})}})}).on("wc_backbone_modal_before_remove",function(){e(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").selectWoo("close")}).trigger("wc-enhanced-select-init"),e("html").on("click",function(t){this===t.target&&e(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").selectWoo("close")})}catch(n){window.console.log(n)}});
|
File diff suppressed because one or more lines are too long
|
@ -52,7 +52,7 @@ jQuery( function( $ ) {
|
|||
}
|
||||
|
||||
// Select2 Enhancement if it exists
|
||||
if ( $().select2 ) {
|
||||
if ( $().selectWoo ) {
|
||||
var wc_country_select_select2 = function() {
|
||||
$( 'select.country_select:visible, select.state_select:visible' ).each( function() {
|
||||
var select2_args = $.extend({
|
||||
|
@ -60,7 +60,7 @@ jQuery( function( $ ) {
|
|||
width: '100%'
|
||||
}, getEnhancedSelectFormatString() );
|
||||
|
||||
$( this ).select2( select2_args );
|
||||
$( this ).selectWoo( select2_args );
|
||||
// Maintain focus after select https://github.com/select2/select2/issues/4384
|
||||
$( this ).on( 'select2:select', function() {
|
||||
$( this ).focus();
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(t){function e(){return{language:{errorLoading:function(){return wc_country_select_params.i18n_searching},inputTooLong:function(t){var e=t.input.length-t.maximum;return 1===e?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",e)},inputTooShort:function(t){var e=t.minimum-t.input.length;return 1===e?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",e)},loadingMore:function(){return wc_country_select_params.i18n_load_more},maximumSelected:function(t){return 1===t.maximum?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",t.maximum)},noResults:function(){return wc_country_select_params.i18n_no_matches},searching:function(){return wc_country_select_params.i18n_searching}}}}if("undefined"==typeof wc_country_select_params)return!1;if(t().select2){var n=function(){t("select.country_select:visible, select.state_select:visible").each(function(){var n=t.extend({placeholderOption:"first",width:"100%"},e());t(this).select2(n),t(this).on("select2:select",function(){t(this).focus()})})};n(),t(document.body).bind("country_to_state_changed",function(){n()})}var c=wc_country_select_params.countries.replace(/"/g,'"'),o=t.parseJSON(c);t(document.body).on("change","select.country_to_state, input.country_to_state",function(){var e=t(this).closest(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-shipping-calculator");e.length||(e=t(this).closest(".form-row").parent());var n=t(this).val(),c=e.find("#billing_state, #shipping_state, #calc_shipping_state"),i=c.parent(),a=c.attr("name"),r=c.attr("id"),s=c.val(),_=c.attr("placeholder")||c.attr("data-placeholder")||"";if(o[n])if(t.isEmptyObject(o[n]))c.parent().hide().find(".select2-container").remove(),c.replaceWith('<input type="hidden" class="hidden" name="'+a+'" id="'+r+'" value="" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]);else{var l="",u=o[n];for(var p in u)u.hasOwnProperty(p)&&(l=l+'<option value="'+p+'">'+u[p]+"</option>");c.parent().show(),c.is("input")&&(c.replaceWith('<select name="'+a+'" id="'+r+'" class="state_select" data-placeholder="'+_+'"></select>'),c=e.find("#billing_state, #shipping_state, #calc_shipping_state")),c.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+l),c.val(s).change(),t(document.body).trigger("country_to_state_changed",[n,e])}else c.is("select")?(i.show().find(".select2-container").remove(),c.replaceWith('<input type="text" class="input-text" name="'+a+'" id="'+r+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e])):c.is('input[type="hidden"]')&&(i.show().find(".select2-container").remove(),c.replaceWith('<input type="text" class="input-text" name="'+a+'" id="'+r+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]));t(document.body).trigger("country_to_state_changing",[n,e])}),t(function(){t(":input.country_to_state").change()})});
|
||||
jQuery(function(t){function e(){return{language:{errorLoading:function(){return wc_country_select_params.i18n_searching},inputTooLong:function(t){var e=t.input.length-t.maximum;return 1===e?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",e)},inputTooShort:function(t){var e=t.minimum-t.input.length;return 1===e?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",e)},loadingMore:function(){return wc_country_select_params.i18n_load_more},maximumSelected:function(t){return 1===t.maximum?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",t.maximum)},noResults:function(){return wc_country_select_params.i18n_no_matches},searching:function(){return wc_country_select_params.i18n_searching}}}}if("undefined"==typeof wc_country_select_params)return!1;if(t().selectWoo){var n=function(){t("select.country_select:visible, select.state_select:visible").each(function(){var n=t.extend({placeholderOption:"first",width:"100%"},e());t(this).selectWoo(n),t(this).on("select2:select",function(){t(this).focus()})})};n(),t(document.body).bind("country_to_state_changed",function(){n()})}var o=wc_country_select_params.countries.replace(/"/g,'"'),c=t.parseJSON(o);t(document.body).on("change","select.country_to_state, input.country_to_state",function(){var e=t(this).closest(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-shipping-calculator");e.length||(e=t(this).closest(".form-row").parent());var n=t(this).val(),o=e.find("#billing_state, #shipping_state, #calc_shipping_state"),i=o.parent(),a=o.attr("name"),r=o.attr("id"),s=o.val(),_=o.attr("placeholder")||o.attr("data-placeholder")||"";if(c[n])if(t.isEmptyObject(c[n]))o.parent().hide().find(".select2-container").remove(),o.replaceWith('<input type="hidden" class="hidden" name="'+a+'" id="'+r+'" value="" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]);else{var l="",u=c[n];for(var p in u)u.hasOwnProperty(p)&&(l=l+'<option value="'+p+'">'+u[p]+"</option>");o.parent().show(),o.is("input")&&(o.replaceWith('<select name="'+a+'" id="'+r+'" class="state_select" data-placeholder="'+_+'"></select>'),o=e.find("#billing_state, #shipping_state, #calc_shipping_state")),o.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+l),o.val(s).change(),t(document.body).trigger("country_to_state_changed",[n,e])}else o.is("select")?(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+a+'" id="'+r+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e])):o.is('input[type="hidden"]')&&(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+a+'" id="'+r+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]));t(document.body).trigger("country_to_state_changing",[n,e])}),t(function(){t(":input.country_to_state").change()})});
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -112,7 +112,8 @@ class WC_Admin_Assets {
|
|||
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
|
||||
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'select2' ), WC_VERSION );
|
||||
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.0' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
||||
wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array(
|
||||
'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
|
||||
|
|
|
@ -136,7 +136,7 @@ class WC_Admin_Settings {
|
|||
|
||||
do_action( 'woocommerce_settings_start' );
|
||||
|
||||
wp_enqueue_script( 'woocommerce_settings', WC()->plugin_url() . '/assets/js/admin/settings' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'select2' ), WC()->version, true );
|
||||
wp_enqueue_script( 'woocommerce_settings', WC()->plugin_url() . '/assets/js/admin/settings' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'selectWoo' ), WC()->version, true );
|
||||
|
||||
wp_localize_script( 'woocommerce_settings', 'woocommerce_settings_params', array(
|
||||
'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'woocommerce' ),
|
||||
|
|
|
@ -102,8 +102,8 @@ class WC_Admin_Setup_Wizard {
|
|||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
||||
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'select2' ), WC_VERSION );
|
||||
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.0' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
||||
wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array(
|
||||
'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
|
||||
|
|
|
@ -231,6 +231,11 @@ class WC_Frontend_Scripts {
|
|||
'deps' => array( 'jquery' ),
|
||||
'version' => '4.0.3',
|
||||
),
|
||||
'selectWoo' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/selectWoo/selectWoo.full' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery' ),
|
||||
'version' => '1.0.0',
|
||||
),
|
||||
'wc-address-i18n' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery' ),
|
||||
|
@ -367,7 +372,7 @@ class WC_Frontend_Scripts {
|
|||
self::enqueue_script( 'wc-cart' );
|
||||
}
|
||||
if ( is_checkout() || is_account_page() ) {
|
||||
self::enqueue_script( 'select2' );
|
||||
self::enqueue_script( 'selectWoo' );
|
||||
self::enqueue_style( 'select2' );
|
||||
|
||||
// Password strength meter. Load in checkout, account login and edit account page.
|
||||
|
|
Loading…
Reference in New Issue