From: Timo Tijhof Date: Tue, 22 Dec 2015 03:10:33 +0000 (-0800) Subject: mediawiki.page.patrol.ajax: Rename file to match module name X-Git-Tag: 1.31.0-rc.0~8583^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=82def5ea5f476cf67432ab2a26f4bd9399ea5d1d;p=lhc%2Fweb%2Fwiklou.git mediawiki.page.patrol.ajax: Rename file to match module name Change-Id: If8b99d336749d26f18246491ca094487b4dea18e --- diff --git a/resources/Resources.php b/resources/Resources.php index c66dcb2181..4e247e08fa 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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 index 0000000000..f9b0d3564b --- /dev/null +++ b/resources/src/mediawiki/page/patrol.ajax.js @@ -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 + */ +( 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 index f9b0d3564b..0000000000 --- a/resources/src/mediawiki/page/patrol.js +++ /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 - */ -( 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 ) );