I want to create a new plugin to insert a loginform.
I have this: But he says that he con't find the menuitem. What to do?
fckconfig.js:
['inlogmenu'],
fckplugins.js:
// Register the related command.
// RegisterCommand takes the following arguments: CommandName, DialogCommand
// FCKDialogCommand takes the following arguments: CommandName, Dialog Title, Path to HTML file, Width, Height
FCKCommands.RegisterCommand( 'inlogmenu', new FCKDialogCommand( 'inlogmenu', FCKLang.inlogmenuDlgTitle,
FCKPlugins.Items['inlogmenu'].Path + 'fck_inlogmenu.html', 340, 200 ) ) ;
// Create the toolbar button.
// FCKToolbarButton takes the following arguments: CommandName, Button Caption
var oinlogmenuItem = new FCKToolbarButton( 'inlogmenu', FCKLang.inlogmenuBtn ) ;
oinlogmenuItem.IconPath = FCKPlugins.Items['inlogmenu'].Path + 'inlogmenu.gif' ;
FCKToolbarItems.RegisterItem( 'inlogmenu', oinlogmenuItem ) ;
// The object used for all inlogmenu operations.
var FCKinlogmenu = new Object() ;
// Add a new inlogmenu at the actual selection.
// This function will be called from the HTML file when the user clicks the OK button.
// This function receives the values from the Dialog
FCKinlogmenu.Add = function( linkname, caption )
{
if(linkname.substr(0,4) != "http" && linkname.substr(0,4) != "HTTP")
linkname = "http://"+linkname ;
FCK.InsertHtml("
<form action="index.php?actie=inloggen" method="post" name="inlogformulier">
<table>
<tr>
<td>
Gebruikersnaam:
</td>
<td>
<input type="text" name="gebruikersnaam" /><br><br>
</td>
</tr>
<tr>
<td>
Wachtwoord:
</td>
<td>
<input type="password" name="wachtwoord" /><br>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="Inloggen" />
</td>
<td>
<input type="reset" value="Opnieuw" />
</td>
</tr>
</table>
</form>
") ;
}
//End code
fck_inlogmenu.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html> <head> <title>Link Properties</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta content="noindex, nofollow" name="robots"> <script language="javascript"> //Standard setup stuff (notice the command name used in the property names) var oEditor = window.parent.InnerDialogLoaded() ; var FCK = oEditor.FCK ; var FCKLang = oEditor.FCKLang ; var FCKinlogmenu = oEditor.FCKinlogmenu ; window.onload = function () //Runs when the toolbar button is clicked and this page is loaded { LoadSelected() ; //see function below window.parent.SetOkButton( true ) ; // Show the "Ok" button. } //Get the currently selected element from the editor. Two Options follow. //1. Use this form for some elements such as images //var eSelected = oEditor.FCKSelection.GetSelectedElement() ; //2. Use this form for elements with inner text (including the if statement) var eSelected = FCK.Selection.MoveToAncestorNode( 'A' ) if ( eSelected ) FCK.Selection.MoveToNode( eSelected ) ; //If an anchor (A) object is currently selected, load the properties into the dialog function LoadSelected() { if ( !eSelected ) return ; txtHref.value = eSelected.href ; txtCaption.value = eSelected.innerText ; //following code would work with option 1 above. // if ( eSelected.tagName == 'IMG' ) { // -- code for setting dialog values -- } // else // eSelected == null ; //this will replace the current selection if not the right type } //Code that runs after the OK button is clicked //If a link has been entered, pass the values to the Add() function in the fckplugin.js file. function Ok() { if ( document.getElementById('txtHref').value.length > 0 ) FCKinlogmenu.Add( txtHref.value, txtCaption.value ) ; return true ; } </script> </head> <body scroll="no" style="OVERFLOW: hidden"> <table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr> <td> <table cellSpacing="0" cellPadding="0" align="center" border="0"> <tr> <td> Type the URL for the link<br> <input id="txtHref" type="text"><br> Type the caption for the link<br> <input id="txtCaption" type="text"> </td> </tr> </table> </td> </tr> </table> </body> </html>
<!-- End Code -->
nl.js
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2006 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/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: en.js
* Placholder English language file.
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*/
FCKLang.inlogmenuBtn = 'Inlogmenu invoegen' ;
FCKLang.inlogmenuDlgTitle = 'inlogmenu' ;
en.js:
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2006 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/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: en.js
* Placholder English language file.
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*/
FCKLang.inlogmenuBtn = 'Inlogmenu invoegen' ;
FCKLang.inlogmenuDlgTitle = 'inlogmenu' ;
fck_contextmenu.js:
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2006 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/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fck_contextmenu.js
* Defines the FCK.ContextMenu object that is responsible for all
* Context Menu operations in the editing area.
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*/
FCK.ContextMenu = new Object() ;
FCK.ContextMenu.Listeners = new Array() ;
FCK.ContextMenu.RegisterListener = function( listener )
{
if ( listener )
this.Listeners.push( listener ) ;
}
function FCK_ContextMenu_Init()
{
var oInnerContextMenu = FCK.ContextMenu._InnerContextMenu = new FCKContextMenu( FCKBrowserInfo.IsIE ? window : window.parent, FCK.EditorWindow, FCKLang.Dir ) ;
oInnerContextMenu.OnBeforeOpen = FCK_ContextMenu_OnBeforeOpen ;
oInnerContextMenu.OnItemClick = FCK_ContextMenu_OnItemClick ;
// Get the registering function.
var oMenu = FCK.ContextMenu ;
// Register all configured context menu listeners.
for ( var i = 0 ; i < FCKConfig.ContextMenu.length ; i++ )
oMenu.RegisterListener( FCK_ContextMenu_GetListener( FCKConfig.ContextMenu[i] ) ) ;
}
function FCK_ContextMenu_GetListener( listenerName )
{
switch ( listenerName )
{
case 'Generic' :
return {
AddItems : function( menu, tag, tagName )
{
menu.AddItem( 'Cut' , FCKLang.Cut , 7, FCKCommands.GetCommand( 'Cut' ).GetState() == FCK_TRISTATE_DISABLED ) ;
menu.AddItem( 'Copy' , FCKLang.Copy , 8, FCKCommands.GetCommand( 'Copy' ).GetState() == FCK_TRISTATE_DISABLED ) ;
menu.AddItem( 'Paste' , FCKLang.Paste , 9, FCKCommands.GetCommand( 'Paste' ).GetState() == FCK_TRISTATE_DISABLED ) ;
}} ;
case 'Table' :
return {
AddItems : function( menu, tag, tagName )
{
var bIsTable = ( tagName == 'TABLE' ) ;
var bIsCell = ( !bIsTable && FCKSelection.HasAncestorNode( 'TABLE' ) ) ;
if ( bIsCell )
{
menu.AddSeparator() ;
var oItem = menu.AddItem( 'Cell' , FCKLang.CellCM ) ;
oItem.AddItem( 'TableInsertCell' , FCKLang.InsertCell, 58 ) ;
oItem.AddItem( 'TableDeleteCells' , FCKLang.DeleteCells, 59 ) ;
oItem.AddItem( 'TableMergeCells' , FCKLang.MergeCells, 60 ) ;
oItem.AddItem( 'TableSplitCell' , FCKLang.SplitCell, 61 ) ;
oItem.AddSeparator() ;
oItem.AddItem( 'TableCellProp' , FCKLang.CellProperties, 57 ) ;
menu.AddSeparator() ;
oItem = menu.AddItem( 'Row' , FCKLang.RowCM ) ;
oItem.AddItem( 'TableInsertRow' , FCKLang.InsertRow, 62 ) ;
oItem.AddItem( 'TableDeleteRows' , FCKLang.DeleteRows, 63 ) ;
menu.AddSeparator() ;
oItem = menu.AddItem( 'Column' , FCKLang.ColumnCM ) ;
oItem.AddItem( 'TableInsertColumn' , FCKLang.InsertColumn, 64 ) ;
oItem.AddItem( 'TableDeleteColumns' , FCKLang.DeleteColumns, 65 ) ;
}
if ( bIsTable || bIsCell )
{
menu.AddSeparator() ;
menu.AddItem( 'TableDelete' , FCKLang.TableDelete ) ;
menu.AddItem( 'TableProp' , FCKLang.TableProperties, 39 ) ;
}
}} ;
case 'Link' :
return {
AddItems : function( menu, tag, tagName )
{
var bInsideLink = ( tagName == 'A' || FCKSelection.HasAncestorNode( 'A' ) ) ;
if ( bInsideLink || FCK.GetNamedCommandState( 'Unlink' ) != FCK_TRISTATE_DISABLED )
{
menu.AddSeparator() ;
if ( bInsideLink )
menu.AddItem( 'Link', FCKLang.EditLink , 34 ) ;
menu.AddItem( 'Unlink' , FCKLang.RemoveLink , 35 ) ;
}
}} ;
case 'Image' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'IMG' && !tag.getAttribute( '_fckfakelement' ) )
{
menu.AddSeparator() ;
menu.AddItem( 'Image', FCKLang.ImageProperties, 37 ) ;
}
}} ;
case 'Anchor' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'IMG' && tag.getAttribute( '_fckanchor' ) )
{
menu.AddSeparator() ;
menu.AddItem( 'Anchor', FCKLang.AnchorProp, 36 ) ;
}
}} ;
case 'Flash' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'IMG' && tag.getAttribute( '_fckflash' ) )
{
menu.AddSeparator() ;
menu.AddItem( 'Flash', FCKLang.FlashProperties, 38 ) ;
}
}} ;
case 'Form' :
return {
AddItems : function( menu, tag, tagName )
{
if ( FCKSelection.HasAncestorNode('FORM') )
{
menu.AddSeparator() ;
menu.AddItem( 'Form', FCKLang.FormProp, 48 ) ;
}
}} ;
case 'Checkbox' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'INPUT' && tag.type == 'checkbox' )
{
menu.AddSeparator() ;
menu.AddItem( 'Checkbox', FCKLang.CheckboxProp, 49 ) ;
}
}} ;
case 'Radio' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'INPUT' && tag.type == 'radio' )
{
menu.AddSeparator() ;
menu.AddItem( 'Radio', FCKLang.RadioButtonProp, 50 ) ;
}
}} ;
case 'TextField' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'INPUT' && ( tag.type == 'text' || tag.type == 'password' ) )
{
menu.AddSeparator() ;
menu.AddItem( 'TextField', FCKLang.TextFieldProp, 51 ) ;
}
}} ;
case 'HiddenField' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'INPUT' && tag.type == 'hidden' )
{
menu.AddSeparator() ;
menu.AddItem( 'HiddenField', FCKLang.HiddenFieldProp, 56 ) ;
}
}} ;
case 'ImageButton' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'INPUT' && tag.type == 'image' )
{
menu.AddSeparator() ;
menu.AddItem( 'ImageButton', FCKLang.ImageButtonProp, 55 ) ;
}
}} ;
case 'Button' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'INPUT' && ( tag.type == 'button' || tag.type == 'submit' || tag.type == 'reset' ) )
{
menu.AddSeparator() ;
menu.AddItem( 'Button', FCKLang.ButtonProp, 54 ) ;
}
}} ;
case 'Select' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'SELECT' )
{
menu.AddSeparator() ;
menu.AddItem( 'Select', FCKLang.SelectionFieldProp, 53 ) ;
}
}} ;
case 'Textarea' :
return {
AddItems : function( menu, tag, tagName )
{
if ( tagName == 'TEXTAREA' )
{
menu.AddSeparator() ;
menu.AddItem( 'Textarea', FCKLang.TextareaProp, 52 ) ;
}
}} ;
case 'BulletedList' :
return {
AddItems : function( menu, tag, tagName )
{
if ( FCKSelection.HasAncestorNode('UL') )
{
menu.AddSeparator() ;
menu.AddItem( 'BulletedList', FCKLang.BulletedListProp, 27 ) ;
}
}} ;
case 'NumberedList' :
return {
AddItems : function( menu, tag, tagName )
{
if ( FCKSelection.HasAncestorNode('OL') )
{
menu.AddSeparator() ;
menu.AddItem( 'NumberedList', FCKLang.NumberedListProp, 26 ) ;
}
}} ;
case 'inlogmenu' :
return {
AddItems : function( menu, tag, tagName )
{
menu.AddSeparator() ;
menu.AddItem( 'inlogmenu', FCKLang.inlogmenuProp, 99 ) ;
}} ;
}
}
function FCK_ContextMenu_OnBeforeOpen()
{
// Update the UI.
FCK.Events.FireEvent( "OnSelectionChange" ) ;
// Get the actual selected tag (if any).
var oTag, sTagName ;
if ( oTag = FCKSelection.GetSelectedElement() )
sTagName = oTag.tagName ;
// Cleanup the current menu items.
var oMenu = FCK.ContextMenu._InnerContextMenu ;
oMenu.RemoveAllItems() ;
// Loop through the listeners.
var aListeners = FCK.ContextMenu.Listeners ;
for ( var i = 0 ; i < aListeners.length ; i++ )
aListeners[i].AddItems( oMenu, oTag, sTagName ) ;
}
function FCK_ContextMenu_OnItemClick( item )
{
FCK.Focus() ;
FCKCommands.GetCommand( item.Name ).Execute() ;
}