FCKConfig.Plugins.Add( 'pagesetter', 'en' ) ;FCKLang.InsertLinkBtn = 'Link to pagesetter article' ; //This will be the caption for your toolbar buttonvar InsertPagesetterCommand=function(){
//create our own command, we dont want to use the FCKDialogCommand because it uses the default fck layout and not our own
};
InsertPagesetterCommand.prototype.Execute=function(){
}
InsertPagesetterCommand.GetState=function() {
return FCK_TRISTATE_OFF; //we dont want the button to be toggled
}
InsertPagesetterCommand.Execute=function() {
//open a popup window when the button is clicked
window.open('XXXXXXX/index.php?module=pagesetter&func=pubfind&url=relative&html=a&targetID=' + XXXXXXXX, 'insertPagesetter', 'width=750,height=350,scrollbars=yes,scrolling=yes,location=no,toolbar=no');
}
FCKCommands.RegisterCommand('pagesetter', InsertPagesetterCommand ); //otherwise our command will not be found
var oInsertPagesetter = new FCKToolbarButton('pagesetter', FCKLang.InsertLinkBtn);
oInsertPagesetter.IconPath = FCKPlugins.Items['pagesetter'].Path + 'pagesetter.gif' ; //specifies the image used in the toolbar
FCKToolbarItems.RegisterItem( 'pagesetter', oInsertPagesetter );FCKConfig.Plugins.Add( 'pagesetter', 'en' ) ;FCKLang.InsertLinkBtn = 'Link to pagesetter article' ; //This will be the caption for your toolbar button
FCKLang.InsertLinkDlgTitle = 'Pagesetter Links' ; //This will be the title of the dialog boxvar InsertPagesetterCommand=function(){
//create our own command, we dont want to use the FCKDialogCommand because it uses the default fck layout and not our own
};
InsertPagesetterCommand.prototype.Execute=function(){
}
InsertPagesetterCommand.GetState=function() {
return FCK_TRISTATE_OFF; //we dont want the button to be toggled
}
InsertPagesetterCommand.Execute=function() {
oEditor = FCK.Name;
//open a popup window when the button is clicked
window.open("http://www.YOURURL.com/dev/index.php?module=pagesetter&func=pubfind&url=relative&html=a&targetID="+oEditor+"&targetMode=FCK", "", "width=750,height=315,resizable");
}
FCKCommands.RegisterCommand('pagesetter', InsertPagesetterCommand ); //otherwise our command will not be found
var oInsertPagesetter = new FCKToolbarButton('pagesetter', FCKLang.InsertLinkBtn);
oInsertPagesetter.IconPath = FCKPlugins.Items['pagesetter'].Path + 'pagesetter.gif' ; //specifies the image used in the toolbar
FCKToolbarItems.RegisterItem( 'pagesetter', oInsertPagesetter );//=============================================================================
// Stand alone link selector for Pagesetter
// (C) Jorn Lind-Nielsen
//=============================================================================
// htmlArea 3.0 editor for access in selector window
var currentPagesetterEditor = null;
//=============================================================================
// External interface functions
//=============================================================================
// onClick handler for "find publication" button in external program
function pagesetterFindPub(inputID, pagesetterURL)
{
window.open(pagesetterURL+"&targetID="+inputID, "", "width=750,height=315,resizable");
}
function pagesetterFindPubHtmlArea30(editor, pagesetterURL)
{
// Save editor for access in selector window
currentPagesetterEditor = editor;
// Inform publication selector of how it should paste the resulting HTML
pagesetterURL += "&target=htmlArea30";
window.open(pagesetterURL, "", "width=750,height=450,resizable");
}
//=============================================================================
// Paste link into parent input field
//=============================================================================
function pagesetterPasteLink(URLMode, HTMLMode, title, url, targetInputID, targetMode)
{
//TMZ added this line:
window.opener.currentPagesetterEditor = window.opener.FCK;
var html = url;
if (targetMode == 'htmlArea30')
{
//TMZ commented out:
//var selectedHTML = window.opener.currentPagesetterEditor.getSelectedHTML();
//TMZ added the next "if" statement:
if (document.all){
selectedHTML = window.opener.FCK.EditorDocument.selection.createRange().text;
} else {
selectedHTML = window.opener.FCK.EditorWindow.getSelection();
}
if (typeof selectedHTML != "undefined" && selectedHTML != '')
{
title = selectedHTML;
}
}
// Strip absolute part of URL if requested
if (URLMode != "absolute")
{
var startPos = url.indexOf("index.php?");
url = url.substr(startPos);
}
// Add <A> tag around url if requested
if (HTMLMode == 'a')
{
html = "<a href=\"" + url + "\"/>" + title + "</a>";
}
else
html = url;
// Paste link data into original input/textarea element
if (targetMode == 'htmlArea30')
{
// TMZ commented out the next two lines:
// window.opener.currentPagesetterEditor.focusEditor();
// window.opener.currentPagesetterEditor.insertHTML();
//TMZ added these two lines:
window.opener.currentPagesetterEditor.Focus();
window.opener.currentPagesetterEditor.InsertHtml(html);
}
else
{
// Where to insert the calculate URL
var targetInputElement = window.opener.document.getElementById(targetInputID);
if (targetInputElement.tagName == 'INPUT')
{
// Simply overwrite value of input elements
targetInputElement.value = html;
}
else if (targetInputElement.tagName == 'TEXTAREA')
{
// Try to paste into textarea - technique depends on browser (and Pagesetter framework)
if (typeof document.selection != "undefined")
{
if (targetInputElement.style.display == 'none' && // Someone has hidden the original textarea
typeof window.opener.editor_insertHTML != "undefined") // ... and this function is defined => guess we are using htmlArea
{
// IE: using htmlArea for editing
window.opener.editor_insertHTML(targetInputID, html);
}
else
{
// IE: Move focus to textarea (which fortunately keeps its current selection) and overwrite selection
targetInputElement.focus();
window.opener.document.selection.createRange().text = html;
}
}
else if (typeof targetInputElement.selectionStart != "undefined")
{
// Mozilla: Get start and end points of selection and create new value based on old value
var startPos = targetInputElement.selectionStart;
var endPos = targetInputElement.selectionEnd;
targetInputElement.value = targetInputElement.value.substring(0, startPos)
+ html
+ targetInputElement.value.substring(endPos, targetInputElement.value.length);
}
else
{
// Others: just append to the current value
targetInputElement.value += html;
}
}
}
window.close();
}Template courtesy of Designs By Darren.