diff options
author | Richard Beales <[email protected]> | 2013-03-18 07:32:01 +0000 |
---|---|---|
committer | Richard Beales <[email protected]> | 2013-03-18 07:32:01 +0000 |
commit | 7c97d17aaf373339a8bcd917ad59ca6018148f0d (patch) | |
tree | 5a3c04f0f9529be392c1263d3feb75806eb43797 /lib/dijit/_Contained.js.uncompressed.js | |
parent | 70db7424e7068701e60cc5bcdfe8f858be508179 (diff) | |
parent | c670a80ddd9b03bd4ea6d940a9ed682fd26248d7 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'lib/dijit/_Contained.js.uncompressed.js')
-rw-r--r-- | lib/dijit/_Contained.js.uncompressed.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/dijit/_Contained.js.uncompressed.js b/lib/dijit/_Contained.js.uncompressed.js new file mode 100644 index 000000000..280a368db --- /dev/null +++ b/lib/dijit/_Contained.js.uncompressed.js @@ -0,0 +1,60 @@ +define("dijit/_Contained", [ + "dojo/_base/declare", // declare + "./registry" // registry.getEnclosingWidget(), registry.byNode() +], function(declare, registry){ + + // module: + // dijit/_Contained + + return declare("dijit._Contained", null, { + // summary: + // Mixin for widgets that are children of a container widget + // + // example: + // | // make a basic custom widget that knows about it's parents + // | declare("my.customClass",[dijit._Widget,dijit._Contained],{}); + + _getSibling: function(/*String*/ which){ + // summary: + // Returns next or previous sibling + // which: + // Either "next" or "previous" + // tags: + // private + var node = this.domNode; + do{ + node = node[which+"Sibling"]; + }while(node && node.nodeType != 1); + return node && registry.byNode(node); // dijit/_WidgetBase + }, + + getPreviousSibling: function(){ + // summary: + // Returns null if this is the first child of the parent, + // otherwise returns the next element sibling to the "left". + + return this._getSibling("previous"); // dijit/_WidgetBase + }, + + getNextSibling: function(){ + // summary: + // Returns null if this is the last child of the parent, + // otherwise returns the next element sibling to the "right". + + return this._getSibling("next"); // dijit/_WidgetBase + }, + + getIndexInParent: function(){ + // summary: + // Returns the index of this widget within its container parent. + // It returns -1 if the parent does not exist, or if the parent + // is not a dijit._Container + + var p = this.getParent(); + if(!p || !p.getIndexOfChild){ + return -1; // int + } + return p.getIndexOfChild(this); // int + } + }); +}); |