2010-11-15 08:39:52 +01:00
|
|
|
/*
|
2011-11-08 17:40:44 +01:00
|
|
|
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
|
2010-11-15 08:39:52 +01:00
|
|
|
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
|
|
|
see: http://dojotoolkit.org/license for details
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-11-08 17:40:44 +01:00
|
|
|
if(!dojo._hasResource["dijit._Contained"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
|
dojo._hasResource["dijit._Contained"] = true;
|
2010-11-15 08:39:52 +01:00
|
|
|
dojo.provide("dijit._Contained");
|
2011-11-08 17:40:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
dojo.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
|
|
|
|
// | dojo.declare("my.customClass",[dijit._Widget,dijit._Contained],{});
|
|
|
|
|
|
|
|
getParent: function(){
|
|
|
|
// summary:
|
|
|
|
// Returns the parent widget of this widget, assuming the parent
|
|
|
|
// specifies isContainer
|
|
|
|
var parent = dijit.getEnclosingWidget(this.domNode.parentNode);
|
|
|
|
return parent && parent.isContainer ? parent : null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_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 && dijit.byNode(node); // dijit._Widget
|
|
|
|
},
|
|
|
|
|
|
|
|
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._Widget
|
|
|
|
},
|
|
|
|
|
|
|
|
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._Widget
|
|
|
|
},
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2010-11-15 08:39:52 +01:00
|
|
|
}
|