I created a "SaveAs" Toolbar button like so:
//*********************************************************
How would you know that a button you created got clicked?
I created a "SaveAs" button where I do the following:
var FCKSaveAs = function()
{
}
FCKSaveAs.prototype.Execute = function()
{
//your code here
var name = prompt("Enter file name?", "File name here");
alert('You file name is:');
//tried seting INPUT ID="MyInputId" value to name but didn't work.
//document.getElementById('MyInputId').value = name;
//document.getElementById('MyInputId').innerHTML= name;
}
FCKSaveAs.prototype.GetState = function()
{
return FCK_TRISTATE_OFF;
}
// Register your command.
FCKCommands.RegisterCommand( 'SaveAs', new FCKSaveAs ) ;
var oFCKSaveAs = new FCKToolbarButton( "SaveAs",'Save As',null,FCK_TOOLBARITEM_ICONTEXT, true,true,1) ;
oFCKSaveAs.IconPath = FCKConfig.PluginsPath + 'SaveAs/SaveAsFile.gif' ;
FCKToolbarItems.RegisterItem( 'SaveAs', oFCKSaveAs ) ;
//***************************************************
I can get the promt and alert command to work fine. I am having a problem accesing a form on my main page where FCKEditor is. This form contains an Input field whos value I want to replace with my promp value i received. I tried adding:
document.getElementById('MyInputId').value = name;
and
document.getElementById('MyInputId').innerHTML= name;
Any ideas?
thanks.
//*********************************************************
How would you know that a button you created got clicked?
I created a "SaveAs" button where I do the following:
var FCKSaveAs = function()
{
}
FCKSaveAs.prototype.Execute = function()
{
//your code here
var name = prompt("Enter file name?", "File name here");
alert('You file name is:');
//tried seting INPUT ID="MyInputId" value to name but didn't work.
//document.getElementById('MyInputId').value = name;
//document.getElementById('MyInputId').innerHTML= name;
}
FCKSaveAs.prototype.GetState = function()
{
return FCK_TRISTATE_OFF;
}
// Register your command.
FCKCommands.RegisterCommand( 'SaveAs', new FCKSaveAs ) ;
var oFCKSaveAs = new FCKToolbarButton( "SaveAs",'Save As',null,FCK_TOOLBARITEM_ICONTEXT, true,true,1) ;
oFCKSaveAs.IconPath = FCKConfig.PluginsPath + 'SaveAs/SaveAsFile.gif' ;
FCKToolbarItems.RegisterItem( 'SaveAs', oFCKSaveAs ) ;
//***************************************************
I can get the promt and alert command to work fine. I am having a problem accesing a form on my main page where FCKEditor is. This form contains an Input field whos value I want to replace with my promp value i received. I tried adding:
document.getElementById('MyInputId').value = name;
and
document.getElementById('MyInputId').innerHTML= name;
Any ideas?
thanks.
RE: I created a "SaveAs" toolbar button.....
//*******************
FCKSaveAs.prototype.Execute = function()
{
//your code here
var name = prompt("Enter file name?", "File name here");
alert('You file name is:');
if (typeof(FCKConfig.FCKSaveAsFunction))
{
FCKConfig.FCKSaveAsFunction(name);
}
}
//*******************
and in the fckeditor/fckconfig.js i added the following:
FCKConfig.FCKSaveAsFunction = function(name)
{
alert('Save as clicked from config file name: ' + name);
document.getElementById('MyTemplateName').innerHTML= name;
}
The alert works fine, but the getElementById('MyTemplateName') part doesn't.
How can I access an element in the fckeditor form? cause this gives me an error.
RE: I created a "SaveAs" toolbar button.....
var FCKSaveAs = function()
{
}
// tell your plugin what to do
FCKSaveAs.prototype.Execute = function()
{
//your code here
var name = prompt("Enter web page name?", "web page name here");
if (name)
{
// ACCESS FORM INPUT ELEMENT CALLED MyInput
var oForm = FCK.LinkedField.form ;
oForm.MyInput.value = name;
// other ways to access all elements in form
// for (var i=0; i < oForm.elements.length; i++){
// if (oForm.elements[i].name =='TemplateName') {
// oForm.elements[i].value = name;
// }
// }
FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( 'Save' ).Execute() ;
//alert("The input cannot be parsed to a number");
}
}
// manage the plugins' button behavior
FCKSaveAs.prototype.GetState = function()
{
return FCK_TRISTATE_OFF;
}
// Register your command.
FCKCommands.RegisterCommand( 'SaveAs', new FCKSaveAs ) ;
var oFCKSaveAs = new FCKToolbarButton( "SaveAs",'Save As',null,FCK_TOOLBARITEM_ICONTEXT, true,true,1) ;
oFCKSaveAs.IconPath = FCKConfig.PluginsPath + 'SaveAs/SaveAsFile.gif' ;
FCKToolbarItems.RegisterItem( 'SaveAs', oFCKSaveAs ) ;