1 /* Prototype JavaScript framework
2 * (c) 2005 Sam Stephenson <sam@conio.net>
4 * Prototype is freely distributable under the terms of an MIT-style license.
6 * For details, see the Prototype web site: http://prototype.conio.net/
8 /*--------------------------------------------------------------------------*/
11 //note: this is a stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).
16 this.initialize
.apply(this, arguments
);
21 Object
.extend = function(destination
, source
) {
22 for (property
in source
) {
23 destination
[property
] = source
[property
];
28 Function
.prototype.bind = function(object
) {
31 return __method
.apply(object
, arguments
);
36 var elements
= new Array();
38 for (var i
= 0; i
< arguments
.length
; i
++) {
39 var element
= arguments
[i
];
40 if (typeof element
== 'string')
41 element
= document
.getElementById(element
);
43 if (arguments
.length
== 1)
46 elements
.push(element
);
52 //-------------------------
54 document
.getElementsByClassName = function(className
) {
55 var children
= document
.getElementsByTagName('*') || document
.all
;
56 var elements
= new Array();
58 for (var i
= 0; i
< children
.length
; i
++) {
59 var child
= children
[i
];
60 var classNames
= child
.className
.split(' ');
61 for (var j
= 0; j
< classNames
.length
; j
++) {
62 if (classNames
[j
] == className
) {
72 //-------------------------
74 if (!window
.Element
) {
75 var Element
= new Object();
78 Object
.extend(Element
, {
79 remove: function(element
) {
81 element
.parentNode
.removeChild(element
);
84 hasClassName: function(element
, className
) {
88 var a
= element
.className
.split(' ');
89 for (var i
= 0; i
< a
.length
; i
++) {
90 if (a
[i
] == className
)
96 addClassName: function(element
, className
) {
98 Element
.removeClassName(element
, className
);
99 element
.className
+= ' ' + className
;
102 removeClassName: function(element
, className
) {
103 element
= $(element
);
106 var newClassName
= '';
107 var a
= element
.className
.split(' ');
108 for (var i
= 0; i
< a
.length
; i
++) {
109 if (a
[i
] != className
) {
112 newClassName
+= a
[i
];
115 element
.className
= newClassName
;
118 // removes whitespace-only text node children
119 cleanWhitespace: function(element
) {
120 element
= $(element
);
121 for (var i
= 0; i
< element
.childNodes
.length
; i
++) {
122 var node
= element
.childNodes
[i
];
123 if (node
.nodeType
== 3 && !/\S/.test(node
.nodeValue
))
124 Element
.remove(node
);