// Background image holder with fullscreen option $(window).on("load resize", function () { // Headroom if ($(window).width() > 0) { if ($("[data-toggle='headroom']").length > 0) { $("[data-toggle='headroom']").headroom({ // vertical offset in px before element is first unpinned offset: 0, // or you can specify tolerance individually for up/down scroll tolerance: { up: 40, down: 5, }, // css classes to apply classes: { // when element is initialised initial: "headroom", // when scrolling up pinned: "headroom--pinned", // when scrolling down unpinned: "headroom--unpinned", // when above offset top: "headroom--top", // when below offset notTop: "fixed-top", // when at bottom of scoll area bottom: "headroom--bottom", // when not at bottom of scroll area //notBottom : "headroom--not-bottom" }, onPin: function () { if ($(window).offset.top > 0) { var height = $("[data-toggle='headroom']").height(); $("body").css({ "padding-top": height + "px" }); } else { $("body").css({ "padding-top": 0 }); } }, onUnpin: function () { var height = $("[data-toggle='headroom']").height(); $("body").css({ "padding-top": height + "px" }); }, onTop: function () { $("body").css({ "padding-top": 0 }); }, onBottom: function () {}, }); } } }); // On document ready functions $(document).ready(function () { // Bootstrap - Submenu event for small resolutions $('.dropdown-menu .dropdown-submenu [data-toggle="dropdown"]').on( "click", function (e) { if (!$(this).next().hasClass("show")) { $(this) .parents(".dropdown-menu") .first() .find(".show") .removeClass("show"); } var $subMenu = $(this).next(".dropdown-menu"); $subMenu.toggleClass("show"); $subMenu.parent().toggleClass("show"); $(this) .parents(".nav-item.dropdown.show") .on("hidden.bs.dropdown", function (e) { $(".dropdown-submenu .show").removeClass("show"); }); return false; } ); // Fix the closing problem when clicking inside dopdown menu $(".navbar .dropdown-menu").on("click", function (event) { event.stopPropagation(); }); // One page nav $(".navbar-onepage .nav-link").on("click", function (e) { var $anchor = $(this); $("html, body") .stop() .animate( { scrollTop: $($anchor.attr("href")).offset().top, }, 1500, "easeInOutExpo" ); e.preventDefault(); }); // Hamburger if ($(".hamburger-js")[0]) { $(".hamburger-js").each(function () { var $this = $(this); $this.on("click", function (e) { $this.toggleClass("is-active"); // Do something else, like open/close menu }); }); } // Footer reveal if ($("[data-footer-reveal]").length) { $("[data-footer-reveal]").footerReveal({ shadow: false, zIndex: -101, }); } // Input group - plus minus $(".btn-number").click(function (e) { e.preventDefault(); fieldName = $(this).attr("data-field"); type = $(this).attr("data-type"); var input = $("input[name='" + fieldName + "']"); var currentVal = parseInt(input.val()); if (!isNaN(currentVal)) { if (type == "minus") { if (currentVal > input.attr("min")) { input.val(currentVal - 1).change(); } if (parseInt(input.val()) == input.attr("min")) { $(this).attr("disabled", true); } } else if (type == "plus") { if (currentVal < input.attr("max")) { input.val(currentVal + 1).change(); } if (parseInt(input.val()) == input.attr("max")) { $(this).attr("disabled", true); } } } else { input.val(0); } }); $(".input-number").focusin(function () { $(this).data("oldValue", $(this).val()); }); $(".input-number").change(function () { minValue = parseInt($(this).attr("min")); maxValue = parseInt($(this).attr("max")); valueCurrent = parseInt($(this).val()); name = $(this).attr("name"); if (valueCurrent >= minValue) { $( ".btn-number[data-type='minus'][data-field='" + name + "']" ).removeAttr("disabled"); } else { alert("Sorry, the minimum value was reached"); $(this).val($(this).data("oldValue")); } if (valueCurrent <= maxValue) { $( ".btn-number[data-type='plus'][data-field='" + name + "']" ).removeAttr("disabled"); } else { alert("Sorry, the maximum value was reached"); $(this).val($(this).data("oldValue")); } }); $(".input-number").keydown(function (e) { // Allow: backspace, delete, tab, escape, enter and . if ( $.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 || // Allow: Ctrl+A (e.keyCode == 65 && e.ctrlKey === true) || // Allow: home, end, left, right (e.keyCode >= 35 && e.keyCode <= 39) ) { // let it happen, don't do anything return; } // Ensure that it is a number and stop the keypress if ( (e.shiftKey || e.keyCode < 48 || e.keyCode > 57) && (e.keyCode < 96 || e.keyCode > 105) ) { e.preventDefault(); } }); // Floating label $(".has-floating-label .form-control") .on("focus blur", function (e) { $(this) .parents(".form-group") .toggleClass( "focused", e.type === "focus" || this.value.length > 0 ); }) .trigger("blur"); // Bootstrap selected $(".selectpicker").each(function (index, element) { $(".selectpicker").select2({}); }); // Datepicker if ($(".datepicker")[0]) { $(".datepicker").each(function () { var $this = $(this); $this.flatpickr({ noCalendar: $this.data("datepicker-no-calendar") ? $this.data("datepicker-no-calendar") : false, enableTime: $this.data("datepicker-enable-time") ? $this.data("datepicker-enable-time") : false, inline: $this.data("datepicker-inline") ? $this.data("datepicker-inline") : false, allowInput: $this.data("datepicker-allow-input") ? $this.data("datepicker-allow-input") : true, mode: $this.data("datepicker-mode") ? $this.data("datepicker-mode") : "single", static: true, inline: $this.data("datepicker-inline") ? $this.data("datepicker-inline") : false, nextArrow: '', prevArrow: '', }); }); } // Custom file input $(".custom-input-file").each(function () { var $input = $(this), $label = $input.next("label"), labelVal = $label.html(); $input.on("change", function (e) { var fileName = ""; if (this.files && this.files.length > 1) fileName = ( this.getAttribute("data-multiple-caption") || "" ).replace("{count}", this.files.length); else if (e.target.value) fileName = e.target.value.split("\\").pop(); if (fileName) $label.find("span").html(fileName); else $label.html(labelVal); }); // Firefox bug fix $input .on("focus", function () { $input.addClass("has-focus"); }) .on("blur", function () { $input.removeClass("has-focus"); }); }); // NoUI Slider if ($(".input-slider-container")[0]) { $(".input-slider-container").each(function () { var slider = $(this).find(".input-slider"); var sliderId = slider.attr("id"); var minValue = slider.data("range-value-min"); var maxValue = slider.data("range-value-max"); var sliderValue = $(this).find(".range-slider-value"); var sliderValueId = sliderValue.attr("id"); var startValue = sliderValue.data("range-value-low"); var c = document.getElementById(sliderId), d = document.getElementById(sliderValueId); noUiSlider.create(c, { start: [parseInt(startValue)], //step: 1000, range: { min: [parseInt(minValue)], max: [parseInt(maxValue)], }, }); c.noUiSlider.on("update", function (a, b) { //alert(b) d.textContent = a[b]; }); }); } if ($("#input-slider-range")[0]) { var c = document.getElementById("input-slider-range"), d = document.getElementById("input-slider-range-value-low"), e = document.getElementById("input-slider-range-value-high"), f = [d, e]; noUiSlider.create(c, { start: [ parseInt(d.getAttribute("data-range-value-low")), parseInt(e.getAttribute("data-range-value-high")), ], connect: !0, range: { min: parseInt(c.getAttribute("data-range-value-min")), max: parseInt(c.getAttribute("data-range-value-max")), }, }), c.noUiSlider.on("update", function (a, b) { f[b].textContent = a[b]; }), c.noUiSlider.on("change", function (a, b) { rangefilter(a); }); } // Flip cards if ($(".card-flip")[0]) { $(".card-flip-container").imagesLoaded(function () { $(".card-flip").each(function () { $this = $(this); $this.flip({ front: ".card-front", back: ".card-back", forceHeight: true, trigger: $this.data("flip-trigger") ? $this.data("flip-trigger") : "hover", reverse: $this.data("flip-reverse") ? $this.data("flip-reverse") : false, }); }); }); } // Bootstrap Carousels $(".carousel").carousel({ interval: 5000, pause: "hover", }); // Smooth scroll $(".scroll-me, [data-scroll-to]").on("click", function (event) { var hash = $(this).data("scroll-to"); var offset = $(this).data("scroll-to-offset") ? $(this).data("scroll-to-offset") : 0; // Animate scroll to the selected section $("html, body") .stop(true, true) .animate( { scrollTop: $(hash).offset().top - offset, }, 600 ); event.preventDefault(); }); // To top var offset = 300, //browser window scroll (in pixels) after which the "back to top" link opacity is reduced offset_opacity = 1200, //duration of the top scrolling animation (in ms) scroll_top_duration = 700, //grab the "back to top" link $back_to_top = $(".back-to-top"); //hide or show the "back to top" link $(window).scroll(function () { $(this).scrollTop() > offset ? $back_to_top.addClass("back-to-top-is-visible") : $back_to_top.removeClass("back-to-top-is-visible cd-fade-out"); if ($(this).scrollTop() > offset_opacity) { $back_to_top.addClass("back-to-top-fade-out"); } }); //smooth scroll to top $back_to_top.on("click", function (event) { event.preventDefault(); $("body, html").animate( { scrollTop: 0, }, scroll_top_duration ); }); // Light gallery if ($('[data-toggle="light-gallery"]').length > 0) { $('[data-toggle="light-gallery"]').lightGallery({ selector: "this", }); } if ($(".light-gallery").length > 0) { $(".light-gallery").each(function () { var $this = $(this); $this.lightGallery({ selector: ".item", thumbnail: true, }); }); } // Isotope // for each container $(".masonry-container").each(function (i, masonryContainer) { var $masonryContainer = $(masonryContainer); // init isotope for container var $masonry = $masonryContainer .find(".masonry") .imagesLoaded(function () { // Set default filter if exists var filterMenuItems = $masonryContainer.find( ".masonry-filter-menu" ); var defaultFilterButton = filterMenuItems.find(".default"); var defaultFilterValue = defaultFilterButton.data("filter"); if ( defaultFilterValue != undefined && defaultFilterValue != "" ) { if (defaultFilterValue != "*") { defaultFilterValue = "." + defaultFilterValue; } defaultFilterButton.addClass("active"); } $masonry.isotope({ itemSelector: ".masonry-item", filter: defaultFilterValue, }); }); // init filters for container $masonryContainer .find(".masonry-filter-menu") .on("click", "a", function () { var filterValue = $(this).attr("data-filter"); if (filterValue == "*") { filterValue = ""; } else { filterValue = "." + filterValue; } $masonry.isotope({ filter: filterValue, }); }); }); $(".masonry-filter-menu").each(function (i, buttonGroup) { var $buttonGroup = $(buttonGroup); $buttonGroup.on("click", "a", function () { $buttonGroup.find(".active").removeClass("active"); $(this).addClass("active"); }); }); // Swiper var productSwiper; if ($(".product-swiper-container").length > 0) { $(".product-swiper-container").each(function (index, element) { $(this).addClass("s-" + index); $(this) .find(".swiper-pagination") .addClass("sp-" + index); productSwiper = $(".s-" + index).swiper({ speed: 400, loop: true, grabCursor: true, pagination: ".sp-" + index, paginationClickable: true, centeredSlides: false, preloadImages: false, lazyLoading: true, observer: true, observerParents: true, }); }); } if ($(".swiper-container-centered").length > 0) { $(".swiper-container-centered").each(function () { var swiper = new Swiper(".swiper-container-centered", { pagination: ".swiper-pagination", slidesPerView: "auto", centeredSlides: true, paginationClickable: true, spaceBetween: 30, initialSlide: 1, breakpoints: { // when window width is <= 320px 768: { slidesPerView: 1, spaceBetweenSlides: 0, }, // when window width is <= 480px 991: { slidesPerView: 2, spaceBetweenSlides: 0, }, }, }); }); } // Swiper with coverflow effect if ($(".swiper-container-coverflow").length > 0) { $(".swiper-container-coverflow").each(function () { var swiper = new Swiper($(this), { pagination: $(this).find(".swiper-pagination"), effect: "coverflow", grabCursor: true, centeredSlides: true, initialSlide: $(this).data("swiper-initial-slide"), slidesPerView: $(this).data("swiper-items"), coverflow: { rotate: 0, stretch: 0, depth: 300, modifier: 1, slideShadows: true, }, breakpoints: { 576: { slidesPerView: 1, spaceBetweenSlides: 0, initialSlide: 0, }, 768: { slidesPerView: 2, spaceBetweenSlides: 0, }, // when window width is <= 480px 992: { slidesPerView: 3, spaceBetweenSlides: 0, initialSlide: 2, }, }, }); }); } if ($(".countdown").length > 0) { $(".countdown").each(function () { var $this = $(this); var date = $this.data("countdown-date"); $this.countdown(date).on("update.countdown", function (event) { var $this = $(this).html( event.strftime( "" + '