mediawiki.page.patrol.ajax: Rename file to match module name
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 22 Dec 2015 03:10:33 +0000 (19:10 -0800)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 22 Dec 2015 03:10:58 +0000 (19:10 -0800)
Change-Id: If8b99d336749d26f18246491ca094487b4dea18e

resources/Resources.php
resources/src/mediawiki/page/patrol.ajax.js [new file with mode: 0644]
resources/src/mediawiki/page/patrol.js [deleted file]

index c66dcb2..4e247e0 100644 (file)
@@ -1632,7 +1632,7 @@ return array(
                'targets' => array( 'desktop', 'mobile' ),
        ),
        'mediawiki.page.patrol.ajax' => array(
-               'scripts' => 'resources/src/mediawiki/page/patrol.js',
+               'scripts' => 'resources/src/mediawiki/page/patrol.ajax.js',
                'dependencies' => array(
                        'mediawiki.page.startup',
                        'mediawiki.api',
diff --git a/resources/src/mediawiki/page/patrol.ajax.js b/resources/src/mediawiki/page/patrol.ajax.js
new file mode 100644 (file)
index 0000000..f9b0d35
--- /dev/null
@@ -0,0 +1,65 @@
+/*!
+ * Animate patrol links to use asynchronous API requests to
+ * patrol pages, rather than navigating to a different URI.
+ *
+ * @since 1.21
+ * @author Marius Hoch <hoo@online.de>
+ */
+( function ( mw, $ ) {
+       if ( !mw.user.tokens.exists( 'patrolToken' ) ) {
+               // Current user has no patrol right, or an old cached version of user.tokens
+               // that didn't have patrolToken yet.
+               return;
+       }
+       $( function () {
+               var $patrolLinks = $( '.patrollink a' );
+               $patrolLinks.on( 'click', function ( e ) {
+                       var $spinner, href, rcid, apiRequest;
+
+                       // Start preloading the notification module (normally loaded by mw.notify())
+                       mw.loader.load( 'mediawiki.notification' );
+
+                       // Hide the link and create a spinner to show it inside the brackets.
+                       $spinner = $.createSpinner( {
+                               size: 'small',
+                               type: 'inline'
+                       } );
+                       $( this ).hide().after( $spinner );
+
+                       href = $( this ).attr( 'href' );
+                       rcid = mw.util.getParamValue( 'rcid', href );
+                       apiRequest = new mw.Api();
+
+                       apiRequest.postWithToken( 'patrol', {
+                               action: 'patrol',
+                               rcid: rcid
+                       } )
+                       .done( function ( data ) {
+                               // Remove all patrollinks from the page (including any spinners inside).
+                               $patrolLinks.closest( '.patrollink' ).remove();
+                               if ( data.patrol !== undefined ) {
+                                       // Success
+                                       var title = new mw.Title( data.patrol.title );
+                                       mw.notify( mw.msg( 'markedaspatrollednotify', title.toText() ) );
+                               } else {
+                                       // This should never happen as errors should trigger fail
+                                       mw.notify( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } );
+                               }
+                       } )
+                       .fail( function ( error ) {
+                               $spinner.remove();
+                               // Restore the patrol link. This allows the user to try again
+                               // (or open it in a new window, bypassing this ajax module).
+                               $patrolLinks.show();
+                               if ( error === 'noautopatrol' ) {
+                                       // Can't patrol own
+                                       mw.notify( mw.msg( 'markedaspatrollederror-noautopatrol' ), { type: 'warn' } );
+                               } else {
+                                       mw.notify( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } );
+                               }
+                       } );
+
+                       e.preventDefault();
+               } );
+       } );
+}( mediaWiki, jQuery ) );
diff --git a/resources/src/mediawiki/page/patrol.js b/resources/src/mediawiki/page/patrol.js
deleted file mode 100644 (file)
index f9b0d35..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*!
- * Animate patrol links to use asynchronous API requests to
- * patrol pages, rather than navigating to a different URI.
- *
- * @since 1.21
- * @author Marius Hoch <hoo@online.de>
- */
-( function ( mw, $ ) {
-       if ( !mw.user.tokens.exists( 'patrolToken' ) ) {
-               // Current user has no patrol right, or an old cached version of user.tokens
-               // that didn't have patrolToken yet.
-               return;
-       }
-       $( function () {
-               var $patrolLinks = $( '.patrollink a' );
-               $patrolLinks.on( 'click', function ( e ) {
-                       var $spinner, href, rcid, apiRequest;
-
-                       // Start preloading the notification module (normally loaded by mw.notify())
-                       mw.loader.load( 'mediawiki.notification' );
-
-                       // Hide the link and create a spinner to show it inside the brackets.
-                       $spinner = $.createSpinner( {
-                               size: 'small',
-                               type: 'inline'
-                       } );
-                       $( this ).hide().after( $spinner );
-
-                       href = $( this ).attr( 'href' );
-                       rcid = mw.util.getParamValue( 'rcid', href );
-                       apiRequest = new mw.Api();
-
-                       apiRequest.postWithToken( 'patrol', {
-                               action: 'patrol',
-                               rcid: rcid
-                       } )
-                       .done( function ( data ) {
-                               // Remove all patrollinks from the page (including any spinners inside).
-                               $patrolLinks.closest( '.patrollink' ).remove();
-                               if ( data.patrol !== undefined ) {
-                                       // Success
-                                       var title = new mw.Title( data.patrol.title );
-                                       mw.notify( mw.msg( 'markedaspatrollednotify', title.toText() ) );
-                               } else {
-                                       // This should never happen as errors should trigger fail
-                                       mw.notify( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } );
-                               }
-                       } )
-                       .fail( function ( error ) {
-                               $spinner.remove();
-                               // Restore the patrol link. This allows the user to try again
-                               // (or open it in a new window, bypassing this ajax module).
-                               $patrolLinks.show();
-                               if ( error === 'noautopatrol' ) {
-                                       // Can't patrol own
-                                       mw.notify( mw.msg( 'markedaspatrollederror-noautopatrol' ), { type: 'warn' } );
-                               } else {
-                                       mw.notify( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } );
-                               }
-                       } );
-
-                       e.preventDefault();
-               } );
-       } );
-}( mediaWiki, jQuery ) );