1ACC.address = { 2 3 _autoload: [ 4 "bindToChangeAddressButton", 5 "bindCreateUpdateAddressForm", 6 "bindSuggestedDeliveryAddresses", 7 "bindCountrySpecificAddressForms", 8 "showAddressFormButtonPanel", 9 "bindViewAddressBook", 10 "bindToColorboxClose", 11 "showRemoveAddressFromBookConfirmation", 12 "backToListAddresses" 13 ], 14 15 spinner: $("<img src='" + ACC.config.commonResourcePath + "/images/spinner.gif' />"), 16 addressID: '', 17 18 handleChangeAddressButtonClick: function () 19 { 20 21 22 ACC.address.addressID = ($(this).data("address")) ? $(this).data("address") : ''; 23 $('#summaryDeliveryAddressFormContainer').show(); 24 $('#summaryOverlayViewAddressBook').show(); 25 $('#summaryDeliveryAddressBook').hide(); 26 27 28 $.getJSON(getDeliveryAddressesUrl, ACC.address.handleAddressDataLoad); 29 return false; 30 }, 31 32 handleAddressDataLoad: function (data) 33 { 34 ACC.address.setupDeliveryAddressPopupForm(data); 35 36 // Show the delivery address popup 37 ACC.colorbox.open("",{ 38 inline: true, 39 href: "#summaryDeliveryAddressOverlay", 40 overlayClose: false, 41 onOpen: function (){ 42 // empty address form fields 43 ACC.address.emptyAddressForm(); 44 $(document).on('change', '#saveAddress', function () 45 { 46 var saveAddressChecked = $(this).prop('checked'); 47 $('#defaultAddress').prop('disabled', !saveAddressChecked); 48 if (!saveAddressChecked) 49 { 50 $('#defaultAddress').prop('checked', false); 51 } 52 }); 53 } 54 }); 55 56 }, 57 58 setupDeliveryAddressPopupForm: function (data) 59 { 60 // Fill the available delivery addresses 61 $('#summaryDeliveryAddressBook').html($('#deliveryAddressesTemplate').tmpl({addresses: data})); 62 // Handle selection of address 63 $('#summaryDeliveryAddressBook button.use_address').click(ACC.address.handleSelectExistingAddressClick); 64 // Handle edit address 65 $('#summaryDeliveryAddressBook button.edit').click(ACC.address.handleEditAddressClick); 66 // Handle set default address 67 $('#summaryDeliveryAddressBook button.default').click(ACC.address.handleDefaultAddressClick); 68 }, 69 70 emptyAddressForm: function () 71 { 72 var options = { 73 url: getDeliveryAddressFormUrl, 74 data: {addressId: ACC.address.addressID, createUpdateStatus: ''}, 75 type: 'GET', 76 success: function (data) 77 { 78 $('#summaryDeliveryAddressFormContainer').html(data); 79 ACC.address.bindCreateUpdateAddressForm(); 80 } 81 }; 82 83 $.ajax(options); 84 }, 85 86 handleSelectExistingAddressClick: function () 87 { 88 var addressId = $(this).attr('data-address'); 89 $.postJSON(setDeliveryAddressUrl, {addressId: addressId}, ACC.address.handleSelectExitingAddressSuccess); 90 return false; 91 }, 92 93 handleEditAddressClick: function () 94 { 95 96 $('#summaryDeliveryAddressFormContainer').show(); 97 $('#summaryOverlayViewAddressBook').show(); 98 $('#summaryDeliveryAddressBook').hide(); 99 100 var addressId = $(this).attr('data-address'); 101 var options = { 102 url: getDeliveryAddressFormUrl, 103 data: {addressId: addressId, createUpdateStatus: ''}, 104 target: '#summaryDeliveryAddressFormContainer', 105 type: 'GET', 106 success: function (data) 107 { 108 ACC.address.bindCreateUpdateAddressForm(); 109 ACC.colorbox.resize(); 110 }, 111 error: function (xht, textStatus, ex) 112 { 113 alert("Failed to update cart. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 114 } 115 }; 116 117 $(this).ajaxSubmit(options); 118 return false; 119 }, 120 121 handleDefaultAddressClick: function () 122 { 123 var addressId = $(this).attr('data-address'); 124 var options = { 125 url: setDefaultAddressUrl, 126 data: {addressId: addressId}, 127 type: 'GET', 128 success: function (data) 129 { 130 ACC.address.setupDeliveryAddressPopupForm(data); 131 }, 132 error: function (xht, textStatus, ex) 133 { 134 alert("Failed to update address book. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 135 } 136 }; 137 138 $(this).ajaxSubmit(options); 139 return false; 140 }, 141 142 handleSelectExitingAddressSuccess: function (data) 143 { 144 if (data != null) 145 { 146 ACC.refresh.refreshPage(data); 147 ACC.colorbox.close(); 148 } 149 else 150 { 151 alert("Failed to set delivery address"); 152 } 153 }, 154 155 bindCreateUpdateAddressForm: function () 156 { 157 $('.create_update_address_form').each(function () 158 { 159 var options = { 160 type: 'POST', 161 beforeSubmit: function () 162 { 163 $('#checkout_delivery_address').block({ message: ACC.address.spinner }); 164 }, 165 success: function (data) 166 { 167 $('#summaryDeliveryAddressFormContainer').html(data); 168 var status = $('.create_update_address_id').attr('status'); 169 if (status != null && "success" === status.toLowerCase()) 170 { 171 ACC.refresh.getCheckoutCartDataAndRefreshPage(); 172 ACC.colorbox.close(); 173 } 174 else 175 { 176 ACC.address.bindCreateUpdateAddressForm(); 177 ACC.colorbox.resize(); 178 } 179 }, 180 error: function (xht, textStatus, ex) 181 { 182 alert("Failed to update cart. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 183 }, 184 complete: function () 185 { 186 $('#checkout_delivery_address').unblock(); 187 } 188 }; 189 190 $(this).ajaxForm(options); 191 }); 192 }, 193 194 refreshDeliveryAddressSection: function (data) 195 { 196 $('.summaryDeliveryAddress').replaceWith($('#deliveryAddressSummaryTemplate').tmpl(data)); 197 198 }, 199 200 bindSuggestedDeliveryAddresses: function () 201 { 202 var status = $('.add_edit_delivery_address_id').attr('status'); 203 if (status != null && "hasSuggestedAddresses" == status) 204 { 205 ACC.address.showSuggestedAddressesPopup(); 206 } 207 }, 208 209 showSuggestedAddressesPopup: function () 210 { 211 $(document).ready(function(){ 212 ACC.colorbox.open("Suggested Addresses",{ 213 href: "#popup_suggested_delivery_addresses", 214 inline: true, 215 width:"525px", 216 onComplete: function () 217 { 218 $(this).colorbox.resize(); 219 } 220 }); 221 222 }) 223 }, 224 225 bindCountrySpecificAddressForms: function (){ 226 $(document).on("change",'#countrySelector select', function (){ 227 var options = { 228 'addressCode': '', 229 'countryIsoCode': $(this).val() 230 }; 231 ACC.address.displayCountrySpecificAddressForm(options, ACC.address.showAddressFormButtonPanel); 232 }) 233 234 }, 235 236 showAddressFormButtonPanel: function () 237 { 238 if ($('#countrySelector :input').val() !== '') 239 { 240 $('#addressform_button_panel').show(); 241 } 242 }, 243 244 bindToColorboxClose: function () 245 { 246 $(document).on("click", ".closeColorBox", function () 247 { 248 ACC.colorbox.close(); 249 }) 250 }, 251 252 253 displayCountrySpecificAddressForm: function (options, callback) 254 { 255 $.ajax({ 256 url: ACC.config.encodedContextPath + '/my-account/addressform', 257 async: true, 258 data: options, 259 dataType: "html", 260 beforeSend: function () 261 { 262 $("#i18nAddressForm").html(ACC.address.spinner); 263 } 264 }).done(function (data) 265 { 266 $("#i18nAddressForm").html($(data).html()); 267 if (typeof callback == 'function') 268 { 269 callback.call(); 270 } 271 }); 272 }, 273 274 bindToChangeAddressButton: function () 275 { 276 $(document).on("click", '.summaryDeliveryAddress .editButton', ACC.address.handleChangeAddressButtonClick); 277 }, 278 279 bindViewAddressBook: function () 280 { 281 282 $(document).on("click",".js-address-book",function(e){ 283 e.preventDefault(); 284
285 ACC.colorbox.open("Saved Addresses",{ 286 href: "#addressbook", 287 inline: true, 288 width:"380px" 289 }); 290 291 }); 292 293 294 $(document).on("click", '#summaryOverlayViewAddressBook', function () 295 { 296 $('#summaryDeliveryAddressFormContainer').hide(); 297 $('#summaryOverlayViewAddressBook').hide(); 298 $('#summaryDeliveryAddressBook').show(); 299 ACC.colorbox.resize(); 300 }); 301 }, 302 303 showRemoveAddressFromBookConfirmation: function () 304 { 305 $(document).on("click", ".removeAddressFromBookButton", function () 306 { 307 var addressId = $(this).data("addressId"); 308 var popupTitle = $(this).data("popupTitle"); 309 310 ACC.colorbox.open(popupTitle,{ 311 inline: true, 312 height: false, 313 href: "#popup_confirm_address_removal_" + addressId, 314 onComplete: function () 315 { 316 317 $(this).colorbox.resize(); 318 } 319 }); 320 321 }) 322 }, 323 324 backToListAddresses: function(){ 325 $(".addressBackBtn").on("click", function(){ 326 var sUrl = $(this).data("backToAddresses"); 327 window.location = sUrl; 328 }); 329 } 330};
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.