function goSearch(){ var key = $(".android_enter").val(); key = key.replace(/\//g,""); key = key.replace(/\\/g,""); console.log("key:" + key); location.href= "/market/search?key=" + key; } function showSearchBtn(){ $('#searchbar_wrapper').slideToggle('slow'); $('.android_enter').focus(); } function searchInputListener(){ //trigger search text by keybord enter $('.android_enter').focusin(function () { $(document).keypress(function (e) { if (e.which == 13) { //alert('press enter'); goSearch(); } }); }); } function menuListener(){ $('.narrow_down').click(function(){ $('.listlist').toggle('slide', {direction: 'right'}, 150); }); $('body').bind("touchstart",function(){ $(".listlist").hide('slide', { direction: 'right' }, 150, function(){}); }); $('body').bind("click",function(){ $('.listlist').hide('slide', { direction: 'right' }, 150, function(){}); }); $('.listlist, .narrow_down').bind('click touchstart', function(event){ event.stopPropagation(); }); } function languageSwitch(){ $.colorbox({ href: '/intro/language_form_intro.php', top : '48px', opacity:0.5, transition: 'none', open:true, width: 360, initialWidth: 360, height: 360, initialHeight: 360, overlayClose:true, escKey:true, scrolling:false, onComplete: function() { $('#cboxClose').hide(); } }); } function closeLanguage(){ $.fn.colorbox.close(); } function setLanguage(language){ //網址避免得到# url = location.pathname + location.search; if(url.indexOf("?", 0)!=-1){ url = url + "&l=" + language; }else{ url = url + "?l=" + language; } location.replace(url); } function detectDeviceWidth(){ var w = $(window).width(); if(w <= 320){ $('.market_list_headertitle').hide(); } } $(document).ready(function(){ detectDeviceWidth(); menuListener(); searchInputListener(); cart_getCartItemRowCount(); });