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 = []; 28 29$(document).ready(function(){ 30 setCountries(); 31 bindPostcode(); 32 bindStateInputAndUpdate(); 33}); 34 35function setCountries() 36{ 37 if (typeof countries !== 'undefined' && countries) 38 { 39 var countriesPS = []; 40 for (var i in countries) 41 { 42 var id_country = countries[i]['id_country']; 43 if (typeof countries[i]['states'] !== 'undefined' && countries[i]['states'] && countries[i]['contains_states']) 44 { 45 countriesPS[id_country] = []; 46 for (var j in countries[i]['states']) 47 countriesPS[parseInt(id_country)].push({'id' : parseInt(countries[i]['states'][j]['id_state']), 'name' : countries[i]['states'][j]['name']}); 48 } 49 if (typeof countries[i]['need_identification_number'] !== 'undefined' && parseInt(countries[i]['need_identification_number']) > 0) 50 countriesNeedIDNumber.push(parseInt(countries[i]['id_country'])); 51 if (typeof countries[i]['need_zip_code'] !== 'undefined' && parseInt(countries[i]['need_zip_code']) > 0) 52 countriesNeedZipCode[parseInt(countries[i]['id_country'])] = countries[i]['zip_code_format']; 53 } 54 } 55 countries = countriesPS; 56} 57 58function bindPostcode() 59{ 60 $(document).on('keyup', 'input[name=postcode]', function(e) 61 { 62 $(this).val($(this).val().toUpperCase()); 63 }); 64} 65 66function bindStateInputAndUpdate() 67{ 68 $('.id_state, .dni, .postcode').css({'display':'none'}); 69 updateState(); 70 updateNeedIDNumber(); 71 updateZipCode(); 72 73 $(document).on('change', '#id_country', function(e) 74 { 75 updateState(); 76 updateNeedIDNumber(); 77 updateZipCode(); 78 }); 79 80 if ($('#id_country_invoice').length !== 0) 81 { 82 $(document).on('change', '#id_country_invoice', function(e) 83 { 84 updateState('invoice'); 85 updateNeedIDNumber('invoice'); 86 updateZipCode('invoice'); 87 }); 88 updateState('invoice'); 89 updateNeedIDNumber('invoice'); 90 updateZipCode('invoice'); 91 } 92 93 if (typeof idSelectedState !== 'undefined' && idSelectedState) 94 $('.id_state option[value=' + idSelectedState + ']').prop('selected', true); 95 if (typeof idSelectedStateInvoice !== 'undefined' && idSelectedStateInvoice) 96 $('.id_state_invoice option[value=' + idSelectedStateInvoice + ']').prop('selected', true); 97} 98 99function updateState(suffix) 100{ 101 $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')+' option:not(:first-child)').remove(); 102 if (typeof countries !== 'undefined') 103 var states = countries[parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val())]; 104 if (typeof states !== 'undefined') 105 { 106 $(states).each(function(key, item){ 107 $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).append('<option value="' + parseInt(item.id) + '">' + item.name + '</option>'); 108 }); 109 110 $('.id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 111 } 112 else 113 $('.id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 114 115 if($('#id_state').length || $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).length) 116 { 117 $elem = $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')); 118 $elem.parent().find('.selector, .wrap-custom-select').remove(); 119 customSelect($elem); 120 } 121} 122 123function updateNeedIDNumber(suffix) 124{ 125 var idCountry = parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val()); 126 if (typeof countriesNeedIDNumber !== 'undefined' && in_array(idCountry, countriesNeedIDNumber)) 127 { 128 $('.dni' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 129 } 130 else 131 $('.dni' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 132} 133 134function updateZipCode(suffix) 135{ 136 var idCountry = parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val()); 137 if (typeof countriesNeedZipCode !== 'undefined' && typeof countriesNeedZipCode[i
137dCountry] !== 'undefined') 138 { 139 $('.postcode' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 140 } 141 else 142 $('.postcode'+(typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 143}
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.