!
解决方案 »
- Extjs4.x ,tree.getStore().load(); 重复加载多次的问题!!
- 哪位有endnote.gif,contract.gif,expand.gif等图片
- json的问题,应该是没有语法错误的,但ie6下一直报“缺少对象”错误
- FF中,如何输出选中范围的 HTML内容 ???
- 覆盖一个函数后如何还原?
- 实现滚动的问题?
- 可不可以使滚轴的拖杆始终是拖在最下面
- 两个相关联的SELECT的问题 在线等!!
- 请问现在还有不被拦截的弹窗代码吗?或者能躲过上网助手和tt,myie的
- 关于文件上载控件的疑难问题!!!请进!
- javascript两个参数无刷新相乘
- 求一正则表达式,在字符串匹配后面加上一段字符串
* Cloudgamer JavaScript Library v0.1
* Copyright (c) 2009 cloudgamer
* Blog : http : // cloudgamer.cnblogs.com /
* Date : 2009 - 10 - 15
*/var $$, $$B, $$A, $$F, $$D, $$E, $$S;(function()
{ var O, B, A, F, D, E, S;
/* Object */ O = function (id)
{
return "string" == typeof id ? document.getElementById(id) : id; }
; O.extend = function (destination, source)
{
for (var property in source)
{
destination[property] = source[property];
}
return destination;
}
; O.deepextend = function (destination, source)
{
for (var property in source)
{
var copy = source[property];
if ( destination === copy ) continue;
if ( typeof copy === "object" )
{
destination[property] = arguments.callee( destination[property] ||
{
}
, copy );
}
else
{
destination[property] = copy;
}
}
return destination;
}
;
/* Browser */ /* from youa */
B = (function(ua)
{
var b =
{
msie : / msie / .test(ua) && ! / opera / .test(ua),
opera : / opera / .test(ua),
safari : / webkit / .test(ua) && ! / chrome / .test(ua),
firefox : / firefox / .test(ua),
chrome : / chrome / .test(ua)
}
;
var vMark = "";
for (var i in b)
{
if (b[i])
{
vMark = "safari" == i ? "version" : i;
break; }
}
b.version = vMark && RegExp("(?:" + vMark + ")[\\/: ]([\\d.]+)").test(ua) ? RegExp.$1 : "0"; b.ie = b.msie;
b.ie6 = b.msie && parseInt(b.version) == 6;
b.ie7 = b.msie && parseInt(b.version) == 7;
b.ie8 = b.msie && parseInt(b.version) == 8; return b;
}
)(window.navigator.userAgent.toLowerCase());
/* Array */ A = function()
{ var ret =
{
isArray : function( obj )
{
return Object.prototype.toString.call(obj) === "[object Array]";
}
,
indexOf : function( array, elt, from )
{
if (array.indexOf)
{
return array.indexOf(elt);
}
else
{
var len = array.length;
from = isNaN(from) ? 0
: (from < 0) ? Math.ceil(from) + len : Math.floor(from); for ( ; from < len; from ++ )
{
if ( array[i] === elt ) return i; }
return - 1;
}
}
,
lastIndexOf : function( array, elt, from )
{
if (array.lastIndexOf)
{
return array.lastIndexOf(elt);
}
else
{
var len = array.length;
from = isNaN(from) || from >= len - 1 ? len - 1
: from < 0 ? Math.ceil(from) + len : Math.floor(from) for ( ; from > - 1; from -- )
{
if ( array[i] === elt ) return i; }
return - 1;
}
}
} function each( object, callback )
{
if ( undefined === object.length )
{
for ( var name in object )
{
if (false === callback( object[name], name, object ))
break;
}
}
else
{
for ( var i = 0, len = object.length; i < len;
i ++ )
{
if (false === callback( object[i], i, object ))
break;
}
}
}
; each(
{
forEach : function( object, callback, thisp )
{
each.call( thisp, object, function()
{
callback.apply(thisp, arguments); }
);
}
,
map : function( object, callback, thisp )
{
var ret = [];
each.call( thisp, object, function()
{
ret.push(callback.apply(thisp, arguments)); }
);
return ret;
}
,
filter : function( object, callback, thisp )
{
var ret = [];
each.call( thisp, object, function(item)
{
callback.apply(thisp, arguments) && ret.push(item);
}
);
return ret;
}
,
every : function( object, callback, thisp )
{
var ret = true;
each.call( thisp, object, function()
{
if ( ! callback.apply(thisp, arguments) )
{
ret = false;
return false; }
;
}
);
return ret; }
,
some : function( object, callback, thisp )
{
var ret = false;
each.call( thisp, object, function()
{
if ( callback.apply(thisp, arguments) )
{
ret = true;
return false; }
;
}
);
return ret;
}
}
, function(method, name)
{
ret[name] = function( object, callback, thisp )
{
var original = object[name];
if (original)
{
return original( callback, thisp );
}
else
{
return method( object, callback, thisp );
}
}
}
); return ret;
}
()
/* Function */ F = (function()
{
var slice = Array.prototype.slice;
return
{
bind : function( fun, thisp )
{
var args = slice.call(arguments, 2);
return function()
{
return fun.apply(thisp, args.concat(slice.call(arguments)));
}
}
,
bindAsEventListener : function( fun, thisp )
{
var args = slice.call(arguments, 2);
return function(event)
{
return fun.apply(thisp, [E.fixEvent(event)].concat(args));
}
}
}
;
}
)();
/* Dom */ D =
{
getScrollTop : function(node)
{
var doc = node ? node.ownerDocument : document;
return doc.documentElement.scrollTop || doc.body.scrollTop;
}
,
getScrollLeft : function(node)
{
var doc = node ? node.ownerDocument : document;
return doc.documentElement.scrollLeft || doc.body.scrollLeft;
}
,
contains : function(a, b)
{
return (this.contains = a.compareDocumentPosition
? function (a, b)
{
return ! ! (a.compareDocumentPosition(b) & 16); }
: function (a, b)
{
return a != b && a.contains(b); }
)(a, b);
}
,
rect : function(node)
{
var left = 0, top = 0, right = 0, bottom = 0;
// ie8的getBoundingClientRect获取不准确
if ( ! node.getBoundingClientRect || B.ie8 )
{
var n = node;
while (n)
{
left += n.offsetLeft, top += n.offsetTop;
n = n.offsetParent; }
;
right = left + node.offsetWidth;
bottom = top + node.offsetHeight;
}
else
{
var rect = node.getBoundingClientRect();
left = right = this.getScrollLeft(node);
top = bottom = this.getScrollTop(node);
left += rect.left;
right += rect.right;
top += rect.top;
bottom += rect.bottom;
}
;
return
{
"left" : left, "top" : top, "right" : right, "bottom" : bottom
}
;
}
,
clientRect : function(node)
{
var rect = this.rect(node), sLeft = this.getScrollLeft(node), sTop = this.getScrollTop(node);
rect.left -= sLeft;
rect.right -= sLeft;
rect.top -= sTop;
rect.bottom -= sTop;
return rect;
}
,
curStyle : function(elem)
{
return (this.curStyle = document.defaultView
? function (elem)
{
return document.defaultView.getComputedStyle(elem, null); }
: function (elem)
{
return elem.currentStyle; }
)(elem);
}
,
getStyle : function(elem, name)
{
return (this.getStyle = document.defaultView
? function (elem, name)
{
var style = document.defaultView.getComputedStyle(elem, null);
return name in style ? style[ name ] : style.getPropertyValue( name );
}
: function (elem, name)
{
var style = elem.currentStyle;
// 透明度 from youa
if (name == "opacity")
{
if ( /alpha\(opacity=(.*)\)/i.test(style.filter) )
{
var opacity = parseFloat(RegExp.$1);
return opacity ? opacity / 100 : 0;
}
return 1;
}
;