+++ /dev/null
-/*\r
-Copyright (c) 2003-2013, 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 pluginPath;\r
-\r
- var previewCmd =\r
- {\r
- modes : { wysiwyg:1, source:1 },\r
- canUndo : false,\r
- readOnly : 1,\r
- exec : function( editor )\r
- {\r
- var sHTML,\r
- config = editor.config,\r
- baseTag = config.baseHref ? '<base href="' + config.baseHref + '"/>' : '',\r
- isCustomDomain = CKEDITOR.env.isCustomDomain();\r
-\r
- if ( config.fullPage )\r
- {\r
- sHTML = editor.getData()\r
- .replace( /<head>/, '$&' + baseTag )\r
- .replace( /[^>]*(?=<\/title>)/, '$& — ' + editor.lang.preview );\r
- }\r
- else\r
- {\r
- var bodyHtml = '<body ',\r
- body = editor.document && editor.document.getBody();\r
-\r
- if ( body )\r
- {\r
- if ( body.getAttribute( 'id' ) )\r
- bodyHtml += 'id="' + body.getAttribute( 'id' ) + '" ';\r
- if ( body.getAttribute( 'class' ) )\r
- bodyHtml += 'class="' + body.getAttribute( 'class' ) + '" ';\r
- }\r
-\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
- CKEDITOR.tools.buildStyleHtml( editor.config.contentsCss ) +\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
- // With Firefox only, we need to open a special preview page, so\r
- // anchors will work properly on it. (#9047)\r
- if ( CKEDITOR.env.gecko )\r
- {\r
- window._cke_htmlToLoad = sHTML;\r
- sOpenUrl = pluginPath + 'preview.html';\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 && !CKEDITOR.env.gecko )\r
- {\r
- var doc = oWindow.document;\r
- doc.open();\r
- doc.write( sHTML );\r
- doc.close();\r
-\r
- // Chrome will need this to show the embedded. (#8016)\r
- CKEDITOR.env.webkit && setTimeout( function() { doc.body.innerHTML += ''; }, 0 );\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
- pluginPath = this.path;\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