Popup"

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

(New page: == Example on how to access the editor from a popup window == This example shows how to insert text in the FCKeditor: * '''fckpkugin.js''' file<pre> /* * your plugin must be put in the '...)
 
 
(6 intermediate revisions by one other user not shown)
Line 2: Line 2:
  
 
This example shows how to insert text in the FCKeditor:
 
This example shows how to insert text in the FCKeditor:
* '''fckpkugin.js''' file<pre>
+
 
 +
* '''fckpkugin.js''' file
 +
<pre>//fckplugin.js
 
/*
 
/*
* your plugin must be put in the 'editor/plugins/#plug-in name#' (the name is specified in fckconfig.js -> addPlugin, see below)
+
* your plugin must be put in the 'editor/plugins/#plug-in name#' (the name is specified in fckconfig.js -&gt; addPlugin, see below)
* in my case this is 'editor/plugins/insertvariables/'
+
* in my case this is 'editor/plugins/insertvariables/'
*
+
*
* insert variable editor
+
* insert variable editor
* @author: Tim Struyf, Roots Software (http://www.roots.be), tim.struyf@roots.be
+
* @author: Tim Struyf, Roots Software (http://www.roots.be), tim.struyf@roots.be
*/
+
*/
 
var InsertVariableCommand=function(){
 
var InsertVariableCommand=function(){
        //create our own command, we dont want to use the FCKDialogCommand because it uses the default fck layout and not our own
+
//create our own command, we dont want to use the FCKDialogCommand because it uses the default fck layout and not our own
 
};
 
};
InsertVariableCommand.prototype.Execute=function(){
 
}
 
 
InsertVariableCommand.GetState=function() {
 
InsertVariableCommand.GetState=function() {
        return FCK_TRISTATE_OFF; //we dont want the button to be toggled
+
return FCK_TRISTATE_OFF; //we dont want the button to be toggled
 
}
 
}
 
InsertVariableCommand.Execute=function() {
 
InsertVariableCommand.Execute=function() {
        //open a popup window when the button is clicked
+
//open a popup window when the button is clicked
        window.open('insertVariable.do', 'insertVariable', 'width=500,height=400,scrollbars=no,scrolling=no,location=no,toolbar=no');
+
window.open('insertVariable.do', 'insertVariable', 'width=500,height=400,scrollbars=no,scrolling=no,location=no,toolbar=no');
 
}
 
}
 
FCKCommands.RegisterCommand('Insert_Variables', InsertVariableCommand ); //otherwise our command will not be found
 
FCKCommands.RegisterCommand('Insert_Variables', InsertVariableCommand ); //otherwise our command will not be found
 
var oInsertVariables = new FCKToolbarButton('Insert_Variables', 'insert variable');
 
var oInsertVariables = new FCKToolbarButton('Insert_Variables', 'insert variable');
 
oInsertVariables.IconPath = FCKConfig.PluginsPath + 'insertvariables/variable.gif'; //specifies the image used in the toolbar
 
oInsertVariables.IconPath = FCKConfig.PluginsPath + 'insertvariables/variable.gif'; //specifies the image used in the toolbar
FCKToolbarItems.RegisterItem( 'Insert_Variables', oInsertVariables );
+
FCKToolbarItems.RegisterItem( 'Insert_Variables', oInsertVariables );</pre>  
</pre>
+
* web page source file
* web page file<pre>
+
<pre>//insertVariable.do
//insertVariable.do
+
&lt;html&gt;&lt;head&gt; etc...
<html><head> etc...
+
&lt;script language="javascript"&gt;
<script language="javascript">
+
&lt;!--
        <!--
+
var variable = null;
        var variable           = null;
+
var FCK = window.opener.FCK;
        var FCK                 = window.opener.FCK;
+
function ok() {
        function ok() {
+
if(variable&nbsp;!= null) {
                if(variable != null) {
+
FCK.Focus();
                        FCK.Focus();
+
var B = FCK.EditorDocument.selection.createRange(); //only works in IE
                        var B = FCK.EditorDocument.selection.createRange(); //only works in IE
+
B.text = variable;
                        B.text = variable;
+
}
                }
+
window.close();
                window.close();
+
}
        }
+
//--&gt;
        //-->
+
&lt;/script&gt;
</script>
+
&lt;/head&gt;
</head>
+
&lt;body&gt;
<body>
 
 
etc..
 
etc..
<a href="#" onClick="variable='this is a test'; ok();">insert text</a>
+
&lt;a href="#" onClick="variable='this is a test'; ok();"&gt;insert text&lt;/a&gt;
</body>
+
&lt;/body&gt;
</html>
+
&lt;/html&gt;
</pre>
+
</pre>  
* '''fckconfig.js'''<pre>
+
* '''fckconfig.js'''
//in fckconfig.js add this
+
<pre>//in fckconfig.js add this
FCKConfig.Plugins.Add( 'insertvariables' ) ;
+
FCKConfig.Plugins.Add( 'insertvariables' )&nbsp;;
 
/* add this to your toolbar or to the default toolbar
 
/* add this to your toolbar or to the default toolbar
* ['Insert_Variables']
+
* ['Insert_Variables']
*/
+
*/
 
FCKConfig. ToolbarSets["myToolbar"] = [
 
FCKConfig. ToolbarSets["myToolbar"] = [
        ['Bold','Italic','Underline'],['Insert_Variables']
+
['Bold','Italic','Underline'],['Insert_Variables']
] ;
+
]&nbsp;;
 
</pre>
 
</pre>

Latest revision as of 15:29, 8 March 2008

Example on how to access the editor from a popup window

This example shows how to insert text in the FCKeditor:

  • fckpkugin.js file
//fckplugin.js
/*
* your plugin must be put in the 'editor/plugins/#plug-in name#' (the name is specified in fckconfig.js -> addPlugin, see below)
* in my case this is 'editor/plugins/insertvariables/'
*
* insert variable editor
* @author: Tim Struyf, Roots Software (http://www.roots.be), tim.struyf@roots.be
*/
var InsertVariableCommand=function(){
//create our own command, we dont want to use the FCKDialogCommand because it uses the default fck layout and not our own
};
InsertVariableCommand.GetState=function() {
return FCK_TRISTATE_OFF; //we dont want the button to be toggled
}
InsertVariableCommand.Execute=function() {
//open a popup window when the button is clicked
window.open('insertVariable.do', 'insertVariable', 'width=500,height=400,scrollbars=no,scrolling=no,location=no,toolbar=no');
}
FCKCommands.RegisterCommand('Insert_Variables', InsertVariableCommand ); //otherwise our command will not be found
var oInsertVariables = new FCKToolbarButton('Insert_Variables', 'insert variable');
oInsertVariables.IconPath = FCKConfig.PluginsPath + 'insertvariables/variable.gif'; //specifies the image used in the toolbar
FCKToolbarItems.RegisterItem( 'Insert_Variables', oInsertVariables );
  • web page source file
//insertVariable.do
<html><head> etc...
<script language="javascript">
<!--
var variable = null;
var FCK = window.opener.FCK;
function ok() {
if(variable != null) {
FCK.Focus();
var B = FCK.EditorDocument.selection.createRange(); //only works in IE
B.text = variable;
}
window.close();
}
//-->
</script>
</head>
<body>
etc..
<a href="#" onClick="variable='this is a test'; ok();">insert text</a>
</body>
</html>
  • fckconfig.js
//in fckconfig.js add this
FCKConfig.Plugins.Add( 'insertvariables' ) ;
/* add this to your toolbar or to the default toolbar
* ['Insert_Variables']
*/
FCKConfig. ToolbarSets["myToolbar"] = [
['Bold','Italic','Underline'],['Insert_Variables']
] ;
This page was last edited on 8 March 2008, at 15:29.