/* ------------------------------------------ JS Main - RALPH HUTCHINGS ------------------------------------------- */ $( document ).ready(function() { // delegate calls to data-toggle="lightbox" $(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) { event.preventDefault(); return $(this).ekkoLightbox({ always_show_close: true }); }); $(document).ready(function(){ $(".owl-carousel").owlCarousel({ loop:true, margin:10, nav:true, pagination: false, responsive:{ 0:{ items:1 }, 600:{ items:1 }, 1000:{ items:1 } } }); }); $('.photo-grid-more-p0').cubeportfolio({ loadMore: '.js-loadMore-p0', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 3 }, { width: 320, cols: 3 }], }); $('.photo-grid-more-location').cubeportfolio({ loadMore: '.js-loadMore-p0', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 3 }, { width: 320, cols: 3 }], }); $('.photo-grid-more-p1').cubeportfolio({ loadMore: '.js-loadMore-p1', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 3 }, { width: 320, cols: 3 }], }); $('.photo-grid-more-p2').cubeportfolio({ loadMore: '.js-loadMore-p2', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 3 }, { width: 320, cols: 3 }], }); $('.photo-grid-more-p3').cubeportfolio({ loadMore: '.js-loadMore-p3', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 2 }, { width: 320, cols: 2 }], }); $('.photo-grid-more-p4').cubeportfolio({ loadMore: '.js-loadMore-p4', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 2 }, { width: 320, cols: 2 }], }); $('.photo-grid-more-p5').cubeportfolio({ loadMore: '.js-loadMore-p5', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 2 }, { width: 320, cols: 2 }], }); $('.photo-grid-more-p6').cubeportfolio({ loadMore: '.js-loadMore-p6', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 2 }, { width: 320, cols: 2 }], }); $('.photo-grid-more-p7').cubeportfolio({ loadMore: '.js-loadMore-p7', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 2 }, { width: 320, cols: 2 }], }); $('.photo-grid-more-p8').cubeportfolio({ loadMore: '.js-loadMore-p8', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 2 }, { width: 320, cols: 2 }], }); $('.photo-grid-more-p9').cubeportfolio({ loadMore: '.js-loadMore-p9', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 3 }, { width: 480, cols: 2 }, { width: 320, cols: 2 }], }); $('.photo-grid-more-p10').cubeportfolio({ loadMore: '.js-loadMore-p0', loadMoreAction: 'click', gapHorizontal: 0, gapVertical: 0, mediaQueries: [{ width: 1500, cols: 3 }, { width: 1100, cols: 3 }, { width: 800, cols: 2 }, { width: 480, cols: 1 }, { width: 320, cols: 1 }], }); $('#grid-container').cubeportfolio({ loadMore: '#js-loadMore-masonry-projects', loadMoreAction: 'click', mediaQueries: [{ width: 1500, cols: 4 }, { width: 1100, cols: 3 }, { width: 800, cols: 2 }, { width: 480, cols: 2 }, { width: 320, cols: 2 }], }); $('.overlay nav ul li').find('a').click(function(){ toggleOverlay(); var $href = $(this).attr('href'); var $anchor = $($href).offset(); //window.scrollTo($anchor.left,$anchor.top); $("html, body").delay(500).animate({scrollTop: $($href).offset().top }, 1000); return false; }); $('.book').find('a').click(function(){ var $href = $(this).attr('href'); var $anchor = $($href).offset(); //window.scrollTo($anchor.left,$anchor.top); $("html, body").delay(500).animate({scrollTop: $($href).offset().top }, 1000); return false; }); $('.content-floatter').find('a').click(function(){ var $href = $(this).attr('href'); var $anchor = $($href).offset(); //window.scrollTo($anchor.left,$anchor.top); $("html, body").delay(500).animate({scrollTop: $($href).offset().top }, 1000); return false; }); }); /* detect touch */ if("ontouchstart" in window){ document.documentElement.className = document.documentElement.className + " touch"; } if(!$("html").hasClass("touch")){ /* background fix */ $(".parallax").css("background-attachment", "fixed"); } /* fix vertical when not overflow call fullscreenFix() if .fullscreen content changes */ function fullscreenFix(){ var h = $('body').height(); // set .fullscreen height $(".content-b").each(function(i){ if($(this).innerHeight() > h){ $(this).closest(".fullscreen").addClass("overflow"); } }); } $(window).resize(fullscreenFix); fullscreenFix(); /* resize background images */ function backgroundResize(){ var windowH = $(window).height(); $(".background").each(function(i){ var path = $(this); // variables var contW = path.width(); var contH = path.height(); var imgW = path.attr("data-img-width"); var imgH = path.attr("data-img-height"); var ratio = imgW / imgH; // overflowing difference var diff = parseFloat(path.attr("data-diff")); diff = diff ? diff : 0; // remaining height to have fullscreen image only on parallax var remainingH = 0; if(path.hasClass("parallax") && !$("html").hasClass("touch")){ var maxH = contH > windowH ? contH : windowH; remainingH = windowH - contH; } // set img values depending on cont imgH = contH + remainingH + diff; imgW = imgH * ratio; // fix when too large if(contW > imgW){ imgW = contW; imgH = imgW / ratio; } // path.data("resized-imgW", imgW); path.data("resized-imgH", imgH); path.css("background-size", imgW + "px " + imgH + "px"); }); } $(window).resize(backgroundResize); $(window).focus(backgroundResize); backgroundResize(); /* set parallax background-position */ function parallaxPosition(e){ var heightWindow = $(window).height(); var topWindow = $(window).scrollTop(); var bottomWindow = topWindow + heightWindow; var currentWindow = (topWindow + bottomWindow) / 2; $(".parallax").each(function(i){ var path = $(this); var height = path.height(); var top = path.offset().top; var bottom = top + height; // only when in range if(bottomWindow > top && topWindow < bottom){ var imgW = path.data("resized-imgW"); var imgH = path.data("resized-imgH"); // min when image touch top of window var min = 0; // max when image touch bottom of window var max = - imgH + heightWindow; // overflow changes parallax var overflowH = height < heightWindow ? imgH - height : imgH - heightWindow; // fix height on overflow top = top - overflowH; bottom = bottom + overflowH; // value with linear interpolation var value = min + (max - min) * (currentWindow - top) / (bottom - top); // set background-position var orizontalPosition = path.attr("data-oriz-pos"); orizontalPosition = orizontalPosition ? orizontalPosition : "50%"; $(this).css("background-position", orizontalPosition + " " + value + "px"); } }); } if(!$("html").hasClass("touch")){ $(window).resize(parallaxPosition); //$(window).focus(parallaxPosition); $(window).scroll(parallaxPosition); parallaxPosition(); } var triggerBttn = document.getElementById( 'trigger-overlay' ); var overlay = document.querySelector( 'div.overlay' ); var closeBttn = overlay.querySelector( 'button.overlay-close' ); transEndEventNames = { 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd', 'msTransition': 'MSTransitionEnd', 'transition': 'transitionend' }, transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ], support = { transitions : Modernizr.csstransitions }; function toggleOverlay() { if( classie.has( overlay, 'open' ) ) { classie.remove( overlay, 'open' ); classie.add( overlay, 'close' ); var onEndTransitionFn = function( ev ) { if( support.transitions ) { if( ev.propertyName !== 'visibility' ) return; this.removeEventListener( transEndEventName, onEndTransitionFn ); } classie.remove( overlay, 'close' ); }; if( support.transitions ) { overlay.addEventListener( transEndEventName, onEndTransitionFn ); } else { onEndTransitionFn(); } } else if( !classie.has( overlay, 'close' ) ) { classie.add( overlay, 'open' ); } } triggerBttn.addEventListener( 'click', toggleOverlay ); closeBttn.addEventListener( 'click', toggleOverlay );