mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-29 06:11:40 +02:00
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:
parent
2d7aed2f4b
commit
fdd275c605
@ -109,6 +109,8 @@ var et2_tabbox = /** @class */ (function (_super) {
|
|||||||
}
|
}
|
||||||
tabData.push({
|
tabData.push({
|
||||||
"id": index_name,
|
"id": index_name,
|
||||||
|
"onclick": et2_readAttrWithDefault(node, "onclick", ''),
|
||||||
|
"ondblclick": et2_readAttrWithDefault(node, "ondblclick", ''),
|
||||||
"label": this.egw().lang(et2_readAttrWithDefault(node, "label", "Tab")),
|
"label": this.egw().lang(et2_readAttrWithDefault(node, "label", "Tab")),
|
||||||
"widget": null,
|
"widget": null,
|
||||||
"widget_options": widget_options,
|
"widget_options": widget_options,
|
||||||
@ -287,6 +289,19 @@ var et2_tabbox = /** @class */ (function (_super) {
|
|||||||
entry.flagDiv.hide();
|
entry.flagDiv.hide();
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
entry.flagDiv.click({ "tabs": this, "idx": i }, function (e) {
|
||||||
e.data.tabs.setActiveTab(e.data.idx);
|
e.data.tabs.setActiveTab(e.data.idx);
|
||||||
});
|
});
|
||||||
|
@ -139,6 +139,8 @@ class et2_tabbox extends et2_valueWidget implements et2_IInput,et2_IResizeable,e
|
|||||||
}
|
}
|
||||||
tabData.push({
|
tabData.push({
|
||||||
"id": index_name,
|
"id": index_name,
|
||||||
|
"onclick": et2_readAttrWithDefault(node, "onclick", ''),
|
||||||
|
"ondblclick": et2_readAttrWithDefault(node, "ondblclick", ''),
|
||||||
"label": this.egw().lang(et2_readAttrWithDefault(node, "label", "Tab")),
|
"label": this.egw().lang(et2_readAttrWithDefault(node, "label", "Tab")),
|
||||||
"widget": null,
|
"widget": null,
|
||||||
"widget_options": widget_options,
|
"widget_options": widget_options,
|
||||||
@ -364,11 +366,26 @@ class et2_tabbox extends et2_valueWidget implements et2_IInput,et2_IResizeable,e
|
|||||||
entry.flagDiv.hide();
|
entry.flagDiv.hide();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entry.flagDiv.click({"tabs": this, "idx": i}, function(e) {
|
if(this.tabData[i]['onclick'])
|
||||||
e.data.tabs.setActiveTab(e.data.idx);
|
{
|
||||||
});
|
/* ...(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"))
|
entry.contentDiv = jQuery(document.createElement("div"))
|
||||||
.addClass("et2_tabcntr")
|
.addClass("et2_tabcntr")
|
||||||
.appendTo(this.tabContainer);
|
.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());
|
this.setActiveTab(this.get_active_tab());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
et2_register_widget(et2_tabbox, ["tabbox"]);
|
et2_register_widget(et2_tabbox, ["tabbox"]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user