"use strict";
var lastScroll = 0;
//check for browser os
var isMobile = false;
var isiPhoneiPad = false;
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
isMobile = true;
}
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
isiPhoneiPad = true;
}
function SetMegamenuPosition() {
if ($(window).width() > 991) {
setTimeout(function () {
var totalHeight = $('nav.navbar').outerHeight();
$('.mega-menu').css({top: totalHeight});
if ($('.navbar-brand-top').length === 0)
$('.dropdown.simple-dropdown > .dropdown-menu').css({top: totalHeight});
}, 200);
} else {
$('.mega-menu').css('top', '');
$('.dropdown.simple-dropdown > .dropdown-menu').css('top', '');
}
}
function pad(d) {
return (d < 10) ? '0' + d.toString() : d.toString();
}
function isIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer, return version number
{
return true;
} else // If another browser, return 0
{
return false;
}
}
//page title space
function setPageTitleSpace() {
if ($('.navbar').hasClass('navbar-top') || $('nav').hasClass('navbar-fixed-top')) {
if ($('.top-space').length > 0) {
var top_space_height = $('.navbar').outerHeight();
if ($('.top-header-area').length > 0) {
top_space_height = top_space_height + $('.top-header-area').outerHeight();
}
$('.top-space').css('margin-top', top_space_height + "px");
}
}
}
//swiper button position in auto height slider
function setButtonPosition() {
if ($(window).width() > 767 && $(".swiper-auto-height-container").length > 0) {
var leftPosition = parseInt($('.swiper-auto-height-container .swiper-slide').css('padding-left'));
var bottomPosition = parseInt($('.swiper-auto-height-container .swiper-slide').css('padding-bottom'));
var bannerWidth = parseInt($('.swiper-auto-height-container .slide-banner').outerWidth());
$('.navigation-area').css({'left': bannerWidth + leftPosition + 'px', 'bottom': bottomPosition + 'px'});
} else if ($(".swiper-auto-height-container").length > 0) {
$('.navigation-area').css({'left': '', 'bottom': ''});
}
}
$(window).on("scroll", init_scroll_navigate);
function init_scroll_navigate() {
/*==============================================================
One Page Main JS - START CODE
=============================================================*/
var menu_links = $(".navbar-nav li a");
var scrollPos = $(document).scrollTop();
menu_links.each(function () {
var currLink = $(this);
if (currLink.attr("href").indexOf("#") > -1 && $(currLink.attr("href")).length > 0) {
var refElement = $(currLink.attr("href"));
if (refElement.position().top <= scrollPos && refElement.position().top + refElement.height() > scrollPos) {
menu_links.removeClass("active");
currLink.addClass("active");
} else {
currLink.removeClass("active");
}
}
});
/*==============================================================
One Page Main JS - END CODE
=============================================================*/
/*==============================================================*/
//background color slider Start
/*==============================================================*/
var $window = $(window),
$body = $('.bg-background-fade'),
$panel = $('.color-code');
var scroll = $window.scrollTop() + ($window.height() / 2);
$panel.each(function () {
var $this = $(this);
if ($this.position().top <= scroll && $this.position().top + $this.height() > scroll) {
$body.removeClass(function (index, css) {
return (css.match(/(^|\s)color-\S+/g) || []).join(' ');
});
$body.addClass('color-' + $(this).data('color'));
}
});
/*==============================================================*/
//background color slider End
/*==============================================================*/
/* ===================================
sticky nav Start
====================================== */
var headerHeight = $('nav').outerHeight();
if (!$('header').hasClass('no-sticky')) {
if ($(document).scrollTop() >= headerHeight) {
$('header').addClass('sticky');
} else if ($(document).scrollTop() <= headerHeight) {
$('header').removeClass('sticky');
setTimeout(function () {
setPageTitleSpace();
}, 500);
}
SetMegamenuPosition();
}
/* ===================================
header appear on scroll up
====================================== */
var st = $(this).scrollTop();
if (st > lastScroll) {
$('.sticky').removeClass('header-appear');
$('.dropdown.on').removeClass('on').removeClass('open').find('.dropdown-menu').fadeOut(100);
} else
$('.sticky').addClass('header-appear');
lastScroll = st;
if (lastScroll <= headerHeight)
$('header').removeClass('header-appear');
/* ===================================
sticky nav End
====================================== */
}
/*==============================================================
parallax text - START CODE
==============================================================*/
function parallax_text() {
var window_width = $(window).width();
if (window_width > 1024) {
if ($('.swiper-auto-width .swiper-slide').length !== 0) {
$(document).on("mousemove", ".swiper-auto-width .swiper-slide", function (e) {
var positionX = e.clientX;
var positionY = e.clientY;
positionX = Math.round(positionX / 10) - 80;
positionY = Math.round(positionY / 10) - 40;
$(this).find('.parallax-text').css({'transform': 'translate(' + positionX + 'px,' + positionY + 'px)', 'transition-duration': '0s'});
});
$(document).on("mouseout", ".swiper-auto-width .swiper-slide", function (e) {
$('.parallax-text').css({'transform': 'translate(0,0)', 'transition-duration': '0.5s'});
});
}
}
}
/*==============================================================*/
//parallax text - END CODE
/*==============================================================*/
/*==============================================================*/
//Search - START CODE
/*==============================================================*/
function ScrollStop() {
return false;
}
function ScrollStart() {
return true;
}
function validationSearchForm() {
var error = true;
$('#search-header input[type=text]').each(function (index) {
if (index === 0) {
if ($(this).val() === null || $(this).val() === "") {
$("#search-header").find("input:eq(" + index + ")").css({"border": "none", "border-bottom": "2px solid red"});
error = false;
} else {
$("#search-header").find("input:eq(" + index + ")").css({"border": "none", "border-bottom": "2px solid #000"});
}
}
});
return error;
}
/*==============================================================
Search - END CODE
==============================================================*/
/*==============================================================
equalize - START CODE
==============================================================*/
function equalizeHeight() {
$(document).imagesLoaded(function () {
if ($(window).width() < 768) {
$('.equalize').equalize({equalize: 'outerHeight', reset: true});
$('.equalize.md-equalize-auto').children().css("height", "");
$('.equalize.sm-equalize-auto').children().css("height", "");
$('.equalize.xs-equalize-auto').children().css("height", "");
return false;
} else if ($(window).width() < 992) {
$('.equalize').equalize({equalize: 'outerHeight', reset: true});
$('.equalize.md-equalize-auto').children().css("height", "");
$('.equalize.sm-equalize-auto').children().css("height", "");
return false;
} else if ($(window).width() < 1199) {
$('.equalize').equalize({equalize: 'outerHeight', reset: true});
$('.equalize.md-equalize-auto').children().css("height", "");
return false;
} else {
$('.equalize').equalize({equalize: 'outerHeight', reset: true});
}
});
}
/*==============================================================
equalize - END CODE
==============================================================*/
/*==============================================================
dynamic font size START CODE
==============================================================*/
function feature_dynamic_font_line_height() {
if ($('.dynamic-font-size').length > 0) {
var site_width = 1100;
var window_width = $(window).width();
if (window_width < site_width) {
var window_site_width_ratio = window_width / site_width;
$('.dynamic-font-size').each(function () {
var font_size = $(this).attr('data-fontsize');
var line_height = $(this).attr('data-lineheight');
if (font_size != '' && font_size != undefined) {
var new_font_size = Math.round(font_size * window_site_width_ratio * 1000) / 1000;
$(this).css('font-size', new_font_size + 'px');
}
if (line_height !== '' && line_height !== undefined) {
var new_line_height = Math.round(line_height * window_site_width_ratio * 1000) / 1000;
$(this).css('line-height', new_line_height + 'px');
}
});
} else {
$('.dynamic-font-size').each(function () {
var font_size = $(this).attr('data-fontsize');
var line_height = $(this).attr('data-lineheight');
if (font_size !== '' && font_size !== undefined) {
$(this).css('font-size', font_size + 'px');
}
if (line_height !== '' && line_height !== undefined) {
$(this).css('line-height', line_height + 'px');
}
});
}
}
}
/*==============================================================
dynamic font size END CODE
==============================================================*/
/*==============================================================
set parallax
==============================================================*/
function stellarParallax() {
if ($(window).width() > 1024) {
$.stellar();
} else {
$.stellar('destroy');
$('.parallax').css('background-position', '');
}
}
/*==============================================================
full screen START CODE
==============================================================*/
function fullScreenHeight() {
var element = $(".full-screen");
var $minheight = $(window).height();
element.parents('section').imagesLoaded(function () {
if ($(".top-space .full-screen").length > 0) {
var $headerheight = $("header nav.navbar").outerHeight();
$(".top-space .full-screen").css('min-height', $minheight - $headerheight);
} else {
element.css('min-height', $minheight);
}
});
var minwidth = $(window).width();
$(".full-screen-width").css('min-width', minwidth);
var sidebarNavHeight = $('.sidebar-nav-style-1').height() - $('.logo-holder').parent().height() - $('.footer-holder').parent().height() - 10;
$(".sidebar-nav-style-1 .nav").css('height', (sidebarNavHeight));
var style2NavHeight = parseInt($('.sidebar-part2').height() - parseInt($('.sidebar-part2 .sidebar-middle').css('padding-top')) - parseInt($('.sidebar-part2 .sidebar-middle').css('padding-bottom')) - parseInt($(".sidebar-part2 .sidebar-middle .sidebar-middle-menu .nav").css('margin-bottom')));
$(".sidebar-part2 .sidebar-middle .sidebar-middle-menu .nav").css('height', (style2NavHeight));
}
/*==============================================================
full screen END CODE
==============================================================*/
function SetResizeContent() {
// all function call
feature_dynamic_font_line_height();
SetMegamenuPosition();
setPageTitleSpace();
setButtonPosition();
parallax_text();
stellarParallax();
fullScreenHeight();
equalizeHeight();
}
/* ===================================
START RESIZE
====================================== */
$(window).resize(function (event) {
// Bootsnav menu work with eualize height
$("nav.navbar.bootsnav ul.nav").each(function () {
$("li.dropdown", this).on("mouseenter", function (e) {
if ($(window).width() > 991) {
$(this).find('.equalize').equalize({equalize: 'outerHeight', reset: true});
return false;
}
});
});
setTimeout(function () {
SetResizeContent();
}, 500);
event.preventDefault();
});
/* ===================================
END RESIZE
====================================== */
/* ===================================
START READY
====================================== */
$(document).ready(function () {
"use strict";
// Bootsnav menu work with eualize height
$("nav.navbar.bootsnav ul.nav").each(function () {
$("li.dropdown", this).on("mouseenter", function () {
if ($(window).width() > 991) {
$(this).find('.equalize').equalize({equalize: 'outerHeight', reset: true});
return false;
}
});
});
// Bootsnav tab work with eualize height
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var target = $(e.target).attr("href");
if ($(window).width() > 991) {
$(target).find('.equalize').equalize({equalize: 'outerHeight', reset: true});
return false;
}
});
// Active class to current menu for only html
var pgurl = window.location.href.substr(window.location.href.lastIndexOf("/") + 1);
var $hash = window.location.hash.substring(1);
if ($hash) {
$hash = "#" + $hash;
pgurl = pgurl.replace($hash, "");
} else {
pgurl = pgurl.replace("#", "");
}
$(".nav li a").each(function () {
if ($(this).attr("href") == pgurl || $(this).attr("href") == pgurl + '.html') {
$(this).parent().addClass("active");
$(this).parents('li.dropdown').addClass("active");
}
});
$(window).scroll(function () {
if ($(this).scrollTop() > 150)
$('.scroll-top-arrow').fadeIn('slow');
else
$('.scroll-top-arrow').fadeOut('slow');
});
//Click event to scroll to top
$(document).on('click', '.scroll-top-arrow', function () {
$('html, body').animate({scrollTop: 0}, 800);
return false;
});
/* ===================================
swiper slider
====================================== */
var swiperFull = new Swiper('.swiper-full-screen', {
pagination: '.swiper-pagination',
paginationClickable: true,
loop: true,
autoplay: 5000,
slidesPerView: 1,
keyboardControl: true,
preventClicks: false,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev'
});
var swiperAutoFade = new Swiper('.swiper-auto-fade', {
pagination: '.swiper-pagination',
loop: true,
autoplay: 5000,
slidesPerView: 1,
paginationClickable: true,
keyboardControl: true,
preventClicks: false,
effect: 'fade',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev'
});
var swiperSecond = new Swiper('.swiper-slider-second', {
pagination: '.swiper-pagination-second',
slidesPerView: 1,
paginationClickable: true,
keyboardControl: true,
preventClicks: false,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev'
});
var swiperThird = new Swiper('.swiper-slider-third', {
pagination: '.swiper-pagination-third',
slidesPerView: 1,
paginationClickable: true,
keyboardControl: true,
preventClicks: false,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev'
});
var swiperNumber = new Swiper('.swiper-number-pagination', {
pagination: '.swiper-number',
paginationClickable: true,
autoplay: 4000,
preventClicks: false,
autoplayDisableOnInteraction: false,
paginationBulletRender: function (swiper, index, className) {
return '' + pad((index + 1)) + '';
}
});
var swiperVerticalPagination = new Swiper('.swiper-vertical-pagination', {
pagination: '.swiper-pagination-white',
direction: 'vertical',
slidesPerView: 1,
paginationClickable: true,
spaceBetween: 0,
preventClicks: false,
mousewheelControl: true
});
var swiperClients = new Swiper('.swiper-slider-clients', {
pagination: null,
slidesPerView: 6,
paginationClickable: true,
autoplay: 3000,
preventClicks: false,
autoplayDisableOnInteraction: false,
breakpoints: {
480: {
slidesPerView: 1
},
650: {
slidesPerView: 2
},
850: {
slidesPerView: 3
}
}
});
var swiperThreeSlides = new Swiper('.swiper-three-slides', {
pagination: '.swiper-pagination-three-slides',
paginationClickable: true,
slidesPerView: 3,
keyboardControl: true,
mousewheelControl: false,
preventClicks: false,
nextButton: '.second-swiper-button-next',
prevButton: '.second-swiper-button-prev',
breakpoints: {
480: {
slidesPerView: 1
},
767: {
slidesPerView: 2
},
850: {
slidesPerView: 2
}
}
});
var swiperFourSlides = new Swiper('.swiper-four-slides', {
pagination: '.swiper-pagination-four-slides',
autoplay: 3000,
slidesPerView: 4,
paginationClickable: true,
keyboardControl: true,
mousewheelControl: false,
preventClicks: false,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
breakpoints: {
850: {
slidesPerView: 2
},
650: {
slidesPerView: 2
},
480: {
slidesPerView: 1
}
}
});
var swiperDemoHeaderStyle = new Swiper('.swiper-demo-header-style', {
pagination: '.swiper-pagination-demo-header-style',
loop: true,
autoplay: 3000,
slidesPerView: 4,
paginationClickable: true,
keyboardControl: true,
mousewheelControl: false,
preventClicks: true,
slidesPerGroup: 4,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
breakpoints: {
1199: {
slidesPerGroup: 2,
slidesPerView: 2
},
767: {
slidesPerGroup: 1,
slidesPerView: 1
}
}
});
var swiperAutoSlideIndex = 0;
var swiperAutoSlide = new Swiper('.swiper-auto-width', {
scrollbar: '.swiper-scrollbar',
scrollbarHide: false,
scrollbarDraggable: true,
slidesPerView: 'auto',
centeredSlides: true,
spaceBetween: 80,
preventClicks: false,
scrollbarSnapOnRelease: true,
nextButton: '.swiper-next-style2',
prevButton: '.swiper-prev-style2',
mousewheelControl: true,
speed: 1000,
keyboardControl: true,
breakpoints: {
1199: {
spaceBetween: 60
},
960: {
spaceBetween: 30
},
767: {
spaceBetween: 15
}
},
onSlideChangeEnd: function (swiper) {
swiperAutoSlideIndex = swiper.activeIndex;
}
});
var swiperMultipurpose = new Swiper('.swiper-bottom-scrollbar-full', {
scrollbar: '.swiper-scrollbar',
scrollbarHide: false,
scrollbarDraggable: true,
slidesPerView: 'auto',
scrollbarSnapOnRelease: true,
grabCursor: true,
preventClicks: false,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
mousewheelControl: true,
spaceBetween: 30,
keyboardControl: true,
speed: 1000,
breakpoints: {
767: {
direction: 'vertical',
//slidesPerView: 1,
scrollbarHide: true,
spaceBetween: 0,
pagination: false,
autoHeight: true
}
}
});
var swiperAutoHieght = new Swiper('.swiper-auto-height-container', {
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
effect: 'fade',
loop: true,
preventClicks: false,
autoHeight: true
});
var swiperMultyRow = new Swiper('.swiper-multy-row-container', {
nextButton: '.swiper-portfolio-next',
prevButton: '.swiper-portfolio-prev',
slidesPerView: 4,
spaceBetween: 15,
scrollbarSnapOnRelease: true,
autoplay: 3000,
autoplayDisableOnInteraction: true,
breakpoints: {
991: {
slidesPerView: 2
},
767: {
slidesPerView: 1
}
}
});
var swiperBlog = new Swiper('.swiper-blog', {
slidesPerView: "auto",
centeredSlides: true,
spaceBetween: 15,
scrollbarSnapOnRelease: true,
autoplay: 5000,
autoplayDisableOnInteraction: true,
preventClicks: false,
loop: true,
loopedSlides: 3
});
var swiperPresentation = new Swiper('.swiper-presentation', {
slidesPerView: 4,
centeredSlides: true,
spaceBetween: 30,
scrollbarSnapOnRelease: true,
autoplay: 3000,
autoplayDisableOnInteraction: true,
preventClicks: true,
loop: true,
loopedSlides: 6,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
breakpoints: {
991: {
spaceBetween: 15,
slidesPerView: 2
},
767: {
slidesPerView: 1
}
}
});
//swiper resize for IE
if (isIE()) {
setTimeout(function () {
$(document).imagesLoaded(function () {
if ($(".swiper-full-screen").length > 0)
swiperFull.onResize();
if ($(".swiper-auto-fade").length > 0)
swiperAutoFade.onResize();
if ($(".swiper-number-pagination").length > 0)
swiperNumber.onResize();
if ($(".swiper-slider-clients").length > 0)
swiperClients.onResize();
if ($(".swiper-slider-second").length > 0)
swiperSecond.onResize();
if ($(".swiper-slider-third").length > 0)
swiperThird.onResize();
if ($(".swiper-three-slides").length > 0)
swiperThreeSlides.onResize();
if ($(".swiper-four-slides").length > 0)
swiperFourSlides.onResize();
if ($(".swiper-vertical-pagination").length > 0)
swiperVerticalPagination.onResize();
if ($(".swiper-auto-height-container").length > 0)
swiperAutoHieght.onResize();
if ($(".swiper-multy-row-container").length > 0)
swiperMultyRow.onResize();
if ($(".swiper-blog").length > 0)
swiperBlog.onResize();
if ($(".swiper-swiperPresentation").length > 0)
swiperPresentation.onResize();
if ($(".swiper-demo-header-style").length > 0)
swiperDemoHeaderStyle.onResize();
});
}, 300);
}
$(window).resize(function () {
setTimeout(function () {
if ($(".swiper-full-screen").length > 0)
swiperFull.onResize();
if ($(".swiper-auto-fade").length > 0)
swiperAutoFade.onResize();
if ($(".swiper-number-pagination").length > 0)
swiperNumber.onResize();
if ($(".swiper-slider-clients").length > 0)
swiperClients.onResize();
if ($(".swiper-slider-second").length > 0)
swiperSecond.onResize();
if ($(".swiper-slider-third").length > 0)
swiperThird.onResize();
if ($(".swiper-three-slides").length > 0)
swiperThreeSlides.onResize();
if ($(".swiper-four-slides").length > 0)
swiperFourSlides.onResize();
if ($(".swiper-vertical-pagination").length > 0)
swiperVerticalPagination.onResize();
if ($(".swiper-auto-height-container").length > 0)
swiperAutoHieght.onResize();
if ($(".swiper-multy-row-container").length > 0)
swiperMultyRow.onResize();
if ($(".swiper-blog").length > 0)
swiperBlog.onResize();
if ($(".swiper-swiperPresentation").length > 0)
swiperPresentation.onResize();
if ($(".swiper-demo-header-style").length > 0)
swiperDemoHeaderStyle.onResize();
}, 500);
setTimeout(function () {
//destroy swiper
var window_width = $(window).width();
if (window_width < 768) {
if ($(".swiper-bottom-scrollbar-full").length > 0) {
if (swiperMultipurpose) {
swiperMultipurpose.detachEvents();
swiperMultipurpose.destroy(true, true);
swiperMultipurpose = undefined;
}
swiperMultipurpose = new Swiper('.swiper-bottom-scrollbar-full', {
scrollbar: '.swiper-scrollbar',
scrollbarHide: false,
scrollbarDraggable: true,
slidesPerView: 'auto',
scrollbarSnapOnRelease: true,
grabCursor: true,
preventClicks: false,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
mousewheelControl: true,
spaceBetween: 30,
keyboardControl: true,
speed: 1000,
breakpoints: {
767: {
direction: 'vertical',
//slidesPerView: 1,
scrollbarHide: true,
spaceBetween: 0,
pagination: false,
autoHeight: true
}
}
});
}
} else {
if ($(".swiper-bottom-scrollbar-full").length > 0) {
if (swiperMultipurpose) {
swiperMultipurpose.detachEvents();
swiperMultipurpose.destroy(true, true);
swiperMultipurpose = undefined;
}
swiperMultipurpose = new Swiper('.swiper-bottom-scrollbar-full', {
scrollbar: '.swiper-scrollbar',
scrollbarHide: false,
scrollbarDraggable: true,
slidesPerView: 'auto',
scrollbarSnapOnRelease: true,
grabCursor: true,
preventClicks: false,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
mousewheelControl: true,
spaceBetween: 30,
keyboardControl: true,
speed: 1000
});
}
}
}, 500);
if ($(".swiper-auto-width").length > 0 && swiperAutoSlide) {
swiperAutoSlide.detachEvents();
swiperAutoSlide.destroy(true);
swiperAutoSlide = undefined;
$(".swiper-auto-width .swiper-wrapper").css("transform", "").css("transition-duration", "");
$(".swiper-auto-width .swiper-slide").css("margin-right", "");
setTimeout(function () {
swiperAutoSlide = new Swiper('.swiper-auto-width', {
scrollbar: '.swiper-scrollbar',
scrollbarHide: false,
scrollbarDraggable: true,
slidesPerView: 'auto',
centeredSlides: true,
spaceBetween: 80,
preventClicks: false,
scrollbarSnapOnRelease: true,
nextButton: '.swiper-next-style2',
prevButton: '.swiper-prev-style2',
mousewheelControl: true,
speed: 1000,
keyboardControl: true,
breakpoints: {
1199: {
spaceBetween: 60
},
960: {
spaceBetween: 30
},
767: {
spaceBetween: 15
}
},
onSlideChangeEnd: function (swiper) {
swiperAutoSlideIndex = swiper.activeIndex;
}
});
swiperAutoSlide.slideTo(swiperAutoSlideIndex, 1000, false);
}, 1000);
}
});
/*==============================================================
smooth scroll
==============================================================*/
var scrollAnimationTime = 1200, scrollAnimation = 'easeInOutExpo';
$(document).on('click.smoothscroll', 'a.scrollto', function (event) {
event.preventDefault();
var target = this.hash;
if ($(target).length != 0) {
$('html, body').stop()
.animate({
'scrollTop': $(target)
.offset()
.top
}, scrollAnimationTime, scrollAnimation, function () {
window.location.hash = target;
});
}
});
/*==============================================================
humburger menu one page navigation
==============================================================*/
if ($('.full-width-pull-menu').length > 0) {
$(document).on('click', '.full-width-pull-menu .inner-link', function (e) {
//$('body').removeClass('overflow-hidden position-fixed');
$(".full-width-pull-menu .close-button-menu").trigger("click");
var _this = $(this);
setTimeout(function () {
var target = _this.attr("href");
if ($(target).length > 0) {
$('html, body').stop()
.animate({
'scrollTop': $(target).offset().top
});
}
}, 500);
});
}
// Inner links
if ($('.navbar-top').length > 0 || $('.navbar-scroll-top').length > 0 || $('.nav-top-scroll').length > 0) {
$('.inner-link').smoothScroll({
speed: 900,
offset: 0
});
} else {
$('.inner-link').smoothScroll({
speed: 900,
offset: -59
});
}
$('.section-link').smoothScroll({
speed: 900,
offset: 1
});
/*==============================================================*/
//PieChart For Onepage - START CODE
/*==============================================================*/
if ($('.chart1').length > 0) {
$('.chart1').appear();
$('.chart1').easyPieChart({
barColor: '#929292',
trackColor: '#d9d9d9',
scaleColor: false,
easing: 'easeOutBounce',
scaleLength: 1,
lineCap: 'round',
lineWidth: 3, //12
size: 150, //110
animate: {
duration: 2000,
enabled: true
},
onStep: function (from, to, percent) {
$(this.el).find('.percent').text(Math.round(percent));
}
});
$(document.body).on('appear', '.chart1', function (e) {
// this code is executed for each appeared element
if (!$(this).hasClass('appear')) {
$(this).addClass('appear');
$(this).data('easyPieChart').update(0).update($(this).data('percent'));
}
});
}
if ($('.chart2').length > 0) {
$('.chart2').appear();
$('.chart2').easyPieChart({
easing: 'easeOutCirc',
barColor: '#ff214f',
trackColor: '#c7c7c7',
scaleColor: false,
scaleLength: 1,
lineCap: 'round',
lineWidth: 2, //12
size: 120, //110
animate: {
duration: 2000,
enabled: true
},
onStep: function (from, to, percent) {
$(this.el).find('.percent').text(Math.round(percent));
}
});
$(document.body).on('appear', '.chart2', function (e) {
// this code is executed for each appeared element
if (!$(this).hasClass('appear')) {
$(this).addClass('appear');
$(this).data('easyPieChart').update(0).update($(this).data('percent'));
}
});
}
if ($('.chart3').length > 0) {
$('.chart3').appear();
$('.chart3').easyPieChart({
easing: 'easeOutCirc',
barColor: '#ff214f',
trackColor: '',
scaleColor: false,
scaleLength: 1,
lineCap: 'round',
lineWidth: 3, //12
size: 140, //110
animate: {
duration: 2000,
enabled: true
},
onStep: function (from, to, percent) {
$(this.el).find('.percent').text(Math.round(percent));
}
});
$(document.body).on('appear', '.chart3', function (e) {
// this code is executed for each appeared element
if (!$(this).hasClass('appear')) {
$(this).addClass('appear');
$(this).data('easyPieChart').update(0).update($(this).data('percent'));
}
});
}
/*==============================================================*/
//PieChart For Onepage - END CODE
/*==============================================================*/
/*==============================================================
portfolio filter
==============================================================*/
var $portfolio_filter = $('.portfolio-grid');
$portfolio_filter.imagesLoaded(function () {
$portfolio_filter.isotope({
layoutMode: 'masonry',
itemSelector: '.grid-item',
percentPosition: true,
masonry: {
columnWidth: '.grid-sizer'
}
});
$portfolio_filter.isotope();
});
var $grid_selectors = $('.portfolio-filter > li > a');
$grid_selectors.on('click', function () {
$grid_selectors.parent().removeClass('active');
$(this).parent().addClass('active');
var selector = $(this).attr('data-filter');
$portfolio_filter.find('.grid-item').removeClass('animated').css("visibility", ""); // avoid problem to filter after sorting
$portfolio_filter.find('.grid-item').each(function () {
/* remove perticular element from WOW array when you don't want animation on element after DOM lead */
wow.removeBox(this);
$(this).css("-webkit-animation", "none");
$(this).css("-moz-animation", "none");
$(this).css("-ms-animation", "none");
$(this).css("animation", "none");
});
$portfolio_filter.isotope({filter: selector});
return false;
});
$(window).resize(function () {
if (!isMobile && !isiPhoneiPad) {
setTimeout(function () {
$portfolio_filter.find('.grid-item').removeClass('wow').removeClass('animated'); // avoid problem to filter after window resize
$portfolio_filter.isotope('layout');
}, 300);
}
});
var $blog_filter = $('.blog-grid');
$blog_filter.imagesLoaded(function () {
$blog_filter.isotope({
layoutMode: 'masonry',
itemSelector: '.grid-item',
percentPosition: true,
masonry: {
columnWidth: '.grid-sizer'
}
});
});
$(window).resize(function () {
setTimeout(function () {
$blog_filter.find('.grid-item').removeClass('wow').removeClass('animated'); // avoid problem to filter after window resize
$blog_filter.isotope('layout');
}, 300);
});
/*==============================================================
lightbox gallery
==============================================================*/
$('.lightbox-gallery').magnificPopup({
delegate: 'a',
type: 'image',
tLoading: 'Loading image #%curr%...',
mainClass: 'mfp-fade',
fixedContentPos: true,
closeBtnInside: false,
gallery: {
enabled: true,
navigateByImgClick: true,
preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
}
});
/* for group gallery */
var lightboxgallerygroups = {};
$('.lightbox-group-gallery-item').each(function () {
var id = $(this).attr('data-group');
if (!lightboxgallerygroups[id]) {
lightboxgallerygroups[id] = [];
}
lightboxgallerygroups[id].push(this);
});
$.each(lightboxgallerygroups, function () {
$(this).magnificPopup({
type: 'image',
closeOnContentClick: true,
closeBtnInside: false,
gallery: {enabled: true}
});
});
$('.lightbox-portfolio').magnificPopup({
delegate: '.gallery-link',
type: 'image',
tLoading: 'Loading image #%curr%...',
mainClass: 'mfp-fade',
fixedContentPos: true,
closeBtnInside: false,
gallery: {
enabled: true,
navigateByImgClick: false,
preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
}
});
/*==============================================================
single image lightbox - zoom animation
==============================================================*/
$('.single-image-lightbox').magnificPopup({
type: 'image',
closeOnContentClick: true,
fixedContentPos: true,
closeBtnInside: false,
mainClass: 'mfp-no-margins mfp-with-zoom', // class to remove default margin from left and right side
image: {
verticalFit: true
},
zoom: {
enabled: true,
duration: 300 // don't foget to change the duration also in CSS
}
});
/*==============================================================
zoom gallery
==============================================================*/
$('.zoom-gallery').magnificPopup({
delegate: 'a',
type: 'image',
mainClass: 'mfp-with-zoom mfp-img-mobile',
fixedContentPos: true,
closeBtnInside: false,
image: {
verticalFit: true,
titleSrc: function (item) {
return item.el.attr('title');
}
},
gallery: {
enabled: true
},
zoom: {
enabled: true,
duration: 300, // don't foget to change the duration also in CSS
opener: function (element) {
return element.find('img');
}
}
});
/*==============================================================*/
//Modal popup - START CODE
/*==============================================================*/
$('.modal-popup').magnificPopup({
type: 'inline',
preloader: false,
// modal: true,
blackbg: true,
callbacks: {
open: function () {
$('html').css('margin-right', 0);
}
}
});
$(document).on('click', '.popup-modal-dismiss', function (e) {
e.preventDefault();
$.magnificPopup.close();
});
/*==============================================================*/
//Modal popup - END CODE
/*==============================================================*/
/*==============================================================*/
//Modal popup - zoom animation - START CODE
/*==============================================================*/
$('.popup-with-zoom-anim').magnificPopup({
type: 'inline',
fixedContentPos: false,
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: true,
preloader: false,
midClick: true,
removalDelay: 300,
blackbg: true,
mainClass: 'my-mfp-zoom-in'
});
$('.popup-with-move-anim').magnificPopup({
type: 'inline',
fixedContentPos: false,
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: true,
preloader: false,
midClick: true,
removalDelay: 300,
blackbg: true,
mainClass: 'my-mfp-slide-bottom'
});
/*==============================================================*/
//Modal popup - zoom animation - END CODE
/*==============================================================*/
/*==============================================================
popup with form
==============================================================*/
$('.popup-with-form').magnificPopup({
type: 'inline',
preloader: false,
closeBtnInside: false,
fixedContentPos: true,
focus: '#name',
callbacks: {
beforeOpen: function () {
if ($(window).width() < 700) {
this.st.focus = false;
} else {
this.st.focus = '#name';
}
}
}
});
/*==============================================================
video magnific popup
==============================================================*/
$('.popup-youtube, .popup-vimeo, .popup-googlemap').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: true,
closeBtnInside: false
});
/*==============================================================
ajax magnific popup for onepage portfolio
==============================================================*/
$('.ajax-popup').magnificPopup({
type: 'ajax',
alignTop: true,
fixedContentPos: true,
overflowY: 'scroll', // as we know that popup content is tall we set scroll overflow by default to avoid jump
callbacks: {
open: function () {
$('.navbar .collapse').removeClass('in');
$('.navbar a.dropdown-toggle').addClass('collapsed');
}
}
});
/*==============================================================
mega menu width
===============================================================*/
$("ul.mega-menu-full").each(function (idx, elm) {
var megaMenuWidth = 0;
$(this).children('li').each(function (idx, elm) {
var LIheight = 0;
console.log($(this).outerWidth());
megaMenuWidth += $(this).outerWidth();
});
$(this).width(megaMenuWidth + 95);
megaMenuWidth = 0;
});
/*==============================================================
fit videos
==============================================================*/
$(".fit-videos").fitVids();
/*==============================================================
form to email
==============================================================*/
$("#success-subscribe-newsletter").hide();
$("#success-subscribe-newsletter2").hide();
$("#success-contact-form").hide();
$("#success-project-contact-form").hide();
$("#success-contact-form-2").hide();
$("#success-contact-form-3").hide();
$("#success-project-contact-form-4").hide();
//Subscribe newsletter form
$(document).on("click", '#button-subscribe-newsletter', function () {
var error = ValidationsubscribenewsletterForm();
if (error) {
$.ajax({
type: "POST",
url: "email-templates/subscribe-newsletter.php",
data: $("#subscribenewsletterform").serialize(),
success: function (result) {
// Un-comment below code to redirect user to thank you page.
//window.location.href="thank-you.html";
$('input[type=text],textarea').each(function () {
$(this).val('');
});
$("#success-subscribe-newsletter").html(result);
$("#success-subscribe-newsletter").fadeIn("slow");
$('#success-subscribe-newsletter').delay(4000).fadeOut("slow");
}
});
}
});
function ValidationsubscribenewsletterForm() {
var error = true;
$('#subscribenewsletterform input[type=text]').each(function (index) {
if (index == 0) {
if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) {
$("#subscribenewsletterform").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#subscribenewsletterform").find("input:eq(" + index + ")").removeClass("required-error");
}
}
});
return error;
}
$(document).on("click", '#button-subscribe-newsletter2', function () {
var error = ValidationsubscribenewsletterForm2();
if (error) {
$.ajax({
type: "POST",
url: "email-templates/subscribe-newsletter.php",
data: $("#subscribenewsletterform2").serialize(),
success: function (result) {
// Un-comment below code to redirect user to thank you page.
//window.location.href="thank-you.html";
$('input[type=text],textarea').each(function () {
$(this).val('');
});
$("#success-subscribe-newsletter2").html(result);
$("#success-subscribe-newsletter2").fadeIn("slow");
$('#success-subscribe-newsletter2').delay(4000).fadeOut("slow");
}
});
}
});
function ValidationsubscribenewsletterForm2() {
var error = true;
$('#subscribenewsletterform2 input[type=text]').each(function (index) {
if (index == 0) {
if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) {
$("#subscribenewsletterform2").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#subscribenewsletterform2").find("input:eq(" + index + ")").removeClass("required-error");
}
}
});
return error;
}
//Contact us form
$(document).on("click", '#contact-us-button', function () {
var error = ValidationContactForm();
if (error) {
$.ajax({
type: "POST",
url: "email-templates/contact.php",
data: $("#contact-form").serialize(),
success: function (result) {
// Un-comment below code to redirect user to thank you page.
//window.location.href="thank-you.html";
$('input[type=text],textarea').each(function () {
$(this).val('');
});
$("#success-contact-form").html(result);
$("#success-contact-form").fadeIn("slow");
$('#success-contact-form').delay(4000).fadeOut("slow");
}
});
}
});
function ValidationContactForm() {
var error = true;
$('#contact-form input[type=text]').each(function (index) {
if (index == 0) {
if ($(this).val() == null || $(this).val() == "") {
$("#contact-form").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#contact-form").find("input:eq(" + index + ")").removeClass("required-error");
}
} else if (index == 1) {
if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) {
$("#contact-form").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#contact-form").find("input:eq(" + index + ")").removeClass("required-error");
}
}
});
return error;
}
//Contact us form 2
$('#contact-us-button-2').on("click", function () {
var error = ValidationContactForm2();
if (error) {
$.ajax({
type: "POST",
url: "email-templates/contact.php",
data: $("#contact-form-2").serialize(),
success: function (result) {
// Un-comment below code to redirect user to thank you page.
//window.location.href="thank-you.html";
$('input[type=text],textarea').each(function () {
$(this).val('');
});
$("#success-contact-form-2").html(result);
$("#success-contact-form-2").fadeIn("slow");
$('#success-contact-form-2').delay(4000).fadeOut("slow");
}
});
}
});
function ValidationContactForm2() {
var error = true;
$('#contact-form-2 input[type=text]').each(function (index) {
if (index == 0) {
if ($(this).val() == null || $(this).val() == "") {
$("#contact-form-2").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#contact-form-2").find("input:eq(" + index + ")").removeClass("required-error");
}
} else if (index == 1) {
if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) {
$("#contact-form-2").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#contact-form-2").find("input:eq(" + index + ")").removeClass("required-error");
}
}
});
return error;
}
//Contact us form 3
$(document).on("click", '#contact-us-button-3', function () {
var error = ValidationContactForm3();
if (error) {
$.ajax({
type: "POST",
url: "email-templates/contact.php",
data: $("#contact-form-3").serialize(),
success: function (result) {
// Un-comment below code to redirect user to thank you page.
//window.location.href="thank-you.html";
$('input[type=text],textarea').each(function () {
$(this).val('');
});
$("#success-contact-form-3").html(result);
$("#success-contact-form-3").fadeIn("slow");
$('#success-contact-form-3').delay(4000).fadeOut("slow");
}
});
}
});
function ValidationContactForm3() {
var error = true;
$('#contact-form-3 input[type=text]').each(function (index) {
if (index == 0) {
if ($(this).val() == null || $(this).val() == "") {
$("#contact-form-3").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#contact-form-3").find("input:eq(" + index + ")").removeClass("required-error");
}
} else if (index == 1) {
if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) {
$("#contact-form-3").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#contact-form-3").find("input:eq(" + index + ")").removeClass("required-error");
}
}
});
return error;
}
//Project Contact us form
$(document).on("click", '#project-contact-us-button', function () {
var error = ValidationProjectContactForm();
if (error) {
$.ajax({
type: "POST",
url: "email-templates/project-contact.php",
data: $("#project-contact-form").serialize(),
success: function (result) {
// Un-comment below code to redirect user to thank you page.
//window.location.href="thank-you.html";
$('input[type=text],textarea').each(function () {
$(this).val('');
});
$("#success-project-contact-form").html(result);
$("#success-project-contact-form").fadeIn("slow");
$('#success-project-contact-form').delay(4000).fadeOut("slow");
}
});
}
});
function ValidationProjectContactForm() {
var error = true;
$('#project-contact-form input[type=text]').each(function (index) {
if (index == 0) {
if ($(this).val() == null || $(this).val() == "") {
$("#project-contact-form").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#project-contact-form").find("input:eq(" + index + ")").removeClass("required-error");
}
} else if (index == 2) {
if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) {
$("#project-contact-form").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#project-contact-form").find("input:eq(" + index + ")").removeClass("required-error");
}
}
});
return error;
}
//Project Contact us form 2
$(document).on("click", '#project-contact-us-4-button', function () {
var error = ValidationProjectContactForm4();
if (error) {
$.ajax({
type: "POST",
url: "email-templates/project-contact.php",
data: $("#project-contact-form-4").serialize(),
success: function (result) {
// Un-comment below code to redirect user to thank you page.
//window.location.href="thank-you.html";
$('input[type=text],textarea').each(function () {
$(this).val('');
});
$("#success-project-contact-form-4").html(result);
$("#success-project-contact-form-4").fadeIn("slow");
$('#success-project-contact-form-4').delay(4000).fadeOut("slow");
}
});
}
});
function ValidationProjectContactForm4() {
var error = true;
$('#project-contact-form-4 input[type=text]').each(function (index) {
if (index == 0) {
if ($(this).val() == null || $(this).val() == "") {
$("#project-contact-form-4").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#project-contact-form-4").find("input:eq(" + index + ")").removeClass("required-error");
}
} else if (index == 2) {
if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) {
$("#project-contact-form-4").find("input:eq(" + index + ")").addClass("required-error");
error = false;
} else {
$("#project-contact-form-4").find("input:eq(" + index + ")").removeClass("required-error");
}
}
});
return error;
}
/*==============================================================
End form to email
==============================================================*/
/*==============================================================
wow animation - on scroll
==============================================================*/
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
mobile: false,
live: true
});
$(window).imagesLoaded(function () {
wow.init();
});
/*==============================================================
counter
==============================================================*/
$(function ($) {
animatecounters();
});
function animatecounters() {
$('.timer').each(count);
function count(options) {
var $this = $(this);
options = $.extend({}, options || {}, $this.data('countToOptions') || {});
$this.countTo(options);
}
}
/* ===================================
counter number reset while scrolling
====================================== */
$('.timer').appear();
$(document.body).on('appear', '.timer', function (e) {
// this code is executed for each appeared element
if (!$(this).hasClass('appear')) {
animatecounters();
$(this).addClass('appear');
}
});
$('.countdown').countdown($('.countdown').attr("data-enddate")).on('update.countdown', function (event) {
$(this).html(event.strftime('' + '
'));
});
/* ===================================
left nav
====================================== */
$(document).on('click', '.right-menu-button', function (e) {
$('body').toggleClass('left-nav-on');
});
/*==============================================================*/
// hamburger menu
/*==============================================================*/
$(document).on('click', '.btn-hamburger', function () {
$('.hamburger-menu').toggleClass('show-menu');
$('body').removeClass('show-menu');
});
/*==============================================================*/
//sidebar nav open
/*==============================================================*/
$(document).on('click', '#mobileToggleSidenav', function () {
$(this).closest('nav').toggleClass('sidemenu-open');
});
/*=================================
//justified Gallery
=================================*/
$(document).imagesLoaded(function () {
if ($(".justified-gallery").length > 0) {
$(".justified-gallery").justifiedGallery({
rowHeight: 400,
maxRowHeight: false,
captions: true,
margins: 10,
waitThumbnailsLoad: true
});
}
});
$('.atr-nav').on("click", function () {
$(".atr-div").append("X");
$(".atr-div").animate({
width: "toggle"
});
});
$('.close-cross').on("click", function () {
$(".atr-div").hide();
});
var menuRight = document.getElementById('cbp-spmenu-s2'),
showRightPush = document.getElementById('showRightPush'),
body = document.body;
if (showRightPush) {
showRightPush.onclick = function () {
classie.toggle(this, 'active');
if (menuRight)
classie.toggle(menuRight, 'cbp-spmenu-open');
};
}
var test = document.getElementById('close-pushmenu');
if (test) {
test.onclick = function () {
classie.toggle(this, 'active');
if (menuRight)
classie.toggle(menuRight, 'cbp-spmenu-open');
};
}
//blog page header animation
$(document).on('mouseover', ".blog-header-style1 li", function () {
$('.blog-header-style1 li.blog-column-active').removeClass('blog-column-active');
$(this).addClass('blog-column-active');
}).on('mouseleave', function () {
$(this).removeClass('blog-column-active');
$('.blog-header-style1 li:first-child').addClass('blog-column-active');
});
/*==============================================================*/
//big menu open close start
/*==============================================================*/
$('.big-menu-open').on("click", function () {
$('.big-menu-right').addClass("open");
});
$('.big-menu-close').on("click", function () {
$('.big-menu-right').removeClass("open");
});
/*==============================================================*/
//big menu open close end
/*==============================================================*/
/*==============================================================
instagramfeed
==============================================================*/
if ($('#instaFeed-style1').length != 0) {
var instaFeedStyle1 = new Instafeed({
target: 'instaFeed-style1',
get: 'user',
userId: 5640046896,
limit: '8',
accessToken: '5640046896.1677ed0.f7cd85767e124a9f9f8d698cb33252a0',
resolution: "low_resolution",
error: {
template: 'No Images Found
'
},
template: ''
});
instaFeedStyle1.run();
}
if ($('#instaFeed-aside').length != 0) {
var instaFeedAside = new Instafeed({
target: 'instaFeed-aside',
get: 'user',
userId: 5640046896,
limit: '6',
accessToken: '5640046896.1677ed0.f7cd85767e124a9f9f8d698cb33252a0',
resolution: "low_resolution",
after: function () {
equalizeHeight();
},
error: {
template: 'No Images Found
'
},
template: '
{{likes}}'
});
instaFeedAside.run();
}
if ($('#instaFeed-footer').length != 0) {
var instaFeedFooter = new Instafeed({
target: 'instaFeed-footer',
get: 'user',
userId: 5640046896,
limit: '6',
accessToken: '5640046896.1677ed0.f7cd85767e124a9f9f8d698cb33252a0',
resolution: "low_resolution",
after: function () {
equalizeHeight();
},
error: {
template: 'No Images Found
'
},
template: '
{{likes}}'
});
instaFeedFooter.run();
}
/*==============================================================
instagramfeed end
==============================================================*/
/*==============================================================*/
//revolution Start
/*==============================================================*/
/* ================================
home-creative-studio
================================*/
if ($("#rev_slider_151_1").revolution == undefined) {
revslider_showDoubleJqueryError("#rev_slider_151_1");
} else {
$("#rev_slider_151_1").show().revolution({
sliderType: "standard",
jsFileLocation: "revolution/js/",
sliderLayout: "fullscreen",
dottedOverlay: "none",
delay: 9000,
navigation: {
keyboardNavigation: "off",
keyboard_direction: "vertical",
mouseScrollNavigation: "off",
mouseScrollReverse: "default",
onHoverStop: "off",
touch: {
touchenabled: "on",
swipe_threshold: 75,
swipe_min_touches: 1,
swipe_direction: "horizontal",
drag_block_vertical: false
},
arrows: {
style: "uranus",
enable: true,
hide_onmobile: false,
hide_over: 479,
hide_onleave: false,
tmp: '',
left: {
h_align: "left",
v_align: "center",
h_offset: 0,
v_offset: 0
},
right: {
h_align: "right",
v_align: "center",
h_offset: 0,
v_offset: 0
}
}
},
responsiveLevels: [1240, 1024, 778, 480],
visibilityLevels: [1240, 1024, 778, 480],
gridwidth: [1240, 1024, 778, 480],
gridheight: [868, 768, 960, 720],
lazyType: "none",
scrolleffect: {
blur: "on",
maxblur: "20",
on_slidebg: "on",
direction: "top",
multiplicator: "2",
multiplicator_layers: "2",
tilt: "10",
disable_on_mobile: "off"
},
parallax: {
type: "scroll",
origo: "slidercenter",
speed: 400,
levels: [5, 10, 15, 20, 25, 30, 35, 40, 45, 46, 47, 48, 49, 50, 51, 55]
},
shadow: 0,
spinner: "spinner3",
stopLoop: "off",
stopAfterLoops: -1,
stopAtSlide: -1,
shuffle: "off",
autoHeight: "off",
fullScreenAutoWidth: "off",
fullScreenAlignForce: "off",
fullScreenOffsetContainer: "",
fullScreenOffset: "0px",
hideThumbsOnMobile: "off",
hideSliderAtLimit: 0,
hideCaptionAtLimit: 0,
hideAllCaptionAtLilmit: 0,
debugMode: false,
fallbacks: {
simplifyAll: "off",
nextSlideOnWindowFocus: "off",
disableFocusListener: false
}
});
}
/* ================================
home-classic-web-agency
================================*/
if ($("#rev_slider_1174_1").revolution == undefined) {
revslider_showDoubleJqueryError("#rev_slider_1174_1");
} else {
$("#rev_slider_1174_1").show().revolution({
sliderType: "hero",
jsFileLocation: "revolution/js/",
sliderLayout: "fullscreen",
dottedOverlay: "none",
delay: 9000,
navigation: {
},
responsiveLevels: [1240, 1024, 778, 480],
visibilityLevels: [1240, 1024, 778, 480],
gridwidth: [1240, 1024, 778, 480],
gridheight: [868, 768, 960, 720],
lazyType: "none",
parallax: {
type: "scroll",
origo: "slidercenter",
speed: 400,
levels: [10, 15, 20, 25, 30, 35, 40, -10, -15, -20, -25, -30, -35, -40, -45, 55]
},
shadow: 0,
spinner: "off",
autoHeight: "off",
fullScreenAutoWidth: "off",
fullScreenAlignForce: "off",
fullScreenOffsetContainer: "",
disableProgressBar: "on",
hideThumbsOnMobile: "off",
hideSliderAtLimit: 0,
hideCaptionAtLimit: 0,
hideAllCaptionAtLilmit: 0,
debugMode: false,
fallbacks: {
simplifyAll: "off",
disableFocusListener: false
}
});
}
/* ================================
home-classic-corporate
================================*/
if ($("#rev_slider_1078_1").revolution == undefined) {
revslider_showDoubleJqueryError("#rev_slider_1078_1");
} else {
$("#rev_slider_1078_1").show().revolution({
sliderType: "standard",
jsFileLocation: "revolution/js/",
sliderLayout: "fullscreen",
dottedOverlay: "none",
delay: 9000,
navigation: {
keyboardNavigation: "on",
keyboard_direction: "horizontal",
mouseScrollNavigation: "off",
mouseScrollReverse: "default",
onHoverStop: "off",
touch: {
touchenabled: "on",
swipe_threshold: 75,
swipe_min_touches: 1,
swipe_direction: "horizontal",
drag_block_vertical: false
}
,
arrows: {
style: "zeus",
enable: true,
hide_onmobile: true,
hide_under: 600,
hide_onleave: true,
hide_delay: 200,
hide_delay_mobile: 1200,
tmp: '',
left: {
h_align: "left",
v_align: "center",
h_offset: 30,
v_offset: 0
},
right: {
h_align: "right",
v_align: "center",
h_offset: 30,
v_offset: 0
}
}
,
bullets: {
enable: true,
hide_onmobile: false,
hide_under: 300,
style: "hermes",
hide_onleave: false,
hide_delay: 200,
hide_delay_mobile: 1200,
direction: "horizontal",
h_align: "center",
v_align: "bottom",
h_offset: 0,
v_offset: 30,
space: 8,
tmp: ' {{title}}'
}
},
viewPort: {
enable: true,
outof: "pause",
visible_area: "80%",
presize: false
},
responsiveLevels: [1240, 1024, 778, 480],
visibilityLevels: [1240, 1024, 778, 480],
gridwidth: [1240, 1024, 778, 480],
gridheight: [600, 600, 500, 400],
lazyType: "none",
parallax: {
type: "mouse",
origo: "slidercenter",
speed: 2000,
levels: [2, 3, 4, 5, 6, 7, 12, 16, 10, 50, 46, 47, 48, 49, 50, 55]
},
shadow: 0,
spinner: "off",
stopLoop: "off",
stopAfterLoops: -1,
stopAtSlide: -1,
shuffle: "off",
autoHeight: "off",
hideThumbsOnMobile: "off",
hideSliderAtLimit: 0,
hideCaptionAtLimit: 0,
hideAllCaptionAtLilmit: 0,
debugMode: false,
fallbacks: {
simplifyAll: "off",
nextSlideOnWindowFocus: "off",
disableFocusListener: false
}
});
}
/*==============================================================*/
//revolution End
/*==============================================================*/
/*==============================================================*/
//magnificPopup Start
/*==============================================================*/
$('.header-search-form').magnificPopup({
mainClass: 'mfp-fade',
closeOnBgClick: true,
preloader: false,
// for white backgriund
fixedContentPos: false,
closeBtnInside: false,
callbacks: {
open: function () {
setTimeout(function () {
$('.search-input').focus();
}, 500);
$('#search-header').parent().addClass('search-popup');
if (!isMobile) {
$('body').addClass('overflow-hidden');
//$('body').addClass('position-fixed');
$('body').addClass('width-100');
document.onmousewheel = ScrollStop;
} else {
$('body, html').on('touchmove', function (e) {
e.preventDefault();
});
}
},
close: function () {
if (!isMobile) {
$('body').removeClass('overflow-hidden');
//$('body').removeClass('position-fixed');
$('body').removeClass('width-100');
$('#search-header input[type=text]').each(function (index) {
if (index == 0) {
$(this).val('');
$("#search-header").find("input:eq(" + index + ")").css({"border": "none", "border-bottom": "2px solid rgba(255,255,255,0.5)"});
}
});
document.onmousewheel = ScrollStart;
} else {
$('body, html').unbind('touchmove');
}
}
}
});
/*==============================================================*/
//magnificPopup End
/*==============================================================*/
$("input.search-input").on("keypress", function (event) {
if (event.which == 13 && !isMobile) {
$("button.search-button").trigger("click");
event.preventDefault();
}
});
$("input.search-input").on("keyup", function (event) {
if ($(this).val() == null || $(this).val() == "") {
$(this).css({"border": "none", "border-bottom": "2px solid red"});
} else {
$(this).css({"border": "none", "border-bottom": "2px solid rgba(255,255,255,0.5)"});
}
});
$("form.search-form, form.search-form-result").submit(function (event) {
var error = validationSearchForm();
if (error) {
var action = $(this).attr('action');
action = action == '#' || action == '' ? 'blog-grid-3columns.html' : action;
action = action + '?' + $(this).serialize();
window.location = action;
}
event.preventDefault();
});
$(document).on("click", '.navbar .navbar-collapse a.dropdown-toggle, .accordion-style1 .panel-heading a, .accordion-style2 .panel-heading a, .accordion-style3 .panel-heading a, .toggles .panel-heading a, .toggles-style2 .panel-heading a, .toggles-style3 .panel-heading a, a.carousel-control, .nav-tabs a[data-toggle="tab"], a.shopping-cart', function (e) {
e.preventDefault();
});
$(document).on('touchstart click', 'body', function (e) {
if ($(window).width() < 992) {
if (!$('.navbar-collapse').has(e.target).is('.navbar-collapse') && $('.navbar-collapse').hasClass('in') && !$(e.target).hasClass('navbar-toggle')) {
$('.navbar-collapse').collapse('hide');
}
} else {
if (!$('.navbar-collapse').has(e.target).is('.navbar-collapse') && $('.navbar-collapse ul').hasClass('in')) {
console.log(this);
$('.navbar-collapse').find('a.dropdown-toggle').addClass('collapsed');
$('.navbar-collapse').find('ul.dropdown-menu').removeClass('in');
$('.navbar-collapse a.dropdown-toggle').removeClass('active');
}
}
});
$('.navbar-collapse a.dropdown-toggle').on('touchstart', function (e) {
$('.navbar-collapse a.dropdown-toggle').not(this).removeClass('active');
if ($(this).hasClass('active'))
$(this).removeClass('active');
else
$(this).addClass('active');
});
$('button.navbar-toggle').on("click", function (e) {
if (isMobile) {
$(".cart-content").css('opacity', '0');
$(".cart-content").css('visibility', 'hidden');
}
});
$('a.dropdown-toggle').on("click", function (e) {
if (isMobile) {
$(".cart-content").css('opacity', '0');
$(".cart-content").css('visibility', 'hidden');
}
});
$(document).on('touchstart click', '.navbar-collapse [data-toggle="dropdown"]', function (event) {
var $innerLinkLI = $(this).parents('ul.navbar-nav').find('li.dropdown a.inner-link').parent('li.dropdown');
if (!$(this).hasClass('inner-link') && !$(this).hasClass('dropdown-toggle') && $innerLinkLI.hasClass('open')) {
$innerLinkLI.removeClass('open');
}
var target = $(this).attr('target');
if ($(window).width() <= 991 && $(this).attr('href') && $(this).attr('href').indexOf("#") <= -1 && !$(event.target).is('i')) {
if (event.ctrlKey || event.metaKey) {
window.open($(this).attr('href'), "_blank");
return false;
} else if (!target)
window.location = $(this).attr('href');
else
window.open($(this).attr('href'), target);
} else if ($(window).width() > 991 && $(this).attr('href').indexOf("#") <= -1) {
if (event.ctrlKey || event.metaKey) {
window.open($(this).attr('href'), "_blank");
return false;
} else if (!target)
window.location = $(this).attr('href');
else
window.open($(this).attr('href'), target);
} else if ($(window).width() <= 991 && $(this).attr('href') && $(this).attr('href').length > 1 && $(this).attr('href').indexOf("#") >= 0 && $(this).hasClass('inner-link')) {
$(this).parents('ul.navbar-nav').find('li.dropdown').not($(this).parent('.dropdown')).removeClass('open');
if ($(this).parent('.dropdown').hasClass('open')) {
$(this).parent('.dropdown').removeClass('open');
} else {
$(this).parent('.dropdown').addClass('open');
}
$(this).toggleClass('active');
}
});
/* ===================================
skillbar
====================================== */
$('.skillbar').appear();
$('.skillbar').skillBars({
from: 0,
speed: 4000,
interval: 100,
decimals: 0
});
$(document.body).on('appear', '.skillbar', function (e) {
// this code is executed for each appeared element
if (!$(this).hasClass('appear')) {
$(this).addClass('appear');
$(this).find('.skillbar-bar').css("width", "0%");
$(this).skillBars({
from: 0,
speed: 4000,
interval: 100,
decimals: 0
});
}
});
/* ===================================
touchstart click
====================================== */
$('body').on('touchstart click', function (e) {
if ($(window).width() < 992) {
}
});
/*==============================================================*/
//Set Resize Header Menu - START CODE
/*==============================================================*/
$('nav.full-width-pull-menu ul.panel-group li.dropdown a.dropdown-toggle').on("click", function (e) {
if ($(this).parent('li').find('ul.dropdown-menu').length > 0) {
if ($(this).parent('li').hasClass('open')) {
$(this).parent('li').removeClass('open');
} else {
$(this).parent('li').addClass('open');
}
}
});
/*==============================================================*/
//accordion - START CODE
/*==============================================================*/
$('.accordion-style1 .collapse').on('show.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').addClass('active-accordion');
$('a[href="#' + id + '"] .panel-title span').html('');
});
$('.accordion-style1 .collapse').on('hide.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').removeClass('active-accordion');
$('a[href="#' + id + '"] .panel-title span').html('');
});
$('.nav.navbar-nav a.inner-link').on("click", function (e) {
$(this).parents('ul.navbar-nav').find('a.inner-link').removeClass('active');
var $this = $(this);
if ($('.nav-header-container .navbar-toggle').is(':visible'))
$(this).parents('.navbar-collapse').collapse('hide');
setTimeout(function () {
$this.addClass('active');
}, 1000);
});
$('.accordion-style2 .collapse').on('show.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').addClass('active-accordion');
$('a[href="#' + id + '"] .panel-title').find('i').addClass('fa-angle-up').removeClass('fa-angle-down');
});
$('.accordion-style2 .collapse').on('hide.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').removeClass('active-accordion');
$('a[href="#' + id + '"] .panel-title').find('i').removeClass('fa-angle-up').addClass('fa-angle-down');
});
$('.accordion-style3 .collapse').on('show.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').addClass('active-accordion');
$('a[href="#' + id + '"] .panel-title').find('i').addClass('fa-angle-up').removeClass('fa-angle-down');
});
$('.accordion-style3 .collapse').on('hide.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').removeClass('active-accordion');
$('a[href="#' + id + '"] .panel-title').find('i').removeClass('fa-angle-up').addClass('fa-angle-down');
});
/*==============================================================*/
//accordion - END CODE
/*==============================================================*/
/*==============================================================*/
//toggles - START CODE
/*==============================================================*/
$('.toggles .collapse').on('show.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').addClass('active-accordion');
$('a[href="#' + id + '"] .panel-title span').html('');
});
$('.toggles .collapse').on('hide.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').removeClass('active-accordion');
$('a[href="#' + id + '"] .panel-title span').html('');
});
$('.toggles-style2 .collapse').on('show.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').addClass('active-accordion');
$('a[href="#' + id + '"] .panel-title span').html('');
});
$('.toggles-style2 .collapse').on('hide.bs.collapse', function () {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').removeClass('active-accordion');
$('a[href="#' + id + '"] .panel-title span').html('');
});
/*==============================================================*/
//toggles - END CODE
/*==============================================================*/
/* ===================================
blog hover box
====================================== */
$(document).on("mouseenter", ".blog-post-style4 .grid-item", function (e) {
$(this).find("figcaption .blog-hover-text").slideDown(300);
});
$(document).on("mouseleave", ".blog-post-style4 .grid-item", function (e) {
$(this).find("figcaption .blog-hover-text").slideUp(300);
});
/* ===================================
End blog hover box
====================================== */
SetResizeContent();
var $allNonRatinaImages = $("img:not([data-at2x])");
$allNonRatinaImages.attr('data-no-retina', '');
/*==============================================================*/
//demo button - START CODE
/*==============================================================*/
var $buythemediv = '';
$('body').append($buythemediv);
/*==============================================================*/
//demo button - END CODE
/*==============================================================*/
});
/* ===================================
END READY
====================================== */
/* ===================================
START Page Load
====================================== */
$(window).load(function () {
var hash = window.location.hash.substr(1);
if (hash != "") {
setTimeout(function () {
$(window).imagesLoaded(function () {
var scrollAnimationTime = 1200,
scrollAnimation = 'easeInOutExpo';
var target = '#' + hash;
if ($(target).length > 0) {
$('html, body').stop()
.animate({
'scrollTop': $(target).offset().top
}, scrollAnimationTime, scrollAnimation, function () {
window.location.hash = target;
});
}
});
}, 500);
}
});
/* ===================================
END Page Load
====================================== */
/*!
Colorbox 1.6.4
license: MIT
http://www.jacklmoore.com/colorbox
*/
(function ($, document, window) {
var
// Default settings object.
// See http://jacklmoore.com/colorbox for details.
defaults = {
// data sources
html: false,
photo: false,
iframe: false,
inline: false,
// behavior and appearance
transition: "elastic",
speed: 300,
fadeOut: 300,
width: false,
initialWidth: "600",
innerWidth: false,
maxWidth: false,
height: false,
initialHeight: "450",
innerHeight: false,
maxHeight: false,
scalePhotos: true,
scrolling: true,
opacity: 0.9,
preloading: true,
className: false,
overlayClose: true,
escKey: true,
arrowKey: true,
top: false,
bottom: false,
left: false,
right: false,
fixed: false,
data: undefined,
closeButton: true,
fastIframe: true,
open: false,
reposition: true,
loop: true,
slideshow: false,
slideshowAuto: true,
slideshowSpeed: 2500,
slideshowStart: "start slideshow",
slideshowStop: "stop slideshow",
photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,
// alternate image paths for high-res displays
retinaImage: false,
retinaUrl: false,
retinaSuffix: '@2x.$1',
// internationalization
current: "image {current} of {total}",
previous: "previous",
next: "next",
close: "close",
xhrError: "This content failed to load.",
imgError: "This image failed to load.",
// accessbility
returnFocus: true,
trapFocus: true,
// callbacks
onOpen: false,
onLoad: false,
onComplete: false,
onCleanup: false,
onClosed: false,
rel: function() {
return this.rel;
},
href: function() {
// using this.href would give the absolute url, when the href may have been inteded as a selector (e.g. '#container')
return $(this).attr('href');
},
title: function() {
return this.title;
},
createImg: function() {
var img = new Image();
var attrs = $(this).data('cbox-img-attrs');
if (typeof attrs === 'object') {
$.each(attrs, function(key, val){
img[key] = val;
});
}
return img;
},
createIframe: function() {
var iframe = document.createElement('iframe');
var attrs = $(this).data('cbox-iframe-attrs');
if (typeof attrs === 'object') {
$.each(attrs, function(key, val){
iframe[key] = val;
});
}
if ('frameBorder' in iframe) {
iframe.frameBorder = 0;
}
if ('allowTransparency' in iframe) {
iframe.allowTransparency = "true";
}
iframe.name = (new Date()).getTime(); // give the iframe a unique name to prevent caching
iframe.allowFullscreen = true;
return iframe;
}
},
// Abstracting the HTML and event identifiers for easy rebranding
colorbox = 'colorbox',
prefix = 'cbox',
boxElement = prefix + 'Element',
// Events
event_open = prefix + '_open',
event_load = prefix + '_load',
event_complete = prefix + '_complete',
event_cleanup = prefix + '_cleanup',
event_closed = prefix + '_closed',
event_purge = prefix + '_purge',
// Cached jQuery Object Variables
$overlay,
$box,
$wrap,
$content,
$topBorder,
$leftBorder,
$rightBorder,
$bottomBorder,
$related,
$window,
$loaded,
$loadingBay,
$loadingOverlay,
$title,
$current,
$slideshow,
$next,
$prev,
$close,
$groupControls,
$events = $(''), // $({}) would be preferred, but there is an issue with jQuery 1.4.2
// Variables for cached values or use across multiple functions
settings,
interfaceHeight,
interfaceWidth,
loadedHeight,
loadedWidth,
index,
photo,
open,
active,
closing,
loadingTimer,
publicMethod,
div = "div",
requests = 0,
previousCSS = {},
init;
// ****************
// HELPER FUNCTIONS
// ****************
// Convenience function for creating new jQuery objects
function $tag(tag, id, css) {
var element = document.createElement(tag);
if (id) {
element.id = prefix + id;
}
if (css) {
element.style.cssText = css;
}
return $(element);
}
// Get the window height using innerHeight when available to avoid an issue with iOS
// http://bugs.jquery.com/ticket/6724
function winheight() {
return window.innerHeight ? window.innerHeight : $(window).height();
}
function Settings(element, options) {
if (options !== Object(options)) {
options = {};
}
this.cache = {};
this.el = element;
this.value = function(key) {
var dataAttr;
if (this.cache[key] === undefined) {
dataAttr = $(this.el).attr('data-cbox-'+key);
if (dataAttr !== undefined) {
this.cache[key] = dataAttr;
} else if (options[key] !== undefined) {
this.cache[key] = options[key];
} else if (defaults[key] !== undefined) {
this.cache[key] = defaults[key];
}
}
return this.cache[key];
};
this.get = function(key) {
var value = this.value(key);
return $.isFunction(value) ? value.call(this.el, this) : value;
};
}
// Determine the next and previous members in a group.
function getIndex(increment) {
var
max = $related.length,
newIndex = (index + increment) % max;
return (newIndex < 0) ? max + newIndex : newIndex;
}
// Convert '%' and 'px' values to integers
function setSize(size, dimension) {
return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10));
}
// Checks an href to see if it is a photo.
// There is a force photo option (photo: true) for hrefs that cannot be matched by the regex.
function isImage(settings, url) {
return settings.get('photo') || settings.get('photoRegex').test(url);
}
function retinaUrl(settings, url) {
return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url;
}
function trapFocus(e) {
if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) {
e.stopPropagation();
$box.focus();
}
}
function setClass(str) {
if (setClass.str !== str) {
$box.add($overlay).removeClass(setClass.str).addClass(str);
setClass.str = str;
}
}
function getRelated(rel) {
index = 0;
if (rel && rel !== false && rel !== 'nofollow') {
$related = $('.' + boxElement).filter(function () {
var options = $.data(this, colorbox);
var settings = new Settings(this, options);
return (settings.get('rel') === rel);
});
index = $related.index(settings.el);
// Check direct calls to Colorbox.
if (index === -1) {
$related = $related.add(settings.el);
index = $related.length - 1;
}
} else {
$related = $(settings.el);
}
}
function trigger(event) {
// for external use
$(document).trigger(event);
// for internal use
$events.triggerHandler(event);
}
var slideshow = (function(){
var active,
className = prefix + "Slideshow_",
click = "click." + prefix,
timeOut;
function clear () {
clearTimeout(timeOut);
}
function set() {
if (settings.get('loop') || $related[index + 1]) {
clear();
timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed'));
}
}
function start() {
$slideshow
.html(settings.get('slideshowStop'))
.unbind(click)
.one(click, stop);
$events
.bind(event_complete, set)
.bind(event_load, clear);
$box.removeClass(className + "off").addClass(className + "on");
}
function stop() {
clear();
$events
.unbind(event_complete, set)
.unbind(event_load, clear);
$slideshow
.html(settings.get('slideshowStart'))
.unbind(click)
.one(click, function () {
publicMethod.next();
start();
});
$box.removeClass(className + "on").addClass(className + "off");
}
function reset() {
active = false;
$slideshow.hide();
clear();
$events
.unbind(event_complete, set)
.unbind(event_load, clear);
$box.removeClass(className + "off " + className + "on");
}
return function(){
if (active) {
if (!settings.get('slideshow')) {
$events.unbind(event_cleanup, reset);
reset();
}
} else {
if (settings.get('slideshow') && $related[1]) {
active = true;
$events.one(event_cleanup, reset);
if (settings.get('slideshowAuto')) {
start();
} else {
stop();
}
$slideshow.show();
}
}
};
}());
function launch(element) {
var options;
if (!closing) {
options = $(element).data(colorbox);
settings = new Settings(element, options);
getRelated(settings.get('rel'));
if (!open) {
open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
setClass(settings.get('className'));
// Show colorbox so the sizes can be calculated in older versions of jQuery
$box.css({visibility:'hidden', display:'block', opacity:''});
$loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden');
$content.css({width:'', height:''}).append($loaded);
// Cache values needed for size calculations
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();
interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
loadedHeight = $loaded.outerHeight(true);
loadedWidth = $loaded.outerWidth(true);
// Opens inital empty Colorbox prior to content being loaded.
var initialWidth = setSize(settings.get('initialWidth'), 'x');
var initialHeight = setSize(settings.get('initialHeight'), 'y');
var maxWidth = settings.get('maxWidth');
var maxHeight = settings.get('maxHeight');
settings.w = Math.max((maxWidth !== false ? Math.min(initialWidth, setSize(maxWidth, 'x')) : initialWidth) - loadedWidth - interfaceWidth, 0);
settings.h = Math.max((maxHeight !== false ? Math.min(initialHeight, setSize(maxHeight, 'y')) : initialHeight) - loadedHeight - interfaceHeight, 0);
$loaded.css({width:'', height:settings.h});
publicMethod.position();
trigger(event_open);
settings.get('onOpen');
$groupControls.add($title).hide();
$box.focus();
if (settings.get('trapFocus')) {
// Confine focus to the modal
// Uses event capturing that is not supported in IE8-
if (document.addEventListener) {
document.addEventListener('focus', trapFocus, true);
$events.one(event_closed, function () {
document.removeEventListener('focus', trapFocus, true);
});
}
}
// Return focus on closing
if (settings.get('returnFocus')) {
$events.one(event_closed, function () {
$(settings.el).focus();
});
}
}
var opacity = parseFloat(settings.get('opacity'));
$overlay.css({
opacity: opacity === opacity ? opacity : '',
cursor: settings.get('overlayClose') ? 'pointer' : '',
visibility: 'visible'
}).show();
if (settings.get('closeButton')) {
$close.html(settings.get('close')).appendTo($content);
} else {
$close.appendTo(''); // replace with .detach() when dropping jQuery < 1.4
}
load();
}
}
// Colorbox's markup needs to be added to the DOM prior to being called
// so that the browser will go ahead and load the CSS background images.
function appendHTML() {
if (!$box) {
init = false;
$window = $(window);
$box = $tag(div).attr({
id: colorbox,
'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS.
role: 'dialog',
tabindex: '-1'
}).hide();
$overlay = $tag(div, "Overlay").hide();
$loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]);
$wrap = $tag(div, "Wrapper");
$content = $tag(div, "Content").append(
$title = $tag(div, "Title"),
$current = $tag(div, "Current"),
$prev = $('').attr({id:prefix+'Previous'}),
$next = $('').attr({id:prefix+'Next'}),
$slideshow = $('').attr({id:prefix+'Slideshow'}),
$loadingOverlay
);
$close = $('').attr({id:prefix+'Close'});
$wrap.append( // The 3x3 Grid that makes up Colorbox
$tag(div).append(
$tag(div, "TopLeft"),
$topBorder = $tag(div, "TopCenter"),
$tag(div, "TopRight")
),
$tag(div, false, 'clear:left').append(
$leftBorder = $tag(div, "MiddleLeft"),
$content,
$rightBorder = $tag(div, "MiddleRight")
),
$tag(div, false, 'clear:left').append(
$tag(div, "BottomLeft"),
$bottomBorder = $tag(div, "BottomCenter"),
$tag(div, "BottomRight")
)
).find('div div').css({'float': 'left'});
$loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none; max-width:none;');
$groupControls = $next.add($prev).add($current).add($slideshow);
}
if (document.body && !$box.parent().length) {
$(document.body).append($overlay, $box.append($wrap, $loadingBay));
}
}
// Add Colorbox's event bindings
function addBindings() {
function clickHandler(e) {
// ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.
// See: http://jacklmoore.com/notes/click-events/
if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) {
e.preventDefault();
launch(this);
}
}
if ($box) {
if (!init) {
init = true;
// Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
$next.click(function () {
publicMethod.next();
});
$prev.click(function () {
publicMethod.prev();
});
$close.click(function () {
publicMethod.close();
});
$overlay.click(function () {
if (settings.get('overlayClose')) {
publicMethod.close();
}
});
// Key Bindings
$(document).bind('keydown.' + prefix, function (e) {
var key = e.keyCode;
if (open && settings.get('escKey') && key === 27) {
e.preventDefault();
publicMethod.close();
}
if (open && settings.get('arrowKey') && $related[1] && !e.altKey) {
if (key === 37) {
e.preventDefault();
$prev.click();
} else if (key === 39) {
e.preventDefault();
$next.click();
}
}
});
if ($.isFunction($.fn.on)) {
// For jQuery 1.7+
$(document).on('click.'+prefix, '.'+boxElement, clickHandler);
} else {
// For jQuery 1.3.x -> 1.6.x
// This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed.
// This is not here for jQuery 1.9, it's here for legacy users.
$('.'+boxElement).live('click.'+prefix, clickHandler);
}
}
return true;
}
return false;
}
// Don't do anything if Colorbox already exists.
if ($[colorbox]) {
return;
}
// Append the HTML when the DOM loads
$(appendHTML);
// ****************
// PUBLIC FUNCTIONS
// Usage format: $.colorbox.close();
// Usage from within an iframe: parent.jQuery.colorbox.close();
// ****************
publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
var settings;
var $obj = this;
options = options || {};
if ($.isFunction($obj)) { // assume a call to $.colorbox
$obj = $('');
options.open = true;
}
if (!$obj[0]) { // colorbox being applied to empty collection
return $obj;
}
appendHTML();
if (addBindings()) {
if (callback) {
options.onComplete = callback;
}
$obj.each(function () {
var old = $.data(this, colorbox) || {};
$.data(this, colorbox, $.extend(old, options));
}).addClass(boxElement);
settings = new Settings($obj[0], options);
if (settings.get('open')) {
launch($obj[0]);
}
}
return $obj;
};
publicMethod.position = function (speed, loadedCallback) {
var
css,
top = 0,
left = 0,
offset = $box.offset(),
scrollTop,
scrollLeft;
$window.unbind('resize.' + prefix);
// remove the modal so that it doesn't influence the document width/height
$box.css({top: -9e4, left: -9e4});
scrollTop = $window.scrollTop();
scrollLeft = $window.scrollLeft();
if (settings.get('fixed')) {
offset.top -= scrollTop;
offset.left -= scrollLeft;
$box.css({position: 'fixed'});
} else {
top = scrollTop;
left = scrollLeft;
$box.css({position: 'absolute'});
}
// keeps the top and left positions within the browser's viewport.
if (settings.get('right') !== false) {
left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.get('right'), 'x'), 0);
} else if (settings.get('left') !== false) {
left += setSize(settings.get('left'), 'x');
} else {
left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
}
if (settings.get('bottom') !== false) {
top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.get('bottom'), 'y'), 0);
} else if (settings.get('top') !== false) {
top += setSize(settings.get('top'), 'y');
} else {
top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
}
$box.css({top: offset.top, left: offset.left, visibility:'visible'});
// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
// but it has to be shrank down around the size of div#colorbox when it's done. If not,
// it can invoke an obscure IE bug when using iframes.
$wrap[0].style.width = $wrap[0].style.height = "9999px";
function modalDimensions() {
$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = (parseInt($box[0].style.width,10) - interfaceWidth)+'px';
$content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = (parseInt($box[0].style.height,10) - interfaceHeight)+'px';
}
css = {width: settings.w + loadedWidth + interfaceWidth, height: settings.h + loadedHeight + interfaceHeight, top: top, left: left};
// setting the speed to 0 if the content hasn't changed size or position
if (speed) {
var tempSpeed = 0;
$.each(css, function(i){
if (css[i] !== previousCSS[i]) {
tempSpeed = speed;
return;
}
});
speed = tempSpeed;
}
previousCSS = css;
if (!speed) {
$box.css(css);
}
$box.dequeue().animate(css, {
duration: speed || 0,
complete: function () {
modalDimensions();
active = false;
// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
$wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
$wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
if (settings.get('reposition')) {
setTimeout(function () { // small delay before binding onresize due to an IE8 bug.
$window.bind('resize.' + prefix, publicMethod.position);
}, 1);
}
if ($.isFunction(loadedCallback)) {
loadedCallback();
}
},
step: modalDimensions
});
};
publicMethod.resize = function (options) {
var scrolltop;
if (open) {
options = options || {};
if (options.width) {
settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
}
if (options.innerWidth) {
settings.w = setSize(options.innerWidth, 'x');
}
$loaded.css({width: settings.w});
if (options.height) {
settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
}
if (options.innerHeight) {
settings.h = setSize(options.innerHeight, 'y');
}
if (!options.innerHeight && !options.height) {
scrolltop = $loaded.scrollTop();
$loaded.css({height: "auto"});
settings.h = $loaded.height();
}
$loaded.css({height: settings.h});
if(scrolltop) {
$loaded.scrollTop(scrolltop);
}
publicMethod.position(settings.get('transition') === "none" ? 0 : settings.get('speed'));
}
};
publicMethod.prep = function (object) {
if (!open) {
return;
}
var callback, speed = settings.get('transition') === "none" ? 0 : settings.get('speed');
$loaded.remove();
$loaded = $tag(div, 'LoadedContent').append(object);
function getWidth() {
settings.w = settings.w || $loaded.width();
settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
return settings.w;
}
function getHeight() {
settings.h = settings.h || $loaded.height();
settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
return settings.h;
}
$loaded.hide()
.appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
.css({width: getWidth(), overflow: settings.get('scrolling') ? 'auto' : 'hidden'})
.css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
.prependTo($content);
$loadingBay.hide();
// floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
$(photo).css({'float': 'none'});
setClass(settings.get('className'));
callback = function () {
var total = $related.length,
iframe,
complete;
if (!open) {
return;
}
function removeFilter() { // Needed for IE8 in versions of jQuery prior to 1.7.2
if ($.support.opacity === false) {
$box[0].style.removeAttribute('filter');
}
}
complete = function () {
clearTimeout(loadingTimer);
$loadingOverlay.hide();
trigger(event_complete);
settings.get('onComplete');
};
$title.html(settings.get('title')).show();
$loaded.show();
if (total > 1) { // handle grouping
if (typeof settings.get('current') === "string") {
$current.html(settings.get('current').replace('{current}', index + 1).replace('{total}', total)).show();
}
$next[(settings.get('loop') || index < total - 1) ? "show" : "hide"]().html(settings.get('next'));
$prev[(settings.get('loop') || index) ? "show" : "hide"]().html(settings.get('previous'));
slideshow();
// Preloads images within a rel group
if (settings.get('preloading')) {
$.each([getIndex(-1), getIndex(1)], function(){
var img,
i = $related[this],
settings = new Settings(i, $.data(i, colorbox)),
src = settings.get('href');
if (src && isImage(settings, src)) {
src = retinaUrl(settings, src);
img = document.createElement('img');
img.src = src;
}
});
}
} else {
$groupControls.hide();
}
if (settings.get('iframe')) {
iframe = settings.get('createIframe');
if (!settings.get('scrolling')) {
iframe.scrolling = "no";
}
$(iframe)
.attr({
src: settings.get('href'),
'class': prefix + 'Iframe'
})
.one('load', complete)
.appendTo($loaded);
$events.one(event_purge, function () {
iframe.src = "//about:blank";
});
if (settings.get('fastIframe')) {
$(iframe).trigger('load');
}
} else {
complete();
}
if (settings.get('transition') === 'fade') {
$box.fadeTo(speed, 1, removeFilter);
} else {
removeFilter();
}
};
if (settings.get('transition') === 'fade') {
$box.fadeTo(speed, 0, function () {
publicMethod.position(0, callback);
});
} else {
publicMethod.position(speed, callback);
}
};
function load () {
var href, setResize, prep = publicMethod.prep, $inline, request = ++requests;
active = true;
photo = false;
trigger(event_purge);
trigger(event_load);
settings.get('onLoad');
settings.h = settings.get('height') ?
setSize(settings.get('height'), 'y') - loadedHeight - interfaceHeight :
settings.get('innerHeight') && setSize(settings.get('innerHeight'), 'y');
settings.w = settings.get('width') ?
setSize(settings.get('width'), 'x') - loadedWidth - interfaceWidth :
settings.get('innerWidth') && setSize(settings.get('innerWidth'), 'x');
// Sets the minimum dimensions for use in image scaling
settings.mw = settings.w;
settings.mh = settings.h;
// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
if (settings.get('maxWidth')) {
settings.mw = setSize(settings.get('maxWidth'), 'x') - loadedWidth - interfaceWidth;
settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
}
if (settings.get('maxHeight')) {
settings.mh = setSize(settings.get('maxHeight'), 'y') - loadedHeight - interfaceHeight;
settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
}
href = settings.get('href');
loadingTimer = setTimeout(function () {
$loadingOverlay.show();
}, 100);
if (settings.get('inline')) {
var $target = $(href).eq(0);
// Inserts an empty placeholder where inline content is being pulled from.
// An event is bound to put inline content back when Colorbox closes or loads new content.
$inline = $('').hide().insertBefore($target);
$events.one(event_purge, function () {
$inline.replaceWith($target);
});
prep($target);
} else if (settings.get('iframe')) {
// IFrame element won't be added to the DOM until it is ready to be displayed,
// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
prep(" ");
} else if (settings.get('html')) {
prep(settings.get('html'));
} else if (isImage(settings, href)) {
href = retinaUrl(settings, href);
photo = settings.get('createImg');
$(photo)
.addClass(prefix + 'Photo')
.bind('error.'+prefix,function () {
prep($tag(div, 'Error').html(settings.get('imgError')));
})
.one('load', function () {
if (request !== requests) {
return;
}
// A small pause because some browsers will occasionally report a
// img.width and img.height of zero immediately after the img.onload fires
setTimeout(function(){
var percent;
if (settings.get('retinaImage') && window.devicePixelRatio > 1) {
photo.height = photo.height / window.devicePixelRatio;
photo.width = photo.width / window.devicePixelRatio;
}
if (settings.get('scalePhotos')) {
setResize = function () {
photo.height -= photo.height * percent;
photo.width -= photo.width * percent;
};
if (settings.mw && photo.width > settings.mw) {
percent = (photo.width - settings.mw) / photo.width;
setResize();
}
if (settings.mh && photo.height > settings.mh) {
percent = (photo.height - settings.mh) / photo.height;
setResize();
}
}
if (settings.h) {
photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px';
}
if ($related[1] && (settings.get('loop') || $related[index + 1])) {
photo.style.cursor = 'pointer';
$(photo).bind('click.'+prefix, function () {
publicMethod.next();
});
}
photo.style.width = photo.width + 'px';
photo.style.height = photo.height + 'px';
prep(photo);
}, 1);
});
photo.src = href;
} else if (href) {
$loadingBay.load(href, settings.get('data'), function (data, status) {
if (request === requests) {
prep(status === 'error' ? $tag(div, 'Error').html(settings.get('xhrError')) : $(this).contents());
}
});
}
}
// Navigates to the next page/image in a set.
publicMethod.next = function () {
if (!active && $related[1] && (settings.get('loop') || $related[index + 1])) {
index = getIndex(1);
launch($related[index]);
}
};
publicMethod.prev = function () {
if (!active && $related[1] && (settings.get('loop') || index)) {
index = getIndex(-1);
launch($related[index]);
}
};
// Note: to use this within an iframe use the following format: parent.jQuery.colorbox.close();
publicMethod.close = function () {
if (open && !closing) {
closing = true;
open = false;
trigger(event_cleanup);
settings.get('onCleanup');
$window.unbind('.' + prefix);
$overlay.fadeTo(settings.get('fadeOut') || 0, 0);
$box.stop().fadeTo(settings.get('fadeOut') || 0, 0, function () {
$box.hide();
$overlay.hide();
trigger(event_purge);
$loaded.remove();
setTimeout(function () {
closing = false;
trigger(event_closed);
settings.get('onClosed');
}, 1);
});
}
};
// Removes changes Colorbox made to the document, but does not remove the plugin.
publicMethod.remove = function () {
if (!$box) { return; }
$box.stop();
$[colorbox].close();
$box.stop(false, true).remove();
$overlay.remove();
closing = false;
$box = null;
$('.' + boxElement)
.removeData(colorbox)
.removeClass(boxElement);
$(document).unbind('click.'+prefix).unbind('keydown.'+prefix);
};
// A method for fetching the current element Colorbox is referencing.
// returns a jQuery object.
publicMethod.element = function () {
return $(settings.el);
};
publicMethod.settings = defaults;
}(jQuery, document, window));