0byt3m1n1
Path:
/
var
/
www
/
clients
/
client38
/
web37
/
web
/
wp-content
/
themes
/
Impreza
/
common
/
js
/
base
/
[
Home
]
File: header.min.js
!function($,undefined){"use strict";var _window=window;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={};this.canvasOffset=0;this.bodyHeight=$us.$body.height();this.adminBarHeight=0;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.breakpoints={laptops:1280,tablets:1024,mobiles:600};for(var k in this.breakpoints){this.breakpoints[k]=parseInt(((settings[k]||{}).options||{}).breakpoint)||this.breakpoints[k]} $('.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'].concat(Object.keys(this.breakpoints))).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=document.getElementById('wpadminbar');return wpAdminBar?wpAdminBar.offsetHeight: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;if(this.isHorizontal()&&(!this.currentStateIs('mobiles')||(this.adminBarHeight&&this.adminBarHeight>=this.getScrollTop()))){height+=this.adminBarHeight} if(!this.isStickyAutoHidden()){height+=this.getHeight()} return height},getScrollTop:function(){return Math.ceil($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')||this.currentStateIs('laptops')){$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;i<elms.length;i ++){var elmId;if(typeof elms[i]=='object'){elmId=elms[i][0];if(!this.$places[elmId]||!this.$elms[elmId]){continue} this.$elms[elmId].appendTo($place);this._placeElements(elms[i].shift(),this.$places[elmId])}else{elmId=elms[i];if(!this.$elms[elmId]){continue} this.$elms[elmId].appendTo($place)}}},_isVerticalScrollable:function(){if(!this.isVertical()){return} if((this.currentStateIs('default')||this.currentStateIs('laptops'))&&this.isFixed()){this.$container.addClass('scrollable');var headerHeight=this.getHeight(),canvasHeight=parseInt($us.canvas.winHeight),documentHeight=parseInt($us.$document.height());this.$container.removeClass('scrollable');if(headerHeight>canvasHeight){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('tablets')||this.currentStateIs('mobiles')))||!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')||this.currentStateIs('laptops'))){var top=($us.canvas.getHeightFirstSection()+this.adminBarHeight);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)}} if(this.isVertical()&&!headerAttachedFirstSection&&!headerAbovePosition&&this._states.vertical_scrollable){var headerHeight=this.getHeight(),documentHeight=parseInt($us.$document.height());if(documentHeight>headerHeight){var canvasHeight=parseInt($us.canvas.winHeight)+this.canvasOffset,scrollRangeDiff=(headerHeight-canvasHeight),cssProps;if(this._headerScrollRange===undefined){this._headerScrollRange=[0,scrollRangeDiff]} if(this.bodyHeight>headerHeight){if(scrollTop<this._headerScrollRange[0]){this._headerScrollRange[0]=Math.max(0,scrollTop);this._headerScrollRange[1]=(this._headerScrollRange[0]+scrollRangeDiff);cssProps={position:'fixed',top:this.adminBarHeight}}else if(this._headerScrollRange[0]<scrollTop&&scrollTop<this._headerScrollRange[1]){cssProps={position:'absolute',top:this._headerScrollRange[0]}}else if(this._headerScrollRange[1]<=scrollTop){this._headerScrollRange[1]=Math.min(documentHeight-canvasHeight,scrollTop);this._headerScrollRange[0]=(this._headerScrollRange[1]-scrollRangeDiff);cssProps={position:'fixed',top:(canvasHeight-headerHeight)}}}else{cssProps={position:'absolute',top:this.adminBarHeight,}} if(cssProps){this.$container.css(cssProps)}}}},resize:function(){var newState='default';for(var state in this.breakpoints){if(_window.innerWidth<=this.breakpoints[state]){newState=state}else{break}} this.setState(newState||'default');this.canvasOffset=$us.$window.outerHeight()-$us.$window.innerHeight();this.bodyHeight=$us.$body.height();this.adminBarHeight=this.getAdminBarHeight();if(this.isFixed()&&this.isHorizontal()){this.$container.addClass('notransition');$us.timeout(function(){this.$container.removeClass('notransition')}.bind(this),50)} this._isVerticalScrollable.call(this);this._events.scroll.call(this)}}});$us.header=new USHeader($us.headerSettings||{})}(window.jQuery)