Вход Регистрация
Файл: fckeditor/editor/_source/internals/fcklisthandler.js
Строк: 174
<?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 ==
 *
 * Tool object to manage HTML lists items (UL, OL and LI).
 */

var FCKListHandler =
{
    
OutdentListItem : function( listItem )
    {
        var 
eParent listItem.parentNode ;

        
// It may happen that a LI is not in a UL or OL (Orphan).
        
if ( eParent.tagName.toUpperCase().Equals'UL','OL' ) )
        {
            var 
oDocument FCKTools.GetElementDocumentlistItem ) ;
            var 
oDogFrag = new FCKDocumentFragmentoDocument ) ;

            
// All children and successive siblings will be moved to a a DocFrag.
            
var eNextSiblings oDogFrag.RootNode ;
            var 
eHasLiSibling false ;

            
// If we have nested lists inside it, let's move it to the list of siblings.
            
var eChildList FCKDomTools.GetFirstChildlistItem, ['UL','OL'] ) ;
            if ( 
eChildList )
            {
                
eHasLiSibling true ;

                var 
eChild ;
                
// The extra () is to avoid a warning with strict error checking. This is ok.
                
while ( (eChild eChildList.firstChild) )
                    
eNextSiblings.appendChildeChildList.removeChildeChild ) ) ;

                
FCKDomTools.RemoveNodeeChildList ) ;
            }

            
// Move all successive siblings.
            
var eSibling ;
            var 
eHasSuccessiveLiSibling false ;
            
// The extra () is to avoid a warning with strict error checking. This is ok.
            
while ( (eSibling listItem.nextSibling) )
            {
                if ( !
eHasLiSibling && eSibling.nodeType == && eSibling.nodeName.toUpperCase() == 'LI' )
                    
eHasSuccessiveLiSibling eHasLiSibling true ;

                
eNextSiblings.appendChildeSibling.parentNode.removeChildeSibling ) ) ;

                
// If a sibling is a incorrectly nested UL or OL, consider only its children.
                
if ( !eHasSuccessiveLiSibling && eSibling.nodeType == && eSibling.nodeName.toUpperCase().Equals'UL','OL' ) )
                    
FCKDomTools.RemoveNodeeSiblingtrue ) ;
            }

            
// If we are in a list chain.
            
var sParentParentTag eParent.parentNode.tagName.toUpperCase() ;
            var 
bWellNested = ( sParentParentTag == 'LI' ) ;
            if ( 
bWellNested || sParentParentTag.Equals'UL','OL' ) )
            {
                if ( 
eHasLiSibling )
                {
                    var 
eChildList eParent.cloneNodefalse ) ;
                    
oDogFrag.AppendToeChildList ) ;
                    
listItem.appendChildeChildList ) ;
                }
                else if ( 
bWellNested )
                    
oDogFrag.InsertAfterNodeeParent.parentNode ) ;
                else
                    
oDogFrag.InsertAfterNodeeParent ) ;

                
// Move the LI after its parent.parentNode (the upper LI in the hierarchy).
                
if ( bWellNested )
                    
FCKDomTools.InsertAfterNodeeParent.parentNodeeParent.removeChildlistItem ) ) ;
                else
                    
FCKDomTools.InsertAfterNodeeParenteParent.removeChildlistItem ) ) ;
            }
            else
            {
                if ( 
eHasLiSibling )
                {
                    var 
eNextList eParent.cloneNodefalse ) ;
                    
oDogFrag.AppendToeNextList ) ;
                    
FCKDomTools.InsertAfterNodeeParenteNextList ) ;
                }

                var 
eBlock oDocument.createElementFCKConfig.EnterMode == 'p' 'p' 'div' ) ;
                
FCKDomTools.MoveChildreneParent.removeChildlistItem ), eBlock ) ;
                
FCKDomTools.InsertAfterNodeeParenteBlock ) ;

                if ( 
FCKConfig.EnterMode == 'br' )
                {
                    
// We need the bogus to make it work properly. In Gecko, we
                    // need it before the new block, on IE, after it.
                    
if ( FCKBrowserInfo.IsGecko )
                        
eBlock.parentNode.insertBeforeFCKTools.CreateBogusBRoDocument ), eBlock ) ;
                    else
                        
FCKDomTools.InsertAfterNodeeBlockFCKTools.CreateBogusBRoDocument ) ) ;

                    
FCKDomTools.RemoveNodeeBlocktrue ) ;
                }
            }

            if ( 
this.CheckEmptyListeParent ) )
                
FCKDomTools.RemoveNodeeParenttrue ) ;
        }
    },

    
CheckEmptyList : function( listElement )
    {
        return ( 
FCKDomTools.GetFirstChildlistElement'LI' ) == null ) ;
    },

    
// Check if the list has contents (excluding nested lists).
    
CheckListHasContents : function( listElement )
    {
        var 
eChildNode listElement.firstChild ;

        while ( 
eChildNode )
        {
            switch ( 
eChildNode.nodeType )
            {
                case 
:
                    if ( !
eChildNode.nodeName.IEquals'UL','LI' ) )
                        return 
true ;
                    break ;

                case 
:
                    if ( 
eChildNode.nodeValue.Trim().length )
                        return 
true ;
            }

            
eChildNode eChildNode.nextSibling ;
        }

        return 
false ;
    }
} ;
?>
Онлайн: 0
Реклама