Jdlrobson has uploaded a new change for review.

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


Change subject: Allow editors to know that undo is unsupported
......................................................................

Allow editors to know that undo is unsupported

This avoids confusing behaviour
Introduce M.query to allow easy lookup of query string parameters
Use a nasty alert since this is an edge case and won't be surfaced
to too many people thus doesn't really warrant much new design work
(Note a toast might be missed)

Bug: 54851
Change-Id: If3b681e0de598dca32719fa0f71a7653aaa0bf77
---
M MobileFrontend.i18n.php
M includes/MobileFrontend.hooks.php
M includes/Resources.php
M javascripts/common/application.js
M javascripts/common/history-alpha.js
A javascripts/loggingSchemas/MobileWebCta2.js
M javascripts/modules/editor/editor.js
M javascripts/modules/tutorials/newbie.js
M javascripts/specials/watchlist.js
9 files changed, 59 insertions(+), 9 deletions(-)


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

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 25e4a59..60cfff9 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -250,6 +250,7 @@
        'mobile-frontend-photo-upload-login' => 'You must be logged in to add 
an image.',
 
        // edit
+       'mobile-frontend-editor-undo-unsupported' => 'Undo is not currently 
supported on mobile.',
        'mobile-frontend-editor-newpage-prompt' => 'This page doesn\'t exist. 
Why not be bold and create it?',
        'mobile-frontend-editor-disabled' => 'You are not allowed to edit this 
page.',
        'mobile-frontend-editor-unavailable' => 'Mobile editing is not 
currently available on your browser. Please try a different browser.',
@@ -698,6 +699,7 @@
 
 Used when the user is not logged in.
 {{Related|Mobile-frontend-login}}',
+       'mobile-frontend-editor-undo-unsupported' => 'Shown when user attempts 
to do an undo which is currently not supported.',
        'mobile-frontend-editor-newpage-prompt' => "Message shown when a page 
doesn't exist.",
        'mobile-frontend-editor-disabled' => 'Toast message that appears when a 
user is unable to edit a page and clicks edit icon',
        'mobile-frontend-editor-unavailable' => 'Toast message that appears 
when a user has a browser incapable of editing when they click on the edit 
button.',
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 6ea9b93..8acfbb5 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -516,8 +516,12 @@
 
                // redirect to mobile editor instead of showing desktop editor
                if ( $context->shouldDisplayMobileView() ) {
-                       $articleUrl = $context->getMobileUrl( 
$article->getTitle()->getFullURL() );
                        $output = $context->getOutput();
+                       $data = $output->getRequest()->getValues();
+                       // Unset these to avoid a redirect loop but make sure 
we pass other parameters to edit e.g. undo actions
+                       unset( $data['action'] );
+                       unset( $data['title'] );
+                       $articleUrl = $context->getMobileUrl( 
$article->getTitle()->getFullURL( $data ) );
                        $section = (int)$output->getRequest()->getVal( 
'section', 0 );
                        $output->redirect( $articleUrl . '#editor/' . $section 
);
                        return false;
diff --git a/includes/Resources.php b/includes/Resources.php
index 670d4c1..1fddcdf 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -508,6 +508,9 @@
                        'mobile-frontend-show-button',
                        'mobile-frontend-hide-button',
 
+                       // editor.js
+                       'mobile-frontend-editor-undo-unsupported',
+
                        // issues.js
                        'mobile-frontend-meta-data-issues',
                        'mobile-frontend-meta-data-issues-header',
diff --git a/javascripts/common/application.js 
b/javascripts/common/application.js
index 6b4f61b..1c59985 100644
--- a/javascripts/common/application.js
+++ b/javascripts/common/application.js
@@ -2,6 +2,7 @@
 // (see https://bugzilla.wikimedia.org/show_bug.cgi?id=44264)
 ( function( M, $ ) {
        var Router = M.require( 'Router' ),
+               qs = window.location.search.split( '?' )[1],
                PageApi = M.require( 'PageApi' ),
                $viewportMeta, viewport,
                ua = window.navigator.userAgent,
@@ -271,6 +272,7 @@
                supportsGeoLocation: supportsGeoLocation,
                supportsPositionFixed: supportsPositionFixed,
                prettyEncodeTitle: prettyEncodeTitle,
+               query: deParam( qs ),
                // FIXME: Replace all instances of M.template with mw.template
                template: mw.template,
                unlockViewport: unlockViewport,
diff --git a/javascripts/common/history-alpha.js 
b/javascripts/common/history-alpha.js
index f360dde..72294d6 100644
--- a/javascripts/common/history-alpha.js
+++ b/javascripts/common/history-alpha.js
@@ -25,8 +25,7 @@
        // do not run more than once
        function init() {
                var title = mw.config.get( 'wgTitle' ),
-                       qs = window.location.search.split( '?' )[1],
-                       currentUrl = mw.util.wikiGetlink( title, M.deParam( qs 
) );
+                       currentUrl = mw.util.wikiGetlink( title, M.query );
                // initial history state does not contain title
                // run before binding to avoid nasty surprises
                History.replaceState( null, title, currentUrl );
diff --git a/javascripts/loggingSchemas/MobileWebCta2.js 
b/javascripts/loggingSchemas/MobileWebCta2.js
new file mode 100644
index 0000000..4b69c6d
--- /dev/null
+++ b/javascripts/loggingSchemas/MobileWebCta2.js
@@ -0,0 +1,39 @@
+( function( M, $ ) {
+
+       function log( name, destination ) {
+               return M.log( 'MobileWebCTA', {
+                       name: name,
+                       destination: destination,
+                       username: mw.config.get( 'wgUserName' ),
+                       userEditCount: parseInt( mw.config.get( 
'wgUserEditCount' ), 10 ),
+                       mobileMode: mw.config.get( 'wgMFMode' )
+               } );
+       }
+
+       function hijackLink( selector, name ) {
+               function linkHandler( ev ) {
+                       ev.preventDefault();
+                       var href = $( this ).attr( 'href' );
+                       log( name, href ).always( function() {
+                               window.location.href = href;
+                       } );
+               }
+               $( selector ).on( M.tapEvent( 'click' ), linkHandler );
+       }
+
+       M.define( 'loggingSchemas/MobileWebClickTracking', {
+               log: log,
+               hijackLink: hijackLink
+       } );
+
+       // Add EventLogging to hamburger menu
+       hijackLink( '#mw-mf-page-left .icon-home a', 'hamburger-home' );
+       hijackLink( '#mw-mf-page-left .icon-random a', 'hamburger-random' );
+       hijackLink( '#mw-mf-page-left .icon-nearby a', 'hamburger-nearby' );
+       hijackLink( '#mw-mf-page-left .icon-watchlist a', 'hamburger-watchlist' 
);
+       hijackLink( '#mw-mf-page-left .icon-settings a', 'hamburger-settings' );
+       hijackLink( '#mw-mf-page-left .icon-uploads a', 'hamburger-uploads' );
+       hijackLink( '#mw-mf-page-left .icon-profile', 'hamburger-profile' );
+       hijackLink( '#mw-mf-page-left .icon-anon a', 'hamburger-login' );
+       hijackLink( '#mw-mf-page-left .icon-secondary-logout', 
'hamburger-logout' );
+} )( mw.mobileFrontend, jQuery );
diff --git a/javascripts/modules/editor/editor.js 
b/javascripts/modules/editor/editor.js
index fe1eb16..0d59b5f 100644
--- a/javascripts/modules/editor/editor.js
+++ b/javascripts/modules/editor/editor.js
@@ -48,7 +48,9 @@
 
        function init( page ) {
                var isNew = mw.config.get( 'wgArticleId' ) === 0;
-
+               if ( M.query.undo ) {
+                       window.alert( mw.msg( 
'mobile-frontend-editor-undo-unsupported' ) );
+               }
                M.router.route( /^editor\/(\d+)$/, function( sectionId ) {
                        var loadingOverlay = new LoadingOverlay();
                        loadingOverlay.show();
diff --git a/javascripts/modules/tutorials/newbie.js 
b/javascripts/modules/tutorials/newbie.js
index affc665..cc0e02d 100644
--- a/javascripts/modules/tutorials/newbie.js
+++ b/javascripts/modules/tutorials/newbie.js
@@ -1,18 +1,19 @@
 ( function( M, $ ) {
        var LeadPhotoTutorialOverlay = M.require( 
'tutorials/LeadPhotoTutorialOverlay' ),
                PageActionOverlay = M.require( 'tutorials/PageActionOverlay' ),
+               action = M.query.article_action,
                escapeHash = M.require( 'toggle' ).escapeHash;
 
        function shouldShowUploadTutorial() {
                // FIXME: Limit audience to only users with low edit count
                return $( '#ca-upload' ).hasClass( 'enabled' ) &&
-                       window.location.search.indexOf( 
'article_action=photo-upload' ) > -1;
+                       action === 'photo-upload';
        }
 
        function shouldShowEditTutorial() {
                // FIXME: Limit audience to only users with low edit count
                return $( '#ca-edit' ).hasClass( 'enabled' ) &&
-                       window.location.search.indexOf( 'article_action=edit' ) 
> -1;
+                       action === 'edit';
        }
 
        $( function() {
diff --git a/javascripts/specials/watchlist.js 
b/javascripts/specials/watchlist.js
index ce1c2f8..654c2d2 100644
--- a/javascripts/specials/watchlist.js
+++ b/javascripts/specials/watchlist.js
@@ -1,10 +1,8 @@
 ( function( M, $ ) {
        var star = M.require( 'watchstar' ),
-               qs = window.location.search.substr( 1 ),
                schema = M.require( 'loggingSchemas/MobileWebClickTracking' ),
                pageName = mw.config.get( 'wgCanonicalSpecialPageName' ) === 
'Watchlist' ? 'watchlist' : 'diff',
-               params = mw.mobileFrontend.deParam( qs ),
-               subPageName = params.watchlistview || 'a-z';
+               subPageName = M.query.watchlistview || 'a-z';
 
        function init() {
                var $watchlist = $( 'ul.page-list' ),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If3b681e0de598dca32719fa0f71a7653aaa0bf77
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

Reply via email to