PageSourceSearch

https://www.rep-sneaker.com/ext/dokan-lite/assets/js/vendor-address.js

js rep-sneaker.com collected 2026-10-06 13:13:35 UTC 5,161 bytes, 108 lines download raw bytes

1( function($, window) {
2    const dokan_address_wrapper = $( '.dokan-address-fields' );
3    const dokan_address_select = {
4        init: function () {
5            dokan_address_wrapper.on( 'change', 'select.country_to_state', this.state_select );
6        },
7        state_select: function () {
8            let states_json = wc_country_select_params.countries.replace( /"/g, '"' ),
9                states = $.parseJSON( states_json ),
10                $statebox = $( '#dokan_address_state' ),
11                input_name = $statebox.attr( 'name' ),
12                input_id = $statebox.attr( 'id' ),
13                input_class = $statebox.attr( 'class' ),
14                value = $statebox.val(),
15                selected_state = $( '#dokan_selected_state' ).val(),
16                input_selected_state = $( '#dokan_selected_state' ).val(),
17                country = $( this ).val();
18
19            if ( states[ country ] ) {
20                if ( $.isEmptyObject( states[ country ] ) ) {
21
22                    $( 'div#dokan-states-box' ).slideUp( 2 );
23                    if ( $statebox.is( 'select' ) ) {
24                        $( 'select#dokan_address_state' ).replaceWith( '<input type="text" class="' + input_class + '" name="' + input_name + '" id="' + input_id + '" required />' );
25                    }
26
27                    $( '#dokan_address_state' ).val( 'N/A' );
28
29                } else {
30                    input_selected_state = '';
31
32                    let options = '',
33                        state = states[ country ],
34                        selected_value = '';
35
36                    for ( let index in state ) {
37                        if ( state.hasOwnProperty( index ) ) {
38                            if ( selected_state ) {
39                                if ( selected_state == index ) {
40                                    selected_value = 'selected="selected"';
41                                } else {
42                                    selected_value = '';
43                                }
44                            }
45                            options = options + '<option value="' + index + '"' + selected_value + '>' + state[ index ] + '</option>';
46                        }
47                    }
48
49                    if ( $statebox.is( 'select' ) ) {
50                        $( 'select#dokan_address_state' ).html( '<option value="">' + wc_country_select_params.i18n_select_state_text + '</option>' + options );
51                    }
52                    if ( $statebox.is( 'input' ) ) {
53                        $( 'input#dokan_address_state' ).replaceWith( '<select type="text" class="' + input_class + '" name="' + input_name + '" id="' + input_id + '" required ></select>' );
54                        $( 'select#dokan_address_state' ).html( '<option value="">' + wc_country_select_params.i18n_select_state_text + '</option>' + options );
55                    }
56                    $( '#dokan_address_state' ).removeClass( 'dokan-hide' );
57                    $( 'div#dokan-states-box' ).slideDown();
58
59                }
60            } else {
61                if ( $statebox.is( 'select' ) ) {
62                    input_selected_state = '';
63                    $( 'select#dokan_address_state' ).replaceWith( '<input type="text" class="' + input_class + '" name="' + input_name + '" id="' + input_id + '" required="required"/>' );
64                }
65                $( '#dokan_address_state' ).val(input_selected_state);
66
67                if ( $( '#dokan_address_state' ).val() == 'N/A' ){
68                    $( '#dokan_address_state' ).val('');
69                }
70                $( '#dokan_address_state' ).removeClass( 'dokan-hide' );
71                $( 'div#dokan-states-box' ).slideDown();
72            }
73
74            $( document.body ).trigger( 'dokan_vendor_country_to_state_changing', [country] );
75        }
76    }
77    window.dokan_address_select = dokan_address_select;
78    window.dokan_address_select.init();
79
80    $( document.body )
81		.on( 'dokan_vendor_country_to_state_changing', function( event, country ) {
82            // wc_address_i18n_params is required to continue, ensure the object exists
83            if ( typeof wc_address_i18n_params === 'undefined' ) {
84                return false;
85            }
86
87            var locale_json = wc_address_i18n_params.locale.replace( /&quot;/g, '"' ), locale = JSON.parse( locale_json ),thislocale;
88
89			if ( typeof locale[ country ] !== 'undefined' ) {
90				thislocale = locale[ country ];
91			} else {
92				thislocale = locale['default'];
93			}
94
95            let required = thislocale?.state?.required || undefined === thislocale?.state?.required;
96
97            if (thislocale?.state?.label) {
98                let labelElement = `${thislocale?.state?.label} ${required ? '<span class="required"> *</span>' : ''}`;
99
100                $('.dokan-address-fields #dokan-states-box label').html(labelElement);
101                $('.dokan-address-fields #dokan-states-box #dokan_address_state').attr('data-state', thislocale?.state?.label);
102            }
103
104
105            $('.dokan-address-fields #dokan-states-box #dokan_address_state').attr('required', required);
106        })
107
108} )(jQuery, window)

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.