From: Fomafix Date: Wed, 4 Jan 2017 17:45:57 +0000 (+0100) Subject: mediawiki.page.watch.ajax: Use title with spaces instead of _ X-Git-Tag: 1.31.0-rc.0~4400^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=e13b3b72a40c190e6e1ef0b3d653e2741f5bb471;p=lhc%2Fweb%2Fwiklou.git mediawiki.page.watch.ajax: Use title with spaces instead of _ Since 1f15d1d5828dfbc70d036a52da57460ea0e89175 titles with spaces get shown with _ instead of spaces in the success notification message. Change-Id: I80bd1d2440ce8b815abb1fe19f4bd080bcc00fcc --- diff --git a/resources/src/mediawiki/page/watch.js b/resources/src/mediawiki/page/watch.js index 5dda7e0d90..7cfe058a89 100644 --- a/resources/src/mediawiki/page/watch.js +++ b/resources/src/mediawiki/page/watch.js @@ -106,11 +106,12 @@ $links = $links.filter( ':not( #bodyContent *, #content * )' ); $links.click( function ( e ) { - var action, api, $link; + var mwTitle, action, api, $link; + mwTitle = mw.Title.newFromText( title ); action = mwUriGetAction( this.href ); - if ( action !== 'watch' && action !== 'unwatch' ) { + if ( !mwTitle || ( action !== 'watch' && action !== 'unwatch' ) ) { // Let native browsing handle the link return true; } @@ -132,16 +133,15 @@ api[ action ]( title ) .done( function ( watchResponse ) { - var mwTitle, message, otherAction = action === 'watch' ? 'unwatch' : 'watch'; + var message, otherAction = action === 'watch' ? 'unwatch' : 'watch'; - mwTitle = mw.Title.newFromText( title ); - if ( mwTitle && mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1 ) { + if ( mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1 ) { message = action === 'watch' ? 'addedwatchtext-talk' : 'removedwatchtext-talk'; } else { message = action === 'watch' ? 'addedwatchtext' : 'removedwatchtext'; } - mw.notify( mw.message( message, title ).parseDom(), { + mw.notify( mw.message( message, mwTitle.getPrefixedText() ).parseDom(), { tag: 'watch-self' } ); @@ -153,18 +153,17 @@ $( '#wpWatchthis' ).prop( 'checked', watchResponse.watched === true ); } ) .fail( function () { - var cleanTitle, msg, link; + var msg, link; // Reset link to non-loading mode updateWatchLink( $link, action ); // Format error message - cleanTitle = title.replace( /_/g, ' ' ); link = mw.html.element( 'a', { href: mw.util.getUrl( title ), - title: cleanTitle - }, cleanTitle + title: mwTitle.getPrefixedText() + }, mwTitle.getPrefixedText() ); msg = mw.message( 'watcherrortext', link );