132 lines
3.5 KiB
JavaScript
132 lines
3.5 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');
|
|
});
|
|
});
|
|
|
|
|
|
|
|
/* Product slider
|
|
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
|
|
// optional
|
|
$('#blogCarousel').carousel({
|
|
interval: 5000
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/* 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);
|
|
});
|
|
|
|
/*-------------------
|
|
Quantity change
|
|
--------------------- */
|
|
var proQty = $('.pro-qty');
|
|
proQty.prepend('<span class="dec qtybtn">-</span>');
|
|
proQty.append('<span class="inc qtybtn">+</span>');
|
|
proQty.on('click', '.qtybtn', function () {
|
|
var $button = $(this);
|
|
var oldValue = $button.parent().find('input').val();
|
|
if ($button.hasClass('inc')) {
|
|
var newVal = parseFloat(oldValue) + 1;
|
|
} else {
|
|
// Don't allow decrementing below zero
|
|
if (oldValue > 0) {
|
|
var newVal = parseFloat(oldValue) - 1;
|
|
} else {
|
|
newVal = 0;
|
|
}
|
|
}
|
|
$button.parent().find('input').val(newVal);
|
|
});
|
|
|
|
})(jQuery);
|
|
|
|
|
|
/* collapse js*/
|
|
|
|
$(document).ready(function(){
|
|
// Add minus icon for collapse element which is open by default
|
|
$(".collapse.show").each(function(){
|
|
$(this).prev(".card-header").find(".fa").addClass("fa-minus").removeClass("fa-plus");
|
|
});
|
|
|
|
// Toggle plus minus icon on show hide of collapse element
|
|
$(".collapse").on('show.bs.collapse', function(){
|
|
$(this).prev(".card-header").find(".fa").removeClass("fa-plus").addClass("fa-minus");
|
|
}).on('hide.bs.collapse', function(){
|
|
$(this).prev(".card-header").find(".fa").removeClass("fa-minus").addClass("fa-plus");
|
|
});
|
|
});
|
|
|
|
|