diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index 48fc8fef90..055a9fbbcc 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -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; } diff --git a/modules/ve/init/mw/styles/ve.init.mw.ViewPageTarget.css b/modules/ve/init/mw/styles/ve.init.mw.ViewPageTarget.css index 7ba22f8cd3..6644d9b970 100644 --- a/modules/ve/init/mw/styles/ve.init.mw.ViewPageTarget.css +++ b/modules/ve/init/mw/styles/ve.init.mw.ViewPageTarget.css @@ -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 { diff --git a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js index 2aeeff95af..7923dc2f9d 100644 --- a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js @@ -756,6 +756,8 @@ ve.init.mw.ViewPageTarget.prototype.getSaveDialogHtml = function ( callback ) { var viewPage = this, $wrap = $( '
' ).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 () {