1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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, oeID = window.opener.tinyMCE.activeEditor.id;
// 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'] = oeID;
settings['theme_advanced_resizing'] = false;
settings['strict_loading_mode'] = true;
settings.save_onsavecallback = function() {
moveContent();
window.opener.tinyMCE.get(oeID).execCommand('mceSave');
window.close();
};
function unloadHandler(e) {
moveContent();
}
function moveContent() {
// find the original editor, execute restore state in it's plugin instance
window.opener.tinyMCE.get(oeID).plugins.fullscreen.saveState(tinyMCE.activeEditor);
// prevent moveContent from being called twice - e.g. if the unloadHandler runs after moveContent()
tinymce.dom.Event.remove(window, "beforeunload", unloadHandler);
}
function closeFullscreen() {
// moveContent() will be called by the unload handler
window.close();
}
function doParentSubmit() {
moveContent();
if (window.opener.tinyMCE.selectedInstance.formElement.form)
window.opener.tinyMCE.selectedInstance.formElement.form.submit();
window.close();
return false;
}
function render() {
var e = document.getElementById('fullscreenarea'), vp, ed, ow, oh, dom = tinymce.DOM;
vp = dom.getViewPort();
settings.width = vp.w;
settings.height = vp.h - 15;
settings.oninit = function() {
var ed = tinyMCE.activeEditor;
window.opener.tinyMCE.get(oeID).plugins.fullscreen.loadState(ed);
tinymce.dom.Event.add(window, 'resize', function() {
var vp = dom.getViewPort();
tinyMCE.activeEditor.theme.resizeTo(vp.w, vp.h);
});
}
tinyMCE.init(settings);
}
// Add onunload
tinymce.dom.Event.add(window, "beforeunload", unloadHandler);
</script>
</head>
<body style="margin:0;overflow:hidden;width:100%;height:100%" scrolling="no" scroll="no">
<form onsubmit="doParentSubmit();">
<textarea id="fullscreenarea" style="width:100%; height:100%"></textarea>
</form>
<script type="text/javascript">
render();
</script>
</body>
</html>
|