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 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 updateState(); 94 updateNeedIDNumber(); 95 updateZipCode(); 96 97 $(document).on('change', '#id_country', function(e) 98 { 99 updateState(); 100 updateNeedIDNumber(); 101 updateZipCode(); 102 if (typeof validate_field !== 'undefined') 103 validate_field('#postcode'); 104 }); 105 106 if ($('#id_country_invoice').length !== 0) 107 { 108 $(document).on('change', '#id_country_invoice', function(e) 109 { 110 updateState('invoice'); 111 updateNeedIDNumber('invoice'); 112 updateZipCode('invoice'); 113 if (typeof validate_field !== 'undefined') 114 validate_field('#postcode_invoice'); 115 }); 116 updateState('invoice'); 117 updateNeedIDNumber('invoice'); 118 updateZipCode('invoice'); 119 } 120 121 if (typeof idSelectedState !== 'undefined' && idSelectedState) 122 $('.id_state option[value=' + idSelectedState + ']').prop('selected', true); 123 if (typeof idSelectedStateInvoice !== 'undefined' && idSelectedStateInvoice) 124 $('.id_state_invoice option[value=' + idSelectedStateInvoice + ']').prop('selected', true); 125} 126 127function updateState(suffix) 128{ 129 $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')+' option:not(:first-child)').remove(); 130 if (typeof countries !== 'undefined') 131 var state_list = states[parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val())]; 132 if (typeof state_list !== 'undefined') 133 { 134 $(state_list).each(function(key, item){ 135 $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).append('<option value="' + parseInt(item.id) + '">' + item.name + '</option>'); 136 }); 137 138 $('.id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 139 $('#id_state, #id_state_invoice').uniform(); 140 } 141 else 142 $('.id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 143} 144 145function updateNeedIDNumber(suffix) 146{ 147 var id_country = parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val()); 148 if (in_array(id_country, countriesNeedIDNumber)) 149 { 150 $('.dni' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 151 $('#dni').uniform(); 152 } 153 else 154 $('.dni' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 155} 156 157function updateZipCode(suffix) 158{ 159 var id_country = parseInt($('#id_country' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).val()); 160 if (typeof countriesNeedZipCode[id_country] !== 'undefined') 161 { 162 $('.postcode' + (typeof suffix !== 'undefined' ? '_' + suffix : '') + ':hidden').fadeIn('slow'); 163 $('#postcode').uniform(); 164 } 165 else 166 $('.postcode'+(typeof suffix !== 'undefined' ? '_' + suffix : '')).fadeOut('fast'); 167}
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.