2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fckstyledef_ie.js
14
* FCKStyleDef Class: represents a single stylke definition. (IE specific)
17
* Frederico Caldeira Knabben (fredck@fckeditor.net)
20
FCKStyleDef.prototype.ApplyToSelection = function()
22
var oSelection = FCK.EditorDocument.selection ;
24
if ( oSelection.type == 'Text' )
26
var oRange = oSelection.createRange() ;
28
// Create the main element.
29
var e = document.createElement( this.Element ) ;
30
e.innerHTML = oRange.htmlText ;
32
// Set the attributes.
33
this._AddAttributes( e ) ;
35
// Remove the duplicated elements.
36
this._RemoveDuplicates( e ) ;
38
// Replace the selection with the resulting HTML.
39
oRange.pasteHTML( e.outerHTML ) ;
41
else if ( oSelection.type == 'Control' )
43
var oControl = FCKSelection.GetSelectedElement() ;
44
if ( oControl.tagName == this.Element )
45
this._AddAttributes( oControl ) ;
49
FCKStyleDef.prototype._AddAttributes = function( targetElement )
51
for ( var a in this.Attributes )
53
switch ( a.toLowerCase() )
56
targetElement.style.cssText = this.Attributes[a] ;
60
targetElement.setAttribute( 'className', this.Attributes[a], 0 ) ;
64
targetElement.setAttribute( a, this.Attributes[a], 0 ) ;
69
FCKStyleDef.prototype._RemoveDuplicates = function( parent )
71
for ( var i = 0 ; i < parent.children.length ; i++ )
73
var oChild = parent.children[i] ;
74
this._RemoveDuplicates( oChild ) ;
76
if ( this.IsEqual( oChild ) )
77
FCKTools.RemoveOuterTags( oChild ) ;
81
FCKStyleDef.prototype.IsEqual = function( e )
83
if ( e.tagName != this.Element )
86
for ( var a in this.Attributes )
88
switch ( a.toLowerCase() )
91
if ( e.style.cssText.toLowerCase() != this.Attributes[a].toLowerCase() )
95
if ( e.getAttribute( 'className', 0 ) != this.Attributes[a] )
99
if ( e.getAttribute( a, 0 ) != this.Attributes[a] )
107
FCKStyleDef.prototype._RemoveMe = function( elementToCheck )
109
if ( ! elementToCheck )
112
var oParent = elementToCheck.parentElement ;
114
if ( this.IsEqual( elementToCheck ) )
116
if ( this.IsObjectElement )
118
for ( var a in this.Attributes )
120
switch ( a.toLowerCase() )
123
elementToCheck.removeAttribute( 'className', 0 ) ;
126
elementToCheck.removeAttribute( a, 0 ) ;
132
FCKTools.RemoveOuterTags( elementToCheck ) ;
135
this._RemoveMe( oParent ) ;
b'\\ No newline at end of file'