← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5267: Modernized the paging javascript so it works on the latest browsers

 

------------------------------------------------------------
revno: 5267
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-02 10:05:28 +0100
message:
  Modernized the paging javascript so it works on the latest browsers
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-07-25 02:08:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm	2011-12-02 09:05:28 +0000
@@ -79,48 +79,55 @@
 function pagingList( currentPage, pageSize )
 {
 	var url = '${baseLink}currentPage=' + currentPage + '&pageSize=' + pageSize;
-	if( isAjax == undefined )
+	if ( isAjax == undefined )
 	{
 		window.location.href = url;
 	}
 	else
 	{
-		var index = url.indexOf('?');
-		var link = url.substring(0, index);
-		var data = url.substring(index + 1);
+		var index = url.indexOf( '?' );
+		var link = url.substring( 0, index );
+		var data = url.substring( index + 1 );
+		
 		jQuery.postUTF8( link , data, function(html)
-			{
-				if( contentDiv == undefined) setInnerHTML( 'contentDiv', html);
-				else setInnerHTML(contentDiv, html);
-			});
+		{
+			if ( contentDiv == undefined )
+			{
+				setInnerHTML( 'contentDiv', html );
+			}
+			else
+			{
+				setInnerHTML( contentDiv, html );
+			}
+		} );
 	}
 }
 
-function changePageSize( e, baseLink )
+function changePageSize( event, baseLink )
 {
-	var key = getKeyCode(e);
+	var key = event.keyCode || event.charCode || event.which;
 	
-	if ( key==13 || key==1 )// Enter
+	if ( key == 13 || key == 1 )// Enter
 	{
 		// ---------------------------------------------------
-		// validate parametter
+		// Validate parameters
 		// ---------------------------------------------------
 		
-		var pageSize = jQuery("#sizeOfPage").val();
+		var pageSize = jQuery( "#sizeOfPage" ).val();
 		
 		if ( pageSize < 1)
 		{
 			pageSize = 1;
 		}
 
-		var currentPage = jQuery("#jumpToPage").val();
-		var numberOfPages = eval("$numberOfPages");
+		var currentPage = jQuery( "#jumpToPage" ).val();
+		var numberOfPages = eval( "$numberOfPages" );
 		if ( currentPage > numberOfPages )
 		{
 			currentPage = numberOfPages;
 		}
 		
-		jQuery.cookie("pageSize", pageSize, {path: "/"});
+		jQuery.cookie( "pageSize", pageSize, {path: "/"} );
 		
 		// ---------------------------------------------------
 		// Paging
@@ -130,11 +137,4 @@
 	}
 }
 
-function getKeyCode(e)
-{
-	 if (window.event)
-		return window.event.keyCode;
-	 return (e)? e.which : null;
-}
-
 </script>
\ No newline at end of file