phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] news_admin/js/fckeditor/editor/_source/commandclasse


From: skwashd
Subject: [Phpgroupware-cvs] news_admin/js/fckeditor/editor/_source/commandclasses fcktextcolorcommand.js, 1.1 fcktablecommand.js, 1.1 fckstylecommand.js, 1.1 fckpasteplaintextcommand.js, 1.1 fckpastewordcommand.js, 1.1 fckspellcheckcommand_gecko.js, 1.1 fckspellcheckcommand_ie.js, 1.1 fcknamedcommand.js, 1.1 fck_othercommands.js, 1.1
Date: Tue, 24 May 2005 16:32:00 +0200

Update of news_admin/js/fckeditor/editor/_source/commandclasses

Added Files:
     Branch: MAIN
            fcktextcolorcommand.js 
            fcktablecommand.js 
            fckstylecommand.js 
            fckpasteplaintextcommand.js 
            fckpastewordcommand.js 
            fckspellcheckcommand_gecko.js 
            fckspellcheckcommand_ie.js 
            fcknamedcommand.js 
            fck_othercommands.js 

Log Message:
I am working on a much better version of news_admin, this is just a taste of 
what is coming.

Adding FCKeditor, which has the following issues:
* Images and files support FCKd
* Spellcheck FCKing up

Didn't include non php code or samples other unneeded crap

====================================================
Index: fcktextcolorcommand.js
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2004 Frederico Caldeira Knabben
 *
 * Licensed under the terms of the GNU Lesser General Public License:
 *              http://www.opensource.org/licenses/lgpl-license.php
 *
 * For further information visit:
 *              http://www.fckeditor.net/
 *
 * File Name: fcktextcolorcommand.js
 *      FCKTextColorCommand Class: represents the text color comand. It shows 
the
 *      color selection panel.
 *
 * Version:  2.0 RC3
 * Modified: 2004-11-19 08:16:00
 *
 * File Authors:
 *              Frederico Caldeira Knabben (address@hidden)
 */

// FCKTextColorCommand Contructor
//              type: can be 'ForeColor' or 'BackColor'.
var FCKTextColorCommand = function( type )
{
        this.Name = type == 'ForeColor' ? 'TextColor' : 'BGColor' ;
        this.Type = type ;

        /*      BEGIN ###
                The panel should be created in the "Execute" method for best
                memory use, but it not works in Gecko in that way.
        */

        this._Panel = new FCKPanel() ;
        this._Panel.StyleSheet = FCKConfig.SkinPath + 'fck_contextmenu.css' ;
        this._Panel.Create() ;

        this._CreatePanelBody( this._Panel.Document, this._Panel.PanelDiv ) ;

        //      END ###
}

FCKTextColorCommand.prototype.Execute = function( panelX, panelY, relElement )
{
        /*
                BEGIN ###
                This is the right code to create the panel, but it is not
                working well with Gecko, so it has been moved to the
                class contructor.

        // Create the Color Panel if needed.
        if ( ! this._Panel )
        {
                this._Panel = new FCKPanel() ;
                this._Panel.StyleSheet = FCKConfig.SkinPath + 
'fck_contextmenu.css' ;
                this._Panel.Create() ;

                this._CreatePanelBody( this._Panel.Document, 
this._Panel.PanelDiv ) ;
        }
                END ###
        */

        // We must "cache" the actual panel type to be used in the SetColor 
method.
        FCK._ActiveColorPanelType = this.Type ;

        // Show the Color Panel at the desired position.
        this._Panel.Show( panelX, panelY, relElement ) ;
}

FCKTextColorCommand.prototype.SetColor = function( color )
{
        if ( FCK._ActiveColorPanelType == 'ForeColor' )
                FCK.ExecuteNamedCommand( 'ForeColor', color ) ;
        else if ( FCKBrowserInfo.IsGecko )
                FCK.ExecuteNamedCommand( 'hilitecolor', color ) ;
        else
                FCK.ExecuteNamedCommand( 'BackColor', color ) ;

        // Delete the "cached" active panel type.
        delete FCK._ActiveColorPanelType ;
}

FCKTextColorCommand.prototype.GetState = function()
{
        return FCK_TRISTATE_OFF ;
}

FCKTextColorCommand.prototype._CreatePanelBody = function( targetDocument, 
targetDiv )
{
        function CreateSelectionDiv()
        {
                var oDiv = targetDocument.createElement( "DIV" ) ;
                oDiv.className = 'ColorDeselected' ;
                oDiv.onmouseover        = function() { 
this.className='ColorSelected' ; } ;
                oDiv.onmouseout         = function() { 
this.className='ColorDeselected' ; } ;

                return oDiv ;
        }

        // Create the Table that will hold all colors.
        var oTable = targetDiv.appendChild( targetDocument.createElement( 
"TABLE" ) ) ;
        oTable.style.tableLayout = 'fixed' ;
        oTable.cellPadding = 0 ;
        oTable.cellSpacing = 0 ;
        oTable.border = 0 ;
        oTable.width = 150 ;

        var oCell = oTable.insertRow(-1).insertCell(-1) ;
        oCell.colSpan = 8 ;

        // Create the Button for the "Automatic" color selection.
        var oDiv = oCell.appendChild( CreateSelectionDiv() ) ;
        oDiv.innerHTML =
                '<table cellspacing="0" cellpadding="0" width="100%" 
border="0">\
                        <tr>\
                                <td><div class="ColorBoxBorder"><div 
class="ColorBox" style="background-color: #000000"></div></div></td>\
                                <td nowrap width="100%" align="center" 
unselectable="on">' + FCKLang.ColorAutomatic + '</td>\
                        </tr>\
                </table>' ;

        oDiv.Command = this ;
        oDiv.onclick = function()
        {
                this.className = 'ColorDeselected' ;
                this.Command.SetColor( '' ) ;
                this.Command._Panel.Hide() ;
        }

        // Create an array of colors based on the configuration file.
        var aColors = FCKConfig.FontColors.split(',') ;

        // Create the colors table based on the array.
        var iCounter = 0 ;
        while ( iCounter < aColors.length )
        {
                var oRow = oTable.insertRow(-1) ;

                for ( var i = 0 ; i < 8 && iCounter < aColors.length ; i++, 
iCounter++ )
                {
                        var oDiv = oRow.insertCell(-1).appendChild( 
CreateSelectionDiv() ) ;
                        oDiv.Color = aColors[iCounter] ;
                        oDiv.innerHTML = '<div class="ColorBoxBorder"><div 
class="ColorBox" style="background-color: #' + aColors[iCounter] + 
'"></div></div>' ;

                        oDiv.Command = this ;
                        oDiv.onclick = function()
                        {
                                this.className = 'ColorDeselected' ;
                                this.Command.SetColor( '#' + this.Color ) ;
                                this.Command._Panel.Hide() ;
                        }
                }
        }

        // Create the Row and the Cell for the "More Colors..." button.
        var oCell = oTable.insertRow(-1).insertCell(-1) ;
        oCell.colSpan = 8 ;

        var oDiv = oCell.appendChild( CreateSelectionDiv() ) ;
        oDiv.innerHTML = '<table width="100%" cellpadding="0" cellspacing="0" 
border="0"><tr><td nowrap align="center">' + FCKLang.ColorMoreColors + 
'</td></tr></table>' ;

        oDiv.Command = this ;
        oDiv.onclick = function()
        {
                this.className = 'ColorDeselected' ;
                this.Command._Panel.Hide() ;
                FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 
'dialog/fck_colorselector.html', 400, 330, this.Command.SetColor ) ;
        }
}

====================================================
Index: fcktablecommand.js
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2004 Frederico Caldeira Knabben
 *
 * Licensed under the terms of the GNU Lesser General Public License:
 *              http://www.opensource.org/licenses/lgpl-license.php
 *
 * For further information visit:
 *              http://www.fckeditor.net/
 *
 * File Name: fcktablecommand.js
 *      FCKPastePlainTextCommand Class: represents the
 *      "Paste as Plain Text" command.
 *
 * Version:  2.0 RC3
 * Modified: 2004-11-22 15:41:58
 *
 * File Authors:
 *              Frederico Caldeira Knabben (address@hidden)
 */

var FCKTableCommand = function( command )
{
        this.Name = command ;
}

FCKTableCommand.prototype.Execute = function()
{
        switch ( this.Name )
        {
                case 'TableInsertRow' :
                        FCKTableHandler.InsertRow() ;
                        break ;
                case 'TableDeleteRows' :
                        FCKTableHandler.DeleteRows() ;
                        break ;
                case 'TableInsertColumn' :
                        FCKTableHandler.InsertColumn() ;
                        break ;
                case 'TableDeleteColumns' :
                        FCKTableHandler.DeleteColumns() ;
                        break ;
                case 'TableInsertCell' :
                        FCKTableHandler.InsertCell() ;
                        break ;
                case 'TableDeleteCells' :
                        FCKTableHandler.DeleteCells() ;
                        break ;
                case 'TableMergeCells' :
                        FCKTableHandler.MergeCells() ;
                        break ;
                case 'TableSplitCell' :
                        FCKTableHandler.SplitCell() ;
                        break ;
                default :
                        alert( FCKLang.UnknownCommand.replace( /%1/g, this.Name 
) ) ;
        }
}

FCKTableCommand.prototype.GetState = function()
{
        return FCK_TRISTATE_OFF ;
}

====================================================
Index: fckstylecommand.js
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2004 Frederico Caldeira Knabben
 *
 * Licensed under the terms of the GNU Lesser General Public License:
 *              http://www.opensource.org/licenses/lgpl-license.php
 *
 * For further information visit:
 *              http://www.fckeditor.net/
 *
 * File Name: fckstylecommand.js
 *      FCKStyleCommand Class: represents the "Style" command.
 *
 * Version:  2.0 RC3
 * Modified: 2004-11-22 11:07:24
 *
 * File Authors:
 *              Frederico Caldeira Knabben (address@hidden)
 */

var FCKStyleCommand = function()
{
        this.Name = 'Style' ;

        // Load the Styles defined in the XML file.
        this.StylesLoader = new FCKStylesLoader() ;
        this.StylesLoader.Load( FCKConfig.StylesXmlPath ) ;
        this.Styles = this.StylesLoader.Styles ;
}

FCKStyleCommand.prototype.Execute = function( styleName, styleComboItem )
{
        if ( styleComboItem.Selected )
                styleComboItem.Style.RemoveFromSelection() ;
        else
                styleComboItem.Style.ApplyToSelection() ;

        FCK.Focus() ;

        FCK.Events.FireEvent( "OnSelectionChange" ) ;
}

FCKStyleCommand.prototype.GetState = function()
{
        var oSelection = FCK.EditorDocument.selection ;

        if ( FCKSelection.GetType() == 'Control' )
        {
                var e = FCKSelection.GetSelectedElement() ;
                        if ( e )
                                return this.StylesLoader.StyleGroups[ e.tagName 
] ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ;
                        else
                                FCK_TRISTATE_OFF ;
        }
        else
                return FCK_TRISTATE_OFF ;
}

FCKStyleCommand.prototype.GetActiveStyles = function()
{
        var aActiveStyles = new Array() ;

        if ( FCKSelection.GetType() == 'Control' )
                this._CheckStyle( FCKSelection.GetSelectedElement(), 
aActiveStyles, false ) ;
        else
                this._CheckStyle( FCKSelection.GetParentElement(), 
aActiveStyles, true ) ;

        return aActiveStyles ;
}

FCKStyleCommand.prototype._CheckStyle = function( element, targetArray, 
checkParent )
{
        if ( ! element )
                return ;

        if ( element.nodeType == 1 )
        {
                var aStyleGroup = this.StylesLoader.StyleGroups[ 
element.tagName ] ;
                if ( aStyleGroup )
                {
                        for ( var i = 0 ; i < aStyleGroup.length ; i++ )
                        {
                                if ( aStyleGroup[i].IsEqual( element ) )
                                        targetArray[ targetArray.length ] = 
aStyleGroup[i] ;
                        }
                }
        }

        if ( checkParent )
                this._CheckStyle( element.parentNode, targetArray, checkParent 
) ;
}

====================================================
Index: fckpasteplaintextcommand.js
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2004 Frederico Caldeira Knabben
 *
 * Licensed under the terms of the GNU Lesser General Public License:
 *              http://www.opensource.org/licenses/lgpl-license.php
 *
 * For further information visit:
 *              http://www.fckeditor.net/
 *
 * File Name: fckpasteplaintextcommand.js
 *      FCKPastePlainTextCommand Class: represents the
 *      "Paste as Plain Text" command.
 *
 * Version:  2.0 RC3
 * Modified: 2004-08-20 23:08:23
 *
 * File Authors:
 *              Frederico Caldeira Knabben (address@hidden)
 */

var FCKPastePlainTextCommand = function()
{
        this.Name = 'PasteText' ;
}

FCKPastePlainTextCommand.prototype.Execute = function()
{
        FCK.PasteAsPlainText() ;
}

FCKPastePlainTextCommand.prototype.GetState = function()
{
        return FCK.GetNamedCommandState( 'Paste' ) ;
}

====================================================
Index: fckpastewordcommand.js
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2004 Frederico Caldeira Knabben
 *
 * Licensed under the terms of the GNU Lesser General Public License:
 *              http://www.opensource.org/licenses/lgpl-license.php
 *
 * For further information visit:
 *              http://www.fckeditor.net/
 *
 * File Name: fckpastewordcommand.js
 *      FCKPasteWordCommand Class: represents the "Paste from Word" command.
 *
 * Version:  2.0 RC3
 * Modified: 2004-08-30 23:20:46
 *
 * File Authors:
 *              Frederico Caldeira Knabben (address@hidden)
 */

var FCKPasteWordCommand = function()
{
        this.Name = 'PasteWord' ;
}

FCKPasteWordCommand.prototype.Execute = function()
{
        FCK.PasteFromWord() ;
}

FCKPasteWordCommand.prototype.GetState = function()
{
        return FCK.GetNamedCommandState( 'Paste' ) ;
}

====================================================
Index: fckspellcheckcommand_gecko.js
var FCKSpellCheckCommand = function()
{
        this.Name = 'SpellCheck' ;
        this.IsEnabled = ( FCKConfig.SpellChecker == 'SpellerPages' ) ;
}

FCKSpellCheckCommand.prototype.Execute = function()
{
        FCKDialog.OpenDialog( 'FCKDialog_SpellCheck', 'Spell Check', 
'dialog/fck_spellerpages.html', 440, 480 ) ;
}

FCKSpellCheckCommand.prototype.GetState = function()
{
        return this.IsEnabled ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ;
}

====================================================
Index: fckspellcheckcommand_ie.js
var FCKSpellCheckCommand = function()
{
        this.Name = 'SpellCheck' ;
        this.IsEnabled = ( FCKConfig.SpellChecker == 'ieSpell' || 
FCKConfig.SpellChecker == 'SpellerPages' ) ;
}

FCKSpellCheckCommand.prototype.Execute = function()
{
        switch ( FCKConfig.SpellChecker )
        {
                case 'ieSpell' :
                        this._RunIeSpell() ;
                        break ;

                case 'SpellerPages' :
                        FCKDialog.OpenDialog( 'FCKDialog_SpellCheck', 'Spell 
Check', 'dialog/fck_spellerpages.html', 440, 480 ) ;
                        break ;
        }
}

FCKSpellCheckCommand.prototype._RunIeSpell = function()
{
        try
        {
                var oIeSpell = new ActiveXObject( "ieSpell.ieSpellExtension" ) ;
                oIeSpell.CheckAllLinkedDocuments( FCK.EditorDocument ) ;
        }
        catch( e )
        {
                if( e.number == -2146827859 )
                {
                        if ( confirm( FCKLang.IeSpellDownload ) )
                                window.open( FCKConfig.IeSpellDownloadUrl , 
'IeSpellDownload' ) ;
                }
                else
                        alert( 'Error Loading ieSpell: ' + e.message + ' (' + 
e.number + ')' ) ;
        }
}

FCKSpellCheckCommand.prototype.GetState = function()
{
        return this.IsEnabled ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ;
}

====================================================
Index: fcknamedcommand.js
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2004 Frederico Caldeira Knabben
 *
 * Licensed under the terms of the GNU Lesser General Public License:
 *              http://www.opensource.org/licenses/lgpl-license.php
 *
 * For further information visit:
 *              http://www.fckeditor.net/
 *
 * File Name: fcknamedcommand.js
 *      FCKNamedCommand Class: represents an internal browser command.
 *
 * Version:  2.0 RC3
 * Modified: 2004-08-17 15:05:35
 *
 * File Authors:
 *              Frederico Caldeira Knabben (address@hidden)
 */

var FCKNamedCommand = function( commandName )
{
        this.Name = commandName ;
}

FCKNamedCommand.prototype.Execute = function()
{
        FCK.ExecuteNamedCommand( this.Name ) ;
}

FCKNamedCommand.prototype.GetState = function()
{
        return FCK.GetNamedCommandState( this.Name ) ;
}


====================================================
Index: fck_othercommands.js
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2004 Frederico Caldeira Knabben
 *
 * Licensed under the terms of the GNU Lesser General Public License:
 *              http://www.opensource.org/licenses/lgpl-license.php
 *
 * For further information visit:
 *              http://www.fckeditor.net/
 *
 * File Name: fck_othercommands.js
 *      Definition of other commands that are not available internaly in the
 *      browser (see FCKNamedCommand).
 *
 * Version:  2.0 RC3
 * Modified: 2005-01-04 18:39:05
 *
 * File Authors:
 *              Frederico Caldeira Knabben (address@hidden)
 */

// ### General Dialog Box Commands.
var FCKDialogCommand = function( name, title, url, width, height, 
getStateFunction, getStateParam )
{
        this.Name       = name ;
        this.Title      = title ;
        this.Url        = url ;
        this.Width      = width ;
        this.Height     = height ;

        this.GetStateFunction   = getStateFunction ;
        this.GetStateParam              = getStateParam ;
}

FCKDialogCommand.prototype.Execute = function()
{
        FCKDialog.OpenDialog( 'FCKDialog_' + this.Name , this.Title, this.Url, 
this.Width, this.Height ) ;
}

FCKDialogCommand.prototype.GetState = function()
{
        if ( this.GetStateFunction )
                return this.GetStateFunction( this.GetStateParam ) ;
        else
                return FCK_TRISTATE_OFF ;
}

// Generic Undefined command (usually used when a command is under development).
var FCKUndefinedCommand = function()
{
        this.Name = 'Undefined' ;
}

FCKUndefinedCommand.prototype.Execute = function()
{
        alert( FCKLang.NotImplemented ) ;
}

FCKUndefinedCommand.prototype.GetState = function()
{
        return FCK_TRISTATE_OFF ;
}

// ### FontName
var FCKFontNameCommand = function()
{
        this.Name = 'FontName' ;
}

FCKFontNameCommand.prototype.Execute = function( fontName )
{
        if (fontName == null || fontName == "")
        {
                // TODO: Remove font name attribute.
        }
        else
                FCK.ExecuteNamedCommand( 'FontName', fontName ) ;
}

FCKFontNameCommand.prototype.GetState = function()
{
        return FCK.GetNamedCommandValue( 'FontName' ) ;
}

// ### FontSize
var FCKFontSizeCommand = function()
{
        this.Name = 'FontSize' ;
}

FCKFontSizeCommand.prototype.Execute = function( fontSize )
{
        if ( typeof( fontSize ) == 'string' ) fontSize = parseInt(fontSize) ;

        if ( fontSize == null || fontSize == '' )
        {
                // TODO: Remove font size attribute (Now it works with size 3. 
Will it work forever?)
                FCK.ExecuteNamedCommand( 'FontSize', 3 ) ;
        }
        else
                FCK.ExecuteNamedCommand( 'FontSize', fontSize ) ;
}

FCKFontSizeCommand.prototype.GetState = function()
{
        return FCK.GetNamedCommandValue( 'FontSize' ) ;
}

// ### FormatBlock
var FCKFormatBlockCommand = function()
{
        this.Name = 'FormatBlock' ;
}

FCKFormatBlockCommand.prototype.Execute = function( formatName )
{
        if ( formatName == null || formatName == '' )
                FCK.ExecuteNamedCommand( 'FormatBlock', '<P>' ) ;
        else
                FCK.ExecuteNamedCommand( 'FormatBlock', '<' + formatName + '>' 
) ;
}

FCKFormatBlockCommand.prototype.GetState = function()
{
        return FCK.GetNamedCommandValue( 'FormatBlock' ) ;
}

// ### Preview
var FCKPreviewCommand = function()
{
        this.Name = 'Preview' ;
}

FCKPreviewCommand.prototype.Execute = function()
{
     FCK.Preview() ;
}

FCKPreviewCommand.prototype.GetState = function()
{
        return FCK_TRISTATE_OFF ;
}

// ### Save
var FCKSaveCommand = function()
{
        this.Name = 'Save' ;
}

FCKSaveCommand.prototype.Execute = function()
{
        // Get the linked field form.
        var oForm = FCK.LinkedField.form ;

        // Submit the form.
        oForm.submit() ;
}

FCKSaveCommand.prototype.GetState = function()
{
        return FCK_TRISTATE_OFF ;
}

// ### NewPage
var FCKNewPageCommand = function()
{
        this.Name = 'NewPage' ;
}

FCKNewPageCommand.prototype.Execute = function()
{
        FCK.SetHTML( FCKBrowserInfo.IsGecko ? '&nbsp;' : '' ) ;
}

FCKNewPageCommand.prototype.GetState = function()
{
        return FCK_TRISTATE_OFF ;
}

// ### Source button
var FCKSourceCommand = function()
{
        this.Name = 'Source' ;
}

FCKSourceCommand.prototype.Execute = function()
{
     FCK.SwitchEditMode() ;
}

FCKSourceCommand.prototype.GetState = function()
{
        return ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_OFF : 
FCK_TRISTATE_ON ) ;
}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]