Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/181700
Change subject: Hygiene: Rename _save to onSaveBegin and _prepareForSave to
onStageChanges
......................................................................
Hygiene: Rename _save to onSaveBegin and _prepareForSave to onStageChanges
Since these are events triggered by clicking save/continue and are overriden
they should be public or protected not private.
To be consistent with other names let's prefix them with `on` and
add common lines of code to the parent postRender method
Change-Id: Ic04df0411bfee67b89039e45daae2f95fdc4084d
---
M javascripts/modules/editor/EditorOverlay.js
M javascripts/modules/editor/EditorOverlayBase.js
M javascripts/modules/editor/VisualEditorOverlay.js
3 files changed, 16 insertions(+), 24 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/00/181700/1
diff --git a/javascripts/modules/editor/EditorOverlay.js
b/javascripts/modules/editor/EditorOverlay.js
index 44fba9a..7233c86 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -107,11 +107,8 @@
return false;
} );
this.clearSpinner();
- } else {
- this.$( '.continue' ).on( 'click', $.proxy(
this, '_prepareForSave' ) );
}
this.$( '.back' ).on( 'click', $.proxy( this,
'_hidePreview' ) );
- this.$( '.submit' ).on( 'click', $.proxy( this, '_save'
) );
// make license links open in separate tabs
this.$( '.license a' ).attr( 'target', '_blank' );
@@ -123,7 +120,7 @@
self._switchToVisualEditor(
options );
} else {
if ( window.confirm( mw.msg(
'mobile-frontend-editor-switch-confirm' ) ) ) {
- self._prepareForSave();
+ self.onStageChanges();
}
}
} );
@@ -173,17 +170,16 @@
this.showSpinner();
this.$anonWarning.hide();
// reenable "Next" button and handle click
- this.$( '.continue' ).show().on( 'click', $.proxy(
this, '_prepareForSave' ) );
+ this.$( '.continue' ).show().on( 'click', $.proxy(
this, 'onStageChanges' ) );
this._loadContent();
},
/**
* Prepares the preview interface and reveals the save screen
of the overlay
* @method
- * @private
* @inheritdoc
*/
- _prepareForSave: function () {
+ onStageChanges: function () {
var self = this,
params = {
text: this.$content.val()
@@ -213,7 +209,7 @@
self.$preview.show();
} );
- EditorOverlayBase.prototype._prepareForSave.apply(
this, arguments );
+ EditorOverlayBase.prototype.onStageChanges.apply( this,
arguments );
},
/**
@@ -307,7 +303,7 @@
* the save action to the editor API.
* @inheritdoc
*/
- _save: function () {
+ onSaveBegin: function () {
var self = this,
options = {
summary: this.$( '.summary' ).val()
@@ -316,7 +312,7 @@
if ( self.sectionLine !== '' ) {
options.summary = '/* ' + self.sectionLine + '
*/' + options.summary;
}
- EditorOverlayBase.prototype._save.apply( this,
arguments );
+ EditorOverlayBase.prototype.onSaveBegin.apply( this,
arguments );
if ( this.confirmAborted ) {
return;
}
diff --git a/javascripts/modules/editor/EditorOverlayBase.js
b/javascripts/modules/editor/EditorOverlayBase.js
index ac8bb6a..a1f59c3 100644
--- a/javascripts/modules/editor/EditorOverlayBase.js
+++ b/javascripts/modules/editor/EditorOverlayBase.js
@@ -71,7 +71,7 @@
summaryMsg: mw.msg(
'mobile-frontend-editor-summary-placeholder' ),
placeholder: mw.msg(
'mobile-frontend-editor-placeholder' ),
waitMsg: mw.msg( 'mobile-frontend-editor-wait' ),
- // icons.spinner can't be used, the spinner class
changes to display:none in _prepareForSave
+ // icons.spinner can't be used, the spinner class
changes to display:none in onStageChanges
waitIcon: new Icon( {
tagName: 'button',
name: 'spinner',
@@ -223,11 +223,9 @@
/**
* Prepares the penultimate screen before saving.
* Expects to be overridden by child class.
- * FIXME: EditorOverlay and VisualEditorOverlay have common
* @method
- * @private
*/
- _prepareForSave: function () {
+ onStageChanges: function () {
// FIXME: Don't call a private method that is outside
the class.
this._showHidden( '.save-header, .save-panel' );
this.log( 'save' );
@@ -241,9 +239,8 @@
* Executed when the editor clicks the save button. Expects to
be overridden by child
* class. Checks if the save needs to be confirmed.
* @method
- * @private
*/
- _save: function () {
+ onSaveBegin: function () {
this.confirmAborted = false;
// Ask for confirmation in some cases
if ( !this.confirmSave() ) {
@@ -271,6 +268,8 @@
Overlay.prototype.postRender.apply( this, arguments );
// FIXME: Don't call a private method that is outside
the class.
this._showHidden( '.initial-header' );
+ this.$( '.submit' ).on( 'click', $.proxy( this,
'onSaveBegin' ) );
+ this.$( '.continue' ).on( 'click', $.proxy( this,
'onStageChanges' ) );
},
/**
* Set up the editor switching interface
diff --git a/javascripts/modules/editor/VisualEditorOverlay.js
b/javascripts/modules/editor/VisualEditorOverlay.js
index a3cd6b5..47da61b 100644
--- a/javascripts/modules/editor/VisualEditorOverlay.js
+++ b/javascripts/modules/editor/VisualEditorOverlay.js
@@ -100,9 +100,6 @@
/** @inheritdoc **/
postRender: function ( options ) {
var self = this;
- // Save button
- this.$( '.continue' ).on( 'click', $.proxy( this,
'_prepareForSave' ) );
- this.$( '.submit' ).on( 'click', $.proxy( this, '_save'
) );
this.$( '.back' ).on( 'click', $.proxy( this,
'switchToEditor' ) );
this.$( '.source-editor' ).on( 'click', function () {
// If changes have been made tell the user they
have to save first
@@ -110,7 +107,7 @@
self.switchToSourceEditor( options );
} else {
if ( window.confirm( mw.msg(
'mobile-frontend-editor-switch-confirm' ) ) ) {
- self._prepareForSave();
+ self.onStageChanges();
}
}
} );
@@ -131,14 +128,14 @@
* Disables the VE editor interface in preparation for saving.
* @inheritdoc
*/
- _prepareForSave: function () {
+ onStageChanges: function () {
// need to blur contenteditable to be sure that
keyboard is properly closed
this.$( '[contenteditable]' ).blur();
this.$( '.surface' ).hide();
- EditorOverlayBase.prototype._prepareForSave.apply(
this, arguments );
+ EditorOverlayBase.prototype.onStageChanges.apply( this,
arguments );
},
/** @inheritdoc **/
- _save: function () {
+ onSaveBegin: function () {
var
self = this,
doc =
this.target.surface.getModel().getDocument(),
@@ -147,7 +144,7 @@
summary: summary
};
- EditorOverlayBase.prototype._save.apply( this,
arguments );
+ EditorOverlayBase.prototype.onSaveBegin.apply( this,
arguments );
if ( this.confirmAborted ) {
return;
}
--
To view, visit https://gerrit.wikimedia.org/r/181700
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic04df0411bfee67b89039e45daae2f95fdc4084d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits