uibar.js
4.47 KB
/*! dili 2016-01-06 */
define("event",function(require,exports){function transit(target,options){this.target=target,this.opt={pauseGroup:null,onOver:function(){},onOut:function(){}},$.extend(this.opt,options),this.init()}var events={x:function(ev){return ev.pageX||ev.clientX+$(document).scrollLeft()},y:function(ev){return ev.pageY||ev.clientY+$(document).scrollTop()}};events.transit=function(target,options){$(target).each(function(){new transit(this,options)})};var transit_tick_timer=null,transit_timers=[];return transit.prototype={init:function(){var _this=this,target=this.target;target.onTrigger=function(){clearInterval(this.timer),clearTimeout(this.outTimer),this._triggered=!0,this._onOver.call(_this,this)},this.bind()},bind:function(){var _this=this;$(this.target).bind("mouseover.transit",function(event){_this.onStart(this,event)}),$(this.target).bind("mousemove.transit",function(event){_this.onProcess(event)}),$(this.target).bind("mouseout.transit",function(event){_this.onStop()})},bindGroup:function(target){var _this=this,group=this.opt.pauseGroup;group&&group.length&&(group.unbind("mouseover.transit").bind("mouseover.transit",function(event){clearTimeout(_this.current.outTimer)}),group.unbind("mouseout.transit").bind("mouseout.transit",function(event){_this.onStop()}))},onStart:function(target,event){var _this=this;target._onOver=this.opt.onOver,target._onOut=this.opt.onOut,this.current=target,this.coorArr=[.123456,.654321],this.clear(),this.tick(),clearTimeout(_this.current.outTimer),this.bindGroup(target),transit_timers.push(this.current),this.current.timer=setInterval(function(){_this.coorArr.push(_this.coor),_this.compareCoor()},23)},onProcess:function(event){this.coor=[event.pageX,event.pageY]},onStop:function(){var _this=this;return this.clear(),this.current&&$(this.current).length?(clearTimeout(this.current.outTimer),void(this.current.outTimer=setTimeout(function(){_this.current._triggered&&(_this.current._onOut.call(_this,_this.current),_this.current._triggered=!1)},24))):!1},compareCoor:function(){var arr=this.coorArr,len=arr.length,lastCoor=arr[len-1],prevCoor=arr[len-2];lastCoor[0]==prevCoor[0]&&lastCoor[1]==prevCoor[1]&&this.current.onTrigger()},clear:function(){for(var i=0;i<transit_timers.length;i++){var target=transit_timers[i];target===this.current&&(clearInterval(this.current.timer),transit_timers.splice(i,1))}},tick:function(){clearTimeout(transit_tick_timer),transit_tick_timer=setTimeout(function(){if(transit_timers.length)for(var i=0;i<transit_timers.length;i++){var target=transit_timers[i];clearInterval(target.timer),transit_timers.splice(i,1)}},3e3)}},events}),define(function(require,exports,module){var _Event=require("event");$(function(){var methods={barHover:{onOver:function(view){$(view).find(".floatinglayer").show()},onOut:function(view){$(view).find(".floatinglayer").hide(),$(view).find(".a-block").hasClass("a-block")&&$(view).find(".a-block").find(".show-bar-text").stop().animate({left:"0px"},300)}}};_Event.transit(".receipt",methods.barHover),_Event.transit(".user li",methods.barHover),_Event.transit(".soll-top",methods.barHover),_Event.transit(".ui-search-bar",methods.barHover),_Event.transit(".ui-im",methods.barHover);var $top,$body;$top=$body=window.opera?"CSS1Compat"==document.compatMode?$("html"):$("body"):$("html,body"),$(".soll-top").click(function(){$top.animate({scrollTop:0},800)});var sollp=$(".soll-top");$(window).scroll(function(){var scrollTop=0;scrollTop=document.all?document.documentElement.scrollTop+document.body.scrollTop:$(this).scrollTop(),scrollTop>0?"none"==sollp.css("display")&&sollp.show():sollp.hide(),scrollTop>180?$(".ui-search-bar").show():$(".ui-search-bar").hide()}),$(".bar-menu").click(function(){var thisview=$(this).find("span");"-40px"==$(".mui-bar .user").css("right")?($(".mui-bar").removeClass("addhover"),thisview.removeClass("icon-menu-more-colse").addClass("icon-menu-more-add"),$(".mui-bar .user").stop().animate({right:0},300),$(this).find("p").html("隐藏")):($(".mui-bar").addClass("addhover"),thisview.removeClass("icon-menu-more-add").addClass("icon-menu-more-colse"),$(".mui-bar .user").stop().animate({right:-40},300),$(this).find("p").html("显示"))});var uibarsize=function(){$(this).width()<1200?($(".bar-menu span").removeClass("icon-menu-more-add").addClass("icon-menu-more-colse"),$(".mui-bar .user").stop().animate({right:-40},300)):($(".bar-menu span").removeClass("icon-menu-more-colse").addClass("icon-menu-more-add"),$(".mui-bar .user").stop().animate({right:0},300))};$(window).resize(uibarsize),uibarsize()})});