1ACC.cart = { 2 3 _autoload: [ 4 "bindHelp", 5 "cartRestoration", 6 "bindCartPage", 7 "bindMultiDEntryRemoval", 8 "bindMultidCartProduct", 9 ["bindApplyVoucher", $("#js-voucher-apply-btn").length != 0], 10 ["bindToReleaseVoucher", $("#js-applied-vouchers").length != 0], 11 "bindRemoveAllClick" 12 ], 13 14 bindRemoveAllClick: function () { 15 $('#removeAllCartItems').on("click", ACC.cart.emptyCartConfirmation); 16 }, 17 18 emptyCartConfirmation: function () { 19 ACC.colorbox.open("Remove All Items",{ 20 html: "<div><p>Are you sure you want to remove all the items from your cart?</p><button class='btn-small removeAllCartItemsConfirmation' style='float:right;'>Remove All</button></div>", 21 width:"380px", 22 initialWidth :"380px", 23 fixed:true, 24 className:"nonResponsive", 25 }); 26 $('.removeAllCartItemsConfirmation').on("click", ACC.cart.emptyCart); 27 }, 28 29 emptyCart: function () { 30 $.colorbox.close(); 31 $('.cart__buyingFor .loader-img').show(); 32 $("#cartEntryActionForm").attr('method', 'GET').attr('action', '/cart/entry/execute/REMOVEALL').submit(); 33 }, 34 35 bindHelp: function () { 36 $(document).on("click", ".js-cart-help", function (e) { 37 e.preventDefault(); 38 var title = $(this).data("help"); 39 ACC.colorbox.open(ACC.common.encodeHtml(title), { 40 html: $(".js-help-popup-content").text(), 41 width: "300px" 42 }); 43 }); 44 $(document).on("click", "#passwordPattern", function (e) { 45 e.preventDefault(); 46 var title = $(this).data("help"); 47 ACC.colorbox.open(ACC.common.encodeHtml(title), { 48 html: $(".passwordPattern-popup-content").text(), 49 width: "300px" 50 }); 51 }); 52 $(document).on("click", "#chkPasswordPattern", function (e) { 53 e.preventDefault(); 54 var title = $(this).data("help"); 55 ACC.colorbox.open(ACC.common.encodeHtml(title), { 56 html: $(".chkpasswordPattern-popup-content").text(), 57 width: "300px" 58 }); 59 }); 60 $(document).on("click", "#usernamePattern", function (e) { 61 e.preventDefault(); 62 var title = $(this).data("help"); 63 ACC.colorbox.open(ACC.common.encodeHtml(title), { 64 html: $(".usernamePattern-popup-content").text(), 65 width: "300px" 66 }); 67 }); 68 $(document).on("click", "#orgaccessPattern", function (e) { 69 e.preventDefault(); 70 var title = $(this).data("help"); 71 ACC.colorbox.open(ACC.common.encodeHtml(title), { 72 html: $(".orgaccessPattern-popup-content").text(), 73 width : "400px", 74 initialWidth: "300px" 75 }); 76 $('#cboxLoadedContent').css('margin-top','0px'); 77 $('#cboxContent').css('height','190px'); 78 }); 79 }, 80 81 cartRestoration: function () { 82 $('.cartRestoration').click(function () { 83 var sCartUrl = $(this).data("cartUrl"); 84 window.location = sCartUrl; 85 }); 86 }, 87 88 bindCartPage: function () { 89 // link to display the multi-d grid in read-only mode 90 $(document).on("click", '.js-show-editable-grid', function (event) { 91 ACC.cart.populateAndShowEditableGrid(this, event); 92 }); 93 }, 94 95 bindMultiDEntryRemoval: function () { 96 $(document).on("click", '.js-submit-remove-product-multi-d', function () { 97 var itemIndex = $(this).data("index"); 98 var $form = $(document).find('#updateCartForm' + itemIndex); 99 var initialCartQuantity = $form.find('input[name=initialQuantity]'); 100 var cartQuantity = $form.find('input[name=quantity]'); 101 var entryNumber = $form.find('input[name=entryNumber]').val(); 102 var productCode = $form.find('input[name=productCode]').val(); 103 var productName = form.find('input[name=productName]').val(); 104 var productPrice = form.find('input[name=productPrice]').val(); 105 var productManufacturerData = form.find('input[name=productManufacturerData]').val(); 106 107 cartQuantity.val(0); 108 initialCartQuantity.val(0); 109 110 ACC.gtm.updateCart_gtm(productCode, productName, productPrice, productManufacturerData, initialCartQuantity, c
110artQuantity.val()); 111 112 var method = $form.attr("method") ? $form.attr("method").toUpperCase() : "GET"; 113 $.ajax({ 114 url: $form.attr("action"), 115 data: $form.serialize(), 116 type: method, 117 dataType: "text", 118 success: function (data) { 119 location.reload(); 120 }, 121 error: function () { 122 console.log("Failed to remove quantity. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 123 } 124 125 }); 126 127 }); 128 }, 129 130 populateAndShowEditableGrid: function (element, event) { 131 var readOnly = $(element).data("readOnlyMultidGrid"); 132 var itemIndex = $(element).data("index"); 133 grid = $(document).find("#ajaxGrid" + itemIndex); 134 135 var gridEntries = $(document).find('#grid' + itemIndex); 136 var strSubEntries = gridEntries.data("sub-entries"); 137 var arrSubEntries = strSubEntries.split(','); 138 var firstVariantCode = arrSubEntries[0].split(':')[0]; 139 140 $(element).toggleClass('open'); 141 142 var targetUrl = gridEntries.data("target-url"); 143 144 var mapCodeQuantity = new Object(); 145 for (var i = 0; i < arrSubEntries.length; i++) { 146 var arrValue = arrSubEntries[i].split(":"); 147 mapCodeQuantity[arrValue[0]] = arrValue[1]; 148 } 149 150 if (grid.children('#cartOrderGridForm').length > 0) { 151 grid.slideToggle("slow"); 152 } 153 else { 154 var method = "GET"; 155 $.ajax({ 156 url: targetUrl, 157 data: {productCode: firstVariantCode, readOnly: readOnly}, 158 type: method, 159 dataType: 'html', 160 success: function (data) { 161 grid.html(data); 162 $("#ajaxGrid").removeAttr('id'); 163 var $gridContainer = grid.find(".product-grid-container"); 164 var numGrids = $gridContainer.length; 165 for (var i = 0; i < numGrids; i++) { 166 ACC.cart.getProductQuantity($gridContainer.eq(i), mapCodeQuantity, i); 167 } 168 grid.slideDown("slow"); 169 ACC.cart.coreCartGridTableActions(element, mapCodeQuantity); 170 ACC.productorderform.coreTableScrollActions(grid.children('#cartOrderGridForm')); 171 }, 172 error: function (xht, textStatus, ex) { 173 console.log("Failed to get variant matrix. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 174 } 175 176 }); 177 } 178 }, 179 180 181 coreCartGridTableActions: function (element, mapCodeQuantity) { 182 ACC.productorderform.bindUpdateFutureStockButton(".update_future_stock_button"); 183 ACC.productorderform.bindVariantSelect($(".variant-select-btn"), 'cartOrderGridForm'); 184 var itemIndex = $(element).data("index"); 185 var skuQuantityClass = '.sku-quantity'; 186 187 var quantityBefore = 0; 188 var grid = $(document).find('#ajaxGrid' + itemIndex + " .product-grid-container"); 189 190 grid.on('focusin', skuQuantityClass, function (event) { 191 quantityBefore = jQuery.trim(this.value); 192 193 $(this).parents('tr').next('.variant-summary').remove(); 194 if ($(this).parents('table').data(ACC.productorderform.selectedVariantData)) { 195 ACC.productorderform.selectedVariants = $(this).parents('table').data(ACC.productorderform.selectedVariantData); 196 } else { 197 ACC.productorderform.selectedVariants = []; 198 } 199 200 if (quantityBefore == "") { 201 quantityBefore = 0; 202 this.value = 0; 203 } 204 }); 205 206 grid.on('focusout keypress', skuQuantityClass, function (event) { 207 var code = event.keyCode || event.which || event.charCode; 208 209 if (code != 13 && code != undefined) { 210 return; 211 } 212 213 var quantityAfter = 0; 214 var gridLevelTotalPrice = ""; 215 216 var indexPattern = "[0-9]+"; 217 var currentIndex = parseInt($(this).attr("id").match(indexPattern)); 218 219 this.value = ACC.productorderform.filterSkuEntry(this.value); 220 221 quantityAfter = jQuery.trim(this.value); 222 var variantCode = $(document).find("input[id='cartEntries[" + currentIndex + "].sku']").val(); 223 224 if (isNaN(jQuery.trim(this.value))) { 225 this.value = 0; 226 } 227 228 if (quantityAfter == "") { 229 quantityAfter = 0; 230 this.value = 0; 231 } 232 233 var $gridTotalValue = grid.find("[data-grid-total-id=" + 'total_value_' + currentIndex + "]"); 234 var currentPrice = $(document).find("input[id='productPrice[" + currentIndex + "]']").val(); 235 236 if (quantityAfter > 0) { 237 gridLevelTotalPrice = ACC.productorderform.formatTotalsCurrency(parseFloat(currentPrice) * parseInt(quantityAfter)); 238 } 239 240 $gridTotalValue.text(gridLevelTotalPrice); 241 242 var _this = this; 243 var priceSibling = $(this).siblings('.price'); 244 var propSibling = $(this).siblings('.variant-prop'); 245 var currentSkuId = $(this).next('.td_stock').data('sku-id'); 246 var currentBaseTotal = $(this).siblings('.data-grid-total'); 247 248 if (this.value != quantityBefore) { 249 var newVariant = true;
250 ACC.productorderform.selectedVariants.forEach(function (item, index) { 251 if (item.id === currentSkuId) { 252 newVariant = false; 253 254 if(_this.value === '0' || _this.value === 0){ 255 ACC.productorderform.selectedVariants.splice(index, 1); 256 } else { 257 ACC.productorderform.selectedVariants[index].quantity = _this.value; 258 ACC.productorderform.selectedVariants[index].total = ACC.productorderform.updateVariantTotal(priceSibling, _this.value, currentBaseTotal); 259 } 260 } 261 }); 262 263 if(newVariant && this.value > 0){ 264 // update variantData 265 ACC.productorderform.selectedVariants.push({ 266 id: currentSkuId, 267 size: propSibling.data('variant-prop'), 268 quantity: _this.value, 269 total: ACC.productorderform.updateVariantTotal(priceSibling, _this.value, currentBaseTotal) 270 }); 271 } 272 } 273 ACC.productorderform.showSelectedVariant($(this).parents('table')); 274 if (this.value > 0 && this.value != quantityBefore) { 275 $(this).parents('table').addClass('selected'); 276 } else { 277 if (ACC.productorderform.selectedVariants.length === 0) { 278 $(this).parents('table').removeClass('selected').find('.variant-summary').remove(); 279 280 } 281 } 282 283 if (quantityBefore != quantityAfter) { 284 var method = "POST"; 285 $.ajax({ 286 url: ACC.config.encodedContextPath + '/cart/updateMultiD', 287 data: {productCode: variantCode, quantity: quantityAfter, entryNumber: -1}, 288 type: method, 289 success: function (data, textStatus, xhr) { 290 ACC.cart.refreshCartData(data, -1, quantityAfter, itemIndex); 291 mapCodeQuantity[variantCode] = quantityAfter; 292 }, 293 error: function (xhr, textStatus, error) { 294 var redirectUrl = xhr.getResponseHeader("redirectUrl"); 295 var connection = xhr.getResponseHeader("Connection"); 296 // check if error leads to a redirect 297 if (redirectUrl !== null) { 298 window.location = redirectUrl; 299 // check if error is caused by a closed connection 300 } else if (connection === "close") { 301 window.location.reload(); 302 } 303 } 304 }); 305 } 306 }); 307 }, 308 309 refreshCartData: function (cartData, entryNum, quantity, itemIndex) { 310 // if cart is empty, we need to reload the whole page 311 if (cartData.entries.length == 0) { 312 location.reload(); 313 } 314 else { 315 var form; 316 317 if (entryNum == -1) // grouped item 318 { 319 form = $(document).find('.js-qty-form' + itemIndex); 320 var productCode = form.find('input[name=productCode]').val(); 321 322 var quantity = 0; 323 var entryPrice = 0; 324 for (var i = 0; i < cartData.entries.length; i++) { 325 var entry = cartData.entries[i]; 326 if (entry.product.code == productCode) { 327 quantity = entry.quantity; 328 entryPrice = entry.totalPrice; 329 ACC.cart.updateEntryNumbersForCartMenuData(entry); 330 break; 331 } 332 } 333 334 if (quantity == 0) { 335 location.reload(); 336 } 337 else { 338 form.find(".qtyValue").text(quantity); 339 form.parent().parent().find(".js-item-total").text(entryPrice.formattedValue); 340 } 341 } 342 343 ACC.cart.refreshCartPageWithJSONResponse(cartData); 344 } 345 }, 346 347 refreshCartPageWithJSONResponse: function (cartData) { 348 // refresh mini cart 349 ACC.minicart.updateMiniCartDisplay(); 350 $('.js-cart-top-totals').text($("#cartTopTotalSectionTemplate").tmpl(cartData)); 351 $('div .cartpotproline').remove(); 352 $('div .cartproline').remove(); 353 $('.js-cart-totals').remove(); 354 $('#ajaxCartPotentialPromotionSection').text($("#cartPotentialPromotionSectionTemplate").tmpl(cartData)); 355 $('#ajaxCartPromotionSection').text($("#cartPromotionSectionTemplate").tmpl(cartData)); 356 $('#ajaxCart').text($("#cartTotalsTemplate").tmpl(cartData)); 357 ACC.quote.bindQuoteDiscount(); 358 }, 359 360 updateEntryNumbersForCartMenuData: function (entry) { 361 var entryNumbers = ""; 362 $.each(entry.entries, function(index, subEntry) { 363 if(index != 0){ 364 entryNumbers = entryNumbers + ";"; 365 } 366 entryNumbers = entryNumbers + subEntry.entryNumber; 367 }); 368 $('.js-execute-entry-action-button').data('actionEntryNumbers',entryNumbers); 369 }, 370 371 getProductQuantity: function (gridContainer, mapData, i) { 372 var tables = gridContainer.find("table"); 373 374 $.each(tables, function (index, currentTable) { 375 var skus = jQuery.map($(currentTable).find("input[type='hidden'].sku"), function (o) { 376 return o.value 377 }); 378 var quantities = jQuery.map($(currentTable).find("input[type='textbox'].sku-quantity"), function (o) { 379 return o 380 }); 381 var selectedVariants = []; 382 383 $.each(skus, function (index, skuId) {
384 var quantity = mapData[skuId]; 385 if (quantity != undefined) { 386 quantities[index].value = quantity; 387 388 var indexPattern = "[0-9]+"; 389 var currentIndex = parseInt(quantities[index].id.match(indexPattern)); 390 var gridTotalValue = gridContainer.find("[data-grid-total-id=" + 'total_value_' + currentIndex + "]"); 391 var gridLevelTotalPrice = ""; 392 var currentPrice = $(document).find("input[id='productPrice[" + currentIndex + "]']").val(); 393 if (quantity > 0) { 394 gridLevelTotalPrice = ACC.productorderform.formatTotalsCurrency(parseFloat(currentPrice) * parseInt(quantity)); 395 } 396 gridTotalValue.text(gridLevelTotalPrice); 397 398 selectedVariants.push({ 399 id: skuId, 400 size: $(quantities[index]).siblings('.variant-prop').data('variant-prop'), 401 quantity: quantity, 402 total: gridLevelTotalPrice 403 }); 404 } 405 }); 406 407 if (selectedVariants.length != 0) { 408 $.tmpl(ACC.productorderform.$variantSummaryTemplate, { 409 variants: selectedVariants 410 }).appendTo($(currentTable).addClass('selected')); 411 $(currentTable).find('.variant-summary .variant-property').text($(currentTable).find('.variant-detail').data('variant-property')); 412 $(currentTable).data(ACC.productorderform.selectedVariantData, selectedVariants); 413 } 414 }); 415 416 }, 417 418 bindMultidCartProduct: function () { 419 // link to display the multi-d grid in read-only mode 420 $(document).on("click",'.showQuantityProduct', function (event){ 421 ACC.multidgrid.populateAndShowGrid(this, event, true); 422 }); 423 424 // link to display the multi-d grid in read-only mode 425 $(document).on("click",'.showQuantityProductOverlay', function (event){ 426 ACC.multidgrid.populateAndShowGridOverlay(this, event); 427 }); 428 429 }, 430 431 bindApplyVoucher: function () { 432 433 $("#js-voucher-apply-btn").on("click", function (e) { 434 ACC.cart.handleApplyVoucher(e); 435 }); 436 437 $("#js-voucher-code-text").on("keypress", function (e) { 438 var code = (e.keyCode ? e.keyCode : e.which); 439 if (code == 13) { 440 ACC.cart.handleApplyVoucher(e); 441 } 442 }); 443 }, 444 445 handleApplyVoucher: function (e) { 446 var voucherCode = $.trim($("#js-voucher-code-text").val()); 447 if (voucherCode != '' && voucherCode.length > 0) { 448 $("#applyVoucherForm").submit(); 449 } 450 }, 451 452 bindToReleaseVoucher: function () { 453 $('.js-release-voucher-remove-btn').on("click", function (event) { 454 $(this).closest('form').submit(); 455 }); 456 } 457 458}; 459 460function dateValues(backDate){ 461 var backEndDate=backDate; 462 var defaultDate; 463 if(backEndDate){ 464 var d1=new Date(backEndDate); 465 var d2=new Date(); 466 if(d1 <= d2){ 467 defaultDate=d2; 468 }else{ 469 defaultDate=d1; 470 } 471 } 472 var todayTime = new Date(defaultDate); 473 var month = todayTime .getMonth() + 1; 474 var day = todayTime .getDate(); 475 var year = todayTime .getFullYear(); 476 return month + "/" + day + "/" + year; 477 478} 479function GetFormattedDate(d) { 480 var todayTime = new Date(d); 481 var month = todayTime .getMonth() + 1; 482 var day = todayTime .getDate(); 483 var year = todayTime .getFullYear(); 484 return month + "/" + day + "/" + year; 485} 486 487function requestedDateHandler(obj){ 488 var requestDate = obj.val(); 489 if( requestDate !== obj.siblings('.backEndDate').val()) { 490 var itemCode = obj.closest('.js-cart-item-root').find(".productcodevalue").val(); 491 obj.siblings('.backEndDate').val(requestDate); 492 updateItemRequestDate(requestDate, itemCode); 493 } 494} 495 496function saveCutoffAdjustments(adjustedItems) { 497 if (adjustedItems.length > 0) {
498 var productCodes = []; 499 var requestedDates = []; 500 for (var i = 0; i < adjustedItems.length; i++) { 501 productCodes.push(adjustedItems[i].productCode); 502 requestedDates.push(adjustedItems[i].adjustedDate); 503 } 504 $.ajax({ 505 type: 'POST', 506 url: ACC.config.encodedContextPath + '/cart/updateCutoffAdjustedDates', 507 data: { 508 'productCodes[]': productCodes, 509 'requestedDates[]': requestedDates 510 }, 511 success: function () { 512 window.bseCutoffAdjustedItems = []; 513 }, 514 error: function () { 515 // Keep items in bseCutoffAdjustedItems so checkout can retry 516 console.warn('Failed to save cutoff-adjusted dates'); 517 } 518 }); 519 } 520} 521 522function updateRequestOrderDate(requestOrderDate){ 523 $.ajax({ 524 type: 'POST', 525 url: '/cart/updaterequestedorderdate', 526 data: { 527 "requestdate": requestOrderDate 528 }, 529 success: function (data) { 530 processRequestDateResponse(data); 531 } 532 }); 533} 534function processRequestDateResponse(data) { 535 $(data).find('.js-row-deliveryDates').each(function(){ 536 $('#'+$(this).attr('id')).html($(this).html()); 537 }); 538 539 initDatePickers(); 540 541 // Re-apply cutoff adjustments on the fresh server response and save them 542 window.bseCutoffAdjustedItems = applyCutoffTimeAdjustments(); 543 saveCutoffAdjustments(window.bseCutoffAdjustedItems); 544} 545 546function updateItemRequestDate(requestdate, itemcode) { 547 $.ajax({ 548 type: 'POST', 549 url: '/cart/updaterequesteddate', 550 data : { 551 "requestdate" : requestdate, 552 "itemcode" : itemcode 553 }, 554 success: function(data){ 555 processRequestDateResponse(data); 556 } 557 }); 558} 559 560function initDatePickers(){ 561 $(".requesteddate").each(function(){ 562 var ele=$(this); 563 $(this).val(dateValues($(this).parent().find(".backEndDate").val())); 564 }); 565 566 $('.requesteddate').datepicker({ 567 minDate:new Date(), 568 beforeShowDay: $.datepicker.noWeekends 569 }); 570 571 $('.requesteddate').on('change', function () { 572 requestedDateHandler($(this)); 573 }); 574 575 $('.requested-date img.icon').on('click', function () { 576 $('.requested-date .hasDatepicker').datepicker('show'); 577 }); 578 579 $('.bse-item-requested-date img.icon').on('click', function () { 580 $(this).parent().find('.requesteddate.hasDatepicker').datepicker('show'); 581 }); 582} 583 584function getNextBusinessDay(date) { 585 var next = new Date(date.getTime()); 586 next.setDate(next.getDate() + 1); 587 while (next.getDay() === 0 || next.getDay() === 6) { 588 next.setDate(next.getDate() + 1); 589 } 590 return next; 591} 592 593function formatDatePadded(d) { 594 var month = ('0' + (d.getMonth() + 1)).slice(-2); 595 var day = ('0' + d.getDate()).slice(-2); 596 var year = d.getFullYear(); 597 return month + "/" + day + "/" + year; 598} 599 600function parseDateString(str) { 601 var parts = str.trim().split('/'); 602 return new Date(parseInt(parts[2], 10), parseInt(parts[0], 10) - 1, parseInt(parts[1], 10)); 603} 604 605function isSameDay(d1, d2) { 606 return d1.getFullYear() === d2.getFullYear() 607 && d1.getMonth() === d2.getMonth() 608 && d1.getDate() === d2.getDate(); 609} 610 611function applyCutoffTimeAdjustments() { 612 var cutoffEnabled = $('#cutoffTimeEnabled').val(); 613 var cutoffHour = parseInt($('#cutoffTimeHour').val(), 10); 614 var adjustedItems = []; 615 616 if (cutoffEnabled !== 'true' || isNaN(cutoffHour)) { 617 return adjustedItems; 618 } 619 620 var now = new Date(); 621 if (now.getHours() < cutoffHour) { 622 return adjustedItems; 623 } 624 625 var today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); 626 var nextBizDay = getNextBusinessDay(today); 627 628 $('.bse-item-delivery-dates[data-product-code]').each(function () { 629 var $container = $(this); 630 var productCode = $container.attr('data-product-code'); 631 var $dateWrappers = $container.find('.bse-item-delivery-date-wrapper'); 632 var needsAdjustment = false;
633 var latestDate = null; 634 635 $dateWrappers.each(function () { 636 var $dateEl = $(this).find('.bse-date'); 637 var dateText = $dateEl.text().trim(); 638 if (!dateText) return; 639 640 var deliveryDate = parseDateString(dateText); 641 if (isSameDay(deliveryDate, today)) { 642 needsAdjustment = true; 643 if (!latestDate || nextBizDay > latestDate) { 644 latestDate = nextBizDay; 645 } 646 } else { 647 var dNorm = new Date(deliveryDate.getFullYear(), deliveryDate.getMonth(), deliveryDate.getDate()); 648 if (dNorm > today) { 649 if (!latestDate || deliveryDate > latestDate) { 650 latestDate = deliveryDate; 651 } 652 } 653 } 654 }); 655 656 // For split deliveries after cutoff, merge all dates to the latest 657 if (needsAdjustment && $dateWrappers.length > 1 && latestDate) { 658 $dateWrappers.each(function () { 659 $(this).find('.bse-date').text(formatDatePadded(latestDate)); 660 }); 661 } else if (needsAdjustment) { 662 // Single delivery date that is today - update to next business day 663 $dateWrappers.each(function () { 664 var $dateEl = $(this).find('.bse-date'); 665 var dateText = $dateEl.text().trim(); 666 if (dateText && isSameDay(parseDateString(dateText), today)) { 667 $dateEl.text(formatDatePadded(nextBizDay)); 668 } 669 }); 670 if (!latestDate) latestDate = nextBizDay; 671 } 672 673 if (needsAdjustment) { 674 var adjustedDate = latestDate || nextBizDay; 675 // Update the requested date input for this item 676 var $row = $container.closest('.js-row-deliveryDates'); 677 var $reqInput = $row.find('.requesteddate'); 678 var $backEnd = $row.find('.backEndDate'); 679 if ($reqInput.length) { 680 var currentReq = parseDateString($reqInput.val()); 681 if (isSameDay(currentReq, today)) { 682 $reqInput.val(formatDatePadded(adjustedDate)); 683 $backEnd.val(formatDatePadded(adjustedDate)); 684 } 685 } 686 adjustedItems.push({ 687 productCode: productCode, 688 adjustedDate: formatDatePadded(adjustedDate) 689 }); 690 } 691 }); 692 693 return adjustedItems; 694} 695 696$(document).ready(function () { 697 698 initDatePickers(); 699 700 // Apply cutoff time adjustments on page load and save immediately 701 window.bseCutoffAdjustedItems = applyCutoffTimeAdjustments(); 702 saveCutoffAdjustments(window.bseCutoffAdjustedItems); 703 704 $(".requestedorderdate").each(function () { 705 var ele = $(this); 706 $(this).val(dateValues($(this).parent().find(".backEndDate").val())); 707 }); 708 709 $('.requestedorderdate').on('change', function () { 710 $(this).siblings('.backEndDate').val($('.requestedorderdate').val()); 711 var requestOrderDate = $('.requestedorderdate').val(); 712 updateRequestOrderDate(requestOrderDate); 713 }); 714 715 $('.requestedorderdate').datepicker({ 716 minDate:new Date(), 717 beforeShowDay: $.datepicker.noWeekends 718 }); 719 720 $(".saveItemNotes").each(function(){ 721 $(this).on("change",function(){ 722 var itemcode=$(this).closest(".js-cart-item-root").find(".entry-product-code").text().slice(0, -2); 723 var itemNotes=$(this).parent().find(".saveItemNotes").val(); 724 $.ajax({ 725 type: 'POST', 726 url: '/cart/itemNotes', 727 data : { 728 "itemNotes" : itemNotes, 729 "itemcode" : itemcode 730 }, 731 success: function(response){ 732 console.log(response); 733 }, 734 error: function(){ 735 console.log(); 736 } 737 }); 738 }); 739 740 }); 741 742 var len = 0; 743 var maxchar = 132; 744 745 var saveItemNotesList = $(".saveItemNotes"); 746 var itemNotesRemainingList = $(".itemNotesRemainingC") 747 748 for (var i = 0; i < saveItemNotesList.length; i++) { 749 750 holder = $(saveItemNotesList[i].value.length); 751 var len = parseInt(holder[0]); 752 753 if(len > maxchar){ 754 return false;
755 } 756 else if (len > 0) { 757 $(itemNotesRemainingList[i]).html(( maxchar - len )+ " characters remaining"); 758 } 759 else { 760 $(itemNotesRemainingList[i]).html(( maxchar )+ " characters remaining"); 761 } 762 } 763 764 $('.saveItemNotes').keyup(function(){ 765 len = this.value.length 766 if(len > maxchar){ 767 return false; 768 } 769 else if (len > 0) { 770 $(this).siblings( "#itemNotesremainingC" ).html(( maxchar - len )+ " characters remaining"); 771 } 772 else { 773 $(this).siblings( "#itemNotesremainingC" ).html(( maxchar )+ " characters remaining"); 774 } 775 }) 776}); 777
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.