--- /dev/null
+/*\r
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+/**\r
+ * @file Preview plugin.\r
+ */\r
+\r
+(function()\r
+{\r
+ var previewCmd =\r
+ {\r
+ modes : { wysiwyg:1, source:1 },\r
+ canUndo : false,\r
+ exec : function( editor )\r
+ {\r
+ var sHTML,\r
+ isCustomDomain = CKEDITOR.env.ie && document.domain != window.location.hostname;\r
+ if ( editor.config.fullPage )\r
+ sHTML = editor.getData();\r
+ else\r
+ {\r
+ var bodyHtml = '<body ',\r
+ body = CKEDITOR.document.getBody(),\r
+ baseTag = ( editor.config.baseHref.length > 0 ) ? '<base href="' + editor.config.baseHref + '" _cktemp="true"></base>' : '';\r
+\r
+ if ( body.getAttribute( 'id' ) )\r
+ bodyHtml += 'id="' + body.getAttribute( 'id' ) + '" ';\r
+ if ( body.getAttribute( 'class' ) )\r
+ bodyHtml += 'class="' + body.getAttribute( 'class' ) + '" ';\r
+ bodyHtml += '>';\r
+\r
+ sHTML =\r
+ editor.config.docType +\r
+ '<html dir="' + editor.config.contentsLangDirection + '">' +\r
+ '<head>' +\r
+ baseTag +\r
+ '<title>' + editor.lang.preview + '</title>' +\r
+ '<link href="' + editor.config.contentsCss + '" type="text/css" rel="stylesheet" _cktemp="true"/>' +\r
+ '</head>' + bodyHtml +\r
+ editor.getData() +\r
+ '</body></html>';\r
+ }\r
+\r
+ var iWidth = 640, // 800 * 0.8,\r
+ iHeight = 420, // 600 * 0.7,\r
+ iLeft = 80; // (800 - 0.8 * 800) /2 = 800 * 0.1.\r
+ try\r
+ {\r
+ var screen = window.screen;\r
+ iWidth = Math.round( screen.width * 0.8 );\r
+ iHeight = Math.round( screen.height * 0.7 );\r
+ iLeft = Math.round( screen.width * 0.1 );\r
+ }\r
+ catch ( e ){}\r
+\r
+ var sOpenUrl = '';\r
+ if ( isCustomDomain )\r
+ {\r
+ window._cke_htmlToLoad = sHTML;\r
+ sOpenUrl = 'javascript:void( (function(){' +\r
+ 'document.open();' +\r
+ 'document.domain="' + document.domain + '";' +\r
+ 'document.write( window.opener._cke_htmlToLoad );' +\r
+ 'document.close();' +\r
+ 'window.opener._cke_htmlToLoad = null;' +\r
+ '})() )';\r
+ }\r
+\r
+ var oWindow = window.open( sOpenUrl, null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' +\r
+ iWidth + ',height=' + iHeight + ',left=' + iLeft );\r
+\r
+ if ( !isCustomDomain )\r
+ {\r
+ oWindow.document.write( sHTML );\r
+ oWindow.document.close();\r
+ }\r
+ }\r
+ };\r
+\r
+ var pluginName = 'preview';\r
+\r
+ // Register a plugin named "preview".\r
+ CKEDITOR.plugins.add( pluginName,\r
+ {\r
+ init : function( editor )\r
+ {\r
+ editor.addCommand( pluginName, previewCmd );\r
+ editor.ui.addButton( 'Preview',\r
+ {\r
+ label : editor.lang.preview,\r
+ command : pluginName\r
+ });\r
+ }\r
+ });\r
+})();\r