Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179160

Change subject: Hygiene: Document EditorOverlay and EditorOverlayBase
......................................................................

Hygiene: Document EditorOverlay and EditorOverlayBase

Change-Id: Ib88873e2d67a859438daef5e830cd6ce2a09456e
---
M javascripts/modules/editor/EditorOverlay.js
M javascripts/modules/editor/EditorOverlayBase.js
2 files changed, 77 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/60/179160/1

diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 25fad80..cb9c27c 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -40,7 +40,7 @@
                editor: 'SourceEditor',
                sectionLine: '',
 
-               /*
+               /**
                 * Check whether VisualEditor is enabled or not.
                 * @method
                 * @return boolean
@@ -53,6 +53,7 @@
                                mw.config.get( 'wgPageContentModel' ) === 
'wikitext';
                },
 
+               /** @inheritdoc **/
                initialize: function ( options ) {
                        this.api = new EditorApi( {
                                title: options.title,
@@ -82,6 +83,7 @@
                        }
                },
 
+               /** @inheritdoc **/
                postRender: function ( options ) {
                        var self = this;
                        EditorOverlayBase.prototype.postRender.apply( this, 
arguments );
@@ -161,6 +163,7 @@
 
                /**
                 * Handles click on "Edit without login" in anonymous editing 
warning.
+                * @private
                 */
                _showEditorAfterWarning: function () {
                        this.showSpinner();
@@ -170,13 +173,16 @@
                        this._loadContent();
                },
 
+               /**
+                * Prepares the preview interface and reveals the save screen 
of the overlay
+                * @private
+                * @inheritdoc
+                */
                _prepareForSave: function () {
                        var self = this,
                                params = {
                                        text: this.$content.val()
                                };
-
-                       this._showHidden( '.save-header, .save-panel' );
 
                        this.scrollTop = $( 'body' ).scrollTop();
                        this.$content.hide();
@@ -205,6 +211,10 @@
                        EditorOverlayBase.prototype._prepareForSave.apply( 
this, arguments );
                },
 
+               /**
+                * Hides the preview and reverts back to initial screen.
+                * @private
+                */
                _hidePreview: function () {
                        this.api.abort();
                        this.clearSpinner();
@@ -215,6 +225,10 @@
                        this.abuseFilterPanel.hide();
                },
 
+               /**
+                * Requests content from the API and reveals it in UI.
+                * @private
+                */
                _loadContent: function () {
                        var self = this;
 
@@ -234,6 +248,11 @@
                                } );
                },
 
+               /**
+                * Loads a {VisualEditorOverlay} and replaces the existing 
EditorOverlay with it
+                * based on the current option values.
+                * @private
+                */
                _switchToVisualEditor: function ( options ) {
                        var self = this;
                        this.log( 'switch' );
@@ -259,6 +278,10 @@
                        );
                },
 
+               /**
+                * Reveals an abuse filter panel inside the view.
+                * @private
+                */
                _showAbuseFilter: function ( type, message ) {
                        this.abuseFilterPanel.show( type, message );
                        this._showHidden( '.save-header' );
@@ -269,6 +292,7 @@
                /**
                 * Executed when the editor clicks the save button. Handles 
logging and submitting
                 * the save action to the editor API.
+                * @inheritdoc
                 */
                _save: function () {
                        var self = this,
@@ -323,6 +347,14 @@
                                        }
                                } );
                },
+
+               /**
+                * Checks whether the existing content has changed.
+                * FIXME: Make method of EditorApi
+                * @uses EditorApi
+                * @private
+                * @return {Boolean}
+                */
                _hasChanged: function () {
                        return this.api.hasChanged;
                }
diff --git a/javascripts/modules/editor/EditorOverlayBase.js 
b/javascripts/modules/editor/EditorOverlayBase.js
index 1b4fb63..bd4b417 100644
--- a/javascripts/modules/editor/EditorOverlayBase.js
+++ b/javascripts/modules/editor/EditorOverlayBase.js
@@ -76,14 +76,22 @@
                        captchaTryAgainMsg: mw.msg( 
'mobile-frontend-editor-captcha-try-again' ),
                        switchMsg: mw.msg( 
'mobile-frontend-editor-switch-editor' )
                } ),
+               /** @inheritdoc **/
                templatePartials: {
                        switcher: mw.template.get( 'mobile.editor.common', 
'switcher.hogan' ),
                        editHeader: mw.template.get( 'mobile.editor.common', 
'editHeader.hogan' ),
                        previewHeader: mw.template.get( 'mobile.editor.common', 
'previewHeader.hogan' ),
                        saveHeader: mw.template.get( 'mobile.editor.common', 
'saveHeader.hogan' )
                },
+               /** @inheritdoc **/
                template: mw.template.get( 'mobile.editor.common', 
'EditorOverlayBase.hogan' ),
+               /** @inheritdoc **/
                className: 'overlay editor-overlay',
+               /**
+                * Logs an event to  
http://meta.wikimedia.org/wiki/Schema:MobileWebEditing
+                * @param {String} action name in workflow.
+                * @param {String} [errorText] error to report if applicable
+                */
                log: function ( action, errorText ) {
                        var
                                data = {
@@ -162,6 +170,7 @@
                                expires: 30
                        } );
                },
+               /** @inheritdoc **/
                initialize: function ( options ) {
                        if ( !options.previewingMsg ) {
                                options.previewingMsg = mw.msg( 
'mobile-frontend-editor-previewing-page', options.title );
@@ -196,11 +205,23 @@
 
                        Overlay.prototype.initialize.apply( this, arguments );
                },
+               /**
+                * Report errors back to the user. Silently record the error 
using EventLogging.
+                * @param {String} msg key of message to display to user
+                * @param {String} errorText to log to EventLogging
+                */
                reportError: function ( msg, errorText ) {
                        this.log( 'error', errorText );
                        toast.show( msg, 'toast error' );
                },
+               /**
+                * Prepares the penultimate screen before saving.
+                * Expects to be overriden by child class.
+                * FIXME: EditorOverlay and VisualEditorOverlay have common
+                * @private
+                */
                _prepareForSave: function () {
+                       this._showHidden( '.save-header, .save-panel' );
                        this.log( 'save' );
                        // Scroll to the top of the page, so that the summary 
input is visible
                        // (even if overlay was scrolled down when editing) and 
weird iOS header
@@ -208,6 +229,11 @@
                        // screen, instead staying lower until a subsequent 
scroll event).
                        window.scrollTo( 0, 1 );
                },
+               /**
+                * Executed when the editor clicks the save button. Expects to 
be overriden by child
+                * class. Checks if the save needs to be confirmed.
+                * @private
+                */
                _save: function () {
                        this.confirmAborted = false;
                        // Ask for confirmation in some cases
@@ -217,6 +243,7 @@
                        }
                        this.log( 'submit' );
                },
+               /** @inheritdoc **/
                postRender: function () {
                        var self = this;
                        this.$spinner = self.$( '.spinner' );
@@ -254,6 +281,10 @@
                                } );
                        } );
                },
+               /**
+                * Allow prompts user to confirm before closing and losing edit.
+                * @inheritdoc
+                */
                hide: function ( force ) {
                        var confirmMessage = mw.msg( 
'mobile-frontend-editor-cancel-confirm' );
                        if ( force || !this._hasChanged() || window.confirm( 
confirmMessage ) ) {
@@ -262,6 +293,17 @@
                                return false;
                        }
                },
+               /**
+                * Checks whether the state of the thing being edited as 
changed. Expects to be
+                * implemented by child class.
+                * @private
+                */
+               _hasChanged: $.noop(),
+               /**
+                * Reveal the captcha in the View
+                * @param {String} url a url to an image representing the 
current captcha.
+                * @private
+                */
                _showCaptcha: function ( url ) {
                        var self = this,
                                $input = this.$( '.captcha-word' );

-- 
To view, visit https://gerrit.wikimedia.org/r/179160
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib88873e2d67a859438daef5e830cd6ce2a09456e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to