;window.dzsprx_self_options={};(function($){$.fn.dzsparallaxer=function(o){var defaults={settings_mode:'scroll',mode_scroll:'normal',easing:'easeIn',animation_duration:'20',direction:'normal',js_breakout:'off',breakout_fix:'off',is_fullscreen:'off',settings_movexaftermouse:"off",init_delay:"0",init_functional_delay:"0",settings_substract_from_th:0,settings_detect_out_of_screen:true,init_functional_remove_delay_on_scroll:"off",settings_makeFunctional:false,settings_scrollTop_is_another_element_top:null,settings_clip_height_is_window_height:false,settings_listen_to_object_scroll_top:null,settings_mode_oneelement_max_offset:'20',simple_parallaxer_convert_simple_img_to_bg_if_possible:"on"}
if(typeof o=='undefined'){if(typeof $(this).attr('data-options')!='undefined'&&$(this).attr('data-options')!=''){var aux=$(this).attr('data-options');aux='window.dzsprx_self_options = '+aux;eval(aux);o=$.extend({},window.dzsprx_self_options);window.dzsprx_self_options=$.extend({},{});}}o=$.extend(defaults,o);Math.easeIn=function(t,b,c,d){return-c*(t/=d)*(t-2)+b;};Math.easeOutQuad=function(t,b,c,d){t/=d;return-c*t*(t-2)+b;};Math.easeInOutSine=function(t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;};o.settings_mode_oneelement_max_offset=parseInt(o.settings_mode_oneelement_max_offset,10);var simple_parallaxer_max_offset=parseInt(o.settings_mode_oneelement_max_offset,10);this.each(function(){var cthis=$(this);var _theTarget=null,_blackOverlay=null,_fadeouttarget=null;var nritems=0,tobeloaded=0;var i=0;var tw=0,th=0,ch=0,cw=0,ww=0,wh=0,last_wh=0,last_cthis_ot=0,initialheight=0;var int_calculate_dims=0;var duration_viy=0;var target_viy=0,target_vix=0,target_bo=0;var begin_viy=0,begin_vix=0,begin_bo=0;var finish_viy=0,finish_vix=0,finish_bo=0;var change_viy=0,change_vix=0,change_bo=0;var backup_duration_viy=0
var api_outer_update_func=null,_scrollTop_is_another_element_top=null;var st=0,vi_y=0,bo_o=0,cthis_ot=0;var lazyloading_setsource='';var started=false,debug_var=false;var animator_objects_arr=null;var stop_enter_frame=false,sw_suspend_functional=false,sw_stop_enter_frame=false,sw_out_of_display=false;var init_delay=0,init_functional_delay=0;var inter_debug_func=0,inter_suspend_enter_frame=0,inter_scroll_from_resize=0,inter_recheck_dims=0;var responsive_reference_width=0,responsive_optimal_height=0;init_delay=Number(o.init_delay);init_functional_delay=Number(o.init_functional_delay);if(init_delay){setTimeout(init,init_delay);}else{init();}function init(){if(o.settings_makeFunctional==true){var allowed=false;var url=document.URL;var urlStart=url.indexOf("://")+3;var urlEnd=url.indexOf("/",urlStart);var domain=url.substring(urlStart,urlEnd);if(domain.indexOf('l')>-1&&domain.indexOf('c')>-1&&domain.indexOf('o')>-1&&domain.indexOf('l')>-1&&domain.indexOf('a')>-1&&domain.indexOf('h')>-1){allowed=true;}if(domain.indexOf('d')>-1&&domain.indexOf('i')>-1&&domain.indexOf('g')>-1&&domain.indexOf('d')>-1&&domain.indexOf('z')>-1&&domain.indexOf('s')>-1){allowed=true;}if(domain.indexOf('o')>-1&&domain.indexOf('z')>-1&&domain.indexOf('e')>-1&&domain.indexOf('h')>-1&&domain.indexOf('t')>-1){allowed=true;}if(domain.indexOf('e')>-1&&domain.indexOf('v')>-1&&domain.indexOf('n')>-1&&domain.indexOf('a')>-1&&domain.indexOf('t')>-1){allowed=true;}if(allowed==false){return;}}if(o.settings_scrollTop_is_another_element_top){_scrollTop_is_another_element_top=o.settings_scrollTop_is_another_element_top;}_theTarget=cthis.find('.dzsparallaxer--target').eq(0);if(cthis.find('.dzsparallaxer--blackoverlay').length>0){_blackOverlay=cthis.find('.dzsparallaxer--blackoverlay').eq(0);}if(cthis.find('.dzsparallaxer--fadeouttarget').length>0){_fadeouttarget=cthis.find('.dzsparallaxer--fadeouttarget').eq(0);}if(!cthis.hasClass('wait-readyall')){setTimeout(function(){duration_viy=Number(o.animation_duration);},300);}cthis.addClass('mode-'+o.settings_mode);ch=cthis.height();if(o.settings_movexaftermouse=='on'){cw=cthis.width();}if(_theTarget){th=_theTarget.height();if(o.settings_movexaftermouse=='on'){tw=_theTarget.width();}}if(o.settings_substract_from_th){th-=o.settings_substract_from_th;}initialheight=ch;if(o.breakout_fix=='2'){console.info(cthis.prev());}if(cthis.attr('data-responsive-reference-width')){responsive_reference_width=Number(cthis.attr('data-responsive-reference-width'));}if(cthis.attr('data-responsive-optimal-height')){responsive_optimal_height=Number(cthis.attr('data-responsive-optimal-height'));}if(cthis.find('.dzsprxseparator--bigcurvedline').length>0){cthis.find('.dzsprxseparator--bigcurvedline').append('');}if(cthis.find('.dzsprxseparator--2triangles').length>0){cthis.find('.dzsprxseparator--2triangles').append('');}if(cthis.find('.dzsprxseparator--triangle').length>0){cthis.find('.dzsprxseparator--triangle').append('');}if(cthis.get(0)){cthis.get(0).api_set_scrollTop_is_another_element_top=function(arg){_scrollTop_is_another_element_top=arg;}}if(is_touch_device()){cthis.addClass('is-touch');}if(is_mobile()){cthis.addClass('is-mobile');}if(cthis.find('.divimage').length>0||cthis.find('img').length>0){var _loadTarget=cthis.children('.divimage, img').eq(0);if(_loadTarget.attr('data-src')){lazyloading_setsource=_loadTarget.attr('data-src');$(window).on('scroll',handle_scroll);handle_scroll();}else{init_start();}}else{init_start();}}function init_start(){if(started){return;}started=true;if(is_ie11()){cthis.addClass('is-ie-11');}$(window).bind('resize',handle_resize);handle_resize();inter_recheck_dims=setInterval(function(){handle_resize(null,{'call_from':'autocheck'})},2000);if(cthis.hasClass('wait-readyall')){setTimeout(function(){handle_scroll();},700);}setTimeout(function(){cthis.addClass('dzsprx-readyall');handle_scroll();if(cthis.hasClass('wait-readyall')){duration_viy=Number(o.animation_duration);}},1000);if(cthis.find('*[data-parallaxanimation]').length>0){cthis.find('*[data-parallaxanimation]').each(function(){var _t=$(this);if(_t.attr('data-parallaxanimation')){if(animator_objects_arr==null){animator_objects_arr=[];}animator_objects_arr.push(_t);var aux=_t.attr('data-parallaxanimation');aux='window.aux_opts2 = '+aux;aux=aux.replace(/'/g,'"')
try{eval(aux);}catch(err){console.info(aux,err);window.aux_opts2=null;}if(window.aux_opts2){for(i=0;i');console.info()
if(o.simple_parallaxer_convert_simple_img_to_bg_if_possible=='on'&&_theTarget.attr('data-src')&&_theTarget.children().length==0){_theTarget.parent().addClass('is-image');}if(simple_parallaxer_max_offset>0){handle_frame();}}inter_debug_func=setInterval(debug_func,1000);setTimeout(function(){},1500);if(cthis.hasClass('use-loading')){if(cthis.find('.divimage').length>0||cthis.children('img').length>0){if(cthis.find('.divimage').length>0){if(lazyloading_setsource){cthis.find('.divimage').eq(0).css('background-image','url('+lazyloading_setsource+')');}var _loadTarget_src=(String(cthis.find('.divimage').eq(0).css('background-image')).split('"'))[1];if(_loadTarget_src==undefined){_loadTarget_src=(String(cthis.find('.divimage').eq(0).css('background-image')).split('url('))[1];_loadTarget_src=(String(_loadTarget_src).split(')'))[0];}var _loadTarget=new Image();_loadTarget.onload=function(e){cthis.addClass('loaded');};_loadTarget.src=_loadTarget_src;}}else{cthis.addClass('loaded');}setTimeout(function(){cthis.addClass('loaded');calculate_dims();},10000)}cthis.get(0).api_set_update_func=function(arg){api_outer_update_func=arg;}
cthis.get(0).api_handle_scroll=handle_scroll;cthis.get(0).api_destroy=destroy;cthis.get(0).api_destroy_listeners=destroy_listeners;if(o.settings_mode=='scroll'||o.settings_mode=='oneelement'){$(window).off('scroll',handle_scroll);$(window).on('scroll',handle_scroll);handle_scroll();setTimeout(handle_scroll,1000);if(document&&document.addEventListener){document.addEventListener("touchmove",handle_mousemove,false);}}if(o.settings_mode=='mouse_body'||o.settings_movexaftermouse=='on'){$(document).bind('mousemove',handle_mousemove);}}function destroy(){api_outer_update_func=null;stop_enter_frame=true;api_outer_update_func=null;$(window).off('scroll',handle_scroll);if(document&&document.addEventListener){document.removeEventListener("touchmove",handle_mousemove,false);}}function debug_func(){debug_var=true;}function destroy_listeners(){clearInterval(inter_debug_func);clearInterval(inter_recheck_dims);sw_stop_enter_frame=true;}function handle_resize(e,pargs){cw=cthis.width();ww=window.innerWidth;wh=window.innerHeight;var margs={'call_from':'event'};if(pargs){margs=$.extend(margs,pargs);}if(started===false){return;}if(o.settings_mode=='oneelement'){var last_translate=cthis.css('transform');cthis.css('transform','translate3d(0,0,0)');}cthis_ot=parseInt(cthis.offset().top,10);if(margs.call_from=='autocheck'){if(Math.abs(last_wh-wh)<4&&Math.abs(last_cthis_ot-cthis_ot)<4){if(o.settings_mode=='oneelement'){cthis.css('transform',last_translate);}return false;}}last_wh=wh;last_cthis_ot=cthis_ot;if(responsive_reference_width&&responsive_optimal_height){if(cw0){cthis.css('margin-left','-'+cthis.offset().left+'px');}}if(o.is_fullscreen=='on'){}}function calculate_dims(){ch=cthis.outerHeight();th=_theTarget.outerHeight();wh=window.innerHeight;if(o.settings_substract_from_th){th-=o.settings_substract_from_th;}if(o.settings_clip_height_is_window_height){ch=window.innerHeight;}if(cthis.hasClass('allbody')==false&&cthis.hasClass('dzsparallaxer---window-height')==false&&responsive_reference_width==0){if(th<=initialheight&&th>0){if(o.settings_mode!='oneelement'&&cthis.hasClass('do-not-set-js-height')==false&&cthis.hasClass('height-is-based-on-content')==false){cthis.height(th);}ch=cthis.height();if(is_ie()&&version_ie()<=10){_theTarget.css('top','0');}else{_theTarget.css('transform','translate3d(0,'+0+'px,0)');}if(_blackOverlay){_blackOverlay.css('opacity','0');}}else{if(o.settings_mode!='oneelement'&&cthis.hasClass('do-not-set-js-height')==false&&cthis.hasClass('height-is-based-on-content')==false){cthis.height(initialheight);}}}if(_theTarget.attr('data-forcewidth_ratio')){_theTarget.width(Number(_theTarget.attr('data-forcewidth_ratio'))*_theTarget.height());if(_theTarget.width()0){vi_y=0};if(vi_y1){bo_o=1};if(bo_o<0){bo_o=0};finish_viy=vi_y;}if(o.settings_movexaftermouse=='on'){var mx=e.pageX;var vi_x=0;vi_x=(mx/ww)*(cw-tw);if(vi_x>0){vi_x=0};if(vi_xst-wh&&st=cthis.offset().top){init_start();}}if(th==0){return;}if(started===false||(o.settings_mode!='scroll'&&o.settings_mode!='oneelement')){return;}if(o.settings_mode=='oneelement'){var aux_r=(st-cthis_ot+wh)/wh;if(cthis.attr('id')=='debug'){}if(aux_r<0){aux_r=0;}if(aux_r>1){aux_r=1;}if(o.direction=='reverse'){aux_r=Math.abs(1-aux_r);}vi_y=(aux_r*(o.settings_mode_oneelement_max_offset*2))-o.settings_mode_oneelement_max_offset;finish_viy=vi_y;if(cthis.attr('id')=='debug'){}}if(o.settings_mode=='scroll'){if(o.mode_scroll=='fromtop'){vi_y=((st/ch))*(ch-th);if(o.is_fullscreen=='on'){vi_y=st/($('body').height()-wh)*(ch-th);if(_scrollTop_is_another_element_top){vi_y=st/(_scrollTop_is_another_element_top.height()-wh)*(ch-th);}}if(o.direction=='reverse'){vi_y=(1-(st/ch))*(ch-th);if(o.is_fullscreen=='on'){vi_y=(1-(st/($('body').height()-wh)))*(ch-th);if(_scrollTop_is_another_element_top){vi_y=(1-(st/(_scrollTop_is_another_element_top.height()-wh)))*(ch-th);}}}}cthis_ot=cthis.offset().top;if(_scrollTop_is_another_element_top){cthis_ot=-parseInt(_scrollTop_is_another_element_top.css('top'),10);}var auxer5=(st-(cthis_ot-wh))/((cthis_ot+ch)-(cthis_ot-wh));if(o.is_fullscreen=='on'){auxer5=st/($('body').height()-wh);if(_scrollTop_is_another_element_top){auxer5=st/(_scrollTop_is_another_element_top.outerHeight()-wh);}}if(auxer5>1){auxer5=1;}if(auxer5<0){auxer5=0;}if(animator_objects_arr){for(i=0;i1){aux_r=1;}aux_r=Math.abs(1-aux_r);if(cthis.hasClass('is-mobile')){simple_parallaxer_max_offset=cthis.height()/2;}vi_y=(aux_r*(simple_parallaxer_max_offset*2))-simple_parallaxer_max_offset;}if(_fadeouttarget){var auxer4=Math.abs(((st-cthis_ot)/cthis.outerHeight())-1);if(auxer4>1){auxer4=1;}if(auxer4<0){auxer4=0;}_fadeouttarget.css('opacity',auxer4);}bo_o=st/ch;if(cthis.hasClass('simple-parallax')==false){if(vi_y>0){vi_y=0};if(vi_y1){bo_o=1};if(bo_o<0){bo_o=0};if(margs.force_vi_y){vi_y=margs.force_vi_y;}finish_viy=vi_y;finish_bo=bo_o;if(duration_viy===0){target_viy=finish_viy;if(sw_suspend_functional==false||0){if(cthis.hasClass('simple-parallax')){if(_theTarget.parent().hasClass('is-image')||cthis.hasClass('simple-parallax--is-only-image')){_theTarget.css('background-position-y','calc(50% - '+parseInt(target_viy,10)+'px)')}}else{if(is_ie()&&version_ie()<=10){_theTarget.css('top',''+target_viy+'px');}else{_theTarget.css('transform','translate3d('+target_vix+'px,'+target_viy+'px,0)');if(o.settings_mode=='oneelement'){cthis.css('transform','translate3d('+target_vix+'px,'+target_viy+'px,0)');}}}}}}var time=0;}function switch_suspend_enter_frame(){sw_suspend_functional=true;}function handle_frame(){if(sw_suspend_functional){requestAnimFrame(handle_frame);return false;}if(isNaN(target_viy)){target_viy=0;}if(debug_var){debug_var=false;}if(duration_viy===0){if(api_outer_update_func){api_outer_update_func(target_viy);}requestAnimFrame(handle_frame);return false;}begin_viy=target_viy;change_viy=finish_viy-begin_viy;begin_bo=target_bo;change_bo=finish_bo-begin_bo;if(o.easing=='easeIn'){target_viy=Number(Math.easeIn(1,begin_viy,change_viy,duration_viy).toFixed(5));target_bo=Number(Math.easeIn(1,begin_bo,change_bo,duration_viy).toFixed(5));}if(o.easing=='easeOutQuad'){target_viy=Math.easeOutQuad(1,begin_viy,change_viy,duration_viy);target_bo=Math.easeOutQuad(1,begin_bo,change_bo,duration_viy);}if(o.easing=='easeInOutSine'){target_viy=Math.easeInOutSine(1,begin_viy,change_viy,duration_viy);target_bo=Math.easeInOutSine(1,begin_bo,change_bo,duration_viy);}target_vix=0;if(o.settings_movexaftermouse=='on'){begin_vix=target_vix;change_vix=finish_vix-begin_vix;target_vix=Math.easeIn(1,begin_vix,change_vix,duration_viy);}if(cthis.hasClass('simple-parallax')){if(_theTarget.parent().hasClass('is-image')){_theTarget.css('background-position-y','calc(50% - '+parseInt(target_viy,10)+'px)')}}else{if(is_ie()&&version_ie()<=10){_theTarget.css('top',''+target_viy+'px');}else{_theTarget.css('transform','translate3d('+target_vix+'px,'+target_viy+'px,0)');if(o.settings_mode=='oneelement'){cthis.css('transform','translate3d('+target_vix+'px,'+target_viy+'px,0)');}}}if(_blackOverlay){_blackOverlay.css('opacity',target_bo);}if(api_outer_update_func){api_outer_update_func(target_viy);}if(stop_enter_frame){return false;}requestAnimFrame(handle_frame);}})}
window.dzsprx_init=function(selector,settings){if(typeof(settings)!="undefined"&&typeof(settings.init_each)!="undefined"&&settings.init_each==true){var element_count=0;for(var e in settings){element_count++;}if(element_count==1){settings=undefined;}$(selector).each(function(){var _t=$(this);_t.dzsparallaxer(settings)});}else{$(selector).dzsparallaxer(settings);}};})(jQuery);function is_mobile(){var userAgent=navigator.userAgent||navigator.vendor||window.opera;if(/windows phone/i.test(userAgent)){return true;}if(/android/i.test(userAgent)){return true;}if(/iPad|iPhone|iPod/.test(userAgent)&&!window.MSStream){return true;}return false;}function is_touch_device(){return!!('ontouchstart'in window);}window.requestAnimFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(callback){window.setTimeout(callback,1000/60);};})();function is_ie(){var ua=window.navigator.userAgent;var msie=ua.indexOf('MSIE ');if(msie>0){return parseInt(ua.substring(msie+5,ua.indexOf('.',msie)),10);}var trident=ua.indexOf('Trident/');if(trident>0){var rv=ua.indexOf('rv:');return parseInt(ua.substring(rv+3,ua.indexOf('.',rv)),10);}var edge=ua.indexOf('Edge/');if(edge>0){return parseInt(ua.substring(edge+5,ua.indexOf('.',edge)),10);}return false;};function is_ie11(){return!(window.ActiveXObject)&&"ActiveXObject"in window;}function version_ie(){return parseFloat(navigator.appVersion.split("MSIE")[1]);};jQuery(document).ready(function($){$('.dzsparallaxer---window-height').each(function(){var _t=$(this);$(window).on('resize',handle_resize);handle_resize();function handle_resize(){var wh=window.innerHeight;_t.height(wh);}})
dzsprx_init('.dzsparallaxer.auto-init',{init_each:true});});
;/**
* HSCore -
*
* @author HtmlStream
* @version 1.0
*/
;
(function ($) {
'use strict';
$.HSCore = {
/**
*
*
* @param
*
* @return
*/
init: function () {
$(document).ready(function (e) {
// Botostrap Tootltips
$('[data-toggle="tooltip"]').tooltip();
// Set Background Image Dynamically
if ($('[data-bg-img-src]').length) $.HSCore.helpers.bgImage($('[data-bg-img-src]'));
// Extends jQuery
$.HSCore.helpers.extendjQuery();
// Detect Internet Explorer (IE)
$.HSCore.helpers.detectIE();
// Bootstrap Navigation Options
$.HSCore.helpers.bootstrapNavOptions.init();
});
$(window).on('load', function (e) {
});
},
/**
*
*
* @var
*/
components: {},
/**
*
*
* @var
*/
helpers: {
Math: {
getRandomValueFromRange: function(startPoint, endPoint, fixed) {
var fixedInner = fixed ? fixed : false;
Math.random();
return fixedInner ? (Math.random() * (endPoint - startPoint) + startPoint) : (Math.floor(Math.random() * (endPoint - startPoint + 1)) + startPoint);
}
},
/**
* Sets background-image dynamically.
*
* @param jQuery collection
*
* @return jQuery|undefined
*/
bgImage: function (collection) {
if (!collection || !collection.length) return;
return collection.each(function (i, el) {
var $el = $(el),
bgImageSrc = $el.data('bg-img-src');
if (bgImageSrc) $el.css('background-image', 'url(' + bgImageSrc + ')');
});
},
/**
* Extends basic jQuery functionality
*
* @return undefined
*/
extendjQuery: function () {
$.fn.extend({
/**
* Runs specified function after loading of all images.
*
* @return Deferred
*/
imagesLoaded: function () {
var $imgs = this.find('img[src!=""]');
if (!$imgs.length) {
return $.Deferred().resolve().promise();
}
var dfds = [];
$imgs.each(function () {
var dfd = $.Deferred();
dfds.push(dfd);
var img = new Image();
img.onload = function () {
dfd.resolve();
};
img.onerror = function () {
dfd.resolve();
};
img.src = this.src;
});
return $.when.apply($, dfds);
}
});
},
/**
* Detect Internet Explorer (IE)
*
* @return version of IE or false, if browser is not Internet Explorer
*/
detectIE: function() {
var ua = window.navigator.userAgent;
var trident = ua.indexOf('Trident/');
if (trident > 0) {
// IE 11 => return version number
var rv = ua.indexOf('rv:');
var ieV = parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
document.querySelector('body').className += ' IE';
}
var edge = ua.indexOf('Edge/');
if (edge > 0) {
// IE 12 (aka Edge) => return version number
var ieV = parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
document.querySelector('body').className += ' IE';
}
// other browser
return false;
},
/**
* Bootstrap navigation options
*
*/
bootstrapNavOptions: {
init: function () {
this.mobileHideOnScroll();
},
mobileHideOnScroll: function () {
var $collection = $('.navbar');
if (!$collection.length) return;
var $w = $(window),
breakpointsMap = {
'sm': 576,
'md': 768,
'lg': 992,
'xl': 1200
};
$('body').on('click.HSMobileHideOnScroll', '.navbar-toggler', function (e) {
var $navbar = $(this).closest('.navbar');
if ($navbar.length) {
$navbar.data('mobile-menu-scroll-position', $w.scrollTop());
}
e.preventDefault();
});
$w.on('scroll.HSMobileHideOnScroll', function (e) {
$collection.each(function (i, el) {
var $this = $(el), $toggler, $nav, offset, $hamburgers, breakpoint;
if ($this.hasClass('navbar-toggleable-xl')) breakpoint = breakpointsMap['xl'];
else if ($this.hasClass('navbar-toggleable-lg')) breakpoint = breakpointsMap['lg'];
else if ($this.hasClass('navbar-toggleable-md')) breakpoint = breakpointsMap['md'];
else if ($this.hasClass('navbar-toggleable-xs')) breakpoint = breakpointsMap['xs'];
if ($w.width() > breakpoint) return;
$toggler = $this.find('.navbar-toggler');
$nav = $this.find('.navbar-collapse');
if (!$nav.data('mobile-scroll-hide')) return;
if ($nav.length) {
offset = $this.data('mobile-menu-scroll-position');
if (Math.abs($w.scrollTop() - offset) > 40 && $nav.hasClass('show')) {
$toggler.trigger('click');
$hamburgers = $toggler.find('.is-active');
if ($hamburgers.length) {
$hamburgers.removeClass('is-active');
}
}
}
});
});
}
}
},
/**
*
*
* @var
*/
settings: {
rtl: false
}
};
$.HSCore.init();
})(jQuery);
;/**
* Header Component.
*
* @author Htmlstream
* @version 1.0
*
*/
;(function ($) {
'use strict';
$.HSCore.components.HSHeader = {
/**
* Base configuration.
*
* @var Object _baseConfig
*/
_baseConfig: {
headerFixMoment: 0,
headerFixEffect: 'slide',
breakpointsMap: {
'md': 768,
'sm': 576,
'lg': 992,
'xl': 1200
}
},
/**
* Initializtion of header.
*
* @param jQuery element
*
* @return jQuery
*/
init: function( element ) {
if( !element || element.length !== 1 || element.data('HSHeader')) return;
var self = this;
this.element = element;
this.config = $.extend(true, {}, this._baseConfig, element.data());
this.observers = this._detectObservers();
this.fixMediaDifference( this.element );
this.element.data('HSHeader', new HSHeader(this.element, this.config, this.observers ) );
$(window)
.on('scroll.uHeader', function(e){
element
.data('HSHeader')
.notify();
})
.on('resize.uHeader', function(e){
if( self.resizeTimeOutId ) clearTimeout( self.resizeTimeOutId );
self.resizeTimeOutId = setTimeout( function(){
element
.data('HSHeader')
.checkViewport()
.update();
}, 100 );
})
.trigger('scroll.uHeader');
return this.element;
},
/**
*
*
* @param
*
* @return
*/
_detectObservers: function() {
if(!this.element || !this.element.length) return;
var observers = {
'xs': [],
'sm': [],
'md': [],
'lg': [],
'xl': []
};
/* ------------------------ xs -------------------------*/
// Has Hidden Element
if( this.element.hasClass('u-header--has-hidden-element') ) {
observers['xs'].push(
new HSHeaderHasHiddenElement( this.element )
);
}
// Sticky top
if( this.element.hasClass('u-header--sticky-top') ) {
if( this.element.hasClass('u-header--show-hide') ) {
observers['xs'].push(
new HSHeaderMomentShowHideObserver( this.element )
);
}
else if( this.element.hasClass('u-header--toggle-section') ) {
observers['xs'].push(
new HSHeaderHideSectionObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo') ) {
observers['xs'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance') ) {
observers['xs'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Floating
if( this.element.hasClass('u-header--floating') ) {
observers['xs'].push(
new HSHeaderFloatingObserver( this.element )
);
}
if( this.element.hasClass('u-header--invulnerable') ) {
observers['xs'].push(
new HSHeaderWithoutBehaviorObserver( this.element )
);
}
// Sticky bottom
if( this.element.hasClass('u-header--sticky-bottom') ) {
if(this.element.hasClass('u-header--change-appearance')) {
observers['xs'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo') ) {
observers['xs'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
}
// Abs top & Static
if( this.element.hasClass('u-header--abs-top') || this.element.hasClass('u-header--static')) {
if( this.element.hasClass('u-header--show-hide') ) {
observers['xs'].push(
new HSHeaderShowHideObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo') ) {
observers['xs'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance') ) {
observers['xs'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Abs bottom & Abs top 2nd screen
if( this.element.hasClass('u-header--abs-bottom') || this.element.hasClass('u-header--abs-top-2nd-screen') ) {
observers['xs'].push(
new HSHeaderStickObserver( this.element )
);
if( this.element.hasClass('u-header--change-appearance') ) {
observers['xs'].push(
new HSHeaderChangeAppearanceObserver( this.element, {
fixPointSelf: true
} )
);
}
if( this.element.hasClass('u-header--change-logo') ) {
observers['xs'].push(
new HSHeaderChangeLogoObserver( this.element, {
fixPointSelf: true
} )
);
}
}
/* ------------------------ sm -------------------------*/
// Sticky top
// Has Hidden Element
if( this.element.hasClass('u-header--has-hidden-element--sm') ) {
observers['sm'].push(
new HSHeaderHasHiddenElement( this.element )
);
}
if( this.element.hasClass('u-header--sticky-top--sm') ) {
if( this.element.hasClass('u-header--show-hide--sm') ) {
observers['sm'].push(
new HSHeaderMomentShowHideObserver( this.element )
);
}
else if( this.element.hasClass('u-header--toggle-section--sm') ) {
observers['sm'].push(
new HSHeaderHideSectionObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--sm') ) {
observers['sm'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance--sm') ) {
observers['sm'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Floating
if( this.element.hasClass('u-header--floating--sm') ) {
observers['sm'].push(
new HSHeaderFloatingObserver( this.element )
);
}
if( this.element.hasClass('u-header--invulnerable--sm') ) {
observers['sm'].push(
new HSHeaderWithoutBehaviorObserver( this.element )
);
}
// Sticky bottom
if( this.element.hasClass('u-header--sticky-bottom--sm') ) {
if(this.element.hasClass('u-header--change-appearance--sm')) {
observers['sm'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--sm') ) {
observers['sm'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
}
// Abs top & Static
if( this.element.hasClass('u-header--abs-top--sm') || this.element.hasClass('u-header--static--sm')) {
if( this.element.hasClass('u-header--show-hide--sm') ) {
observers['sm'].push(
new HSHeaderShowHideObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--sm') ) {
observers['sm'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance--sm') ) {
observers['sm'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Abs bottom & Abs top 2nd screen
if( this.element.hasClass('u-header--abs-bottom--sm') || this.element.hasClass('u-header--abs-top-2nd-screen--sm') ) {
observers['sm'].push(
new HSHeaderStickObserver( this.element )
);
if( this.element.hasClass('u-header--change-appearance--sm') ) {
observers['sm'].push(
new HSHeaderChangeAppearanceObserver( this.element, {
fixPointSelf: true
} )
);
}
if( this.element.hasClass('u-header--change-logo--sm') ) {
observers['sm'].push(
new HSHeaderChangeLogoObserver( this.element, {
fixPointSelf: true
} )
);
}
}
/* ------------------------ md -------------------------*/
// Has Hidden Element
if( this.element.hasClass('u-header--has-hidden-element--md') ) {
observers['md'].push(
new HSHeaderHasHiddenElement( this.element )
);
}
// Sticky top
if( this.element.hasClass('u-header--sticky-top--md') ) {
if( this.element.hasClass('u-header--show-hide--md') ) {
observers['md'].push(
new HSHeaderMomentShowHideObserver( this.element )
);
}
else if( this.element.hasClass('u-header--toggle-section--md') ) {
observers['md'].push(
new HSHeaderHideSectionObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--md') ) {
observers['md'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance--md') ) {
observers['md'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Floating
if( this.element.hasClass('u-header--floating--md') ) {
observers['md'].push(
new HSHeaderFloatingObserver( this.element )
);
}
if( this.element.hasClass('u-header--invulnerable--md') ) {
observers['md'].push(
new HSHeaderWithoutBehaviorObserver( this.element )
);
}
// Sticky bottom
if( this.element.hasClass('u-header--sticky-bottom--md') ) {
if(this.element.hasClass('u-header--change-appearance--md')) {
observers['md'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--md') ) {
observers['md'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
}
// Abs top & Static
if( this.element.hasClass('u-header--abs-top--md') || this.element.hasClass('u-header--static--md')) {
if( this.element.hasClass('u-header--show-hide--md') ) {
observers['md'].push(
new HSHeaderShowHideObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--md') ) {
observers['md'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance--md') ) {
observers['md'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Abs bottom & Abs top 2nd screen
if( this.element.hasClass('u-header--abs-bottom--md') || this.element.hasClass('u-header--abs-top-2nd-screen--md') ) {
observers['md'].push(
new HSHeaderStickObserver( this.element )
);
if( this.element.hasClass('u-header--change-appearance--md') ) {
observers['md'].push(
new HSHeaderChangeAppearanceObserver( this.element, {
fixPointSelf: true
} )
);
}
if( this.element.hasClass('u-header--change-logo--md') ) {
observers['md'].push(
new HSHeaderChangeLogoObserver( this.element, {
fixPointSelf: true
} )
);
}
}
/* ------------------------ lg -------------------------*/
// Has Hidden Element
if( this.element.hasClass('u-header--has-hidden-element--lg') ) {
observers['lg'].push(
new HSHeaderHasHiddenElement( this.element )
);
}
// Sticky top
if( this.element.hasClass('u-header--sticky-top--lg') ) {
if( this.element.hasClass('u-header--show-hide--lg') ) {
observers['lg'].push(
new HSHeaderMomentShowHideObserver( this.element )
);
}
else if( this.element.hasClass('u-header--toggle-section--lg') ) {
observers['lg'].push(
new HSHeaderHideSectionObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--lg') ) {
observers['lg'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance--lg') ) {
observers['lg'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Floating
if( this.element.hasClass('u-header--floating--lg') ) {
observers['lg'].push(
new HSHeaderFloatingObserver( this.element )
);
}
if( this.element.hasClass('u-header--invulnerable--lg') ) {
observers['lg'].push(
new HSHeaderWithoutBehaviorObserver( this.element )
);
}
// Sticky bottom
if( this.element.hasClass('u-header--sticky-bottom--lg') ) {
if(this.element.hasClass('u-header--change-appearance--lg')) {
observers['lg'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--lg') ) {
observers['lg'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
}
// Abs top & Static
if( this.element.hasClass('u-header--abs-top--lg') || this.element.hasClass('u-header--static--lg')) {
if( this.element.hasClass('u-header--show-hide--lg') ) {
observers['lg'].push(
new HSHeaderShowHideObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--lg') ) {
observers['lg'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance--lg') ) {
observers['lg'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Abs bottom & Abs top 2nd screen
if( this.element.hasClass('u-header--abs-bottom--lg') || this.element.hasClass('u-header--abs-top-2nd-screen--lg') ) {
observers['lg'].push(
new HSHeaderStickObserver( this.element )
);
if( this.element.hasClass('u-header--change-appearance--lg') ) {
observers['lg'].push(
new HSHeaderChangeAppearanceObserver( this.element, {
fixPointSelf: true
} )
);
}
if( this.element.hasClass('u-header--change-logo--lg') ) {
observers['lg'].push(
new HSHeaderChangeLogoObserver( this.element, {
fixPointSelf: true
} )
);
}
}
/* ------------------------ xl -------------------------*/
// Has Hidden Element
if( this.element.hasClass('u-header--has-hidden-element--xl') ) {
observers['xl'].push(
new HSHeaderHasHiddenElement( this.element )
);
}
// Sticky top
if( this.element.hasClass('u-header--sticky-top--xl') ) {
if( this.element.hasClass('u-header--show-hide--xl') ) {
observers['xl'].push(
new HSHeaderMomentShowHideObserver( this.element )
);
}
else if( this.element.hasClass('u-header--toggle-section--xl') ) {
observers['xl'].push(
new HSHeaderHideSectionObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--xl') ) {
observers['xl'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance--xl') ) {
observers['xl'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Floating
if( this.element.hasClass('u-header--floating--xl') ) {
observers['xl'].push(
new HSHeaderFloatingObserver( this.element )
);
}
// Sticky bottom
if( this.element.hasClass('u-header--invulnerable--xl') ) {
observers['xl'].push(
new HSHeaderWithoutBehaviorObserver( this.element )
);
}
// Sticky bottom
if( this.element.hasClass('u-header--sticky-bottom--xl') ) {
if(this.element.hasClass('u-header--change-appearance--xl')) {
observers['xl'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--xl') ) {
observers['xl'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
}
// Abs top & Static
if( this.element.hasClass('u-header--abs-top--xl') || this.element.hasClass('u-header--static--xl')) {
if( this.element.hasClass('u-header--show-hide--xl') ) {
observers['xl'].push(
new HSHeaderShowHideObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-logo--xl') ) {
observers['xl'].push(
new HSHeaderChangeLogoObserver( this.element )
);
}
if( this.element.hasClass('u-header--change-appearance--xl') ) {
observers['xl'].push(
new HSHeaderChangeAppearanceObserver( this.element )
);
}
}
// Abs bottom & Abs top 2nd screen
if( this.element.hasClass('u-header--abs-bottom--xl') || this.element.hasClass('u-header--abs-top-2nd-screen--xl') ) {
observers['xl'].push(
new HSHeaderStickObserver( this.element )
);
if( this.element.hasClass('u-header--change-appearance--xl') ) {
observers['xl'].push(
new HSHeaderChangeAppearanceObserver( this.element, {
fixPointSelf: true
} )
);
}
if( this.element.hasClass('u-header--change-logo--xl') ) {
observers['xl'].push(
new HSHeaderChangeLogoObserver( this.element, {
fixPointSelf: true
} )
);
}
}
return observers;
},
/**
*
*
* @param
*
* @return
*/
fixMediaDifference: function(element) {
if(!element || !element.length || !element.filter('[class*="u-header--side"]').length) return;
var toggleable;
if(element.hasClass('u-header--side-left--xl') || element.hasClass('u-header--side-right--xl')) {
toggleable = element.find('.navbar-toggleable-xl');
if(toggleable.length) {
toggleable
.removeClass('navbar-toggleable-xl')
.addClass('navbar-toggleable-lg');
}
}
else if(element.hasClass('u-header--side-left--lg') || element.hasClass('u-header--side-right--lg')) {
toggleable = element.find('.navbar-toggleable-lg');
if(toggleable.length) {
toggleable
.removeClass('navbar-toggleable-lg')
.addClass('navbar-toggleable-md');
}
}
else if(element.hasClass('u-header--side-left--md') || element.hasClass('u-header--side-right--md')) {
toggleable = element.find('.navbar-toggleable-md');
if(toggleable.length) {
toggleable
.removeClass('navbar-toggleable-md')
.addClass('navbar-toggleable-sm');
}
}
else if(element.hasClass('u-header--side-left--sm') || element.hasClass('u-header--side-right--sm')) {
toggleable = element.find('.navbar-toggleable-sm');
if(toggleable.length) {
toggleable
.removeClass('navbar-toggleable-sm')
.addClass('navbar-toggleable');
}
}
}
}
/**
* HSHeader constructor function.
*
* @param jQuery element
* @param Object config
* @param Object observers
*
* @return undefined
*/
function HSHeader( element, config, observers ) {
if( !element || !element.length ) return;
this.element = element;
this.config = config;
this.observers = observers && $.isPlainObject( observers ) ? observers : {};
this.viewport = 'xs';
this.checkViewport();
}
/**
*
*
* @return Object
*/
HSHeader.prototype.checkViewport = function() {
var $w = $(window);
if( $w.width() > this.config.breakpointsMap['sm'] && this.observers['sm'].length ){
this.prevViewport = this.viewport;
this.viewport = 'sm';
return this;
}
if( $w.width() > this.config.breakpointsMap['md'] && this.observers['md'].length ) {
this.prevViewport = this.viewport;
this.viewport = 'md';
return this;
}
if( $w.width() > this.config.breakpointsMap['lg'] && this.observers['lg'].length ) {
this.prevViewport = this.viewport;
this.viewport = 'lg';
return this;
}
if( $w.width() > this.config.breakpointsMap['xl'] && this.observers['xl'].length ) {
this.prevViewport = this.viewport;
this.viewport = 'xl';
return this;
}
if(this.prevViewport) this.prevViewport = this.viewport;
this.viewport = 'xs';
return this;
}
/**
* Notifies all observers.
*
* @return Object
*/
HSHeader.prototype.notify = function(){
if( this.prevViewport ) {
this.observers[this.prevViewport].forEach(function(observer){
observer.destroy();
});
this.prevViewport = null;
}
this.observers[this.viewport].forEach(function(observer){
observer.check();
});
return this;
}
/**
* Reinit all header's observers.
*
* @return Object
*/
HSHeader.prototype.update = function() {
// if( this.prevViewport ) {
// this.observers[this.prevViewport].forEach(function(observer){
// observer.destroy();
// });
// this.prevViewport = null;
// }
for(var viewport in this.observers) {
this.observers[viewport].forEach(function(observer){
observer.destroy();
});
}
this.prevViewport = null;
this.observers[this.viewport].forEach(function(observer){
observer.reinit();
});
return this;
}
/**
* Abstract constructor function for each observer.
*
* @param jQuery element
*
* @return Boolean|undefined
*/
function HSAbstractObserver(element) {
if( !element || !element.length ) return;
this.element = element;
this.defaultState = true;
this.reinit = function() {
this
.destroy()
.init()
.check();
}
return true;
}
/**
* Header's observer which is responsible for 'sticky' behavior.
*
* @param jQuery element
*/
function HSHeaderStickObserver( element ) {
if( !HSAbstractObserver.call(this, element) ) return;
this.init();
}
/**
*
*
* @param
*
* @return
*/
HSHeaderStickObserver.prototype.init = function() {
this.defaultState = true;
this.offset = this.element.offset().top;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderStickObserver.prototype.destroy = function() {
this.toDefaultState();
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderStickObserver.prototype.check = function() {
var $w = $(window),
docScrolled = $w.scrollTop();
if( docScrolled > this.offset && this.defaultState) {
this.changeState();
}
else if(docScrolled < this.offset && !this.defaultState){
this.toDefaultState();
}
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderStickObserver.prototype.changeState = function() {
this.element.addClass('js-header-fix-moment');
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderStickObserver.prototype.toDefaultState = function() {
this.element.removeClass('js-header-fix-moment');
this.defaultState = !this.defaultState;
return this;
}
/**
* Header's observer which is responsible for 'show/hide' behavior which is depended on scroll direction.
*
* @param jQuery element
*/
function HSHeaderMomentShowHideObserver( element ) {
if( !HSAbstractObserver.call(this, element) ) return;
this.init();
}
/**
*
*
* @return Object
*/
HSHeaderMomentShowHideObserver.prototype.init = function() {
this.direction = 'down';
this.delta = 0;
this.defaultState = true;
this.offset = isFinite( this.element.data('header-fix-moment') ) && this.element.data('header-fix-moment') != 0 ? this.element.data('header-fix-moment') : 5;
this.effect = this.element.data('header-fix-effect') ? this.element.data('header-fix-effect') : 'show-hide';
return this;
}
/**
*
*
* @return Object
*/
HSHeaderMomentShowHideObserver.prototype.destroy = function() {
this.toDefaultState();
return this;
}
/**
*
*
* @param
*
* @return Object
*/
HSHeaderMomentShowHideObserver.prototype.checkDirection = function() {
if( $(window).scrollTop() > this.delta ) {
this.direction = 'down';
}
else {
this.direction = 'up';
}
this.delta = $(window).scrollTop();
return this;
}
/**
*
*
* @return Object
*/
HSHeaderMomentShowHideObserver.prototype.toDefaultState = function() {
switch( this.effect ) {
case 'slide' :
this.element.removeClass('u-header--moved-up');
break;
case 'fade' :
this.element.removeClass('u-header--faded');
break;
default:
this.element.removeClass('u-header--invisible');
}
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @return Object
*/
HSHeaderMomentShowHideObserver.prototype.changeState = function() {
switch( this.effect ) {
case 'slide' :
this.element.addClass('u-header--moved-up');
break;
case 'fade' :
this.element.addClass('u-header--faded');
break;
default:
this.element.addClass('u-header--invisible');
}
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @return Object
*/
HSHeaderMomentShowHideObserver.prototype.check = function() {
var docScrolled = $(window).scrollTop();
this.checkDirection();
if( docScrolled >= this.offset && this.defaultState && this.direction == 'down' ) {
this.changeState();
}
else if ( !this.defaultState && this.direction == 'up') {
this.toDefaultState();
}
return this;
}
/**
*
*
* @param
*
* @return
*/
function HSHeaderShowHideObserver( element ) {
if( !HSAbstractObserver.call(this, element) ) return;
this.init();
}
/**
*
*
* @param
*
* @return Object
*/
HSHeaderShowHideObserver.prototype.init = function() {
if(!this.defaultState && $(window).scrollTop() > this.offset) return this;
this.defaultState = true;
this.transitionDuration = parseFloat( getComputedStyle( this.element.get(0) )['transition-duration'], 10 ) * 1000;
this.offset = isFinite( this.element.data('header-fix-moment') ) && this.element.data('header-fix-moment') > this.element.outerHeight() ? this.element.data('header-fix-moment') : this.element.outerHeight() + 100;
this.effect = this.element.data('header-fix-effect') ? this.element.data('header-fix-effect') : 'show-hide';
return this;
}
/**
*
*
* @param
*
* @return Object
*/
HSHeaderShowHideObserver.prototype.destroy = function() {
if( !this.defaultState && $(window).scrollTop() > this.offset ) return this;
this.element.removeClass('u-header--untransitioned');
this._removeCap();
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderShowHideObserver.prototype._insertCap = function() {
this.element.addClass('js-header-fix-moment u-header--untransitioned');
if( this.element.hasClass('u-header--static') ) {
$('html').css('padding-top', this.element.outerHeight() );
}
switch( this.effect ) {
case 'fade' :
this.element.addClass('u-header--faded');
break;
case 'slide' :
this.element.addClass('u-header--moved-up');
break;
default :
this.element.addClass('u-header--invisible')
}
this.capInserted = true;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderShowHideObserver.prototype._removeCap = function() {
var self = this;
this.element.removeClass('js-header-fix-moment');
if( this.element.hasClass('u-header--static') ) {
$('html').css('padding-top', 0 );
}
if(this.removeCapTimeOutId) clearTimeout(this.removeCapTimeOutId);
this.removeCapTimeOutId = setTimeout(function() {
self.element.removeClass('u-header--moved-up u-header--faded u-header--invisible');
}, 10);
this.capInserted = false;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderShowHideObserver.prototype.check = function() {
var $w = $(window);
if( $w.scrollTop() > this.element.outerHeight() && !this.capInserted ) {
this._insertCap();
}
else if($w.scrollTop() <= this.element.outerHeight() && this.capInserted) {
this._removeCap();
}
if( $w.scrollTop() > this.offset && this.defaultState) {
this.changeState();
}
else if( $w.scrollTop() <= this.offset && !this.defaultState ) {
this.toDefaultState();
}
}
/**
*
*
* @param
*
* @return
*/
HSHeaderShowHideObserver.prototype.changeState = function() {
this.element.removeClass('u-header--untransitioned');
if( this.animationTimeoutId ) clearTimeout( this.animationTimeoutId );
switch( this.effect ) {
case 'fade' :
this.element.removeClass('u-header--faded');
break;
case 'slide' :
this.element.removeClass('u-header--moved-up');
break;
default:
this.element.removeClass('u-header--invisible');
}
this.defaultState = !this.defaultState;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderShowHideObserver.prototype.toDefaultState = function() {
var self = this;
this.animationTimeoutId = setTimeout(function(){
self.element.addClass('u-header--untransitioned');
}, this.transitionDuration );
switch( this.effect ) {
case 'fade' :
this.element.addClass('u-header--faded');
break;
case 'slide' :
this.element.addClass('u-header--moved-up');
break;
default:
this.element.addClass('u-header--invisible');
}
this.defaultState = !this.defaultState;
}
/**
*
*
* @param
*
* @return
*/
function HSHeaderChangeLogoObserver( element, config ) {
if( !HSAbstractObserver.call( this, element ) ) return;
this.config = {
fixPointSelf: false
}
if( config && $.isPlainObject(config) ) this.config = $.extend(true, {}, this.config, config);
this.init();
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeLogoObserver.prototype.init = function() {
if(this.element.hasClass('js-header-fix-moment')) {
this.hasFixedClass = true;
this.element.removeClass('js-header-fix-moment');
}
if( this.config.fixPointSelf ) {
this.offset = this.element.offset().top;
}
else {
this.offset = isFinite( this.element.data('header-fix-moment') ) ? this.element.data('header-fix-moment') : 0;
}
if(this.hasFixedClass) {
this.hasFixedClass = false;
this.element.addClass('js-header-fix-moment');
}
this.imgs = this.element.find('.u-header__logo-img');
this.defaultState = true;
this.mainLogo = this.imgs.filter('.u-header__logo-img--main');
this.additionalLogo = this.imgs.not('.u-header__logo-img--main');
if( !this.imgs.length ) return this;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeLogoObserver.prototype.destroy = function() {
this.toDefaultState();
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeLogoObserver.prototype.check = function() {
var $w = $(window);
if( !this.imgs.length ) return this;
if( $w.scrollTop() > this.offset && this.defaultState) {
this.changeState();
}
else if( $w.scrollTop() <= this.offset && !this.defaultState ) {
this.toDefaultState();
}
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeLogoObserver.prototype.changeState = function() {
if(this.mainLogo.length) {
this.mainLogo.removeClass('u-header__logo-img--main');
}
if(this.additionalLogo.length) {
this.additionalLogo.addClass('u-header__logo-img--main');
}
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeLogoObserver.prototype.toDefaultState = function() {
if(this.mainLogo.length) {
this.mainLogo.addClass('u-header__logo-img--main');
}
if(this.additionalLogo.length) {
this.additionalLogo.removeClass('u-header__logo-img--main');
}
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
function HSHeaderHideSectionObserver( element ) {
if( !HSAbstractObserver.call(this, element) ) return;
this.init();
}
/**
*
*
* @param
*
* @return Object
*/
HSHeaderHideSectionObserver.prototype.init = function() {
this.offset = isFinite( this.element.data('header-fix-moment') ) ? this.element.data('header-fix-moment') : 5;
this.section = this.element.find('.u-header__section--hidden');
this.defaultState = true;
this.sectionHeight = this.section.length ? this.section.outerHeight() : 0;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHideSectionObserver.prototype.destroy = function() {
if( this.section.length ) {
this.element.css({
'margin-top': 0
});
}
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHideSectionObserver.prototype.check = function() {
if(!this.section.length) return this;
var $w = $(window),
docScrolled = $w.scrollTop();
if( docScrolled > this.offset && this.defaultState) {
this.changeState();
}
else if( docScrolled <= this.offset && !this.defaultState ) {
this.toDefaultState();
}
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHideSectionObserver.prototype.changeState = function() {
var self = this;
this.element.stop().animate({
'margin-top': self.sectionHeight * -1 - 1 // last '-1' is a small fix
});
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHideSectionObserver.prototype.toDefaultState = function() {
this.element.stop().animate({
'margin-top': 0
});
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
function HSHeaderChangeAppearanceObserver(element, config) {
if( !HSAbstractObserver.call(this, element) ) return;
this.config = {
fixPointSelf: false
}
if( config && $.isPlainObject(config) ) this.config = $.extend(true, {}, this.config, config);
this.init();
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeAppearanceObserver.prototype.init = function() {
if(this.element.hasClass('js-header-fix-moment')) {
this.hasFixedClass = true;
this.element.removeClass('js-header-fix-moment');
}
if( this.config.fixPointSelf ) {
this.offset = this.element.offset().top;
}
else {
this.offset = isFinite( this.element.data('header-fix-moment') ) ? this.element.data('header-fix-moment') : 5;
}
if( this.hasFixedClass ) {
this.hasFixedClass = false;
this.element.addClass('js-header-fix-moment');
}
this.sections = this.element.find('[data-header-fix-moment-classes]');
this.defaultState = true;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeAppearanceObserver.prototype.destroy = function() {
this.toDefaultState();
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeAppearanceObserver.prototype.check = function() {
if( !this.sections.length ) return this;
var $w = $(window),
docScrolled = $w.scrollTop();
if( docScrolled > this.offset && this.defaultState) {
this.changeState();
}
else if( docScrolled <= this.offset && !this.defaultState ) {
this.toDefaultState();
}
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeAppearanceObserver.prototype.changeState = function() {
this.sections.each(function(i,el){
var $this = $(el),
classes = $this.data('header-fix-moment-classes'),
exclude = $this.data('header-fix-moment-exclude');
if( !classes && !exclude ) return;
$this.addClass( classes + ' js-header-change-moment');
$this.removeClass( exclude );
});
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderChangeAppearanceObserver.prototype.toDefaultState = function() {
this.sections.each(function(i,el){
var $this = $(el),
classes = $this.data('header-fix-moment-classes'),
exclude = $this.data('header-fix-moment-exclude');
if( !classes && !exclude ) return;
$this.removeClass( classes + ' js-header-change-moment' );
$this.addClass( exclude );
});
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
function HSHeaderHasHiddenElement(element, config) {
if( !HSAbstractObserver.call(this, element) ) return;
this.config = {
animated: true
}
if( config && $.isPlainObject(config) ) this.config = $.extend(true, {}, this.config, config);
this.init();
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHasHiddenElement.prototype.init = function() {
this.offset = isFinite( this.element.data('header-fix-moment') ) ? this.element.data('header-fix-moment') : 5;
this.elements = this.element.find('.u-header--hidden-element');
this.defaultState = true;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHasHiddenElement.prototype.destroy = function() {
this.toDefaultState();
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHasHiddenElement.prototype.check = function() {
if( !this.elements.length ) return this;
var $w = $(window),
docScrolled = $w.scrollTop();
if( docScrolled > this.offset && this.defaultState) {
this.changeState();
}
else if( docScrolled <= this.offset && !this.defaultState ) {
this.toDefaultState();
}
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHasHiddenElement.prototype.changeState = function() {
if(this.config.animated) {
this.elements.stop().slideUp();
}
else {
this.elements.hide();
}
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderHasHiddenElement.prototype.toDefaultState = function() {
if(this.config.animated) {
this.elements.stop().slideDown();
}
else {
this.elements.show();
}
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
function HSHeaderFloatingObserver(element, config) {
if( !HSAbstractObserver.call(this, element) ) return;
this.config = config && $.isPlainObject(config) ? $.extend(true, {}, this.config, config) : {};
this.init();
}
/**
*
*
* @param
*
* @return
*/
HSHeaderFloatingObserver.prototype.init = function() {
this.offset = this.element.offset().top;
this.sections = this.element.find('.u-header__section');
this.defaultState = true;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderFloatingObserver.prototype.destroy = function() {
this.toDefaultState();
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderFloatingObserver.prototype.check = function() {
var $w = $(window),
docScrolled = $w.scrollTop();
if( docScrolled > this.offset && this.defaultState) {
this.changeState();
}
else if( docScrolled <= this.offset && !this.defaultState ) {
this.toDefaultState();
}
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderFloatingObserver.prototype.changeState = function() {
this.element
.addClass('js-header-fix-moment')
.addClass( this.element.data('header-fix-moment-classes') )
.removeClass( this.element.data('header-fix-moment-exclude') );
if( this.sections.length ) {
this.sections.each(function(i, el){
var $section = $(el);
$section.addClass( $section.data('header-fix-moment-classes') )
.removeClass( $section.data('header-fix-moment-exclude') );
});
}
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
HSHeaderFloatingObserver.prototype.toDefaultState = function() {
this.element
.removeClass('js-header-fix-moment')
.removeClass( this.element.data('header-fix-moment-classes') )
.addClass( this.element.data('header-fix-moment-exclude') );
if( this.sections.length ) {
this.sections.each(function(i, el){
var $section = $(el);
$section.removeClass( $section.data('header-fix-moment-classes') )
.addClass( $section.data('header-fix-moment-exclude') );
});
}
this.defaultState = !this.defaultState;
return this;
}
/**
*
*
* @param
*
* @return
*/
function HSHeaderWithoutBehaviorObserver( element ) { if( !HSAbstractObserver.call(this, element) ) return; }
HSHeaderWithoutBehaviorObserver.prototype.check = function() {
return this;
}
HSHeaderWithoutBehaviorObserver.prototype.init = function() {
return this;
}
HSHeaderWithoutBehaviorObserver.prototype.destroy = function() {
return this;
}
HSHeaderWithoutBehaviorObserver.prototype.changeState = function() {
return this;
}
HSHeaderWithoutBehaviorObserver.prototype.toDefaultState = function() {
return this;
}
})(jQuery);
;/**
* Hamburgers plugin helper.
*
* @author Htmlstream
* @version 1.0
* @requires hamburgers.min.css
*
*/
;(function($){
'use strict';
$.HSCore.helpers.HSHamburgers = {
/**
* Initialize 'hamburgers' plugin.
*
* @param String selector
*
* @return undefined;
*/
init: function(selector) {
if( !selector || !$(selector).length ) return;
var hamburgers = $(selector),
timeoutid;
hamburgers.each(function(i, el){
var $this = $(this);
if($this.closest('button').length) {
$this.closest('button').get(0).addEventListener('click', function(e){
var $self = $(this),
$hamburger = $self.find(selector);
if(timeoutid) clearTimeout(timeoutid);
timeoutid = setTimeout(function(){
$hamburger.toggleClass('is-active');
}, 10);
e.preventDefault();
}, false);
}
else {
$this.get(0).addEventListener('click', function(e){
var $self = $(this);
if(timeoutid) clearTimeout(timeoutid);
timeoutid = setTimeout(function(){
$self.toggleClass('is-active');
}, 10);
e.preventDefault();
}, false);
}
});
}
};
})(jQuery);
;/**
* Tabs wrapper.
*
* @author Htmlstream
* @version 1.0
* @requires
*
*/
;(function ($) {
'use strict';
$.HSCore.components.HSTabs = {
/**
*
*
* @var Object _baseConfig
*/
_baseConfig: {},
/**
*
*
* @var jQuery pageCollection
*/
pageCollection: $(),
/**
* Initialization of Tabs wrapper.
*
* @param String selector (optional)
* @param Object config (optional)
*
* @return jQuery pageCollection - collection of initialized items.
*/
init: function (selector, config) {
this.collection = selector && $(selector).length ? $(selector) : $();
if (!$(selector).length) return;
this.config = config && $.isPlainObject(config) ?
$.extend({}, this._baseConfig, config) : this._baseConfig;
this.config.itemSelector = selector;
this.initTabs();
return this.pageCollection;
},
initTabs: function () {
//Variables
var $self = this,
collection = $self.pageCollection;
//Actions
this.collection.each(function (i, el) {
//Variables
var windW = $(window).width(),
//Tabs
$tabs = $(el),
$tabsItem = $tabs.find('.nav-item'),
tabsType = $tabs.data('tabs-mobile-type'), //[slide-up-down], [accordion], [hide-extra-items]
controlClasses = $tabs.data('btn-classes'),
context = $tabs.parent(),
//Tabs Content
$tabsContent = $('#' + $tabs.data('target')),
$tabsContentItem = $tabsContent.find('.tab-pane');
if (windW < 767) {
$('body').on('click', function () {
if (tabsType) {
$tabs.slideUp(200);
} else {
$tabs.find('.nav-inner').slideUp(200);
}
});
} else {
$('body').off('click');
}
if (windW > 767 && tabsType) {
$tabs.removeAttr('style');
$tabsContentItem.removeAttr('style');
context.off('click', '.js-tabs-mobile-control');
context.off('click', '[role="tab"]');
if (tabsType == 'accordion') {
$tabsContent.find('.js-tabs-mobile-control').remove();
} else {
context.find('.js-tabs-mobile-control').remove();
}
return;
}
if (windW < 768 && tabsType == 'accordion') {
$self.accordionEffect($tabsContent, $tabsItem, $tabsContentItem, controlClasses);
} else if (windW < 768 && tabsType == 'slide-up-down') {
$self.slideUpDownEffect(context, $tabs, controlClasses);
}
//Actions
collection = collection.add($tabs);
});
},
slideUpDownEffect: function (context, menu, btnClasses) {
if (context.find('.js-tabs-mobile-control').length) return;
//Create control
var activeItemHTML = menu.find('.active').html();
$(menu).before('' + activeItemHTML + '');
/*----- CLICK -----*/
context.on('click', '.js-tabs-mobile-control', function (e) {
e.stopPropagation();
e.preventDefault();
$(menu).slideToggle(200);
});
context.on('click', '[role="tab"]', function (e) {
e.preventDefault();
var thisHTML = $(this).html(),
$targetControl = $(this).closest('ul').prev('.js-tabs-mobile-control');
$targetControl.html(thisHTML);
$(menu).slideUp(200);
});
},
accordionEffect: function (context, menuItem, menu, btnClasses) {
if (context.find('.js-tabs-mobile-control').length) return;
//Create control
$(menu).before('');
menuItem.each(function () {
var thisIndex = $(this).index(),
thisHTML = $(this).find('[role="tab"]').html();
if ($(this).find('[role="tab"]').hasClass('active')) {
$(menu[thisIndex]).prev().addClass('active');
}
$(menu[thisIndex]).prev().html(thisHTML);
});
/*----- CLICK -----*/
context.on('click', '.js-tabs-mobile-control', function (e) {
e.preventDefault();
if ($(this).hasClass('active')) return;
var contextID = context.attr('id');
context.find('.js-tabs-mobile-control').removeClass('active');
console.log(contextID);
$('[data-target="' + contextID + '"]').find('.nav-link').removeClass('active');
var $target = $(this).next(),
targetID = $target.attr('id');
if ($target.hasClass('fade')) {
$(this).addClass('active');
$('[href="#' + targetID + '"]').addClass('active');
$(menu)
.slideUp(200);
$target
.slideDown(200, function () {
context.find('[role="tabpanel"]').removeClass('show active');
$target.addClass('show active');
});
} else {
$(this).addClass('active');
$(menu).slideUp(200);
$target.slideDown(200);
}
});
}
}
})(jQuery);
;/**
* HSPopup - wrapper of the Fancybox plugin.
*
* @author Htmlstream
* @version 1.0
* @requires fancybox.js (v2.1.5)
*
*/
;(function($){
'use strict';
$.HSCore.components.HSPopup = {
/**
* Base configuration of the wrapper.
*
* @protected
*/
_baseConfig: {
baseClass: 'u-fancybox-theme',
slideClass: 'u-fancybox-slide',
speed: 1000,
slideSpeedCoefficient: 1,
infobar: false,
slideShow: false,
fullScreen: true,
thumbs: false,
closeBtn: true,
baseTpl : '' +
'
' +
'
' +
'
' +
'
' +
'' +
'
' +
'
' +
'
' +
'
' +
'
',
onInit: $.noop,
beforeMove: $.noop,
beforeClose: $.noop
},
/**
* Initialization of the wrapper.
*
* @param {String} selector
* @param {Object} config (optional)
* @public
*/
init: function(selector, config) {
if(!selector) return;
var hiddenGallery,
$collection = $(selector);
if(!$collection.length) return;
config = config && $.isPlainObject(config) ? $.extend(true, {}, this._baseConfig, config) : this._baseConfig;
config = this._predefineCallbacks( config );
this.$body = $('body');
this.initGallery(selector, config);
},
/**
* Initialization of a gallery.
*
* @param {String} selector
* @param {Object} config (optional)
* @public
*/
initGallery: function(selector, config) {
$('body').on('click.HSPopup', selector, function(e) {
var $this = $(this),
index = 0,
$gallery,
predefinedCollection = [],
collectionItem;
if( $this.data('fancybox-gallery') ) {
$gallery = $('[data-fancybox-gallery="' + $this.data('fancybox-gallery') + '"]');
}
else if ( $this.data('fancybox-hidden-gallery') ) {
$gallery = $('[data-fancybox-hidden-gallery="' + $this.data('fancybox-hidden-gallery') + '"]');
}
if( $gallery && $gallery.length ) {
index = $gallery.index( $this );
$gallery.each(function(i, el){
var $el = $(el);
collectionItem = {
src: $el.attr(el.nodeName === "IMG" || el.nodeName === "IFRAME" ? 'src' : 'href'),
customOpts: {
fancyboxAnimateIn: $el.data('fancybox-animate-in'),
fancyboxAnimateOut: $el.data('fancybox-animate-out'),
fancyboxSpeed: $el.data('fancybox-speed'),
fancyboxSlideSpeed: $el.data('fancybox-slide-speed'),
fancyboxBlurBg: $el.data('fancybox-blur-bg'),
fancyboxBg: $el.data('fancybox-bg')
}
};
if( $el.data('fancybox-type') ) {
collectionItem.type = $el.data('fancybox-type');
console.log($el);
}
predefinedCollection.push(collectionItem);
});
console.log(predefinedCollection);
}
else {
collectionItem = {
src: $this.attr('href'),
customOpts: {
fancyboxAnimateIn: $this.data('fancybox-animate-in'),
fancyboxAnimateOut: $this.data('fancybox-animate-out'),
fancyboxSpeed: $this.data('fancybox-speed'),
fancyboxSlideSpeed: $this.data('fancybox-slide-speed'),
fancyboxBlurBg: $this.data('fancybox-blur-bg'),
fancyboxBg: $this.data('fancybox-bg')
}
};
if( $this.data('fancybox-type') ) {
collectionItem.type = $this.data('fancybox-type');
}
predefinedCollection = [collectionItem];
}
$.fancybox.open(
predefinedCollection,
predefinedCollection[index].customOpts.fancyboxSpeed ? $.extend(true, {}, config, {
speed: predefinedCollection[index].customOpts.fancyboxSpeed
}) : config,
index
);
e.preventDefault();
});
},
/**
* Integration of custom options.
*
* @param {Object} config
* @private
* @returns {Object}
*/
_predefineCallbacks: function( config ) {
var self = this,
onInitCallback = config.onInit,
beforeMoveCallback = config.beforeMove,
beforeCloseCallback = config.beforeClose;
config.onInit = function( instance ) {
self._defaultBgColor = instance.$refs.bg.css('background-color');
if(instance.group.length > 1) {
instance.$refs.container.find('.fancybox-button--left, .fancybox-button--right').show();
}
if( $.isFunction( onInitCallback ) ) onInitCallback.call(this, instance);
};
config.beforeMove = function( instance, slide ) {
if( self._currentSlide ) {
self._closeSlide( self._currentSlide, instance );
}
setTimeout( function() {
self._openSlide( slide, instance );
}, 0 );
self._currentSlide = slide;
beforeMoveCallback.call(this, instance, slide);
};
config.beforeClose = function( instance, slide ) {
setTimeout( function() {
self._closeSlide( slide, instance );
}, 0 );
beforeCloseCallback.call(this, instance, slide);
};
return config;
},
/**
* Closes the specified slide.
*
* @param {Object} slide
* @param {Object} instance
* @private
*/
_closeSlide: function( slide, instance ) {
var $image = $(slide.$image),
itemData = slide.customOpts ? slide.customOpts : slide.opts.$orig.data(),
groupLength = instance.group.length;
this._blurBg(false);
if( itemData.fancyboxAnimateOut ) {
if( $image.hasClass(itemData.fancyboxAnimateIn) ) $image.removeClass( itemData.fancyboxAnimateIn );
$image.addClass(itemData.fancyboxAnimateOut );
}
},
/**
* Opens the specified slide.
*
* @param {Object} slide
* @param {Object} instance
* @private
*/
_openSlide: function( slide, instance ) {
var $image = $(slide.$image),
itemData = slide.customOpts ? slide.customOpts : slide.opts.$orig.data();
instance.$refs.bg.css(
'background-color',
(itemData.fancyboxBg ? itemData.fancyboxBg : this._defaultBgColor)
);
this._blurBg(itemData.fancyboxBlurBg ? true : false);
$image.css('animation-duration', (itemData.fancyboxSlideSpeed && itemData.fancyboxSlideSpeed >= slide.opts.speed ? itemData.fancyboxSlideSpeed : slide.opts.speed * Math.abs( slide.opts.slideSpeedCoefficient )) + 'ms');
if( itemData.fancyboxAnimateIn ) {
if( $image.hasClass( itemData.fancyboxAnimateOut ) ) $image.removeClass( itemData.fancyboxAnimateOut );
$image.addClass( 'animated ' + itemData.fancyboxAnimateIn );
}
},
/**
* Makes blur background while slide is opening.
*
* @param {Boolean} isBlur
* @private
*/
_blurBg: function(isBlur) {
var self = this;
if( isBlur ) {
if( this._blurBgTimeOut ) clearTimeout( this._blurBgTimeOut );
if( !this.blurBgContainer ) {
this.blurBgContainer = $('', {
class: 'u-fancybox-blur-bg-container'
});
this.$body.append(this.blurBgContainer);
}
if( this.blurBgContainer.children().length ) return;
this.blurBgContainer.append( this.$body.children().not('.fancybox-container') );
}
else {
if(!this.blurBgContainer || !this.blurBgContainer.children().length) return;
this._blurBgTimeOut = setTimeout(function(){
self.$body.append( self.blurBgContainer.children() );
}, 10)
}
}
};
})(jQuery);
;/*
* HS Mega Menu - jQuery Plugin
* @version: 1.0.0 (Sun, 26 Feb 2017)
* @requires: jQuery v1.6 or later
* @author: HtmlStream
* @event-namespace: .HSMegaMenu
* @browser-support: IE9+
* @license:
*
* Copyright 2017 HtmlStream
*
*/
;(function($){
'use strict';
/**
* Creates a mega menu.
*
* @constructor
* @param {HTMLElement|jQuery} element - The element to create the mega menu for.
* @param {Object} options - The options
*/
function MegaMenu(element, options) {
var self = this;
/**
* Current element.
*
* @public
*/
this.$element = $(element);
/**
* Current options set by the caller including defaults.
*
* @public
*/
this.options = $.extend(true, {}, MegaMenu.defaults, options);
/**
* Collection of menu elements.
*
* @private
*/
this._items = $();
Object.defineProperties( this, {
/**
* Contains composed selector of menu items.
*
* @public
*/
itemsSelector: {
get: function() {
return self.options.classMap.hasSubMenu + ',' +
self.options.classMap.hasMegaMenu;
}
},
/**
* Contains chain of active items.
*
* @private
*/
_tempChain: {
value: null,
writable: true
},
/**
* Contains current behavior state.
*
* @public
*/
state: {
value: null,
writable: true
}
});
this.initialize();
};
/**
* Default options of the mega menu.
*
* @public
*/
MegaMenu.defaults = {
event: 'hover',
direction: 'horizontal',
breakpoint: 991,
animationIn: false,
animationOut: false,
rtl: false,
hideTimeOut: 300,
// For 'vertical' direction only
sideBarRatio: 1/4,
pageContainer: $('body'),
classMap: {
initialized: '.hs-menu-initialized',
mobileState: '.hs-mobile-state',
subMenu: '.hs-sub-menu',
hasSubMenu: '.hs-has-sub-menu',
hasSubMenuActive: '.hs-sub-menu-opened',
megaMenu: '.hs-mega-menu',
hasMegaMenu: '.hs-has-mega-menu',
hasMegaMenuActive: '.hs-mega-menu-opened'
},
mobileSpeed: 400,
mobileEasing: 'linear',
beforeOpen: function(){},
beforeClose: function(){},
afterOpen: function(){},
afterClose: function(){}
};
/**
* Initialization of the plugin.
*
* @protected
*/
MegaMenu.prototype.initialize = function() {
var self = this,
$w = $(window);
if( this.options.rtl ) this.$element.addClass('hs-rtl');
this.$element
.addClass(this.options.classMap.initialized.slice(1))
.addClass('hs-menu-' + this.options.direction);
// Independent events
$w.on('resize.HSMegaMenu', function(e){
if( self.resizeTimeOutId ) clearTimeout( self.resizeTimeOutId );
self.resizeTimeOutId = setTimeout( function(){
if($w.width() <= self.options.breakpoint && self.state == 'desktop') self.initMobileBehavior();
else if( $w.width() > self.options.breakpoint && self.state == 'mobile' ) self.initDesktopBehavior();
self.refresh();
}, 50 );
});
$(document)
.on('click.HSMegaMenu', function(e){
var $parents = $(e.target).parents(self.itemsSelector);
self.closeAll( $parents.add($(e.target)) );
})
.on('keyup.HSMegaMenu', function(e){
if( e.keyCode && e.keyCode == 27 ) self.closeAll();
});
if($w.width() <= this.options.breakpoint) this.initMobileBehavior();
else if( $w.width() > this.options.breakpoint) this.initDesktopBehavior();
this.smartPositions();
return this;
};
MegaMenu.prototype.smartPositions = function() {
var self = this,
$submenus = this.$element.find( this.options.classMap.subMenu );
$submenus.each(function(i, el) {
MenuItem.smartPosition( $(el), self.options );
});
};
/**
* Binding events to menu elements.
*
* @protected
*/
MegaMenu.prototype.bindEvents = function() {
var self = this,
selector;
// Hover case
if(this.options.event === 'hover' && !_isTouch()) {
this.$element
.on(
'mouseenter.HSMegaMenu',
this.options.classMap.hasMegaMenu + ':not([data-event="click"]),' +
this.options.classMap.hasSubMenu + ':not([data-event="click"])',
function(e) {
var $this = $(this),
$chain = $this.parents( self.itemsSelector);
// Lazy initialization
if( !$this.data('HSMenuItem') ) {
self.initMenuItem( $this, self.getType( $this ) );
}
$chain = $chain.add($this);
self.closeAll( $chain );
$chain.each(function(i, el){
var HSMenuItem = $(el).data('HSMenuItem');
if(HSMenuItem.hideTimeOutId) clearTimeout(HSMenuItem.hideTimeOutId);
HSMenuItem.show();
});
self._items = self._items.not( $chain );
self._tempChain = $chain;
e.preventDefault();
e.stopPropagation();
}
)
.on(
'mouseleave.HSMegaMenu',
this.options.classMap.hasMegaMenu + ':not([data-event="click"]),' +
this.options.classMap.hasSubMenu + ':not([data-event="click"])',
function(e) {
var $this = $(this),
HSMenuItem = $this.data('HSMenuItem'),
$chain = $(e.relatedTarget).parents( self.itemsSelector );
HSMenuItem.hideTimeOutId = setTimeout( function(){
self.closeAll( $chain );
}, self.options.hideTimeOut );
self._items = self._items.add( self._tempChain );
self._tempChain = null;
e.preventDefault();
e.stopPropagation();
}
)
.on(
'click.HSMegaMenu',
this.options.classMap.hasMegaMenu + '[data-event="click"] > a, ' +
this.options.classMap.hasSubMenu + '[data-event="click"] > a',
function(e) {
var $this = $(this).parent('[data-event="click"]'),
HSMenuItem;
// Lazy initialization
if(!$this.data('HSMenuItem')) {
self.initMenuItem( $this, self.getType( $this ) );
}
self.closeAll( $this.add(
$this.parents(self.itemsSelector)
) );
HSMenuItem = $this
.data('HSMenuItem');
if(HSMenuItem.isOpened) {
HSMenuItem.hide();
}
else{
HSMenuItem.show();
}
e.preventDefault();
e.stopPropagation();
}
);
}
// Click case
else {
this.$element
.on(
'click.HSMegaMenu',
(_isTouch() ?
this.options.classMap.hasMegaMenu + ' > a, ' +
this.options.classMap.hasSubMenu + ' > a' :
this.options.classMap.hasMegaMenu + ':not([data-event="hover"]) > a,' +
this.options.classMap.hasSubMenu + ':not([data-event="hover"]) > a'),
function(e) {
var $this = $(this).parent(),
HSMenuItem,
$parents = $this.parents(self.itemsSelector);
// Lazy initialization
if(!$this.data('HSMenuItem')) {
self.initMenuItem( $this, self.getType( $this ) );
}
self.closeAll( $this.add(
$this.parents( self.itemsSelector )
) );
HSMenuItem = $this
.addClass('hs-event-prevented')
.data('HSMenuItem');
if(HSMenuItem.isOpened) {
HSMenuItem.hide();
}
else{
HSMenuItem.show();
}
e.preventDefault();
e.stopPropagation();
}
);
if(!_isTouch()) {
this.$element
.on(
'mouseenter.HSMegaMenu',
this.options.classMap.hasMegaMenu + '[data-event="hover"],' +
this.options.classMap.hasSubMenu + '[data-event="hover"]',
function(e) {
var $this = $(this),
$parents = $this.parents( self.itemsSelector);
// Lazy initialization
if( !$this.data('HSMenuItem') ) {
self.initMenuItem( $this, self.getType( $this ) );
}
self.closeAll( $this.add($parents) );
$parents.add($this).each(function(i, el){
var HSMenuItem = $(el).data('HSMenuItem');
if(HSMenuItem.hideTimeOutId) clearTimeout(HSMenuItem.hideTimeOutId);
HSMenuItem.show();
});
e.preventDefault();
e.stopPropagation();
}
)
.on(
'mouseleave.HSMegaMenu',
this.options.classMap.hasMegaMenu + '[data-event="hover"],' +
this.options.classMap.hasSubMenu + '[data-event="hover"]',
function(e) {
var $this = $(this),
HSMenuItem = $this.data('HSMenuItem');
HSMenuItem.hideTimeOutId = setTimeout( function(){
self.closeAll(
$(e.relatedTarget).parents(self.itemsSelector)
);
}, self.options.hideTimeOut );
e.preventDefault();
e.stopPropagation();
}
)
}
}
};
/**
* Initialization of certain menu item.
*
* @protected
*/
MegaMenu.prototype.initMenuItem = function(element, type) {
var self = this,
Item = new MenuItem(
element,
element.children(
self.options.classMap[type === 'mega-menu' ? 'megaMenu' : 'subMenu']
),
$.extend(true, {type: type}, self.options, element.data()),
self.$element
);
element.data( 'HSMenuItem', Item );
this._items = this._items.add( element );
};
/**
* Destroys of desktop behavior, then makes initialization of mobile behavior.
*
* @protected
*/
MegaMenu.prototype.initMobileBehavior = function() {
var self = this;
this.state = 'mobile';
this.$element
.off('.HSMegaMenu')
.addClass( this.options.classMap.mobileState.slice(1) )
.on('click.HSMegaMenu', self.options.classMap.hasSubMenu + ' > a, ' + self.options.classMap.hasMegaMenu + ' > a', function(e){
var $this = $(this).parent(),
MenuItemInstance;
// Lazy initialization
if( !$this.data('HSMenuItem') ) {
self.initMenuItem( $this, self.getType( $this ) );
}
self.closeAll( $this.parents( self.itemsSelector ).add($this) );
MenuItemInstance = $this
.data('HSMenuItem');
console.log(MenuItemInstance.isOpened);
if(MenuItemInstance.isOpened) {
MenuItemInstance.mobileHide();
}
else {
MenuItemInstance.mobileShow();
}
e.preventDefault();
e.stopPropagation();
})
.find( this.itemsSelector )
.not(
this.options.classMap.hasSubMenuActive + ',' +
this.options.classMap.hasMegaMenuActive
)
.children(
this.options.classMap.subMenu + ',' +
this.options.classMap.megaMenu
)
.hide();
};
/**
* Destroys of mobile behavior, then makes initialization of desktop behavior.
*
* @protected
*/
MegaMenu.prototype.initDesktopBehavior = function() {
this.state = 'desktop';
this.$element
.removeClass(this.options.classMap.mobileState.slice(1))
.off('.HSMegaMenu')
.find( this.itemsSelector )
.not(
this.options.classMap.hasSubMenuActive + ',' +
this.options.classMap.hasMegaMenuActive
)
.children(
this.options.classMap.subMenu + ',' +
this.options.classMap.megaMenu
)
.hide();
this.bindEvents();
};
/**
* Hides all of opened submenus/megamenus.
*
* @param {jQuery} except - collection of elements, which shouldn't be closed.
* @return {jQuery}
* @public
*/
MegaMenu.prototype.closeAll = function(except) {
var self = this;
return this._items.not(except && except.length ? except : $()).each(function(i, el){
$(el)
.removeClass('hs-event-prevented')
.data('HSMenuItem')[self.state == 'mobile' ? 'mobileHide' : 'hide']();
});
};
/**
* Returns type of sub menu based on specified menu item.
*
* @param {jQuery} item
* @return {String|null}
* @public
*/
MegaMenu.prototype.getType = function( item ) {
if(!item || !item.length) return null;
return item.hasClass(this.options.classMap.hasSubMenu.slice(1)) ? 'sub-menu' :
(item.hasClass(this.options.classMap.hasMegaMenu.slice(1)) ? 'mega-menu' : null);
};
/**
* Returns current menu state.
*
* @return {String}
* @public
*/
MegaMenu.prototype.getState = function() {
return this.state;
};
/**
* Updates bounds of all menu items.
*
* @return {jQuery}
* @public
*/
MegaMenu.prototype.refresh = function() {
return this._items.add( this._tempChain ).each(function(i, el){
$(el).data('HSMenuItem')._updateMenuBounds();
});
};
/**
* Creates a mega-menu element.
*
* @param {jQuery} element
* @param {jQuery} menu
* @param {Object} options
* @param {jQuery} container
* @constructor
*/
function MenuItem(element, menu, options, container) {
var self = this;
/**
* Current menu item element.
*
* @public
*/
this.$element = element;
/**
* Current mega menu element.
*
* @public
*/
this.menu = menu;
/**
* Item options.
*
* @public
*/
this.options = options;
/**
* MegaMenu container.
*
* @public
*/
this.$container = container;
Object.defineProperties(this, {
/**
* Contains css class of menu item element.
*
* @public
*/
itemClass: {
get: function() {
return self.options.type === 'mega-menu' ?
self.options.classMap.hasMegaMenu :
self.options.classMap.hasSubMenu;
}
},
/**
* Contains css active-class of menu item element.
*
* @public
*/
activeItemClass: {
get: function() {
return self.options.type === 'mega-menu' ?
self.options.classMap.hasMegaMenuActive :
self.options.classMap.hasSubMenuActive;
}
},
/**
* Contains css class of menu element.
*
* @public
*/
menuClass: {
get: function() {
return self.options.type === 'mega-menu' ?
self.options.classMap.megaMenu :
self.options.classMap.subMenu;
}
},
isOpened: {
get: function() {
return this.$element.hasClass(this.activeItemClass.slice(1));
}
}
});
this.menu.addClass('animated').on('click.HSMegaMenu', function(e){
self._updateMenuBounds();
});
if( this.$element.data('max-width') ) this.menu.css('max-width', this.$element.data('max-width') );
if( this.$element.data('position') ) this.menu.addClass( 'hs-position-' + this.$element.data('position') );
if( this.options.animationOut ) {
this.menu.on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(e) {
if(self.menu.hasClass(self.options.animationOut)) {
self.$element.removeClass(self.activeItemClass.slice(1));
self.options.afterClose.call(self, self.$element, self.menu);
}
if(self.menu.hasClass(self.options.animationIn)) {
self.options.afterOpen.call(self, self.$element, self.menu);
}
e.stopPropagation();
e.preventDefault();
});
}
}
/**
* Shows the mega-menu item.
*
* @public
* @return {MenuItem}
*/
MenuItem.prototype.show = function() {
if( !this.menu.length ) return this;
this.$element.addClass(this.activeItemClass.slice(1));
if(this.options.direction == 'horizontal') this.smartPosition( this.menu, this.options );
this._updateMenuBounds();
if(this.options.animationOut) {
this.menu.removeClass(this.options.animationOut);
}
else {
this.options.afterOpen.call(this, this.$element, this.menu);
}
if(this.options.animationIn) this.menu.addClass(this.options.animationIn);
return this;
}
/**
* Hides the mega-menu item.
*
* @public
* @return {MenuItem}
*/
MenuItem.prototype.hide = function() {
var self = this;
if( !this.menu.length ) return this;
if(!this.options.animationOut) {
this.$element.removeClass(this.activeItemClass.slice(1));
}
if(this.options.animationIn) this.menu.removeClass(this.options.animationIn);
if(this.options.animationOut) {
this.menu
.addClass(this.options.animationOut);
}
else{
this.options.afterClose.call(this, this.$element, this.menu);
}
return this;
}
/**
* Shows the mega-menu item.
*
* @public
* @return {MenuItem}
*/
MenuItem.prototype.mobileShow = function() {
var self = this;
if( !this.menu.length ) return this;
this.menu
.removeClass( this.options.animationIn )
.removeClass( this.options.animationOut )
.stop()
.slideDown({
duration: self.options.mobileSpeed,
easing: self.options.mobileEasing,
complete: function() {
self.options.afterOpen.call(self, self.$element, self.menu);
}
});
this.$element.addClass(this.activeItemClass.slice(1));
return this;
};
/**
* Hides the mega-menu item.
*
* @public
* @return {MenuItem}
*/
MenuItem.prototype.mobileHide = function() {
var self = this;
if( !this.menu.length ) return this;
this.menu.stop().slideUp({
duration: self.options.mobileSpeed,
easing: self.options.mobileEasing,
complete: function() {
self.options.afterClose.call(self, self.$element, self.menu);
}
});
this.$element.removeClass(this.activeItemClass.slice(1));
return this;
};
/**
* Check, if element is in viewport.
*
* @param {jQuery} element
* @param {Object} options
* @public
*/
MenuItem.prototype.smartPosition = function( element, options ) {
MenuItem.smartPosition(element, options);
};
/**
* Check, if element is in viewport.
*
* @param {jQuery} element
* @param {Object} options
* @static
* @public
*/
MenuItem.smartPosition = function( element, options ) {
if(!element && !element.length) return;
var $w = $(window);
element.removeClass('hs-reversed');
if(!options.rtl) {
if( element.offset().left + element.outerWidth() > $w.width() ) {
element.addClass('hs-reversed');
}
}
else {
if(element.offset().left < 0) {
element.addClass('hs-reversed');
}
}
};
/**
* Updates bounds of current opened menu.
*
* @private
*/
MenuItem.prototype._updateMenuBounds = function() {
var width = 'auto';
if( this.options.direction == 'vertical' && this.options.type == 'mega-menu' ) {
if( this.$container && this.$container.data('HSMegaMenu').getState() == 'desktop' ) {
if( !this.options.pageContainer.length ) this.options.pageContainer = $('body');
width = this.options.pageContainer.outerWidth() * (1 - this.options.sideBarRatio);
}
else {
width = 'auto';
}
this.menu.css({
'width': width,
'height': 'auto'
});
if( this.menu.outerHeight() > this.$container.outerHeight() ) {
return;
}
this.menu.css('height', '100%');
}
};
/**
* The jQuery plugin for the MegaMenu.
*
* @public
*/
$.fn.HSMegaMenu = function(options) {
return this.each(function(i, el) {
var $this = $(this);
if(!$this.data('HSMegaMenu')) {
$this.data('HSMegaMenu', new MegaMenu($this, options));
}
});
};
/**
* Helper function for detect touch events in the environment.
*
* @return {Boolean}
* @private
*/
function _isTouch() {
return ('ontouchstart' in window);
}
})(jQuery);