mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Merge "(bug 42136) Use user prefs to set initial state of "Watch this"."
This commit is contained in:
commit
aac3954384
|
@ -56,14 +56,12 @@ class VisualEditorHooks {
|
|||
|
||||
/**
|
||||
* Adds extra variables to the page config.
|
||||
*
|
||||
* This is attached to the MediaWiki 'MakeGlobalVariablesScript' hook.
|
||||
*/
|
||||
public static function onMakeGlobalVariablesScript( &$vars ) {
|
||||
global $wgUser, $wgTitle;
|
||||
public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) {
|
||||
$vars['wgVisualEditor'] = array(
|
||||
'isPageWatched' => $wgUser->isWatched( $wgTitle )
|
||||
'isPageWatched' => $out->getUser()->isWatched( $out->getTitle() )
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -262,6 +262,7 @@
|
|||
margin-bottom: 1em;
|
||||
border: solid 1px #cccccc;
|
||||
border-radius: 0 0 0.25em 0.25em;
|
||||
min-height: 2.25em;
|
||||
}
|
||||
|
||||
.ve-init-mw-viewPageTarget-saveDialog-body label {
|
||||
|
|
|
@ -756,6 +756,8 @@ ve.init.mw.ViewPageTarget.prototype.getSaveDialogHtml = function ( callback ) {
|
|||
var viewPage = this,
|
||||
$wrap = $( '<div>' ).html( this.constructor.saveDialogTemplate );
|
||||
|
||||
// Based on EditPage::getCheckboxes and EditPage::initialiseForm
|
||||
|
||||
mw.user.getRights( function ( rights ) {
|
||||
// MediaWiki only allows usage of minor flag when editing an existing page
|
||||
// and the user has the right to use the feature.
|
||||
|
@ -765,6 +767,20 @@ ve.init.mw.ViewPageTarget.prototype.getSaveDialogHtml = function ( callback ) {
|
|||
.find( '.ve-init-mw-viewPageTarget-saveDialog-minorEdit-label, #ve-init-mw-viewPageTarget-saveDialog-minorEdit' )
|
||||
.remove();
|
||||
}
|
||||
|
||||
if ( mw.user.isAnon() ) {
|
||||
$wrap
|
||||
.find( '.ve-init-mw-viewPageTarget-saveDialog-watchList-label, #ve-init-mw-viewPageTarget-saveDialog-watchList' )
|
||||
.remove();
|
||||
} else if (
|
||||
mw.user.options.get( 'watchdefault' ) ||
|
||||
( mw.user.options.get( 'watchcreations' ) && !viewPage.pageExists ) ||
|
||||
mw.config.get( 'wgVisualEditor' ).isPageWatched
|
||||
) {
|
||||
$wrap
|
||||
.find( '#ve-init-mw-viewPageTarget-saveDialog-watchList' )
|
||||
.prop( 'checked', true );
|
||||
}
|
||||
callback( $wrap );
|
||||
} );
|
||||
};
|
||||
|
@ -820,9 +836,6 @@ ve.init.mw.ViewPageTarget.prototype.setupSaveDialog = function () {
|
|||
.find( '.ve-init-mw-viewPageTarget-saveDialog-watchList-label' )
|
||||
.html( ve.init.platform.getParsedMessage( 'watchthis' ) )
|
||||
.end()
|
||||
.find( '#ve-init-mw-viewPageTarget-saveDialog-watchList' )
|
||||
.prop( 'checked', mw.config.get( 'wgVisualEditor' ).isPageWatched )
|
||||
.end()
|
||||
.find( '.ve-init-mw-viewPageTarget-saveDialog-saveButton' )
|
||||
.on( {
|
||||
'mousedown': function () {
|
||||
|
|
Loading…
Reference in a new issue