?? yui-ext-core.js
字號:
var range=el.ownerDocument.createRange();var frag;switch(where){case'beforebegin':range.setStartBefore(el);frag=range.createContextualFragment(html);el.parentNode.insertBefore(frag,el);return el.previousSibling;case'afterbegin':if(el.firstChild){range.setStartBefore(el.firstChild);}else{range.selectNodeContents(el);range.collapse(true);}frag=range.createContextualFragment(html);el.insertBefore(frag,el.firstChild);return el.firstChild;case'beforeend':if(el.lastChild){range.setStartAfter(el.lastChild);}else{range.selectNodeContents(el);range.collapse(false);}frag=range.createContextualFragment(html);el.appendChild(frag);return el.lastChild;case'afterend':range.setStartAfter(el);frag=range.createContextualFragment(html);el.parentNode.insertBefore(frag,el.nextSibling);return el.nextSibling;}throw'Illegal insertion point -> "'+where+'"';};this.insertBefore=function(el,o,returnElement){el=YAHOO.util.Dom.get(el);var newNode;if(this.useDom){newNode=createDom(o,null);el.parentNode.insertBefore(newNode,el);}else{var html=createHtml(o);newNode=this.insertHtml('beforeBegin',el,html);}return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;};this.insertAfter=function(el,o,returnElement){el=YAHOO.util.Dom.get(el);var newNode;if(this.useDom){newNode=createDom(o,null);el.parentNode.insertBefore(newNode,el.nextSibling);}else{var html=createHtml(o);newNode=this.insertHtml('afterEnd',el,html);}return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;};this.append=function(el,o,returnElement){el=YAHOO.util.Dom.get(el);var newNode;if(this.useDom){newNode=createDom(o,null);el.appendChild(newNode);}else{var html=createHtml(o);newNode=this.insertHtml('beforeEnd',el,html);}return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;};this.overwrite=function(el,o,returnElement){el=YAHOO.util.Dom.get(el);el.innerHTML=createHtml(o);return returnElement?YAHOO.ext.Element.get(el.firstChild,true):el.firstChild;};this.createTemplate=function(o){var html=createHtml(o);return new YAHOO.ext.DomHelper.Template(html);};}();YAHOO.ext.DomHelper.Template=function(html){this.html=html;};YAHOO.ext.DomHelper.Template.prototype={applyTemplate:function(values){if(this.compiled){return this.compiled(values);}var empty='';var fn=function(match,index){if(typeof values[index]!='undefined'){return values[index];}else{return empty;}}return this.html.replace(this.re,fn);},re:/\{(\w+)\}/g,compile: function(){
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);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -