jenkins-bot has submitted this change and it was merged.

Change subject: Rewrite nearby as an overlay
......................................................................


Rewrite nearby as an overlay

Reuse watchlist css
No styling attempted in this patchset

Change-Id: I727d606fb1c48a699b2964449fb3f33ae2d3b37e
---
M MobileFrontend.php
M javascripts/specials/nearby.js
A templates/articleList.html
3 files changed, 39 insertions(+), 14 deletions(-)

Approvals:
  awjrichards: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MobileFrontend.php b/MobileFrontend.php
index 6424075..557c273 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -525,7 +525,17 @@
                'javascripts/specials/mobileoptions.js',
        ),
 );
-$wgResourceModules['mobile.nearby.scripts'] = 
$wgMFMobileSpecialPageResourceScriptBoilerplate + array(
+
+$wgResourceModules['mobile.nearby.plumbing'] = 
$wgMFMobileResourceTemplateBoilerplate + array(
+       'templates' => array(
+               'articleList',
+       ),
+);
+$wgResourceModules['mobile.nearby.scripts'] = $wgMFMobileResourceBoilerplate + 
array(
+       'dependencies' => array(
+               'mobile.nearby.plumbing',
+               'mobile.stable',
+       ),
        'messages' => array(
                'mobile-frontend-nearby-error',
                'mobile-frontend-nearby-refresh',
@@ -535,6 +545,9 @@
                'mobile-frontend-nearby-lookup-error',
                'mobile-frontend-nearby-noresults',
        ),
+       'styles' => array(
+               'stylesheets/specials/watchlist.css',
+       ),
        'scripts' => array(
                'javascripts/specials/nearby.js',
        ),
diff --git a/javascripts/specials/nearby.js b/javascripts/specials/nearby.js
index fc975b6..c22b22f 100644
--- a/javascripts/specials/nearby.js
+++ b/javascripts/specials/nearby.js
@@ -3,25 +3,25 @@
 ( function() {
        var supported = !!navigator.geolocation,
                popup = M.require( 'notifications' ),
-               cachedPages;
+               View = M.require( 'view' ),
+               cachedPages,
+               Nearby = View.extend( {
+                       template: M.template.get( 'articleList' )
+               } );
 
        function render( $content, pages ) {
-               var $ul, $li;
-
-               $content.empty();
-               $ul = $( '<ul class="suggestions-results">' );
                pages.sort( function( a, b ) {
                        return a.dist > b.dist ? 1 : -1;
                } ).forEach( function( page ) {
-                       $li = $( '<li class="suggestions-result">' ).
-                               appendTo( $ul );
-                       $( '<a>' ).attr( 'href', M.history.getArticleUrl( 
page.title ) ).
-                               attr( '_target', 'blank' ). // horrible hack 
for time being
-                               text( page.title ).appendTo( $li );
-                       $( '<p>' ).text( mw.message( 
'mobile-frontend-nearby-distance-report',
-                               ( page.dist / 1000 ).toFixed( 2 ) ) ).appendTo( 
$li );
+                       page.url = M.history.getArticleUrl( page.title );
+                       page.proximity = mw.message( 
'mobile-frontend-nearby-distance-report',
+                               ( page.dist / 1000 ).toFixed( 2 ) );
                } );
-               $ul.appendTo( $content );
+
+               new Nearby( {
+                       el: $content[0],
+                       pages: pages
+               } );
        }
 
        function findResults( lat, lng ) {
diff --git a/templates/articleList.html b/templates/articleList.html
new file mode 100644
index 0000000..b60ddaf
--- /dev/null
+++ b/templates/articleList.html
@@ -0,0 +1,12 @@
+<ul class="mw-mf-watchlist-results a-to-z">
+       {{#pages}}
+       <li title="{{title}}">
+               <a href="{{url}}" class="title">
+                       <div class="listThumb listThumbV" 
style="background-image: url({{pageimage}})"></div>
+                       <h2>{{title}}</h2>
+                       <div class="mw-mf-time">{{modified}}</div>
+                       <span class="proximity">{{proximity}}</span>
+               </a>
+       </li>
+       {{/pages}}
+</ul>

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I727d606fb1c48a699b2964449fb3f33ae2d3b37e
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[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

Reply via email to