|
79 | 79 | element.removeAttr('tooltip-template-url'); |
80 | 80 | } |
81 | 81 |
|
| 82 | + if (element.attr('tooltip-template-url-cache') !== undefined) { |
| 83 | + |
| 84 | + attributesToAdd['tooltip-template-url-cache'] = element.attr('tooltip-template-url-cache'); |
| 85 | + element.removeAttr('tooltip-template-url-cache'); |
| 86 | + } |
| 87 | + |
82 | 88 | if (element.attr('tooltip-controller') !== undefined) { |
83 | 89 |
|
84 | 90 | attributesToAdd['tooltip-controller'] = element.attr('tooltip-controller'); |
|
212 | 218 | 'smart': false, |
213 | 219 | 'closeButton': false, |
214 | 220 | 'size': '', |
215 | | - 'speed': 'steady' |
| 221 | + 'speed': 'steady', |
| 222 | + 'tooltipTemplateUrlCache': false |
216 | 223 | }; |
217 | 224 |
|
218 | 225 | return { |
|
240 | 247 | } |
241 | 248 | }; |
242 | 249 | } |
243 | | - , tooltipDirective = /*@ngInject*/ ["$log", "$http", "$compile", "$timeout", "$controller", "$injector", "tooltipsConf", function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf) { |
| 250 | + , tooltipDirective = /*@ngInject*/ ["$log", "$http", "$compile", "$timeout", "$controller", "$injector", "tooltipsConf", "$templateCache", function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf) { |
244 | 251 |
|
245 | 252 | var linkingFunction = function linkingFunction($scope, $element, $attrs, $controllerDirective, $transcludeFunc) { |
246 | 253 |
|
|
557 | 564 | } |
558 | 565 | } |
559 | 566 | , onTooltipTemplateChange = function onTooltipTemplateChange(newValue) { |
560 | | - |
561 | 567 | if (newValue) { |
562 | 568 | tooltipElement.removeClass('_force-hidden'); //see lines below, this forces to hide tooltip when is empty |
563 | 569 | tipTipElement.empty(); |
|
574 | 580 | } |
575 | 581 | } |
576 | 582 | , onTooltipTemplateUrlChange = function onTooltipTemplateUrlChange(newValue) { |
577 | | - |
578 | 583 | if (newValue) { |
579 | 584 |
|
580 | 585 | $http.get(newValue).then(function onResponse(response) { |
|
598 | 603 | tooltipElement.addClass('_force-hidden'); //force to be hidden if empty |
599 | 604 | } |
600 | 605 | } |
| 606 | + , onTooltipTemplateUrlCacheChange = function onTooltipTemplateUrlCacheChange(newValue) { |
| 607 | + if (newValue && $attrs.tooltipTemplateUrl) { |
| 608 | + |
| 609 | + var template = $templateCache.get($attrs.tooltipTemplateUrl); |
| 610 | + |
| 611 | + if (typeof template !== 'undefined') { |
| 612 | + |
| 613 | + tooltipElement.removeClass('_force-hidden'); //see lines below, this forces to hide tooltip when is empty |
| 614 | + tipTipElement.empty(); |
| 615 | + tipTipElement.append(closeButtonElement); |
| 616 | + tipTipElement.append($compile(response.data)(scope)); |
| 617 | + $timeout(function doLater() { |
| 618 | + |
| 619 | + onTooltipShow(); |
| 620 | + }); |
| 621 | + } |
| 622 | + } else { |
| 623 | + //hide tooltip because is empty |
| 624 | + tipTipElement.empty(); |
| 625 | + tooltipElement.addClass('_force-hidden'); //force to be hidden if empty |
| 626 | + } |
| 627 | + } |
601 | 628 | , onTooltipSideChange = function onTooltipSideChange(newValue) { |
602 | 629 |
|
603 | 630 | if (newValue) { |
|
718 | 745 | } |
719 | 746 | , unregisterOnTooltipTemplateChange = $attrs.$observe('tooltipTemplate', onTooltipTemplateChange) |
720 | 747 | , unregisterOnTooltipTemplateUrlChange = $attrs.$observe('tooltipTemplateUrl', onTooltipTemplateUrlChange) |
| 748 | + , unregisterOnTooltipTemplateUrlCacheChange = $attrs.$observe('tooltipTemplateUrlCache', onTooltipTemplateUrlCacheChange) |
721 | 749 | , unregisterOnTooltipSideChangeObserver = $attrs.$observe('tooltipSide', onTooltipSideChange) |
722 | 750 | , unregisterOnTooltipShowTrigger = $attrs.$observe('tooltipShowTrigger', onTooltipShowTrigger) |
723 | 751 | , unregisterOnTooltipHideTrigger = $attrs.$observe('tooltipHideTrigger', onTooltipHideTrigger) |
|
777 | 805 |
|
778 | 806 | unregisterOnTooltipTemplateChange(); |
779 | 807 | unregisterOnTooltipTemplateUrlChange(); |
| 808 | + unregisterOnTooltipTemplateUrlCacheChange(); |
780 | 809 | unregisterOnTooltipSideChangeObserver(); |
781 | 810 | unregisterOnTooltipShowTrigger(); |
782 | 811 | unregisterOnTooltipHideTrigger(); |
|
0 commit comments