$(function() { var $win = $(window), // $cloneNav = $('#fixHeaderMenu').clone().addClass('clone-nav d-block').appendTo('body'), $cloneNav = $('#fixHeaderMenu').addClass('clone-nav d-block'), showClass = 'is-show'; var ua = navigator.userAgent; if (ua.indexOf('iPhone') < 0 || ua.indexOf('Android') < 0 && ua.indexOf('Mobile') < 0) { $win.on('load scroll', function() { var value = $(this).scrollTop(); if ( value > 300 ) { $cloneNav.addClass(showClass); } else { $cloneNav.removeClass(showClass); } }); } }); /////////////////////// /////////////////////// /////////////////// /////////////////////// MOBILE MENU DESIGN ////////////////////// /////////////////////// /////////////////////// ////////////////// $(document).ready(function() { // jQuery code // mobile menu $(".toggler-menu-mobile").on("click", function(e){ e.preventDefault(); $(".screen-overlay").toggleClass("active"); $('.megamenu-block').toggleClass("show"); }); $(".megamenu-block .btn-close, .screen-overlay").on("click", function(e){ e.preventDefault(); $(".megamenu-block").removeClass("show"); $(".screen-overlay").removeClass("active"); }); // mobile-shows submenu $('.has-submenu').children('a').on('click', function(event){ event.preventDefault(); if( $(this).next('ul').not('.active')) { $(this).next('ul').addClass('active').end().parent('.has-submenu').parent('ul').addClass('move-out'); } }); $('.go-back').on('click', function(event){ event.preventDefault(); $(this).parent('ul').removeClass('active').parent('.has-submenu').parent('ul').removeClass('move-out'); }); //////////////////////// Prevent closing from click inside dropdown $(document).on('click', '.dropdown-menu', function (e) { e.stopPropagation(); }); /////////////////////// /////////////////////// /////////////////// /////////////////////// SEARCH AUTOCOMPLETE ////////////////////// /////////////////////// /////////////////////// ////////////////// var records = { url: function(phrase) { return "/resources/c_media/themes/theme_65/js/autocomplete-result.php?phrase=" + phrase +"&format=json"; }, getValue: function(element) { return element.name; }, highlightPhrase: true, list: { onLoadEvent: function() { $('.eac-item a[href*="cid"]').each(function() { $(this).append(' - Category'); }); $('.eac-item a[href*="search"]').each(function() { $(this).append(' - Brand'); }); }, match: { enabled: true }, showAnimation: { type: "fade", //normal|slide|fade time: 400, callback: function() {} }, hideAnimation: { type: "fade", //normal|slide|fade time: 400, callback: function() {} } }, template: { type: "links", fields: { link: "link" } }, adjustWidth: false, theme:"blue-light", requestDelay: 500 }; $("#main_search").easyAutocomplete(records); $("#main_search2").easyAutocomplete(records); }); // jquery end /////////////////////// /////////////////////// /////////////////////// /////// /////////////////////// EMAIL SUBSCRIPTION POPUP FORM /////////////////////// /////////////////////// /////////////////////// /////////////////////// /////// $(document).ready(function() { var delay = 300; // milliseconds var cookie_expire = 7; // days var cookie = localStorage.getItem("list-builder"); if(cookie == undefined || cookie == null) { cookie = 0; } if(((new Date()).getTime() - cookie) / (1000 * 60 * 60 * 24) > cookie_expire) { $("#list-builder").delay(delay).fadeIn("fast", () => { $("#popup-box").fadeIn("fast", () => {}); }); $("button[name=subscribe]").click(() => { $.ajax({ type: "POST", url: $("#popup-form").attr("action"), data: $("#popup-form").serialize(), success: (data) => { $("#popup-box-content").html("

Thank you for subscribing to The Polyglot Developer newsletter!

"); } }); }); $("#popup-close").click(() => { $("#list-builder, #popup-box").hide(); localStorage.setItem("list-builder", (new Date()).getTime()); }); } });