Bmansurov has uploaded a new change for review.

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

Change subject: Promote WikiGrok Roulette to beta
......................................................................

Promote WikiGrok Roulette to beta

Also:
* Show the next button when a badge is showed
* Show different encouragement texts according to the design
* Explicitly convert string to number

Change-Id: I1358539ae285fb2c62ac9fcdebb84e41542b9cb6
---
M includes/Resources.php
M includes/skins/SkinMinervaAlpha.php
M includes/skins/SkinMinervaBeta.php
M javascripts/modules/wikiGrokRoulette/init.js
M javascripts/modules/wikigrok/WikiGrokDialogC.js
M less/modules/wikigrok/WikiGrokDialog.less
A templates/modules/wikigrok/WikiGrokRouletteBadge.hogan
7 files changed, 77 insertions(+), 54 deletions(-)


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

diff --git a/includes/Resources.php b/includes/Resources.php
index 3695b23..c7ebcee 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -1161,6 +1161,9 @@
                'scripts' => array(
                        'javascripts/modules/wikigrok/WikiGrokDialogC.js',
                ),
+               'templates' => array(
+                       'Badge.hogan' => 
'templates/modules/wikigrok/WikiGrokRouletteBadge.hogan',
+               ),
        ),
 
        'mobile.gallery' => $wgMFResourceFileModuleBoilerplate + array(
@@ -1668,6 +1671,7 @@
                        // load code under certain conditions.
                        'mobile.preferredLanguages',
                        'mobile.references.beta',
+                       'mobile.wikigrok.roulette',
                ),
        ),
        'mobile.alpha' => $wgMFResourceFileModuleBoilerplate + array(
@@ -1677,7 +1681,6 @@
                        'mobile.infobox',
                        'mobile.bannerImage',
                        'mobile.fontchanger',
-                       'mobile.wikigrok.roulette',
                        'mobile.errorReport',
                        'mobile.otherProjects',
                ),
diff --git a/includes/skins/SkinMinervaAlpha.php 
b/includes/skins/SkinMinervaAlpha.php
index 474c1e6..55cc0b1 100644
--- a/includes/skins/SkinMinervaAlpha.php
+++ b/includes/skins/SkinMinervaAlpha.php
@@ -86,31 +86,4 @@
 
                return $vars;
        }
-
-       /**
-        * {@inheritdoc}
-        */
-       protected function getDiscoveryTools() {
-               $config = $this->getMFConfig();
-
-               $items = parent::getDiscoveryTools();
-               if (
-                       $config->get( 'MFEnableWikiGrok' ) &&
-                       $config->get( 'MFEnableWikiGrokInSidebar' ) &&
-                       ( $this->getUser()->isLoggedIn() || $config->get( 
'MFEnableWikiGrokForAnons' ) )
-               ) {
-                       $items['wikigrok'] = array(
-                               'links' => array(
-                                       array(
-                                               'text' => $this->msg( 
'mobile-frontend-main-menu-wikigrok-roulette' ),
-                                               'href' => '#',
-                                               'class' => MobileUI::iconClass( 
'wikigrok', 'before',
-                                                       'wikigrok-roulette' ),
-                                       ),
-                               ),
-                               'class' => 'jsonly'
-                       );
-               }
-               return $items;
-       }
 }
diff --git a/includes/skins/SkinMinervaBeta.php 
b/includes/skins/SkinMinervaBeta.php
index e33c037..b204455 100644
--- a/includes/skins/SkinMinervaBeta.php
+++ b/includes/skins/SkinMinervaBeta.php
@@ -152,4 +152,30 @@
                                Html::closeElement( 'div' ) );
                }
        }
+
+       /**
+        * {@inheritdoc}
+        */
+       protected function getDiscoveryTools() {
+               $config = $this->getMFConfig();
+
+               $items = parent::getDiscoveryTools();
+               if (
+                       $config->get( 'MFEnableWikiGrok' ) &&
+                       $config->get( 'MFEnableWikiGrokInSidebar' )
+               ) {
+                       $items['wikigrok'] = array(
+                               'links' => array(
+                                       array(
+                                               'text' => $this->msg( 
'mobile-frontend-main-menu-wikigrok-roulette' ),
+                                               'href' => '#',
+                                               'class' => MobileUI::iconClass( 
'wikigrok', 'before',
+                                                       'wikigrok-roulette' ),
+                                       ),
+                               ),
+                               'class' => 'jsonly'
+                       );
+               }
+               return $items;
+       }
 }
diff --git a/javascripts/modules/wikiGrokRoulette/init.js 
b/javascripts/modules/wikiGrokRoulette/init.js
index c867f67..bb6467f 100644
--- a/javascripts/modules/wikiGrokRoulette/init.js
+++ b/javascripts/modules/wikiGrokRoulette/init.js
@@ -1,5 +1,4 @@
 ( function ( M, $ ) {
-       M.require( 'context' ).assertMode( [ 'alpha' ] );
        var browser = M.require( 'browser' ),
                mainMenu = M.require( 'skin' ).mainMenu,
                $wikiGrokMenuItem =  $( '#mw-mf-page-left' ).find( 
'.wikigrok-roulette' ),
diff --git a/javascripts/modules/wikigrok/WikiGrokDialogC.js 
b/javascripts/modules/wikigrok/WikiGrokDialogC.js
index c53b2c9..7f6a253 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialogC.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialogC.js
@@ -18,27 +18,28 @@
                        thanksMsg: 'You just made Wikipedia a little better, 
thanks! But wait, there is more.',
                        isDrawer: true
                } ),
+               events: {
+                       'click .wg-badge .next': 'onClickNext'
+               },
                /**
                 * Load the next page if available.
                 * Show badge when the user reaches a milestone.
                 * @inheritdoc
                 * @method
                 */
-               postRecordClaims: function () {
+               postRecordClaims: function ( options ) {
                        var self = this,
                                badgeLevels = [ 1, 3, 5, 10, 20, 50, 100 ],
                                showNext = true,
-                               responseText,
                                responseCount;
 
-                       self.$( '.wg-content, .footer' ).hide();
                        self.$( '.spinner' ).show();
 
                        // Count responses if local storage supported
                        if ( browser.supportsLocalStorage ) {
-                               responseCount = localStorage.getItem( 
'wikiGrokResponseCount' );
-                               // Increment claim response count, null if no 
responses
-                               if ( responseCount !== null ) {
+                               responseCount = parseInt( localStorage.getItem( 
'wikiGrokResponseCount' ) );
+                               // Increment claim response count
+                               if ( !isNaN( responseCount ) ) {
                                        responseCount++;
                                } else {
                                        responseCount = 1;
@@ -49,26 +50,33 @@
                                // Add badge if responseCount is at a badge 
level
                                if ( $.inArray( responseCount, badgeLevels ) 
!== -1 ) {
                                        showNext = false;
-                                       responseText = 'Good going! <br> You 
just completed ' + responseCount + ' task';
                                        if ( responseCount === 1 ) {
-                                               responseText += '.';
+                                               options.tasks = responseCount + 
' task';
                                        } else {
-                                               responseText += 's.';
+                                               options.tasks = responseCount + 
' tasks';
                                        }
-                                       self.$( '.spinner' ).hide();
-                                       self.$( '.wg-link' ).empty().addClass( 
'wg-badge-' + responseCount ).show();
-                                       self.$( '.wg-content' )
-                                               .html( responseText )
-                                               .show();
-                                       // let the user enjoy the badge for 2 
seconds
-                                       setTimeout( function () {
-                                               
wikiGrokRoulette.navigateToNextPage();
-                                       }, 2000 );
+                                       options.responseCount = responseCount;
+                                       if ( responseCount < 25 ) {
+                                               options.encouragementText = 
'Good going!';
+                                       } else if ( responseCount < 100 ) {
+                                               options.encouragementText = 
'Whooa, hold up!';
+                                       } else {
+                                               options.encouragementText = 
'Nice!';
+                                       }
+                                       this.template = mw.template.get( 
'mobile.wikigrok.dialog.c', 'Badge.hogan' );
+                                       this.render( options );
                                }
                        }
                        if ( showNext ) {
                                wikiGrokRoulette.navigateToNextPage();
                        }
+               },
+
+               /**
+                * Load the next WikiGrok page
+                */
+               onClickNext: function () {
+                       wikiGrokRoulette.navigateToNextPage();
                },
 
                /**
@@ -79,14 +87,17 @@
 
                        Drawer.prototype.postRender.apply( this, arguments );
 
-                       options.beginQuestions = true;
-                       WikiGrokDialogB.prototype.postRender.apply( this, 
arguments );
+                       // Don't run this when rendering the Badge template
+                       if ( !options.beginQuestions ) {
+                               options.beginQuestions = true;
+                               WikiGrokDialogB.prototype.postRender.apply( 
this, arguments );
 
-                       self.askWikidataQuestion( options );
+                               self.askWikidataQuestion( options );
+
+                               // Silently fetch the next page
+                               wikiGrokRoulette.getNextPage();
+                       }
                        this.show();
-
-                       // Silently fetch the next page
-                       wikiGrokRoulette.getNextPage();
                }
        } );
 
diff --git a/less/modules/wikigrok/WikiGrokDialog.less 
b/less/modules/wikigrok/WikiGrokDialog.less
index da97619..42052f9 100644
--- a/less/modules/wikigrok/WikiGrokDialog.less
+++ b/less/modules/wikigrok/WikiGrokDialog.less
@@ -42,7 +42,8 @@
                background-position: center top;
                .background-image-svg-quick('images/wikigrok');
 
-               a {
+               a,
+               .next {
                        margin-top: 1em;
                }
 
diff --git a/templates/modules/wikigrok/WikiGrokRouletteBadge.hogan 
b/templates/modules/wikigrok/WikiGrokRouletteBadge.hogan
new file mode 100644
index 0000000..75198aa
--- /dev/null
+++ b/templates/modules/wikigrok/WikiGrokRouletteBadge.hogan
@@ -0,0 +1,10 @@
+<div class="pane content">
+       <p class="wg-content">
+               {{encouragementText}}
+               <br>
+               You just completed {{tasks}}.
+       </p>
+       <p class="wg-link wg-badge wg-badge-{{responseCount}}">
+               <button class="mw-ui-button mw-ui-progressive mw-ui-block 
next">Yay, let's do more...</button>
+       </p>
+</div>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1358539ae285fb2c62ac9fcdebb84e41542b9cb6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <bmansu...@wikimedia.org>

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

Reply via email to