← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7911: Single click to select one data-element being selected only when to create/update program-stage.

 

------------------------------------------------------------
revno: 7911
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-08-14 15:46:27 +0700
message:
  Single click to select one data-element being selected only when to create/update program-stage.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.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-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2012-06-13 04:13:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2012-08-14 08:46:27 +0000
@@ -76,7 +76,7 @@
 	var selectedList = jQuery("#selectedList");
 	jQuery("#availableList").children().each(function(i, item){
 		if( item.selected ){
-			html = "<tr class='selected' id='" + item.value + "' ondblclick='unSelectDataElement( this )'><td onclick='select(this)'>" + item.text + "</td>";
+			html = "<tr class='selected' id='" + item.value + "' ondblclick='unSelectDataElement( this )'><td onmousedown='select(event,this)'>" + item.text + "</td>";
 			html += "<td align='center'><input type='checkbox' name='compulsory' value='" + item.value + "'></td>";
 			html += "<td align='center'><input type='checkbox' name='allowProvided' value='" + item.value + "'></td>";
 			html += "</tr>";
@@ -91,7 +91,7 @@
 {
 	var selectedList = jQuery("#selectedList");
 	jQuery("#availableList").children().each(function(i, item){
-		html = "<tr class='selected' id='" + item.value + "' ondblclick='unSelectDataElement( this )'><td onclick='select(this)'>" + item.text + "</td>";
+		html = "<tr class='selected' id='" + item.value + "' ondblclick='unSelectDataElement( this )'><td onmousedown='select(this)'>" + item.text + "</td>";
 		html += "<td align='center'><input type='checkbox' name='compulsory' value='" + item.value + "'></td>";
 		html += "<td align='center'><input type='checkbox' name='allowProvided' value='" + item.value + "'></td>";
 		html += "</tr>";
@@ -175,13 +175,40 @@
 	element.remove();
 }
 
-function select( element )
+function select( event, element )
 {
+	if ( !getKeyCode( event ) )// Ctrl
+	{
+		jQuery("#selectedList .selected").removeClass( 'selected' );
+	}
+	
 	element = jQuery( element ).parent();
 	if( element.hasClass( 'selected') ) element.removeClass( 'selected' );
 	else element.addClass( 'selected' );
 }
 
+function getKeyCode(e)
+{
+	var ctrlPressed=0;
+
+	if (parseInt(navigator.appVersion)>3) {
+
+		var evt = e ? e:window.event;
+
+		if (document.layers && navigator.appName=="Netscape"
+		&& parseInt(navigator.appVersion)==4) {
+			// NETSCAPE 4 CODE
+			var mString =(e.modifiers+32).toString(2).substring(3,6);
+			ctrlPressed =(mString.charAt(1)=="1");
+		}
+		else {
+			// NEWER BROWSERS [CROSS-PLATFORM]
+			ctrlPressed=evt.ctrlKey;
+		}
+	}
+	return ctrlPressed;
+}
+
 function repeatableOnChange()
 {
 	var checked = byId('irregular').checked;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2012-07-30 06:23:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2012-08-14 08:46:27 +0000
@@ -82,7 +82,7 @@
 						<tbody id="selectedList">
 							#foreach ( $programStageDataElement in $programStageDataElements )
 								<tr ondblclick="unSelectDataElement( this )" id="$programStageDataElement.dataElement.id">
-									<td onclick="select(this)">$encoder.htmlEncode( $programStageDataElement.dataElement.name )</td>
+									<td onmousedown="select(event,this)">$encoder.htmlEncode( $programStageDataElement.dataElement.name )</td>
 									<td align="center"><input type="checkbox" name="compulsory" value="$programStageDataElement.dataElement.id" #if($programStageDataElement.compulsory == true ) checked #end /></td>
 									<td align="center"><input type="checkbox" name="allowProvided" value="$programStageDataElement.dataElement.id" #if($programStageDataElement.allowProvidedElsewhere == true ) checked #end /></td>
 								</tr>