annotate WebContent/jscripts/tiny_mce/plugins/fullscreen/editor_plugin_src.js @ 5:0be9d53a6967

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