$(document).ready(function(){ // vars bonesResponsiveSlide = false; /* Overall Click Event for Body ----------------------------------------- */ $('body').click(function(e) { var target = $(e.target); bonesClick(target); }); function bonesClick(target) { /* Responsive Navigation ----------------------------------------- */ if( target.is('.nav-toggle') && bonesResponsiveSlide == false) { // slides body $('body').animate({'left': '200px'}, 500 ); // says body is slid out to right bonesResponsiveSlide = true } else if( bonesResponsiveSlide == true && !target.is('.nav') ) { // slides body back to left $('body').animate({'left': '0'}, 500 ); bonesResponsiveSlide = false; } // <-- RESPONSIVE NAVIGATION /* Tabs ----------------------------------------- */ if( target.is('.tabs li') ) { // class control for styling $('.tabs li').removeClass('active'); $(target).addClass('active'); // the tab to look for var tab = $(target).attr('data-tab'); // steps through tab content section until finding the right one $('.tab-content').each(function(){ if( $(this).attr('data-tab') != tab ) $(this).hide(); else $(this).show(); }); } // <-- TABS } // <-- bonesClick() | OVERALL CLICK CONTROL /* Responsive Control for Window Resize ----------------------------------------- */ $(window).resize(function(){ if( $('body').width() < 768 && bonesResponsiveSlide == true ) { // moves body back into place if it's out $('body').css('left', '0'); bonesResponsiveSlide = false; } }); // <-- WINDOW RESIZE /* Tooltip ----------------------------------------- */ if( $('.tooltip').length > 0 ) { bonesTooltipHover = 0; // counter to help build page tooltip elements $('.tooltip').hover(function(){ // iterative counter to build unique tooltip IDs bonesTooltipHover++; // get the element's title and then hide it (temporarily) bonesTooltipContent = $(this).attr('title'); $(this).attr('title', ''); // create (iterative) custom ID for tooltip, then build the element bonesTooltipID = 'bones-tooltip-'+bonesTooltipHover; $('body').prepend('