From 78ea1dc5dfee490184f9bb7ee72da39ec7df4979 Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Thu, 18 Jul 2013 19:06:16 +0100 Subject: [PATCH] mediawiki.notification: Expose close method to hide a Notification Bug: 51338 Change-Id: Icd7fd1ac328094ddc2560d4804dd52fc85879867 --- resources/mediawiki/mediawiki.notification.js | 2 ++ resources/mediawiki/mediawiki.notify.js | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/resources/mediawiki/mediawiki.notification.js b/resources/mediawiki/mediawiki.notification.js index 70f639c573..4ede80961c 100644 --- a/resources/mediawiki/mediawiki.notification.js +++ b/resources/mediawiki/mediawiki.notification.js @@ -426,6 +426,7 @@ * @param {HTMLElement|jQuery|mw.Message|string} message * @param {Object} options The options to use for the notification. * See #defaults for details. + * @return {Object} Object with a close function to close the notification */ notify: function ( message, options ) { var notif; @@ -438,6 +439,7 @@ } else { preReadyNotifQueue.push( notif ); } + return { close: $.proxy( notif.close, notif ) }; }, /** diff --git a/resources/mediawiki/mediawiki.notify.js b/resources/mediawiki/mediawiki.notify.js index 83d95b61b8..743d651728 100644 --- a/resources/mediawiki/mediawiki.notify.js +++ b/resources/mediawiki/mediawiki.notify.js @@ -1,22 +1,23 @@ /** * @class mw.plugin.notify */ -( function ( mw ) { +( function ( mw, $ ) { 'use strict'; /** * @see mw.notification#notify * @param message * @param options + * @return {jQuery.Promise} */ mw.notify = function ( message, options ) { + var d = $.Deferred(); // Don't bother loading the whole notification system if we never use it. mw.loader.using( 'mediawiki.notification', function () { - // Don't bother calling mw.loader.using a second time after we've already loaded mw.notification. - mw.notify = mw.notification.notify; // Call notify with the notification the user requested of us. - mw.notify( message, options ); - } ); + d.resolve( mw.notification.notify( message, options ) ); + }, d.reject ); + return d.promise(); }; /** @@ -24,4 +25,4 @@ * @mixins mw.plugin.notify */ -}( mediaWiki ) ); +}( mediaWiki, jQuery ) ); -- 2.20.1