=== 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 + */ + 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