mirror of https://github.com/1099438829/macUI.git
1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
jQuery.iUtil={getPosition:function(e){var x=0,y=0,restoreStyle=!1,es=e.style;"none"==jQuery(e).css("display")&&(oldVisibility=es.visibility,oldPosition=es.position,es.visibility="hidden",es.display="block",es.position="absolute",restoreStyle=!0);for(var el=e;el;)x+=el.offsetLeft+(el.currentStyle&&!jQuery.browser.opera&&parseInt(el.currentStyle.borderLeftWidth)||0),y+=el.offsetTop+(el.currentStyle&&!jQuery.browser.opera&&parseInt(el.currentStyle.borderTopWidth)||0),el=el.offsetParent;for(el=e;el&&el.tagName&&"body"!=el.tagName.toLowerCase();)x-=el.scrollLeft||0,y-=el.scrollTop||0,el=el.parentNode;return restoreStyle&&(es.display="none",es.position=oldPosition,es.visibility=oldVisibility),{x:x,y:y}},getPositionLite:function(el){for(var x=0,y=0;el;)x+=el.offsetLeft||0,y+=el.offsetTop||0,el=el.offsetParent;return{x:x,y:y}},getSize:function(e){var w=jQuery.css(e,"width"),h=jQuery.css(e,"height"),wb=0,hb=0,es=e.style;return"none"!=jQuery(e).css("display")?(wb=e.offsetWidth,hb=e.offsetHeight):(oldVisibility=es.visibility,oldPosition=es.position,es.visibility="hidden",es.display="block",es.position="absolute",wb=e.offsetWidth,hb=e.offsetHeight,es.display="none",es.position=oldPosition,es.visibility=oldVisibility),{w:w,h:h,wb:wb,hb:hb}},getSizeLite:function(el){return{wb:el.offsetWidth||0,hb:el.offsetHeight||0}},getClient:function(e){var h,w,de;return e?(w=e.clientWidth,h=e.clientHeight):(de=document.documentElement,w=window.innerWidth||self.innerWidth||de&&de.clientWidth||document.body.clientWidth,h=window.innerHeight||self.innerHeight||de&&de.clientHeight||document.body.clientHeight),{w:w,h:h}},getScroll:function(e){var t,l,w,h,iw,ih;return e&&"body"!=e.nodeName.toLowerCase()?(t=e.scrollTop,l=e.scrollLeft,w=e.scrollWidth,h=e.scrollHeight,iw=0,ih=0):(document.documentElement&&document.documentElement.scrollTop?(t=document.documentElement.scrollTop,l=document.documentElement.scrollLeft,w=document.documentElement.scrollWidth,h=document.documentElement.scrollHeight):document.body&&(t=document.body.scrollTop,l=document.body.scrollLeft,w=document.body.scrollWidth,h=document.body.scrollHeight),iw=self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0,ih=self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0),{t:t,l:l,w:w,h:h,iw:iw,ih:ih}},getMargins:function(e,toInteger){var el=jQuery(e),t=el.css("marginTop")||"",r=el.css("marginRight")||"",b=el.css("marginBottom")||"",l=el.css("marginLeft")||"";return toInteger?{t:parseInt(t)||0,r:parseInt(r)||0,b:parseInt(b)||0,l:parseInt(l)}:{t:t,r:r,b:b,l:l}},getPadding:function(e,toInteger){var el=jQuery(e),t=el.css("paddingTop")||"",r=el.css("paddingRight")||"",b=el.css("paddingBottom")||"",l=el.css("paddingLeft")||"";return toInteger?{t:parseInt(t)||0,r:parseInt(r)||0,b:parseInt(b)||0,l:parseInt(l)}:{t:t,r:r,b:b,l:l}},getBorder:function(e,toInteger){var el=jQuery(e),t=el.css("borderTopWidth")||"",r=el.css("borderRightWidth")||"",b=el.css("borderBottomWidth")||"",l=el.css("borderLeftWidth")||"";return toInteger?{t:parseInt(t)||0,r:parseInt(r)||0,b:parseInt(b)||0,l:parseInt(l)||0}:{t:t,r:r,b:b,l:l}},getPointer:function(event){var x,y;return{x:event.pageX||event.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)||0,y:event.pageY||event.clientY+(document.documentElement.scrollTop||document.body.scrollTop)||0}},traverseDOM:function(nodeEl,func){for(func(nodeEl),nodeEl=nodeEl.firstChild;nodeEl;)jQuery.iUtil.traverseDOM(nodeEl,func),nodeEl=nodeEl.nextSibling},purgeEvents:function(nodeEl){jQuery.iUtil.traverseDOM(nodeEl,(function(el){for(var attr in el)"function"==typeof el[attr]&&(el[attr]=null)}))},centerEl:function(el,axis){var clientScroll=$.iUtil.getScroll(),windowSize=$.iUtil.getSize(el);axis&&"vertically"!=axis||$(el).css({top:clientScroll.t+(Math.max(clientScroll.h,clientScroll.ih)-clientScroll.t-windowSize.hb)/2+"px"}),axis&&"horizontally"!=axis||$(el).css({left:clientScroll.l+(Math.max(clientScroll.w,clientScroll.iw)-clientScroll.l-windowSize.wb)/2+"px"})},fixPNG:function(el,emptyGIF){var images,png;$('img[@src*="png"]',el||document).each((function(){png=this.src,this.src=emptyGIF,this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+png+"')"}))}},[].indexOf||(Array.prototype.indexOf=function(v,n){n=null==n?0:n;for(var m=this.length,i=n;i<m;i++)if(this[i]==v)return i;return-1}),jQuery.fxCheckTag=function(e){return!/^tr$|^td$|^tbody$|^caption$|^thead$|^tfoot$|^col$|^colgroup$|^th$|^body$|^header$|^script$|^frame$|^frameset$|^option$|^optgroup$|^meta$/i.test(e.nodeName)},jQuery.fx.destroyWrapper=function(e,old){var c=e.firstChild,cs=c.style;cs.position=old.position,cs.marginTop=old.margins.t,cs.marginLeft=old.margins.l,cs.marginBottom=old.margins.b,cs.marginRight=old.margins.r,cs.top=old.top+"px",cs.left=old.left+"px",e.parentNode.insertBefore(c,e),e.parentNode.removeChild(e)},jQuery.fx.buildWrapper=function(e){if(!jQuery.fxCheckTag(e))return!1;var t=jQuery(e),es=e.style,restoreStyle=!1,oldStyle={};oldStyle.position=t.css("position"),"none"==t.css("display")&&(oldVisibility=t.css("visibility"),es.visibility="hidden",es.display="",restoreStyle=!0),oldStyle.sizes=jQuery.iUtil.getSize(e),oldStyle.margins=jQuery.iUtil.getMargins(e);var oldFloat=e.currentStyle?e.currentStyle.styleFloat:t.css("float");oldStyle.top=parseInt(t.css("top"))||0,oldStyle.left=parseInt(t.css("left"))||0;var wid="w_"+parseInt(1e4*Math.random()),wr=document.createElement(/^img$|^br$|^input$|^hr$|^select$|^textarea$|^object$|^iframe$|^button$|^form$|^table$|^ul$|^dl$|^ol$/i.test(e.nodeName)?"div":e.nodeName);jQuery.attr(wr,"id",wid),wr.className="fxWrapper";var wrs=wr.style,top=0,left=0;return"relative"!=oldStyle.position&&"absolute"!=oldStyle.position||(top=oldStyle.top,left=oldStyle.left),wrs.display="none",wrs.top=top+"px",wrs.left=left+"px",wrs.position="relative"!=oldStyle.position&&"absolute"!=oldStyle.position?"relative":oldStyle.position,wrs.overflow="hidden",wrs.height=oldStyle.sizes.hb+"px",wrs.width=oldStyle.sizes.wb+"px",wrs.marginTop=oldStyle.margins.t,wrs.marginRight=oldStyle.margins.r,wrs.marginBottom=oldStyle.margins.b,wrs.marginLeft=oldStyle.margins.l,jQuery.browser.msie?wrs.styleFloat=oldFloat:wrs.cssFloat=oldFloat,e.parentNode.insertBefore(wr,e),es.marginTop="0px",es.marginRight="0px",es.marginBottom="0px",es.marginLeft="0px",es.position="absolute",es.listStyle="none",es.top="0px",es.left="0px",restoreStyle&&(es.display="none",es.visibility=oldVisibility),wr.appendChild(e),wrs.display="block",{oldStyle:oldStyle,wrapper:jQuery(wr)}},jQuery.fx.namedColors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]},jQuery.fx.parseColor=function(color,notColor){return jQuery.fx.namedColors[color]?{r:jQuery.fx.namedColors[color][0],g:jQuery.fx.namedColors[color][1],b:jQuery.fx.namedColors[color][2]}:(result=/^rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)$/.exec(color))?{r:parseInt(result[1]),g:parseInt(result[2]),b:parseInt(result[3])}:(result=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)$/.exec(color))?{r:2.55*parseFloat(result[1]),g:2.55*parseFloat(result[2]),b:2.55*parseFloat(result[3])}:(result=/^#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])$/.exec(color))?{r:parseInt("0x"+result[1]+result[1]),g:parseInt("0x"+result[2]+result[2]),b:parseInt("0x"+result[3]+result[3])}:(result=/^#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$/.exec(color))?{r:parseInt("0x"+result[1]),g:parseInt("0x"+result[2]),b:parseInt("0x"+result[3])}:1!=notColor&&{r:255,g:255,b:255}},jQuery.fx.cssProps={borderBottomWidth:1,borderLeftWidth:1,borderRightWidth:1,borderTopWidth:1,bottom:1,fontSize:1,height:1,left:1,letterSpacing:1,lineHeight:1,marginBottom:1,marginLeft:1,marginRight:1,marginTop:1,maxHeight:1,maxWidth:1,minHeight:1,minWidth:1,opacity:1,outlineOffset:1,outlineWidth:1,paddingBottom:1,paddingLeft:1,paddingRight:1,paddingTop:1,right:1,textIndent:1,top:1,width:1,zIndex:1},jQuery.fx.colorCssProps={backgroundColor:1,borderBottomColor:1,borderLeftColor:1,borderRightColor:1,borderTopColor:1,color:1,outlineColor:1},jQuery.fx.cssSides=["Top","Right","Bottom","Left"],jQuery.fx.cssSidesEnd={borderWidth:["border","Width"],borderColor:["border","Color"],margin:["margin",""],padding:["padding",""]},jQuery.fn.extend({animate:function(prop,speed,easing,callback){return this.queue((function(){var opt=jQuery.speed(speed,easing,callback),e=new jQuery.fxe(this,opt,prop)}))},pause:function(speed,callback){return this.queue((function(){var opt=jQuery.speed(speed,callback),e=new jQuery.pause(this,opt)}))},stop:function(step){return this.each((function(){this.animationHandler&&jQuery.stopAnim(this,step)}))},stopAll:function(step){return this.each((function(){this.animationHandler&&jQuery.stopAnim(this,step),this.queue&&this.queue.fx&&(this.queue.fx=[])}))}}),jQuery.extend({pause:function(elem,options){var z=this,values;z.step=function(){jQuery.isFunction(options.complete)&&options.complete.apply(elem)},z.timer=setInterval((function(){z.step()}),options.duration),elem.animationHandler=z},easing:{linear:function(p,n,firstNum,delta,duration){return(-Math.cos(p*Math.PI)/2+.5)*delta+firstNum}},fxe:function(elem,options,prop){var z=this,values,y=elem.style,oldOverflow=jQuery.css(elem,"overflow"),oldDisplay=jQuery.css(elem,"display"),props={};for(p in z.startTime=(new Date).getTime(),options.easing=options.easing&&jQuery.easing[options.easing]?options.easing:"linear",z.getValues=function(tp,vp){if(jQuery.fx.cssProps[tp])if("show"==vp||"hide"==vp||"toggle"==vp){elem.orig||(elem.orig={});var r=parseFloat(jQuery.css(elem,tp));elem.orig[tp]=r&&r>-1e4?r:parseFloat(jQuery.css(elem,tp))||0,options[vp="toggle"==vp?"none"==oldDisplay?"show":"hide":vp]=!0,props[tp]="show"==vp?[0,elem.orig[tp]]:[elem.orig[tp],0],"opacity"!=tp?y[tp]=props[tp][0]+("zIndex"!=tp&&"fontWeight"!=tp?"px":""):jQuery.attr(y,"opacity",props[tp][0])}else props[tp]=[parseFloat(jQuery.css(elem,tp)),parseFloat(vp)||0];else if(jQuery.fx.colorCssProps[tp])props[tp]=[jQuery.fx.parseColor(jQuery.css(elem,tp)),jQuery.fx.parseColor(vp)];else if(/^margin$|padding$|border$|borderColor$|borderWidth$/i.test(tp)){var m=vp.replace(/\s+/g," ").replace(/rgb\s*\(\s*/g,"rgb(").replace(/\s*,\s*/g,",").replace(/\s*\)/g,")").match(/([^\s]+)/g);switch(tp){case"margin":case"padding":case"borderWidth":case"borderColor":m[3]=m[3]||m[1]||m[0],m[2]=m[2]||m[0],m[1]=m[1]||m[0];for(var i=0;i<jQuery.fx.cssSides.length;i++){var nmp=jQuery.fx.cssSidesEnd[tp][0]+jQuery.fx.cssSides[i]+jQuery.fx.cssSidesEnd[tp][1];props[nmp]="borderColor"==tp?[jQuery.fx.parseColor(jQuery.css(elem,nmp)),jQuery.fx.parseColor(m[i])]:[parseFloat(jQuery.css(elem,nmp)),parseFloat(m[i])]}break;case"border":for(var i=0;i<m.length;i++){var floatVal=parseFloat(m[i]),sideEnd=isNaN(floatVal)?!/transparent|none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset/i.test(m[i])&&"Color":"Width";if(sideEnd)for(var j=0;j<jQuery.fx.cssSides.length;j++)nmp="border"+jQuery.fx.cssSides[j]+sideEnd,props[nmp]="Color"==sideEnd?[jQuery.fx.parseColor(jQuery.css(elem,nmp)),jQuery.fx.parseColor(m[i])]:[parseFloat(jQuery.css(elem,nmp)),floatVal];else y.borderStyle=m[i]}}}else y[tp]=vp;return!1},prop)if("style"==p){var newStyles=jQuery.parseStyle(prop[p]);for(np in newStyles)this.getValues(np,newStyles[np])}else if("className"==p){if(document.styleSheets)for(var i=0;i<document.styleSheets.length;i++){var cssRules=document.styleSheets[i].cssRules||document.styleSheets[i].rules||null;if(cssRules)for(var j=0;j<cssRules.length;j++)if(cssRules[j].selectorText=="."+prop[p]){var rule=new RegExp("."+prop[p]+" {"),styles=cssRules[j].style.cssText,newStyles=jQuery.parseStyle(styles.replace(rule,"").replace(/}/g,""));for(np in newStyles)this.getValues(np,newStyles[np])}}}else this.getValues(p,prop[p]);y.display="none"==oldDisplay?"block":oldDisplay,y.overflow="hidden",z.step=function(){var t=(new Date).getTime();if(t>options.duration+z.startTime){for(p in clearInterval(z.timer),z.timer=null,props)"opacity"==p?jQuery.attr(y,"opacity",props[p][1]):"object"==typeof props[p][1]?y[p]="rgb("+props[p][1].r+","+props[p][1].g+","+props[p][1].b+")":y[p]=props[p][1]+("zIndex"!=p&&"fontWeight"!=p?"px":"");if(options.hide||options.show)for(var p in elem.orig)"opacity"==p?jQuery.attr(y,p,elem.orig[p]):y[p]="";y.display=options.hide?"none":"none"!=oldDisplay?oldDisplay:"block",y.overflow=oldOverflow,elem.animationHandler=null,jQuery.isFunction(options.complete)&&options.complete.apply(elem)}else{var n=t-this.startTime,pr=n/options.duration;for(p in props)if("object"==typeof props[p][1])y[p]="rgb("+parseInt(jQuery.easing[options.easing](pr,n,props[p][0].r,props[p][1].r-props[p][0].r,options.duration))+","+parseInt(jQuery.easing[options.easing](pr,n,props[p][0].g,props[p][1].g-props[p][0].g,options.duration))+","+parseInt(jQuery.easing[options.easing](pr,n,props[p][0].b,props[p][1].b-props[p][0].b,options.duration))+")";else{var pValue=jQuery.easing[options.easing](pr,n,props[p][0],props[p][1]-props[p][0],options.duration);"opacity"==p?jQuery.attr(y,"opacity",pValue):y[p]=pValue+("zIndex"!=p&&"fontWeight"!=p?"px":"")}}},z.timer=setInterval((function(){z.step()}),13),elem.animationHandler=z},stopAnim:function(elem,step){step?elem.animationHandler.startTime-=1e8:(window.clearInterval(elem.animationHandler.timer),elem.animationHandler=null,jQuery.dequeue(elem,"fx"))}}),jQuery.parseStyle=function(styles){var newStyles={};if("string"==typeof styles){styles=styles.toLowerCase().split(";");for(var i=0;i<styles.length;i++)rule=styles[i].split(":"),2==rule.length&&(newStyles[jQuery.trim(rule[0].replace(/\-(\w)/g,(function(m,c){return c.toUpperCase()})))]=jQuery.trim(rule[1]))}return newStyles},jQuery.iFisheye={build:function(options){return this.each((function(){var el=this;el.fisheyeCfg={items:jQuery(options.items,this),container:jQuery(options.container,this),pos:jQuery.iUtil.getPosition(this),itemWidth:options.itemWidth,itemsText:options.itemsText,proximity:options.proximity,valign:options.valign,halign:options.halign,maxWidth:options.maxWidth},jQuery.iFisheye.positionContainer(el,0),jQuery(window).bind("resize",(function(){el.fisheyeCfg.pos=jQuery.iUtil.getPosition(el),jQuery.iFisheye.positionContainer(el,0),jQuery.iFisheye.positionItems(el)})),jQuery.iFisheye.positionItems(el),el.fisheyeCfg.items.bind("mouseover",(function(){jQuery(el.fisheyeCfg.itemsText,this).get(0).style.display="block"})).bind("mouseout",(function(){jQuery(el.fisheyeCfg.itemsText,this).get(0).style.display="none"})),jQuery(document).bind("mousemove",(function(e){var pointer=jQuery.iUtil.getPointer(e),toAdd=0;if(el.fisheyeCfg.halign&&"center"==el.fisheyeCfg.halign)var posx=pointer.x-el.fisheyeCfg.pos.x-(el.offsetWidth-el.fisheyeCfg.itemWidth*el.fisheyeCfg.items.size())/2-el.fisheyeCfg.itemWidth/2;else if(el.fisheyeCfg.halign&&"right"==el.fisheyeCfg.halign)var posx=pointer.x-el.fisheyeCfg.pos.x-el.offsetWidth+el.fisheyeCfg.itemWidth*el.fisheyeCfg.items.size();else var posx=pointer.x-el.fisheyeCfg.pos.x;var posy=Math.pow(pointer.y-el.fisheyeCfg.pos.y-el.offsetHeight/2,2);el.fisheyeCfg.items.each((function(nr){distance=Math.sqrt(Math.pow(posx-nr*el.fisheyeCfg.itemWidth,2)+posy),distance-=el.fisheyeCfg.itemWidth/2,distance=distance<0?0:distance,distance=distance>el.fisheyeCfg.proximity?el.fisheyeCfg.proximity:distance,distance=el.fisheyeCfg.proximity-distance,extraWidth=el.fisheyeCfg.maxWidth*distance/el.fisheyeCfg.proximity,this.style.width=el.fisheyeCfg.itemWidth+extraWidth+"px",this.style.left=el.fisheyeCfg.itemWidth*nr+toAdd+"px",toAdd+=extraWidth})),jQuery.iFisheye.positionContainer(el,toAdd)}))}))},positionContainer:function(el,toAdd){el.fisheyeCfg.halign&&("center"==el.fisheyeCfg.halign?el.fisheyeCfg.container.get(0).style.left=(el.offsetWidth-el.fisheyeCfg.itemWidth*el.fisheyeCfg.items.size())/2-toAdd/2+"px":"left"==el.fisheyeCfg.halign?el.fisheyeCfg.container.get(0).style.left=-toAdd/el.fisheyeCfg.items.size()+"px":"right"==el.fisheyeCfg.halign&&(el.fisheyeCfg.container.get(0).style.left=el.offsetWidth-el.fisheyeCfg.itemWidth*el.fisheyeCfg.items.size()-toAdd/2+"px")),el.fisheyeCfg.container.get(0).style.width=el.fisheyeCfg.itemWidth*el.fisheyeCfg.items.size()+toAdd+"px"},positionItems:function(el){el.fisheyeCfg.items.each((function(nr){this.style.width=el.fisheyeCfg.itemWidth+"px",this.style.left=el.fisheyeCfg.itemWidth*nr+"px"}))}},jQuery.fn.Fisheye=jQuery.iFisheye.build; |