2 * editor_plugin_src.js
\r
4 * Copyright 2009, Moxiecode Systems AB
\r
5 * Released under LGPL License.
\r
7 * License: http://tinymce.moxiecode.com/license
\r
8 * Contributing: http://tinymce.moxiecode.com/contributing
\r
12 var DOM = tinymce.DOM;
\r
14 tinymce.create('tinymce.plugins.FullScreenPlugin', {
\r
15 init : function(ed, url) {
\r
16 var t = this, s = {}, vp;
\r
20 // Register commands
\r
21 ed.addCommand('mceFullScreen', function() {
\r
22 var win, de = DOM.doc.documentElement;
\r
24 if (ed.getParam('fullscreen_is_enabled')) {
\r
25 if (ed.getParam('fullscreen_new_window'))
\r
26 closeFullscreen(); // Call to close in new window
\r
28 DOM.win.setTimeout(function() {
\r
29 tinymce.dom.Event.remove(DOM.win, 'resize', t.resizeFunc);
\r
30 tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
\r
32 DOM.remove('mce_fullscreen_container');
\r
33 de.style.overflow = ed.getParam('fullscreen_html_overflow');
\r
34 DOM.setStyle(DOM.doc.body, 'overflow', ed.getParam('fullscreen_overflow'));
\r
35 DOM.win.scrollTo(ed.getParam('fullscreen_scrollx'), ed.getParam('fullscreen_scrolly'));
\r
36 tinyMCE.settings = tinyMCE.oldSettings; // Restore old settings
\r
43 if (ed.getParam('fullscreen_new_window')) {
\r
44 win = DOM.win.open(url + "/fullscreen.htm", "mceFullScreenPopup", "fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width=" + screen.availWidth + ",height=" + screen.availHeight);
\r
46 win.resizeTo(screen.availWidth, screen.availHeight);
\r
51 tinyMCE.oldSettings = tinyMCE.settings; // Store old settings
\r
52 s.fullscreen_overflow = DOM.getStyle(DOM.doc.body, 'overflow', 1) || 'auto';
\r
53 s.fullscreen_html_overflow = DOM.getStyle(de, 'overflow', 1);
\r
54 vp = DOM.getViewPort();
\r
55 s.fullscreen_scrollx = vp.x;
\r
56 s.fullscreen_scrolly = vp.y;
\r
58 // Fixes an Opera bug where the scrollbars doesn't reappear
\r
59 if (tinymce.isOpera && s.fullscreen_overflow == 'visible')
\r
60 s.fullscreen_overflow = 'auto';
\r
62 // Fixes an IE bug where horizontal scrollbars would appear
\r
63 if (tinymce.isIE && s.fullscreen_overflow == 'scroll')
\r
64 s.fullscreen_overflow = 'auto';
\r
66 // Fixes an IE bug where the scrollbars doesn't reappear
\r
67 if (tinymce.isIE && (s.fullscreen_html_overflow == 'visible' || s.fullscreen_html_overflow == 'scroll'))
\r
68 s.fullscreen_html_overflow = 'auto';
\r
70 if (s.fullscreen_overflow == '0px')
\r
71 s.fullscreen_overflow = '';
\r
73 DOM.setStyle(DOM.doc.body, 'overflow', 'hidden');
\r
74 de.style.overflow = 'hidden'; //Fix for IE6/7
\r
75 vp = DOM.getViewPort();
\r
76 DOM.win.scrollTo(0, 0);
\r
81 n = DOM.add(DOM.doc.body, 'div', {id : 'mce_fullscreen_container', style : 'position:' + (tinymce.isIE6 || (tinymce.isIE && !DOM.boxModel) ? 'absolute' : 'fixed') + ';top:0;left:0;width:' + vp.w + 'px;height:' + vp.h + 'px;z-index:200000;'});
\r
82 DOM.add(n, 'div', {id : 'mce_fullscreen'});
\r
84 tinymce.each(ed.settings, function(v, n) {
\r
88 s.id = 'mce_fullscreen';
\r
89 s.width = n.clientWidth;
\r
90 s.height = n.clientHeight - 15;
\r
91 s.fullscreen_is_enabled = true;
\r
92 s.fullscreen_editor_id = ed.id;
\r
93 s.theme_advanced_resizing = false;
\r
94 s.save_onsavecallback = function() {
\r
95 ed.setContent(tinyMCE.get(s.id).getContent({format : 'raw'}), {format : 'raw'});
\r
96 ed.execCommand('mceSave');
\r
99 tinymce.each(ed.getParam('fullscreen_settings'), function(v, k) {
\r
103 if (s.theme_advanced_toolbar_location === 'external')
\r
104 s.theme_advanced_toolbar_location = 'top';
\r
106 t.fullscreenEditor = new tinymce.Editor('mce_fullscreen', s);
\r
107 t.fullscreenEditor.onInit.add(function() {
\r
108 t.fullscreenEditor.setContent(ed.getContent());
\r
109 t.fullscreenEditor.focus();
\r
112 t.fullscreenEditor.render();
\r
114 t.fullscreenElement = new tinymce.dom.Element('mce_fullscreen_container');
\r
115 t.fullscreenElement.update();
\r
116 //document.body.overflow = 'hidden';
\r
118 t.resizeFunc = tinymce.dom.Event.add(DOM.win, 'resize', function() {
\r
119 var vp = tinymce.DOM.getViewPort(), fed = t.fullscreenEditor, outerSize, innerSize;
\r
121 // Get outer/inner size to get a delta size that can be used to calc the new iframe size
\r
122 outerSize = fed.dom.getSize(fed.getContainer().firstChild);
\r
123 innerSize = fed.dom.getSize(fed.getContainer().getElementsByTagName('iframe')[0]);
\r
125 fed.theme.resizeTo(vp.w - outerSize.w + innerSize.w, vp.h - outerSize.h + innerSize.h);
\r
130 // Register buttons
\r
131 ed.addButton('fullscreen', {title : 'fullscreen.desc', cmd : 'mceFullScreen'});
\r
133 ed.onNodeChange.add(function(ed, cm) {
\r
134 cm.setActive('fullscreen', ed.getParam('fullscreen_is_enabled'));
\r
138 getInfo : function() {
\r
140 longname : 'Fullscreen',
\r
141 author : 'Moxiecode Systems AB',
\r
142 authorurl : 'http://tinymce.moxiecode.com',
\r
143 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',
\r
144 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
150 tinymce.PluginManager.add('fullscreen', tinymce.plugins.FullScreenPlugin);
\r