diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-10 15:19:30 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-10 15:19:30 +0200 |
commit | 3843f75b494bd8f612dc7b940a1d9b331d70f581 (patch) | |
tree | b7342ddf4820b3d060bbbae5b5aa64235bc492a1 /js/app/directives/undonotification.coffee | |
parent | 347000cc2d5597c1971942ebdbe97461c9fa5802 (diff) |
undo queue fixes (unittests not adjusted yet: todo fix folderbusinesslayer and feedbusinesslayer specs)
Diffstat (limited to 'js/app/directives/undonotification.coffee')
-rw-r--r-- | js/app/directives/undonotification.coffee | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/js/app/directives/undonotification.coffee b/js/app/directives/undonotification.coffee index 5e30af169..acf3f886d 100644 --- a/js/app/directives/undonotification.coffee +++ b/js/app/directives/undonotification.coffee @@ -20,23 +20,22 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -angular.module('News').directive 'undoNotification', ['$rootScope', -($rootScope) -> +angular.module('News').directive 'undoNotification', +['$rootScope', '$timeout', 'Config', +($rootScope, $timeout, Config) -> return (scope, elm, attr) -> - - elm.click -> - $(@).fadeOut() - - scope.$on 'notUndone', -> - $(elm).fadeOut() - undo = -> caption = '' + timeout = null + + $(elm).click -> + timout = null + $(@).fadeOut() - link = $(elm).find('a') - link.click -> + $(elm).find('a').click -> undo() + timout = null $rootScope.$apply() elm.fadeOut() @@ -44,9 +43,18 @@ angular.module('News').directive 'undoNotification', ['$rootScope', return caption scope.$on 'undoMessage', (scope, data) -> + # cancel previous timeouts + if timeout + $timeout.cancel(timeout.promise) + + # fade out if not reset with a new + timeout = $timeout => + $(elm).fadeOut() + , Config.undoTimeout + undo = data.undoCallback caption = data.caption - elm.fadeIn().css("display","inline") + $(elm).fadeIn().css("display","inline") ]
\ No newline at end of file |