/*
*
* Descrip: Site wide script calls
*
*/
jQuery(document).ready(function () {
"use strict";
//aos
AOS.init();
//foundation
$(document).foundation();
//prevent glitchy slider
function animateOpacity(selector) {
$(selector).on('init', function(event, slick){
$(selector).animate({ opacity: 1 });
});
}
animateOpacity('.banner-showcase');
animateOpacity('.featured-work-slide');
animateOpacity('.insight-slide');
animateOpacity('.video-slider');
animateOpacity('.testimonial-slide');
animateOpacity('.featured-work-slide-lessthan-3-col');
//slick carousel
$(window).on('load', function() {
function initializeSlides(selector, slidesToShow, breakpointSettings, autoplay, autoplaySpeed) {
$(selector).slick({
dots: false,
infinite: true,
speed: 300,
slidesToShow: slidesToShow,
slidesToScroll: 1,
autoplay: autoplay,
autoplaySpeed: autoplaySpeed,
responsive: breakpointSettings
});
}
const commonBreakpoints = [
{
breakpoint: 1024,
settings: {
slidesToShow: 2,
slidesToScroll: 1,
infinite: true,
dots: false
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
];
initializeSlides('.featured-work-slide-lessthan-3-col', 2, commonBreakpoints, false, 8000);
initializeSlides('.featured-work-slide', 3, commonBreakpoints, false, 8000);
initializeSlides('.insight-slide', 3, commonBreakpoints, false, 8000);
initializeSlides('.video-slider', 3, commonBreakpoints, true, 6000);
$('.banner-showcase').slick({
dots: true,
infinite: true,
arrows: false,
autoplay: true,
autoplaySpeed: 7000,
fade: true,
cssEase: 'linear'
});
$('.testimonial-slide').slick({
dots: false,
infinite: true,
adaptiveHeight: true,
});
});
// change the rest of the list to grey on hover
const liElements = document.querySelectorAll('#services-accordion-hover li');
liElements.forEach((li) => {
li.addEventListener('mouseenter', () => {
liElements.forEach((otherLi) => {
if (otherLi !== li) {
otherLi.classList.add('hovered');
}
});
});
li.addEventListener('mouseleave', () => {
liElements.forEach((otherLi) => {
if (otherLi !== li) {
otherLi.classList.remove('hovered');
}
});
});
});
//mailchimp ajax sign up
$('.sign-up-form button').on('click', function(e){
e.preventDefault();
//get the form
var $form = $(this).parent().parent().parent();
var responseDivSuccess = $('#mce-responses #mce-success-response');
var responseDivError = $('#mce-responses #mce-error-response');
//clear error div
responseDivError.html('');
var error_free = true;
//check if fields are populated
if($($form).find('input') === ''){
error_free = false;
responseDivError.html('Email address is required.');
responseDivError.show();
}
//consent
if($($form).find('input.checkbox_style_one').is(":checked")){
} else {
error_free = false;
responseDivError.append('
Consent checkbox should be ticked.');
responseDivError.show();
}
if(error_free == true) {
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
cache: false,
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
if (data && data.result == "success") {
//hide form
//console.log(JSON.stringify(data)); //for testing
$form.hide();
//show success message
responseDivSuccess.html(data.msg);
responseDivSuccess.show();
//set timer and hide subscribe widget + add cookie
$.cookie("signupWidgetClosed", 1, { expires : 1 });
//hide widget & form container after 2 seconds
setTimeout(function(){
signupWidget.hide();
signupFormContainer.hide();
}, 2000);
} else {
responseDivError.html('Something went wrong. Please try again later.');
responseDivError.show();
//console.log(JSON.stringify(data)); //for testing
}
},
error: function (error) {;
//console.log(JSON.stringify(error)); //for testing
responseDivError.html('Something went wrong. Please try again later.');
responseDivError.show();
}
});
}
});
// init clock
if($('.clockbox').length > 0){
setInterval(run_the_clock, 1000);
//get AM/PM and update the fields
$('.clockbox').each(function (){
//get am / pm from the offset
let clockId = $(this).attr('id'),
cityOffset = $('#'+clockId+' input#city-offset').val(),
date = calcTime(cityOffset);
});
}
// read less more testimonials
$('.testimonial-item .read-more').on('click', function(e){
e.preventDefault();
$(this).hide();
$(this).parent().find('.read-less').show();
$(this).parent().find('.read-more').hide();
});
$('.testimonial-item .read-less').on('click', function(e){
e.preventDefault();
$(this).hide();
$(this).parent().find('.read-more').show();
$(this).parent().find('.read-less').hide();
});
var featuredWork = $('.flexible-featured-work');
// carousel for featured work
if(featuredWork.length > 0){
featuredWork.find('.mobile-carousel').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoplay: false,
infinite: false,
});
}
$(window).resize(function(){
var width = $(window).width();
if(width > 1024){
//toggle mobile nav to hide
//check if mobile nav is active and if yes toggle it
if($('body').hasClass('mobile-menu-show')){
//animation out
var $animation = $("#mobile-navigation").data("animation");
MotionUI.animateOut($("#mobile-navigation"), $animation);
$('.m-menu.hamburger').removeClass('is-active');
if($('body').hasClass('mobile-menu-show')){
$('body').removeClass('mobile-menu-show noscroll');
}
}
}
if(width < 1200){
// close search desktop-header
if($('.desktop-header').hasClass('search-open')) {
$('.desktop-header .header-search .hamburger-box').trigger('click');
}
} else {
// close search desktop-header
if($('.header-mobile').hasClass('search-open')) {
$('.header-mobile .header-search .hamburger-box').trigger('click');
}
}
});
/*
*
* Collapse News and Media Accordion on Mobile devices
*
*/
if( $('.flexible-news-and-media-grid').length > 0 ) {
if( $(window).width() < 640 ) {
$('.flexible-news-and-media-grid .accordion li.is-active a').trigger('click');
}
$(window).resize(function(){
if( $(window).width() < 640 ) {
//$('.flexible-news-and-media-grid .accordion li.is-active a').trigger('click');
} else {
if( !$('.flexible-news-and-media-grid .accordion li:nth-child(1)').hasClass('is-active') ) {
$('.flexible-news-and-media-grid .accordion li:nth-child(1) > a').trigger('click');
}
}
});
}
/*
*
* Sticky Widget- Desktop
*
*/
if( $('.sticky-widget.desktop').length > 0 ) {
var $sticky_widget_desktop = $('.sticky-widget.desktop');
$('.sticky-widget.desktop .show-sticky-widget').on('click', function(){
$sticky_widget_desktop.addClass('is-visible');
});
$('.sticky-widget.desktop .hide-sticky-widget').on('click', function(){
$sticky_widget_desktop.removeClass('is-visible');
});
}
/*
*
* Sticky Widget- Mobile
*
*/
if( $('.sticky-widget.mobile').length > 0 ) {
let $sticky_widget = $('.sticky-widget.mobile .content'),
$sticky_content = $sticky_widget.find('> div'),
$tgtHeight;
$('.sticky-widget.mobile .show-sticky-widget').on('click', function() {
if( $(this).hasClass('active') ){
$(this).removeClass('active');
$sticky_widget.animate({height: 0}, 250, function() {
});
$sticky_widget.parent().parent().removeClass('is-visible');
} else {
$tgtHeight = $sticky_content.outerHeight();
$(this).addClass('active');
$sticky_widget.animate({height: $tgtHeight}, 250, function() {
$sticky_widget.css({
'height': 'auto',
})
});
$sticky_widget.parent().parent().addClass('is-visible');
}
});
}
/*
*
* Add Margin Bottom to Footer if Mobile Sticky Widget is visible
*
*/
if( $('.sticky-widget.mobile').length > 0 ) {
if( $('.sticky-widget.mobile').is(':visible') ){
$('footer').addClass('sticky-exists');
}
}
/*
*
* Sticky Widget
* Home page Expend Widget near Introduction section
*
*/
if( $('.sticky-widget.desktop').length > 0 ) {
if( $('body.home').length > 0 || $('body.page-template-template-landing-page-builder').length > 0 ){
$(window).scroll(function() {
if( $(window).width() > 640 ) {
if ($(document).scrollTop() > 200) {
if( !$('.sticky-widget.desktop').hasClass('is-visible') ){
if( !$('.sticky-widget.desktop .show-sticky-widget').attr('data-scroll-activated') == 1 ){
$('.sticky-widget.desktop .show-sticky-widget').attr('data-scroll-activated', '1');
$('.sticky-widget.desktop .show-sticky-widget').trigger('click');
}
}
}
}
});
}
}
/*
*
* Sticky Widget
* Home page Collapse Widget near Introduction section
*
*/
if( $('.sticky-widget.desktop').length > 0 ) {
if( $('body.home').length > 0 || $('body.page-template-template-landing-page-builder').length > 0 ){
$(window).scroll(function() {
if( $(window).width() > 640 ) {
if ($('#trigger-floating-slider')) {
let ele = $('#trigger-floating-slider');
let curPos = ele.offset().top;
if ($(document).scrollTop() > (curPos - 200)) {
if ($('.sticky-widget.desktop').hasClass('is-visible')) {
if ($('.sticky-widget.desktop .show-sticky-widget').attr('data-scroll-activated') == 1) {
$('.sticky-widget.desktop .hide-sticky-widget').attr('data-scroll-activated', '1');
$('.sticky-widget.desktop .hide-sticky-widget').trigger('click');
}
}
}
}
}
});
}
}
/*
*
* Search bar
* Global search component reveal
*
*/
if( $('.show-search').length > 0 ) {
let searchOverlay = $('.search-overlay');
$('.show-search').each(function () {
let theHeader = $(this).parents('header'),
headerSearch = theHeader.find('.header-search'),
searchWrap = headerSearch.find('.search-wrap'),
btnClose = searchWrap.find('.hamburger-box');
let isTransparentBody = document.querySelector(".is-header-transparent");
if(isTransparentBody){
var transparentBody = document.querySelector(".is-transparent");
}
$(this).click(function (e) {
if(isTransparentBody) {
transparentBody.classList.remove("is-transparent");
}
e.preventDefault();
theHeader.toggleClass('search-open');
let openHeight = searchWrap.outerHeight();
// animate open header search
headerSearch.css({
opacity: 1,
})
headerSearch.animate({
height: openHeight,
}, 300, function() {
headerSearch.css({
height: 'auto',
})
});
// set input field active
headerSearch.find('input[name="s"]').focus();
// close mobile menu if open and reset mobile header
if($('.hamburger.m-menu').hasClass('is-active')) {
$('.hamburger.m-menu').trigger('click');
// $('header.header-mobile').removeClass('search-open');
}
// apply click method on search overlay
searchOverlay.unbind('click').click(function () {
btnClose.trigger('click');
})
// show overlay
if(!searchOverlay.hasClass('show')) {
searchOverlay.addClass('show');
$('body').addClass('noscroll');
toggleSearchOverlay(true);
}
})
btnClose.click(function (e) {
let scrollPercent = 100 * $(window).scrollTop() / ($(document).height() - $(window).height());
theHeader.toggleClass('search-open');
if(isTransparentBody) {
if (!(scrollPercent >= 5)) {
transparentBody.classList.add("is-transparent");
}
}
// animate close header search
headerSearch.animate({
height: 0,
opacity: 0,
}, 300);
// show overlay
if(searchOverlay.hasClass('show')) {
searchOverlay.removeClass('show');
$('body').removeClass('noscroll');
toggleSearchOverlay(false);
}
})
})
function toggleSearchOverlay(cond) {
let o = cond ? 1 : 0,
h = cond ? '100vh' : 0,
w = cond ? '100vw' : 0;
if (cond) {
searchOverlay.css({
height: h,
width: w,
})
}
searchOverlay.animate({
opacity: o,
}, 300, function() {
if (!cond) {
searchOverlay.css({
height: h,
width: w,
})
}
});
}
}
/*
*
* Search bar filters
* Global search filters reveal
*
*/
if( $('.search-filter .cat-type').length > 0 ) {
$('.search-filter .cat-type').each(function () {
let catBtn = $(this),
colParent = catBtn.parents('.column'),
subCatWrap = catBtn.next('.sub-cat-wrap'),
subCatInner = subCatWrap.find('.sub-cat-type');
catBtn.click(function (e) {
e.preventDefault();
colParent.addClass('clicked');
$('.search-filter .column.active').each(function () {
if (!$(this).hasClass('clicked')) {
$(this).removeClass('active');
$(this).find('.sub-cat-wrap').animate({
height: 0,
}, 250);
}
});
if(colParent.hasClass('active')) {
colParent.removeClass('active');
// animate close sub filter category
subCatWrap.animate({
height: 0,
}, 250, function() {
colParent.removeClass('clicked');
});
} else {
colParent.addClass('active');
let openHeight = subCatInner.outerHeight();
// animate open header search
subCatWrap.animate({
height: openHeight,
}, 250, function() {
colParent.removeClass('clicked');
subCatWrap.css({
height: 'auto',
})
});
}
});
})
}
/*
*
* Top Categories bar filters
* Global search filters reveal
*
*/
if( $('.row.top-categories .cat-type').length > 0 ) {
$('.row.top-categories .cat-type').each(function () {
let catBtn = $(this),
colParent = catBtn.parents('.column'),
subCatWrap = catBtn.next('.sub-cat-wrap'),
subCatInner = subCatWrap.find('.sub-cat-type'),
openHeight = subCatInner.outerHeight();
catBtn.click(function (e) {
e.preventDefault();
colParent.addClass('clicked');
openHeight = subCatInner.outerHeight();
let $del = 0;
$('.row.top-categories .column.active').each(function () {
if (!$(this).hasClass('clicked')) {
let $opened = $(this),
$openedHeight = $opened.find('.sub-cat-type').outerHeight();
$del = 200;
$opened.removeClass('active');
$opened.find('.sub-cat-wrap').addClass('animate').css({
height: $openedHeight,
});
$opened.find('.sub-cat-wrap').animate({
height: 0,
}, 200, function() {
$opened.find('.sub-cat-wrap').removeClass('animate');
});
}
});
if(colParent.hasClass('active')) {
colParent.removeClass('active');
// animate close sub filter category
subCatWrap.addClass('animate');
subCatWrap.css({
height: openHeight,
})
subCatWrap.animate({
height: 0,
}, 250, function() {
subCatWrap.removeClass('animate');
colParent.removeClass('clicked');
});
} else {
colParent.addClass('active');
// animate open header search
subCatWrap.addClass('animate');
setTimeout(function (){
subCatWrap.animate({
height: openHeight,
}, 250, function() {
colParent.removeClass('clicked');
subCatWrap.removeClass('animate');
});
}, $del);
}
});
})
}
/*
*
* Single Project page
* Sticky Widget
*
**/
if( $('body.single-projectsx').length > 0 ){
/*
*
* Our Work - Sticky Widget Filter - Top category
*
*/
$('.sticky-widget.our-work .top-categories > li > a').on('click', function(e){
e.preventDefault();
if( $(this).hasClass('active') ){
$(this).removeClass('active');
$(this).parent().removeClass('active');
} else {
$(this).addClass('active');
$(this).parent().addClass('active');
}
});
/*
*
* Our Work - Sticky Widget Filter - First Category is active
*
*/
$('.sticky-widget.our-work .top-categories > li:first-child').addClass('active');
$('.sticky-widget.our-work .top-categories > li:first-child > a').addClass('active');
}
/*
*
* Our Work Scripts
*
*/
if( $('.flexible-our-work').length > 0 ){
/*
*
* Our Work - Load More
*
*/
var projects_load_more_button = $('.flexible-our-work button#load-more-projects'),
projects_output_container = $('.flexible-our-work .content .projects-grid'),
project_loader = $('.flexible-our-work .projects-load-more .loader');
projects_load_more_button.on('click', function(e){
e.preventDefault();
// project_loader.show();
// projects_load_more_button.hide();
var $child_term_id = projects_load_more_button.attr('data-child-term-id'),
$parent_term_id = projects_load_more_button.attr('data-parent-term-id'),
$paged = projects_load_more_button.attr('data-paged');
load_more_projects( $parent_term_id, $child_term_id, $paged );
});
/*
*
* Our Work - Filter - Top category
*
*/
$('.flexible-our-work .top-categories > li > a').on('click', function(e){
e.preventDefault();
if( $(this).hasClass('active') ){
$(this).removeClass('active');
$(this).parent().removeClass('active');
//projects_content_align( false );
} else {
$(this).addClass('active');
$(this).parent().addClass('active');
// projects_content_align( true );
}
});
/*
*
* Our Work - Filter - Top category
* Align Grid on Page load if any active Top Category present
*
*/
if( $('.flexible-our-work .top-categories > li.active' ).length ){
projects_content_align( true );
}
/*
*
* Our Work - Sticky Widget Filter - Top category
*
*/
$('.sticky-widget.our-work .top-categories > li > a').on('click', function(e){
e.preventDefault();
if( $(this).hasClass('active') ){
$(this).removeClass('active');
$(this).parent().removeClass('active');
} else {
$(this).addClass('active');
$(this).parent().addClass('active');
}
});
/*
*
* Our Work - Sticky Widget Filter - First Category is active
*
*/
$('.sticky-widget.our-work .top-categories > li:first-child').addClass('active');
$('.sticky-widget.our-work .top-categories > li:first-child > a').addClass('active');
/*
*
* Our Work - Sticky Widget Filter - Sub category
*
*/
$('.sticky-widget.our-work .sub-categories > li > a').on('click', function(e){
e.preventDefault();
if( $(this).hasClass('active') ){
$(this).removeClass('active');
$(this).parent().removeClass('active');
//update load more button parameters
projects_load_more_button.attr('data-parent-term-id', $(this).parent().parent().parent().find('> a').attr('data-term-id') );
projects_load_more_button.attr('data-child-term-id', $(this).attr('data-term-id') );
projects_load_more_button.attr('data-paged', 2 );
//update sub categories in the filter
update_projects_filter( projects_load_more_button.attr('data-parent-term-id'), projects_load_more_button.attr('data-child-term-id') );
//load projects
load_projects_by_filter( projects_load_more_button.attr('data-parent-term-id'), projects_load_more_button.attr('data-child-term-id'), 1 );
projects_content_align( true );
} else {
//remove from others first
$('.sticky-widget.our-work .sub-categories > li > a').find('.active').removeClass('active');
$('.sticky-widget.our-work .sub-categories > li').find('.active').removeClass('active');
$(this).addClass('active');
$(this).parent().addClass('active');
//update load more button parameters
projects_load_more_button.attr('data-parent-term-id', $(this).parent().parent().parent().find('> a').attr('data-term-id') );
projects_load_more_button.attr('data-child-term-id', $(this).attr('data-term-id') );
projects_load_more_button.attr('data-paged', 2 );
//update sub categories in the filter
update_projects_filter( projects_load_more_button.attr('data-parent-term-id'), projects_load_more_button.attr('data-child-term-id') );
//load projects
load_projects_by_filter( projects_load_more_button.attr('data-parent-term-id'), projects_load_more_button.attr('data-child-term-id'), 1 );
projects_content_align( true );
}
});
/*
*
* Move Content When menu is expended
*
*/
function projects_content_align( $value ){
if ( $value == true ){
//align by pushing down
projects_output_container.parent().addClass('expended');
} else {
//align by pushing up
projects_output_container.parent().removeClass('expended');
}
}
/*
*
* Our Work - Filter - Sub category
*
*/
$('.flexible-our-work .sub-cat-type > li > a').on('click', function(e){
e.preventDefault();
$(this).parents('.sub-cat-wrap').addClass('loading');
if( $(this).hasClass('active') ){
$(this).removeClass('active');
$(this).parent().removeClass('active');
// set active to ALL which is first on the list
$(this).parents('.sub-cat-type').find('li:first-child').addClass('active').find('a').addClass('active');
//update load more button parameters
projects_load_more_button.attr('data-parent-term-id', $(this).parents('.column').find('.cat-type a').attr('data-term-id') );
projects_load_more_button.attr('data-child-term-id', 0 );
projects_load_more_button.attr('data-paged', 2 );
//load projects
load_projects_by_filter( projects_load_more_button.attr('data-parent-term-id'), projects_load_more_button.attr('data-child-term-id'), 1 );
} else {
//remove from others first
$('.flexible-our-work .sub-cat-type > li > a').find('.active').removeClass('active');
$('.flexible-our-work .sub-cat-type > li').find('.active').removeClass('active');
$(this).addClass('active');
$(this).parent().addClass('active');
//update load more button parameters
projects_load_more_button.attr('data-parent-term-id', $(this).parent().parent().parent().find('> a').attr('data-term-id') );
projects_load_more_button.attr('data-child-term-id', $(this).attr('data-term-id') );
projects_load_more_button.attr('data-paged', 2 );
//load projects
load_projects_by_filter( projects_load_more_button.attr('data-parent-term-id'), projects_load_more_button.attr('data-child-term-id'), 1 );
}
});
/*
*
* Update Projects Filter Selected Parent and Child Categories
*
*/
function update_projects_filter( $parent_term_id, $child_term_id ){
$('.flexible-our-work .filter-wrapper ul.top-categories > li').each(function(){
if( $(this).find('a').attr('data-term-id') == parseInt( $parent_term_id ) ){
$(this).addClass('active');
$(this).find('a').addClass('active');
$(this).find('ul.sub-categories > li').each(function(){
if( $(this).find(' > a').attr('data-term-id') == parseInt( $child_term_id ) ){
$(this).addClass('active');
$(this).find(' > a').addClass('active');
} else {
$(this).removeClass('active');
$(this).find(' > a').removeClass('active');
}
});
} else {
$(this).removeClass('active');
$(this).find(' > a').removeClass('active');
}
});
}
/*
*
* Load More projects
*
*/
function load_more_projects( $parent_term_id, $child_term_id, $paged ){
project_loader.show();
projects_load_more_button.hide();
$.ajax({
url:ajax_object.ajax_url,
data: {
'action': 'projects_load_more',
'parent_category': $parent_term_id,
'child_category' : $child_term_id,
'paged': $paged
},
success:function(data){
//parse json data
$(data).insertAfter( projects_output_container.find('.single-project-item').last() );
//update paged value on the button
$paged++;
projects_load_more_button.attr('data-paged', $paged);
if(data === '') {
projects_load_more_button.hide();
projects_load_more_button.parent().append('
');
} else {
projects_load_more_button.show();
}
},
complete: function(){
//initiate equalizer on the added row
$(".being-lazy-interchange").unveilInterchange(200);
project_loader.hide();
},
error: function(errorThrown){
project_loader.hide();
projects_load_more_button.show();
}
});
return false;
}
/*
*
* Load More by Filter
*
*/
function load_projects_by_filter( $parent_term_id, $child_term_id, $paged ){
project_loader.show();
projects_load_more_button.hide();
if( projects_load_more_button.parent().find('.no-more-to-load').length > 0 ){
projects_load_more_button.parent().find('.no-more-to-load').remove();
}
$.ajax({
url:ajax_object.ajax_url,
data: {
'action': 'projects_load_more',
'parent_category': $parent_term_id,
'child_category' : $child_term_id,
'paged': $paged,
},
success:function(data){
//parse json data
projects_output_container.html(data);
if(data === ''){
projects_load_more_button.hide();
projects_load_more_button.parent().append('');
} else {
projects_load_more_button.show();
if( projects_load_more_button.parent().find('.no-more-to-load').length > 0 ){
projects_load_more_button.parent().find('.no-more-to-load').remove();
}
}
},
complete: function(){
//initiate equalizer on the added row
$(".being-lazy-interchange").unveilInterchange(200);
project_loader.hide();
$('.row.top-categories .sub-cat-wrap').removeClass('loading');
if( projects_load_more_button.parent().find('.no-more-to-load').length > 0 ){
} else {
projects_load_more_button.show();
}
},
error: function(errorThrown){
project_loader.hide();
projects_load_more_button.show();
}
});
return false;
}
}
/*
*
* Blog - Page load with pre filter
*
*/
if($('.blog-filter').length) {
let queryString = window.location.search;
if(queryString) {
let urlParams = new URLSearchParams(queryString);
if(urlParams.get('term')) {
setTimeout(function() {
$('.blog-filter ul li a[data-term-id=' + urlParams.get('term') + ']').trigger('click');
}, 500);
}
}
}
/*
*
* Blog - Filter
*
*/
$('.posts-filter .filter ul li a').on('click', function(e){
e.preventDefault();
if( $(this).hasClass('is-active') ){
//do nothing
} else {
$('.posts-filter .filter ul li a').removeClass('is-active');
$(this).addClass('is-active');
var $term_id = $(this).attr('data-term-id');
blog_posts_filter( $term_id );
}
});
/*
*
* Media
* Show More Publications
*
*/
$('.publicataions-feed-wrapper .action-control button').on('click', function(e){
e.preventDefault();
var publications_container = $(this).parent().parent();
publications_container.find('.publication-item.hidden').each(function(){
MotionUI.animateIn( $(this), 'fade-in' );
});
$(this).remove();
});
/*
*
* We Work With
* "Carousel"
*
*/
if( $('.flexible-we-work-with').length > 0 ) {
$('.project-groups-navigation ul li a.accordion-title').on('click', function(e){
e.preventDefault();
if( !$(this).hasClass('is-active') ){
$(this).parent().parent().find('.is-active').removeClass('is-active');
$(this).addClass('is-active');
$(this).parent().addClass('is-active');
}
we_work_arrow_nav($(this).attr('data-project-group-id'));
});
$('.project-groups-arrow-nav button').on('click', function(e){
e.preventDefault();
var $current_group = $('.project-group-wrapper.is-active').attr('data-project-group-id');
if( parseInt($current_group) == 1 ){
we_work_arrow_nav( parseInt($current_group)+1 );
we_work_accordion_nav( parseInt($current_group)+1 )
} else {
we_work_arrow_nav( parseInt($current_group)-1 );
we_work_accordion_nav( parseInt($current_group)-1 )
}
});
}
/*
*
* Scroll to Section
* Project Page
*
*/
$('ul.services-list-navigation li a').on('click', function(e){
e.preventDefault();
var parts = $(this).attr('href').split('#');
var part = parts[parts.length - 1];
var header = $('header.classic-header').outerHeight();
if( $('.classic-header.header-mobile').is(':visible') ){
header = $('.classic-header.header-mobile').outerHeight();
}
var offset_calculated = header;
setTimeout(function(){
$('html, body').animate({
scrollTop: $('#'+part).offset().top-offset_calculated
}, 1000);
}, 100);
});
/*
*
* Scroll to Section
*
*/
$('.scroll-to').on('click', function(e){
e.preventDefault();
var section = $(this).attr('data-scroll-to');
var header = $('header.classic-header').outerHeight();
if( $('.classic-header.header-mobile').is(':visible') ){
header = $('.classic-header.header-mobile').outerHeight();
}
var offset_calculated = header;
setTimeout(function(){
$('html, body').animate({
scrollTop: $('#'+section).offset().top-offset_calculated
}, 1000);
}, 100);
});
/*
*
* Scroll to Contact details
*
*/
$('a.scroll-to-phone').on('click', function(e){
e.preventDefault();
setTimeout(function(){
$('html, body').animate({
scrollTop: $('#being-contact-details').offset().top-150
}, 1000);
}, 100);
});
/*
*
* Our Work - Portfolio Filter
*
*/
$('.projects-navigation nav ul li a').on('click', function(e){
e.preventDefault();
if( $(this).hasClass('active') ){
//do nothing
} else {
$('.projects-navigation nav ul li a').removeClass('active');
$(this).addClass('active');
var parts = $(this).attr('href').split('#');
var part = parts[parts.length - 1];
projects_filter( part );
}
});
/*
*
* Trigger resize for Home page Case studies
*
*/
if( $('body').hasClass('home') ){
if( $('.flexible-case-studies-grid-type-one').length > 0 ){
$(window).resize();
}
}
/*
*
* Full Width Video - Style Two with Thumbnail and Play Button
* 2020
*/
if ($('.flexible-full-width-video thumbnail')) {
$('.flexible-full-width-video .thumbnail').each(function () {
var iframe = $(this).find('iframe');
var player = new Vimeo.Player(iframe);
var playerLayer = $(this).find('.placeholder-wrapper');
var playBtn = $(this).find('.play-video');
playBtn.click(function (e) {
e.preventDefault();
playerLayer.hide();
player.play();
})
player.on('pause', function() {
playerLayer.show();
});
});
}
var full_width_video_container,
full_width_video_root_container,
full_width_video_obj;
$('.flexible-full-width-video button.play-video').on('click', function(){
//collect data
var video_id = $(this).attr('data-video-id'),
video_type = $(this).attr('data-video-type'),
sound = $(this).attr('data-video-sound'),
autoplay = $(this).attr('data-video-autoplay'),
controls = $(this).attr('data-video-controls'),
loop = $(this).attr('data-video-loop'),
full_width_video_container = $(this).parent().parent().parent().parent().find('.custom-responsive-embed'),
full_width_video_root_container = $(this).parent().parent().parent().parent();
if ( video_type == 'vimeo' ){
var iframe = '';
full_width_video_container.html( iframe );
full_width_video_obj = full_width_video_container.find('iframe');
//resize iframe
align_being_video_iframe( full_width_video_root_container, full_width_video_obj );
} else if ( video_type == 'youtube' ) {
var iframe = '';
full_width_video_container.html( iframe );
full_width_video_obj = full_width_video_container.find('iframe');
//resize iframe
align_being_video_iframe( full_width_video_root_container, full_width_video_obj );
} else if ( video_type == 'mp4' ) {
var video = '';
full_width_video_container.html( video );
if( autoplay == 'autoplay' ){
full_width_video_container.find('video').get(0).play();
}
} else {
//error
}
full_width_video_root_container.removeClass('not-initiated');
full_width_video_root_container.addClass('initiated');
});
/*
*
* Full Width Video - Style Two iFrame Resize
* 2020
*
*/
$(window).resize(function(){
if( full_width_video_obj != '' && full_width_video_root_container != '' ){
// align_being_video_iframe( full_width_video_root_container, full_width_video_obj );
}
});
/*
*
*
* iFrame load on lick for Shortcode
*
*/
var iframe_container,
iframe_root_container,
iframe_obj;
$('.being-vimeo-iframe button.play-iframe-video').on('click', function(){
//collect data
var video_id = $(this).attr('data-vimeo-id'),
contorls = $(this).attr('data-video-sound'),
sound = $(this).attr('data-video-controls');
iframe_container = $(this).parent().parent().parent().parent().find('.being-responsive-embed'),
iframe_root_container = $(this).parent().parent().parent().parent();
var iframe = '';
iframe_container.html( iframe );
iframe_obj = iframe_container.find('iframe');
//resize iframe
align_being_video_iframe( iframe_root_container, iframe_obj );
iframe_root_container.removeClass('not-initiated');
iframe_root_container.addClass('initiated');
});
/*
*
*
* wpcf Accordion
*
*
*/
var acc = document.getElementsByClassName("wpcf-accordion");
var i;
// console.log(acc);
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.display === "block") {
panel.style.display = "none";
} else {
panel.style.display = "block";
}
});
}
/*
*
*
* iFrame Resize - New Script
*
*
*/
$(window).resize(function(){
if( iframe_root_container != '' && iframe_obj != '' ){
align_being_video_iframe( iframe_root_container, iframe_obj );
}
});
/*
*
* Service Page Accordion for Overview and Offerings
*
*/
if( $('.service-accordion').length > 0 ){
//on load
service_accordion();
//on resize
$(window).resize(function(){
service_accordion();
});
}
/*
*
*
* "Lazy Load" for Videos
*
*
*/
if( $('#staff-grid-wrapper .grid-posts-row ').length > 0 ){
let lazyLoadInstance = new LazyLoad();
}
/*
*
*
* Hide Contact form when Message is submitted
*
*
*/
$(document).on('DOMNodeInserted', function(e) {
if ( $(e.target).hasClass('wpcf7-mail-sent-ok') ) {
$('.contact-form li').hide();
}
});
// /*
// *
// * Main Nav Dropdown
// * TO BE REMOVED
// *
// */
//
// $('ul.menu li.dropdown > a').on('click', function(e){
// e.preventDefault();
// if( $(this).parent().hasClass('active') ){
// //remove to minimise
// $(this).parent().removeClass('active');
// } else {
// //add to expend
// $(this).parent().addClass('active');
// }
// });
/*
*
* Add Source Page to Contact Form
*
*/
if( $( '.submission-source' ).length > 0 ){
var current_page_url = window.location.href;
$( '.submission-source' ).val( current_page_url );
}
/*
*
* Landing Page - Add body class if LP form exists
* 2020
*
*/
if( $( '.lp-contact' ).length > 0 ){
$('body').addClass('landing-page');
}
if( $( '.covid-contact' ).length > 0 ){
$('body').addClass('landing-page');
}
/*
*
* Lazy Load with Unveil
* Foundation Interchange
*
*/
$(".being-lazy-interchange").unveilInterchange(50);
/*
*
* Lazy Load with Unveil
* Default WordPress Content
*
*/
$("img.size-full").unveilWordpress(50);
/*
*
* Show more projects
*
*/
$('.projects-action-control button#show-more-items').on('click', function(e){
e.preventDefault();
var $paged = $(this).val(),
$posts_per_page = $(this).attr('data-posts-per-page'),
$animation = $("#mobile-navigation").data("animation");
//calculate next posts to show
var posts_to_show_from = ( parseInt( $paged ) * $posts_per_page ) - ( parseInt( $posts_per_page ) - 1 ),
posts_to_show_to = parseInt( $paged ) * $posts_per_page;
var i = posts_to_show_from,
first_element = posts_to_show_from;
while ( i <= posts_to_show_to ) {
$(this).parent().parent().parent().parent().find('.single-project-item').each(function(){
if( $(this).attr('data-order-id') == i ) {
MotionUI.animateIn( $(this), 'fade-in' );
}
});
i++;
}
//scroll to down to the first element loaded
setTimeout(function(){
$('html, body').animate({
scrollTop: $(document).find('#project-item-'+posts_to_show_from).offset().top
}, 1000);
}, 700);
$(this).val( parseInt( $paged )+1 )
});
//popup for social media sharing widget
$('#social-sharing-widget a').on("click", function(e) {
e.preventDefault();
var blnResize = 'yes';
// Set values for window
var intWidth = '500';
var intHeight = '400';
var strResize = (blnResize ? 'yes' : 'no');
var left = ($(window).width()/2 - intWidth/2),
top = ($(window).height()/2 - intHeight/2);
// Set title and open popup with focus on it
var strParam = 'width=' + intWidth + ',height=' + intHeight + ',top=' + top + ',left=' + left + ',resizable=' + strResize;
var objWindow = window.open($(this).attr('href'), 'Share', strParam).focus();
});
//initiate clients logos carousel
if($('.logos-carousel').length > 0){
$('.logos-carousel').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000,
});
}
//resize instagram feed on small devices on load
if($('.flexible-instagram-feed').length > 0){
var width = $(window).width();
if(width < 640){
resize_instagram_feed();
}
}
//fix instagram feed on resize
$(window).resize(function(){
var width = $(window).width();
if($('.flexible-instagram-feed').length > 0){
if(width < 640){
resize_instagram_feed();
}
}
});
//remove scroll on mobile phones if mobile menu
var mobileMenu = $('.full-screen-mobile-menu');
$(mobileMenu).on('touchmove', function(e) {
e.preventDefault();
}, false);
// add expand button on mobile menu of have drop down
mobileMenu.find('nav ul.menu li.menu-item-has-children').append('');
mobileMenu.find('nav ul.menu li.menu-item-has-children .btn-sub').click(function (e) {
e.preventDefault();
$(this).parents('li.menu-item-has-children').toggleClass('expand-sub-menu');
})
//initite office maps
$('.office-map').each(function(){
var map = null;
// create map - refer to gmap.js file
map = new_map( $(this) );
});
//change letter in GDPR plugin button I Agree to I agree
if($('.gdpr-privacy-bar').length > 0){
$('button.gdpr-agreement').html('All good');
}
if($('.scroll-to-top').length > 0){
var $document = $(document);
var scrollToTop = $('.scroll-to-top');
var windowHeight = $(window).height();
$(scrollToTop).on('click', function(){
$('html, body').animate({
scrollTop: $('body').offset().top-100
}, 500);
});
}
function transparentHeader() {
var transparentBody = document.querySelector(".is-header-transparent");
var scrollPercent = 100 * $(window).scrollTop() / ($(document).height() - $(window).height());
if (scrollPercent >= 5) {
scrollToTop.show();
if(transparentBody) {
transparentBody.classList.remove("is-transparent");
}
} else {
scrollToTop.hide();
if(transparentBody) {
transparentBody.classList.add("is-transparent");
}
}
}
// Call the function on page load
$(document).ready(function() {
transparentHeader();
});
// Bind the function to the scroll event
$(window).scroll(function() {
transparentHeader();
});
//privacy BAR smooth processing
var gdprPrivacyBar = $('.gdpr-privacy-bar');
$('button.gdpr-agreement').on('click', function(e){
e.stopImmediatePropagation();
//set cookie for a day
$.cookie("gdpr[privacy_bar]", 1, { expires : 1, path: '/' });
//hide bar
gdprPrivacyBar.animate({bottom:'-100%'}, "slow");
});
//hamburger toggle
$('.right-part .hamburger').click(function(){
if($('.right-part .hamburger').hasClass('is-active')){
//animation out
var $animation = $("#mobile-navigation").data("animation");
MotionUI.animateOut($("#mobile-navigation"), $animation);
$('.right-part .hamburger').removeClass('is-active');
if($('body').hasClass('mobile-menu-show')){
$('body').removeClass('mobile-menu-show noscroll');
}
// $('.off-canvas').foundation('close', cb);
} else {
$('#mobile-navigation').show();
$('.right-part .hamburger').addClass('is-active');
if($('#mobile-navigation').hasClass('full-screen-mobile-menu')){
$('body').addClass('mobile-menu-show noscroll');
}
//animation in
var $animation = $("#mobile-navigation").data("animation");
MotionUI.animateIn($("#mobile-navigation"), $animation);
// close sticky menu if open
if($('.sticky-widget.is-visible')) {
$('.sticky-widget').removeClass('is-visible');
}
}
});
//flexslider options
$('.flexslider').flexslider();
//slick carousel
$('.slick').slick({
slidesToShow: 2,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000,
});
// featherlight slick
$('.fl-slick').featherlight({
afterOpen: function(event){
if(!this.$content.find('.slick-fl').hasClass('slick-initialized')) {
this.$content.find('.slick-fl').slick({
slidesToShow: 1,
slidesToScroll: 1,
centerMode: true,
variableWidth: true,
});
}
}
});
//load more button
if($('#load-more-posts').length > 0){
$('#load-more-posts').on('click', function(e){
var category = $(this).attr('data-term-id'),
posts_per_page = $(this).attr('data-posts-per-page'),
grid_layout = $(this).attr('data-grid-layout'),
equal_height = 1,
loader = $('.flexible-blog-posts-grid .loader'),
loadMoreBtn = $('#load-more-posts'),
paged = $(this).val();
e.preventDefault();
loadMoreBtn.hide();
loader.show();
$.ajax({
url:ajax_object.ajax_url,
data: {
'action': 'load_more_posts',
'category': category,
'posts_per_page': posts_per_page,
'grid_layout': grid_layout,
'equal_height' : equal_height,
'paged': paged,
},
success:function(data){
//parse json data
$(data).insertAfter( $('#posts-grid-wrapper .grid-posts-row .columns').last() );
//update paged value on the button
paged++;
$('#load-more-posts').val(paged);
loader.hide();
if(data === ''){
loadMoreBtn.hide();
$('.grid-posts-action-control').html('');
} else {
loadMoreBtn.show();
}
},
complete: function(){
//initiate equalizer on the added row
// Foundation.reInit('equalizer');
$(".being-lazy-interchange").unveilInterchange(200);
},
error: function(errorThrown){
//loader.hide();
loadMoreBtn.show();
}
});
return false;
});
}
//on page load check if there is a job id in url and show the content respectevily
if($('.flexible-jobs-and-internships').length > 0){
//get "id" from URL after hash sign
var hash = window.location.hash;
if(hash != ''){
var contentId = hash.substring(1, hash.length);
//remove current active item
$('.item-content .single-job-internship-item-content').removeClass('active-item');
//show the content
$('#'+contentId).addClass('active-item');
}
}
//provide download PDF link for Embeded PDF on mobile phones and tablets
if($('.responsive-embed.pdf').length > 0){
var $device_type = detectmob();
if($device_type === true){
//mobile or tablet
//hide object
$('.responsive-embed.pdf object').hide();
//show download pdf link
$('.responsive-embed.pdf .download-pdf').show();
}
}
//jobs tabs
if( $('.jobs-list-section .action-control button').length > 0 ){
var width = $(window).width();
var $animation = $(".flexible-jobs-and-internships .single-job-internship-item-content").data("animation");
//offset
var offset = 0;
if(width < 1024 && width > 640){
offset = 150;
} else if(width < 640){
offset = 80;
} else {
offset = 125;
}
$('.jobs-list-section .action-control button').on('click', function(e){
// console.log('here 3')
var width = $(window).width();
e.preventDefault();
var jobValue = $(this).val();
//check content items and show the required item
$('.item-content .single-job-internship-item-content').each(function(){
if( $(this).attr('id') === jobValue ){
//update url
history.pushState(null, null, '#'+jobValue);
//check if this already active
if( $(this).hasClass('active-item') ){
$('html, body').animate({
scrollTop: $('.flexible-jobs-and-internships .item-content').offset().top-offset
}, 1000);
} else {
//remove all active items first
$('.item-content .single-job-internship-item-content').removeClass('active-item');
//set this to active
$(this).addClass('active-item');
//animate
MotionUI.animateIn($(this), $animation);
//for mobile devices add a scroll to;
if( width < 640 ) {
$('html, body').animate({
scrollTop: $('.flexible-jobs-and-internships .item-content' ).offset().top-offset
}, 500);
}
}
}
});
});
}
//scroll to columns News and Media
if($('.scroll-to-column-links').length > 0){
//close functionality
$(".scroll-to-column-target .action-control span").on('click', function(e){
e.preventDefault();
//get part
var part = $(this).parent().parent().attr('id');
scroll_to_column(part);
});
//scroll to functionality
$('.scroll-to-column-links li a').on('click', function(e){
e.preventDefault();
var parts = $(this).attr('href').split('#');
var part = parts[parts.length - 1];
scroll_to_column(part);
});
}
$(document).on('wppopups.popup_opened', function(e,id){
$('body').addClass('noscroll');
});
$(document).on('wppopups.popup_closed', function(e,id){
$('body').removeClass('noscroll');
});
const items = document.querySelectorAll('.item-category');
items.forEach(item => {
item.addEventListener('mouseover', () => {
if (!item.classList.contains('active')) {
items.forEach(otherItem => {
if (otherItem !== item) {
otherItem.style.opacity = '0.5';
}
});
}
});
item.addEventListener('mouseout', () => {
if (!item.classList.contains('active')) {
items.forEach(otherItem => {
if (otherItem !== item) {
otherItem.style.opacity = '1';
}
});
}
});
});
});
//resize instagram feed
function resize_instagram_feed(){
$('.flexible-instagram-feed #sbi_images .sbi_item').each(function(){
var imageWidth = $(this).find('.sbi_photo').width();
//set height
$(this).find('.sbi_photo').height(imageWidth);
});
}
//align contact groups on contact page
function align_contact_groups(){
var contactDetailsHeight = 300;
$('.flexible-contact-us .office').each(function(){
if($(this).find('.contact-details').outerHeight() > contactDetailsHeight){
//override
contactDetailsHeight = $(this).find('.contact-details').outerHeight();
$(this).find('.contact-details').css('height', contactDetailsHeight);
} else {
$(this).find('.contact-details').css('height', contactDetailsHeight);
}
});
}
function scroll_to_job(){
//get animation
var $animation = $(".flexible-jobs-and-internships .single-job-internship-item-content").data("animation");
}
function show_and_scroll_case_studies($this, scrollToSection){
var $animation = $(".case-study-column .body").data("animation");
var fixedPosElementsHeight = 0;
//add mobile header height
fixedPosElementsHeight = $('.header-mobile').outerHeight()-1;
//add subscribe if visible
if($('.signup-widget-wrapper.mobile:visible').length > 0){
fixedPosElementsHeight = fixedPosElementsHeight + $('.signup-widget-wrapper.mobile .signup-widget-part-one').outerHeight();
}
//animate the content and then scroll
//add expended class
if($this.hasClass('expended')){
$($this).removeClass('expended');
//find and show the content of the column
MotionUI.animateOut($('.case-studies #'+scrollToSection+ ' .body'), $animation);
$('html, body').animate({
scrollTop: $('.case-studies #'+scrollToSection).position().top-fixedPosElementsHeight
}, 500);
} else {
$($this).addClass('expended');
MotionUI.animateIn($('.case-studies #'+scrollToSection+ ' .body'), $animation);
//scroll to the column
setTimeout(function(){
$('html, body').animate({
scrollTop: $('.case-studies #'+scrollToSection).position().top-fixedPosElementsHeight
}, 500);
}, 500);
}
}
function scroll_to_column(part){
var links = $('.scroll-to-column-links');
var $animation = $(".scroll-to-column-target").data("animation");
$('.flexible-news-and-media-grid .single-column').each(function(){
if($(this).attr('id') == part){
if($(this).hasClass('expended')){
MotionUI.animateOut($(this), $animation);
$(this).removeClass('expended');
} else {
MotionUI.animateIn($(this), $animation);
$(this).addClass('expended');
}
} else {
if($(this).hasClass('expended')){
MotionUI.animateOut($(this), $animation);
$(this).removeClass('expended');
}
}
})
}
//run the clock
function run_the_clock(){
//loop through each office clock
$('.clockbox').each(function (){
let $this = $(this),
cityOffset = $this.find('input#city-offset').val(),
cityName = $this.find('input#city-name').val(),
date = calcTime(cityOffset),
period = (date.getHours() >= 12) ? 'PM' : 'AM',
hourHand = $this.find('svg #hour'),
minuteHand = $this.find('svg #minute'),
secondHand = $this.find('svg #second'),
periodDiv = $this.find('div.am-pm');
// currently we only have 2 timezones, as the location added the object will be having more according to city offset
const timeZoneMap = {
"0": "GMT",
"1": "GMT",
"10": "AEDT",
"11": "AEDT",
};
let hr = date.getHours(),
min = date.getMinutes(),
sec = date.getSeconds();
let digitalHour = hr,
digitalMinute = min,
session = "AM";
if (digitalHour > 12) {
digitalHour = digitalHour%12;
}
if (digitalHour < 10) {
digitalHour = "0" + digitalHour;
}
digitalMinute = (min < 10) ? "0" + min : min;
var time = digitalHour + ":" + digitalMinute + " " + period + " (" + timeZoneMap[cityOffset] + ")";
if(document.getElementById("MyClockDisplay-"+cityName)){
document.getElementById("MyClockDisplay-"+cityName).innerText = time;
document.getElementById("MyClockDisplay-"+cityName).textContent = time;
}
let hrPosition = hr*360/12 + ((min * 360/60)/12),
minPosition = (min * 360/60) + (sec* 360/60)/60,
secPosition = sec * 360/60;
//Then we need to apply these numbers as degrees in the inline styles for transform on each of the objects.
hourHand.css('transform', 'rotate(' + hrPosition + 'deg)');
minuteHand.css('transform', 'rotate(' + minPosition + 'deg)');
secondHand.css('transform', 'rotate(' + secPosition + 'deg)');
// fill period
periodDiv.html(period);
});
}
//calcualte time for the office location
function calcTime(offset) {
// create Date object for current location
var d = new Date();
// convert to msec
// subtract local time zone offset
// get UTC time in msec
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// create new Date object for different city
// using supplied offset
var officeTime = new Date(utc + (3600000*offset));
// return time as a string
return officeTime;
}
function resize_responsive_embed_iframe(){
var iframe = $('.responsive-embed iframe');
var iframeContainerHeight = $('header.classic-header').outerHeight();
var iframeContainerWidth = $('.video-iframe').width();
//get the height of the off canvas header
var width = $(window).width();
var height = $('.off-canvas').outerHeight();
var widthMultiplier = 0.85;
var heightMultiplier = 1.199;
//medium down
if ( width < 1024 ){
widthMultiplier = 0;
//reset width and height
iframe.css('height', '100%');
iframe.css('width', '100%');
}
//medium large
if(width >= 1024 && width <= 1200){
if(height < 800){
heightMultiplier = 0.5;
} else if (height > 1024 && height < 1450) {
heightMultiplier = 1.5;
} else {
heightMultiplier = 0.15;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth+(iframeContainerWidth*5));
}
//ipad pro portrait
if(width === 1024 && height < 1450){
heightMultiplier = 0.1;
widthMultiplier = 2;
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth+(iframeContainerWidth*widthMultiplier));
}
//ipad in landscape
if(width === 1024 && height === 768){
heightMultiplier = 0.1;
widthMultiplier = 1;
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth+(iframeContainerWidth));
}
if(width > 1024 && width < 1199){
widthMultiplier = 1;
if(height < 770){
heightMultiplier = 1;
} else if(height >= 800 && height < 900){
heightMultiplier = 0.15;
} else if(height >= 1200 && height < 1500){
heightMultiplier = 0.25;
widthMultiplier = 2;
} else {
heightMultiplier = 0.15;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth+(iframeContainerWidth*widthMultiplier));
}
if(width > 1200 && width < 1450){
widthMultiplier = 1;
if(height < 799){
heightMultiplier = 0.30;
} else if(height >= 800 && height < 900){
heightMultiplier = 0.35;
} else if(height >= 901 && height < 1000){
heightMultiplier = 0.15;
} else if(height >= 1200 && height < 1500){
heightMultiplier = 0.25;
widthMultiplier = 2;
} else {
heightMultiplier = 0.10;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth+(iframeContainerWidth*widthMultiplier));
}
if(width >= 1451 && width < 1550){
if(height < 849){
heightMultiplier = 0.8;
} else if( height >= 850 && height < 898) {
heightMultiplier = 0.5;
} else if( height >= 899 && height < 1000) {
heightMultiplier = 0.30;
} else {
heightMultiplier = 0.6;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth+(iframeContainerWidth*1));
}
if(width >= 1551 && width < 1679){
widthMultiplier = 1;
if(height < 849){
heightMultiplier = 0.8;
} else if( height >= 850 && height < 898) {
heightMultiplier = 0.5;
} else if( height >= 899 && height < 1000) {
heightMultiplier = 0.30;
} else {
heightMultiplier = 0.6;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth+(iframeContainerWidth*widthMultiplier));
}
if(width >= 1680 && width < 1920){
widthMultiplier = 1;
if(height < 849){
heightMultiplier = 1.5;
} else if( height >= 850 && height < 898) {
heightMultiplier = 0.80;
} else if( height >= 899 && height < 1000) {
heightMultiplier = 0.60;
} else {
heightMultiplier = 0.6;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth+(iframeContainerWidth*widthMultiplier));
}
if(width > 1920 && width < 2250) {
//for ultra large screens
// console.log('test')
if(height < 849){
heightMultiplier = 1.5;
} else if( height >= 850 && height < 898) {
heightMultiplier = 0.80;
} else if( height >= 899 && height < 1000) {
heightMultiplier = 0.70;
} else {
heightMultiplier = 0.6;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth*2);
}
if(width > 2250 && width < 2700) {
//for ultra large screens
if(height < 849){
heightMultiplier = 1;
} else if( height >= 850 && height < 999) {
heightMultiplier = 1;
} else if( height >= 1000 && height < 1099) {
heightMultiplier = 1;
} else if( height >= 1100 && height < 1200) {
heightMultiplier = 0.55;
} else {
heightMultiplier = 0.40;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth*2);
}
if(width > 2700) {
//for ultra large screens
if(height < 800){
heightMultiplier = 1.55;
} else if( height >= 800 && height < 900) {
heightMultiplier = 1.25;
} else if (height >= 901 && height < 998){
heightMultiplier = 0.65;
} else if (height >= 999 && height < 1099){
heightMultiplier = 0.65;
} else if (height >= 1100 && height < 1229){
heightMultiplier = 0.55;
} else if (height >= 1230 && height < 1349){
heightMultiplier = 0.35;
} else if (height >= 1350 && height < 1500){
heightMultiplier = 0.15;
} else if (height >= 1501 ){
heightMultiplier = 0.25;
}
iframe.height(iframeContainerHeight+(iframeContainerHeight*heightMultiplier));
iframe.width(iframeContainerWidth*2);
}
}
//function to resize gallery images on
function resize_gallery_images(){
var maxHeight = -1;
//get tallest image from tge first row
$('#images-grid-wrapper .grid-image-gallery-row:first-child .image').each(function() {
maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
});
$('.grid-image-gallery-row').each(function(){
$('.image img', this).each(function(){
$(this).height(maxHeight);
});
});
}
function unset_height_gallery_images(){
$('.grid-image-gallery-row').each(function(){
$('.image img', this).each(function(){
$(this).height('auto');
});
});
}
function resize_align_with_main_nav(){
var adminBarHeight = 0;
if($('#wpadminbar').length > 0){
adminBarHeight = $('#wpadminbar').height();
}
$('.align-with-main-nav').height($('header').outerHeight()-adminBarHeight);
var width = $(window).width();
//if video is withing align with main nav class
if (width < 1024){
$('.align-with-main-nav').css('height', 'auto');
} else {
// console.log('align')
$('.align-with-main-nav').height($('header').outerHeight()-adminBarHeight);
}
}
//adjust widget position
function adjust_singup_widget_position(){
var width = $(window).width();
var signupWidget = $('.signup-widget-wrapper.mobile');
var signupWidgetheight = $('.signup-widget-wrapper.mobile').outerHeight();
var signupActionPartHeight = $('.signup-widget-wrapper.mobile .signup-widget-inner .signup-widget-part-one').outerHeight();
var calcTopPosition = signupWidgetheight-signupActionPartHeight;
if(width < 1024){
// signupWidget.css('top', )
signupWidget.css('top', '-'+calcTopPosition+'px');
} else {
signupWidget.css('top', 'unset');
}
}
function check_position_of_header(){
var mobileHeader = $('header.header-mobile');
var secondMobileHeader = $('.second-mobile-header');
var width = $(document).width();
var signupWidgetPartOne = $('.signup-widget-wrapper.mobile .signup-widget-part-one').outerHeight();
var signupWidget = $('.signup-widget-wrapper.mobile');
var signupWidgetHeight = $('.signup-widget-wrapper.mobile').outerHeight();
//if signup widget is visible for smaller devices
if(width < 1024 && $('.signup-widget-wrapper.mobile').not(":hidden")){
mobileHeader.css('top', signupWidgetPartOne);
secondMobileHeader.css('margin-top', mobileHeader.outerHeight()+signupWidgetPartOne);
adjust_singup_widget_position();
} else {
signupWidget.css('top', '-'+signupWidgetHeight);
mobileHeader.css('top', 0);
}
}
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
}
function showPosition(position) {
var latdegrees = position.coords.latitude;
var londegrees = position.coords.longitude;
//make an ajax call
if(londegrees != '' && londegrees != ''){
$.ajax({
url:ajax_object.ajax_url,
data: {
'action': 'get_user_location',
'lat': latdegrees,
'long': londegrees
},
cache: false,
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
//console.log(JSON.stringify(data)); //for testing
//switch offices
switch_offices(data.country);
},
error: function (error) {;
//console.log(JSON.stringify(error)); //for testing
//do nothing
}
});
}
}
function switch_offices(country){
var i = 2;
if(country !== ''){
$('.flexible-contact-us .off-canvas-main-content .cell').each(function(){
if($(this).attr('id') == country.toLowerCase()){
$(this).css('order', '1');
} else {
$(this).css('order', i);
++i;
}
});
}
}
//all things being keep image ratio
function ratio_two_to_one(){
$('.featured-image.ratio-two-to-one').each(function(){ $(this).height($(this).width()/2)});
}
//align campaign to the right part
function align_with_right_part() {
var width = $(window).width();
if(width > 640){
//change on load
//news section
var newsOuterHeight = $('.all-things-right-part .all-things-column.news').outerHeight();
var newsInnerHeight = $('.all-things-right-part .all-things-column.news').height();
var newsBottomPadding = newsOuterHeight - newsInnerHeight;
var news = $('.all-things-right-part .news .all-things-content-wrapper').outerHeight()+newsBottomPadding;
//says section
var saysOuterHeight = $('.all-things-right-part .all-things-column.says').outerHeight();
var saysInnerHeight = $('.all-things-right-part .all-things-column.says').height();
var saysBottomPadding = saysOuterHeight - saysInnerHeight;
var says = saysOuterHeight-(saysBottomPadding) - $('.all-things-right-part .all-things-column.says .title').outerHeight() - $('.all-things-right-part .all-things-column.says .description').height();
$('.align-with-right-part').height(news+says+7.5);
} else {
//reset
$('.align-with-right-part').css('height', '');
}
}
//align case studies
function align_case_studies_grid_items(){
var width = $(window).width();
var tallest = 0;
if(width > 640) {
//align
$('.flexible-case-studies-grid .case-study-column .case-study-content-wrapper').each(function(){
if($(this).height() > tallest){
tallest = $(this).height();
}
});
if(tallest > 0) {
$('.flexible-case-studies-grid .case-study-column .case-study-content-wrapper').each(function(){
$(this).height(tallest);
});
}
} else {
//reset height to auto
$('.flexible-case-studies-grid .case-study-column .case-study-content-wrapper').each(function(){
$(this).css('height', 'auto');
});
}
}
//resize portfolio iframe
function resize_portfolio_iframe(){
var iframeWidth = $('.off-canvas-main-content').width();
$('.iframe-wrapper').each(function(){
$(this).height((iframeWidth/1.75)-5);
var iframeActualWidth = $(this).parent().width();
$(this).width(iframeActualWidth+5)
});
}
//detect mobile or tablet
function detectmob() {
if( navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
){
return true;
} else {
return false;
}
}
/*
*
* Collect Filter Selected Options
*
*/
function collect_filter_selected_options( $filter_id ){
var filter_options_array = [];
if( $filter_id != '' ){
$('.folio-filter-item fieldset[data-filter-id="' + $filter_id + '"] ul li').each( function() {
if( $(this).find('input').is(":checked") ) {
filter_options_array.push( $(this).find('input').attr('data-filter-value') );
}
});
var filter_options = {
"filter_id" : $filter_id,
"filter_options" : filter_options_array
};
} else {
//collect all
$('.folio-filter-item fieldset ul li').each( function() {
if( $(this).find('input').is(":checked") ) {
filter_options_array.push( $(this).find('input').attr('data-filter-value') );
}
});
var filter_options = {
"filter_id" : $filter_id,
"filter_options" : filter_options_array
};
}
return filter_options;
}
/*
*
* Get Filter URL string
*
*/
function get_filter_url_string(){
var $filter_url_string = '',
i = 0;
$('.folio-filter-item').each(function(){
$filter_parameters = collect_filter_selected_options( $(this).find('fieldset').attr('data-filter-id') );
$.each( $filter_parameters, function( key, value ) {
if( key == 'filter_id' ){
if( i == 0 ){
$filter_url_string += '?'+value+'=';
} else {
$filter_url_string += '&'+value+'=';
}
} else {
$filter_url_string += value;
}
});
i++;
});
return $filter_url_string;
}
/*
*
* Load Projects Filter Results
*
*/
function projects_filter_load(){
var $filter_parameters = collect_filter_selected_options( '' ),
cat_ids = $filter_parameters.filter_options;
$('.projects-grid .grid-x .single-project-item').each(function(){
//split categories
var this_cats = $(this).attr('data-industry'),
this_cats_arr = this_cats.split(",");
if( cat_ids.length == 1 ){
if( $.inArray( cat_ids[0], this_cats_arr) !== -1 ){
//yes, show
// $(this).removeClass('filter-hidden');
// $(this).addClass('filter-shown');
MotionUI.animateIn( $(this), 'fade-in');
} else {
//hide
$(this).addClass('filter-hidden');
$(this).removeClass('filter-shown');
}
} else if( cat_ids.length == 2 ){
if( $.inArray( cat_ids[0], this_cats_arr) !== -1 || $.inArray( cat_ids[1], this_cats_arr) !== -1 ){
//yes, show
$(this).removeClass('filter-hidden');
$(this).addClass('filter-shown');
MotionUI.animateIn( $(this), 'fade-in');
} else {
//hide
$(this).addClass('filter-hidden');
$(this).removeClass('filter-shown');
}
} else if( cat_ids.length == 3 ) {
if( $.inArray( cat_ids[0], this_cats_arr) !== -1 || $.inArray( cat_ids[1], this_cats_arr) !== -1 || $.inArray( cat_ids[2], this_cats_arr) !== -1 ){
//yes, show
$(this).removeClass('filter-hidden');
$(this).addClass('filter-shown');
MotionUI.animateIn( $(this), 'fade-in');
} else {
//hide
$(this).addClass('filter-hidden');
$(this).removeClass('filter-shown');
}
}
});
}
/*
*
* Clear Folio Filter
*
*/
function clear_folio_filter(){
//clear all
$('.projects-grid .grid-x .single-project-item').each(function(){
$(this).removeClass('filter-hidden');
$(this).removeClass('filter-shown');
MotionUI.animateIn( $(this), 'fade-in');
});
//clear url
var clear_url = window.location.protocol + "//" + window.location.host + window.location.pathname;
window.history.pushState({ path: clear_url }, '', clear_url);
}
/*
*
* Service page accordion
*
*/
function service_accordion(){
var width = $(window).width();
if( width < 640 ) {
var i = 0;
$('.service-accordion ul.accordion > li').each(function(){
if( i == 0 ){
if( $(this).hasClass('is-active') ){
//skip
} else {
//expend
$(this).find('a').trigger('click');
}
} else {
if( $(this).hasClass('is-active') ){
//skip
$(this).find('a').trigger('click');
}
}
i++;
});
} else {
//open items
$('.service-accordion ul.accordion li').each(function(){
if($(this).hasClass('is-active')){
} else {
$(this).find('a').trigger('click');
}
});
}
}
/*
*
* iFrame video resize new script
*
*/
function align_being_video_iframe( $iframe_root_container, $iframe ){
if( $iframe ){
var width_mutiplier = 1.3,
height_multiplier = 1.3,
height = $('.off-canvas').outerHeight(),
width = $(window).width();
if( height < 850 ){
height_multiplier = 3;
width_mutiplier = 2.3;
}
if( width < 640 ){
width_mutiplier = 1.1;
height_multiplier = 1.1;
}
if( width < 1249 && width > 1024 ) {
width_mutiplier = 3;
height_multiplier = 3;
}
if( width < 1450 && width > 1250 ) {
width_mutiplier = 2;
height_multiplier = 3;
}
if( width < 2199 && width > 1780 ) {
width_mutiplier = 1.8;
height_multiplier = 1.8;
}
if( width > 2200 ) {
width_mutiplier = 1.5;
height_multiplier = 1.5;
}
$iframe.css('width', $iframe_root_container.width()*width_mutiplier );
$iframe.css('height', $iframe_root_container.outerHeight()*height_multiplier );
}
}
/*
*
* Projects Fiflter
*
*/
function projects_filter( $part ){
if( $part ){
$('.projects-grid .project-category-section').removeClass('active');
$('.projects-grid #'+$part).addClass('active');
MotionUI.animateIn( $('.projects-grid #'+$part), 'fade-in' );
$(window).resize();
}
}
/*
*
* We Work With
* "Carousel Functionality for Bottom Arrows"
*
*/
function we_work_arrow_nav( $group_id ){
if( $group_id ) {
//update groups
$('.project-groups-grid .project-group-wrapper').each(function(){
if( $(this).attr('data-project-group-id') == $group_id ){
if( !$(this).hasClass("is-active") ){
$(this).addClass('is-active');
$(window).resize();
MotionUI.animateIn( $(this), 'fade-in' );
}
} else {
if( $(this).hasClass("is-active") ){
$(this).removeClass('is-active');
}
}
});
}
}
/*
*
* We Work With
* "Carousel Functionality for Left Accordion"
*
*/
function we_work_accordion_nav( $group_id ){
if( $group_id ) {
//update nav
$('.project-groups-navigation ul li a.accordion-title').each(function(){
if( $(this).attr('data-project-group-id') == $group_id ){
$(this).trigger('click');
}
});
}
}
/*
*
* Blog Posts Filter
*
*/
function blog_posts_filter( $term_id ){
var posts_per_page = $('.flexible-blog-posts-grid button#load-more-posts').attr('data-posts-per-page'),
grid_layout = $('.flexible-blog-posts-grid button#load-more-posts').attr('data-grid-layout'),
loader = $('.flexible-blog-posts-grid .loader'),
loadMoreBtn = $('#load-more-posts');
loadMoreBtn.hide();
loader.show();
$.ajax({
url:ajax_object.ajax_url,
data: {
'action': 'filter_posts',
'category': $term_id,
'posts_per_page': posts_per_page,
'grid_layout': grid_layout,
'equal_height' : 1,
},
success:function(data){
//parse json data
$('#posts-grid-wrapper .grid-posts-row').html( data );
//update paged value on the button
loader.hide();
loadMoreBtn.show();
},
complete: function(){
//initiate equalizer on the added row
Foundation.reInit('equalizer');
$(".being-lazy-interchange").unveilInterchange(200);
},
error: function(errorThrown){
//loader.hide();
loadMoreBtn.show();
}
});
//update load more button with cat ID and reset Pagination
$('#posts-grid-wrapper button#load-more-posts').attr('data-term-id', $term_id);
$('#posts-grid-wrapper button#load-more-posts').val(2);
return false;
}