1 | /** |
---|
2 | * $Id: editor_plugin_src.js 520 2008-01-07 16:30:32Z spocke $ |
---|
3 | * |
---|
4 | * @author Moxiecode |
---|
5 | * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. |
---|
6 | */ |
---|
7 | |
---|
8 | (function() { |
---|
9 | tinymce.create('tinymce.plugins.FullPagePlugin', { |
---|
10 | init : function(ed, url) { |
---|
11 | var t = this; |
---|
12 | |
---|
13 | t.editor = ed; |
---|
14 | |
---|
15 | // Register commands |
---|
16 | ed.addCommand('mceFullPageProperties', function() { |
---|
17 | ed.windowManager.open({ |
---|
18 | file : url + '/fullpage.htm', |
---|
19 | width : 430 + parseInt(ed.getLang('fullpage.delta_width', 0)), |
---|
20 | height : 495 + parseInt(ed.getLang('fullpage.delta_height', 0)), |
---|
21 | inline : 1 |
---|
22 | }, { |
---|
23 | plugin_url : url, |
---|
24 | head_html : t.head |
---|
25 | }); |
---|
26 | }); |
---|
27 | |
---|
28 | // Register buttons |
---|
29 | ed.addButton('fullpage', {title : 'fullpage.desc', cmd : 'mceFullPageProperties'}); |
---|
30 | |
---|
31 | ed.onBeforeSetContent.add(t._setContent, t); |
---|
32 | ed.onGetContent.add(t._getContent, t); |
---|
33 | }, |
---|
34 | |
---|
35 | getInfo : function() { |
---|
36 | return { |
---|
37 | longname : 'Fullpage', |
---|
38 | author : 'Moxiecode Systems AB', |
---|
39 | authorurl : 'http://tinymce.moxiecode.com', |
---|
40 | infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage', |
---|
41 | version : tinymce.majorVersion + "." + tinymce.minorVersion |
---|
42 | }; |
---|
43 | }, |
---|
44 | |
---|
45 | // Private plugin internal methods |
---|
46 | |
---|
47 | _createSerializer : function() { |
---|
48 | return new tinymce.dom.Serializer({ |
---|
49 | dom : this.editor.dom, |
---|
50 | apply_source_formatting : true |
---|
51 | }); |
---|
52 | }, |
---|
53 | |
---|
54 | _setContent : function(ed, o) { |
---|
55 | var t = this, sp, ep, c = o.content; |
---|
56 | |
---|
57 | // Parse out head, body and footer |
---|
58 | sp = c.indexOf('<body'); |
---|
59 | if (sp == -1) |
---|
60 | sp = c.indexOf('<BODY'); |
---|
61 | |
---|
62 | if (sp != -1) { |
---|
63 | sp = c.indexOf('>', sp); |
---|
64 | t.head = c.substring(0, sp + 1); |
---|
65 | |
---|
66 | ep = c.indexOf('</body', sp); |
---|
67 | if (ep == -1) |
---|
68 | ep = c.indexOf('</body', ep); |
---|
69 | |
---|
70 | o.content = c.substring(sp + 1, ep); |
---|
71 | t.foot = c.substring(ep); |
---|
72 | } else { |
---|
73 | t.head = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; |
---|
74 | t.head += '\n<html>\n<head>\n<title>Untitled document</title>\n</head>\n<body>\n'; |
---|
75 | t.foot = '\n</body>\n</html>'; |
---|
76 | } |
---|
77 | }, |
---|
78 | |
---|
79 | _getContent : function(ed, o) { |
---|
80 | var t = this; |
---|
81 | |
---|
82 | o.content = tinymce.trim(t.head) + '\n' + tinymce.trim(o.content) + '\n' + tinymce.trim(t.foot); |
---|
83 | } |
---|
84 | }); |
---|
85 | |
---|
86 | // Register plugin |
---|
87 | tinymce.PluginManager.add('fullpage', tinymce.plugins.FullPagePlugin); |
---|
88 | })(); |
---|