jenkins-bot has submitted this change and it was merged.
Change subject: Story 774: Allow people to navigate to nearby places
......................................................................
Story 774: Allow people to navigate to nearby places
Currently only for iphone, android and windows phone users
Other devices to not show the directions link
Change-Id: Ic160bd370b394f9760c42ffb47b30f0272c44002
Note: in future the label should be replaced by text
---
M MobileFrontend.i18n.php
M includes/Resources.php
M javascripts/specials/nearby.js
M javascripts/specials/overlays/preview.js
M templates/articleList.html
M templates/overlays/pagePreview.html
6 files changed, 38 insertions(+), 2 deletions(-)
Approvals:
Jdlrobson: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index d11565f..0729d8e 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -140,6 +140,7 @@
'mobile-frontend-nearby-error' => '{{SITENAME}} Nearby is having some
issues.',
'mobile-frontend-nearby-error-guidance' => 'Try refreshing your
location.',
'mobile-frontend-nearby-link' => 'Read this page in full',
+ 'mobile-frontend-nearby-directions' => 'Navigate here',
// image donation
'mobile-frontend-donate-image-login' => 'You must be logged in to see
your uploads.',
@@ -520,6 +521,7 @@
'mobile-frontend-nearby-error' => 'Text of generic error message when
querying geodata api',
'mobile-frontend-nearby-error-guidance' => 'Message explaining actions
user can take when keying error {{msg-mw|mobile-frontend-nearby-error}}',
'mobile-frontend-nearby-link' => 'Text of link that takes user to full
page',
+ 'mobile-frontend-nearby-directions' => 'Text of directions link',
'mobile-frontend-donate-image-login' => 'Title for
[[Special:UserLogin]] when being redirected to [[Special:Uploads]].
Used when the user is not logged in.
diff --git a/includes/Resources.php b/includes/Resources.php
index 8fe564a..c374c31 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -583,6 +583,7 @@
'mobile-frontend-nearby-noresults',
'mobile-frontend-nearby-noresults-guidance',
'mobile-frontend-nearby-link',
+ 'mobile-frontend-nearby-directions',
),
'scripts' => array(
'javascripts/specials/nearby.js',
diff --git a/javascripts/specials/nearby.js b/javascripts/specials/nearby.js
index 9ddc702..64c4505 100644
--- a/javascripts/specials/nearby.js
+++ b/javascripts/specials/nearby.js
@@ -136,6 +136,8 @@
coords = page.coordinates[0],
lngLat = { latitude: coords.lat, longitude:
coords.lon };
page.dist = calculateDistance( curLocation,
lngLat );
+ page.latitude = coords.lat;
+ page.longitude = coords.lon;
page.proximity = distanceMessage( page.dist );
}
pages.push( page );
diff --git a/javascripts/specials/overlays/preview.js
b/javascripts/specials/overlays/preview.js
index 7589fc9..fc004e6 100644
--- a/javascripts/specials/overlays/preview.js
+++ b/javascripts/specials/overlays/preview.js
@@ -1,5 +1,7 @@
( function( M, $ ) {
var Overlay = M.require( 'Overlay' ),
+ ua = window.navigator.userAgent,
+ device = 'unknown',
Page = M.require( 'page' ),
LoadingOverlay = Overlay.extend( {
defaults: {
@@ -10,10 +12,28 @@
PagePreviewOverlay = Overlay.extend( {
template: M.template.get( 'overlays/pagePreview' ),
preRender: function( options ) {
+ var directionUrl;
options.heading = options.page.title;
options.preview = options.page.lead;
options.url = M.history.getArticleUrl(
options.heading );
options.readMoreLink = mw.msg(
'mobile-frontend-nearby-link' );
+
+ if ( options.latLngString ) {
+ // Yeeyyy no standards!
+ // FIXME: would be nice to provide an
opensource alternative
+ if ( device === 'iphone' ) {
+ directionUrl =
'http://maps.apple.com/?daddr=' + options.latLngString;
+ } else if ( device === 'android' ) {
+ directionUrl = 'geo:' +
options.latLngString + '?z=15';
+ } else if ( device === 'wp' ) {
+ directionUrl = 'maps:' +
options.latLngString;
+ } // FIXME: what in other cases?!
+
+ if ( directionUrl ) {
+ options.directionUrl =
directionUrl;
+ options.directionLabel =
mw.msg( 'mobile-frontend-nearby-directions' );
+ }
+ }
},
postRender: function( options ) {
var $preview, nodes;
@@ -33,6 +53,14 @@
module = M.require( 'nearby' ),
endpoint = module.endpoint;
+ if ( ua.match( /OS [0-9]+_[0-9]+ like Mac OS X/ ) ) {
+ device = 'iphone';
+ } else if ( ua.match( /Android/ ) ) {
+ device = 'android';
+ } else if ( ua.match( /Windows Phone/ ) ) {
+ device = 'wp';
+ }
+
$( function() {
// FIXME: temporary code, replace if previews get to stable or
are removed
module.getOverlay().openPage = function( ev ) {
@@ -43,7 +71,9 @@
loader.show();
M.history.retrievePage( title, endpoint, true ).done(
function( page ) {
- var preview = new PagePreviewOverlay( { page:
new Page( page ), img: $( '<div>' ).append( $a.find( '.listThumb' ).clone()
).html() } );
+ var preview = new PagePreviewOverlay( { page:
new Page( page ),
+ latLngString: $a.data( 'latlng' ),
+ img: $( '<div>' ).append( $a.find(
'.listThumb' ).clone() ).html() } );
loader.hide();
preview.show();
} ).fail( function() {
diff --git a/templates/articleList.html b/templates/articleList.html
index a941b48..3dc20ea 100644
--- a/templates/articleList.html
+++ b/templates/articleList.html
@@ -8,7 +8,7 @@
<ul class="mw-mf-watchlist-results a-to-z">
{{#pages}}
<li title="{{title}}">
- <a href="{{url}}" class="title" name="{{anchor}}">
+ <a href="{{url}}" class="title" name="{{anchor}}"
data-latlng="{{latitude}},{{longitude}}">
<div class="listThumb {{pageimageClass}}"
style="{{listThumbStyleAttribute}}"></div>
<h2>{{title}}</h2>
<div class="info proximity">{{proximity}}</div>
diff --git a/templates/overlays/pagePreview.html
b/templates/overlays/pagePreview.html
index afeeae3..be0be28 100644
--- a/templates/overlays/pagePreview.html
+++ b/templates/overlays/pagePreview.html
@@ -1,5 +1,6 @@
<div class="header">
<button class="cancel escapeOverlay">{{closeMsg}}</button>
+ {{#directionUrl}}<a
href="{{directionUrl}}">{{directionLabel}}</a>{{/directionUrl}}
</div>
<p class="message">
<a href="{{url}}">{{readMoreLink}}</a>
--
To view, visit https://gerrit.wikimedia.org/r/68306
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic160bd370b394f9760c42ffb47b30f0272c44002
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: awjrichards <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits