From c60501e950e90b28a50317495a7ad0879a479257 Mon Sep 17 00:00:00 2001 From: bfederle Date: Thu, 22 Dec 2011 08:41:40 -0800 Subject: [PATCH] UI widgets: support event-based notifications Triggering 'cloudStack.addNotification' adds a new UI notification, to avoid having to specify DOM element containing the jQuery widget every time. This event accepts same args as .notifications('add', ...) Example: $(window).trigger('cloudStack.addNotification', { desc: 'Description', interval: 1000, poll: function(args) { ... args.complete(); } }); --- ui/scripts/ui/widgets/notifications.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/scripts/ui/widgets/notifications.js b/ui/scripts/ui/widgets/notifications.js index 08b5dc48aba..e6f44750b2a 100644 --- a/ui/scripts/ui/widgets/notifications.js +++ b/ui/scripts/ui/widgets/notifications.js @@ -230,7 +230,11 @@ return this; }; - // Events + // Setup notification listener -- accepts same args as + $(window).bind('cloudStack.addNotification', function(event, data) { + $('.notifications').notifications('add', data); + }); + $(document).click(function(event) { var $target = $(event.target); var $attachTo, $popup;