/*------------------------------------------------------------------ project: gonex - html onepage theme version: 1.0 last change: 14/07/2017 author: graphberry url: # license: #/pages/license -------------------------------------------------------------------*/ var $j = jquery.noconflict(true); $j(function(){ 'use strict'; /*-------------------------------------------------- scrollspy bootstrap ---------------------------------------------------*/ $j('body').scrollspy({ target: '#header', offset: 85 }); /*-------------------------------------------------- smooth scroll ---------------------------------------------------*/ smoothscroll.init({ selector: '.smoothscroll', speed: 1000, offset: 85, before: function(anchor, toggle){ // check if mobile navigation is active var query = modernizr.mq('(max-width: 767px)'); // check if element is navigation eelement var navitem = $j(toggle).parents("#main-navbar").length; // if mobile nav & nav item then close nav if (query && navitem !== 0) { $j("button.navbar-toggle").click(); } } }); /*-------------------------------------------------- search toggle ---------------------------------------------------*/ $j('#btn-togglesearch').click(function(){ $j(this).find('.ico-search-icon').toggleclass('text-green') $j('#search-input').toggleclass('search-active'); $j('#search-input>input').focus(); }); /*-------------------------------------------------- mixitup ---------------------------------------------------*/ var mixer = mixitup('#works-grid', { selectors: { control: '[data-mixitup-control]' } }); /*-------------------------------------------------- works gallery: grid and image calculation ---------------------------------------------------*/ var calcgrid = function() { var querymedium = modernizr.mq('(min-width: 992px)'); var querysmall = modernizr.mq('(min-width: 480px)'); var windowwidth = ($j('.grid').width()); var itemheight2 = (windowwidth/100)*30; var itemheight = itemheight2/2; if(querymedium) { $j('.grid-item').height(itemheight); $j('.grid-item.-height2').height(itemheight2); } else if(querysmall) { $j('.grid-item').height(windowwidth/2); $j('.grid-item.-height2').height(windowwidth/2); } else { $j('.grid-item').height(windowwidth); $j('.grid-item.-height2').height(windowwidth); } } var calcimg = function () { $j(".grid-item>img").each(function(i, img) { // reset to default // on window resize $j(img).css({ width: '100%', height: 'auto', marginleft: 0 }); if($j(img).height() < $j(img).parent().height()) { $j(img).css({ height: '100%', width: 'auto', marginleft: function(){ return (($j(img).parent().width() - $j(img).width()) / 2) } }); } }); } calcgrid(); $j.when(calcgrid).then(calcimg); // change gallery layout on window resize $j(window).on("resize", function(){ calcgrid(); $j.when(calcgrid).then(calcimg); }); /*-------------------------------------------------- current year ---------------------------------------------------*/ // automatically update copyright year in the footer var currenttime = new date(); var year = currenttime.getfullyear(); $j("#year").text(year); /*-------------------------------------------------- bootstrap modal google map ---------------------------------------------------*/ $j("#map-modal").one("shown.bs.modal", function () { initmap(); }); });