PHP 8.2.31
Preview: users.js Size: 3.78 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/assets/js/admin/users.js

/*global wc_users_params */
jQuery( function ( $ ) {

	/**
	 * Users country and state fields
	 */
	var wc_users_fields = {
		states: null,
		init: function() {
			if ( typeof wc_users_params.countries !== 'undefined' ) {
				/* State/Country select boxes */
				this.states = JSON.parse( wc_users_params.countries.replace( /"/g, '"' ) );
			}

			$( '.js_field-country' ).selectWoo().on( 'change', this.change_country );
			$( '.js_field-country' ).trigger( 'change', [ true ] );
			$( document.body ).on( 'change', 'select.js_field-state', this.change_state );

			$( document.body ).on( 'click', 'button.js_copy-billing', this.copy_billing );
		},

		change_country: function( e, stickValue ) {
			// Check for stickValue before using it
			if ( typeof stickValue === 'undefined' ) {
				stickValue = false;
			}

			// Prevent if we don't have the metabox data
			if ( wc_users_fields.states === null ) {
				return;
			}

			var $this = $( this ),
				country = $this.val(),
				$state = $this.parents( '.form-table' ).find( ':input.js_field-state' ),
				$parent = $state.parent(),
				input_name = $state.attr( 'name' ),
				input_id = $state.attr( 'id' ),
				stickstatefield = 'woocommerce.stickState-' + country,
				value = $this.data( stickstatefield ) ? $this.data( stickstatefield ) : $state.val(),
				placeholder = $state.attr( 'placeholder' ),
				$newstate;

			if ( stickValue ){
				$this.data( 'woocommerce.stickState-' + country, value );
			}

			// Remove the previous DOM element
			$parent.show().find( '.select2-container' ).remove();

			if ( ! $.isEmptyObject( wc_users_fields.states[ country ] ) ) {
				var state          = wc_users_fields.states[ country ],
					$defaultOption = $( '<option value=""></option>' )
						.text( wc_users_fields.i18n_select_state_text );

				$newstate = $( '<select style="width: 25em;"></select>' )
					.prop( 'id', input_id )
					.prop( 'name', input_name )
					.prop( 'placeholder', placeholder )
					.addClass( 'js_field-state' )
					.append( $defaultOption );

				$.each( state, function( index ) {
					var $option = $( '<option></option>' )
						.prop( 'value', index )
						.text( state[ index ] );
					$newstate.append( $option );
				} );

				$newstate.val( value );

				$state.replaceWith( $newstate );

				$newstate.show().selectWoo().hide().trigger( 'change' );
			} else {
				$newstate = $( '<input type="text" />' )
					.prop( 'id', input_id )
					.prop( 'name', input_name )
					.prop( 'placeholder', placeholder )
					.addClass( 'js_field-state regular-text' )
					.val( value );
				$state.replaceWith( $newstate );
			}

			// This event has a typo - deprecated in 2.5.0
			$( document.body ).trigger( 'contry-change.woocommerce', [country, $( this ).closest( 'div' )] );
			$( document.body ).trigger( 'country-change.woocommerce', [country, $( this ).closest( 'div' )] );
		},

		change_state: function() {
			// Here we will find if state value on a select has changed and stick it to the country data
			var $this = $( this ),
				state    = $this.val(),
				$country = $this.parents( '.form-table' ).find( ':input.js_field-country' ),
				country  = $country.val();

			$country.data( 'woocommerce.stickState-' + country, state );
		},

		copy_billing: function( event ) {
			event.preventDefault();

			$( '#fieldset-billing' ).find( 'input, select' ).each( function( i, el ) {
				// The address keys match up, except for the prefix
				var shipName = el.name.replace( /^billing_/, 'shipping_' );
				// Swap prefix, then check if there are any elements
				var shipEl = $( '[name="' + shipName + '"]' );
				// No corresponding shipping field, skip this item
				if ( ! shipEl.length ) {
					return;
				}
				// Found a matching shipping element, update the value
				shipEl.val( el.value ).trigger( 'change' );
			} );
		}
	};

	wc_users_fields.init();

});

Directory Contents

Dirs: 0 × Files: 70

Name Size Perms Modified Actions
3.89 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
2.23 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
4.35 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
2.77 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
16.84 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
6.66 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
2.99 KB lrw-r--r-- 2025-04-01 15:51:36
Edit Download
1.61 KB lrw-r--r-- 2025-04-01 15:51:36
Edit Download
54.51 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
33.12 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
42.26 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
22.55 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
37.39 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
19.50 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
4.95 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
3.02 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
2.34 KB lrw-r--r-- 2018-05-23 19:30:10
Edit Download
1.25 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
1.16 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
730 B lrw-r--r-- 2023-12-27 00:45:02
Edit Download
696 B lrw-r--r-- 2025-07-29 12:34:58
Edit Download
298 B lrw-r--r-- 2025-07-29 12:34:58
Edit Download
2.60 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
1.66 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
7.06 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
4.58 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
5.39 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
2.70 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
12.04 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
6.08 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
11.95 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
6.25 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
5.38 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.08 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
4.62 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
2.52 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.78 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
1.87 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
4.06 KB lrw-r--r-- 2024-09-23 20:44:04
Edit Download
1.59 KB lrw-r--r-- 2024-09-23 20:44:04
Edit Download
869 B lrw-r--r-- 2021-05-18 21:00:20
Edit Download
336 B lrw-r--r-- 2021-05-18 21:00:20
Edit Download
1.61 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
1.13 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
13.58 KB lrw-r--r-- 2023-08-16 00:05:04
Edit Download
7.71 KB lrw-r--r-- 2023-08-16 00:05:04
Edit Download
1.98 KB lrw-r--r-- 2022-10-19 00:34:38
Edit Download
1.17 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
3.79 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
2.09 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
2.92 KB lrw-r--r-- 2023-05-24 03:17:54
Edit Download
1.70 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
1.43 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
638 B lrw-r--r-- 2026-02-23 17:58:34
Edit Download
10.05 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
6.35 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
6.57 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
3.57 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
7.04 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.90 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
35.43 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
17.10 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
9.23 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
4.85 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
1.33 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
574 B lrw-r--r-- 2026-02-23 17:58:34
Edit Download
1.78 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
1.05 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
22.32 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
11.93 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).