diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-07-22 14:56:00 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-07-23 01:17:38 +0200 |
commit | b00de0258be84d6a1b2309b95f23e10068865ed3 (patch) | |
tree | 2e647d7cf8cde8fe5aaf9b32d9a93637f507a77c /apps | |
parent | 644b6e60d555cf5bae1c03e32c7330fe4d8dce56 (diff) | |
download | nextcloud-server-b00de0258be84d6a1b2309b95f23e10068865ed3.tar.gz nextcloud-server-b00de0258be84d6a1b2309b95f23e10068865ed3.zip |
Make sure notifier cleans up.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/contacts/js/contacts.js | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 7c1304c559a..e53f695f976 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -21,27 +21,31 @@ Contacts={ * data: An object that will be passed as argument to the timeouthandler and clickhandler functions. */ notify:function(params) { - var notifier = $('#notification'); - notifier.text(params.message); - notifier.fadeIn(); + self = this; + if(!self.notifier) { + self.notifier = $('#notification'); + } + self.notifier.text(params.message); + self.notifier.fadeIn(); + self.notifier.on('click', function() { $(this).fadeOut();}); var timer = setTimeout(function() { - notifier.fadeOut(); + self.notifier.fadeOut(); if(params.timeouthandler && $.isFunction(params.timeouthandler)) { - params.timeouthandler(notifier.data(dataid)); - notifier.off('click'); - notifier.data(dataid, null); + params.timeouthandler(self.notifier.data(dataid)); + self.notifier.off('click'); + self.notifier.removeData(dataid); } }, params.timeout && $.isNumeric(params.timeout) ? parseInt(params.timeout)*1000 : 10000); var dataid = timer.toString(); if(params.data) { - notifier.data(dataid, params.data); + self.notifier.data(dataid, params.data); } if(params.clickhandler && $.isFunction(params.clickhandler)) { - notifier.on('click', function() { + self.notifier.on('click', function() { clearTimeout(timer); - notifier.off('click'); - params.clickhandler(notifier.data(dataid)); - notifier.data(dataid, null); + self.notifier.off('click'); + params.clickhandler(self.notifier.data(dataid)); + self.notifier.removeData(dataid); }); } }, |