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'); $('.menu-toggle').on('click',function(e){ e.preventDefault(); if ( $body.is('.nav-shown') ) { $body.addClass('nav-hidden').removeClass('nav-shown'); } else { $body.addClass('nav-shown').removeClass('nav-hidden'); } }); /*-------------------------------------------------------------------------------------- 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); } }); $window.resize(); // make links open in new window $('#wp-admin-bar-tbc-home a').attr('target','_blank'); $('.content 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'); }); /*-------------------------------------------------------------------------------------- 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)