(function($){ "use strict"; // Start of use strict $(document).ready(function(){ //Fix select $('.orderby').selectmenu(); //Fix table responsive $('table').each(function(){ $(this).addClass('table'); $(this).wrap( "
" ); }) //Menu Responsive if($(window).width()<1025){ $('body').click(function(){ $('.main-menu').removeClass('active'); }); $('.show-menu').click(function(event){ event.preventDefault(); event.stopPropagation(); $(this).hide(); $(this).next().show(); $('.main-menu').addClass('active'); }); $('.hide-menu').click(function(event){ event.preventDefault(); event.stopPropagation(); $(this).hide(); $(this).prev().show(); $('.main-menu').removeClass('active'); }); $('.main-nav li.menu-item-has-children>a').click(function(event){ event.stopPropagation(); $(this).toggleClass('active'); if($(this).hasClass('active')){ event.preventDefault(); $(this).next().stop(true,true).fadeIn(400); }else{ $(this).next().stop(true,true).fadeOut(400); } }); } //Fixed Latest News if($(window).width()>768){ $('.item-home-latest-news').click(function(){ if($(this).hasClass('active')){ $(this).removeClass('active'); }else{ $(this).addClass('active'); } }); } //Attr Filter Price var price_max = Number($( "#slider-range-price" ).attr('data-pmax')); var price_min = Number($( "#slider-range-price" ).attr('data-pmin')); $( "#slider-range-price" ).slider({ range: true, min: price_min, max: price_max, values: [ price_min, price_max ], stop: function( event, ui ){ $('#get-filter-price').trigger('click'); }, slide: function( event, ui ) { $( "#amount-price" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] ); $( "#get-filter-price" ).val( ui.values[ 0 ] + "," + ui.values[ 1 ] ); } }); $( "#amount-price" ).val( "$" + $( "#slider-range-price" ).slider( "values", 0 ) + " - $" + $( "#slider-range-price" ).slider( "values", 1 ) ); $('.box-attr-filter').on('click',function(e){ e.preventDefault(); e.stopPropagation(); }) $('.attr-list li a').on('click',function(e){ e.preventDefault(); e.stopPropagation(); if($(this).hasClass('selected')) $(this).removeClass('selected'); else $(this).addClass('selected'); // console.log(get_filter()); }) function get_filter(){ var filter = []; $('ul.attr-list').each(function(){ var key = $(this).attr('data-key'); filter[key]=[]; $(this).find('li a').each(function(){ if($(this).hasClass('selected')) filter[key].push($(this).attr('data-value')); }) }) filter['price'] = $( "#get-filter-price" ).val(); return filter; } //Box Filter $('body').click(function(){ $('.box-attr-filter').slideUp(); }); $('.btn-filter').click(function(event){ event.preventDefault(); event.stopPropagation(); $('.box-attr-filter').slideToggle(); }); //Product Quick View // $('.product-quick-view').fancybox(); //Testimonial $('.left-open').on('click',function(e){ e.preventDefault(); $(this).parents('.item').removeClass('right-open'); $(this).parents('.item').removeClass('left-close'); $(this).parents('.item').addClass('left-open'); }) $('.left-close').on('click',function(e){ e.preventDefault(); $(this).parents('.item').removeClass('left-open'); $(this).parents('.item').addClass('left-close'); }) $('.right-open').on('click',function(e){ e.preventDefault(); $(this).parents('.item').removeClass('left-open'); $(this).parents('.item').removeClass('right-close'); $(this).parents('.item').addClass('right-open'); }) $('.right-close').on('click',function(e){ e.preventDefault(); $(this).parents('.item').removeClass('right-open'); $(this).parents('.item').addClass('right-close'); }) //End //Latest News if($(window).width()>768){ $( ".item.sortable").sortable(); $( ".item.sortable").disableSelection(); } //Popup letter var content = $('#boxes-content').html(); $('#boxes-content').html(''); $('#boxes').html(content); if($('#boxes').html() != ''){ var id = '#dialog'; //Get the screen height and width var maskHeight = $(document).height(); var maskWidth = $(window).width(); //Set heigth and width to mask to fill up the whole screen $('#mask').css({'width':maskWidth,'height':maskHeight}); //transition effect $('#mask').fadeIn(500); $('#mask').fadeTo("slow",0.9); //Get the window height and width var winH = $(window).height(); var winW = $(window).width(); //Set the popup window to center $(id).css('top', winH/2-$(id).height()/2); $(id).css('left', winW/2-$(id).width()/2); //transition effect $(id).fadeIn(2000); //if close button is clicked $('.window .close-popup').click(function (e) { //Cancel the link behavior e.preventDefault(); $('#mask').hide(); $('.window').hide(); }); //if mask is clicked $('#mask').click(function () { $(this).hide(); $('.window').hide(); }); } //End popup letter //Slider Scroll if($('.item-product-featured').length>0){ $('.item-product-featured').each(function(){ $(this).find('.bxslider').bxSlider({ pagerCustom: '.bx-pager', nextText:'', prevText:'' }); }); } //Category Lightbox $('.header-banner-link').click(function(event){ event.preventDefault(); $(this).parent().next().addClass('height-light'); }); $('.header-banner-link').click(function(event){ event.preventDefault(); $(this).parent().next().addClass('height-light'); }); $('.close-category-lightbox').click(function(event){ event.preventDefault(); $(this).parent().removeClass('height-light'); }); //Control Homme Extra Box $('.icon-extra-sub').click(function(event){ event.preventDefault(); $('.icon-extra-sub').addClass('hide-box') $(this).next().addClass('show-box'); }); $('.close-extra-sub').click(function(event){ event.preventDefault(); $('.icon-extra-sub').removeClass('hide-box') $(this).parent().removeClass('show-box'); }); //Reset contact form $('.reset-form').on('click',function(){ $(this).parents('form').find('input[type="text"]').val(''); $(this).parents('form').find('input[type="email"]').val(''); $(this).parents('form').find('textarea').val(''); }) //menu fix if($(window).width() > 768){ $('.main-nav ul.sub-menu').each(function(){ var left = $(this).offset().left; if(left > 1000){ $(this).css({"left": "-100%"}) } if(left < 50){ $(this).css({"left": "100%"}) } }) } //Like click $('.sv-like-click').on('click',function(){ $(this).next().trigger('click'); return false; }) //hotdeal-countdown if($('.hotdeal-countdown').length>0){ $(".hotdeal-countdown").TimeCircles({ fg_width: 0.03, bg_width: 0, text_size: 0, circle_bg_color: "#1b1d1f", time: { Days: { show: true, text: "DAY", color: "#fbb450" }, Hours: { show: true, text: "HOUR", color: "#fbb450" }, Minutes: { show: true, text: "MIN", color: "#fbb450" }, Seconds: { show: true, text: "SEC", color: "#fbb450" } } }); } //Time Circle if($('.deal-countdown').length>0){ $(".deal-countdown").TimeCircles({ fg_width: 0.05, bg_width: 0, text_size: 0, circle_bg_color: "#5f6062", time: { Days: { show: true, text: "", color: "#fff" }, Hours: { show: true, text: "", color: "#fff" }, Minutes: { show: true, text: "", color: "#fff" }, Seconds: { show: true, text: "", color: "#fff" } } }); } //Post Gallery $('.item-post-gallery .fancybox').fancybox(); $('.item-team-gallery .fancybox').fancybox(); //Close Cart Total // $('.info-cart').hover(function(){ // $(this).find('.inner-cart-info').addClass('append');},function(){ // $(this).find('.inner-cart-info').removeClass('append'); // }); $('.close-cart-info').click(function(event){ event.preventDefault(); $(this).parent().removeClass('append'); }); //Toggle Search $('body').click(function(){ $('.select-category').slideUp(); }); $('.toggle-category').click(function(event){ event.preventDefault(); event.stopPropagation(); $(this).next().slideToggle(); }); //Product Gallery if($('.product-gallery .bxslider').length>0){ $('.product-gallery .bxslider').bxSlider({ pagerCustom: '.product-gallery #bx-pager', nextText:'', prevText:'' }); } //Post Gallery if($('.post-format-gallery .bxslider').length>0){ $('.post-format-gallery .bxslider').bxSlider({ pagerCustom: '.post-format-gallery #bx-pager', nextText:'', prevText:'' }); } //Banner Tab Slider if($('.slider-tab').length>0){ $('.slider-tab .bxslider').bxSlider({ pagerCustom: '.slider-tab #bx-pager', nextText:'', prevText:'' }); } //Search product dropdown $('ul.select-category li').click(function(){ var x = $(this).attr('data-filter'); if(x){ $('.cat-value').val(x); } else $('.cat-value').val(''); }); //Count item cart if($("#count-cart-item").length){ var count_cart_item = $("#count-cart-item").val(); $(".cart-item-count").html(count_cart_item); } if($(".get-count-cart-item")){ var count_cart_item = $(".get-count-cart-item").val(); $(".number-cart-total").html(count_cart_item); } // BEGIN Fix Variable product //Select Size $('.selected-attr-size span').text($('.select-attr-size li').first().find('a').text()); $('body').click(function(){ $('.select-attr-size').slideUp(); }); $('.selected-attr-size').click(function(event){ event.preventDefault(); event.stopPropagation(); $(this).parent().find('.select-attr-size').slideToggle(); $(this).parent().next().find('select').trigger( 'focusin' ); var content = ''; var old_content = $(this).parent().find('.select-attr-size').html(); var current_val = $(this).parent().find('.select-attr-size').find('a.selected').parent().attr('data-attribute'); $(this).parent().next().find('select').find('option').each(function(){ var val = $(this).attr('value'); var title = $(this).html(); var el_class = ''; if(current_val == val) el_class = ' class="selected" '; content += '
  • '+title+'
  • '; }) if(content != old_content) $(this).parent().find('.select-attr-size').html(content); }); // $('.select-attr-size').delegate('a','click',function(event){ // event.preventDefault(); // console.log($(this).parent().html()); // $(this).parents('.select-attr-size').find('a').removeClass('selected'); // $(this).addClass('selected'); // $(this).parents('.attr-product').find('.selected-attr-size').find('span').text($(this).text()); // }); $('body').on('click','.select-attr-size a',function(event){ event.preventDefault(); console.log($(this)); $(this).parents('.select-attr-size').find('a').removeClass('selected'); $(this).addClass('selected'); $(this).parents('.attr-product').find('.selected-attr-size').find('span').text($(this).text()); }); //Select Color $('body').on('click','.attr-color li a',function(event){ // console.log($(this)); event.preventDefault(); $('.attr-color li a').removeClass('selected'); $(this).addClass('selected'); }); $('body').on('click','.select-attr-size li',function(event){ // console.log($(this)); var attribute = $(this).attr('data-attribute'); var id = $(this).parent().attr('data-attribute-id'); $('#'+id).val(attribute); $('#'+id).trigger( 'change' ); $('#'+id).trigger( 'focusin' ); }) $('.attr-color').hover(function(){ var old_html = $(this).next().find('select').html(); var current_val = $(this).find('.select-attr-color').find('a.selected').parent().attr('data-attribute'); $(this).next().find('select').trigger( 'focusin' ); var content = ''; $(this).next().find('select').find('option').each(function(){ var val = $(this).attr('value'); var title = $(this).html(); var el_class = ''; if(current_val == val) el_class = ' class="selected" '; if(val != '') content += '
  • '; }) if(old_html != content) $(this).find('.select-attr-color').html(content); }) $('body').on('click','.select-attr-color li',function(event){ var attribute = $(this).attr('data-attribute'); var id = $(this).parent().attr('data-attribute-id'); $('#'+id).val(attribute); $('#'+id).trigger( 'change' ); $('#'+id).trigger( 'focusin' ); return false; }) // END FIX //QUANTITY CLICK $(".quantity").find(".qty-up").on("click",function(){ var min = $(this).prev().attr("data-min"); var max = $(this).prev().attr("data-max"); var step = $(this).prev().attr("data-step"); if(step === undefined) step = 1; if(max !==undefined && Number($(this).prev().val())< Number(max) || max === undefined){ if(step!='') $(this).prev().val(Number($(this).prev().val())+Number(step)); } return false; }) $(".quantity").find(".qty-down").on("click",function(){ var min = $(this).next().attr("data-min"); var max = $(this).next().attr("data-max"); var step = $(this).next().attr("data-step"); if(step === undefined) step = 1; if(Number($(this).next().val()) > 1){ if(min !==undefined && $(this).next().val()>min || min === undefined){ if(step!='') $(this).next().val(Number($(this).next().val())-Number(step)); } } return false; }) $("input.qty-val").on("keyup change",function(){ var max = $(this).attr('data-max'); if( Number($(this).val()) > Number(max) ) $(this).val(max); }) //END }); $(window).load(function(){ //Carousel Slider if($('.sv-slider').length>0){ $('.sv-slider').each(function(){ var seff = $(this); var item = seff.attr('data-item'); var speed = seff.attr('data-speed'); var itemres = seff.attr('data-itemres'); var animation = seff.attr('data-animation'); var nav = seff.attr('data-nav'); var pagination = true, navigation= false, singleItem = false; var autoplay; if(speed != '') autoplay = speed; else autoplay = false; // Navigation if(nav == 'nav-hidden'){ pagination = false; navigation= false; } if(nav == 'the-brand') navigation = true; if(nav == 'owl-default'){ pagination = false; navigation = true; } var prev_text = 'prev'; var next_text = 'next'; if(nav == 'owl-arrow-banner'){ pagination = false; navigation = true; prev_text = ''; next_text = ''; } if(nav == 'post-slider'){ pagination = false; navigation = true; prev_text = ''; next_text = ''; } if(nav == 'home-directnav' || nav == 'partner-slider-directnav'){ pagination = false; navigation = true; prev_text = ''; next_text = ''; } if(animation != ''){ singleItem = true; item = '1'; } // Item responsive if(itemres == '' || itemres === undefined || itemres.split(',').length < 4){ if(item == '1') itemres = '1,1,1,1'; if(item == '2') itemres = '1,1,2,2'; if(item == '3') itemres = '1,1,2,3'; if(item == '4') itemres = '1,1,2,4'; if(item >= '5') itemres = '1,2,3,5'; } itemres = itemres.split(','); seff.owlCarousel({ items: item, itemsCustom: [ [0, itemres[0]], [360, itemres[0]], [480, itemres[1]], [768, itemres[2]], [992, itemres[3]], [1200, item] ], autoPlay:autoplay, pagination: pagination, navigation: navigation, navigationText:[prev_text,next_text], singleItem : singleItem, addClassActive : true, transitionStyle : animation }); }); } //End //Product Tab Slider if($('.product-tab-slider.nav-default').length>0){ $('.product-tab-slider.nav-default').each(function(){ $(this).find('.wrap-item').owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 1], [768, 1], [992, 1], [1200, 1] ], pagination: false, navigation: true, navigationText:['',''] }); }); } //End //Product Tab Icon Slider if($('.product-tab-slider.home-directnav').length>0){ $('.product-tab-slider.home-directnav').each(function(){ $(this).find('.wrap-item').owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 1], [768, 1], [992, 1], [1200, 1] ], pagination: false, navigation: true, navigationText:['',''] }); }); } //End //Product New Slider if($('.grid-product-slider').length>0){ $('.grid-product-slider').each(function(){ $(this).owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 1], [768, 1], [992, 1], [1200, 1] ], pagination: false, navigation: true, navigationText:['',''] }); }); } //end //Product Slider if($('.product-slider').length>0){ $('.none-sidebar .product-slider').each(function(){ $(this).find('.wrap-item').owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 2], [768, 3], [992, 3], [1200, 4] ], pagination: false, navigation: true, }); }); } if($('.product-slider').length>0){ $('.arrow-style.product-slider').each(function(){ $(this).find('.wrap-item').owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 2], [768, 3], [992, 3], [1200, 4] ], pagination: false, navigation: true, navigationText:['',''] }); }); } //Default Product Slider if($('.product-slider').length>0){ $('.has-sidebar .product-slider').each(function(){ $(this).find('.wrap-item').owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 2], [768, 3], [992, 3], [1200, 3] ], pagination: false, navigation: true, }); }); } //END //Product tab if($('.product-slider2').length>0){ $('.arrow-style.product-slider2').each(function(){ $(this).find('.wrap-item').owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 2], [768, 3], [992, 3], [1200, 4] ], pagination: false, navigation: true, navigationText:['',''] }); }); } //category popup slider if($('.default-directnav').length>0){ $('.default-directnav').each(function(){ $(this).find('.wrap-item').owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 1], [768, 1], [992, 1], [1200, 1] ], pagination: false, navigation: true, navigationText:['',''] }); }); } //Home Feaured Slider if($('.home-featured-slider').length>0){ $('.home-featured-slider').each(function(){ $(this).find('.wrap-item').owlCarousel({ items: 1, itemsCustom: [ [0, 1], [480, 1], [768, 1], [992, 1], [1200, 1] ], addClassActive:true, pagination: true, navigation: true, afterAction : afterAction, navigationText:['',''], onChange: function (elem) { var current = this.currentItem; console.log('Current is ' + current); } }); }); var first=$('.home-featured-slider .owl-theme .owl-controls .owl-page').first().index()+1; var last=$('.home-featured-slider .owl-theme .owl-controls .owl-page').last().index()+1; $('.control-paginav-featured-slider').prepend(''+first+''); $('.control-paginav-featured-slider').append(''+last+''); //Range with fixed maximum $( ".control-paginav-featured-slider #slider-range-max" ).slider({ range: "max", min: first, max: last, value: first, slide: function( event, ui ) { console.log(ui); $( ".control-paginav-featured-slider #amount" ).html( ui.value ); $('.home-featured-slider').find('.wrap-item').trigger('owl.goTo', ui.value -1); } }); // console.log($( ".control-paginav-featured-slider #slider-range-max" )); $( ".control-paginav-featured-slider #amount" ).html( $( ".control-paginav-featured-slider #slider-range-max" ).slider( "value" ) ); $( ".control-paginav-featured-slider #amount" ).appendTo($(".control-paginav-featured-slider .ui-slider-handle.ui-state-default.ui-corner-all")); } //Featured fix scroll // $('.home-featured-slider .test-slider-number').on('change keyup',function(){ // var num = $(this).val(); // console.log(num); // $(this).prev('.wrap-item').trigger('owl.goTo', num); // }) function afterAction(){ var num = this.owl.currentItem; // console.log($( ".control-paginav-featured-slider #slider-range-max" ).slider( "value" )); // $( ".control-paginav-featured-slider #slider-range-max" ).slider('option', 'value',num); $('.test-slider-number').val(num); } //END //Process Bar $('.circle-process').each(function(){ var id = $(this).attr('id'); var radius = $(this).attr('data-radius'); var value = $(this).attr('data-value'); var width = $(this).attr('data-width'); var color1 = $(this).attr('data-color1'); var color2 = $(this).attr('data-color2'); var el_class = $(this).attr('data-class'); Circles.create({ id: id, radius: Number(radius), value: Number(value), maxValue: 100, width: Number(width), colors: [color1, color2], duration: 800, wrpClass: 'circles-wrp', textClass: el_class, valueStrokeClass: 'circles-valueStroke', maxValueStrokeClass: 'circles-maxValueStroke', styleWrapper: true, styleText: true }); }) $('.sv-pie-chart').each(function(){ var id = $(this).attr('id'); var class1 = $(this).attr('data-color1'); var class2 = $(this).attr('data-color2'); var id = $(this).attr('id'); $('#'+id).pieChart('#target_'+id); $('#target_'+id).children().find('.pieChart.pie0').attr('class','pieChart pie0 '+class1); $('#target_'+id).children().find('.pieChart.pie1').attr('class','pieChart pie1 '+class2); }) $('.line-progressbar').each(function(){ var id = $(this).attr('id'); var pclass = $(this).attr('data-class'); var value = $(this).attr('data-value'); $( "#"+id ).progressbar({ value: Number(value) }); $(this).prev().html(value+'%'); var val_class = $(this).find('.ui-progressbar-value').attr('class'); $(this).find('.ui-progressbar-value').attr('class',val_class+' '+pclass); }) //END }); })(jQuery);