summaryrefslogtreecommitdiffstats
path: root/js/directive/NewsTimeout.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/directive/NewsTimeout.js')
-rw-r--r--js/directive/NewsTimeout.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/js/directive/NewsTimeout.js b/js/directive/NewsTimeout.js
index 43c6290a3..e54a32793 100644
--- a/js/directive/NewsTimeout.js
+++ b/js/directive/NewsTimeout.js
@@ -16,19 +16,24 @@ app.directive('newsTimeout', function ($timeout, $rootScope) {
'newsTimeout': '&'
},
link: function (scope, element) {
+ var destroyed = false;
var seconds = 7;
var timer = $timeout(scope.newsTimeout, seconds * 1000);
// remove timeout if element is being removed by
// for instance clicking on the x button
- scope.$on('$destroy', function () {
+ element.on('$destroy', function () {
$timeout.cancel(timer);
});
// also delete the entry if undo is ignored and the url
// is changed
$rootScope.$on('$locationChangeStart', function () {
- element.remove();
+ if (!destroyed) {
+ destroyed = true;
+ element.remove();
+ scope.newsTimeout();
+ }
});
}
};