~lutostag/ubuntu/utopic/maas/1.5.2

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/node-base/node-base-debug.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-03-15 18:14:08 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120315181408-zgl94hzo0x4n99an
Tags: 0.1+bzr295+dfsg-0ubuntu2
* debian/patches:
  - 01-fix-database-settings.patch: Update to set PSERV_URL.
  - 02-pserv-config.patch: Set port to 8001.
* debian/maas.postinst: Run maas-import-isos on install.
* debian/control: Depends on rabbitmq-server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.4.1 (build 4118)
 
3
Copyright 2011 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('node-base', function(Y) {
 
8
 
 
9
/**
 
10
 * @module node
 
11
 * @submodule node-base
 
12
 */
 
13
 
 
14
var methods = [
 
15
/**
 
16
 * Determines whether each node has the given className.
 
17
 * @method hasClass
 
18
 * @for Node
 
19
 * @param {String} className the class name to search for
 
20
 * @return {Boolean} Whether or not the element has the specified class
 
21
 */
 
22
 'hasClass',
 
23
 
 
24
/**
 
25
 * Adds a class name to each node.
 
26
 * @method addClass
 
27
 * @param {String} className the class name to add to the node's class attribute
 
28
 * @chainable
 
29
 */
 
30
 'addClass',
 
31
 
 
32
/**
 
33
 * Removes a class name from each node.
 
34
 * @method removeClass
 
35
 * @param {String} className the class name to remove from the node's class attribute
 
36
 * @chainable
 
37
 */
 
38
 'removeClass',
 
39
 
 
40
/**
 
41
 * Replace a class with another class for each node.
 
42
 * If no oldClassName is present, the newClassName is simply added.
 
43
 * @method replaceClass
 
44
 * @param {String} oldClassName the class name to be replaced
 
45
 * @param {String} newClassName the class name that will be replacing the old class name
 
46
 * @chainable
 
47
 */
 
48
 'replaceClass',
 
49
 
 
50
/**
 
51
 * If the className exists on the node it is removed, if it doesn't exist it is added.
 
52
 * @method toggleClass
 
53
 * @param {String} className the class name to be toggled
 
54
 * @param {Boolean} force Option to force adding or removing the class.
 
55
 * @chainable
 
56
 */
 
57
 'toggleClass'
 
58
];
 
59
 
 
60
Y.Node.importMethod(Y.DOM, methods);
 
61
/**
 
62
 * Determines whether each node has the given className.
 
63
 * @method hasClass
 
64
 * @see Node.hasClass
 
65
 * @for NodeList
 
66
 * @param {String} className the class name to search for
 
67
 * @return {Array} An array of booleans for each node bound to the NodeList.
 
68
 */
 
69
 
 
70
/**
 
71
 * Adds a class name to each node.
 
72
 * @method addClass
 
73
 * @see Node.addClass
 
74
 * @param {String} className the class name to add to the node's class attribute
 
75
 * @chainable
 
76
 */
 
77
 
 
78
/**
 
79
 * Removes a class name from each node.
 
80
 * @method removeClass
 
81
 * @see Node.removeClass
 
82
 * @param {String} className the class name to remove from the node's class attribute
 
83
 * @chainable
 
84
 */
 
85
 
 
86
/**
 
87
 * Replace a class with another class for each node.
 
88
 * If no oldClassName is present, the newClassName is simply added.
 
89
 * @method replaceClass
 
90
 * @see Node.replaceClass
 
91
 * @param {String} oldClassName the class name to be replaced
 
92
 * @param {String} newClassName the class name that will be replacing the old class name
 
93
 * @chainable
 
94
 */
 
95
 
 
96
/**
 
97
 * If the className exists on the node it is removed, if it doesn't exist it is added.
 
98
 * @method toggleClass
 
99
 * @see Node.toggleClass
 
100
 * @param {String} className the class name to be toggled
 
101
 * @chainable
 
102
 */
 
103
Y.NodeList.importMethod(Y.Node.prototype, methods);
 
104
/**
 
105
 * @module node
 
106
 * @submodule node-base
 
107
 */
 
108
 
 
109
var Y_Node = Y.Node,
 
110
    Y_DOM = Y.DOM;
 
111
 
 
112
/**
 
113
 * Returns a new dom node using the provided markup string.
 
114
 * @method create
 
115
 * @static
 
116
 * @param {String} html The markup used to create the element
 
117
 * @param {HTMLDocument} doc An optional document context
 
118
 * @return {Node} A Node instance bound to a DOM node or fragment
 
119
 * @for Node
 
120
 */
 
121
Y_Node.create = function(html, doc) {
 
122
    if (doc && doc._node) {
 
123
        doc = doc._node;
 
124
    }
 
125
    return Y.one(Y_DOM.create(html, doc));
 
126
};
 
127
 
 
128
Y.mix(Y_Node.prototype, {
 
129
    /**
 
130
     * Creates a new Node using the provided markup string.
 
131
     * @method create
 
132
     * @param {String} html The markup used to create the element
 
133
     * @param {HTMLDocument} doc An optional document context
 
134
     * @return {Node} A Node instance bound to a DOM node or fragment
 
135
     */
 
136
    create: Y_Node.create,
 
137
 
 
138
    /**
 
139
     * Inserts the content before the reference node.
 
140
     * @method insert
 
141
     * @param {String | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert
 
142
     * @param {Int | Node | HTMLElement | String} where The position to insert at.
 
143
     * Possible "where" arguments
 
144
     * <dl>
 
145
     * <dt>Y.Node</dt>
 
146
     * <dd>The Node to insert before</dd>
 
147
     * <dt>HTMLElement</dt>
 
148
     * <dd>The element to insert before</dd>
 
149
     * <dt>Int</dt>
 
150
     * <dd>The index of the child element to insert before</dd>
 
151
     * <dt>"replace"</dt>
 
152
     * <dd>Replaces the existing HTML</dd>
 
153
     * <dt>"before"</dt>
 
154
     * <dd>Inserts before the existing HTML</dd>
 
155
     * <dt>"before"</dt>
 
156
     * <dd>Inserts content before the node</dd>
 
157
     * <dt>"after"</dt>
 
158
     * <dd>Inserts content after the node</dd>
 
159
     * </dl>
 
160
     * @chainable
 
161
     */
 
162
    insert: function(content, where) {
 
163
        this._insert(content, where);
 
164
        return this;
 
165
    },
 
166
 
 
167
    _insert: function(content, where) {
 
168
        var node = this._node,
 
169
            ret = null;
 
170
 
 
171
        if (typeof where == 'number') { // allow index
 
172
            where = this._node.childNodes[where];
 
173
        } else if (where && where._node) { // Node
 
174
            where = where._node;
 
175
        }
 
176
 
 
177
        if (content && typeof content != 'string') { // allow Node or NodeList/Array instances
 
178
            content = content._node || content._nodes || content;
 
179
        }
 
180
        ret = Y_DOM.addHTML(node, content, where);
 
181
 
 
182
        return ret;
 
183
    },
 
184
 
 
185
    /**
 
186
     * Inserts the content as the firstChild of the node.
 
187
     * @method prepend
 
188
     * @param {String | Node | HTMLElement} content The content to insert
 
189
     * @chainable
 
190
     */
 
191
    prepend: function(content) {
 
192
        return this.insert(content, 0);
 
193
    },
 
194
 
 
195
    /**
 
196
     * Inserts the content as the lastChild of the node.
 
197
     * @method append
 
198
     * @param {String | Node | HTMLElement} content The content to insert
 
199
     * @chainable
 
200
     */
 
201
    append: function(content) {
 
202
        return this.insert(content, null);
 
203
    },
 
204
 
 
205
    /**
 
206
     * @method appendChild
 
207
     * @param {String | HTMLElement | Node} node Node to be appended
 
208
     * @return {Node} The appended node
 
209
     */
 
210
    appendChild: function(node) {
 
211
        return Y_Node.scrubVal(this._insert(node));
 
212
    },
 
213
 
 
214
    /**
 
215
     * @method insertBefore
 
216
     * @param {String | HTMLElement | Node} newNode Node to be appended
 
217
     * @param {HTMLElement | Node} refNode Node to be inserted before
 
218
     * @return {Node} The inserted node
 
219
     */
 
220
    insertBefore: function(newNode, refNode) {
 
221
        return Y.Node.scrubVal(this._insert(newNode, refNode));
 
222
    },
 
223
 
 
224
    /**
 
225
     * Appends the node to the given node.
 
226
     * @method appendTo
 
227
     * @param {Node | HTMLElement} node The node to append to
 
228
     * @chainable
 
229
     */
 
230
    appendTo: function(node) {
 
231
        Y.one(node).append(this);
 
232
        return this;
 
233
    },
 
234
 
 
235
    /**
 
236
     * Replaces the node's current content with the content.
 
237
     * @method setContent
 
238
     * @param {String | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert
 
239
     * @chainable
 
240
     */
 
241
    setContent: function(content) {
 
242
        this._insert(content, 'replace');
 
243
        return this;
 
244
    },
 
245
 
 
246
    /**
 
247
     * Returns the node's current content (e.g. innerHTML)
 
248
     * @method getContent
 
249
     * @return {String} The current content
 
250
     */
 
251
    getContent: function(content) {
 
252
        return this.get('innerHTML');
 
253
    }
 
254
});
 
255
 
 
256
Y.NodeList.importMethod(Y.Node.prototype, [
 
257
    /**
 
258
     * Called on each Node instance
 
259
     * @for NodeList
 
260
     * @method append
 
261
     * @see Node.append
 
262
     */
 
263
    'append',
 
264
 
 
265
    /** Called on each Node instance
 
266
      * @method insert
 
267
      * @see Node.insert
 
268
      */
 
269
    'insert',
 
270
 
 
271
    /**
 
272
     * Called on each Node instance
 
273
     * @for NodeList
 
274
     * @method appendChild
 
275
     * @see Node.appendChild
 
276
     */
 
277
    'appendChild',
 
278
 
 
279
    /** Called on each Node instance
 
280
      * @method insertBefore
 
281
      * @see Node.insertBefore
 
282
      */
 
283
    'insertBefore',
 
284
 
 
285
    /** Called on each Node instance
 
286
      * @method prepend
 
287
      * @see Node.prepend
 
288
      */
 
289
    'prepend',
 
290
 
 
291
    /** Called on each Node instance
 
292
      * @method setContent
 
293
      * @see Node.setContent
 
294
      */
 
295
    'setContent',
 
296
 
 
297
    /** Called on each Node instance
 
298
      * @method getContent
 
299
      * @see Node.getContent
 
300
      */
 
301
    'getContent'
 
302
]);
 
303
/**
 
304
 * @module node
 
305
 * @submodule node-base
 
306
 */
 
307
 
 
308
var Y_Node = Y.Node,
 
309
    Y_DOM = Y.DOM;
 
310
 
 
311
/**
 
312
 * Static collection of configuration attributes for special handling
 
313
 * @property ATTRS
 
314
 * @static
 
315
 * @type object
 
316
 */
 
317
Y_Node.ATTRS = {
 
318
    /**
 
319
     * Allows for getting and setting the text of an element.
 
320
     * Formatting is preserved and special characters are treated literally.
 
321
     * @config text
 
322
     * @type String
 
323
     */
 
324
    text: {
 
325
        getter: function() {
 
326
            return Y_DOM.getText(this._node);
 
327
        },
 
328
 
 
329
        setter: function(content) {
 
330
            Y_DOM.setText(this._node, content);
 
331
            return content;
 
332
        }
 
333
    },
 
334
 
 
335
    /**
 
336
     * Allows for getting and setting the text of an element.
 
337
     * Formatting is preserved and special characters are treated literally.
 
338
     * @config for
 
339
     * @type String
 
340
     */
 
341
    'for': {
 
342
        getter: function() {
 
343
            return Y_DOM.getAttribute(this._node, 'for');
 
344
        },
 
345
 
 
346
        setter: function(val) {
 
347
            Y_DOM.setAttribute(this._node, 'for', val);
 
348
            return val;
 
349
        }
 
350
    },
 
351
 
 
352
    'options': {
 
353
        getter: function() {
 
354
            return this._node.getElementsByTagName('option');
 
355
        }
 
356
    },
 
357
 
 
358
    /**
 
359
     * Returns a NodeList instance of all HTMLElement children.
 
360
     * @readOnly
 
361
     * @config children
 
362
     * @type NodeList
 
363
     */
 
364
    'children': {
 
365
        getter: function() {
 
366
            var node = this._node,
 
367
                children = node.children,
 
368
                childNodes, i, len;
 
369
 
 
370
            if (!children) {
 
371
                childNodes = node.childNodes;
 
372
                children = [];
 
373
 
 
374
                for (i = 0, len = childNodes.length; i < len; ++i) {
 
375
                    if (childNodes[i][TAG_NAME]) {
 
376
                        children[children.length] = childNodes[i];
 
377
                    }
 
378
                }
 
379
            }
 
380
            return Y.all(children);
 
381
        }
 
382
    },
 
383
 
 
384
    value: {
 
385
        getter: function() {
 
386
            return Y_DOM.getValue(this._node);
 
387
        },
 
388
 
 
389
        setter: function(val) {
 
390
            Y_DOM.setValue(this._node, val);
 
391
            return val;
 
392
        }
 
393
    }
 
394
};
 
395
 
 
396
Y.Node.importMethod(Y.DOM, [
 
397
    /**
 
398
     * Allows setting attributes on DOM nodes, normalizing in some cases.
 
399
     * This passes through to the DOM node, allowing for custom attributes.
 
400
     * @method setAttribute
 
401
     * @for Node
 
402
     * @for NodeList
 
403
     * @chainable
 
404
     * @param {string} name The attribute name
 
405
     * @param {string} value The value to set
 
406
     */
 
407
    'setAttribute',
 
408
    /**
 
409
     * Allows getting attributes on DOM nodes, normalizing in some cases.
 
410
     * This passes through to the DOM node, allowing for custom attributes.
 
411
     * @method getAttribute
 
412
     * @for Node
 
413
     * @for NodeList
 
414
     * @param {string} name The attribute name
 
415
     * @return {string} The attribute value
 
416
     */
 
417
    'getAttribute'
 
418
 
 
419
]);
 
420
/**
 
421
 * @module node
 
422
 * @submodule node-base
 
423
 */
 
424
 
 
425
var Y_Node = Y.Node;
 
426
var Y_NodeList = Y.NodeList;
 
427
/**
 
428
 * List of events that route to DOM events
 
429
 * @static
 
430
 * @property DOM_EVENTS
 
431
 * @for Node
 
432
 */
 
433
 
 
434
Y_Node.DOM_EVENTS = {
 
435
    abort: 1,
 
436
    beforeunload: 1,
 
437
    blur: 1,
 
438
    change: 1,
 
439
    click: 1,
 
440
    close: 1,
 
441
    command: 1,
 
442
    contextmenu: 1,
 
443
    dblclick: 1,
 
444
    DOMMouseScroll: 1,
 
445
    drag: 1,
 
446
    dragstart: 1,
 
447
    dragenter: 1,
 
448
    dragover: 1,
 
449
    dragleave: 1,
 
450
    dragend: 1,
 
451
    drop: 1,
 
452
    error: 1,
 
453
    focus: 1,
 
454
    key: 1,
 
455
    keydown: 1,
 
456
    keypress: 1,
 
457
    keyup: 1,
 
458
    load: 1,
 
459
    message: 1,
 
460
    mousedown: 1,
 
461
    mouseenter: 1,
 
462
    mouseleave: 1,
 
463
    mousemove: 1,
 
464
    mousemultiwheel: 1,
 
465
    mouseout: 1,
 
466
    mouseover: 1,
 
467
    mouseup: 1,
 
468
    mousewheel: 1,
 
469
    orientationchange: 1,
 
470
    reset: 1,
 
471
    resize: 1,
 
472
    select: 1,
 
473
    selectstart: 1,
 
474
    submit: 1,
 
475
    scroll: 1,
 
476
    textInput: 1,
 
477
    unload: 1
 
478
};
 
479
 
 
480
// Add custom event adaptors to this list.  This will make it so
 
481
// that delegate, key, available, contentready, etc all will
 
482
// be available through Node.on
 
483
Y.mix(Y_Node.DOM_EVENTS, Y.Env.evt.plugins);
 
484
 
 
485
Y.augment(Y_Node, Y.EventTarget);
 
486
 
 
487
Y.mix(Y_Node.prototype, {
 
488
    /**
 
489
     * Removes event listeners from the node and (optionally) its subtree
 
490
     * @method purge
 
491
     * @param {Boolean} recurse (optional) Whether or not to remove listeners from the
 
492
     * node's subtree
 
493
     * @param {String} type (optional) Only remove listeners of the specified type
 
494
     * @chainable
 
495
     *
 
496
     */
 
497
    purge: function(recurse, type) {
 
498
        Y.Event.purgeElement(this._node, recurse, type);
 
499
        return this;
 
500
    }
 
501
 
 
502
});
 
503
 
 
504
Y.mix(Y.NodeList.prototype, {
 
505
    _prepEvtArgs: function(type, fn, context) {
 
506
        // map to Y.on/after signature (type, fn, nodes, context, arg1, arg2, etc)
 
507
        var args = Y.Array(arguments, 0, true);
 
508
 
 
509
        if (args.length < 2) { // type only (event hash) just add nodes
 
510
            args[2] = this._nodes;
 
511
        } else {
 
512
            args.splice(2, 0, this._nodes);
 
513
        }
 
514
 
 
515
        args[3] = context || this; // default to NodeList instance as context
 
516
 
 
517
        return args;
 
518
    },
 
519
 
 
520
    /**
 
521
    Subscribe a callback function for each `Node` in the collection to execute
 
522
    in response to a DOM event.
 
523
 
 
524
    NOTE: Generally, the `on()` method should be avoided on `NodeLists`, in
 
525
    favor of using event delegation from a parent Node.  See the Event user
 
526
    guide for details.
 
527
 
 
528
    Most DOM events are associated with a preventable default behavior, such as
 
529
    link clicks navigating to a new page.  Callbacks are passed a
 
530
    `DOMEventFacade` object as their first argument (usually called `e`) that
 
531
    can be used to prevent this default behavior with `e.preventDefault()`. See
 
532
    the `DOMEventFacade` API for all available properties and methods on the
 
533
    object.
 
534
 
 
535
    By default, the `this` object will be the `NodeList` that the subscription
 
536
    came from, <em>not the `Node` that received the event</em>.  Use
 
537
    `e.currentTarget` to refer to the `Node`.
 
538
 
 
539
    Returning `false` from a callback is supported as an alternative to calling
 
540
    `e.preventDefault(); e.stopPropagation();`.  However, it is recommended to
 
541
    use the event methods.
 
542
 
 
543
    @example
 
544
 
 
545
        Y.all(".sku").on("keydown", function (e) {
 
546
            if (e.keyCode === 13) {
 
547
                e.preventDefault();
 
548
 
 
549
                // Use e.currentTarget to refer to the individual Node
 
550
                var item = Y.MyApp.searchInventory( e.currentTarget.get('value') );
 
551
                // etc ...
 
552
            }
 
553
        });
 
554
 
 
555
    @method on
 
556
    @param {String} type The name of the event
 
557
    @param {Function} fn The callback to execute in response to the event
 
558
    @param {Object} [context] Override `this` object in callback
 
559
    @param {Any} [arg*] 0..n additional arguments to supply to the subscriber
 
560
    @return {EventHandle} A subscription handle capable of detaching that
 
561
                          subscription
 
562
    @for NodeList
 
563
    **/
 
564
    on: function(type, fn, context) {
 
565
        return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments));
 
566
    },
 
567
 
 
568
    /**
 
569
     * Applies an one-time event listener to each Node bound to the NodeList.
 
570
     * @method once
 
571
     * @param {String} type The event being listened for
 
572
     * @param {Function} fn The handler to call when the event fires
 
573
     * @param {Object} context The context to call the handler with.
 
574
     * Default is the NodeList instance.
 
575
     * @return {EventHandle} A subscription handle capable of detaching that
 
576
     *                    subscription
 
577
     * @for NodeList
 
578
     */
 
579
    once: function(type, fn, context) {
 
580
        return Y.once.apply(Y, this._prepEvtArgs.apply(this, arguments));
 
581
    },
 
582
 
 
583
    /**
 
584
     * Applies an event listener to each Node bound to the NodeList.
 
585
     * The handler is called only after all on() handlers are called
 
586
     * and the event is not prevented.
 
587
     * @method after
 
588
     * @param {String} type The event being listened for
 
589
     * @param {Function} fn The handler to call when the event fires
 
590
     * @param {Object} context The context to call the handler with.
 
591
     * Default is the NodeList instance.
 
592
     * @return {EventHandle} A subscription handle capable of detaching that
 
593
     *                    subscription
 
594
     * @for NodeList
 
595
     */
 
596
    after: function(type, fn, context) {
 
597
        return Y.after.apply(Y, this._prepEvtArgs.apply(this, arguments));
 
598
    },
 
599
 
 
600
    /**
 
601
     * Applies an one-time event listener to each Node bound to the NodeList
 
602
     * that will be called only after all on() handlers are called and the
 
603
     * event is not prevented.
 
604
     *
 
605
     * @method onceAfter
 
606
     * @param {String} type The event being listened for
 
607
     * @param {Function} fn The handler to call when the event fires
 
608
     * @param {Object} context The context to call the handler with.
 
609
     * Default is the NodeList instance.
 
610
     * @return {EventHandle} A subscription handle capable of detaching that
 
611
     *                    subscription
 
612
     * @for NodeList
 
613
     */
 
614
    onceAfter: function(type, fn, context) {
 
615
        return Y.onceAfter.apply(Y, this._prepEvtArgs.apply(this, arguments));
 
616
    }
 
617
});
 
618
 
 
619
Y_NodeList.importMethod(Y.Node.prototype, [
 
620
    /**
 
621
      * Called on each Node instance
 
622
      * @method detach
 
623
      * @see Node.detach
 
624
      * @for NodeList
 
625
      */
 
626
    'detach',
 
627
 
 
628
    /** Called on each Node instance
 
629
      * @method detachAll
 
630
      * @see Node.detachAll
 
631
      * @for NodeList
 
632
      */
 
633
    'detachAll'
 
634
]);
 
635
 
 
636
/**
 
637
Subscribe a callback function to execute in response to a DOM event or custom
 
638
event.
 
639
 
 
640
Most DOM events are associated with a preventable default behavior such as
 
641
link clicks navigating to a new page.  Callbacks are passed a `DOMEventFacade`
 
642
object as their first argument (usually called `e`) that can be used to
 
643
prevent this default behavior with `e.preventDefault()`. See the
 
644
`DOMEventFacade` API for all available properties and methods on the object.
 
645
 
 
646
If the event name passed as the first parameter is not a whitelisted DOM event,
 
647
it will be treated as a custom event subscriptions, allowing
 
648
`node.fire('customEventName')` later in the code.  Refer to the Event user guide
 
649
for the full DOM event whitelist.
 
650
 
 
651
By default, the `this` object in the callback will refer to the subscribed
 
652
`Node`.
 
653
 
 
654
Returning `false` from a callback is supported as an alternative to calling
 
655
`e.preventDefault(); e.stopPropagation();`.  However, it is recommended to use
 
656
the event methods.
 
657
 
 
658
@example
 
659
 
 
660
    Y.one("#my-form").on("submit", function (e) {
 
661
        e.preventDefault();
 
662
 
 
663
        // proceed with ajax form submission instead...
 
664
    });
 
665
 
 
666
@method on
 
667
@param {String} type The name of the event
 
668
@param {Function} fn The callback to execute in response to the event
 
669
@param {Object} [context] Override `this` object in callback
 
670
@param {Any} [arg*] 0..n additional arguments to supply to the subscriber
 
671
@return {EventHandle} A subscription handle capable of detaching that
 
672
                      subscription
 
673
@for Node
 
674
**/
 
675
 
 
676
Y.mix(Y.Node.ATTRS, {
 
677
    offsetHeight: {
 
678
        setter: function(h) {
 
679
            Y.DOM.setHeight(this._node, h);
 
680
            return h;
 
681
        },
 
682
 
 
683
        getter: function() {
 
684
            return this._node.offsetHeight;
 
685
        }
 
686
    },
 
687
 
 
688
    offsetWidth: {
 
689
        setter: function(w) {
 
690
            Y.DOM.setWidth(this._node, w);
 
691
            return w;
 
692
        },
 
693
 
 
694
        getter: function() {
 
695
            return this._node.offsetWidth;
 
696
        }
 
697
    }
 
698
});
 
699
 
 
700
Y.mix(Y.Node.prototype, {
 
701
    sizeTo: function(w, h) {
 
702
        var node;
 
703
        if (arguments.length < 2) {
 
704
            node = Y.one(w);
 
705
            w = node.get('offsetWidth');
 
706
            h = node.get('offsetHeight');
 
707
        }
 
708
 
 
709
        this.setAttrs({
 
710
            offsetWidth: w,
 
711
            offsetHeight: h
 
712
        });
 
713
    }
 
714
});
 
715
/**
 
716
 * @module node
 
717
 * @submodule node-base
 
718
 */
 
719
 
 
720
var Y_Node = Y.Node;
 
721
 
 
722
Y.mix(Y_Node.prototype, {
 
723
    /**
 
724
     * Makes the node visible.
 
725
     * If the "transition" module is loaded, show optionally
 
726
     * animates the showing of the node using either the default
 
727
     * transition effect ('fadeIn'), or the given named effect.
 
728
     * @method show
 
729
     * @for Node
 
730
     * @param {String} name A named Transition effect to use as the show effect.
 
731
     * @param {Object} config Options to use with the transition.
 
732
     * @param {Function} callback An optional function to run after the transition completes.
 
733
     * @chainable
 
734
     */
 
735
    show: function(callback) {
 
736
        callback = arguments[arguments.length - 1];
 
737
        this.toggleView(true, callback);
 
738
        return this;
 
739
    },
 
740
 
 
741
    /**
 
742
     * The implementation for showing nodes.
 
743
     * Default is to toggle the style.display property.
 
744
     * @method _show
 
745
     * @protected
 
746
     * @chainable
 
747
     */
 
748
    _show: function() {
 
749
        this.setStyle('display', '');
 
750
 
 
751
    },
 
752
 
 
753
    _isHidden: function() {
 
754
        return Y.DOM.getStyle(this._node, 'display') === 'none';
 
755
    },
 
756
 
 
757
    toggleView: function(on, callback) {
 
758
        this._toggleView.apply(this, arguments);
 
759
    },
 
760
 
 
761
    _toggleView: function(on, callback) {
 
762
        callback = arguments[arguments.length - 1];
 
763
 
 
764
        // base on current state if not forcing
 
765
        if (typeof on != 'boolean') {
 
766
            on = (this._isHidden()) ? 1 : 0;
 
767
        }
 
768
 
 
769
        if (on) {
 
770
            this._show();
 
771
        }  else {
 
772
            this._hide();
 
773
        }
 
774
 
 
775
        if (typeof callback == 'function') {
 
776
            callback.call(this);
 
777
        }
 
778
 
 
779
        return this;
 
780
    },
 
781
 
 
782
    /**
 
783
     * Hides the node.
 
784
     * If the "transition" module is loaded, hide optionally
 
785
     * animates the hiding of the node using either the default
 
786
     * transition effect ('fadeOut'), or the given named effect.
 
787
     * @method hide
 
788
     * @param {String} name A named Transition effect to use as the show effect.
 
789
     * @param {Object} config Options to use with the transition.
 
790
     * @param {Function} callback An optional function to run after the transition completes.
 
791
     * @chainable
 
792
     */
 
793
    hide: function(callback) {
 
794
        callback = arguments[arguments.length - 1];
 
795
        this.toggleView(false, callback);
 
796
        return this;
 
797
    },
 
798
 
 
799
    /**
 
800
     * The implementation for hiding nodes.
 
801
     * Default is to toggle the style.display property.
 
802
     * @method _hide
 
803
     * @protected
 
804
     * @chainable
 
805
     */
 
806
    _hide: function() {
 
807
        this.setStyle('display', 'none');
 
808
    }
 
809
});
 
810
 
 
811
Y.NodeList.importMethod(Y.Node.prototype, [
 
812
    /**
 
813
     * Makes each node visible.
 
814
     * If the "transition" module is loaded, show optionally
 
815
     * animates the showing of the node using either the default
 
816
     * transition effect ('fadeIn'), or the given named effect.
 
817
     * @method show
 
818
     * @param {String} name A named Transition effect to use as the show effect.
 
819
     * @param {Object} config Options to use with the transition.
 
820
     * @param {Function} callback An optional function to run after the transition completes.
 
821
     * @for NodeList
 
822
     * @chainable
 
823
     */
 
824
    'show',
 
825
 
 
826
    /**
 
827
     * Hides each node.
 
828
     * If the "transition" module is loaded, hide optionally
 
829
     * animates the hiding of the node using either the default
 
830
     * transition effect ('fadeOut'), or the given named effect.
 
831
     * @method hide
 
832
     * @param {String} name A named Transition effect to use as the show effect.
 
833
     * @param {Object} config Options to use with the transition.
 
834
     * @param {Function} callback An optional function to run after the transition completes.
 
835
     * @chainable
 
836
     */
 
837
    'hide',
 
838
 
 
839
    'toggleView'
 
840
]);
 
841
 
 
842
if (!Y.config.doc.documentElement.hasAttribute) { // IE < 8
 
843
    Y.Node.prototype.hasAttribute = function(attr) {
 
844
        if (attr === 'value') {
 
845
            if (this.get('value') !== "") { // IE < 8 fails to populate specified when set in HTML
 
846
                return true;
 
847
            }
 
848
        }
 
849
        return !!(this._node.attributes[attr] &&
 
850
                this._node.attributes[attr].specified);
 
851
    };
 
852
}
 
853
 
 
854
// IE throws an error when calling focus() on an element that's invisible, not
 
855
// displayed, or disabled.
 
856
Y.Node.prototype.focus = function () {
 
857
    try {
 
858
        this._node.focus();
 
859
    } catch (e) {
 
860
        Y.log('error focusing node: ' + e.toString(), 'error', 'node');
 
861
    }
 
862
 
 
863
    return this;
 
864
};
 
865
 
 
866
// IE throws error when setting input.type = 'hidden',
 
867
// input.setAttribute('type', 'hidden') and input.attributes.type.value = 'hidden'
 
868
Y.Node.ATTRS.type = {
 
869
    setter: function(val) {
 
870
        if (val === 'hidden') {
 
871
            try {
 
872
                this._node.type = 'hidden';
 
873
            } catch(e) {
 
874
                this.setStyle('display', 'none');
 
875
                this._inputType = 'hidden';
 
876
            }
 
877
        } else {
 
878
            try { // IE errors when changing the type from "hidden'
 
879
                this._node.type = val;
 
880
            } catch (e) {
 
881
                Y.log('error setting type: ' + val, 'info', 'node');
 
882
            }
 
883
        }
 
884
        return val;
 
885
    },
 
886
 
 
887
    getter: function() {
 
888
        return this._inputType || this._node.type;
 
889
    },
 
890
 
 
891
    _bypassProxy: true // don't update DOM when using with Attribute
 
892
};
 
893
 
 
894
if (Y.config.doc.createElement('form').elements.nodeType) {
 
895
    // IE: elements collection is also FORM node which trips up scrubVal.
 
896
    Y.Node.ATTRS.elements = {
 
897
            getter: function() {
 
898
                return this.all('input, textarea, button, select');
 
899
            }
 
900
    };
 
901
}
 
902
 
 
903
 
 
904
 
 
905
}, '3.4.1' ,{requires:['dom-base', 'node-core', 'event-base']});