[ Index ] |
|
Code source de FCKeditor 2.4 |
1 /* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 * 21 * File Name: fckdomrange_gecko.js 22 * Class for working with a selection range, much like the W3C DOM Range, but 23 * it is not intented to be an implementation of the W3C interface. 24 * (Gecko Implementation) 25 * 26 * File Authors: 27 * Frederico Caldeira Knabben (www.fckeditor.net) 28 */ 29 30 FCKDomRange.prototype.MoveToSelection = function() 31 { 32 this.Release( true ) ; 33 34 var oSel = this.Window.getSelection() ; 35 36 if ( oSel.rangeCount == 1 ) 37 { 38 this._Range = FCKW3CRange.CreateFromRange( this.Window.document, oSel.getRangeAt(0) ) ; 39 this._UpdateElementInfo() ; 40 } 41 } 42 43 FCKDomRange.prototype.Select = function() 44 { 45 var oRange = this._Range ; 46 if ( oRange ) 47 { 48 var oDocRange = this.Window.document.createRange() ; 49 oDocRange.setStart( oRange.startContainer, oRange.startOffset ) ; 50 51 try 52 { 53 oDocRange.setEnd( oRange.endContainer, oRange.endOffset ) ; 54 } 55 catch ( e ) 56 { 57 // There is a bug in Firefox implementation (it would be too easy 58 // otherwhise). The new start can't be after the end (W3C says it can). 59 // So, let's create a new range and collapse it to the desired point. 60 if ( e.toString().Contains( 'NS_ERROR_ILLEGAL_VALUE' ) ) 61 { 62 oRange.collapse( true ) ; 63 oDocRange.setEnd( oRange.endContainer, oRange.endOffset ) ; 64 } 65 else 66 throw( e ) ; 67 } 68 69 var oSel = this.Window.getSelection() ; 70 oSel.removeAllRanges() ; 71 72 // We must add a clone otherwise Firefox will have rendering issues. 73 oSel.addRange( oDocRange ) ; 74 } 75 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |