1 | /** |
---|
2 | * $Id: editor_plugin_src.js 544 2008-01-17 13:07:00Z spocke $ |
---|
3 | * |
---|
4 | * @author Moxiecode |
---|
5 | * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. |
---|
6 | */ |
---|
7 | |
---|
8 | (function() { |
---|
9 | var DOM = tinymce.DOM; |
---|
10 | |
---|
11 | tinymce.create('tinymce.plugins.FullScreenPlugin', { |
---|
12 | init : function(ed, url) { |
---|
13 | var t = this, s = {}, vp; |
---|
14 | |
---|
15 | t.editor = ed; |
---|
16 | |
---|
17 | // Register commands |
---|
18 | ed.addCommand('mceFullScreen', function() { |
---|
19 | var win, de = document.documentElement; |
---|
20 | |
---|
21 | if (ed.getParam('fullscreen_is_enabled')) { |
---|
22 | if (ed.getParam('fullscreen_new_window')) |
---|
23 | closeFullscreen(); // Call to close in new window |
---|
24 | else { |
---|
25 | window.setTimeout(function() { |
---|
26 | tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format : 'raw'}), {format : 'raw'}); |
---|
27 | tinyMCE.remove(ed); |
---|
28 | DOM.remove('mce_fullscreen_container'); |
---|
29 | de.style.overflow = ed.getParam('fullscreen_html_overflow'); |
---|
30 | DOM.setStyle(document.body, 'overflow', ed.getParam('fullscreen_overflow')); |
---|
31 | window.scrollTo(ed.getParam('fullscreen_scrollx'), ed.getParam('fullscreen_scrolly')); |
---|
32 | }, 10); |
---|
33 | } |
---|
34 | |
---|
35 | return; |
---|
36 | } |
---|
37 | |
---|
38 | if (ed.getParam('fullscreen_new_window')) { |
---|
39 | win = window.open(url + "/fullscreen.htm", "mceFullScreenPopup", "fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=no,left=0,top=0,width=" + screen.availWidth + ",height=" + screen.availHeight); |
---|
40 | try { |
---|
41 | win.resizeTo(screen.availWidth, screen.availHeight); |
---|
42 | } catch (e) { |
---|
43 | // Ignore |
---|
44 | } |
---|
45 | } else { |
---|
46 | s.fullscreen_overflow = DOM.getStyle(document.body, 'overflow', 1) || 'auto'; |
---|
47 | s.fullscreen_html_overflow = DOM.getStyle(de, 'overflow', 1); |
---|
48 | vp = DOM.getViewPort(); |
---|
49 | s.fullscreen_scrollx = vp.x; |
---|
50 | s.fullscreen_scrolly = vp.y; |
---|
51 | |
---|
52 | // Fixes an Opera bug where the scrollbars doesn't reappear |
---|
53 | if (tinymce.isOpera && s.fullscreen_overflow == 'visible') |
---|
54 | s.fullscreen_overflow = 'auto'; |
---|
55 | |
---|
56 | // Fixes an IE bug where horizontal scrollbars would appear |
---|
57 | if (tinymce.isIE && s.fullscreen_overflow == 'scroll') |
---|
58 | s.fullscreen_overflow = 'auto'; |
---|
59 | |
---|
60 | if (s.fullscreen_overflow == '0px') |
---|
61 | s.fullscreen_overflow = ''; |
---|
62 | |
---|
63 | DOM.setStyle(document.body, 'overflow', 'hidden'); |
---|
64 | de.style.overflow = 'hidden'; //Fix for IE6/7 |
---|
65 | vp = DOM.getViewPort(); |
---|
66 | window.scrollTo(0, 0); |
---|
67 | |
---|
68 | if (tinymce.isIE) |
---|
69 | vp.h -= 1; |
---|
70 | |
---|
71 | n = DOM.add(document.body, 'div', {id : 'mce_fullscreen_container', style : 'position:absolute;top:0;left:0;width:' + vp.w + 'px;height:' + vp.h + 'px;z-index:150;'}); |
---|
72 | DOM.add(n, 'div', {id : 'mce_fullscreen'}); |
---|
73 | |
---|
74 | tinymce.each(ed.settings, function(v, n) { |
---|
75 | s[n] = v; |
---|
76 | }); |
---|
77 | |
---|
78 | s.id = 'mce_fullscreen'; |
---|
79 | s.width = n.clientWidth; |
---|
80 | s.height = n.clientHeight - 15; |
---|
81 | s.fullscreen_is_enabled = true; |
---|
82 | s.fullscreen_editor_id = ed.id; |
---|
83 | s.theme_advanced_resizing = false; |
---|
84 | |
---|
85 | tinymce.each(ed.getParam('fullscreen_settings'), function(v, k) { |
---|
86 | s[k] = v; |
---|
87 | }); |
---|
88 | |
---|
89 | if (s.theme_advanced_toolbar_location === 'external') |
---|
90 | s.theme_advanced_toolbar_location = 'top'; |
---|
91 | |
---|
92 | t.fullscreenEditor = new tinymce.Editor('mce_fullscreen', s); |
---|
93 | t.fullscreenEditor.onInit.add(function() { |
---|
94 | t.fullscreenEditor.setContent(ed.getContent({format : 'raw', no_events : 1}), {format : 'raw', no_events : 1}); |
---|
95 | }); |
---|
96 | |
---|
97 | t.fullscreenEditor.render(); |
---|
98 | tinyMCE.add(t.fullscreenEditor); |
---|
99 | |
---|
100 | t.fullscreenElement = new tinymce.dom.Element('mce_fullscreen_container'); |
---|
101 | t.fullscreenElement.update(); |
---|
102 | //document.body.overflow = 'hidden'; |
---|
103 | } |
---|
104 | }); |
---|
105 | |
---|
106 | // Register buttons |
---|
107 | ed.addButton('fullscreen', {title : 'fullscreen.desc', cmd : 'mceFullScreen'}); |
---|
108 | |
---|
109 | ed.onNodeChange.add(function(ed, cm) { |
---|
110 | cm.setActive('fullscreen', ed.getParam('fullscreen_is_enabled')); |
---|
111 | }); |
---|
112 | }, |
---|
113 | |
---|
114 | getInfo : function() { |
---|
115 | return { |
---|
116 | longname : 'Fullscreen', |
---|
117 | author : 'Moxiecode Systems AB', |
---|
118 | authorurl : 'http://tinymce.moxiecode.com', |
---|
119 | infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen', |
---|
120 | version : tinymce.majorVersion + "." + tinymce.minorVersion |
---|
121 | }; |
---|
122 | } |
---|
123 | }); |
---|
124 | |
---|
125 | // Register plugin |
---|
126 | tinymce.PluginManager.add('fullscreen', tinymce.plugins.FullScreenPlugin); |
---|
127 | })(); |
---|