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

Change subject: Infinite scroll load more
......................................................................


Infinite scroll load more

Change-Id: I454c48d1cc184d3c72453083834f6b204763315f
---
M handlebars/compiled/flow_block_topic.handlebars.php
M handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/flow_load_more.handlebars
M modules/new/components/flow-board.js
5 files changed, 44 insertions(+), 13 deletions(-)

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



diff --git a/handlebars/compiled/flow_block_topic.handlebars.php 
b/handlebars/compiled/flow_block_topic.handlebars.php
index 7607282..8c848bb 100644
--- a/handlebars/compiled/flow_block_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic.handlebars.php
@@ -266,4 +266,4 @@
 </div>
 ';
 }
-?>
\ No newline at end of file
+?>
diff --git a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php 
b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
index bbafc6f..eaa144f 100644
--- a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
@@ -188,4 +188,4 @@
 </div>
 ';
 }
-?>
\ No newline at end of file
+?>
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php 
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index e196c0f..bf6c2c7 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -323,12 +323,12 @@
        '.((LCRun3::ifvar($cx, ((is_array($in['links']['pagination']) && 
isset($in['links']['pagination']['fwd'])) ? $in['links']['pagination']['fwd'] : 
null))) ? '
        <a data-flow-interactive-handler="apiRequest"
           data-flow-api-handler="loadMore"
-          data-flow-api-target="< .flow-component"
+          data-flow-load-handler="loadMore"
           href="'.htmlentities(((is_array($in['links']['pagination']['fwd']) 
&& isset($in['links']['pagination']['fwd']['url'])) ? 
$in['links']['pagination']['fwd']['url'] : null), ENT_QUOTES, 'UTF-8').'"
           title="'.htmlentities(((is_array($in['links']['pagination']['fwd']) 
&& isset($in['links']['pagination']['fwd']['title'])) ? 
$in['links']['pagination']['fwd']['title'] : null), ENT_QUOTES, 'UTF-8').'"
-          class="flow-ui-button flow-ui-progressive /*flow-ui-quiet 
flow-ui-thin*/"><span class="wikiglyph wikiglyph-article"></span> 
'.LCRun3::ch($cx, 'l10n', Array('flow-load-more'), 'encq').'</a>
+          class="flow-ui-button flow-ui-progressive flow-load-interactive 
/*flow-ui-quiet flow-ui-thin*/"><span class="wikiglyph 
wikiglyph-article"></span> '.LCRun3::ch($cx, 'l10n', Array('flow-load-more'), 
'encq').'</a>
 ' : '').'
 </div>
 ';
 }
-?>
\ No newline at end of file
+?>
diff --git a/handlebars/flow_load_more.handlebars 
b/handlebars/flow_load_more.handlebars
index ea3ecd9..dc86cb5 100644
--- a/handlebars/flow_load_more.handlebars
+++ b/handlebars/flow_load_more.handlebars
@@ -1,8 +1,8 @@
 {{#if links.pagination.fwd}}
        <a data-flow-interactive-handler="apiRequest"
           data-flow-api-handler="loadMore"
-          data-flow-api-target="< .flow-component"
+          data-flow-load-handler="loadMore"
           href="{{links.pagination.fwd.url}}"
           title="{{links.pagination.fwd.title}}"
-          class="flow-ui-button flow-ui-progressive /*flow-ui-quiet 
flow-ui-thin*/"><span class="wikiglyph wikiglyph-article"></span> {{l10n 
"flow-load-more"}}</a>
+          class="flow-ui-button flow-ui-progressive flow-load-interactive 
/*flow-ui-quiet flow-ui-thin*/"><span class="wikiglyph 
wikiglyph-article"></span> {{l10n "flow-load-more"}}</a>
 {{/if}}
\ No newline at end of file
diff --git a/modules/new/components/flow-board.js 
b/modules/new/components/flow-board.js
index d566c9c..3d5d4d9 100644
--- a/modules/new/components/flow-board.js
+++ b/modules/new/components/flow-board.js
@@ -760,6 +760,27 @@
                        );
                };
 
+               /**
+                * Stores the load more button for use with infinite scroll.
+                * @param {jQuery} $button
+                */
+               FlowBoardComponent.UI.events.loadHandlers.loadMore = function ( 
$button ) {
+                       var flowBoard = 
FlowBoardComponent.prototype.getInstanceByElement( $button );
+
+                       if ( !flowBoard.$loadMoreNodes ) {
+                               // Create a new $loadMoreNodes list
+                               flowBoard.$loadMoreNodes = $();
+                       } else {
+                               // Remove any loadMore nodes that are no longer 
in the body
+                               flowBoard.$loadMoreNodes = 
flowBoard.$loadMoreNodes.filter( function () {
+                                       return $( this ).closest( 'body' 
).length;
+                               } );
+                       }
+
+                       // Store this new loadMore node
+                       flowBoard.$loadMoreNodes = 
flowBoard.$loadMoreNodes.add( $button );
+               };
+
                ////////////////////////////////////////////////////////////
                // FlowBoardComponent.UI event interactive handlers
                ////////////////////
@@ -1505,16 +1526,26 @@
 
                /**
                 * Called on window.scroll. Checks to see if a FlowBoard needs 
to have more content loaded.
-                * @todo Find a better way than directly targetting the button 
by class
                 */
                FlowBoardComponent.UI.infiniteScrollCheck = function () {
-                       var windowPosition = $( window ).scrollTop() + $( 
window ).height();
+                       var windowHeight = $( window ).height(),
+                               scrollPosition = $( window ).scrollTop();
 
-                       $.each( FlowBoardComponent.prototype.getInstances(), 
function () {
-                               var flowBoard = this;
+                       if ( scrollPosition > 25 ) {
+                               $.each( 
FlowBoardComponent.prototype.getInstances(), function () {
+                                       var flowBoard = this,
+                                               $loadMoreNodes = 
flowBoard.$loadMoreNodes || $();
 
-
-                       } );
+                                       // Check each loadMore button
+                                       $loadMoreNodes.each( function () {
+                                               // Only count this button as 
infinite-scrollable if it appears below the fold
+                                               // and that we have scrolled at 
least 50% of the way to it
+                                               if ( this.offsetTop > 
windowHeight && scrollPosition / ( this.offsetTop - windowHeight ) > 0.5 ) {
+                                                       $( this ).click();
+                                               }
+                                       } );
+                               } );
+                       }
                };
 
                /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I454c48d1cc184d3c72453083834f6b204763315f
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: frontend-rewrite
Gerrit-Owner: SG <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to