Files
manjapro_v6/agen/js/custom.js
T

179 lines
4.0 KiB
JavaScript

/*---------------------------------------------------------------------
File Name: custom.js
---------------------------------------------------------------------*/
$(function () {
"use strict";
/* Preloader
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
setTimeout(function () {
$('.loader_bg').fadeToggle();
}, 1500);
/* Tooltip
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
/* Mouseover
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$(document).ready(function(){
$(".main-menu ul li.megamenu").mouseover(function(){
if (!$(this).parent().hasClass("#wrapper")){
$("#wrapper").addClass('overlay');
}
});
$(".main-menu ul li.megamenu").mouseleave(function(){
$("#wrapper").removeClass('overlay');
});
});
/* Toggle sidebar
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$(document).ready(function () {
$('#sidebarCollapse').on('click', function () {
$('#sidebar').toggleClass('active');
$(this).toggleClass('active');
});
});
/* Product slider
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
// optional
$('#blogCarousel').carousel({
interval: 5000
});
});
function getURL() { window.location.href; } ;
/* Toggle sidebar
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
function openNav() {
document.getElementById("mySidepanel").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidepanel").style.width = "0";
}
/* Animate js*/
(function($) {
//Function to animate slider captions
function doAnimations(elems) {
//Cache the animationend event in a variable
var animEndEv = "webkitAnimationEnd animationend";
elems.each(function() {
var $this = $(this),
$animationType = $this.data("animation");
$this.addClass($animationType).one(animEndEv, function() {
$this.removeClass($animationType);
});
});
}
//Variables on page load
var $myCarousel = $("#carouselExampleIndicators"),
$firstAnimatingElems = $myCarousel
.find(".carousel-item:first")
.find("[data-animation ^= 'animated']");
//Initialize carousel
$myCarousel.carousel();
//Animate captions in first slide on page load
doAnimations($firstAnimatingElems);
//Other slides to be animated on carousel slide event
$myCarousel.on("slide.bs.carousel", function(e) {
var $animatingElems = $(e.relatedTarget).find(
"[data-animation ^= 'animated']"
);
doAnimations($animatingElems);
});
})(jQuery);
/* Toggle sidebar
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
function openNav() {
document.getElementById("mySidepanel").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidepanel").style.width = "0";
}
// owl-carousel
$('.owl-carousel').owlCarousel({
loop: true,
margin: 15,
nav: true,
responsive: {
0: {
items: 1
},
600: {
items: 3
},
1000: {
items: 3
}
}
})
// menu js
// define all UI variable
const navToggler = document.querySelector('.nav-toggler');
const navMenu = document.querySelector('.site-navbar ul');
const navLinks = document.querySelectorAll('.site-navbar a');
// load all event listners
allEventListners();
// functions of all event listners
function allEventListners() {
// toggler icon click event
navToggler.addEventListener('click', togglerClick);
// nav links click event
navLinks.forEach( elem => elem.addEventListener('click', navLinkClick));
}
// togglerClick function
function togglerClick() {
navToggler.classList.toggle('toggler-open');
navMenu.classList.toggle('open');
}
// navLinkClick function
function navLinkClick() {
if(navMenu.classList.contains('open')) {
navToggler.click();
}
}