// Hide Header on on scroll down // var didScroll; // var lastScrollTop = 0; // var delta = 5; // var navbarHeight = $(".nav").outerHeight(); // $(window).scroll(function(event) { // didScroll = true; // }); // setInterval(function() { // if (didScroll) { // hasScrolled(); // didScroll = false; // } // }, 250); $(document).ready(function () { DarkMode.setDark(false); $(".zoom").mousemove(function (e) { zoom(e); }); function zoom(e) { var x, y; var zoomer = e.currentTarget; if (e.offsetX) { offsetX = e.offsetX; } else { offsetX = e.touches[0].pageX; } if (e.offsetY) { offsetY = e.offsetY; } else { offsetX = e.touches[0].pageX; } x = (offsetX / zoomer.offsetWidth) * 100; y = (offsetY / zoomer.offsetHeight) * 100; zoomer.style.backgroundPosition = x + "% " + y + "%"; } $(".selecter").selectpicker(); }); $(document).on("click", ".heartBtn", function () { $(this).toggleClass("heartBtnActive"); }); $(document).on("click", ".searchBtn", function () { $(".nav").addClass("overNav"); $(".serchBar").slideDown(); $(".subMenu").slideUp(); $("#cLogo").attr("class", "showInline"); $("#wLogo").attr("class", "hide"); }); $(document).on("click", ".closeSearchBtn", function () { $(".nav").removeClass("overNav"); $(".serchBar").slideUp(); $("#cLogo").attr("class", "hide"); $("#wLogo").attr("class", "showInline"); }); $(document).on("click", ".subBack", function () { $(".nav").removeClass("overNav"); $(".subMenu").slideUp(); $("#cLogo").attr("class", "hide"); $("#wLogo").attr("class", "showInline"); }); $(document).on("click", ".shopBtn", function () { $(".nav").addClass("overNav"); $(".subMenu").slideDown(); $(".serchBar").slideUp(); $("#cLogo").attr("class", "showInline"); $("#wLogo").attr("class", "hide"); }); $(document).on("click", ".addToBagPreviewBtn", function () { $("body").addClass("fixedHeight"); $(".cartPreview").fadeIn(); $(".sildePreviewWrap").animate({ right: "0" }); }); $(document).on("click", ".continueBtn", function () { $("body").removeClass("fixedHeight"); $(".cartPreview").fadeOut(); $(".sildePreviewWrap").animate({ right: "-40%" }); }); $(document).on("click", ".cartPreviewCloseBtn", function () { $("body").removeClass("fixedHeight"); $(".cartPreview").fadeOut(); $(".sildePreviewWrap").animate({ right: "-40%" }); }); $(document).on("click", ".plantProfileBtn", function () { $(".productDetailDesWrap").hide(); $(".productProfileWrap").fadeIn(); }); $(document).on("click", ".productProfileCloseBtn", function () { $(".productProfileWrap").hide(); $(".productDetailDesWrap").fadeIn(); }); $(document).on("click", ".continueToShipBtn", function () { $(".checkOutInfo").hide(); $(".checkOutPayment").fadeIn(); $("html, body").animate({ scrollTop: 0 }, "slow"); }); $(document).on("click", ".returnPaymentInfoBtn", function () { $(".checkOutPayment").hide(); $(".checkOutInfo").fadeIn(); }); $(document).on("click", ".orderDetailBtn", function () { $(".orderPreview").hide(); $(".orderDetail").fadeIn(); }); $(document).on("click", ".closeOrderDetail", function () { $(".orderDetail").hide(); $(".orderPreview").fadeIn(); }); $(document).on("click", ".addressEditBtn", function () { $(this) .parent() .parent() .parent() .find(".addressTextareaWrap input") .attr("readonly", false); // $(this).parent().parent().find( "addressTextarea" ).attr("readonly", true); $(this).removeClass("show"); $(this).addClass("hide"); $(this).parent().find(".addressSaveBtn").addClass("show"); }); $(document).on("click", ".addressSaveBtn", function () { $(this) .parent() .parent() .parent() .find(".addressTextareaWrap input") .attr("readonly", true); $(this).removeClass("show"); $(this).addClass("hide"); $(this).parent().find(".addressEditBtn").addClass("show"); }); $(document).on("click", ".accountMenu a", function () { $(".mobileAccountMenu").animate({ left: "-100%" }); $("body").removeClass("fixedHeight"); }); $(document).on("click", ".faqMenu a", function () { $(".mobilefaqMenu").animate({ left: "-100%" }); $("body").removeClass("fixedHeight"); }); $(document).on("click", ".mobileAccountMenuBack", function () { $(".mobileAccountMenu").animate({ left: "0" }); $("body").addClass("fixedHeight"); }); $(document).on("click", ".noteBarClose", function () { $(".noteBar").hide(); }); $(document).on("click", ".mobilefaqMenuBack", function () { $(".mobilefaqMenu").animate({ left: "0" }); $("body").addClass("fixedHeight"); }); $(document).on("click", ".addNewAddressBtn", function () { // var div = $('

'); $(".addressItemWrap").append( '

' ); }); $(document).on("click", ".addressMoveBtn", function () { $(this).parent().parent().parent().parent().remove(); }); $(".ourStoriesItem").hover(function () { var image = $(this).data("image"); $(".ourStoriesItemImg").css("background-image", "url(" + image + ")"); }); // Show the first tab and hide the rest // Click function $("#tabs-nav li").click(function () { $("#tabs-nav li").removeClass("active"); $(this).addClass("active"); $(".tab-content").hide(); var activeTab = $(this).find("a").attr("href"); $(activeTab).fadeIn(); return false; }); $('.subMainWarp a[href^="#"]').on("click", function (event) { $(".subCatWrap").hide(); $(".subMainWarp a").removeClass("active"); $(this).addClass("active"); var target = $(this).attr("href"); $(".subCatWrap" + target).toggle(); }); $(".continueToShipBtn").on("click", function () { $(".subMenuImgWrap").hide(); $(".subMenuImgWrap").removeClass("show"); var target = $(this).attr("data-promotion"); console.log($(".subMenuImgWrap ." + target)); $("." + target).toggleClass("show"); }); $(".plantBtn").on("click", function () { $(".subMenuImgWrap").hide(); $(".subMenuImgWrap").removeClass("show"); var target = $(this).attr("data-promotion"); console.log($(".subMenuImgWrap ." + target)); $("." + target).toggleClass("show"); }); $('.color').change(function() { var slideno = $(this).val(); alert(slideno); $('.slider-nav').slick('slickGoTo', slideno - 1); if (slideno == "Own") { $(".potChoice").fadeIn(); } else { $(".potChoice").hide(); } }); /* $(".color").change(function (e) { var selectedItem = $(this).val(); e.preventDefault(); $(".slider-nav").slick("slickGoTo", selectedItem - 1); if (selectedItem == "Own") { $(".potChoice").fadeIn(); } else { $(".potChoice").hide(); } });*/ $(".messageCardCheck").change(function () { if ($(this).is(":checked")) { $(".messageCardChoice").show(); } else { $(".messageCardChoice").hide(); } }); $(".transplantingCheck").change(function () { if ($(this).is(":checked")) { $(".transplantingChoice").show(); } else { $(".transplantingChoice").hide(); } }); var search = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace, // url points to a json file that contains an array of country names, see // https://github.com/twitter/typeahead.js/blob/gh-pages/data/countries.json prefetch: "../assets/json/search.json", }); $(".searchAutoComplete").typeahead(null, { name: "search", source: search, }); // $('a[href^="#"]').on('click',function (e) { // e.preventDefault(); // var target = this.hash; // var $target = $(target); // $('html, body').stop().animate({ // 'scrollTop': $target.offset().top -200 // }, 900, 'swing', function () { // }); // }); // function hasScrolled() { // var st = $(this).scrollTop(); // // Make sure they scroll more than delta // if (Math.abs(lastScrollTop - st) <= delta) return; // // If they scrolled down and are past the navbar, add class .nav-up. // // This is necessary so you never see what is "behind" the navbar. // if (st > lastScrollTop && st > navbarHeight) { // // Scroll Down // $(".nav").addClass("nav-up"); // } else { // // Scroll Up // if (st + $(window).height() < $(document).height()) { // $(".nav").removeClass("nav-up"); // } // } // lastScrollTop = st; // } window.inputNumber = function (el) { var min = el.attr("min") || false; var max = el.attr("max") || false; var els = {}; els.dec = el.prev(); els.inc = el.next(); el.each(function () { init($(this)); }); function init(el) { els.dec.on("click", decrement); els.inc.on("click", increment); function decrement() { var value = el[0].value; value--; if (!min || value >= min) { el[0].value = value; } } function increment() { var value = el[0].value; value++; if (!max || value <= max) { el[0].value = value++; } } } }; $(document).ready(function () { var ratingElem = $('.rating input[name="star"]'); ratingElem.change(function () { if (this.checked) { $(this).parent().addClass("active"); } }); $(".productTabNav a").click(function () { $(".panel").hide(); $(".productTabNav a.active").removeClass("active"); $(this).addClass("active"); var panel = $(this).attr("href"); $(panel).fadeIn(); return false; // prevents link action }); // end click $(".productTabNav a:first").click(); }); $(".input-number").keypress(function (e) { //if the letter is not digit then display error and don't type anything if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { //display error message return false; } }); $(".scrollTop").click(function () { // When arrow is clicked $("html").animate( { scrollTop: 0, // Scroll to top of body }, 500 ); });