/*!
* headhesive v1.1.1 - An on-demand sticky header
* Url: http://markgoodyear.com/labs/headhesive
* Copyright (c) Mark Goodyear — @markgdyr — http://markgoodyear.com
* License: MIT
*/
!function(t,s,e){"use strict";function i(t){for(var s=0;t;)s+=t.offsetTop,t=t.offsetParent;return s}var o=function(t,s){for(var e in s)s.hasOwnProperty(e)&&(t[e]="object"==typeof s[e]?o(t[e],s[e]):s[e]);return t},n=function(t,s){var e,i,o,n=Date.now||function(){return(new Date).getTime()},l=null,c=0,h=function(){c=n(),l=null,o=t.apply(e,i),e=i=null};return function(){var r=n(),f=s-(r-c);return e=this,i=arguments,0>=f?(clearTimeout(l),l=null,c=r,o=t.apply(e,i),e=i=null):l||(l=setTimeout(h,f)),o}},l=function(){return t.pageYOffset!==e?t.pageYOffset:(s.documentElement||s.body.parentNode||s.body).scrollTop},c=function(e,i){"querySelector"in s&&"addEventListener"in t&&(this.visible=!1,this.options={offset:300,classes:{clone:"headhesive",stick:"headhesive--stick",unstick:"headhesive--unstick"},throttle:250,onInit:function(){},onStick:function(){},onUnstick:function(){},onDestroy:function(){}},this.elem="string"==typeof e?s.querySelector(e):e,this.options=o(this.options,i),this.init())};c.prototype={constructor:c,init:function(){if(this.clonedElem=this.elem.cloneNode(!0),this.clonedElem.className+=" "+this.options.classes.clone,s.body.insertBefore(this.clonedElem,s.body.firstChild),"number"==typeof this.options.offset)this.scrollOffset=this.options.offset;else{if("string"!=typeof this.options.offset)throw new Error("Invalid offset: "+this.options.offset);this.scrollOffset=i(s.querySelector(this.options.offset))}this._throttleUpdate=n(this.update.bind(this),this.options.throttle),t.addEventListener("scroll",this._throttleUpdate,!1),this.options.onInit.call(this)},destroy:function(){s.body.removeChild(this.clonedElem),t.removeEventListener("scroll",this._throttleUpdate),this.options.onDestroy.call(this)},stick:function(){this.visible||(this.clonedElem.className=this.clonedElem.className.replace(new RegExp("(^|\\s)*"+this.options.classes.unstick+"(\\s|$)*","g"),""),this.clonedElem.className+=" "+this.options.classes.stick,this.visible=!0,this.options.onStick.call(this))},unstick:function(){this.visible&&(this.clonedElem.className=this.clonedElem.className.replace(new RegExp("(^|\\s)*"+this.options.classes.stick+"(\\s|$)*","g"),""),this.clonedElem.className+=" "+this.options.classes.unstick,this.visible=!1,this.options.onUnstick.call(this))},update:function(){l()>this.scrollOffset?this.stick():this.unstick()}},t.Headhesive=c}(window,document);
(function($){
// $('.asm-tab').responsiveTabs({
// startCollapsed: 'accordion',
// active: 0
// });
$(document).on('change', '.others select', function(e) {
if($(this).val()=='Other'){
$('.others-inbox').toggleClass('displaybox');
}else{
$('.others-inbox').removeClass('displaybox');
}
});
if ( $(".request-a-quote-container").length ) {
var $container = $("html,body");
var $scrollTo = $('.request-a-quote-container');
var offset = 200;
$('html, body').animate({
scrollTop: $scrollTo.offset().top - offset,
}, 2000, 'linear');
}
$( ".others select" ).select(function() {
alert( "Handler for .select() called." );
});
$( ".others li" ).click(function() {
if($(this).find('input').val()=='Other'){
$('.others-inbox').toggleClass('displaybox');
}
});
window.sr = ScrollReveal();
sr.reveal('.topreveal .so-widget-ff-widget-text', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.topreveal', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.right', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.left', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.circle-image', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.year-structure', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.reveal-anim', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.reveal-anim2', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.reveal-anim3', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
sr.reveal('.reveal-anim4', { duration: 1000,scale: 0.9, easing: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', reset: false }, 50);
var controller = new ScrollMagic.Controller();
$(".timeline .items").each(function() {
var contentTweenTL = new TimelineMax({
repeat:0,
});
var contentTween = contentTweenTL.from($('#'+this.id).find(".year"), 0.6, {
x: -100,
autoAlpha: 0,
delay: 0,
ease: Power2.easeOut
}, .1).to($('#'+this.id).find(".small-circle-nav"), 0.6, {
css:{borderColor:"#313390", backgroundColor: '#313390'},
ease: Power2.easeOut,
}, .1).from($('#'+this.id).find(".col-82"), 0.6, {
x: -100,
autoAlpha: 0,
ease: Power2.easeOut
}, .2).from($(this).find(".bottom-line"), .2, {
height: 0,
autoAlpha: 0,
delay: 0,
ease: Power2.easeOut
}, .1);
var scene3 = new ScrollMagic.Scene({triggerElement: "#"+this.id, offset: 10})
.setTween(contentTween)
.addTo(controller)
.setClassToggle("#"+this.id, "active")
.reverse(true)
// .addIndicators()
;
});
$(".services-btn").click(function(e) {
e.preventDefault();
$( "body" ).toggleClass('services-box-down');
});
$(".close-btn-1").click(function(e) {
e.preventDefault();
$( "body" ).removeClass('services-box-down');
});
if($( ".site-container" ).height() < $(window).height()){
$( ".site-container" ).toggleClass('vh100');
}
$('.request-a-qoute .gf_progressbar_wrapper').prependTo( $( ".gform_page_footer" ) );
$( "h2" ).insertBefore( $( ".container" ) );
$(".team-overview .right-angle-nav").click(function() {
$(".team-overview .slick-next").click();
});
$(".team-overview .left-angle-nav").click(function() {
$(".team-overview .slick-prev").click();
});
$( ".circle-nav" ).click(function() {
$('.timeline .items').removeClass("animation-timeline");
var result = $(this).parent().last().parent('.flex').parent().last().parent().last().toggleClass("animation-timeline");
console.log(result);
});
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
var accordion_id = getUrlParameter('id');
if(accordion_id){
$('#'+accordion_id).toggleClass('in');
// $('#'+accordion_id+' .panel-collapse').toggleClass('in');
var offset = 200;
$('html, body').animate({
scrollTop: $('#'+accordion_id+'-panel').offset().top - offset,
}, 2000, 'linear');
}
$('.ff_services_carousel .right-angle-nav').click(function () {
$('.ff_services_carousel .slick-next').click();
});
$('.ff_services_carousel .left-angle-nav').click(function () {
$('.ff_services_carousel .slick-prev').click();
});
// Gravity form group fields
function ff_group_form_fields( g_index ){
$(".group-fields_wrapper .g"+ g_index +", .group-fields .g"+ g_index)
.wrapAll("
");
}
// Set Equal Heights
function ff_set_equal_heights( selector, optional_target ){
var target = "";
optional_target = typeof optional_target !== "undefined" ? optional_target : "";
if( optional_target == "" ) {
target = selector;
} else {
target = optional_target;
}
var temp_height = 0;
$(selector).each(function(){
if( temp_height < $(this).height() ) {
temp_height = $(this).height();
}
$(this).find(target).css("min-height", temp_height + "px");
});
}
// Equal Heights
function equalHeight(group) {
var tallest = 0;
group.each(function() {
var thisHeight = $(this).height();
if(thisHeight > tallest) {
tallest = thisHeight;
}
});
group.height(tallest);
}
// Swap Elements
function ff_swap_children(el, target_window_width){
var left_child = el.children()[0];
var right_child = el.children()[1];
if( $(window).width() <= target_window_width ) {
if( !$(left_child).hasClass("child-1") ) {
left_child.before(right_child); // swap
}
} else {
if( $(left_child).hasClass("child-1") ) {
left_child.before(right_child); // swap back
}
}
}
function ff_swap_children_init(el){
el.children().each(function(index){
$(this).addClass("child-"+ index);
})
}
// Browser Detection
function custom_browser_detect(){
var browser_class = "";
if((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf("OPR")) != -1 )
{
browser_class = "opera";
}
else if(navigator.userAgent.indexOf("Chrome") != -1 )
{
browser_class = "chrome";
}
else if(navigator.userAgent.indexOf("Safari") != -1)
{
browser_class = "safari";
}
else if(navigator.userAgent.indexOf("Firefox") != -1 )
{
browser_class = "firefox";
}
else if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true )) //IF IE > 10
{
browser_class = "iE";
}
return browser_class;
}
/* Document Ready */
$(function(){
ff_swap_children_init($(".swap-768-panel-grid-cell"));
if( $(".swap-768-panel-grid-cell").length ) {
ff_swap_children($(".swap-768-panel-grid-cell"), 768);
}
// Browser Detect
var browser_class = custom_browser_detect();
$("body").addClass(browser_class);
// Accordion Styling
$('.panel-group .accordion-toggle').on('click', function(){
$('.panel-group .accordion-toggle').removeClass('active');
$(this).addClass('active');
});
// Custom Accordion
if( $('.btn-show-content').length && $('.show-content').length ) {
$('.btn-show-content').on('click', function(){
$(this).toggleClass('active');
$('.show-content-' + $(this).attr('rel')).fadeToggle();
});
}
// Auto link phone numbers in mobile
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
if( $('.phone-num').length > 0 ) {
$('.phone-num').each(function(){
if( $(this).prop('tagName') != 'A' ) {
var contactNum = $(this).text().replace(/\s+/g, ''),
overrideNum = $(this).attr('data-override');
if( overrideNum ) contactNum = overrideNum;
$(this).wrapAll('');
}
});
}
}
/* Form Extra Wrappers */
if( $('.group-fields_wrapper, .group-fields').length > 0 ) {
if( $('.group-fields_wrapper .g1, .group-fields .g1').length > 0 ) {
ff_group_form_fields(1);
}
if( $('.group-fields_wrapper .g2, .group-fields .g2').length > 0 ) {
ff_group_form_fields(2);
}
if( $('.group-fields_wrapper .g3, .group-fields .g3').length > 0 ) {
ff_group_form_fields(3);
}
}
/* Gravity Form Extra Styles */
if( $('.radio-style-1 .gfield_radio').length ) {
$('.radio-style-1 .gfield_radio input').wrap('');
$('.radio-style-1 .gfield_radio .input-wrap').on('click', function(){
$(this).find('input').attr('checked', 'checked');
$(this).closest('ul').find('li').removeClass('checked');
$(this).closest('li').addClass('checked');
});
$('.radio-style-1 .gfield_radio input').on('change', function(){
$(this).closest('ul').find('li').removeClass('checked');
if( $(this).is(':checked') ) {
$(this).closest('li').addClass('checked');
}
});
}
if( $('.checkbox-style-1 .gfield_checkbox').length ) {
$('.checkbox-style-1 .gfield_checkbox input').wrap('');
$('.checkbox-style-1 .gfield_checkbox .input-wrap').on('click', function(){
if( $(this).find('input').is(':checked') ) {
$(this).closest('li').find('input').attr('checked', false);
$(this).closest('li').removeClass('checked');
} else {
$(this).closest('li').find('input').attr('checked', 'checked');
$(this).closest('li').addClass('checked');
}
});
$('.checkbox-style-1 .gfield_checkbox label').on('click', function(){
var this_input = $(this).closest('li').find('input');
setTimeout(function(){
this_input.attr('checked', 'checked');
this_input.closest('li').addClass('checked');
}, 50);
});
$('.checkbox-style-1 .gfield_checkbox input').on('change', function(){
if( $(this).is(':checked') ) {
$(this).closest('li').addClass('checked');
} else {
$(this).closest('li').removeClass('checked');
}
});
}
// Custom Popup Content
function custom_popup_content( parent_item, child_item ) {
$( parent_item + ' .activate-popup').click(function(){
var parent_item = $(this).closest( child_item );
if( !parent_item.hasClass('active') ) {
$( child_item + '.active').removeClass('active').find('.popup-content').hide();
parent_item.addClass('active').find('.popup-content').fadeIn();
}
});
$( parent_item + ' .popup-content .close-btn').click(function(){
$(this).closest('.popup-content').fadeOut();
$(this).closest( child_item ).removeClass('active');
})
}
/* Accordion Scroll on open */
var last_accordion_opened = 0;
$('.accordion-toggle').on('click', function(){
var target = $(this).closest('.panel');
var wait = setInterval(function() {
if( !$('.panel-collapse').is(':animated') ) {
clearInterval(wait);
animate_scroll_to(target, 115, 400);
}
}, 300);
})
function animate_scroll_to(target, offset, animationSpeed){
$('html,body').stop().animate({
scrollTop: target.offset().top - offset
}, animationSpeed);
}
$('a.goto[href*="#"]:not([href="#"]), .scroll-to').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
var pos_offset = $(this).attr('data-offset');
pos_offset = ( pos_offset == undefined ) ? 0 : pos_offset;
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top - pos_offset
}, 500);
return false;
}
}
});
// Sample Scroll Reveal
/* $('.home-about, .c2s-2 .home-form, .copyright-text').addClass('sr-enter-right');
$('.c2s-2 .home-posts, .linkback').addClass('sr-enter-left');
$('.team-members-carousel, .page-bottom-content .content-cta, .testimonials .testimonial-box, .content-cta, .team-members-container .team-member').addClass('sr-enter-bottom');
$('.footer-widget-wrapper .column-1').attr('data-sr', 'enter bottom, move 75px, over 1s, after 0.5s');
$('.footer-widget-wrapper .column-2').attr('data-sr', 'enter bottom, move 75px, over 1.5s, after 0.5s');
$('.footer-widget-wrapper .column-3').attr('data-sr', 'enter bottom, move 75px, over 2s, after 0.5s'); */
/* Scroll Reveal */
/* $('.sr-enter-left').attr('data-sr', 'enter left, move 100px over 1s, after 0.5s');
$('.sr-enter-right').attr('data-sr', 'enter right, move 100px, over 1s, after 0.5s');
$('.sr-enter-top').attr('data-sr', 'enter top, move 100px, over 1s, after 0.5s');
$('.sr-enter-bottom').attr('data-sr', 'enter bottom, move 75px, over 1s, after 0.5s');
window.sr = new scrollReveal(); */
/* Sticky Kit */
// Solve offsets
/* var width = $( window ).width();
var admin_bar_outer_height = ( $('#wpadminbar').length > 0 ) ? $('#wpadminbar').outerHeight() : 0;
var offset_top = admin_bar_outer_height;
$('.content-sidebar .content-sidebar-wrap > .content').stick_in_parent({
offset_top: 20 + offset_top,
parent: '.content-sidebar-wrap',
spacer: '.sticky-content-spacer',
recalc_every: 1,
});
$('.content-sidebar .content-sidebar-wrap > .sidebar-primary').stick_in_parent({
offset_top: 20 + offset_top,
parent: '.content-sidebar-wrap',
spacer: '.sticky-sidebar-spacer',
recalc_every: 1,
}); */
/* Internal Testimonial Slideshow */
if( $('.testimonials-slideshow').length ) {
$('.testimonials-slideshow').slick({
autoplay: true,
autoplaySpeed: 6000,
speed: 700,
infinite: true,
fade: true
});
$('.testimonials-slideshow').on('beforeChange', function(event, slick, currentSlide, nextSlide){
$('.testimonials-slideshow [data-slick-index="' + currentSlide + '"]').fadeTo('fast',0);
});
}
if( $('.testimonials-carousel').length ) {
$('.testimonials-carousel .carousel-container').slick({
autoplay: true,
autoplaySpeed: 20000,
infinite: true,
arrows: false,
dots: false,
slidesToShow: 1,
slidesToScroll: 1,
});
}
if( $('.sidebar-testimonial-wrapper').length ) {
$('.sidebar-testimonial-wrapper .carousel-container').slick({
autoplay: true,
autoplaySpeed: 20000,
infinite: true,
arrows: false,
dots: false,
slidesToShow: 1,
slidesToScroll: 1,
});
}
// News Carousel
if( $('.column-post-carousel').length ) {
$('.column-post-carousel').slick({
dots: true,
infinite: true,
autoplay: false,
arrows: false,
pauseOnHover: true,
autoplaySpeed: 7000,
speed: 300,
slidesToShow: 2,
slidesToScroll: 2,
responsive: [
{
breakpoint: 1023,
settings: {
slidesToShow: 2,
slidesToScroll: 1,
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
}
}
// You can unslick at a given breakpoint now by adding:
// settings: "unslick"
// instead of a settings object
]
});
}
// Instagram Carousel
if( $('.instagram-carousel').length ) {
$('.instagram-carousel .row').slick({
dots: false,
infinite: true,
autoplay: false,
arrows: true,
pauseOnHover: true,
autoplaySpeed: 7000,
speed: 300,
slidesToShow: 5,
slidesToScroll: 5,
responsive: [
/* {
breakpoint: 768,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
}
}, */
]
});
}
// Logo Carousel
if( $('.logo-carousel .carousel-container').length ) {
$('.logo-carousel .carousel-container').slick({
dots: false,
arrows: false,
infinite: true,
autoplay: true,
centerMode: true,
pauseOnHover: false,
autoplaySpeed: 0,
speed: 5000,
cssEase: 'linear',
slidesToShow: 1,
slidesToScroll: 1,
initialSlide: 1,
variableWidth: true,
});
}
// CTA Carousel
if( $('.cta-carousel').length ) {
$('.cta-carousel').slick({
dots: true,
infinite: true,
autoplay: true,
arrows: false,
pauseOnHover: true,
autoplaySpeed: 8000,
speed: 300,
slidesToShow: 1,
slidesToScroll: 1,
});
}
if($(".box-item .heading").length){
$(".box-item .heading").dotdotdot({
height: 80,
fallbackToLetter: true,
watch: true,
});
}
if( $('.truncate-text, .truncate') ) {
$('.truncate-text, .truncate').dotdotdot();
}
if( $('.carousel-cols-3').length ) {
$('.carousel-cols-3 .row').slick({
dots: false,
infinite: true,
autoplay: true,
autoplaySpeed: 20000,
arrows: true,
speed: 300,
slidesToShow: 3,
slidesToScroll: 1,
responsive: [
{
breakpoint: 767,
settings: {
slidesToShow: 2,
slidesToScroll: 2,
}
},
{
breakpoint: 539,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
}
}
],
});
}
if( $('.carousel-cols-4').length ) {
$('.carousel-cols-4 .row').slick({
dots: false,
infinite: true,
arrows: true,
speed: 300,
slidesToShow: 4,
slidesToScroll: 4,
responsive: [
{
breakpoint: 1023,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 2,
slidesToScroll: 2,
}
},
{
breakpoint: 539,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
}
}
],
});
}
/* Add OS and Browser Class */
custom_detect_browser(['Windows', 'Mac', 'Chrome']);
function custom_detect_browser(a){
for(i=0; i < a.length; i++){
if(navigator.appVersion.indexOf(a[i]) > 0){
$('body').addClass(a[i].toLowerCase());
}
}
}
/* 404 Button */
if( $('#btn-404').length ) {
//new Vivus('btn-404', {start:'inViewport',type:'oneByOne', duration: 50}, '');
}
/* Map Pointer Events */
$('.embed-container-maps').click(function () {
$('.embed-container-maps iframe').css('pointer-events', 'auto');
});
$('.embed-container-maps').mouseleave(function(){
$('.embed-container-maps iframe').css('pointer-events', 'none');
});
/* Swap Sections */
var width = $( window ).width();
if( $('.swap-sections').length ){
if( width < 768 ) {
swap_sides('swap');
} else {
swap_sides('default');
}
$( window ).resize(function() {
var width = $( window ).width();
// Mobile Style Fix
if( width < 768 ) {
swap_sides('swap');
} else {
swap_sides('default');
}
});
}
function swap_sides(action){
if(action == 'swap') {
$('.swap-sections').each(function(){
$(this).find('.image-container').after($(this).find('.content-container'));
});
} else {
// Default
$('.swap-sections').each(function(){
$(this).find('.image-container').before($(this).find('.content-container'));
});
}
}
// Advanced Search Form
var resizing = false,
searchForm = $('.cd-main-search'),
searchTrigger = $('.asf-trigger');
if( searchTrigger.length ) {
function closeSearchForm() {
searchTrigger.removeClass('search-form-visible');
searchForm.removeClass('is-visible');
}
$(document).on('click', '.asf-trigger', function(event){
event.preventDefault();
if( searchTrigger.hasClass('search-form-visible') ) {
searchForm.find('form').submit();
} else {
searchTrigger.addClass('search-form-visible');
searchForm.addClass('is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
searchForm.find('input[type="search"]').focus().end().off('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend');
});
}
});
// Close search form
searchForm.on('click', '.asf-close', function(){
closeSearchForm();
});
$(document).keyup(function(event){
if( event.which=='27' ) closeSearchForm();
});
}
// Set Equal Heights
if( $('.half-box').length ){
equalHeight($('.half-box'));
}
if( $('.box-item .heading').length ){
equalHeight($('.box-item .heading'));
}
if( $('.box-item .content').length ){
equalHeight($('.box-item .content'));
}
if( $('.image-box-style-1').length ){
equalHeight($('.image-box-style-1'));
}
if( $('.box-item .content').length ){
equalHeight($('.box-item .content'));
}
if( $('.equal-height-columns').length ) {
ff_set_equal_heights(
'.equal-height-columns',
'.so-panel, .panel-widget-style'
);
}
// Captcha Placeholder
var placeholder = $('.custom-form-v2 .captcha-container .gfield_label');
if( placeholder.length ) {
$('.custom-form-v2 .captcha-container input[type="text"]').attr('placeholder', placeholder.text());
}
/* if( $('.site-header').length ) {
// Sticky Header
ff_sticky_element('.site-header', 99999, 0, true, '',
function(){
$('body').removeClass('sticky-header-deactivated').addClass('sticky-header-activated');
},
function(){
$('body').removeClass('sticky-header-activated').addClass('sticky-header-deactivated');
}
);
} */
function ff_sticky_element(el, scroll_stick_limit, scroll_offset, sticky_spacer, sticky_spacer_height, activation_callback, deactivate_callback){
var sticky_element = $(el),
sticky_element_pos = sticky_element.offset().top,
current_scroll_pos,
sticky_spacer_el;
// Defaults
scroll_stick_limit = ( scroll_stick_limit === undefined ) ? 99999 : scroll_stick_limit;
scroll_offset = ( scroll_offset === undefined ) ? false : scroll_offset;
sticky_spacer = ( sticky_spacer === undefined ) ? false : sticky_spacer;
activation_callback = ( activation_callback === undefined ) ? false : activation_callback;
deactivate_callback = ( deactivate_callback === undefined ) ? false : deactivate_callback;
if( scroll_offset ) {
// offset position for sticky element activation
sticky_element_pos += scroll_offset;
}
if( sticky_spacer ) {
// Fix for space bump on position fix activate
sticky_spacer_height = ( sticky_spacer_height === undefined || sticky_spacer_height == false || sticky_spacer_height == '' ) ? sticky_element.outerHeight() : sticky_spacer_height;
sticky_spacer_el = $('').css('position', 'absolute');
sticky_element.before(sticky_spacer_el);
}
sticky_element.addClass('stick-init');
//var sticky_did_scroll = false;
$(window).scroll(function(){
ff_on_scroll_sticky();
});
// Set Interval 300ms for performance improvement
/* setInterval(function() {
if(sticky_did_scroll) {
sticky_did_scroll = false;
}
}, 300); */
function ff_on_scroll_sticky(){
//sticky_did_scroll = true;
current_scroll_pos = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
if( current_scroll_pos > sticky_element_pos && current_scroll_pos < sticky_element_pos + scroll_stick_limit ) {
// Activate sticky - if scroll position gets past the element position + offset , until scroll_stick_limit is reached
if( sticky_element.hasClass('stick') ) {
return false;
}
sticky_element.removeClass('unstick').addClass('stick');
if( sticky_spacer ) {
sticky_spacer_el.css('position', 'relative');
}
if( activation_callback ) {
activation_callback();
}
} else {
// Deactivate Sticky
if( sticky_element.hasClass('unstick') ) {
return false;
}
sticky_element.removeClass('stick').addClass('unstick');
if( sticky_spacer ) {
sticky_spacer_el.css('position', 'absolute');
}
if( deactivate_callback ) {
deactivate_callback();
}
}
}
}
// Breadcrumb Special Links
var special_links = JSON.parse(site_data.breadcrumb_special_links);
if( special_links != null ) {
var i;
for ( i = 0; i < special_links.length; i++ ) {
var string = special_links[i].link.split('|')[0];
var string_with_markup = special_links[i].link.split('|')[1];
var breadcrumb_string = $('.breadcrumb:contains("'+ string +'")');
if( breadcrumb_string.length ) {
breadcrumb_string.html(breadcrumb_string.html().replace(string, string_with_markup));
}
}
}
// Sticky Header - Headhesive
if($(site_data.sticky_header_selector).length){
var options = {
offset: '#sticky_header_trigger_point',
classes: {
clone: 'site-header--clone',
stick: 'site-header--stick',
unstick: 'site-header--unstick'
},
onStick: function(){
custom_dropdown_menu_close();
},
onUnstick: function(){
custom_dropdown_menu_close();
},
};
// Initialise with options
var header = new Headhesive(site_data.sticky_header_selector, options);
}
// Custom Animation
$.fn.visible = function(partial) {
var $t = $(this),
$w = $(window),
viewTop = $w.scrollTop(),
viewBottom = viewTop + $w.height(),
_top = $t.offset().top,
_bottom = _top + $t.height(),
compareTop = partial === true ? _bottom : _top,
compareBottom = partial === true ? _top : _bottom;
return ((compareBottom <= viewBottom) && (compareTop >= viewTop));
};
var win = $(window);
function animate_element(selector){
var animation_name = selector.split("animate-")[1];
var animate_el = $('.'+ selector);
win.scroll(function(event) {
animate_el.each(function(i, el) {
var el = $(el);
if (el.visible(true)) {
el.addClass(animation_name);
}
});
});
}
/* Custom Dropdown Menu */
if( $('.burger-menu-trigger').length ) {
$('body').on('click', '.burger-menu-trigger', function(){
var button = $(this);
var menu = $(this).next('.menu-container');
if( $(this).hasClass('active') ) {
// Hide Menu
button.removeClass('active');
menu.removeClass('active');
} else {
// Show Menu
button.addClass('active');
menu.addClass('active');
}
});
$('body').click(function(e) {
if( $(e.target).closest('#ff-custom-dropdown-menu').length == 0 ) {
custom_dropdown_menu_close();
}
})
}
function custom_dropdown_menu_close(){
$('#ff-custom-dropdown-menu .burger-menu-trigger').removeClass('active');
$('#ff-custom-dropdown-menu .menu-container').removeClass('active');
}
// Styles Page Navigation
if( $('.ff-styles-page').length ) {
var a = '';
a += '';
$('.entry-content .style-heading .widget-title').each(function(){
if( $(this).parent('.exclude').length ) {
// exclude
} else {
a += ''+ $(this).text() +'';
}
});
a += '
';
$('.entry-content').prepend(a);
$('.ff-styles-nav span').click(function(){
$('html, body').animate({
scrollTop: $('.widget-title:contains("'+ $(this).text() +'")').offset().top - 130
}, 100);
});
$('body').append('');
$('.ff-scroll-to-top').click(function(){
$('html, body').animate({ scrollTop: 0 }, 100);
})
}
// Footer CTA
if( $('.footer-sticky-cta').length ) {
if( $.cookie('close-footer-cta') == undefined ) {
$('body').addClass('with-footer-sticky-cta');
} else {
$('.footer-sticky-cta').addClass('disabled');
}
}
$('.footer-sticky-cta .close-btn').click(function(){
$('.footer-sticky-cta').addClass('disabled');
$('body').removeClass('with-footer-sticky-cta');
$.cookie('close-footer-cta', true, { expires: 1, path: '/' })
});
function footer_cta_stick_check() {
if( $.cookie('close-footer-cta') == undefined ) {
if( window.pageYOffset > site_data.footer_sticky_cta_offset ) {
// Activate Footer
$('body').addClass('with-footer-sticky-cta');
$('.footer-sticky-cta').removeClass('unstick slide-out-bck-bottom').addClass('stick slide-in-fwd-bottom');
} else {
// Deactivate Footer CTA
$('body').removeClass('with-footer-sticky-cta');
$('.footer-sticky-cta').removeClass('stick slide-in-fwd-bottom').addClass('unstick slide-out-bck-bottom');
}
}
}
/*var $header;
var $header_init_height;
header_stick_init();
function header_stick_init(){
$header = $('.site-header');
$header_init_height = $header.outerHeight();
if( $header.parent().attr('class') != 'sticky-header-spacer' ) {
$header.wrap('