PageSourceSearch

https://markstyletokyo.fr/themes/pf_ministore/js/tools/statesManagement.js

js markstyletokyo.fr collected 2026-10-08 01:41:54 UTC 5,437 bytes, 165 lines download raw bytes

1/*
2* 2007-2015 PrestaShop
3*
4* NOTICE OF LICENSE
5*
6* This source file is subject to the Academic Free License (AFL 3.0)
7* that is bundled with this package in the file LICENSE.txt.
8* It is also available through the world-wide-web at this URL:
9* http://opensource.org/licenses/afl-3.0.php
10* If you did not receive a copy of the license and are unable to
11* obtain it through the world-wide-web, please send an email
12* to [email protected] so we can send you a copy immediately.
13*
14* DISCLAIMER
15*
16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
17* versions in the future. If you wish to customize PrestaShop for your
18* needs please refer to http://www.prestashop.com for more information.
19*
20*  @author PrestaShop SA <[email protected]>
21*  @copyright  2007-2015 PrestaShop SA
22*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
23*  International Registered Trademark & Property of PrestaShop SA
24*/
25//global variables
26var countriesNeedIDNumber = [];
27var countriesNeedZipCode = [];
28var states = [];
29
30$(document).ready(function(){
31	setCountries();
32	bindStateInputAndUpdate();
33	//bindUniform();
34	bindZipcode();
35	bindCheckbox();
36	$(document).on('click', '#invoice_address', function(e){
37		bindCheckbox();
38	});
39});
40
41function setCountries()
42{
43	if (typeof countries !== 'undefined' && countries)
44	{
45		var countriesPS = [];
46	    for (var i in countries)
47		{
48			var id_country = countries[i]['id_country'];
49			if (typeof countries[i]['states'] !== 'undefined' && parseInt(countries[i]['contains_states']))
50			{
51				countriesPS[id_country] = [];
52	    		for (var j in countries[i]['states'])
53					countriesPS[parseInt(id_country)].push({'id' : parseInt(countries[i]['states'][j]['id_state']), 'name' : countries[i]['states'][j]['name']});
54			}
55
56			if (typeof countries[i]['need_identification_number'] !== 'undefined' && parseInt(countries[i]['need_identification_number']) > 0)
57				countriesNeedIDNumber.push(parseInt(countries[i]['id_country']));
58			if (typeof countries[i]['need_zip_code'] !== 'undefined' && parseInt(countries[i]['need_zip_code']) > 0)
59				countriesNeedZipCode[parseInt(countries[i]['id_country'])] = countries[i]['zip_code_format'];
60		}
61	}
62	states = countriesPS;
63}
64
65function bindCheckbox()
66{
67	if ($('#invoice_address:checked').length > 0)
68	{
69		$('#opc_invoice_address').slideDown('slow');
70		if ($('#company_invoice').val() == '')
71			$('#vat_number_block_invoice').hide();
72		//bindUniform();
73	}
74	else
75		$('#opc_invoice_address').slideUp('slow');
76}
77
78function bindZipcode()
79{
80	$(document).on('keyup', 'input[name^=postcode]', function(e)
81	{
82		var char = String.fromCharCode(e.keyCode);
83		if (/[a-zA-Z]/.test(char))
84			$.trim($(this).val($(this).val().toUpperCase()));
85	});
86}
87
88function bindStateInputAndUpdate()
89{
90	$('.id_state, .dni, .postcode').css({'display':'none'});
91	updateState();
92	updateNeedIDNumber();
93	updateZipCode();
94
95	$(document).on('change', '#id_country', function(e)
96	{
97		updateState();
98		updateNeedIDNumber();
99		updateZipCode();
100		if (typeof validate_field !== 'undefined')
101			validate_field('#postcode');
102	});
103
104	if ($('#id_country_invoice').length !== 0)
105	{
106		$(document).on('change', '#id_country_invoice', function(e)
107		{
108			updateState('invoice');
109			updateNeedIDNumber('invoice');
110			updateZipCode('invoice');
111			if (typeof validate_field !== 'undefined')
112				validate_field('#postcode_invoice');
113		});
114		updateState('invoice');
115		updateNeedIDNumber('invoice');
116		updateZipCode('invoice');
117	}
118
119	if (typeof idSelectedState !== 'undefined' && idSelectedState)
120		$('.id_state option[value=' + idSelectedState + ']').prop('selected', true);
121	if (typeof idSelectedStateInvoice !== 'undefined' && idSelectedStateInvoice)
122		$('.id_state_invoice option[value=' + idSelectedStateInvoice + ']').prop('selected', true);
123}
124
125function updateState(suffix)
126{
127	$('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')+' option:not(:first-child)').remove();
128	if (typeof countries !== 'undefined')
129		var state_list = states[parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val())];
130	if (typeof state_list !== 'undefined')
131	{
132		$(state_list).each(function(key, item){
133			$('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).append('<option value="' + parseInt(item.id) + '">' + item.name + '</option>');
134		});
135
136		$('.id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow');
137		//$('#id_state, #id_state_invoice').uniform();
138	}
139	else
140		$('.id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast');
141}
142
143function updateNeedIDNumber(suffix)
144{
145	var id_country = parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val());
146	if (in_array(id_country, countriesNeedIDNumber))
147	{
148		$('.dni' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow');
149		//$('#dni').uniform();
150	}
151	else
152		$('.dni' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast');
153}
154
155function updateZipCode(suffix)
156{
157	var id_country = parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val());
158	if (typeof countriesNeedZipCode[id_country] !== 'undefined')
159	{
160		$('.postcode' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow');
161		//$('#postcode').uniform();
162	}
163	else
164		$('.postcode'+(typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast');
165}

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.