1 2// JavaScript Document 3 4$(document).ready(function () { 5 // navbar 6 $('.navbar-toggler .navbar-toggler-icon').click(function () { 7 $(this).toggleClass('open'); 8 }); 9 10 // Sticky Nabvar 11 $(window).on('scroll', function () { 12 let header_top_h = $('header .h-top').outerHeight(); 13 if (window.scrollY > header_top_h) { 14 $('.navbar-sticky').addClass('fixed-top'); 15 // add padding top to show content behind navbar 16 let navbar_height = $('.navbar').height(); 17 document.body.style.paddingTop = navbar_height + 'px'; 18 } else { 19 $('.navbar-sticky').removeClass('fixed-top'); 20 // remove padding top from body 21 document.body.style.paddingTop = '0'; 22 } 23 }); 24 25 // Hamburger menu 26 $(".nav-item.dropdown").hover(function () { 27 $(this).children(".dropdown-menu").toggleClass('show'); 28 }); 29 30 $('.search-icon').click(function () { 31 $(".search-container").toggleClass('opened'); 32 }); 33 34 $(document).click(function (e) { 35 var container = $(".search-toggle"); 36 if (!container.is(e.target) 37 && container.has(e.target).length === 0) { 38 $('.search-container').removeClass('opened'); 39 } 40 }); 41 42 43 // Back To Top Button 44 $(window).scroll(function () { 45 if ($(this).scrollTop() > 20) { 46 $('#toTopBtn').fadeIn(); 47 } else { 48 $('#toTopBtn').fadeOut(); 49 } 50 }); 51 52 $('#toTopBtn').click(function () { 53 $("html, body").animate({ 54 scrollTop: 0 55 }, { 56 duration: 300, 57 easing: "linear" 58 }); 59 return false; 60 }); 61 62 $("#btnMasterSearch").on("click", masterSearch); 63 $("#txtMasterSearch").on("keydown", function (event) { 64 if (event.keyCode == 13) { 65 masterSearch(); 66 } 67 }); 68 69 $("#txtMasterSearch").autocomplete({ 70 source: "/Shop/Search.aspx", 71 minLength: 2, 72 delay: 200, 73 select: function (event, ui) { 74 if (browserSupportsSessionStorage()) 75 sessionStorage.setItem("masterCategoryClicked", true); 76 77 document.location.href = "/Shop/Search.aspx?id={0}".format(ui.item.id); 78 } 79 }).data("ui-autocomplete")._renderItem = function (ul, item) { 80 return $("<li>") 81 .append($("<a>").html(item.label)) 82 .appendTo(ul); 83 }; 84 85 $("#search-terms").autocomplete({ 86 source: "/Shop/Search.aspx", 87 minLength: 2, 88 delay: 200, 89 select: function (event, ui) { 90 if (browserSupportsSessionStorage()) 91 sessionStorage.setItem("masterCategoryClicked", true); 92 93 document.location.href = "/Shop/Search.aspx?id={0}".format(ui.item.id); 94 } 95 }).data("ui-autocomplete")._renderItem = function (ul, item) { 96 return $("<li>") 97 .append($("<a>").html(item.label)) 98 .appendTo(ul); 99 }; 100 101 $(window).on("resize", function () { 102 $("ul.ui-menu.ui-autocomplete").hide(); 103 }); 104 105 $(document).on("click", "a.masterCategory", function () { 106 if (browserSupportsSessionStorage()) 107 sessionStorage.setItem("masterCategoryClicked", true); 108 }); 109 $(document).on("click", "#dvProdListSustainability a", function () { 110 if (browserSupportsSessionStorage()) 111 sessionStorage.setItem("masterCategoryClicked", true); 112 }); 113 $(document).on("click", "#masterOrderTracking", function (e) { 114 e.preventDefault(); 115 openShippingDetails(null, null); 116 }); 117 118 // OFI Browser 119 objectFitImages(); 120 121 // shim to default .button() as JqueryUI method while Bootstrap uses .bsButton() 122 if ($.fn.button && $.fn.button.noConflict) { 123 var bootstrapButton = $.fn.button.noConflict(); 124 $.fn.bsButton = bootstrapButton; 125 } 126}); 127 128 129function browserSupportsSessionStorage() { 130 ///<summary>Determines if the user's browser can utilize sessionStorage.</summary> 131 try { 132 if (sessionStorage) { 133 sessionStorage.setItem("test", "1"); 134 sessionStorage.removeItem("test", "1"); 135 return true; 136 } 137 else { 138 return false; 139 } 140 } 141 catch (ex) { 142 return false; 143 } 144} 145 146String.prototype.format = function () { 147 ///<summary>Similar in function to the c# String.Format, but without the data formatting. 148 ///Example: "Some test {0} string {1}.".format(value0, value1); 149 ///</summary> 150 var args = arguments; 151 var re = /\{(\d+)\}/g; 152 var f = function (match, number) { 153 return number in args ? args[number] : match; 154 }; 155 return this.replace(re, f); 156} 157 158function masterSearch() { 159 var v = $("#txtMasterSearch").val().trim(); 160 if (v) 161 document.location.href = "/Shop/Search.aspx?s=" + escape(v); 162} 163 164function openChat() { 165 var win = window.open("/LiveChat/Chat.aspx?referrer=" + document.location.href, "chat", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizeable=0,width=585,height=625"); 166 win.trigger("focus"); 167 win.opener = self; 168} 169 170function masterMobileSite() { 171 $.removeCookie("DesktopSite", { path: '/' });
172 document.location.reload(); 173} 174 175function masterDesktopSite() { 176 $.cookie("DesktopSite", 1, { path: '/', expires: 30 }); 177 document.location.reload(); 178}
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.