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