1/* 2** nopCommerce country select js functions 3*/ 4+function ($) { 5 'use strict'; 6 if ('undefined' == typeof (jQuery)) { 7 throw new Error('jQuery JS required'); 8 } 9 function countrySelectHandler() { 10 var $this = $(this); 11 var selectedItem = $this.val(); 12 var stateProvince = $($this.data('stateprovince')); 13 14 if(stateProvince.length == 0) 15 return; 16 17 var loading = $($this.data('loading')); 18 loading.show(); 19 $.ajax({ 20 cache: false, 21 type: "GET", 22 url: $this.data('url'), 23 data: { 24 'countryId': selectedItem, 25 'addSelectStateItem': "true" 26 }, 27 success: function (data, textStatus, jqXHR) { 28 stateProvince.html(''); 29 $.each(data, 30 function (id, option) { 31 stateProvince.append($('<option></option>').val(option.id).html(option.name)); 32 }); 33 }, 34 error: function (jqXHR, textStatus, errorThrown) { 35 alert('Failed to retrieve states.'); 36 }, 37 complete: function(jqXHR, textStatus) { 38 var stateId = (typeof Billing !== "undefined") ? Billing.selectedStateId : (typeof CheckoutBilling !== "undefined") ? CheckoutBilling.selectedStateId : 0; 39 $('#' + stateProvince[0].id + ' option[value=' + stateId + ']').prop('selected', true); 40 41 loading.hide(); 42 } 43 }); 44 } 45 if ($(document).has('[data-trigger="country-select"]')) { 46 $('select[data-trigger="country-select"]').change(countrySelectHandler); 47 } 48 $.fn.countrySelect = function () { 49 this.each(function () { 50 $(this).change(countrySelectHandler); 51 }); 52 } 53}(jQuery);
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.