/* from http://www.sitepoint.com/javascript-generate-lighter-darker-color/ */ function ColorLuminance( hex, lum ) { // validate hex string hex = String( hex ).replace( /[^0-9a-f]/gi, '' ); if ( hex.length < 6 ) { hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; } lum = lum || 0; // convert to decimal and change luminosity var rgb = "#", c, i; for ( i = 0; i < 3; i++ ) { c = parseInt( hex.substr( i * 2, 2 ), 16 ); c = Math.round( Math.min( Math.max( 0, c + (c * lum) ), 255 ) ).toString( 16 ); rgb += ("00" + c).substr( c.length ); } return rgb; } // make masonry blog items the same height function fixMasonryHeight() { jQuery( '.blog-item-masonry .blog-item-inner' ).height('auto'); // applies only for larger displays if ( jQuery( window ).width() >= 768 ) { var maxHeight = 0; jQuery( '.blog-item-masonry .blog-item-inner' ).each( function () { var $height = jQuery( this ).outerHeight() + 3; if ( $height > maxHeight ) { maxHeight = $height; } } ); jQuery( '.blog-item-masonry .blog-item-inner' ).height( maxHeight ); } } // make menu dropdowns hover on mouse over jQuery( '[data-toggle="dropdown"]' ).bootstrapDropdownHover( { clickBehavior: 'default', hideTimeout: 50 } ); // detect high density (retina) display function isHighDensity() { return ((window.matchMedia && (window.matchMedia( 'only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)' ).matches || window.matchMedia( 'only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)' ).matches)) || (window.devicePixelRatio && window.devicePixelRatio > 1.3)); } jQuery( document ).ready( function () { jQuery( '#nav' ).affix( { offset: { top: Math.max( jQuery( '#blog-category' ).height() - 50, 200 ) } } ); // Pretty Photo jQuery( 'a[data-gal]' ).each( function () { jQuery( this ).attr( 'rel', jQuery( this ).data( 'gal' ) ); } ); jQuery( "a[data-rel^='prettyPhoto']" ).prettyPhoto( {animationSpeed: 'slow', theme: 'light_square', slideshow: false, overlay_gallery: false, social_tools: false, deeplinking: false, show_title: true} ); // PARALLAX, see http://code.tutsplus.com/tutorials/a-simple-parallax-scrolling-technique--net-27641 //var isMobile = window.matchMedia("only screen and (max-width: 760px)"); if (!isMobile.matches) { var $window = jQuery( window ); //You forgot this line in the above example jQuery( 'div[data-type="background"], section[data-type="background"]' ).each( function () { var $bgobj = jQuery( this ); // assigning the object jQuery( window ).scroll( function () { var yPos = -($window.scrollTop() / $bgobj.data( 'speed' )); // Put together our final background position var coords = '50% ' + yPos + 'px'; // Move the background $bgobj.css( {backgroundPosition: coords} ); } ); } ); } // Init Skrollr var s = skrollr.init( { forceHeight: false, render: function ( data ) { //Debugging - Log the current scroll position. //console.log(data.curTop); } } ); // ISOTOPE /* activate jquery isotope */ var $container = jQuery( '.portfolio-items' ).isotope( { itemSelector: '.item', masonry: { columnWidth: '.col-sm-3' } } ); // bind filter button click jQuery( '.filters-group' ).on( 'click', 'a', function () { var filterValue = jQuery( this ).attr( 'data-filter' ); // use filterFn if matches value jQuery( '.portfolio-items' ).isotope( {filter: filterValue} ); } ); fixMasonryHeight(); } ); jQuery(window).resize(function() { fixMasonryHeight(); }); jQuery( window ).on( "debouncedresize", function ( event ) { jQuery( '.portfolio-items' ).isotope( { itemSelector: '.item', masonry: { columnWidth: '.col-sm-3' } } ); } ); jQuery( window ).load( function () { jQuery( '.portfolio-items' ).isotope( { itemSelector: '.item', masonry: { columnWidth: '.col-sm-3' } } ); } ); // TESTIMONIALS _ FLICKITY jQuery( '.testimonials .testimonials-content' ).flickity( { wrapAround: true, pageDots: true, prevNextButtons: false, autoPlay: 5000 } );