$(function($){ /*xynav*/ $(".xydropdowns").dropdowns(); /*边栏客服*/ $(".side2 ul li").hover(function(){ $(this).find(".sidebox").stop().animate({"width":"200px"},200).css({"opacity":"1","filter":"Alpha(opacity=100)","background":"#d11817"}); },function(){ $(this).find(".sidebox").stop().animate({"width":"54px"},200).css({"opacity":"0.6","filter":"Alpha(opacity=60)","background":"#000"}); }); $('#email').keydown(function(event) { //event.preventDefault(); if (event.keyCode == 13) { if(checkemailformen()) { sendemailform(); } } }); /*$("#pxp").html($(document.body).width());*/ $("#submitbtn").on("click",function(){ if(checkemailformen()) { sendemailform(); } }); $('#MessageModal').on('shown.bs.modal', function (e) { $(this).css('display', 'block'); var modalHeight = $(window).height() / 2 - $('#MessageModal .modal-dialog').height() / 2; $(this).find('.modal-dialog').css({'margin-top': modalHeight}); }); /*手机菜单*/ $(".panel-title a").on("click",function(){ var el = $(this).find("span > i"); if(el.hasClass("fa fa-plus")) { el.removeClass("fa fa-plus").addClass("fa fa-minus"); }else { el.removeClass("fa fa-minus").addClass("fa fa-plus"); } }); }); $(window).resize(function(){ if($(document.body).width() > 767){ } /*$("#pxp").html($(document.body).width());*/ }); $(window).load(function(){ /*$("#fixtopnav").sticky({ topSpacing: 0 });*/ }); /*check email form function*/ function checkemailform() { if(!$("input[name='email']").val().match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/)) { //alert("邮箱格式不正确!请重新输入"); $("#msgString").text("邮箱格式不正确!请重新输入"); $("#MessageModal").modal('show'); return false; } else { return true; } } function checkemailformen() { if(!$("input[name='email']").val().match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/)) { //alert("邮箱格式不正确!请重新输入"); $("#msgString").text("Invalid email format!"); $("#MessageModal").modal('show'); return false; } else { return true; } } /*send email function*/ function sendemailform() { var email = $.trim($("input[name='email']").val()); var pagelang = $.trim($("input[name='pagelang']").val()); $("#emailform")[0].reset(); $.ajax({ type: "POST", url: "/plus/diy.php", data: "email="+email+"&pagelang="+pagelang+"&action=post&diyid=1&do=2&dede_fields=email,text&dede_fieldshash=31dcb3f87fd670cf0a8aadaf34b83bba&postid="+new Date(), success: function(msg){ $("#msgString").text(msg); $("#MessageModal").modal('show'); } }); } function goTop(){ $('html,body').animate({'scrollTop':0},600); } /*check search form function*/ function checksearchformen() { var txt = $.trim($("#searchtxt").val()); if (txt == '' || txt == 'Search...') { alert('Please enter a keyword or product model!'); $('#searchtxt').focus(); return false; }else { $("#searchform").submit(); return true; } }