­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ !function($,undefined){"use strict";function USHeader(settings){this.$container=$('.l-header',$us.$canvas);this.$showBtn=$('.w-header-show:first',$us.$body);this.settings=settings||{};this.state='default';this.$elms={};if(this.$container.length===0){return} this.$places={hidden:$('.l-subheader.for_hidden',this.$container)};this._states={sticky:!1,sticky_auto_hide:!1,scroll_direction:'down',vertical_scrollable:!1,init_height:this.getHeight()};this.pos=this.$container.usMod('pos');this.bg=this.$container.usMod('bg');this.shadow=this.$container.usMod('shadow');this.orientation=$us.$body.usMod('header');this.tabletsBreakpoint=parseInt(settings.tablets&&settings.tablets.options&&settings.tablets.options.breakpoint)||900;this.mobilesBreakpoint=parseInt(settings.mobiles&&settings.mobiles.options&&settings.mobiles.options.breakpoint)||600;$('.l-subheader-cell',this.$container).each(function(_,place){var $place=$(place),key=$place.parent().parent().usMod('at')+'_'+$place.usMod('at');this.$places[key]=$place}.bind(this));$('[class*=ush_]',this.$container).each(function(_,elm){var $elm=$(elm),matches=/(^| )ush_([a-z_]+)_([0-9]+)(\s|$)/.exec(elm.className);if(!matches){return} var id=matches[2]+':'+matches[3];this.$elms[id]=$elm;if($elm.is('.w-vwrapper, .w-hwrapper')){this.$places[id]=$elm}}.bind(this));$us.$window.on('scroll',$us.debounce(this._events.scroll.bind(this),10)).on('resize load',$us.debounce(this._events.resize.bind(this),10));this.$container.on('contentChange',this._events.contentChange.bind(this));this.$showBtn.on('click',this._events.showBtn.bind(this));this.on('changeSticky',this._events._changeSticky.bind(this)).on('swichVerticalScrollable',this._events._swichVerticalScrollable.bind(this));this._events.resize.call(this);if(this.isStickyAutoHideEnabled()){this.$container.addClass('sticky_auto_hide')} this.$container.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd',function(){$us.debounce(this.trigger.bind(this,'transitionEnd'),1)()}.bind(this))} $.extend(USHeader.prototype,$us.mixins.Events,{prevScrollTop:0,currentStateIs:function(state){return(state&&['default','tablets','mobiles'].indexOf(state)!==-1&&this.state===state)},isVertical:function(){return this.orientation==='ver'},isHorizontal:function(){return this.orientation==='hor'},isFixed:function(){return this.pos==='fixed'},isTransparent:function(){return this.bg==='transparent'},_isWithinScrollBoundaries:function(scrollTop){scrollTop=parseInt(scrollTop);return(scrollTop+window.innerHeight>=$us.$document.height())||scrollTop<=0},isHidden:function(){return!!$us.header.settings.is_hidden},isStickyEnabled:function(){return this.settings[this.state].options.sticky||!1},isStickyAutoHideEnabled:function(){return this.isStickyEnabled()&&(this.settings[this.state].options.sticky_auto_hide||!1)},isSticky:function(){return this._states.sticky||!1},isStickyAutoHidden:function(){return this._states.sticky_auto_hide||!1},getScrollDirection:function(){return this._states.scroll_direction||'down'},getAdminBarHeight:function(){var $wpAdminBar=$('#wpadminbar',$us.$body);return $wpAdminBar.length?parseInt($wpAdminBar.height()):0},getHeight:function(){var height=0,beforeContent=getComputedStyle(this.$container.get(0),':before').content;if(beforeContent&&['none','auto'].indexOf(beforeContent)===-1){height=beforeContent.replace(/[^+\d]/g,'')} if(!height){height=this.$container.outerHeight()} return!isNaN(height)?parseInt(height):0},getInitHeight:function(){return parseInt(this._states.init_height)||this.getHeight()},getCurrentHeight:function(){var height=0,adminBarHeight=this.getAdminBarHeight();if(this.isHorizontal()&&(!this.currentStateIs('mobiles')||(adminBarHeight&&adminBarHeight>=this.getScrollTop()))){height+=adminBarHeight} if(!this.isStickyAutoHidden()){height+=this.getHeight()} return height},getScrollTop:function(){return parseInt($us.$window.scrollTop())||this.prevScrollTop},getOffsetTop:function(){var top=parseInt(this.$container.css('top'));return!isNaN(top)?top:0},isScrollAtTopPosition:function(){return parseInt($us.$window.scrollTop())===0},setState:function(state){if(this.currentStateIs(state)){return} var options=this.settings[state].options||{},orientation=options.orientation||'hor',pos=($us.toBool(options.sticky)?'fixed':'static'),bg=($us.toBool(options.transparent)?'transparent':'solid'),shadow=options.shadow||'thin';if(orientation==='ver'){pos='fixed';bg='solid'} this._setOrientation(orientation);this._setPos(pos);this._setBg(bg);this._setShadow(shadow);this._setLayout(this.settings[state].layout||{});$us.$body.usMod('state',this.state=state);if(this.currentStateIs('default')){$us.$body.removeClass('header-show')} if($us.nav!==undefined){$us.nav.resize()} if(this.isStickyAutoHideEnabled()){this.$container.removeClass('down')}},_setPos:function(pos){if(pos===this.pos){return} this.$container.usMod('pos',this.pos=pos);if(this.pos==='static'){this.trigger('changeSticky',!1)}},_setBg:function(bg){if(bg!=this.bg){this.$container.usMod('bg',this.bg=bg)}},_setShadow:function(shadow){if(shadow!=this.shadow){this.$container.usMod('shadow',this.shadow=shadow)}},_setLayout:function(layout){for(var place in layout){if(!layout[place]||!this.$places[place]){continue} this._placeElements(layout[place],this.$places[place])}},_setOrientation:function(orientation){if(orientation!=this.orientation){$us.$body.usMod('header',this.orientation=orientation)}},_placeElements:function(elms,$place){for(var i=0;icanvasHeight){this.trigger('swichVerticalScrollable',!0)}else if(this._states.vertical_scrollable){this.trigger('swichVerticalScrollable',!1)} if(headerHeight>documentHeight){this.$container.css({position:'absolute',top:0})}}else if(this._states.vertical_scrollable){this.trigger('swichVerticalScrollable',!1)}},_events:{_swichVerticalScrollable:function(_,state){this.$container.toggleClass('scrollable',this._states.vertical_scrollable=!!state);if(!this._states.vertical_scrollable){this.$container.resetInlineCSS('position','top','bottom');delete this._headerScrollRange}},_changeSticky:function(_,state){this._states.sticky=!!state;var currentHeight=this.getCurrentHeight();$us.debounce(function(){this.$container.toggleClass('sticky',this._states.sticky).resetInlineCSS('position','top','bottom');if(currentHeight==this.getCurrentHeight()){this.trigger('transitionEnd')}}.bind(this),10)()},contentChange:function(){this._isVerticalScrollable.call(this)},showBtn:function(e){if($us.$body.hasClass('header-show')){return} e.stopPropagation();$us.$body.addClass('header-show').on(($.isMobile?'touchstart':'click'),this._events.hideMobileVerticalHeader.bind(this))},hideMobileVerticalHeader:function(e){if($.contains(this.$container[0],e.target)){return} $us.$body.off(($.isMobile?'touchstart':'click'),this._events.hideMobileVerticalHeader.bind(this));$us.timeout(function(){$us.$body.removeClass('header-show')},10)},scroll:function(){var scrollTop=this.getScrollTop(),headerAbovePosition=($us.canvas.headerInitialPos==='above');if(this.prevScrollTop!=scrollTop){this._states.scroll_direction=(this.prevScrollTop<=scrollTop)?'down':'up'} this.prevScrollTop=scrollTop;if(this.isScrollAtTopPosition()){this._states.scroll_direction='up'} if(this.isStickyAutoHideEnabled()&&this.isSticky()&&!this._isWithinScrollBoundaries(scrollTop)&&!headerAbovePosition){this._states.sticky_auto_hide=(this.getScrollDirection()==='down');this.$container.toggleClass('down',this._states.sticky_auto_hide)} if(!this.isFixed()){return} var headerAttachedFirstSection=['bottom','below'].indexOf($us.canvas.headerInitialPos)!==-1;if(this.isHorizontal()&&(headerAbovePosition||(headerAttachedFirstSection&&!this.currentStateIs('default'))||!headerAttachedFirstSection)){if(this.isStickyEnabled()){var scrollBreakpoint=parseInt(this.settings[this.state].options.scroll_breakpoint)||100,isSticky=scrollTop>=scrollBreakpoint;if(isSticky!=this.isSticky()){this.trigger('changeSticky',isSticky)}} if(this.isSticky()){$us.debounce(function(){if(!$us.$window.scrollTop()){this.trigger('changeSticky',!1)}}.bind(this),1)()}} if(this.isHorizontal()&&headerAttachedFirstSection&&!headerAbovePosition&&this.currentStateIs('default')){var top=($us.canvas.getHeightFirstSection()+this.getAdminBarHeight());if($us.canvas.headerInitialPos=='bottom'){top-=this.getInitHeight()} if(this.isStickyEnabled()){var isSticky=scrollTop>=top;if(isSticky!=this.isSticky()){$us.debounce(function(){this.trigger('changeSticky',isSticky)}.bind(this),1)()}} if(!this.isSticky()&&top!=this.getOffsetTop()){this.$container.css('top',top)}} var headerHeight=this.getHeight(),documentHeight=parseInt($us.$document.height());if(this.isVertical()&&!headerAttachedFirstSection&&!headerAbovePosition&&!jQuery.isMobile&&this._states.vertical_scrollable&&documentHeight>headerHeight){var canvasHeight=parseInt($us.canvas.winHeight),scrollRangeDiff=(headerHeight-canvasHeight),cssProps;if(this._headerScrollRange===undefined){this._headerScrollRange=[0,scrollRangeDiff]} if(scrollTop<=this._headerScrollRange[0]){this._headerScrollRange[0]=Math.max(0,scrollTop);this._headerScrollRange[1]=(this._headerScrollRange[0]+scrollRangeDiff);cssProps={position:'fixed',top:this.getAdminBarHeight()}}else if(this._headerScrollRange[0]