/* ===================================================== */
/* Skyline Main Javascript
/* ===================================================== */
var address = "Kensington Gardens Square, London, UK";
/*
If is the customizer page
Load via window load
*/
if (zx_settings.is_customizer) {
jQuery(window).load(function () {
var $ = jQuery;
zx_init($);
jQuery("#import-demo").click(function () {
console.log('demo butotns been clicled');
});
});
} else {
jQuery(document).ready(function ($) {
zx_init($);
}); // End doc ready
}
jQuery(window).load(function () {
if (jQuery('body').hasClass('vc_editor')) {
var $ = jQuery;
// Some elements need loading after window.load only for vc_front editor
zx_init_shapes($);
zx_init_sliders($);
zx_init_hexes($);
zx_init_process($);
zx_init_services($);
if ($.isFunction($.fn.zorbixAjaxPortfolio)) {
$('.portfolio').zorbixAjaxPortfolio();
}
//zx_init($);
// Update Portfolio options VC save
$(".vc_panel-btn-save", window.parent.document).click(function () {
setTimeout(
function () {
zx_init_shapes($);
$('.portfolio').each(function () {
if ($.isFunction($.fn.zorbixAjaxPortfolio)) {
$(this).zorbixAjaxPortfolio();
}
});
}, 2000);
});
}
});
function zx_init($) {
zx_init_bars($);
zx_init_maps($);
zx_init_process($);
zx_init_preloader($);
zx_init_animations($);
zx_init_to_top($);
zx_init_backgrounds($);
zx_init_services($);
zx_init_video_bg($);
zx_init_shapes($);
zx_init_sliders($);
zx_init_blog_masonry($);
if ($.isFunction($.fn.zorbixAjaxPortfolio)) {
$('.portfolio').zorbixAjaxPortfolio();
}
// Menu
zx_init_menu_dropdowns($);
//zx_init_menu_scroll_change($);
zx_init_menu($);
zx_init_menu_smooth_jump($);
zx_init_milestones($);
zx_init_hexes($);
var zx_top = $('.header').css('top');
if( 0 !== $('.top-bar').length && 0 === $('.header.solid').length ) {
zx_top = $('.top-bar').outerHeight();
$('.header').after('
');
}
$('.header.solid').sticky({ topSpacing: zx_top, responsiveWidth: true, className: 'js-stuck' });
zx_menu_change($);
var body = $('body');
$('.vc_message_box-theme-style-dismissible').alerts();
$('.counter').countdownTimer();
$('.video-wrapper').fitVids();
$('.newsletter').newsletter({
inlineErrors: true // Setting to false means it will not display inlines errors
});
$("a[data-pp^='prettyPhoto']").prettyPhoto({
hook: 'data-pp',
theme: 'light_square',
social_tools: ''
});
$('.accordian').accordian();
$('.tabs').tabs({
type: 'top'
});
$('.sidetabs').tabs({
type: 'side'
});
$('.toggle').toggle();
if (isMobile.any() === null) {
$(".player").mb_YTPlayer();
}
// Make hovers work on tap start (rather then after or not at all)
$(".feature-hex-wrap, .feature-shape-wrap").on('touchstart', function (e) {
});
$(".hexes-img").on('touchstart', function (e) {
});
} // zx_init
function zx_init_blog_masonry($) {
$(window).load(function () {
jQuery('.blog-masonry').waitForImages(function () {
jQuery('.blog-masonry').isotope({
itemSelector: '.blog-post'
});
});
});
}
function zx_menu_change($) {
var headerElem = $('.header');
if (!headerElem.data('fixed-height')) {
var currentPos = jQuery(window).scrollTop();
if (currentPos > 800) {
headerElem.addClass('hd-short')
}
$(window).on('scroll', function() {
var currentPos = jQuery(window).scrollTop();
if (currentPos > 900 ) {
headerElem.addClass('hd-short');
} else {
headerElem.removeClass('hd-short');
}
});
}
}
function zx_init_menu_dropdowns($) {
function menu_is_mobile() {
return ( $('.main_menu > li > ul').first().css('position') !== 'absolute' );
}
// Add class to mega-menu dropdowns
$('.header .main_menu .mega li').addClass('mega-sub');
// Desktop hover dropdowns
$('.header .main_menu .menu-item-has-children').not('.mega-sub').hover(function () {
if (!menu_is_mobile()) {
$(this).find('>ul').stop(true, true).fadeIn(500);
}
}, function () {
if (!menu_is_mobile()) {
$(this).find('>ul').stop(true, true).fadeOut(500);
}
});
// Mobile click dropdowns
$('.main_menu li a').on('click', function (event) {
event.preventDefault();
if (menu_is_mobile()) {
$(this).parent().find('>ul:first, .menu-cols').stop(true, true).slideToggle();
}
});
//$('.main_menu li a').on('click', function (event) {
// if (menu_is_mobile()) {
// $(this).parent().find('>ul:first, .menu-cols').stop(true, true).slideToggle();
// }
// event.preventDefault();
//});
}
window.zx_init_menu = function ($) {
// Menu open
$('.header .open-btn').on('click', zx_menuOpenClose);
// Ipad dropdowns
$('.menu a').on('click', function (event) {
event.returnDefault();
});
//zx_init_smooth_jump($);
};
window.zx_menuOpenClose = function () {
var $ = jQuery;
// Close all open dropdowns menus
if (!$('.header').hasClass('opened')) {
$('.main_menu').find('ul').removeAttr('display', 'none');
}
// Slide open
$(this).closest('.header').toggleClass('opened').find('.main_menu').slideToggle(function () {
// Remove slide toggle display none so that it doesn't stay hidden when switching back
// to desktop after closing the menu
if (!$('.header').hasClass('opened')) {
$('.header .main_menu').removeAttr('style');
}
});
return false;
};
window.zx_init_menu_smooth_jump = function ($) {
$(".main_menu li, .down, .smooth-jump").on('click', function () {
// Get the url from the clicked item
var url = $(this).attr("href");
// or an anchor within
if (url === undefined) {
url = $(this).find('a').attr("href");
}
// If is a page jump
if (url.charAt(0) ==='#' && url != '#' && url != '#.html') {
url = url.substring(url.indexOf("#"));
$(".main_menu a").removeClass('current');
$(this).addClass('current');
$.smooth({elem: url, offset: -60});
zx_menuOpenClose();
return false;
} else {
// If it isn't a dropdown, go to the page
if (url !== '#') {
window.location = url;
}
}
});
};
window.zx_init_bars = function ($) {
$('.vc_bar').each(function () {
$(this).html($(this).data('value') + '%');
});
};
window.zx_init_hexes = function ($) {
$('.hexes-imgs-wrap').each(function () {
var contentContainer = $(this).siblings('.hexes-content');
if (contentContainer.find('.inner').length > 0) {
contentContainer = contentContainer.find('.inner');
}
var orginal_content = contentContainer.html();
$(this, '.animated-content .hexes-img').css('cursor', 'pointer');
var selected = $(this, '.animated-content').find('.hexes-img');
$(selected).on('click', function () {
var member_info = $(this).find('.feature-hex-info').html();
$(this).find('.feature-hex-info').css('background', 'purple');
contentContainer.stop().fadeOut(function () {
contentContainer.html(member_info);
$(this).find('.hexes-back').on('click', showOrginalContent);
});
contentContainer.fadeIn();
});
function showOrginalContent() {
contentContainer.stop().fadeOut(function () {
contentContainer.html(orginal_content);
contentContainer.fadeIn();
});
}
});
};
window.zx_init_shapes = function ($) { // Append SVG CLip templates
var body = $('body');
if (0 === $('.hidden_mask').length) {
body.prepend('
');
body.prepend('
');
// Feature shapes circle
body.prepend('
');
}
// Create SVG Masks
$('.create-svg').each(function () {
var src = $(this).attr('src');
var clip_mask = $(this).data('clip');
if (clip_mask === '#circle_mask') {
var svg_circle = '
';
$(this).after(svg_circle);
}
else if ($(this).data('clip') == '#hex_mask') {
$(this).after('
');
} else if ($(this).data('clip') == '#hex_mask_bigger') {
$(this).after('
');
$(this).remove();
}
$(this).remove();
});
};
window.zx_init_preloader = function ($) {
$('body').waitForImages(function () {
$('.preloader').fadeOut(1000);
});
};
window.zx_init_animations = function ($) {
if (isMobile.any() === null) {
$('.animated').appear(function () {
var elem = $(this),
delay = elem.data('animate-delay'),
animation = elem.data('animate');
delay = delay + 500;
setTimeout(function () {
elem.addClass(animation).css('opacity', '1');
elem.addClass(animation).find('i').css('opacity', '1');
}, delay);
}); // End appear
$('.appear-hover').appear(function () {
var delay2 = $(this).data('hover-delay'),
elem2 = $(this);
setTimeout(function () {
elem2.removeClass('appear-hover');
}, delay2);
});
} else {
$('.animated').css('opacity', '1').find('i').css('opacity', '1');
}
};
window.zx_init_to_top = function ($) {
var topBtn = $('.top-btn');
if (topBtn.length) {
topBtn.on('click', function (event) {
event.preventDefault();
$.smooth({elem: 'body', offset: -60});
});
showTopButton();
$(window).on('scroll', function () {
showTopButton();
});
}
function showTopButton() {
if (jQuery(window).scrollTop() > 100) {
topBtn.addClass('show');
} else {
topBtn.removeClass('show');
}
}
};
window.zx_init_backgrounds = function ($) {
$('[data-background]').each(function () {
$(this).css('background-image', "url(" + $(this).data("background") + ")");
});
};
window.zx_init_services = function ($) {
$('.services-animated').each(function () {
var hoverElem = $(this).find('.service-box'),
backBtn = $(this).find('.services-back'),
hoverInfo = '.service-info',
infoElem = $(this).next('.service-text').find('.inner'),
orginal_content = $(infoElem).html();
$(hoverElem).css('cursor', 'pointer');
$(hoverElem).on('click', function () {
var member_info = $(this).find(hoverInfo).html();
$(infoElem).stop().fadeOut(function () {
$(infoElem).html(member_info);
$('.btn-back').on('click', {
infoElem: infoElem,
orginal_content: orginal_content
}, processServicesBack);
});
$(infoElem).fadeIn();
});
}); // End each
};
window.zx_init_process = function ($) {
$('.process-animated').each(function () {
var hoverElem = $(this).find('.process-box'),
backBtn = $(this).find('.process-back'),
hoverInfo = '.process-info';
$(this).find('.process-text').html('
');
var infoElem = $(this).find('.process-text').find('.inner'),
hoverContainerElem = '.process-animated',
orginal_content = $(infoElem).html();
$(hoverElem).css('cursor', 'pointer');
$(hoverElem).on('click', function () {
var member_info = $(this).find(hoverInfo).html();
$(infoElem).stop().fadeOut(function () {
$(infoElem).html(member_info);
$('.process-back').on('click', {
infoElem: infoElem,
orginal_content: orginal_content
}, processServicesBack);
});
$(infoElem).fadeIn();
});
}); // End each
// First to occuply info section
$('.process-animated .process-box').eq(0).trigger('click');
};
var processServicesBack = function (event) {
var infoElem = event.data.infoElem,
orginal_content = event.data.orginal_content;
jQuery(infoElem).stop().fadeOut(function () {
jQuery(infoElem).html(orginal_content);
jQuery(infoElem).fadeIn();
});
event.preventDefault();
};
window.zx_init_video_bg = function ($) {
// Only run video on desktop
var videoBackground = $('.video-background');
if (isMobile.any() === null) {
videoBackground.parent('.video-slider').after('
');
// Pause Video
$('.video_pause').on('click', function (e) {
e.preventDefault();
if (videoBackground.get(0).paused === false) {
videoBackground.get(0).pause();
$(this).find('i').removeClass('fa-play').addClass('fa-pause');
} else {
videoBackground.get(0).play();
$(this).find('i').removeClass('fa-pause').addClass('fa-play');
}
});
// Unmute
$('.video_mute').on('click', function (e) {
e.preventDefault();
videoBackground.get(0).muted = !videoBackground.get(0).muted;
$(this).find('i').toggleClass('fa-volume-off').toggleClass('fa-volume-up');
});
}
};
window.zx_init_maps = function ($) {
// http://www.smashinglabs.pl/gmap/documentation
if ($.isFunction($.fn.gMap)) {
var mapStyles = [{
"featureType": "landscape",
"stylers": [{
"saturation": -100
}, {
"lightness": 65
}, {
"visibility": "on"
}]
}, {
"featureType": "poi",
"stylers": [{
"saturation": -100
}, {
"lightness": 51
}, {
"visibility": "simplified"
}]
}, {
"featureType": "road.highway",
"stylers": [{
"saturation": -100
}, {
"visibility": "simplified"
}]
}, {
"featureType": "road.arterial",
"stylers": [{
"saturation": -100
}, {
"lightness": 30
}, {
"visibility": "on"
}]
}, {
"featureType": "road.local",
"stylers": [{
"saturation": -100
}, {
"lightness": 40
}, {
"visibility": "on"
}]
}, {
"featureType": "transit",
"stylers": [{
"saturation": -100
}, {
"visibility": "simplified"
}]
}, {
"featureType": "administrative.province",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "water",
"elementType": "labels",
"stylers": [{
"visibility": "on"
}, {
"lightness": -25
}, {
"saturation": -100
}]
}, {
"featureType": "water",
"elementType": "geometry",
"stylers": [{
"hue": "#ffff00"
}, {
"lightness": -25
}, {
"saturation": -97
}]
}];
// var address = "Kensington Gardens Square, London, UK";
$('.google-map').each(function () {
var address = $(this).data('address');
var markers = $(this).data('markers');
var zoom = $(this).data('zoom');
zoom = ( zoom ) ? zoom : 16;
// If no markers are set default to the address
// Format to json
if (!markers) {
markers = [{"address": address}];
} else {
if (markers.indexOf('{') !== -1) {
markers = markers.replace(/{/gi, '{"address":"');
markers = markers.replace(/}/gi, '"}');
markers = '[' + markers + ']';
markers = jQuery.parseJSON(markers);
} else {
markers = [{"address": markers}];
}
}
$(this).gMap({
address: address,
markers: markers,
zoom: zoom,
styles: mapStyles,
scrollwheel: false
});
});
$('.map-overlay').on('click', function (event) {
event.preventDefault();
$('.map-holder .close-btn').fadeIn();
$(this).fadeOut(function () {
$('.map-holder').css('height', '400');
});
});
$('.map-holder .close-btn').on('click', function (e) {
e.preventDefault();
var elem = this;
$('.map-overlay').fadeIn(function () {
$('.map-holder').css('height', '100');
$(elem).fadeOut();
});
});
} else {
console.warn('gmap not found');
}
};
window.zx_init_sliders = function ($) {
$('.testimonial').bxSlider({
auto: true,
speed: 1000,
pause: 8000,
mode: 'fade',
pager: false,
controls: false
});
$('.post-slider').bxSlider({
auto: true,
speed: 1000,
pause: 8000,
mode: 'fade',
pager: false,
adaptiveHeight: true
});
$('.promo-slider').bxSlider({
auto: false,
speed: 1000,
pause: 8000,
mode: 'fade',
pager: false,
adaptiveHeight: false,
controls: true
});
$('.portfolio-slider').bxSlider({
auto: false,
speed: 1000,
pause: 8000,
mode: 'fade',
pager: false
});
$('.page-heading-slider').bxSlider({
auto: true,
speed: 1000,
pause: 8000,
mode: 'fade',
pager: false,
adaptiveHeight: false
});
// Set height
var pageHeadingWrap = $('.page-heading-slider-wrap');
var page_heading_slider_height = ( pageHeadingWrap.data('bxheight') ) ? pageHeadingWrap.data('bxheight') : 300;
pageHeadingWrap.find('.bx-viewport').css('height', page_heading_slider_height);
};
window.zx_init_milestones = function ($) {
$('.milestone').each(function () {
$(this).appear(function () {
var countElem = $(this).find('.count');
var numCountTo = countElem.data('count').toString();
numCountTo = numCountTo.replace(',', '');
numCountTo.replace( '.', '' );
countElem.countTo({
from: 0,
to: numCountTo,
speed: 2200,
refreshInterval: 60,
formatter: function (value, options) {
value = value.toFixed(options.decimals);
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return value;
}
});
});
});
};