(function(n,t){typeof define=="function"&&define.amd?define(t):typeof module=="object"&&module.exports?module.exports=t():n.wishlistModule=t()})(this,function(){function t(t){t.preventDefault();var i=$(this),u=$('input[name="productCode"]').length>0?$('input[name="productCode"]').val():i.parents(".associated-product").data("id"),r={wishlistID:i.data("wishlistid")||-1,stockID:i.data("stockid")||-1,productID:i.data("productid")||-1,basketID:i.data("basketid")||-1,qty:i.parents(".sizePicker")?i.parents(".sizePicker").find('[name="quantity"]').val():1},f=$.param(r),e=r.basketID==-1?"/ajax/addtowishlist":"/ajax/addbaskettowishlist";i.attr("data-loading","true");$(".tooltip",i.parent()).tooltip("hide");$.ajax({url:e,data:f,success:function(t){if(t.error)if(t.error.message.indexOf("Please log in")!=-1){var r=t.results.stock;"credentials"in navigator?credentialHelper.attemptSignIn("/ajax/loginmodal?iswishlist=true&stockcode="+r):OpenModal("/ajax/loginmodal?iswishlist=true&stockcode="+r)}else alert(t.error.message);else n.setPlaceholderValues(t.results.WishlistItems),n.updateHeader(t.results.loggedIn),i.addClass("in-wishlist").find(".glyphicon-star-empty").removeClass("glyphicon-star-empty").addClass("glyphicon-star"),i.trigger("added.wishlist.remarkable"),$(document).trigger("rc-product-add-to-wishlist",{productCode:u});i.removeAttr("data-loading")},error:function(){alert("There has been an error\nPlease refresh and try again");i.removeAttr("data-loading")}})}var n={version:"1.0.0",placeholderSelector:".js-wishlist-total"};return n.init=function(){n.attachEventListeners()},n.attachEventListeners=function(n){var i=n||document;$(i).on("click",".js-add-to-wishlist",t)},n.updatePlaceholderValues=function(){n.setPlaceholderValues(Remarkable.WishlistItems)},n.setPlaceholderValues=function(t){$(n.placeholderSelector).html("("+t+")");t>0?$(n.placeholderSelector).removeClass("hidden"):$(n.placeholderSelector).addClass("hidden")},n.updateHeader=function(n){n||$(".js-wishlist-url").attr("href","/account/wishlist")},n}),function(n,t){typeof define=="function"&&define.amd?define(["jquery",],t):typeof module=="object"&&module.exports?module.exports=t(require("jquery")):n.listingPage=t(n.jQuery)}(this,function(n){function c(){n=window.jQuery}function l(){var u,r;n(".filter-group__title a").on("click",function(n){n.preventDefault()});u=v();SetupFullWidthOwl();t.multipleSashes();r=n(".dynamicContent");u&&History.init();History.Adapter.bind(window,"statechange",function(){e(History.getState().url)});r.on("click",".paging-module a:not(.paging-module__style a), .filter-container a:not(.no-ajax), .category-intro__links a",function(r){var f,o,s;r.preventDefault();r.stopPropagation();n(this).parent("li").toggleClass("active");f=n(this).attr("href");n(r.target).parents(".paging-module").length&&!i?(i=!0,Remarkable.isMobile?u?n(this).hasClass("js-load-more")?e(f,!0):History.pushState(null,"Loading...",f):window.location=f:ScrollToElement(".dynamicContent",15,function(){u?History.pushState(null,"Loading...",f):window.location=f})):u?History.pushState(null,"Loading...",f):window.location=f;o=n(this).parents(".filter-group").data("id");s=n(this).attr("title");!n(this).parents(".paging-module").length&&n(this).parents(".filter-group").length&&(t.countFilter(o),n(document).trigger("rc-filters-clicked",{filterName:o,filterProp:s}))});r.on("change",".js-filter-select",function(t){var o,e,i,r,f;t.preventDefault();o=n(this).val();u?History.pushState(null,"Loading...",o):window.location=o;e=n(this).parents(".filter-group").find("> .filter-group__title:eq(0)").text();i=n(this).attr("title");n(this).data("filtername")&&(e=n(this).data("filtername"));Remarkable.isMobile?ScrollToElement(".dynamicContent",106):ScrollToElement(".dynamicContent",15);r="OTHER";f="DESC";e=="sort by"&&(i=n(".paging-module__sort select :selected").text(),i=="Price High To Low"&&(r="PRICE",f="DESC"),i=="Price Low To High"&&(r="PRICE",f="ASC"),i=="Top Selling First"&&(r="POPULARITY",f="DESC"));n(document).trigger("rc-filters-clicked",{filterName:e,filterProp:i,filterSort:r,filterOrder:f})});f();r.on("click",".js-toggle-filters",function(i){i.preventDefault();ScrollToElement(".filter-container",106);n(".filter-container").toggleClass("opened");var r=n(".page-container");r.toggleClass("prevent-scroll");t.saveFilterState();Remarkable.startFilterURL=location.href});r.on("click",".js-cancel-filters",function(t){t.preventDefault();History.pushState(null,"Loading...",Remarkable.startFilterURL);n(document).trigger("rc-filters-clicked",{filterName:filterName})});r.on("shown.bs.collapse hidden.bs.collapse",".filter-group .panel-collapse",function(n){n.preventDefault();t.saveFilterState()});r.on("click",".js-view-mode",function(t){t.preventDefault();var i=n(this).data("mode");setCookie("viewStyle",i);o();s(i);n(document).trigger("rc-viewmode",{filterName:i})});setTileCascade(300);scrollElm=Remarkable.isMobile?n(".page-container"):n(document);scrollElm.scroll(function(){requestAnimFrame(t.checkLoadMore)});r.on("click",".js-clear-filter-customisation",function(){t.clearFilterState();window.location.reload()});r.on("click",".js-show-modal",function(){var i=window.original_uv||universal_variable,t;n(this).data("href").indexOf("quickview")>0&&(t=getProductListName(n(this)),n(document).trigger("rc-quickview",{productID:n(this).parents(".associated-product").data("id"),listName:t}))});r.on("click",".associated-product",function(t){var r=window.original_uv||universal_variable,i;n(t.target).parents(".associated-product__controls").length<1&&!n(t.target).hasClass("ajax-owl-carousel__next")&&!n(t.target).hasClass("ajax-owl-carousel__prev")&&(i=getProductListName(n(t.target)),n(document).trigger("rc-product-click",{productID:n(this).data("id"),listName:i,href:n(this).find("[itemprop=url]").attr("href")}))})}function f(n){var t=getCookie("viewStyle"),i;t!=undefined?(i=t,s(i,n)):setCookie("viewStyle","model")}function e(r,u){var e=n(".dynamicContent"),o=n("input[name=currentpage]:last").val(),s="left",c=parseInt(a("page",r))||1;c<parseInt(o)&&(s="right");document.title="Loading...";u||t.AjaxShow();n(".js-load-more").text("Loading...");n.ajax({url:r,success:function(o){var c=n('input[name="ajaxTitle"]',o).val(),y=n(".filter-container--slider").hasClass("opened"),s=n(o),l,a,v;t.updateUniversalVariable(s);u?(l=n(".paging-module:not(.paging-module--top-bar)",e),a=l.parent(),l.remove(),a.append(s.find(".listing-items").next()),n(".listing-items",e).append(s.find(".listing-items").html())):e.html(s.find(".dynamicContent").html());y&&n(".filter-container--slider").addClass("opened");document.title=c;SetupFullWidthOwl();n('[data-toggle="tooltip"]').tooltip();t.AjaxHide();f();setTimeout(function(){Unveil()},500);ajaxOwlCarousel.init(n(".ajax-owl-carousel"));setTileCascade(300);n(document).trigger("rc-pageview",{url:h(r),title:c});v=n("input[name=currentpage]:last").val();n("[data-page="+v+"] .js-listing-image:first").on("load",function(){n(document).trigger("rc-pageview-first-product",{url:h(r),title:c})});t.multipleSashes();setTimeout(function(){i=!1},1e3)},error:function(){window.location=r}})}function o(){var i=getCookie("viewStyle"),t=n(".paging-module__style");t.find(".paging-module__btn").removeClass("btn-primary");n('[data-mode="'+i+'"]',t).addClass("btn-primary")}function s(t,i){var r=".listing-items",f="state-"+t,u=!1,e;n(r+'[class*="state-"]').length?n(r).hasClass(f)||(u=!0):t=="product"&&(u=!0);o();u&&(UnbindImgHover(),e=n(".listing-items img[data-eimageswap]:not(.noswap)",i),e.each(function(){var t=n(this),u=t.attr("src"),r=t.attr("data-src")?t.attr("data-src"):t.attr("src"),i=t.attr("data-eimageswap");t.attr("src").indexOf("blank")!=-1?(t.attr("data-src",i),t.attr("data-eimageswap",r)):(t.attr("src",i),t.attr("data-src",i),t.attr("data-eimageswap",r))}),n(r).removeClass("state-model state-product").addClass(f))}function a(n,t){n=n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+n+"=([^&#]*)"),i=r.exec(t);return i==null?"":decodeURIComponent(i[1].replace(/\+/g," "))}function h(n){for(var r=n.split("/"),i="",t=3;t<r.length;t++)i+="/",i+=r[t];return i}function v(){var n=window.location.href,t;return n.indexOf("#!")!=-1?(t=n.split("#!"),newURL=t[0]+t[1]+"&isOldUrl=true",window.location=newURL,!1):n.indexOf("#mrasn")!=-1?!1:!0}var n=n,t={},i;t.init=function(){c();console.log("Listing Page: Enter");n(document).trigger("rc-product-list-visible",{pageName:n("h1").text().trim()});l();wishlistModule.init()};t.exit=function(){console.log("Listing Page: Exit")};t.AjaxShow=function(){NProgress.start();n(".ajaxLoaderOverlay").addClass("show")};t.AjaxHide=function(){NProgress.done();n(".ajaxLoaderOverlay").removeClass("show")};t.getFilterOrder=function(n){var r=n||t.getFilterStateLS(),u=[],i;for(i in r)u.push([i,r[i].clicked?r[i].clicked:0]);return u.sort(function(n,t){return n[1]-t[1]})};t.reorderFilters=function(i,r){for(var e=r||10,f=t.getFilterOrder(),u=0;u<f.length;u++)f[u][1]>e&&(n('[data-id="'+f[u][0]+'"]',i).parent().detach().insertAfter(n(".filter-container > .col:first-of-type",i)),n(".js-clear-filter-customisation",i).removeClass("hidden"))};t.clearFilterState=function(){try{localStorage.removeItem("FilterState")}catch(n){}};t.getFilterState=function(t){var i={};return n(".filter-group[data-id]",t).each(function(){i[n(this).data("id")]={collapsed:n(".panel-collapse.collapse",this).hasClass("in")?!0:!1}}),n(".filter-container",t).each(function(){i[n(this).data("id")]={collapsed:n(this).hasClass("opened")}}),i};t.saveFilterState=function(i){var f=t.getFilterState(i),r,u;try{window.localStorage&&(r=JSON.parse(localStorage.getItem("FilterState")),u=n.extend(!0,r,f),localStorage.setItem("FilterState",JSON.stringify(u)))}catch(e){console.log(e)}};t.getFilterStateLS=function(){try{return window.localStorage&&localStorage.getItem("FilterState")?JSON.parse(localStorage.getItem("FilterState")):{}}catch(t){return{}}};t.updateUniversalVariable=function(t){t.filter(".qubitPageUV").each(function(){n.globalEval(this.text||this.textContent||this.innerHTML||"")});checkQubit()};t.setFilterState=function(t){var i,r,u,f;try{if(window.localStorage&&localStorage.getItem("FilterState")){i=JSON.parse(localStorage.getItem("FilterState"));i.filtercontainer.collapsed==!0&&t&&n(".filter-container",t).addClass("opened");for(r in i)i.hasOwnProperty(r)&&(u=i[r].collapsed,f=n(".filter-group[data-id="+r+"]",t),n('.filter-group__title[data-toggle="collapse"]',f).toggleClass("collapsed",!u).attr("aria-expanded",u),n(".panel-collapse",f).toggleClass("in",u))}}catch(e){}};t.countFilter=function(i){var u={},r=t.getFilterStateLS(),f;u[i]={clicked:r[i]&&r[i].clicked?r[i].clicked+1:1};f=n.extend(!0,r,u);localStorage.setItem("FilterState",JSON.stringify(f))};var y=5,r=0,u=0;return t.stickyFooter=function(){(scrollTopElm=Remarkable.isMobile?n(".page-container"):n(document),r=scrollTopElm.scrollTop(),Math.abs(u-r)<=y)||(r>u?n(".fixed-filters-xs").addClass("offscreen"):n(".fixed-filters-xs").removeClass("offscreen"),u=r)},i=!1,t.checkLoadMore=function(){var t=Remarkable.isMobile?n(".page-container"):n(document);t.scrollTop()>=t[0].scrollHeight-t.height()-450&&!i&&n(".js-load-more").trigger("click")},t.multipleSashes=function(){var i,t;typeof t!="undefined"&&window.removeEventListener("resize",t);i=n(".associated-product__sash.bottom-center + .associated-product__sash.bottom-center");i.length>1&&(t=Remarkable.debounce(function(){i.prev().css({bottom:i.height()})},250),t(),window.addEventListener("resize",t))},t})