jQuery(document).ready(function($) {
"use strict";
// Header - MenuMenu
$("#main-nav-menu li").not('.menu-box, .menu-box .menu-item, .menu-full').hover(function(){
$(this).find("ul:first").slideDown("fast").show().css({display:"block"});
},function(){
$(this).find("ul:first").css({display:"none"});
});
$("#main-nav-menu li.menu-box").hover(function(){
$(this).find("div.sub-menu-wrap:first").slideDown("fast").show().css({display:"block"});
//$('
').appendTo('body');
},function(){
$(this).find("div.sub-menu-wrap:first").css({display:"none"});
//$('#overlay-mask').remove();
});
$(".main-nav").on('click', 'a', function(e){
if ($(this).attr('href') == '#') {
e.preventDefault();
}
});
// Header - MenuMenu - Mobile
$(".mobi-menu").on("click",function(){
$(".main-menu").addClass("toggle-show");
$('.nav-menu').attr('id', 'mobi-nav-menu');
});
$(".mobi-menu-close").on("click",function(){
$(".main-menu").removeClass("toggle-show");
//$('.nav-menu').attr('id', 'main-nav-menu');
});
$("#mobi-nav-menu li.menu-item-has-children").append('
');
$("#mobi-nav-menu li.menu-item-has-children .mean-clicked").on("click",function(){
$(this).toggleClass("mean-toggle");
$(this).parent().find('ul:first').toggle("fast").css({display:"block"});
$(this).parent().siblings().find(".mean-clicked").removeClass("mean-toggle");
$(this).parent().siblings().find("ul:first").css({display:"none"});
});
// Header - SearchForm
$(document).mouseup(function(e){
var container = $("#menu-search-box");
if(!container.is(e.target) && container.has(e.target).length === 0){
container.hide();
}
});
$(".btn-search").on("click",function(){
$(".search-box").slideDown("fast");
$(this).toggleClass("btn-search-active");
$(".search-box #searchform #ls").focus();
});
$(".search-box .mobi-menu-close").on("click",function(){
$(".search-box").slideUp("fast");
});
//SearchForm Remove Input Blank Space of Beginning
$('.search-field').on('keydown', function(e) {
if (e.which === 32 && e.target.selectionStart === 0) {
return false;
}
$('.search-field').on("input", function () {
$(this).val($(this).val().replace(/^\s+/g, ''));
});
});
//ClickAnywhereToClose
$(document).on("click", "#popup-mask-cover" , function() {
$(".widget_shopping_cart").animate({"right":"-500px","opacity":"0"},200);
$("#popup-mask-cover").remove();
$("html").css({"height":"auto","overflow":"inherit"});
$(".btn-search").removeClass("btn-search-active");
});
// Widget - Horizontal Menu
$('.widget_nav_menu ul li.cat-item:has(ul.children)').addClass('menu-item-has-children');
$('.widget_nav_menu_horizontal ul li').hover(function(){
$(this).find('ul:first').slideDown("fast").css({display:"block"});
},function(){
$(this).find('ul:first').slideUp("fast").css({display:"none"});
});
// Widget - Vertical Menu
$('.widget_nav_menu_vertical .current-cat-ancestor.menu-item-has-children').each(function(){
$(this).addClass('open').find('ul').first().slideDown(200);
});
$('.widget_nav_menu_vertical .current-cat.menu-item-has-children').each(function(){
$(this).addClass('open');
});
$('.widget_nav_menu_vertical ul li .plus-minus').on('click', function(){
var element = $(this).parent('li');
if (element.hasClass('open')) {
element.removeClass('open');
element.find('li').removeClass('open');
element.find('ul').slideUp(200);
} else {
element.addClass('open');
element.children('ul').slideDown(200);
element.siblings('li').children('ul').slideUp(200);
element.siblings('li').removeClass('open');
element.siblings('li').find('li').removeClass('open');
element.siblings('li').find('ul').slideUp(200);
}
});
//NavMenu
$('.filters-nav .filter-ul li.cat-item:has(ul.children)').addClass('item-has-children');
$('.filters-nav .filter-ul > li').each(function(){
var curLi = $(this).width();
var childUl = $(this).find("ul:first").width();
if ( curLi > childUl ) {
$(this).find("ul:first").width(curLi);
} else {
$(this).find("a:first").width(childUl - 30);
}
});
$(".filters-nav .filter-ul li").hover(function(){
$(this).find("ul:first").slideDown("fast").show().css({display:"block"});
},function(){
$(this).find("ul:first").slideUp("fast").hide().css({display:"none"});
});
//Accordion
$('.accordion-list .accordion-header').first().addClass('active-header');
$('.accordion-list .accordion-content').first().slideDown().toggleClass('open-content');
$('.accordion-item').delegate(".accordion-header","click",function(){
if($(this).hasClass('inactive-header')) {
$('.active-header').toggleClass('active-header').toggleClass('inactive-header').next().slideToggle().toggleClass('open-content');
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
} else {
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
}
});
// Post - hr
$(".entry hr").before('
');
//Post - Fancybox
$(".entry-content a").each(function(i, el) {
var href_value = el.href;
if (/\.(jpg|jpeg|png|gif)$/.test(href_value)) {
$(this).attr("data-fancybox","gallery-post");
}
});
$('[data-fancybox="gallery-post"]').fancybox({
caption : function() {
return $(this).parent().next('figcaption').html();
}
});
//ProductThumbGallery
var $videoWidth = $(".single-product-gallery").width();
$(".single-product-gallery .product-gallery-zoom .product-video").css({"width":$videoWidth+'px', "height":$videoWidth+'px'});
$(".single-product-gallery .flex-control-thumbs li.flex-video").hover( function() {
$(".single-product-gallery .product-gallery-zoom .product-video").show();
$(".single-product-gallery .product-gallery-zoom .product-image").hide();
$(this).addClass("flex-active").siblings().removeClass("flex-active");
return false;
});
$(".single-product-gallery .flex-control-thumbs li.flex-thumb").hover( function() {
$(".single-product-gallery .product-gallery-zoom .product-video").hide();
$(".single-product-gallery .product-gallery-zoom .product-image").show();
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('src',$(this).find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('data-src',$(this).find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('data-large_image',$(this).find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('xoriginal',$(this).find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('srcset',$(this).find("img").attr("xpreview"));
$(this).addClass("flex-active").siblings().removeClass("flex-active");
return false;
});
//GetThumbLiWidth
var $carouselRTWidth, $carouselLTWidth, $countNext;
var $thumbsLiWidth4 = $(".single-product-gallery .product-thumbs-wrapper").width()/4;
var $thumbsLiWidth3 = $(".single-product-gallery .product-thumbs-wrapper").width()/3;
//ThumbGalleryCarousel
var $carouselUl = $(".flex-control-thumbs");
var $imgli = $(".flex-control-thumbs li");
var $arrowPrev = $(".single-product-gallery .jcarousel-control-prev");
var $arrowNext = $(".single-product-gallery .jcarousel-control-next");
var $countPrev = 0;
$arrowPrev.click(function() {
$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").prev().addClass("flex-active").siblings().removeClass("flex-active");
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('src',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('data-src',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('data-large_image',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('xoriginal',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('srcset',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
if( $(".product-thumbs-gallery .flex-control-thumbs li.flex-video").hasClass("flex-active") ){
$(".single-product-gallery .product-gallery-zoom .product-video").show();
$(".single-product-gallery .product-gallery-zoom .product-image").hide();
} else {
$(".single-product-gallery .product-gallery-zoom .product-video").hide();
$(".single-product-gallery .product-gallery-zoom .product-image").show();
}
$arrowNext.removeClass("disable");
if ( $countPrev < 1 ) {
$(this).addClass("disable");
return;
}
$countPrev--;
$countNext++;
$carouselUl.animate({left:$carouselRTWidth}, 100);
});
if( $(window).width() >= 768 ){
$(".flex-control-thumbs li").css("width", $thumbsLiWidth4);
$(".single-product-gallery .product-thumbs-gallery").css("height", $thumbsLiWidth4 - 10);
$(".product-thumbs-gallery .flex-control-thumbs li.flex-video .btn-play-video").css({"width":$thumbsLiWidth4-10+'px', "line-height":$thumbsLiWidth4-10+'px'});
$(".product-thumbs-gallery .flex-control-thumbs li.flex-video .btn-play-video .icon-play-video").css({"height":$thumbsLiWidth4-10+'px'});
$carouselRTWidth = '+='+$thumbsLiWidth4+'px';
$carouselLTWidth = '-='+$thumbsLiWidth4+'px';
$countNext = $imgli.length;
$carouselUl.css("width", $imgli.length*$thumbsLiWidth4);
$arrowNext.click(function() {
$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").next().addClass("flex-active").siblings().removeClass("flex-active");
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('src',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('data-src',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('data-large_image',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('xoriginal',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('srcset',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$arrowPrev.removeClass("disable");
if ( $countNext <= 4 ) {
$(this).addClass("disable");
return;
}
$countPrev++;
$countNext--;
$carouselUl.animate({left:$carouselLTWidth}, 100);
if( $(".product-thumbs-gallery .flex-control-thumbs li.flex-video").hasClass("flex-active") ){
$(".single-product-gallery .product-gallery-zoom .product-video").show();
$(".single-product-gallery .product-gallery-zoom .product-image").hide();
} else {
$(".single-product-gallery .product-gallery-zoom .product-video").hide();
$(".single-product-gallery .product-gallery-zoom .product-image").show();
}
});
} else {
$(".flex-control-thumbs li").css("width", $thumbsLiWidth3);
$(".single-product-gallery .product-thumbs-gallery").css("height", $thumbsLiWidth3 - 10);
$(".product-thumbs-gallery .flex-control-thumbs li.flex-video .btn-play-video").css({"width":$thumbsLiWidth3-10+'px', "line-height":$thumbsLiWidth3-10+'px'});
$(".product-thumbs-gallery .flex-control-thumbs li.flex-video .btn-play-video .icon-play-video").css({"height":$thumbsLiWidth3-10+'px'});
$carouselRTWidth = '+='+$thumbsLiWidth3+'px';
$carouselLTWidth = '-='+$thumbsLiWidth3+'px';
$countNext = $imgli.length;
$carouselUl.css("width", $imgli.length*$thumbsLiWidth3);
$arrowNext.click(function() {
$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").next().addClass("flex-active").siblings().removeClass("flex-active");
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('src',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('data-src',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('data-large_image',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('xoriginal',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$(".single-product-gallery .product-gallery-zoom .product-image img").attr('srcset',$(".product-thumbs-gallery .flex-control-thumbs li.flex-active").find("img").attr("xpreview"));
$arrowPrev.removeClass("disable");
if ( $countNext <= 3 ) {
$(this).addClass("disable");
return;
}
$countPrev++;
$countNext--;
$carouselUl.animate({left:$carouselLTWidth}, 100);
if( $(".product-thumbs-gallery .flex-control-thumbs li.flex-video").hasClass("flex-active") ){
$(".single-product-gallery .product-gallery-zoom .product-video").show();
$(".single-product-gallery .product-gallery-zoom .product-image").hide();
} else {
$(".single-product-gallery .product-gallery-zoom .product-video").hide();
$(".single-product-gallery .product-gallery-zoom .product-image").show();
}
});
}
// Product - MetaTabs
var $title = $(".wc-tabs li");
var $content = $(".product-content div.entry-content, .wc-tab");
$title.click(function(){
var index = $title.index($(this));
$(this).addClass("active").siblings().removeClass("active");
$content.hide();
$($content.get(index)).show();
return false;
});
// Product - TabsPinned
var pin = $('.tabs-list');
if( pin.length ){
var pinHeight = pin.offset().top - 100;
$(window).scroll(function() {
var scroolHeight = $(this).scrollTop();
if( scroolHeight >= pinHeight ) {
pin.addClass('fixed-box');
} else if( scroolHeight < pinHeight ) {
pin.removeClass('fixed-box');
}
});
}
setTimeout(function (){
$('.woocommerce-tabs .wc-tabs li').click( function(){
var anchorFix = $('#anchor-fix-tabs');
if (anchorFix.length) {
$('html, body').animate({
scrollTop: ( anchorFix.offset().top - 80 )
},500);
return false;
}
});
}, 0);
// Product - InquiryButton
$(".woocommerce-tabs .wc-tabs #tab-iq, .product-extra-buttons .btn-inquiry, .product-inquiry .btn-inquiry, .mobi-bar .btn-inquiry").click(function(){
$(".woocommerce-tabs .wc-tabs #tab-iq, .woocommerce-tabs .wc-tabs #tab-title-iq").addClass("active").siblings().removeClass("active");
$(".product-content #entry-iq").show().siblings().hide();
});
//Gallery - MediaLibrary
$(".gallery a").each(function(){
if ($(this).is(':empty')){}else{
var link=$(this).attr("href");
var suffix=link.slice(-4);
if(suffix==='.jpg' || suffix==='.png' || suffix==='.gif'){
$(this).attr("data-fancybox","gallery-media");
}
}
});
$('[data-fancybox="gallery-media"]').fancybox({
caption : function() {
return $(this).parent().next('figcaption').html();
}
});
//ShareLink
$('.social-share-container a').not(".no-popup").click(function(event) {
event.preventDefault();
var width = 760;
var height = 450;
var toppx = ($(window).height() / 2) - (height / 2);
var leftpx = ($(window).width() / 2) - (width / 2);
window.open($(this).attr("href"), "popupWindow", "width=" + width + ",height=" + height + ",scrollbars=yes,left=" + leftpx + ",top="+toppx);
});
//NumberCounter V1
$('.counter').each(function () {
var duration;
if( $(this).data('delay') ){
duration = $(this).data('delay');
} else {
duration = 3000;
}
$(this).prop('Counter',0).animate({
Counter: $(this).text()
}, {
duration: duration,
easing: 'swing',
step: function (now) {
$(this).text(Math.ceil(now));
}
});
});
});