1ACC.productorderform = { 2 3 _autoload: [ 4 "headerActions", 5 "coreTableActions", 6 "addToCartOrderGridForm" 7 ], 8 9 $addToCartOrderForm: $("#AddToCartOrderForm"), 10 $addToCartBtn: $('#addToCartBtn'), 11 $omsErrorMessageContainer: $("#globalMessages"), 12 $emptySkuQuantityInputs: $(".sku-quantity[value]"), 13 $nonEmptySkuQuantityInputs: $(".sku-quantity[value]"), 14 $totalGridValues: $("[data-grid-total-id]"), 15 16 // Templates 17 $futureTooltipTemplate: $("#future-stock-template"), 18 $futureTooltipErrorTemplate: $("#future-tooltip-error-template"), 19 $omsErrorMessageTemplate: $("#oms-error-message-template"), 20 $variantSummaryTemplate: $("#variant-summary"), 21 selectedVariantData: 'selected-variant', 22 selectedVariants: [], 23 quantityTotal: 0, 24 scrollTopPos: 0, 25 26 headerActions: function () { 27 ACC.productorderform.bindProductDetailToggle($(".product-details-toggle")); 28 }, 29 30 coreTableActions: function () { 31 ACC.productorderform.coreTableScrollActions(ACC.productorderform.$addToCartOrderForm); 32 ACC.productorderform.bindUpdateFutureStockButton(".update_future_stock_button"); 33 ACC.productorderform.bindHideFutureStockInfo(".hide_future_stock_info"); 34 ACC.productorderform.bindVariantSelect($(".variant-select-btn"),'AddToCartOrderForm'); 35 ACC.productorderform.cancelVariantModal(".closeVariantModal"); 36 ACC.productorderform.checkLimitExceed(".sku-quantity"); 37 var skuQuantityClass = '.sku-quantity'; 38 var skuVariantQuantityClass = '#cboxContent .sku-quantity'; 39 40 var quantityBefore = 0; 41 var quantityAfter = 0; 42 43 44 ACC.productorderform.$addToCartOrderForm.on('click', skuQuantityClass, function (event) { 45 $(this).select(); 46 }); 47 48 ACC.productorderform.$addToCartOrderForm.on('focusin', skuQuantityClass, function (event) { 49 quantityBefore = jQuery.trim(this.value); 50 51 //reset 52 $(this).parents('tr').next('.variant-summary').remove(); 53 if($(this).parents('table').data(ACC.productorderform.selectedVariantData)){ 54 ACC.productorderform.selectedVariants = $(this).parents('table').data(ACC.productorderform.selectedVariantData); 55 } else { 56 ACC.productorderform.selectedVariants = []; 57 } 58 59 if (quantityBefore == "") { 60 quantityBefore = 0; 61 this.value = 0; 62 } 63 }); 64 65 $(skuQuantityClass).on('blur keypress', function (event) { 66 var code = event.keyCode || event.which || event.charCode; 67 68 if (code != 13 && code != undefined) { 69 return; 70 } 71 72 var indexPattern = "[0-9]+"; 73 var currentIndex = parseInt($(this).attr("id").match(indexPattern)); 74 var totalPrice = 0; 75 var _this = this; 76 var currentPrice = $("input[id='productPrice[" + currentIndex + "]']").val(); 77 this.value = ACC.productorderform.filterSkuEntry(this.value); 78 var $currentTotalItems = $('.js-total-items-count'); 79 var currentTotalItemsValue = $currentTotalItems.html(); 80 var currentTotalPrice = $('.js-total-price-value').val(); 81 var $gridGroup = $(this).parents('.orderForm_grid_group'); 82 83 if (isNaN(jQuery.trim(this.value))) { 84 this.value = 0; 85 } 86 87 quantityAfter = jQuery.trim(this.value); 88 if (quantityAfter == "") { 89 quantityAfter = 0; 90 this.value = 0; 91 } 92 93 //If order forms advanced search enabled 94 if(ACC.orderform) { 95 if(sessionStorage.totalItems !== undefined && sessionStorage.totalPriceVal !== undefined) { 96 currentTotalItemsValue = sessionStorage.totalItems; 97 currentTotalPrice = sessionStorage.totalPriceVal; 98 } 99 100 if (quantityBefore == 0) { 101 $currentTotalItems.html(parseInt(currentTotalItemsValue) + parseInt(quantityAfter)); 102 totalPrice = parseFloat(currentTotalPrice) + parseFloat(currentPrice) * parseInt(quantityAfter); 103 } else { 104 $currentTotalItems.html(parseInt(currentTotalItemsValue) + (parseInt(quantityAfter) - parseInt(quantityBefore))); 105 totalPrice = parseFloat(currentTotalPrice) + parseFloat(currentPrice) * (parseInt(quantityAfter) - parseInt(quantityBefore)); 106 } 107 108 sessionStorage.totalPrice = ACC.productorderform.formatTotalsCurrency(totalPrice); 109 sessionStorage.totalItems = $currentTotalItems.html() ; 110 sessionStorage.totalPriceVal = totalPrice; 111 112 ACC.orderform.addToSkuQtyInput(_this); 113 114 } else if($gridGroup && $gridGroup.length >0) { 115 var $closestQuantityValue = $gridGroup.find('#quantityValue'); 116 var $closestAvgPriceValue = $gridGroup.find('#avgPriceValue'); 117 var $closestSubtotalValue = $gridGroup.find('#subtotalValue'); 118 var currentQuantityValue = $closestQuantityValue.val(); 119 var currentSubtotalValue = $closestSubtotalValue.val(); 120 121 if (quantityBefore == 0) { 122 $closestQuantityValue.val(parseInt(currentQuantityValue) + parseInt(quantityAfter)); 123 $closestSubtotalValue.val(parseFloat(currentSubtotalValue) + parseFloat(currentPrice) * parseInt(quantityAfter)); 124 125 $currentTotalItems.html(parseInt(currentTotalItemsValue) + parseInt(quantityAfter)); 126 totalPrice = parseFloat(currentTotalPrice) + parseFloat(currentPrice) * parseInt(quantityAfter); 127 } else { 128 $closestQuantityValue.val(parseInt(currentQuantityValue) + (parseInt(quantityAfter) - parseInt(quantityBefore))); 129 $closestSubtotalValue.val(parseFloat(currentSubtotalValue) + parseFloat(currentPrice) * (parseInt(quantityAfter) - parseInt(quantityBefore))); 130 131 $currentTotalItems.html(parseInt(currentTotalItemsValue) + (parseInt(quantityAfter) - parseInt(quantityBefore))); 132 totalPrice = parseFloat(currentTotalPrice) + parseFloat(currentPrice) * (parseInt(quantityAfter) - parseInt(quantityBefore)); 133 } 134 135 ACC.productorderform.enableBeforeUnloadEvent(quantityAfter,$currentTotalItems.text()); 136 137 // if there are no items to add, disable addToCartBtn, otherwise, enable it 138 if ($currentTotalItems.length != 0 && $currentTotalItems.text() == 0) { 139 ACC.productorderform.$addToCartBtn.attr('disabled', 'disabled'); 140 $(window).off('beforeunload', ACC.productorderform.beforeUnloadHandler); 141 } else { 142 ACC.productorderform.$addToCartBtn.removeAttr('disabled'); 143 } 144 145 if (parseInt($closestQuantityValue.val()) > 0) { 146 $closestAvgPriceValue.val(parseFloat($closestSubtotalValue.val()) / parseInt($closestQuantityValue.val())); 147 } else { 148 $closestAvgPriceValue.val(0); 149 } 150 } 151 152 if($gridGroup && $gridGroup.length >0) 153 { 154 var gridLevelTotalPrice = ""; 155 var $gridTotalValue = $gridGroup.find("[data-grid-total-id=" + 'total_value_' + currentIndex + "]"); 156 157 if (quantityAfter > 0) { 158 gridLevelTotalPrice =ACC.productorderform.formatTotalsCurrency(parseFloat(currentPrice) * parseInt(quantityAfter)); 159 } 160 $gridTotalValue.html(gridLevelTotalPrice); 161 ACC.productorderform.updateSelectedVariantGridTotal(this,quantityBefore,false,false); 162 } 163 164 $('.js-total-price').html(ACC.productorderform.formatTotalsCurrency(totalPrice)); 165 $('.js-total-price-value').val(totalPrice); 166 }); 167 168 // MOBILE 169 $('body').on('focusin', skuVariantQuantityClass, function () { 170 quantityBefore = jQuery.trim(this.value); 171 172 var currentVariantId = $(this).data('variant-id'); 173 var currentBaseInput = $("#AddToCartOrderForm, #cartOrderGridForm").find("[data-variant-id='" + currentVariantId + "']"); 174 currentBaseInput.trigger('focusin'); 175 176 currentBaseInput.parents('table').find('.variant-summary').remove(); 177 if(currentBaseInput.parents('table').data(ACC.productorderform.selectedVariantData)){ 178 ACC.productorderform.selectedVariants = currentBaseInput.parents('table').data(ACC.productorderform.selectedVariantData); 179 } else { 180 ACC.productorderform.selectedVariants = []; 181 } 182 183 if (quantityBefore == "") { 184 quantityBefore = 0; 185 this.value = 0; 186 } 187 }); 188 189 $('body').on('blur', skuVariantQuantityClass, function () { 190 var priceSibling = $(this).siblings('.price'); 191 var totalSibling = $(this).siblings('.data-grid-total'); 192 var currentVariantId = $(this).data('variant-id'); 193 var currentBaseInput = $("#AddToCartOrderForm, #cartOrderGridForm").find("[data-variant-id='" + currentVariantId + "']"); 194 this.value = ACC.productorderform.filterSkuEntry(this.value); 195 196 // no text allowed || no negative number allowed || no empty string 197 if (isNaN(jQuery.trim(this.value)) || this.value < 0 || this.value == "") { 198 this.value = 0; 199 } 200 201 // set current value also to hidden input field (baseTable), because its the base of all further interaction 202 currentBaseInput.val(this.value); 203 currentBaseInput.trigger('blur'); 204 ACC.productorderform.updateVariantTotal(priceSibling, this.value, totalSibling); 205 206 // if there are no items to add, disable addToCartBtn, otherwise, enable it 207 if (this.value > 0 && this.value != quantityBefore) { 208 currentBaseInput.parents('table').addClass('selected'); 209 currentBaseInput.trigger('change'); 210 } else { 211 if (ACC.productorderform.selectedVariants.length === 0) { 212 currentBaseInput.parents('table').removeClass('selected'); 213 } 214 } 215 }); 216 }, 217 218 // MOBILE 219 updateSelectedVariantGridTotal: function(_this,quantityBefore,isFillQty,resetSummary){ 220 var priceSibling = $(_this).siblings('.price'); 221 var propSibling = $(_this).siblings('.variant-prop'); 222 var currentSkuId = $(_this).next('.td_stock').data('sku-id'); 223 var currentBaseTotal = $(_this).siblings('.data-grid-total'); 224 225 if(isFillQty) { 226 ACC.productorderform.selectedVariants = []; 227 } 228 229 if (_this.value != quantityBefore) { 230 var newVariant = true;
231 ACC.productorderform.selectedVariants.forEach(function(item, index) { 232 if(item.id === currentSkuId){ 233 newVariant = false; 234 if(_this.value === '0' || _this.value === 0){ 235 ACC.productorderform.selectedVariants.splice(index, 1); 236 } else { 237 ACC.productorderform.selectedVariants[index].quantity = _this.value; 238 ACC.productorderform.selectedVariants[index].total = ACC.productorderform.updateVariantTotal(priceSibling, _this.value, currentBaseTotal); 239 } 240 } 241 }); 242 243 if(newVariant && _this.value > 0){ 244 // update variantData 245 ACC.productorderform.selectedVariants.push({ 246 id: currentSkuId, 247 size: propSibling.data('variant-prop'), 248 quantity: _this.value, 249 total: ACC.productorderform.updateVariantTotal(priceSibling, _this.value, currentBaseTotal) 250 }); 251 } 252 } 253 254 if(resetSummary){ 255 $(_this).parents('table').find('.variant-summary').remove(); 256 } 257 258 ACC.productorderform.showSelectedVariant($(_this).parents('table')); 259 260 if (_this.value > 0 && _this.value != quantityBefore) { 261 $(_this).parents('table').addClass('selected'); 262 } else { 263 if (ACC.productorderform.selectedVariants.length === 0) { 264 $(_this).parents('table').removeClass('selected').find('.variant-summary').remove(); 265 } 266 } 267 268 }, 269 270 updateVariantTotal: function (priceSibling, quantity, totalElement) { 271 var variantTotal = parseFloat(priceSibling.data('variant-price')) * parseInt(quantity); 272 // set total in modal and baseVariant 273 totalElement.html(ACC.productorderform.formatTotalsCurrency(variantTotal)); 274 275 return ACC.productorderform.formatTotalsCurrency(variantTotal); 276 }, 277 278 bindUpdateFutureStockButton: function (updateFutureStockButton) { 279 $('body').on('click', updateFutureStockButton,function (event) { 280 event.preventDefault(); 281 282 var $gridContainer = $(this).parents('.orderForm_grid_group').find(".product-grid-container"); 283 var $skus = jQuery.map($gridContainer.find("input[type='hidden'].sku"), function (o) { 284 return o.value 285 }); 286 var skusId = $(this).data('skusId'); 287 var futureStockUrl = $(this).data('skusFutureStockUrl'); 288 var postData = {skus: $skus, productCode: skusId}; 289 var hideFutureStockInfo = $(this).parent().find(".hide_future_stock_info"); 290 var showFutureStockLink = $(this); 291 292 $.ajax({ 293 url: futureStockUrl, 294 type: 'POST', 295 data: postData, 296 traditional: true, 297 dataType: 'json', 298 success: function (data) { 299 ACC.productorderform.updateFuture($gridContainer, $skus, data, skusId, showFutureStockLink , hideFutureStockInfo); 300 }, 301 error: function (xht, textStatus, ex) { 302 alert("Failed to get delivery modes. Error details [" + xht + ", " + textStatus + ", " + ex + "]"); 303 } 304 }); 305 }); 306 }, 307 308 bindHideFutureStockInfo: function (hideFutureStockInfoLink) { 309 $('body').on('click', hideFutureStockInfoLink, function (event) { 310 event.preventDefault(); 311 var gridContainer = $(this).parent().parent().find(".product-grid-container"); 312 var updateFutureStockInfo = $(this).parent().find(".update_future_stock_button"); 313 updateFutureStockInfo.show(); 314 $(this).hide(); 315 var cell = gridContainer.find("[data-sku-id]"); 316 cell.children(".future_stock, .out-of-stock").remove(); 317 }); 318 }, 319 320 updateFuture: function (gridContainer, skus, freshData, callerId, showFutureStockInfoLink ,hideFutureStockInfo) { 321 // clear prior error messages 322 ACC.productorderform.$omsErrorMessageContainer.find("div").remove(); 323 324 function isEmpty(obj) { 325 return (Object.keys(obj).length <= 0); 326 } 327 328 if (freshData !== null && typeof freshData['basket.page.viewFuture.unavailable'] !== 'undefined') { 329 // future stock service is not available 330 $.tmpl(ACC.productorderform.$omsErrorMessageTemplate, { 331 errorMessage: freshData['basket.page.viewFuture.unavailable'] 332 }).appendTo(ACC.productorderform.$omsErrorMessageContainer); 333 } 334 else { 335 if(!isEmpty(freshData)) { 336 showFutureStockInfoLink.hide(); 337 hideFutureStockInfo.css( "display", "block"); 338 $.each(skus, function (index, skuId) { 339 var stocks = freshData[skuId]; 340 341 var cell = gridContainer.find("[data-sku-id='" + skuId + "']"); 342 var isCurrentlyInStock = cell[0].attributes['class'].nodeValue.indexOf("in-stock") != -1; 343 var futureStockPresent = typeof stocks !== 'undefined' && stocks !== null && stocks[0] !== null && typeof stocks[0] !== 'undefined'; 344 345 cell.children(".future_stock, .out-of-stock").remove(); // remove previous tool tips 346 347 if (futureStockPresent) { 348 // we have stock for this product 349 if (!isCurrentlyInStock) { 350 cell.addClass("future-stock"); 351 } 352 353 // render template and append to cell 354 $.tmpl(ACC.productorderform.$futureTooltipTemplate, { 355 formattedDate: stocks[0].formattedDate, 356 availabilities: stocks 357 }).appendTo(cell); 358 359 } else { 360 // no future stock for this product 361 if (!isCurrentlyInStock) { 362 cell[0].attributes['class'].nodeValue = "td_stock out-of-stock"; 363 } 364 } 365 }); 366 } 367 368 } 369 }, 370 371 toJSON: function (gridForm, skipZeroQuantity) { 372 var skus = gridForm.find("input.sku").map(function (index, element) { 373 return element.value 374 }), 375 skuQuantities = gridForm.find("input.sku-quantity").map(function (index, element) { 376 return parseInt(element.value) 377 }), 378 skusAsJSON = []; 379 380 for (var i = 0; i < skus.length; i++) { 381 if (!(skipZeroQuantity && skuQuantities[i] === 0)) { 382 skusAsJSON.push({"product": {"code": skus[i]}, "quantity": skuQuantities[i]}); 383 } 384 } 385 386 return JSON.stringify({"cartEntries": skusAsJSON}); 387 }, 388 389 formatTotalsCurrency: function (amount) { 390 return Currency.formatMoney(Number(amount).toFixed(2), Currency.money_format[ACC.common.currentCurrency]); 391 }, 392 393 cleanValues: function () { 394 if ($(".orderForm_grid_group").length !== 0) { 395 var formattedTotal = ACC.productorderform.formatTotalsCurrency('0.00'); 396 397 $('.js-total-price').html(formattedTotal); 398 $('#quantity, .js-total-items-count').html(0); 399 $('#quantityValue, #avgPriceValue, #subtotalValue, .
399js-total-price-value').val(0); 400 ACC.productorderform.$emptySkuQuantityInputs.val(0); 401 ACC.productorderform.$totalGridValues.html(""); 402 } 403 }, 404 405 calculateGrid: function () { 406 ACC.productorderform.$nonEmptySkuQuantityInputs.trigger('focusout'); 407 }, 408 409 bindProductDetailToggle: function (productDetailToggle) { 410 productDetailToggle.on("click", function (event) { 411 event.preventDefault(); 412 413 $(this).parents('.product-details').toggleClass('open'); 414 }); 415 }, 416 417 showSelectedVariant: function (currentVariant) { 418 // render template and append to table 419 $.tmpl(ACC.productorderform.$variantSummaryTemplate, { 420 variants: ACC.productorderform.selectedVariants 421 }).appendTo(currentVariant); 422 // save selectedVariantData 423 $('.variant-summary .variant-property').html($('.variant-detail').data('variant-property')); 424 currentVariant.data(ACC.productorderform.selectedVariantData, ACC.productorderform.selectedVariants); 425 currentVariant.removeClass('currentVariant'); 426 }, 427 428 bindVariantSelect: function (variantSelectBtn,parentId) { 429 variantSelectBtn.on("click", function (event) { 430 event.preventDefault(); 431 var currentVariant = $(this).parents('table'); 432 433 // reset 434 if(currentVariant.data(ACC.productorderform.selectedVariantData)){ 435 ACC.productorderform.selectedVariants = currentVariant.data(ACC.productorderform.selectedVariantData); 436 } else { 437 ACC.productorderform.selectedVariants = []; 438 } 439 440 var titleHeader = variantSelectBtn.html(); 441 var tableWrap = $('#'+parentId).clone().empty().attr('id', parentId+'Variant'); 442 443 currentVariant.addClass('currentVariant'); 444 var popupContent = $(this).parents('.orderForm_grid_group').clone(); 445 currentVariant.removeClass('currentVariant'); 446 $(popupContent).find('.currentVariant').siblings().remove(); 447 tableWrap.html(popupContent); 448 tableWrap.find('.hidden-xs').removeClass('hidden-xs'); 449 tableWrap.find('.hide').removeClass('hide'); 450 scrollTopPos = $('body').scrollTop(); 451 $('body').scrollTop(0); 452 453 ACC.colorbox.open(titleHeader, { 454 html: tableWrap, 455 width:"100%", 456 reposition: false, 457 className: 'variantSelectMobile', 458 onCleanup : function() { 459 if(ACC.productorderform.$addToCartOrderForm.find('.selected').length > 0) { 460 ACC.productorderform.$addToCartBtn.removeAttr('disabled'); 461 } else { 462 ACC.productorderform.$addToCartBtn.attr('disabled', 'disabled'); 463 } 464 $('body').scrollTop(scrollTopPos); 465 } 466 }); 467 }); 468 }, 469 470 cancelVariantModal: function (closeVariantModal) { 471 $('body').on('click', closeVariantModal, function (event) { 472 event.preventDefault(); 473 ACC.colorbox.close(); 474 }); 475 }, 476 checkLimitExceed: function (closeVariantModal1) { 477 $('body').on('keyup blur', closeVariantModal1, function (event) { 478 var input=Number($(this).val()); 479 var stock_amt=Number($(this).attr('data-instock')); 480 if(input>stock_amt) 481 $(this).val(stock_amt); 482 }); 483 }, 484 485 resetSelectedVariant: function () { 486 // Reset all the selectedVariant data 487 ACC.productorderform.selectedVariants = []; 488 $('.product-grid-container table').removeData(ACC.productorderform.selectedVariantData) 489 .removeClass('selected') 490 .removeClass('currentVariant'); 491 }, 492 493 addToCartOrderGridForm: function addToCartOrderGridForm() { 494 // Prevent accidentally submitting the form by hitting the Enter key. 495 $("#AddToCartOrderForm").keypress( 496 function(event){ 497 if (event.which == '13') { 498 event.preventDefault(); 499 } 500 }); 501 502 ACC.productorderform.$addToCartBtn.click(function () { 503 ACC.productorderform.$addToCartBtn.attr('disabled', 'disabled'); 504 505 $.ajax({ 506 url: ACC.productorderform.$addToCartOrderForm.attr("action"), 507 type: 'POST', 508 dataType: 'json', 509 contentType: 'application/json', 510 data: ACC.productorderform.toJSON( ACC.productorderform.$addToCartOrderForm, true), 511 async: false, 512 success: function (response) { 513 $(window).off('beforeunload', ACC.productorderform.beforeUnloadHandler); 514 ACC.product.displayAddToCartPopup(response); 515 ACC.productorderform.cleanValues(); 516 ACC.productorderform.resetSelectedVariant(); 517 }, 518 error: function (jqXHR, textStatus, errorThrown) { 519 // log the error to the console 520 console.log("The following error occured: " + textStatus, errorThrown); 521 } 522 }); 523 }); 524 }, 525 526 beforeUnloadHandler: function() { 527 return ACC.productorderform.$addToCartOrderForm.attr('data-grid-confirm-message'); 528 }, 529 530 enableBeforeUnloadEvent: function(quantityAfter,currentTotalItems) { 531 if(!ACC.orderform) 532 { 533 if(quantityAfter > 0 && currentTotalItems > 0) 534 { 535 $(window).off('beforeunload', ACC.productorderform.beforeUnloadHandler) 536 .on('beforeunload', ACC.productorderform.beforeUnloadHandler); 537 } 538 } 539 }, 540 541 filterSkuEntry: function(quantityInput){ 542 var filteredQty = 0; 543 if (/\D/g.test(quantityInput)) { 544 // Filter non-digits from input value. 545 filteredQty = quantityInput.replace(/\D/g, ''); 546 } 547 else 548 { 549 filteredQty = quantityInput; 550 } 551 return filteredQty; 552 }, 553 554 // Order form scroll 555 coreTableScrollActions: function ($scrollContent) { 556 if ($scrollContent.hasClass('visible')) { 557 ACC.productorderform.orderGridScroll($scrollContent);
558 var scrollRight = $scrollContent.parent().find('.order-form-scroll.right'), 559 scrollLeft = $scrollContent.parent().find('.order-form-scroll.left'), 560 scrollUp = $scrollContent.parent().find('.order-form-scroll.up'), 561 scrollDown = $scrollContent.parent().find('.order-form-scroll.down'); 562 var widthReference = $scrollContent.find('.widthReference').outerWidth(), 563 heightReference = $scrollContent.find('.product-grid-container table').eq(0).height() /2;// devided by 2 otherwise no nice behaviour 564 var maxWidth = 0, 565 maxHeight = 0; 566 var widthDiff = 0, 567 heightDiff = 0; 568 569 $scrollContent.find('.product-grid-container table').each(function(){ 570 if($(this).outerWidth() > maxWidth){ 571 maxWidth = $(this).outerWidth(); 572 } 573 }); 574 $scrollContent.find('.orderForm_grid_group').each(function(){ 575 maxHeight += $(this).height(); 576 }); 577 578 widthDiff = maxWidth - $scrollContent.outerWidth();//scroll-offset 579 heightDiff = maxHeight - $scrollContent.height() + 14;//scroll-offset 580 581 $scrollContent.scroll(function(){ 582 if($(this).scrollLeft() > 0) { 583 scrollLeft.show(); 584 } else { 585 scrollLeft.hide(); 586 } 587 588 if($(this).scrollLeft() >= widthDiff) { 589 scrollRight.hide(); 590 } else { 591 scrollRight.show(); 592 } 593 594 if($(this).scrollTop() > 0) { 595 scrollUp.show(); 596 } else { 597 scrollUp.hide(); 598 } 599 600 if($(this).scrollTop() >= heightDiff) { 601 scrollDown.hide(); 602 } else { 603 scrollDown.show(); 604 } 605 606 $scrollContent.find('.update-future-stock').css('margin-right', -$(this).scrollLeft()); 607 }); 608 609 $scrollContent.parent().find('.order-form-scroll').click(function () { 610 var pos = { left: $scrollContent.scrollLeft(), 611 top: $scrollContent.scrollTop() }; 612 613 if($(this).hasClass('right')) { 614 $scrollContent.scrollLeft(pos.left + widthReference); 615 } 616 else if($(this).hasClass('left')) { 617 $scrollContent.scrollLeft(pos.left - widthReference); 618 } 619 else if($(this).hasClass('up')) { 620 $scrollContent.scrollTop(pos.top - heightReference); 621 } 622 else { 623 $scrollContent.scrollTop(pos.top + heightReference); 624 } 625 }); 626 } 627 }, 628 629 orderGridScroll: function (scrollContent) { 630 var showRight = false; 631 var calcHeight = 0; 632 var maxWidth = $(scrollContent).find('.orderForm_grid_group').innerWidth(); 633 var maxHeight = $(scrollContent).innerHeight() - 18; 634 635 $(scrollContent).find('.product-grid-container table').each(function () { 636 if ($(this).width() > maxWidth) { 637 showRight = true; 638 } 639 calcHeight += $(this).height(); 640 }); 641 642 if (showRight) { 643 $(scrollContent).parent().find('.order-form-scroll.right').show(); 644 } 645 646 if (calcHeight > maxHeight) { 647 $(scrollContent).parent().find('.order-form-scroll.down').show(); 648 } 649 }, 650 651 calculateVariantTotal:function(_this,quantityToAdd){ 652 var $gridGroup = _this.parents('.orderForm_grid_group'); 653 var indexPattern = "[0-9]+"; 654 var currentIndex = parseInt(_this.attr("id").match(indexPattern)); 655 var currentPrice = $("input[id='productPrice[" + currentIndex + "]']").val(); 656 var $gridTotalValue = $gridGroup.find("[data-grid-total-id=" + 'total_value_' + currentIndex + "]"); 657 if(quantityToAdd > 0) 658 $gridTotalValue.html(ACC.productorderform.formatTotalsCurrency(parseFloat(currentPrice) * parseInt(quantityToAdd))); 659 } 660};
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.