(function($) {
'use strict';
$(document).ready(function() {
/*-----------------------------------------------------------------------------------*/
/* Page Loader
/*-----------------------------------------------------------------------------------*/
if ( $( '.loader-page' ).length ) {
$('.loader-page').delay(600).fadeOut(1000);
}
/*-----------------------------------------------------------------------------------*/
/* Detect Mobile Browser
/*-----------------------------------------------------------------------------------*/
var mobileDetect = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
/*-----------------------------------------------------------------------------------*/
/* Home icon in main menu
/*-----------------------------------------------------------------------------------*/
$('.main-navigation .menu-item-home:first-child > a').prepend('');
/*-----------------------------------------------------------------------------------*/
/* Set nanoscroller
/*-----------------------------------------------------------------------------------*/
function setNano() {
if ( $( '#tertiary.widget-area' ).length ) {
$('.nano').nanoScroller({ preventPageScrolling: true });
}
}
setNano();
/*-----------------------------------------------------------------------------------*/
/* Sidebar Push Button
/*-----------------------------------------------------------------------------------*/
$('.hamburger, .opacityBox').click(function(){
$('body, .atracium-sidebar-button, .atracium-bar, .atracium-subbar').toggleClass('yesOpen');
$('.hamburger--spin').toggleClass('is-active');
if (mobileDetect) {
$('.opacityBox').toggleClass('yesOpen');
}
});
/*-----------------------------------------------------------------------------------*/
/* Search Button
/*-----------------------------------------------------------------------------------*/
$('.atracium-search-button .asbutton').click(function(){
if ($('.atracium-search-button').hasClass('searchOpen')) {
$('.atracium-search-button, .atracium-subbar').removeClass('searchOpen');
} else {
$('.atracium-search-button, .atracium-subbar').addClass('searchOpen');
if (!mobileDetect) {
$('.atracium-search-button .search-container .search-field').focus();
}
}
});
/*-----------------------------------------------------------------------------------*/
/* Menu Widget
/*-----------------------------------------------------------------------------------*/
if ( $( 'aside ul.menu' ).length ) {
$('aside ul.menu').find('li').each(function(){
if($(this).children('ul').length > 0){
$(this).append('');
}
});
$('aside ul.menu > li.menu-item-has-children .indicatorBar, .aside ul.menu > li.page_item_has_children .indicatorBar').click(function() {
$(this).parent().find('> ul.sub-menu, > ul.children').toggleClass('yesOpenBar');
$(this).toggleClass('yesOpenBar');
var $self = $(this).parent();
if($self.find('> ul.sub-menu, > ul.children').hasClass('yesOpenBar')) {
$self.find('> ul.sub-menu, > ul.children').slideDown(300);
} else {
$self.find('> ul.sub-menu, > ul.children').slideUp(200);
}
});
}
/*-----------------------------------------------------------------------------------*/
/* Fixed Menu to top
/*-----------------------------------------------------------------------------------*/
$( window ).scroll( function () {
var topmenu = $( '.front-page-menu' ).outerHeight();
if ( $( document ).scrollTop() > ( topmenu + 400 ) ) {
$( '.front-page-menu .navbar' ).addClass( 'navbar-inverse' );
} else {
$( '.front-page-menu .navbar' ).removeClass( 'navbar-inverse' );
}
} );
/*-----------------------------------------------------------------------------------*/
/* Change Header Height
/*-----------------------------------------------------------------------------------*/
var myHeader = $('.main-header'),
myIntro = $('.intro');
myHeader.height($(window).height() - 21);
myIntro.each(function () {
$(this).css('paddingTop', (($(window).height() - myIntro.height()) / 2) - 50 );
});
$('.page-header').each(function () {
$('.page-header .atraciumLogo p').css('marginLeft', (($(window).width() - myIntro.width()) / 2) - 50 );
$('.page-header .site-title').css('paddingTop', (($('.page-header').height() - $('.atraciumLogo').height()) / 2) );
});
/*-----------------------------------------------------------------------------------*/
/* Scroll To Features
/*-----------------------------------------------------------------------------------*/
$('.main-header .arrow i').click(function () {
$('html, body').animate({
scrollTop: $('.categories').offset().top
}, 1000);
});
/*-----------------------------------------------------------------------------------*/
/* Register Light Slider
/*-----------------------------------------------------------------------------------*/
$('#lightSlider').lightSlider({
item: 2
});
/*-----------------------------------------------------------------------------------*/
/* Scroll To Top
/*-----------------------------------------------------------------------------------*/
if (!mobileDetect || $('#toTop').hasClass('scrolltop_on') ) {
$(window).scroll(function(){
if ($(this).scrollTop() > 700) {
$('#toTop').addClass('visible');
}
else {
$('#toTop').removeClass('visible');
}
});
$('#toTop').click(function(){
$('html, body').animate({ scrollTop: 0 }, 1000);
return false;
});
}
/*-----------------------------------------------------------------------------------*/
/* Detect Mobile Browser
/*-----------------------------------------------------------------------------------*/
if (!mobileDetect) {
/*-----------------------------------------------------------------------------------*/
/* Effect for site branding
/*-----------------------------------------------------------------------------------*/
$( '.atraciumLogo' ).data( 'height', $( '.atraciumLogo' ).outerHeight() );
$( window ).scroll( function() {
var position = window.scrollY,
bottom = window.innerHeight - document.getElementById( 'colophon' ).offsetHeight,
height = $( '.atraciumLogo' ).data( 'height' ),
content = $( '#content' ).offset().top,
footer = $( '#colophon' ).offset().top - position;
if ( position > 0 && content > position && footer > bottom ) {
if ( position < height ) {
$('.atraciumLogo').css({
'opacity' : ( 1 - position / height / 1.5 )
});
}
} else if ( position <= 0 ) {
$('.atraciumLogo').css({
'opacity' : 1
});
}
});
}
});
})(jQuery);