Вход Регистрация
Файл: fckeditor/editor/_source/internals/fckdocumentprocessor.js
Строк: 327
<?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 ==
 *
 * Advanced document processors.
 */

var FCKDocumentProcessor = new Object() ;
FCKDocumentProcessor._Items = new Array() ;

FCKDocumentProcessor.AppendNew = function()
{
    var 
oNewItem = new Object() ;
    
this._Items.AddItemoNewItem ) ;
    return 
oNewItem ;
}

FCKDocumentProcessor.Process = function( document )
{
    var 
bIsDirty FCK.IsDirty() ;
    var 
oProcessor;
    while( ( 
oProcessor this._Items[i++] ) )
        
oProcessor.ProcessDocumentdocument ) ;
    if ( !
bIsDirty )
        
FCK.ResetIsDirty() ;
}

var 
FCKDocumentProcessor_CreateFakeImage = function( fakeClassrealElement )
{
    var 
oImg FCKTools.GetElementDocumentrealElement ).createElement'IMG' ) ;
    
oImg.className fakeClass ;
    
oImg.src FCKConfig.BasePath 'images/spacer.gif' ;
    
oImg.setAttribute'_fckfakelement''true') ;
    
oImg.setAttribute'_fckrealelement'FCKTempBin.AddElementrealElement ), ) ;
    return 
oImg ;
}

// Link Anchors
if ( FCKBrowserInfo.IsIE || FCKBrowserInfo.IsOpera )
{
    var 
FCKAnchorsProcessor FCKDocumentProcessor.AppendNew() ;
    
FCKAnchorsProcessor.ProcessDocument = function( document )
    {
        var 
aLinks document.getElementsByTagName'A' ) ;

        var 
oLink ;
        var 
aLinks.length ;
        while ( 
>= && ( oLink aLinks[i--] ) )
        {
            
// If it is anchor. Doesn't matter if it's also a link (even better: we show that it's both a link and an anchor)
            
if ( oLink.name.length )
            {
                
//if the anchor has some content then we just add a temporary class
                
if ( oLink.innerHTML !== '' )
                {
                    if ( 
FCKBrowserInfo.IsIE )
                        
oLink.className += ' FCK__AnchorC' ;
                }
                else
                {
                    var 
oImg FCKDocumentProcessor_CreateFakeImage'FCK__Anchor'oLink.cloneNode(true) ) ;
                    
oImg.setAttribute'_fckanchor''true') ;

                    
oLink.parentNode.insertBeforeoImgoLink ) ;
                    
oLink.parentNode.removeChildoLink ) ;
                }
            }
        }
    }
}

// Page Breaks
var FCKPageBreaksProcessor FCKDocumentProcessor.AppendNew() ;
FCKPageBreaksProcessor.ProcessDocument = function( document )
{
    var 
aDIVs document.getElementsByTagName'DIV' ) ;

    var 
eDIV ;
    var 
aDIVs.length ;
    while ( 
>= && ( eDIV aDIVs[i--] ) )
    {
        if ( 
eDIV.style.pageBreakAfter == 'always' && eDIV.childNodes.length == && eDIV.childNodes[0].style && eDIV.childNodes[0].style.display == 'none' )
        {
            var 
oFakeImage FCKDocumentProcessor_CreateFakeImage'FCK__PageBreak'eDIV.cloneNode(true) ) ;

            
eDIV.parentNode.insertBeforeoFakeImageeDIV ) ;
            
eDIV.parentNode.removeChildeDIV ) ;
        }
    }
/*
    var aCenters = document.getElementsByTagName( 'CENTER' ) ;

    var oCenter ;
    var i = aCenters.length - 1 ;
    while ( i >= 0 && ( oCenter = aCenters[i--] ) )
    {
        if ( oCenter.style.pageBreakAfter == 'always' && oCenter.innerHTML.Trim().length == 0 )
        {
            var oFakeImage = FCKDocumentProcessor_CreateFakeImage( 'FCK__PageBreak', oCenter.cloneNode(true) ) ;

            oCenter.parentNode.insertBefore( oFakeImage, oCenter ) ;
            oCenter.parentNode.removeChild( oCenter ) ;
        }
    }
*/
}

// EMBED and OBJECT tags.
FCKEmbedAndObjectProcessor = (function()
{
    var 
customProcessors = [] ;

    var 
processElement = function( el )
    {
        var clone = 
el.cloneNodetrue ) ;
        var 
replaceElement ;
        var 
fakeImg replaceElement FCKDocumentProcessor_CreateFakeImage'FCK__UnknownObject', clone ) ;
        
FCKEmbedAndObjectProcessor.RefreshViewfakeImgel ) ;

        for ( var 
customProcessors.length i++ )
            
replaceElement customProcessors[i]( elreplaceElement ) || replaceElement ;

        if ( 
replaceElement != fakeImg )
            
FCKTempBin.RemoveElementfakeImg.getAttribute'_fckrealelement' ) ) ;

        
el.parentNode.replaceChildreplaceElementel ) ;
    }

    var 
processElementsByName = function( elementNamedoc )
    {
        var 
aObjects doc.getElementsByTagNameelementName );
        for ( var 
aObjects.length >= i-- )
            
processElementaObjects[i] ) ;
    }

    var 
processObjectAndEmbed = function( doc )
    {
        
processElementsByName'object'doc );
        
processElementsByName'embed'doc );
    }

    return 
FCKTools.MergeFCKDocumentProcessor.AppendNew(),
               {
                
ProcessDocument : function( doc )
                {
                    
// Firefox 3 would sometimes throw an unknown exception while accessing EMBEDs and OBJECTs
                    // without the setTimeout().
                    
if ( FCKBrowserInfo.IsGecko )
                        
FCKTools.RunFunctionprocessObjectAndEmbedthis, [ doc ] ) ;
                    else
                        
processObjectAndEmbeddoc ) ;
                },

                
RefreshView : function( placeHolderoriginal )
                {
                    if ( 
original.getAttribute'width' ) > )
                        
placeHolder.style.width FCKTools.ConvertHtmlSizeToStyleoriginal.getAttribute'width' ) ) ;

                    if ( 
original.getAttribute'height' ) > )
                        
placeHolder.style.height FCKTools.ConvertHtmlSizeToStyleoriginal.getAttribute'height' ) ) ;
                },

                
AddCustomHandler : function( func )
                {
                    
customProcessors.pushfunc ) ;
                }
            } ) ;
} )() ;

FCK.GetRealElement = function( fakeElement )
{
    var 
FCKTempBin.ElementsfakeElement.getAttribute('_fckrealelement') ] ;

    if ( 
fakeElement.getAttribute('_fckflash') )
    {
        if ( 
fakeElement.style.width.length )
                
e.width FCKTools.ConvertStyleSizeToHtmlfakeElement.style.width ) ;

        if ( 
fakeElement.style.height.length )
                
e.height FCKTools.ConvertStyleSizeToHtmlfakeElement.style.height ) ;
    }

    return 
;
}

// HR Processor.
// This is a IE only (tricky) thing. We protect all HR tags before loading them
// (see FCK.ProtectTags). Here we put the HRs back.
if ( FCKBrowserInfo.IsIE )
{
    
FCKDocumentProcessor.AppendNew().ProcessDocument = function( document )
    {
        var 
aHRs document.getElementsByTagName'HR' ) ;

        var 
eHR ;
        var 
aHRs.length ;
        while ( 
>= && ( eHR aHRs[i--] ) )
        {
            
// Create the replacement HR.
            
var newHR document.createElement'hr' ) ;
            
newHR.mergeAttributeseHRtrue ) ;

            
// We must insert the new one after it. insertBefore will not work in all cases.
            
FCKDomTools.InsertAfterNodeeHRnewHR ) ;

            
eHR.parentNode.removeChildeHR ) ;
        }
    }
}

// INPUT:hidden Processor.
FCKDocumentProcessor.AppendNew().ProcessDocument = function( document )
{
    var 
aInputs document.getElementsByTagName'INPUT' ) ;

    var 
oInput ;
    var 
aInputs.length ;
    while ( 
>= && ( oInput aInputs[i--] ) )
    {
        if ( 
oInput.type == 'hidden' )
        {
            var 
oImg FCKDocumentProcessor_CreateFakeImage'FCK__InputHidden'oInput.cloneNode(true) ) ;
            
oImg.setAttribute'_fckinputhidden''true') ;

            
oInput.parentNode.insertBeforeoImgoInput ) ;
            
oInput.parentNode.removeChildoInput ) ;
        }
    }
}

// Flash handler.
FCKEmbedAndObjectProcessor.AddCustomHandler( function( elfakeImg )
    {
        if ( ! ( 
el.nodeName.IEquals'embed' ) && ( el.type == 'application/x-shockwave-flash' || /.swf($|#|?)/i.test( el.src ) ) ) )
            
return ;
        
fakeImg.className 'FCK__Flash' ;
        
fakeImg.setAttribute'_fckflash''true');
    } ) ;

// Buggy <span class="Apple-style-span"> tags added by Safari.
if ( FCKBrowserInfo.IsSafari )
{
    
FCKDocumentProcessor.AppendNew().ProcessDocument = function( doc )
    {
        var 
spans doc.getElementsByClassName ?
            
doc.getElementsByClassName'Apple-style-span' ) :
            Array.
prototype.filter.call(
                    
doc.getElementsByTagName'span' ),
                    function( 
item ){ return item.className == 'Apple-style-span' ; }
                    ) ;
        for ( var 
spans.length >= i-- )
            
FCKDomTools.RemoveNodespans[i], true ) ;
    }
}
?>
Онлайн: 0
Реклама