/* ---------------------------------- */ /* * TABLE OF CONTENTS * * @Initialize * @Events * @AutoInstantiate * @Omniture * @ProofPoints * @Line * @Scrollable * @Stories * @MainNav * @Counter * @SiteScroll * @TargetBlank * @Keyboard * @Worker Methods * */ /* ---------------------------------- */ /* Initialize */ jQuery ( function ($) { $.Body = $('body'); $.Window = $(window); // $.Scroll = ($.browser.mozilla || $.browser.msie) ? $('html') : $.Body; $.Scroll = $.Body; $.Mobile = ($.Body.hasClass('webkit-mobile') || (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))), $.Unsupported = $.Body.hasClass('unsupported-browser'); // $.Body // .Keyboard() // .Omniture(); // $('[data-controller]').Instantiate(); // Draw Lines // Bug with IE canvas implementation requires onload // if ($.browser.msie) // $(window).bind('load',function(){$('[data-canvasline]').Line();}) // else // $('[data-canvasline]').Line(); // $('[data-target=_blank]').TargetBlank(); $.Window.bind('scroll',verticalParallax); $('#mainmenu a').bind('click', function(e){ $.Body.triggerHandler($.Events.SCROLL_TO,$.Window) //e.preventDefault(); }); } //})(jQuery ); (function($) { $.Events = { OMNITURE_TRACK: 'omnitureTrack', OMNITURE_TRACK_LINK: 'omnitureTrackLink', SECTION_ENTER: 'sectionEnter', SCROLL_TO: 'scrollTo', SCROLL: 'windowScroll', SCROLL_ENTER: 'windowScrollEnter', SCROLL_LEAVE: 'windwScrollLeave', KEY_UP: 'keyUp', KEY_DOWN: 'keyDown', KEY_LEFT: 'keyLeft', KEY_RIGHT: 'keyRight', KEY_ESC: 'keyEsc', KEY_SPACE: 'keySpace', PROOF_POINT: 'proofPointMore' } // Events $.Views = { } // Views getPageScroll = function() { var yScroll; if (self.pageYOffset) { yScroll = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { yScroll = document.documentElement.scrollTop; } else if (document.body) { yScroll = document.body.scrollTop; } return yScroll; } vertParallax = function(item){ var windowScrollY = getPageScroll(); var pp = item.position(); //if((windowScrollY) >= item.position().top){ var tmp = Math.round(parseInt(item.attr('y')) - (windowScrollY - parseInt(item.attr('top'))) * parseFloat(item.attr('friction'))); var _x = '25% ' var bpos = _x + (tmp) + 'px'; item.css({'backgroundPosition':bpos, 'top': tmp}); //} } activeMenu = function(item){ var windowScrollY = getPageScroll(); var pp = item.position(); if((windowScrollY) >= item.position().top && windowScrollY < (item.position().top+parseInt(item.attr('h')))){ $("#mainmenu ."+item.attr('id')).addClass('active'); }else{ $("#mainmenu ."+item.attr('id')).removeClass('active'); } } verticalParallax = function(e){ $("#home_bg, #home_img, #home_decor, #home_content, #wedding_bg, #wedding_img, #wedding_decor, #wedding_content, #eventi_bg, #eventi_img, #eventi_decor, #eventi_content").each(function(){ //#contact_bg, #contact_img, #contact_decor, #contact_content vertParallax($(this)); }); $("#home,#wedding, #eventi, #contact").each(function(){ activeMenu($(this)); }); }; })(jQuery); jQuery(document).ready(function() { // parallax jQuery("#home_bg, #home_img, #home_decor, #home_content, #wedding_bg, #wedding_img, #wedding_decor, #wedding_content, #eventi_bg, #eventi_img, #eventi_decor, #eventi_content").each(function(){ //#contact_bg, #contact_img, #contact_decor, #contact_content jQuery(this).attr('top', parseInt(jQuery(this).css('top'))); //$(this).attr('y', parseInt($(this).position().top)); jQuery(this).attr('y', 0); jQuery(this).attr('friction', parseFloat(jQuery(this).attr("data-friction"))); }); jQuery("#home,#wedding, #eventi, #contact, #c6971").each(function(){ jQuery(this).attr('h', parseInt(jQuery(this).css('height'))); }); function filterPath(string) { return string .replace(/^\//,'') .replace(/(index|default).[a-zA-Z]{3,4}$/,'') .replace(/\/$/,''); } var j_mac = jQuery.noConflict(); j_mac('a[href*=#]').bind('click', function(e) { var target = j_mac(this).attr("href"); //Get the target t_mac = filterPath(target); //alert(t_mac); e.preventDefault(); //prevent the "normal" behaviour which would be a "hard" jump var thisPath = filterPath(this.pathname) || filterPath(location.pathname); j_mac('html, body').stop().animate({ scrollTop: j_mac(t_mac).offset().top }, 4000, function() { //location.hash = t_mac; }); return false; }); return false; });