Вход Регистрация
Файл: fckeditor/editor/_source/internals/fckxhtml_ie.js
Строк: 245
<?php

/*
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * Defines the FCKXHtml object, responsible for the XHTML operations.
 * IE specific.
 */

FCKXHtml._GetMainXmlString = function()
{
    return 
this.MainNode.xml ;
}

FCKXHtml._AppendAttributes = function( xmlNodehtmlNodenodenodeName )
{
    var 
aAttributes htmlNode.attributes,
        
bHasStyle ;

    for ( var 
aAttributes.length n++ )
    {
        var 
oAttribute aAttributes[n] ;

        if ( 
oAttribute.specified )
        {
            var 
sAttName oAttribute.nodeName.toLowerCase() ;
            var 
sAttValue ;

            
// Ignore any attribute starting with "_fck".
            
if ( sAttName.StartsWith'_fck' ) )
                continue ;
            
// The following must be done because of a bug on IE regarding the style
            // attribute. It returns "null" for the nodeValue.
            
else if ( sAttName == 'style' )
            {
                
// Just mark it to do it later in this function.
                
bHasStyle true ;
                continue ;
            }
            
// There are two cases when the oAttribute.nodeValue must be used:
            //        - for the "class" attribute
            //        - for events attributes (on IE only).
            
else if ( sAttName == 'class' )
            {
                
sAttValue oAttribute.nodeValue.replaceFCKRegexLib.FCK_Class'' ) ;
                if ( 
sAttValue.length == )
                    continue ;
            }
            else if ( 
sAttName.indexOf('on') == )
                
sAttValue oAttribute.nodeValue ;
            else if ( 
nodeName == 'body' && sAttName == 'contenteditable' )
                continue ;
            
// XHTML doens't support attribute minimization like "CHECKED". It must be transformed to checked="checked".
            
else if ( oAttribute.nodeValue === true )
                
sAttValue sAttName ;
            else
            {
                
// We must use getAttribute to get it exactly as it is defined.
                // There are some rare cases that IE throws an error here, so we must try/catch.
                
try
                {
                    
sAttValue htmlNode.getAttributesAttName) ;
                }
                catch (
e) {}
            }
            
this._AppendAttributenodesAttNamesAttValue || oAttribute.nodeValue ) ;
        }
    }

    
// IE loses the style attribute in JavaScript-created elements tags. (#2390)
    
if ( bHasStyle || htmlNode.style.cssText.length )
    {
        var 
data FCKTools.ProtectFormStyleshtmlNode ) ;
        var 
sStyleValue htmlNode.style.cssText.replaceFCKRegexLib.StylePropertiesFCKTools.ToLowerCase ) ;
        
FCKTools.RestoreFormStyleshtmlNodedata ) ;
        
this._AppendAttributenode'style'sStyleValue ) ;
    }
}

// On very rare cases, IE is loosing the "align" attribute for DIV. (right align and apply bulleted list)
FCKXHtml.TagProcessors['div'] = function( nodehtmlNode )
{
    if ( 
htmlNode.align.length )
        
FCKXHtml._AppendAttributenode'align'htmlNode.align ) ;

    
node FCKXHtml._AppendChildNodesnodehtmlNodetrue ) ;

    return 
node ;
}

// IE automatically changes <FONT> tags to <FONT size=+0>.
FCKXHtml.TagProcessors['font'] = function( nodehtmlNode )
{
    if ( 
node.attributes.length == )
        
node FCKXHtml.XML.createDocumentFragment() ;

    
node FCKXHtml._AppendChildNodesnodehtmlNode ) ;

    return 
node ;
}

FCKXHtml.TagProcessors['form'] = function( nodehtmlNode )
{
    if ( 
htmlNode.acceptCharset && htmlNode.acceptCharset.length && htmlNode.acceptCharset != 'UNKNOWN' )
        
FCKXHtml._AppendAttributenode'accept-charset'htmlNode.acceptCharset ) ;

    
// IE has a bug and htmlNode.attributes['name'].specified=false if there is
    // no element with id="name" inside the form (#360 and SF-BUG-1155726).
    
var nameAtt htmlNode.attributes['name'] ;

    if ( 
nameAtt && nameAtt.value.length )
        
FCKXHtml._AppendAttributenode'name'nameAtt.value ) ;

    
node FCKXHtml._AppendChildNodesnodehtmlNodetrue ) ;

    return 
node ;
}

// IE doens't see the value attribute as an attribute for the <INPUT> tag.
FCKXHtml.TagProcessors['input'] = function( nodehtmlNode )
{
    if ( 
htmlNode.name )
        
FCKXHtml._AppendAttributenode'name'htmlNode.name ) ;

    if ( 
htmlNode.value && !node.attributes.getNamedItem'value' ) )
        
FCKXHtml._AppendAttributenode'value'htmlNode.value ) ;

    if ( !
node.attributes.getNamedItem'type' ) )
        
FCKXHtml._AppendAttributenode'type''text' ) ;

    return 
node ;
}

FCKXHtml.TagProcessors['label'] = function( nodehtmlNode )
{
    if ( 
htmlNode.htmlFor.length )
        
FCKXHtml._AppendAttributenode'for'htmlNode.htmlFor ) ;

    
node FCKXHtml._AppendChildNodesnodehtmlNode ) ;

    return 
node ;
}

// Fix behavior for IE, it doesn't read back the .name on newly created maps
FCKXHtml.TagProcessors['map'] = function( nodehtmlNode )
{
    if ( ! 
node.attributes.getNamedItem'name' ) )
    {
        var 
name htmlNode.name ;
        if ( 
name )
            
FCKXHtml._AppendAttributenode'name'name ) ;
    }

    
node FCKXHtml._AppendChildNodesnodehtmlNodetrue ) ;

    return 
node ;
}

FCKXHtml.TagProcessors['meta'] = function( nodehtmlNode )
{
    var 
oHttpEquiv node.attributes.getNamedItem'http-equiv' ) ;

    if ( 
oHttpEquiv == null || oHttpEquiv.value.length == )
    {
        
// Get the http-equiv value from the outerHTML.
        
var sHttpEquiv htmlNode.outerHTML.matchFCKRegexLib.MetaHttpEquiv ) ;

        if ( 
sHttpEquiv )
        {
            
sHttpEquiv sHttpEquiv[1] ;
            
FCKXHtml._AppendAttributenode'http-equiv'sHttpEquiv ) ;
        }
    }

    return 
node ;
}

// IE ignores the "SELECTED" attribute so we must add it manually.
FCKXHtml.TagProcessors['option'] = function( nodehtmlNode )
{
    if ( 
htmlNode.selected && !node.attributes.getNamedItem'selected' ) )
        
FCKXHtml._AppendAttributenode'selected''selected' ) ;

    
node FCKXHtml._AppendChildNodesnodehtmlNode ) ;

    return 
node ;
}

// IE doens't hold the name attribute as an attribute for the <TEXTAREA> and <SELECT> tags.
FCKXHtml.TagProcessors['textarea'] = FCKXHtml.TagProcessors['select'] = function( nodehtmlNode )
{
    if ( 
htmlNode.name )
        
FCKXHtml._AppendAttributenode'name'htmlNode.name ) ;

    
node FCKXHtml._AppendChildNodesnodehtmlNode ) ;

    return 
node ;
}
?>
Онлайн: 3
Реклама