Bmansurov has uploaded a new change for review.

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

Change subject: WIP: Alpha: Quickly lookup info about a wiki page
......................................................................

WIP: Alpha: Quickly lookup info about a wiki page

Change-Id: I39fdd06155cef514f6b2670bc9248d1290bdc146
---
M includes/Resources.php
A javascripts/modules/quickLookup/init.js
2 files changed, 59 insertions(+), 0 deletions(-)


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

diff --git a/includes/Resources.php b/includes/Resources.php
index 1eb7cd4..ecfa1ae 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -1047,6 +1047,18 @@
                ),
        ),
 
+       'mobile.quickLookup' => $wgMFResourceParsedMessageModuleBoilerplate + 
array(
+               'dependencies' => array(
+                       'mobile.startup',
+                       'mobile.toast',
+               ),
+               'scripts' => array(
+                       'javascripts/modules/quickLookup/init.js',
+               ),
+               'messages' => array(
+               ),
+       ),
+
        'mobile.languages' => $wgMFResourceParsedMessageModuleBoilerplate + 
array(
                'dependencies' => array(
                        'mobile.overlays',
@@ -1630,6 +1642,7 @@
                        'mobile.fontchanger',
                        'mobile.errorReport',
                        'mobile.otherProjects',
+                       'mobile.quickLookup',
                ),
                'scripts' => array(
                        'javascripts/modules/commonsCategory/init.js',
diff --git a/javascripts/modules/quickLookup/init.js 
b/javascripts/modules/quickLookup/init.js
new file mode 100644
index 0000000..fc79499
--- /dev/null
+++ b/javascripts/modules/quickLookup/init.js
@@ -0,0 +1,46 @@
+( function ( M, $ ) {
+       var api = M.require( 'api' ),
+               toast = M.require( 'toast' ),
+               hostname = window.location.hostname,
+               startTouch,
+               endTouch,
+               link,
+               title;
+
+       $( function () {
+               // we want a long horizontal swipe
+               $( 'a' ).on( 'touchstart', function ( ev ) {
+                       startTouch = ev.originalEvent.changedTouches[0];
+               } ).on( 'touchend', function ( ev ) {
+                       endTouch = ev.originalEvent.changedTouches[0];
+                       if ( Math.abs( startTouch.pageX - endTouch.pageX ) > 
200 ) {
+                               link = ev.currentTarget;
+                               title = $( link ).text();
+                               if ( link.hostname === hostname ) {
+                                       toast.show( 'Looking for <b>' + title + 
'</b>', 'toast' );
+                                       api.get( {
+                                               prop: 'extracts',
+                                               exsentences: 3,
+                                               titles: title,
+                                               exintro: '',
+                                               continue: '',
+                                               explaintext: ''
+                                       } ).done( function ( data ) {
+                                               var pages = OO.getProp( data, 
'query', 'pages' ),
+                                                       pageID,
+                                                       extract;
+                                               if ( pages ) {
+                                                       for ( pageID in pages ) 
{
+                                                               extract = 
OO.getProp( pages, pageID, 'extract' );
+                                                               if ( extract ) {
+                                                                       
toast.show( extract );
+                                                                       break;
+                                                               }
+                                                       }
+                                               }
+                                       } );
+                               }
+                       }
+               } );
+       } );
+}( mw.mobileFrontend, jQuery ) );

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

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

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

Reply via email to