1/* 2* 2007-2016 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-2016 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 if (typeof bindUniform !=='undefined') 34 bindUniform(); 35 bindZipcode(); 36 bindCheckbox(); 37 $(document).on('click', '#invoice_address', function(e){ 38 bindCheckbox(); 39 }); 40}); 41 42function setCountries() 43{ 44 if (typeof countries !== 'undefined' && countries) 45 { 46 var countriesPS = []; 47 for (var i in countries) 48 { 49 var id_country = countries[i]['id_country']; 50 if (typeof countries[i]['states'] !== 'undefined' && parseInt(countries[i]['contains_states'])) 51 { 52 countriesPS[id_country] = []; 53 for (var j in countries[i]['states']) 54 countriesPS[parseInt(id_country)].push({'id' : parseInt(countries[i]['states'][j]['id_state']), 'name' : countries[i]['states'][j]['name']}); 55 } 56 57 if (typeof countries[i]['need_identification_number'] !== 'undefined' && parseInt(countries[i]['need_identification_number']) > 0) 58 countriesNeedIDNumber.push(parseInt(countries[i]['id_country'])); 59 if (typeof countries[i]['need_zip_code'] !== 'undefined' && parseInt(countries[i]['need_zip_code']) > 0) 60 countriesNeedZipCode[parseInt(countries[i]['id_country'])] = countries[i]['zip_code_format']; 61 } 62 } 63 states = countriesPS; 64} 65 66function bindCheckbox() 67{ 68 if ($('#invoice_address:checked').length > 0) 69 { 70 $('#opc_invoice_address').slideDown('slow'); 71 if ($('#company_invoice').val() == '') 72 $('#vat_number_block_invoice').hide(); 73 if (typeof bindUniform !=='undefined') 74 bindUniform(); 75 } 76 else
77 $('#opc_invoice_address').slideUp('slow'); 78} 79 80function bindZipcode() 81{ 82 $(document).on('keyup', 'input[name^=postcode]', function(e) 83 { 84 var char = String.fromCharCode(e.keyCode); 85 if (/[a-zA-Z]/.test(char)) 86 $.trim($(this).val($(this).val().toUpperCase())); 87 }); 88} 89 90function bindStateInputAndUpdate() 91{ 92 $('.id_state, .dni, .postcode').css({'display':'none'}); 93 94 if (typeof idSelectedCountry !== 'undefined' && idSelectedCountry) 95 $('#id_country option[value=' + idSelectedCountry + ']').prop('selected', true); 96 97 updateState(); 98 updateNeedIDNumber(); 99 updateZipCode(); 100 101 $(document).on('change', '#id_country', function(e) 102 { 103 updateState(); 104 updateNeedIDNumber(); 105 updateZipCode(); 106 if (typeof validate_field !== 'undefined') 107 validate_field('#postcode'); 108 }); 109 110 if ($('#id_country_invoice').length !== 0) 111 { 112 $(document).on('change', '#id_country_invoice', function(e) 113 { 114 updateState('invoice'); 115 updateNeedIDNumber('invoice'); 116 updateZipCode('invoice'); 117 if (typeof validate_field !== 'undefined') 118 validate_field('#postcode_invoice'); 119 }); 120 updateState('invoice'); 121 updateNeedIDNumber('invoice'); 122 updateZipCode('invoice'); 123 } 124 125 if (typeof idSelectedState !== 'undefined' && idSelectedState) 126 $('.id_state option[value=' + idSelectedState + ']').prop('selected', true); 127 if (typeof idSelectedStateInvoice !== 'undefined' && idSelectedStateInvoice) 128 $('.id_state_invoice option[value=' + idSelectedStateInvoice + ']').prop('selected', true); 129} 130 131function updateState(suffix) 132{ 133 $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')+' option:not(:first-child)').remove(); 134 if (typeof countries !== 'undefined') 135 var state_list = states[parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val())]; 136 if (typeof state_list !== 'undefined') 137 { 138 $(state_list).each(function(key, item){ 139 $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).append('<option value="' + parseInt(item.id) + '">' + item.name + '</option>'); 140 }); 141 142 $('.id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 143 $('#id_state, #id_state_invoice').uniform(); 144 } 145 else 146 $('.id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 147} 148 149function updateNeedIDNumber(suffix) 150{ 151 var id_country = parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val()); 152 if (in_array(id_country, countriesNeedIDNumber)) 153 { 154 $('.dni' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 155 $('#dni').uniform(); 156 } 157 else 158 $('.dni' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 159} 160 161function updateZipCode(suffix) 162{ 163 var id_country = parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val()); 164 if (typeof countriesNeedZipCode[id_country] !== 'undefined') 165 { 166 $('.postcode' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 167 $('#postcode').uniform(); 168 } 169 else 170 $('.postcode'+(typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 171}
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.