diff options
Diffstat (limited to 'js/directive/NewsTimeout.js')
-rw-r--r-- | js/directive/NewsTimeout.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/js/directive/NewsTimeout.js b/js/directive/NewsTimeout.js new file mode 100644 index 000000000..dc87dd5aa --- /dev/null +++ b/js/directive/NewsTimeout.js @@ -0,0 +1,29 @@ +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright Bernhard Posselt 2014 + */ +app.directive('newsTimeout', ($timeout) => { + 'use strict'; + + return { + restrict: 'A', + scope: { + 'newsTimeout': '&' + }, + link: (scope) => { + let seconds = 7; + let timer = $timeout(scope.newsTimeout, seconds * 1000); + + // remove timeout if element is being removed by + // for instance clicking on the x button + scope.$on('$destroy', () => { + $timeout.cancel(timer); + }); + } + }; +});
\ No newline at end of file |