Version 3.18.1
Show:

File: tree/js/extensions/tree-node-selectable.js

            /**
            @module tree
            @submodule tree-selectable
            **/
            
            /**
            `Tree.Node` extension that adds methods useful for nodes in trees that use the
            `Tree.Selectable` extension.
            
            @class Tree.Node.Selectable
            @constructor
            @extensionfor Tree.Node
            **/
            
            function NodeSelectable() {}
            
            NodeSelectable.prototype = {
                /**
                Returns `true` if this node is currently selected.
            
                @method isSelected
                @return {Boolean} `true` if this node is currently selected, `false`
                    otherwise.
                **/
                isSelected: function () {
                    return !!this.state.selected;
                },
            
                /**
                Selects this node.
            
                @method select
                @param {Object} [options] Options.
                    @param {Boolean} [options.silent=false] If `true`, the `select` event
                        will be suppressed.
                    @param {String} [options.src] Source of the change, to be passed along
                        to the event facade of the resulting event. This can be used to
                        distinguish between changes triggered by a user and changes
                        triggered programmatically, for example.
                @chainable
                **/
                select: function (options) {
                    this.tree.selectNode(this, options);
                    return this;
                },
            
                /**
                Unselects this node.
            
                @method unselect
                @param {Object} [options] Options.
                    @param {Boolean} [options.silent=false] If `true`, the `unselect` event
                        will be suppressed.
                    @param {String} [options.src] Source of the change, to be passed along
                        to the event facade of the resulting event. This can be used to
                        distinguish between changes triggered by a user and changes
                        triggered programmatically, for example.
                @chainable
                **/
                unselect: function (options) {
                    this.tree.unselectNode(this, options);
                    return this;
                }
            };
            
            Y.Tree.Node.Selectable = NodeSelectable;