X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.special.watchlist%2Fwatchlist.js;h=e8373c3d77ad15ea6a553abd2326b597cbe9cf8d;hp=565ed2c974dc12d917cf5e72144d36bc66f8225b;hb=dfec83932fd38a9086eb5a2e212889ad00f35b0e;hpb=5623d4c64319a98ddd8263c597002d173464ccbf diff --git a/resources/src/mediawiki.special.watchlist/watchlist.js b/resources/src/mediawiki.special.watchlist/watchlist.js index 565ed2c974..e8373c3d77 100644 --- a/resources/src/mediawiki.special.watchlist/watchlist.js +++ b/resources/src/mediawiki.special.watchlist/watchlist.js @@ -1,14 +1,14 @@ /*! * JavaScript for Special:Watchlist */ -( function ( mw, $, OO ) { +( function () { $( function () { var api = new mw.Api(), $progressBar, $resetForm = $( '#mw-watchlist-resetbutton' ); // If the user wants to reset their watchlist, use an API call to do so (no reload required) // Adapted from a user script by User:NQ of English Wikipedia // (User:NQ/WatchlistResetConfirm.js) - $resetForm.submit( function ( event ) { + $resetForm.on( 'submit', function ( event ) { var $button = $resetForm.find( 'input[name=mw-watchlist-reset-submit]' ); event.preventDefault(); @@ -41,7 +41,7 @@ } ).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(); + $resetForm.off( 'submit' ).trigger( 'submit' ); } ); } ); @@ -50,7 +50,7 @@ // add a listener on all form elements in the header form $( '#mw-watchlist-form input, #mw-watchlist-form select' ).on( 'change', function () { // submit the form when one of the input fields is modified - $( '#mw-watchlist-form' ).submit(); + $( '#mw-watchlist-form' ).trigger( 'submit' ); } ); } @@ -64,17 +64,15 @@ $watchlistLine = $unwatchLink.closest( 'li, table' ) .find( '[data-target-page]' ), pageTitle = $watchlistLine.data( 'targetPage' ), - isTalk = mw.Title.newFromText( pageTitle ).getNamespaceId() % 2 === 1; + isTalk = mw.Title.newFromText( pageTitle ).isTalkPage(); // Utility function for looping through each watchlist line that matches // a certain page or its associated page (e.g. Talk) function forEachMatchingTitle( title, callback ) { var titleObj = mw.Title.newFromText( title ), - pageNamespaceId = titleObj.getNamespaceId(), - isTalk = pageNamespaceId % 2 === 1, - associatedTitle = mw.Title.makeTitle( isTalk ? pageNamespaceId - 1 : pageNamespaceId + 1, - titleObj.getMainText() ).getPrefixedText(); + associatedTitleObj = titleObj.isTalkPage() ? titleObj.getSubjectPage() : titleObj.getTalkPage(), + associatedTitle = associatedTitleObj.getPrefixedText(); $( '.mw-changeslist-line' ).each( function () { var $this = $( this ), $row, $unwatchLink; @@ -102,6 +100,7 @@ // Depending on whether we are watching or unwatching, for each entry of the page (and its associated page i.e. Talk), // change the text, tooltip, and non-JS href of the (un)watch button, and update the styling of the watchlist entry. + // eslint-disable-next-line no-jquery/no-class-state if ( $unwatchLink.hasClass( 'mw-unwatch-link' ) ) { api.unwatch( pageTitle ) .done( function () { @@ -149,10 +148,9 @@ event.preventDefault(); event.stopPropagation(); - $unwatchLink.blur(); + $unwatchLink.trigger( 'blur' ); } ); } } ); -}( mediaWiki, jQuery, OO ) -); +}() );