X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fpage%2Fwatch.js;h=5b55bb2d7246c84f3920afb4d6ebf872fe775fb1;hp=7d35cb759c4457e2441bd302203750a16daf741b;hb=5c34da77f9321fae9b43454b7e1296e3f1c248ac;hpb=2dd58ade75d15a5895c0c010e17b6f729a0f72fe diff --git a/resources/src/mediawiki/page/watch.js b/resources/src/mediawiki/page/watch.js index 7d35cb759c..5b55bb2d72 100644 --- a/resources/src/mediawiki/page/watch.js +++ b/resources/src/mediawiki/page/watch.js @@ -2,11 +2,22 @@ * Animate watch/unwatch links to use asynchronous API requests to * watch pages, rather than navigating to a different URI. * - * @class mw.page.watch.ajax + * Usage: + * + * var watch = require( 'mediawiki.page.watch.ajax' ); + * watch.updateWatchLink( + * $node, + * 'watch', + * 'loading' + * ); + * + * @class mw.plugin.page.watch.ajax + * @singleton */ ( function ( mw, $ ) { - // The name of the page to watch or unwatch - var title = mw.config.get( 'wgRelevantPageName' ); + var watch, + // The name of the page to watch or unwatch + title = mw.config.get( 'wgRelevantPageName' ); /** * Update the link text, link href attribute and (if applicable) @@ -96,14 +107,19 @@ } // Expose public methods - mw.page.watch = { + watch = { updateWatchLink: updateWatchLink }; + module.exports = watch; $( function () { - var $links = $( '.mw-watchlink a, a.mw-watchlink' ); - // Restrict to core interfaces, ignore user-generated content - $links = $links.filter( ':not( #bodyContent *, #content * )' ); + var $links = $( '.mw-watchlink a[data-mw="interface"], a.mw-watchlink[data-mw="interface"]' ); + if ( !$links.length ) { + // Fallback to the class-based exclusion method for backwards-compatibility + $links = $( '.mw-watchlink a, a.mw-watchlink' ); + // Restrict to core interfaces, ignore user-generated content + $links = $links.filter( ':not( #bodyContent *, #content * )' ); + } $links.click( function ( e ) { var mwTitle, action, api, $link;