Jdlrobson has uploaded a new change for review.

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

Change subject: Restore the place on Nearby for back button
......................................................................

Restore the place on Nearby for back button

Bug: 72566
Change-Id: I1e17918e218b999dc124b0568e200d60e2f27ca1
---
M javascripts/modules/nearby/Nearby.js
1 file changed, 17 insertions(+), 1 deletion(-)


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

diff --git a/javascripts/modules/nearby/Nearby.js 
b/javascripts/modules/nearby/Nearby.js
index 948057a..963de4d 100644
--- a/javascripts/modules/nearby/Nearby.js
+++ b/javascripts/modules/nearby/Nearby.js
@@ -150,10 +150,26 @@
                        this._postRenderLinks();
                },
                _postRenderLinks: function () {
-                       this.$( 'a' ).on( 'click', function () {
+                       var offset,
+                               hash = window.location.hash;
+
+                       this.$( 'a' ).each( function ( i ) {
+                               // FIXME: not unique if multiple Nearby objects 
on same page
+                               $( this ).attr( 'id', 'nearby-page-list-item-' 
+ i );
+                       } ).on( 'tap', function () {
+                               window.location.hash = $( this ).attr( 'id' );
                                // name funnel for watchlists to catch 
subsequent uploads
                                $.cookie( 'mwUploadsFunnel', 'nearby', { 
expires: new Date( new Date().getTime() + 60000) } );
                        } );
+
+                       // Restore the offset
+                       if ( hash.indexOf( '/' ) === -1 ) {
+                               offset = $( window.location.hash ).offset();
+                               if ( offset ) {
+                                       // Don't reset the hash here as we 
don't want to trigger another Route
+                                       $( window ).scrollTop( offset.top );
+                               }
+                       }
                }
        } );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e17918e218b999dc124b0568e200d60e2f27ca1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to