dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "mediawiki.legacy.shared can be run in mobile target"
[lhc/web/wiklou.git]
/
resources
/
src
/
mediawiki
/
page
/
watch.js
diff --git
a/resources/src/mediawiki/page/watch.js
b/resources/src/mediawiki/page/watch.js
index
5dda7e0
..
6322ccd
100644
(file)
--- a/
resources/src/mediawiki/page/watch.js
+++ b/
resources/src/mediawiki/page/watch.js
@@
-5,8
+5,9
@@
* @class mw.page.watch.ajax
*/
( function ( mw, $ ) {
* @class mw.page.watch.ajax
*/
( 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)
/**
* Update the link text, link href attribute and (if applicable)
@@
-96,9
+97,17
@@
}
// Expose public methods
}
// Expose public methods
-
mw.page.
watch = {
+ watch = {
updateWatchLink: updateWatchLink
};
updateWatchLink: updateWatchLink
};
+ module.exports = watch;
+
+ // Deprecated since 1.30
+ mw.log.deprecate( mw, 'page',
+ { watch: watch },
+ 'Use require( \'mediawiki.page.watch.ajax\' ) instead.',
+ 'mw.page'
+ );
$( function () {
var $links = $( '.mw-watchlink a, a.mw-watchlink' );
$( function () {
var $links = $( '.mw-watchlink a, a.mw-watchlink' );
@@
-106,11
+115,12
@@
$links = $links.filter( ':not( #bodyContent *, #content * )' );
$links.click( function ( e ) {
$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 );
action = mwUriGetAction( this.href );
- if (
action !== 'watch' && action !== 'unwatch'
) {
+ if (
!mwTitle || ( action !== 'watch' && action !== 'unwatch' )
) {
// Let native browsing handle the link
return true;
}
// Let native browsing handle the link
return true;
}
@@
-132,16
+142,15
@@
api[ action ]( title )
.done( function ( watchResponse ) {
api[ action ]( title )
.done( function ( watchResponse ) {
- var m
wTitle, m
essage, 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';
}
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'
} );
tag: 'watch-self'
} );
@@
-149,22
+158,21
@@
updateWatchLink( $link, otherAction );
// Update the "Watch this page" checkbox on action=edit when the
updateWatchLink( $link, otherAction );
// Update the "Watch this page" checkbox on action=edit when the
- // page is watched or unwatched via the tab (
bug 12
395).
+ // page is watched or unwatched via the tab (
T14
395).
$( '#wpWatchthis' ).prop( 'checked', watchResponse.watched === true );
} )
.fail( function () {
$( '#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
// 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 ),
link = mw.html.element(
'a', {
href: mw.util.getUrl( title ),
- title:
cleanTitle
- },
cleanTitle
+ title:
mwTitle.getPrefixedText()
+ },
mwTitle.getPrefixedText()
);
msg = mw.message( 'watcherrortext', link );
);
msg = mw.message( 'watcherrortext', link );