jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brus...@apache.org
Subject svn commit: r807787 - in /incubator/jspwiki/trunk: ChangeLog src/WebContent/scripts/jspwiki-edit.js src/java/org/apache/wiki/Release.java
Date Tue, 25 Aug 2009 20:03:40 GMT
Author: brushed
Date: Tue Aug 25 20:03:39 2009
New Revision: 807787

URL: http://svn.apache.org/viewvc?rev=807787&view=rev
Log:
3.0.0-svn-148        
        * JSPWIKI-580: Fixing the quirky handling of the textarea selection range in IEx browsers.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=807787&r1=807786&r2=807787&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Tue Aug 25 20:03:39 2009
@@ -1,3 +1,11 @@
+2009-08-25 Dirk Frederickx <brushed@apache.org>
+
+        * 3.0.0-svn-148
+        
+        * JSPWIKI-580: Fixing the quirky handling of the textarea selection range
+        in IEx browsers.
+        
+
 2009-08-23 Harry Metske <metskem@apache.org>
 
         * 3.0.0-svn-147

Modified: incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js?rev=807787&r1=807786&r2=807787&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js (original)
+++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-edit.js Tue Aug 25 20:03:39 2009
@@ -2299,23 +2299,25 @@
 		var txta = this.ta;
 		if(!end) end = start;
 
-		if(window.ie){
-			/**/
+		if($defined(txta.setSelectionRange)){
+
+			txta.setSelectionRange(start, end);
+
+		} else {
+
             var value = txta.value,
             	diff = value.substr(start, end - start).replace(/\r/g, '').length;
 
             start = value.substr(0, start).replace(/\r/g, '').length;
-            /**/
+           
 			var range = txta.createTextRange();
 			range.collapse(true);
-			//range.moveEnd('character',end-start);
 			range.moveEnd('character', start + diff);
 			range.moveStart('character', start);
 			range.select();
 			//textarea.scrollTop = scrollPosition;
 			//textarea.focus();
-		} else {
-			txta.setSelectionRange(start, end);
+
 		}
 		return this;
 	},
@@ -2331,6 +2333,7 @@
 		thin - boolean indicates whether selection is empty (start==end)
 	*/
 
+/* ffs
 	getIERanges: function(){
 		this.ta.focus();
 		var txta = this.ta,
@@ -2341,29 +2344,29 @@
 		dupe.setEndPoint('EndToStart', re);
 		return { start: dupe.text.length, end: dupe.text.length + range.text.length, length: range.text.length,
text: range.text };
 	},
-
+*/
 	getSelectionRange: function(){
 
 		var txta = this.ta,
 			pos = {start: 0, end: 0, thin: true};
 
-			if( window.ie ){
+		if( $defined(txta.selectionStart) ){
 
-		  		var range = document.selection.createRange();
-				if (!range || range.parentElement() != txta) return pos;
-		 		var dup = range.duplicate(),
-					value = txta.value,
-					offset = value.length - value.match(/[\n\r]*$/)[0].length;
-
-				dup.moveToElementText(txta);
-				dup.setEndPoint('StartToEnd', range);
-				pos.end = offset - dup.text.length;
-		  		dup.setEndPoint('StartToStart', range);
-				pos.start = offset - dup.text.length;
+			pos = { start: txta.selectionStart, end: txta.selectionEnd };
 
 		} else {
 		
-			pos = { start: txta.selectionStart, end: txta.selectionEnd };
+	  		var range = document.selection.createRange();
+			if (!range || range.parentElement() != txta) return pos;
+	 		var dup = range.duplicate(),
+				value = txta.value,
+				offset = value.length - value.match(/[\n\r]*$/)[0].length;
+
+			dup.moveToElementText(txta);
+			dup.setEndPoint('StartToEnd', range);
+			pos.end = offset - dup.text.length;
+	  		dup.setEndPoint('StartToStart', range);
+			pos.start = offset - dup.text.length;
 
 		}
 
@@ -2388,24 +2391,28 @@
 	*/
 	setSelection: function(){
 
-		var value = $A(arguments).join(''),
+		var value = $A(arguments).join('').replace(/\r/g, ''),
 			txta = this.ta,
 			scrollTop = txta.scrollTop; //cache top
 		 
-		if( window.ie ){
+		if( $defined(txta.selectionStart) ){
+
+			var start = txta.selectionStart, 
+				end = txta.selectionEnd,
+				v = txta.value;
+			txta.value = v.substr(0, start) + value + v.substr(end);
+			txta.selectionStart = start;
+			txta.selectionEnd = start + value.length;
+
+		} else { 
+
 			txta.focus();
 			var range = document.selection.createRange();
 			range.text = value;			
 			range.collapse(true);
 			range.moveStart("character", -value.length);
 			range.select();
-		} else { 
-			var start = txta.selectionStart, 
-				end = txta.selectionEnd;
-			//txta.value = txta.value.substring(0, start) + value + txta.value.substring(end);
-			txta.value = txta.value.substr(0, start) + value + txta.value.substr(end);
-			txta.selectionStart = start;
-			txta.selectionEnd = start + value.length;
+
 		}
 		txta.focus();
 		txta.scrollTop = scrollTop;		

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=807787&r1=807786&r2=807787&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Tue Aug 25 20:03:39 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "147";
+    public static final String     BUILD         = "148";
 
     /**
      *  This is the generic version string you should use



Mime
View raw message