mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
Add a function to get information about the tab a widget is on
This commit is contained in:
parent
4308444034
commit
a462f30f9c
@ -248,6 +248,42 @@ var et2_DOMWidget = (function(){ "use strict"; return et2_widget.extend(et2_IDOM
|
||||
return this._surroundingsMgr;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get data for the tab this widget is on.
|
||||
*
|
||||
* Will return null if the widget is not on a tab or tab data containing
|
||||
* - id
|
||||
* - label
|
||||
* - widget (top level widget)
|
||||
* - contentDiv (jQuery object for the div the tab content is in)
|
||||
*
|
||||
* @returns {Object|null} Data for tab the widget is on
|
||||
*/
|
||||
get_tab_info: function() {
|
||||
var parent = this;
|
||||
do {
|
||||
parent = parent._parent;
|
||||
} while (parent !== this.getRoot() && parent._type !== 'tabbox');
|
||||
|
||||
// No tab
|
||||
if(parent === this.getRoot())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Find the tab index
|
||||
for(var i = 0; i < parent.tabData.length; i++)
|
||||
{
|
||||
// Find the tab
|
||||
if(parent.tabData[i].contentDiv.has(this.div).length)
|
||||
{
|
||||
return parent.tabData[i];
|
||||
}
|
||||
}
|
||||
// On a tab, but we couldn't find it? This gives best result so far.
|
||||
return this._parent.get_tab_info();
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the parent DOM node of this element. Takes a wider variety of types
|
||||
* than setParentDOMNode(), and matches the set_<attribute> naming convention.
|
||||
|
Loading…
Reference in New Issue
Block a user