← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1949: Fix bug Formula editor not working in Chrome.

 

------------------------------------------------------------
revno: 1949
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Thu 2010-06-03 00:00:23 +0700
message:
  Fix bug Formula editor not working in Chrome.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/commons.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/denum.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.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/util/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/commons.js	2010-05-26 14:45:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/commons.js	2010-06-02 17:00:23 +0000
@@ -746,3 +746,45 @@
     	);
     }
 }
+
+function setSelectionRange( input, selectionStart, selectionEnd ) 
+{
+	if ( input.setSelectionRange ) 
+	{
+		input.focus();
+	    input.setSelectionRange( selectionStart, selectionEnd );
+	}
+	else if ( input.createTextRange ) 
+	{
+	    var range = input.createTextRange();
+	    range.collapse( true );
+	    range.moveEnd( 'character', selectionEnd );
+	    range.moveStart( 'character', selectionStart );
+	    range.select();
+	}
+}
+
+function setCaretToPos ( input, pos ) 
+{
+	setSelectionRange( input, pos, pos );
+}
+
+function getFilteredDataElementsReceived( xmlObject )
+{
+	var operandList = document.getElementById( "dataElementId" );
+			
+	operandList.options.length = 0;
+	
+	var operands = xmlObject.getElementsByTagName( "operand" );
+	
+	for ( var i = 0; i < operands.length; i++)
+	{
+		var id = operands[ i ].getElementsByTagName( "operandId" )[0].firstChild.nodeValue;
+		var elementName = operands[ i ].getElementsByTagName( "operandName" )[0].firstChild.nodeValue;
+		
+		var option = document.createElement( "option" );
+		option.value = "[" + id + "]";
+		option.text = elementName;
+		operandList.add( option, null );	
+	}
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/denum.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/denum.js	2010-03-17 16:08:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/denum.js	2010-06-02 17:00:23 +0000
@@ -15,26 +15,6 @@
     request.send( url );
 }
 
-function getFilteredDataElementsReceived( xmlObject )
-{
-	var operandList = document.getElementById( "dataElementId" );
-			
-	operandList.options.length = 0;
-	
-	var operands = xmlObject.getElementsByTagName( "operand" );
-	
-	for ( var i = 0; i < operands.length; i++)
-	{
-		var id = operands[ i ].getElementsByTagName( "operandId" )[0].firstChild.nodeValue;
-		var elementName = operands[ i ].getElementsByTagName( "operandName" )[0].firstChild.nodeValue;
-		
-		var option = document.createElement( "option" );
-		option.value = "[" + id + "]";
-		option.text = elementName;
-		operandList.add( option, null );	
-	}
-}
-
 function getSelectedRadioValue( radioGroupName )
 {
 	var radioGroup = document.getElementsByName( radioGroupName );
@@ -194,7 +174,9 @@
 	
 	disableRadioGroup( radioGroupName );
 	
-	updateFormulaText( inputAreaName );	
+	updateFormulaText( inputAreaName );
+	
+	setCaretToPos( inputArea, inputArea.value.length);
 }
 
 function updateFormulaText( formulaFieldName )

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js	2010-05-28 19:17:07 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js	2010-06-02 17:00:23 +0000
@@ -45,7 +45,9 @@
 	
 	inputArea.value = textBefore + inputText + textAfter;
 	
-	updateTextualExpression( inputAreaName );	
+	updateTextualExpression( inputAreaName );
+	
+	setCaretToPos( inputArea, inputArea.value.length);
 }
 
 function filterDataElements( dataSetName, filterName )
@@ -65,26 +67,6 @@
     request.send( url );
 }
 
-function getFilteredDataElementsReceived( xmlObject )
-{
-	var operandList = document.getElementById( "dataElementId" );
-			
-	operandList.options.length = 0;
-	
-	var operands = xmlObject.getElementsByTagName( "operand" );
-	
-	for ( var i = 0; i < operands.length; i++)
-	{
-		var id = operands[ i ].getElementsByTagName( "operandId" )[0].firstChild.nodeValue;
-		var elementName = operands[ i ].getElementsByTagName( "operandName" )[0].firstChild.nodeValue;
-		
-		var option = document.createElement( "option" );
-		option.value = "[" + id + "]";
-		option.text = elementName;
-		operandList.add( option, null );	
-	}
-}
-
 function updateTextualExpression( expressionFieldName )
 {	
 	var expression = htmlEncode( document.getElementById( expressionFieldName ).value );