|
6 | 6 | * http://720kb.github.io/angular-tooltips |
7 | 7 | * |
8 | 8 | * MIT license |
9 | | - * Fri May 19 2017 |
| 9 | + * Thu May 18 2017 |
10 | 10 | */ |
11 | 11 | /*global angular,window*/ |
12 | 12 | (function withAngular(angular, window) { |
|
225 | 225 | 'closeButton': false, |
226 | 226 | 'size': '', |
227 | 227 | 'speed': 'steady', |
228 | | - 'tooltipTemplateUrlCache': true, |
| 228 | + 'tooltipTemplateUrlCache': false, |
229 | 229 | 'show': null |
230 | 230 | }; |
231 | 231 |
|
|
571 | 571 | registerOnScrollFrom(parentElement); |
572 | 572 | } |
573 | 573 | } |
574 | | - , showTemplate = function showTemplate(template) { |
575 | | - |
576 | | - tooltipElement.removeClass('_force-hidden'); //see lines below, this forces to hide tooltip when is empty |
577 | | - tipTipElement.empty(); |
578 | | - tipTipElement.append(closeButtonElement); |
579 | | - tipTipElement.append(template); |
580 | | - $timeout(function doLater() { |
581 | | - |
582 | | - onTooltipShow(); |
583 | | - }); |
584 | | - } |
585 | | - , hideTemplate = function hideTemplate() { |
586 | | - |
587 | | - //hide tooltip because is empty |
588 | | - tipTipElement.empty(); |
589 | | - tooltipElement.addClass('_force-hidden'); //force to be hidden if empty |
590 | | - } |
591 | | - , getTemplate = function getTemplate(tooltipTemplateUrl) { |
592 | | - |
593 | | - var template = $templateCache.get(tooltipTemplateUrl); |
594 | | - |
595 | | - if (typeof template === 'undefined') { |
596 | | - |
597 | | - // How should failing to load the template be handled? |
598 | | - template = $http.get(tooltipTemplateUrl).then(function onGetTemplateSuccess(response) { |
599 | | - |
600 | | - return response.data; |
601 | | - }); |
602 | | - $templateCache.put(tooltipTemplateUrl, template); |
603 | | - } |
604 | | - |
605 | | - return template; |
606 | | - } |
607 | 574 | , onTooltipTemplateChange = function onTooltipTemplateChange(newValue) { |
608 | | - |
609 | 575 | if (newValue) { |
610 | | - |
611 | | - showTemplate(newValue); |
| 576 | + tooltipElement.removeClass('_force-hidden'); //see lines below, this forces to hide tooltip when is empty |
| 577 | + tipTipElement.empty(); |
| 578 | + tipTipElement.append(closeButtonElement); |
| 579 | + tipTipElement.append(newValue); |
| 580 | + $timeout(function doLaterShow() { |
| 581 | + |
| 582 | + onTooltipShow(); |
| 583 | + }); |
612 | 584 | } else { |
613 | | - |
614 | | - hideTemplate(); |
| 585 | + //hide tooltip because is empty |
| 586 | + tipTipElement.empty(); |
| 587 | + tooltipElement.addClass('_force-hidden'); //force to be hidden if empty |
615 | 588 | } |
616 | 589 | } |
617 | 590 | , onTooltipTemplateUrlChange = function onTooltipTemplateUrlChange(newValue) { |
618 | | - |
619 | 591 | if (newValue && !$attrs.tooltipTemplateUrlCache) { |
620 | | - |
621 | | - getTemplate(newValue).then(function onGetTemplateSuccess(template) { |
622 | | - |
623 | | - showTemplate($compile(template)(scope)); |
624 | | - }).catch(function onGetTemplateFailure(reason) { |
625 | | - |
626 | | - $log.error(reason); |
| 592 | + |
| 593 | + $http.get(newValue).then(function onResponse(response) { |
| 594 | + |
| 595 | + if (response && |
| 596 | + response.data) { |
| 597 | + |
| 598 | + tooltipElement.removeClass('_force-hidden'); //see lines below, this forces to hide tooltip when is empty |
| 599 | + tipTipElement.empty(); |
| 600 | + tipTipElement.append(closeButtonElement); |
| 601 | + tipTipElement.append($compile(response.data)(scope)); |
| 602 | + $timeout(function doLater() { |
| 603 | + |
| 604 | + onTooltipShow(); |
| 605 | + }); |
| 606 | + } |
627 | 607 | }); |
628 | 608 | } else { |
629 | | - |
630 | | - hideTemplate(); |
| 609 | + //hide tooltip because is empty |
| 610 | + tipTipElement.empty(); |
| 611 | + tooltipElement.addClass('_force-hidden'); //force to be hidden if empty |
631 | 612 | } |
632 | 613 | } |
633 | 614 | , onTooltipTemplateUrlCacheChange = function onTooltipTemplateUrlCacheChange(newValue) { |
634 | | - |
635 | 615 | if (newValue && $attrs.tooltipTemplateUrl) { |
636 | | - |
637 | | - getTemplate($attrs.tooltipTemplateUrl).then(function onGetTemplateSuccess(template) { |
638 | | - |
639 | | - showTemplate($compile(template)(scope)); |
640 | | - }).catch(function onGetTemplateFailure(reason) { |
641 | 616 |
|
642 | | - $log.error(reason); |
643 | | - }); |
| 617 | + var template = $templateCache.get($attrs.tooltipTemplateUrl); |
| 618 | + |
| 619 | + if (typeof template !== 'undefined') { |
| 620 | + |
| 621 | + tooltipElement.removeClass('_force-hidden'); //see lines below, this forces to hide tooltip when is empty |
| 622 | + tipTipElement.empty(); |
| 623 | + tipTipElement.append(closeButtonElement); |
| 624 | + tipTipElement.append($compile(template)(scope)); |
| 625 | + $timeout(function doLater() { |
| 626 | + onTooltipShow(); |
| 627 | + }); |
| 628 | + } |
644 | 629 | } else { |
645 | | - |
646 | | - hideTemplate(); |
| 630 | + //hide tooltip because is empty |
| 631 | + tipTipElement.empty(); |
| 632 | + tooltipElement.addClass('_force-hidden'); //force to be hidden if empty |
647 | 633 | } |
648 | 634 | } |
649 | 635 | , onTooltipSideChange = function onTooltipSideChange(newValue) { |
|
0 commit comments