; (function () { 'use strict'; // iPad and iPod detection var isiPad = function () { return (navigator.platform.indexOf("iPad") != -1); }; var isiPhone = function () { return ( (navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) ); }; // Main Menu Superfish var mainMenu = function () { $('.sf-menu').superfish({ delay: 0, animation: { opacity: 'show' }, speed: 'fast', cssArrows: true, disableHI: true }); }; // Parallax var parallax = function () { $(window).stellar(); }; // Offcanvas and cloning of the main menu var offcanvas = function () { var $clone = $('.ui-menu-wrap').clone(); $clone.attr({ 'class': 'ui-offcanvas-menu' }); $clone.find('> ul').attr({ 'class': '', 'id': '' }); $('.ui-page').prepend($clone); // click the burger $('.ui-nav-toggle').on('click', function () { if ($('body').hasClass('ui-offcanvas')) { $('body').removeClass('ui-offcanvas'); } else { $('body').addClass('ui-offcanvas'); } // $('body').toggleClass('ui-offcanvas'); }); $('.ui-offcanvas-menu').css('height', $(window).height()); $(window).resize(function () { var w = $(window); $('.ui-offcanvas-menu').css('height', w.height()); if (w.width() > 769) { if ($('body').hasClass('ui-offcanvas')) { $('body').removeClass('ui-offcanvas'); } } }); } // Click outside of the Mobile Menu var mobileMenuOutsideClick = function () { $(document).click(function (e) { var container = $(".ui-offcanvas-menu, .ui-nav-toggle"); if (!container.is(e.target) && container.has(e.target).length === 0) { if ($('body').hasClass('ui-offcanvas')) { $('body').removeClass('ui-offcanvas'); } } }); }; var backToTop = function () { $(document).on("click", ".feedback", function () { $('body,html').animate({ scrollTop: 0 }, 300); return false; }); }; // var messagePost = function () { // $(document).on("submit", "#messageForm", function () { // var data = $("#messageForm").serialize(); // $.ajax({ // url : "/api/feedback/post", // async : true, //            type: "POST", // data : data, // success : function (data) { // if (data.code == 1) { // alert("留言成功!"); // $('#messageForm')[0].reset() // } else { // alert(data.msg); // } // }, // error : function (data) { // alert(data.responseText); // }, // }); // return false; // }); // }; var swiperSlide = function () { new Swiper('.ui-slide', { cssMode: true, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, pagination: { el: '.swiper-pagination' }, mousewheel: false, keyboard: true, }); var num = $(window).width() > 992 ? 4 : 1; new Swiper('.cate-slide', { cssMode: true, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, slidesPerView: num, spaceBetween: 30, mousewheel: false, keyboard: true, }); }; $(function () { mainMenu(); parallax(); offcanvas(); mobileMenuOutsideClick(); backToTop(); // messagePost(); swiperSlide(); }); }());