webcit_before_automake is now the trunk
[citadel.git] / webcit / tiny_mce / plugins / preview / editor_plugin_src.js
1 /* Import plugin specific language pack */\r
2 tinyMCE.importPluginLanguagePack('preview', 'cs,de,el,en,fr_ca,it,ko,pt,sv,zh_cn,fa,fr,pl,pt_br,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,zh_tw,zh_tw_utf8,sk');\r
3 \r
4 function TinyMCE_preview_getInfo() {\r
5         return {\r
6                 longname : 'Preview',\r
7                 author : 'Moxiecode Systems',\r
8                 authorurl : 'http://tinymce.moxiecode.com',\r
9                 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_preview.html',\r
10                 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion\r
11         };\r
12 };\r
13 \r
14 /**\r
15  * Returns the HTML contents of the preview control.\r
16  */\r
17 function TinyMCE_preview_getControlHTML(control_name) {\r
18         switch (control_name) {\r
19                 case "preview":\r
20                         var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcePreview\');return false;';\r
21                         return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_preview" src="{$pluginurl}/images/preview.gif" title="{$lang_preview_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';\r
22         }\r
23 \r
24         return "";\r
25 }\r
26 \r
27 /**\r
28  * Executes the mcePreview command.\r
29  */\r
30 function TinyMCE_preview_execCommand(editor_id, element, command, user_interface, value) {\r
31         // Handle commands\r
32         switch (command) {\r
33                 case "mcePreview":\r
34                         var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null);\r
35                         var previewWidth = tinyMCE.getParam("plugin_preview_width", "550");\r
36                         var previewHeight = tinyMCE.getParam("plugin_preview_height", "600");\r
37 \r
38                         // Use a custom preview page\r
39                         if (previewPage) {\r
40                                 var template = new Array();\r
41 \r
42                                 template['file'] = previewPage;\r
43                                 template['width'] = previewWidth;\r
44                                 template['height'] = previewHeight;\r
45 \r
46                                 tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", inline : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")});\r
47                         } else {\r
48                                 var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height="  + previewHeight);\r
49                                 var html = "";\r
50 \r
51                                 html += tinyMCE.getParam('doctype');\r
52                                 html += '<html xmlns="http://www.w3.org/1999/xhtml">';\r
53                                 html += '<head>';\r
54                                 html += '<title>' + tinyMCE.getLang('lang_preview_desc') + '</title>';\r
55                                 html += '<base href="' + tinyMCE.getParam("document_base_url") + '">';\r
56                                 html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';\r
57                                 html += '<link href="' + tinyMCE.getParam("content_css") + '" rel="stylesheet" type="text/css">';\r
58                                 html += '</head>';\r
59                                 html += '<body>';\r
60                                 html += tinyMCE.getContent();\r
61                                 html += '</body>';\r
62                                 html += '</html>';\r
63 \r
64                                 win.document.write(html);\r
65                                 win.document.close();\r
66                         }\r
67 \r
68                         return true;\r
69         }\r
70 \r
71         return false;\r
72 }\r