Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/65000
Change subject: Nearby back button tweaks
......................................................................
Nearby back button tweaks
Only load from cache when a hash is present (suggesting back
button behaviour) if no hash present attempt a lookup
When hitting back button return to previously clicked item
Change-Id: I6c8e5793b153c399ea12d1f46c0bd6a1cb96e00f
---
M javascripts/specials/nearby.js
M javascripts/specials/overlays/preview.js
M templates/articleList.html
A templates/photoUploadAction.html
4 files changed, 15 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/00/65000/1
diff --git a/javascripts/specials/nearby.js b/javascripts/specials/nearby.js
index 15a78e7..53a90f2 100644
--- a/javascripts/specials/nearby.js
+++ b/javascripts/specials/nearby.js
@@ -49,12 +49,17 @@
this.$el.html( errorHtml );
this.$( '.noscript' ).removeClass( 'noscript' );
},
+ openPage: function( ev ) {
+ // help back button work
+ window.location.hash = '#' + $(
ev.currentTarget ).attr( 'name' );
+ window.location = $( ev.currentTarget ).attr(
'href' );
+ },
initialize: function() {
var self = this;
this.$( 'a' ).on( 'mousedown', function( ev ) {
// name funnel for watchlists to catch
subsequent uploads
$.cookie( 'mwUploadsFunnel', 'nearby',
{ expires: new Date( new Date().getTime() + 60000) } );
- self.emit( 'page-click', ev );
+ self.openPage( ev );
} );
self.emit( 'postRender', this.$el );
}
@@ -94,7 +99,7 @@
function render( $content, pages ) {
cache( CACHE_KEY_RESULTS, $.toJSON( pages ) ); // cache result
- pages = $.map( pages, function( page ) {
+ pages = $.map( pages, function( page, i ) {
var coords, lngLat, thumb;
if ( page.thumbnail ) {
@@ -105,6 +110,7 @@
page.pageimageClass = 'needsPhoto';
page.cta = mw.msg(
'mobile-frontend-needs-photo' );
}
+ page.anchor = 'item_' + i;
page.url = M.history.getArticleUrl( page.title );
if ( page.coordinates ) { // FIXME: protect against bug
47133 (remove when resolved)
coords = page.coordinates[0],
@@ -211,9 +217,10 @@
curLocation = false;
}
}
- init();
- if ( lastSearchResult ) {
+ if ( lastSearchResult && window.location.hash ) {
render( $( '#content' ), $.parseJSON( lastSearchResult
) );
+ } else {
+ init();
}
} else {
overlay.renderError();
diff --git a/javascripts/specials/overlays/preview.js
b/javascripts/specials/overlays/preview.js
index 315c960..f200ca3 100644
--- a/javascripts/specials/overlays/preview.js
+++ b/javascripts/specials/overlays/preview.js
@@ -34,7 +34,7 @@
endpoint = module.endpoint;
$( function() {
- module.getOverlay().on( 'page-click', function( ev ) {
+ module.getOverlay().openPage = function( ev ) {
ev.preventDefault();
var loader = new LoadingOverlay(),
$a = $( ev.currentTarget ),
@@ -48,7 +48,6 @@
} ).fail( function() {
loader.hide(); // FIXME: do something more
meaningful e.g. error overlay
} );
- } );
+ };
} );
-
}( mw.mobileFrontend, jQuery ) );
diff --git a/templates/articleList.html b/templates/articleList.html
index 18db2f3..e2f8178 100644
--- a/templates/articleList.html
+++ b/templates/articleList.html
@@ -1,7 +1,7 @@
<ul class="mw-mf-watchlist-results a-to-z">
{{#pages}}
<li title="{{title}}">
- <a href="{{url}}" class="title">
+ <a href="{{url}}" class="title" name="{{anchor}}">
<div class="listThumb {{pageimageClass}}"
style="{{listThumbStyleAttribute}}"></div>
<h2>{{title}}</h2>
{{#cta}}<div class="info">{{cta}}</div>{{/cta}}
diff --git a/templates/photoUploadAction.html b/templates/photoUploadAction.html
new file mode 100644
index 0000000..1a861d9
--- /dev/null
+++ b/templates/photoUploadAction.html
@@ -0,0 +1 @@
+<input name="file" type="file">
--
To view, visit https://gerrit.wikimedia.org/r/65000
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c8e5793b153c399ea12d1f46c0bd6a1cb96e00f
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