From 220cfd36be97ce813fdb0b5b8ebdfee025f53b8f Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 22 Jun 2017 15:17:35 +0200 Subject: [PATCH] help tip can be changed in the runtime --- .../src/main/js/gui/leftPanel/Panel.js | 60 ++++++++++++------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/frontend-js/src/main/js/gui/leftPanel/Panel.js b/frontend-js/src/main/js/gui/leftPanel/Panel.js index 7b5d45d2f6..71c51b3296 100644 --- a/frontend-js/src/main/js/gui/leftPanel/Panel.js +++ b/frontend-js/src/main/js/gui/leftPanel/Panel.js @@ -26,29 +26,8 @@ function Panel(params) { $(self.getElement()).css("position", "relative"); if (params.helpTip !== undefined) { - var helpTipButton = Functions.createElement({ - type : "button", - style : "position: absolute; top:5px; right: 5px;width:18px", - content : '<span class="ui-icon ui-icon-help" style="margin-left: -0.5em;"/>', - }); - helpTipButton.onclick = function() { - var helpDialogDiv = Functions.createElement({ - type : "div", - content : params.helpTip, - }); - $(helpDialogDiv).dialog({ - close : function(event, ui) { - $(this).dialog('destroy').remove(); - }, - position : { - my : "left top", - at : "left bottom", - of : helpTipButton - }, - }); - $('.ui-dialog').find("a").blur(); - }; - self.getElement().appendChild(helpTipButton); + self.createHelpButton(); + self.setHelpTip(params.helpTip); } GuiConnector.addWindowResizeEvent(function() { @@ -63,6 +42,33 @@ function Panel(params) { Panel.prototype = Object.create(AbstractGuiElement.prototype); Panel.prototype.constructor = Panel; +Panel.prototype.createHelpButton = function() { + var self = this; + var helpTipButton = Functions.createElement({ + type : "button", + style : "position: absolute; top:5px; right: 5px;width:18px", + content : '<span class="ui-icon ui-icon-help" style="margin-left: -0.5em;"/>', + }); + helpTipButton.onclick = function() { + var helpDialogDiv = Functions.createElement({ + type : "div", + content : self.getHelpTip(), + }); + $(helpDialogDiv).dialog({ + close : function(event, ui) { + $(this).dialog('destroy').remove(); + }, + position : { + my : "left top", + at : "left bottom", + of : helpTipButton + }, + }); + $('.ui-dialog').find("a").blur(); + }; + self.getElement().appendChild(helpTipButton); +}; + Panel.prototype.disablePanel = function(message) { var self = this; @@ -447,6 +453,14 @@ Panel.prototype.getParent = function() { return this._parent; }; +Panel.prototype.setHelpTip = function(helpTip) { + this._helpTip = helpTip; +}; + +Panel.prototype.getHelpTip = function() { + return this._helpTip; +}; + Panel.prototype.onresize = function() { var self = this; var footerPosition = window.innerHeight; -- GitLab