📄 yui-ext-debug.js
字号:
c.width - leftSpace - b.width - (pad.right||0) );
this.setYConstraint(topSpace - (pad.top||0), c.height - topSpace - b.height - (pad.bottom||0) );
}
}
YAHOO.ext.util.MixedCollection = function(allowFunctions){
this.items = [];
this.keys = [];
this.events = {
'clear' : new YAHOO.util.CustomEvent('clear'),
'add' : new YAHOO.util.CustomEvent('add'),
'replace' : new YAHOO.util.CustomEvent('replace'),
'remove' : new YAHOO.util.CustomEvent('remove')
}
this.allowFunctions = allowFunctions === true;
};
YAHOO.extendX(YAHOO.ext.util.MixedCollection, YAHOO.ext.util.Observable, {
allowFunctions : false,
add : function(key, o){
if(arguments.length == 1){
o = arguments[0];
key = this.getKey(o);
}
this.items.push(o);
if(typeof key != 'undefined' && key != null){
this.items[key] = o;
this.keys.push(key);
}
this.fireEvent('add', this.items.length-1, o, key);
return o;
},
getKey : function(o){
return null;
},
replace : function(key, o){
if(arguments.length == 1){
o = arguments[0];
key = this.getKey(o);
}
if(typeof this.items[key] == 'undefined'){
return this.add(key, o);
}
var old = this.items[key];
if(typeof key == 'number'){ this.items[key] = o;
}else{
var index = this.indexOfKey(key);
this.items[index] = o;
this.items[key] = o;
}
this.fireEvent('replace', key, old, o);
return o;
},
addAll : function(objs){
if(arguments.length > 1 || objs instanceof Array){
var args = arguments.length > 1 ? arguments : objs;
for(var i = 0, len = args.length; i < len; i++){
this.add(args[i]);
}
}else{
for(var key in objs){
if(this.allowFunctions || typeof objs[key] != 'function'){
this.add(objs[key], key);
}
}
}
},
each : function(fn, scope){
for(var i = 0, len = this.items.length; i < len; i++){
fn.call(scope || window, this.items[i]);
}
},
eachKey : function(fn, scope){
for(var i = 0, len = this.keys.length; i < len; i++){
fn.call(scope || window, this.keys[i], this.items[i]);
}
},
find : function(fn, scope){
for(var i = 0, len = this.items.length; i < len; i++){
if(fn.call(scope || window, this.items[i])){
return this.items[i];
}
}
return null;
},
insert : function(index, key, o){
if(arguments.length == 2){
o = arguments[1];
key = this.getKey(o);
}
if(index >= this.items.length){
return this.add(o, key);
}
this.items.splice(index, 0, o);
if(typeof key != 'undefined' && key != null){
this.items[key] = o;
this.keys.splice(index, 0, key);
}
this.fireEvent('add', index, o, key);
return o;
},
remove : function(o){
var index = this.indexOf(o);
this.items.splice(index, 1);
if(typeof this.keys[index] != 'undefined'){
var key = this.keys[index];
this.keys.splice(index, 1);
delete this.items[key];
}
this.fireEvent('remove', o);
return o;
},
removeAt : function(index){
this.items.splice(index, 1);
var key = this.keys[index];
if(typeof key != 'undefined'){
this.keys.splice(index, 1);
delete this.items[key];
}
this.fireEvent('remove', o, key);
},
removeKey : function(key){
var o = this.items[key];
var index = this.indexOf(o);
this.items.splice(index, 1);
this.keys.splice(index, 1);
delete this.items[key];
this.fireEvent('remove', o, key);
},
getCount : function(){
return this.items.length;
},
indexOf : function(o){
if(!this.items.indexOf){
for(var i = 0, len = this.items.length; i < len; i++){
if(this.items[i] == o) return i;
}
return -1;
}else{
return this.items.indexOf(o);
}
},
indexOfKey : function(key){
if(!this.keys.indexOf){
for(var i = 0, len = this.keys.length; i < len; i++){
if(this.keys[i] == key) return i;
}
return -1;
}else{
return this.keys.indexOf(key);
}
},
item : function(key){
return this.items[key];
},
contains : function(o){
return this.indexOf(o) != -1;
},
containsKey : function(key){
return typeof this.items[key] != 'undefined';
},
clear : function(o){
this.items = [];
this.keys = [];
this.fireEvent('clear');
},
first : function(){
return this.items[0];
},
last : function(){
return this.items[this.items.length];
}
});
YAHOO.ext.util.MixedCollection.prototype.get = YAHOO.ext.util.MixedCollection.prototype.item;
YAHOO.ext.util.JSON = new function(){
var useHasOwn = {}.hasOwnProperty ? true : false;
var pad = function(n) {
return n < 10 ? '0' + n : n;
};
var m = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
};
var encodeString = function(s){
if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
var c = m[b];
if(c){
return c;
}
c = b.charCodeAt();
return '\\u00' +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
}
return '"' + s + '"';
};
var encodeArray = function(o){
var a = ['['], b, i, l = o.length, v;
for (i = 0; i < l; i += 1) {
v = o[i];
switch (typeof v) {
case 'undefined':
case 'function':
case 'unknown':
break;
default:
if (b) {
a.push(',');
}
a.push(v === null ? "null" : YAHOO.ext.util.JSON.encode(v));
b = true;
}
}
a.push(']');
return a.join('');
};
var encodeDate = function(o){
return '"' + o.getFullYear() + '-' +
pad(o.getMonth() + 1) + '-' +
pad(o.getDate()) + 'T' +
pad(o.getHours()) + ':' +
pad(o.getMinutes()) + ':' +
pad(o.getSeconds()) + '"';
};
this.encode = function(o){
if(typeof o == 'undefined' || o === null){
return 'null';
}else if(o instanceof Array){
return encodeArray(o);
}else if(o instanceof Date){
return encodeDate(o);
}else if(typeof o == 'string'){
return encodeString(o);
}else if(typeof o == 'number'){
return isFinite(o) ? String(o) : "null";
}else if(typeof o == 'boolean'){
return String(o);
}else {
var a = ['{'], b, i, v;
for (var i in o) {
if(!useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case 'undefined':
case 'function':
case 'unknown':
break;
default:
if(b){
a.push(',');
}
a.push(this.encode(i), ':',
v === null ? "null" : this.encode(v));
b = true;
}
}
}
a.push('}');
return a.join('');
}
};
this.decode = function(json){
return eval('(' + json + ')');
};
}();
YAHOO.ext.util.CSS = new function(){
var rules = null;
var toCamel = function(property) {
var convert = function(prop) {
var test = /(-[a-z])/i.exec(prop);
return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase());
};
while(property.indexOf('-') > -1) {
property = convert(property);
}
return property;
};
this.getRules = function(refreshCache){
if(rules == null || refreshCache){
rules = {};
var ds = document.styleSheets;
for(var i =0, len = ds.length; i < len; i++){
try{
var ss = ds[i];
var ssRules = ss.cssRules || ss.rules;
for(var j = ssRules.length-1; j >= 0; --j){
rules[ssRules[j].selectorText] = ssRules[j];
}
}catch(e){} }
}
return rules;
};
this.getRule = function(selector, refreshCache){
var rs = this.getRules(refreshCache);
if(!(selector instanceof Array)){
return rs[selector];
}
for(var i = 0; i < selector.length; i++){
if(rs[selector[i]]){
return rs[selector[i]];
}
}
return null;
};
this.updateRule = function(selector, property, value){
if(!(selector instanceof Array)){
var rule = this.getRule(selector);
if(rule){
rule.style[toCamel(property)] = value;
return true;
}
}else{
for(var i = 0; i < selector.length; i++){
if(this.updateRule(selector[i], property, value)){
return true;
}
}
}
return false;
};
this.apply = function(el, selector){
if(!(selector instanceof Array)){
var rule = this.getRule(selector);
if(rule){
var s = rule.style;
for(var key in s){
if(typeof s[key] != 'function'){
if(s[key] && String(s[key]).indexOf(':') < 0 && s[key] != 'false'){
try{el.style[key] = s[key];}catch(e){}
}
}
}
return true;
}
}else{
for(var i = 0; i < selector.length; i++){
if(this.apply(el, selector[i])){
return true;
}
}
}
return false;
};
this.applyFirst = function(el, id, selector){
var selectors = [
'#' + id + ' ' + selector,
selector
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -