dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25331
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12537: use $ instead of jQuery in anonymousReg.js
------------------------------------------------------------
revno: 12537
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-09 21:44:17 +0200
message:
use $ instead of jQuery in anonymousReg.js
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.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-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-10-09 11:13:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-10-09 19:44:17 +0000
@@ -390,7 +390,7 @@
setFieldValue( "programStageId", '' );
setFieldValue( "programId", '' );
- jQuery( '#advancedSearchTB [name=searchText]' ).val( '' );
+ $( '#advancedSearchTB [name=searchText]' ).val( '' );
setFieldValue( 'orgunitId', orgUnits[0] );
setFieldValue( 'orgunitName', orgUnitNames[0] );
@@ -413,15 +413,15 @@
}
function updateProgramList( arr ) {
- jQuery( '#searchingAttributeIdTD [id=searchObjectId] option' ).remove();
- jQuery( '#advancedSearchTB [id=searchObjectId] option' ).remove();
+ $( '#searchingAttributeIdTD [id=searchObjectId] option' ).remove();
+ $( '#advancedSearchTB [id=searchObjectId] option' ).remove();
clearListById( 'displayInReports' );
clearListById( 'programId' );
- jQuery( '#programId' ).append( '<option value="" psid="" reportDateDes="' + i18n_report_date + '">[' + i18n_please_select + ']</option>' );
+ $( '#programId' ).append( '<option value="" psid="" reportDateDes="' + i18n_report_date + '">[' + i18n_please_select + ']</option>' );
for ( var i = 0; i < arr.length; i++ ) {
- jQuery( '#programId' ).append(
+ $( '#programId' ).append(
'<option value="' + arr[i].id
+ '" puid="' + arr[i].uid
+ '" programType="' + arr[i].type
@@ -441,7 +441,7 @@
disable( 'addBtn' );
disable( 'filterBtn' );
disable( 'removeBtn' );
- jQuery( '#criteriaDiv :input' ).each( function ( idx, item ) {
+ $( '#criteriaDiv :input' ).each( function ( idx, item ) {
disable( this.id );
} );
}
@@ -451,7 +451,7 @@
enable( 'addBtn' );
enable( 'filterBtn' );
enable( 'removeBtn' );
- jQuery( '#criteriaDiv :input' ).each( function ( idx, item ) {
+ $( '#criteriaDiv :input' ).each( function ( idx, item ) {
enable( this.id );
} );
}
@@ -459,12 +459,12 @@
function getDataElements() {
hideById( 'dataEntryInfor' );
hideById( 'listDiv' );
- jQuery( '#searchingAttributeIdTD [id=searchObjectId] option' ).remove();
- jQuery( '#advancedSearchTB [id=searchObjectId] option' ).remove();
- programStageId = jQuery( '#programId option:selected' ).attr( 'psid' );
+ $( '#searchingAttributeIdTD [id=searchObjectId] option' ).remove();
+ $( '#advancedSearchTB [id=searchObjectId] option' ).remove();
+ programStageId = $( '#programId option:selected' ).attr( 'psid' );
setFieldValue( 'programStageId', programStageId );
- setInnerHTML( 'reportDateDescriptionField', jQuery( '#programId option:selected' ).attr( 'reportDateDes' ) );
- setInnerHTML( 'reportDateDescriptionField2', jQuery( '#programId option:selected' ).attr( 'reportDateDes' ) );
+ setInnerHTML( 'reportDateDescriptionField', $( '#programId option:selected' ).attr( 'reportDateDes' ) );
+ setInnerHTML( 'reportDateDescriptionField2', $( '#programId option:selected' ).attr( 'reportDateDes' ) );
if ( programStageId == '' ) {
removeAllAttributeOption();
@@ -477,22 +477,23 @@
return;
}
- jQuery.getJSON( "getProgramStageDataElementList.action",
+ $.getJSON( "getProgramStageDataElementList.action",
{
programStageId: getFieldValue( 'programStageId' )
},
function ( json ) {
- jQuery( '#advancedSearchTB [name=searchText]' ).val( '' );
- jQuery( '.stage-object-selected' ).attr( 'psid', jQuery( '#programId option:selected' ).attr( "psid" ) );
+ $( '#advancedSearchTB [name=searchText]' ).val( '' );
+ $( '.stage-object-selected' ).attr( 'psid', $( '#programId option:selected' ).attr( "psid" ) );
clearListById( 'searchObjectId' );
clearListById( 'displayInReports' );
- jQuery( '[name=searchObjectId]' ).append( '<option value="" >[' + i18n_please_select + ']</option>' );
- for ( i in json.programStageDataElements ) {
- jQuery( '[name=searchObjectId]' ).append( '<option value="' + json.programStageDataElements[i].id + '" uid="' + json.programStageDataElements[i].uid + '" type="' + json.programStageDataElements[i].type + '">' + json.programStageDataElements[i].name + '</option>' );
- if ( json.programStageDataElements[i].displayInReports == 'true' ) {
- jQuery( '#displayInReports' ).append( '<option value="' + json.programStageDataElements[i].id + '" uid="' + json.programStageDataElements[i].uid + '" ></option>' );
+ $('[name=searchObjectId]').append('<option value="" >[' + i18n_please_select + ']</option>');
+ for( i in json.programStageDataElements ) {
+ $('[name=searchObjectId]').append('<option value="' + json.programStageDataElements[i].id + '" uid="' + json.programStageDataElements[i].uid + '" type="' + json.programStageDataElements[i].type + '">' + json.programStageDataElements[i].name + '</option>');
+
+ if( json.programStageDataElements[i].displayInReports == 'true' ) {
+ $('#displayInReports').append('<option value="' + json.programStageDataElements[i].id + '" uid="' + json.programStageDataElements[i].uid + '" ></option>');
}
}
@@ -506,9 +507,9 @@
}
function dataElementOnChange( this_ ) {
- var container = jQuery( this_ ).parent().parent().attr( 'id' );
- var element = jQuery( '#' + container + ' [id=searchText]' );
- var valueType = jQuery( '#' + container + ' [id=searchObjectId] option:selected' ).attr( 'type' );
+ var container = $( this_ ).parent().parent().attr( 'id' );
+ var element = $( '#' + container + ' [id=searchText]' );
+ var valueType = $( '#' + container + ' [id=searchObjectId] option:selected' ).attr( 'type' );
if ( valueType == 'date' ) {
element.replaceWith( getDateField( container ) );
@@ -524,10 +525,10 @@
}
else if ( valueType == 'optionset' ) {
element.replaceWith( searchTextBox );
- autocompletedFilterField( container + " [id=searchText]", jQuery(this_).find("option:selected").attr('uid') );
+ autocompletedFilterField( container + " [id=searchText]", $(this_).find("option:selected").attr('uid') );
}
else if ( valueType == 'username' ) {
- autocompletedUsernameField( jQuery( this_ ).attr( 'id' ) );
+ autocompletedUsernameField( $( this_ ).attr( 'id' ) );
}
else {
element.replaceWith( searchTextBox );
@@ -536,7 +537,7 @@
}
function autocompletedFilterField( idField, searchObjectId ) {
- var input = jQuery( "#" + idField );
+ var input = $( "#" + idField );
input.css( "width", "237px" );
input.autocomplete( {
delay: 0,
@@ -597,7 +598,7 @@
}
function autocompletedUsernameField( idField ) {
- var input = jQuery( "#" + idField );
+ var input = $( "#" + idField );
input.parent().width( input.width() + 200 );
var dataElementId = input.attr( 'id' ).split( '-' )[1];
@@ -684,9 +685,9 @@
}
function removeAllAttributeOption() {
- jQuery( '#advancedSearchTB tbody tr' ).each( function ( i, item ) {
+ $( '#advancedSearchTB tbody tr' ).each( function ( i, item ) {
if ( i > 0 ) {
- jQuery( item ).remove();
+ $( item ).remove();
}
} )
}
@@ -702,11 +703,11 @@
flag = false;
}
- if ( flag && !listAll && jQuery( '#filterBtn' ).attr( "disabled" ) == "disabled" ) {
- jQuery( '#advancedSearchTB tr' ).each( function ( index, row ) {
+ if ( flag && !listAll && $( '#filterBtn' ).attr( "disabled" ) == "disabled" ) {
+ $( '#advancedSearchTB tr' ).each( function ( index, row ) {
if ( index > 1 ) {
- jQuery( row ).find( ':input' ).each( function ( idx, item ) {
- var input = jQuery( item );
+ $( row ).find( ':input' ).each( function ( idx, item ) {
+ var input = $( item );
if ( input.attr( 'type' ) != 'button' && idx == 0 && input.val() == '' ) {
showWarningMessage( i18n_specify_data_element );
flag = false;
@@ -733,8 +734,8 @@
hideById( 'listDiv' );
var params = 'anonynousEntryForm=true';
- jQuery( '#displayInReports option' ).each( function ( i, item ) {
- var input = jQuery( item );
+ $( '#displayInReports option' ).each( function ( i, item ) {
+ var input = $( item );
params += '&filterValues=de_' + input.val() + '_false_';
} );
@@ -750,16 +751,16 @@
if ( byId( "incompleted" ).checked ) {
params += '&useCompletedEvents=false';
}
- jQuery( '#advancedSearchTB tr' ).each( function ( index, row ) {
+ $( '#advancedSearchTB tr' ).each( function ( index, row ) {
if ( index > 1 ) {
- jQuery( row ).find( ':input' ).each( function ( idx, item ) {
- var input = jQuery( item );
+ $( row ).find( ':input' ).each( function ( idx, item ) {
+ var input = $( item );
if ( input.attr( 'type' ) != 'button' ) {
if ( idx == 0 && input.val() != '' ) {
searchingValue = 'de_' + input.val() + '_false_';
}
else if ( input.val() != '' ) {
- value += jQuery.trim( input.val() ).toLowerCase();
+ value += $.trim( input.val() ).toLowerCase();
}
}
} );
@@ -777,7 +778,7 @@
params += '&facilityLB=selected';
params += '&level=0';
params += '&orgunitIds=' + getFieldValue( 'orgunitId' );
- params += '&programStageId=' + jQuery( '#programId option:selected' ).attr( 'psid' );
+ params += '&programStageId=' + $( '#programId option:selected' ).attr( 'psid' );
params += '&orderByOrgunitAsc=false';
params += '&userOrganisationUnit=false';
params += '&userOrganisationUnitChildren=false';
@@ -807,7 +808,7 @@
var searchInfor = (listAll) ? i18n_list_all_events : i18n_search_events_by_dataelements;
setInnerHTML( 'searchInforTD', searchInfor );
- if ( !listAll && jQuery( '#filterBtn' ).attr( "disabled" ) == "disabled" ) {
+ if ( !listAll && $( '#filterBtn' ).attr( "disabled" ) == "disabled" ) {
showById( 'minimized-advanced-search' );
hideById( 'advanced-search' );
}
@@ -870,7 +871,7 @@
function showUpdateEvent( programStageInstanceId ) {
hideById( 'dataEntryMenu' );
showById( 'eventActionMenu' );
- jQuery( "[name=eventActionLink]" ).hide();
+ $( "[name=eventActionLink]" ).hide();
hideById( 'selectDiv' );
hideById( 'searchDiv' );
hideById( 'listDiv' );
@@ -898,7 +899,7 @@
function showAddEventForm( isCreateEvent ) {
showById( 'eventActionMenu' );
- jQuery( "[name=eventActionLink]" ).hide();
+ $( "[name=eventActionLink]" ).hide();
hideById( 'dataEntryMenu' );
setInnerHTML( 'dataEntryFormDiv', '' );
hideById( 'selectDiv' );
@@ -909,7 +910,7 @@
hideById( 'actionDiv' );
showById( 'dataEntryInfor' );
setFieldValue( 'programStageInstanceId', '0' );
- setInnerHTML( 'programName', jQuery( '#programId option:selected' ).text() );
+ setInnerHTML( 'programName', $( '#programId option:selected' ).text() );
if( isCreateEvent != undefined ){
addNewEvent();
}
@@ -917,11 +918,11 @@
function addNewEvent() {
var programStageInstanceId = getFieldValue( 'programStageInstanceId' );
- var programId = jQuery( '#programId option:selected' ).val();
+ var programId = $( '#programId option:selected' ).val();
var executionDate = getFieldValue( 'executionDate' );
var orgunitId = getFieldValue( 'orgunitId' );
- jQuery( "#executionDate" ).css( 'background-color', SAVING_COLOR );
+ $( "#executionDate" ).css( 'background-color', SAVING_COLOR );
service.saveExecutionDate( programId, programStageInstanceId, executionDate, orgunitId );
}
@@ -934,9 +935,9 @@
var result = window.confirm( i18n_confirm_remove_empty_events );
if ( result ) {
- jQuery.getJSON( "removeEmptyEvents.action",
+ $.getJSON( "removeEmptyEvents.action",
{
- programStageId: jQuery( '#selectDiv [id=programId] option:selected' ).attr( 'psid' )
+ programStageId: $( '#selectDiv [id=programId] option:selected' ).attr( 'psid' )
},
function ( json ) {
if ( json.response == 'success' ) {
@@ -975,21 +976,21 @@
function removeAllOption() {
enable( 'filterBtn' );
- jQuery( '#advancedSearchTB tr' ).each( function ( i, row ) {
+ $( '#advancedSearchTB tr' ).each( function ( i, row ) {
if ( i > 2 ) {
- jQuery( this ).remove();
+ $( this ).remove();
}
else if ( i == 2 ) {
- jQuery( this ).find( ':input' ).each( function ( idx, item ) {
- var input = jQuery( item );
+ $( this ).find( ':input' ).each( function ( idx, item ) {
+ var input = $( item );
if ( input.attr( 'type' ) != 'button' ) {
input.val( '' );
}
} );
}
} );
- jQuery( '#searchObjectId' ).val( "" );
- jQuery( '#searchText' ).val( "" );
+ $( '#searchObjectId' ).val( "" );
+ $( '#searchText' ).val( "" );
searchEvents( eval( getFieldValue( "listAll" ) ) );
}
@@ -1009,7 +1010,7 @@
saveExecutionDate: function( programId, programStageInstanceId, executionDate, organisationUnitId ) {
ajaxExecutionDate(programId, programStageInstanceId, executionDate, organisationUnitId).done(function ( json ) {
if ( json.response == 'success' ) {
- jQuery( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
+ $( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
setFieldValue( 'programStageInstanceId', json.message );
if ( programStageInstanceId != json.message ) {
@@ -1017,7 +1018,7 @@
}
}
else {
- jQuery( "#executionDate" ).css( 'background-color', ERROR_COLOR );
+ $( "#executionDate" ).css( 'background-color', ERROR_COLOR );
showWarningMessage( json.message );
}
} ).fail( function () {
@@ -1032,7 +1033,7 @@
programStageInstanceId = "local"+i;
setFieldValue( 'programStageInstanceId', programStageInstanceId );
- jQuery( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
+ $( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
showUpdateEvent( programStageInstanceId );
var data = {};
@@ -1045,7 +1046,7 @@
} else {
// if we have a programStageInstanceId, just reuse that one
setFieldValue( 'programStageInstanceId', programStageInstanceId );
- jQuery( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
+ $( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
showUpdateEvent( programStageInstanceId );
}
} );
@@ -1064,15 +1065,15 @@
})();
function updateDataForm() {
- jQuery( '#inputCriteriaDiv' ).remove();
+ $( '#inputCriteriaDiv' ).remove();
showById( 'programName' );
showById( 'actionDiv' );
- var programName = jQuery( '#programId option:selected' ).text();
- var programStageId = jQuery( '#programId option:selected' ).attr( 'psid' );
- jQuery( '.stage-object-selected' ).attr( 'psid', programStageId );
+ var programName = $( '#programId option:selected' ).text();
+ var programStageId = $( '#programId option:selected' ).attr( 'psid' );
+ $( '.stage-object-selected' ).attr( 'psid', programStageId );
setInnerHTML( 'programName', programName );
- jQuery('#executionDate').css('width',430);
- jQuery('#executionDate').css('margin-right',34);
+ $('#executionDate').css('width',430);
+ $('#executionDate').css('margin-right',34);
if ( getFieldValue( 'completed' ) == 'true' ) {
disable( "completeBtn" );
@@ -1087,10 +1088,10 @@
showById( 'dataEntryInfor' );
showById( 'entryFormContainer' );
- jQuery( "#entryForm :input" ).each( function () {
- if ( ( jQuery( this ).attr( 'options' ) != null && jQuery( this ).attr( 'options' ) == 'true' )
- || ( jQuery( this ).attr( 'username' ) != null && jQuery( this ).attr( 'username' ) == 'true' ) ) {
- var input = jQuery( this );
+ $( "#entryForm :input" ).each( function () {
+ if ( ( $( this ).attr( 'options' ) != null && $( this ).attr( 'options' ) == 'true' )
+ || ( $( this ).attr( 'username' ) != null && $( this ).attr( 'username' ) == 'true' ) ) {
+ var input = $( this );
input.parent().width( input.width() + 200 );
}
} );