Changeset 898
- Timestamp:
- 10/10/07 19:20:10 (6 years ago)
- Location:
- trunk/modules
- Files:
-
- 2 modified
-
Gecko/Gecko.js (modified) (1 diff)
-
InternetExplorer/InternetExplorer.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/Gecko/Gecko.js
r894 r898 692 692 Xinha.prototype.setCC = function ( target ) 693 693 { 694 var cc = this.cc; 694 695 try 695 696 { 696 697 if ( target == "textarea" ) 697 698 { 698 var ta = this._textArea;699 var ta = this._textArea; 699 700 var index = ta.selectionStart; 700 701 var before = ta.value.substring( 0, index ) 701 702 var after = ta.value.substring( index, ta.value.length ); 702 703 703 if ( after.match(/^[^<]*>/) ) 704 if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, and inside the body) 704 705 { 705 706 var tagEnd = after.indexOf(">") + 1; 706 ta.value = before + after.substring( 0, tagEnd ) + this.cc + after.substring( tagEnd, after.length ); 707 } 708 else ta.value = before + this.cc + after; 707 ta.value = before + after.substring( 0, tagEnd ) + cc + after.substring( tagEnd, after.length ); 708 } 709 else ta.value = before + cc + after; 710 ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); 711 ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); 709 712 } 710 713 else 711 714 { 712 715 var sel = this.getSelection(); 713 sel.getRangeAt(0).insertNode( document.createTextNode( this.cc ) );716 sel.getRangeAt(0).insertNode( document.createTextNode( cc ) ); 714 717 } 715 718 } catch (e) {} -
trunk/modules/InternetExplorer/InternetExplorer.js
r865 r898 436 436 Xinha.prototype.setCC = function ( target ) 437 437 { 438 var cc = this.cc; 438 439 if ( target == "textarea" ) 439 440 { … … 441 442 var pos = document.selection.createRange(); 442 443 pos.collapse(); 443 pos.text = this.cc;444 var index = ta.value.indexOf( this.cc );444 pos.text = cc; 445 var index = ta.value.indexOf( cc ); 445 446 var before = ta.value.substring( 0, index ); 446 var after = ta.value.substring( index + this.cc.length , ta.value.length );447 var after = ta.value.substring( index + cc.length , ta.value.length ); 447 448 448 if ( after.match(/^[^<]*>/))449 if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, and inside the body) 449 450 { 450 451 var tagEnd = after.indexOf(">") + 1; 451 ta.value = before + after.substring( 0, tagEnd ) + this.cc + after.substring( tagEnd, after.length ); 452 } 453 else ta.value = before + this.cc + after; 452 ta.value = before + after.substring( 0, tagEnd ) + cc + after.substring( tagEnd, after.length ); 453 } 454 else ta.value = before + cc + after; 455 ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); 456 ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); 454 457 } 455 458 else … … 460 463 { 461 464 var control = r.item(0); 462 control.outerHTML += this.cc;465 control.outerHTML += cc; 463 466 } 464 467 else 465 468 { 466 469 r.collapse(); 467 r.text = this.cc;470 r.text = cc; 468 471 } 469 472 }
