Merge "More minor/watch checkbox state computation server-side"

This commit is contained in:
jenkins-bot 2016-04-11 14:18:56 +00:00 committed by Gerrit Code Review
commit 5dc1257507
2 changed files with 8 additions and 9 deletions

View file

@ -497,7 +497,12 @@ class ApiVisualEditor extends ApiBase {
$req->setVal( 'format', 'text/x-wiki' );
$ep->importFormData( $req ); // By reference for some reason (bug 52466)
$tabindex = 0;
$states = [ 'minor' => false, 'watch' => false ];
$states = [
'minor' => $user->getOption( 'minordefault' ) && $title->exists(),
'watch' => $user->getOption( 'watchdefault' ) ||
( $user->getOption( 'watchcreations' ) && !$title->exists() ) ||
$user->isWatched( $title ),
];
$checkboxes = $ep->getCheckboxes( $tabindex, $states );
// HACK: Find out which red links are on the page
@ -542,7 +547,6 @@ class ApiVisualEditor extends ApiBase {
'checkboxes' => $checkboxes,
'links' => $links,
'protectedClasses' => implode( ' ', $protectedClasses ),
'watched' => $user->isWatched( $title ),
'basetimestamp' => $baseTimestamp,
'starttimestamp' => wfTimestampNow(),
'oldid' => $oldid,

View file

@ -306,12 +306,7 @@ ve.init.mw.DesktopArticleTarget.prototype.loadSuccess = function ( response ) {
}
if ( data.checkboxes ) {
defaults = {
wpMinoredit: !!mw.user.options.get( 'minordefault' ),
wpWatchthis: !!mw.user.options.get( 'watchdefault' ) ||
( !!mw.user.options.get( 'watchcreations' ) && !this.pageExists ) ||
data.watched === ''
};
defaults = {};
$( '.editCheckboxes input' ).each( function () {
defaults[ this.name ] = this.checked;
} );
@ -342,7 +337,7 @@ ve.init.mw.DesktopArticleTarget.prototype.loadSuccess = function ( response ) {
}
checkbox = new OO.ui.CheckboxInputWidget( {
value: $this.attr( 'value' ),
selected: name && defaults[ name ]
selected: defaults[ name ] !== undefined ? defaults[ name ] : $this.prop( 'checked' )
} );
// HACK: CheckboxInputWidget doesn't support access keys
checkbox.$input.attr( 'accesskey', $( this ).attr( 'accesskey' ) );