PageSourceSearch

https://www.jamesavery.com/on/demandware.static/Sites-JamesAvery-Site/-/en_US/v1791032420395/js/search.js

js jamesavery.com collected 2026-10-03 19:23:39 UTC 19,577 bytes, 1 lines download raw bytes

1!function(){"use strict";var t,e={8148:function(t,e,n){var r=n(7584);function i(){if("IntersectionObserver"in window){var t=$(".product-tile-view-track");t.each((function(){if(!(t=$(this)).attr("data-viewed")){new IntersectionObserver((function(t,e){t.forEach((function(t){if(t.isIntersecting){var n=$(t.target),r=n.find(".product").data("pid"),i=n.find(".pdp-link a").data("gtm-data");if(r&&r.indexOf("STL")>-1){var a={shopTheLookID:r};Object.assign(i,a)}var o={list:$("#categoryName").val()};Object.assign(i,o),$(document).trigger("productTile:trackDynamicImpression",{gtmData:i}),e.unobserve(t.target),n.attr("data-viewed",!0)}}))}),{rootMargin:"0px 0px 0px 0px",threshold:0}).observe(t[0])}}))}}function a(t,e){var n=t.find(e);$(e).empty().html(n.html())}function o(t){$(".refinement.active").each((function(){$(this).removeClass("active");var e=t.find("."+$(this)[0].className.replace(/ /g,"."));e.addClass("active"),e.find("button.title").attr("aria-expanded","true")})),a(t,".refinements"),l()}function s(t,e){var n=t.data("url");$.spinner().start(),$.ajax({url:n,method:"GET",success:function(t){e.append(t),$.spinner().stop()},error:function(){$.spinner().stop()}})}function c(){var t,e=navigator.userAgent,n=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(t=e.match(/version\/(\d+)/i))&&n.splice(1,1,t[1]),n.join(":")}function d(t){var e,n=navigator.userAgent,r=[],i=t.split(":"),a=i[0].toLowerCase();r.push(a);var o=null!=(e="safari"==a&&null!=n.match(/version\/(.{3}\d+)/i)?n.match(/version\/(.{3}\d+)/i):n.match(/version\/(\d+)/i))?e[1]:"safari"!=a?i[1]:"";return r.push(o),r}function l(){"true"!==($("#isMobile").length>0&&$("#isMobile").val())?$(".refinements .refinement").slice(0,3).addClass("active"):$(".refinements .refinement").hasClass("active")&&$(".refinements .refinement").removeClass("active")}t.exports={trackPLPClick:function(){"true"==$.trim($("input[name=plp_infinitescroll]").val())&&(history.scrollRestoration&&(history.scrollRestoration="manual"),$(window).on("scroll",(function(){"Product-Show"!=sessionStorage.pagedata&&(sessionStorage.scrollPos=$(window).scrollTop())})),$(document).on("click",".breadcrumb-item a",(function(){sessionStorage.setItem("scrollPos",0)})),window.addEventListener("load",(function(){var t=d(c()),e=t[0];("safari"!=e||"safari"==e&&parseFloat(t[1])>16.2)&&(sessionStorage.pagedata=$(".page").data("action"));var n=sessionStorage.getItem("scrollPos")?sessionStorage.getItem("scrollPos"):0;n&&window.scrollTo({top:n,behavior:"instant"}),l()})),window.addEventListener("unload",(function(){sessionStorage.pagedata=$(".page").data("action"),sessionStorage.scrollPos=$(window).scrollTop()})))},customCheckbox:function(){$(document).on("click",".show-more-search",(function(){var t=$(this).data("hide"),e=$(this).data("see-more"),n=$(this).data("see-less"),r=parseInt($(this).data("see-more-length"),10),i=$(this).closest(".refinement"),a=i.length?i.find("li:not(.search-hide)"):null;$(document).trigger("fliter:trackingViewmoreAnalytics",{dataAction:$.trim($(this).text()),dataLabel:$.trim($(this).closest(".active.refinement").find(".gtm-refinement-header").data("refinement-name"))}),t||"true"===t?($(this).data("hide",!1),$(this).text(n),a.removeClass("d-none")):($(this).data("hide",!0),$(this).text(e),a.each((function(t){t>r-1&&!$(this).hasClass("value-selected")&&$(this).addClass("d-none")})))}
1))},filter:function(){$(".container").on("click","button.filter-results",(function(){$(".refinement-bar, .modal-background").show(),$(".refinement-bar").addClass("d-flex"),$(".refinement-bar").siblings().attr("aria-hidden",!0),$(".refinement-bar").closest(".row").siblings().attr("aria-hidden",!0),$(".refinement-bar").closest(".tab-pane.active").siblings().attr("aria-hidden",!0),$(".refinement-bar").closest(".container.search-results").siblings().attr("aria-hidden",!0),$(".refinement-bar .close").focus(),$("body").addClass("noscroll")}))},closeRefinements:function(){$(".container").on("click",".refinement-bar button.close, .modal-background",(function(){$(".refinement-bar, .modal-background").hide(),$(".refinement-bar").removeClass("d-flex"),$(".refinement-bar").siblings().attr("aria-hidden",!1),$(".refinement-bar").closest(".row").siblings().attr("aria-hidden",!1),$(".refinement-bar").closest(".tab-pane.active").siblings().attr("aria-hidden",!1),$(".refinement-bar").closest(".container.search-results").siblings().attr("aria-hidden",!1),$(".btn.filter-results").focus(),$("body").removeClass("noscroll")}))},resize:function(){$(window).resize((function(){$(".refinement-bar, .modal-background").hide(),$(".refinement-bar").removeClass("d-flex"),$(".refinement-bar").siblings().attr("aria-hidden",!1),$(".refinement-bar").closest(".row").siblings().attr("aria-hidden",!1),$(".refinement-bar").closest(".tab-pane.active").siblings().attr("aria-hidden",!1),$(".refinement-bar").closest(".container.search-results").siblings().attr("aria-hidden",!1),$("body").removeClass("noscroll")}))},sort:function(){$(document).on("sort:trackingDynamicImpression",(function(){i()}))},showMore:function(){$(".container").on("click",".show-more .more",(function(t){t.stopPropagation();var e=$(this).data("url"),n=$.trim($("input[name=plp_infinitescroll]").val());t.preventDefault(),$.spinner().start();var r=$(this).attr("href")?$(this).attr("href"):window.location.href;$(this).trigger("search:showMore",t),$.ajax({url:e,data:{selectedUrl:e},method:"GET",success:function(t){if($(".grid-footer").replaceWith(t),function(t){$("<div>").append($(t)).find(".grid-footer").data("sort-options").options.forEach((function(t){$("option."+t.id).val(t.url)}))}(t),i(),"true"==n){window.name=encodeURIComponent($(".product-grid.plp").html());var a={results:window.name};window.history.replaceState(a,e,r),window.addEventListener("popstate",(function(){window.history.replaceState({results:null},e,window.location.href)}))}else window.history.pushState({},"",r);$.spinner().stop()},error:function(){$.spinner().stop()}})}))},applyFilter:function(){$(".container").on("click",".refinements li button, .refinement-bar button.reset, .filter-value button, .swatch-filter button, .refinements #apply-filter",(function(t){t.preventDefault(),t.stopPropagation(),$.spinner().start(),$(this).trigger("search:filter",t);var e=!($(window).width()>=769),n="#"+$(this).find("span").last().attr("id"),s=$(this).data("href"),c=$(this).data("filter-name"),d=$(this).data("filter-category"),l="apply-filter"===$(this).attr("id");l&&$(".refinement-bar button.close").trigger("click");var u=$(this).data("browser-url");$.ajax({url:s,data:{page:$(".grid-footer").data("page-number"),selectedUrl:s},method:"GET",success:function(t){!function(t,e){var n=$(t),s={".refinements":o},c="true"===$("#isMobile").val()&&$(window).width()<=768&&!e&&parseInt(n.find("#apply-filter").data("selected-count"))>0;(c?[".header-bar",".header.page-title",".filter-bar",".mobile-result-count"]:[".grid-header",".header-bar",".header.page-title",".product-grid.plp",".show-more",".filter-bar",".mobile-result-count"]).forEach((function(t){a(n,t)})),Object.keys(s).forEach((function(t){s[t](n)})),c||(r.enhancingSelectDropdown(!0),i())}(t,l),sessionStorage.pagedata="Search-Show";var p=$('#apply-filter:not(".disabled")');p.length&&p.attr("data-href",s),window.history.pushState({},"",u),$(document).trigger("filter:trackingFilterAnalytics",{filterName:c,filterCategory:d}),e||window.scrollTo({top:$(".grid-header").offset()?$(".grid-header").offset().top:0,behavior:"instant"}),$.spinner().stop(),$(n).parent("button").focus()},error:function(){$.spinner().stop(),$(n).parent("button").focus()}})}))},showImageVarations:function(){$(document).on("click",".swatch",(function(t){var e=$
1(t.target);if(!e.parents(".swatch-click").hasClass("selected")){var n=$(this).attr("data-swatch-details"),r=$(this).attr("data-image-preset"),i=JSON.parse(n)[0].absURL;r&&(i+=i.indexOf("?")>-1?"&"+r:"?"+r);var a=e.parents(".product-tile"),o=$(a).children(".image-container").children("a"),s=$(a).find(".pdp-link").children("a"),c=e.parents(".swatch-click").data("href");if(o.attr("href",c),s.attr("href",c),o.children("img").attr("src",i),e.parents(".swatches").find(".swatch-click.selected").removeClass("selected"),e.parents(".swatch-click").addClass("selected"),e.parents(".swatch-click").find(".variationame")){var d=e.parents(".swatch-click").find(".variationame").text(),l=a.find(".product-click-track"),u=JSON.parse(l.attr("data-gtm-data"));u.variant=$.trim(d),l.attr("data-gtm-data",JSON.stringify(u))}}}))},productDetectionOnPLPLoad:function(){r.enhancingSelectDropdown(!0),i(),"true"==$.trim($("input[name=plp_infinitescroll]").val())&&($.spinner().start(),null!=window.history.state&&null!=window.history.state.results&&$(".product-grid.plp").html(decodeURIComponent(window.history.state.results)),setTimeout((function(){$.spinner().stop()}),900))},showContentTab:function(){$(".container").on("click",".content-search",(function(){""===$("#content-search-results").html()&&s($(this),$("#content-search-results"))})),$(".container").on("click",".show-more-content button",(function(){s($(this),$("#content-search-results")),$(".show-more-content").remove()}))},SortHideDropdown:function(){$(document).click((function(t){$(t.target).closest(".custom-dropdown__options").length||$(t.target).closest(".custom-dropdown__selected").length||!$(".custom-dropdown__optionsWrapper.custom-dropdown-active").length||$(".custom-dropdown__selected--text").click()}))},PLPBackButtonPreviousStage:function(){window.addEventListener("popstate",(function(){if("true"==$.trim($("input[name=plp_infinitescroll]").val())){var t=d(c()),e=t[0];if("safari"!=e||"safari"==e&&parseFloat(t[1])>16.2||"Search-Show"==sessionStorage.pagedata){window.name="",sessionStorage.scrollPos=0,window.scrollTo({top:0,behavior:"instant"});window.history.replaceState({results:null},"",window.location.href),location.reload()}else sessionStorage.pagedata="Search-Show"}else location.reload()}))}}},7584:function(t){function e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw o}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var r=function(t,e,n,r,a){var o=r?r.find(a):$(a);n&&(o=n.find("select").length>1?$(n.find("select").get(0)):$(n.find("select")));var s,c=o.children("option").length,d="sort-order-custom"===o.prop("name");if(d){var l=window.location.href,u=i.getQueryString(l),p=i.getQueryStringParams(u).srule;if(o&&o.length>0&&o[0].selectedIndex)s=o[0].selectedIndex;else if(p){var f=$("option[data-id="+p+"]"),h=o.children("option").index(f);s=h}else s=0}else s=0;o.addClass("d-none"),o.after('<div class="custom-dropdown"></div>');for(var m=o.next("div.custom-dropdown"),v=$("<div />",{class:"custom-dropdown__selected",id:"customDropdownSelected"}).appendTo(m),g=$("<span />",{class:"custom-dropdown__selected--text"}).appendTo(v),w=$("<div />",{class:"custom-dropdown__optionsWrapper"}).insertBefore(v),b=$("<ul />",{class:"custom-dropdown__options"}).appendTo(w),y=0;y<c;y++)$("<li />",{class:"custom-dropdown__options--item",text:o.children("option").eq(y).text(),"data-value":o.children("option").eq(y).val(),"data-browser-url":o.children("option").eq(y).data("browser-url"),"data-sort-option":o.children("option").eq(y).attr("data-sort-option")}).appendTo(b);var S=b.children("li");e?g.text(e):""===o.children("option").eq(0).text().trim()?g.text(o.children("option").eq(1).text()):g.text(
1o.children("option").eq(s).text()),t&&(e?S.eq(e-1).hide():S.eq(s).hide()),v.click((function(){w.toggleClass("custom-dropdown-active"),v.toggleClass("active-dropdown")})),S.each((function(e){$(this).click((function(){t&&(S.eq(s).show(),$(this).hide(),s=e);var n=$(this).text();g.text(n),w.removeClass("custom-dropdown-active");var r=$(this).attr("data-value"),i=$(this).data("browser-url"),a=$("#isFromCYO").data("isfromcyo"),c=$(this).attr("data-sort-option");o.val(r),$.spinner().start(),$.ajax({url:r,data:{selectedUrl:r},method:"GET",success:function(t){var e=$(".accordion-collapse.show");e.length?e.find(".product-grid").empty().html(t):$(".product-grid").not(".cartRecommendationCarousel").empty().html(t),d&&!a&&window.history.pushState({},"",i),c&&($(document).trigger("sort:trackingSortAnalytics",{sortOption:c}),$(document).trigger("sort:trackingDynamicImpression")),$.spinner().stop()},error:function(){$.spinner().stop()}}),o.change()}))}))},i={breakpoints:{xs:320,sm:480,md:768,lg:1024,xl:1280,"mobile-menu":1024},appendParamToURL:function(t,e,n){if(-1!==t.indexOf(e+"="))return t;var r=-1!==t.indexOf("?")?"&":"?";return t+r+e+"="+encodeURIComponent(n)},removeParamFromURL:function(t,e){if(-1===t.indexOf("?")||-1===t.indexOf(e+"="))return t;var n,r,i=t.split("?")[0],a=t.split("?")[1],o=[];a.indexOf("#")>-1&&(n=a.split("#")[1]||"",a=a.split("#")[0]),r=a.split("&");for(var s=0;s<r.length;s++)r[s].split("=")[0]!==e&&o.push(r[s]);return i+"?"+o.join("&")+(n?"#"+n:"")},appendToUrl:function(t,e){var n=t;return n+=(-1!==n.indexOf("?")?"&":"?")+Object.keys(e).map((function(t){return t+"="+encodeURIComponent(e[t])})).join("&")},appendParamsToUrl:function(t,e){var n=t;return n+=(-1!==n.indexOf("?")?"&":"?")+Object.keys(e).map((function(n){return new URL(t).searchParams.get(n)?"":n+"="+encodeURIComponent(e[n])})).join("&")},getQueryString:function(t){var e;if("string"!=typeof t)return null;var n=document.createElement("a");return n.href=t,n.search&&(e=n.search.substr(1)),e},toAbsoluteUrl:function(t){var e=t;return 0!==t.indexOf("http")&&"/"!==t.charAt(0)&&(e="/"+t),e},getQueryStringParams:function(t){if(!t||0===t.length)return{};var e={};return decodeURIComponent(t).replace(new RegExp("([^?=&]+)(=([^&]*))?","g"),(function(t,n,r,i){e[n]=i})),e},getUrlParam:function(t,e){var n=e;return window.location.href.indexOf(t)>-1&&(n=this.getUrlVars()[t]),n},validatePattern:function(t){var e=t.val(),n=t.siblings(".invalid-feedback"),r=!0;if(e){var i=t.data("invalid-error")||t.data("pattern-mismatch"),a=t.prop("pattern")||t.attr("pattern");new RegExp(a).test(e)?(t.removeClass("is-invalid"),n.empty(),r=!0):(t.addClass("is-invalid"),n.empty().html(i),r=!1)}else t.removeClass("is-invalid"),n.empty(),r=!0;return r},insertURLParam:function(t,e){for(var n=encodeURIComponent(t),r=encodeURIComponent(e),i=document.location.search.substr(1).split("&"),a=0;a<i.length;a++)if(i[a].startsWith(n+"=")){var o=i[a].split("=");o[1]=r,i[a]=o.join("=");break}a>=i.length&&(i[i.length]=[n,r].join("="));var s=i.join("&"),c=window.location.href.split("?")[0];window.history.replaceState({},document.title,c+"?"+s)},enhancingSelectDropdown:function(t,e,n,i){n?r(t,e,n):($("select").each((function(){r(t,e,n,i,this)})),$("body").click((function(t){"customDropdownSelected"!==t.target.id&&(t.target.classList&&t.target.classList.contains("slick-slider")||t.target.classList.contains("slick-lightbox-inner")||t.target.classList.contains("slick-lightbox"))&&($(".slick-lightbox").remove(),$("body").css("overflow","inherit"))})))},onLoadSEOUpdateOnViewerImages:function(t){var e=$("#"+t+"_flyoutZoomView .s7staticimage img"),n=$("#"+t+"_flyoutZoomView .s7flyoutzoom img"),r=$("#"+t).data("product-title"),i=$("#"+t).data("product-alt");e.attr("title",r).attr("alt",i),n.attr("title",r).attr("alt",i)},dynamicSEOUpdateOnViewerImages:function(t){if("MutationObserver"in window){var n=function(t){t.alt=$(r).data("product-alt"),t.title=$(r).data("product-title")},r=document.querySelector("#"+t);new MutationObserver((function(t){t.forEach((function(t){"childList"===t.type&&t.addedNodes.forEach((function(t){if("IMG"===t.tagName&&n(t),t.nodeType===Node.ELEMENT_NODE){var r,i=e(t.getElementsByTagName("img"));try{for(i.s();!(r=i.n()).done;){var a=r.value;n(a)}}catch(t){i.e(t)}finally{i.f()}}}))}))})).observe(r,{childList:!0,subtree:!0})}},selectSwatchOnViewerSwipe:function(t,e){var n=0,r=0,i=e.attr("id"),a=$("#"+i+"_container_inner").children().not("[class*=swatches]"),o=e.find(".s7thumbcell")?e.find(".s7thumbcell").length-1:0;if(o>
10&&a){Array.from(a).forEach((function(i){i.addEventListener("touchstart",(function(t){n=t.changedTouches[0].screenX})),i.addEventListener("touchend",(function(i){var a,s,c;r=i.changedTouches[0].screenX,a=t.getComponent("swatches"),s=e.find(".s7thumbcell[aria-selected=true]"),c=parseInt(e.find(".s7thumbcell[aria-selected=true]").attr("swindex")),r<n&&c<=o&&($(document).trigger("s7image:swipe","Left"),a.selectSwatch(parseInt(s.next().attr("swindex")),!0)),r>n&&c>=0&&($(document).trigger("s7image:swipe","Right"),a.selectSwatch(parseInt(s.prev().attr("swindex")),!0))}))}))}},trackPDPVideoEvents:function(t,e){try{var n=e?e.split(",")[0]:"";if("MILESTONE"===n||"PLAY"===n){var r=$("#"+t).length>0?$("#"+t).closest(".product-detail"):null,i=r&&r.find(".product-name").length>0?r.find(".product-name").first().text().replace(/[\n"]/g,"").trim():"";switch(n){case"PLAY":var a=$("#"+t).find("video").length>0?$("#"+t).find("video")[0]:null;if(!a||!a.duration)return;var o=a.duration,s=e.split(",")[1]/1e3,c=Math.round(s/o*100);c>0&&c<100&&dataLayer.push({event:"pdpVideo",videoStatus:"start",videoPercent:c,videoTitle:i});break;case"MILESTONE":var d=e.split(",")[1];"0"===d&&dataLayer.push({event:"pdpVideo",videoStatus:"start",videoPercent:0,videoTitle:i}),"25"!==d&&"50"!==d&&"75"!==d||dataLayer.push({event:"pdpVideo",videoStatus:"progress",videoPercent:parseInt(d,10),videoTitle:i}),"100"===d&&dataLayer.push({event:"pdpVideo",videoStatus:"complete",videoPercent:100,videoTitle:i})}}}catch(t){}},trackHasVideoEvent:function(t,e){var n=t.closest(".product-detail").length>0?t.closest(".product-detail").data("master")?t.closest(".product-detail").data("master"):t.closest(".product-detail").data("pid"):null,r=t.closest(".product-detail").length>0?t.closest(".product-detail").data("product-name"):null;if(n&&r){var i=!1;e&&e.component&&e.component.jsonSet&&e.component.jsonSet.item&&e.component.jsonSet.item.forEach((function(t){"video"!==t.type&&"video_set"!==t.type||(i=!0)})),dataLayer.push({event:"pdp_data_loaded",product:{id:n,name:r,has_video:i}})}}};t.exports=i},2343:function(t){function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}t.exports=function(t){"function"==typeof t?t():"object"===e(t)&&Object.keys(t).forEach((function(e){"function"==typeof t[e]&&t[e]()}))}}},n={};function r(t){var i=n[t];if(void 0!==i)return i.exports;var a=n[t]={exports:{}};return e[t](a,a.exports,r),a.exports}t=r(2343),$(document).ready((function(){t(r(8148))}))}();

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.