Page MenuHomeIn-Portal Phabricator

fckplugin.js
No OneTemporary

File Metadata

Created
Sun, Mar 9, 9:41 PM

fckplugin.js

var MyPreviewCommand = function()
{
this.Name = 'MyPreview' ;
}
MyPreviewCommand.prototype.Execute = function()
{
initXmlHTTP();
xmlHTTP.onreadystatechange = OnGetAnswerPost;
// the path is NOT /admin, otherwise content will be stored in admin session !
xmlHTTP.open('POST', FCKConfig.ProjectPath+'index.php?t=dummy&events[c]=OnUpdatePreviewBlock&ajax=yes', true);
xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHTTP.send('&preview_content=' + encodeURIComponent(FCK.GetXHTML()));
}
MyPreviewCommand.prototype.GetState = function()
{
return FCK_TRISTATE_OFF;
}
function initXmlHTTP(){
//if (xmlHTTP) return;
try {
xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlHTTP = false;
}
}
if (!xmlHTTP && typeof XMLHttpRequest!='undefined') {
xmlHTTP = new XMLHttpRequest();
}
}
function OnGetAnswerPost()
{
var ret = '';
if (xmlHTTP.readyState == 4) {
if (xmlHTTP.status==200) {
ret = xmlHTTP.responseText;
var iWidth = FCKConfig.ScreenWidth * 0.8 ;
var iHeight = FCKConfig.ScreenHeight * 0.7 ;
var iLeft = ( FCKConfig.ScreenWidth - iWidth ) / 2 ;
var sOpenUrl = FCKConfig.PreviewUrl+'&_editor_preview_=1';
var oWindow = window.open(sOpenUrl, null, 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ;
}
}
}
FCKCommands.RegisterCommand( 'MyPreview', new MyPreviewCommand());
FCKToolbarItems.RegisterItem( 'MyPreview', new FCKToolbarButton( 'MyPreview' , FCKLang.PreviewLbl, FCKLang.Preview, null, false, true, 5) ) ;

Event Timeline