/* ================================================== Custom jQuery functions. ================================================== */ ///////////////////////////////////////////// // NO CONFLICT ///////////////////////////////////////////// var $j = jQuery.noConflict(); var onLoad = { init: function(){ page.init(); nav.init(); footer.init(); slider.init(); portfolio.init(); reloadFunctions.init(); } }; ///////////////////////////////////////////// // PAGE FUNCTIONS ///////////////////////////////////////////// var page = { init: function () { // FITVIDS $j('article.type-portfolio,article.type-post').fitVids(); // FADE INS var $overlay_items = $j('.overlay-shape'); $overlay_items.fadeIn(2000); } }; ///////////////////////////////////////////// // NAVIGATION ///////////////////////////////////////////// var nav = { init: function(){ // Main Nav $j("ul.sub-menu").parent().addClass('parent'); $j(".menu li.parent").hoverIntent({ over: function () { $j(this).find('ul.sub-menu:first').css("display", "block"); var $left = "10px"; if ($j(this).find('ul.sub-menu:first').parent().parent().hasClass("sub-menu")) { $left = $j(this).find('ul.sub-menu:first').parent().parent().outerWidth() - 2; } if ($j(this).parent().css("opacity") == 1) { $j(this).find('ul.sub-menu:first').stop().animate({ "opacity": "1", "left": $left }, 200); } }, out: function () { $j(this).find('ul.sub-menu:first').stop().animate({ "opacity": "0", "left": "-20px" }, 200); hideNav($j(this).find('ul.sub-menu:first')); } }); // Mobile Nav var $mobile_select = $j('.dropdown-menu'), $selected_page_text = $j('.selected-option'); $selected_page_text.html($mobile_select.find('option:selected').text()); $mobile_select.change(function() { location = $j(this).find("option:selected").val(); }); // Prevent #'s being added to the address bar $j('nav .menu li').on('click', 'a', function(e) { if ($j(this).attr('href') == "#") { e.preventDefault(); } }); } }; function hideNav($subnav) { setTimeout(function() { if ($subnav.css("opacity") == "0") { $subnav.css("display", "none"); } }, 300); } ///////////////////////////////////////////// // FOOTER FUNCTION ///////////////////////////////////////////// var $body = $j('html,body'), $sticky_footer = $j('#sticky-footer'); if ($j.browser.safari) { $body = $j('body'); } var footer = { init: function() { var deviceAgent = navigator.userAgent.toLowerCase(); var agentID = deviceAgent.match(/(iphone|ipod|ipad|android|iemobile)/); if (agentID) { $sticky_footer.css('position','relative'); $sticky_footer.css('bottom', 0); } else { $j(window).scroll(function(){ positionStickyFooter(); }); } } } function positionStickyFooter() { if ($j('#footer:in-viewport').attr('id') == "footer") { $sticky_footer.css('position','relative'); $sticky_footer.css('bottom','0'); } else { if ($sticky_footer.css('position') == "relative") { $sticky_footer.css('bottom','-80px'); } $sticky_footer.css('position','fixed'); } if (($body.scrollTop() > 50) || ($j('#footer:in-viewport').attr('id') == "footer")) { $sticky_footer.stop().animate({ "bottom": "0" }, 400); } else { $sticky_footer.stop().animate({ "bottom": "-80px" }, 400); } } ///////////////////////////////////////////// // FLEXSLIDER FUNCTION ///////////////////////////////////////////// var slider = { init: function() { $j('.flexslider').flexslider({ animation: "slide", //String: Select your animation type, "fade" or "slide" slideDirection: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical" slideshow: true, //Boolean: Animate slider automatically slideshowSpeed: 12000, //Integer: Set the speed of the slideshow cycling, in milliseconds animationDuration: 400, //Integer: Set the speed of animations, in milliseconds directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false) controlNav: true, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage keyboardNav: true, //Boolean: Allow slider navigating via keyboard left/right keys mousewheel: false, //Boolean: Allow slider navigating via mousewheel prevText: "Prev", //String: Set the text for the "previous" directionNav item nextText: "Next", //String: Set the text for the "next" directionNav item pausePlay: false, //Boolean: Create pause/play dynamic element pauseText: '5', //String: Set the text for the "pause" pausePlay item playText: '4', //String: Set the text for the "play" pausePlay item randomize: false, //Boolean: Randomize slide order slideToStart: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide) animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended. pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering controlsContainer: "", //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken. manualControls: "", //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs. start: function(){}, //Callback: function(slider) - Fires when the slider loads the first slide before: function(){}, //Callback: function(slider) - Fires asynchronously with each slider animation after: function(){}, //Callback: function(slider) - Fires after each slider animation completes end: function(){} //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous) }); } } ///////////////////////////////////////////// // PORTFOLIO ///////////////////////////////////////////// var portfolio = { init: function() { // cache container var $page_wrap = $j('.inner-page-wrap'), $container = $j('.portfolio-wrap').find('.filterable-items'), $col_width = 0; // initialize isotope $container.isotope({ animationEngine: 'best-available', animationOptions: { duration: 300, easing: 'easeInOutQuad', queue: false }, resizable: true, layoutMode: 'fitRows' }); // Enable filter options on when there are items from that skill $j('.filtering li').each( function() { //var $filter = $j(this), $filter_name = $j(this).find('a').attr('class'), $portfolio_items = $j(this).parent().parent().parent().parent().find('.filterable-items'); var $filter = $j(this), $filter_name = $j(this).find('a').attr('class'), $portfolio_items = $j('.filterable-items'); $portfolio_items.find('li').each( function() { if ( $j(this).hasClass($filter_name) ) { $filter.addClass('has-items'); } }); }); // filter items when filter link is clicked $j('.filtering li').on('click', 'a', function() { $j('.filtering li').removeClass('selected'); $j(this).parent().addClass('selected'); var selector = $j(this).attr('data-filter'); //var $portfolio_items = $j(this).parent().parent().parent().parent().find('.filterable-items'); var $portfolio_items = $j('.filterable-items'); $portfolio_items.isotope({ filter: selector }, function() { positionStickyFooter(); }); return false; }); } } ///////////////////////////////////////////// // RELOAD FUNCTIONS ///////////////////////////////////////////// var reloadFunctions = { init:function() { // Remove title attributes from images to avoid showing on hover $j('img[title]').each(function() { $j(this).removeAttr('title'); }); $j('a[title]').each(function() { $j(this).removeAttr('title'); }); // Tabs Shortcode Function $j('.tabbed-asset').tabs(); // Accordion Shortcode Function $j('.accordion').accordion({ collapsible: true, autoHeight: false }); // Button hover tooltips $j('.tooltip').each( function() { $j(this).css( 'marginLeft', '-' + Math.round( ($j(this).outerWidth() / 2) ) + 'px' ); }); $j('.comment-avatar').hover( function() { $j(this).find('.tooltip' ).stop().animate({ bottom: '50px', opacity: 1 }, 500, 'easeInOutExpo'); }, function() { $j(this).find('.tooltip').stop().animate({ bottom: '25px', opacity: 0 }, 500, 'easeInOutExpo'); }); // Animate Top Links $j('.animate-top').on('click', function(e) { $j('body,html').animate({scrollTop: 0}, 800); }); } } $j(document).ready(onLoad.init); ///////////////////////////////////////////// // GOOGLE WEB FONT FUNCTION ///////////////////////////////////////////// WebFontConfig = { google: { families: ['Source Sans Pro', 'Source Sans Pro', 'Vidaloka'] } }; (function() { document.getElementsByTagName("html")[0].setAttribute("class","wf-loading") // NEEDED to push the wf-loading class to your head document.getElementsByTagName("html")[0].setAttribute("className","wf-loading") // for IE… var wf = document.createElement('script'); wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; wf.type = 'text/javascript'; wf.async = 'false'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wf, s); })();