(function($) {
"use strict";
//update header style and scroll to top
function headerstyle() {
if($('.main-header').length){
var windowpos = $(window).scrolltop();
var siteheader = $('.main-header');
var scrolllink = $('.scroll-top');
if (windowpos >= 110) {
siteheader.addclass('fixed-header');
scrolllink.addclass('open');
} else {
siteheader.removeclass('fixed-header');
scrolllink.removeclass('open');
}
}
}
headerstyle();
//submenu dropdown toggle
if($('.main-header li.dropdown ul').length){
$('.main-header .navigation li.dropdown').append('
');
}
//mobile nav hide show
if($('.mobile-menu').length){
$('.mobile-menu .menu-box').mcustomscrollbar();
var mobilemenucontent = $('.main-header .menu-area .main-menu').html();
$('.mobile-menu .menu-box .menu-outer').append(mobilemenucontent);
$('.sticky-header .main-menu').append(mobilemenucontent);
//dropdown button
$('.mobile-menu li.dropdown .dropdown-btn').on('click', function() {
$(this).toggleclass('open');
$(this).prev('ul').slidetoggle(500);
});
//dropdown button
$('.mobile-menu li.dropdown .dropdown-btn').on('click', function() {
$(this).prev('.megamenu').slidetoggle(900);
});
//menu toggle btn
$('.mobile-nav-toggler').on('click', function() {
$('body').addclass('mobile-menu-visible');
});
//menu toggle btn
$('.mobile-menu .menu-backdrop,.mobile-menu .close-btn').on('click', function() {
$('body').removeclass('mobile-menu-visible');
});
}
// 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
}, 1000);
});
}
// elements animation
if($('.wow').length){
var wow = new wow({
mobile: false
});
wow.init();
}
//contact form validation
if($('#contact-form').length){
$('#contact-form').validate({
rules: {
username: {
required: true
},
email: {
required: true,
email: true
},
phone: {
required: true
},
subject: {
required: true
},
message: {
required: true
}
}
});
}
//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});
}
//lightbox / fancybox
if($('.lightbox-image').length) {
$('.lightbox-image').fancybox({
openeffect : 'fade',
closeeffect : 'fade',
helpers : {
media : {}
}
});
}
//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');
}
});
}
//accordion box
if($('.accordion-box').length){
$(".accordion-box").on('click', '.acc-btn', function() {
var outerbox = $(this).parents('.accordion-box');
var target = $(this).parents('.accordion');
if($(this).hasclass('active')!==true){
$(outerbox).find('.accordion .acc-btn').removeclass('active');
}
if ($(this).next('.acc-content').is(':visible')){
$(this).parent().removeclass('active-block');
$(this).next('.acc-content').slideup(300);
}else{
$(this).addclass('active');
$(outerbox).children('.accordion').removeclass('active-block');
$(outerbox).find('.accordion').children('.acc-content').slideup(300);
target.addclass('active-block');
$(this).next('.acc-content').slidedown(300);
}
});
}
// banner-carousel
if ($('.banner-carousel').length) {
$('.banner-carousel').owlcarousel({
loop:true,
margin:0,
nav:true,
animateout: 'fadeout',
animatein: 'fadein',
active: true,
smartspeed: 1000,
autoplay: 6000,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
800:{
items:1
},
1024:{
items:1
}
}
});
}
// single-item-carousel
if ($('.single-item-carousel').length) {
$('.single-item-carousel').owlcarousel({
loop:true,
margin:30,
nav:false,
smartspeed: 3000,
autoplay: true,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
480:{
items:1
},
600:{
items:1
},
800:{
items:1
},
1200:{
items:1
}
}
});
}
//two-column-carousel
if ($('.two-column-carousel').length) {
$('.two-column-carousel').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 3000,
autoplay: 4000,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
480:{
items:1
},
600:{
items:1
},
800:{
items:2
},
1024:{
items:2
}
}
});
}
//three-item-carousel
if ($('.three-item-carousel').length) {
$('.three-item-carousel').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 1000,
autoplay: 500,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
480:{
items:1
},
600:{
items:2
},
800:{
items:2
},
1024:{
items:3
}
}
});
}
//three-item-carousel-2
if ($('.three-item-carousel-2').length) {
$('.three-item-carousel-2').owlcarousel({
loop:true,
margin:0,
nav:true,
smartspeed: 1000,
autoplay: 500,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
480:{
items:1
},
600:{
items:2
},
800:{
items:2
},
1024:{
items:3
}
}
});
}
// four item carousel
if ($('.four-item-carousel').length) {
$('.four-item-carousel').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 500,
autoplay: 5000,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:2
},
800:{
items:3
},
1024:{
items:3
},
1200:{
items:4
}
}
});
}
//add one page nav
if($('.scroll-nav').length) {
$('.scroll-nav').onepagenav();
}
//search popup
if($('#search-popup').length){
//show popup
$('.search-toggler.search-toggler1').on('click', function() {
$('#search-popup').addclass('popup-visible');
});
$(document).keydown(function(e){
if(e.keycode === 27) {
$('#search-popup').removeclass('popup-visible');
}
});
//hide popup
$('.close-search,.search-popup .overlay-layer').on('click', function() {
$('#search-popup').removeclass('popup-visible');
});
}
// color switcher
function swithcermenu () {
if ($('.switch_menu').length) {
$('.switch_btn button').on('click', function(){
$('.switch_menu').toggle(500)
});
$('#styleoptions').styleswitcher({
haspreview: true,
fullpath: 'assets/css/color/',
cookie: {
expires: 30,
ismanagingload: true
}
});
};
}
// page direction
function directionswitch() {
if ($('.page_direction').length) {
$('.direction_switch button').on('click', function() {
$('body').toggleclass(function(){
return $(this).is('.rtl, .ltr') ? 'rtl ltr' : 'rtl';
})
});
};
}
/*$(document).ready(function() {
$('select:not(.ignore)').niceselect();
});*/
/* =========================================================================
when document is scrollig, do
========================================================================== */
jquery(document).on('ready', function () {
(function ($) {
// add your functions
swithcermenu();
directionswitch();
})(jquery);
});
/* ==========================================================================
when document is scrollig, do
========================================================================== */
$(window).on('scroll', function() {
headerstyle();
});
/* ==========================================================================
when document is loaded, do
========================================================================== */
/*$(window).on('load', function() {
handlepreloader();
});*/
})(window.jquery);