diff --git a/api/js/etemplate/et2_widget_tabs.js b/api/js/etemplate/et2_widget_tabs.js index afc1821fdf..1a2d981b7c 100644 --- a/api/js/etemplate/et2_widget_tabs.js +++ b/api/js/etemplate/et2_widget_tabs.js @@ -109,6 +109,8 @@ var et2_tabbox = /** @class */ (function (_super) { } tabData.push({ "id": index_name, + "onclick": et2_readAttrWithDefault(node, "onclick", ''), + "ondblclick": et2_readAttrWithDefault(node, "ondblclick", ''), "label": this.egw().lang(et2_readAttrWithDefault(node, "label", "Tab")), "widget": null, "widget_options": widget_options, @@ -287,6 +289,19 @@ var et2_tabbox = /** @class */ (function (_super) { entry.flagDiv.hide(); } else { + if (this.tabData[i]['onclick']) { + /* ...(this.tab['onclick'], this.widget, this.widget) + why this.widget twice? + first is the widget, second is the method context. + second is optional, and defaults to the DOM node + */ + var click_function = function () { et2_compileLegacyJS(this.tab['onclick'], this.widget, this.widget)(this.widget); }; + entry.flagDiv.on("click", click_function.bind({ widget: this, tab: this.tabData[i] })); + } + if (this.tabData[i]['ondblclick']) { + var dblclick_function = function () { et2_compileLegacyJS(this.tab['ondblclick'], this.widget, this.widget)(this.widget); }; + entry.flagDiv.on("dblclick", dblclick_function.bind({ widget: this, tab: this.tabData[i] })); + } entry.flagDiv.click({ "tabs": this, "idx": i }, function (e) { e.data.tabs.setActiveTab(e.data.idx); }); diff --git a/api/js/etemplate/et2_widget_tabs.ts b/api/js/etemplate/et2_widget_tabs.ts index 5236ebf2aa..394f636c2a 100644 --- a/api/js/etemplate/et2_widget_tabs.ts +++ b/api/js/etemplate/et2_widget_tabs.ts @@ -139,6 +139,8 @@ class et2_tabbox extends et2_valueWidget implements et2_IInput,et2_IResizeable,e } tabData.push({ "id": index_name, + "onclick": et2_readAttrWithDefault(node, "onclick", ''), + "ondblclick": et2_readAttrWithDefault(node, "ondblclick", ''), "label": this.egw().lang(et2_readAttrWithDefault(node, "label", "Tab")), "widget": null, "widget_options": widget_options, @@ -364,11 +366,26 @@ class et2_tabbox extends et2_valueWidget implements et2_IInput,et2_IResizeable,e entry.flagDiv.hide(); } else - { - entry.flagDiv.click({"tabs": this, "idx": i}, function(e) { - e.data.tabs.setActiveTab(e.data.idx); - }); - } + { + if(this.tabData[i]['onclick']) + { + /* ...(this.tab['onclick'], this.widget, this.widget) + why this.widget twice? + first is the widget, second is the method context. + second is optional, and defaults to the DOM node + */ + let click_function = function(){et2_compileLegacyJS(this.tab['onclick'], this.widget, this.widget)(this.widget)}; + entry.flagDiv.on("click",click_function.bind({widget:this, tab:this.tabData[i]})); + } + if(this.tabData[i]['ondblclick']) + { + let dblclick_function = function(){et2_compileLegacyJS(this.tab['ondblclick'], this.widget, this.widget)(this.widget)}; + entry.flagDiv.on("dblclick",dblclick_function.bind({widget:this, tab:this.tabData[i]})); + } + entry.flagDiv.click({"tabs": this, "idx": i}, function(e) { + e.data.tabs.setActiveTab(e.data.idx); + }); + } entry.contentDiv = jQuery(document.createElement("div")) .addClass("et2_tabcntr") .appendTo(this.tabContainer); @@ -587,5 +604,6 @@ class et2_tabbox extends et2_valueWidget implements et2_IInput,et2_IResizeable,e } this.setActiveTab(this.get_active_tab()); } + } et2_register_widget(et2_tabbox, ["tabbox"]);