bgneal@312: /** bgneal@312: * editor_plugin_src.js bgneal@312: * bgneal@312: * Copyright 2009, Moxiecode Systems AB bgneal@312: * Released under LGPL License. bgneal@312: * bgneal@312: * License: http://tinymce.moxiecode.com/license bgneal@312: * Contributing: http://tinymce.moxiecode.com/contributing bgneal@312: */ bgneal@312: bgneal@312: (function() { bgneal@312: var DOM = tinymce.DOM; bgneal@312: bgneal@312: tinymce.create('tinymce.plugins.FullScreenPlugin', { bgneal@312: init : function(ed, url) { bgneal@312: var t = this, s = {}, vp; bgneal@312: bgneal@312: t.editor = ed; bgneal@312: bgneal@312: // Register commands bgneal@312: ed.addCommand('mceFullScreen', function() { bgneal@312: var win, de = DOM.doc.documentElement; bgneal@312: bgneal@312: if (ed.getParam('fullscreen_is_enabled')) { bgneal@312: if (ed.getParam('fullscreen_new_window')) bgneal@312: closeFullscreen(); // Call to close in new window bgneal@312: else { bgneal@312: DOM.win.setTimeout(function() { bgneal@312: tinymce.dom.Event.remove(DOM.win, 'resize', t.resizeFunc); bgneal@312: tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format : 'raw'}), {format : 'raw'}); bgneal@312: tinyMCE.remove(ed); bgneal@312: DOM.remove('mce_fullscreen_container'); bgneal@312: de.style.overflow = ed.getParam('fullscreen_html_overflow'); bgneal@312: DOM.setStyle(DOM.doc.body, 'overflow', ed.getParam('fullscreen_overflow')); bgneal@312: DOM.win.scrollTo(ed.getParam('fullscreen_scrollx'), ed.getParam('fullscreen_scrolly')); bgneal@312: tinyMCE.settings = tinyMCE.oldSettings; // Restore old settings bgneal@312: }, 10); bgneal@312: } bgneal@312: bgneal@312: return; bgneal@312: } bgneal@312: bgneal@312: if (ed.getParam('fullscreen_new_window')) { bgneal@312: 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@312: try { bgneal@312: win.resizeTo(screen.availWidth, screen.availHeight); bgneal@312: } catch (e) { bgneal@312: // Ignore bgneal@312: } bgneal@312: } else { bgneal@312: tinyMCE.oldSettings = tinyMCE.settings; // Store old settings bgneal@312: s.fullscreen_overflow = DOM.getStyle(DOM.doc.body, 'overflow', 1) || 'auto'; bgneal@312: s.fullscreen_html_overflow = DOM.getStyle(de, 'overflow', 1); bgneal@312: vp = DOM.getViewPort(); bgneal@312: s.fullscreen_scrollx = vp.x; bgneal@312: s.fullscreen_scrolly = vp.y; bgneal@312: bgneal@312: // Fixes an Opera bug where the scrollbars doesn't reappear bgneal@312: if (tinymce.isOpera && s.fullscreen_overflow == 'visible') bgneal@312: s.fullscreen_overflow = 'auto'; bgneal@312: bgneal@312: // Fixes an IE bug where horizontal scrollbars would appear bgneal@312: if (tinymce.isIE && s.fullscreen_overflow == 'scroll') bgneal@312: s.fullscreen_overflow = 'auto'; bgneal@312: bgneal@312: // Fixes an IE bug where the scrollbars doesn't reappear bgneal@312: if (tinymce.isIE && (s.fullscreen_html_overflow == 'visible' || s.fullscreen_html_overflow == 'scroll')) bgneal@312: s.fullscreen_html_overflow = 'auto'; bgneal@312: bgneal@312: if (s.fullscreen_overflow == '0px') bgneal@312: s.fullscreen_overflow = ''; bgneal@312: bgneal@312: DOM.setStyle(DOM.doc.body, 'overflow', 'hidden'); bgneal@312: de.style.overflow = 'hidden'; //Fix for IE6/7 bgneal@312: vp = DOM.getViewPort(); bgneal@312: DOM.win.scrollTo(0, 0); bgneal@312: bgneal@312: if (tinymce.isIE) bgneal@312: vp.h -= 1; bgneal@312: bgneal@312: 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@312: DOM.add(n, 'div', {id : 'mce_fullscreen'}); bgneal@312: bgneal@312: tinymce.each(ed.settings, function(v, n) { bgneal@312: s[n] = v; bgneal@312: }); bgneal@312: bgneal@312: s.id = 'mce_fullscreen'; bgneal@312: s.width = n.clientWidth; bgneal@312: s.height = n.clientHeight - 15; bgneal@312: s.fullscreen_is_enabled = true; bgneal@312: s.fullscreen_editor_id = ed.id; bgneal@312: s.theme_advanced_resizing = false; bgneal@312: s.save_onsavecallback = function() { bgneal@312: ed.setContent(tinyMCE.get(s.id).getContent({format : 'raw'}), {format : 'raw'}); bgneal@312: ed.execCommand('mceSave'); bgneal@312: }; bgneal@312: bgneal@312: tinymce.each(ed.getParam('fullscreen_settings'), function(v, k) { bgneal@312: s[k] = v; bgneal@312: }); bgneal@312: bgneal@312: if (s.theme_advanced_toolbar_location === 'external') bgneal@312: s.theme_advanced_toolbar_location = 'top'; bgneal@312: bgneal@312: t.fullscreenEditor = new tinymce.Editor('mce_fullscreen', s); bgneal@312: t.fullscreenEditor.onInit.add(function() { bgneal@312: t.fullscreenEditor.setContent(ed.getContent()); bgneal@312: t.fullscreenEditor.focus(); bgneal@312: }); bgneal@312: bgneal@312: t.fullscreenEditor.render(); bgneal@312: bgneal@312: t.fullscreenElement = new tinymce.dom.Element('mce_fullscreen_container'); bgneal@312: t.fullscreenElement.update(); bgneal@312: //document.body.overflow = 'hidden'; bgneal@312: bgneal@312: t.resizeFunc = tinymce.dom.Event.add(DOM.win, 'resize', function() { bgneal@312: var vp = tinymce.DOM.getViewPort(), fed = t.fullscreenEditor, outerSize, innerSize; bgneal@312: bgneal@312: // Get outer/inner size to get a delta size that can be used to calc the new iframe size bgneal@312: outerSize = fed.dom.getSize(fed.getContainer().firstChild); bgneal@312: innerSize = fed.dom.getSize(fed.getContainer().getElementsByTagName('iframe')[0]); bgneal@312: bgneal@312: fed.theme.resizeTo(vp.w - outerSize.w + innerSize.w, vp.h - outerSize.h + innerSize.h); bgneal@312: }); bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: // Register buttons bgneal@312: ed.addButton('fullscreen', {title : 'fullscreen.desc', cmd : 'mceFullScreen'}); bgneal@312: bgneal@312: ed.onNodeChange.add(function(ed, cm) { bgneal@312: cm.setActive('fullscreen', ed.getParam('fullscreen_is_enabled')); bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: getInfo : function() { bgneal@312: return { bgneal@312: longname : 'Fullscreen', bgneal@312: author : 'Moxiecode Systems AB', bgneal@312: authorurl : 'http://tinymce.moxiecode.com', bgneal@312: infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen', bgneal@312: version : tinymce.majorVersion + "." + tinymce.minorVersion bgneal@312: }; bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: // Register plugin bgneal@312: tinymce.PluginManager.add('fullscreen', tinymce.plugins.FullScreenPlugin); bgneal@312: })();