|
0
|
1 |
/* |
|
|
2 |
Copyright (c) 2009, Yahoo! Inc. All rights reserved. |
|
|
3 |
Code licensed under the BSD License: |
|
|
4 |
http://developer.yahoo.net/yui/license.txt |
|
|
5 |
version: 3.0.0b1 |
|
|
6 |
build: 1163 |
|
|
7 |
*/ |
|
|
8 |
YUI.add('dom-base', function(Y) { |
|
|
9 |
|
|
|
10 |
(function(Y) { |
|
|
11 |
/** |
|
|
12 |
* The DOM utility provides a cross-browser abtraction layer |
|
|
13 |
* normalizing DOM tasks, and adds extra helper functionality |
|
|
14 |
* for other common tasks. |
|
|
15 |
* @module dom |
|
|
16 |
* @submodule dom-base |
|
|
17 |
* |
|
|
18 |
*/ |
|
|
19 |
|
|
|
20 |
/** |
|
|
21 |
* Provides DOM helper methods. |
|
|
22 |
* @class DOM |
|
|
23 |
* |
|
|
24 |
*/ |
|
|
25 |
var NODE_TYPE = 'nodeType', |
|
|
26 |
OWNER_DOCUMENT = 'ownerDocument', |
|
|
27 |
DOCUMENT_ELEMENT = 'documentElement', |
|
|
28 |
DEFAULT_VIEW = 'defaultView', |
|
|
29 |
PARENT_WINDOW = 'parentWindow', |
|
|
30 |
TAG_NAME = 'tagName', |
|
|
31 |
PARENT_NODE = 'parentNode', |
|
|
32 |
FIRST_CHILD = 'firstChild', |
|
|
33 |
LAST_CHILD = 'lastChild', |
|
|
34 |
PREVIOUS_SIBLING = 'previousSibling', |
|
|
35 |
NEXT_SIBLING = 'nextSibling', |
|
|
36 |
CONTAINS = 'contains', |
|
|
37 |
COMPARE_DOCUMENT_POSITION = 'compareDocumentPosition', |
|
|
38 |
|
|
|
39 |
re_tag = /<([a-z]+)/i; |
|
|
40 |
|
|
|
41 |
Y.DOM = { |
|
|
42 |
/** |
|
|
43 |
* Returns the HTMLElement with the given ID (Wrapper for document.getElementById). |
|
|
44 |
* @method byId |
|
|
45 |
* @param {String} id the id attribute |
|
|
46 |
* @param {Object} doc optional The document to search. Defaults to current document |
|
|
47 |
* @return {HTMLElement | null} The HTMLElement with the id, or null if none found. |
|
|
48 |
*/ |
|
|
49 |
byId: function(id, doc) { |
|
|
50 |
doc = doc || Y.config.doc; |
|
|
51 |
// TODO: IE Name |
|
|
52 |
return doc.getElementById(id); |
|
|
53 |
}, |
|
|
54 |
|
|
|
55 |
/** |
|
|
56 |
* Returns the text content of the HTMLElement. |
|
|
57 |
* @method getText |
|
|
58 |
* @param {HTMLElement} element The html element. |
|
|
59 |
* @return {String} The text content of the element (includes text of any descending elements). |
|
|
60 |
*/ |
|
|
61 |
getText: (document.documentElement.textContent !== undefined) ? |
|
|
62 |
function(element) { |
|
|
63 |
var ret = ''; |
|
|
64 |
if (element) { |
|
|
65 |
ret = element.textContent; |
|
|
66 |
} |
|
|
67 |
return ret || ''; |
|
|
68 |
} : function(element) { |
|
|
69 |
var ret = ''; |
|
|
70 |
if (element) { |
|
|
71 |
ret = element.innerText; |
|
|
72 |
} |
|
|
73 |
return ret || ''; |
|
|
74 |
}, |
|
|
75 |
|
|
|
76 |
/** |
|
|
77 |
* Sets the text content of the HTMLElement. |
|
|
78 |
* @method setText |
|
|
79 |
* @param {HTMLElement} element The html element. |
|
|
80 |
* @param {String} content The content to add. |
|
|
81 |
*/ |
|
|
82 |
setText: (document.documentElement.textContent !== undefined) ? |
|
|
83 |
function(element, content) { |
|
|
84 |
if (element) { |
|
|
85 |
element.textContent = content; |
|
|
86 |
} |
|
|
87 |
} : function(element, content) { |
|
|
88 |
if (element) { |
|
|
89 |
element.innerText = content; |
|
|
90 |
} |
|
|
91 |
}, |
|
|
92 |
|
|
|
93 |
// TODO: pull out sugar (rely on _childBy, byAxis, etc)? |
|
|
94 |
/* |
|
|
95 |
* Finds the firstChild of the given HTMLElement. |
|
|
96 |
* @method firstChild |
|
|
97 |
* @deprecated Use _childBy |
|
|
98 |
* @param {HTMLElement} element The html element. |
|
|
99 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
100 |
* The optional function is passed the current HTMLElement being tested as its only argument. |
|
|
101 |
* If no function is given, the first found is returned. |
|
|
102 |
* @return {HTMLElement | null} The first matching child html element. |
|
|
103 |
*/ |
|
|
104 |
firstChild: function(element, fn) { |
|
|
105 |
return Y.DOM._childBy(element, null, fn); |
|
|
106 |
}, |
|
|
107 |
|
|
|
108 |
// @deprecated Use _childBy |
|
|
109 |
firstChildByTag: function(element, tag, fn) { |
|
|
110 |
return Y.DOM._childBy(element, tag, fn); |
|
|
111 |
}, |
|
|
112 |
|
|
|
113 |
/* |
|
|
114 |
* Finds the lastChild of the given HTMLElement. |
|
|
115 |
* @method lastChild |
|
|
116 |
* @deprecated Use _childBy |
|
|
117 |
* @param {HTMLElement} element The html element. |
|
|
118 |
* @param {String} tag The tag to search for. |
|
|
119 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
120 |
* The optional function is passed the current HTMLElement being tested as its only argument. |
|
|
121 |
* If no function is given, the first found is returned. |
|
|
122 |
* @return {HTMLElement | null} The first matching child html element. |
|
|
123 |
*/ |
|
|
124 |
lastChild: function(element, fn) { |
|
|
125 |
return Y.DOM._childBy(element, null, fn, true); |
|
|
126 |
}, |
|
|
127 |
|
|
|
128 |
// @deprecated Use _childBy |
|
|
129 |
lastChildByTag: function(element, tag, fn) { |
|
|
130 |
return Y.DOM._childBy(element, tag, fn, true); |
|
|
131 |
}, |
|
|
132 |
|
|
|
133 |
/* |
|
|
134 |
* Finds all HTMLElement childNodes matching the given tag. |
|
|
135 |
* @method childrenByTag |
|
|
136 |
* @deprecated Use Selector |
|
|
137 |
* @param {HTMLElement} element The html element. |
|
|
138 |
* @param {String} tag The tag to search for. |
|
|
139 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
140 |
* The optional function is passed the current HTMLElement being tested as its only argument. |
|
|
141 |
* If no function is given, all children with the given tag are collected. |
|
|
142 |
* @return {Array} The collection of child elements. |
|
|
143 |
* TODO: Webkit children.tags() returns grandchildren |
|
|
144 |
*/ |
|
|
145 |
_childrenByTag: function() { |
|
|
146 |
if (document[DOCUMENT_ELEMENT].children) { |
|
|
147 |
return function(element, tag, fn, toArray) { // TODO: keep toArray option? |
|
|
148 |
tag = (tag && tag !== '*') ? tag.toUpperCase() : null; |
|
|
149 |
var elements = [], |
|
|
150 |
wrapFn = fn; |
|
|
151 |
if (element) { |
|
|
152 |
if (tag && !Y.UA.webkit) { // children.tags() broken in safari |
|
|
153 |
elements = element.children.tags(tag); |
|
|
154 |
} else { |
|
|
155 |
elements = element.children; |
|
|
156 |
if (tag) { |
|
|
157 |
wrapFn = function(el) { |
|
|
158 |
return el[TAG_NAME].toUpperCase() === tag && (!fn || fn(el)); |
|
|
159 |
}; |
|
|
160 |
} |
|
|
161 |
} |
|
|
162 |
|
|
|
163 |
elements = Y.DOM.filterElementsBy(elements, wrapFn); |
|
|
164 |
} |
|
|
165 |
|
|
|
166 |
return elements; |
|
|
167 |
}; |
|
|
168 |
} else { |
|
|
169 |
return function(element, tag, fn) { |
|
|
170 |
tag = (tag && tag !== '*') ? tag.toUpperCase() : null; |
|
|
171 |
var elements = [], |
|
|
172 |
wrapFn = fn; |
|
|
173 |
|
|
|
174 |
if (element) { |
|
|
175 |
elements = element.childNodes; |
|
|
176 |
if (tag) { // wrap fn and add tag test TODO: allow tag in filterElementsBy? |
|
|
177 |
wrapFn = function(el) { |
|
|
178 |
return el[TAG_NAME].toUpperCase() === tag && (!fn || fn(el)); |
|
|
179 |
}; |
|
|
180 |
} |
|
|
181 |
|
|
|
182 |
elements = Y.DOM.filterElementsBy(elements, wrapFn); |
|
|
183 |
} |
|
|
184 |
return elements; |
|
|
185 |
}; |
|
|
186 |
} |
|
|
187 |
}(), |
|
|
188 |
|
|
|
189 |
/* |
|
|
190 |
* Finds all HTMLElement childNodes. |
|
|
191 |
* @method children |
|
|
192 |
* @deprecated Use Selector |
|
|
193 |
* @param {HTMLElement} element The html element. |
|
|
194 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
195 |
* The optional function is passed the current HTMLElement being tested as its only argument. |
|
|
196 |
* If no function is given, all children are collected. |
|
|
197 |
* @return {Array} The collection of child elements. |
|
|
198 |
*/ |
|
|
199 |
children: function(element, fn) { |
|
|
200 |
return Y.DOM._childrenByTag(element, null, fn); |
|
|
201 |
}, |
|
|
202 |
|
|
|
203 |
/* |
|
|
204 |
* Finds the previous sibling of the element. |
|
|
205 |
* @method previous |
|
|
206 |
* @deprecated Use elementByAxis |
|
|
207 |
* @param {HTMLElement} element The html element. |
|
|
208 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
209 |
* The optional function is passed the current DOM node being tested as its only argument. |
|
|
210 |
* If no function is given, the first sibling is returned. |
|
|
211 |
* @param {Boolean} all optional Whether all node types should be scanned, or just element nodes. |
|
|
212 |
* @return {HTMLElement | null} The matching DOM node or null if none found. |
|
|
213 |
*/ |
|
|
214 |
previous: function(element, fn, all) { |
|
|
215 |
return Y.DOM.elementByAxis(element, PREVIOUS_SIBLING, fn, all); |
|
|
216 |
}, |
|
|
217 |
|
|
|
218 |
/* |
|
|
219 |
* Finds the next sibling of the element. |
|
|
220 |
* @method next |
|
|
221 |
* @deprecated Use elementByAxis |
|
|
222 |
* @param {HTMLElement} element The html element. |
|
|
223 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
224 |
* The optional function is passed the current DOM node being tested as its only argument. |
|
|
225 |
* If no function is given, the first sibling is returned. |
|
|
226 |
* @param {Boolean} all optional Whether all node types should be scanned, or just element nodes. |
|
|
227 |
* @return {HTMLElement | null} The matching DOM node or null if none found. |
|
|
228 |
*/ |
|
|
229 |
next: function(element, fn, all) { |
|
|
230 |
return Y.DOM.elementByAxis(element, NEXT_SIBLING, fn, all); |
|
|
231 |
}, |
|
|
232 |
|
|
|
233 |
/* |
|
|
234 |
* Finds the ancestor of the element. |
|
|
235 |
* @method ancestor |
|
|
236 |
* @deprecated Use elementByAxis |
|
|
237 |
* @param {HTMLElement} element The html element. |
|
|
238 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
239 |
* The optional function is passed the current DOM node being tested as its only argument. |
|
|
240 |
* If no function is given, the parentNode is returned. |
|
|
241 |
* @param {Boolean} all optional Whether all node types should be scanned, or just element nodes. |
|
|
242 |
* @return {HTMLElement | null} The matching DOM node or null if none found. |
|
|
243 |
*/ |
|
|
244 |
// TODO: optional stopAt node? |
|
|
245 |
ancestor: function(element, fn, all) { |
|
|
246 |
return Y.DOM.elementByAxis(element, PARENT_NODE, fn, all); |
|
|
247 |
}, |
|
|
248 |
|
|
|
249 |
/** |
|
|
250 |
* Searches the element by the given axis for the first matching element. |
|
|
251 |
* @method elementByAxis |
|
|
252 |
* @param {HTMLElement} element The html element. |
|
|
253 |
* @param {String} axis The axis to search (parentNode, nextSibling, previousSibling). |
|
|
254 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
255 |
* @param {Boolean} all optional Whether all node types should be returned, or just element nodes. |
|
|
256 |
* The optional function is passed the current HTMLElement being tested as its only argument. |
|
|
257 |
* If no function is given, the first element is returned. |
|
|
258 |
* @return {HTMLElement | null} The matching element or null if none found. |
|
|
259 |
*/ |
|
|
260 |
elementByAxis: function(element, axis, fn, all) { |
|
|
261 |
while (element && (element = element[axis])) { // NOTE: assignment |
|
|
262 |
if ( (all || element[TAG_NAME]) && (!fn || fn(element)) ) { |
|
|
263 |
return element; |
|
|
264 |
} |
|
|
265 |
} |
|
|
266 |
return null; |
|
|
267 |
}, |
|
|
268 |
|
|
|
269 |
/* |
|
|
270 |
* Finds all elements with the given tag. |
|
|
271 |
* @method byTag |
|
|
272 |
* @deprecated Use Selector |
|
|
273 |
* @param {String} tag The tag being search for. |
|
|
274 |
* @param {HTMLElement} root optional An optional root element to start from. |
|
|
275 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
276 |
* The optional function is passed the current HTMLElement being tested as its only argument. |
|
|
277 |
* If no function is given, all elements with the given tag are returned. |
|
|
278 |
* @return {Array} The collection of matching elements. |
|
|
279 |
*/ |
|
|
280 |
byTag: function(tag, root, fn) { |
|
|
281 |
root = root || Y.config.doc; |
|
|
282 |
|
|
|
283 |
var elements = root.getElementsByTagName(tag), |
|
|
284 |
retNodes = [], |
|
|
285 |
i, len; |
|
|
286 |
|
|
|
287 |
for (i = 0, len = elements.length; i < len; ++i) { |
|
|
288 |
if ( !fn || fn(elements[i]) ) { |
|
|
289 |
retNodes[retNodes.length] = elements[i]; |
|
|
290 |
} |
|
|
291 |
} |
|
|
292 |
return retNodes; |
|
|
293 |
}, |
|
|
294 |
|
|
|
295 |
/* |
|
|
296 |
* Finds the first element with the given tag. |
|
|
297 |
* @method firstByTag |
|
|
298 |
* @deprecated Use Selector |
|
|
299 |
* @param {String} tag The tag being search for. |
|
|
300 |
* @param {HTMLElement} root optional An optional root element to start from. |
|
|
301 |
* @param {Function} fn optional An optional boolean test to apply. |
|
|
302 |
* The optional function is passed the current HTMLElement being tested as its only argument. |
|
|
303 |
* If no function is given, the first match is returned. |
|
|
304 |
* @return {HTMLElement} The matching element. |
|
|
305 |
*/ |
|
|
306 |
firstByTag: function(tag, root, fn) { |
|
|
307 |
root = root || Y.config.doc; |
|
|
308 |
|
|
|
309 |
var elements = root.getElementsByTagName(tag), |
|
|
310 |
ret = null, |
|
|
311 |
i, len; |
|
|
312 |
|
|
|
313 |
for (i = 0, len = elements.length; i < len; ++i) { |
|
|
314 |
if ( !fn || fn(elements[i]) ) { |
|
|
315 |
ret = elements[i]; |
|
|
316 |
break; |
|
|
317 |
} |
|
|
318 |
} |
|
|
319 |
return ret; |
|
|
320 |
}, |
|
|
321 |
|
|
|
322 |
/* |
|
|
323 |
* Filters a collection of HTMLElements by the given attributes. |
|
|
324 |
* @method filterElementsBy |
|
|
325 |
* @param {Array} elements The collection of HTMLElements to filter. |
|
|
326 |
* @param {Function} fn A boolean test to apply. |
|
|
327 |
* The function is passed the current HTMLElement being tested as its only argument. |
|
|
328 |
* If no function is given, all HTMLElements are kept. |
|
|
329 |
* @return {Array} The filtered collection of HTMLElements. |
|
|
330 |
*/ |
|
|
331 |
filterElementsBy: function(elements, fn, firstOnly) { |
|
|
332 |
var ret = (firstOnly) ? null : [], |
|
|
333 |
i, len; |
|
|
334 |
for (i = 0, len = elements.length; i < len; ++i) { |
|
|
335 |
if (elements[i][TAG_NAME] && (!fn || fn(elements[i]))) { |
|
|
336 |
if (firstOnly) { |
|
|
337 |
ret = elements[i]; |
|
|
338 |
break; |
|
|
339 |
} else { |
|
|
340 |
ret[ret.length] = elements[i]; |
|
|
341 |
} |
|
|
342 |
} |
|
|
343 |
} |
|
|
344 |
|
|
|
345 |
return ret; |
|
|
346 |
}, |
|
|
347 |
|
|
|
348 |
/** |
|
|
349 |
* Determines whether or not one HTMLElement is or contains another HTMLElement. |
|
|
350 |
* @method contains |
|
|
351 |
* @param {HTMLElement} element The containing html element. |
|
|
352 |
* @param {HTMLElement} needle The html element that may be contained. |
|
|
353 |
* @return {Boolean} Whether or not the element is or contains the needle. |
|
|
354 |
*/ |
|
|
355 |
contains: function(element, needle) { |
|
|
356 |
var ret = false; |
|
|
357 |
|
|
|
358 |
if ( !needle || !element || !needle[NODE_TYPE] || !element[NODE_TYPE]) { |
|
|
359 |
ret = false; |
|
|
360 |
} else if (element[CONTAINS]) { |
|
|
361 |
if (Y.UA.opera || needle[NODE_TYPE] === 1) { // IE & SAF contains fail if needle not an ELEMENT_NODE |
|
|
362 |
ret = element[CONTAINS](needle); |
|
|
363 |
} else { |
|
|
364 |
ret = Y.DOM._bruteContains(element, needle); |
|
|
365 |
} |
|
|
366 |
} else if (element[COMPARE_DOCUMENT_POSITION]) { // gecko |
|
|
367 |
if (element === needle || !!(element[COMPARE_DOCUMENT_POSITION](needle) & 16)) { |
|
|
368 |
ret = true; |
|
|
369 |
} |
|
|
370 |
} |
|
|
371 |
|
|
|
372 |
return ret; |
|
|
373 |
}, |
|
|
374 |
|
|
|
375 |
/** |
|
|
376 |
* Determines whether or not the HTMLElement is part of the document. |
|
|
377 |
* @method inDoc |
|
|
378 |
* @param {HTMLElement} element The containing html element. |
|
|
379 |
* @param {HTMLElement} doc optional The document to check. |
|
|
380 |
* @return {Boolean} Whether or not the element is attached to the document. |
|
|
381 |
*/ |
|
|
382 |
inDoc: function(element, doc) { |
|
|
383 |
doc = doc || element[OWNER_DOCUMENT]; |
|
|
384 |
var id = element.id; |
|
|
385 |
if (!id) { // TODO: remove when done? |
|
|
386 |
id = element.id = Y.guid(); |
|
|
387 |
} |
|
|
388 |
|
|
|
389 |
return !! (doc.getElementById(id)); |
|
|
390 |
}, |
|
|
391 |
|
|
|
392 |
/** |
|
|
393 |
* Inserts the new node as the previous sibling of the reference node |
|
|
394 |
* @method insertBefore |
|
|
395 |
* @param {String | HTMLElement} newNode The node to be inserted |
|
|
396 |
* @param {String | HTMLElement} referenceNode The node to insert the new node before |
|
|
397 |
* @return {HTMLElement} The node that was inserted (or null if insert fails) |
|
|
398 |
*/ |
|
|
399 |
insertBefore: function(newNode, referenceNode) { |
|
|
400 |
var ret = null, |
|
|
401 |
parent; |
|
|
402 |
if (newNode && referenceNode && (parent = referenceNode.parentNode)) { // NOTE: assignment |
|
|
403 |
if (typeof newNode === 'string') { |
|
|
404 |
newNode = Y.DOM.create(newNode); |
|
|
405 |
} |
|
|
406 |
ret = parent.insertBefore(newNode, referenceNode); |
|
|
407 |
} else { |
|
|
408 |
} |
|
|
409 |
return ret; |
|
|
410 |
}, |
|
|
411 |
|
|
|
412 |
/** |
|
|
413 |
* Inserts the new node as the next sibling of the reference node |
|
|
414 |
* @method insertAfter |
|
|
415 |
* @param {String | HTMLElement} newNode The node to be inserted |
|
|
416 |
* @param {String | HTMLElement} referenceNode The node to insert the new node after |
|
|
417 |
* @return {HTMLElement} The node that was inserted (or null if insert fails) |
|
|
418 |
*/ |
|
|
419 |
insertAfter: function(newNode, referenceNode) { |
|
|
420 |
if (!newNode || !referenceNode || !referenceNode[PARENT_NODE]) { |
|
|
421 |
return null; |
|
|
422 |
} |
|
|
423 |
|
|
|
424 |
if (typeof newNode === 'string') { |
|
|
425 |
newNode = Y.DOM.create(newNode); |
|
|
426 |
} |
|
|
427 |
|
|
|
428 |
if (referenceNode[NEXT_SIBLING]) { |
|
|
429 |
return referenceNode[PARENT_NODE].insertBefore(newNode, referenceNode[NEXT_SIBLING]); |
|
|
430 |
} else { |
|
|
431 |
return referenceNode[PARENT_NODE].appendChild(newNode); |
|
|
432 |
} |
|
|
433 |
}, |
|
|
434 |
|
|
|
435 |
/** |
|
|
436 |
* Creates a new dom node using the provided markup string. |
|
|
437 |
* @method create |
|
|
438 |
* @param {String} html The markup used to create the element |
|
|
439 |
* @param {HTMLDocument} doc An optional document context |
|
|
440 |
*/ |
|
|
441 |
create: function(html, doc) { |
|
|
442 |
html = Y.Lang.trim(html); // match IE which trims whitespace from innerHTML |
|
|
443 |
if (!doc && Y.DOM._cloneCache[html]) { |
|
|
444 |
return Y.DOM._cloneCache[html].cloneNode(true); // NOTE: return |
|
|
445 |
} |
|
|
446 |
|
|
|
447 |
doc = doc || Y.config.doc; |
|
|
448 |
var m = re_tag.exec(html), |
|
|
449 |
create = Y.DOM._create, |
|
|
450 |
custom = Y.DOM.creators, |
|
|
451 |
ret = null, |
|
|
452 |
tag, nodes; |
|
|
453 |
|
|
|
454 |
if (m && custom[m[1]]) { |
|
|
455 |
if (typeof custom[m[1]] === 'function') { |
|
|
456 |
create = custom[m[1]]; |
|
|
457 |
} else { |
|
|
458 |
tag = custom[m[1]]; |
|
|
459 |
} |
|
|
460 |
} |
|
|
461 |
|
|
|
462 |
nodes = create(html, doc, tag).childNodes; |
|
|
463 |
|
|
|
464 |
if (nodes.length === 1) { // return single node, breaking parentNode ref from "fragment" |
|
|
465 |
ret = nodes[0].parentNode.removeChild(nodes[0]); |
|
|
466 |
} else { // return multiple nodes as a fragment |
|
|
467 |
ret = doc.createDocumentFragment(); |
|
|
468 |
while (nodes.length) { |
|
|
469 |
ret.appendChild(nodes[0]); |
|
|
470 |
} |
|
|
471 |
} |
|
|
472 |
|
|
|
473 |
Y.DOM._cloneCache[html] = ret.cloneNode(true); |
|
|
474 |
return ret; |
|
|
475 |
}, |
|
|
476 |
|
|
|
477 |
CUSTOM_ATTRIBUTES: (!document.documentElement.hasAttribute) ? { // IE < 8 |
|
|
478 |
'for': 'htmlFor', |
|
|
479 |
'class': 'className' |
|
|
480 |
} : { // w3c |
|
|
481 |
'htmlFor': 'for', |
|
|
482 |
'className': 'class' |
|
|
483 |
}, |
|
|
484 |
|
|
|
485 |
/** |
|
|
486 |
* Provides a normalized attribute interface. |
|
|
487 |
* @method setAttibute |
|
|
488 |
* @param {String | HTMLElement} el The target element for the attribute. |
|
|
489 |
* @param {String} attr The attribute to set. |
|
|
490 |
* @param {String} val The value of the attribute. |
|
|
491 |
*/ |
|
|
492 |
setAttribute: function(el, attr, val) { |
|
|
493 |
if (el && el.setAttribute) { |
|
|
494 |
attr = Y.DOM.CUSTOM_ATTRIBUTES[attr] || attr; |
|
|
495 |
el.setAttribute(attr, val); |
|
|
496 |
} |
|
|
497 |
}, |
|
|
498 |
|
|
|
499 |
|
|
|
500 |
/** |
|
|
501 |
* Provides a normalized attribute interface. |
|
|
502 |
* @method getAttibute |
|
|
503 |
* @param {String | HTMLElement} el The target element for the attribute. |
|
|
504 |
* @param {String} attr The attribute to get. |
|
|
505 |
* @return {String} The current value of the attribute. |
|
|
506 |
*/ |
|
|
507 |
getAttribute: function(el, attr) { |
|
|
508 |
var ret = ''; |
|
|
509 |
if (el && el.getAttribute) { |
|
|
510 |
attr = Y.DOM.CUSTOM_ATTRIBUTES[attr] || attr; |
|
|
511 |
ret = el.getAttribute(attr, 2); |
|
|
512 |
|
|
|
513 |
if (ret === null) { |
|
|
514 |
ret = ''; // per DOM spec |
|
|
515 |
} |
|
|
516 |
} |
|
|
517 |
return ret; |
|
|
518 |
}, |
|
|
519 |
|
|
|
520 |
// @deprecated |
|
|
521 |
srcIndex: (document.documentElement.sourceIndex) ? |
|
|
522 |
function(node) { |
|
|
523 |
return (node && node.sourceIndex) ? node.sourceIndex : null; |
|
|
524 |
} : |
|
|
525 |
function(node) { |
|
|
526 |
return (node && node[OWNER_DOCUMENT]) ? |
|
|
527 |
[].indexOf.call(node[OWNER_DOCUMENT]. |
|
|
528 |
getElementsByTagName('*'), node) : null; |
|
|
529 |
}, |
|
|
530 |
|
|
|
531 |
isWindow: function(obj) { |
|
|
532 |
return obj.alert && obj.document; |
|
|
533 |
}, |
|
|
534 |
|
|
|
535 |
_fragClones: { |
|
|
536 |
div: document.createElement('div') |
|
|
537 |
}, |
|
|
538 |
|
|
|
539 |
_create: function(html, doc, tag) { |
|
|
540 |
tag = tag || 'div'; |
|
|
541 |
|
|
|
542 |
var frag = Y.DOM._fragClones[tag]; |
|
|
543 |
if (frag) { |
|
|
544 |
frag = frag.cloneNode(false); |
|
|
545 |
} else { |
|
|
546 |
frag = Y.DOM._fragClones[tag] = doc.createElement(tag); |
|
|
547 |
} |
|
|
548 |
frag.innerHTML = html; |
|
|
549 |
return frag; |
|
|
550 |
}, |
|
|
551 |
|
|
|
552 |
_removeChildNodes: function(node) { |
|
|
553 |
while (node.firstChild) { |
|
|
554 |
node.removeChild(node.firstChild); |
|
|
555 |
} |
|
|
556 |
}, |
|
|
557 |
|
|
|
558 |
_cloneCache: {}, |
|
|
559 |
|
|
|
560 |
/** |
|
|
561 |
* Inserts content in a node at the given location |
|
|
562 |
* @method addHTML |
|
|
563 |
* @param {HTMLElement} node The node to insert into |
|
|
564 |
* @param {String} content The content to be inserted |
|
|
565 |
* @param {String} where Where to insert the content; default is after lastChild |
|
|
566 |
*/ |
|
|
567 |
addHTML: function(node, content, where) { |
|
|
568 |
if (typeof content === 'string') { |
|
|
569 |
content = Y.Lang.trim(content); // match IE which trims whitespace from innerHTML |
|
|
570 |
} |
|
|
571 |
|
|
|
572 |
var newNode = Y.DOM._cloneCache[content]; |
|
|
573 |
|
|
|
574 |
if (newNode) { |
|
|
575 |
newNode = newNode.cloneNode(true); |
|
|
576 |
} else { |
|
|
577 |
if (content.nodeType) { // domNode |
|
|
578 |
newNode = content; |
|
|
579 |
} else { // create from string and cache |
|
|
580 |
newNode = Y.DOM.create(content); |
|
|
581 |
} |
|
|
582 |
} |
|
|
583 |
|
|
|
584 |
if (where) { |
|
|
585 |
if (where.nodeType) { // insert regardless of relationship to node |
|
|
586 |
// TODO: check if node.contains(where)? |
|
|
587 |
where.parentNode.insertBefore(newNode, where); |
|
|
588 |
} else { |
|
|
589 |
switch (where) { |
|
|
590 |
case 'replace': |
|
|
591 |
while (node.firstChild) { |
|
|
592 |
node.removeChild(node.firstChild); |
|
|
593 |
} |
|
|
594 |
node.appendChild(newNode); |
|
|
595 |
break; |
|
|
596 |
case 'before': |
|
|
597 |
node.parentNode.insertBefore(newNode, node); |
|
|
598 |
break; |
|
|
599 |
case 'after': |
|
|
600 |
if (node.nextSibling) { // IE errors if refNode is null |
|
|
601 |
node.parentNode.insertBefore(newNode, node.nextSibling); |
|
|
602 |
} else { |
|
|
603 |
node.parentNode.appendChild(newNode); |
|
|
604 |
} |
|
|
605 |
break; |
|
|
606 |
default: |
|
|
607 |
node.appendChild(newNode); |
|
|
608 |
} |
|
|
609 |
} |
|
|
610 |
} else { |
|
|
611 |
node.appendChild(newNode); |
|
|
612 |
} |
|
|
613 |
|
|
|
614 |
return newNode; |
|
|
615 |
}, |
|
|
616 |
|
|
|
617 |
VALUE_SETTERS: {}, |
|
|
618 |
|
|
|
619 |
VALUE_GETTERS: {}, |
|
|
620 |
|
|
|
621 |
getValue: function(node) { |
|
|
622 |
var ret = '', // TODO: return null? |
|
|
623 |
getter; |
|
|
624 |
|
|
|
625 |
if (node && node[TAG_NAME]) { |
|
|
626 |
getter = Y.DOM.VALUE_GETTERS[node[TAG_NAME].toLowerCase()]; |
|
|
627 |
|
|
|
628 |
if (getter) { |
|
|
629 |
ret = getter(node); |
|
|
630 |
} else { |
|
|
631 |
ret = node.value; |
|
|
632 |
} |
|
|
633 |
} |
|
|
634 |
|
|
|
635 |
return (typeof ret === 'string') ? ret : ''; |
|
|
636 |
}, |
|
|
637 |
|
|
|
638 |
setValue: function(node, val) { |
|
|
639 |
var setter; |
|
|
640 |
|
|
|
641 |
if (node && node[TAG_NAME]) { |
|
|
642 |
setter = Y.DOM.VALUE_SETTERS[node[TAG_NAME].toLowerCase()]; |
|
|
643 |
|
|
|
644 |
if (setter) { |
|
|
645 |
setter(node, val); |
|
|
646 |
} else { |
|
|
647 |
node.value = val; |
|
|
648 |
} |
|
|
649 |
} |
|
|
650 |
}, |
|
|
651 |
|
|
|
652 |
_stripScripts: function(node) { |
|
|
653 |
var scripts = node.getElementsByTagName('script'), |
|
|
654 |
i, script; |
|
|
655 |
|
|
|
656 |
for (i = 0, script; script = scripts[i++];) { |
|
|
657 |
script.parentNode.removeChild(script); |
|
|
658 |
} |
|
|
659 |
}, |
|
|
660 |
|
|
|
661 |
_execScripts: function(scripts, startIndex) { |
|
|
662 |
var newScript, |
|
|
663 |
i, script; |
|
|
664 |
|
|
|
665 |
startIndex = startIndex || 0; |
|
|
666 |
|
|
|
667 |
for (i = startIndex, script; script = scripts[i++];) { |
|
|
668 |
newScript = script.ownerDocument.createElement('script'); |
|
|
669 |
script.parentNode.replaceChild(newScript, script); |
|
|
670 |
if (script.text) { |
|
|
671 |
newScript.text = script.text; |
|
|
672 |
} else if (script.src) { |
|
|
673 |
newScript.src = script.src; |
|
|
674 |
|
|
|
675 |
// "pause" while loading to ensure exec order |
|
|
676 |
// FF reports typeof onload as "undefined", so try IE first |
|
|
677 |
if (typeof newScript.onreadystatechange !== 'undefined') { |
|
|
678 |
newScript.onreadystatechange = function() { |
|
|
679 |
if (/loaded|complete/.test(script.readyState)) { |
|
|
680 |
event.srcElement.onreadystatechange = null; |
|
|
681 |
// timer to help ensure exec order |
|
|
682 |
setTimeout(function() { |
|
|
683 |
Y.DOM._execScripts(scripts, i++); |
|
|
684 |
}, 0); |
|
|
685 |
} |
|
|
686 |
}; |
|
|
687 |
} else { |
|
|
688 |
newScript.onload = function(e) { |
|
|
689 |
e.target.onload = null; |
|
|
690 |
Y.DOM._execScripts(scripts, i++); |
|
|
691 |
}; |
|
|
692 |
} |
|
|
693 |
return; // NOTE: early return to chain async loading |
|
|
694 |
} |
|
|
695 |
} |
|
|
696 |
}, |
|
|
697 |
|
|
|
698 |
/** |
|
|
699 |
* Brute force version of contains. |
|
|
700 |
* Used for browsers without contains support for non-HTMLElement Nodes (textNodes, etc). |
|
|
701 |
* @method _bruteContains |
|
|
702 |
* @private |
|
|
703 |
* @param {HTMLElement} element The containing html element. |
|
|
704 |
* @param {HTMLElement} needle The html element that may be contained. |
|
|
705 |
* @return {Boolean} Whether or not the element is or contains the needle. |
|
|
706 |
*/ |
|
|
707 |
_bruteContains: function(element, needle) { |
|
|
708 |
while (needle) { |
|
|
709 |
if (element === needle) { |
|
|
710 |
return true; |
|
|
711 |
} |
|
|
712 |
needle = needle.parentNode; |
|
|
713 |
} |
|
|
714 |
return false; |
|
|
715 |
}, |
|
|
716 |
|
|
|
717 |
// TODO: move to Lang? |
|
|
718 |
/** |
|
|
719 |
* Memoizes dynamic regular expressions to boost runtime performance. |
|
|
720 |
* @method _getRegExp |
|
|
721 |
* @private |
|
|
722 |
* @param {String} str The string to convert to a regular expression. |
|
|
723 |
* @param {String} flags optional An optinal string of flags. |
|
|
724 |
* @return {RegExp} An instance of RegExp |
|
|
725 |
*/ |
|
|
726 |
_getRegExp: function(str, flags) { |
|
|
727 |
flags = flags || ''; |
|
|
728 |
Y.DOM._regexCache = Y.DOM._regexCache || {}; |
|
|
729 |
if (!Y.DOM._regexCache[str + flags]) { |
|
|
730 |
Y.DOM._regexCache[str + flags] = new RegExp(str, flags); |
|
|
731 |
} |
|
|
732 |
return Y.DOM._regexCache[str + flags]; |
|
|
733 |
}, |
|
|
734 |
|
|
|
735 |
// TODO: make getDoc/Win true privates? |
|
|
736 |
/** |
|
|
737 |
* returns the appropriate document. |
|
|
738 |
* @method _getDoc |
|
|
739 |
* @private |
|
|
740 |
* @param {HTMLElement} element optional Target element. |
|
|
741 |
* @return {Object} The document for the given element or the default document. |
|
|
742 |
*/ |
|
|
743 |
_getDoc: function(element) { |
|
|
744 |
element = element || {}; |
|
|
745 |
|
|
|
746 |
return (element[NODE_TYPE] === 9) ? element : // element === document |
|
|
747 |
element[OWNER_DOCUMENT] || // element === DOM node |
|
|
748 |
element.document || // element === window |
|
|
749 |
Y.config.doc; // default |
|
|
750 |
}, |
|
|
751 |
|
|
|
752 |
/** |
|
|
753 |
* returns the appropriate window. |
|
|
754 |
* @method _getWin |
|
|
755 |
* @private |
|
|
756 |
* @param {HTMLElement} element optional Target element. |
|
|
757 |
* @return {Object} The window for the given element or the default window. |
|
|
758 |
*/ |
|
|
759 |
_getWin: function(element) { |
|
|
760 |
var doc = Y.DOM._getDoc(element); |
|
|
761 |
return doc[DEFAULT_VIEW] || doc[PARENT_WINDOW] || Y.config.win; |
|
|
762 |
}, |
|
|
763 |
|
|
|
764 |
// @deprecated, use Selector |
|
|
765 |
_childBy: function(element, tag, fn, rev) { |
|
|
766 |
var ret = null, |
|
|
767 |
root, axis; |
|
|
768 |
|
|
|
769 |
if (element) { |
|
|
770 |
if (rev) { |
|
|
771 |
root = element[LAST_CHILD]; |
|
|
772 |
axis = PREVIOUS_SIBLING; |
|
|
773 |
} else { |
|
|
774 |
root = element[FIRST_CHILD]; |
|
|
775 |
axis = NEXT_SIBLING; |
|
|
776 |
} |
|
|
777 |
|
|
|
778 |
if (Y.DOM._testElement(root, tag, fn)) { // is the matching element |
|
|
779 |
ret = root; |
|
|
780 |
} else { // need to scan nextSibling axis of firstChild to find matching element |
|
|
781 |
ret = Y.DOM.elementByAxis(root, axis, fn); |
|
|
782 |
} |
|
|
783 |
} |
|
|
784 |
return ret; |
|
|
785 |
|
|
|
786 |
}, |
|
|
787 |
|
|
|
788 |
_batch: function(nodes, fn, arg1, arg2, arg3, etc) { |
|
|
789 |
fn = (typeof name === 'string') ? Y.DOM[fn] : fn; |
|
|
790 |
var result, |
|
|
791 |
ret = []; |
|
|
792 |
|
|
|
793 |
if (fn && nodes) { |
|
|
794 |
Y.each(nodes, function(node) { |
|
|
795 |
if ((result = fn.call(Y.DOM, node, arg1, arg2, arg3, etc)) !== undefined) { |
|
|
796 |
ret[ret.length] = result; |
|
|
797 |
} |
|
|
798 |
}); |
|
|
799 |
} |
|
|
800 |
|
|
|
801 |
return ret.length ? ret : nodes; |
|
|
802 |
}, |
|
|
803 |
|
|
|
804 |
_testElement: function(element, tag, fn) { |
|
|
805 |
tag = (tag && tag !== '*') ? tag.toUpperCase() : null; |
|
|
806 |
return (element && element[TAG_NAME] && |
|
|
807 |
(!tag || element[TAG_NAME].toUpperCase() === tag) && |
|
|
808 |
(!fn || fn(element))); |
|
|
809 |
}, |
|
|
810 |
|
|
|
811 |
creators: {}, |
|
|
812 |
|
|
|
813 |
_IESimpleCreate: function(html, doc) { |
|
|
814 |
doc = doc || Y.config.doc; |
|
|
815 |
return doc.createElement(html); |
|
|
816 |
} |
|
|
817 |
}; |
|
|
818 |
|
|
|
819 |
|
|
|
820 |
(function(Y) { |
|
|
821 |
var creators = Y.DOM.creators, |
|
|
822 |
create = Y.DOM.create, |
|
|
823 |
re_tbody = /(?:\/(?:thead|tfoot|tbody|caption|col|colgroup)>)+\s*<tbody/, |
|
|
824 |
|
|
|
825 |
TABLE_OPEN = '<table>', |
|
|
826 |
TABLE_CLOSE = '</table>'; |
|
|
827 |
|
|
|
828 |
if (Y.UA.gecko || Y.UA.ie) { // require custom creation code for certain element types |
|
|
829 |
Y.mix(creators, { |
|
|
830 |
option: function(html, doc) { |
|
|
831 |
return create('<select>' + html + '</select>', doc); |
|
|
832 |
}, |
|
|
833 |
|
|
|
834 |
tr: function(html, doc) { |
|
|
835 |
return create('<tbody>' + html + '</tbody>', doc); |
|
|
836 |
}, |
|
|
837 |
|
|
|
838 |
td: function(html, doc) { |
|
|
839 |
return create('<tr>' + html + '</tr>', doc); |
|
|
840 |
}, |
|
|
841 |
|
|
|
842 |
tbody: function(html, doc) { |
|
|
843 |
return create(TABLE_OPEN + html + TABLE_CLOSE, doc); |
|
|
844 |
}, |
|
|
845 |
|
|
|
846 |
legend: 'fieldset' |
|
|
847 |
}); |
|
|
848 |
|
|
|
849 |
creators.col = creators.tbody; // IE wraps in colgroup |
|
|
850 |
} |
|
|
851 |
|
|
|
852 |
if (Y.UA.ie) { |
|
|
853 |
Y.mix(creators, { |
|
|
854 |
// TODO: thead/tfoot with nested tbody |
|
|
855 |
// IE adds TBODY when creating TABLE elements (which may share this impl) |
|
|
856 |
tbody: function(html, doc) { |
|
|
857 |
var frag = create(TABLE_OPEN + html + TABLE_CLOSE, doc), |
|
|
858 |
tb = frag.children.tags('tbody')[0]; |
|
|
859 |
|
|
|
860 |
if (frag.children.length > 1 && tb && !re_tbody.test(html)) { |
|
|
861 |
tb[PARENT_NODE].removeChild(tb); // strip extraneous tbody |
|
|
862 |
} |
|
|
863 |
return frag; |
|
|
864 |
}, |
|
|
865 |
|
|
|
866 |
script: function(html, doc) { |
|
|
867 |
var frag = doc.createElement('div'); |
|
|
868 |
|
|
|
869 |
frag.innerHTML = '-' + html; |
|
|
870 |
frag.removeChild(frag[FIRST_CHILD]); |
|
|
871 |
return frag; |
|
|
872 |
} |
|
|
873 |
|
|
|
874 |
}, true); |
|
|
875 |
|
|
|
876 |
Y.mix(Y.DOM.VALUE_GETTERS, { |
|
|
877 |
button: function(node) { |
|
|
878 |
return (node.attributes && node.attributes.value) ? node.attributes.value.value : ''; |
|
|
879 |
} |
|
|
880 |
}); |
|
|
881 |
|
|
|
882 |
Y.mix(Y.DOM.VALUE_SETTERS, { |
|
|
883 |
// IE: node.value changes the button text, which should be handled via innerHTML |
|
|
884 |
button: function(node, val) { |
|
|
885 |
var attr = node.attributes.value; |
|
|
886 |
if (!attr) { |
|
|
887 |
attr = node[OWNER_DOCUMENT].createAttribute('value'); |
|
|
888 |
node.setAttributeNode(attr); |
|
|
889 |
} |
|
|
890 |
|
|
|
891 |
attr.value = val; |
|
|
892 |
} |
|
|
893 |
}); |
|
|
894 |
} |
|
|
895 |
|
|
|
896 |
if (Y.UA.gecko || Y.UA.ie) { |
|
|
897 |
Y.mix(creators, { |
|
|
898 |
th: creators.td, |
|
|
899 |
thead: creators.tbody, |
|
|
900 |
tfoot: creators.tbody, |
|
|
901 |
caption: creators.tbody, |
|
|
902 |
colgroup: creators.tbody, |
|
|
903 |
col: creators.tbody, |
|
|
904 |
optgroup: creators.option |
|
|
905 |
}); |
|
|
906 |
} |
|
|
907 |
|
|
|
908 |
Y.mix(Y.DOM.VALUE_GETTERS, { |
|
|
909 |
option: function(node) { |
|
|
910 |
var attrs = node.attributes; |
|
|
911 |
return (attrs.value && attrs.value.specified) ? node.value : node.text; |
|
|
912 |
}, |
|
|
913 |
|
|
|
914 |
select: function(node) { |
|
|
915 |
var val = node.value, |
|
|
916 |
options = node.options; |
|
|
917 |
|
|
|
918 |
if (options && val === '') { |
|
|
919 |
if (node.multiple) { |
|
|
920 |
} else { |
|
|
921 |
val = Y.DOM.getValue(options[node.selectedIndex], 'value'); |
|
|
922 |
} |
|
|
923 |
} |
|
|
924 |
|
|
|
925 |
return val; |
|
|
926 |
} |
|
|
927 |
}); |
|
|
928 |
})(Y); |
|
|
929 |
|
|
|
930 |
})(Y); |
|
|
931 |
Y.mix(Y.DOM, { |
|
|
932 |
/** |
|
|
933 |
* Determines whether a DOM element has the given className. |
|
|
934 |
* @method hasClass |
|
|
935 |
* @param {HTMLElement} element The DOM element. |
|
|
936 |
* @param {String} className the class name to search for |
|
|
937 |
* @return {Boolean} Whether or not the element has the given class. |
|
|
938 |
*/ |
|
|
939 |
hasClass: function(node, className) { |
|
|
940 |
var re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); |
|
|
941 |
return re.test(node.className); |
|
|
942 |
}, |
|
|
943 |
|
|
|
944 |
/** |
|
|
945 |
* Adds a class name to a given DOM element. |
|
|
946 |
* @method addClass |
|
|
947 |
* @param {HTMLElement} element The DOM element. |
|
|
948 |
* @param {String} className the class name to add to the class attribute |
|
|
949 |
*/ |
|
|
950 |
addClass: function(node, className) { |
|
|
951 |
if (!Y.DOM.hasClass(node, className)) { // skip if already present |
|
|
952 |
node.className = Y.Lang.trim([node.className, className].join(' ')); |
|
|
953 |
} |
|
|
954 |
}, |
|
|
955 |
|
|
|
956 |
/** |
|
|
957 |
* Removes a class name from a given element. |
|
|
958 |
* @method removeClass |
|
|
959 |
* @param {HTMLElement} element The DOM element. |
|
|
960 |
* @param {String} className the class name to remove from the class attribute |
|
|
961 |
*/ |
|
|
962 |
removeClass: function(node, className) { |
|
|
963 |
if (className && Y.DOM.hasClass(node, className)) { |
|
|
964 |
node.className = Y.Lang.trim(node.className.replace(Y.DOM._getRegExp('(?:^|\\s+)' + |
|
|
965 |
className + '(?:\\s+|$)'), ' ')); |
|
|
966 |
|
|
|
967 |
if ( Y.DOM.hasClass(node, className) ) { // in case of multiple adjacent |
|
|
968 |
Y.DOM.removeClass(node, className); |
|
|
969 |
} |
|
|
970 |
} |
|
|
971 |
}, |
|
|
972 |
|
|
|
973 |
/** |
|
|
974 |
* Replace a class with another class for a given element. |
|
|
975 |
* If no oldClassName is present, the newClassName is simply added. |
|
|
976 |
* @method replaceClass |
|
|
977 |
* @param {HTMLElement} element The DOM element. |
|
|
978 |
* @param {String} oldClassName the class name to be replaced |
|
|
979 |
* @param {String} newClassName the class name that will be replacing the old class name |
|
|
980 |
*/ |
|
|
981 |
replaceClass: function(node, oldC, newC) { |
|
|
982 |
Y.DOM.addClass(node, newC); |
|
|
983 |
Y.DOM.removeClass(node, oldC); |
|
|
984 |
}, |
|
|
985 |
|
|
|
986 |
/** |
|
|
987 |
* If the className exists on the node it is removed, if it doesn't exist it is added. |
|
|
988 |
* @method toggleClass |
|
|
989 |
* @param {HTMLElement} element The DOM element. |
|
|
990 |
* @param {String} className the class name to be toggled |
|
|
991 |
*/ |
|
|
992 |
toggleClass: function(node, className) { |
|
|
993 |
if (Y.DOM.hasClass(node, className)) { |
|
|
994 |
Y.DOM.removeClass(node, className); |
|
|
995 |
} else { |
|
|
996 |
Y.DOM.addClass(node, className); |
|
|
997 |
} |
|
|
998 |
} |
|
|
999 |
}); |
|
|
1000 |
|
|
|
1001 |
|
|
|
1002 |
|
|
|
1003 |
}, '3.0.0b1' ,{requires:['event'], skinnable:false}); |