bgneal@45
|
1 /**
|
bgneal@183
|
2 * editor_plugin_src.js
|
bgneal@45
|
3 *
|
bgneal@183
|
4 * Copyright 2009, Moxiecode Systems AB
|
bgneal@183
|
5 * Released under LGPL License.
|
bgneal@183
|
6 *
|
bgneal@183
|
7 * License: http://tinymce.moxiecode.com/license
|
bgneal@183
|
8 * Contributing: http://tinymce.moxiecode.com/contributing
|
bgneal@45
|
9 */
|
bgneal@45
|
10
|
bgneal@45
|
11 (function() {
|
bgneal@45
|
12 var DOM = tinymce.DOM;
|
bgneal@45
|
13
|
bgneal@45
|
14 tinymce.create('tinymce.plugins.FullScreenPlugin', {
|
bgneal@45
|
15 init : function(ed, url) {
|
bgneal@45
|
16 var t = this, s = {}, vp;
|
bgneal@45
|
17
|
bgneal@45
|
18 t.editor = ed;
|
bgneal@45
|
19
|
bgneal@45
|
20 // Register commands
|
bgneal@45
|
21 ed.addCommand('mceFullScreen', function() {
|
bgneal@45
|
22 var win, de = DOM.doc.documentElement;
|
bgneal@45
|
23
|
bgneal@45
|
24 if (ed.getParam('fullscreen_is_enabled')) {
|
bgneal@45
|
25 if (ed.getParam('fullscreen_new_window'))
|
bgneal@45
|
26 closeFullscreen(); // Call to close in new window
|
bgneal@45
|
27 else {
|
bgneal@45
|
28 DOM.win.setTimeout(function() {
|
bgneal@45
|
29 tinymce.dom.Event.remove(DOM.win, 'resize', t.resizeFunc);
|
bgneal@45
|
30 tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
|
bgneal@45
|
31 tinyMCE.remove(ed);
|
bgneal@45
|
32 DOM.remove('mce_fullscreen_container');
|
bgneal@45
|
33 de.style.overflow = ed.getParam('fullscreen_html_overflow');
|
bgneal@45
|
34 DOM.setStyle(DOM.doc.body, 'overflow', ed.getParam('fullscreen_overflow'));
|
bgneal@45
|
35 DOM.win.scrollTo(ed.getParam('fullscreen_scrollx'), ed.getParam('fullscreen_scrolly'));
|
bgneal@45
|
36 tinyMCE.settings = tinyMCE.oldSettings; // Restore old settings
|
bgneal@45
|
37 }, 10);
|
bgneal@45
|
38 }
|
bgneal@45
|
39
|
bgneal@45
|
40 return;
|
bgneal@45
|
41 }
|
bgneal@45
|
42
|
bgneal@45
|
43 if (ed.getParam('fullscreen_new_window')) {
|
bgneal@45
|
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);
|
bgneal@45
|
45 try {
|
bgneal@45
|
46 win.resizeTo(screen.availWidth, screen.availHeight);
|
bgneal@45
|
47 } catch (e) {
|
bgneal@45
|
48 // Ignore
|
bgneal@45
|
49 }
|
bgneal@45
|
50 } else {
|
bgneal@45
|
51 tinyMCE.oldSettings = tinyMCE.settings; // Store old settings
|
bgneal@45
|
52 s.fullscreen_overflow = DOM.getStyle(DOM.doc.body, 'overflow', 1) || 'auto';
|
bgneal@45
|
53 s.fullscreen_html_overflow = DOM.getStyle(de, 'overflow', 1);
|
bgneal@45
|
54 vp = DOM.getViewPort();
|
bgneal@45
|
55 s.fullscreen_scrollx = vp.x;
|
bgneal@45
|
56 s.fullscreen_scrolly = vp.y;
|
bgneal@45
|
57
|
bgneal@45
|
58 // Fixes an Opera bug where the scrollbars doesn't reappear
|
bgneal@45
|
59 if (tinymce.isOpera && s.fullscreen_overflow == 'visible')
|
bgneal@45
|
60 s.fullscreen_overflow = 'auto';
|
bgneal@45
|
61
|
bgneal@45
|
62 // Fixes an IE bug where horizontal scrollbars would appear
|
bgneal@45
|
63 if (tinymce.isIE && s.fullscreen_overflow == 'scroll')
|
bgneal@45
|
64 s.fullscreen_overflow = 'auto';
|
bgneal@45
|
65
|
bgneal@45
|
66 // Fixes an IE bug where the scrollbars doesn't reappear
|
bgneal@45
|
67 if (tinymce.isIE && (s.fullscreen_html_overflow == 'visible' || s.fullscreen_html_overflow == 'scroll'))
|
bgneal@45
|
68 s.fullscreen_html_overflow = 'auto';
|
bgneal@45
|
69
|
bgneal@45
|
70 if (s.fullscreen_overflow == '0px')
|
bgneal@45
|
71 s.fullscreen_overflow = '';
|
bgneal@45
|
72
|
bgneal@45
|
73 DOM.setStyle(DOM.doc.body, 'overflow', 'hidden');
|
bgneal@45
|
74 de.style.overflow = 'hidden'; //Fix for IE6/7
|
bgneal@45
|
75 vp = DOM.getViewPort();
|
bgneal@45
|
76 DOM.win.scrollTo(0, 0);
|
bgneal@45
|
77
|
bgneal@45
|
78 if (tinymce.isIE)
|
bgneal@45
|
79 vp.h -= 1;
|
bgneal@45
|
80
|
bgneal@45
|
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;'});
|
bgneal@45
|
82 DOM.add(n, 'div', {id : 'mce_fullscreen'});
|
bgneal@45
|
83
|
bgneal@45
|
84 tinymce.each(ed.settings, function(v, n) {
|
bgneal@45
|
85 s[n] = v;
|
bgneal@45
|
86 });
|
bgneal@45
|
87
|
bgneal@45
|
88 s.id = 'mce_fullscreen';
|
bgneal@45
|
89 s.width = n.clientWidth;
|
bgneal@45
|
90 s.height = n.clientHeight - 15;
|
bgneal@45
|
91 s.fullscreen_is_enabled = true;
|
bgneal@45
|
92 s.fullscreen_editor_id = ed.id;
|
bgneal@45
|
93 s.theme_advanced_resizing = false;
|
bgneal@45
|
94 s.save_onsavecallback = function() {
|
bgneal@45
|
95 ed.setContent(tinyMCE.get(s.id).getContent({format : 'raw'}), {format : 'raw'});
|
bgneal@45
|
96 ed.execCommand('mceSave');
|
bgneal@45
|
97 };
|
bgneal@45
|
98
|
bgneal@45
|
99 tinymce.each(ed.getParam('fullscreen_settings'), function(v, k) {
|
bgneal@45
|
100 s[k] = v;
|
bgneal@45
|
101 });
|
bgneal@45
|
102
|
bgneal@45
|
103 if (s.theme_advanced_toolbar_location === 'external')
|
bgneal@45
|
104 s.theme_advanced_toolbar_location = 'top';
|
bgneal@45
|
105
|
bgneal@45
|
106 t.fullscreenEditor = new tinymce.Editor('mce_fullscreen', s);
|
bgneal@45
|
107 t.fullscreenEditor.onInit.add(function() {
|
bgneal@45
|
108 t.fullscreenEditor.setContent(ed.getContent());
|
bgneal@45
|
109 t.fullscreenEditor.focus();
|
bgneal@45
|
110 });
|
bgneal@45
|
111
|
bgneal@45
|
112 t.fullscreenEditor.render();
|
bgneal@45
|
113
|
bgneal@45
|
114 t.fullscreenElement = new tinymce.dom.Element('mce_fullscreen_container');
|
bgneal@45
|
115 t.fullscreenElement.update();
|
bgneal@45
|
116 //document.body.overflow = 'hidden';
|
bgneal@45
|
117
|
bgneal@45
|
118 t.resizeFunc = tinymce.dom.Event.add(DOM.win, 'resize', function() {
|
bgneal@217
|
119 var vp = tinymce.DOM.getViewPort(), fed = t.fullscreenEditor, outerSize, innerSize;
|
bgneal@45
|
120
|
bgneal@217
|
121 // Get outer/inner size to get a delta size that can be used to calc the new iframe size
|
bgneal@217
|
122 outerSize = fed.dom.getSize(fed.getContainer());
|
bgneal@217
|
123 innerSize = fed.dom.getSize(fed.getContainer().getElementsByTagName('iframe')[0]);
|
bgneal@217
|
124
|
bgneal@217
|
125 fed.theme.resizeTo(vp.w - outerSize.w + innerSize.w, vp.h - outerSize.h + innerSize.h);
|
bgneal@45
|
126 });
|
bgneal@45
|
127 }
|
bgneal@45
|
128 });
|
bgneal@45
|
129
|
bgneal@45
|
130 // Register buttons
|
bgneal@45
|
131 ed.addButton('fullscreen', {title : 'fullscreen.desc', cmd : 'mceFullScreen'});
|
bgneal@45
|
132
|
bgneal@45
|
133 ed.onNodeChange.add(function(ed, cm) {
|
bgneal@45
|
134 cm.setActive('fullscreen', ed.getParam('fullscreen_is_enabled'));
|
bgneal@45
|
135 });
|
bgneal@45
|
136 },
|
bgneal@45
|
137
|
bgneal@45
|
138 getInfo : function() {
|
bgneal@45
|
139 return {
|
bgneal@45
|
140 longname : 'Fullscreen',
|
bgneal@45
|
141 author : 'Moxiecode Systems AB',
|
bgneal@45
|
142 authorurl : 'http://tinymce.moxiecode.com',
|
bgneal@45
|
143 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',
|
bgneal@45
|
144 version : tinymce.majorVersion + "." + tinymce.minorVersion
|
bgneal@45
|
145 };
|
bgneal@45
|
146 }
|
bgneal@45
|
147 });
|
bgneal@45
|
148
|
bgneal@45
|
149 // Register plugin
|
bgneal@45
|
150 tinymce.PluginManager.add('fullscreen', tinymce.plugins.FullScreenPlugin);
|
bgneal@45
|
151 })(); |