2009-11-21 03:26:09 +01:00
|
|
|
/**
|
2011-04-05 01:42:57 +02:00
|
|
|
* editor_plugin_src.js
|
2009-11-21 03:26:09 +01:00
|
|
|
*
|
2011-04-05 01:42:57 +02:00
|
|
|
* Copyright 2009, Moxiecode Systems AB
|
|
|
|
* Released under LGPL License.
|
|
|
|
*
|
|
|
|
* License: http://tinymce.moxiecode.com/license
|
|
|
|
* Contributing: http://tinymce.moxiecode.com/contributing
|
2009-11-21 03:26:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
var DOM = tinymce.DOM;
|
|
|
|
|
2014-04-23 00:47:10 +02:00
|
|
|
// State Transfer function
|
|
|
|
var transferState = function(oldEditor, newEditor, bookmark) {
|
|
|
|
var transferColorButtonState = function(swapme) {
|
|
|
|
var c = oldEditor.controlManager.get(swapme);
|
|
|
|
var newC = newEditor.controlManager.get(swapme);
|
|
|
|
|
|
|
|
if (c && newC) {
|
|
|
|
newC.displayColor(c.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
transferColorButtonState('forecolor');
|
|
|
|
transferColorButtonState('backcolor');
|
|
|
|
newEditor.setContent(oldEditor.getContent({format : 'raw'}), {format : 'raw'});
|
|
|
|
newEditor.selection.moveToBookmark(bookmark);
|
|
|
|
|
|
|
|
if (oldEditor.plugins.spellchecker && newEditor.plugins.spellchecker) {
|
|
|
|
newEditor.plugins.spellchecker.setLanguage(oldEditor.plugins.spellchecker.selectedLang);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-11-21 03:26:09 +01:00
|
|
|
tinymce.create('tinymce.plugins.FullScreenPlugin', {
|
|
|
|
init : function(ed, url) {
|
2014-04-23 00:47:10 +02:00
|
|
|
var t = this, s = {}, de = DOM.doc.documentElement, vp, fullscreen_overflow, fullscreen_html_overflow, fullscreen_scrollx, fullscreen_scrolly, posCss, bookmark;
|
2009-11-21 03:26:09 +01:00
|
|
|
|
|
|
|
// Register commands
|
|
|
|
ed.addCommand('mceFullScreen', function() {
|
2014-04-23 00:47:10 +02:00
|
|
|
var win, oed;
|
2009-11-21 03:26:09 +01:00
|
|
|
|
|
|
|
if (ed.getParam('fullscreen_is_enabled')) {
|
|
|
|
if (ed.getParam('fullscreen_new_window'))
|
2014-04-23 00:47:10 +02:00
|
|
|
closeFullscreen(); // Call to close in fullscreen.htm
|
2009-11-21 03:26:09 +01:00
|
|
|
else {
|
|
|
|
DOM.win.setTimeout(function() {
|
2014-04-23 00:47:10 +02:00
|
|
|
var fullscreenEditor = ed;
|
|
|
|
|
|
|
|
// find the editor that opened this one, execute restore function there
|
|
|
|
var originalEditor = tinyMCE.get(fullscreenEditor.getParam('fullscreen_editor_id'));
|
|
|
|
originalEditor.plugins.fullscreen.saveState(fullscreenEditor);
|
|
|
|
|
|
|
|
tinyMCE.remove(fullscreenEditor);
|
2009-11-21 03:26:09 +01:00
|
|
|
}, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ed.getParam('fullscreen_new_window')) {
|
2014-04-23 00:47:10 +02:00
|
|
|
t.fullscreenSettings = {
|
|
|
|
bookmark: ed.selection.getBookmark()
|
|
|
|
};
|
2009-11-21 03:26:09 +01:00
|
|
|
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);
|
|
|
|
try {
|
|
|
|
win.resizeTo(screen.availWidth, screen.availHeight);
|
|
|
|
} catch (e) {
|
|
|
|
// Ignore
|
|
|
|
}
|
|
|
|
} else {
|
2014-04-23 00:47:10 +02:00
|
|
|
fullscreen_overflow = DOM.getStyle(DOM.doc.body, 'overflow', 1) || 'auto';
|
|
|
|
fullscreen_html_overflow = DOM.getStyle(de, 'overflow', 1);
|
2009-11-21 03:26:09 +01:00
|
|
|
vp = DOM.getViewPort();
|
2014-04-23 00:47:10 +02:00
|
|
|
fullscreen_scrollx = vp.x;
|
|
|
|
fullscreen_scrolly = vp.y;
|
2009-11-21 03:26:09 +01:00
|
|
|
|
|
|
|
// Fixes an Opera bug where the scrollbars doesn't reappear
|
2014-04-23 00:47:10 +02:00
|
|
|
if (tinymce.isOpera && fullscreen_overflow == 'visible')
|
|
|
|
fullscreen_overflow = 'auto';
|
2009-11-21 03:26:09 +01:00
|
|
|
|
|
|
|
// Fixes an IE bug where horizontal scrollbars would appear
|
2014-04-23 00:47:10 +02:00
|
|
|
if (tinymce.isIE && fullscreen_overflow == 'scroll')
|
|
|
|
fullscreen_overflow = 'auto';
|
2009-11-21 03:26:09 +01:00
|
|
|
|
|
|
|
// Fixes an IE bug where the scrollbars doesn't reappear
|
2014-04-23 00:47:10 +02:00
|
|
|
if (tinymce.isIE && (fullscreen_html_overflow == 'visible' || fullscreen_html_overflow == 'scroll'))
|
|
|
|
fullscreen_html_overflow = 'auto';
|
2009-11-21 03:26:09 +01:00
|
|
|
|
2014-04-23 00:47:10 +02:00
|
|
|
if (fullscreen_overflow == '0px')
|
|
|
|
fullscreen_overflow = '';
|
2009-11-21 03:26:09 +01:00
|
|
|
|
|
|
|
DOM.setStyle(DOM.doc.body, 'overflow', 'hidden');
|
|
|
|
de.style.overflow = 'hidden'; //Fix for IE6/7
|
|
|
|
vp = DOM.getViewPort();
|
|
|
|
DOM.win.scrollTo(0, 0);
|
|
|
|
|
|
|
|
if (tinymce.isIE)
|
|
|
|
vp.h -= 1;
|
|
|
|
|
2011-04-05 01:42:57 +02:00
|
|
|
// Use fixed position if it exists
|
2012-05-08 06:29:43 +02:00
|
|
|
if (tinymce.isIE6 || document.compatMode == 'BackCompat')
|
2011-04-05 01:42:57 +02:00
|
|
|
posCss = 'absolute;top:' + vp.y;
|
|
|
|
else
|
|
|
|
posCss = 'fixed;top:0';
|
|
|
|
|
|
|
|
n = DOM.add(DOM.doc.body, 'div', {
|
2012-09-14 05:26:17 +02:00
|
|
|
id : 'mce_fullscreen_container',
|
2011-04-05 01:42:57 +02:00
|
|
|
style : 'position:' + posCss + ';left:0;width:' + vp.w + 'px;height:' + vp.h + 'px;z-index:200000;'});
|
2009-11-21 03:26:09 +01:00
|
|
|
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;
|
|
|
|
s.save_onsavecallback = function() {
|
2011-10-29 11:43:39 +02:00
|
|
|
ed.setContent(tinyMCE.get(s.id).getContent());
|
2009-11-21 03:26:09 +01:00
|
|
|
ed.execCommand('mceSave');
|
|
|
|
};
|
|
|
|
|
|
|
|
tinymce.each(ed.getParam('fullscreen_settings'), function(v, k) {
|
|
|
|
s[k] = v;
|
|
|
|
});
|
|
|
|
|
2014-04-23 00:47:10 +02:00
|
|
|
t.fullscreenSettings = {
|
|
|
|
bookmark: ed.selection.getBookmark(),
|
|
|
|
fullscreen_overflow: fullscreen_overflow,
|
|
|
|
fullscreen_html_overflow: fullscreen_html_overflow,
|
|
|
|
fullscreen_scrollx: fullscreen_scrollx,
|
|
|
|
fullscreen_scrolly: fullscreen_scrolly
|
|
|
|
};
|
|
|
|
|
2009-11-21 03:26:09 +01:00
|
|
|
if (s.theme_advanced_toolbar_location === 'external')
|
|
|
|
s.theme_advanced_toolbar_location = 'top';
|
|
|
|
|
2014-04-23 00:47:10 +02:00
|
|
|
tinyMCE.oldSettings = tinyMCE.settings; // Store old settings, the Editor constructor overwrites them
|
2009-11-21 03:26:09 +01:00
|
|
|
t.fullscreenEditor = new tinymce.Editor('mce_fullscreen', s);
|
|
|
|
t.fullscreenEditor.onInit.add(function() {
|
2014-04-23 00:47:10 +02:00
|
|
|
t.loadState(t.fullscreenEditor);
|
2009-11-21 03:26:09 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
t.fullscreenEditor.render();
|
|
|
|
|
|
|
|
t.fullscreenElement = new tinymce.dom.Element('mce_fullscreen_container');
|
|
|
|
t.fullscreenElement.update();
|
|
|
|
//document.body.overflow = 'hidden';
|
|
|
|
|
|
|
|
t.resizeFunc = tinymce.dom.Event.add(DOM.win, 'resize', function() {
|
2011-04-05 01:42:57 +02:00
|
|
|
var vp = tinymce.DOM.getViewPort(), fed = t.fullscreenEditor, outerSize, innerSize;
|
|
|
|
|
|
|
|
// Get outer/inner size to get a delta size that can be used to calc the new iframe size
|
2012-09-14 05:26:17 +02:00
|
|
|
outerSize = fed.dom.getSize(fed.getContainer().getElementsByTagName('table')[0]);
|
2011-04-05 01:42:57 +02:00
|
|
|
innerSize = fed.dom.getSize(fed.getContainer().getElementsByTagName('iframe')[0]);
|
2009-11-21 03:26:09 +01:00
|
|
|
|
2011-04-05 01:42:57 +02:00
|
|
|
fed.theme.resizeTo(vp.w - outerSize.w + innerSize.w, vp.h - outerSize.h + innerSize.h);
|
2009-11-21 03:26:09 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Register buttons
|
|
|
|
ed.addButton('fullscreen', {title : 'fullscreen.desc', cmd : 'mceFullScreen'});
|
|
|
|
|
|
|
|
ed.onNodeChange.add(function(ed, cm) {
|
|
|
|
cm.setActive('fullscreen', ed.getParam('fullscreen_is_enabled'));
|
|
|
|
});
|
2014-04-23 00:47:10 +02:00
|
|
|
|
|
|
|
// fullscreenEditor is a param here because in window mode we don't create it
|
|
|
|
t.loadState = function(fullscreenEditor) {
|
|
|
|
if (!(fullscreenEditor && t.fullscreenSettings)) {
|
|
|
|
throw "No fullscreen editor to load to";
|
|
|
|
}
|
|
|
|
|
|
|
|
transferState(ed, fullscreenEditor, t.fullscreenSettings.bookmark);
|
|
|
|
fullscreenEditor.focus();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// fullscreenEditor is a param here because in window mode we don't create it
|
|
|
|
t.saveState = function(fullscreenEditor) {
|
|
|
|
if (!(fullscreenEditor && t.fullscreenSettings)) {
|
|
|
|
throw "No fullscreen editor to restore from";
|
|
|
|
}
|
|
|
|
var settings = t.fullscreenSettings;
|
|
|
|
|
|
|
|
transferState(fullscreenEditor, ed, fullscreenEditor.selection.getBookmark());
|
|
|
|
|
|
|
|
// cleanup only required if window mode isn't used
|
|
|
|
if (!ed.getParam('fullscreen_new_window')) {
|
|
|
|
tinymce.dom.Event.remove(DOM.win, 'resize', t.resizeFunc);
|
|
|
|
delete t.resizeFunc;
|
|
|
|
|
|
|
|
DOM.remove('mce_fullscreen_container');
|
|
|
|
|
|
|
|
DOM.doc.documentElement.style.overflow = settings.fullscreen_html_overflow;
|
|
|
|
DOM.setStyle(DOM.doc.body, 'overflow', settings.fullscreen_overflow);
|
|
|
|
DOM.win.scrollTo(settings.fullscreen_scrollx, settings.fullscreen_scrolly);
|
|
|
|
}
|
|
|
|
tinyMCE.settings = tinyMCE.oldSettings; // Restore old settings
|
|
|
|
|
|
|
|
// clear variables
|
|
|
|
delete tinyMCE.oldSettings;
|
|
|
|
delete t.fullscreenEditor;
|
|
|
|
delete t.fullscreenElement;
|
|
|
|
delete t.fullscreenSettings;
|
|
|
|
|
|
|
|
// allow the fullscreen editor to be removed before restoring focus and selection
|
|
|
|
DOM.win.setTimeout(function() {
|
|
|
|
ed.selection.moveToBookmark(bookmark);
|
|
|
|
ed.focus();
|
|
|
|
}, 10);
|
|
|
|
};
|
2009-11-21 03:26:09 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
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);
|
2012-09-14 05:26:17 +02:00
|
|
|
})();
|