/* ---------------------------------------------- /* * preloader /* ---------------------------------------------- */ (function(){ jquery(document).ready(function() { /* ---------------------------------------------- /* * scroll top /* ---------------------------------------------- */ jquery(window).scroll(function() { if (jquery(this).scrolltop() > 100) { jquery('.scroll-up').fadein(); } else { jquery('.scroll-up').fadeout(); } }); jquery('.scroll-up').click(function () { jquery("html, body").animate({ scrolltop: 0 }, 700); return false; }); /* ---------------------------------------------- /* * initialization general scripts for all pages /* ---------------------------------------------- */ var homesection = jquery('.home-section'), navbar = jquery('.navbar-custom'), navheight = navbar.height(), // worksgrid = jquery('#works-grid'), width = math.max(jquery(window).width(), window.innerwidth), mobiletest = false; if(/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.useragent)) { mobiletest = true; } document.onload = my_function(); spicepress_buildhomesection(homesection); spicepress_navbaranimation(navbar, homesection, navheight); spicepress_navbarsubmenu(width); spicepress_hoverdropdown(width, mobiletest); jquery(window).resize(function() { var width = math.max(jquery(window).width(), window.innerwidth); spicepress_buildhomesection(homesection); spicepress_hoverdropdown(width, mobiletest); }); function my_function () { jquery('.dropdown-menu').parent().addclass('dropdown'); jquery('li.dropdown').find('a:first').addclass('dropdown-toggle'); // jquery('li.dropdown').find('a:first').after( "" ); } /* ---------------------------------------------- /* * home section height /* ---------------------------------------------- */ function spicepress_buildhomesection(homesection) { if (homesection.length > 0) { if (homesection.hasclass('home-full-height')) { homesection.height(jquery(window).height()); } else { homesection.height(jquery(window).height() * 0.85); } } } /* ---------------------------------------------- /* * transparent navbar animation /* ---------------------------------------------- */ function spicepress_navbaranimation(navbar, homesection, navheight) { var topscroll = jquery(window).scrolltop(); if (navbar.length > 0 && homesection.length > 0) { if(topscroll >= navheight) { navbar.removeclass('navbar-transparent'); } else { navbar.addclass('navbar-transparent'); } } } /* ---------------------------------------------- /* * navbar submenu /* ---------------------------------------------- */ function spicepress_navbarsubmenu(width) { if (width > breakpoint_settings.menu_breakpoint) { jquery('.navbar-custom .navbar-nav > li.dropdown').hover(function() { var menuleftoffset = jquery('.dropdown-menu', jquery(this)).offset().left; var menu1levelwidth = jquery('.dropdown-menu', jquery(this)).width(); if (width - menuleftoffset < menu1levelwidth * 2) { jquery(this).children('.dropdown-menu').addclass('leftauto'); } else { jquery(this).children('.dropdown-menu').removeclass('leftauto'); } if (jquery('.dropdown', jquery(this)).length > 0) { var menu2levelwidth = jquery('.dropdown-menu', jquery(this)).width(); if (width - menuleftoffset - menu1levelwidth < menu2levelwidth) { jquery(this).children('.dropdown-menu').addclass('left-side'); } else { jquery(this).children('.dropdown-menu').removeclass('left-side'); } } }); jquery('.navbar-custom .navbar-nav > li.dropdown a.dropdown-toggle').focus(function() { var menuleftoffsets = jquery('.dropdown-menu', jquery(this).parent()).offset().left; var menu1levelwidth = jquery('.dropdown-menu', jquery(this).parent()).width(); if (width - menuleftoffsets < menu1levelwidth * 2) { jquery(this).parent().children('.dropdown-menu').addclass('leftauto'); } else { jquery(this).parent().children('.dropdown-menu').removeclass('leftauto'); } if (jquery('.dropdown', jquery(this).parent()).length > 0) { var menu2levelwidth = jquery('.dropdown-menu', jquery(this).parent()).width(); if (width - menuleftoffsets - menu1levelwidth < menu2levelwidth) { jquery(this).parent().children('.dropdown-menu').addclass('left-side'); } else { jquery(this).parent().children('.dropdown-menu').removeclass('left-side'); } } }); } } /* ---------------------------------------------- /* * navbar hover dropdown on desctop /* ---------------------------------------------- */ function spicepress_hoverdropdown(width, mobiletest) { if ((width > breakpoint_settings.menu_breakpoint) && (mobiletest !== true)) { jquery('.navbar-custom').removeclass('open'); var delay = 0; var settimeoutconst; jquery('.navbar-custom .navbar-nav > li.dropdown, .navbar-custom li.dropdown > ul > li.dropdown').hover(function() { var jquerythis = jquery(this); settimeoutconst = settimeout(function() { jquerythis.addclass('open'); jquerythis.find('.dropdown-toggle').addclass('disabled'); }, delay); }, function() { cleartimeout(settimeoutconst); jquery(this).removeclass('open'); jquery(this).find('.dropdown-toggle').removeclass('disabled'); }); } else { jquery('.navbar-custom .navbar-nav > li.dropdown, .navbar-custom li.dropdown > ul > li.dropdown').unbind('mouseenter mouseleave'); jquery('.navbar-custom [data-toggle=dropdown]').not('.binded').addclass('binded').on('click', function(event) { event.preventdefault(); event.stoppropagation(); jquery(this).parent().siblings().removeclass('open'); jquery(this).parent().siblings().find('[data-toggle=dropdown]').parent().removeclass('open'); jquery(this).parent().toggleclass('open'); }); } } /* ---------------------------------------------- /* * navbar collapse on click /* ---------------------------------------------- */ jquery(document).on('click','.navbar-collapse.in',function(e) { if( jquery(e.target).is('a') && jquery(e.target).attr('class') != 'dropdown-toggle' ) { jquery(this).collapse('hide'); } }); if( jquery(window).width() > breakpoint_settings.menu_breakpoint) { jquery('.nav li.dropdown').hover(function() { if( jquery(window).width() > 1100) { jquery('.dropdown-menu').removeattr("style"); } jquery(this).addclass('open'); }, function() { jquery(this).removeclass('open'); }); jquery('.nav li.dropdown-submenu').hover(function() { jquery(this).addclass('open'); }, function() { jquery(this).removeclass('open'); }); } jquery('li.dropdown').find('.fa-angle-down').each(function(){ jquery(this).on('click', function(){ if( jquery(window).width() < breakpoint_settings.menu_breakpoint) { jquery(this).parent().next().slidetoggle(); } return false; }); }); /* ---------------------------------------------- /* * navbar focus dropdown on desktop /* ---------------------------------------------- */ const toplevellinks = array.prototype.slice.call(document.queryselectorall(".navbar-custom .navbar-nav > li.dropdown a.dropdown-toggle"), 0); toplevellinks.foreach(function(link){ return link.addeventlistener('focus', function(e) { this.parentelement.classlist.add('open') e.preventdefault(); var div_list = e.target.parentelement.queryselectorall( ".open" ); var div_array = array.prototype.slice.call(div_list); div_array.foreach(function(e){ return e.classlist.remove( "open" ) }); }) }) jquery('li a').focus(function() { jquery(this).parent().siblings().removeclass('open'); jquery(this).parent().siblings().find(".open").removeclass('open'); }); jquery('a,input').bind('focus', function() { if(!jquery(this).closest(".menu-item").length ) { toplevellinks.foreach(function(link){ return link.parentelement.classlist.remove('open') }) } }) if(jquery(window).width() >= breakpoint_settings.menu_breakpoint){ //for header fix jquery(window).bind('scroll', function () { if (jquery(window).scrolltop() > 100) { jquery('.navbar-overlapped.navbar-custom').addclass('stiky-header'); } else { jquery('.navbar-overlapped.navbar-custom').removeclass('stiky-header'); } }); } jquery('li.dropdown').find('.caret').each(function(){ jquery(this).on('click', function(){ if( jquery(window).width() <= breakpoint_settings.menu_breakpoint) { jquery('li.dropdown,li.dropdown-submenu').removeclass('open'); jquery(this).parent().next().slidetoggle(); } return false; }); }); jquery('a,input').bind('focus', function() { if(!jquery(this).closest(".menu-item").length && ( jquery(window).width() <= breakpoint_settings.menu_breakpoint) ) { jquery('.navbar-collapse').removeclass('in'); } }) }); })(jquery);