/* Bottom navigator display */ ;(function(win, $){ var addHandler = function(el, type, handler){ if(el.addEventListener) el.addEventListener(type, handler, false); else if(el.attachEvent) el.attachEvent("on"+type, handler); else el["on"+type] = handler; },msflag = false; // For ':active' addHandler(document.body, "touchstart", $.noop); // Initialize variables var $scontainer = $('body > #scroll_container'),ua = navigator.userAgent.toLowerCase(), $btmnav = $('body > #mphone_btmnav'),navH = $btmnav.outerHeight(), $sbcontainer = $scontainer.children('#scroll_container_bg'); var $li = $btmnav.find('li'),$mpop = $('body > #mphone_morepop'), cln = $li.filter(':not(.more)').length,step = win.isHandheld?1:2,minliw = 60 * step; // Onload event $(win).bind("pageloaded", function(){ var maxW = $scontainer.width(),btop = $sbcontainer.height(); // 鍏煎鍏朵粬搴曢儴娴姩灞� var $fixedlayer = $scontainer.children('.fixedbottom'); $fixedlayer.find(".price").height("auto"); var indom = $fixedlayer.find(".price").outerHeight(); if(indom>$fixedlayer.height()) $fixedlayer.height(indom); $fixedlayer.length && $fixedlayer.css("bottom", navH+'px'); var $fixedlayer2 = $scontainer.find('.parametercon, .wzc_meau, .wkjdibubutton'); $fixedlayer2.length && $fixedlayer2.css("bottom", navH+'px'); // Mobile-website preview var scframw = 0, _hdname = $.cookie('hdname') || ''; var regarr = /hdname=([a-z0-9]+)\b/i.exec(location.search); if (/^[a-z0-9]+$/i.test(_hdname) || regarr != null) { step = 1;minliw = 60; if (regarr != null) { _hdname = regarr[1]; $.cookie('hdname', _hdname); } maxW = parent.$('#'+_hdname+'_frame').width(); scframw = maxW; } else $.removeCookie('hdname'); // Create placeholder var $placeholder = $scontainer.children('#mphone_placeholder'); if(! $placeholder.length){ $placeholder = $('
').appendTo($scontainer); $placeholder.css({height: navH+'px',top: btop+'px'}); }else{ $scontainer.height(function(n, c){return c + navH}); $sbcontainer.height(function(n, c){return c + navH}); } // Reset container-height if(win.isHandheld && !msflag) $scontainer.height(function(n, c){return c + navH}); msflag = true; // Reset navbar-positon var navleft = (/micromessenger/i.test(ua) && !/windowswechat/i.test(ua))?'auto':($scontainer.offset().left+'px'); $btmnav.css({"bottom": '0px',"left": navleft,"width": maxW+'px',"visibility": 'visible'}); // Reset column-style var $hlight = $btmnav.find('li:first .highlightbg'),highliw = lin = 0; if ($hlight.length > 0){highliw = Math.max(64, $btmnav.find('li:first').width());lin = 1} maxW -= highliw; var liw = Math.floor(maxW / (cln - lin)); if (minliw > liw) {/* 'more' button */ var moreW = 20 * step,actW = maxW - moreW,cln2 = Math.floor(actW / minliw); newliw = Math.max(minliw, Math.floor(actW / cln2)); var $litarget = lin ? $li.filter(':not(:first):lt('+cln2+')') : $li.filter(':lt('+cln2+')'); $litarget.width(newliw+'px').show().children('a').width(newliw+'px'); $li.filter(':gt('+(cln2 - 1 + lin)+')').hide().filter('.more').show(); // 'more' event $li.filter('.more').unbind("click").bind("click", function(){ if($mpop.is(':visible')) return false; $li.filter(':hidden:not(.more)').clone(true).show().appendTo($mpop.children('ul').empty()); if(scframw > 0) $mpop.css("max-width", '132px'); $mpop.css({"bottom": (navH + 5)+'px',"right": ($scontainer.offset().left + 2 * step)+'px'}).show(); }); } else { var $more = $li.filter('.more'),$target = $more.siblings(); $more.unbind("click").hide(); // Highlight fixed-width if (highliw > 0) { liw = Math.floor(maxW / (cln - 1)); $target = $li.filter(':gt(0):not(.more)'); } $target.width(liw+'px').show().children('a').width(liw+'px'); } // Resize & Scroll var etype = (("orientation" in win) && ("onorientationchange" in win))?"orientationchange":"resize"; $scontainer.add(this).bind(etype, function(e){ // Destroy 'more' popup if($mpop.is(':visible')) $mpop.hide().children('ul').empty(); // Reload $(win).triggerHandler("pageloaded"); // Fixed low-version if(ua.indexOf('android 2.3') > -1) $btmnav.css('top', ($(this).height() - navH)+'px'); }).bind("click", function(e){ // Destroy 'more' popup if($mpop.is(':visible') && ! $(e.target).closest(['#mphone_btmnav','#mphone_morepop']).length) $mpop.hide().children('ul').empty(); }); }).load(function(){ var sid = null; sid = setTimeout(function(){ if(msflag) return false;$(win).triggerHandler("pageloaded");clearTimeout(sid) }, 500); if(!is_website_mobile()){ setTimeout(function(){ if($mpop.is(':visible')) $mpop.hide().children('ul').empty(); $(win).triggerHandler("pageloaded"); // Fixed low-version if(ua.indexOf('android 2.3') > -1) $btmnav.css('top', ($(this).height() - navH)+'px'); },1000) } }); })(window, jQuery);