diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-07-21 14:24:26 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-07-21 14:24:26 +0200 |
commit | 11aa571751015b31332e2c113c238a050928b191 (patch) | |
tree | 856fff9b0f80c9844cf4b820ac3e6427dc905c32 /apps | |
parent | 687c87bc5b4d4c04cdb05adcab2465d8dfbb34cc (diff) | |
download | nextcloud-server-11aa571751015b31332e2c113c238a050928b191.tar.gz nextcloud-server-11aa571751015b31332e2c113c238a050928b191.zip |
Added option to notify method.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/contacts/js/contacts.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 8d881498768..130d6b64319 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -12,10 +12,28 @@ String.prototype.strip_tags = function(){ Contacts={ UI:{ + /** + * Arguments: + * message: The text message to show. The only mandatory parameter. + * timeout: The timeout in seconds before the notification disappears. Default 10. + * timeouthandler: A function to run on timeout. + * clickhandler: A function to run on click. If a timeouthandler is given it will be cancelled. + */ notify:function(params) { - $('#notification').text(params.message); - $('#notification').fadeIn(); - setTimeout(function() {$('#notification').fadeOut();}, 10000); + var notifier = $('#notification'); + notifier.text(params.message); + notifier.fadeIn(); + var timer = setTimeout(function() { + notifier.fadeOut(); + if(params.timeouthandler && $.isFunction(params.timeouthandler)) { params.timeouthandler();} + }, params.timeout && $.isNumeric(params.timeout) ? parseInt(params.timeout)*1000 : 10000); + if(params.clickhandler && $.isFunction(params.clickhandler)) { + notifier.on('click', function() { + clearTimeout(timer); + notifier.off('click'); + params.clickhandler(); + }); + } }, notImplemented:function() { OC.dialogs.alert(t('contacts', 'Sorry, this functionality has not been implemented yet'), t('contacts', 'Not implemented')); |