2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
\r
5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
\r
8 /* Import plugin specific language pack */
\r
9 tinyMCE.importPluginLanguagePack('fullscreen');
\r
11 var TinyMCE_FullScreenPlugin = {
\r
12 getInfo : function() {
\r
14 longname : 'Fullscreen',
\r
15 author : 'Moxiecode Systems AB',
\r
16 authorurl : 'http://tinymce.moxiecode.com',
\r
17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',
\r
18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
\r
22 initInstance : function(inst) {
\r
23 if (!tinyMCE.settings['fullscreen_skip_plugin_css'])
\r
24 tinyMCE.importCSS(inst.getContainerWin().document, tinyMCE.baseURL + "/plugins/fullscreen/css/page.css");
\r
27 getControlHTML : function(cn) {
\r
30 return tinyMCE.getButtonHTML(cn, 'lang_fullscreen_desc', '{$pluginurl}/images/fullscreen.gif', 'mceFullScreen');
\r
36 execCommand : function(editor_id, element, command, user_interface, value) {
\r
41 case "mceFullScreen":
\r
42 inst = tinyMCE.getInstanceById(editor_id);
\r
44 if (tinyMCE.getParam('fullscreen_new_window'))
\r
45 this._toggleFullscreenWin(inst);
\r
47 this._toggleFullscreen(inst);
\r
52 // Pass to next handler in chain
\r
56 _toggleFullscreenWin : function(inst) {
\r
57 if (tinyMCE.getParam('fullscreen_is_enabled')) {
\r
58 // In fullscreen mode
\r
59 window.opener.tinyMCE.execInstanceCommand(tinyMCE.getParam('fullscreen_editor_id'), 'mceSetContent', false, tinyMCE.getContent(inst.editorId));
\r
62 tinyMCE.setWindowArg('editor_id', inst.editorId);
\r
64 var win = window.open(tinyMCE.baseURL + "/plugins/fullscreen/fullscreen.htm", "mceFullScreenPopup", "fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width=" + screen.availWidth + ",height=" + screen.availHeight);
\r
65 try { win.resizeTo(screen.availWidth, screen.availHeight); } catch (e) {}
\r
69 _toggleFullscreen : function(inst) {
\r
70 var ds = inst.getData('fullscreen'), editorContainer, tableElm, iframe, vp, cw, cd, re, w, h, si, blo, delta = 0, cell, row, fcml, bcml;
\r
72 cw = inst.getContainerWin();
\r
74 editorContainer = cd.getElementById(inst.editorId + '_parent');
\r
75 tableElm = editorContainer.firstChild;
\r
76 iframe = inst.iframeElement;
\r
77 re = cd.getElementById(inst.editorId + '_resize');
\r
78 blo = document.getElementById('mce_fullscreen_blocker');
\r
79 fcm = new TinyMCE_Layer(inst.editorId + '_fcMenu');
\r
80 fcml = new TinyMCE_Layer(inst.editorId + '_fcMenu');
\r
81 bcml = new TinyMCE_Layer(inst.editorId + '_bcMenu');
\r
83 if (fcml.exists() && fcml.isVisible()) {
\r
84 tinyMCE.switchClass(inst.editorId + '_forecolor', 'mceMenuButton');
\r
88 if (bcml.exists() && bcml.isVisible()) {
\r
89 tinyMCE.switchClass(inst.editorId + '_backcolor', 'mceMenuButton');
\r
94 // Handle External Toolbar
\r
95 if (inst.toolbarElement) {
\r
96 delta += inst.toolbarElement.offsetHeight;
\r
98 cell = tableElm.tBodies[0].insertRow(0).insertCell(-1);
\r
99 cell.className = 'mceToolbarTop';
\r
100 cell.nowrap = true;
\r
102 ds.oldToolbarParent = inst.toolbarElement.parentNode;
\r
103 ds.toolbarHolder = document.createTextNode('...');
\r
105 cell.appendChild(ds.oldToolbarParent.replaceChild(ds.toolbarHolder, inst.toolbarElement));
\r
110 vp = tinyMCE.getViewPort(cw);
\r
111 ds.scrollX = vp.left;
\r
112 ds.scrollY = vp.top;
\r
114 // Opera has a bug restoring scrollbars
\r
115 if (!tinyMCE.isOpera)
\r
116 tinyMCE.addCSSClass(cd.body, 'mceFullscreen');
\r
118 tinyMCE.getParentNode(tableElm.parentNode, function (n) {
\r
119 if (n.nodeName == 'BODY')
\r
122 if (n.nodeType == 1)
\r
123 tinyMCE.addCSSClass(n, 'mceFullscreenPos');
\r
129 re.style.display = 'none';
\r
131 vp = tinyMCE.getViewPort(cw);
\r
133 ds.oldWidth = iframe.style.width ? iframe.style.width : iframe.offsetWidth;
\r
134 ds.oldHeight = iframe.style.height ? iframe.style.height : iframe.offsetHeight;
\r
135 ds.oldTWidth = tableElm.style.width ? tableElm.style.width : tableElm.offsetWidth;
\r
136 ds.oldTHeight = tableElm.style.height ? tableElm.style.height : tableElm.offsetHeight;
\r
139 if (ds.oldWidth && ds.oldWidth.indexOf)
\r
140 ds.oldTWidth = ds.oldWidth.indexOf('%') != -1 ? ds.oldWidth : ds.oldTWidth;
\r
142 if (!blo && tinyMCE.isRealIE) {
\r
143 blo = tinyMCE.createTag(document, 'iframe', {id : 'mce_fullscreen_blocker', src : 'about:blank', frameBorder : 0, width : vp.width, height : vp.height, style : 'display: block; position: absolute; left: 0; top: 0; z-index: 999; margin: 0; padding: 0;'});
\r
144 document.body.appendChild(blo);
\r
147 tableElm.style.position = 'absolute';
\r
148 tableElm.style.zIndex = 1000;
\r
149 tableElm.style.left = tableElm.style.top = '0';
\r
151 tableElm.style.width = vp.width + 'px';
\r
152 tableElm.style.height = vp.height + 'px';
\r
154 if (tinyMCE.isRealIE) {
\r
155 iframe.style.width = vp.width + 'px';
\r
156 iframe.style.height = vp.height + 'px';
\r
158 // Calc new width/height based on overflow
\r
159 w = iframe.parentNode.clientWidth - (tableElm.offsetWidth - vp.width);
\r
160 h = iframe.parentNode.clientHeight - (tableElm.offsetHeight - vp.height);
\r
162 w = iframe.parentNode.clientWidth;
\r
163 h = iframe.parentNode.clientHeight;
\r
166 iframe.style.width = w + "px";
\r
167 iframe.style.height = (h+delta) + "px";
\r
169 tinyMCE.switchClass(inst.editorId + '_fullscreen', 'mceButtonSelected');
\r
172 inst.useCSS = false;
\r
174 // Handle External Toolbar
\r
175 if (inst.toolbarElement) {
\r
176 row = inst.toolbarElement.parentNode.parentNode;
\r
178 row.parentNode.removeChild(row);
\r
180 ds.oldToolbarParent.replaceChild(inst.toolbarElement, ds.toolbarHolder);
\r
182 ds.oldToolbarParent = null;
\r
183 ds.toolbarHolder = null;
\r
187 blo.parentNode.removeChild(blo);
\r
190 tinyMCE.getParentNode(tableElm.parentNode, function (n) {
\r
191 if (n.nodeName == 'BODY')
\r
194 if (n.nodeType == 1)
\r
195 tinyMCE.removeCSSClass(n, 'mceFullscreenPos');
\r
198 if (re && tinyMCE.getParam("theme_advanced_resizing", false))
\r
199 re.style.display = 'block';
\r
201 tableElm.style.position = 'static';
\r
202 tableElm.style.zIndex = '';
\r
203 tableElm.style.width = '';
\r
204 tableElm.style.height = '';
\r
206 tableElm.style.width = ds.oldTWidth ? ds.oldTWidth : '';
\r
207 tableElm.style.height = ds.oldTHeight ? ds.oldTHeight : '';
\r
209 iframe.style.width = ds.oldWidth ? ds.oldWidth : '';
\r
210 iframe.style.height = ds.oldHeight ? ds.oldHeight : '';
\r
212 tinyMCE.switchClass(inst.editorId + '_fullscreen', 'mceButtonNormal');
\r
213 ds.enabled = false;
\r
215 tinyMCE.removeCSSClass(cd.body, 'mceFullscreen');
\r
216 cw.scrollTo(ds.scrollX, ds.scrollY);
\r
218 inst.useCSS = false;
\r
222 handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
\r
223 if (tinyMCE.getParam('fullscreen_is_enabled'))
\r
224 tinyMCE.switchClass(editor_id + '_fullscreen', 'mceButtonSelected');
\r
230 tinyMCE.addPlugin("fullscreen", TinyMCE_FullScreenPlugin);
\r