X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.special%2Fmediawiki.special.watchlist.js;h=7cc9b9bb5ad3240f368f930fcf3c03fea3e6885e;hb=ecd61a6d457175fc175b3b0c4decaa44da40f733;hp=223770f43ad0e4bfb200ee38a905caba42710051;hpb=f4d70ceedcbbe66bb5ee7177c86f6faf883f8b12;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.special/mediawiki.special.watchlist.js b/resources/src/mediawiki.special/mediawiki.special.watchlist.js index 223770f43a..7cc9b9bb5a 100644 --- a/resources/src/mediawiki.special/mediawiki.special.watchlist.js +++ b/resources/src/mediawiki.special/mediawiki.special.watchlist.js @@ -9,52 +9,42 @@ // Adapted from a user script by User:NQ of English Wikipedia // (User:NQ/WatchlistResetConfirm.js) $resetForm.submit( function ( event ) { - event.preventDefault(); - - OO.ui.confirm( mw.msg( 'watchlist-mark-all-visited' ) ) - .done( function ( confirmed ) { - var $button; + var $button = $resetForm.find( 'input[name=mw-watchlist-reset-submit]' ); - if ( !confirmed ) { - return; - } - - // Disable reset button to prevent multiple requests - $button = $resetForm.find( 'input[name=mw-watchlist-reset-submit]' ); - $button.prop( 'disabled', true ); + event.preventDefault(); - // Show progress bar - if ( $progressBar ) { - $progressBar.css( 'visibility', 'visible' ); - } else { - $progressBar = new OO.ui.ProgressBarWidget( { progress: false } ).$element; - $progressBar.css( { - position: 'absolute', - width: '100%' - } ); - $resetForm.append( $progressBar ); - } + // Disable reset button to prevent multiple concurrent requests + $button.prop( 'disabled', true ); - // Use action=setnotificationtimestamp to mark all as visited, - // then set all watchlist lines accordingly - new mw.Api().postWithToken( 'csrf', { - formatversion: 2, - action: 'setnotificationtimestamp', - entirewatchlist: true - } ).done( function () { - // Enable button again - $button.prop( 'disabled', false ); - // Hide the button because further clicks can not generate any visual changes - $button.css( 'visibility', 'hidden' ); - $progressBar.css( 'visibility', 'hidden' ); - $( '.mw-changeslist-line-watched' ) - .removeClass( 'mw-changeslist-line-watched' ) - .addClass( 'mw-changeslist-line-not-watched' ); - } ).fail( function () { - // On error, fall back to server-side reset - // First remove this submit listener and then re-submit the form - $resetForm.off( 'submit' ).submit(); + if ( !$progressBar ) { + $progressBar = new OO.ui.ProgressBarWidget( { progress: false } ).$element; + $progressBar.css( { + position: 'absolute', + width: '100%' } ); + } + // Show progress bar + $resetForm.append( $progressBar ); + + // Use action=setnotificationtimestamp to mark all as visited, + // then set all watchlist lines accordingly + new mw.Api().postWithToken( 'csrf', { + formatversion: 2, + action: 'setnotificationtimestamp', + entirewatchlist: true + } ).done( function () { + // Enable button again + $button.prop( 'disabled', false ); + // Hide the button because further clicks can not generate any visual changes + $button.css( 'visibility', 'hidden' ); + $progressBar.detach(); + $( '.mw-changeslist-line-watched' ) + .removeClass( 'mw-changeslist-line-watched' ) + .addClass( 'mw-changeslist-line-not-watched' ); + } ).fail( function () { + // On error, fall back to server-side reset + // First remove this submit listener and then re-submit the form + $resetForm.off( 'submit' ).submit(); } ); } );