mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "ArticleTarget: remember whether we preloaded, so it can affect the save button"
This commit is contained in:
commit
93c2da8e78
|
@ -239,6 +239,8 @@ class ApiVisualEditor extends ApiBase {
|
|||
$wgTitle = $title;
|
||||
RequestContext::getMain()->setTitle( $title );
|
||||
|
||||
$preloaded = false;
|
||||
|
||||
// Get information about current revision
|
||||
if ( $title->exists() ) {
|
||||
$latestRevision = Revision::newFromTitle( $title );
|
||||
|
@ -287,6 +289,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
$params['preload'], $params['preloadparams'], $title,
|
||||
$params['paction'] !== 'wikitext'
|
||||
);
|
||||
$preloaded = true;
|
||||
}
|
||||
} else {
|
||||
$apiParams['rvsection'] = $section;
|
||||
|
@ -327,6 +330,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
$params['preload'], $params['preloadparams'], $title,
|
||||
$params['paction'] !== 'wikitext'
|
||||
);
|
||||
$preloaded = true;
|
||||
}
|
||||
$baseTimestamp = wfTimestampNow();
|
||||
$oldid = 0;
|
||||
|
@ -584,6 +588,15 @@ class ApiVisualEditor extends ApiBase {
|
|||
( !empty( $params['preload'] ) && isset( $content ) )
|
||||
) {
|
||||
$result['content'] = $content;
|
||||
if ( $preloaded ) {
|
||||
// If the preload param was actually used, pass it
|
||||
// back so the caller knows. (It's not obvious to the
|
||||
// caller, because in some situations it'll depend on
|
||||
// whether the page has been created. They can work it
|
||||
// out from some of the other returns, but this is
|
||||
// simpler.)
|
||||
$result['preloaded'] = $params['preload'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -283,6 +283,7 @@ ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
|
|||
this.fromEditedState = data.fromEditedState;
|
||||
this.switched = data.switched || 'wteswitched' in new mw.Uri( location.href ).query;
|
||||
this.doc = this.constructor.static.parseDocument( this.originalHtml, this.getDefaultMode() );
|
||||
this.preloaded = data.preloaded;
|
||||
|
||||
this.remoteNotices = ve.getObjectValues( data.notices );
|
||||
this.protectedClasses = data.protectedClasses;
|
||||
|
@ -1882,7 +1883,7 @@ ve.init.mw.ArticleTarget.prototype.updateToolbarSaveButtonState = function () {
|
|||
return;
|
||||
}
|
||||
|
||||
this.edited = this.getSurface().getModel().hasBeenModified() || this.fromEditedState;
|
||||
this.edited = this.getSurface().getModel().hasBeenModified() || this.fromEditedState || this.preloaded;
|
||||
if ( this.sectionTitle ) {
|
||||
this.edited = this.edited || this.sectionTitle.getValue() !== '';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue