JGonera has uploaded a new change for review.

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

Change subject: Create a reusable AbuseFilterPanel
......................................................................

Create a reusable AbuseFilterPanel

This will be used in following commits to show abuse filter messages in
uploads.

In the process, make AbuseFilterOverlay use M.overlayManager.

Change-Id: I7e84b8c6a8a1051a92878d8de8776af64c740c5f
---
M includes/Resources.php
A javascripts/modules/editor/AbuseFilterPanel.js
M javascripts/modules/editor/EditorOverlay.js
M javascripts/modules/editor/EditorOverlayBase.js
A templates/modules/editor/AbuseFilterPanel.html
M templates/modules/editor/EditorOverlayBase.html
6 files changed, 81 insertions(+), 37 deletions(-)


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

diff --git a/includes/Resources.php b/includes/Resources.php
index 10a21ed..7999c54 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -288,6 +288,20 @@
                ),
                'scripts' => array(
                        'javascripts/modules/editor/EditorApi.js',
+                       'javascripts/modules/editor/AbuseFilterOverlay.js',
+                       'javascripts/modules/editor/AbuseFilterPanel.js',
+               ),
+               'templates' => array(
+                       'modules/editor/AbuseFilterOverlay',
+                       'modules/editor/AbuseFilterPanel',
+               ),
+               'messages' => array(
+                       // AbuseFilterOverlay
+                       'mobile-frontend-photo-ownership-confirm',
+                       // AbuseFilterPanel
+                       'mobile-frontend-editor-abusefilter-warning',
+                       'mobile-frontend-editor-abusefilter-disallow',
+                       'mobile-frontend-editor-abusefilter-read-more',
                ),
        ),
 
@@ -326,10 +340,6 @@
                        'mobile-frontend-editor-error-preview',
                        'mobile-frontend-account-create-captcha-placeholder',
                        'mobile-frontend-editor-captcha-try-again',
-                       'mobile-frontend-photo-ownership-confirm',
-                       'mobile-frontend-editor-abusefilter-warning',
-                       'mobile-frontend-editor-abusefilter-disallow',
-                       'mobile-frontend-editor-abusefilter-read-more',
                        'mobile-frontend-editor-editing-page',
                        'mobile-frontend-editor-previewing-page',
                ),
@@ -363,11 +373,9 @@
                        'mobile.loggingSchemas',
                ),
                'scripts' => array(
-                       'javascripts/modules/editor/AbuseFilterOverlay.js',
                        'javascripts/modules/editor/EditorOverlay.js',
                ),
                'templates' => array(
-                       'modules/editor/AbuseFilterOverlay',
                        'modules/editor/EditorOverlayHeader',
                        'modules/editor/EditorOverlay',
                ),
diff --git a/javascripts/modules/editor/AbuseFilterPanel.js 
b/javascripts/modules/editor/AbuseFilterPanel.js
new file mode 100644
index 0000000..05e7f67
--- /dev/null
+++ b/javascripts/modules/editor/AbuseFilterPanel.js
@@ -0,0 +1,45 @@
+( function( M ) {
+       var
+               View = M.require( 'View' ),
+               AbuseFilterOverlay = M.require( 
'modules/editor/AbuseFilterOverlay' ),
+               AbuseFilterPanel;
+
+       AbuseFilterPanel = View.extend( {
+               defaults: {
+                       readMoreMsg: mw.msg( 
'mobile-frontend-editor-abusefilter-read-more')
+               },
+               template: M.template.get( 'modules/editor/AbuseFilterPanel' ),
+               className: 'panel hidden',
+
+               initialize: function() {
+                       this._super();
+                       this.isDisallowed = false;
+               },
+
+               show: function( type, message ) {
+                       var msg;
+
+                       // OverlayManager will replace previous instance of the 
route if present
+                       M.overlayManager.add( /^\/abusefilter$/, function() {
+                               return new AbuseFilterOverlay( { message: 
message } );
+                       } );
+
+                       if ( type === 'warning' ) {
+                               msg = mw.msg( 
'mobile-frontend-editor-abusefilter-warning' );
+                       } else if ( type === 'disallow' ) {
+                               msg = mw.msg( 
'mobile-frontend-editor-abusefilter-disallow' );
+                               this.isDisallowed = true;
+                       }
+
+                       this.$( '.message p' ).text( msg );
+                       this.$el.removeClass( 'hidden' );
+               },
+
+               hide: function() {
+                       this.$el.addClass( 'hidden' );
+               }
+       } );
+
+       M.define( 'modules/editor/AbuseFilterPanel', AbuseFilterPanel );
+
+}( mw.mobileFrontend ) );
diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 90cfb52..79212de 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -8,7 +8,7 @@
                inNavSignupCampaign = M.query.campaign === 'leftNavSignup',
                Section = M.require( 'Section' ),
                EditorApi = M.require( 'modules/editor/EditorApi' ),
-               AbuseFilterOverlay = M.require( 
'modules/editor/AbuseFilterOverlay' ),
+               AbuseFilterPanel = M.require( 'modules/editor/AbuseFilterPanel' 
),
                mobileLeftNavbarEditCTA = M.require( 
'loggingSchemas/mobileLeftNavbarEditCTA' ),
                EditorOverlay;
 
@@ -73,6 +73,8 @@
                        } );
                        // make license links open in separate tabs
                        this.$( '.license a' ).attr( 'target', '_blank' );
+
+                       this.abuseFilterPanel = new 
AbuseFilterPanel().appendTo( this.$( '.panels' ) );
 
                        // If in readOnly mode, make textarea readonly
                        if ( this.readOnly ) {
@@ -144,6 +146,7 @@
                        this.$content.show();
                        window.scrollTo( 0, this.scrollTop );
                        this._showHidden( '.initial-header' );
+                       this.abuseFilterPanel.hide();
                },
 
                _loadContent: function() {
@@ -173,22 +176,10 @@
                },
 
                _showAbuseFilter: function( type, message ) {
-                       var self = this, msg;
-
-                       this.$( '.abusefilter-panel .readmore' ).on( 'click', 
function() {
-                               new AbuseFilterOverlay( { parent: self, 
message: message } ).show();
-                       } );
-
-                       if ( type === 'warning' ) {
-                               msg = mw.msg( 
'mobile-frontend-editor-abusefilter-warning' );
-                       } else if ( type === 'disallow' ) {
-                               msg = mw.msg( 
'mobile-frontend-editor-abusefilter-disallow' );
-                               // disable continue and save buttons, reenabled 
when user changes content
-                               this.$( '.continue, .submit' ).prop( 
'disabled', true );
-                       }
-
-                       this.$( '.message p' ).text( msg );
-                       this._showHidden( '.save-header, .abusefilter-panel' );
+                       this.abuseFilterPanel.show( type, message );
+                       this._showHidden( '.save-header' );
+                       // disable continue and save buttons, reenabled when 
user changes content
+                       this.$( '.continue, .submit' ).prop( 'disabled', 
this.abuseFilterPanel.isDisallowed );
                },
 
                _save: function() {
diff --git a/javascripts/modules/editor/EditorOverlayBase.js 
b/javascripts/modules/editor/EditorOverlayBase.js
index e038559..556d739 100644
--- a/javascripts/modules/editor/EditorOverlayBase.js
+++ b/javascripts/modules/editor/EditorOverlayBase.js
@@ -18,7 +18,6 @@
                        waitMsg: mw.msg( 'mobile-frontend-editor-wait' ),
                        captchaMsg: mw.msg( 
'mobile-frontend-account-create-captcha-placeholder' ),
                        captchaTryAgainMsg: mw.msg( 
'mobile-frontend-editor-captcha-try-again' ),
-                       abusefilterReadMoreMsg: mw.msg( 
'mobile-frontend-editor-abusefilter-read-more')
                },
                template: M.template.get( 'modules/editor/EditorOverlayBase' ),
                className: 'overlay editor-overlay',
diff --git a/templates/modules/editor/AbuseFilterPanel.html 
b/templates/modules/editor/AbuseFilterPanel.html
new file mode 100644
index 0000000..4c96530
--- /dev/null
+++ b/templates/modules/editor/AbuseFilterPanel.html
@@ -0,0 +1,3 @@
+<div class="message">
+       <p></p><a href="#/abusefilter" class="readmore">{{readMoreMsg}}</a>
+</div>
diff --git a/templates/modules/editor/EditorOverlayBase.html 
b/templates/modules/editor/EditorOverlayBase.html
index 8c04466..7a97e76 100644
--- a/templates/modules/editor/EditorOverlayBase.html
+++ b/templates/modules/editor/EditorOverlayBase.html
@@ -24,21 +24,19 @@
        </div>
 </div>
 
-<div class="save-panel panel hideable hidden">
-       <input class="summary" placeholder="{{summaryMsg}}" />
-       <p class="license">{{{licenseMsg}}}</p>
-</div>
-<div class="captcha-panel panel hideable hidden">
-       <div class="inputs-box">
-               <img src="">
-               <input class="captcha-word" placeholder="{{captchaMsg}}" />
+<div class="panels">
+       <div class="save-panel panel hideable hidden">
+               <input class="summary" placeholder="{{summaryMsg}}" />
+               <p class="license">{{{licenseMsg}}}</p>
+       </div>
+       <div class="captcha-panel panel hideable hidden">
+               <div class="inputs-box">
+                       <img src="">
+                       <input class="captcha-word" 
placeholder="{{captchaMsg}}" />
+               </div>
        </div>
 </div>
-<div class="abusefilter-panel panel hideable hidden">
-       <div class="message">
-               <p></p><button class="readmore 
inline">{{abusefilterReadMoreMsg}}</button>
-       </div>
-</div>
+
 <div class="spinner loading"></div>
 
 {{>content}}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7e84b8c6a8a1051a92878d8de8776af64c740c5f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: JGonera <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to