+++ /dev/null
-/*\r
- * FCKeditor - The text editor for internet\r
- * Copyright (C) 2003-2006 Frederico Caldeira Knabben\r
- * \r
- * Licensed under the terms of the GNU Lesser General Public License:\r
- * http://www.opensource.org/licenses/lgpl-license.php\r
- * \r
- * For further information visit:\r
- * http://www.fckeditor.net/\r
- * \r
- * "Support Open Source software. What about a donation today?"\r
- * \r
- * File Name: fckstyledef_ie.js\r
- * FCKStyleDef Class: represents a single stylke definition. (IE specific)\r
- * \r
- * File Authors:\r
- * Frederico Caldeira Knabben (fredck@fckeditor.net)\r
- */\r
-\r
-FCKStyleDef.prototype.ApplyToSelection = function()\r
-{\r
- var oSelection = FCK.ToolbarSet.CurrentInstance.EditorDocument.selection ;\r
- \r
- if ( oSelection.type == 'Text' )\r
- {\r
- var oRange = oSelection.createRange() ;\r
- \r
- // Create the main element.\r
- var e = document.createElement( this.Element ) ;\r
- e.innerHTML = oRange.htmlText ;\r
- \r
- // Set the attributes.\r
- this._AddAttributes( e ) ;\r
- \r
- // Remove the duplicated elements.\r
- this._RemoveDuplicates( e ) ;\r
- \r
- // Replace the selection with the resulting HTML.\r
- oRange.pasteHTML( e.outerHTML ) ;\r
- }\r
- else if ( oSelection.type == 'Control' )\r
- {\r
- var oControl = FCK.ToolbarSet.CurrentInstance.Selection.GetSelectedElement() ;\r
- if ( oControl.tagName == this.Element )\r
- this._AddAttributes( oControl ) ;\r
- }\r
-}\r
-\r
-FCKStyleDef.prototype._AddAttributes = function( targetElement )\r
-{\r
- for ( var a in this.Attributes )\r
- {\r
- switch ( a.toLowerCase() )\r
- {\r
- case 'style' :\r
- targetElement.style.cssText = this.Attributes[a] ;\r
- break ;\r
-\r
- case 'class' :\r
- targetElement.setAttribute( 'className', this.Attributes[a], 0 ) ;\r
- break ;\r
-\r
- case 'src' :\r
- targetElement.setAttribute( '_fcksavedurl', this.Attributes[a], 0 ) ;\r
-\r
- default :\r
- targetElement.setAttribute( a, this.Attributes[a], 0 ) ;\r
- }\r
- }\r
-}\r
-\r
-FCKStyleDef.prototype._RemoveDuplicates = function( parent )\r
-{\r
- for ( var i = 0 ; i < parent.children.length ; i++ )\r
- {\r
- var oChild = parent.children[i] ;\r
- this._RemoveDuplicates( oChild ) ;\r
- \r
- if ( this.IsEqual( oChild ) )\r
- FCKTools.RemoveOuterTags( oChild ) ;\r
- }\r
-}\r
-\r
-FCKStyleDef.prototype.IsEqual = function( e )\r
-{\r
- if ( e.tagName != this.Element )\r
- return false ;\r
- \r
- for ( var a in this.Attributes )\r
- {\r
- switch ( a.toLowerCase() )\r
- {\r
- case 'style' :\r
- if ( e.style.cssText.toLowerCase() != this.Attributes[a].toLowerCase() )\r
- return false ;\r
- break ;\r
- case 'class' :\r
- if ( e.getAttribute( 'className', 0 ) != this.Attributes[a] )\r
- return false ;\r
- break ;\r
- default :\r
- if ( e.getAttribute( a, 0 ) != this.Attributes[a] )\r
- return false ;\r
- }\r
- }\r
- \r
- return true ;\r
-}\r
-\r
-FCKStyleDef.prototype._RemoveMe = function( elementToCheck )\r
-{\r
- if ( ! elementToCheck )\r
- return ;\r
-\r
- var oParent = elementToCheck.parentElement ;\r
-\r
- if ( this.IsEqual( elementToCheck ) )\r
- {\r
- if ( this.IsObjectElement )\r
- {\r
- for ( var a in this.Attributes )\r
- {\r
- switch ( a.toLowerCase() )\r
- {\r
- case 'class' :\r
- elementToCheck.removeAttribute( 'className', 0 ) ;\r
- break ;\r
- default :\r
- elementToCheck.removeAttribute( a, 0 ) ;\r
- }\r
- }\r
- return ;\r
- }\r
- else\r
- FCKTools.RemoveOuterTags( elementToCheck ) ;\r
- }\r
- \r
- this._RemoveMe( oParent ) ;\r
-}
\ No newline at end of file