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;
}
}
}
;
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;
}
;