/* Hielo by TEMPLATED templated.co @templatedco Released for free under the Creative Commons Attribution 3.0 license (templated.co/license) */ var settings = { banner: { // Indicators (= the clickable dots at the bottom). indicators: true, // Transition speed (in ms) // For timing purposes only. It *must* match the transition speed of "#banner > article". speed: 1500, // Transition delay (in ms) delay: 5000, // Parallax intensity (between 0 and 1; higher = more intense, lower = less intense; 0 = off) parallax: 0. } }; (function($) { skel.breakpoints({ xlarge: '(max-width: 1680px)', large: '(max-width: 1280px)', medium: '(max-width: 980px)', small: '(max-width: 736px)', xsmall: '(max-width: 480px)' }); /** * Applies parallax scrolling to an element's background image. * @return {jQuery} jQuery object. */ $.fn._parallax = (skel.vars.browser == 'ie' || skel.vars.mobile) ? function() { return $(this) } : function(intensity) { var $window = $(window), $this = $(this); if (this.length == 0 || intensity === 0) return $this; if (this.length > 1) { for (var i=0; i < this.length; i++) $(this[i])._parallax(intensity); return $this; } if (!intensity) intensity = 0.25; $this.each(function() { var $t = $(this), on, off; on = function() { $t.css('background-position', 'center 100%, center 100%, center 0px'); $window .on('scroll._parallax', function() { var pos = parseInt($window.scrollTop()) - parseInt($t.position().top); $t.css('background-position', 'center ' + (pos * (-1 * intensity)) + 'px'); }); }; off = function() { $t .css('background-position', ''); $window .off('scroll._parallax'); }; skel.on('change', function() { if (skel.breakpoint('medium').active) (off)(); else (on)(); }); }); $window .off('load._parallax resize._parallax') .on('load._parallax resize._parallax', function() { $window.trigger('scroll'); }); return $(this); }; /** * Custom banner slider for Slate. * @return {jQuery} jQuery object. */ $.fn._slider = function(options) { var $window = $(window), $this = $(this); if (this.length == 0) return $this; if (this.length > 1) { for (var i=0; i < this.length; i++) $(this[i])._slider(options); return $this; } // Vars. var current = 0, pos = 0, lastPos = 0, slides = [], indicators = [], $indicators, $slides = $this.children('article'), intervalId, isLocked = false, i = 0; // Turn off indicators if we only have one slide. if ($slides.length == 1) options.indicators = false; // Functions. $this._switchTo = function(x, stop) { if (isLocked || pos == x) return; isLocked = true; if (stop) window.clearInterval(intervalId); // Update positions. lastPos = pos; pos = x; // Hide last slide. slides[lastPos].removeClass('top'); if (options.indicators) indicators[lastPos].removeClass('visible'); // Show new slide. slides[pos].addClass('visible').addClass('top'); if (options.indicators) indicators[pos].addClass('visible'); // Finish hiding last slide after a short delay. window.setTimeout(function() { slides[lastPos].addClass('instant').removeClass('visible'); window.setTimeout(function() { slides[lastPos].removeClass('instant'); isLocked = false; }, 100); }, options.speed); }; // Indicators. if (options.indicators) $indicators = $('