2 * $Id: editor_plugin_src.js 920 2008-09-09 14:05:33Z spocke $
\r
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
\r
9 tinymce.create('tinymce.plugins.FullPagePlugin', {
\r
10 init : function(ed, url) {
\r
15 // Register commands
\r
16 ed.addCommand('mceFullPageProperties', function() {
\r
17 ed.windowManager.open({
\r
18 file : url + '/fullpage.htm',
\r
19 width : 430 + parseInt(ed.getLang('fullpage.delta_width', 0)),
\r
20 height : 495 + parseInt(ed.getLang('fullpage.delta_height', 0)),
\r
29 ed.addButton('fullpage', {title : 'fullpage.desc', cmd : 'mceFullPageProperties'});
\r
31 ed.onBeforeSetContent.add(t._setContent, t);
\r
32 ed.onSetContent.add(t._setBodyAttribs, t);
\r
33 ed.onGetContent.add(t._getContent, t);
\r
36 getInfo : function() {
\r
38 longname : 'Fullpage',
\r
39 author : 'Moxiecode Systems AB',
\r
40 authorurl : 'http://tinymce.moxiecode.com',
\r
41 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage',
\r
42 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
46 // Private plugin internal methods
\r
48 _setBodyAttribs : function(ed, o) {
\r
49 var bdattr, i, len, kv, k, v, t, attr = this.head.match(/body(.*?)>/i);
\r
51 if (attr && attr[1]) {
\r
52 bdattr = attr[1].match(/\s*(\w+\s*=\s*".*?"|\w+\s*=\s*'.*?'|\w+\s*=\s*\w+|\w+)\s*/g);
\r
55 for(i = 0, len = bdattr.length; i < len; i++) {
\r
56 kv = bdattr[i].split('=');
\r
57 k = kv[0].replace(/\s/,'');
\r
61 v = v.replace(/^\s+/,'').replace(/\s+$/,'');
\r
62 t = v.match(/^["'](.*)["']$/);
\r
69 ed.dom.setAttrib(ed.getBody(), 'style', v);
\r
75 _createSerializer : function() {
\r
76 return new tinymce.dom.Serializer({
\r
77 dom : this.editor.dom,
\r
78 apply_source_formatting : true
\r
82 _setContent : function(ed, o) {
\r
83 var t = this, sp, ep, c = o.content, v, st = '';
\r
85 // Parse out head, body and footer
\r
86 c = c.replace(/<(\/?)BODY/gi, '<$1body');
\r
87 sp = c.indexOf('<body');
\r
90 sp = c.indexOf('>', sp);
\r
91 t.head = c.substring(0, sp + 1);
\r
93 ep = c.indexOf('</body', sp);
\r
95 ep = c.indexOf('</body', ep);
\r
97 o.content = c.substring(sp + 1, ep);
\r
98 t.foot = c.substring(ep);
\r
101 return s.replace(/<\/?[A-Z]+/g, function(a) {
\r
102 return a.toLowerCase();
\r
106 t.head = low(t.head);
\r
107 t.foot = low(t.foot);
\r
110 if (ed.getParam('fullpage_default_xml_pi'))
\r
111 t.head += '<?xml version="1.0" encoding="' + ed.getParam('fullpage_default_encoding', 'ISO-8859-1') + '" ?>\n';
\r
113 t.head += ed.getParam('fullpage_default_doctype', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
\r
114 t.head += '\n<html>\n<head>\n<title>' + ed.getParam('fullpage_default_title', 'Untitled document') + '</title>\n';
\r
116 if (v = ed.getParam('fullpage_default_encoding'))
\r
117 t.head += '<meta http-equiv="Content-Type" content="' + v + '" />\n';
\r
119 if (v = ed.getParam('fullpage_default_font_family'))
\r
120 st += 'font-family: ' + v + ';';
\r
122 if (v = ed.getParam('fullpage_default_font_size'))
\r
123 st += 'font-size: ' + v + ';';
\r
125 if (v = ed.getParam('fullpage_default_text_color'))
\r
126 st += 'color: ' + v + ';';
\r
128 t.head += '</head>\n<body' + (st ? ' style="' + st + '"' : '') + '>\n';
\r
129 t.foot = '\n</body>\n</html>';
\r
133 _getContent : function(ed, o) {
\r
136 o.content = tinymce.trim(t.head) + '\n' + tinymce.trim(o.content) + '\n' + tinymce.trim(t.foot);
\r
141 tinymce.PluginManager.add('fullpage', tinymce.plugins.FullPagePlugin);
\r