mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
Merge "More minor/watch checkbox state computation server-side"
This commit is contained in:
commit
5dc1257507
|
@ -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,
|
||||
|
|
|
@ -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' ) );
|
||||
|
|
Loading…
Reference in a new issue