2 * Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
\r
6 tinymce.create('tinymce.plugins.FullPagePlugin', {
\r
7 init : function(ed, url) {
\r
12 // Register commands
\r
13 ed.addCommand('mceFullPageProperties', function() {
\r
14 ed.windowManager.open({
\r
15 file : url + '/fullpage.htm',
\r
16 width : 430 + parseInt(ed.getLang('fullpage.delta_width', 0)),
\r
17 height : 495 + parseInt(ed.getLang('fullpage.delta_height', 0)),
\r
26 ed.addButton('fullpage', {title : 'fullpage.desc', cmd : 'mceFullPageProperties'});
\r
28 ed.onBeforeSetContent.add(t._setContent, t);
\r
29 ed.onSetContent.add(t._setBodyAttribs, t);
\r
30 ed.onGetContent.add(t._getContent, t);
\r
33 getInfo : function() {
\r
35 longname : 'Fullpage',
\r
36 author : 'Moxiecode Systems AB',
\r
37 authorurl : 'http://tinymce.moxiecode.com',
\r
38 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage',
\r
39 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
43 // Private plugin internal methods
\r
45 _setBodyAttribs : function(ed, o) {
\r
46 var bdattr, i, len, kv, k, v, t, attr = this.head.match(/body(.*?)>/i);
\r
48 if (attr && attr[1]) {
\r
49 bdattr = attr[1].match(/\s*(\w+\s*=\s*".*?"|\w+\s*=\s*'.*?'|\w+\s*=\s*\w+|\w+)\s*/g);
\r
52 for(i = 0, len = bdattr.length; i < len; i++) {
\r
53 kv = bdattr[i].split('=');
\r
54 k = kv[0].replace(/\s/,'');
\r
58 v = v.replace(/^\s+/,'').replace(/\s+$/,'');
\r
59 t = v.match(/^["'](.*)["']$/);
\r
66 ed.dom.setAttrib(ed.getBody(), 'style', v);
\r
72 _createSerializer : function() {
\r
73 return new tinymce.dom.Serializer({
\r
74 dom : this.editor.dom,
\r
75 apply_source_formatting : true
\r
79 _setContent : function(ed, o) {
\r
80 var t = this, sp, ep, c = o.content, v, st = '';
\r
82 // Parse out head, body and footer
\r
83 c = c.replace(/<(\/?)BODY/gi, '<$1body');
\r
84 sp = c.indexOf('<body');
\r
87 sp = c.indexOf('>', sp);
\r
88 t.head = c.substring(0, sp + 1);
\r
90 ep = c.indexOf('</body', sp);
\r
92 ep = c.indexOf('</body', ep);
\r
94 o.content = c.substring(sp + 1, ep);
\r
95 t.foot = c.substring(ep);
\r
98 return s.replace(/<\/?[A-Z]+/g, function(a) {
\r
99 return a.toLowerCase();
\r
103 t.head = low(t.head);
\r
104 t.foot = low(t.foot);
\r
107 if (ed.getParam('fullpage_default_xml_pi'))
\r
108 t.head += '<?xml version="1.0" encoding="' + ed.getParam('fullpage_default_encoding', 'ISO-8859-1') + '" ?>\n';
\r
110 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
111 t.head += '\n<html>\n<head>\n<title>' + ed.getParam('fullpage_default_title', 'Untitled document') + '</title>\n';
\r
113 if (v = ed.getParam('fullpage_default_encoding'))
\r
114 t.head += '<meta http-equiv="Content-Type" content="' + v + '" />\n';
\r
116 if (v = ed.getParam('fullpage_default_font_family'))
\r
117 st += 'font-family: ' + v + ';';
\r
119 if (v = ed.getParam('fullpage_default_font_size'))
\r
120 st += 'font-size: ' + v + ';';
\r
122 if (v = ed.getParam('fullpage_default_text_color'))
\r
123 st += 'color: ' + v + ';';
\r
125 t.head += '</head>\n<body' + (st ? ' style="' + st + '"' : '') + '>\n';
\r
126 t.foot = '\n</body>\n</html>';
\r
130 _getContent : function(ed, o) {
\r
133 o.content = tinymce.trim(t.head) + '\n' + tinymce.trim(o.content) + '\n' + tinymce.trim(t.foot);
\r
138 tinymce.PluginManager.add('fullpage', tinymce.plugins.FullPagePlugin);
\r