Merge "Implement non-JS RollbackAction with form"
[lhc/web/wiklou.git] / resources / src / mediawiki.rollback.confirmation.js
1 /*!
2 * JavaScript for rollback confirmation prompt
3 */
4 ( function () {
5
6 var postRollback = function ( url ) {
7 var $form = $( '<form>', {
8 action: url,
9 method: 'post'
10 } );
11 $form.appendTo( 'body' ).trigger( 'submit' );
12 };
13
14 $( '.mw-rollback-link a' ).each( function () {
15 $( this ).confirmable( {
16 i18n: {
17 confirm: mw.msg( 'rollback-confirmation-confirm', $( this ).data( 'rollback-count' ) ),
18 yes: mw.msg( 'rollback-confirmation-yes' ),
19 no: mw.msg( 'rollback-confirmation-no' )
20 },
21 handler: function ( e ) {
22 e.preventDefault();
23 postRollback( $( this ).attr( 'href' ) );
24 }
25 } );
26 } );
27
28 }() );