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