=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java 2012-05-29 21:23:47 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java 2012-09-30 20:23:50 +0000 @@ -40,6 +40,8 @@ public class GetInterpretationsAction implements Action { + private static final int PAGE_SIZE = 6; + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -52,6 +54,17 @@ } // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer page; + + public void setPage( Integer page ) + { + this.page = page; + } + + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- @@ -61,16 +74,18 @@ { return interpretations; } - + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- public String execute() { + int first = page != null ? ( page * PAGE_SIZE ) : 0; + interpretationService.updateCurrentUserLastChecked(); - interpretations = interpretationService.getInterpretations( 0, 20 ); + interpretations = interpretationService.getInterpretations( first, PAGE_SIZE ); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js 2012-09-30 17:45:22 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js 2012-09-30 20:23:50 +0000 @@ -1,9 +1,52 @@ +var currentPage = 0; +var pageLock = false; + $( document ).ready( function() { $( ".commentArea" ).autogrow(); + + $( document ).scroll( function() { + isNextPage(); + } ); + $( "#interpretationFeed" ).load( "getInterpretations.action" ); } ); +function isNextPage() +{ + var fromTop = $( document ).scrollTop(); + var height = $( document ).height(); + var threshold = 0.7; + var loaded = parseFloat( parseFloat( fromTop ) / parseFloat( height ) ); + + if ( loaded >= threshold ) + { + loadNextPage(); + } +} + +function loadNextPage() +{ + if ( pageLock == true ) + { + return false; + } + + pageLock = true; + currentPage++; + + $.get( "getInterpretations.action", { page: currentPage }, function( data ) { + $( "#interpretationFeed" ).append( data ); + + if ( !isDefined ( data ) || $.trim( data ).length == 0 ) + { + $( document ).off( "scroll" ); + } + + pageLock = false; + } ); +} + function showUserInfo( id ) { $( "#userInfo" ).load( "../dhis-web-commons-ajax-html/getUser.action?id=" + id, function() {