diff --git a/etemplate/js/et2_tabs.js b/etemplate/js/et2_tabs.js
index 059d4d745e..bb69cbb4a9 100644
--- a/etemplate/js/et2_tabs.js
+++ b/etemplate/js/et2_tabs.js
@@ -23,6 +23,10 @@
*/
var et2_tabbox = et2_DOMWidget.extend({
+ /**
+ * Currently selected tab
+ */
+ selected_index: 0,
init: function(_parent, _type) {
// Create the outer tabbox container
this.container = $j(document.createElement("div"))
@@ -53,14 +57,47 @@ var et2_tabbox = et2_DOMWidget.extend({
},
_readTabs: function(tabData, tabs) {
+ var selected = "";
+ this.selected_index = 0;
+ var hidden = {};
+ if (this.id)
+ {
+ // Set the value for this element
+ var contentMgr = this.getArrayMgr("content");
+ if (contentMgr != null) {
+ var val = contentMgr.getValueForID(this.id);
+ if (val !== null)
+ {
+ selected = val;
+ }
+ }
+ contentMgr = this.getArrayMgr("readonlys");
+ if (contentMgr != null) {
+ var val = contentMgr.getValueForID(this.id);
+ if (val !== null)
+ {
+ hidden = val;
+ }
+ }
+ }
+ var i = 0;
et2_filteredNodeIterator(tabs, function(node, nodeName) {
if (nodeName == "tab")
{
+ var index_name = et2_readAttrWithDefault(node, "label");
+ var hide = false;
+ if(index_name) {
+ if(selected == index_name) this.selected_index = i;
+ if(hidden[index_name]) {
+ hide = true;
+ }
+ }
tabData.push({
"label": egw.lang(et2_readAttrWithDefault(node, "label", "Tab")),
"widget": null,
"contentDiv": null,
- "flagDiv": null
+ "flagDiv": null,
+ "hidden": hide
});
}
else
@@ -68,6 +105,7 @@ var et2_tabbox = et2_DOMWidget.extend({
throw("Error while parsing: Invalid tag '" + nodeName +
"' in tabs tag");
}
+ i++;
}, this);
},
@@ -124,24 +162,31 @@ var et2_tabbox = et2_DOMWidget.extend({
for (var i = 0; i < this.tabData.length; i++)
{
var entry = this.tabData[i];
-
entry.flagDiv = $j(document.createElement("span"))
.addClass("et2_tabflag")
.text(entry.label)
- .appendTo(this.flagContainer)
- .click({"tabs": this, "idx": i}, function(e) {
+ .appendTo(this.flagContainer);
+ if(entry.hidden)
+ {
+ entry.flagDiv.hide();
+ }
+ else
+ {
+ entry.flagDiv.click({"tabs": this, "idx": i}, function(e) {
e.data.tabs.setActiveTab(e.data.idx);
});
-
+ }
entry.contentDiv = $j(document.createElement("div"))
.addClass("et2_tabcntr")
.appendTo(this.tabContainer);
}
- this.setActiveTab(0);
+ this.setActiveTab(this.selected_index);
},
setActiveTab: function(_idx) {
+ this.selected_index = _idx;
+
// Remove the "active" flag from all tabs-flags
$j(".et2_tabflag", this.flagContainer).removeClass("active");
diff --git a/etemplate/js/test/et2_test_tabbox.json b/etemplate/js/test/et2_test_tabbox.json
new file mode 100644
index 0000000000..2b1a829ece
--- /dev/null
+++ b/etemplate/js/test/et2_test_tabbox.json
@@ -0,0 +1,10 @@
+var tabbox_data = {
+ "content": {
+ "tab_1": "Test4"
+ },
+ "readonlys": {
+ "tab_1": {
+ "Disabled": true
+ }
+ }
+}
diff --git a/etemplate/js/test/et2_test_tabbox.xet b/etemplate/js/test/et2_test_tabbox.xet
index cc6eb75b03..b0d517d341 100644
--- a/etemplate/js/test/et2_test_tabbox.xet
+++ b/etemplate/js/test/et2_test_tabbox.xet
@@ -1,16 +1,14 @@
-
+
+
-
-
-
@@ -20,6 +18,10 @@
+
+
+
+
diff --git a/etemplate/js/test/test_xml.html b/etemplate/js/test/test_xml.html
index 8d78f3a41e..c0df2b195b 100644
--- a/etemplate/js/test/test_xml.html
+++ b/etemplate/js/test/test_xml.html
@@ -38,6 +38,7 @@
+
@@ -60,7 +61,7 @@
Timesheet edit dialog
Template proxy test
Grid test
- Tabs test
+ Tabs test
Textbox test
Description test
Basic widgits