jQuery(document).ready(function( $ ) { $('#social-icons li a, .portfolio-navigation a, .blog-navigation a, .flickr_badge_image a img').tooltip() jQuery('ul.topmenu').ProgressHeaderMenu({}); jQuery(document).ProgressMenuHover({}); jQuery('a.mobile-menu-btn').ProgressMobileMenuToggle({}); jQuery('ul.tablet-menu li.menu-parent-item > a').ProgressTabletSubmenuClose(); /*-----------------------------------------------------------------------------------*/ /* Image Hoverlay /*-----------------------------------------------------------------------------------*/ itemOverlay=function(){ $(".entry_image, .portfolio-item a, .related-projects a, .portfolio-widget .post_image").hover(function() { $(this).find('.item-overlay').stop().animate({opacity: 'show'}, 400); }, function() { $(this).find('.item-overlay').stop().animate({opacity: 'hide'}, 400); }); }; itemOverlay(); /*-----------------------------------------------------------------------------------*/ /* Siblings Fader /*-----------------------------------------------------------------------------------*/ siblingsFader=function(){ $(".flickr_badge_image, .posts-widget li").hover(function() { $(this).siblings().stop().fadeTo(400,0.5); }, function() { $(this).siblings().stop().fadeTo(400,1); }); }; siblingsFader(); /*-----------------------------------------------------------------------------------*/ /* To Top Button /*-----------------------------------------------------------------------------------*/ function tdl_scroll_to_top() { var windowWidth = $(window).width(), didScroll = false; if( windowWidth > 992 ) { var $freeride = $('#back-to-top'); $freeride.click(function(e) { $('body,html').animate({ scrollTop: "0" }); e.preventDefault(); }) $(window).scroll(function() { didScroll = true; }); setInterval(function() { if( didScroll ) { didScroll = false; if( $(window).scrollTop() > 200 ) { $freeride.css('display', 'block'); } else { $freeride.css('display', 'none'); } } }, 250); } } tdl_scroll_to_top(); /*-----------------------------------------------------------------------------------*/ /* Drop-down Page /*-----------------------------------------------------------------------------------*/ var $dropDownWrapper = $( '#dropdown-wrapper' ); if ( $dropDownWrapper.length ) { $('#dropdown-trigger').click(function() { var pageHeight = $('.dropdown-page').height() + 60; // Get the height, while including the top and bottom padding of the drop-down page var wrapperHeight = $dropDownWrapper.height(); // Animate the height of the wrapper, depending on the current state (visible or not) if( wrapperHeight == 0 ) { $('#dropdown-trigger span').removeClass("drop-down-arrows-bottom"); $('#dropdown-trigger span').addClass("drop-down-arrows-top"); $dropDownWrapper.animate( { height: pageHeight }, 700, 'easeOutCubic', function() { $(this).css('height', 'auto'); }); } else { $('#dropdown-trigger span').removeClass("drop-down-arrows-top"); $('#dropdown-trigger span').addClass("drop-down-arrows-bottom"); $dropDownWrapper.animate( { height: 0 }, 500, 'easeOutCubic' ); } $( 'body, html' ).animate({ scrollTop: 0 }, 200, 'easeOutCubic' ); }); } /*-----------------------------------------------------------------------------------*/ /* Ajax Portfolio /*-----------------------------------------------------------------------------------*/ var portfolioRevealer = $('#portfolio-revealer'); var portfoliourl = portfolioRevealer.attr('data-loader'); var portfolioItems = $('.ajax-portfolio .portfolio-item'); $('.ajax-portfolio .portfolio-item a .portfolio-image, .ajax-portfolio .portfolio-item a .portfolio-desc').click( function(e) { if( !$(this).parent().parent().hasClass('portfolio-revealed') ) { portfolioItems.removeClass('portfolio-revealed'); portfolioRevealer.css({ overflow: 'hidden' }); $(this).parent().parent().addClass('portfolio-revealed'); var portPostId = $(this).parent().parent().attr('id').split('portfolio-')[1]; initiatePortfolio(portPostId); } e.preventDefault(); }); function newNextPrev(portPostId) { var portNext = getNextPortfolio(portPostId); var portPrev = getPrevPortfolio(portPostId); $('#next-portfolio').attr('data-id', portNext); $('#prev-portfolio').attr('data-id', portPrev); } function initiatePortfolio(portPostId, getIt) { if(!getIt) { getIt = false; } var portNext = getNextPortfolio(portPostId); var portPrev = getPrevPortfolio(portPostId); if(getIt == false) { var portfolioLoader = $('#portfolio-loader'); portfolioLoader.fadeIn(200); closeRevealer(); portfolioRevealer.find('.portfolio-reveal-wrap').load(portfoliourl, { portid: portPostId, portnext: portNext, portprev: portPrev }, function() { initializePortfolio(); $(".vcontainer").fitVids(); openRevealer(); portfolioLoader.fadeOut(200); }); } if($().scrollTo) { jQuery.scrollTo('#portfolio-revealer', 400, {offset:-50}); } } function closeRevealer() { if( portfolioRevealer.height() != 0 ) { portfolioRevealer.find('.portfolio-reveal-wrapper').stop(true).animate({ opacity: 0 }, 200); portfolioRevealer.css({ overflow: 'hidden' }); portfolioRevealer.stop(true).animate({ height: 0 }, 500, 'easeOutCubic'); portfolioRevealer.find('#portfolio-slider').remove(); portfolioRevealer.css({ overflow: 'hidden' }); } } function openRevealer() { portfolioRevealer.stop(true).animate({ height: portfolioRevealer.find('#portfolio-reveal').outerHeight() }, 650, 'easeOutCubic', function () { portfolioRevealer.css({ height: 'auto' }); portfolioRevealer.css({ overflow: 'visible' }); }); } function getNextPortfolio(portPostId) { var portNext = $('#portfolio .portfolio-item').first().attr('id').split('portfolio-')[1]; var hasNext = $('#portfolio-' + portPostId).next(); if(hasNext.length != 0) { while( hasNext.hasClass('portfolio-item') == false && hasNext.length != 0 ) { hasNext = hasNext.next(); } if(hasNext.length != 0) { var portNext = hasNext.attr('id').split('portfolio-')[1]; } } return portNext; } function getPrevPortfolio(portPostId) { var portPrev = jQuery('#portfolio .portfolio-item').last().attr('id').split('portfolio-')[1]; var hasPrev = jQuery('#portfolio-' + portPostId).prev(); if(hasPrev.length != 0) { while( hasPrev.hasClass('portfolio-item') == false && hasPrev.length != 0 ) { hasPrev = hasPrev.prev(); } if(hasPrev.length != 0) { var portPrev = hasPrev.attr('id').split('portfolio-')[1]; } } return portPrev; } function initializePortfolio() { $('#next-portfolio, #prev-portfolio').click( function() { var portPostId = $(this).attr('data-id'); portfolioItems.removeClass('portfolio-revealed'); portfolioRevealer.css({ overflow: 'hidden' }); $('#portfolio-' + portPostId).addClass('portfolio-revealed'); initiatePortfolio(portPostId); return false; }); $('#close-portfolio').click( function() { $('html,body').animate({scrollTop: $('body').offset().top}, 2000, 'easeOutCubic'); portfolioRevealer.stop(true).animate({ height: 0 }, 500, 'easeOutQuad', function(){ portfolioRevealer.find('#portfolio-slider').remove(); portfolioRevealer.css({ overflow: 'hidden' }); }); portfolioItems.removeClass('portfolio-revealed'); $('#portfolio-revealer').animate({ height: 0}, 500, 'easeOutCubic', function(){ portfolioRevealer.css({ overflow: 'hidden' }); $('.portfolio_content').remove(); // video and audio stop playing } ); return false; }); } /*-----------------------------------------------------------------------------------*/ /* Pretty Photo /*-----------------------------------------------------------------------------------*/ $(document).ready(function(){ $("a[rel^='prettyPhoto']").prettyPhoto({ theme: 'pp_default', }); }); /*-----------------------------------------------------------------------------------*/ /* fitVids /*-----------------------------------------------------------------------------------*/ $(".vcontainer").fitVids(); }); /** * Progress Plugin JS Standards and Helpers */ !function( $ ){ /** * Prototype Based Object Creation as recommended by Crawford * pretty common pattern, so this might also be included by a * helper library */ if (typeof Object.create !== 'function') { Object.create = function (o) { var F = function () { }; F.prototype = o; return new F(); }; } /** * Bridge for registering new plugins. * @param name the name of the plugin * @param object the prototype object */ jQuery.plugin = function(name, object) { //add init method that will automatically // merge the options and defaults // set elem and jQueryElem attributes // call the object's _build function // return the object object.init = function(options, elem) { return jQuery.pluginInit(options, elem, this); }; jQuery.fn[name] = function(options) { var args = Array.prototype.slice.call(arguments, 1); return this.each(function() { var instance = jQuery.data(this, name); if (!instance) { instance = jQuery.data(this, name, Object.create(object).init(options, this)); } }); }; }; jQuery.pluginInit = function(options, elem, thisobj) { //Merge the defaults and passed in options thisobj.options = jQuery.extend({}, thisobj.options, options); //store DOM and jQuery element thisobj.elem = elem; thisobj.jQueryElem = jQuery(elem); //Build dom initial structure thisobj._build(); //return this so we can chain/use the bridge with less code return thisobj; }; }( window.jQuery || window.ender ); /** * Creating a new jQuery Plugin using the Progress Plugin System * * 1. Define an object literal (ex. ProgressMyPlugin) for your plugin definition with the following members * 1. 'options: {}' - an object literal containing mappings for default options of the plugin * 2. '_build: function(){...}' - the main entry point for your plugin * 2. Register the object literal against the plugin name in the self-calling function at the bottom of * Progress-plugins.js. (ex. jQuery.plugin('ProgressMyPlugin', ProgressMyPlugin); ) * 3. You can now call your plugin with the syntax: jQuery('#myObj').ProgressMyPlugin({'option1': 'Value'}); * 1. The object literal you provide to the plugin call will be available in your plugin definition through * the 'options' member of the plugin definition * * Patterns for usage within the the plugin definition * * Example: jQuery('#myObj').ProgressMyPlugin({'option1': 'Value'}); * * * The options declared on the plugin definition are merged with the options provided in the plugin call. The options * fed to the plugin call take precedence. * * * the jQuery('#myObj') value is available in the plugin by calling this.jQueryElem * * * In any given method member of the plugin definition the 'this' keyword will refer to the plugin definition itself. * However, if a callback is nested inside a member method, the 'this' keyword in the callback scope will refer to the * object the callback is associated with this. In order to access the plugin definition inside a callback, we define * a variable ('that' by convention) above the callback scope that can be accessed within the callback closure. * ex. * var that = this; jQuery(window).resize(function() { if (that.scrollview == null) { that._setupScrollview(); } else { that.jQueryElem.css("width", jQuery(this).width() - 10); } that._updateEnable(); }); this._updateEnable(); * */ var ProgressGlobals = {}; var ProgressHeaderMenu = { options:{ 'menuSelector':'ul.topmenu', 'desktopMenuSelector':'.desktop-menu', 'tabletMenuPortraitSelector':'.tablet-menu-portrait', 'mobileMenuSelector':'.mobile-menu' }, _build:function () { var that = this; jQuery(window).smartresize(function () { that.initializeMenus(); }); jQuery(window).trigger('resize'); }, isDesktop:function () { return (this.getWindowWidth() > 959 || jQuery('html.ie8').length > 0); }, isMobile:function () { return !(this.getWindowWidth() > 767 || jQuery('html.ie8').length > 0); }, isTablet:function () { return(this.getWindowWidth() < 960 && this.getWindowWidth() > 767); }, initializeMenus:function () { var menuSelector = this.options.menuSelector; if (this.isDesktop()) { menuSelector = jQuery('html.touch').length > 0 ? this.options.tabletMenuLandscapeSelector : this.options.desktopMenuSelector; } else if (this.isTablet()) { menuSelector = this.options.tabletMenuPortraitSelector; } else if (this.isMobile()) { return; } var $menuList = jQuery(menuSelector); // Only run if the menu hasn't already been initialized if ($menuList.length > 0 && $menuList.attr('class').indexOf('sf-js-enabled') == -1) { $menuList.supersubs({ minWidth:15, // minimum width of sub-menus in em units maxWidth:30, // maximum width of sub-menus in em units extraWidth:1 // extra width can ensure lines don't sometimes turn over // due to slight rounding differences and font-family }).superfish({ delay:200, animation:{opacity:'show', height:'show'}, speed:'fast', autoArrows:false, dropShadows:false }); } }, getWindowWidth:function () { return jQuery(window).width(); } }; var ProgressMenuHover = { options:{}, _build:function () { jQuery('ul.desktop-menu li, ul.tablet-menu li').hover(function () { jQuery(this).addClass('sfHover'); }); jQuery('ul.desktop-menu li, ul.tablet-menu li').mouseleave(function () { jQuery(this).removeClass('sfHover'); }); } }; var ProgressMobileMenuToggle = { options:{'mobileButtonSelector':'.mobile-menu-btn'}, _build:function () { var that = this; jQuery(this.options.mobileButtonSelector).click(function () { jQuery(this).toggleClass('menu-open'); }); } }; var ProgressTabletSubmenuClose = { options:{}, _build:function () { var that = this; that.jQueryElem.click(function () { var $parent = jQuery(this).parent('li.menu-parent-item'); if ($parent.hasClass('sfHover')) { $parent.hideSuperfishUl(); } else { $parent.showSuperfishUl(); } return false; }); } }; /* Register our object literal */ !function ($) { jQuery.plugin('ProgressHeaderMenu', ProgressHeaderMenu); jQuery.plugin('ProgressMenuHover', ProgressMenuHover); jQuery.plugin('ProgressTabletSubmenuClose', ProgressTabletSubmenuClose); jQuery.plugin('ProgressMobileMenuToggle', ProgressMobileMenuToggle); }(window.jQuery || window.ender);