1ACC.productDetail = { 2 3 _autoload: [ 4 "initPageEvents", 5 "bindVariantOptions", 6 "bindCollapseSlider", 7 "addWarehouseName", 8 ["disableDropdownsWithOneOption", $('div.product-main-info').length > 0], 9 ["bindCollapseText" , $('.collapse-text-container').length > 0], 10 ["initVisualizedProductVariant", $('.visualized').length > 0], 11 ["initStock", !$(".warehouse").val()], 12 "sendPDPDatalayerItem" 13 ], 14 15 sendPDPDatalayerItem: function () { 16 $(document).ready(function() { 17 if (document.getElementById("ecommerceProductDetailView").getAttribute("data-datalayerItem-value").length > 0) { 18 ACC.track.ecommerceProductDetailView(JSON.parse(document.getElementById("ecommerceProductDetailView").getAttribute("data-datalayerItem-value"))); 19 } 20 }); 21 }, 22 23 initStock: function (){ 24 $(".check-stock-status:not(.colormix-stock-status)").click(); 25 }, 26 27 checkStock: function (event , $input, $stock) { 28 var productCode = $(event).data("product"); 29 var checkStockUrl = $(event).data("url"); 30 var quantity = parseFloat($input.val().replace(',', '.')) || 1; 31 var salesUnit = $(event).data("salesunit"); 32 33 var stockParent = $stock.parent(); 34 stockParent.prepend(loaderAnimation.display()) 35 $stock.hide() 36 $.ajax({ 37 url: productCode + checkStockUrl + "?q=" + quantity, 38 cache: false, 39 type: 'GET', 40 dataType: "json", 41 success: function (res) { 42 ACC.productDetail.updateAvailabilityIndicator(res, $stock, salesUnit); 43 stockParent.find('.loader-container').remove(); 44 $stock.show(); 45 $stock.removeClass('hidden'); 46 }, 47 complete:function () { 48 ACC.tooltip.fixTooltipsPosition(); 49 } 50 }); 51 }, 52 53 updateAvailabilityIndicator: function (data, item, salesunit) { 54 var stockAvailability; 55 item? stockAvailability = item : stockAvailability = $('.stock'); 56 57 var tooltipColor = stockAvailability.find('.tooltip-color'); 58 var tooltipHolder = stockAvailability.find('.tooltip-holder'); 59 var tooltipBody = stockAvailability.find('.tooltip-body'); 60 var tooltipwraper = stockAvailability.find('.tooltip-wrapper'); 61 var availabilityLink = stockAvailability.find('.availability-link .warehouse'); 62 var warehouseHead = $('.warehouse-head'); 63 var warehouseText = $('.warehouse').text().trim(); 64 65 tooltipBody.html(""); 66 67 if(data.stockLevelStatus && data.stockLevelStatus.code){ 68 if(data.stockLevelStatus.code.toLowerCase() == "outofstock"){ 69 availabilityLink.html(stockAvailability.find('.color-wrapper').data('notAvailable')) 70 stockAvailability.addClass('out-of-stock'); 71 tooltipHolder.css('display' , 'none') 72 }else{ 73 stockAvailability.removeClass('out-of-stock'); 74 tooltipColor.removeAttr('class'); 75 tooltipColor.addClass('tooltip-color ' + data.stockStatusLightsColor); 76 77 tooltipHolder.removeAttr('class'); 78 tooltipHolder.addClass('tooltip-holder ' + data.stockStatusLightsColor); 79 80 tooltipwraper.removeAttr('class'); 81 tooltipwraper.addClass('tooltip-wrapper ' + data.stockStatusLightsColor); 82 availabilityLink.html(data.warehouseName) 83 if (warehouseHead.is(':empty')) { 84 warehouseHead.text(warehouseText); 85 } 86 87 if (data != null) { 88 warehouseText = data.warehouseName; 89 warehouseHead.text(warehouseText); 90 } 91 92 for (var stockSchedule in data.stockAllocationSchedule) { 93 const confirmedQuantity = data.stockAllocationSchedule[stockSchedule].confirmedQuantity; 94 if(confirmedQuantity != null && confirmedQuantity >= 0) {
95 var left = $('<div></div>').addClass('left').html(data.stockAllocationSchedule[stockSchedule].confirmedQuantity.toString().replace('.',',')); 96 } else { 97 var left = $('<div></div>').addClass('left').html('Error'); 98 } 99 var date = new Date(data.stockAllocationSchedule[stockSchedule].confirmedDeliveryDate); 100 var right = $('<div></div>').addClass('right').html(date.toLocaleDateString()); 101 var center = $('<div></div>').addClass('center').html(salesunit + '.'); 102 var content = left.add(right).add(center); 103 var wrap = $('<div></div>').addClass('wrap').append(content); 104 105 tooltipBody.append(wrap); 106 } 107 } 108 } else { 109 availabilityLink.html(stockAvailability.find('.color-wrapper').data('notAvailable')) 110 stockAvailability.parent().addClass('out-of-stock'); 111 tooltipHolder.css('display' , 'none') 112 } 113 }, 114 115 bindCollapseSlider: function () { 116 $(document).ready(function () { 117 var collapseComponent = $(".custom-collapse"); 118 var collapseProductDetailsContent = $(".collapse-product-details-content"); 119 var collapseGradient = $(".collapse-gradient"); 120 var collapseToggle = $(".collapse-toggle-wrapper"); 121 var collapseToggleBtn = $("#collapseToggle"); 122 123 if (collapseProductDetailsContent.height() <= 258) { 124 collapseGradient.hide(); 125 collapseToggle.hide(); 126 } else { 127 collapseToggleBtn.text("Mehr anzeigen"); 128 collapseToggleBtn.click(function () { 129 var $this = $(this); 130 if ($this.text() === "Mehr anzeigen") { 131 collapseGradient.css("margin-top", collapseProductDetailsContent.height()); 132 collapseComponent.css("height", collapseProductDetailsContent.height()); 133 $this.text("Weniger anzeigen"); 134 } else { 135 collapseGradient.css("margin-top", 208); 136 collapseComponent.css("height", 0); 137 $this.text("Mehr anzeigen"); 138 } 139 }); 140 } 141 }); 142 143 }, 144 bindCollapseText : function(){ 145 var initContentHeight = $('.collapse-text-content').height(); 146 if($('.collapse-text-content').height() > 65){ 147 $('.collapse-text-container').addClass('active') 148 $('.show-more').click(function () { 149 $(this).parent().parent().addClass('open') 150 $('.collapse-text-content').css('max-height' , initContentHeight) 151 }) 152 $('.show-less').click(function () { 153 $(this).parent().parent().removeClass('open') 154 $('.collapse-text-content').removeAttr('style') 155 }) 156 } 157 158 }, 159 160 checkQtySelector: function (self, mode) { 161 var input = $(self).parents(".js-qty-selector").find(".js-qty-selector-input"); 162 var formattedVal = input.val().replace(',', '.'); 163 var inputVal = +formattedVal; 164 var minusBtn = $(self).parents(".js-qty-selector").find(".js-qty-selector-minus"); 165 var step = input.data('min'); 166 var minQtyMulti = +input.data('minimum-multiple-quantity'); 167 if(minQtyMulti) { 168 step = minQtyMulti; 169 } 170 171 $(self).parents(".js-qty-selector").find(".btn").removeAttr("disabled"); 172 173 if (mode === "minus") { 174 if (inputVal >= step) { 175 ACC.productDetail.updateQtyValue(self, inputVal - step); 176 if (inputVal - step <= step) { 177 minusBtn.attr("disabled", "disabled"); 178 } 179 } else { 180 minusBtn.attr("disabled", "disabled"); 181 } 182 } else if (mode === "reset") { 183 ACC.productDetail.updateQtyValue(self, step); 184 185 } else if (mode === "plus") { 186 ACC.productDetail.updateQtyValue(self, inputVal + step); 187 } else if (mode === "input") { 188 if (inputVal === step) { 189 minusBtn.attr("disabled", "disabled"); 190 } 191 } else if (mode === "focusout") { 192 ACC.productDetail.updateQtyValue(self, inputVal, 'focusout'); 193 if (inputVal <= step) { 194 minusBtn.attr("disabled", "disabled"); 195 } else { 196 minusBtn.removeAttr('disabled'); 197 } 198 } 199 $(".check-stock-status").click(); 200 }, 201 202 updateQtyValue: function (self, value, mode) { 203 if(mode !== 'focusout') { 204 var input = $(self).parents(".js-qty-selector").find(".js-qty-selector-input"); 205 206 input.val(value) 207 input.blur(); 208 } 209 var addtocartQty = $(self).parents(".addtocart-component").find("#addToCartForm").find(".js-qty-selector-input"); 210 addtocartQty.val(value); 211 }, 212 213 initPageEvents: function () { 214 $("input:radio[name='pim']").change(function () { 215 console.log($(this).val()) 216 ACC.colorCube.pim = $(this).val() 217 }) 218 $(document).on("click", '.js-qty-selector .js-qty-selector-minus', function () { 219 ACC.productDetail.checkQtySelector(this, "minus"); 220 }); 221 222 $(document).on("click", '.js-qty-selector .js-qty-selector-plus', function () { 223 ACC.productDetail.checkQtySelector(this, "plus"); 224 }); 225 226 $(document).on("click", '#addToCartForm .js-add-to-cart', function (e) { 227 e.preventDefault(); 228 var variantSelects = $('.js-product-variant-selector option.placeholder:selected'); 229 230 if(variantSelects.length > 1){ 231 $("#select_variant_error").css('display', 'block'); 232 }else if(!$(this).hasClass('needFarbton')) { 233 var addToCartForm = $(e.target).parent(), 234 addToCartQty = $(addToCartForm).find(".js-qty-selector-input"), 235 formattedVal = addToCartQty.val().replace(',', '.') 236 addToCartQty.val(+formattedVal); 237 238 addToCartForm.submit(); 239 }else{ 240 $('.farbton-input-container').addClass('error') 241 } 242 }); 243 244 $(document).on("keydown", '.js-qty-selector .js-qty-selector-input', function (e) { 245 if (($(this).val() != " " && (isNumeric(e.key))) || isSeperator(e.key) || isNavigation(e.key)) { 246 } else if (e.which === 38) { 247 ACC.productDetail.checkQtySelector(this, "plus"); 248 } else if (e.which === 40) { 249 ACC.productDetail.checkQtySelector(this, "minus"); 250 } else { 251 ACC.productDetail.checkQtySelector(this); 252 e.preventDefault(); 253 } 254 }); 255 256 function isNumeric(key) { 257 return !isNaN(key); 258 } 259 260 function isSeperator(key) { 261 return key === "," || key === "."; 262 } 263 264 function isNavigation(key){ 265 return key === "Backspace" || key === "Delete" || key === "ArrowLeft" || key === "ArrowRight" || key === "Tab"; 266 } 267 268 $(document).on("focusout", '.js-qty-selector .js-qty-selector-input', function (e) { 269 ACC.productDetail.checkQtySelector(this, "focusout"); 270 }); 271 272 $("#Size").change(function () { 273 changeOnVariantOptionSelection($("#Size option:selected")); 274 }); 275 276 $("#variant").change(function () { 277 changeOnVariantOptionSelection($("#variant option:selected")); 278 }); 279 280 function debounce(func, wait) 281 { 282 let timeout; 283 return function (...args) 284 { 285 const context = this; 286 clearTimeout(timeout); 287 timeout = setTimeout(() =>
287 func.apply(context, args), wait); 288 }; 289 } 290 291 let stockCheckTimeout = parseInt($(".config").data("stock-check-timeout"), 10) || 2000; 292 293 $(document).on("click keydown", '.check-stock-status', debounce(function (event) 294 { 295 console.log("stock-check-trigger"); 296 if (isValidInteraction(event)) 297 { 298 ACC.productDetail.checkStock(this, $("#pdpAddtoCartInput"), $('.stock')); 299 } 300 }, stockCheckTimeout)); 301 302 function isValidInteraction(event) 303 { 304 return ( 305 event.type === "click" || 306 (event.type === "keydown" && (event.key === "Enter" || event.key === "Tab")) 307 ); 308 } 309 310 $(document).on("click", '.check-variant-stock-status', debounce(function (event) { 311 312 if (isValidInteraction(event)) { 313 ACC.productDetail.checkStock(this, $(this).closest('.widthReference').find('.sku-quantity'), $(this).closest('.widthReference').find('.stock')); 314 } 315 }, stockCheckTimeout)); 316 317 function changeOnVariantOptionSelection(optionSelected) { 318 window.location.href = optionSelected.attr('value'); 319 } 320 321 // show current selector by initial load 322 $(".selectPriority").change(function () { 323 window.location.href = $(this[this.selectedIndex]).val(); 324 }); 325 326 // show current selector by change event 327 $(".selectPriority").change(function () { 328 ACC.productDetail.resetVariantSelector($(this)); 329 ACC.productDetail.showVariantSelector($(this)); 330 ACC.productDetail.hideQuantityControls(); 331 }); 332 333 $('.js-product-variant-selector').on('change', function () { 334 ACC.productDetail.resetVariantSelector($(this)); 335 336 var productCode = $(this).find('option:selected').data('product-code'); 337 $('.add_to_cart_form').find('input[name=productCodePost]').val(productCode); 338 window.location.href = $(this).find('option:selected').val(); 339 }); 340 341 342 if($('.js-qty-selector-input').data('min') > 1){ 343 $('.check-stock-status').click() 344 } 345 346 // disable the addToCart button on reloading 347 window.onbeforeunload = function () { 348 $('#addToCartButton').attr('disabled' , 'disabled') 349 } 350 }, 351 352 resetVariantSelector: function(select){ 353 $('.js-product-variant-selector').not(select).each(function(){ 354 var currentSelect = $(this).val($('option:first', $(this)).val()); 355 var placeholder = currentSelect.parents('.custom-select').find('.select-items .placeholder').html(); 356 currentSelect.parents('.custom-select').find('.select-selected .select-selected-custom').html(placeholder); 357 }); 358 }, 359 360 showVariantSelector: function(select){ 361 var selectedVariant = select.find('option:selected').data('variant'); 362 $('.variant-elements-select').addClass('hide'); 363 $('#variant-elements-' + selectedVariant).removeClass('hide'); 364 ACC.productDetail.toggleQuantityControls(); 365 }, 366 367 toggleQuantityControls: function(){ 368 var selected = $('.variant-elements-select .js-product-variant-selector option:selected').not('.placeholder'); 369 370 if(selected.length > 0){ 371 ACC.productDetail.showQuantityControls(); 372 }else{ 373 ACC.productDetail.hideQuantityControls(); 374 } 375 }, 376 377 showQuantityControls: function(){ 378 $('.quantity-controls, .stock-wrapper').removeClass('hide'); 379 }, 380 381 hideQuantityControls: function(){ 382 $('.quantity-controls, .stock-wrapper').addClass('hide'); 383 }, 384 385 bindVariantOptions: function () { 386 ACC.productDetail.bindCurrentStyle(); 387 ACC.productDetail.bindCurrentSize(); 388 ACC.productDetail.bindCurrentType(); 389 }, 390 391 bindCurrentStyle: function () { 392 var currentStyle = $("#currentStyleValue").data("styleValue"); 393 var styleSpan = $(".styleName"); 394 if (currentStyle != null) { 395 styleSpan.text(": " + currentStyle); 396 } 397 }, 398 399 bindCurrentSize: function () { 400 var currentSize = $("#currentSizeValue").data("sizeValue"); 401 var sizeSpan = $(".sizeName"); 402 if (currentSize != null) { 403 sizeSpan.text(": " + currentSize); 404 } 405 }, 406 407 bindCurrentType: function () { 408 var currentSize = $("#currentTypeValue").data("typeValue"); 409 var sizeSpan = $(".typeName"); 410 if (currentSize != null) { 411 sizeSpan.text(": " + currentSize); 412 } 413 }, 414 disableDropdownsWithOneOption: function () { 415 $('select').each(function () { 416 if($(this).find('option').length < 2){ 417 $(this).attr("disabled", "disabled"); 418 } 419 }) 420 }, 421 422 initVisualizedProductVariant : function () { 423 var $list = $('.visualized ul');
424 var numOfFittedEl = parseInt(($list.width()+10) /60); 425 426 // check the position of the selected variant to know weather we should initialize the show-more logic or not 427 var selectedItemIndex = 0; 428 $list.children().each(function (i) { 429 if($(this).hasClass('selected')) { 430 selectedItemIndex = i; 431 } 432 }); 433 if(selectedItemIndex < numOfFittedEl) { 434 var $showMore = $list.find('.show-more'); 435 ACC.productDetail.calculateVisualizedProductVariant($list, $showMore) 436 $(window).resize(function(){ 437 ACC.productDetail.calculateVisualizedProductVariant($list, $showMore) 438 }); 439 } 440 }, 441 calculateVisualizedProductVariant: function ($list, $showMore) { 442 // 60 = the square width (50) + the gab between the squares (10) 443 // $list.width()+ removing the extra 10 that we get from the last square (since it has no gap after it) 444 var numOfFittedEl = parseInt(($list.width()+10) /60); 445 if ($list.width() > 540) { 446 if(numOfFittedEl < $list.children().length -1) { 447 $list.addClass('too-many') 448 $list.removeClass('two-rows') 449 $showMore.css('grid-column-start' , numOfFittedEl.toString()); 450 }else { 451 $list.removeClass('too-many') 452 } 453 }else { 454 if(numOfFittedEl*2 < $list.children().length -1) { 455 $list.addClass('too-many') 456 $list.addClass('two-rows') 457 $showMore.css('grid-column-start' , numOfFittedEl.toString()); 458 }else { 459 $list.removeClass('too-many') 460 } 461 } 462 463 $showMore.click(function (e) { 464 e.preventDefault(); 465 $(this).parent().removeClass('too-many') 466 }) 467 }, 468 getProductInfo: function (productCode) { 469 var url = ACC.config.encodedContextPath + '/quickOrder/productInfo?code=' + productCode; 470 return $.ajax({ 471 url : url, 472 type : 'GET', 473 success : function(result) { 474 console.log(result) 475 if (result.errorMsg != null && result.errorMsg.length > 0) { 476 console.log(result.errorMsg) 477 } 478 }, 479 error : function(jqXHR, textStatus, errorThrown) { 480 console.log("The following error occurred: " + textStatus, errorThrown); 481 } 482 }); 483 }, 484 initializeProductAvailabilityCheckLink: function (product, $link) { 485 $link.data('url', product.url + '/stock/schedule'); 486 $link.data('product', product.code); 487 product.price && product.price.unitForNetPrice && $link.data('salesunit', product.price.unitForNetPrice.sapCode); 488 }, 489 hideProductAvailability: function () { 490 var $addToCart = $('.addtocart-component'); 491 $addToCart.find('.stock-error').addClass('hidden'); 492 $addToCart.find('.stock').addClass('hidden'); 493 $addToCart.find('.check-stock-status').addClass('hidden'); 494 $addToCart.find('.stock-warning').show(); 495 }, 496 showProductAvailability: function () { 497 var $addToCart = $('.addtocart-component'); 498 $addToCart.find('.stock').removeClass('hidden'); 499 $addToCart.find('.check-stock-status').removeClass('hidden'); 500 $addToCart.find('.stock-warning').hide(); 501 },
502 addWarehouseName: function () { 503 function fillEmptyWarehouseHead() { 504 var warehouseHead = $('.warehouse-head:empty'); 505 var warehouseText = $('.warehouse').text().trim(); 506 if (warehouseText.length > 0) { 507 warehouseHead.text(warehouseText); 508 } 509 } 510 function checkConditions() { 511 var warehouseHeadIsEmpty = $('.warehouse-head:empty').length > 0; 512 var warehouseTextNotEmpty = $('.warehouse').text().trim().length > 0; 513 if (warehouseHeadIsEmpty && warehouseTextNotEmpty) { 514 clearInterval(checkInterval); 515 fillEmptyWarehouseHead(); 516 } 517 } 518 if ($('.product-main-info').length) { 519 checkConditions(); // Ãberprüfen Sie zuerst den aktuellen Status 520 var checkInterval = setInterval(checkConditions, 100); 521 } 522 } 523};
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.