Update of /cvsroot/phpslash/phpslash-dev/public_html/scripts/fckeditor/editor/_source/classes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12486/phpslash-dev/public_html/scripts/fckeditor/editor/_source/classes
Added Files:
fckcolorpanel.js fckpanel_gecko.js fckpanel_ie.js
fcktoolbarpanelbutton.js fcktoolbarpanelbutton_gecko.js
fcktoolbarpanelbutton_ie.js
Log Message:
complete fckeditor addition
--- NEW FILE: fckcolorpanel.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: fckcolorpanel.js
* FCKColorPanel Class: represents a Color Selection panel.
*
* Version: 2.0 Beta 2
* Modified: 2004-08-20 22:35:45
*
* File Authors:
* Frederico Caldeira Knabben (fr...@fc...)
*/
var FCKColorPanel = function( setColorFunction )
{
// SetColorFunction is the function to be called when the user selects the
// desired color (from the panel itself or from the "More Colors..." popup.
this.SetColorFunction = setColorFunction ;
}
// Inherit from FCKPanel.
FCKColorPanel.prototype = new FCKPanel ;
FCKColorPanel.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 = targetDocument.createElement( "TABLE" ) ;
oTable.cellPadding = 0 ;
oTable.cellSpacing = 0 ;
oTable.border = 0 ;
// Create the Button for the "Automatic" color selection.
var oDiv = 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">Automatic</td>\
</tr>\
</table>' ;
oDiv.Panel = this ;
oDiv.onclick = function()
{
this.className = 'ColorDeselected' ;
this.Panel.SetColorFunction( '' ) ;
this.Panel.Hide() ;
}
var oCell = oTable.insertRow(-1).insertCell(-1) ;
oCell.colSpan = 8 ;
oCell.appendChild( oDiv ) ;
// 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 = CreateSelectionDiv() ;
oDiv.Color = aColors[iCounter] ;
oDiv.innerHTML = '<div class="ColorBoxBorder"><div class="ColorBox" style="background-color: #' + aColors[iCounter] + '"></div></div>' ;
oDiv.Panel = this ;
oDiv.onclick = function()
{
this.className = 'ColorDeselected' ;
this.Panel.SetColorFunction( '#' + this.Color ) ;
this.Panel.Hide() ;
}
oCell = oRow.insertCell(-1) ;
oCell.appendChild( oDiv ) ;
}
}
// Create the Row and the Cell for the "More Colors..." button.
var oDiv = CreateSelectionDiv() ;
oDiv.innerHTML = '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td nowrap align="center">More Colors...</td></tr></table>' ;
oDiv.Panel = this ;
oDiv.onclick = function()
{
this.className = 'ColorDeselected' ;
this.Panel.Hide() ;
FCKDialog.OpenDialog( 'FCKDialog_Color', 'Select a Color', 'dialog/fck_colorselector.html', 400, 330, this.Panel.SetColorFunction ) ;
}
var oCell = oTable.insertRow(-1).insertCell(-1) ;
oCell.colSpan = 8 ;
oCell.appendChild( oDiv ) ;
// Append the resulting table to the target DIV.
targetDiv.appendChild( oTable ) ;
}
--- NEW FILE: fckpanel_gecko.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: fckpanel_gecko.js
* FCKPanel Class: this is the IE version of the base class used to implement
* "Panel" classes.
*
* Version: 2.0 Beta 2
* Modified: 2004-08-20 16:32:56
*
* File Authors:
* Frederico Caldeira Knabben (fr...@fc...)
*/
// The Panel Styles where already liaded in the parent window by the Context Menu scripts.
// (They are included in the fck_contextmenu CSS)
var FCKPanel = function()
{}
FCKPanel.prototype.Create = function()
{
// Create the main DIV that is used as the panel base.
this.PanelDiv = window.parent.document.createElement('DIV') ;
this.PanelDiv.style.visibility = 'hidden' ;
this.PanelDiv.className = 'FCK_Panel' ;
this.PanelDiv.style.zIndex = 10000 ;
this.PanelDiv.oncontextmenu = function() { return false ; }
// Put the main DIV inside the parent document.
window.parent.document.body.appendChild( this.PanelDiv );
// It calls a method that must be defined on classes that inherit the
// FCKPanel class.
if ( this.CreatePanelBody )
this.CreatePanelBody( window.parent.document, this.PanelDiv ) ;
this.Created = true ;
}
FCKPanel.prototype.Show = function( panelX, panelY )
{
if ( ! this.Created )
this.Create() ;
// Set the context menu DIV in the specified location.
this.PanelDiv.style.left = panelX + 'px' ;
this.PanelDiv.style.top = panelY + 'px' ;
// Watch the "OnClick" event for all windows to close the Context Menu.
var oActualWindow = FCK.EditorWindow ;
while ( oActualWindow )
{
oActualWindow.document.addEventListener( 'click', this._OnDocumentClick, false ) ;
if ( oActualWindow != oActualWindow.parent )
oActualWindow = oActualWindow.parent ;
else if ( oActualWindow.opener == null )
oActualWindow = oActualWindow.opener ;
else
break ;
}
// Show it.
this.PanelDiv.style.visibility = '' ;
FCK.ActivePanel = this ;
}
FCKPanel.prototype._OnDocumentClick = function( event )
{
if ( ! FCK.ActivePanel ) return ;
var e = event.target ;
while ( e )
{
if ( e == FCK.ActivePanel.PanelDiv ) return ;
e = e.parentNode ;
}
FCK.ActivePanel.Hide() ;
}
FCKPanel.prototype.Hide = function()
{
this.PanelDiv.style.visibility = 'hidden' ;
this.PanelDiv.style.left = this.PanelDiv.style.top = '1px' ;
delete FCK.ActivePanel ;
}
--- NEW FILE: fckpanel_ie.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: fckpanel_ie.js
* FCKPanel Class: this is the IE version of the base class used to implement
* "Panel" classes.
*
* Version: 2.0 Beta 2
* Modified: 2004-08-27 15:55:23
*
* File Authors:
* Frederico Caldeira Knabben (fr...@fc...)
*/
var FCKPanel = function()
{}
FCKPanel.prototype.Create = function()
{
// Create the Popup that will hold the panel.
this._Popup = window.createPopup() ;
this._Popup.document.createStyleSheet( FCKConfig.SkinPath + 'fck_contextmenu.css' ) ;
this._Popup.document.oncontextmenu = function() { return false ; }
// Create the main DIV that is used as the panel base.
this.PanelDiv = this._Popup.document.createElement('DIV') ;
this.PanelDiv.className = 'FCK_Panel' ;
// Put the main DIV inside the Popup.
this._Popup.document.body.appendChild(this.PanelDiv) ;
// It calls a method that must be defined on classes that inherit the
// FCKPanel class.
if ( this.CreatePanelBody )
this.CreatePanelBody( this._Popup.document, this.PanelDiv ) ;
this._Popup.document.close() ;
this.Created = true ;
}
FCKPanel.prototype.Show = function( panelX, panelY )
{
if ( ! this.Created )
this.Create() ;
// The offsetWidth and offsetHeight properties are not available if the
// element is not visible. So we must "show" the popup with no size to
// be able to use that values in the second call.
this._Popup.show( panelX, panelY, 0, 0 ) ;
// Second call: Show the Popup at the specified location.
this._Popup.show( panelX, panelY, this.PanelDiv.offsetWidth, this.PanelDiv.offsetHeight ) ;
}
FCKPanel.prototype.Hide = function()
{
if ( this._Popup )
this._Popup.hide() ;
}
--- NEW FILE: fcktoolbarpanelbutton.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: fcktoolbarpanelbutton.js
* FCKToolbarPanelButton Class: represents a special button in the toolbar
* that shows a panel when pressed.
*
* Version: 2.0 Beta 2
* Modified: 2004-08-27 16:27:03
*
* File Authors:
* Frederico Caldeira Knabben (fr...@fc...)
*/
var FCKToolbarPanelButton = function( commandName, label, tooltip, style )
{
this.Command = FCKCommands[ commandName ] ;
this.Label = label ? label : commandName ;
this.Tooltip = tooltip ? tooltip : ( label ? label : commandName) ;
this.Style = style ? style : FCK_TOOLBARITEM_ONLYICON ;
this.State = FCK_UNKNOWN ;
if ( this.Command == null )
alert( 'Unknown command name "' + commandName + '"' ) ;
}
FCKToolbarPanelButton.prototype.CreateInstance = function( parentToolbar )
{
/*
<td title="Bold" class="TB_Button_Off" unselectable="on" onmouseover="Button_OnMouseOver(this);" onmouseout="Button_OnMouseOut(this);">
<table class="TB_ButtonType_Icon" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="TB_Icon"><img src="icons/button.redo.gif" width="21" height="21" style="VISIBILITY: hidden" onload="this.style.visibility = '';"></td>
<td class="TB_Text" unselectable="on">Redo</td>
<td class="TB_ButtonArrow"><img src="skin/images/toolbar_buttonarrow.gif" width="5" height="3"></td>
</tr>
</table>
</td>
*/
this.DOMDiv = document.createElement( 'div' ) ;
this.DOMDiv.className = 'TB_Button_Off' ;
this.DOMDiv.FCKToolbarButton = this ;
this.DOMDiv.onmouseover = function()
{
if ( this.FCKToolbarButton.State != FCK_TRISTATE_DISABLED )
{
this.className = 'TB_Button_On' ;
}
}
this.DOMDiv.onmouseout = function()
{
if ( this.FCKToolbarButton.State != FCK_TRISTATE_DISABLED && this.FCKToolbarButton.State != FCK_TRISTATE_ON )
{
this.className = 'TB_Button_Off' ;
}
}
this.DOMDiv.onclick = function( ev )
{
// Call the OnClick event handler (it is different depending o the browser version.
if ( this.FCKToolbarButton.State != FCK_TRISTATE_DISABLED )
this.FCKToolbarButton.HandleOnClick( this.FCKToolbarButton, ev ) ;
// For Mozilla we must stop the event propagation to avoid it hiding
// the panel because of a click outside of it.
if ( ev )
ev.stopPropagation() ;
return false ;
}
// Gets the correct CSS class to use for the specified style (param).
var sClass ;
switch ( this.Style )
{
case FCK_TOOLBARITEM_ONLYICON :
sClass = 'TB_ButtonType_Icon' ;
break ;
case FCK_TOOLBARITEM_ONLYTEXT :
sClass = 'TB_ButtonType_Text' ;
break ;
case FCK_TOOLBARITEM_ICONTEXT :
sClass = '' ;
break ;
}
this.DOMDiv.innerHTML =
'<table title="' + this.Tooltip + '" class="' + sClass + '" cellspacing="0" cellpadding="0" border="0" unselectable="on">' +
'<tr>' +
'<td class="TB_Icon" unselectable="on"><img src="' + FCKConfig.SkinPath + 'toolbar/button.' + this.Command.Name.toLowerCase() + '.gif" width="21" height="21" style="VISIBILITY: hidden" onload="this.style.visibility = \'\';" unselectable="on"></td>' +
'<td class="TB_Text" unselectable="on">' + this.Label + '</td>' +
'<td class="TB_ButtonArrow" unselectable="on"><img src="' + FCKConfig.SkinPath + 'images/toolbar.buttonarrow.gif" width="5" height="3"></td>' +
'</tr>' +
'</table>' ;
var oCell = parentToolbar.DOMRow.insertCell(-1) ;
oCell.appendChild( this.DOMDiv ) ;
this.RefreshState() ;
}
// The Panel Button works like a normal button so the refresh state function
// defined for the normal button can be reused here.
FCKToolbarPanelButton.prototype.RefreshState = FCKToolbarButton.prototype.RefreshState ;
--- NEW FILE: fcktoolbarpanelbutton_gecko.js ---
FCKToolbarPanelButton.prototype.HandleOnClick = function( panelButton, ev )
{
// The X and Y position of the Panel must be calculated based on
// the button position.
var e = panelButton.DOMDiv ;
// Get the DIV and the editor frame positions.
var oDivCoords = FCKTools.GetElementPosition( e ) ;
var oFrmCoords = FCKTools.GetElementPosition( window.frameElement ) ;
// Get the actual window (IFRAME) position on screen.
var iPanelX = oDivCoords.X + oFrmCoords.X ;
var iPanelY = oDivCoords.Y + oFrmCoords.Y + e.offsetHeight ; // The button height is added so the panel is aligned on its base line.
panelButton.Command.Execute(iPanelX,iPanelY) ;
}
--- NEW FILE: fcktoolbarpanelbutton_ie.js ---
FCKToolbarPanelButton.prototype.HandleOnClick = function( panelButton, ev )
{
// The X and Y position of the Panel must be calculated based on
// the button position.
var e = panelButton.DOMDiv ;
// Get the DIV position.
var oDivCoords = FCKTools.GetElementPosition( e ) ;
// Get the actual window (IFRAME) position on screen.
var iPanX = oDivCoords.X + window.screenLeft ;
var iPanY = oDivCoords.Y + window.screenTop + e.offsetHeight + 1 ; // The button height is added so the panel is aligned on its base line.
panelButton.Command.Execute(iPanX,iPanY) ;
}
|