/*--------------------------------------------------------------
Fire up functions on $(document).ready()
--------------------------------------------------------------*/
jQuery(document).ready(function () {
truethemes_SuperFish();
truethemes_MobileMenu();
jQuery("#menu-main-nav li:has(ul)").addClass("parent");
jQuery(".ubermenu-nav li:has(ul)").addClass("tt-uber-parent");
truethemes_Sliders();
jQuery('.slider-content-video,.video_wrapper').fitVids();
truethemes_Gallery();
truethemes_masonry_blog();
truethemes_KeyboardTab();
jQuery('div.mc_signup_submit input#mc_signup_submit').removeClass('button');
jQuery('.checkout-button.button.alt.wc-forward').find('br').remove();
//parallax
jQuery('.tt-parallax-text').fadeIn(1000); //delete this to remove fading content
var $window = jQuery(window);
jQuery('section[data-type="background"]').each(function () {
var $bgobj = jQuery(this);
jQuery(window).scroll(function () {
var yPos = -($window.scrollTop() / $bgobj.data('speed'));
var coords = '50% ' + yPos + 'px';
$bgobj.css({
backgroundPosition: coords
});
});
});
});
/*--------------------------------------------------------------
Fire up functions on $(window).load()
--------------------------------------------------------------*/
jQuery(window).load(function () {
truethemes_Fadeimages();
truethemes_MobileSubs();
truethemes_LightboxHover();
jQuery("a[data-gal^='prettyPhoto']").prettyPhoto({
hook:'data-gal', // do not change, sky will fall
theme: 'light_square', // options: light_rounded / dark_rounded / pp_default / dark_square / facebook
});
truethemes_ScrollTop();
truethemes_Tabs();
if (jQuery(window).width() > 1024) { //only load sticky on non-mobile devices
truethemes_StickySidebar();
}
truethemes_flexslider_for_gallery_post_format();
});
/*---------------------------------------------------------------------------*/
/*
/* Note to developers:
/* Easily uncompress any functions using: http://jsbeautifier.org/
/*
/*---------------------------------------------------------------------------*/
/*--------------------------------------------------------------
Superfish - Dropdown Menus
--------------------------------------------------------------*/
function truethemes_SuperFish(){
//only activate top-toolbar if child
is present
jQuery(".top-block ul:has(ul)").addClass("sf-menu");
jQuery('ul.sf-menu').superfish({
delay: 100,
animation: {
opacity: 'show',
height: 'show'
},
speed: 'fast',
disableHI: true,
autoArrows: false,
dropShadows: false
})
}
// 2/3/4th level menu offscreen fix
// thanks to sakib000: https://forum.jquery.com/topic/suprtfish-menu-text-off-screen
var wapoMainWindowWidth = jQuery(window).width();
jQuery('#menu-main-nav.sf-menu ul li').mouseover(function(){
// checks if third level menu exist
var subMenuExist = jQuery(this).find('.sub-menu').length;
if( subMenuExist > 0){
var subMenuWidth = jQuery(this).find('.sub-menu').width();
var subMenuOffset = jQuery(this).find('.sub-menu').parent().offset().left + subMenuWidth;
// if sub menu is off screen, give new position
if((subMenuOffset + subMenuWidth) > wapoMainWindowWidth){
var newSubMenuPosition = subMenuWidth + 14;
jQuery(this).find('.sub-menu').css({
left: -newSubMenuPosition
});
}
}
});
/*--------------------------------------------------------------
Sliders + Testimonials
--------------------------------------------------------------*/
function truethemes_Sliders(){
//data pulled in from Site Options using wp_localize()
var tt_slider_directionNav;
var tt_slider_pause_hover;
var tt_slider_randomize;
var tt_testimonial_directionNav;
var tt_testimonial_pause_hover;
var tt_testimonial_randomize;
if(php_data.karma_jquery_directionNav == 'true'){tt_slider_directionNav = true;}else{tt_slider_directionNav = false;}
if(php_data.karma_jquery_pause_hover == 'true'){tt_slider_pause_hover = true;}else{tt_slider_pause_hover = false;}
if(php_data.karma_jquery_randomize == 'true'){tt_slider_randomize = true;}else{tt_slider_randomize = false;}
if(php_data.testimonial_directionNav == 'true'){tt_testimonial_directionNav = true;}else{tt_testimonial_directionNav = false;}
if(php_data.testimonial_pause_hover == 'true'){tt_testimonial_pause_hover = true;}else{tt_testimonial_pause_hover = false;}
if(php_data.testimonial_randomize == 'true'){tt_testimonial_randomize = true;}else{tt_testimonial_randomize = false;}
//karma jquery sliders
jQuery('.jquery1-slider-wrap, .jquery2-slider-bg, .jquery3-slider-wrap').flexslider({
slideshowSpeed: php_data.karma_jquery_slideshowSpeed,
pauseOnHover: tt_slider_pause_hover,
randomize: tt_slider_randomize,
directionNav: tt_slider_directionNav,
animation: php_data.karma_jquery_animation_effect,
animationSpeed: php_data.karma_jquery_animationSpeed,
smoothHeight: true
});
//testimonial shortcode
jQuery('.testimonials').flexslider({
slideshowSpeed: php_data.testimonial_slideshowSpeed,
pauseOnHover: tt_testimonial_pause_hover,
randomize: tt_testimonial_randomize,
directionNav: tt_testimonial_directionNav,
animation: php_data.testimonial_animation_effect,
animationSpeed: php_data.testimonial_animationSpeed,
controlsContainer: ".testimonials",
smoothHeight: true
});
jQuery('.true-testimonial-1-flexslider').flexslider({
slideshowSpeed: php_data.testimonial_slideshowSpeed,
animation: "slide",
namespace: "true-",
start: function(slider) {
slider.removeClass('loading');
}
});
jQuery('.true-testimonial-2-flexslider').flexslider({
slideshowSpeed: php_data.testimonial_slideshowSpeed,
animation: "slide",
controlNav: "thumbnails",
namespace: "true-",
start: function(slider) {
slider.removeClass('loading');
}
});
}
/*--------------------------------------------------------------
Tabs
--------------------------------------------------------------*/
function truethemes_Tabs(){
//Added since 3.0.2 dev 4.
//tabs init code, added with browser url sniff to get tab id to allow activating tab via link
//example url http://localhost:8888/karma-experimental/shortcodes/tabs-accordion/?tab=2
var tab_id = window.location.search.split('?tab=');
if (tab_id) {
var tab_index = tab_id[1] - 1;
jQuery('.tabs-area').tabs({
show: { effect: "fadeIn" },
hide: { effect: "fadeOut" },
active: tab_index
})
} else {
jQuery('.tabs-area').tabs({
show: { effect: "fadeIn" },
hide: { effect: "fadeOut" },
active: 0
})
}
}
/*--------------------------------------------------------------
Accessible Keyboard Tabbing
--------------------------------------------------------------*/
function truethemes_KeyboardTab() {
jQuery(function(){
var lastKey = new Date(),
lastClick = new Date();
jQuery(document).on( "focusin", function(e){
jQuery(".non-keyboard-outline").removeClass("non-keyboard-outline");
var wasByKeyboard = lastClick < lastKey
if( wasByKeyboard ) {
jQuery( e.target ).addClass( "non-keyboard-outline");
}
});
jQuery(document).on( "click", function(){
lastClick = new Date();
});
jQuery(document).on( "keydown", function() {
lastKey = new Date();
});
});
}
/*--------------------------------------------------------------
Image Fade-in
--------------------------------------------------------------*/
function truethemes_Fadeimages() {
jQuery('[class^="attachment"]').each(function (index) {
var t = jQuery('[class^="attachment"]').length;
// When retina.js swaps the images, the new image, being
// larger, overflows the frame. To fix this, take the
// size of the zoomlayer, and apply it to the new image.
// We do it regardless of whether the image has been swapped
// by retina.js since it would be a waste to detect whether
// the iamge has been swapped.
var z = jQuery(this).prev('.lightbox-zoom');
jQuery(this).css({
'width': z.css('width'),
'height': z.css('height')
});
if (t > 0) {
jQuery(this).delay(160 * index).fadeIn(400)
}
})
}
/*--------------------------------------------------------------
Lightbox hover
--------------------------------------------------------------*/
function truethemes_LightboxHover() {
jQuery('.lightbox-img').hover(function() {
jQuery(this).children().first().children().first().stop(true);
jQuery(this).children().first().children().first().fadeTo('normal', .90)
}, function() {
jQuery(this).children().first().children().first().stop(true);
jQuery(this).children().first().children().first().fadeTo('normal', 0)
})
}
/*--------------------------------------------------------------
Scroll to Top
--------------------------------------------------------------*/
function truethemes_ScrollTop() {
jQuery('a.link-top').click(function() {
if (!jQuery.browser.opera) {
jQuery('body').animate({
scrollTop: 0
}, {
queue: false,
duration: 1200
})
}
jQuery('html').animate({
scrollTop: 0
}, {
queue: false,
duration: 1200
});
return false
})
}
jQuery(document).ready(function($){
// browser window scroll (in pixels) after which the "back to top" link is shown
var offset = 300,
//duration of the top scrolling animation
scroll_top_duration = 700,
//grab the "back to top" link
$back_to_top = $('.karma-scroll-top');
//hide or show the "back to top" link
$(window).scroll(function(){
( $(this).scrollTop() > offset ) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
});
//smooth scroll to top
$back_to_top.on('click', function(event){
event.preventDefault();
$('body,html').animate({
scrollTop: 0 ,
}, scroll_top_duration
);
});
});
/*--------------------------------------------------------------
Sticky Sidebar
--------------------------------------------------------------*/
function truethemes_StickySidebar() {
// Since 4.4 - site option to activate sticky
if(php_data.sticky_sidebar == 'true'){
/*
Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net
*/
(function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k));
if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b(""))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q,
u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),eb&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}),
a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize",
y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n