1var spinner = '<div class="loader-container" style="margin-left: 50%">\n' + '\t\t<div class="lds-dots">\n' + '\t\t\t<div class="dot dot__first">\n' + '\t\t\t</div>\n' + '\t\t\t<div class="dot dot__second">\n' + '\t\t\t</div>\n' + '\t\t\t<div class="dot dot__third">\n' + '\t\t\t</div>\n' + '\t</div>' + '\t</div>' 2 3ACC.documentFinder = { 4 5 _autoload: ["handleChangedDocumentKind", "bindToAddToCartFormDocument", "enableDocumentKind", "enableDownloadLink"], 6 multiDownloadInterval: null, 7 hadRunningDownloads: false, 8 9 enableDownloadLink: function(){ 10 $(document) 11 .off("click.documentFinder", ".download-link") 12 .on("click", ".download-link", function(event) { 13 event.preventDefault(); 14 console.count('download-link click'); 15 // Prevent default anchor behavior 16 if ($(event.currentTarget).hasClass('disabled')) { 17 return; 18 } 19 20 $('.global-alerts').html(""); 21 ACC.documentFinder.doAjaxCallMoreDownload(this, event); 22 }); 23 }, 24 25 enableRefreshDownloads: function() { 26 var self = this; 27 28 if (self.multiDownloadInterval !== null) { 29 return; 30 } 31 32 self.refreshMultiDownloads(); 33 34 self.multiDownloadInterval = setInterval(function() { 35 self.refreshMultiDownloads(); 36 }, 1000); 37 }, 38 stopDownloadsPolling: function() { 39 if (this.multiDownloadInterval !== null) { 40 clearInterval(this.multiDownloadInterval); 41 this.multiDownloadInterval = null; 42 } 43 }, 44 enableDocumentKind() { 45 $(document).ready(function() { 46 $('select[name="documentKind"]').prop('disabled', false); 47 }); 48 }, 49 50 // enableRefreshDownloads() {setInterval(function() { 51 // ACC.documentFinder.refreshMultiDownloads(); 52 // }, 1000); 53 // }, 54 downloadPdf: function(element, event, endpoint) { 55 event.preventDefault(); 56 var documentType = $(element).data("documenttype"); 57 var invoiceCode = $(element).data("documentnumber"); 58 var url = ACC.config.contextPath + '/documents/' + endpoint + '/' + documentType + "/" + invoiceCode; 59 60 $.ajax({ 61 url: url, 62 type: 'GET', 63 // fetch body to check if PDF exists 64 success: function(data) { 65 if (!data || data.length === 0) { 66 ACC.documentFinder.showNoPdfMessage(invoiceCode); 67 } else { 68 window.open(url, '_blank', "width=1024,height=768,resizable=yes,scrollbars=yes"); 69 } 70 }, 71 error: function(xhr) { 72 console.error("Error downloading PDF:", xhr.status); 73 ACC.documentFinder.showNoPdfMessage(invoiceCode); 74 } 75 }); 76 77 return false; 78 }, 79 downloadInvoice: function(element, event) { 80 "use strict"; 81 event.preventDefault(); 82 var documentType = $(element).data("documenttype"); 83 var invoiceCode = $(element).data("documentnumber") 84 , options = { 85 url: ACC.config.contextPath + '/documents/downloadInvoice/' + documentType + "/" + invoiceCode, 86 type: 'GET', 87 contentType: 'application/pdf', 88 sync: true, 89 success: function(data) { 90 window.open(this.url, '_blank', "width=1024,height=768,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no"); 91 }, 92 error: function(data, textStatus, ex) { 93 var body = $("html, body"); 94 body.stop().animate({ 95 scrollTop: 0 96 }, '500', 'swing', function() { 97 }); 98 } 99 }; 100 $(element).ajaxSubmit(options); 101 return false; 102 }, 103 104 doAjaxCallForInvoice: function(element, event) { 105 return ACC.documentFinder.downloadPdf(element, event, 'downloadPDF'); 106 }, 107 doAjaxCallForDownloadInvoice: function(element, event) { 108 return ACC.documentFinder.downloadInvoice(element, event, 'downloadInvoice'); 109 }, 110 111 doAjaxCallForLieferscheinnachweis: function(element, event) { 112 return ACC.documentFinder.downloadPdf(element, event, 'downloadLieferscheinnachweis'); 113 }, 114 115 showNoPdfMessage: function(invoiceCode) { 116 var $msgBox = $("#noPdfMessageBox"); 117 var msgTemplate = $msgBox.data("template"); 118 var msg = msgTemplate.replace("{0}", invoiceCode); 119 120 $msgBox.text(msg).stop(true, true).fadeIn(500).delay(4000).fadeOut(500); 121 }, 122 123 doAjaxCallMoreDownload: function(element, event) { 124 let selectedNumbers = {}; 125 if (element.classList.contains("download-both")) { 126 selectedNumbers[element.dataset.documentnumber] = element.dataset.documenttype; 127 } else { 128 $('input[name="selectedDeliveries"]:checked').each(function() { 129 const checkboxValue = this.value; 130 131 const documentType = $(this).closest('tr').find('.download-l
131ink, .downloadLieferscheinnachweis, .downloadPDF').data('documenttype'); 132 133 selectedNumbers[checkboxValue] = documentType; 134 }); 135 } 136 if (Object.keys(selectedNumbers).length === 0) { 137 $('.download-more-message').fadeIn(); 138 setTimeout(()=>{ 139 $('.download-more-message').fadeOut(); 140 } 141 , 5000); 142 return; 143 } 144 145 const documentType = $(element).data('documenttype'); 146 147 $.ajax({ 148 url: ACC.config.encodedContextPath + '/documents/download-more-documents', 149 method: 'POST', 150 contentType: 'application/json', 151 data: JSON.stringify({ 152 documentNumbers: selectedNumbers 153 }), 154 xhrFields: { 155 responseType: 'blob' 156 }, 157 success: function(blob, textStatus, xhr) { 158 const status = xhr.getResponseHeader('X-Download-Status'); 159 if (xhr.status === 200 && status === 'READY') { 160 if (!blob || blob.size === 0) { 161 ACC.documentFinder.showNoPdfMessage(Object.keys(selectedNumbers).join(", ")); 162 return; 163 } 164 165 const url = window.URL.createObjectURL(blob); 166 const a = document.createElement('a'); 167 a.href = url; 168 const now = new Date(); 169 const formattedDateTime = getFormattedLocalDateTime(); 170 a.download = `${documentType}_ ${formattedDateTime}.zip`; 171 document.body.appendChild(a); 172 a.click(); 173 a.remove(); 174 window.URL.revokeObjectURL(url); 175 } else if (xhr.status === 202 && status === 'STARTED') { 176 //download cj started 177 ACC.documentFinder.enableRefreshDownloads(); 178 } 179 }, 180 error: function() { 181 ACC.documentFinder.showNoPdfMessage(Object.keys(selectedNumbers).join(", ")); 182 } 183 }); 184 }, 185 186 refreshMultiDownloads: function() { 187 $.ajax({ 188 url: ACC.config.encodedContextPath + '/documents/documentFinder/multiDownload/status', 189 type: 'GET', 190 success: function(html) { 191 $('#multiDownloadContainer').html(html); 192 var runningCount = $('#runnigMultiDownloads .multidownloadRow').length; 193 if (runningCount >= 5) { 194 $('.download-link').addClass('disabled'); 195 } else { 196 $('.download-link').removeClass('disabled'); 197 } 198 var finishedCount = $('#finishedMultiDownlads .multidownloadRow').length; 199 if (runningCount > 0) { 200 self.hadRunningDownloads = true; 201 } 202 if (runningCount === 0 && self.hadRunningDownloads && finishedCount > 0) { 203 console.log("stop polling") 204 ACC.documentFinder.stopDownloadsPolling(); 205 } 206 } 207 }); 208 }, 209 210 handleChangedDocumentKind: function() { 211 "use strict"; 212 $(document).on("change", '#profile\\.firstName', function() { 213 var options = { 214 'documentKind': $(this).val() 215 }; 216 if (options.documentKind === "delivery") { 217 $(".documentfindersearchresults-container").show(); 218 ACC.documentFinder.refreshMultiDownloads(); 219 $("#multiDownloadContainer").show(); 220 $(".nav-tabs").hide(); 221 $(".docs-invoices-sum ").hide(); 222 } else { 223 $(".documentfindersearchresults-container").hide(); 224 $(".nav-tabs").show(); 225 $(".docs-invoices-sum ").show(); 226 $("#multiDownloadContainer").hide(); 227 } 228 $.ajax({ 229 url: ACC.config.encodedContextPath + '/documents/filterForm', 230 async: true, 231 data: options, 232 dataType: "html", 233 beforeSend: function() { 234 $("#toreplace").html(ACC.address.spinner); 235 } 236 }).done(function(data) { 237 238 $("#toreplace").html($(data).html()); 239 let format = "dd/MM/yy" 240 if (navigator.language == "de-DE") { 241 format = "dd.mm.yy" 242 } 243 $("#datepickerfrom").datepicker({ 244 dateFormat: format 245 }); 246 $("#datepickerto").datepicker({ 247 dateFormat: format 248 }); 249 $('#search').get(0).value = "";
250 // clear search field 251 }); 252 }); 253 254 $(document).on("change", '#documentPeriode', function() { 255 256 if ($(this).val() === "custom") { 257 $(".date-periode-selector").show(); 258 } else { 259 $(".date-periode-selector").hide(); 260 } 261 262 }); 263 let format = "dd/MM/yy" 264 if (navigator.language == "de-DE") { 265 format = "dd.mm.yy" 266 } 267 $("#datepickerfrom").datepicker({ 268 dateFormat: format 269 }); 270 $("#datepickerto").datepicker({ 271 dateFormat: format 272 }); 273 274 try { 275 if ($('#documentPeriode').get(0).value == "custom") { 276 $(".date-periode-selector").show(); 277 } 278 } catch (err) {// value is null, this happens when every other page than /documents 279 // is opened 280 } 281 $(document).on("change", '#documentCriteria', function() { 282 283 if ($(this).val() != "") { 284 $(".additional-search-text").show(); 285 } else { 286 $(".additional-search-text").hide(); 287 } 288 289 }); 290 291 try { 292 if ($('#documentCriteria').get(0).value != "") { 293 $(".additional-search-text").show(); 294 } 295 } catch (err) {// value is null, this happens when every other page than /documents 296 // is opened 297 } 298 $(document).on("click", "#searchDocuments", function() { 299 let requestString = $('#searchForm').serializeArray() 300 /* 301 * jQuery.each(requestString, function(i, field) { 302 * if (field.name == "toDate") { let d = 303 * $("#datepickerto").datepicker( "getDate"); if (d) { 304 * field.value = d.toJSON().toString(); } } if 305 * (field.name == "fromDate") { let d = 306 * $("#datepickerfrom").datepicker( "getDate"); if 307 * (d) { field.value = d.toJSON().toString(); } } 308 * }); 309 */ 310 requestString = $.param(requestString); 311 $.ajax({ 312 url: ACC.config.encodedContextPath + '/documents/searchResults?' + requestString, 313 async: true, 314 dataType: "html", 315 beforeSend: function() { 316 $("#docList").html(spinner); 317 $("#tabs_belege a[href='#docList']").tab('show'); 318 } 319 }).done(function(data) { 320 $("#docList").html($(data).html()); 321 // number of elements minus the 322 // header returns the count. 323 var numberOfDocuments = $("#docList table tbody").children().not(".hidden-md, .hidden-lg, .noDeliveriesFound").length; 324 var searchruslttext = $(".doclistNoOfPositions").text(); 325 $(".doclistNoOfPositions").text(searchruslttext.replace(/\b\d+\b/, parseInt(numberOfDocuments) || 0)); 326 $("#doclistNoOfPositions").text(parseInt(numberOfDocuments) || 0); 327 $(".documentLink").each(function() { 328 // handle 329 // tab 330 // clicked 331 ACC.documentFinder.handleTabClicked($(this)); 332 }); 333 if ($("#profile\\.firstName").find(":selected").val() === "delivery") { 334 $("#belege-table").DataTable({ 335 searching: false, 336 autoWidth: false, 337 paging: false, 338 info: false, 339 columnDefs: [{ 340 orderable: false, 341 targets: [1, 4] 342 }// disable on column 0 and 4 343 ] 344 }); 345 }else if($.fn.dataTable.isDataTable('#belege-table')){ 346 var table = new DataTable('#belege-table'); 347 table.destroy(); 348 } 349 $('.download-link:not(.download-both)').addClass('disabled'); 350 351 const checkboxes = document.querySelectorAll('input[name="selectedDeliveries"], #selectAllCheckbox'); 352
353 checkboxes.forEach(cb=>{ 354 cb.addEventListener('change', ()=>{ 355 const anyChecked = [...checkboxes].some(c=>c.checked); 356 357 if (anyChecked) { 358 $('.download-link').removeClass('disabled'); 359 360 } else { 361 $('.download-link').addClass('disabled'); 362 $('.download-both').removeClass('disabled'); 363 } 364 } 365 ); 366 } 367 ); 368 }); 369 370 371 372 373 }); 374 375 $(document).on("click", ".downloadPDF", function(event) { 376 $('.global-alerts').html(""); 377 ACC.documentFinder.doAjaxCallForInvoice(this, event); 378 379 }); 380 381 $(document).on("click", ".downloadInvoice", function(event) { 382 $('.global-alerts').html(""); 383 ACC.documentFinder.doAjaxCallForDownloadInvoice(this, event); 384 385 }) 386 387 $(document).on("click", ".downloadLieferscheinnachweis", function(event) { 388 $('.global-alerts').html(""); 389 ACC.documentFinder.doAjaxCallForLieferscheinnachweis(this, event); 390 391 }); 392 393 $(document).on("click", ".positionBasketIcon", function(event) { 394 ACC.documentFinder.addToCart($(this)); 395 }); 396 $(document).on("click", ".js-document-order-add-to-cart", function(event) { 397 ACC.documentFinder.addToCartFromQuotePopup($(this)); 398 }); 399 // $(document).on("click", "#document" + num_tabs + " .productNo", 400 // function (event) { 401 // ACC.documentFinder.addToCart($(this).data('material'), 1); 402 // 403 // }); 404 $(document).on("click", "#addAll button", function(event) { 405 ACC.documentFinder.addAllToCart($(this)); 406 }); 407 }, 408 409 handleTabClicked: function(item) { 410 411 item.click(function() { 412 413 ACC.documentFinder.openDocumentInTab(this); 414 }); 415 }, 416 417 openDocumentInTab: function(productNode) { 418 var docNo = $(productNode).data('documentid') 419 , docType = $(productNode).data('documenttype') 420 , num_tabs = docType + docNo 421 , $tabList = $("div#tabs_belege ul") 422 , $tabs = $("div#tabs_belege .tab-content") 423 , $newTabListItem = $(document.createElement('li')) 424 , $newTabListItemLink = $(document.createElement('a')) 425 , $closeTabTrigger = $(document.createElement('span')) 426 , $newTabPanel = $(document.createElement('div')); 427 428 // add tab with close icon 429 $closeTabTrigger.addClass('glyphicon glyphicon-remove'); 430 431 $newTabListItemLink.attr('href', '#document' + num_tabs).attr('aria-controls', 'document' + num_tabs).attr('role', 'tab').attr('data-toggle', 'tab').text(docNo + ' ').append($closeTabTrigger); 432 433 $newTabListItem.attr('id', 'tab' + num_tabs).attr('role', 'presentation').append($newTabListItemLink).appendTo($tabList); 434 435 $newTabPanel.attr('id', 'document' + num_tabs).attr('role', 'tabpanel').addClass('tab-pane').appendTo($tabs); 436 437 $("#tabs_belege a[href='#document" + num_tabs + "']").tab('show'); 438 439 // Close icon: removing the tab on click 440 $tabList.find(".glyphicon-remove").on("click", function() { 441 var $this = $(this) 442 , $tabListItem = $this.closest('li') 443 , $tabListItemLink = $tabListItem.find('a').first() 444 , tabId = $tabListItemLink.attr('aria-controls') 445 , $tabPanel = $('#' + tabId); 446 447 $tabListItem.add($tabPanel).remove(); 448 $('#tabs_belege a:first').tab('show'); 449 }); 450 451 $.ajax({ 452 url: ACC.config.encodedContextPath + '/documents/details/' + docType + '/' + docNo, 453 async: true, 454 dataType: "html", 455 beforeSend: function() { 456 $("#document" + num_tabs).html(spinner); 457 } 458 }).done(function(data) { 459 var res = $(data).html(); 460 var $tab = $("#document" + num_tabs) 461 $tab.html(res); 462 console.log($tab.find('.js-update-multiple-input')) 463 $tab.find('.js-update-multiple-input').each(function() { 464 ACC.publicStaticMethods.bindInputFieldForMultiple($(this), false) 465 }) 466 467 // check if at least one row could be added 468 $tab.find("#addAll button").parent().parent().find("table tr.responsive-table-item").each(function() { 469 let quantity = parseFloat(ACC.publicStaticMethods.makeGermanNumberComputed($(this).find(".positionBasketQuantity").get(0).value)); 470 let offerPrice = $($(this).find(".positionNetValue").get(0)).data("netprice"); 471 if (quantity > 0 && offerPrice) { 472 $tab.find("#addAll button").removeAttr('disabled') 473 return false;
474 } 475 }); 476 477 // check if row could be added to cart 478 $tab.find(".positionBasketIcon").each(function() { 479 let quantityElement = $(this).parents(".row"); 480 let quantityExist = quantityElement.find(".positionBasketQuantity").length; 481 let documentEntryRow = quantityElement.parents(".responsive-table-item"); 482 let offerPrice = documentEntryRow.find(".positionNetValue").data("netprice"); 483 if (quantityExist == 0 || offerPrice == "") { 484 $(this).attr('disabled', 'disabled') 485 } 486 }) 487 }); 488 }, 489 490 addToCartFromQuotePopup: function(elem) { 491 492 var quantityElement = elem.parents(".priceMaterialProductPopup__row__addToCart"); 493 var documentEntryRow = quantityElement.parents(".priceMaterialProductPopup__row"); 494 var documentEntryRowMessage = documentEntryRow.find('.priceMaterialProductPopup__row__message'); 495 var quantityLocale = documentEntryRow.find(".popup-responsive-js-qty-selector-input").val(); 496 var quantity = parseFloat(quantityLocale.replace(',', '.')); 497 var code = documentEntryRow.find(".popup-responsive-code").data('code'); 498 var documentNumber = documentEntryRow.find(".popup-documentNumber").val(); 499 var documentEntryNumber = documentEntryRow.find(".popup-documentEntryNumber").val(); 500 var postData = "productCodePost=" + code + "&doubleQty=" + quantity + "&documentNumber=" + documentNumber + "&documentEntryNumber=" + documentEntryNumber; 501 $.ajax({ 502 url: ACC.config.encodedContextPath + '/cart/popup/add?' + postData, 503 type: 'POST', 504 dataType: 'json', 505 contentType: 'application/json', 506 data: "", 507 async: true, 508 beforeSend: function() { 509 var elemWidth = elem.width(); 510 elem.addClass('loading'); 511 elem.append(loaderAnimation.display('display: inline-block;transform: scale(.5) translateY(-9px);width:' + elemWidth + 'px')) 512 elem.attr('disabled', 'disabled') 513 }, 514 success: function(response) { 515 documentEntryRowMessage.html(code + ' ' + $('#addToCartMesaage').html()).addClass('success'); 516 setTimeout(function() { 517 documentEntryRowMessage.html('').removeClass('success'); 518 }, 5000) 519 520 }, 521 error: function(jqXHR, textStatus, errorThrown) { 522 documentEntryRowMessage.html($('#generalError').html()).addClass('error'); 523 setTimeout(function() { 524 documentEntryRowMessage.html('').removeClass('success'); 525 }, 5000) 526 console.log("The following error occurred: " + textStatus, errorThrown); 527 }, 528 complete: function() { 529 elem.removeClass('loading'); 530 elem.find('.loader-container').remove(); 531 elem.removeAttr('disabled') 532 } 533 }); 534 }, 535 536 addToCart: function(elem) { 537 let quantityElement = elem.parents(".row"); 538 let quantity = parseFloat(ACC.publicStaticMethods.makeGermanNumberComputed(quantityElement.find(".positionBasketQuantity").val())); 539 let documentEntryRow = quantityElement.parents(".responsive-table-item"); 540 let offerPrice = documentEntryRow.find(".positionNetValue").data("netprice"); 541 if (quantity > 0 && offerPrice) { 542 let material = documentEntryRow.data('material'); 543 let skusAsJSON = []; 544 let quotationData = elem.parent().find(".quotationData"); 545 let quotationNumber = quotationData.data("quotationnumber"); 546 let quotationExpired = quotationData.data("quotationexpired"); 547 let division = quotationData.data("division"); 548 let positionNumber = quantityElement.find(".positionBasketQuantity").data('position'); 549 550 let currency = documentEntryRow.find(".positionNetValue").data("currency"); 551 let salesUnit = documentEntryRow.find(".positionBasketQuantity").data("salesunit"); 552 let basequantity = documentEntryRow.find(".positionNetValue").data("basequantity");
553 let price = Big(offerPrice).div(basequantity).toJSON(); 554 if (quotationNumber && quotationExpired == false) { 555 skusAsJSON.push({ 556 "product": { 557 "code": material 558 }, 559 //"quantity" : quantity, 560 "quantity": parseFloat(Math.ceil(quantity)), 561 "doubleQty": quantity, 562 "unit": { 563 "sapCode": salesUnit 564 }, 565 "documentNumber": quotationNumber, 566 "offerPrice": price, 567 "documentEntryNumber": positionNumber, 568 "division": division 569 }); 570 } else { 571 skusAsJSON.push({ 572 "product": { 573 "code": material 574 }, 575 //"quantity" : quantity, 576 "quantity": parseFloat(Math.ceil(quantity)), 577 "doubleQty": quantity, 578 "unit": { 579 "sapCode": salesUnit 580 } 581 }); 582 } 583 ACC.documentFinder.addArticlesToCart(skusAsJSON, elem); 584 } 585 586 }, 587 588 addAllToCart: function(elem) { 589 let skusAsJSON = []; 590 let quotationData = elem.parent().find(".quotationData"); 591 let quotationNumber = quotationData.data('quotationnumber'); 592 let quotationExpired = quotationData.data("quotationexpired"); 593 let division = quotationData.data('division'); 594 elem.parent().parent().find("table tr.responsive-table-item").each(function() { 595 if ($(this).data('instock') == true) { 596 if ($(this).data('external') == false) { 597 let quantity = parseFloat(ACC.publicStaticMethods.makeGermanNumberComputed($(this).find(".positionBasketQuantity").get(0).value)); 598 let offerPrice = $($(this).find(".positionNetValue").get(0)).data("netprice"); 599 if (quantity > 0 && offerPrice) { 600 let positionNumber = $($(this).find(".positionBasketQuantity").get(0)).data('position'); 601 let currency = $($(this).find(".positionNetValue").get(0)).data("currency"); 602 let salesUnit = $($(this).find(".positionBasketQuantity").get(0)).data("salesunit"); 603 let basequantity = $($(this).find(".positionNetValue").get(0)).data("basequantity"); 604 let price = Big(offerPrice).div(basequantity).toJSON(); 605 if (quotationNumber && quotationExpired == false) { 606 skusAsJSON.push({ 607 "product": { 608 "code": $(this).data('material') 609 }, 610 //"quantity" : quantity, 611 "quantity": parseFloat(Math.ceil(quantity)), 612 "doubleQty": quantity, 613 "unit": { 614 "salesUnit": salesUnit 615 }, 616 "documentNumber": quotationNumber, 617 "offerPrice": price, 618 "documentEntryNumber": positionNumber, 619 "division": division 620 }); 621 } else { 622 skusAsJSON.push({ 623 "product": { 624 "code": $(this).data('material') 625 }, 626 //"quantity" : quantity, 627 "quantity": parseFloat(Math.ceil(quantity)), 628 "doubleQty": quantity, 629 "unit": { 630 "salesUnit": salesUnit 631 } 632 }); 633 } 634 } 635 } 636 } 637 }); 638 639 ACC.documentFinder.addArticlesToCart(skusAsJSON, elem); 640 }, 641 handleAddToCartSuccess: function(response) { 642 ACC.documentFinder.displayAddToCartPopupDocument(response); 643 }, 644 bindToAddToCartFormDocument: function() { 645 var addToCartForm = $('.add_to_cart_form'); 646 addToCartForm.ajaxForm({ 647 beforeSubmit: ACC.documentFinder.showRequestDocument, 648 success: ACC.documentFinder.displayAddToCartPopupDocument, 649 complete: completeAddToCart 650 }); 651 setTimeout(function() { 652 $ajaxCallEvent = true; 653 }, 2000); 654 655 function completeAddToCart(options, status, $form) { 656 var $btn = $form.find('.btn'); 657 $btn.removeClass('loading'); 658 $btn.find('.loader-container').remove(); 659 $btn.removeAttr('disabled') 660 } 661 }, 662 showRequestDocument: function(arr, $form, options) { 663 if ($('.btn.loading').length == 0) { 664 var $btn = $form.find('.btn'); 665 $btn.addClass('loading'); 666 $btn.append(loaderAnimationDocs.display('display: inline-block;transform: scale(.5) translateY(-25px)')) 667 $btn.attr('disabled', 'disabled') 668 } 669 670 if ($ajaxCallEvent) { 671 $ajaxCallEvent = false;
672 return true; 673 } 674 return false; 675 676 }, 677 displayAddToCartPopupDocument: function(cartResult, statusText, xhr, formElement) { 678 $ajaxCallEvent = true; 679 console.log(cartResult); 680 $('#addToCartLayer').remove(); 681 if (typeof ACC.minicart.updateMiniCartDisplay == 'function') { 682 ACC.minicart.updateMiniCartDisplay(); 683 } 684 var titleHeader = $('#addToCartTitle').html(); 685 686 ACC.colorbox.open(titleHeader, { 687 html: cartResult.addToCartLayer, 688 width: "950px", 689 maxHeight: "100%", 690 onComplete: function() { 691 $.colorbox.resize(); 692 ACC.common.refreshScreenReaderBuffer(); 693 ACC.colorbox.calculateBodyPadding(); 694 }, 695 onClosed: function() { 696 location.reload(); 697 } 698 }); 699 700 $.ajax({ 701 url: '/_ui/responsive/common/daw-basic/mustache/carousel.mustache', 702 type: "GET", 703 beforeSend: function() {}, 704 error: function(jqXHR, textStatus, errorThrown) { 705 console.log(jqXHR); 706 console.log(textStatus + " "); 707 console.log(errorThrown + " "); 708 }, 709 success: function(template) { 710 var slider = Mustache.render(template, cartResult) 711 , 712 $lastSeen = $('#product-references'); 713 console.log(slider); 714 715 $lastSeen.append(slider); 716 717 var carouselConfig = { 718 "default": { 719 navigation: true, 720 navigationText: ["<span class='glyphicon glyphicon-chevron-left'></span>", "<span class='glyphicon glyphicon-chevron-right'></span>"], 721 pagination: false, 722 itemsCustom: [[0, 2], [1024, 2]], 723 responsiveBaseElement: $('.carousel__component') 724 725 }, 726 "rotating-image": { 727 navigation: false, 728 pagination: true, 729 singleItem: true 730 }, 731 "lazy-reference": { 732 navigation: true, 733 navigationText: ["<span class='glyphicon glyphicon-chevron-left'></span>", "<span class='glyphicon glyphicon-chevron-right'></span>"], 734 pagination: false, 735 lazyLoad: true 736 } 737 }; 738 739 $(".js-owl-carousel").each(function() { 740 var $c = $(this); 741 $.each(carouselConfig, function(key, config) { 742 if ($c.hasClass("js-owl-" + key)) { 743 var $e = $(document).find(".js-owl-" + key); 744 $e.owlCarousel(config); 745 } 746 }); 747 }); 748 749 }, 750 complete: function() { 751 $.colorbox.resize(); 752 } 753 }); 754 755 }, 756 handleDocumentFlowClick: function(x) { 757 console.log("x: " + $(x).data("documentnumber")); 758 ACC.documentFinder.openDocumentInTab(x) 759 }, 760 761 addArticleToCart: function(article) { 762 if (typeof article !== 'object') { 763 throw new Error('object only'); 764 } 765 addArticlesToCart([article]); 766 }, 767 768 addArticlesToCart: function(articles, elem) { 769 if (!Array.isArray(articles)) { 770 throw new Error('array of objects only'); 771 } 772 773 const dataObject = JSON.stringify({ 774 "cartEntries": articles 775 }); 776 777 $.ajax({ 778 url: ACC.config.encodedContextPath + '/cart/addQuickOrder?skip=true', 779 type: 'POST', 780 dataType: 'json', 781 contentType: 'application/json', 782 data: dataObject, 783 beforeSend: function() { 784 var $btn = elem; 785 $btn.addClass('loading'); 786 $btn.append(loaderAnimation.display('display: inline-block;transform: scale(.5) translate(-15px, -25px); width: 18px')) 787 $('.js-belege-addToCart').each(function() { 788 $(this).attr('disabled', 'disabled') 789 }) 790 }, 791 success: function(response) { 792 if (response.quickOrderErrorData.length) { 793 ACC.publicStaticMethods.triggerGlobalMessage(response.quickOrderErrorData[0].errorMsg, 'error') 794 } else { 795 ACC.product.displayAddToCartPopup(response) 796 } 797 }, 798 error: function(jqXHR, textStatus, errorThrown) { 799 var $btn = elem; 800 $btn.closest('tr').find('.text-danger.colormix-note').removeClass('hidden') 801 $btn.addClass('disabled') 802 // log the error to the console 803 console.log("The following error occurred: " + textStatus, errorThrown); 804 ACC.publicStaticMethods.triggerGlobalMessage($('#generalError').html(), 'error') 805 }, 806 complete: function() { 807 var $btn = elem; 808 $btn.removeClass('loading'); 809 $btn.find('.loader-container').remove(); 810 $('.js-belege-addToCart:not(.disabled)').each(function() { 811 $(this).removeAttr('disabled') 812 }) 813 } 814 }); 815 } 816 817}; 818 819loaderAnimationDocs = { 820 display: function(styles) { 821 return ' <div class="loader-container" style="' + styles + '">\n' + ' <div class="lds-dots">\n' + ' <div class="dot dot__first"></div>\n' + ' <div class="dot dot__second"></div>\n' + ' <div class="dot dot__third"></div>\n' + ' </div>\n' + ' </div>'; 822 }, 823 displayShaderLoader: function($parent, styles) { 824 $parent.css('position', 'relative').append('<div class="shader-loader">\n' + ' <div class="loader-container" style="' + styles + '">\n' + ' <div class="lds-dots">\n' + ' <div class="dot dot__first"></div>\n' + ' <div class="dot dot__second"></div>\n' + ' <div class="dot dot__third"></div>\n' + ' </div>\n' + ' </div>
824\n' + ' </div>') 825 } 826} 827function getFormattedLocalDateTime() { 828 const now = new Date(); 829 const pad = n=>n.toString().padStart(2, '0'); 830 const yyyy = now.getFullYear(); 831 const MM = pad(now.getMonth() + 1); 832 const dd = pad(now.getDate()); 833 return `${yyyy}${MM}${dd}`; 834} 835 836window.toggleDeliveryAllCheckboxes = function(source) { 837 const checkboxes = document.querySelectorAll('input[name="selectedDeliveries"]'); 838 checkboxes.forEach(cb=>cb.checked = source.checked); 839}
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.