(function($){window.ps=window.ps||{};ps.currentBreakpoint=null;ps.navBreakpoint=!1;ps.breakpoints={xl:1600,lg:1200,md:750,sm:360,nav:1240};enquire.register('screen and (min-width: '+ps.breakpoints.xl+'px)',{match:function(){ps.currentBreakpoint='xl'}}).register('screen and (min-width: '+ps.breakpoints.lg+'px) and (max-width: '+(ps.breakpoints.xl-1)+'px)',{match:function(){ps.currentBreakpoint='lg'}}).register('screen and (min-width: '+ps.breakpoints.md+'px) and (max-width: '+(ps.breakpoints.lg-1)+'px)',{match:function(){ps.currentBreakpoint='md'}}).register('screen and (max-width: '+(ps.breakpoints.md-1)+'px)',{match:function(){ps.currentBreakpoint='sm'}}).register('screen and (max-width: '+(ps.breakpoints.nav-1)+'px)',{match:function(){ps.navBreakpoint=!0},unmatch:function(){ps.navBreakpoint=!1}});$('.sso-linked').on('load',function(){location.reload()});$(document).on('keyup','textarea',function(){while($(this).outerHeight()<this.scrollHeight+parseFloat($(this).css('borderTopWidth'))+parseFloat($(this).css('borderBottomWidth'))){$(this).height($(this).height()+1)}});function showDataLabel(e){if(typeof e==='object'){e.stopPropagation()}
$(this).closest('[data-label]').toggleClass('j-label',!$(this).val()=='')}
$.fn.showDataLabels=function(){return $(this).each(showDataLabel)};$('[data-label] input, [data-label] textarea, [data-label] select').showDataLabels();$(document).on('keyup','[data-label] input, [data-label] textarea',$.debounce(showDataLabel,100));$(document).on('change','[data-label] select',$.debounce(showDataLabel,100));$('.j-inc, .j-dec').on('click',function(){var $input=$(this).parent().find('input');var oldValue=$input.val();var newVal=0;if(button.hasClass('j-inc')){newVal=parseFloat(oldValue)+1}else{newVal=oldValue>0?parseFloat(oldValue)-1:0}
$input.val(newVal)});var go_pickers={};$('.s-input-date-picker').each(function(li_index){var lo_input=$(this).find('input:first');var lo_field=$(this).get(0);var lo_picker=new Pikaday({field:lo_field,input:lo_input,format:'D MMM YYYY',onSelect:function(){this._o.input.val(this.getDate().toLocaleDateString())}});$(this).data('picker-index',li_index);go_pickers[li_index]=lo_picker;$(this).on('click',function(){var li_thisindex=$(this).data('picker-index');var lo_thispicker=go_pickers[li_thisindex];if(typeof lo_thispicker=='object'){lo_thispicker.show()}})});$(document).on('click','.j-popup-example',function(){$.popup.open({class:'ps-popup--example',url:'/popup-example'})});$(document).on('click','.j-trigger-privacy',function(){if($('.j-close-slide-in').length){$.slideIn.close()}
$.popup.open({class:'s-popup--bottom s-popup privacy-popup',url:'/popup-privacy',})});$(document).on('click','.j-popup-bottom-example',function(){$.popup.open({class:'ps-popup--example ps-popup--bottom',url:'/popup-example'})});$(document).on('click','.j-slide-in-example',function(){$.slideIn.open({class:'ps-slide-in--example',url:'/slide-in-example'})});$(document).on('click','.j-geo-locate-popup',function(){$.popup.open({class:'popup-geo-locate',url:'/popup-geo-locate'})});if(typeof triggerGeoPopup!='undefined'&&triggerGeoPopup!=1){$.popup.open({class:'popup-geo-locate',url:'/popup-geo-locate'})}
if(typeof triggerGeoPopup!='undefined'&&triggerGeoPopup!=1){$.popup.open({class:'popup-geo-locate',url:'/popup-geo-locate'})}
if(typeof welcomePopup!='undefined'&&welcomePopup!=1){triggerWelcomePopup()}
$(document).on('click','.j-laybuy-popup',function(){$.popup.open({class:'ps-popup--laybuy',url:'/popup-laybuy'})});$(document).on('click','.j-afterpay-popup',function(){$.popup.open({class:'ps-popup--afterpay',url:'/popup-afterpay'})});$(document).on('click','.j-loading-popup',function(){$.popup.open({class:'ps-popup--loader',url:'/popup-loader'})});$(document).on('click','.j-login-slide-in',function(e){e.preventDefault();$.slideIn.open({url:'/slide-in-login',class:'slide-in-login'})});$(document).on('click','.j-register-slide-in',function(e){e.preventDefault();$.slideIn.open({url:'/slide-in-register',class:'slide-in-register'})});if(!(typeof URLSearchParams==='undefined')){var registerParams=new URLSearchParams(window.location.search);if(registerParams.has('register')){$.slideIn.open({url:'/slide-in-register',class:'slide-in-register'})}}
$(document).on('submit','#j-register-form',function(e){e.preventDefault();var _form=$(this);var formData=_form.serializeArray();var formAction=_form.attr('action');_form.find('.s-input-error, .s-error').html('').addClass('is-hidden');$('.j-form-error, .j-form-success').html('').addClass('is-hidden');$.ajax({url:formAction,type:'post',dataType:'json',data:formData,success:function(po_response){if(po_response.status){$('.j-form-success').html(po_response.data.message).removeClass('is-hidden');_form[0].reset();subscribeTimer=setTimeout(function(){window.location.href='/my-account'},3000)}else{if(po_response.data.errors.form){$('.j-form-error').html(po_response.data.errors.form).removeClass('is-hidden')}
lo_errors=po_response.data.errors;if(!$.isEmptyObject(lo_errors)){$.each(lo_errors,function(name,value){if(name=='recaptcha'){$('.j-recaptcha-error').html(value).removeClass('is-hidden')}else if(name=='dob'){$('.j-dob-error').html(value).removeClass('is-hidden')}else{_form.find('input[name="'+name+'"]').next('.has-error').html(value).removeClass('is-hidden')}})}}},})});function triggerWelcomePopup(){if(!$('.popup-geo-locate').length){setTimeout(function(){$.popup.open({class:'s-popup welcome-popup',url:'/popup-welcome'})},3000)}}
if($('#v-site-header').length){new Vue({el:'#v-site-header',name:'Header',store:peppercheckout.cart.$store,data:function(){return{searchActive:!1,searchTransitionActive:!1,isMobile:!1,}},components:{'search-result':vcSearchResult,},methods:{showSearch:function(){this.searchActive=!0},hideSearch:function(){this.searchActive=!1},onSearchTransition:function(){$('body').toggleClass('has-search-active');this.searchTransitionActive=!this.searchTransitionActive;if(!this.searchActive){this.$nextTick(nav.reInit)}}},mounted:function(){GlobalEventBus.$on('search:show',this.showSearch);GlobalEventBus.$on('search:hide',this.hideSearch)},created:function(){var _this=this;this.$nextTick(function(){enquire.register('(max-width: '+(ps.breakpoints.lg-1)+'px)',{match:function(){_this.isMobile=!0;_this.searchActive=!1}}).register('(min-width: '+ps.breakpoints.lg+'px)',{match:function(){_this.isMobile=!1;_this.searchActive=!0}})})}})}
$(document).on('click','.co-cart .s-dropdown-styled',function(){$('.co-cart j-dropdown-styled').not(this).find('ul').slideUp();$(this).find('ul').slideToggle();$(this).toggleClass('is-active')});var promoStrip={$wrap:$('.j-promo-strip'),$slider:$('.j-promo-strip-slider'),$close:$('.j-promo-strip-close'),close:function(){promoStrip.$wrap.remove();$.post('/api/site/hidepromobanner',{location:"top"})},init:function(){if(promoStrip.$slider.length){promoStrip.$slider.slick({arrows:!1,autoplay:!0,mobileFirst:!0,autoplaySpeed:6000,accessibility:!1})}
setTimeout(function(){promoStrip.$wrap.removeClass('is-invisible')},300);promoStrip.$close.on('click',promoStrip.close)}};promoStrip.init();var promoStripFooter={$wrap:$('.j-footer-promo-strip'),$slider:$('.j-footer-promo-strip-slider'),$close:$('.j-footer-promo-strip-close'),close:function(){promoStripFooter.$wrap.remove();$.post('/api/site/hidepromobanner',{location:"bottom"})},init:function(){if(promoStripFooter.$slider.length){promoStripFooter.$slider.slick({arrows:!1,autoplay:!0,autoplaySpeed:6000})}
setTimeout(function(){promoStripFooter.$wrap.removeClass('is-invisible')},300);promoStripFooter.$close.on('click',promoStripFooter.close)}};promoStripFooter.init();var nav={$siteHeader:$('.j-site-header'),$primaryNav:$('.j-primary-nav'),$subnavShow:$('.j-show-sub-nav'),$subnavHide:$('.j-hide-sub-nav'),$toggle:$('.j-toggle-nav'),$toggleOverlay:$('.j-toggle-overlay'),offset:$('.j-pre-header').outerHeight()||0,height:$('.j-site-header').outerHeight(),toggled:!1,events:{},show:function(){nav.toggled=!0;nav.$toggle.addClass('is-active').attr('aria-expanded','true');nav.$primaryNav.addClass('is-active');$('body').addClass('has-nav-active');$('html, body').animate({scrollTop:nav.$siteHeader.offset().top});$.overlay.show(nav.hide)},hide:function(){nav.toggled=!1;nav.$toggle.removeClass('is-active').attr('aria-expanded','false');nav.$primaryNav.removeClass('is-active');$('body').removeClass('has-nav-active');$.overlay.hide()},initMobileMenu:function(){nav.$subnavShow.on('click.subnav',nav.showSubNav);nav.$toggleOverlay.off('mouseenter.subnav').off('mouseleave.subnav');nav.$subnavHide.on('click',nav.hideSubNav);nav.$toggle.on('click',nav.toggle)},destroyMobileMenu:function(){nav.$subnavShow.off('click.subnav');nav.$toggleOverlay.on('mouseenter.subnav',nav.showSubNav).on('mouseleave.subnav',nav.hideSubNav);nav.$subnavHide.off('click',nav.hideSubNav);nav.$toggle.off('click',nav.toggle);nav.hide()},updateLayoutDimensions:function(){nav.offset=$('.j-pre-header').outerHeight()||0;nav.height=nav.$siteHeader.outerHeight()},toggle:function(){nav.toggled?nav.hide():nav.show()},showSubNav:function(e){e.preventDefault();if(!ps.navBreakpoint){$.overlay.show()}else{nav.$primaryNav.scrollTop(0)}
$(this).closest('.has-sub-nav').addClass('is-active')},hideSubNav:function(e){e.preventDefault();if(!ps.navBreakpoint){$.overlay.hide()}
$(this).closest('.has-sub-nav').removeClass('is-active')},positionHeader:function(){var $body=$('body');var scroll=Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop);nav.updateLayoutDimensions();if(scroll>nav.offset){$body.addClass('has-fixed-header').css('padding-top',nav.height);nav.$siteHeader.addClass('is-fixed')}else{$body.removeClass('has-fixed-header').css('padding-top','');nav.$siteHeader.removeClass('is-fixed')}},init:function(){nav.updateLayoutDimensions();nav.positionHeader();enquire.register('screen and (max-width: '+(ps.breakpoints.nav-1)+'px)',nav.initMobileMenu);enquire.register('screen and (min-width: '+ps.breakpoints.nav+'px)',nav.destroyMobileMenu);$(window).on('resize scroll',$.throttle(nav.positionHeader,10))},destroy:function(){enquire.unregister('screen and (max-width: '+(ps.breakpoints.nav-1)+'px)',nav.initMobileMenu);enquire.unregister('screen and (min-width: '+ps.breakpoints.nav+'px)',nav.destroyMobileMenu);nav.$subnavHide.off('click',nav.hideSubNav);nav.$subnavShow.off('click.subnav').off('mouseenter.subnav').off('mouseleave.subnav');$(window).off('resize scroll',$.throttle(nav.positionHeader,10))},reInit:function(){nav.$siteHeader=$('.j-site-header');nav.$primaryNav=$('.j-primary-nav');nav.$subnavShow=$('.j-show-sub-nav');nav.$subnavHide=$('.j-hide-sub-nav');nav.$toggle=$('.j-toggle-nav');nav.$toggleOverlay=$('.j-toggle-overlay');if(ps.navBreakpoint){nav.destroyMobileMenu();nav.initMobileMenu()}else{nav.destroy();nav.init()}}}
nav.init();var search={$el:null,init:function(){GlobalEventBus.$on('search-results:show',search.onShow);GlobalEventBus.$on('search-results:hide',search.onHide)},initEvents:function(){$(window).on('resize.search',$.debounce(search.setMaxHeight,100))},destroyEvents:function(){$(window).off('resize.search')},setMaxHeight:function(){var rect=search.$el[0].getBoundingClientRect();search.$el.css('max-height',window.innerHeight-rect.top+'px')},onShow:function(){search.$el=$('.j-search-typeahead-results');search.setMaxHeight();search.initEvents();$.overlay.show(function(){GlobalEventBus.$emit('search:hide')})},onHide:function(){search.destroyEvents();$.overlay.hide()}}
search.init();$(document).on('submit','.j-newsletter-form',function(e){e.preventDefault();var _form=$(this);var formAction=_form.attr('action');var formData=_form.serializeArray();_form.find('.s-success, .s-input-error').html('').addClass('is-hidden');$.ajax({url:formAction,type:'post',dataType:'json',data:formData,success:function(response){if(response.status){var gaData={eventCategory:'Email Signup',eventAction:'Sign Up',eventLabel:'Footer Sign Up',};$(document).trigger('psevent',['footerEmailSignUp',gaData]);_form.find('.s-success').removeClass('is-hidden').html(response.data.message);var subscribeTimer=setTimeout(function(){_form.find('.s-success').addClass('is-hidden');_form[0].reset()},3000)}else{if(response.data.error){_form.find('.s-input-error').removeClass('is-hidden').html(response.data.error)}}},})});$(document).on('submit','.j-welcomepopup',function(e){e.preventDefault();var _form=$(this);var formAction=_form.attr('action');var formData=_form.serializeArray();_form.find('.s-success, .s-input-error').html('').addClass('is-hidden');$.ajax({url:formAction,type:'post',dataType:'json',data:formData,success:function(response){if(response.status){var gaData={eventCategory:'Email Signup',eventAction:'Sign Up',eventLabel:'Welcome Sign Up',};$(document).trigger('psevent',['welcomeEmailSignUp',gaData]);_form.find('.s-success').removeClass('is-hidden').html(response.data.message);var subscribeTimer=setTimeout(function(){_form.find('.s-success').addClass('is-hidden');_form[0].reset();$.popup.close({class:'s-popup welcome-popup',url:'/popup-welcome'})},3000)}else{if(response.data.error){_form.find('.s-error').removeClass('is-hidden').html(response.data.error)}}},})});$(document).on('click','.j-close-welcome-popup',function(e){e.preventDefault();$.popup.close()});if(!(typeof peppercontentjs==='undefined')){peppercontentjs.full.adaptiveHeight=!1;$('.j-slider-product').each(function(){var productRowId=this.id;new Vue({el:'#'+productRowId,name:'ProductRow',data:function(){return{items:{}}},created:function(){this.items=window[productRowId].items}})});$('.j-slider-product').on('init',function(){$(this).verticallyPosition({image:'.s-image img'})});peppercontentjs.init()}
$('.j-collapsible').collapsible();var collapsibleOnMobile=$('.j-collapsible-mobile');if(collapsibleOnMobile.length){enquire.register('(max-width: '+(ps.breakpoints.lg-1)+'px)',{match:function(){collapsibleOnMobile.collapsible()},unmatch:function(){collapsibleOnMobile.collapsible('destroy')},})}
var password={checkValidity:function(){var $this=$(this);var $rules=$('#'+$this.attr('aria-describedby'));var value=$this.val();$rules.find('.j-password-chars').toggleClass('is-valid',value.length>=8)},toggleVisibility:function(){var $toggle=$(this);var $input=$toggle.prev();var isPassword=$input.attr('type')==='password';$input.attr('type',isPassword?'text':'password');$toggle.toggleClass('is-toggled')},};$(document).on('keypress','.j-password',$.debounce(password.checkValidity,100));$(document).on('click','.j-password-toggle',password.toggleVisibility);var faqTabs=$('.j-faq-tabs').tabs({onSelect:function(tab){var tabName=$(tab).attr('id');window.history.replaceState('','','/faq/'+tabName)}});if(faqTabs.length){enquire.register('(max-width: '+ps.breakpoints.md+'px)',{match:function(){faqTabs.dropdown({valueEl:'button'})},unmatch:function(){faqTabs.dropdown('destroy')}})}
$(document).on('submit','#j-forgot-password-form',function(e){e.preventDefault();var forgotpasswordForm=$(this);var formData=forgotpasswordForm.serializeArray();forgotpasswordForm.find('.j-form-success').addClass('is-hidden');forgotpasswordForm.find('.j-email-error').addClass('is-hidden');forgotpasswordForm.find('.j-form-error').addClass('is-hidden');$.ajax({url:'/customerapi/forgotpassword',type:'post',dataType:'json',data:formData,success:function(response){if(response.status){forgotpasswordForm.find('#email').val('');forgotpasswordForm.find('.j-form-success').removeClass('is-hidden').html(response.data.message)}else{if(response.data.errors.form){forgotpasswordForm.find('.j-form-error').removeClass('is-hidden').html(response.data.errors.form)}else{if(response.data.errors.email){forgotpasswordForm.find('.j-email-error').removeClass('is-hidden').html(response.data.errors.email)}}}},})});$(document).on('submit','#j-reset-password-form',function(e){e.preventDefault();var resetpasswordForm=$(this);var formData=resetpasswordForm.serializeArray();resetpasswordForm.find('.j-password-error').addClass('is-hidden');resetpasswordForm.find('.j-form-error').addClass('is-hidden');$.ajax({url:'/customerapi/resetpassword',type:'post',dataType:'json',data:formData,success:function(response){if(response.status){window.location.href='/my-account'}else{if(response.data.errors.form){resetpasswordForm.find('.j-form-error').removeClass('is-hidden').html(response.data.errors.form)}else{if(response.data.errors.password){resetpasswordForm.find('.j-password-error').removeClass('is-hidden').html(response.data.errors.password)}}}},})});$(document).on('submit','#j-login-form',function(e){e.preventDefault();var _form=$(this);var formData=_form.serializeArray();var formAction=_form.attr('action');_form.find('.s-input-error, .s-error').html('').addClass('is-hidden');$.ajax({url:formAction,type:'post',dataType:'json',data:formData,success:function(po_response){if(po_response.status){window.location.href='/my-account'}else{if(po_response.data.errors.form){_form.find('.j-form-error').html(po_response.data.errors.form).removeClass('is-hidden')}
lo_errors=po_response.data.errors;if(!$.isEmptyObject(lo_errors)){$.each(lo_errors,function(name,value){_form.find('input[name="'+name+'"]').parents('.s-input').next('.s-input-error').html(value).removeClass('is-hidden')})}}},})});$("#update-preferences").on('submit',function(e){e.preventDefault();var form=$(this);var url=form.attr('action');$.ajax({type:"POST",url:url,data:form.serialize(),success:function(response){if(response.status){customerid=response.data.customerid;url='/preference-centre?status=updated&i='+customerid;window.location.href=url}}})});$("#handle-email").on('submit',function(e){e.preventDefault();var form=$(this);var url=form.attr('action');$.ajax({type:"POST",url:url,data:form.serialize(),success:function(response){if(response.status){customerid=response.data.customerid;url='/preference-centre?i='+customerid;window.location.href=url}}})});$(document).on('click','.j-domainchange-header',function(e){var $this=$(this);e.preventDefault();var storefrontName=$this.data('storefrontname');var gaData={eventCategory:'Domain Selector',eventAction:'Header',eventLabel:storefrontName,};$(document).trigger('psevent',['headerdomainchange',gaData]);window.location.href=$this.attr('href')});$(document).on('click','.j-domainchange-footer',function(e){var $this=$(this);e.preventDefault();var storefrontName=$this.data('storefrontname');var gaData={eventCategory:'Domain Selector',eventAction:'Footer',eventLabel:storefrontName,};$(document).trigger('psevent',['footerdomainchange',gaData]);window.location.href=$this.attr('href')});$(document).on('click','.j-navlogoutlink',function(e){var $this=$(this);e.preventDefault();var gaData={eventCategory:'Account',eventAction:'Click',eventLabel:'Sign out',};$(document).trigger('psevent',['accountlogout',gaData]);window.location.href=$this.attr('href')});$(document).on('click','.j-category-colourswatch',function(e){var $this=$(this);e.preventDefault();var gaData={eventCategory:'Category Page',eventAction:'Click',eventLabel:'Colour Swatch',};$(document).trigger('psevent',['categoryColorSwatch',gaData]);window.location.href=$this.attr('href')});$(document).on('click','j-gtm-category-add-to-cart',function(e){var gaData={eventCategory:'Category Page',eventAction:'Click',eventLabel:'Add to Cart Hover',};$(document).trigger('psevent',['categoryAddToCart',gaData])});$(document).on('click','.cart-slider .co-cart__item-update .co-size__dropdown li, .cart-slider .co-size__dropdown.s-dropdown.co-tab-mob option',function(e){var gaData={eventCategory:'Slide Cart',eventAction:'Size Change',eventLabel:'Click - Size Change',};$(document).trigger('psevent',['sliderCartChangeSize',gaData])});$(document).on('click','.cart-slider button.co-button--promocode',function(e){var gaData={eventCategory:'Slide Cart',eventAction:'Promo Code',eventLabel:'Click Apply Promo Code',};$(document).trigger('psevent',['sliderCartapplypromo',gaData])});$(document).on('click','.site-footer .s-social-nav__link',function(e){var $this=$(this);var socialPlatform='';var storeFront='';socialPlatform=$this.hasClass('j-facebook')?'Facebook':'';socialPlatform=$this.hasClass('j-instagram')?'Instagram':socialPlatform;storeFront=$this.hasClass('j-nos')?'Number One Shoes':'';storeFront=$this.hasClass('j-han')?'Hannahs':storeFront;var gaData={eventCategory:'Social Click',eventAction:'Click',eventLabel:socialPlatform+' : '+storeFront,};$(document).trigger('psevent',['socialFooterClick',gaData])});$(document).on('click','.ps-category-item .ps-category-promo__image, .ps-category-promo__cta',function(e){e.preventDefault();var $this=$(this);var eventLabelValue='';if($this.is('.ps-category-promo__cta')){eventLabelValue=$this.html()}else{eventLabelValue=$this.siblings('.ps-category-promo__description').children().html()}
var gaData={eventCategory:'Category Promo',eventAction:'Click',eventLabel:eventLabelValue,};$(document).trigger('psevent',['categoryPageCTA',gaData]);window.location.href=$this.attr('href')});$(document).on('click','nav.site-nav a',function(e){var $this=$(this);var pagetitle=$this.data('pagetitle');var maincategory=$this.data('maincategory');if($this.hasClass('j-domainchange-header')||(pagetitle==null&&maincategory==null)){return}
var gaData={eventCategory:'Navigation',eventAction:maincategory,eventLabel:pagetitle,};$(document).trigger('psevent',['mainNavigationClicks',gaData])})}(jQuery))