2
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
3
Code licensed under the BSD License:
4
http://developer.yahoo.net/yui/license.txt
7
YUI.add('node', function(Y) {
10
* The Node Utility provides a DOM-like interface for interacting with DOM nodes.
12
* @submodule node-base
16
* The Node class provides a wrapper for manipulating DOM Nodes.
17
* Node properties can be accessed via the set/get methods.
18
* Use Y.get() to retrieve Node instances.
20
* <strong>NOTE:</strong> All node properties are accessed using the
21
* <code>set</code> and <code>get</code> methods.
31
//CDATA_SECTION_NODE = 4,
32
//ENTITY_REFERENCE_NODE = 5,
34
//PROCESSING_INSTRUCTION_NODE = 7,
36
DOCUMENT_NODE = 9; //,
37
//DOCUMENT_TYPE_NODE = 10,
38
//DOCUMENT_FRAGMENT_NODE = 11,
41
var OWNER_DOCUMENT = 'ownerDocument',
43
NODE_NAME = 'nodeName',
44
NODE_TYPE = 'nodeType';
46
var RE_VALID_PROP_TYPES = /(?:string|boolean|number)/;
48
var Selector = Y.Selector;
56
var wrapDOM = function(node) {
58
yuid = (node) ? node._yuid : null,
59
instance = _instances[yuid],
60
existingNode = _nodes[yuid];
63
if (NODE_TYPE in node) {
64
if (instance && existingNode && node === existingNode) {
65
ret = instance; // reuse existing Nodes if nodes match
69
} else if ('item' in node || 'push' in node) {
70
ret = new Y.NodeList(node);
76
var wrapFn = function(fn) {
79
ret = (typeof fn === 'string') ?
81
return Y.Selector.test(n, fn);
84
return fn(_instances[n._yuid]);
91
var getDoc = function(node) {
92
node = _nodes[node._yuid];
93
return (node[NODE_TYPE] === 9) ? node : node[OWNER_DOCUMENT];
96
// returns HTMLElement
97
var getDOMNode = function(node) {
98
if (node && !node.nodeType && node._yuid) {
99
node = _nodes[node._yuid];
107
* Wraps the input and outputs of a node instance
109
var nodeInOut = function(method, a, b, c, d, e) {
110
if (a) { // first 2 may be Node instances or nodes (TODO: or strings?)
116
return wrapDOM(_nodes[this._yuid][method](a, b, c, d, e));
120
* Wraps the return value in a node instance
122
var nodeOut = function(method, a, b, c, d, e) {
123
return wrapDOM(_nodes[this._yuid][method](a, b, c, d, e));
127
* Returns directy from node method call
129
var rawOut = function(method, a, b, c, d, e) {
130
return _nodes[this._yuid][method](a, b, c, d, e);
133
var noOut = function(method, a, b, c, d, e) {
134
_nodes[this._yuid][method](a, b, c, d, e);
140
* Returns a Node instance.
141
* @property parentNode
144
'parentNode': BASE_NODE,
147
* Returns a NodeList instance.
148
* @property childNodes
151
'childNodes': BASE_NODE,
154
* Returns a NodeList instance.
158
'children': function(node) {
159
node = _nodes[node._yuid];
160
var children = node.children;
162
if (children === undefined) {
163
var childNodes = node.childNodes;
166
for (var i = 0, len = childNodes.length; i < len; ++i) {
167
if (childNodes[i][TAG_NAME]) {
168
children[children.length] = childNodes[i];
176
* Returns a Node instance.
177
* @property firstChild
180
'firstChild': BASE_NODE,
183
* Returns a Node instance.
184
* @property lastChild
187
'lastChild': BASE_NODE,
190
* Returns a Node instance.
191
* @property previousSibling
194
'previousSibling': BASE_NODE,
197
* Returns a Node instance.
198
* @property previousSibling
201
'nextSibling': BASE_NODE,
204
* Returns a Node instance.
205
* @property ownerDocument
208
'ownerDocument': BASE_NODE,
211
* Returns a Node instance.
212
* @property offsetParent
215
'offsetParent': ELEMENT_NODE,
218
* Returns a Node instance.
219
* @property documentElement
222
'documentElement': DOCUMENT_NODE,
225
* Returns a Node instance.
229
'body': DOCUMENT_NODE,
233
* Returns a NodeList instance.
237
'elements': ELEMENT_NODE,
241
* Returns a NodeList instance.
245
'rows': ELEMENT_NODE,
248
* Returns a NodeList instance.
252
'cells': ELEMENT_NODE,
255
* Returns a Node instance.
259
'tHead': ELEMENT_NODE,
262
* Returns a Node instance.
266
'tFoot': ELEMENT_NODE,
269
* Returns a NodeList instance.
273
'tBodies': ELEMENT_NODE
277
* Passes through to DOM method.
278
* @method replaceChild
279
* @param {HTMLElement | Node} node Node to be inserted
280
* @param {HTMLElement | Node} refNode Node to be replaced
281
* @return {Node} The replaced node
283
replaceChild: nodeInOut,
286
* Passes through to DOM method.
287
* @method appendChild
288
* @param {HTMLElement | Node} node Node to be appended
289
* @return {Node} The appended node
291
appendChild: nodeInOut,
294
* Passes through to DOM method.
295
* @method insertBefore
296
* @param {HTMLElement | Node} newNode Node to be appended
297
* @param {HTMLElement | Node} refNode Node to be inserted before
298
* @return {Node} The inserted node
300
insertBefore: nodeInOut,
303
* Passes through to DOM method.
304
* @method removeChild
305
* @param {HTMLElement | Node} node Node to be removed
306
* @return {Node} The removed node
308
removeChild: nodeInOut,
311
* Passes through to DOM method.
312
* @method hasChildNodes
313
* @return {Boolean} Whether or not the node has any childNodes
315
hasChildNodes: rawOut,
318
* Passes through to DOM method.
320
* @param {HTMLElement | Node} node Node to be cloned
321
* @return {Node} The clone
326
* Passes through to DOM method.
327
* @method getAttribute
328
* @param {String} attribute The attribute to retrieve
329
* @return {String} The current value of the attribute
331
getAttribute: rawOut,
334
* Passes through to DOM method.
335
* @method setAttribute
336
* @param {String} attribute The attribute to set
337
* @param {String} The value to apply to the attribute
343
* Passes through to DOM method.
344
* @method hasAttribute
345
* @param {String} attribute The attribute to test for
346
* @return {Boolean} Whether or not the attribute is present
348
hasAttribute: rawOut,
351
* Passes through to DOM method.
352
* @method scrollIntoView
355
scrollIntoView: noOut,
358
* Passes through to DOM method.
359
* @method getElementsByTagName
360
* @param {String} tagName The tagName to collect
361
* @return {NodeList} A NodeList representing the HTMLCollection
363
getElementsByTagName: nodeOut,
366
* Passes through to DOM method.
373
* Passes through to DOM method.
380
* Passes through to DOM method.
381
* Only valid on FORM elements
388
* Passes through to DOM method.
389
* Only valid on FORM elements
396
var addNodeListMethod = function(name) {
397
NodeList.prototype[name] = function() {
399
nodes = _nodelists[this._yuid],
402
for (var i = 0, len = nodes.length; i < len; ++i) {
403
_nodes[_tmpNode._yuid] = nodes[i];
404
ret = _tmpNode[name].apply(_tmpNode, arguments);
405
if (ret !== _tmpNode) {
410
return a.length ? a : this;
414
var METHODS_INVOKE = {
415
'getBoundingClientRect': true
418
var Node = function(node) {
419
if (!node || !node[NODE_TYPE]) {
420
Y.log('invalid node:' + node, 'error', 'Node');
425
try { // IE errors on non-element expandos (cant be reused)
430
_instances[yuid] = this;
437
* Normalizes nodeInnerText and textContent.
441
'text': function(node) {
442
return Y.DOM.getText(_nodes[node._yuid]);
446
* Returns a nodeList of option elements
450
'options': function(node) {
451
return (node) ? node.getElementsByTagName('option') : [];
455
Node.setters = function(prop, fn) {
456
if (typeof prop == 'string') {
458
} else { // assume object
459
Y.each(prop, function(fn, prop) {
460
Node.setters(prop, fn);
465
Node.getters = function(prop, fn) {
466
if (typeof prop == 'string') {
468
} else { // assume object
469
Y.each(prop, function(fn, prop) {
470
Node.getters(prop, fn);
475
Node.methods = function(name, fn) {
476
if (typeof name == 'string') {
477
Node.prototype[name] = function() {
478
var args = slice.call(arguments);
480
var ret = fn.apply(null, args);
481
if (ret === undefined) {
487
addNodeListMethod(name);
490
} else { // assume object
491
Y.each(name, function(fn, name) {
492
Node.methods(name, fn);
497
Node.getDOMNode = function(node) {
502
} else if (typeof node === 'string') {
503
ret = Selector.query(node, null, true);
505
ret = _nodes[node._yuid];
510
Node.wrapDOMMethod = function(name) {
512
var args = slice.call(arguments);
513
args.unshift(Y.Node.getDOMNode(args.shift()));
514
return Y.DOM[name].apply(Y.DOM, args);
519
Node.addDOMMethods = function(methods) {
521
Y.each(methods, function(v, n) {
522
add[v] = Y.Node.wrapDOMMethod(v);
530
* Set the value of the property/attribute on the HTMLElement bound to this Node.
531
* Only strings/numbers/booleans are passed through unless a SETTER exists.
533
* @param {String} prop Property to set
534
* @param {any} val Value to apply to the given property
537
set: function(prop, val) {
538
var node = _nodes[this._yuid];
539
if (prop in SETTERS) { // use custom setter
540
SETTERS[prop](this, prop, val); // passing Node instance
541
} else if (RE_VALID_PROP_TYPES.test(typeof node[prop])) { // safe to write
548
* Get the value of the property/attribute on the HTMLElement bound to this Node.
549
* Only strings/numbers/booleans are passed through unless a GETTER exists.
551
* @param {String} prop Property to get
552
* @return {any} Current value of the property
554
get: function(prop) {
556
var node = _nodes[this._yuid];
557
if (prop in GETTERS) { // use custom getter
558
val = GETTERS[prop](this, prop);
559
} else if (prop in PROPS_WRAP) { // wrap DOM object (HTMLElement, HTMLCollection, Document)
560
if (typeof PROPS_WRAP[prop] === 'function') {
561
val = PROPS_WRAP[prop](this);
566
if (_restrict && _restrict[this._yuid] && !Y.DOM.contains(node, val)) {
567
val = null; // not allowed to go outside of root node
571
} else if (RE_VALID_PROP_TYPES.test(typeof node[prop])) { // safe to read
577
invoke: function(method, a, b, c, d, e) {
578
if (a) { // first 2 may be Node instances or strings
579
a = (a[NODE_TYPE]) ? a : getDOMNode(a);
581
b = (b[NODE_TYPE]) ? b : getDOMNode(b);
584
var node = _nodes[this._yuid];
585
if (node && METHODS_INVOKE[method] && node[method]) {
586
return node[method](a, b, c, d, e);
591
hasMethod: function(method) {
592
return !!(METHODS_INVOKE[method] && _nodes[this._yuid][method]);
595
//normalize: function() {},
596
//isSupported: function(feature, version) {},
597
toString: function() {
598
var node = _nodes[this._yuid] || {};
599
return node.id || node[NODE_NAME] || 'undefined node';
603
* Retrieves a single node based on the given CSS selector.
606
* @param {string} selector The CSS selector to test against.
607
* @return {Node} A Node instance for the matching HTMLElement.
609
query: function(selector) {
610
return wrapDOM(Selector.query(selector, _nodes[this._yuid], true));
614
* Retrieves a nodeList based on the given CSS selector.
617
* @param {string} selector The CSS selector to test against.
618
* @return {NodeList} A NodeList instance for the matching HTMLCollection/Array.
620
queryAll: function(selector) {
621
return wrapDOM(Selector.query(selector, _nodes[this._yuid]));
625
* Test if the supplied node matches the supplied selector.
628
* @param {string} selector The CSS selector to test against.
629
* @return {boolean} Whether or not the node matches the selector.
631
test: function(selector) {
632
return Selector.test(_nodes[this._yuid], selector);
636
* Compares nodes to determine if they match.
637
* Node instances can be compared to each other and/or HTMLElements.
639
* @param {HTMLElement | Node} refNode The reference node to compare to the node.
640
* @return {Boolean} True if the nodes match, false if they do not.
642
compareTo: function(refNode) {
643
refNode = refNode[NODE_TYPE] ? refNode : _nodes[refNode._yuid];
644
return _nodes[this._yuid] === refNode;
648
* Returns the nearest ancestor that passes the test applied by supplied boolean method.
650
* @param {String | Function} fn A selector or boolean method for testing elements.
651
* If a function is used, it receives the current node being tested as the only argument.
652
* @return {Node} The matching Node instance or null if not found
654
ancestor: function(fn) {
655
return wrapDOM(Y.DOM.elementByAxis(_nodes[this._yuid], 'parentNode', wrapFn(fn)));
659
* Returns the previous matching sibling.
660
* Returns the nearest element node sibling if no method provided.
662
* @param {String | Function} fn A selector or boolean method for testing elements.
663
* If a function is used, it receives the current node being tested as the only argument.
664
* @param {Boolean} all optional Whether all node types should be returned, or just element nodes.
665
* @return {Node} Node instance or null if not found
667
previous: function(fn, all) {
668
return wrapDOM(Y.DOM.elementByAxis(_nodes[this._yuid], 'previousSibling', wrapFn(fn)), all);
672
* Returns the next matching sibling.
673
* Returns the nearest element node sibling if no method provided.
675
* @param {String | Function} fn A selector or boolean method for testing elements.
676
* If a function is used, it receives the current node being tested as the only argument.
677
* @param {Boolean} all optional Whether all node types should be returned, or just element nodes.
678
* @return {Node} Node instance or null if not found
680
next: function(fn, all) {
681
return wrapDOM(Y.DOM.elementByAxis(_nodes[this._yuid], 'nextSibling', wrapFn(fn)), all);
685
* Attaches a DOM event handler.
687
* @param {String} type The type of DOM Event to listen for
688
* @param {Function} fn The handler to call when the event fires
689
* @param {Object} arg An argument object to pass to the handler
692
attach: function(type, fn, arg) {
693
var args = slice.call(arguments, 0);
694
args.unshift(_nodes[this._yuid]);
695
return Y.Event.addListener.apply(Y.Event, args);
701
* @param {String} type The type of DOM Event to listen for
702
* @param {Function} fn The handler to call when the event fires
703
* @param {Object} arg An argument object to pass to the handler
707
on: function(type, fn, arg) {
708
return this.attach.apply(this, arguments);
711
addEventListener: function(type, fn, arg) {
712
return Y.Event.nativeAdd(_nodes[this._yuid], type, fn, arg);
716
* Detaches a DOM event handler.
718
* @param {String} type The type of DOM Event
719
* @param {Function} fn The handler to call when the event fires
721
detach: function(type, fn) {
722
var args = slice.call(arguments, 0);
723
args.unshift(_nodes[this._yuid]);
724
return Y.Event.removeListener.apply(Y.Event, args);
727
removeEventListener: function(type, fn) {
728
return Y.Event.nativeRemove(_nodes[this._yuid], type, fn);
732
* Creates a Node instance from HTML string
734
* @param {String|Array} html The string of html to create
735
* @return {Node} A new Node instance
737
create: function(html) {
738
return Y.Node.create(html);
742
* Determines whether the ndoe is an ancestor of another HTML element in the DOM hierarchy.
744
* @param {Node | HTMLElement} needle The possible node or descendent
745
* @return {Boolean} Whether or not this node is the needle its ancestor
747
contains: function(needle) {
748
return Y.DOM.contains(_nodes[this._yuid], getDOMNode(needle));
752
* Applies the supplied plugin to the node.
754
* @param {Function} The plugin Class to apply
755
* @param {Object} config An optional config to pass to the constructor
758
plug: function(PluginClass, config) {
759
config = config || {};
761
if (PluginClass && PluginClass.NS) {
762
this[PluginClass.NS] = new PluginClass(config);
768
* Determines whether the node is appended to the document.
770
* @param {Node|HTMLElement} doc optional An optional document to check against.
771
* Defaults to current document.
772
* @return {Boolean} Whether or not this node is appended to the document.
774
inDoc: function(doc) {
775
var node = _nodes[this._yuid];
776
doc = (doc) ? getDoc(doc) : node.ownerDocument;
777
if (doc.documentElement) {
778
return Y.DOM.contains(doc.documentElement, node);
783
Y.each(METHODS, function(fn, method) {
784
Node.prototype[method] = function() {
785
return fn.apply(this, [method].concat(slice.call(arguments)));
790
* Creates a Node instance from an HTML string
792
* @param {String} html HTML string
794
Node.create = function(html) {
795
return wrapDOM(Y.DOM.create(html));
798
Node.getById = function(id, doc) {
799
doc = (doc && doc[NODE_TYPE]) ? doc : Y.config.doc;
800
return wrapDOM(doc.getElementById(id));
804
* Retrieves a Node instance for the given object/string.
805
* Note: Use 'document' string to retrieve document Node instance from string
808
* @param {document|HTMLElement|HTMLCollection|Array|String} node The object to wrap.
809
* @param {document|Node} doc optional The document containing the node. Defaults to current document.
810
* @param {boolean} isRoot optional Whether or not this node should be treated as a root node. Root nodes
811
* aren't allowed to traverse outside their DOM tree.
812
* @return {Node} A wrapper instance for the supplied object.
814
Node.get = function(node, doc, isRoot) {
815
if (node instanceof Node) {
821
} else if (doc._yuid && _nodes[doc._yuid]) {
822
doc = _nodes[doc._yuid];
825
if (node && typeof node === 'string') {
826
if (node === 'document') {
829
node = Y.Selector.query(node, doc, true);
833
node = wrapDOM(node);
836
_restrict = _restrict || {};
837
_restrict[node._yuid] = node;
844
* Retrieves a NodeList instance for the given object/string.
847
* @param {HTMLCollection|Array|String} node The object to wrap.
848
* @param {document|Node} doc optional The document containing the node. Defaults to current document.
849
* @return {NodeList} A NodeList instance for the supplied nodes.
851
Node.all = function(nodes, doc) {
852
if (nodes instanceof NodeList) {
858
} else if (doc._yuid && _nodes[doc._yuid]) {
859
doc = _nodes[doc._yuid];
862
if (nodes && typeof nodes == 'string') {
863
nodes = Selector.query(nodes, doc);
866
return wrapDOM(nodes);
871
* A wrapper for manipulating multiple DOM elements
876
var NodeList = function(nodes) {
877
// TODO: input validation
878
_nodelists[Y.stamp(this)] = nodes;
881
// used to call Node methods against NodeList nodes
882
var _tmpNode = Node.create('<div></div>');
883
NodeList.prototype = {};
885
Y.each(Node.prototype, function(fn, name) {
886
if (typeof Node.prototype[name] == 'function') {
887
addNodeListMethod(name);
891
Y.mix(NodeList.prototype, {
893
* Retrieves the Node instance at the given index.
896
* @param {Number} index The index of the target Node.
897
* @return {Node} The Node instance at the given index.
899
item: function(index) {
900
var node = _nodelists[this._yuid][index];
901
return (node && node[TAG_NAME]) ? wrapDOM(node) : (node && node.get) ? node : null;
905
* Set the value of the property/attribute on all HTMLElements bound to this NodeList.
906
* Only strings/numbers/booleans are passed through unless a SETTER exists.
908
* @param {String} prop Property to set
909
* @param {any} val Value to apply to the given property
913
set: function(name, val) {
914
var nodes = _nodelists[this._yuid];
915
for (var i = 0, len = nodes.length; i < len; ++i) {
916
_nodes[_tmpNode._yuid] = nodes[i];
917
_tmpNode.set(name, val);
924
* Get the value of the property/attribute for each of the HTMLElements bound to this NodeList.
925
* Only strings/numbers/booleans are passed through unless a GETTER exists.
927
* @param {String} prop Property to get
928
* @return {Array} Array containing the current values mapped to the Node indexes
931
get: function(name) {
932
if (name == 'length') { // TODO: remove
933
Y.log('the length property is deprecated; use size()', 'warn', 'NodeList');
934
return _nodelists[this._yuid].length;
936
var nodes = _nodelists[this._yuid];
938
for (var i = 0, len = nodes.length; i < len; ++i) {
939
_nodes[_tmpNode._yuid] = nodes[i];
940
ret[i] = _tmpNode.get(name);
947
* Filters the NodeList instance down to only nodes matching the given selector.
949
* @param {String} selector The selector to filter against
950
* @return {NodeList} NodeList containing the updated collection
953
filter: function(selector) {
954
return wrapDOM(Selector.filter(_nodelists[this._yuid], selector));
958
* Applies the given function to each Node in the NodeList.
960
* @param {Function} fn The function to apply
961
* @param {Object} context optional An optional context to apply the function with
962
* Default context is the NodeList instance
963
* @return {NodeList} NodeList containing the updated collection
966
each: function(fn, context) {
967
context = context || this;
968
var nodes = _nodelists[this._yuid];
969
for (var i = 0, len = nodes.length; i < len; ++i) {
970
fn.call(context, Y.Node.get(nodes[i]), i, this);
976
* Returns the current number of items in the NodeList.
978
* @return {Int} The number of items in the NodeList.
981
return _nodelists[this._yuid].length;
984
toString: function() {
985
var nodes = _nodelists[this._yuid] || [];
986
return 'NodeList (' + nodes.length + ' items)';
992
Y.NodeList = NodeList;
996
* Extended Node interface for managing node styles.
998
* @submodule node-style
1002
Y.Node.addDOMMethods([
1004
* Returns the style's current value.
1006
* @param {String} attr The style attribute to retrieve.
1007
* @return {String} The current value of the style property for the element.
1012
* Returns the computed value for the given style property.
1013
* @method getComputedStyle
1014
* @param {String} attr The style attribute to retrieve.
1015
* @return {String} The computed value of the style property for the element.
1020
* Sets a style property of the node.
1022
* @param {String} attr The style attribute to set.
1023
* @param {String|Number} val The value.
1029
* Sets multiple style properties on the node.
1031
* @param {Object} hash An object literal of property:value pairs.
1038
* Extended Node interface for managing classNames.
1043
Y.Node.addDOMMethods([
1045
* Determines whether the node has the given className.
1047
* @param {String} className the class name to search for
1048
* @return {Boolean} Whether or not the node has the given class.
1053
* Adds a class name to the node.
1055
* @param {String} className the class name to add to the node's class attribute
1061
* Removes a class name from the node.
1062
* @method removeClass
1063
* @param {String} className the class name to remove from the node's class attribute
1069
* Replace a class with another class.
1070
* If no oldClassName is present, the newClassName is simply added.
1071
* @method replaceClass
1072
* @param {String} oldClassName the class name to be replaced
1073
* @param {String} newClassName the class name that will be replacing the old class name
1079
* If the className exists on the node it is removed, if it doesn't exist it is added.
1080
* @method toggleClass
1081
* @param {String} className the class name to be toggled
1087
* Extended Node interface for managing regions and screen positioning.
1088
* Adds support for positioning elements and normalizes window size and scroll detection.
1090
* @submodule node-screen
1096
* Returns a region object for the node
1102
* Returns a region object for the node's viewport
1103
* @property viewportRegion
1109
getNode = Y.Node.getDOMNode;
1111
Y.each(ATTR, function(v, n) {
1112
Y.Node.getters(v, Y.Node.wrapDOMMethod(v));
1115
Y.Node.addDOMMethods([
1117
* Determines whether or not the node is currently visible in the viewport.
1118
* @method inViewportRegion
1119
* @return {Boolean} Whether or not the node is currently positioned
1120
* within the viewport's region
1125
// these need special treatment to extract 2nd node arg
1128
* Compares the intersection of the node with another node or region
1130
* @param {Node|Object} node2 The node or region to compare with.
1131
* @param {Object} altRegion An alternate region to use (rather than this node's).
1132
* @return {Object} An object representing the intersection of the regions.
1134
intersect: function(node1, node2, altRegion) {
1135
if (node2 instanceof Y.Node) { // might be a region object
1136
node2 = getNode(node2);
1138
return Y.DOM.intersect(getNode(node1), node2, altRegion);
1142
* Determines whether or not the node is within the giving region.
1144
* @param {Node|Object} node2 The node or region to compare with.
1145
* @param {Boolean} all Whether or not all of the node must be in the region.
1146
* @param {Object} altRegion An alternate region to use (rather than this node's).
1147
* @return {Object} An object representing the intersection of the regions.
1149
inRegion: function(node1, node2, all, altRegion) {
1150
if (node2 instanceof Y.Node) { // might be a region object
1151
node2 = getNode(node2);
1153
return Y.DOM.inRegion(getNode(node1), node2, all, altRegion);
1158
* Extended Node interface for managing regions and screen positioning.
1159
* Adds support for positioning elements and normalizes window size and scroll detection.
1161
* @submodule node-screen
1167
* Returns the inner width of the viewport (exludes scrollbar).
1168
* @property winWidth
1174
* Returns the inner height of the viewport (exludes scrollbar).
1175
* @property winHeight
1182
* @property winHeight
1189
* @property docHeight
1195
* Amount page has been scroll vertically
1196
* @property docScrollX
1202
* Amount page has been scroll horizontally
1203
* @property docScrollY
1209
Y.Node.getters(v, Y.Node.wrapDOMMethod(v));
1213
Y.Node.addDOMMethods([
1215
* Gets the current position of the node in page coordinates.
1216
* Nodes must be part of the DOM tree to have page coordinates
1217
* (display:none or nodes not appended return false).
1219
* @return {Array} The XY position of the node
1224
* Set the position of the node in page coordinates, regardless of how the node is positioned.
1225
* The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
1227
* @param {Array} xy Contains X & Y values for new position (coordinates are page-based)
1233
* Gets the current position of the node in page coordinates.
1234
* Nodes must be part of the DOM tree to have page coordinates
1235
* (display:none or nodes not appended return false).
1237
* @return {Int} The X position of the node
1242
* Set the position of the node in page coordinates, regardless of how the node is positioned.
1243
* The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
1245
* @param {Int} x X value for new position (coordinates are page-based)
1251
* Gets the current position of the node in page coordinates.
1252
* Nodes must be part of the DOM tree to have page coordinates
1253
* (display:none or nodes not appended return false).
1255
* @return {Int} The Y position of the node
1260
* Set the position of the node in page coordinates, regardless of how the node is positioned.
1261
* The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
1263
* @param {Int} y Y value for new position (coordinates are page-based)
1270
}, '3.0.0pr1' ,{requires:['dom']});