Jdlrobson has uploaded a new change for review.

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


Change subject: Alpha: Surface nearby articles
......................................................................

Alpha: Surface nearby articles

Note: Appears to be an unrelated encoding change in this file

Change-Id: I99eecdcd20eed8b4df88152f0eeecc6e730522cb
---
M MobileFrontend.i18n.php
M includes/Resources.php
A javascripts/modules/nearbypages.js
M less/common/pagelist.less
A less/modules/nearbypages.less
M stylesheets/common/pagelist.css
A stylesheets/modules/images/nearby.png
A stylesheets/modules/nearbypages.css
A templates/overlays/nearby.html
9 files changed, 116 insertions(+), 2 deletions(-)


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

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 3c031e4..7cfaf83 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -125,6 +125,9 @@
 
        'mobile-frontend-user-cta' => 'Please login or sign up to see your 
notifications.',
 
+       // nearby overlay
+       'mobile-frontend-nearby-to-page' => 'The following pages are related to 
$1 by their geographical location',
+
        // nearby
        'mobile-frontend-nearby-title' => 'Nearby',
        'mobile-frontend-nearby-loading' => 'Loading topics near your current 
location',
@@ -507,6 +510,7 @@
        'mobile-frontend-page-saving' => 'Text shown whilst an article is being 
saved.
 {{Identical|Saving}}',
        'mobile-frontend-user-cta' => 'Appears when you click user icon when 
not logged in. First link is to login form, 2nd to sign up form. Links are 
created in JavaScript.',
+       'mobile-frontend-nearby-to-page' => 'Pretext that describes that the 
pages are related as they have locations near the location of the current 
article',
        'mobile-frontend-nearby-title' => 'Title of Special:Nearby.
 {{Identical|Nearby}}',
        'mobile-frontend-nearby-loading' => 'Informative message telling user 
that their location is being looked up',
@@ -13849,7 +13853,7 @@
        'mobile-frontend-nearby-error' => '{{SITENAME}}附近功能有一些問題。',
        'mobile-frontend-nearby-error-guidance' => '嘗試更新你的位置。',
        'mobile-frontend-nearby-link' => '以全顯幕閱讀此頁',
-       'mobile-frontend-nearby-directions' => '瀏覽這𥚃',
+       'mobile-frontend-nearby-directions' => '瀏覽這嚃',
        'mobile-frontend-donate-image-login' => '您必須登入以查看您的上傳。',
        'mobile-frontend-photo-upload-generic' => '貢獻圖片',
        'mobile-frontend-donate-image-title' => '上載',
diff --git a/includes/Resources.php b/includes/Resources.php
index 8d7ff07..4f31b9f 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -339,11 +339,18 @@
                ),
        ),
 
+       'mobile.alpha.plumbing' => $wgMFMobileResourceTemplateBoilerplate + 
array(
+               'templates' => array(
+                       'overlays/nearby',
+               ),
+       ),
        'mobile.alpha' => $wgMFMobileResourceBoilerplate + array(
                'dependencies' => array(
                        'mobile.stable',
                        'mobile.beta',
                        'mobile.history',
+                       'mobile.alpha.plumbing',
+                       'nearby',
                ),
                'messages' => array(
 
@@ -352,9 +359,13 @@
 
                        // history-alpha.js
                        'mobile-frontend-language-article-heading',
+
+                       // nearbypages.js
+                       'mobile-frontend-nearby-to-page',
                ),
                'styles' => array(
                        'stylesheets/modules/mf-tables.css',
+                       'stylesheets/modules/nearbypages.css',
                ),
                'scripts' => array(
                        'javascripts/modules/mf-inline-style-scrubber.js',
@@ -362,6 +373,7 @@
                        'javascripts/modules/mf-tables.js',
                        'javascripts/modules/mf-translator.js',
                        'javascripts/modules/lazyload.js',
+                       'javascripts/modules/nearbypages.js'
                ),
        ),
 
@@ -590,7 +602,7 @@
                ),
        ),
 
-       'mobile.nearby.scripts' => $wgMFMobileResourceBoilerplate + array(
+       'nearby' => $wgMFMobileResourceBoilerplate + array(
                'dependencies' => array(
                        'mobile.stable.common',
                        'mobile.nearby.styles',
@@ -616,6 +628,14 @@
                'scripts' => array(
                        'javascripts/modules/NearbyApi.js',
                        'javascripts/widgets/Nearby.js',
+               ),
+       ),
+
+       'mobile.nearby.scripts' => $wgMFMobileResourceBoilerplate + array(
+               'dependencies' => array(
+                       'nearby',
+               ),
+               'scripts' => array(
                        'javascripts/specials/nearby.js',
                ),
                // stop flash of unstyled content when loading from cache
diff --git a/javascripts/modules/nearbypages.js 
b/javascripts/modules/nearbypages.js
new file mode 100644
index 0000000..289d2a4
--- /dev/null
+++ b/javascripts/modules/nearbypages.js
@@ -0,0 +1,56 @@
+( function( M, $ ) {
+var latLng, lat, lng,
+       Overlay = M.require( 'Overlay' ),
+
+       Nearby = M.require( 'widgets/nearby' ),
+
+       GeoOverlay = Overlay.extend( {
+               template: M.template.get( 'overlays/nearby' ),
+               defaults: {
+                       heading: 'Nearby',
+                       pretext: mw.message( 'mobile-frontend-nearby-to-page', 
mw.config.get( 'wgTitle' ) )
+               },
+               initialize: function( options ) {
+                       this._super( options );
+                       this.latLngString = options.latitude + ',' + 
options.longitude;
+               },
+               postRender: function( options ) {
+                       var widget;
+
+                       this._super( options );
+                       widget = new Nearby( {
+                               range: 2000,
+                               el: this.$( '.container' )
+                       } );
+                       widget.load( options.latitude, options.longitude,
+                               { latitude: options.latitude, longitude: 
options.longitude } );
+               }
+       } );
+
+
+function initNearbyButton( latitude, longitude ) {
+       var overlay = new GeoOverlay( { latitude: latitude, longitude: 
longitude } );
+       $( '<button class="nearby">' ).on( 'click', function() {
+               overlay.show();
+       } ).appendTo( '#section_0' );
+}
+
+function init() {
+       // in form 37.783; -122.417 - take the first one
+       latLng = $( '.geo' ).eq( 0 ).text();
+       // Matches <number>;<spaces><number> where number can be negative or 
positive and a float or integer
+       latLng = latLng.match( /([\-]?[\-0-9]+[\.]?[0-9]*);[ 
]+([\-]?[0-9]+[\.]?[0-9]*)/ );
+       if ( latLng ) {
+               lat = latLng[1];
+               lng = latLng[2];
+       }
+
+       if ( lat && lng ) {
+               // in business!
+               initNearbyButton( lat, lng );
+       }
+}
+init();
+M.on( 'page-loaded', init );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/less/common/pagelist.less b/less/common/pagelist.less
index 967b17f..4e328c7 100644
--- a/less/common/pagelist.less
+++ b/less/common/pagelist.less
@@ -104,6 +104,7 @@
                }
                .listThumb {
                        width: @thumbOverlayWidth;
+                       height: 100%;
                        margin-left: -@thumbOverlaySpace;
                }
                a.title {
diff --git a/less/modules/nearbypages.less b/less/modules/nearbypages.less
new file mode 100644
index 0000000..61fba86
--- /dev/null
+++ b/less/modules/nearbypages.less
@@ -0,0 +1,9 @@
+.nearby {
+       // FIXME: Replace with a more appropriate image
+       background-image: url(images/nearby.png);
+       width: 20px;
+       height: 20px;
+       background-size: 20px 20px;
+       background-repeat: no-repeat;
+       margin-left: 8px;
+}
diff --git a/stylesheets/common/pagelist.css b/stylesheets/common/pagelist.css
index 76d8c9f..39bb7be 100644
--- a/stylesheets/common/pagelist.css
+++ b/stylesheets/common/pagelist.css
@@ -98,6 +98,7 @@
 }
 .mw-mf-overlay ul.a-to-z li .listThumb {
   width: 40px;
+  height: 100%;
   margin-left: -55px;
 }
 .mw-mf-overlay ul.a-to-z li a.title {
diff --git a/stylesheets/modules/images/nearby.png 
b/stylesheets/modules/images/nearby.png
new file mode 100644
index 0000000..c830b70
--- /dev/null
+++ b/stylesheets/modules/images/nearby.png
Binary files differ
diff --git a/stylesheets/modules/nearbypages.css 
b/stylesheets/modules/nearbypages.css
new file mode 100644
index 0000000..eb0e681
--- /dev/null
+++ b/stylesheets/modules/nearbypages.css
@@ -0,0 +1,8 @@
+.nearby {
+  background-image: url(images/nearby.png);
+  width: 20px;
+  height: 20px;
+  background-size: 20px 20px;
+  background-repeat: no-repeat;
+  margin-left: 8px;
+}
diff --git a/templates/overlays/nearby.html b/templates/overlays/nearby.html
new file mode 100644
index 0000000..ccc9267
--- /dev/null
+++ b/templates/overlays/nearby.html
@@ -0,0 +1,15 @@
+<div class="header">
+       <button class="cancel">{{closeMsg}}</button>
+       <h2>{{heading}}</h2>
+       <button class="add">+</button>
+</div>
+<p class="mw-mf-overlay-header">{{pretext}}</p>
+<div class="container">
+       <ul>
+               {{#sections}}
+                       <li>
+                               <a data-id="{{id}}">{{heading}}</a>
+                       </li>
+               {{/sections}}
+       </ul>
+</div>

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

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