/** * 公用导航搜索和快捷导航 * * @dependencies 依赖zepto.min.js */ $(document).ready(function() { var oSoClear = ai.i("js-so-ico-clear"), oSoPopText = ai.i("js-so-pop-text"), oSoPopBtnCancel = ai.i("js-so-pop-btn-cancel"), oSoPopGuessSlip = ai.i("js-so-pop-guess-slip"), oSoPop= ai.i("js-so-pop"), oSoPopBtn = ai.i("js-so-pop-btn"), oSoPopGuess = ai.i("js-so-pop-guess"), oSoPopPromote = ai.i("js-so-pop-promote"), oSoPopFormShell = ai.i("js-so-pop-form-shell"); $("#js-ico-search").click(function() { if ("undefined" == typeof browserType) { browserType = ""; } if (browserType == "0") { $("#js-so-pop").show(); $("#js-so-pop-text").val(""); $("#js-so-pop-text").focus(); } else { window.location = "/search.html"; } }); $("#js-so-pop-btn-cancel").click(function(event) { $(".so-pop-guess-slip").html(""); $(".g-search").hide(); }); $("#js-so-ico-clear").click(function(event) { $("#js-so-pop-guess").hide(); $("#js-so-pop-btn").hide(); $("#js-so-pop-btn-cancel").show(); $("#js-so-pop-promote").show(); $("#js-so-pop-text").val(""); $("#js-so-pop-text").focus(); }); $("#js-so-pop-text").on("input", function(o) { textChange(o); }, false); ai.touchMovePreventDefault(oSoPop); ai.touchMovePreventDefault(oSoPopFormShell); oSoPopFormShell.addEventListener('touchstart', function(e){ e.stopPropagation(); }); oSoPopGuess.addEventListener('touchstart', function(e){ e.stopPropagation(); }); oSoPopGuessSlip.addEventListener('touchstart',function(e){ e.preventDefault(); oSoPopBtn.focus(); }); oSoPopPromote.addEventListener('touchstart', function(e){ e.stopPropagation(); }); }); //首页的搜索 $(document).ready(function() { btnStates(); $(".formShell").click(function(event) { event.stopImmediatePropagation(); }); // touch版的首页中间的搜索 // IE if ($.browser.msie) { $("#name").on("onpropertychange", function(o) { inputKeyGetVal(); }, false); // 非IE } else { $("#name").on("input", function(o) { inputKeyGetVal(); }, false); } $("#name").on("focus", function(o) { inputKeyGetVal(); }, false); // 清除文本框内容 $(".closeList").click(function(event) { event.stopImmediatePropagation(); $(this).hide(); $(".inputKey").val(""); $(".popGuess").hide(); $("#searchMask").hide(); btnStates(); }); $("#searchMask").click(function(){ $("#searchMask").hide(); }); $("#searchMask").on("touchmove",function(e){ e.preventDefault(); }) $("#searchMask li").click(function(event){ event.stopImmediatePropagation(); $(".inputKey").val($(this).html()); $("#searchMask").hide(); }) $("#searchMask li").click(function(event){ event.stopImmediatePropagation(); $(".inputKey").val($(this).html()); $("#searchMask").hide(); }) }); function textChange(o) { var num = o.target.value.getBytes(); if (num > 0) { $("#js-so-pop-guess-slip").html(""); $("#js-so-pop-btn-cancel").hide(); $("#js-so-pop-btn").show(); } else { $("#js-so-pop-btn").hide(); $("#js-so-pop-btn-cancel").show(); } if (num > 2) { try { $.ajax({ url : '/matching.html?requestType=ajax&term=' + o.target.value, type : 'get', dataType : "json", success : function(result) { for ( var i in result) { var id = 'sopopchange' + i; $("#js-so-pop-guess-slip").append('