#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# File: node/js/node-view.js

    /**
     * @module node
     * @submodule node-base
     */

    var Y_Node = Y.Node;

    Y.mix(Y_Node.prototype, {
        /**
         * Makes the node visible.
         * If the "transition" module is loaded, show optionally
         * animates the showing of the node using either the default
         * transition effect ('fadeIn'), or the given named effect.
         * @method show
         * @for Node
         * @param {String} name A named Transition effect to use as the show effect.
         * @param {Object} config Options to use with the transition.
         * @param {Function} callback An optional function to run after the transition completes.
         * @chainable
         */
        show: function(callback) {
            callback = arguments[arguments.length - 1];
            this.toggleView(true, callback);
            return this;
        },

        /**
         * The implementation for showing nodes.
         * Default is to remove the hidden attribute and reset the CSS style.display property.
         * @method _show
         * @protected
         * @chainable
         */
        _show: function() {
            this.removeAttribute('hidden');

            // For back-compat we need to leave this in for browsers that
            // do not visually hide a node via the hidden attribute
            // and for users that check visibility based on style display.
            this.setStyle('display', '');

        },

        _isHidden: function() {
            return Y.DOM.getAttribute(this._node, 'hidden') === 'true';
        },

        /**
         * Displays or hides the node.
         * If the "transition" module is loaded, toggleView optionally
         * animates the toggling of the node using given named effect.
         * @method toggleView
         * @for Node
         * @param {String} [name] An optional string value to use as transition effect.
         * @param {Boolean} [on] An optional boolean value to force the node to be shown or hidden
         * @param {Function} [callback] An optional function to run after the transition completes.
         * @chainable
         */
        toggleView: function(on, callback) {
            this._toggleView.apply(this, arguments);
            return this;
        },

        _toggleView: function(on, callback) {
            callback = arguments[arguments.length - 1];

            // base on current state if not forcing
            if (typeof on != 'boolean') {
                on = (this._isHidden()) ? 1 : 0;
            }

            if (on) {
                this._show();
            }  else {
                this._hide();
            }

            if (typeof callback == 'function') {
                callback.call(this);
            }

            return this;
        },

        /**
         * Hides the node.
         * If the "transition" module is loaded, hide optionally
         * animates the hiding of the node using either the default
         * transition effect ('fadeOut'), or the given named effect.
         * @method hide
         * @param {String} name A named Transition effect to use as the show effect.
         * @param {Object} config Options to use with the transition.
         * @param {Function} callback An optional function to run after the transition completes.
         * @chainable
         */
        hide: function(callback) {
            callback = arguments[arguments.length - 1];
            this.toggleView(false, callback);
            return this;
        },

        /**
         * The implementation for hiding nodes.
         * Default is to set the hidden attribute to true and set the CSS style.display to 'none'.
         * @method _hide
         * @protected
         * @chainable
         */
        _hide: function() {
            this.setAttribute('hidden', true);

            // For back-compat we need to leave this in for browsers that
            // do not visually hide a node via the hidden attribute
            // and for users that check visibility based on style display.
            this.setStyle('display', 'none');
        }
    });

    Y.NodeList.importMethod(Y.Node.prototype, [
        /**
         * Makes each node visible.
         * If the "transition" module is loaded, show optionally
         * animates the showing of the node using either the default
         * transition effect ('fadeIn'), or the given named effect.
         * @method show
         * @param {String} name A named Transition effect to use as the show effect.
         * @param {Object} config Options to use with the transition.
         * @param {Function} callback An optional function to run after the transition completes.
         * @for NodeList
         * @chainable
         */
        'show',

        /**
         * Hides each node.
         * If the "transition" module is loaded, hide optionally
         * animates the hiding of the node using either the default
         * transition effect ('fadeOut'), or the given named effect.
         * @method hide
         * @param {String} name A named Transition effect to use as the show effect.
         * @param {Object} config Options to use with the transition.
         * @param {Function} callback An optional function to run after the transition completes.
         * @chainable
         */
        'hide',

        /**
         * Displays or hides each node.
         * If the "transition" module is loaded, toggleView optionally
         * animates the toggling of the nodes using given named effect.
         * @method toggleView
         * @param {String} [name] An optional string value to use as transition effect.
         * @param {Boolean} [on] An optional boolean value to force the nodes to be shown or hidden
         * @param {Function} [callback] An optional function to run after the transition completes.
         * @chainable
         */
        'toggleView'
    ]);