Changeset 14184
- Timestamp:
- 06/26/08 19:08:40 (5 months ago)
- Files:
-
- 1 modified
-
dojox/trunk/string/BidiComplex.js (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojox/trunk/string/BidiComplex.js
r14159 r14184 8 8 // in both static text and dynamic text during user input. 9 9 10 dojox.string.BidiComplex.attachInput = function(/* Object*/field,/*String*/pattern){10 dojox.string.BidiComplex.attachInput = function(/*DOMNode*/field, /*String*/pattern){ 11 11 // summary: 12 // Add Object listeners to the Text contianer Object for Dynamic Complex text 13 // field: Object reference 14 // pattern: Complex Expression Pattern type 15 // example: 16 // dojo.require("dojox.string.BidiComplex"); 17 // var obj = document.getElementById("com"); 18 // dojox.string.BidiComplex.attachInput(obj,"FILE_PATH"); 19 12 // Attach key listeners to the INPUT field to accomodate dynamic complex BiDi expressions 13 // field: INPUT DOM node 14 // pattern: Complex Expression Pattern type. One of "FILE_PATH", "URL", "EMAIL", "XPATH" 15 20 16 dojox.string.BidiComplex._ce_type = pattern; //FIXME: shared ref 21 17 field.alt = dojox.string.BidiComplex._ce_type; … … 32 28 } 33 29 34 field.oncut =dojox.string.BidiComplex._fOnCut;35 field.oncopy =dojox.string.BidiComplex._fOnCopy;30 field.oncut = dojox.string.BidiComplex._fOnCut; 31 field.oncopy = dojox.string.BidiComplex._fOnCopy; 36 32 37 33 field.value = dojox.string.BidiComplex._insertMarkers(field.value, field.alt); … … 47 43 }; 48 44 49 (function(){50 // Unicode Bidirectional Characters51 var LRO = '\u202D',52 RLO = '\u202E',53 PDF = '\u202C',54 LRE = '\u202A',55 RLE = '\u202B',56 LRM = '\u200E',57 RLM = '\u200F';58 59 45 dojox.string.BidiComplex.stripSpecialCharacters = function(str){ 60 // summary: 61 // removes all Unicode directional markers from the string 62 // Example : 63 // var originalString = dojox.string.BidiComplex.stripSpecialCharacters(displayString); 64 // 65 if(!str){ 66 return str; 67 } 68 69 var buf = "", character; 70 for(var i = 0; i < str.length; i++){ // FIXME: dojo.forEach 71 character = str.charAt(i); 72 if((character != LRE) && (character != RLE) 73 && (character != LRM) && (character != RLM) 74 && (character != LRO) && (character != RLO) && 75 (character != PDF)){ 76 buf+=character; 77 } 78 } 79 80 return buf; 46 // summary: 47 // removes all Unicode directional markers from the string 48 49 return str.replace(/[\u200E\u200F\u202A-\u202E]/g, ""); // String 81 50 }; 82 51 … … 92 61 93 62 dojox.string.BidiComplex._ceKeyDown = function(event){ 63 //FIXME: global references: obj and str0 94 64 obj = dojo.isIE ? event.srcElement : event.target; 95 65 str0 = obj.value; … … 97 67 98 68 dojox.string.BidiComplex._ceKeyUp = function(event){ 69 var LRM = '\u200E'; 70 //FIXME: str0 global reference 99 71 obj = dojo.isIE ? event.srcElement : event.target; 100 72 str1 = obj.value; … … 165 137 166 138 if((ieKey == dojo.keys.DELETE) && (str2.charAt(cursorEnd)==LRM)){ 167 obj.value = str2.substring(0, cursorEnd) + str2.substring(cursorEnd+2, str2.length);139 obj.value = str2.substring(0, cursorEnd) + str2.substring(cursorEnd+2, str2.length); 168 140 } 169 141 170 142 if(ieKey == dojo.keys.DELETE){ 171 143 setSelectedRange(obj,cursorStart,cursorEnd); 172 }else if(ieKey == dojo.keys.BACKSPACE){ 173 if(str0.charAt(cursorEnd-1)==LRM){ 174 dojox.string.BidiComplex._setSelectedRange(obj, cursorStart - 1, cursorEnd - 1); 175 }else{ 176 dojox.string.BidiComplex._setSelectedRange(obj, cursorStart, cursorEnd); 177 } 144 }else if(ieKey == dojo.keys.BACKSPACE){ 145 //FIXME: str0 global reference 146 if(str0.charAt(cursorEnd-1)==LRM){ 147 dojox.string.BidiComplex._setSelectedRange(obj, cursorStart - 1, cursorEnd - 1); 148 }else{ 149 dojox.string.BidiComplex._setSelectedRange(obj, cursorStart, cursorEnd); 150 } 178 151 }else if(obj.value.charAt(cursorEnd) != LRM){ 179 152 dojox.string.BidiComplex._setSelectedRange(obj, cursorStart + 1, cursorEnd + 1); … … 234 207 235 208 dojox.string.BidiComplex._getCaretPos = function(event,obj){ 236 237 209 if(!dojo.isIE){ 238 210 return [event.target.selectionStart, event.target.selectionEnd]; … … 395 367 dojox.string.BidiComplex._segmentsPointers = dojox.string.BidiComplex._parse(str, pattern); // FIXME: shared ref 396 368 397 var buf = LRE+ str;369 var buf = '\u202A'/*LRE*/ + str; 398 370 var shift = 1; 399 371 var n; … … 403 375 preStr = buf.substring(0, n + shift); 404 376 postStr = buf.substring(n + shift, buf.length); 405 buf = preStr + LRM+ postStr;377 buf = preStr + '\u200E'/*LRM*/ + postStr; 406 378 shift++; 407 379 } … … 409 381 return buf; 410 382 }; 411 })();