mediawiki.notification: Return the Notification object from .notify calls
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 1 Feb 2014 02:41:49 +0000 (03:41 +0100)
committerOri.livneh <ori@wikimedia.org>
Thu, 20 Feb 2014 08:36:31 +0000 (08:36 +0000)
The implementation is solid, stable and already includes sanity checks
that make it difficult to shoot oneself in the foot.

This essentially makes the class no longer private; adjusted
documentation accordingly.

Bug: 57400
Change-Id: Icecc75e05a1f9a46e8de984c401a0292817d0d4c

maintenance/jsduck/categories.json
resources/mediawiki/mediawiki.notification.js

index f1cd2f8..aa138bd 100644 (file)
@@ -25,6 +25,7 @@
                                        "mw.inspect",
                                        "mw.inspect.reports",
                                        "mw.notification",
+                                       "mw.Notification_",
                                        "mw.user",
                                        "mw.util",
                                        "mw.plugin.*"
index 4ede809..f142fa4 100644 (file)
@@ -8,17 +8,17 @@
                preReadyNotifQueue = [];
 
        /**
-        * Creates a Notification object for 1 message.
-        * Does not insert anything into the document (see #start).
+        * A Notification object for 1 message.
         *
-        * The "_" in the name is to avoid a bug (http://github.com/senchalabs/jsduck/issues/304)
+        * The "_" in the name is to avoid a bug (http://github.com/senchalabs/jsduck/issues/304).
         * It is not part of the actual class name.
         *
         * @class mw.Notification_
         * @alternateClassName mw.Notification
-        * @private
         *
-        * @constructor
+        * @constructor The constructor is not publicly accessible; use mw.notification#notify instead.
+        *  This does not insert anything into the document (see #start).
+        * @private
         */
        function Notification( message, options ) {
                var $notification, $notificationTitle, $notificationContent;
        }
 
        /**
-        * Start the notification.
-        * This inserts it into the page, closes any matching tagged notifications,
-        * handles the fadeIn animations and repacement transitions, and starts autoHide timers.
+        * Start the notification. Called automatically by mw.notification#notify
+        * (possibly asynchronously on document-ready).
+        *
+        * This inserts the notification into the page, closes any matching tagged notifications,
+        * handles the fadeIn animations and replacement transitions, and starts autoHide timers.
+        *
+        * @private
         */
        Notification.prototype.start = function () {
                var
         * Close/hide the notification.
         *
         * @param {Object} options An object containing options for the closing of the notification.
-        *  These are typically only used internally.
         *
         *  - speed: Use a close speed different than the default 'slow'.
         *  - placeholder: Set to false to disable the placeholder transition.
         * Helper function, take a list of notification divs and call
         * a function on the Notification instance attached to them.
         *
+        * @private
+        * @static
         * @param {jQuery} $notifications A jQuery object containing notification divs
         * @param {string} fn The name of the function to call on the Notification instance
         */
                 * @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
+                * @return {mw.Notification} Notification object
                 */
                notify: function ( message, options ) {
                        var notif;
                        } else {
                                preReadyNotifQueue.push( notif );
                        }
-                       return { close: $.proxy( notif.close, notif ) };
+
+                       return notif;
                },
 
                /**