1ACC.quote = { 2 _autoload : [ 3 [ "bindAddComment", $("#js-quote-comments").length !== 0 ], 4 [ "bindAddEntryComment", $(".js-quote-entry-comments").length !== 0], 5 [ "toggleMoreComments", $("#js-quote-comments").length !== 0 ], 6 [ "toggleLessComments", $("#js-quote-comments").length !== 0 ], 7 [ "displayLessComments", $("#js-quote-comments").length !== 0 ], 8 [ "quoteDetailsNavigation", $(".js-quote-actions").length !== 0], 9 [ "bindQuoteButtons", $(".js-btn-quote").length !== 0 ], 10 [ "bindEditQuoteButton", $(".js-quote-edit-btn").length !== 0 ], 11 [ "bindSubmitConfirmation", $(".js-quote-submit-btn").length !== 0], 12 [ "bindCancelConfirmation", $(".js-quote-cancel-btn").length !== 0], 13 [ "bindName" , $("#js-quote-name").length !== 0], 14 [ "bindDescription" , $("#js-quote-description").length !== 0], 15 [ "bindExpirationTime", $("#js-quote-expiration-time").length !== 0], 16 [ "bindCheckoutConfirmation", $(".js-quote-checkout-btn").length !== 0], 17 [ "bindEditConfirmation", $(".js-quote-warning-btn").length !== 0], 18 [ "bindQuoteDiscount", $(".js-quote-discount-link").length !== 0], 19 [ "bindNewCartClick", $(".new__cart--link").length !== 0], 20 [ "bindQuoteDetailsActions", $(".js-quote-details-print").length !== 0], 21 "bindRefineQuoteHistorySearch", 22 "bindQuoteHistorySearchToggle", 23 "bindPodHistorySearchToggle" 24 ], 25 26 bindQuoteHistorySearchToggle: function (){ 27 $(".js-search-history-toggle").click(function(){ 28 $('a[href*="/myQuoteHistory/search?"]').each(function() { 29 var currentHref = $( this ).attr('href'); 30 if (currentHref.indexOf('showSearchOptions') >= 0) { 31 var newparam = '&showSearchOptions=' + $("#showSearchOptions").val() +'&'; 32 var newhref = currentHref.replace(/&showSearchOptions=(.*?)&/g,newparam ) 33 $( this ).attr('href', newhref) 34 } 35 }); 36 if($('.js-quote-search-container').hasClass('hidden')){ 37 $('.js-quote-search-container').removeClass('hidden'); 38 }else{ 39 $('.js-quote-search-container').addClass('hidden') 40 } 41 return false; 42 }); 43 if ($("#showSearchOptions").val() == "true" && $('.js-quote-search-container').length > 0) { 44 $(".js-search-history-toggle").click(); 45 } 46 }, 47 bindPodHistorySearchToggle: function (){ 48 $(".js-search-history-toggle").click(function(){ 49 $('a[href*="/proofOfDelivery/search?"]').each(function() { 50 var currentHref = $( this ).attr('href'); 51 if (currentHref.indexOf('showSearchOptions') >= 0) { 52 var newparam = '&showSearchOptions=' + $("#showSearchOptions").val() +'&'; 53 var newhref = currentHref.replace(/&showSearchOptions=(.*?)&/g,newparam ) 54 $( this ).attr('href', newhref) 55 } 56 }); 57 58 if($('.js-pod-search-container').hasClass('hidden')){ 59 $('.js-pod-search-container').removeClass('hidden'); 60 }else{ 61 $('.js-pod-search-container').addClass('hidden') 62 } 63 return false; 64 }); 65 if ($("#showSearchOptions").val() == "true" && $('.js-pod-search-container').length > 0) { 66 $(".js-search-history-toggle").click(); 67 } 68 }, 69 bindEditQuoteButton: function(){ 70 $(".js-quote-edit-btn").on("click", function(){ 71 var sUrl = $(this).data("quoteEditUrl"); 72 window.location = sUrl; 73 }); 74 }, 75 bindNewCartClick: function(){ 76 $(".new__cart--link").bind("click", function(event){ 77 $(this).unbind(event); 78 }); 79 }, 80 bindAddComment : function() { 81 $(document).on( 82 "keypress", 83 '#js-quote-comments #comment', 84 function(event) { 85 var key = event.keyCode; 86 87 // If the user has pressed enter 88 if (key === 13) { 89 if($('#comment').val().trim() === '') { 90 return false; 91 } 92 event.preventDefault(); 93 ACC.quote.quoteCommentSubmit($('#comment').val()); 94 $('#comment').val(""); 95 return false; 96 } else { 97 return true; 98 } 99 }); 100 }, 101 102 bindAddEntryComment: function () { 103 $(document).on( 104 "keypress", 105 ".js-quote-entry-comments", 106 function (event) { 107 var key = event.keyCode; 108 109 if (key === 13) { 110 event.preventDefault(); 111 ACC.quote.quoteEntryCommentSubmit($(this).val(), $(this).data("entry-number")); 112 return false;
113 } else { 114 return true; 115 } 116 } 117 ); 118 }, 119 120 bindQuoteButtons : function() { 121 $('.js-save-quote-btn').click(function() { 122 var url = $(this).data("saveQuoteUrl"); 123 $('#quoteForm').attr('action', url).submit(); 124 }); 125 $('.js-submit-quote-btn').click(function() { 126 var url = $(this).data("submitQuoteUrl"); 127 $('#quoteForm').attr('action', url).submit(); 128 }); 129 $('.js-accept-quote-btn').click(function() { 130 var url = $(this).data("acceptQuoteUrl"); 131 $('#quoteForm').attr('action', url).submit(); 132 }); 133 }, 134 135 quoteCommentSubmit : function(comment) { 136 var quoteComments = $("#js-quote-comments"); 137 var addCommentUrl = quoteComments.data("quote-base-link") + "comment"; 138 var showAllComments = quoteComments.data("show-all-comments"); 139 140 $.ajax({ 141 url : addCommentUrl, 142 data : { 143 comment : comment 144 }, 145 type : "post", 146 success : function(response) { 147 ACC.quote.onCommentSuccess(showAllComments); 148 } 149 }); 150 }, 151 152 quoteEntryCommentSubmit: function (comment, entryNumber) { 153 if (!comment || !comment.length) { 154 return; 155 } 156 157 var quoteComments = $("#js-quote-comments"); 158 var addEntryCommentUrl = quoteComments.data("quote-base-link") + "entry/comment"; 159 160 $.ajax({ 161 url: addEntryCommentUrl, 162 data: { 163 comment: comment, 164 entryNumber: entryNumber 165 }, 166 type: "post", 167 success: function () { 168 ACC.quote.onEntryCommentSuccess(entryNumber); 169 } 170 }); 171 }, 172 173 onCommentSuccess : function(showAllComments) { 174 $("#commentListDiv").load(location.href + " #commentListDiv", function() { 175 ACC.quote.displayComments("" + showAllComments); 176 }); 177 }, 178 179 onEntryCommentSuccess: function (entryNumber) { 180 var entryNumberHtml = ACC.common.encodeHtml(entryNumber); 181 $("#entryCommentListDiv_" + entryNumberHtml).load(location.href + " #entryCommentListDiv_" + entryNumberHtml, function () { 182 ACC.quote.displayEntryComments(entryNumberHtml); 183 }); 184 185 $("#entryComment_" + entryNumberHtml).val(""); 186 }, 187 188 toggleMoreComments : function() { 189 $(document).on('click', '#moreCommentsAnchor', ACC.quote.displayMoreComments); 190 $(document).on('click', '.js-more-entry-comments-anchor', ACC.quote.displayMoreEntryComments); 191 }, 192 193 toggleLessComments : function() { 194 $(document).on('click', '#lessCommentsAnchor', ACC.quote.displayLessComments); 195 $(document).on('click', '.js-less-entry-comments-anchor', ACC.quote.displayLessEntryComments); 196 }, 197 198 displayMoreComments : function(e) { 199 e.preventDefault(); 200 ACC.quote.displayComments("true"); 201 }, 202 203 displayMoreEntryComments: function (e) { 204 e.preventDefault(); 205 ACC.quote.displayEntryComments($(this).data("entry-number"), "true"); 206 }, 207 208 displayLessComments : function(e) { 209 if (e !== undefined) { 210 e.preventDefault(); 211 } 212 ACC.quote.displayComments("false"); 213 }, 214 215 displayLessEntryComments: function (e) { 216 e.preventDefault(); 217 ACC.quote.displayEntryComments($(this).data("entry-number"), "false"); 218 }, 219 220 displayComments : function(showAll) { 221 var quoteComments = $("#js-quote-comments"); 222 var currentCommentsShown = quoteComments.data("current-comments-shown"); 223 var comments = $('[id^="comment_"]'); 224 225 // iterate over comments. If showAll, just show, otherwise check if max comments is reached then hide 226 for (var i = 0; i < comments.length; i++) { 227 if (showAll === "true") { 228 $(comments[i]).show(); 229 } else { 230 if (i < currentCommentsShown) { 231 $(comments[i]).show(); 232 } else { 233 $(comments[i]).hide(); 234 } 235 } 236 } 237 238 // toggle anchors 239 if (showAll === "false") { 240 $('#moreCommentsAnchor').show(); 241 $('#lessCommentsAnchor').hide(); 242 quoteComments.data("show-all-comments", false); 243 } else { 244 $('#moreCommentsAnchor').hide(); 245 $('#lessCommentsAnchor').show(); 246 quoteComments.data("show-all-comments", true); 247 } 248 249 return false; 250 }, 251 252 displayEntryComments: function (entryNumber, showAll) { 253 var entryNumberHtml = ACC.common.encodeHtml(entryNumber); 254 var quoteEntryComments = $("#entryCommentListDiv_" + entryNumberHtml); 255 var comments = quoteEntryComments.find('[id^="entryComment_' + entryNumberHtml + '"]'); 256 257 showAll = showAll || "" + quoteEntryComments.data("show-all-entry-comments"); 258 259 // iterate over comments. If showAll, just show, otherwise check if max comments is reached then hide 260 for (var i = 0; i < comments.length; i++) { 261 if (showAll === "true") { 262 $(comments[i]).show(); 263 } else { 264 if (i < 4) { 265 $(comments[i]).show(); 266 } else { 267 $(comments[i]).hide(); 268 } 269 } 270 } 271 272 // toggle anchors
273 if (showAll === "false") { 274 quoteEntryComments.find(".js-more-entry-comments-anchor").show(); 275 quoteEntryComments.find(".js-less-entry-comments-anchor").hide(); 276 quoteEntryComments.data("show-all-entry-comments", false); 277 } else { 278 quoteEntryComments.find(".js-more-entry-comments-anchor").hide(); 279 quoteEntryComments.find(".js-less-entry-comments-anchor").show(); 280 quoteEntryComments.data("show-all-entry-comments", true); 281 } 282 283 return false; 284 }, 285 286 quoteDetailsNavigation: function(){ 287 $('.js-quote-actions').on('click', function(e){ 288 $(this).parent().find('nav').toggleClass('display-none'); 289 }); 290 }, 291 292 bindSubmitConfirmation : function(e) { 293 ACC.quote.handleConfirmationModal({ 294 actionButtonSelector:".js-quote-submit-btn", 295 modalWindowSelector:"#js-quote-submit-modal", 296 modalTitleDataAttributeName:"submit-confirmation-modal-title", 297 cancelButtonSelector:"#js-quote-submit-modal #submitNoButton" 298 }); 299 300 $("#quoteSubmitForm").submit(function(event) { 301 var quoteForm = $("#quoteForm"); 302 303 if (quoteForm.is("form")) { 304 event.preventDefault(); 305 306 var submitUrl = $(this).prop("action"); 307 308 quoteForm.prop("action", submitUrl); 309 quoteForm.submit(); 310 } 311 }); 312 }, 313 314 bindCheckoutConfirmation : function(e) { 315 ACC.quote.handleConfirmationModal({ 316 actionButtonSelector:".js-quote-checkout-btn", 317 modalWindowSelector:"#js-quote-checkout-modal", 318 modalTitleDataAttributeName:"submit-confirmation-modal-title", 319 cancelButtonSelector:"#js-quote-checkout-modal #submitNoButton" 320 }); 321 }, 322 323 bindCancelConfirmation: function(e) { 324 ACC.quote.handleConfirmationModal({ 325 actionButtonSelector: ".js-quote-cancel-btn", 326 modalWindowSelector: "#js-quote-cancel-modal", 327 modalTitleDataAttributeName: "cancel-confirmation-modal-title", 328 cancelButtonSelector: "#js-quote-cancel-modal #cancelNoButton" 329 }); 330 }, 331 332 bindEditConfirmation: function(e) { 333 ACC.quote.handleConfirmationModal({ 334 actionButtonSelector: ".js-quote-warning-btn", 335 modalWindowSelector: "#js-quote-edit-modal", 336 modalTitleDataAttributeName:"edit-confirmation-modal-title", 337 cancelButtonSelector: "#js-quote-edit-modal #cancelEditNoButton", 338 confirmButtonSelector: "#js-quote-edit-modal #cancelEditYesButton" 339 }); 340 }, 341 342 handleConfirmationModal: function(options) { 343 var $actionButtonSelector = $(document).find(options.actionButtonSelector); 344 $actionButtonSelector.click(function(e) { 345 e.preventDefault(); 346 347 var modalWindow = $(document).find(options.modalWindowSelector); 348 var title = modalWindow.data(options.modalTitleDataAttributeName); 349 350 if (options.initializeCallback) { 351 options.initializeCallback(); 352 } 353 354 ACC.colorbox.open(ACC.common.encodeHtml(title), { 355 inline: true, 356 href: modalWindow, 357 width: "480px", 358 escKey: false, 359 overlayClose: false, 360 onComplete: function(){ 361 ACC.colorbox.resize(); 362 } 363 }); 364 }); 365 366 var $cancelButtonSelector = $(document).find(options.cancelButtonSelector); 367 $cancelButtonSelector.click(function(e) { 368 e.preventDefault(); 369 ACC.colorbox.close(); 370 }); 371 372 var $confirmButtonSelector = $(document).find(options.confirmButtonSelector); 373 $confirmButtonSelector.click(function(e) { 374 e.preventDefault(); 375 ACC.colorbox.close(); 376 var sUrl = $actionButtonSelector.data("quoteEditUrl"); 377 window.location = sUrl; 378 }); 379 }, 380 381 bindQuoteDiscount: function(e) { 382 ACC.quote.handleDiscountModal({ 383 actionButtonSelector: ".js-quote-discount-link", 384 modalWindowSelector: "#js-quote-discount-modal", 385 modalTitleDataAttributeName: "quote-modal-title", 386 modalTotalDataAttributeName: "quote-modal-total", 387 modalQuoteDiscountDataAttributeName: "quote-modal-quote-discount", 388 modalCurrencyDataAttributeName: "quote-modal-currency", 389 cancelButtonSelector: "#js-quote-discount-modal #cancelButton" 390 }); 391 }, 392 393 bindQuoteDetailsActions: function() { 394 $(".js-quote-details-print").click(function(){ 395 window.print(); 396 }); 397 $(".js-quote-details-return-to-req").click(function(){ 398 location.href='/my-account/submitQuote/' + $(this).data('quote-number'); 399 }); 400 }, 401 402 handleDiscountModal: function(options) { 403 var modalWindow = $(document).find(options.modalWindowSelector); 404 var total = parseFloat(modalWindow.data(options.modalTotalDataAttributeName)); 405 var quoteDiscount = parseFloat(modalWindow.data(options.modalQuoteDiscountDataAttributeName)); 406 var currency = modalWindow.data(options.modalCurrencyDataAttributeName); 407 408 $(document).find(options.actionButtonSelector).click(function(e) { 409 e.preventDefault(); 410 411 var title = modalWindow.data(options.modalTitleDataAttributeName); 412 413 if (options.initializeCallback) { 414 options.initializeCallback(); 415 } 416 417 ACC.colorbox.open(ACC.common.encodeHtml(title), { 418 inline: true, 419 href: modalWindow, 420 width: "480px", 421 onComplete: function(){ 422 ACC.colorbox.resize(); 423 var percent = (quoteDiscount / total) * 100; 424 var adjustTotal = (total - quoteDiscount).toFixed(2); 425 $("#js-quote-discount-by-percentage").val(percent.toFixed(2)); 426 $("#js-quote-discount-by-amount").val(quoteDiscount.toFixed(2)); 427 $("#js-quote-discount-adjust-total").val(adjustTotal); 428 } 429 }); 430 }); 431 432 $(document).find(options.cancelButtonSelector).click(function(e) { 433 e.preventDefault(); 434 ACC.colorbox.close(); 435 }); 436 437 function enableSubmit(){ 438 $("#js-quote-discount-by-percentage").css('border-color', '#cccccc'); 439 $("#js-quote-discount-by-amount").css('border-color', '#cccccc'); 440 $("#js-quote-discount-adjust-total").css('border-color', '#cccccc'); 441 $("#submitButton").prop("disabled", false); 442 } 443 function resetIntial(val) 444 { 445 if(isNaN(parseFloat(val))){ 446 val = 0.00; 447 val=val.toFixed(2); 448 } 449 return val; 450 } 451 function updateByPercentage() 452 { 453 var percent = parseFloat($("#js-quote-discount-by-percentage").val()); 454 // input validation 455 if(percent > 100 || percent < 0){ 456 $("#js-quote-discount-by-percentage").css('border-color', 'red'); 457 $("#submitButton").prop("disabled", true); 458 }else{ 459 enableSubmit(); 460 } 461 var discountAmount = total * percent / 100; 462 var discountAmount = discountAmount.toFixed(2); 463 $("#js-quote-discount-by-amount").val(resetIntial(discountAmount)); 464 var remainTotal = total - discountAmount; 465 var remainTotal = remainTotal.toFixed(2); 466 $("#js-quote-discount-adjust-total").val(resetIntial(remainTotal)); 467 $("#js-quote-discount-rate").val(resetIntial(percent)); 468 $("#js-quote-discount-type").val("PERCENT"); 469 470 updateNewTotal(remainTotal); 471 } 472 473 $('#js-quote-discount-by-percentage').keyup(updateByPercentage); 474 $('#js-quote-discount-by-percentage').change(updateByPercentage); 475 $('#js-quote-discount-by-percentage').blur(reset); 476 $('#js-quote-discount-by-percentage').keypress(holdPreviousValue); 477 478 function reset() 479 { 480 var per = $('#js-quote-discount-by-percentage').val(); 481 var amt = $('#js-quote-discount-by-amount').val(); 482 var tot = $('#js-quote-discount-adjust-total').val(); 483 if(per === '') 484 $('#js-quote-discount-by-percentage').val('0.00'); 485 if(amt === '') 486 $('#js-quote-discount-by-amount').val('0.00'); 487 if(tot === '' || tot === 0.00) 488 $('#js-quote-discount-adjust-total').val(total); 489 } 490 491 function holdPreviousValue(event) 492 { 493 var $this = $(this); 494 if((event.which !== 46 || $this.val().indexOf('.') !== -1)) 495 { 496 if (((event.which < 48 || event.which > 57) && 497 (event.which !== 0 && event.which !== 8))) { 498 event.preventDefault(); 499 } 500 } 501 502 var text = $(this).val(); 503 if ((event.which === 46) && (text.indexOf('.') === -1)) { 504 setTimeout(function() { 505 if ($this.val().substring($this.val().indexOf('.')).length > 3) { 506 $this.val($this.val().substring(0, $this.val().indexOf('.') + 3)); 507 } 508 }, 1); 509 } 510 511 if((text.indexOf('.') !== -1)) 512 { 513 if ((text.substring(text.indexOf('.')).length > 2) && 514 (event.which !== 0 && event.which !== 8) && 515 ($(this)[0].selectionStart >= text.length - 2)) { 516 event.preventDefault(); 517 } 518 } 519 } 520 521 function updateByAmount() 522 { 523 var discountAmount = parseFloat($("#js-quote-discount-by-amount").val()); 524 525 // input validation 526 if(discountAmount > total || discountAmount < 0){ 527 $("#js-quote-discount-by-amount").css('border-color', 'red'); 528 $("#submitButton").prop("disabled", true); 529 }else{ 530 enableSubmit(); 531 } 532 533 var percent = (discountAmount / total) * 100; 534 var percent = percent.toFixed(2); 535 $("#js-quote-discount-by-percentage").val(resetIntial(percent)); 536 var remainTotal = total - discountAmount; 537 var remainTotal = remainTotal.toFixed(2); 538 $("#js-quote-discount-adjust-total").val(resetIntial(remainTotal)); 539 $("#js-quote-discount-rate").val(resetIntial(discountAmount)); 540 $("#js-quote-discount-type").val("ABSOLUTE"); 541 542 updateNewTotal(remainTotal); 543 } 544 545 $('#js-quote-discount-by-amount').keyup(updateByAmount); 546 $('#js-quote-discount-by-amount').change(updateByAmount); 547 $('#js-quote-discount-by-amount').keypress(holdPreviousValue); 548 $('#js-quote-discount-by-amount').blur(reset); 549 550 function updateByAdjustTotal() 551 { 552 var adujstTotal = parseFloat($("#js-quote-discount-adjust-total").val()); 553 554 // input validation 555 if(adujstTotal > total || adujstTotal < 0){ 556 $("#js-quote-discount-adjust-total").css('border-color', 'red'); 557 $("#submitButton").prop("disabled", true); 558 }else{ 559 enableSubmit(); 560 } 561 562 var discountAmount = total - adujstTotal; 563 var discountAmount = discountAmount.toFixed(2); 564 $("#js-quote-discount-by-amount").val(resetIntial(discountAmount)); 565 var percent = (discountAmount / total) * 100; 566 var percent = percent.toFixed(2); 567 $("#js-quote-discount-by-percentage").val(resetIntial(percent)); 568 $("#js-quote-discount-rate").val(resetIntial(adujstTotal)); 569 $("#js-quote-discount-type").val("TARGET"); 570 571 updateNewTotal(adujstTotal); 572 } 573 574 $('#js-quote-discount-adjust-total').keyup(updateByAdjustTotal); 575 $('#js-quote-discount-adjust-total').change(updateByAdjustTotal); 576 $('#js-quote-discount-adjust-total').keypress(holdPreviousValue); 577 $('#js-quote-discount-adjust-total').blur(reset); 578
579 function updateNewTotal(newTotal){ 580 if(isNaN(parseFloat(newTotal))){ 581 newTotal = total; 582 } 583 var newTotal = parseFloat(newTotal).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'); // format num to money 584 $("#js-quote-discount-new-total").text(currency.concat(newTotal)); 585 } 586 }, 587 588 bindName: function () { 589 $("#js-quote-name").on("focusout", function () { 590 ACC.quote.updateMetadata(); 591 }); 592 }, 593 594 bindDescription: function () { 595 $("#js-quote-description").on("focusout", function () { 596 ACC.quote.updateMetadata(); 597 }); 598 }, 599 600 updateMetadata: function () { 601 var quoteForm = $("#quoteFormDiv"); 602 var updateMetadataUrl = quoteForm.data("metadata-url"); 603 var name = $("#js-quote-name").val().trim(); 604 var description = $("#js-quote-description").val(); 605 var nameWrapperElement = $("#js-quote-name-wrapper") 606 607 if (name && name.length) { 608 nameWrapperElement.removeClass("has-error"); 609 610 $.ajax({ 611 url: updateMetadataUrl, 612 data: { 613 name: name, 614 description: description 615 }, 616 type: "POST", 617 success: function() { 618 $(".js-modal-quote-description").text(description); 619 $(".js-modal-quote-name").text(name); 620 } 621 }); 622 } else { 623 if (!nameWrapperElement.hasClass("has-error")) { 624 nameWrapperElement.addClass("has-error"); 625 } 626 } 627 }, 628 629 bindExpirationTime: function(e) { 630 var expirationTimeWrapperElement = $("#js-quote-expiration-time"); 631 var dateFormatForDatePicker = expirationTimeWrapperElement.data("date-format-for-date-picker"); 632 var minOfferValidityPeriodDays = expirationTimeWrapperElement.data("min-offer-validity-period-days"); 633 634 var minDate = new Date(); 635 minDate.setDate(minDate.getDate() + minOfferValidityPeriodDays); 636 637 $("#expirationTime").datepicker({ 638 dateFormat: dateFormatForDatePicker, 639 constrainInput: true, 640 minDate: minDate, 641 onSelect: function() { 642 ACC.quote.handleExpirationTimeUpdate(expirationTimeWrapperElement, dateFormatForDatePicker, 643 minOfferValidityPeriodDays); 644 } 645 }); 646 647 $("#expirationTime").change(function() { 648 ACC.quote.handleExpirationTimeUpdate(expirationTimeWrapperElement, dateFormatForDatePicker, 649 minOfferValidityPeriodDays); 650 }); 651 652 $(document).on("click", ".js-open-datepicker-quote-expiration-time", function() { 653 $("#expirationTime").datepicker('show'); 654 }); 655 }, 656 657 handleExpirationTimeUpdate: function(expirationTimeWrapperElement, dateFormat, minOfferValidityPeriodDays) { 658 var expirationTimeElement = $("#expirationTime"); 659 var expirationTime = expirationTimeElement.val(); 660 661 if (ACC.quote.validateExpirationTime(dateFormat, expirationTime, minOfferValidityPeriodDays)) { 662 ACC.quote.updateExpirationTime(expirationTime.trim()); 663 expirationTimeWrapperElement.removeClass("has-error"); 664 } else { 665 if (!expirationTimeWrapperElement.hasClass("has-error")) { 666 expirationTimeWrapperElement.addClass("has-error"); 667 } 668 } 669 }, 670 671 validateExpirationTime: function(dateFormat, value, minOfferValidityPeriodDays) { 672 try { 673 if (value) { 674 var selectedDate = $.datepicker.parseDate(dateFormat, value); 675 676 var validDate = new Date(); 677 validDate.setHours(0,0,0,0); 678 validDate.setDate(validDate.getDate() + minOfferValidityPeriodDays); 679 680 if (selectedDate >= validDate) { 681 return true; 682 } else { 683 return false; 684 } 685 } else { 686 return true; 687 } 688 } catch (error) { 689 return false; 690 } 691 }, 692 693 updateExpirationTime: function(expirationTime) { 694 var url = $("#js-quote-expiration-time").data("expiration-time-url"); 695 $.ajax({ 696 url: url, 697 type: 'POST', 698 data: {expirationTime: expirationTime}, 699 error: function (jqXHR) { 700 var expirationTimeWrapperElement = $("#js-quote-expiration-time"); 701 if (!expirationTimeWrapperElement.hasClass("has-error")) { 702 expirationTimeWrapperElement.addClass("has-error"); 703 } 704 } 705 }); 706 }, 707 708 bindRefineQuoteHistorySearch: function () { 709 $(document).on("click", '#clearFormBtnQuote', function () { 710 window.location.replace(ACC.config.encodedContextPath + '/my-account/myQuoteHistory?showSearchOptions=true'); 711 712 }); 713 $(document).on("change", '[name="rowsPerPage"]', function (event) { 714 $('[name="perPage"]').val(this.value); 715 $('#form_quoteHistoryForm').submit(); 716 }); 717 $(document).on("click", '.bse-th', function (event) { 718 var colName = $(event.target).data('column'); 719 if (colName) { 720 $('[name="sortBy"]').val(colName); 721 var curCol = $(event.target).data('sort-column'); 722 var curOrder = $(event.target).data('sort-order'); 723 if (colName == curCol) { 724 $('[name="sortDirection"]').val(curOrder == "ASC" ? "DESC" : "ASC"); 725 } else { 726 $('[name="sortDirection"]').val("ASC"); 727 } 728 $('#form_quoteHistoryForm').submit(); 729 } 730 }) 731 } 732 733}; 734 735 736$(document).ready(function () { 737 738//toggles the whole quote block 739 $('.js-quote-toggle-btn').click(function () { 740 $(this).toggleClass('open'); 741 $("#quote__form--collapse").slideToggle(400); 742 if ($(this).hasClass('open')) { 743 $(this).addClass('collapsed'); 744 } else { 745 $(this).removeClass('collapsed'); 746 } 747 }); 748 749//toggles only the comments 750 $('.js-quote-comments-btn').click(function () { 751 $(this).toggleClass('open'); 752 $("#comments__collapse").slideToggle(400); 753 if ($(this).hasClass('open')) { 754 $(this).addClass('collapsed'); 755 } else { 756 $(this).removeClass('collapsed'); 757 } 758 759 }); 760 761});
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.