← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17587: move online/offline bindings out of dom-ready in form.js

 

------------------------------------------------------------
revno: 17587
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-11-26 15:20:19 +0700
message:
  move online/offline bindings out of dom-ready in form.js
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js


--
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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-11-24 11:04:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-11-26 08:20:19 +0000
@@ -154,6 +154,50 @@
     };
 } )( jQuery );
 
+$(document).bind('dhis2.online', function( event, loggedIn ) {
+    if( loggedIn ) {
+        if( dhis2.de.storageManager.hasLocalData() ) {
+            var message = i18n_need_to_sync_notification
+              + ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
+
+            setHeaderMessage(message);
+
+            $('#sync_button').bind('click', dhis2.de.uploadLocalData);
+        }
+        else {
+            if( dhis2.de.emptyOrganisationUnits ) {
+                setHeaderMessage(i18n_no_orgunits);
+            }
+            else {
+                setHeaderDelayMessage(i18n_online_notification);
+            }
+        }
+    }
+    else {
+        var form = [
+            '<form style="display:inline;">',
+            '<label for="username">Username</label>',
+            '<input name="username" id="username" type="text" style="width: 70px; margin-left: 10px; margin-right: 10px" size="10"/>',
+            '<label for="password">Password</label>',
+            '<input name="password" id="password" type="password" style="width: 70px; margin-left: 10px; margin-right: 10px" size="10"/>',
+            '<button id="login_button" type="button">Login</button>',
+            '</form>'
+        ].join('');
+
+        setHeaderMessage(form);
+        dhis2.de.ajaxLogin();
+    }
+});
+
+$(document).bind('dhis2.offline', function() {
+    if( dhis2.de.emptyOrganisationUnits ) {
+        setHeaderMessage(i18n_no_orgunits);
+    }
+    else {
+        setHeaderMessage(i18n_offline_notification);
+    }
+});
+
 /**
  * Page init. The order of events is:
  *
@@ -181,56 +225,6 @@
         } );
     } );
 
-    $( document ).bind( 'dhis2.online', function( event, loggedIn )
-	{
-	    if ( loggedIn )
-	    {
-	        if ( dhis2.de.storageManager.hasLocalData() )
-	        {
-	            var message = i18n_need_to_sync_notification
-	            	+ ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
-
-	            setHeaderMessage( message );
-
-	            $( '#sync_button' ).bind( 'click', dhis2.de.uploadLocalData );
-	        }
-	        else
-	        {
-	            if ( dhis2.de.emptyOrganisationUnits ) {
-	                setHeaderMessage( i18n_no_orgunits );
-	            } 
-	            else {
-	                setHeaderDelayMessage( i18n_online_notification );
-	            }
-            }
-	    }
-	    else
-	    {
-            var form = [
-                '<form style="display:inline;">',
-                    '<label for="username">Username</label>',
-                    '<input name="username" id="username" type="text" style="width: 70px; margin-left: 10px; margin-right: 10px" size="10"/>',
-                    '<label for="password">Password</label>',
-                    '<input name="password" id="password" type="password" style="width: 70px; margin-left: 10px; margin-right: 10px" size="10"/>',
-                    '<button id="login_button" type="button">Login</button>',
-                '</form>'
-            ].join('');
-
-            setHeaderMessage( form );
-            dhis2.de.ajaxLogin();
-	    }
-	} );
-
-    $( document ).bind( 'dhis2.offline', function()
-    {
-      if ( dhis2.de.emptyOrganisationUnits ) {
-          setHeaderMessage( i18n_no_orgunits );
-      } 
-      else {
-          setHeaderMessage( i18n_offline_notification );
-      }
-    } );
-
     dhis2.availability.startAvailabilityCheck();
 } );