Merge "resources: Move various single-file mediawiki.* modules to src/"
[lhc/web/wiklou.git] / resources / src / mediawiki / page / watch.js
index e56e807..5b41876 100644 (file)
@@ -2,7 +2,17 @@
  * Animate watch/unwatch links to use asynchronous API requests to
  * watch pages, rather than navigating to a different URI.
  *
- * @class mw.page.watch.ajax
+ * Usage:
+ *
+ *     var watch = require( 'mediawiki.page.watch.ajax' );
+ *     watch.updateWatchLink(
+ *         $node,
+ *         'watch',
+ *         'loading'
+ *     );
+ *
+ * @class mw.plugin.page.watch.ajax
+ * @singleton
  */
 ( function ( mw, $ ) {
        var watch,
@@ -69,7 +79,7 @@
         * @return {string} The extracted action, defaults to 'view'
         */
        function mwUriGetAction( url ) {
-               var action, actionPaths, key, i, m, parts;
+               var action, actionPaths, key, m, parts;
 
                // TODO: Does MediaWiki give action path or query param
                // precedence? If the former, move this to the bottom
@@ -82,9 +92,7 @@
                for ( key in actionPaths ) {
                        if ( actionPaths.hasOwnProperty( key ) ) {
                                parts = actionPaths[ key ].split( '$1' );
-                               for ( i = 0; i < parts.length; i++ ) {
-                                       parts[ i ] = mw.RegExp.escape( parts[ i ] );
-                               }
+                               parts = parts.map( mw.RegExp.escape );
                                m = new RegExp( parts.join( '(.+)' ) ).exec( url );
                                if ( m && m[ 1 ] ) {
                                        return key;
        };
        module.exports = watch;
 
-       // Deprecated since 1.30
-       mw.log.deprecate( mw, 'page',
-               { watch: watch },
-               'Use require( \'mediawiki.page.watch.ajax\' ) instead.',
-               'mw.page'
-       );
-
        $( function () {
                var $links = $( '.mw-watchlink a[data-mw="interface"], a.mw-watchlink[data-mw="interface"]' );
                if ( !$links.length ) {