X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fsrc%2Fmediawiki.page.watch.ajax.js;h=c56aadac55df7a4137e278427c2f1c6cabff2b10;hb=5bba9d230c25759c616cefe326fcb37cb4405d84;hp=5b41876dbdba30fc17a8e809023ca388bef63aa6;hpb=339adab63a1e6016446743f2003d42fbfc1fbace;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.page.watch.ajax.js b/resources/src/mediawiki.page.watch.ajax.js index 5b41876dbd..c56aadac55 100644 --- a/resources/src/mediawiki.page.watch.ajax.js +++ b/resources/src/mediawiki.page.watch.ajax.js @@ -14,7 +14,7 @@ * @class mw.plugin.page.watch.ajax * @singleton */ -( function ( mw, $ ) { +( function () { var watch, // The name of the page to watch or unwatch title = mw.config.get( 'wgRelevantPageName' ); @@ -90,14 +90,11 @@ actionPaths = mw.config.get( 'wgActionPaths' ); for ( key in actionPaths ) { - if ( actionPaths.hasOwnProperty( key ) ) { - parts = actionPaths[ key ].split( '$1' ); - parts = parts.map( mw.RegExp.escape ); - m = new RegExp( parts.join( '(.+)' ) ).exec( url ); - if ( m && m[ 1 ] ) { - return key; - } - + parts = actionPaths[ key ].split( '$1' ); + parts = parts.map( mw.RegExp.escape ); + m = new RegExp( parts.join( '(.+)' ) ).exec( url ); + if ( m && m[ 1 ] ) { + return key; } } @@ -119,7 +116,7 @@ $links = $links.filter( ':not( #bodyContent *, #content * )' ); } - $links.click( function ( e ) { + $links.on( 'click', function ( e ) { var mwTitle, action, api, $link; mwTitle = mw.Title.newFromText( title ); @@ -149,7 +146,7 @@ .done( function ( watchResponse ) { var message, otherAction = action === 'watch' ? 'unwatch' : 'watch'; - if ( mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1 ) { + if ( mwTitle.isTalkPage() ) { message = action === 'watch' ? 'addedwatchtext-talk' : 'removedwatchtext-talk'; } else { message = action === 'watch' ? 'addedwatchtext' : 'removedwatchtext'; @@ -190,4 +187,4 @@ } ); } ); -}( mediaWiki, jQuery ) ); +}() );