jQuery(document).ready(function(){ /* ---------------------------------------------------------------------- */ /* FlexSlider /* ---------------------------------------------------------------------- */ // $('.flexslider').flexslider({ // animation: "slide", // controlNav: false, // slideshow: true, //Boolean: Animate slider automatically // slideshowSpeed: 5000, //Integer: Set the speed of the slideshow cycling, in milliseconds // itemWidth: 1000, //{NEW} Integer: Box-model width of individual carousel items, including horizontal borders and padding. // itemMargin: 0 //{NEW} Integer: Margin between carousel items. // }); // fancyBox $("a.fancybox").attr("rel", "gallery"); $('.fancybox').fancybox(); $("a.fancyboxGalleria").attr("rel", "gallery"); $('.fancyboxGalleria').fancybox(); $('a.fancyboxyoutube').on('click', function(event) { event.preventDefault(); $.fancybox({ 'type' : 'iframe', // hide the related video suggestions and autoplay the video 'href' : this.href.replace(new RegExp('watch\\?v=', 'i'), 'embed/') + '?rel=0&autoplay=1', 'overlayShow' : true, 'centerOnScroll' : true, 'speedIn' : 100, 'speedOut' : 50, 'width' : 640, 'height' : 480 }); }); }); $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) { // Avoid following the href location when clicking event.preventDefault(); // Avoid having the menu to close when clicking event.stopPropagation(); // If a menu is already open we close it //$('ul.dropdown-menu [data-toggle=dropdown]').parent().removeClass('open'); // opening the one you clicked on $(this).parent().addClass('open'); var menu = $(this).parent().find("ul"); var menupos = menu.offset(); if ((menupos.left + menu.width()) + 30 > $(window).width()) { var newpos = - menu.width(); } else { var newpos = $(this).parent().width(); } menu.css({ left:newpos }); }); function parallax() { var scrollPosition = $(window).scrollTop(); $('#parallax').css('top',(0 - (scrollPosition * 0.3))+'px' ); // bg image moves at 30% of scrolling speed $('#parallax2').css('top',(0 - (scrollPosition * 0.3))+'px' ); // bg image moves at 30% of scrolling speed $('#parallax3').css('top',(0 - (scrollPosition * 0.3))+'px' ); // bg image moves at 30% of scrolling speed $('#parallax4').css('top',(0 - (scrollPosition * 0.3))+'px' ); // bg image moves at 30% of scrolling speed } (function($) { $.fn.parallax01 = function(options) { var windowHeight = $(window).height(); // Establish default settings var settings = $.extend({ speed : 0.15 }, options); // Iterate over each object in collection return this.each( function() { // Save a reference to the element var $this = $(this); // Set up Scroll Handler $(document).scroll(function(){ var scrollTop = $(window).scrollTop(); var offset = $this.offset().top; var height = $this.outerHeight(); // Check if above or below viewport if (offset + height <= scrollTop || offset >= scrollTop + windowHeight) { return; } var yBgPosition = Math.round((offset - scrollTop) * settings.speed); // Apply the Y Background Position to Set the Parallax Effect $this.css('background-position', 'center ' + yBgPosition + 'px'); }); }); } }(jQuery)); $(document).ready(function () { /* Parallax Background ================================================== */ $(window).on('scroll', function (e) { parallax(); }); $('#parrallax2').parallax01({ speed : 0.30 }); $('#parrallax3').parallax01({ speed : 0.30 }); $('#parrallax4').parallax01({ speed : 0.30 }); });