← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6461: Moved top menu js from main template to javascript file. Makes top menu load faster since js now ...

 

------------------------------------------------------------
revno: 6461
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-04-01 21:29:11 +0200
message:
  Moved top menu js from main template to javascript file. Makes top menu load faster since js now can be cached.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.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/main.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js	2012-03-26 18:11:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js	2012-04-01 19:29:11 +0000
@@ -47,37 +47,87 @@
 	$( "#menuDropDownFeedBack" ).click(	function()
 		{
 			window.location.href = currentPath + 'displayFeedbackForm.action' + backURL;
-		});
+		} );
 		
 	$( "#menuDropDownChangeLog" ).click( function()
 		{
 			window.location.href = currentPath + 'displayChangeLog.action' + backURL;
-		});
+		} );
 		
 	$( "#menuDropDownSupportiveSoftware" ).click( function()
 		{
 			window.location.href= currentPath + 'displaySupportiveSoftware.action' + backURL;
-		});
+		} );
 	
 	$( "#menuDropDownUserAccount" ).click( function()
 		{
 			window.location.href = currentPath + 'showUpdateUserAccountForm.action' + backURL;
-		});
+		} );
 		
 	$( "#menuDropDownModuleOverview" ).click( function()
 		{
 			window.location.href = currentPath + 'modules.action' + backURL;
-		});
+		} );
 		
 	$( "#menuDropDownWebApi" ).click( function()
 		{
 			window.location.href = '../api';
-		});
+		} );
 		
 	$( "#menuDropDownAboutDHIS2" ).click( function()
 		{
 			window.location.href = currentPath + 'about.action' + backURL;
-		});
+		} );
+	
+	// Set show and hide drop down events on top menu
+	
+	if ( maintenanceModulesNo > 0 )
+	{
+		$( "#menuLink1" ).hover( function() 
+		{
+			showDropDown( 'menuDropDown1' );
+		}, 
+		function() 
+		{
+			hideDropDownTimeout();
+		} );
+	}
+
+	if ( serviceModulesNo > 0 )
+	{
+		$( "#menuLink2" ).hover( function() 
+		{
+			showDropDown( 'menuDropDown2' );
+		}, 
+		function() 
+		{
+			hideDropDownTimeout();
+		} );
+	}
+
+	$( "#menuLink3" ).hover( function() 
+	{
+		showDropDown( 'menuDropDown3' );
+	}, 
+	function() 
+	{
+		hideDropDownTimeout();
+	} );
+
+	$( "#menuLink4" ).click( function() 
+	{
+		jQuery.cookie( 'pageSize', null, {path:'/'} );
+		window.location.href='../dhis-web-commons-security/logout.action';
+	} );
+
+	$( "#menuDropDown1, #menuDropDown2, #menuDropDown3" ).hover( function() 
+	{
+		cancelHideDropDownTimeout();
+	}, 
+	function() 
+	{
+		hideDropDownTimeout();
+	} );
 	
 	// Intro fade in
 	

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2012-03-07 10:32:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2012-04-01 19:29:11 +0000
@@ -9,13 +9,15 @@
     <link type="image/png" rel="icon" href="../images/favicon.png" />
 
     #foreach ( $style in $stylesheets )
-      <link type="text/css" rel="stylesheet" href="$style">
+    <link type="text/css" rel="stylesheet" href="$style">
     #end
     
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 
     <script type="text/javascript">
 		var dateFormat = 'yy-mm-dd';
+		var maintenanceModulesNo = ${maintenanceModules.size()};
+		var serviceModulesNo = ${serviceModules.size()};
 	</script>
 
     <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.min.js"></script>
@@ -42,64 +44,21 @@
     <script type="text/javascript" src="../dhis-web-commons/javascripts/date.js"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/json2.js"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/validationRules.js"></script>
-
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.util.js"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.array.js"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.select.js"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.comparator.js"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.availability.js"></script>
-
-    <script type="text/javascript" src="../dhis-web-commons/css/${stylesheetDirectory}/dom.js"></script>
-		
-    <script type="text/javascript" src="../main.js"></script>
-  
+    <script type="text/javascript" src="../dhis-web-commons/css/${stylesheetDirectory}/dom.js"></script>		
+    <script type="text/javascript" src="../main.js"></script>  
     <script type="text/javascript" src="../request.js"></script>
     #foreach( $javascript in $javascripts )
-      <script type="text/javascript" src="$javascript"></script>
+    <script type="text/javascript" src="$javascript"></script>
     #end
-
-	<script type="text/javascript">
-		jQuery(document).ready(function() {
-			#if ( $maintenanceModules.size() > 0 )
-			jQuery("#menuLink1").hover(function() {
-				showDropDown( 'menuDropDown1' );
-			}, function() {
-				hideDropDownTimeout();
-			});
-			#end
-
-			#if ( $serviceModules.size() > 0 )
-			jQuery("#menuLink2").hover(function() {
-				showDropDown( 'menuDropDown2' );
-			}, function() {
-				hideDropDownTimeout();
-			});
-			#end
-
-			jQuery("#menuLink3").hover(function() {
-				showDropDown( 'menuDropDown3' );
-			}, function() {
-				hideDropDownTimeout();
-			});
-
-			jQuery("#menuLink4").click( function() {
-				jQuery.cookie('pageSize', null, {path:'/'});
-				window.location.href='../dhis-web-commons-security/logout.action';
-			});
-
-			jQuery("#menuDropDown1, #menuDropDown2, #menuDropDown3").hover(function() {
-				cancelHideDropDownTimeout();
-			}, function() {
-				hideDropDownTimeout();
-			});
-		});
-	</script>
   </head>
   
-  <body>
-    
-    #parse( "macros.vm" )
-        
+  <body>    
+    #parse( "macros.vm" )        
     <div id="header">
       <img id="headerBanner" src="../dhis-web-commons/css/${stylesheetDirectory}/logo_banner.png" 
         onclick="window.location.href='../dhis-web-commons-about/modules.action'" style="cursor:pointer" title="$i18n.getString( 'go_to_system_overview' )">