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