source: Dev/trunk/src/client/dijit/_Contained.js @ 529

Last change on this file since 529 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.6 KB
Line 
1define([
2        "dojo/_base/declare", // declare
3        "./registry"    // registry.getEnclosingWidget(), registry.byNode()
4], function(declare, registry){
5
6        // module:
7        //              dijit/_Contained
8
9        return declare("dijit._Contained", null, {
10                // summary:
11                //              Mixin for widgets that are children of a container widget
12                // example:
13                //      |       // make a basic custom widget that knows about its parents
14                //      |       declare("my.customClass",[dijit._WidgetBase, dijit._Contained],{});
15
16                _getSibling: function(/*String*/ which){
17                        // summary:
18                        //              Returns next or previous sibling
19                        // which:
20                        //              Either "next" or "previous"
21                        // tags:
22                        //              private
23                        var node = this.domNode;
24                        do{
25                                node = node[which+"Sibling"];
26                        }while(node && node.nodeType != 1);
27                        return node && registry.byNode(node);   // dijit/_WidgetBase
28                },
29
30                getPreviousSibling: function(){
31                        // summary:
32                        //              Returns null if this is the first child of the parent,
33                        //              otherwise returns the next element sibling to the "left".
34
35                        return this._getSibling("previous"); // dijit/_WidgetBase
36                },
37
38                getNextSibling: function(){
39                        // summary:
40                        //              Returns null if this is the last child of the parent,
41                        //              otherwise returns the next element sibling to the "right".
42
43                        return this._getSibling("next"); // dijit/_WidgetBase
44                },
45
46                getIndexInParent: function(){
47                        // summary:
48                        //              Returns the index of this widget within its container parent.
49                        //              It returns -1 if the parent does not exist, or if the parent
50                        //              is not a dijit/_Container
51
52                        var p = this.getParent();
53                        if(!p || !p.getIndexOfChild){
54                                return -1; // int
55                        }
56                        return p.getIndexOfChild(this); // int
57                }
58        });
59});
Note: See TracBrowser for help on using the repository browser.