X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.page.ready.js;h=630e3a6465137c6517b9ddcbe0a10a7f805f4007;hp=71e7f800c12ed5e1b2c73a18f65675548471fab3;hb=75e473005d666b1675404305aab154474216dce2;hpb=58f810a0dceb346b127fd0030be3922e05d8fdee diff --git a/resources/src/mediawiki.page.ready.js b/resources/src/mediawiki.page.ready.js index 71e7f800c1..630e3a6465 100644 --- a/resources/src/mediawiki.page.ready.js +++ b/resources/src/mediawiki.page.ready.js @@ -49,10 +49,33 @@ mw.hook( 'wikipage.categories' ).fire( $nodes ); } - $( '#t-print a' ).click( function ( e ) { + $( '#t-print a' ).on( 'click', function ( e ) { window.print(); e.preventDefault(); } ); + + // Turn logout to a POST action + $( '#pt-logout a' ).on( 'click', function ( e ) { + var api = new mw.Api(), returnUrl; + returnUrl = $( '#pt-logout a' ).attr( 'href' ); + mw.notify( + mw.message( 'logging-out-notify' ), + { tag: 'logout', autoHide: false } + ); + api.postWithToken( 'csrf', { + action: 'logout' + } ).done( function () { + // Horrible hack until deprecation of logoutToken in GET is done + returnUrl = returnUrl.replace( /logoutToken=.+?($|&)/g, 'logoutToken=%2B%5C' ); + window.location = returnUrl; + } ).fail( function ( e ) { + mw.notify( + mw.message( 'logout-failed', e ), + { type: 'error', tag: 'logout', autoHide: false } + ); + } ); + e.preventDefault(); + } ); } ); }() );