jenkins-bot has submitted this change and it was merged.
Change subject: Consolidate edit section handling code in ViewPageTarget
......................................................................
Consolidate edit section handling code in ViewPageTarget
Move generation of initial edit summary from setupSaveDialog() to
restoreEditSection().
This allows us to get rid of the properties tracking whether both
halves of the edit section handling had happened, because they're
now in the same method.
Moving setupSaveDialog() down so it runs after restoreEditSection();
this is needed for the communication via this.initialEditSummary
to work correctly.
Change-Id: I06a9c5cf5c752acea8a2ac25d0ffb6ac61cfe986
---
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
1 file changed, 9 insertions(+), 29 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 25c5fe8..c2d70bd 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -51,8 +51,6 @@
this.scrollTop = null;
this.currentUri = currentUri;
this.section = currentUri.query.vesection || null;
- this.sectionPositionRestored = false;
- this.sectionTitleRestored = false;
this.namespaceName = mw.config.get( 'wgCanonicalNamespace' );
this.viewUri = new mw.Uri( mw.util.getUrl( this.pageName ) );
this.veEditUri = this.viewUri.clone().extend( { 'veaction': 'edit' } );
@@ -230,10 +228,10 @@
this.setUpSurface( doc, ve.bind( function() {
this.startSanityCheck();
this.setupToolbarButtons();
- this.setupSaveDialog();
this.attachToolbarButtons();
this.restoreScrollPosition();
this.restoreEditSection();
+ this.setupSaveDialog();
this.setupBeforeUnloadHandler();
this.$document[0].focus();
this.activating = false;
@@ -1206,19 +1204,7 @@
* @method
*/
ve.init.mw.ViewPageTarget.prototype.setupSaveDialog = function () {
- var sectionTitle = '';
-
this.saveDialog = this.surface.getDialogs().getWindow( 'mwSave' );
-
- if ( this.section ) {
- sectionTitle = this.$document.find( 'h1, h2, h3, h4, h5, h6'
).eq( this.section - 1 ).text();
- sectionTitle = '/* ' + ve.graphemeSafeSubstring( sectionTitle,
0, 244 ) + ' */ ';
- this.saveDialog.setEditSummary( sectionTitle );
- this.sectionTitleRestored = true;
- if ( this.sectionPositionRestored ) {
- this.onSectionRestored();
- }
- }
// Connect to save dialog
this.saveDialog.connect( this, {
'save': 'onSaveDialogSave',
@@ -1226,7 +1212,8 @@
'resolve': 'onSaveDialogResolveConflict',
'close': 'onSaveDialogClose'
} );
- // Setup checkboxes
+ // Setup edit summary and checkboxes
+ this.saveDialog.setEditSummary( this.initialEditSummary );
this.saveDialog.setupCheckboxes( ve.getObjectValues( this.checkboxes
).join( '\n' ) );
};
@@ -1608,6 +1595,11 @@
headingNode = $section.data( 'view' ),
lastHeadingLevel = -1;
+ if ( $section.length ) {
+ this.initialEditSummary = '/* ' +
+ ve.graphemeSafeSubstring( $section.text(), 0,
244 ) + ' */ ';
+ }
+
if ( headingNode ) {
// Find next sibling which isn't a heading
offsetNode = headingNode;
@@ -1632,20 +1624,8 @@
}, 200 );
}
- this.sectionPositionRestored = true;
- if ( this.sectionTitleRestored ) {
- this.onSectionRestored();
- }
+ this.section = null;
}
-};
-
-/**
- * Handle restoration of section editing position and title
- */
-ve.init.mw.ViewPageTarget.prototype.onSectionRestored = function () {
- this.section = null;
- this.sectionPositionRestored = false;
- this.sectionTitleRestored = false;
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/95728
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I06a9c5cf5c752acea8a2ac25d0ffb6ac61cfe986
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits