-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BS-270 Added a tooltip to procedures buttons (#723)
* BS-270 | Patrick | Add tooltip to procedures buttons * BS-270 | Patrick | Show tooltip only if text overflows * BS-270 | Patrick | fix formatting issues * BS-270 | Vijay, Mani | remove timeout discrepancy * BS-270 | Vijay, Mani | resolve timeout discrepancy * BS-270 | Patrick | Add comment for tooltip positioning --------- Co-authored-by: vijayanandtwks <vijayanand.s@thoughtworks.com>
- Loading branch information
1 parent
46927d8
commit e7168a6
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use strict"; | ||
|
||
angular.module("bahmni.clinical").directive("tooltip", ['$timeout', function ($timeout) { | ||
return { | ||
restrict: "A", | ||
link: function (scope, element, attrs) { | ||
var tooltip = angular.element('<div class="tooltip">'); | ||
tooltip.text(attrs.tooltip); | ||
|
||
// Tooltip element element positioning absolutely next to the element that the directive is applied to. | ||
tooltip.css({ | ||
position: "absolute", | ||
top: element.offset().top + element.height(), | ||
left: element.offset().left + element.width() / 2 - 70 | ||
}); | ||
|
||
tooltip.hide(); | ||
|
||
element.on("mouseover", function () { | ||
var isTextTruncated = element[0].scrollWidth > element[0].clientWidth; | ||
|
||
var isStillOnElement = true; | ||
var timeoutId = $timeout(function () { | ||
if (isStillOnElement && isTextTruncated) { | ||
tooltip.show(); | ||
} | ||
}, 1000); | ||
element.on("mouseout", function () { | ||
isStillOnElement = false; | ||
clearTimeout(timeoutId); | ||
tooltip.hide(); | ||
}); | ||
}); | ||
|
||
angular.element(document.body).append(tooltip); | ||
|
||
element.on("$destroy", function () { | ||
tooltip.remove(); | ||
}); | ||
} | ||
}; | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters