📄 yui-ext-core-debug.js
字号:
for(var i = 0; i < len; ++i){
ce[i] = YAHOO.ext.Element.get(children[i], true);
}
return ce;
},
isBorderBox : function(){
if(typeof this.bbox == 'undefined'){
var el = this.dom;
var b = YAHOO.ext.util.Browser;
var strict = YAHOO.ext.Strict;
this.bbox = ((b.isIE && !strict && el.style.boxSizing != 'content-box') ||
(b.isGecko && YAHOO.util.Dom.getStyle(el, "-moz-box-sizing") == 'border-box') ||
(!b.isSafari && YAHOO.util.Dom.getStyle(el, "box-sizing") == 'border-box'));
}
return this.bbox;
},
getBox : function(contentBox, local){
var xy;
if(!local){
xy = this.getXY();
}else{
var left = parseInt(YAHOO.util.Dom.getStyle('left'), 10) || 0;
var top = parseInt(YAHOO.util.Dom.getStyle('top'), 10) || 0;
xy = [left, top];
}
var el = this.dom;
var w = el.offsetWidth;
var h = el.offsetHeight;
if(!contentBox){
return {x: xy[0], y: xy[1], width: w, height: h};
}else{
var l = this.getBorderWidth('l')+this.getPadding('l');
var r = this.getBorderWidth('r')+this.getPadding('r');
var t = this.getBorderWidth('t')+this.getPadding('t');
var b = this.getBorderWidth('b')+this.getPadding('b');
return {x: xy[0]+l, y: xy[1]+t, width: w-(l+r), height: h-(t+b)};
}
},
setBox : function(box, adjust, animate, duration, onComplete, easing){
var w = box.width, h = box.height;
if((adjust && !this.autoBoxAdjust) && !this.isBorderBox()){
w -= (this.getBorderWidth('lr') + this.getPadding('lr'));
h -= (this.getBorderWidth('tb') + this.getPadding('tb'));
}
this.setBounds(box.x, box.y, w, h, animate, duration, onComplete, easing);
return this;
},
repaint : function(){
var dom = this.dom;
YAHOO.util.Dom.addClass(dom, 'yui-ext-repaint');
setTimeout(function(){
YAHOO.util.Dom.removeClass(dom, 'yui-ext-repaint');
}, 1);
return this;
},
getMargins : function(side){
if(!side){
return {
top: parseInt(this.getStyle('margin-top'), 10) || 0,
left: parseInt(this.getStyle('margin-left'), 10) || 0,
bottom: parseInt(this.getStyle('margin-bottom'), 10) || 0,
right: parseInt(this.getStyle('margin-right'), 10) || 0
};
}else{
return this.addStyles(side, YAHOO.ext.Element.margins);
}
},
addStyles : function(sides, styles){
var val = 0;
for(var i = 0, len = sides.length; i < len; i++){
var w = parseInt(this.getStyle(styles[sides.charAt(i)]), 10);
if(!isNaN(w)) val += w;
}
return val;
},
createProxy : function(config, renderTo, matchBox){
if(renderTo){
renderTo = YAHOO.util.Dom.get(renderTo);
}else{
renderTo = document.body;
}
config = typeof config == 'object' ?
config : {tag : 'div', cls: config};
var proxy = YAHOO.ext.DomHelper.append(renderTo, config, true);
if(matchBox){
proxy.setBox(this.getBox());
}
return proxy;
},
createShim : function(){
var config = {
tag : 'iframe',
frameBorder:'no',
cls: 'yiframe-shim',
style: 'position:absolute;visibility:hidden;left:0;top:0;overflow:hidden;',
src: YAHOO.ext.SSL_SECURE_URL
};
var shim = YAHOO.ext.DomHelper.append(this.dom.parentNode, config, true);
shim.setBox(this.getBox());
return shim;
},
remove : function(){
this.dom.parentNode.removeChild(this.dom);
delete YAHOO.ext.Element.cache[this.dom.id];
},
addClassOnOver : function(className){
this.on('mouseover', function(){
this.addClass(className);
}, this, true);
this.on('mouseout', function(){
this.removeClass(className);
}, this, true);
return this;
},
swallowEvent : function(eventName, preventDefault){
var fn = function(e){
e.stopPropagation();
if(preventDefault){
e.preventDefault();
}
};
this.mon(eventName, fn);
return this;
},
fitToParent : function(monitorResize){
var p = getEl(this.dom.parentNode, true);
p.beginMeasure(); var box = p.getBox(true, true);
p.endMeasure();
this.setSize(box.width, box.height);
if(monitorResize === true){
YAHOO.ext.EventManager.onWindowResize(this.fitToParent, this, true);
}
return this;
},
getNextSibling : function(){
var n = this.dom.nextSibling;
while(n && n.nodeType != 1){
n = n.nextSibling;
}
return n;
},
getPrevSibling : function(){
var n = this.dom.previousSibling;
while(n && n.nodeType != 1){
n = n.previousSibling;
}
return n;
},
appendChild: function(el){
el = getEl(el);
el.appendTo(this);
return this;
},
createChild: function(config, insertBefore){
var c;
if(insertBefore){
c = YAHOO.ext.DomHelper.insertBefore(insertBefore, config, true);
}else{
c = YAHOO.ext.DomHelper.append(this.dom, config, true);
}
return c;
},
appendTo: function(el){
var node = getEl(el).dom;
node.appendChild(this.dom);
return this;
},
insertBefore: function(el){
var node = getEl(el).dom;
node.parentNode.insertBefore(this.dom, node);
return this;
},
insertAfter: function(el){
var node = getEl(el).dom;
node.parentNode.insertBefore(this.dom, node.nextSibling);
return this;
},
wrap: function(config){
if(!config){
config = {tag: 'div'};
}
var newEl = YAHOO.ext.DomHelper.insertBefore(this.dom, config, true);
newEl.dom.appendChild(this.dom);
return newEl;
},
replace: function(el){
el = getEl(el);
this.insertBefore(el);
el.remove();
return this;
},
insertHtml : function(where, html){
YAHOO.ext.DomHelper.insertHtml(where, this.dom, html);
return this;
},
set : function(o){
var el = this.dom;
var useSet = el.setAttribute ? true : false;
for(var attr in o){
if(attr == 'style' || typeof o[attr] == 'function') continue;
if(attr=='cls'){
el.className = o['cls'];
}else{
if(useSet) el.setAttribute(attr, o[attr]);
else el[attr] = o[attr];
}
}
YAHOO.ext.DomHelper.applyStyles(el, o.style);
return this;
},
addKeyListener : function(key, fn, scope){
var config;
if(typeof key != 'object' || key instanceof Array){
config = {
key: key,
fn: fn,
scope: scope
};
}else{
config = {
key : key.key,
shift : key.shift,
ctrl : key.ctrl,
alt : key.alt,
fn: fn,
scope: scope
};
}
var map = new YAHOO.ext.KeyMap(this, config);
return map;
},
addKeyMap : function(config){
return new YAHOO.ext.KeyMap(this, config);
}
};
YAHOO.ext.Element.prototype.autoBoxAdjust = true;
YAHOO.ext.Element.prototype.autoDisplayMode = true;
YAHOO.ext.Element.unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;
YAHOO.ext.Element.VISIBILITY = 1;
YAHOO.ext.Element.DISPLAY = 2;
YAHOO.ext.Element.blockElements = /^(?:address|blockquote|center|dir|div|dl|fieldset|form|h\d|hr|isindex|menu|ol|ul|p|pre|table|dd|dt|li|tbody|tr|td|thead|tfoot|iframe)$/i;
YAHOO.ext.Element.borders = {l: 'border-left-width', r: 'border-right-width', t: 'border-top-width', b: 'border-bottom-width'};
YAHOO.ext.Element.paddings = {l: 'padding-left', r: 'padding-right', t: 'padding-top', b: 'padding-bottom'};
YAHOO.ext.Element.margins = {l: 'margin-left', r: 'margin-right', t: 'margin-top', b: 'margin-bottom'};
YAHOO.ext.Element.createStopHandler = function(stopPropagation, handler, scope, override){
return function(e){
if(e){
if(stopPropagation){
YAHOO.util.Event.stopEvent(e);
}else {
YAHOO.util.Event.preventDefault(e);
}
}
handler.call(override && scope ? scope : window, e, scope);
};
};
YAHOO.ext.Element.cache = {};
YAHOO.ext.Element.get = function(el, autoGenerateId){
if(!el){ return null; }
autoGenerateId = true; if(el instanceof YAHOO.ext.Element){
el.dom = YAHOO.util.Dom.get(el.id); YAHOO.ext.Element.cache[el.id] = el; return el;
}else if(el.isComposite){
return el;
}else if(el instanceof Array){
return YAHOO.ext.Element.select(el);
}else if(el === document){
if(!YAHOO.ext.Element.cache['__ydocument']){
var docEl = function(){};
docEl.prototype = YAHOO.ext.Element.prototype;
var o = new docEl();
o.dom = document;
YAHOO.ext.Element.cache['__ydocument'] = o;
}
return YAHOO.ext.Element.cache['__ydocument'];
}
var key = el;
if(typeof el != 'string'){ if(!el.id && !autoGenerateId){ return null; }
YAHOO.util.Dom.generateId(el, 'elgen-');
key = el.id;
}
var element = YAHOO.ext.Element.cache[key];
if(!element){
element = new YAHOO.ext.Element(key);
if(!element.dom) return null;
YAHOO.ext.Element.cache[key] = element;
}else{
element.dom = YAHOO.util.Dom.get(key);
}
return element;
};
var getEl = YAHOO.ext.Element.get;
YAHOO.util.Event.addListener(window, 'unload', function(){
YAHOO.ext.Element.cache = null;
});
YAHOO.ext.CompositeElement = function(els){
this.elements = [];
this.addElements(els);
};
YAHOO.ext.CompositeElement.prototype = {
isComposite: true,
addElements : function(els){
if(!els) return this;
var yels = this.elements;
var index = yels.length-1;
for(var i = 0, len = els.length; i < len; i++) {
yels[++index] = getEl(els[i], true);
}
return this;
},
invoke : function(fn, args){
var els = this.elements;
for(var i = 0, len = els.length; i < len; i++) {
YAHOO.ext.Element.prototype[fn].apply(els[i], args);
}
return this;
},
add : function(els){
if(typeof els == 'string'){
this.addElements(YAHOO.ext.Element.selectorFunction(string));
}else if(els instanceof Array){
this.addElements(els);
}else{
this.addElements([els]);
}
return this;
},
each : function(fn, scope){
var els = this.elements;
for(var i = 0, len = els.length; i < len; i++){
fn.call(scope || els[i], els[i], this, i);
}
return this;
}
};
YAHOO.ext.CompositeElementLite = function(els){
YAHOO.ext.CompositeElementLite.superclass.constructor.call(this, els);
this.el = YAHOO.ext.Element.get(this.elements[0], true);
};
YAHOO.extendX(YAHOO.ext.CompositeElementLite, YAHOO.ext.CompositeElement, {
addElements : function(els){
if(els){
this.elemen
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -