← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3715: Minor fix for paging.vm

 

------------------------------------------------------------
revno: 3715
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-24 11:29:53 +0700
message:
  Minor fix for paging.vm
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm	2011-05-13 09:11:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm	2011-05-24 04:29:53 +0000
@@ -1,4 +1,4 @@
-<div class="paging-container">	
+<div class="paging-container">
 	#set ( $baseLink 		= $paging.baseLink )
 	#set ( $pageSize 		= $paging.pageSize )
 	#set ( $currentPage 	= $paging.currentPage )
@@ -15,11 +15,11 @@
 				</td>
 				<td>
 					<span>$i18n.getString("rows_in_page"):</span>
-					<input type="text" id="sizeOfPage" value="$!pageSize" style="width:50px" onkeyup="changePageSize('$baseLink');">
+					<input type="text" id="sizeOfPage" value="$!pageSize" style="width:50px" onKeyPress="changePageSize(event,'$baseLink');">
 				</td>
 				<td>
 					<span>$i18n.getString("jump_to_page"):</span>					
-					<input type="text" id="jumpToPage" value="$!currentPage" style="width:50px" onkeyup="changePageSize('$baseLink');">
+					<input type="text" id="jumpToPage" value="$!currentPage" style="width:50px" onKeyPress="changePageSize(event,'$baseLink');">
 				</td>
 				<td>
 					<input type="button" id="submitButton" value="$i18n.getString('go')" onclick="changePageSize('$baseLink');">
@@ -33,8 +33,8 @@
 			<div class="paging">
 			#if ($currentPage > 1)
 				#set ( $prev = $currentPage - 1 )
-				<a href="javascript:ajaxPaging( 1,${pageSize} );" class="first" title="First">&laquo;&laquo;</a>
-				<a href="javascript:ajaxPaging( ${prev},${pageSize} );" class="prev" title="Previous">&laquo;</a>
+				<a href="javascript:pagingList( 1,${pageSize} );" class="first" title="First">&laquo;&laquo;</a>
+				<a href="javascript:pagingList( ${prev},${pageSize} );" class="prev" title="Previous">&laquo;</a>
 			#else
 				<span class="first" title="First">&laquo;&laquo;</span>
 				<span class="prev" title="Previous">&laquo;</span>
@@ -47,7 +47,7 @@
 						<span class="seperator">|</span>
 					#end
 					#if( $p != $currentPage )
-						<a href="javascript:ajaxPaging( ${p},${pageSize} );" class="page" title="Page $p">$p</a>
+						<a href="javascript:pagingList( ${p},${pageSize} );" class="page" title="Page $p">$p</a>
 					#else
 						<span class="page" title="Page $p">$p</span>
 					#end
@@ -56,8 +56,8 @@
 			
 			#if ( $currentPage < $numberOfPages )
 				#set ( $next = $currentPage + 1 )
-				<a href="javascript:ajaxPaging(${next},${pageSize} );" class="next" title="Next">&raquo;</a>
-				<a href="javascript:ajaxPaging(${numberOfPages},${pageSize} );" class="last" title="Last">&raquo;&raquo;</a>
+				<a href="javascript:pagingList(${next},${pageSize} );" class="next" title="Next">&raquo;</a>
+				<a href="javascript:pagingList(${numberOfPages},${pageSize} );" class="last" title="Last">&raquo;&raquo;</a>
 			#else
 				<span class="next" title="Next">&raquo; </span>
 				<span class="last" title="Last">&raquo;&raquo;</span>
@@ -76,35 +76,9 @@
 var contentDiv;
 var isShowLoader;
 
-function ajaxPaging( currentPage, pageSize )
-{
-	if( isAjax == undefined )
-	{
-		window.location.href = '${baseLink}currentPage=' + currentPage + '&pageSize=' + pageSize;
-	}
-	else
-	{
-		var url = '${baseLink}currentPage=' + currentPage + '&pageSize=' + pageSize;
-		if( contentDiv == undefined) { $( '#contentDiv' ).load(url); }
-		else { $( '#' + contentDiv ).load(url); }
-	}
-}
-
-function changePageSize( baseLink )
-{
-    var pageSize = jQuery("#sizeOfPage").val();
-    
-    if(pageSize < 1)
-    {
-    	pageSize = 1;
-    }
-    
-	var currentPage = jQuery("#jumpToPage").val();
-	
-	jQuery.cookie("pageSize", pageSize, {path: "/"});
-	
-	var url = baseLink + 'currentPage=' + currentPage + '&pageSize=' + pageSize;
-	
+function pagingList( currentPage, pageSize )
+{
+	var url = '${baseLink}currentPage=' + currentPage + '&pageSize=' + pageSize;
 	if( isAjax == undefined )
 	{
 		window.location.href = url;
@@ -116,4 +90,45 @@
 	}
 }
 
+function changePageSize( e, baseLink )
+{
+	var key = getKeyCode(e);
+	
+	if ( key==13 )// Enter
+	{
+		// ---------------------------------------------------
+		// validate parametter
+		// ---------------------------------------------------
+		
+		var pageSize = jQuery("#sizeOfPage").val();
+		
+		if ( pageSize < 1)
+		{
+			pageSize = 1;
+		}
+
+		var currentPage = jQuery("#jumpToPage").val();
+		var numberOfPages = eval("$numberOfPages");
+		if ( currentPage > numberOfPages )
+		{
+			currentPage = numberOfPages;
+		}
+		
+		jQuery.cookie("pageSize", pageSize, {path: "/"});
+		
+		// ---------------------------------------------------
+		// Paging
+		// ---------------------------------------------------
+		
+		pagingList( currentPage, pageSize );
+	}
+}
+
+function getKeyCode(e)
+{
+	 if (window.event)
+		return window.event.keyCode;
+	 return (e)? e.which : null;
+}
+
 </script>
\ No newline at end of file