From 3956760c2310c34c0be7a021c7ea2498cab4c8bc Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 25 Sep 2020 11:53:00 +0200 Subject: [PATCH] Add tooltip for Tab's header, it can be set as attribute 'hint' in openTab framework app object too --- api/js/framework/fw_base.js | 2 +- api/js/framework/fw_ui.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api/js/framework/fw_base.js b/api/js/framework/fw_base.js index 2035806998..b516ddfbaa 100644 --- a/api/js/framework/fw_base.js +++ b/api/js/framework/fw_base.js @@ -492,7 +492,7 @@ var fw_base = (function(){ "use strict"; return Class.extend( _app.tab = this.tabsUi.addTab(_app.icon, this.tabClickCallback, this.tabCloseClickCallback, _app, _pos, _status); _app.tab.setTitle(_app.displayName); - + _app.tab.setHint(_app.hint ? _app.hint : ''); //Set the tab closeable if there's more than one tab this.tabsUi.setCloseable(this.tabsUi._isNotTheLastTab()); // Do not show tab header if the app is with status 5, means run in background diff --git a/api/js/framework/fw_ui.js b/api/js/framework/fw_ui.js index b1d219a6af..ecbaa2f809 100644 --- a/api/js/framework/fw_ui.js +++ b/api/js/framework/fw_ui.js @@ -308,6 +308,7 @@ function egw_fw_ui_tab(_parent, _contHeaderDiv, _contDiv, _icon, _callback, this.position = _pos; this.status = _status; this.notification = 0; + this.hint = ''; //Create the header div and set its "click" function and "hover" event this.headerDiv = document.createElement("span"); @@ -439,6 +440,17 @@ egw_fw_ui_tab.prototype.setTitle = function(_title) jQuery(this.headerH1).text(_title); }; +/** + * setHint sets tooltip of this tab. An existing tooltip will be removed. + * + * @param {string} _hint Text which should be displayed. + */ +egw_fw_ui_tab.prototype.setHint = function(_hint) +{ + this.hint = _hint; + egw().tooltipBind(jQuery(this.headerDiv), _hint); +}; + /** * setTitle sets the content of this tab. Existing content is removed. *