[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 /* 2 * FCKeditor - The text editor for internet 3 * Copyright (C) 2003-2005 Frederico Caldeira Knabben 4 * 5 * Licensed under the terms of the GNU Lesser General Public License: 6 * http://www.opensource.org/licenses/lgpl-license.php 7 * 8 * For further information visit: 9 * http://www.fckeditor.net/ 10 * 11 * "Support Open Source software. What about a donation today?" 12 * 13 * File Name: fckstyledef_gecko.js 14 * FCKStyleDef Class: represents a single stylke definition. (Gecko specific) 15 * 16 * File Authors: 17 * Frederico Caldeira Knabben (fredck@fckeditor.net) 18 */ 19 20 FCKStyleDef.prototype.ApplyToSelection = function() 21 { 22 if ( FCKSelection.GetType() == 'Text' && !this.IsObjectElement ) 23 { 24 var oSelection = FCK.EditorWindow.getSelection() ; 25 26 // Create the main element. 27 var e = FCK.EditorDocument.createElement( this.Element ) ; 28 29 for ( var i = 0 ; i < oSelection.rangeCount ; i++ ) 30 { 31 e.appendChild( oSelection.getRangeAt(i).extractContents() ) ; 32 } 33 34 // Set the attributes. 35 this._AddAttributes( e ) ; 36 37 // Remove the duplicated elements. 38 this._RemoveDuplicates( e ) ; 39 40 var oRange = oSelection.getRangeAt(0) ; 41 oRange.insertNode( e ) ; 42 } 43 else 44 { 45 var oControl = FCKSelection.GetSelectedElement() ; 46 if ( oControl.tagName == this.Element ) 47 this._AddAttributes( oControl ) ; 48 } 49 } 50 51 FCKStyleDef.prototype._AddAttributes = function( targetElement ) 52 { 53 for ( var a in this.Attributes ) 54 targetElement.setAttribute( a, this.Attributes[a], 0 ) ; 55 } 56 57 FCKStyleDef.prototype._RemoveDuplicates = function( parent ) 58 { 59 for ( var i = 0 ; i < parent.childNodes.length ; i++ ) 60 { 61 var oChild = parent.childNodes[i] ; 62 63 if ( oChild.nodeType != 1 ) 64 continue ; 65 66 this._RemoveDuplicates( oChild ) ; 67 68 if ( this.IsEqual( oChild ) ) 69 FCKTools.RemoveOuterTags( oChild ) ; 70 } 71 } 72 73 FCKStyleDef.prototype.IsEqual = function( e ) 74 { 75 if ( e.tagName != this.Element ) 76 return false ; 77 78 for ( var a in this.Attributes ) 79 { 80 if ( e.getAttribute( a ) != this.Attributes[a] ) 81 return false ; 82 } 83 84 return true ; 85 } 86 87 FCKStyleDef.prototype._RemoveMe = function( elementToCheck ) 88 { 89 if ( ! elementToCheck ) 90 return ; 91 92 var oParent = elementToCheck.parentNode ; 93 94 if ( elementToCheck.nodeType == 1 && this.IsEqual( elementToCheck ) ) 95 { 96 if ( this.IsObjectElement ) 97 { 98 for ( var a in this.Attributes ) 99 elementToCheck.removeAttribute( a, 0 ) ; 100 return ; 101 } 102 else 103 FCKTools.RemoveOuterTags( elementToCheck ) ; 104 } 105 106 this._RemoveMe( oParent ) ; 107 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |