1var working = false; 2var page = parseInt($(".page").last().val()); 3var total_pages = parseInt($(".pages").last().val()); 4var displayed_pages = []; 5displayed_pages.push(1); 6var productCompareBtnsContainer = null; 7 8function getLoginForm() { 9 try { 10 var miniLoginFormContainer = document.getElementById("mini-login-form"); 11 $.ajax({ 12 method: 'GET', 13 url: '/b2b/accounts/login/', 14 dataType: 'html', 15 async: 'true', 16 data: {'next': window.location.href}, 17 xhrFields: { 18 withCredentials: true 19 } 20 }) 21 .done(function (data, textStatus, jqXHR) { 22 // miniLoginFormContainer element will only exists when a user has not logged in 23 if (typeof (miniLoginFormContainer) != 'undefined' && miniLoginFormContainer != null) { 24 miniLoginFormContainer.innerHTML = data; 25 } 26 }) 27 // .fail(function (jqXHR, textStatus, errorThrown) { 28 // console.log("LOGIN FORM AJAX CALL FAILURE!") 29 // }); 30 } catch (error) { 31 return 0; 32 } 33} 34 35function uncheckAllComparedProducts() { 36 var checks = document.querySelectorAll('.product-compare-checkbox input[type="checkbox"]') 37 for (var i = 0; i < checks.length; i++) { 38 if (!checks[i].disabled) { 39 checks[i].checked = false; 40 } 41 } 42 productCompareBtnsContainer.classList.add("d-none"); 43} 44 45function openFilterSelector() { 46 var headerContainerHeight = document.getElementById('top-nav-container').offsetHeight; 47 var sideNavBar = document.getElementById('side-bar-filter-selector-container'); 48 sideNavBar.style.top = String(headerContainerHeight) + "px"; 49 sideNavBar.style.paddingBottom = String(headerContainerHeight) + "px"; 50 sideNavBar.classList.add("side-bar-open"); 51 document.body.style.overflow = "hidden"; 52} 53 54function closeFilterSelector() { 55 document.getElementById("side-bar-filter-selector-container").classList.remove("side-bar-open"); 56 document.body.style.overflow = "auto"; 57} 58 59function openSideNavBar() { 60 var headerContainerHeight = document.getElementById('top-nav-container').offsetHeight; 61 var sideNavBar = document.getElementById('side-nav-bar'); 62 sideNavBar.style.top = String(headerContainerHeight) + "px"; 63 sideNavBar.style.height = (window.innerHeight - headerContainerHeight) + "px"; 64 sideNavBar.classList.add("side-bar-open"); 65 document.body.style.overflow = "hidden"; 66 document.getElementById("side-nav-overlay-status-icon").classList.add("bi-x"); 67 document.getElementById("side-nav-overlay-status-icon").classList.remove("bi-list"); 68 closeFilterSelector(); 69} 70 71function closeSideNavBar() { 72 document.getElementById("side-nav-bar").classList.remove("side-bar-open"); 73 document.body.style.overflow = "auto"; 74 document.getElementById("side-nav-overlay-btn").classList.remove("active"); 75 document.getElementById("side-nav-overlay-status-icon").classList.add("bi-list"); 76 document.getElementById("side-nav-overlay-status-icon").classList.remove("bi-x"); 77} 78 79window.addEventListener('mouseup', e => { 80 try { 81 if (!document.getElementById("side-nav-bar").contains(e.target) && e.target.closest("button") != document.getElementById("side-nav-overlay-btn")) { 82 closeSideNavBar(); 83 } 84 if (!document.getElementById("side-bar-filter-selector-container").contains(e.target) && e.target.closest("button") != document.getElementById("side-nav-overlay-btn")) { 85 closeFilterSelector(); 86 } 87 } catch (error) { 88 return 0; 89 } 90}); 91 92function toggleSideNavBar() { 93 // console.log(document.getElementById("side-nav-bar").classList.contains('side-bar-open')) 94 if (document.getElementById("side-nav-bar").classList.contains('side-bar-open')) { 95 closeSideNavBar(); 96 } else { 97 openSideNavBar(); 98 } 99} 100 101//Start Enable hover on navbar 102function toggleDropdown(e) { 103 const _d = $(e.target).closest('.dropdown'), 104 _m = $('.dropdown-menu', _d); 105 setTimeout(function () { 106 const shouldOpen = e.type !== 'click' && _d.is(':hover'); 107 _m.toggleClass('show', shouldOpen); 108 _d.toggleClass('show', shouldOpen); 109 $('[data-toggle="dropdown"]', _d).attr('aria-expanded', shouldOpen); 110 }, e.type === 'mouseleave' ? 70 : 0); 111} 112 113$('.nav') 114 .on('mouseenter mouseleave', '.dropdown', toggleDropdown) 115 .on('click', '.dropdown-menu a', toggleDropdown); 116 117//END Enable hover on navbar 118 119function checkForProductCompareCheckboxElements() { 120 // console.log(productCompareBtnsContainer); 121 $('.product-compare-checkbox-element').click(function () { 122 if ($(".product-compare-checkbox-element:checked").length >= 2) {
123 productCompareBtnsContainer.classList.remove("d-none"); 124 // coNavnsole.log("d-block") 125 } else { 126 productCompareBtnsContainer.classList.add("d-none"); 127 // console.log("d-none") 128 } 129 }); 130} 131 132$(document).ready(function () { 133 document.getElementById('side-nav-overlay-btn').addEventListener("click", toggleSideNavBar); 134 // Product Compare Functionality - START 135 try { 136 var productCompareBtn = document.getElementById('product-compare-btn'); 137 var productUndoCompareBtn = document.getElementById('product-undo-compare-btn'); 138 productUndoCompareBtn.addEventListener("click", uncheckAllComparedProducts); 139 productCompareBtnsContainer = document.getElementById('product-compare-btns-container'); 140 productCompareBtnsContainer.classList.add("d-none"); 141 checkForProductCompareCheckboxElements(); 142 } catch (error) { 143 // console.error(error); 144 // expected output: ReferenceError: nonExistentFunction is not defined 145 // Note - error messages will vary depending on browser 146 } 147 148 $('#product-compare-btn').click(function () { 149 $("input.product-compare-checkbox-element:checkbox[name=products]:checked").each(function () { 150 $(this).appendTo("#product-compare-form"); 151 }); 152 $("#product-compare-form").submit(); 153 }); 154 // Product Compare Functionality - END 155 156 157 // User Login Functionality 158 getLoginForm(); 159 160 // Product Filters Form Functionality 161 // var setProductFiltersFormCheckboxes = $("#set-product-filters-form input[type=checkbox]") 162 // if (typeof(setProductFiltersFormCheckboxes) != 'undefined' && setProductFiltersFormCheckboxes != null) { 163 // setProductFiltersFormCheckboxes.click(function() { $("#set-product-filters-form").submit(); }) 164 // } 165 166 $("#set-product-filters-form :input").change(function () { 167 var $form = $("#set-product-filters-form"); 168 // On search-style listings the price bounds follow the ticked facets, so a 169 // facet change drops the slider range (the previous bounds) instead of 170 // re-applying it to the new result set. 171 if ($form.data("reset-price-on-change") && this.name !== "price_range_slider_field") { 172 $form.find("[name=price_range_slider_field]").prop("disabled", true); 173 } 174 $form.submit(); 175 }); 176 177 $("body").on("click", function (e) { 178 $('.opened').hide(); 179 }) 180 181 $("body").on("click", "#search-button", function (e) { 182 $("#search-form").submit(); 183 184 }) 185 186 187 if (navigator.userAgent.indexOf('MSIE') !== -1 188 || navigator.appVersion.indexOf('Trident/') > -1) { 189 190 // Scroll event check 191 $(window).scroll(function (event) { 192 var scroll = $(window).scrollTop(); 193 194 // Activate sticky for IE if scrolltop is more than 20px 195 if (scroll > 20) { 196 $('.sticky-top').addClass("sticky-top-ie"); 197 } else { 198 $('.sticky-top').removeClass("sticky-top-ie"); 199 } 200 201 }); 202 203 } 204 205 206// Back to top button functionality 207 var mybutton = document.getElementById("back-to-top-btn"); 208 209// When the user scrolls down 20px from the top of the document, show the button 210 window.onscroll = function () { 211 scrollFunction() 212 }; 213 214 function scrollFunction() { 215 if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { 216 mybutton.style.display = "block"; 217 } else { 218 mybutton.style.display = "none"; 219 } 220 } 221 222// END - Back to top button functionality 223 224 225// document.addEventListener("click", (evt) => { 226// const sideNavBar = document.getElementById("side-nav-bar"); 227// let targetElement = evt.target; // clicked element 228// 229// do { 230// if (targetElement == sideNavBar) { 231// // This is a click inside. Do nothing, just return. 232// return; 233// } 234// // Go up the DOM 235// targetElement = targetElement.parentNode; 236// } while (targetElement); 237// 238// // This is a click outside. 239// if ( targetElement != sideNavBar && sideNavBar.classList.contains('side-bar-open')) { 240// closeSideNavBar(); 241// } 242// }); 243 244 245}) 246 247// When the user clicks on the button, scroll to the top of the document
248function topFunction() { 249 // document.body.scrollTop = 0; 250 // document.documentElement.scrollTop = 0; 251 $('html, body').animate({scrollTop: 0}, 'normal') 252} 253 254 255// window.onscroll = function () { myFunction() }; 256 257// var navbar = document.getElementById("nav"); 258// var sticky = navbar.offsetTop; 259 260// function myFunction() { 261// if (window.pageYOffset >= sticky) { 262// navbar.classList.add("sticky-top") 263// 264// } else { 265// navbar.classList.remove("sticky-top"); 266// } 267// } 268 269 270function GetInfiniteData($form) { 271 page = parseInt($(".page").last().val()); 272 if ($.isNumeric(page)) { 273 total_pages = parseInt($(".pages").last().val()); 274 category = $(".category").last().val(); 275 category = $(".category").last().val(); 276 if (displayed_pages.indexOf(page) == '-1') { 277 displayed_pages.push(page); 278 var data = $form.serialize() + "&page=" + page + "&category=" + category; 279 // console.log($form.serialize()); 280 $.ajax({ 281 type: $form.attr("method"), 282 url: $form.attr("action"), 283 data: data, 284 dataType: 'json', 285 success: function (response) { 286 // console.info(response); 287 if (response != null) { 288 $("#category-products-wrapper").append(response.html_form); 289 checkForProductCompareCheckboxElements(); 290 // Get an array of buttons from the page (with ) 291 var addToCartButtons = document.querySelectorAll(".btn-add-to-cart"); 292 // Loop through the resulting array 293 for (var i = 0; i < addToCartButtons.length; i++) { 294 addToCartButtons[i].addEventListener("click", addProductToCart); 295 } 296 working = false; 297 } 298 }, 299 beforeSend: function () { 300 $("#progress").show(); 301 }, 302 complete: function () { 303 $("#progress").hide(); 304 }, 305 // error: function (e) { 306 // console.info("Error while retrieving data! " + e); 307 // } 308 }); 309 310 311 } 312 313 } 314} 315 316$(document).ready(function () { 317 318 319 $('.panel-collapse').on('show.bs.collapse', function () { 320 $(this).siblings('.panel-heading').addClass('active'); 321 }); 322 323 $('.panel-collapse').on('hide.bs.collapse', function () { 324 $(this).siblings('.panel-heading').removeClass('active'); 325 }); 326 327 328 var topNavContainer = document.getElementById('top-nav-container'); 329 var navContainer = document.getElementById('nav-container-lg'); 330 var headerContainer = document.getElementById('header-container'); 331 var navLogoImage = document.getElementById('nav-logo-image'); 332 333 // window.onscroll = function () { 334 // "use strict"; 335 // if (document.body.scrollTop >= headerContainer.scrollHeight || document.documentElement.scrollTop >= headerContainer.scrollHeight ) { 336 // topNavContainer.classList.add("bg-white"); 337 // // headerContainer.classList.remove("pt-lg-5", "py-3"); 338 // navLogoImage.style.maxHeight = "2.5rem"; 339 // // navContainer.classList.add("nav-scrolled", "rounded-bottom"); 340 // // navContainer.classList.remove("bg-transparent"); 341 // navContainer.classList.add("", "rounded-bottom"); 342 // navContainer.classList.remove("bg-transparent"); 343 // } 344 // else { 345 // topNavContainer.classList.remove("bg-white"); 346 // navLogoImage.style.maxHeight = "100%"; 347 // // navContainer.classList.remove("nav-scrolled", "rounded-bottom"); 348 // // navContainer.classList.add("bg-transparent"); 349 // } 350 // }; 351 352 // Get an array of buttons from the page 353 var addToCartButtons = document.querySelectorAll(".btn-add-to-cart"); 354 // Loop through the resulting array 355 for (var i = 0; i < addToCartButtons.length; i++) { 356 addToCartButtons[i].addEventListener("click", addProductToCart); 357 } 358 359 // Get an array of increase-reduce product quantity buttons from the page 360 var alterProductQuantityButtons = document.querySelectorAll(".reduce-product-quantity-btn, .increase-product-quantity-btn"); 361 // var increaseProductQuantityButtons = document.querySelectorAll(".increase-product-quantity-btn"); 362 363 // Loop through the resulting array 364 for (var i = 0; i < alterProductQuantityButtons.length; i++) { 365 alterProductQuantityButtons[i].addEventListener("click", updateProductQuantity); 366 } 367 // for(var i = 0; i < increaseProductQuantityButtons.length; i++) { 368 // increaseProductQuantityButtons[i].addEventListener("click", updateProductQuantity); 369 // } 370 371 // Open mobile view filters in case they where selected before refresh 372 if (document.getElementById('set-product-filters-form').getAttribute('data-filters-applied') == 'true') { 373 // openFilterSelector(); 374 console.log(document.getElementById('set-product-filters-form').getAttribute('data-filters-applied')) 375 } 376 377 378}); 379 380// Functionality to loop banner and promotion images images that have secondary img and href data 381setInterval(function () { 382 Array.from(document.querySelectorAll(".banner-image, .promotion-image")).forEac
382h( 383 function (element, index, array) { 384 var secondaryhref; 385 var secondarysrc; 386 if (element.dataset.secondarysrc) { 387 secondaryhref = element.parentNode.href; 388 element.parentNode.href = element.parentNode.dataset.secondaryhref; 389 element.parentNode.dataset.secondaryhref = secondaryhref; 390 secondarysrc = element.src; 391 element.src = element.dataset.secondarysrc; 392 element.dataset.secondarysrc = secondarysrc; 393 } 394 } 395 ); 396}, 8000); 397 398// TEST 399 400// $(document).on('click', '.dropdown .dropdown-menu', function (e) { 401// e.stopPropagation(); 402// }); 403// 404 405// 406// $('.btn-number').click(function(e){ 407// e.preventDefault(); 408// 409// fieldName = $(this).attr('data-field'); 410// type = $(this).attr('data-type'); 411// var input = $("input[name='"+fieldName+"']"); 412// var currentVal = parseInt(input.val()); 413// if (!isNaN(currentVal)) { 414// if(type == 'minus') { 415// 416// if(currentVal > input.attr('min')) { 417// input.val(currentVal - 1).change(); 418// } 419// if(parseInt(input.val()) == input.attr('min')) { 420// $(this).attr('disabled', true); 421// } 422// 423// } else if(type == 'plus') { 424// 425// if(currentVal < input.attr('max')) { 426// input.val(currentVal + 1).change(); 427// } 428// if(parseInt(input.val()) == input.attr('max')) { 429// $(this).attr('disabled', true); 430// } 431// 432// } 433// } else { 434// input.val(0); 435// } 436// }); 437// $('.input-number').focusin(function(){ 438// $(this).data('oldValue', $(this).val()); 439// }); 440// $('.input-number').change(function() { 441// 442// minValue = parseInt($(this).attr('min')); 443// maxValue = parseInt($(this).attr('max')); 444// valueCurrent = parseInt($(this).val()); 445// 446// name = $(this).attr('name'); 447// if(valueCurrent >= minValue) { 448// $(".btn-number[data-type='minus'][data-field='"+name+"']").removeAttr('disabled') 449// } else { 450// alert('Sorry, the minimum value was reached'); 451// $(this).val($(this).data('oldValue')); 452// } 453// if(valueCurrent <= maxValue) { 454// $(".btn-number[data-type='plus'][data-field='"+name+"']").removeAttr('disabled') 455// } else { 456// alert('Sorry, the maximum value was reached'); 457// $(this).val($(this).data('oldValue')); 458// } 459// }); 460// 461// $(".input-number").keydown(function (e) { 462// // Allow: backspace, delete, tab, escape, enter and . 463// if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 || 464// // Allow: Ctrl+A 465// (e.keyCode == 65 && e.ctrlKey === true) || 466// // Allow: home, end, left, right 467// (e.keyCode >= 35 && e.keyCode <= 39)) { 468// // let it happen, don't do anything 469// return; 470// } 471// // Ensure that it is a number and stop the keypress 472// if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { 473// e.preventDefault(); 474// } 475// }); 476 477$('body').on('click', '.quick-order-btn', function (e) { 478 e.preventDefault(); 479 $.ajax({ 480 url: $(this).attr("href"), 481 type: 'get', 482 dataType: 'json', 483 // beforeSend: function () { 484 // $("#modal").modal("show"); 485 // }, 486 success: function (data) { 487 $("#quick-modal .modal-content .modal-body .container-fluid").html(data.html_data); 488 $("#quick-modal").modal("show"); 489 } 490 }); 491}) 492 493$('body').on('click', '.quick-order-list', function (e) { 494 e.preventDefault(); 495 $.ajax({ 496 url: $(this).attr("href"), 497 type: 'get', 498 dataType: 'json', 499 // beforeSend: function () { 500 // $("#modal").modal("show"); 501 // }, 502 success: function (data) { 503 $('.quick-order-btn').trigger("click"); 504 } 505 }); 506})
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.