Tabs of tabwidget, added onClick and ondDblclick events (#109)

* Tabs of tabwidget, added onClick and ondDblclick events

* OnClick and ondDblclick events on Tabs of tabwidget, parse functions only once.
This commit is contained in:
Alexandros Sigalas 2021-10-13 17:33:37 +03:00 committed by GitHub
parent 2d7aed2f4b
commit fdd275c605
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 5 deletions

View File

@ -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);
});

View File

@ -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"]);