(function($) {
"use strict";
//Hide Loading Box (Preloader)
function handlePreloader() {
if($('.preloader').length){
$('.preloader').delay(200).fadeOut(500);
}
}
//Add One Page nav
if($('.scroll-nav').length) {
$('.scroll-nav ul').onePageNav();
}
$('[data-toggle="tooltip"]').tooltip();
//Hide Bootstrap Onepage Menu On Click
$('.mobile-menu .scroll-nav .navigation li a').on('click', function(){
var windowWidth = $(window).width();
if (windowWidth <= 1199) {
$('.mobile-menu .navbar-toggle').trigger( "click" );
}
});
$('.typed-title').typed({
stringsElement: $('.typing-title'),
backDelay: 1000,
typeSpeed: 0,
loop: true
});
function customScrollbar() {
var windowWidth = $(window).width();
if (windowWidth <= 1199) {
}else {
$(".card-inner").niceScroll();
}
}
customScrollbar();
/*
Vars
*/
var width = $(window).width();
var height = $(window).height();
/*
Header Menu Desktop
*/
var container = $('.card-outer .container');
var innerbox = $('.card-outer .card-inner-box');
var card_items = $('.card-item');
var animation_in = container.data('animation-in');
var animation_out = container.data('animation-out');
$('.main-menu').on('click', 'a', function(){
/* vars */
var id = $(this).attr('href');
var h = parseFloat($(id).offset().top);
var card_item = $(id);
var menu_items = $('.main-menu li');
var menu_item_home = $('.main-menu li.home');
var menu_item = $(this).closest('li');
var d_lnk = $('.lnks .lnk.discover');
/* if desktop */
if(!menu_item.hasClass('active') & $('#home').length) {
/* close card items */
menu_items.removeClass('active');
container.find(card_items).removeClass('animated '+animation_in);
if($(container).hasClass('opened')) {
container.find(card_items).addClass('animated '+animation_out);
}
/* open card item */
menu_item.addClass('active');
container.addClass('opened');
container.find(card_item).removeClass('animated '+animation_out);
container.find(card_item).addClass('animated '+animation_in);
$(card_items).addClass('hide-item');
$(card_item).removeClass('hide-item');
$(card_item).addClass('active');
}
if(!menu_item_home.hasClass('active')) {
$(innerbox).addClass('offsetleft');
}else {
$(innerbox).removeClass('offsetleft');
}
return false;
});
//Jquery Knob animation
if($('.dial').length){
$('.dial').appear(function(){
var elm = $(this);
var color = elm.attr('data-fgColor');
var perc = elm.attr('value');
elm.knob({
'value': 0,
'min':0,
'max':100,
'skin':'tron',
'readOnly':true,
'thickness':0.12,
'dynamicDraw': true,
'displayInput':false
});
$({value: 0}).animate({ value: perc }, {
duration: 2000,
easing: 'swing',
progress: function () { elm.val(Math.ceil(this.value)).trigger('change');
}
});
},{accY: 0});
}
//Jquery Knob animation Two
function knobAnimate() {
if($('.round-dial').length){
$('.round-dial').each(function(){
var elm = $(this);
var color = elm.attr('data-fgColor');
var perc = elm.attr('value');
elm.knob({
'value': 0,
'min':0,
'max':100,
'skin':'tron',
'readOnly':true,
'thickness':0.12,
'dynamicDraw': true,
'displayInput':false
});
$({value: 0}).animate({ value: perc }, {
duration: 0,
easing: 'swing',
progress: function () { elm.val(Math.ceil(this.value)).trigger('change');
}
});
});
}
}
knobAnimate();
//Masonary
function enableMasonry() {
if($('.masonry-items-container').length){
var winDow = $(window);
// Needed variables
var $container=$('.masonry-items-container');
$container.isotope({
itemSelector: '.masonry-item',
masonry: {
columnWidth : '.column-width'
},
animationOptions:{
duration:500,
easing:'linear'
}
});
winDow.on('resize', function(){
$container.isotope({
itemSelector: '.masonry-item',
animationOptions: {
duration: 500,
easing : 'linear',
queue : false
}
});
});
}
}
enableMasonry();
//Masonary Two
function enableMasonryTwo() {
if($('.masonry-two').length){
var winDow = $(window);
// Needed variables
var $container=$('.masonry-two');
$container.isotope({
itemSelector: '.masonry-item',
masonry: {
columnWidth : '.masonry-item',
},
animationOptions:{
duration:500,
easing:'linear'
}
});
winDow.on('resize', function(){
$container.isotope({
itemSelector: '.masonry-item',
animationOptions: {
duration: 500,
easing : 'linear',
queue : false
}
});
});
}
}
enableMasonryTwo();
//Portfolio Carousel one
if ($('.portfolio-carousel-one').length) {
$('.portfolio-carousel-one').owlCarousel({
animateOut: 'fadeOut',
animateIn: 'fadeIn',
loop:true,
mouseDrag:false,
margin:30,
nav:true,
smartSpeed: 700,
autoplay: true,
autoplayTimeout:7000,
navText: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
1024:{
items:1
},
}
});
}
//Portfolio Carousel Two
if ($('.portfolio-carousel-two').length) {
$('.portfolio-carousel-two').owlCarousel({
animateOut: 'fadeOut',
animateIn: 'fadeIn',
loop:true,
mouseDrag:false,
margin:30,
nav:true,
smartSpeed: 700,
autoplay: true,
autoplayTimeout:7000,
navText: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
1024:{
items:1
},
}
});
}
//Portfolio Carousel Slider
if ($('.portfolio-carousel-three').length) {
$('.portfolio-carousel-three').owlCarousel({
loop:true,
margin:20,
nav:true,
smartSpeed: 700,
autoplay: 4000,
navText: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:2
},
800:{
items:3
},
1024:{
items:4
},
1600:{
items:5
}
}
});
}
//Testimonial Carousel
if ($('.testimonial-carousel').length) {
$('.testimonial-carousel').owlCarousel({
loop:true,
margin:20,
nav:true,
smartSpeed: 700,
autoplay: 4000,
navText: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
1024:{
items:1
},
}
});
}
//Testimonial Carousel
if ($('.single-item-carousel').length) {
$('.single-item-carousel').owlCarousel({
loop:true,
margin:20,
nav:true,
smartSpeed: 700,
autoplay: 4000,
navText: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
1024:{
items:1
},
}
});
}
//LightBox / Fancybox
if($('.lightbox-image').length) {
$('.lightbox-image').fancybox({
openEffect : 'fade',
closeEffect : 'fade',
helpers : {
media : {}
}
});
}
//Contact Form Validation
if($('#contact-form').length){
$('#contact-form').validate({
rules: {
username: {
required: true
},
email: {
required: true,
email: true
},
phone: {
required: true
},
message: {
required: true
}
}
});
}
// Scroll to a Specific Div
if($('.scroll-to-target').length){
$(".scroll-to-target").on('click', function() {
var target = $(this).attr('data-target');
// animate
$('html, body').animate({
scrollTop: $(target).offset().top
}, 1500);
});
}
//Progress Bar
if($('.progress-line').length){
$('.progress-line').appear(function(){
var el = $(this);
var percent = el.data('width');
$(el).css('width',percent+'%');
},{accY: 0});
}
//Tabs Box
if($('.tabs-box').length){
$('.tabs-box .tab-buttons .tab-btn').on('click', function(e) {
e.preventDefault();
var target = $($(this).attr('data-tab'));
if ($(target).is(':visible')){
return false;
}else{
target.parents('.tabs-box').find('.tab-buttons').find('.tab-btn').removeClass('active-btn');
$(this).addClass('active-btn');
target.parents('.tabs-box').find('.tabs-content').find('.tab').fadeOut(0);
target.parents('.tabs-box').find('.tabs-content').find('.tab').removeClass('active-tab');
$(target).fadeIn(300);
$(target).addClass('active-tab');
}
});
}
// Elements Animation
if($('.wow').length){
var wow = new WOW(
{
boxClass: 'wow', // animated element css class (default is wow)
animateClass: 'animated', // animation css class (default is animated)
offset: 0, // distance to the element when triggering the animation (default is 0)
mobile: true, // trigger animations on mobile devices (default is true)
live: true // act on asynchronously loaded content (default is true)
}
);
wow.init();
}
//Fact Counter + Text Count
if($('.count-box').length){
$('.count-box').appear(function(){
var $t = $(this),
n = $t.find(".count-text").attr("data-stop"),
r = parseInt($t.find(".count-text").attr("data-speed"), 10);
if (!$t.hasClass("counted")) {
$t.addClass("counted");
$({
countNum: $t.find(".count-text").text()
}).animate({
countNum: n
}, {
duration: r,
easing: "linear",
step: function() {
$t.find(".count-text").text(Math.floor(this.countNum));
},
complete: function() {
$t.find(".count-text").text(this.countNum);
}
});
}
},{accY: 0});
}
//Bottom Parallax
function bottomParallax() {
if($('.bottom-parallax').length){
var windowpos = $(window).scrollTop();
var siteFooter = $('.main-footer').height();
var sitebodyHeight = $('.page-wrapper').height();
var finalHeight = sitebodyHeight - siteFooter - 1100;
if (windowpos >= finalHeight) {
$('body').addClass('parallax-visible');
} else {
$('body').removeClass('parallax-visible');
}
}
}
bottomParallax();
//Make Content Sticky
if($('.sticky-box').length){
var a = new StickySidebar('.portfolio-single .content-column .inner', {
topSpacing: 80,
bottomSpacing: 0,
containerSelector: '.sticky-container',
innerWrapperSelector: '.sticky-box'
});
}
//Split Scroll (Home 7)
if($('#scroll-container').length){
$('#scroll-container').multiscroll({
navigation: true,
css3:true
});
}
/* ==========================================================================
When document is Scrollig, do
========================================================================== */
$(window).on('scroll', function() {
bottomParallax();
});
/* ==========================================================================
When document is loading, do
========================================================================== */
$(window).on('load', function() {
handlePreloader();
enableMasonry();
enableMasonryTwo();
});
/* ==========================================================================
When page is resized
========================================================================== */
$(window).on('resize', function() {
customScrollbar();
});
/* ==========================================================================
When document is Resize, do
========================================================================== */
})(window.jQuery);