1ACC.address = { 2 3 _autoload: [ 4 "bindToChangeAddressButton", 5 "bindCreateUpdateAddressForm", 6 "bindSuggestedDeliveryAddresses", 7 "bindCountrySpecificAddressForms", 8 "showAddressFormButtonPanel", 9 "bindViewAddressBook", 10 "bindToColorboxClose", 11 "showRemoveAddressFromBookConfirmation", 12 "backToListAddresses", 13 "callQasValidation", 14 "getAddressQasString", 15 "getBillingAddressQasString", 16 "addNewB2BUnitPopUpFunction", 17 "createNewB2BUnitConfirmationfunction", 18 "checkSpecialCharecterfunction", 19 "b2bUnitCreationButtonfunction" 20 ], 21 22 spinner: $("<img src='" + ACC.config.commonResourcePath + "/images/spinner.gif' />"), 23 addressID: '', 24 25 handleChangeAddressButtonClick: function () 26 { 27 28 29 ACC.address.addressID = ($(this).data("address")) ? $(this).data("address") : ''; 30 $('#summaryDeliveryAddressFormContainer').show(); 31 $('#summaryOverlayViewAddressBook').show(); 32 $('#summaryDeliveryAddressBook').hide(); 33 34 35 $.getJSON(getDeliveryAddressesUrl, ACC.address.handleAddressDataLoad); 36 return false; 37 }, 38 39 handleAddressDataLoad: function (data) 40 { 41 ACC.address.setupDeliveryAddressPopupForm(data); 42 43 // Show the delivery address popup 44 ACC.colorbox.open("",{ 45 inline: true, 46 href: "#summaryDeliveryAddressOverlay", 47 overlayClose: false, 48 onOpen: function (){ 49 // empty address form fields 50 ACC.address.emptyAddressForm(); 51 $(document).on('change', '#saveAddress', function () 52 { 53 var saveAddressChecked = $(this).prop('checked'); 54 $('#defaultAddress').prop('disabled', !saveAddressChecked); 55 if (!saveAddressChecked) 56 { 57 $('#defaultAddress').prop('checked', false); 58 } 59 }); 60 } 61 }); 62 63 }, 64 65 setupDeliveryAddressPopupForm: function (data) 66 { 67 // Fill the available delivery addresses 68 $('#summaryDeliveryAddressBook').html($('#deliveryAddressesTemplate').tmpl({addresses: data})); 69 // Handle selection of address 70 $('#summaryDeliveryAddressBook button.use_address').click(ACC.address.handleSelectExistingAddressClick); 71 // Handle edit address 72 $('#summaryDeliveryAddressBook button.edit').click(ACC.address.handleEditAddressClick); 73 // Handle set default address 74 $('#summaryDeliveryAddressBook button.default').click(ACC.address.handleDefaultAddressClick); 75 }, 76 77 emptyAddressForm: function () 78 { 79 var options = { 80 url: getDeliveryAddressFormUrl, 81 data: {addressId: ACC.address.addressID, createUpdateStatus: ''}, 82 type: 'GET', 83 dataType: 'html', 84 success: function (data) 85 { 86 $('#summaryDeliveryAddressFormContainer').html(data); 87 ACC.address.bindCreateUpdateAddressForm(); 88 } 89 }; 90 91 $.ajax(options); 92 }, 93 94 handleSelectExistingAddressClick: function () 95 { 96 var addressId = $(this).attr('data-address'); 97 $.postJSON(setDeliveryAddressUrl, {addressId: addressId}, ACC.address.handleSelectExitingAddressSuccess); 98 return false; 99 }, 100 101 handleEditAddressClick: function () 102 { 103 104 $('#summaryDeliveryAddressFormContainer').show(); 105 $('#summaryOverlayViewAddressBook').show(); 106 $('#summaryDeliveryAddressBook').hide(); 107 108 var addressId = $(this).attr('data-address'); 109 var options = { 110 url: getDeliveryAddressFormUrl, 111 data: {addressId: addressId, createUpdateStatus: ''}, 112 target: '#summaryDeliveryAddressFormContainer', 113 type: 'GET', 114 success: function (data) 115 { 116 ACC.address.bindCreateUpdateAddressForm(); 117 ACC.colorbox.resize(); 118 }, 119 error: function (xht, textStatus, ex) 120 { 121 console.log("Failed to update cart. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 122 } 123 }; 124 125 $(this).ajaxSubmit(options); 126 return false; 127 }, 128 129 handleDefaultAddressClick: function () 130 { 131 var addressId = $(this).attr('data-address'); 132 var options = { 133 url: setDefaultAddressUrl, 134 data: {addressId: addressId}, 135 type: 'GET', 136 success: function (data) 137 { 138 ACC.address.setupDeliveryAddressPopupForm(data); 139 }, 140 error: function (xht, textStatus, ex) 141 { 142 console.log("Failed to update address book. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 143 } 144 }; 145 146 $(this).ajaxSubmit(options); 147 return false; 148 }, 149 150 handleSelectExitingAddressSuccess: function (data) 151 { 152 if (data != null) 153 { 154 ACC.refresh.refreshPage(data); 155 ACC.colorbox.close(); 156 } 157 else 158 {
159 console.log("Failed to set delivery address"); 160 } 161 }, 162 163 bindCreateUpdateAddressForm: function () 164 { 165 $('.create_update_address_form').each(function () 166 { 167 var options = { 168 type: 'POST', 169 beforeSubmit: function () 170 { 171 $('#checkout_delivery_address').block({ message: ACC.address.spinner }); 172 }, 173 success: function (data) 174 { 175 $('#summaryDeliveryAddressFormContainer').html(data); 176 var status = $('.create_update_address_id').attr('status'); 177 if (status != null && "success" === status.toLowerCase()) 178 { 179 ACC.refresh.getCheckoutCartDataAndRefreshPage(); 180 ACC.colorbox.close(); 181 } 182 else 183 { 184 ACC.address.bindCreateUpdateAddressForm(); 185 ACC.colorbox.resize(); 186 } 187 }, 188 error: function (xht, textStatus, ex) 189 { 190 console.log("Failed to update cart. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 191 }, 192 complete: function () 193 { 194 $('#checkout_delivery_address').unblock(); 195 } 196 }; 197 198 $(this).ajaxForm(options); 199 }); 200 }, 201 202 refreshDeliveryAddressSection: function (data) 203 { 204 $('.summaryDeliveryAddress').replaceWith($('#deliveryAddressSummaryTemplate').tmpl(data)); 205 206 }, 207 208 bindSuggestedDeliveryAddresses: function () 209 { 210 var status = $('.add_edit_delivery_address_id').attr('status'); 211 if (status != null && "hasSuggestedAddresses" == status) 212 { 213 ACC.address.showSuggestedAddressesPopup(); 214 } 215 }, 216 217 showSuggestedAddressesPopup: function () 218 { 219 $(document).ready(function(){ 220 ACC.colorbox.open("Suggested Addresses",{ 221 href: "#popup_suggested_delivery_addresses", 222 inline: true, 223 width:"525px", 224 onComplete: function () 225 { 226 $(this).colorbox.resize(); 227 } 228 }); 229 230 }) 231 }, 232 233 bindCountrySpecificAddressForms: function (){ 234 $(document).on("change",'#countrySelector select', function (){ 235 var options = { 236 'addressCode': '', 237 'countryIsoCode': $(this).val() 238 }; 239 ACC.address.displayCountrySpecificAddressForm(options, ACC.address.showAddressFormButtonPanel); 240 }) 241 242 }, 243 244 showAddressFormButtonPanel: function () 245 { 246 if ($('#countrySelector :input').val() !== '') 247 { 248 $('#addressform_button_panel').show(); 249 } 250 }, 251 252 bindToColorboxClose: function () 253 { 254 $(document).on("click", ".closeColorBox", function () 255 { 256 ACC.colorbox.close(); 257 }) 258 }, 259 260 261 displayCountrySpecificAddressForm: function (options, callback) 262 { 263 $.ajax({ 264 url: ACC.config.encodedContextPath + '/your-account/addressform', 265 async: true, 266 data: options, 267 dataType: "html", 268 beforeSend: function () 269 { 270 $("#i18nAddressForm").html(ACC.address.spinner); 271 } 272 }).done(function (data) 273 { 274 $("#i18nAddressForm").html($(data).html()); 275 if (typeof callback == 'function') 276 { 277 callback.call(); 278 } 279 }); 280 }, 281 282 bindToChangeAddressButton: function () 283 { 284 $(document).on("click", '.summaryDeliveryAddress .editButton', ACC.address.handleChangeAddressButtonClick); 285 }, 286 287 bindViewAddressBook: function () 288 { 289 290 $(document).on("click",".js-address-book",function(e){ 291 e.preventDefault(); 292 293 ACC.colorbox.open("Saved Addresses",{ 294 href: "#addressbook", 295 inline: true, 296 width:"380px" 297 }); 298 299 }) 300 301 302 $(document).on("click", '#summaryOverlayViewAddressBook', function () 303 { 304 $('#summaryDeliveryAddressFormContainer').hide(); 305 $('#summaryOverlayViewAddressBook').hide(); 306 $('#summaryDeliveryAddressBook').show(); 307 ACC.colorbox.resize(); 308 }); 309 }, 310 311 showRemoveAddressFromBookConfirmation: function () 312 { 313 $(document).on("click", ".removeAddressFromBookButton", function () 314 { 315 var addressId = $(this).data("addressId"); 316 var popupTitle = $(this).data("popupTitle"); 317 318 ACC.colorbox.open(popupTitle,{ 319 inline: true, 320 height: false, 321 href: "#popup_confirm_address_removal_" + addressId, 322 onComplete: function () 323 { 324 325 $(this).colorbox.resize(); 326 } 327 }); 328 329 }) 330 }, 331 332 backToListAddresses: function(){ 333 $(".addressBackBtn").on("click", function(){ 334 var sUrl = $(this).data("backToAddresses"); 335 window.location = sUrl; 336 }); 337 }, 338 339 callQasValidation: function(){ 340 $(document).on("click", ".verifyQas", function (){ 341 342 var addressString = encodeURIComponent(ACC.address.getAddressQasString()); 343 $.ajax({ 344 url: ACC.config.encodedContextPath + '/qas/verify?addressString='+addressString, 345 type: 'GET', 346 success: function (response) { 347 var $response = $(response); 348 var poBoxError = $response.find('#isPoBoxError').val()==='true'; 349 var skipConfirmationPrompt = $response.find('#skipConfirmationPrompt').val()==='true'; 350 if(!poBoxError && skipConfirmationPrompt){ 351 $('.ajax-global-error-message').hide(); 352 ACC.checkout.applyCorrectedAddress($response); 353 }else if(!poBoxError){ 354 $('.ajax-global-error-message').hide(); 355 var addressString = encodeURIComponent(ACC.address.getAddressQasString()); 356 ACC.colorbox.open(messages.verificationMessage,{ 357 html:response, 358 maxWidth:"100%", 359 className:"suggested-address", 360 width:"700px", 361 height:"100%", 362 top:"10%", 363 onComplete: function(){ 364 setTimeout(function(){ 365 _autoload : [ ] 366 367 }, 800); 368 ACC.colorbox.resize(); 369 ACC.checkout.bindSuggestedForms(); 370 ACC.colorbox.resize(); 371 } 372 }); 373 }else if(!poBoxError){ 374 $('.ajax-global-error-message').removeClass("hidden").show(); 375 $('.ajax-global-error-message').html('<div class="alert alert-danger alert-dismissable getAccAlert">'+messages.upsMessage+'</div>'); 376 }else{ 377 $(".dss-loader,.overlay").hide(); 378 $('.ajax-global-error-message').removeClass("hidden").show(); 379 $('.ajax-global-error-message').html('<div class="alert alert-danger alert-dismissable getAccAlert">'+messages.invalidManualAddress+'</div>'); 380 381 //$('#addressForm').submit(); 382 } 383 }, 384 error: function (jqXHR, textStatus, errorThrown) { 385 // log the error to the console 386 console.log("The following error occured: " + textStatus, errorThrown); 387 } 388 }); 389 return false;
390 }); 391 }, 392 getAddressQasString: function (){ 393 var addressForm = $('#i18nAddressForm'); 394 var addressLine1 = addressForm.find('#address\\.line1').val(); 395 var addressLine2 = addressForm.find('#address\\.line2').val(); 396 var addressCity = addressForm.find('#address\\.townCity').val(); 397 var addressRegion = addressForm.find('#address\\.region').val(); 398 var addressPostcode = addressForm.find('#address\\.postcode').val(); 399 if(addressLine1 != undefined){ 400 addressLine1 = addressLine1.replace(/\s+/g, ":"); 401 } 402 if(addressLine2 != undefined){ 403 addressLine2 = addressLine2.replace(/\s+/g, ":"); 404 } 405 if(addressCity != undefined){ 406 addressCity = addressCity.replace(/\s+/g, ":"); 407 } 408 409 return [addressLine1,addressLine2,addressCity,addressRegion,addressPostcode].filter(Boolean).join(';'); 410 411 }, 412 getBillingAddressQasString: function (){ 413 var addressForm; 414 if( $('#billingAddressForm1').length) { 415 addressForm = $('#billingAddressForm1'); 416 }else{ 417 addressForm = $('#billingAddressForm'); 418 } 419 420 var addressLine1 = addressForm.find('#address\\.line1').val(); 421 var addressLine2 = addressForm.find('#address\\.line2').val(); 422 var addressCity = addressForm.find('#address\\.townCity').val(); 423 var addressRegion = addressForm.find('#address\\.region').val(); 424 var addressPostcode = addressForm.find('#address\\.postcode').val(); 425 if(addressLine1 != undefined){ 426 addressLine1 = addressLine1.replace(/\s+/g, ":"); 427 } 428 if(addressLine2 != undefined){ 429 addressLine2 = addressLine2.replace(/\s+/g, ":"); 430 } 431 if(addressCity != undefined){ 432 addressCity = addressCity.replace(/\s+/g, ":"); 433 } 434 return [addressLine1,addressLine2,addressCity,addressRegion,addressPostcode].filter(Boolean).join(';'); 435 436 }, 437 438 addNewB2BUnitPopUpFunction: function () 439 { 440 $(document).on("click", ".addNewB2BUnitPopUp", function () 441 { 442 var popupTitle = $(this).data("popuptitle"); 443 ACC.colorbox.open(popupTitle,{ 444 inline: true, 445 height: "480px", 446 width: "480px", 447 href: "#add_new_b2b_unit_popup", 448 onComplete: function () 449 { 450 $(this).colorbox.resize(); 451 }, 452 onClosed: function() { 453 $("#unitNameText").val(''); 454 $("#createNewB2BUnitConfirmationButton").prop('disabled',true); 455 } 456 }); 457 458 }) 459 }, 460 461 createNewB2BUnitConfirmationfunction: function () 462 { 463 $(document).on("click", ".createNewB2BUnitConfirmation", function () 464 { 465 var unitName = $.trim($("#unitNameText").val()); 466 if (unitName != '' && unitName.length > 0) { 467 $("#newB2BunitForm").submit(); 468 } 469 }) 470 }, 471 472 checkSpecialCharecterfunction: function (e) 473 { 474 $("#unitNameText").keypress(function(e) 475 { 476 var k; 477 $(document).all ? k = e.keyCode : k = e.which; 478 return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); 479 }); 480 }, 481 482 b2bUnitCreationButtonfunction: function (e) 483 { 484 $("#unitNameText").on('keyup',function(e) 485 { 486 var unitName = $("#unitNameText").val(); 487 if (unitName != '') { 488 $("#createNewB2BUnitConfirmationButton").prop('disabled',false); 489 } else { 490 $("#createNewB2BUnitConfirmationButton").prop('disabled',true); 491 } 492 }); 493 } 494}; 495 496$(document).ready(function (){ 497 $("#shippingAddress1").click(function(e) 498 { 499 $(".checkbox label[for='defaultAddress']" ).show(); 500 $("#qasBillAddress").val(false); 501 }); 502 503 $("#shippingAddress2").click(function(e) 504 { 505 $(".checkbox label[for='defaultAddress']" ).hide(); 506 $("#qasBillAddress").val(true); 507 }); 508}); 509 510 511if($('input#BUSINESS').is(':checked')){ 512 $("#address-company-div").removeClass("hidden"); 513 }else{ 514 $("#address-company-div").addClass("hidden"); 515 } 516 517function showHideAddressCompanyField(addType){ 518 if(addType === 'BUSINESS'){ 519 $("#div-address-company").removeClass("hidden"); 520 } 521 else{ 522 $("#div-address-company").addClass("hidden"); 523 } 524} 525 526$('.address-company-wrapper-class label').on('click', function(){ 527 $(this).find('input').attr('checked','checked'); 528 if($('input#BUSINESS').is(':checked')){ 529 $("#address-company-div").removeClass("hidden"); 530 }else{ 531 $("#address-company-div").addClass("hidden"); 532 } 533})
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.