var pageSlide = { toggle: function(e) { if ($('#container').hasClass('show')) { pageSlide.close(e); } else { pageSlide.open(e); } }, open: function(e) { e.preventDefault(); $('#container,#header,#slidemenu').addClass('show'); $('html,body').css({ 'height' : '100%', 'overflow' : 'hidden' }); }, close: function(e) { e.preventDefault(); $('#container,#header,#slidemenu').removeClass('show'); $('html,body').css({ 'height' : 'auto', 'overflow-y' : 'auto' }); }, init: function() { $('#container').on('touchstart click', function(e) { if ($('#container').hasClass('show')) { pageSlide.close(e); } }); $('#header a.menu').on('touchstart click', function(e) { pageSlide.toggle(e); }); } } var mailForm = { closed: false, type: 0, setVisit: function() { if ($.cookie('session') == undefined) { $.cookie('session', true, {path : '/'}); if ($.cookie('visit') == undefined) { $.cookie('visit', 1, { expires: 14, path : '/'}); } else { var visit = $.cookie('visit'); visit = parseInt(visit) + 1; $.cookie('visit', visit, { expires: 14, path : '/'}); } } }, setPageview: function() { if ($.cookie('pageview') == undefined) { $.cookie('pageview', 1, { expires: 14, path : '/'}); } else { var pageview = $.cookie('pageview'); pageview = parseInt(pageview) + 1; $.cookie('pageview', pageview, { expires: 14, path : '/'}); } }, init: function() { if ($.cookie('mf-closed') != undefined) { mailForm.closed = $.cookie('mf-closed'); } mailForm.setVisit(); mailForm.setPageview(); $.getJSON("/js/mailform.json", function(json) { mailForm.type = json.type; if (json.visit != '') { if (parseInt($.cookie('visit')) < json.visit) { console.log($.cookie('visit')); return; } } if (json.pageview != '') { if (parseInt($.cookie('pageview')) < json.pageview) { console.log($.cookie('pageview')); return; } } if (mailForm.type == 0) { return; } else if (mailForm.type == 1) { mailForm.openModal(); } else { $(window).scroll(function() { if ($(this).scrollTop() > 100) { mailForm.open(); } else { mailForm.close(); } }); } }); $('.newsletter input[type="checkbox"]').click(function() { if ($(this).prop('checked')) { $('.newsletter input[type="checkbox"]').prop('checked', true); $('.mktoButton').removeAttr('disabled'); } else { $('.newsletter input[type="checkbox"]').prop('checked', false); $('.mktoButton').attr('disabled', 'disabled'); } }); $('#mailForm a.close').on('click', function() { $.cookie('mf-closed', true, { expires: 14, path : '/'}); mailForm.closed = true; mailForm.close(); return false; }); }, open: function() { if (mailForm.closed == false) { $('#mailForm').css('display', 'block'); } }, openModal: function() { if (mailForm.closed == false) { $('#mailForm').addClass('modal'); $('html,body').css({ 'height': '100%', 'overflow': 'hidden' }); $('#mailForm').css('display', 'block'); } }, close: function() { $('#mailForm').css('display', 'none'); $('html,body').css({ 'height': 'auto', 'overflow': 'auto' }); } } $(function(){ $('a').on('click', function(event) { var category = $(this).parents().map(function () { if (this.className != '') { return this.className; } }).get().reverse().join('>'); var label = $(this).text() ? $(this).text() : $(this).children('img').attr('alt'); var action = 'click'; ga('send', 'event', category, action, label); }); pageSlide.init(); mailForm.init(); $('.image img').lazyload({ threshold: 500, effect: 'fadeIn', effectspeed: 500 }); $(function() { $("#pagetop").click(function() { var o = 500 , i = $("#sb-site").offset().top; return $("html, body").animate({ scrollTop: i }, o, "swing"), !1 }), $(window).on("load resize", function() { var o = $(window).width() , i = 768; if (o <= i) { new $.slidebars({ siteClose: !0, scrollLock: !0 }) } }) }); var isSearchHover = false; $('body').on('mouseup', function() { if (!isSearchHover) { $('.search-box').removeClass('active'); $('.search-box input').css({'width':'0', 'display':'none'}); } }); $('.search-box').hover(function() { isSearchHover = true; }, function() { isSearchHover = false; }); $('.search-box button').on('touchend click', function() { var ua = window.navigator.userAgent.toLowerCase(); if (ua.indexOf('runway app') != -1 || ua.indexOf('im app') != -1) { if (ua.indexOf('iphone') != -1 || ua.indexOf('ipad') != -1 || ua.indexOf('ipod') != -1) { window.scrollTo(0, 0); } } var searchBox = $(this).parent('.search-box'); if (searchBox.hasClass('active')) { if (searchBox.find('input').val() == '') { $('.search-box').removeClass('active'); $('.search-box input').css({'width':'0', 'display':'none'}); return false; } } else { var width = '300px'; if ($(window).width() < 400) { width = '200px'; } $('.search-box input').css({'width':width, 'display':'inline-block'}); $('.search-box input').focus(); searchBox.addClass('active'); return false; } }); $('.popup-modal').magnificPopup({ type:'inline' }); $(document).on('click', '.modal-wrap .close', function (e) { e.preventDefault(); $.magnificPopup.close(); }); }); $(window).load(function() { $('.mktoButton').attr('disabled', 'disabled'); });