⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yui-ext.js

📁 一个使用yui-ext库
💻 JS
📖 第 1 页 / 共 5 页
字号:
        var body = ["this.compiled = function(values){ return ['"];        body.push(this.html.replace(this.re, "', values['$1'], '"));        body.push("'].join('');};");        eval(body.join(''));        return this;    },insertBefore:function(el,values,returnElement){el=YAHOO.util.Dom.get(el);var newNode=YAHOO.ext.DomHelper.insertHtml('beforeBegin',el,this.applyTemplate(values));return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;},insertAfter:function(el,values,returnElement){el=YAHOO.util.Dom.get(el);var newNode=YAHOO.ext.DomHelper.insertHtml('afterEnd',el,this.applyTemplate(values));return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;},append:function(el,values,returnElement){el=YAHOO.util.Dom.get(el);var newNode=YAHOO.ext.DomHelper.insertHtml('beforeEnd',el,this.applyTemplate(values));return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;},overwrite:function(el,values,returnElement){el=YAHOO.util.Dom.get(el);el.innerHTML='';var newNode=YAHOO.ext.DomHelper.insertHtml('beforeEnd',el,this.applyTemplate(values));return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;}};YAHOO.ext.Template=YAHOO.ext.DomHelper.Template;YAHOO.ext.Element=function(element,forceNew){var dom=YAHOO.util.Dom.get(element);if(!dom){return null;}if(!forceNew&&YAHOO.ext.Element.cache[dom.id]){return YAHOO.ext.Element.cache[dom.id];}this.dom=dom;this.id=this.dom.id;this.visibilityMode=YAHOO.ext.Element.VISIBILITY;this.originalDisplay=YAHOO.util.Dom.getStyle(this.dom,'display')||'';if(this.autoDisplayMode){if(this.originalDisplay=='none'){this.setVisibilityMode(YAHOO.ext.Element.DISPLAY);}}if(this.originalDisplay=='none'){this.originalDisplay='';}this.defaultUnit='px';}YAHOO.ext.Element.prototype={setVisibilityMode:function(visMode){this.visibilityMode=visMode;return this;},enableDisplayMode:function(display){this.setVisibilityMode(YAHOO.ext.Element.DISPLAY);if(typeof display!='undefined')this.originalDisplay=display;return this;},animate:function(args,duration,onComplete,easing,animType){this.anim(args,duration,onComplete,easing,animType);return this;},anim:function(args,duration,onComplete,easing,animType){animType=animType||YAHOO.util.Anim;var anim=new animType(this.dom,args,duration||.35,easing||YAHOO.util.Easing.easeBoth);if(onComplete){if(!(onComplete instanceof Array)){anim.onComplete.subscribe(onComplete,this,true);}else{for(var i=0;i<onComplete.length;i++){var fn=onComplete[i];if(fn)anim.onComplete.subscribe(fn,this,true);}}}anim.animate();},scrollIntoView:function(container){var c=getEl(container||document.body,true);var cp=c.getStyle('position');var restorePos=false;if(cp!='relative'&&cp!='absolute'){c.setStyle('position','relative');restorePos=true;}var el=this.dom;var childTop=parseInt(el.offsetTop,10);var childBottom=childTop+el.offsetHeight;var containerTop=parseInt(c.scrollTop,10);var containerBottom=containerTop+c.clientHeight;if(childTop<containerTop){c.scrollTop=childTop;}else if(childBottom>containerBottom){c.scrollTop=childBottom-c.clientHeight;}if(restorePos){c.setStyle('position',cp);}return this;},autoHeight:function(animate,duration,onComplete,easing){var oldHeight=this.getHeight();this.clip();this.setHeight(1);setTimeout(function(){var height=parseInt(this.dom.scrollHeight,10);if(!animate){this.setHeight(height);this.unclip();if(typeof onComplete=='function'){onComplete();}}else{this.setHeight(oldHeight);this.setHeight(height,animate,duration,function(){this.unclip();if(typeof onComplete=='function')onComplete();}.createDelegate(this),easing);}}.createDelegate(this),0);return this;},isVisible:function(deep){var vis=YAHOO.util.Dom.getStyle(this.dom,'visibility')!='hidden'&&YAHOO.util.Dom.getStyle(this.dom,'display')!='none';if(!deep||!vis){return vis;}var p=this.dom.parentNode;while(p&&p.tagName.toLowerCase()!='body'){if(YAHOO.util.Dom.getStyle(p,'visibility')=='hidden'||YAHOO.util.Dom.getStyle(p,'display')=='none'){return false;}p=p.parentNode;}return true;},select:function(selector,unique){return YAHOO.ext.Element.select('#'+this.dom.id+' '+selector,unique);},initDD:function(group,config,overrides){var dd=new YAHOO.util.DD(YAHOO.util.Dom.generateId(this.dom),group,config);return YAHOO.ext.util.Config.apply(dd,overrides);},initDDProxy:function(group,config,overrides){var dd=new YAHOO.util.DDProxy(YAHOO.util.Dom.generateId(this.dom),group,config);return YAHOO.ext.util.Config.apply(dd,overrides);},initDDTarget:function(group,config,overrides){var dd=new YAHOO.util.DDTarget(YAHOO.util.Dom.generateId(this.dom),group,config);return YAHOO.ext.util.Config.apply(dd,overrides);},setVisible:function(visible,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){if(this.visibilityMode==YAHOO.ext.Element.DISPLAY){this.setDisplayed(visible);}else{YAHOO.util.Dom.setStyle(this.dom,'visibility',visible?'visible':'hidden');}}else{this.setOpacity(visible?0:1);YAHOO.util.Dom.setStyle(this.dom,'visibility','visible');if(this.visibilityMode==YAHOO.ext.Element.DISPLAY){this.setDisplayed(true);}var args={opacity:{from:(visible?0:1),to:(visible?1:0)}};var anim=new YAHOO.util.Anim(this.dom,args,duration||.35,easing||(visible?YAHOO.util.Easing.easeIn:YAHOO.util.Easing.easeOut));anim.onComplete.subscribe((function(){if(this.visibilityMode==YAHOO.ext.Element.DISPLAY){this.setDisplayed(visible);}else{YAHOO.util.Dom.setStyle(this.dom,'visibility',visible?'visible':'hidden');}}).createDelegate(this));if(onComplete){anim.onComplete.subscribe(onComplete);}anim.animate();}return this;},isDisplayed:function(){return YAHOO.util.Dom.getStyle(this.dom,'display')!='none';},toggle:function(animate,duration,onComplete,easing){this.setVisible(!this.isVisible(),animate,duration,onComplete,easing);return this;},setDisplayed:function(value){if(typeof value=='boolean'){value=value?this.originalDisplay:'none';}YAHOO.util.Dom.setStyle(this.dom,'display',value);return this;},focus:function(){try{this.dom.focus();}catch(e){}return this;},blur:function(){try{this.dom.blur();}catch(e){}return this;},addClass:function(className){if(className instanceof Array){for(var i=0,len=className.length;i<len;i++){this.addClass(className[i]);}}else{if(!this.hasClass(className)){this.dom.className=this.dom.className+' '+className;}}return this;},radioClass:function(className){var siblings=this.dom.parentNode.childNodes;for(var i=0;i<siblings.length;i++){var s=siblings[i];if(s.nodeType==1){YAHOO.util.Dom.removeClass(s,className);}}this.addClass(className);return this;},removeClass:function(className){if(className instanceof Array){for(var i=0,len=className.length;i<len;i++){this.removeClass(className[i]);}}else{var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g');var c=this.dom.className;if(re.test(c)){this.dom.className=c.replace(re,' ');}}return this;},toggleClass:function(className){if(this.hasClass(className)){this.removeClass(className);}else{this.addClass(className);}return this;},hasClass:function(className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');return re.test(this.dom.className);},replaceClass:function(oldClassName,newClassName){this.removeClass(oldClassName);this.addClass(newClassName);return this;},getStyle:function(name){return YAHOO.util.Dom.getStyle(this.dom,name);},setStyle:function(name,value){if(typeof name=='string'){YAHOO.util.Dom.setStyle(this.dom,name,value);}else{var D=YAHOO.util.Dom;for(var style in name){if(typeof name[style]!='function'){D.setStyle(this.dom,style,name[style]);}}}return this;},applyStyles:function(style){YAHOO.ext.DomHelper.applyStyles(this.dom,style);},getX:function(){return YAHOO.util.Dom.getX(this.dom);},getY:function(){return YAHOO.util.Dom.getY(this.dom);},getXY:function(){return YAHOO.util.Dom.getXY(this.dom);},setX:function(x,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setX(this.dom,x);}else{this.setXY([x,this.getY()],animate,duration,onComplete,easing);}return this;},setY:function(y,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setY(this.dom,y);}else{this.setXY([this.getX(),y],animate,duration,onComplete,easing);}return this;},setLeft:function(left){YAHOO.util.Dom.setStyle(this.dom,'left',this.addUnits(left));return this;},setTop:function(top){YAHOO.util.Dom.setStyle(this.dom,'top',this.addUnits(top));return this;},setRight:function(right){YAHOO.util.Dom.setStyle(this.dom,'right',this.addUnits(right));return this;},setBottom:function(bottom){YAHOO.util.Dom.setStyle(this.dom,'bottom',this.addUnits(bottom));return this;},setXY:function(pos,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setXY(this.dom,pos);}else{this.anim({points:{to:pos}},duration,onComplete,easing,YAHOO.util.Motion);}return this;},setLocation:function(x,y,animate,duration,onComplete,easing){this.setXY([x,y],animate,duration,onComplete,easing);return this;},moveTo:function(x,y,animate,duration,onComplete,easing){this.setXY([x,y],animate,duration,onComplete,easing);return this;},getRegion:function(){return YAHOO.util.Dom.getRegion(this.dom);},getHeight:function(contentHeight){var h=this.dom.offsetHeight;return contentHeight!==true?h:h-this.getBorderWidth('tb')-this.getPadding('tb');},getWidth:function(contentWidth){var w=this.dom.offsetWidth;return contentWidth!==true?w:w-this.getBorderWidth('lr')-this.getPadding('lr');},getSize:function(contentSize){return{width:this.getWidth(contentSize),height:this.getHeight(contentSize)};},adjustWidth:function(width){if(typeof width=='number'){if(this.autoBoxAdjust&&!this.isBorderBox()){width-=(this.getBorderWidth('lr')+this.getPadding('lr'));}if(width<0){width=0;}}return width;},adjustHeight:function(height){if(typeof height=='number'){if(this.autoBoxAdjust&&!this.isBorderBox()){height-=(this.getBorderWidth('tb')+this.getPadding('tb'));}if(height<0){height=0;}}return height;},setWidth:function(width,animate,duration,onComplete,easing){width=this.adjustWidth(width);if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setStyle(this.dom,'width',this.addUnits(width));}else{this.anim({width:{to:width}},duration,onComplete,easing||(width>this.getWidth()?YAHOO.util.Easing.easeOut:YAHOO.util.Easing.easeIn));}return this;},setHeight:function(height,animate,duration,onComplete,easing){height=this.adjustHeight(height);if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setStyle(this.dom,'height',this.addUnits(height));}else{this.anim({height:{to:height}},duration,onComplete,easing||(height>this.getHeight()?YAHOO.util.Easing.easeOut:YAHOO.util.Easing.easeIn));}return this;},setSize:function(width,height,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){this.setWidth(width);this.setHeight(height);}else{width=this.adjustWidth(width);height=this.adjustHeight(height);this.anim({width:{to:width},height:{to:height}},duration,onComplete,easing);}return this;},setBounds:function(x,y,width,height,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){this.setWidth(width);this.setHeight(height);this.setLocation(x,y);}else{width=this.adjustWidth(width);height=this.adjustHeight(height);this.anim({points:{to:[x,y]},width:{to:width},height:{to:height}},duration,onComplete,easing,YAHOO.util.Motion);}return this;},setRegion:function(region,animate,duration,onComplete,easing){this.setBounds(region.left,region.top,region.right-region.left,region.bottom-region.top,animate,duration,onComplete,easing);return this;},addListener:function(eventName,handler,scope,override){YAHOO.util.Event.addListener(this.dom,eventName,handler,scope||this,true);return this;},bufferedListener:function(eventName,fn,scope,millis){var task=new YAHOO.ext.util.DelayedTask();scope=scope||this;var newFn=function(){task.delay(millis||250,fn,scope,Array.prototype.slice.call(arguments,0));}this.addListener(eventName,newFn);return newFn;},addHandler:function(eventName,stopPropagation,handler,scope,override){var fn=YAHOO.ext.Element.createStopHandler(stopPropagation,handler,scope||this,true);YAHOO.util.Event.addListener(this.dom,eventName,fn);return this;},on:function(eventName,handler,scope,override){YAHOO.util.Event.addListener(this.dom,eventName,handler,scope||this,true);return this;},addManagedListener:function(eventName,fn,scope,override){return YAHOO.ext.EventManager.on(this.dom,eventName,fn,scope||this,true);},mon:function(eventName,fn,scope,override){return YAHOO.ext.EventManager.on(this.dom,eventName,fn,scope||this,true);},removeListener:function(eventName,handler,scope){YAHOO.util.Event.removeListener(this.dom,eventName,handler);return this;},removeAllListeners:function(){YAHOO.util.Event.purgeElement(this.dom);return this;},setOpacity:function(opacity,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setStyle(this.dom,'opacity',opacity);}else{this.anim({opacity:{to:opacity}},duration,onComplete,easing);}return this;},getLeft:function(local){if(!local){return this.getX();}else{return parseInt(this.getStyle('left'),10)||0;}},getRight:function(local){if(!local){return this.getX()+this.getWidth();}else{return(this.getLeft(true)+this.getWidth())||0;}},getTop:function(local){if(!local){return this.getY();}else{return parseInt(this.getStyle('top'),10)||0;}},getBottom:function(local){if(!local){return this.getY()+this.getHeight();}else{return(this.getTop(true)+this.getHeight())||0;}},setAbsolutePositioned:function(zIndex){this.setStyle('position','absolute');if(zIndex){this.setStyle('z-index',zIndex);}return this;},setRelativePositioned:function(zIndex){this.setStyle('position','relative');if(zIndex){this.setStyle('z-index',zIndex);}return this;},clearPositioning:function(){this.setStyle('position','');this.setStyle('left','');this.setStyle('right','');this.setStyle('top','');this.setStyle('bottom','');return this;},getPositioning:function(){return{'position':this.getStyle('position'),'left':this.getStyle('left'),'right':this.getStyle('right'),'top':this.getStyle('top'),'bottom':this.getStyle('bottom')};},getBorderWidth:function(side){return this.addStyles(side,YAHOO.ext.Element.borders);},getPadding:function(side){return this.addStyles(side,YAHOO.ext.Element.paddings);},setPositioning:function(positionCfg){if(positionCfg.position)this.setStyle('position',positionCfg.position);if(positionCfg.left)this.setLeft(positionCfg.left);if(positionCfg.right)this.setRight(positionCfg.right);if(positionCfg.top)this.setTop(positionCfg.top);if(positionCfg.bottom)this.setBottom(positionCfg.bottom);return this;},setLeftTop:function(left,top){this.dom.style.left=this.addUnits(left);this.dom.style.top=this.addUnits(top);return this;},move:function(direction,distance,animate,duration,onComplete,easing){var xy=this.getXY();direction=direction.toLowerCase();switch(direction){case'l':case'left':this.moveTo(xy[0]-distance,xy[1],animate,duration,onComplete,easing);break;case'r':case'right':this.moveTo(xy[0]+distance,xy[1],animate,duration,onComplete,easing);break;case't':case'top':case'up':this.moveTo(xy[0],xy[1]-distance,animate,duration,onComplete,easing);break;case'b':case'bottom':case'down':this.moveTo(xy[0],xy[1]+distance,animate,duration,onComplete,easing);break;}return this;},clip:function(){if(!this.isClipped){this.isClipped=true;this.originalClip={'o':this.getStyle('overflow'),'x':this.getStyle('overflow-x'),'y':this.getStyle('overflow-y')};this.setStyle('overflow','hidden');this.setStyle('overflow-x','hidden');this.setStyle('overflow-y','hidden');}return this;},unclip:function(){if(this.isClipped){this.isClipped=false;var o=this.originalClip;if(o.o){this.setStyle('overflow',o.o);}if(o.x){this.setStyle('overflow-x',o.x);}if(o.y){this.setStyle('overflow-y',o.y);}}return this;},alignTo:function(element,position,offsets,animate,duration,onComplete,easing){var otherEl=getEl(element);if(!otherEl){return this;}offsets=offsets||[0,0];var r=otherEl.getRegion();position=position.toLowerCase();switch(position){case'bl':this.moveTo(r.left+offsets[0],r.bottom+offsets[1],animate,duration,onComplete,easing);break;case'br':this.moveTo(r.right+offsets[0],r.bottom+offsets[1],animate,duration,onComplete,easing);break;case'tl':this.moveTo(r.left+offsets[0],r.top+offsets[1],animate,duration,onComplete,easing);break;case'tr':this.moveTo(r.right+offsets[0],r.top+offsets[1],animate,duration,onComplete,easing);break;}return this;},clearOpacity:function(){if(window.ActiveXObject){this.dom.style.filter='';}else{this.dom.style.opacity='';this.dom.style['-moz-opacity']='';this.dom.style['-khtml-opacity']='';}return this;},hide:function(animate,duration,onComplete,easing){this.setVisible(false,animate,duration,onComplete,easing);return this;},show:function(animate,duration,onComplete,easing){this.setVisible(true,animate,duration,onComplete,easing);return this;},addUnits:function(size){if(size===''||size=='auto'||typeof size=='undefined'){return size;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -