|
69 | 69 | element.removeAttr('tooltip-template-url'); |
70 | 70 | } |
71 | 71 |
|
| 72 | + if (element.attr('tooltip-template-url-cache') !== undefined) { |
| 73 | + |
| 74 | + attributesToAdd['tooltip-template-url-cache'] = element.attr('tooltip-template-url-cache'); |
| 75 | + element.removeAttr('tooltip-template-url-cache'); |
| 76 | + } |
| 77 | + |
72 | 78 | if (element.attr('tooltip-controller') !== undefined) { |
73 | 79 |
|
74 | 80 | attributesToAdd['tooltip-controller'] = element.attr('tooltip-controller'); |
|
202 | 208 | 'smart': false, |
203 | 209 | 'closeButton': false, |
204 | 210 | 'size': '', |
205 | | - 'speed': 'steady' |
| 211 | + 'speed': 'steady', |
| 212 | + 'tooltipTemplateUrlCache': false |
206 | 213 | }; |
207 | 214 |
|
208 | 215 | return { |
|
230 | 237 | } |
231 | 238 | }; |
232 | 239 | } |
233 | | - , tooltipDirective = /*@ngInject*/ function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf) { |
| 240 | + , tooltipDirective = /*@ngInject*/ ["$log", "$http", "$compile", "$timeout", "$controller", "$injector", "tooltipsConf", "$templateCache", function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf) { |
234 | 241 |
|
235 | 242 | var linkingFunction = function linkingFunction($scope, $element, $attrs, $controllerDirective, $transcludeFunc) { |
236 | 243 |
|
|
547 | 554 | } |
548 | 555 | } |
549 | 556 | , onTooltipTemplateChange = function onTooltipTemplateChange(newValue) { |
550 | | - |
551 | 557 | if (newValue) { |
552 | 558 | tooltipElement.removeClass('_force-hidden'); //see lines below, this forces to hide tooltip when is empty |
553 | 559 | tipTipElement.empty(); |
|
564 | 570 | } |
565 | 571 | } |
566 | 572 | , onTooltipTemplateUrlChange = function onTooltipTemplateUrlChange(newValue) { |
567 | | - |
568 | 573 | if (newValue) { |
569 | 574 |
|
570 | 575 | $http.get(newValue).then(function onResponse(response) { |
|
588 | 593 | tooltipElement.addClass('_force-hidden'); //force to be hidden if empty |
589 | 594 | } |
590 | 595 | } |
| 596 | + , onTooltipTemplateUrlCacheChange = function onTooltipTemplateUrlCacheChange(newValue) { |
| 597 | + if (newValue && $attrs.tooltipTemplateUrl) { |
| 598 | + |
| 599 | + var template = $templateCache.get($attrs.tooltipTemplateUrl); |
| 600 | + |
| 601 | + if (typeof template !== 'undefined') { |
| 602 | + |
| 603 | + tooltipElement.removeClass('_force-hidden'); //see lines below, this forces to hide tooltip when is empty |
| 604 | + tipTipElement.empty(); |
| 605 | + tipTipElement.append(closeButtonElement); |
| 606 | + tipTipElement.append($compile(response.data)(scope)); |
| 607 | + $timeout(function doLater() { |
| 608 | + |
| 609 | + onTooltipShow(); |
| 610 | + }); |
| 611 | + } |
| 612 | + } else { |
| 613 | + //hide tooltip because is empty |
| 614 | + tipTipElement.empty(); |
| 615 | + tooltipElement.addClass('_force-hidden'); //force to be hidden if empty |
| 616 | + } |
| 617 | + } |
591 | 618 | , onTooltipSideChange = function onTooltipSideChange(newValue) { |
592 | 619 |
|
593 | 620 | if (newValue) { |
|
708 | 735 | } |
709 | 736 | , unregisterOnTooltipTemplateChange = $attrs.$observe('tooltipTemplate', onTooltipTemplateChange) |
710 | 737 | , unregisterOnTooltipTemplateUrlChange = $attrs.$observe('tooltipTemplateUrl', onTooltipTemplateUrlChange) |
| 738 | + , unregisterOnTooltipTemplateUrlCacheChange = $attrs.$observe('tooltipTemplateUrlCache', onTooltipTemplateUrlCacheChange) |
711 | 739 | , unregisterOnTooltipSideChangeObserver = $attrs.$observe('tooltipSide', onTooltipSideChange) |
712 | 740 | , unregisterOnTooltipShowTrigger = $attrs.$observe('tooltipShowTrigger', onTooltipShowTrigger) |
713 | 741 | , unregisterOnTooltipHideTrigger = $attrs.$observe('tooltipHideTrigger', onTooltipHideTrigger) |
|
767 | 795 |
|
768 | 796 | unregisterOnTooltipTemplateChange(); |
769 | 797 | unregisterOnTooltipTemplateUrlChange(); |
| 798 | + unregisterOnTooltipTemplateUrlCacheChange(); |
770 | 799 | unregisterOnTooltipSideChangeObserver(); |
771 | 800 | unregisterOnTooltipShowTrigger(); |
772 | 801 | unregisterOnTooltipHideTrigger(); |
|
789 | 818 | 'terminal': true, |
790 | 819 | 'link': linkingFunction |
791 | 820 | }; |
792 | | - }; |
| 821 | + }]; |
793 | 822 |
|
794 | 823 | angular.module('720kb.tooltips', []) |
795 | 824 | .provider(directiveName + 'Conf', tooltipConfigurationProvider) |
|
0 commit comments