Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Better character coords calculation for IE7+

  • Loading branch information...
commit 56f0e567efa60d0226d5046dd52dd010052d56ca 1 parent 044e1e9
Sergey Chikuyonok authored July 06, 2010

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. 8  src/TextViewer.js
8  src/TextViewer.js
@@ -22,12 +22,14 @@
22 22
 		 */
23 23
 		copy_props = ('font-family,font-size,line-height,text-indent,' +
24 24
 						'padding-top,padding-right,padding-bottom,padding-left,' +
25  
-						'border-left-width,border-right-width,border-left-style,border-right-style').split(',')
  25
+						'border-left-width,border-right-width,border-left-style,border-right-style').split(','),
26 26
 		xml_chars = {
27 27
 			'<' : '&lt;',
28 28
 			'>' : '&gt;',
29 29
 			'&' : '&amp;'
30  
-		};
  30
+		},
  31
+		ua = navigator.userAgent.toLowerCase(),
  32
+		line_breaker = ua.indexOf('msie 6') === -1 ? String.fromCharCode(8203) : '&shy;';
31 33
 	
32 34
 	/**
33 35
 	 * Find start and end index of text line for <code>from</code> index
@@ -68,7 +70,7 @@
68 70
 		str = str.replace(/[<>&]/g, function(str) {
69 71
 			return xml_chars[str];
70 72
 		});
71  
-		return has_pre_wrap ? str : str.replace(/\s/g, '&nbsp;&shy;');
  73
+		return has_pre_wrap ? str : str.replace(/\s/g, '&nbsp;' + line_breaker);
72 74
 	}
73 75
 	
74 76
 	/**

0 notes on commit 56f0e56

Please sign in to comment.
Something went wrong with that request. Please try again.