nouveau style menu_top
[mtweb] / mw / libs / tiny_mce / plugins / fullscreen / editor_plugin_src.js
1 /**\r
2  * editor_plugin_src.js\r
3  *\r
4  * Copyright 2009, Moxiecode Systems AB\r
5  * Released under LGPL License.\r
6  *\r
7  * License: http://tinymce.moxiecode.com/license\r
8  * Contributing: http://tinymce.moxiecode.com/contributing\r
9  */\r
10 \r
11 (function() {\r
12         var DOM = tinymce.DOM;\r
13 \r
14         tinymce.create('tinymce.plugins.FullScreenPlugin', {\r
15                 init : function(ed, url) {\r
16                         var t = this, s = {}, vp;\r
17 \r
18                         t.editor = ed;\r
19 \r
20                         // Register commands\r
21                         ed.addCommand('mceFullScreen', function() {\r
22                                 var win, de = DOM.doc.documentElement;\r
23 \r
24                                 if (ed.getParam('fullscreen_is_enabled')) {\r
25                                         if (ed.getParam('fullscreen_new_window'))\r
26                                                 closeFullscreen(); // Call to close in new window\r
27                                         else {\r
28                                                 DOM.win.setTimeout(function() {\r
29                                                         tinymce.dom.Event.remove(DOM.win, 'resize', t.resizeFunc);\r
30                                                         tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format : 'raw'}), {format : 'raw'});\r
31                                                         tinyMCE.remove(ed);\r
32                                                         DOM.remove('mce_fullscreen_container');\r
33                                                         de.style.overflow = ed.getParam('fullscreen_html_overflow');\r
34                                                         DOM.setStyle(DOM.doc.body, 'overflow', ed.getParam('fullscreen_overflow'));\r
35                                                         DOM.win.scrollTo(ed.getParam('fullscreen_scrollx'), ed.getParam('fullscreen_scrolly'));\r
36                                                         tinyMCE.settings = tinyMCE.oldSettings; // Restore old settings\r
37                                                 }, 10);\r
38                                         }\r
39 \r
40                                         return;\r
41                                 }\r
42 \r
43                                 if (ed.getParam('fullscreen_new_window')) {\r
44                                         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);\r
45                                         try {\r
46                                                 win.resizeTo(screen.availWidth, screen.availHeight);\r
47                                         } catch (e) {\r
48                                                 // Ignore\r
49                                         }\r
50                                 } else {\r
51                                         tinyMCE.oldSettings = tinyMCE.settings; // Store old settings\r
52                                         s.fullscreen_overflow = DOM.getStyle(DOM.doc.body, 'overflow', 1) || 'auto';\r
53                                         s.fullscreen_html_overflow = DOM.getStyle(de, 'overflow', 1);\r
54                                         vp = DOM.getViewPort();\r
55                                         s.fullscreen_scrollx = vp.x;\r
56                                         s.fullscreen_scrolly = vp.y;\r
57 \r
58                                         // Fixes an Opera bug where the scrollbars doesn't reappear\r
59                                         if (tinymce.isOpera && s.fullscreen_overflow == 'visible')\r
60                                                 s.fullscreen_overflow = 'auto';\r
61 \r
62                                         // Fixes an IE bug where horizontal scrollbars would appear\r
63                                         if (tinymce.isIE && s.fullscreen_overflow == 'scroll')\r
64                                                 s.fullscreen_overflow = 'auto';\r
65 \r
66                                         // Fixes an IE bug where the scrollbars doesn't reappear\r
67                                         if (tinymce.isIE && (s.fullscreen_html_overflow == 'visible' || s.fullscreen_html_overflow == 'scroll'))\r
68                                                 s.fullscreen_html_overflow = 'auto'; \r
69 \r
70                                         if (s.fullscreen_overflow == '0px')\r
71                                                 s.fullscreen_overflow = '';\r
72 \r
73                                         DOM.setStyle(DOM.doc.body, 'overflow', 'hidden');\r
74                                         de.style.overflow = 'hidden'; //Fix for IE6/7\r
75                                         vp = DOM.getViewPort();\r
76                                         DOM.win.scrollTo(0, 0);\r
77 \r
78                                         if (tinymce.isIE)\r
79                                                 vp.h -= 1;\r
80 \r
81                                         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;'});\r
82                                         DOM.add(n, 'div', {id : 'mce_fullscreen'});\r
83 \r
84                                         tinymce.each(ed.settings, function(v, n) {\r
85                                                 s[n] = v;\r
86                                         });\r
87 \r
88                                         s.id = 'mce_fullscreen';\r
89                                         s.width = n.clientWidth;\r
90                                         s.height = n.clientHeight - 15;\r
91                                         s.fullscreen_is_enabled = true;\r
92                                         s.fullscreen_editor_id = ed.id;\r
93                                         s.theme_advanced_resizing = false;\r
94                                         s.save_onsavecallback = function() {\r
95                                                 ed.setContent(tinyMCE.get(s.id).getContent({format : 'raw'}), {format : 'raw'});\r
96                                                 ed.execCommand('mceSave');\r
97                                         };\r
98 \r
99                                         tinymce.each(ed.getParam('fullscreen_settings'), function(v, k) {\r
100                                                 s[k] = v;\r
101                                         });\r
102 \r
103                                         if (s.theme_advanced_toolbar_location === 'external')\r
104                                                 s.theme_advanced_toolbar_location = 'top';\r
105 \r
106                                         t.fullscreenEditor = new tinymce.Editor('mce_fullscreen', s);\r
107                                         t.fullscreenEditor.onInit.add(function() {\r
108                                                 t.fullscreenEditor.setContent(ed.getContent());\r
109                                                 t.fullscreenEditor.focus();\r
110                                         });\r
111 \r
112                                         t.fullscreenEditor.render();\r
113 \r
114                                         t.fullscreenElement = new tinymce.dom.Element('mce_fullscreen_container');\r
115                                         t.fullscreenElement.update();\r
116                                         //document.body.overflow = 'hidden';\r
117 \r
118                                         t.resizeFunc = tinymce.dom.Event.add(DOM.win, 'resize', function() {\r
119                                                 var vp = tinymce.DOM.getViewPort(), fed = t.fullscreenEditor, outerSize, innerSize;\r
120 \r
121                                                 // Get outer/inner size to get a delta size that can be used to calc the new iframe size\r
122                                                 outerSize = fed.dom.getSize(fed.getContainer().firstChild);\r
123                                                 innerSize = fed.dom.getSize(fed.getContainer().getElementsByTagName('iframe')[0]);\r
124 \r
125                                                 fed.theme.resizeTo(vp.w - outerSize.w + innerSize.w, vp.h - outerSize.h + innerSize.h);\r
126                                         });\r
127                                 }\r
128                         });\r
129 \r
130                         // Register buttons\r
131                         ed.addButton('fullscreen', {title : 'fullscreen.desc', cmd : 'mceFullScreen'});\r
132 \r
133                         ed.onNodeChange.add(function(ed, cm) {\r
134                                 cm.setActive('fullscreen', ed.getParam('fullscreen_is_enabled'));\r
135                         });\r
136                 },\r
137 \r
138                 getInfo : function() {\r
139                         return {\r
140                                 longname : 'Fullscreen',\r
141                                 author : 'Moxiecode Systems AB',\r
142                                 authorurl : 'http://tinymce.moxiecode.com',\r
143                                 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',\r
144                                 version : tinymce.majorVersion + "." + tinymce.minorVersion\r
145                         };\r
146                 }\r
147         });\r
148 \r
149         // Register plugin\r
150         tinymce.PluginManager.add('fullscreen', tinymce.plugins.FullScreenPlugin);\r
151 })();