Jdlrobson has uploaded a new change for review.

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

Change subject: Make more info dialog reusable
......................................................................

Make more info dialog reusable

* Switch to /wikigrok/about more generic url
* Update links
* Do event logging by binding to the link click

Change-Id: I8a8b8b6645be4649deefe97bc901b47ef6d90bdb
---
M includes/Resources.php
M javascripts/modules/wikigrok/WikiGrokDialog.js
A javascripts/modules/wikigrok/WikiGrokDialogB.js
M javascripts/modules/wikigrok/wikigrokeval.js
4 files changed, 46 insertions(+), 15 deletions(-)


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

diff --git a/includes/Resources.php b/includes/Resources.php
index 47e4804..d8951cb 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -898,9 +898,9 @@
                        'modules/wikigrok/WikiGrokMoreInfo.hogan',
                ),
                'scripts' => array(
-                       'javascripts/modules/wikigrok/wikigrokeval.js',
                        'javascripts/modules/wikigrok/WikiGrokDialog.js',
                        'javascripts/modules/wikigrok/WikiGrokMoreInfo.js',
+                       'javascripts/modules/wikigrok/wikigrokeval.js',
                ),
                'styles' => array(
                        'less/modules/wikigrok/WikiGrokDialog.less',
diff --git a/javascripts/modules/wikigrok/WikiGrokDialog.js 
b/javascripts/modules/wikigrok/WikiGrokDialog.js
index 810bd73..41dd297 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialog.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialog.js
@@ -29,7 +29,7 @@
                                { classes: 'cancel inline mw-ui-button', label: 
'No, thanks' },
                                { classes: 'proceed inline mw-ui-button 
mw-ui-progressive', label: 'Okay!' }
                        ],
-                       noticeMsg: '<a class="wg-notice-link" 
href="#/moreinfo">Tell me more</a>'
+                       noticeMsg: '<a class="wg-notice-link" 
href="#/wikigrok/abou">Tell me more</a>'
                },
                template: M.template.get( 
'modules/wikigrok/WikiGrokDialog.hogan' ),
 
@@ -96,7 +96,7 @@
                                                                                
{ classes: 'not-sure inline mw-ui-button', label: 'Not Sure' },
                                                                                
{ classes: 'no inline mw-ui-button mw-ui-progressive', label: 'No' }
                                                                        ];
-                                                                       
options.noticeMsg = 'All submissions are <a class="wg-notice-link" 
href="#/moreinfo">released freely</a>';
+                                                                       
options.noticeMsg = 'All submissions are <a class="wg-notice-link" 
href="#/wikigrok/about">released freely</a>';
                                                                        
self.render( options );
                                                                }
                                                        }
@@ -144,14 +144,13 @@
                                        { classes: 'quit inline mw-ui-button 
mw-ui-progressive', label: 'Done' }
                                ];
                        }
-                       options.noticeMsg = '<a class="wg-notice-link" 
href="#/moreinfo">Tell me more</a>';
+                       options.noticeMsg = '<a class="wg-notice-link" 
href="#/wikigrok/about">Tell me more</a>';
                        // Re-render with new content for 'Thanks' step
                        this.render( options );
                },
 
                postRender: function( options ) {
-                       var self = this,
-                               WikiGrokMoreInfo = M.require( 
'modules/wikigrok/WikiGrokMoreInfo' );
+                       var self = this;
 
                        // If the user hasn't opted-out of WikiGrok, load the 
interface.
                        if ( !localStorage.getItem( 'mfHideWikiGrok' ) ) {
@@ -205,12 +204,9 @@
                                                // Proceed with asking the user 
a metadata question.
                                                self.askWikidataQuestion( 
options );
                                        } );
-                                       // Make OverlayManager handle 
'#/moreinfo' links. We only need to do
-                                       // this once.
-                                       M.overlayManager.add( /^\/moreinfo$/, 
function() {
+                                       // Log more info clicks
+                                       $( '.wg-notice-link' ).on( 'click', 
function() {
                                                self.log( 'moreinfo' );
-                                               // Load the More Info overlay 
when the link is clicked.
-                                               return new WikiGrokMoreInfo();
                                        } );
                                }
 
diff --git a/javascripts/modules/wikigrok/WikiGrokDialogB.js 
b/javascripts/modules/wikigrok/WikiGrokDialogB.js
new file mode 100644
index 0000000..d2d39e3
--- /dev/null
+++ b/javascripts/modules/wikigrok/WikiGrokDialogB.js
@@ -0,0 +1,27 @@
+( function( M ) {
+       M.assertMode( [ 'beta', 'alpha' ] );
+
+       var WikiGrokDialog = M.require( 'modules/wikigrok/WikiGrokDialog' ),
+               WikiGrokDialogB;
+
+       /**
+        * @class WikiGrokDialog
+        * @extends InlineDialog
+        * THIS IS AN EXPERIMENTAL FEATURE THAT MAY BE MOVED TO A SEPARATE 
EXTENSION.
+        * This creates the dialog at the bottom of the lead section that 
appears when a user
+        * scrolls past the lead. It asks the user to confirm metadata 
information for use
+        * in Wikidata (https://www.wikidata.org).
+        */
+       WikiGrokDialogB = WikiGrokDialog.extend( {
+               version: 'b',
+               defaults: {
+                       headerMsg: ''
+               },
+               postRender: function( options ) {
+                       console.log( this );
+                       this.askWikidataQuestion( options );
+               }
+       } );
+
+       M.define( 'modules/wikigrok/WikiGrokDialogB', WikiGrokDialogB );
+}( mw.mobileFrontend ) );
diff --git a/javascripts/modules/wikigrok/wikigrokeval.js 
b/javascripts/modules/wikigrok/wikigrokeval.js
index a8f7188..8c225e4 100644
--- a/javascripts/modules/wikigrok/wikigrokeval.js
+++ b/javascripts/modules/wikigrok/wikigrokeval.js
@@ -1,5 +1,7 @@
 ( function( M, $ ) {
-       var wikidataID = mw.config.get( 'wgWikibaseItemId' );
+       var wikidataID = mw.config.get( 'wgWikibaseItemId' ),
+               WikiGrokDialog = M.require( 'modules/wikigrok/WikiGrokDialog' ),
+               WikiGrokMoreInfo = M.require( 
'modules/wikigrok/WikiGrokMoreInfo' );
 
        // Get existing Wikidata claims about this page so we can decide if 
it's appropriate
        // to display the WikiGrok interface.
@@ -19,8 +21,7 @@
                dataType: 'jsonp',
                success: function( data ) {
                        var instanceClaims,
-                               loadWikiGrokDialog = false,
-                               WikiGrokDialog;
+                               loadWikiGrokDialog = false;
 
                        // See if the page has any 'instance of' claims.
                        if ( data.entities !== undefined && 
data.entities[wikidataID].claims.P31 !== undefined ) {
@@ -37,10 +38,17 @@
                                        }
                                } );
                                if ( loadWikiGrokDialog ) {
-                                       WikiGrokDialog = M.require( 
'modules/wikigrok/WikiGrokDialog' );
                                        new WikiGrokDialog( { itemId: 
wikidataID } );
                                }
                        }
                }
        } );
+
+       // Make OverlayManager handle '#/wikigrok/moreinfo' links. We only need 
to do
+       // this once.
+       M.overlayManager.add( /^\/wikigrok\/about$/, function() {
+               // Load the More Info overlay when the link is clicked.
+               return new WikiGrokMoreInfo();
+       } );
+
 }( mw.mobileFrontend, jQuery ) );

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

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