Add fullscreen plugin. Props andy. fixes #5735
git-svn-id: https://develop.svn.wordpress.org/trunk@6689 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e518fc833f
commit
c2cf577187
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
* $Id: editor_plugin_src.js 544 2008-01-17 13:07:00Z spocke $
|
||||
*
|
||||
* @author Moxiecode
|
||||
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var DOM = tinymce.DOM;
|
||||
|
||||
tinymce.create('tinymce.plugins.FullScreenPlugin', {
|
||||
init : function(ed, url) {
|
||||
var t = this, s = {}, vp;
|
||||
|
||||
t.editor = ed;
|
||||
|
||||
// Register commands
|
||||
ed.addCommand('mceFullScreen', function() {
|
||||
var win, de = document.documentElement;
|
||||
|
||||
if (ed.getParam('fullscreen_is_enabled')) {
|
||||
if (ed.getParam('fullscreen_new_window'))
|
||||
closeFullscreen(); // Call to close in new window
|
||||
else {
|
||||
window.setTimeout(function() {
|
||||
tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
|
||||
tinyMCE.remove(ed);
|
||||
DOM.remove('mce_fullscreen_container');
|
||||
de.style.overflow = ed.getParam('fullscreen_html_overflow');
|
||||
DOM.setStyle(document.body, 'overflow', ed.getParam('fullscreen_overflow'));
|
||||
window.scrollTo(ed.getParam('fullscreen_scrollx'), ed.getParam('fullscreen_scrolly'));
|
||||
}, 10);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ed.getParam('fullscreen_new_window')) {
|
||||
win = window.open(url + "/fullscreen.htm", "mceFullScreenPopup", "fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=no,left=0,top=0,width=" + screen.availWidth + ",height=" + screen.availHeight);
|
||||
try {
|
||||
win.resizeTo(screen.availWidth, screen.availHeight);
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
} else {
|
||||
s.fullscreen_overflow = DOM.getStyle(document.body, 'overflow', 1) || 'auto';
|
||||
s.fullscreen_html_overflow = DOM.getStyle(de, 'overflow', 1);
|
||||
vp = DOM.getViewPort();
|
||||
s.fullscreen_scrollx = vp.x;
|
||||
s.fullscreen_scrolly = vp.y;
|
||||
|
||||
// Fixes an Opera bug where the scrollbars doesn't reappear
|
||||
if (tinymce.isOpera && s.fullscreen_overflow == 'visible')
|
||||
s.fullscreen_overflow = 'auto';
|
||||
|
||||
// Fixes an IE bug where horizontal scrollbars would appear
|
||||
if (tinymce.isIE && s.fullscreen_overflow == 'scroll')
|
||||
s.fullscreen_overflow = 'auto';
|
||||
|
||||
if (s.fullscreen_overflow == '0px')
|
||||
s.fullscreen_overflow = '';
|
||||
|
||||
DOM.setStyle(document.body, 'overflow', 'hidden');
|
||||
de.style.overflow = 'hidden'; //Fix for IE6/7
|
||||
vp = DOM.getViewPort();
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
if (tinymce.isIE)
|
||||
vp.h -= 1;
|
||||
|
||||
n = DOM.add(document.body, 'div', {id : 'mce_fullscreen_container', style : 'position:absolute;top:0;left:0;width:' + vp.w + 'px;height:' + vp.h + 'px;z-index:150;'});
|
||||
DOM.add(n, 'div', {id : 'mce_fullscreen'});
|
||||
|
||||
tinymce.each(ed.settings, function(v, n) {
|
||||
s[n] = v;
|
||||
});
|
||||
|
||||
s.id = 'mce_fullscreen';
|
||||
s.width = n.clientWidth;
|
||||
s.height = n.clientHeight - 15;
|
||||
s.fullscreen_is_enabled = true;
|
||||
s.fullscreen_editor_id = ed.id;
|
||||
s.theme_advanced_resizing = false;
|
||||
|
||||
tinymce.each(ed.getParam('fullscreen_settings'), function(v, k) {
|
||||
s[k] = v;
|
||||
});
|
||||
|
||||
if (s.theme_advanced_toolbar_location === 'external')
|
||||
s.theme_advanced_toolbar_location = 'top';
|
||||
|
||||
t.fullscreenEditor = new tinymce.Editor('mce_fullscreen', s);
|
||||
t.fullscreenEditor.onInit.add(function() {
|
||||
t.fullscreenEditor.setContent(ed.getContent({format : 'raw', no_events : 1}), {format : 'raw', no_events : 1});
|
||||
});
|
||||
|
||||
t.fullscreenEditor.render();
|
||||
tinyMCE.add(t.fullscreenEditor);
|
||||
|
||||
t.fullscreenElement = new tinymce.dom.Element('mce_fullscreen_container');
|
||||
t.fullscreenElement.update();
|
||||
//document.body.overflow = 'hidden';
|
||||
}
|
||||
});
|
||||
|
||||
// Register buttons
|
||||
ed.addButton('fullscreen', {title : 'fullscreen.desc', cmd : 'mceFullScreen'});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm) {
|
||||
cm.setActive('fullscreen', ed.getParam('fullscreen_is_enabled'));
|
||||
});
|
||||
},
|
||||
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'Fullscreen',
|
||||
author : 'Moxiecode Systems AB',
|
||||
authorurl : 'http://tinymce.moxiecode.com',
|
||||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',
|
||||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('fullscreen', tinymce.plugins.FullScreenPlugin);
|
||||
})();
|
|
@ -0,0 +1,88 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{$lang_fullscreen_title}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<script type="text/javascript" src="../../tiny_mce.js"></script>
|
||||
<script type="text/javascript">
|
||||
function patchCallback(settings, key) {
|
||||
if (settings[key])
|
||||
settings[key] = "window.opener." + settings[key];
|
||||
}
|
||||
|
||||
var settings = {}, paSe = window.opener.tinyMCE.activeEditor.settings;
|
||||
|
||||
// Clone array
|
||||
for (var n in paSe)
|
||||
settings[n] = paSe[n];
|
||||
|
||||
// Override options for fullscreen
|
||||
for (var n in paSe.fullscreen_settings)
|
||||
settings[n] = paSe.fullscreen_settings[n];
|
||||
|
||||
// Patch callbacks, make them point to window.opener
|
||||
patchCallback(settings, 'urlconverter_callback');
|
||||
patchCallback(settings, 'insertlink_callback');
|
||||
patchCallback(settings, 'insertimage_callback');
|
||||
patchCallback(settings, 'setupcontent_callback');
|
||||
patchCallback(settings, 'save_callback');
|
||||
patchCallback(settings, 'onchange_callback');
|
||||
patchCallback(settings, 'init_instance_callback');
|
||||
patchCallback(settings, 'file_browser_callback');
|
||||
patchCallback(settings, 'cleanup_callback');
|
||||
patchCallback(settings, 'execcommand_callback');
|
||||
patchCallback(settings, 'oninit');
|
||||
|
||||
// Set options
|
||||
delete settings.id;
|
||||
settings['mode'] = 'exact';
|
||||
settings['elements'] = 'fullscreenarea';
|
||||
settings['add_unload_trigger'] = false;
|
||||
settings['ask'] = false;
|
||||
settings['document_base_url'] = window.opener.tinyMCE.activeEditor.documentBaseURI.getURI();
|
||||
settings['fullscreen_is_enabled'] = true;
|
||||
settings['fullscreen_editor_id'] = window.opener.tinyMCE.activeEditor.id;
|
||||
settings['theme_advanced_resizing'] = false;
|
||||
|
||||
function unloadHandler(e) {
|
||||
moveContent();
|
||||
}
|
||||
|
||||
function moveContent() {
|
||||
window.opener.tinyMCE.activeEditor.setContent(tinyMCE.activeEditor.getContent({format : 'raw'}));
|
||||
}
|
||||
|
||||
function closeFullscreen() {
|
||||
moveContent();
|
||||
window.close();
|
||||
}
|
||||
|
||||
// Add onunload
|
||||
tinymce.dom.Event.add(window, "beforeunload", unloadHandler);
|
||||
|
||||
function doParentSubmit() {
|
||||
moveContent();
|
||||
|
||||
if (window.opener.tinyMCE.selectedInstance.formElement.form)
|
||||
window.opener.tinyMCE.selectedInstance.formElement.form.submit();
|
||||
|
||||
window.close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function init() {
|
||||
var e = document.getElementById('fullscreenarea');
|
||||
e.value = window.opener.tinyMCE.activeEditor.getContent({format : 'raw'});
|
||||
settings['width'] = e.clientWidth;
|
||||
settings['height'] = e.clientHeight;
|
||||
tinyMCE.init(settings);
|
||||
}
|
||||
</script>
|
||||
<base target="_self" />
|
||||
</head>
|
||||
<body onload="init();" style="margin:0; overflow:hidden; height:100%;" scrolling="no" scroll="no">
|
||||
<form onsubmit="doParentSubmit();" style="height: 100%">
|
||||
<textarea id="fullscreenarea" style="width:100%; height:100%"></textarea>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -27,14 +27,14 @@
|
|||
|
||||
$invalid_elements = apply_filters('mce_invalid_elements', '');
|
||||
|
||||
$plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'wphelp', 'media' );
|
||||
$plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'wphelp', 'media', 'fullscreen' );
|
||||
$plugins = apply_filters('mce_plugins', $plugins);
|
||||
$plugins = implode($plugins, ',');
|
||||
|
||||
$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'link', 'unlink', 'image', 'wp_more', 'separator', 'spellchecker', 'separator', 'wp_help', 'wp_adv', 'wp_adv_start', 'wp_adv_end'));
|
||||
$mce_buttons = implode($mce_buttons, ',');
|
||||
|
||||
$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', 'media', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo'));
|
||||
$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', 'media', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo', 'fullscreen'));
|
||||
$mce_buttons_2 = implode($mce_buttons_2, ',');
|
||||
|
||||
$mce_buttons_3 = apply_filters('mce_buttons_3', array());
|
||||
|
|
Loading…
Reference in New Issue