(function ($) {
"use strict";
/*[ Load page ]
===========================================================*/
$(".animsition").animsition({
inClass: 'fade-in',
outClass: 'fade-out',
inDuration: 1500,
outDuration: 800,
linkElement: '.animsition-link',
loading: true,
loadingParentElement: 'html',
loadingClass: 'animsition-loading-1',
loadingInner: '
',
timeout: false,
timeoutCountdown: 5000,
onLoadEvent: true,
browser: [ 'animation-duration', '-webkit-animation-duration'],
overlay : false,
overlayClass : 'animsition-overlay-slide',
overlayParentElement : 'html',
transition: function(url){ window.location.href = url; }
});
/*[ Back to top ]
===========================================================*/
var windowH = $(window).height()/2;
$(window).on('scroll',function(){
if ($(this).scrollTop() > windowH) {
$("#myBtn").css('display','flex');
} else {
$("#myBtn").css('display','none');
}
});
$('#myBtn').on("click", function(){
$('html, body').animate({scrollTop: 0}, 300);
});
/*==================================================================
[ Fixed Header ]*/
var headerDesktop = $('.container-menu-desktop');
var wrapMenu = $('.wrap-menu-desktop');
if($('.top-bar').length > 0) {
var posWrapHeader = $('.top-bar').height();
}
else {
var posWrapHeader = 0;
}
if($(window).scrollTop() > posWrapHeader) {
$(headerDesktop).addClass('fix-menu-desktop');
$(wrapMenu).css('top',0);
}
else {
$(headerDesktop).removeClass('fix-menu-desktop');
$(wrapMenu).css('top',posWrapHeader - $(this).scrollTop());
}
$(window).on('scroll',function(){
if($(this).scrollTop() > posWrapHeader) {
$(headerDesktop).addClass('fix-menu-desktop');
$(wrapMenu).css('top',0);
}
else {
$(headerDesktop).removeClass('fix-menu-desktop');
$(wrapMenu).css('top',posWrapHeader - $(this).scrollTop());
}
});
/*==================================================================
[ Menu mobile ]*/
$('.btn-show-menu-mobile').on('click', function(){
$(this).toggleClass('is-active');
$('.menu-mobile').slideToggle();
});
var arrowMainMenu = $('.arrow-main-menu-m');
for(var i=0; i= 992){
if($('.menu-mobile').css('display') == 'block') {
$('.menu-mobile').css('display','none');
$('.btn-show-menu-mobile').toggleClass('is-active');
}
$('.sub-menu-m').each(function(){
if($(this).css('display') == 'block') { console.log('hello');
$(this).css('display','none');
$(arrowMainMenu).removeClass('turn-arrow-main-menu-m');
}
});
}
});
/*==================================================================
[ Show / hide modal search ]*/
$('.js-show-modal-search').on('click', function(){
$('.modal-search-header').addClass('show-modal-search');
$(this).css('opacity','0');
});
$('.js-hide-modal-search').on('click', function(){
$('.modal-search-header').removeClass('show-modal-search');
$('.js-show-modal-search').css('opacity','1');
});
$('.container-search-header').on('click', function(e){
e.stopPropagation();
});
/*==================================================================
[ Isotope ]*/
var $topeContainer = $('.isotope-grid');
var $filter = $('.filter-tope-group');
// filter items on button click
$filter.each(function () {
$filter.on('click', 'button', function () {
var filterValue = $(this).attr('data-filter');
$topeContainer.isotope({filter: filterValue});
});
});
// init Isotope
$(window).on('load', function () {
var $grid = $topeContainer.each(function () {
$(this).isotope({
itemSelector: '.isotope-item',
layoutMode: 'fitRows',
percentPosition: true,
animationEngine : 'best-available',
masonry: {
columnWidth: '.isotope-item'
}
});
});
});
var isotopeButton = $('.filter-tope-group button');
$(isotopeButton).each(function(){
$(this).on('click', function(){
for(var i=0; i 0) $(this).next().val(numProduct - 1);
});
$('.btn-num-product-up').on('click', function(){
var numProduct = Number($(this).prev().val());
$(this).prev().val(numProduct + 1);
});
/*==================================================================
[ Rating ]*/
$('.wrap-rating').each(function(){
var item = $(this).find('.item-rating');
var rated = -1;
var input = $(this).find('input');
$(input).val(0);
$(item).on('mouseenter', function(){
var index = item.index(this);
var i = 0;
for(i=0; i<=index; i++) {
$(item[i]).removeClass('zmdi-star-outline');
$(item[i]).addClass('zmdi-star');
}
for(var j=i; j