Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BS-270 Added a tooltip to procedures buttons #723

Merged
merged 7 commits into from
Oct 26, 2023
42 changes: 42 additions & 0 deletions ui/app/clinical/consultation/directives/tooltip.js
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.
gsluthra marked this conversation as resolved.
Show resolved Hide resolved
tooltip.css({
position: "absolute",
top: element.offset().top + element.height(),
left: element.offset().left + element.width() / 2 - 70
gsluthra marked this conversation as resolved.
Show resolved Hide resolved
});

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();
});
}
};
}]);
4 changes: 3 additions & 1 deletion ui/app/clinical/consultation/views/orderSelector.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<a class="grid-row-element button orderBtn ng-binding ng-scope"
ng-click="toggleOrderSelection(test)"
ng-class="{active:isActiveOrderPresent(test), noteditable:isTestIndirectlyPresent(test)}"
ng-disabled="isTestIndirectlyPresent(test)">
ng-disabled="isTestIndirectlyPresent(test)"
tooltip="{{getName(test)}}"
>
<i class="fa fa-ok" ng-show="isActiveOrderPresent(test)"></i>{{getName(test)}}
</a>
</li>
Expand Down
1 change: 1 addition & 0 deletions ui/app/clinical/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ <h3 class="close" ng-click="closeTeleConsultation()">

<script src="consultation/services/treatmentConfig.js"></script>
<script src="consultation/filters/observationValue.js"></script>
<script src="consultation/directives/tooltip.js"></script>
<script src="consultation/directives/buttonsRadio.js"></script>
<script src="consultation/directives/orderSelector.js"></script>
<script src="consultation/directives/cdssPopover.js"></script>
Expand Down
Loading