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

Angular Template cache is now supported #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea/
node_modules/
bower_components/
npm-debug.log
39 changes: 24 additions & 15 deletions lib/angular-tooltips.js
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@
}
};
}
, tooltipDirective = /*@ngInject*/ function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf) {
, tooltipDirective = /*@ngInject*/ function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf, $templateCache) {

var linkingFunction = function linkingFunction($scope, $element, $attrs, $controllerDirective, $transcludeFunc) {

@@ -549,25 +549,34 @@
});
}
}
, onTooltipTemplateUrlChange = function onTooltipTemplateUrlChange(newValue) {
, onTooltipTemplateUrlChange = function onTooltipTemplateUrlChange(templateUrl) {

if (newValue) {
if (!templateUrl) {
return;
}

$http.get(newValue).then(function onResponse(response) {
// Trying to load template from the template cache first.
var template = $templateCache.get(templateUrl);

if (response &&
response.data) {
if ('undefined' === typeof template) {
$http
.get(templateUrl)
.then(function onResponse(response) {
if (response && response.data) {
template = response.data;
$templateCache.put(templateUrl, template);
}
})
;
}

tipTipElement.empty();
tipTipElement.append(closeButtonElement);
tipTipElement.append($compile(response.data)(scope));
$timeout(function doLater() {
tipTipElement.empty();
tipTipElement.append(closeButtonElement);
tipTipElement.append($compile(template)(scope));
$timeout(function doLater() {
onTooltipShow();
});

onTooltipShow();
});
}
});
}
}
, onTooltipSideChange = function onTooltipSideChange(newValue) {