var $window = $(window); var $html = $('html'); var $body = $('body'); /*-------------------------------------------------------------------------------------- Debug Config Show/Hide ======================================================================================*/ $('a.show').on('click',function(e){ e.preventDefault(); if ( $(this).hasClass('plus') ) { $('.debug_config').slideDown(); $(this).addClass('minus').removeClass('plus').text('-'); } else { $('.debug_config').hide(); $(this).addClass('plus').removeClass('minus').text('+'); } }); /*-------------------------------------------------------------------------------------- Mobile Menu ======================================================================================*/ $('.wrap').addClass('animate-transition'); $body.addClass('nav-hidden'); var $overlayEl = $('div.viewport div.overlay,div.viewport div.fixed-overlay'); var $offcanvasEl = $('div.viewport div.off-canvas,div.viewport div.off-canvas'); var $overlayMenu = $overlayEl.length; var $offcanvasMenu = $offcanvasEl.length; $(document).ready(function(){ if ($overlayMenu && $('.tbc-fixed-header header').length) { $body.addClass('push-wrap'); } else if ($offcanvasMenu && $('.tbc-fixed-header header').length) { $body.addClass('push-wrap'); } }); $('.menu-toggle,.close-overlay').on('touchstart click',function(e){ e.preventDefault(); if ($overlayMenu) { if ( $overlayEl.css('display') === 'none' ) { $overlayEl.fadeIn(); } else if ( $overlayEl.css('display') === 'block' ) { $overlayEl.fadeOut(); } if ($('header.tbc-fixed-header').length) { if ( $body.is('.overlay-fixed-shown') ) { $body.addClass('overlay-fixed-hidden').removeClass('overlay-fixed-shown'); } else { $body.addClass('overlay-fixed-shown').removeClass('overlay-fixed-hidden'); } } else { if ( $body.is('.overlay-shown') ) { $body.addClass('overlay-hidden').removeClass('overlay-shown'); $('.menu-toggle .text').text('View Menu'); $('.menu-toggle').toggleClass('green'); $('.menu-toggle .target').show(); $('.menu-toggle .x').hide(); } else { $body.addClass('overlay-shown').removeClass('overlay-hidden'); $('.menu-toggle .text').text('Close Menu'); $('.menu-toggle .target').hide(); $('.menu-toggle .x').show(); $('.menu-toggle').toggleClass('green'); } } } else if ($offcanvasMenu) { if ( $body.is('.nav-shown') ) { $body.addClass('nav-hidden').removeClass('nav-shown'); } else { $body.addClass('nav-shown').removeClass('nav-hidden'); } } }); //accordian sub menus $('div.mobile-menu li:has(ul) > a').on('touchstart click', function(e) { e.preventDefault(); if ($(this).parent().hasClass('active')) { $(this).parent().removeClass('active').children('ul').slideUp(); } else { $(this).parent().addClass('active').children('ul').slideDown(); } }); //dig-in sub menus //$('div.overlay li:has(ul) > a').on('touchstart click', function(e) { // e.preventDefault(); // if ($(this).parent().hasClass('active')) { // $('div.overlay ul.menu > li').fadeIn(); // $(this).parent().removeClass('active').children('ul').hide(); // } else { // $('div.overlay ul.menu > li').hide(); // $(this).parent().addClass('active').show().children('ul').fadeIn(); // } //}); /*-------------------------------------------------------------------------------------- Header Drop Down ======================================================================================*/ //header sub menus $('nav.main li:has(ul)').on('mouseenter', function() { $(this).children('ul').fadeIn(); }); $('nav.main li ul').on('mouseleave', function() { $(this).fadeOut(); }); $('nav.main li:has(ul)').on('mouseleave', function() { $(this).children('ul').fadeOut(); }); /*-------------------------------------------------------------------------------------- Add responsive layout mode classes ======================================================================================*/ function addLayoutVersionClass(width) { if ( width <= 480) { if ( !$body.is('.responsive-phone') ) { $body.addClass('responsive-phone').removeClass('responsive-mini responsive-tablet responsive-desktop nav-shown'); } } else if ( width < 620 ) { if ( !$body.is('.responsive-mini') ) { $body.addClass('responsive-mini').removeClass('responsive-phone responsive-tablet responsive-desktop nav-shown'); } } else if ( width < 940 ) { if ( !$body.is('.responsive-tablet') ) { $body.addClass('responsive-tablet').removeClass('responsive-phone responsive-mini responsive-desktop nav-shown'); } } else { if ( !$body.is('.responsive-desktop') ) { $body.addClass('responsive-desktop').removeClass('responsive-phone responsive-mini responsive-tablet nav-shown'); } } } $window.resize(function(){ if ( $html.is('.tbc-responsive') ) { var width = $(this).width(); addLayoutVersionClass(width); } }); // make links open in new window $('#wp-admin-bar-tbc-home a').attr('target','_blank'); $('.content_wrap a').each(function(){ $this = $(this); if ( $this.attr('href') && $this.attr('href').indexOf('uploads') >= 0 && $this.find('img').is('.alignleft, .alignright, .alignnone, .aligncenter') ) { // the image was added via WordPress's 'Insert into Post' $this.addClass('tbc-modal'); } }); $('.showloading').on('click',function(e){ $(this).addClass('isloading'); }); /*-------------------------------------------------------------------------------------- Equal Height Cols ======================================================================================*/ var equalheight = function(container){ var currentTallest = 0, currentRowStart = 0, rowDivs = [], $el, currentDiv, topPosition = 0; $(container).each(function(){ $el = $(this); $($el).height('auto'); topPosition = $el.position().top; if (currentRowStart !== topPosition) { for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) { rowDivs[currentDiv].height(currentTallest); } rowDivs.length = 0; // empty the array currentRowStart = topPosition; currentTallest = $el.height(); rowDivs.push($el); } else { rowDivs.push($el); currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest); } for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) { rowDivs[currentDiv].height(currentTallest); } }); }; $window.load(function() { equalheight('.equalheight [class*="tbc-c-"]'); equalheight('.equal_height'); }); $window.resize(function(){ equalheight('.equalheight [class*="tbc-c-"]'); equalheight('.equal_height'); }); /*-------------------------------------------------------------------------------------- Add tag retina switch ======================================================================================*/ if( window.devicePixelRatio >= 2 ){ $('.retina').each(function(){ var old_src = $(this).attr('src'); old_src = old_src.replace('.png','-2x.png'); $(this).attr('src',old_src); }); } /*-------------------------------------------------------------------------------------- Add Lightbox effect ======================================================================================*/ $('a.tbc-modal, .lightbox, .fancybox').fancybox({ openEffect: 'elastic', closeEffect: 'elastic' }); /*-------------------------------------------------------------------------------------- Blog Sidebar ======================================================================================*/ var $types = $('#blogtabs #tabs .tab'); $('#blogtabs #tabnav a').on('click',function(e){ e.preventDefault(); $types.removeClass('current').eq($(this).index()).addClass('current'); $(this).addClass('current').siblings().removeClass('current'); }); /*-------------------------------------------------------------------------------------- Add placeholder for all browsers ======================================================================================*/ $('[placeholder]').each(function(){ if ( $(this).is(':visible') ) { $(this).focus(function() { var input = $(this); if (input.val() === input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function() { var input = $(this); if (input.val() === '' || input.val() === input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur().parents('form').submit(function() { $(this).find('[placeholder]').each(function() { var input = $(this); if (input.val() === input.attr('placeholder')) { input.val(''); } }); }); } }); /*-------------------------------------------------------------------------------------- Add full loader ======================================================================================*/ $('.fullpageloading, .showloading').click(function(){ $.fancybox({ content: '
processing
', closeClick: false, closeBtn: false, helpers : { overlay : { closeClick: false, css : { 'background' : 'rgba(200,200,200,0.8)' } } } }); }); /*-------------------------------------------------------------------------------------- Search Form ======================================================================================*/ var $search = $('#s'); var current_search = $search.val(); if ( current_search === '' ) { $search.val('Search'); } else { $search.val(current_search); } $search.focusin(function(){ if ( $(this).val() === 'Search' ) { $(this).val(''); } }); $search.focusout(function(){ if ( $(this).val() === '' ) { $(this).val('Search'); } }); /*-------------------------------------------------------------------------------------- Search Form - Off canvas ======================================================================================*/ var $search2 = $('.s_value'); var current_search2 = $search2.val(); if ( current_search2 === '' ) { $search2.val('Search'); } else { $search2.val(current_search2); } $search2.focusin(function(){ if ( $(this).val() === 'Search' ) { $(this).val(''); } }); $search2.focusout(function(){ if ( $(this).val() === '' ) { $(this).val('Search'); } }); /*-------------------------------------------------------------------------------------- Preload Images ======================================================================================*/ var preloaded = []; function preload_images(images){ for (var x = 0; x < images.length; x++) { preloaded[x] = new Image(); preloaded[x].src = images[x]; } } preload_images([tbc_theme_url+'/images/loading.gif']); // send array of images (literal notation)