← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15159: minor cleanup in dhis2.* js files

 

------------------------------------------------------------
revno: 15159
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-05-06 10:55:23 +0700
message:
  minor cleanup in dhis2.* js files
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.trigger.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.validation.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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js	2013-11-27 17:34:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js	2014-05-06 03:55:23 +0000
@@ -1,5 +1,7 @@
+"use strict";
+
 /*
- * Copyright (c) 2004-2013, University of Oslo
+ * Copyright (c) 2004-2014, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-dhis2.util.namespace( 'dhis2.availability' );
+dhis2.util.namespace('dhis2.availability');
 
 dhis2.availability._isAvailable = -1;
 dhis2.availability._isLoggedIn = -1;
@@ -35,110 +37,96 @@
 /**
  * Start availability check, will trigger dhis2.online / dhis2.offline events
  * when availability changes.
- * 
+ *
  * @param onlineInterval How often to check for availability when online,
  *            default is 10000.
  * @param offlineInterval How often to check for availability when offline,
  *            default is 1000.
  */
-dhis2.availability.startAvailabilityCheck = function( onlineInterval, offlineInterval )
-{
-    onlineInterval = onlineInterval ? onlineInterval : 10000;
-    offlineInterval = offlineInterval ? offlineInterval : 1000;
-
-    function _checkAvailability()
-    {
-        $.ajax( {
-            url : "../dhis-web-commons-stream/ping.action",
-            cache : false,
-            timeout: 10000,
-    		dataType : "text",
-            success : function( data, textStatus, jqXHR )
-            {
-                try {
-                    data = JSON.parse(data);
-                } catch(e) {}
-
-                dhis2.availability._isAvailable = true;
-                var loggedIn = data.loggedIn ? true : false;
-
-                if ( loggedIn != dhis2.availability._isLoggedIn )
-                {
-                    dhis2.availability._isLoggedIn = loggedIn;
-                    $( document ).trigger( "dhis2.online", [ loggedIn ] );
-                }
-            },
-            error : function( jqXHR, textStatus, errorThrown )
-            {
-                if ( dhis2.availability._isAvailable )
-                {
-                    dhis2.availability._isAvailable = false;
-                    dhis2.availability._isLoggedIn = -1;
-                    $( document ).trigger( "dhis2.offline" );
-                }
-            },
-	        complete : function()
-	        {
-	            if ( dhis2.availability._isAvailable )
-	            {
-	                dhis2.availability._availableTimeoutHandler = setTimeout( _checkAvailability, onlineInterval );
-	            }
-	            else
-	            {
-	                dhis2.availability._availableTimeoutHandler = setTimeout( _checkAvailability, offlineInterval );
-	            }
-	        }
-        } );
-    }
-
-    // use 500ms for initial check
-    _availableTimeoutHandler = setTimeout( _checkAvailability, 500 );
+dhis2.availability.startAvailabilityCheck = function( onlineInterval, offlineInterval ) {
+  onlineInterval = onlineInterval ? onlineInterval : 10000;
+  offlineInterval = offlineInterval ? offlineInterval : 1000;
+
+  function _checkAvailability() {
+    $.ajax({
+      url: "../dhis-web-commons-stream/ping.action",
+      cache: false,
+      timeout: 10000,
+      dataType: "text",
+      success: function( data, textStatus, jqXHR ) {
+        try {
+          data = JSON.parse(data);
+        } catch( e ) {
+        }
+
+        dhis2.availability._isAvailable = true;
+        var loggedIn = data.loggedIn ? true : false;
+
+        if( loggedIn != dhis2.availability._isLoggedIn ) {
+          dhis2.availability._isLoggedIn = loggedIn;
+          $(document).trigger("dhis2.online", [ loggedIn ]);
+        }
+      },
+      error: function( jqXHR, textStatus, errorThrown ) {
+        if( dhis2.availability._isAvailable ) {
+          dhis2.availability._isAvailable = false;
+          dhis2.availability._isLoggedIn = -1;
+          $(document).trigger("dhis2.offline");
+        }
+      },
+      complete: function() {
+        if( dhis2.availability._isAvailable ) {
+          dhis2.availability._availableTimeoutHandler = setTimeout(_checkAvailability, onlineInterval);
+        }
+        else {
+          dhis2.availability._availableTimeoutHandler = setTimeout(_checkAvailability, offlineInterval);
+        }
+      }
+    });
+  }
+
+  // use 500ms for initial check
+  setTimeout(_checkAvailability, 500);
 };
 
 /**
  * Stop checking for availability.
  */
-dhis2.availability.stopAvailabilityCheck = function()
-{
-    clearTimeout( dhis2.availability._availableTimeoutHandler );
+dhis2.availability.stopAvailabilityCheck = function() {
+  clearTimeout(dhis2.availability._availableTimeoutHandler);
 };
 
 /**
  * Synchronized one-off check of availability.
  */
-dhis2.availability.syncCheckAvailability = function()
-{
-    var isLoggedIn = false;
-
-    $.ajax( {
-        url : "../dhis-web-commons-stream/ping.action",
-        async : false,
-        cache : false,
-        timeout: 10000,
-    	dataType : "json",
-        success : function( data, textStatus, jqXHR )
-        {
-            dhis2.availability._isAvailable = true;
-            var loggedIn = data.loggedIn ? true : false;
-
-            if ( loggedIn != dhis2.availability._isLoggedIn )
-            {
-                dhis2.availability._isLoggedIn = loggedIn;
-                $( document ).trigger( "dhis2.online", [ loggedIn ] );
-            }
-
-            isLoggedIn = loggedIn;
-        },
-        error : function( jqXHR, textStatus, errorThrown )
-        {
-            if ( dhis2.availability._isAvailable )
-            {
-                dhis2.availability._isAvailable = false;
-                dhis2.availability._isLoggedIn = -1;
-                $( document ).trigger( "dhis2.offline" );
-            }
-        }
-    } );
-
-    return isLoggedIn;
+dhis2.availability.syncCheckAvailability = function() {
+  var isLoggedIn = false;
+
+  $.ajax({
+    url: "../dhis-web-commons-stream/ping.action",
+    async: false,
+    cache: false,
+    timeout: 10000,
+    dataType: "json",
+    success: function( data, textStatus, jqXHR ) {
+      dhis2.availability._isAvailable = true;
+      var loggedIn = data.loggedIn ? true : false;
+
+      if( loggedIn != dhis2.availability._isLoggedIn ) {
+        dhis2.availability._isLoggedIn = loggedIn;
+        $(document).trigger("dhis2.online", [ loggedIn ]);
+      }
+
+      isLoggedIn = loggedIn;
+    },
+    error: function( jqXHR, textStatus, errorThrown ) {
+      if( dhis2.availability._isAvailable ) {
+        dhis2.availability._isAvailable = false;
+        dhis2.availability._isLoggedIn = -1;
+        $(document).trigger("dhis2.offline");
+      }
+    }
+  });
+
+  return isLoggedIn;
 };

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js	2013-08-23 16:11:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js	2014-05-06 03:55:23 +0000
@@ -1,5 +1,7 @@
+"use strict";
+
 /*
- * Copyright (c) 2004-2013, University of Oslo
+ * Copyright (c) 2004-2014, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,54 +29,50 @@
  */
 
 
-dhis2.util.namespace( 'dhis2.comparator' );
+dhis2.util.namespace('dhis2.comparator');
 
 /**
  * Compares two objects and returns result.
- * 
+ *
  * @param a {object} Object A
  * @param b {object} Object B
- * 
+ *
  * @returns {Number} 1 if a>b, -1 if a>b, 0 if equal
  */
-dhis2.comparator.defaultComparator = function( a, b )
-{
-    if ( a === b )
-    {
-        return 0;
-    }
+dhis2.comparator.defaultComparator = function( a, b ) {
+  if( a === b ) {
+    return 0;
+  }
 
-    return ( a > b ) ? 1 : -1;
+  return ( a > b ) ? 1 : -1;
 };
 
 /**
  * Case sensitive compare of two jQuery objects (based on their innerHTML).
- * 
+ *
  * @param a {jQuery} Object A
  * @param b {jQuery} Object B
- * 
+ *
  * @returns {Number} 1 if a>b, -1 if a>b, 0 if equal
  */
-dhis2.comparator.htmlComparator = function( a, b )
-{
-    return dhis2.comparator.defaultComparator( a.html(), b.html() );
+dhis2.comparator.htmlComparator = function( a, b ) {
+  return dhis2.comparator.defaultComparator(a.html(), b.html());
 };
 
 /**
  * Case insensitive compare of two jQuery objects (based on their innerHTML).
- * 
+ *
  * @param a {jQuery} Object A
  * @param b {jQuery} Object B
- * 
+ *
  * @returns {Number} 1 if a>b, -1 if a>=b
  */
-dhis2.comparator.htmlNoCaseComparator = function( a, b )
-{
-    a = !!a ? a.html() : a;
-    b = !!b ? b.html() : b;
-
-    a = !!a ? a.toLowerCase() : a;
-    b = !!b ? b.toLowerCase() : b;
-
-    return dhis2.comparator.defaultComparator( a, b );
+dhis2.comparator.htmlNoCaseComparator = function( a, b ) {
+  a = !!a ? a.html() : a;
+  b = !!b ? b.html() : b;
+
+  a = !!a ? a.toLowerCase() : a;
+  b = !!b ? b.toLowerCase() : b;
+
+  return dhis2.comparator.defaultComparator(a, b);
 };

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js	2014-01-06 12:30:46 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js	2014-05-06 03:55:23 +0000
@@ -1,5 +1,7 @@
+"use strict";
+
 /*
- * Copyright (c) 2004-2013, University of Oslo
+ * Copyright (c) 2004-2014, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,12 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+
 dhis2.util.namespace('dhis2.contextmenu');
 dhis2.util.namespace('dhis2.contextmenu.utils');
 
 /**
  * Creates a resolver to search within a certain scope
- *
  * @param scope Scope to search within
  * @returns Function
  */
@@ -129,7 +134,7 @@
       pageY -= menuHeight;
 
       if( pageY < 0 ) {
-          pageY = e.pageY;
+        pageY = e.pageY;
       }
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2014-05-06 03:32:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2014-05-06 03:55:23 +0000
@@ -1,3 +1,5 @@
+"use strict";
+
 /*
  * Copyright (c) 2004-2014, University of Oslo
  * All rights reserved.
@@ -317,7 +319,7 @@
   var array = [];
   var today = this.calendar.today();
 
-  $.each(periods, function( idx ) {
+  $.each(periods, function() {
     if( this['_endDate'].compareTo(today) <= 0 ) {
       array.push(this);
     }
@@ -335,7 +337,7 @@
   var array = [];
   var today = this.calendar.today();
 
-  $.each(periods, function( idx ) {
+  $.each(periods, function() {
     if( this['_startDate'].compareTo(today) <= 0 ) {
       array.push(this);
     }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js	2014-04-14 06:01:15 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js	2014-05-06 03:55:23 +0000
@@ -1,9 +1,37 @@
+"use strict";
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 /**
  * Simple plugin for keeping two <select /> elements in sync.
- *
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
-
 !(function( $, window, document, undefined ) {
   var methods = {
     create: function( options ) {
@@ -104,7 +132,7 @@
       }
     },
     makeScrollHandler: function( context ) {
-      return function( e ) {
+      return function() {
         if( context.source[0].offsetHeight + context.source.scrollTop() >= context.source[0].scrollHeight ) {
           context.defaultProgressiveLoader(context);
         }
@@ -144,7 +172,7 @@
           return;
         }
 
-        $.each(data[context.iterator], function( idx ) {
+        $.each(data[context.iterator], function() {
           if( context.target.find('option[value=' + this.id + ']').length == 0 ) {
             context.source.append(context.handler(this));
           }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js	2013-11-28 10:34:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js	2014-05-06 03:55:23 +0000
@@ -1,5 +1,7 @@
+"use strict";
+
 /*
- * Copyright (c) 2004-2013, University of Oslo
+ * Copyright (c) 2004-2014, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,212 +27,210 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-dhis2.util.namespace( 'dhis2.sharing' );
+dhis2.util.namespace('dhis2.sharing');
 
 function loadSharingSettings( type, uid ) {
-    return $.ajax( {
-        url: '../api/sharing',
-        data: {
-            type: type,
-            id: uid
-        },
-        dataType: 'json'
-    } );
+  return $.ajax({
+    url: '../api/sharing',
+    data: {
+      type: type,
+      id: uid
+    },
+    dataType: 'json'
+  });
 }
 
 function saveSharingSettings( type, uid, data ) {
-    return $.ajax( {
-        url: '../api/sharing?type=' + type + '&id=' + uid,
-        type: 'POST',
-        dataType: 'text',
-        contentType: 'application/json; charset=UTF-8',
-        data: JSON.stringify( data )
-    } );
+  return $.ajax({
+    url: '../api/sharing?type=' + type + '&id=' + uid,
+    type: 'POST',
+    dataType: 'text',
+    contentType: 'application/json; charset=UTF-8',
+    data: JSON.stringify(data)
+  });
 }
 
 var sharingSelectedItem;
 
-function renderUserGroupAccessTemplate(item) {
-    var tmpl = jQuery('#user-group-access-template').html();
-    var tmpl_html = _.template(tmpl, item);
-
-    return tmpl_html;
-}
-
-function addUserGroupAccessSelectedItem(e) {
-    var tmpl_html = renderUserGroupAccessTemplate({
-        label: sharingSelectedItem.label,
-        id: sharingSelectedItem.id,
-        access: "r-------"
-    });
-
-    $(tmpl_html).insertAfter( $('#sharingAccessTable tbody tr').not('[id]').last() );
-
-    $('#sharingFindUserGroup').val('');
-    sharingSelectedItem = undefined;
-
-    $( '#addUserGroupAccess' ).attr( 'disabled', true );
-}
-
-function removeUserGroupAccess(e) {
-    e.preventDefault();
-    $( this ).parent().parent().remove();
+function renderUserGroupAccessTemplate( item ) {
+  var tmpl = jQuery('#user-group-access-template').html();
+  return _.template(tmpl, item);
+}
+
+function addUserGroupAccessSelectedItem( e ) {
+  var tmpl_html = renderUserGroupAccessTemplate({
+    label: sharingSelectedItem.label,
+    id: sharingSelectedItem.id,
+    access: "r-------"
+  });
+
+  $(tmpl_html).insertAfter($('#sharingAccessTable tbody tr').not('[id]').last());
+
+  $('#sharingFindUserGroup').val('');
+  sharingSelectedItem = undefined;
+
+  $('#addUserGroupAccess').attr('disabled', true);
+}
+
+function removeUserGroupAccess( e ) {
+  e.preventDefault();
+  $(this).parent().parent().remove();
 }
 
 function clearUserGroupAccesses() {
-    $('#sharingAccessTable tbody tr[id]' ).remove();
-}
-
-function setUserGroupAccesses(userGroupAccesses) {
-    clearUserGroupAccesses();
-
-    if(userGroupAccesses) {
-        $.each(userGroupAccesses, function(idx, item) {
-            var tmpl_html = renderUserGroupAccessTemplate({
-                label: item.name,
-                id: item.id,
-                access: item.access
-            });
-
-            $(tmpl_html).insertAfter( $('#sharingAccessTable tbody tr').not('[id]').last() );
-        });
+  $('#sharingAccessTable tbody tr[id]').remove();
+}
+
+function setUserGroupAccesses( userGroupAccesses ) {
+  clearUserGroupAccesses();
+
+  if( userGroupAccesses ) {
+    $.each(userGroupAccesses, function( idx, item ) {
+      var tmpl_html = renderUserGroupAccessTemplate({
+        label: item.name,
+        id: item.id,
+        access: item.access
+      });
+
+      $(tmpl_html).insertAfter($('#sharingAccessTable tbody tr').not('[id]').last());
+    });
+  }
+}
+
+function setPublicAccess( access ) {
+  $('#sharingPublicAccess option').removeAttr('selected').each(function( idx, item ) {
+    if( $(item).val() == access ) {
+      $(item).attr('selected', true);
     }
-}
-
-function setPublicAccess(access) {
-    $( '#sharingPublicAccess option' ).removeAttr( 'selected' ).each( function ( idx, item ) {
-        if ( $( item ).val() == access ) {
-            $( item ).attr( 'selected', true );
-        }
-    } );
+  });
 }
 
 function getPublicAccess() {
-    return $( '#sharingPublicAccess' ).val();
+  return $('#sharingPublicAccess').val();
 }
 
-function setExternalAccess(access) {
-    if(access) {
-        $('#sharingExternalAccess').attr('checked', true);
-    } else {
-        $('#sharingExternalAccess').removeAttr('checked');
-    }
+function setExternalAccess( access ) {
+  if( access ) {
+    $('#sharingExternalAccess').attr('checked', true);
+  } else {
+    $('#sharingExternalAccess').removeAttr('checked');
+  }
 }
 
 function getExternalAccess() {
-    return $('#sharingExternalAccess').is(':checked');
+  return $('#sharingExternalAccess').is(':checked');
 }
 
 function getUserGroupAccesses() {
-    var v = [];
-
-    $( '#sharingAccessTable tbody tr[id]' ).each( function ( idx, item ) {
-        var jqItem = $(item);
-
-        var groupName = $( item ).find('.sharingGroupName').text();
-        var groupAccess = $( item ).find('.sharingGroupAccess').val();
-
-        v.push({
-            id: jqItem.attr('id'),
-            name: groupName,
-            access: groupAccess
-        });
-    } );
-
-    return v;
+  var v = [];
+
+  $('#sharingAccessTable tbody tr[id]').each(function( idx, item ) {
+    var jqItem = $(item);
+
+    var groupName = $(item).find('.sharingGroupName').text();
+    var groupAccess = $(item).find('.sharingGroupAccess').val();
+
+    v.push({
+      id: jqItem.attr('id'),
+      name: groupName,
+      access: groupAccess
+    });
+  });
+
+  return v;
 }
 
 function showSharingDialogWithContext( context ) {
   // context always give type which starts with UpperCase
   var type = context.type.charAt(0).toLowerCase() + context.type.slice(1);
-  showSharingDialog( type, context.uid );
+  showSharingDialog(type, context.uid);
 }
 
 function showSharingDialog( type, uid ) {
-    loadSharingSettings( type, uid ).done( function ( data ) {
-        setPublicAccess( data.object.publicAccess );
-        setExternalAccess( data.object.externalAccess );
-        setUserGroupAccesses( data.object.userGroupAccesses );
-
-        $( '#sharingName' ).text( data.object.name );
-
-        if ( !data.meta.allowExternalAccess ) {
-            $( '#sharingExternalAccess' ).attr( 'disabled', true );
-        }
-
-        if ( !data.meta.allowPublicAccess ) {
-            $( '#sharingPublicAccess' ).attr( 'disabled', true );
-        }
-
-        $( '.removeUserGroupAccess' ).unbind( 'click' );
-        $( document ).on( 'click', '.removeUserGroupAccess', removeUserGroupAccess );
-        $( '#addUserGroupAccess' ).unbind( 'click' ).bind( 'click', addUserGroupAccessSelectedItem );
-
-        $( '#sharingFindUserGroup' ).autocomplete( {
-            source: function ( request, response ) {
-                $.ajax({
-                    url: '../api/sharing/search',
-                    dataType: 'json',
-                    data: {
-                        key: request.term
-                    }
-                } ).success(function(data) {
-                    var v = [];
-                    var u = getUserGroupAccesses();
-
-                    if(data.userGroups) {
-                        $.each(data.userGroups, function(idx, item) {
-                            var d = {};
-
-                            d.label = item.name;
-                            d.value = item.name;
-                            d.id = item.id;
-
-                            var found = false;
-
-                            $.each(u, function(idx, item) {
-                                if(item.id == d.id) {
-                                    found = true;
-                                }
-                            });
-
-                            if(!found) {
-                                v.push(d);
-                            }
-                        });
-                    }
-
-                    response(v);
-                });
-            },
-            minLength: 2,
-            select: function( event, ui ) {
-                sharingSelectedItem = ui.item;
-                $( '#addUserGroupAccess' ).removeAttr( 'disabled' );
-            }
-        });
-
-        $( '#sharingSettings' ).dialog( {
-            modal: true,
-            resizable: false,
-            width: 485,
-            height: 480,
-            buttons: {
-                'Cancel': function () {
-                    $( this ).dialog( 'close' );
-                },
-                'Save': function () {
-                    var me = $( this );
-
-                    data.object.publicAccess = getPublicAccess();
-                    data.object.externalAccess = getExternalAccess();
-                    data.object.userGroupAccesses = getUserGroupAccesses();
-
-                    saveSharingSettings( type, uid, data ).done( function () {
-                        me.dialog( 'close' );
-                    } );
+  loadSharingSettings(type, uid).done(function( data ) {
+    setPublicAccess(data.object.publicAccess);
+    setExternalAccess(data.object.externalAccess);
+    setUserGroupAccesses(data.object.userGroupAccesses);
+
+    $('#sharingName').text(data.object.name);
+
+    if( !data.meta.allowExternalAccess ) {
+      $('#sharingExternalAccess').attr('disabled', true);
+    }
+
+    if( !data.meta.allowPublicAccess ) {
+      $('#sharingPublicAccess').attr('disabled', true);
+    }
+
+    $('.removeUserGroupAccess').unbind('click');
+    $(document).on('click', '.removeUserGroupAccess', removeUserGroupAccess);
+    $('#addUserGroupAccess').unbind('click').bind('click', addUserGroupAccessSelectedItem);
+
+    $('#sharingFindUserGroup').autocomplete({
+      source: function( request, response ) {
+        $.ajax({
+          url: '../api/sharing/search',
+          dataType: 'json',
+          data: {
+            key: request.term
+          }
+        }).success(function( data ) {
+          var v = [];
+          var u = getUserGroupAccesses();
+
+          if( data.userGroups ) {
+            $.each(data.userGroups, function( idx, item ) {
+              var d = {};
+
+              d.label = item.name;
+              d.value = item.name;
+              d.id = item.id;
+
+              var found = false;
+
+              $.each(u, function( idx, item ) {
+                if( item.id == d.id ) {
+                  found = true;
                 }
-            }
-        } );
-    } );
+              });
+
+              if( !found ) {
+                v.push(d);
+              }
+            });
+          }
+
+          response(v);
+        });
+      },
+      minLength: 2,
+      select: function( event, ui ) {
+        sharingSelectedItem = ui.item;
+        $('#addUserGroupAccess').removeAttr('disabled');
+      }
+    });
+
+    $('#sharingSettings').dialog({
+      modal: true,
+      resizable: false,
+      width: 485,
+      height: 480,
+      buttons: {
+        'Cancel': function() {
+          $(this).dialog('close');
+        },
+        'Save': function() {
+          var me = $(this);
+
+          data.object.publicAccess = getPublicAccess();
+          data.object.externalAccess = getExternalAccess();
+          data.object.userGroupAccesses = getUserGroupAccesses();
+
+          saveSharingSettings(type, uid, data).done(function() {
+            me.dialog('close');
+          });
+        }
+      }
+    });
+  });
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js	2013-12-03 09:49:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js	2014-05-06 03:55:23 +0000
@@ -1,7 +1,7 @@
 "use strict";
 
 /*
- * Copyright (c) 2004-2013, University of Oslo
+ * Copyright (c) 2004-2014, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.trigger.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.trigger.js	2013-08-23 16:11:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.trigger.js	2014-05-06 03:55:23 +0000
@@ -1,3 +1,5 @@
+"use strict";
+
 /*
  * Copyright (c) 2004-2013, University of Oslo
  * All rights reserved.
@@ -27,43 +29,37 @@
  */
 
 
-dhis2.util.namespace( 'dhis2.trigger.funcs' );
+dhis2.util.namespace('dhis2.trigger.funcs');
 
 /**
  * Binds a function to be invoked for a given key. Any number of functions can
  * be set for a key. A function should return true or false.
  */
-dhis2.trigger.bind = function( key, func )
-{
-	var funcs = dhis2.trigger.funcs[key] || [];
-	funcs.push( func );	
-	dhis2.trigger.funcs[key] = funcs;
-}
+dhis2.trigger.bind = function( key, func ) {
+  var funcs = dhis2.trigger.funcs[key] || [];
+  funcs.push(func);
+  dhis2.trigger.funcs[key] = funcs;
+};
 
 /**
  * Invokes functions bound to the given key. A function can short-circuit the
  * invocations by returning false.
  */
-dhis2.trigger.invoke = function( key, args )
-{
-	var funcs = dhis2.trigger.funcs[key];
-	var result = true;
-	
-	if ( funcs !== undefined )
-	{
-		$.each( funcs, function( index, func )
-		{
-			if ( $.isFunction( func ) )
-			{
-				result = func( args );
-				
-				if ( result === false )
-				{
-					return false; // Break loop
-				}
-			}
-		} );
-	}
-	
-	return result;
-}
+dhis2.trigger.invoke = function( key, args ) {
+  var funcs = dhis2.trigger.funcs[key];
+  var result = true;
+
+  if( funcs !== undefined ) {
+    $.each(funcs, function( index, func ) {
+      if( $.isFunction(func) ) {
+        result = func(args);
+
+        if( result === false ) {
+          return false; // Break loop
+        }
+      }
+    });
+  }
+
+  return result;
+};

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2014-03-31 16:39:30 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2014-05-06 03:55:23 +0000
@@ -1,3 +1,5 @@
+"use strict";
+
 /*
  * Copyright (c) 2004-2013, University of Oslo
  * All rights reserved.
@@ -37,24 +39,24 @@
  * @returns {object} Namespace object
  */
 dhis2.util.namespace = function( path ) {
-    var parts = path.split('.');
-    var parent = window;
-    var currentPart = '';
-
-    for( var i = 0, length = parts.length; i < length; i++ ) {
-        currentPart = parts[i];
-        parent[currentPart] = parent[currentPart] || {};
-        parent = parent[currentPart];
-    }
-
-    return parent;
+  var parts = path.split('.');
+  var parent = window;
+  var currentPart = '';
+
+  for( var i = 0, length = parts.length; i < length; i++ ) {
+    currentPart = parts[i];
+    parent[currentPart] = parent[currentPart] || {};
+    parent = parent[currentPart];
+  }
+
+  return parent;
 };
 
 /**
  * Escape function for regular expressions.
  */
 dhis2.util.escape = function( text ) {
-    return text.replace(/[-[\]{}()*+?.,\/\\^$|#\s]/g, "\\$&");
+  return text.replace(/[-[\]{}()*+?.,\/\\^$|#\s]/g, "\\$&");
 };
 
 /**
@@ -62,107 +64,105 @@
  * until jQuery gets updated.
  */
 dhis2.util.jqTextFilterCaseSensitive = function( key, not ) {
-    key = dhis2.util.escape(key);
-    not = not || false;
+  key = dhis2.util.escape(key);
+  not = not || false;
 
-    if( not ) {
-        return function( i, el ) {
-            return !!!$(el).text().match("" + key);
-        };
-    }
-    else {
-        return function( i, el ) {
-            return !!$(el).text().match("" + key);
-        };
-    }
+  if( not ) {
+    return function( i, el ) {
+      return !!!$(el).text().match("" + key);
+    };
+  }
+  else {
+    return function( i, el ) {
+      return !!$(el).text().match("" + key);
+    };
+  }
 };
 
 dhis2.util.jqTextFilter = function( key, not ) {
-    key = dhis2.util.escape(key).toLowerCase();
-    not = not || false;
+  key = dhis2.util.escape(key).toLowerCase();
+  not = not || false;
 
-    if( not ) {
-        return function( i, el ) {
-            return !!!$(el).text().toLowerCase().match("" + key);
-        };
-    }
-    else {
-        return function( i, el ) {
-            return !!$(el).text().toLowerCase().match("" + key);
-        };
-    }
+  if( not ) {
+    return function( i, el ) {
+      return !!!$(el).text().toLowerCase().match("" + key);
+    };
+  }
+  else {
+    return function( i, el ) {
+      return !!$(el).text().toLowerCase().match("" + key);
+    };
+  }
 };
 
 dhis2.util.uuid = function() {
-    var S4 = function() {
-        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
-    };
+  var S4 = function() {
+    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
+  };
 
-    return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
-}
+  return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
+};
 
 /**
  * Normalizes an argument object returned from a jQuery promise. If the argument
- * is undefined, not an array or an empty array, undefined is returned. If the 
+ * is undefined, not an array or an empty array, undefined is returned. If the
  * argument is a single promise object, the object is wrapped in an array. If the
  * argument is an array of promise objects, the array is returned unmodified.
  */
 dhis2.util.normalizeArguments = function( args ) {
-	if ( !args || !args.length || !args[0] ) {
-		return undefined;
-	}
-	
-	if ( $.isArray( args[0] ) ) {
-		return args;
-	}
-	else {
-		var arr = [];
-		arr[0] = args;
-		return arr;
-	}
-}
+  if( !args || !args.length || !args[0] ) {
+    return undefined;
+  }
+
+  if( $.isArray(args[0]) ) {
+    return args;
+  }
+  else {
+    var arr = [];
+    arr[0] = args;
+    return arr;
+  }
+};
 
 /**
  * adds ':containsNC' to filtering.
  * $(sel).find(':containsNC(key)').doSomething();
  */
 $.expr[":"].containsNC = function( a, i, m, r ) {
-    var search = dhis2.util.escape(m[3]);
-    return jQuery(a).text().toUpperCase().indexOf(m[search].toUpperCase()) >= 0;
+  var search = dhis2.util.escape(m[3]);
+  return jQuery(a).text().toUpperCase().indexOf(m[search].toUpperCase()) >= 0;
 };
 
 /**
  * adds ':regex' to filtering, use to filter by regular expression
  */
 $.expr[":"].regex = function( a, i, m, r ) {
-    var re = new RegExp(m[3], 'i');
-    return re.test(jQuery(a).text());
+  var re = new RegExp(m[3], 'i');
+  return re.test(jQuery(a).text());
 };
 
 /**
  * adds ':regex' to filtering, use to filter by regular expression
- *
  * (this is the case sensitive version)
  */
 $.expr[":"].regexCS = function( a, i, m, r ) {
-    var re = new RegExp(m[3]);
-    return re.test(jQuery(a).text());
+  var re = new RegExp(m[3]);
+  return re.test(jQuery(a).text());
 };
 
 /**
  * Returns an array of the keys in a given object. Will use ES5 Object.keys() if
  * available, if not it will provide a pure javascript implementation.
- *
  * @returns array of keys
  */
 if( !Object.keys ) {
-    Object.keys = function( obj ) {
-        var keys = new Array();
-        for( k in obj )
-            if( obj.hasOwnProperty(k) )
-                keys.push(k);
-        return keys;
-    };
+  Object.keys = function( obj ) {
+    var keys = [];
+    for( var k in obj )
+      if( obj.hasOwnProperty(k) )
+        keys.push(k);
+    return keys;
+  };
 }
 
 /**
@@ -170,7 +170,7 @@
  * a fix for IE8 and FF 3.6).
  */
 window.log = function( str ) {
-    if( this.console ) {
-        console.log(str);
-    }
+  if( this.console ) {
+    console.log(str);
+  }
 };

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.validation.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.validation.js	2014-01-23 15:36:54 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.validation.js	2014-05-06 03:55:23 +0000
@@ -1,5 +1,7 @@
+"use strict";
+
 /*
- * Copyright (c) 2004-2013, University of Oslo
+ * Copyright (c) 2004-2014, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,92 +28,82 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-dhis2.util.namespace( 'dhis2.validation' );
+dhis2.util.namespace('dhis2.validation');
 
 /**
  * Checks if the given value is valid zero.
  */
-dhis2.validation.isValidZeroNumber = function( value )
-{
-	var regex = /^0(\.0*)?$/;
-	return regex.test( value );
+dhis2.validation.isValidZeroNumber = function( value ) {
+  var regex = /^0(\.0*)?$/;
+  return regex.test(value);
 };
 
 /**
  * Allow only integers or a single zero and no thousands separators.
  */
-dhis2.validation.isInt = function(value)
-{
-	var regex = /^(0|-?[1-9]\d*)$/;
-	return regex.test( value );
+dhis2.validation.isInt = function( value ) {
+  var regex = /^(0|-?[1-9]\d*)$/;
+  return regex.test(value);
 };
 
 /**
  * Allow only positive integers, not zero, no thousands separators.
  */
-dhis2.validation.isPositiveInt = function( value )
-{
-	var regex = /^[1-9]\d*$/;
-	return regex.test( value );
+dhis2.validation.isPositiveInt = function( value ) {
+  var regex = /^[1-9]\d*$/;
+  return regex.test(value);
 };
 
 /**
  * Allow only zero or positive integers, no thousands separators.
  */
-dhis2.validation.isZeroOrPositiveInt = function( value )
-{
-	var regex = /(^0$)|(^[1-9]\d*$)/;
-	return regex.test( value );
+dhis2.validation.isZeroOrPositiveInt = function( value ) {
+  var regex = /(^0$)|(^[1-9]\d*$)/;
+  return regex.test(value);
 };
 
 /**
  * Allow only negative integers, not zero and no thousands separators.
  */
-dhis2.validation.isNegativeInt = function( value )
-{
-	var regex = /^-[1-9]\d*$/;
-	return regex.test( value );
+dhis2.validation.isNegativeInt = function( value ) {
+  var regex = /^-[1-9]\d*$/;
+  return regex.test(value);
 };
 
 /**
  * Allow any real number,optionally with a sign, no thousands separators and a
  * single decimal point.
  */
-dhis2.validation.isNumber = function( value )
-{
-	var regex = /^(-?0|-?[1-9]\d*)(\.\d+)?(E\d+)?$/;
-	return regex.test( value );
+dhis2.validation.isNumber = function( value ) {
+  var regex = /^(-?0|-?[1-9]\d*)(\.\d+)?(E\d+)?$/;
+  return regex.test(value);
 };
 
 /**
  * Checks if the given value is a valid positive number.
  */
-dhis2.validation.isPositiveNumber = function( value )
-{
-	return dhis2.validation.isNumber( value ) && parseFloat( value ) > 0;
+dhis2.validation.isPositiveNumber = function( value ) {
+  return dhis2.validation.isNumber(value) && parseFloat(value) > 0;
 };
 
 /**
  * Checks if the given value is a valid negative number.
  */
-dhis2.validation.isNegativeNumber = function( value )
-{
-	return dhis2.validation.isNumber( value ) && parseFloat( value ) < 0;
+dhis2.validation.isNegativeNumber = function( value ) {
+  return dhis2.validation.isNumber(value) && parseFloat(value) < 0;
 };
 
 /**
  * Returns true if the provided string argument is to be considered a unit
- * interval, which implies that the value is numeric and inclusive between 0 
+ * interval, which implies that the value is numeric and inclusive between 0
  * and 1.
  */
-dhis2.validation.isUnitInterval = function( value )
-{
-	if ( !dhis2.validation.isNumber( value ) )
-	{
-		return false;
-	}
-	
-	var f = parseFloat( value );
-	
-	return f >= 0 && f <= 1;
+dhis2.validation.isUnitInterval = function( value ) {
+  if( !dhis2.validation.isNumber(value) ) {
+    return false;
+  }
+
+  var f = parseFloat(value);
+
+  return f >= 0 && f <= 1;
 };