bgneal@45
|
1 /**
|
bgneal@45
|
2 * $Id: editor_template_src.js 1045 2009-03-04 20:03:18Z spocke $
|
bgneal@45
|
3 *
|
bgneal@45
|
4 * @author Moxiecode
|
bgneal@45
|
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
|
bgneal@45
|
6 */
|
bgneal@45
|
7
|
bgneal@45
|
8 (function(tinymce) {
|
bgneal@45
|
9 var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID, explode = tinymce.explode;
|
bgneal@45
|
10
|
bgneal@45
|
11 // Tell it to load theme specific language pack(s)
|
bgneal@45
|
12 tinymce.ThemeManager.requireLangPack('advanced');
|
bgneal@45
|
13
|
bgneal@45
|
14 tinymce.create('tinymce.themes.AdvancedTheme', {
|
bgneal@45
|
15 sizes : [8, 10, 12, 14, 18, 24, 36],
|
bgneal@45
|
16
|
bgneal@45
|
17 // Control name lookup, format: title, command
|
bgneal@45
|
18 controls : {
|
bgneal@45
|
19 bold : ['bold_desc', 'Bold'],
|
bgneal@45
|
20 italic : ['italic_desc', 'Italic'],
|
bgneal@45
|
21 underline : ['underline_desc', 'Underline'],
|
bgneal@45
|
22 strikethrough : ['striketrough_desc', 'Strikethrough'],
|
bgneal@45
|
23 justifyleft : ['justifyleft_desc', 'JustifyLeft'],
|
bgneal@45
|
24 justifycenter : ['justifycenter_desc', 'JustifyCenter'],
|
bgneal@45
|
25 justifyright : ['justifyright_desc', 'JustifyRight'],
|
bgneal@45
|
26 justifyfull : ['justifyfull_desc', 'JustifyFull'],
|
bgneal@45
|
27 bullist : ['bullist_desc', 'InsertUnorderedList'],
|
bgneal@45
|
28 numlist : ['numlist_desc', 'InsertOrderedList'],
|
bgneal@45
|
29 outdent : ['outdent_desc', 'Outdent'],
|
bgneal@45
|
30 indent : ['indent_desc', 'Indent'],
|
bgneal@45
|
31 cut : ['cut_desc', 'Cut'],
|
bgneal@45
|
32 copy : ['copy_desc', 'Copy'],
|
bgneal@45
|
33 paste : ['paste_desc', 'Paste'],
|
bgneal@45
|
34 undo : ['undo_desc', 'Undo'],
|
bgneal@45
|
35 redo : ['redo_desc', 'Redo'],
|
bgneal@45
|
36 link : ['link_desc', 'mceLink'],
|
bgneal@45
|
37 unlink : ['unlink_desc', 'unlink'],
|
bgneal@45
|
38 image : ['image_desc', 'mceImage'],
|
bgneal@45
|
39 cleanup : ['cleanup_desc', 'mceCleanup'],
|
bgneal@45
|
40 help : ['help_desc', 'mceHelp'],
|
bgneal@45
|
41 code : ['code_desc', 'mceCodeEditor'],
|
bgneal@45
|
42 hr : ['hr_desc', 'InsertHorizontalRule'],
|
bgneal@45
|
43 removeformat : ['removeformat_desc', 'RemoveFormat'],
|
bgneal@45
|
44 sub : ['sub_desc', 'subscript'],
|
bgneal@45
|
45 sup : ['sup_desc', 'superscript'],
|
bgneal@45
|
46 forecolor : ['forecolor_desc', 'ForeColor'],
|
bgneal@45
|
47 forecolorpicker : ['forecolor_desc', 'mceForeColor'],
|
bgneal@45
|
48 backcolor : ['backcolor_desc', 'HiliteColor'],
|
bgneal@45
|
49 backcolorpicker : ['backcolor_desc', 'mceBackColor'],
|
bgneal@45
|
50 charmap : ['charmap_desc', 'mceCharMap'],
|
bgneal@45
|
51 visualaid : ['visualaid_desc', 'mceToggleVisualAid'],
|
bgneal@45
|
52 anchor : ['anchor_desc', 'mceInsertAnchor'],
|
bgneal@45
|
53 newdocument : ['newdocument_desc', 'mceNewDocument'],
|
bgneal@45
|
54 blockquote : ['blockquote_desc', 'mceBlockQuote']
|
bgneal@45
|
55 },
|
bgneal@45
|
56
|
bgneal@45
|
57 stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'],
|
bgneal@45
|
58
|
bgneal@45
|
59 init : function(ed, url) {
|
bgneal@45
|
60 var t = this, s, v, o;
|
bgneal@45
|
61
|
bgneal@45
|
62 t.editor = ed;
|
bgneal@45
|
63 t.url = url;
|
bgneal@45
|
64 t.onResolveName = new tinymce.util.Dispatcher(this);
|
bgneal@45
|
65
|
bgneal@45
|
66 // Default settings
|
bgneal@45
|
67 t.settings = s = extend({
|
bgneal@45
|
68 theme_advanced_path : true,
|
bgneal@45
|
69 theme_advanced_toolbar_location : 'bottom',
|
bgneal@45
|
70 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
|
bgneal@45
|
71 theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
|
bgneal@45
|
72 theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",
|
bgneal@45
|
73 theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6",
|
bgneal@45
|
74 theme_advanced_toolbar_align : "center",
|
bgneal@45
|
75 theme_advanced_fonts : "Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",
|
bgneal@45
|
76 theme_advanced_more_colors : 1,
|
bgneal@45
|
77 theme_advanced_row_height : 23,
|
bgneal@45
|
78 theme_advanced_resize_horizontal : 1,
|
bgneal@45
|
79 theme_advanced_resizing_use_cookie : 1,
|
bgneal@45
|
80 theme_advanced_font_sizes : "1,2,3,4,5,6,7",
|
bgneal@45
|
81 readonly : ed.settings.readonly
|
bgneal@45
|
82 }, ed.settings);
|
bgneal@45
|
83
|
bgneal@45
|
84 // Setup default font_size_style_values
|
bgneal@45
|
85 if (!s.font_size_style_values)
|
bgneal@45
|
86 s.font_size_style_values = "8pt,10pt,12pt,14pt,18pt,24pt,36pt";
|
bgneal@45
|
87
|
bgneal@45
|
88 if (tinymce.is(s.theme_advanced_font_sizes, 'string')) {
|
bgneal@45
|
89 s.font_size_style_values = tinymce.explode(s.font_size_style_values);
|
bgneal@45
|
90 s.font_size_classes = tinymce.explode(s.font_size_classes || '');
|
bgneal@45
|
91
|
bgneal@45
|
92 // Parse string value
|
bgneal@45
|
93 o = {};
|
bgneal@45
|
94 ed.settings.theme_advanced_font_sizes = s.theme_advanced_font_sizes;
|
bgneal@45
|
95 each(ed.getParam('theme_advanced_font_sizes', '', 'hash'), function(v, k) {
|
bgneal@45
|
96 var cl;
|
bgneal@45
|
97
|
bgneal@45
|
98 if (k == v && v >= 1 && v <= 7) {
|
bgneal@45
|
99 k = v + ' (' + t.sizes[v - 1] + 'pt)';
|
bgneal@45
|
100
|
bgneal@45
|
101 if (ed.settings.convert_fonts_to_spans) {
|
bgneal@45
|
102 cl = s.font_size_classes[v - 1];
|
bgneal@45
|
103 v = s.font_size_style_values[v - 1] || (t.sizes[v - 1] + 'pt');
|
bgneal@45
|
104 }
|
bgneal@45
|
105 }
|
bgneal@45
|
106
|
bgneal@45
|
107 if (/^\s*\./.test(v))
|
bgneal@45
|
108 cl = v.replace(/\./g, '');
|
bgneal@45
|
109
|
bgneal@45
|
110 o[k] = cl ? {'class' : cl} : {fontSize : v};
|
bgneal@45
|
111 });
|
bgneal@45
|
112
|
bgneal@45
|
113 s.theme_advanced_font_sizes = o;
|
bgneal@45
|
114 }
|
bgneal@45
|
115
|
bgneal@45
|
116 if ((v = s.theme_advanced_path_location) && v != 'none')
|
bgneal@45
|
117 s.theme_advanced_statusbar_location = s.theme_advanced_path_location;
|
bgneal@45
|
118
|
bgneal@45
|
119 if (s.theme_advanced_statusbar_location == 'none')
|
bgneal@45
|
120 s.theme_advanced_statusbar_location = 0;
|
bgneal@45
|
121
|
bgneal@45
|
122 // Init editor
|
bgneal@45
|
123 ed.onInit.add(function() {
|
bgneal@45
|
124 ed.onNodeChange.add(t._nodeChanged, t);
|
bgneal@45
|
125
|
bgneal@45
|
126 if (ed.settings.content_css !== false)
|
bgneal@45
|
127 ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/" + ed.settings.skin + "/content.css"));
|
bgneal@45
|
128 });
|
bgneal@45
|
129
|
bgneal@45
|
130 ed.onSetProgressState.add(function(ed, b, ti) {
|
bgneal@45
|
131 var co, id = ed.id, tb;
|
bgneal@45
|
132
|
bgneal@45
|
133 if (b) {
|
bgneal@45
|
134 t.progressTimer = setTimeout(function() {
|
bgneal@45
|
135 co = ed.getContainer();
|
bgneal@45
|
136 co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild);
|
bgneal@45
|
137 tb = DOM.get(ed.id + '_tbl');
|
bgneal@45
|
138
|
bgneal@45
|
139 DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}});
|
bgneal@45
|
140 DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}});
|
bgneal@45
|
141 }, ti || 0);
|
bgneal@45
|
142 } else {
|
bgneal@45
|
143 DOM.remove(id + '_blocker');
|
bgneal@45
|
144 DOM.remove(id + '_progress');
|
bgneal@45
|
145 clearTimeout(t.progressTimer);
|
bgneal@45
|
146 }
|
bgneal@45
|
147 });
|
bgneal@45
|
148
|
bgneal@45
|
149 DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css");
|
bgneal@45
|
150
|
bgneal@45
|
151 if (s.skin_variant)
|
bgneal@45
|
152 DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css");
|
bgneal@45
|
153 },
|
bgneal@45
|
154
|
bgneal@45
|
155 createControl : function(n, cf) {
|
bgneal@45
|
156 var cd, c;
|
bgneal@45
|
157
|
bgneal@45
|
158 if (c = cf.createControl(n))
|
bgneal@45
|
159 return c;
|
bgneal@45
|
160
|
bgneal@45
|
161 switch (n) {
|
bgneal@45
|
162 case "styleselect":
|
bgneal@45
|
163 return this._createStyleSelect();
|
bgneal@45
|
164
|
bgneal@45
|
165 case "formatselect":
|
bgneal@45
|
166 return this._createBlockFormats();
|
bgneal@45
|
167
|
bgneal@45
|
168 case "fontselect":
|
bgneal@45
|
169 return this._createFontSelect();
|
bgneal@45
|
170
|
bgneal@45
|
171 case "fontsizeselect":
|
bgneal@45
|
172 return this._createFontSizeSelect();
|
bgneal@45
|
173
|
bgneal@45
|
174 case "forecolor":
|
bgneal@45
|
175 return this._createForeColorMenu();
|
bgneal@45
|
176
|
bgneal@45
|
177 case "backcolor":
|
bgneal@45
|
178 return this._createBackColorMenu();
|
bgneal@45
|
179 }
|
bgneal@45
|
180
|
bgneal@45
|
181 if ((cd = this.controls[n]))
|
bgneal@45
|
182 return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]});
|
bgneal@45
|
183 },
|
bgneal@45
|
184
|
bgneal@45
|
185 execCommand : function(cmd, ui, val) {
|
bgneal@45
|
186 var f = this['_' + cmd];
|
bgneal@45
|
187
|
bgneal@45
|
188 if (f) {
|
bgneal@45
|
189 f.call(this, ui, val);
|
bgneal@45
|
190 return true;
|
bgneal@45
|
191 }
|
bgneal@45
|
192
|
bgneal@45
|
193 return false;
|
bgneal@45
|
194 },
|
bgneal@45
|
195
|
bgneal@45
|
196 _importClasses : function(e) {
|
bgneal@45
|
197 var ed = this.editor, c = ed.controlManager.get('styleselect');
|
bgneal@45
|
198
|
bgneal@45
|
199 if (c.getLength() == 0) {
|
bgneal@45
|
200 each(ed.dom.getClasses(), function(o) {
|
bgneal@45
|
201 c.add(o['class'], o['class']);
|
bgneal@45
|
202 });
|
bgneal@45
|
203 }
|
bgneal@45
|
204 },
|
bgneal@45
|
205
|
bgneal@45
|
206 _createStyleSelect : function(n) {
|
bgneal@45
|
207 var t = this, ed = t.editor, cf = ed.controlManager, c = cf.createListBox('styleselect', {
|
bgneal@45
|
208 title : 'advanced.style_select',
|
bgneal@45
|
209 onselect : function(v) {
|
bgneal@45
|
210 if (c.selectedValue === v) {
|
bgneal@45
|
211 ed.execCommand('mceSetStyleInfo', 0, {command : 'removeformat'});
|
bgneal@45
|
212 c.select();
|
bgneal@45
|
213 return false;
|
bgneal@45
|
214 } else
|
bgneal@45
|
215 ed.execCommand('mceSetCSSClass', 0, v);
|
bgneal@45
|
216 }
|
bgneal@45
|
217 });
|
bgneal@45
|
218
|
bgneal@45
|
219 if (c) {
|
bgneal@45
|
220 each(ed.getParam('theme_advanced_styles', '', 'hash'), function(v, k) {
|
bgneal@45
|
221 if (v)
|
bgneal@45
|
222 c.add(t.editor.translate(k), v);
|
bgneal@45
|
223 });
|
bgneal@45
|
224
|
bgneal@45
|
225 c.onPostRender.add(function(ed, n) {
|
bgneal@45
|
226 if (!c.NativeListBox) {
|
bgneal@45
|
227 Event.add(n.id + '_text', 'focus', t._importClasses, t);
|
bgneal@45
|
228 Event.add(n.id + '_text', 'mousedown', t._importClasses, t);
|
bgneal@45
|
229 Event.add(n.id + '_open', 'focus', t._importClasses, t);
|
bgneal@45
|
230 Event.add(n.id + '_open', 'mousedown', t._importClasses, t);
|
bgneal@45
|
231 } else
|
bgneal@45
|
232 Event.add(n.id, 'focus', t._importClasses, t);
|
bgneal@45
|
233 });
|
bgneal@45
|
234 }
|
bgneal@45
|
235
|
bgneal@45
|
236 return c;
|
bgneal@45
|
237 },
|
bgneal@45
|
238
|
bgneal@45
|
239 _createFontSelect : function() {
|
bgneal@45
|
240 var c, t = this, ed = t.editor;
|
bgneal@45
|
241
|
bgneal@45
|
242 c = ed.controlManager.createListBox('fontselect', {title : 'advanced.fontdefault', cmd : 'FontName'});
|
bgneal@45
|
243 if (c) {
|
bgneal@45
|
244 each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) {
|
bgneal@45
|
245 c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''});
|
bgneal@45
|
246 });
|
bgneal@45
|
247 }
|
bgneal@45
|
248
|
bgneal@45
|
249 return c;
|
bgneal@45
|
250 },
|
bgneal@45
|
251
|
bgneal@45
|
252 _createFontSizeSelect : function() {
|
bgneal@45
|
253 var t = this, ed = t.editor, c, i = 0, cl = [];
|
bgneal@45
|
254
|
bgneal@45
|
255 c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) {
|
bgneal@45
|
256 if (v.fontSize)
|
bgneal@45
|
257 ed.execCommand('FontSize', false, v.fontSize);
|
bgneal@45
|
258 else {
|
bgneal@45
|
259 each(t.settings.theme_advanced_font_sizes, function(v, k) {
|
bgneal@45
|
260 if (v['class'])
|
bgneal@45
|
261 cl.push(v['class']);
|
bgneal@45
|
262 });
|
bgneal@45
|
263
|
bgneal@45
|
264 ed.editorCommands._applyInlineStyle('span', {'class' : v['class']}, {check_classes : cl});
|
bgneal@45
|
265 }
|
bgneal@45
|
266 }});
|
bgneal@45
|
267
|
bgneal@45
|
268 if (c) {
|
bgneal@45
|
269 each(t.settings.theme_advanced_font_sizes, function(v, k) {
|
bgneal@45
|
270 var fz = v.fontSize;
|
bgneal@45
|
271
|
bgneal@45
|
272 if (fz >= 1 && fz <= 7)
|
bgneal@45
|
273 fz = t.sizes[parseInt(fz) - 1] + 'pt';
|
bgneal@45
|
274
|
bgneal@45
|
275 c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))});
|
bgneal@45
|
276 });
|
bgneal@45
|
277 }
|
bgneal@45
|
278
|
bgneal@45
|
279 return c;
|
bgneal@45
|
280 },
|
bgneal@45
|
281
|
bgneal@45
|
282 _createBlockFormats : function() {
|
bgneal@45
|
283 var c, fmts = {
|
bgneal@45
|
284 p : 'advanced.paragraph',
|
bgneal@45
|
285 address : 'advanced.address',
|
bgneal@45
|
286 pre : 'advanced.pre',
|
bgneal@45
|
287 h1 : 'advanced.h1',
|
bgneal@45
|
288 h2 : 'advanced.h2',
|
bgneal@45
|
289 h3 : 'advanced.h3',
|
bgneal@45
|
290 h4 : 'advanced.h4',
|
bgneal@45
|
291 h5 : 'advanced.h5',
|
bgneal@45
|
292 h6 : 'advanced.h6',
|
bgneal@45
|
293 div : 'advanced.div',
|
bgneal@45
|
294 blockquote : 'advanced.blockquote',
|
bgneal@45
|
295 code : 'advanced.code',
|
bgneal@45
|
296 dt : 'advanced.dt',
|
bgneal@45
|
297 dd : 'advanced.dd',
|
bgneal@45
|
298 samp : 'advanced.samp'
|
bgneal@45
|
299 }, t = this;
|
bgneal@45
|
300
|
bgneal@45
|
301 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'});
|
bgneal@45
|
302 if (c) {
|
bgneal@45
|
303 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) {
|
bgneal@45
|
304 c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v});
|
bgneal@45
|
305 });
|
bgneal@45
|
306 }
|
bgneal@45
|
307
|
bgneal@45
|
308 return c;
|
bgneal@45
|
309 },
|
bgneal@45
|
310
|
bgneal@45
|
311 _createForeColorMenu : function() {
|
bgneal@45
|
312 var c, t = this, s = t.settings, o = {}, v;
|
bgneal@45
|
313
|
bgneal@45
|
314 if (s.theme_advanced_more_colors) {
|
bgneal@45
|
315 o.more_colors_func = function() {
|
bgneal@45
|
316 t._mceColorPicker(0, {
|
bgneal@45
|
317 color : c.value,
|
bgneal@45
|
318 func : function(co) {
|
bgneal@45
|
319 c.setColor(co);
|
bgneal@45
|
320 }
|
bgneal@45
|
321 });
|
bgneal@45
|
322 };
|
bgneal@45
|
323 }
|
bgneal@45
|
324
|
bgneal@45
|
325 if (v = s.theme_advanced_text_colors)
|
bgneal@45
|
326 o.colors = v;
|
bgneal@45
|
327
|
bgneal@45
|
328 if (s.theme_advanced_default_foreground_color)
|
bgneal@45
|
329 o.default_color = s.theme_advanced_default_foreground_color;
|
bgneal@45
|
330
|
bgneal@45
|
331 o.title = 'advanced.forecolor_desc';
|
bgneal@45
|
332 o.cmd = 'ForeColor';
|
bgneal@45
|
333 o.scope = this;
|
bgneal@45
|
334
|
bgneal@45
|
335 c = t.editor.controlManager.createColorSplitButton('forecolor', o);
|
bgneal@45
|
336
|
bgneal@45
|
337 return c;
|
bgneal@45
|
338 },
|
bgneal@45
|
339
|
bgneal@45
|
340 _createBackColorMenu : function() {
|
bgneal@45
|
341 var c, t = this, s = t.settings, o = {}, v;
|
bgneal@45
|
342
|
bgneal@45
|
343 if (s.theme_advanced_more_colors) {
|
bgneal@45
|
344 o.more_colors_func = function() {
|
bgneal@45
|
345 t._mceColorPicker(0, {
|
bgneal@45
|
346 color : c.value,
|
bgneal@45
|
347 func : function(co) {
|
bgneal@45
|
348 c.setColor(co);
|
bgneal@45
|
349 }
|
bgneal@45
|
350 });
|
bgneal@45
|
351 };
|
bgneal@45
|
352 }
|
bgneal@45
|
353
|
bgneal@45
|
354 if (v = s.theme_advanced_background_colors)
|
bgneal@45
|
355 o.colors = v;
|
bgneal@45
|
356
|
bgneal@45
|
357 if (s.theme_advanced_default_background_color)
|
bgneal@45
|
358 o.default_color = s.theme_advanced_default_background_color;
|
bgneal@45
|
359
|
bgneal@45
|
360 o.title = 'advanced.backcolor_desc';
|
bgneal@45
|
361 o.cmd = 'HiliteColor';
|
bgneal@45
|
362 o.scope = this;
|
bgneal@45
|
363
|
bgneal@45
|
364 c = t.editor.controlManager.createColorSplitButton('backcolor', o);
|
bgneal@45
|
365
|
bgneal@45
|
366 return c;
|
bgneal@45
|
367 },
|
bgneal@45
|
368
|
bgneal@45
|
369 renderUI : function(o) {
|
bgneal@45
|
370 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;
|
bgneal@45
|
371
|
bgneal@45
|
372 n = p = DOM.create('span', {id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '')});
|
bgneal@45
|
373
|
bgneal@45
|
374 if (!DOM.boxModel)
|
bgneal@45
|
375 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});
|
bgneal@45
|
376
|
bgneal@45
|
377 n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});
|
bgneal@45
|
378 n = tb = DOM.add(n, 'tbody');
|
bgneal@45
|
379
|
bgneal@45
|
380 switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {
|
bgneal@45
|
381 case "rowlayout":
|
bgneal@45
|
382 ic = t._rowLayout(s, tb, o);
|
bgneal@45
|
383 break;
|
bgneal@45
|
384
|
bgneal@45
|
385 case "customlayout":
|
bgneal@45
|
386 ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);
|
bgneal@45
|
387 break;
|
bgneal@45
|
388
|
bgneal@45
|
389 default:
|
bgneal@45
|
390 ic = t._simpleLayout(s, tb, o, p);
|
bgneal@45
|
391 }
|
bgneal@45
|
392
|
bgneal@45
|
393 n = o.targetNode;
|
bgneal@45
|
394
|
bgneal@45
|
395 // Add classes to first and last TRs
|
bgneal@45
|
396 nl = DOM.stdMode ? sc.getElementsByTagName('tr') : sc.rows; // Quick fix for IE 8
|
bgneal@45
|
397 DOM.addClass(nl[0], 'mceFirst');
|
bgneal@45
|
398 DOM.addClass(nl[nl.length - 1], 'mceLast');
|
bgneal@45
|
399
|
bgneal@45
|
400 // Add classes to first and last TDs
|
bgneal@45
|
401 each(DOM.select('tr', tb), function(n) {
|
bgneal@45
|
402 DOM.addClass(n.firstChild, 'mceFirst');
|
bgneal@45
|
403 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast');
|
bgneal@45
|
404 });
|
bgneal@45
|
405
|
bgneal@45
|
406 if (DOM.get(s.theme_advanced_toolbar_container))
|
bgneal@45
|
407 DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
|
bgneal@45
|
408 else
|
bgneal@45
|
409 DOM.insertAfter(p, n);
|
bgneal@45
|
410
|
bgneal@45
|
411 Event.add(ed.id + '_path_row', 'click', function(e) {
|
bgneal@45
|
412 e = e.target;
|
bgneal@45
|
413
|
bgneal@45
|
414 if (e.nodeName == 'A') {
|
bgneal@45
|
415 t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));
|
bgneal@45
|
416
|
bgneal@45
|
417 return Event.cancel(e);
|
bgneal@45
|
418 }
|
bgneal@45
|
419 });
|
bgneal@45
|
420 /*
|
bgneal@45
|
421 if (DOM.get(ed.id + '_path_row')) {
|
bgneal@45
|
422 Event.add(ed.id + '_tbl', 'mouseover', function(e) {
|
bgneal@45
|
423 var re;
|
bgneal@45
|
424
|
bgneal@45
|
425 e = e.target;
|
bgneal@45
|
426
|
bgneal@45
|
427 if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
|
bgneal@45
|
428 re = DOM.get(ed.id + '_path_row');
|
bgneal@45
|
429 t.lastPath = re.innerHTML;
|
bgneal@45
|
430 DOM.setHTML(re, e.parentNode.title);
|
bgneal@45
|
431 }
|
bgneal@45
|
432 });
|
bgneal@45
|
433
|
bgneal@45
|
434 Event.add(ed.id + '_tbl', 'mouseout', function(e) {
|
bgneal@45
|
435 if (t.lastPath) {
|
bgneal@45
|
436 DOM.setHTML(ed.id + '_path_row', t.lastPath);
|
bgneal@45
|
437 t.lastPath = 0;
|
bgneal@45
|
438 }
|
bgneal@45
|
439 });
|
bgneal@45
|
440 }
|
bgneal@45
|
441 */
|
bgneal@45
|
442
|
bgneal@45
|
443 if (!ed.getParam('accessibility_focus'))
|
bgneal@45
|
444 Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});
|
bgneal@45
|
445
|
bgneal@45
|
446 if (s.theme_advanced_toolbar_location == 'external')
|
bgneal@45
|
447 o.deltaHeight = 0;
|
bgneal@45
|
448
|
bgneal@45
|
449 t.deltaHeight = o.deltaHeight;
|
bgneal@45
|
450 o.targetNode = null;
|
bgneal@45
|
451
|
bgneal@45
|
452 return {
|
bgneal@45
|
453 iframeContainer : ic,
|
bgneal@45
|
454 editorContainer : ed.id + '_parent',
|
bgneal@45
|
455 sizeContainer : sc,
|
bgneal@45
|
456 deltaHeight : o.deltaHeight
|
bgneal@45
|
457 };
|
bgneal@45
|
458 },
|
bgneal@45
|
459
|
bgneal@45
|
460 getInfo : function() {
|
bgneal@45
|
461 return {
|
bgneal@45
|
462 longname : 'Advanced theme',
|
bgneal@45
|
463 author : 'Moxiecode Systems AB',
|
bgneal@45
|
464 authorurl : 'http://tinymce.moxiecode.com',
|
bgneal@45
|
465 version : tinymce.majorVersion + "." + tinymce.minorVersion
|
bgneal@45
|
466 }
|
bgneal@45
|
467 },
|
bgneal@45
|
468
|
bgneal@45
|
469 resizeBy : function(dw, dh) {
|
bgneal@45
|
470 var e = DOM.get(this.editor.id + '_tbl');
|
bgneal@45
|
471
|
bgneal@45
|
472 this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);
|
bgneal@45
|
473 },
|
bgneal@45
|
474
|
bgneal@45
|
475 resizeTo : function(w, h) {
|
bgneal@45
|
476 var ed = this.editor, s = ed.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'), dh;
|
bgneal@45
|
477
|
bgneal@45
|
478 // Boundery fix box
|
bgneal@45
|
479 w = Math.max(s.theme_advanced_resizing_min_width || 100, w);
|
bgneal@45
|
480 h = Math.max(s.theme_advanced_resizing_min_height || 100, h);
|
bgneal@45
|
481 w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);
|
bgneal@45
|
482 h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);
|
bgneal@45
|
483
|
bgneal@45
|
484 // Calc difference between iframe and container
|
bgneal@45
|
485 dh = e.clientHeight - ifr.clientHeight;
|
bgneal@45
|
486
|
bgneal@45
|
487 // Resize iframe and container
|
bgneal@45
|
488 DOM.setStyle(ifr, 'height', h - dh);
|
bgneal@45
|
489 DOM.setStyles(e, {width : w, height : h});
|
bgneal@45
|
490 },
|
bgneal@45
|
491
|
bgneal@45
|
492 destroy : function() {
|
bgneal@45
|
493 var id = this.editor.id;
|
bgneal@45
|
494
|
bgneal@45
|
495 Event.clear(id + '_resize');
|
bgneal@45
|
496 Event.clear(id + '_path_row');
|
bgneal@45
|
497 Event.clear(id + '_external_close');
|
bgneal@45
|
498 },
|
bgneal@45
|
499
|
bgneal@45
|
500 // Internal functions
|
bgneal@45
|
501
|
bgneal@45
|
502 _simpleLayout : function(s, tb, o, p) {
|
bgneal@45
|
503 var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
|
bgneal@45
|
504
|
bgneal@45
|
505 if (s.readonly) {
|
bgneal@45
|
506 n = DOM.add(tb, 'tr');
|
bgneal@45
|
507 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
|
bgneal@45
|
508 return ic;
|
bgneal@45
|
509 }
|
bgneal@45
|
510
|
bgneal@45
|
511 // Create toolbar container at top
|
bgneal@45
|
512 if (lo == 'top')
|
bgneal@45
|
513 t._addToolbars(tb, o);
|
bgneal@45
|
514
|
bgneal@45
|
515 // Create external toolbar
|
bgneal@45
|
516 if (lo == 'external') {
|
bgneal@45
|
517 n = c = DOM.create('div', {style : 'position:relative'});
|
bgneal@45
|
518 n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
|
bgneal@45
|
519 DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
|
bgneal@45
|
520 n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
|
bgneal@45
|
521 etb = DOM.add(n, 'tbody');
|
bgneal@45
|
522
|
bgneal@45
|
523 if (p.firstChild.className == 'mceOldBoxModel')
|
bgneal@45
|
524 p.firstChild.appendChild(c);
|
bgneal@45
|
525 else
|
bgneal@45
|
526 p.insertBefore(c, p.firstChild);
|
bgneal@45
|
527
|
bgneal@45
|
528 t._addToolbars(etb, o);
|
bgneal@45
|
529
|
bgneal@45
|
530 ed.onMouseUp.add(function() {
|
bgneal@45
|
531 var e = DOM.get(ed.id + '_external');
|
bgneal@45
|
532 DOM.show(e);
|
bgneal@45
|
533
|
bgneal@45
|
534 DOM.hide(lastExtID);
|
bgneal@45
|
535
|
bgneal@45
|
536 var f = Event.add(ed.id + '_external_close', 'click', function() {
|
bgneal@45
|
537 DOM.hide(ed.id + '_external');
|
bgneal@45
|
538 Event.remove(ed.id + '_external_close', 'click', f);
|
bgneal@45
|
539 });
|
bgneal@45
|
540
|
bgneal@45
|
541 DOM.show(e);
|
bgneal@45
|
542 DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
|
bgneal@45
|
543
|
bgneal@45
|
544 // Fixes IE rendering bug
|
bgneal@45
|
545 DOM.hide(e);
|
bgneal@45
|
546 DOM.show(e);
|
bgneal@45
|
547 e.style.filter = '';
|
bgneal@45
|
548
|
bgneal@45
|
549 lastExtID = ed.id + '_external';
|
bgneal@45
|
550
|
bgneal@45
|
551 e = null;
|
bgneal@45
|
552 });
|
bgneal@45
|
553 }
|
bgneal@45
|
554
|
bgneal@45
|
555 if (sl == 'top')
|
bgneal@45
|
556 t._addStatusBar(tb, o);
|
bgneal@45
|
557
|
bgneal@45
|
558 // Create iframe container
|
bgneal@45
|
559 if (!s.theme_advanced_toolbar_container) {
|
bgneal@45
|
560 n = DOM.add(tb, 'tr');
|
bgneal@45
|
561 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
|
bgneal@45
|
562 }
|
bgneal@45
|
563
|
bgneal@45
|
564 // Create toolbar container at bottom
|
bgneal@45
|
565 if (lo == 'bottom')
|
bgneal@45
|
566 t._addToolbars(tb, o);
|
bgneal@45
|
567
|
bgneal@45
|
568 if (sl == 'bottom')
|
bgneal@45
|
569 t._addStatusBar(tb, o);
|
bgneal@45
|
570
|
bgneal@45
|
571 return ic;
|
bgneal@45
|
572 },
|
bgneal@45
|
573
|
bgneal@45
|
574 _rowLayout : function(s, tb, o) {
|
bgneal@45
|
575 var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;
|
bgneal@45
|
576
|
bgneal@45
|
577 dc = s.theme_advanced_containers_default_class || '';
|
bgneal@45
|
578 da = s.theme_advanced_containers_default_align || 'center';
|
bgneal@45
|
579
|
bgneal@45
|
580 each(explode(s.theme_advanced_containers || ''), function(c, i) {
|
bgneal@45
|
581 var v = s['theme_advanced_container_' + c] || '';
|
bgneal@45
|
582
|
bgneal@45
|
583 switch (v.toLowerCase()) {
|
bgneal@45
|
584 case 'mceeditor':
|
bgneal@45
|
585 n = DOM.add(tb, 'tr');
|
bgneal@45
|
586 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
|
bgneal@45
|
587 break;
|
bgneal@45
|
588
|
bgneal@45
|
589 case 'mceelementpath':
|
bgneal@45
|
590 t._addStatusBar(tb, o);
|
bgneal@45
|
591 break;
|
bgneal@45
|
592
|
bgneal@45
|
593 default:
|
bgneal@45
|
594 a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase();
|
bgneal@45
|
595 a = 'mce' + t._ufirst(a);
|
bgneal@45
|
596
|
bgneal@45
|
597 n = DOM.add(DOM.add(tb, 'tr'), 'td', {
|
bgneal@45
|
598 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da
|
bgneal@45
|
599 });
|
bgneal@45
|
600
|
bgneal@45
|
601 to = cf.createToolbar("toolbar" + i);
|
bgneal@45
|
602 t._addControls(v, to);
|
bgneal@45
|
603 DOM.setHTML(n, to.renderHTML());
|
bgneal@45
|
604 o.deltaHeight -= s.theme_advanced_row_height;
|
bgneal@45
|
605 }
|
bgneal@45
|
606 });
|
bgneal@45
|
607
|
bgneal@45
|
608 return ic;
|
bgneal@45
|
609 },
|
bgneal@45
|
610
|
bgneal@45
|
611 _addControls : function(v, tb) {
|
bgneal@45
|
612 var t = this, s = t.settings, di, cf = t.editor.controlManager;
|
bgneal@45
|
613
|
bgneal@45
|
614 if (s.theme_advanced_disable && !t._disabled) {
|
bgneal@45
|
615 di = {};
|
bgneal@45
|
616
|
bgneal@45
|
617 each(explode(s.theme_advanced_disable), function(v) {
|
bgneal@45
|
618 di[v] = 1;
|
bgneal@45
|
619 });
|
bgneal@45
|
620
|
bgneal@45
|
621 t._disabled = di;
|
bgneal@45
|
622 } else
|
bgneal@45
|
623 di = t._disabled;
|
bgneal@45
|
624
|
bgneal@45
|
625 each(explode(v), function(n) {
|
bgneal@45
|
626 var c;
|
bgneal@45
|
627
|
bgneal@45
|
628 if (di && di[n])
|
bgneal@45
|
629 return;
|
bgneal@45
|
630
|
bgneal@45
|
631 // Compatiblity with 2.x
|
bgneal@45
|
632 if (n == 'tablecontrols') {
|
bgneal@45
|
633 each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) {
|
bgneal@45
|
634 n = t.createControl(n, cf);
|
bgneal@45
|
635
|
bgneal@45
|
636 if (n)
|
bgneal@45
|
637 tb.add(n);
|
bgneal@45
|
638 });
|
bgneal@45
|
639
|
bgneal@45
|
640 return;
|
bgneal@45
|
641 }
|
bgneal@45
|
642
|
bgneal@45
|
643 c = t.createControl(n, cf);
|
bgneal@45
|
644
|
bgneal@45
|
645 if (c)
|
bgneal@45
|
646 tb.add(c);
|
bgneal@45
|
647 });
|
bgneal@45
|
648 },
|
bgneal@45
|
649
|
bgneal@45
|
650 _addToolbars : function(c, o) {
|
bgneal@45
|
651 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a;
|
bgneal@45
|
652
|
bgneal@45
|
653 a = s.theme_advanced_toolbar_align.toLowerCase();
|
bgneal@45
|
654 a = 'mce' + t._ufirst(a);
|
bgneal@45
|
655
|
bgneal@45
|
656 n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a});
|
bgneal@45
|
657
|
bgneal@45
|
658 if (!ed.getParam('accessibility_focus'))
|
bgneal@45
|
659 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
|
bgneal@45
|
660
|
bgneal@45
|
661 h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->'));
|
bgneal@45
|
662
|
bgneal@45
|
663 // Create toolbar and add the controls
|
bgneal@45
|
664 for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
|
bgneal@45
|
665 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});
|
bgneal@45
|
666
|
bgneal@45
|
667 if (s['theme_advanced_buttons' + i + '_add'])
|
bgneal@45
|
668 v += ',' + s['theme_advanced_buttons' + i + '_add'];
|
bgneal@45
|
669
|
bgneal@45
|
670 if (s['theme_advanced_buttons' + i + '_add_before'])
|
bgneal@45
|
671 v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
|
bgneal@45
|
672
|
bgneal@45
|
673 t._addControls(v, tb);
|
bgneal@45
|
674
|
bgneal@45
|
675 //n.appendChild(n = tb.render());
|
bgneal@45
|
676 h.push(tb.renderHTML());
|
bgneal@45
|
677
|
bgneal@45
|
678 o.deltaHeight -= s.theme_advanced_row_height;
|
bgneal@45
|
679 }
|
bgneal@45
|
680
|
bgneal@45
|
681 h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
|
bgneal@45
|
682 DOM.setHTML(n, h.join(''));
|
bgneal@45
|
683 },
|
bgneal@45
|
684
|
bgneal@45
|
685 _addStatusBar : function(tb, o) {
|
bgneal@45
|
686 var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
|
bgneal@45
|
687
|
bgneal@45
|
688 n = DOM.add(tb, 'tr');
|
bgneal@45
|
689 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});
|
bgneal@45
|
690 n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' ');
|
bgneal@45
|
691 DOM.add(n, 'a', {href : '#', accesskey : 'x'});
|
bgneal@45
|
692
|
bgneal@45
|
693 if (s.theme_advanced_resizing) {
|
bgneal@45
|
694 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});
|
bgneal@45
|
695
|
bgneal@45
|
696 if (s.theme_advanced_resizing_use_cookie) {
|
bgneal@45
|
697 ed.onPostRender.add(function() {
|
bgneal@45
|
698 var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
|
bgneal@45
|
699
|
bgneal@45
|
700 if (!o)
|
bgneal@45
|
701 return;
|
bgneal@45
|
702
|
bgneal@45
|
703 if (s.theme_advanced_resize_horizontal)
|
bgneal@45
|
704 c.style.width = Math.max(10, o.cw) + 'px';
|
bgneal@45
|
705
|
bgneal@45
|
706 c.style.height = Math.max(10, o.ch) + 'px';
|
bgneal@45
|
707 DOM.get(ed.id + '_ifr').style.height = Math.max(10, parseInt(o.ch) + t.deltaHeight) + 'px';
|
bgneal@45
|
708 });
|
bgneal@45
|
709 }
|
bgneal@45
|
710
|
bgneal@45
|
711 ed.onPostRender.add(function() {
|
bgneal@45
|
712 Event.add(ed.id + '_resize', 'mousedown', function(e) {
|
bgneal@45
|
713 var c, p, w, h, n, pa;
|
bgneal@45
|
714
|
bgneal@45
|
715 // Measure container
|
bgneal@45
|
716 c = DOM.get(ed.id + '_tbl');
|
bgneal@45
|
717 w = c.clientWidth;
|
bgneal@45
|
718 h = c.clientHeight;
|
bgneal@45
|
719
|
bgneal@45
|
720 miw = s.theme_advanced_resizing_min_width || 100;
|
bgneal@45
|
721 mih = s.theme_advanced_resizing_min_height || 100;
|
bgneal@45
|
722 maw = s.theme_advanced_resizing_max_width || 0xFFFF;
|
bgneal@45
|
723 mah = s.theme_advanced_resizing_max_height || 0xFFFF;
|
bgneal@45
|
724
|
bgneal@45
|
725 // Setup placeholder
|
bgneal@45
|
726 p = DOM.add(DOM.get(ed.id + '_parent'), 'div', {'class' : 'mcePlaceHolder'});
|
bgneal@45
|
727 DOM.setStyles(p, {width : w, height : h});
|
bgneal@45
|
728
|
bgneal@45
|
729 // Replace with placeholder
|
bgneal@45
|
730 DOM.hide(c);
|
bgneal@45
|
731 DOM.show(p);
|
bgneal@45
|
732
|
bgneal@45
|
733 // Create internal resize obj
|
bgneal@45
|
734 r = {
|
bgneal@45
|
735 x : e.screenX,
|
bgneal@45
|
736 y : e.screenY,
|
bgneal@45
|
737 w : w,
|
bgneal@45
|
738 h : h,
|
bgneal@45
|
739 dx : null,
|
bgneal@45
|
740 dy : null
|
bgneal@45
|
741 };
|
bgneal@45
|
742
|
bgneal@45
|
743 // Start listening
|
bgneal@45
|
744 mf = Event.add(DOM.doc, 'mousemove', function(e) {
|
bgneal@45
|
745 var w, h;
|
bgneal@45
|
746
|
bgneal@45
|
747 // Calc delta values
|
bgneal@45
|
748 r.dx = e.screenX - r.x;
|
bgneal@45
|
749 r.dy = e.screenY - r.y;
|
bgneal@45
|
750
|
bgneal@45
|
751 // Boundery fix box
|
bgneal@45
|
752 w = Math.max(miw, r.w + r.dx);
|
bgneal@45
|
753 h = Math.max(mih, r.h + r.dy);
|
bgneal@45
|
754 w = Math.min(maw, w);
|
bgneal@45
|
755 h = Math.min(mah, h);
|
bgneal@45
|
756
|
bgneal@45
|
757 // Resize placeholder
|
bgneal@45
|
758 if (s.theme_advanced_resize_horizontal)
|
bgneal@45
|
759 p.style.width = w + 'px';
|
bgneal@45
|
760
|
bgneal@45
|
761 p.style.height = h + 'px';
|
bgneal@45
|
762
|
bgneal@45
|
763 return Event.cancel(e);
|
bgneal@45
|
764 });
|
bgneal@45
|
765
|
bgneal@45
|
766 me = Event.add(DOM.doc, 'mouseup', function(e) {
|
bgneal@45
|
767 var ifr;
|
bgneal@45
|
768
|
bgneal@45
|
769 // Stop listening
|
bgneal@45
|
770 Event.remove(DOM.doc, 'mousemove', mf);
|
bgneal@45
|
771 Event.remove(DOM.doc, 'mouseup', me);
|
bgneal@45
|
772
|
bgneal@45
|
773 c.style.display = '';
|
bgneal@45
|
774 DOM.remove(p);
|
bgneal@45
|
775
|
bgneal@45
|
776 if (r.dx === null)
|
bgneal@45
|
777 return;
|
bgneal@45
|
778
|
bgneal@45
|
779 ifr = DOM.get(ed.id + '_ifr');
|
bgneal@45
|
780
|
bgneal@45
|
781 if (s.theme_advanced_resize_horizontal)
|
bgneal@45
|
782 c.style.width = Math.max(10, r.w + r.dx) + 'px';
|
bgneal@45
|
783
|
bgneal@45
|
784 c.style.height = Math.max(10, r.h + r.dy) + 'px';
|
bgneal@45
|
785 ifr.style.height = Math.max(10, ifr.clientHeight + r.dy) + 'px';
|
bgneal@45
|
786
|
bgneal@45
|
787 if (s.theme_advanced_resizing_use_cookie) {
|
bgneal@45
|
788 Cookie.setHash("TinyMCE_" + ed.id + "_size", {
|
bgneal@45
|
789 cw : r.w + r.dx,
|
bgneal@45
|
790 ch : r.h + r.dy
|
bgneal@45
|
791 });
|
bgneal@45
|
792 }
|
bgneal@45
|
793 });
|
bgneal@45
|
794
|
bgneal@45
|
795 return Event.cancel(e);
|
bgneal@45
|
796 });
|
bgneal@45
|
797 });
|
bgneal@45
|
798 }
|
bgneal@45
|
799
|
bgneal@45
|
800 o.deltaHeight -= 21;
|
bgneal@45
|
801 n = tb = null;
|
bgneal@45
|
802 },
|
bgneal@45
|
803
|
bgneal@45
|
804 _nodeChanged : function(ed, cm, n, co) {
|
bgneal@45
|
805 var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn;
|
bgneal@45
|
806
|
bgneal@45
|
807 if (s.readonly)
|
bgneal@45
|
808 return;
|
bgneal@45
|
809
|
bgneal@45
|
810 tinymce.each(t.stateControls, function(c) {
|
bgneal@45
|
811 cm.setActive(c, ed.queryCommandState(t.controls[c][1]));
|
bgneal@45
|
812 });
|
bgneal@45
|
813
|
bgneal@45
|
814 cm.setActive('visualaid', ed.hasVisual);
|
bgneal@45
|
815 cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing);
|
bgneal@45
|
816 cm.setDisabled('redo', !ed.undoManager.hasRedo());
|
bgneal@45
|
817 cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));
|
bgneal@45
|
818
|
bgneal@45
|
819 p = DOM.getParent(n, 'A');
|
bgneal@45
|
820 if (c = cm.get('link')) {
|
bgneal@45
|
821 if (!p || !p.name) {
|
bgneal@45
|
822 c.setDisabled(!p && co);
|
bgneal@45
|
823 c.setActive(!!p);
|
bgneal@45
|
824 }
|
bgneal@45
|
825 }
|
bgneal@45
|
826
|
bgneal@45
|
827 if (c = cm.get('unlink')) {
|
bgneal@45
|
828 c.setDisabled(!p && co);
|
bgneal@45
|
829 c.setActive(!!p && !p.name);
|
bgneal@45
|
830 }
|
bgneal@45
|
831
|
bgneal@45
|
832 if (c = cm.get('anchor')) {
|
bgneal@45
|
833 c.setActive(!!p && p.name);
|
bgneal@45
|
834
|
bgneal@45
|
835 if (tinymce.isWebKit) {
|
bgneal@45
|
836 p = DOM.getParent(n, 'IMG');
|
bgneal@45
|
837 c.setActive(!!p && DOM.getAttrib(p, 'mce_name') == 'a');
|
bgneal@45
|
838 }
|
bgneal@45
|
839 }
|
bgneal@45
|
840
|
bgneal@45
|
841 p = DOM.getParent(n, 'IMG');
|
bgneal@45
|
842 if (c = cm.get('image'))
|
bgneal@45
|
843 c.setActive(!!p && n.className.indexOf('mceItem') == -1);
|
bgneal@45
|
844
|
bgneal@45
|
845 if (c = cm.get('styleselect')) {
|
bgneal@45
|
846 if (n.className) {
|
bgneal@45
|
847 t._importClasses();
|
bgneal@45
|
848 c.select(n.className);
|
bgneal@45
|
849 } else
|
bgneal@45
|
850 c.select();
|
bgneal@45
|
851 }
|
bgneal@45
|
852
|
bgneal@45
|
853 if (c = cm.get('formatselect')) {
|
bgneal@45
|
854 p = DOM.getParent(n, DOM.isBlock);
|
bgneal@45
|
855
|
bgneal@45
|
856 if (p)
|
bgneal@45
|
857 c.select(p.nodeName.toLowerCase());
|
bgneal@45
|
858 }
|
bgneal@45
|
859
|
bgneal@45
|
860 if (ed.settings.convert_fonts_to_spans) {
|
bgneal@45
|
861 ed.dom.getParent(n, function(n) {
|
bgneal@45
|
862 if (n.nodeName === 'SPAN') {
|
bgneal@45
|
863 if (!cl && n.className)
|
bgneal@45
|
864 cl = n.className;
|
bgneal@45
|
865
|
bgneal@45
|
866 if (!fz && n.style.fontSize)
|
bgneal@45
|
867 fz = n.style.fontSize;
|
bgneal@45
|
868
|
bgneal@45
|
869 if (!fn && n.style.fontFamily)
|
bgneal@45
|
870 fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase();
|
bgneal@45
|
871 }
|
bgneal@45
|
872
|
bgneal@45
|
873 return false;
|
bgneal@45
|
874 });
|
bgneal@45
|
875
|
bgneal@45
|
876 if (c = cm.get('fontselect')) {
|
bgneal@45
|
877 c.select(function(v) {
|
bgneal@45
|
878 return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn;
|
bgneal@45
|
879 });
|
bgneal@45
|
880 }
|
bgneal@45
|
881
|
bgneal@45
|
882 if (c = cm.get('fontsizeselect')) {
|
bgneal@45
|
883 c.select(function(v) {
|
bgneal@45
|
884 if (v.fontSize && v.fontSize === fz)
|
bgneal@45
|
885 return true;
|
bgneal@45
|
886
|
bgneal@45
|
887 if (v['class'] && v['class'] === cl)
|
bgneal@45
|
888 return true;
|
bgneal@45
|
889 });
|
bgneal@45
|
890 }
|
bgneal@45
|
891 } else {
|
bgneal@45
|
892 if (c = cm.get('fontselect'))
|
bgneal@45
|
893 c.select(ed.queryCommandValue('FontName'));
|
bgneal@45
|
894
|
bgneal@45
|
895 if (c = cm.get('fontsizeselect')) {
|
bgneal@45
|
896 v = ed.queryCommandValue('FontSize');
|
bgneal@45
|
897 c.select(function(iv) {
|
bgneal@45
|
898 return iv.fontSize == v;
|
bgneal@45
|
899 });
|
bgneal@45
|
900 }
|
bgneal@45
|
901 }
|
bgneal@45
|
902
|
bgneal@45
|
903 if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {
|
bgneal@45
|
904 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});
|
bgneal@45
|
905 DOM.setHTML(p, '');
|
bgneal@45
|
906
|
bgneal@45
|
907 ed.dom.getParent(n, function(n) {
|
bgneal@45
|
908 var na = n.nodeName.toLowerCase(), u, pi, ti = '';
|
bgneal@45
|
909
|
bgneal@45
|
910 // Ignore non element and hidden elements
|
bgneal@45
|
911 if (n.nodeType != 1 || n.nodeName === 'BR' || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')))
|
bgneal@45
|
912 return;
|
bgneal@45
|
913
|
bgneal@45
|
914 // Fake name
|
bgneal@45
|
915 if (v = DOM.getAttrib(n, 'mce_name'))
|
bgneal@45
|
916 na = v;
|
bgneal@45
|
917
|
bgneal@45
|
918 // Handle prefix
|
bgneal@45
|
919 if (tinymce.isIE && n.scopeName !== 'HTML')
|
bgneal@45
|
920 na = n.scopeName + ':' + na;
|
bgneal@45
|
921
|
bgneal@45
|
922 // Remove internal prefix
|
bgneal@45
|
923 na = na.replace(/mce\:/g, '');
|
bgneal@45
|
924
|
bgneal@45
|
925 // Handle node name
|
bgneal@45
|
926 switch (na) {
|
bgneal@45
|
927 case 'b':
|
bgneal@45
|
928 na = 'strong';
|
bgneal@45
|
929 break;
|
bgneal@45
|
930
|
bgneal@45
|
931 case 'i':
|
bgneal@45
|
932 na = 'em';
|
bgneal@45
|
933 break;
|
bgneal@45
|
934
|
bgneal@45
|
935 case 'img':
|
bgneal@45
|
936 if (v = DOM.getAttrib(n, 'src'))
|
bgneal@45
|
937 ti += 'src: ' + v + ' ';
|
bgneal@45
|
938
|
bgneal@45
|
939 break;
|
bgneal@45
|
940
|
bgneal@45
|
941 case 'a':
|
bgneal@45
|
942 if (v = DOM.getAttrib(n, 'name')) {
|
bgneal@45
|
943 ti += 'name: ' + v + ' ';
|
bgneal@45
|
944 na += '#' + v;
|
bgneal@45
|
945 }
|
bgneal@45
|
946
|
bgneal@45
|
947 if (v = DOM.getAttrib(n, 'href'))
|
bgneal@45
|
948 ti += 'href: ' + v + ' ';
|
bgneal@45
|
949
|
bgneal@45
|
950 break;
|
bgneal@45
|
951
|
bgneal@45
|
952 case 'font':
|
bgneal@45
|
953 if (s.convert_fonts_to_spans)
|
bgneal@45
|
954 na = 'span';
|
bgneal@45
|
955
|
bgneal@45
|
956 if (v = DOM.getAttrib(n, 'face'))
|
bgneal@45
|
957 ti += 'font: ' + v + ' ';
|
bgneal@45
|
958
|
bgneal@45
|
959 if (v = DOM.getAttrib(n, 'size'))
|
bgneal@45
|
960 ti += 'size: ' + v + ' ';
|
bgneal@45
|
961
|
bgneal@45
|
962 if (v = DOM.getAttrib(n, 'color'))
|
bgneal@45
|
963 ti += 'color: ' + v + ' ';
|
bgneal@45
|
964
|
bgneal@45
|
965 break;
|
bgneal@45
|
966
|
bgneal@45
|
967 case 'span':
|
bgneal@45
|
968 if (v = DOM.getAttrib(n, 'style'))
|
bgneal@45
|
969 ti += 'style: ' + v + ' ';
|
bgneal@45
|
970
|
bgneal@45
|
971 break;
|
bgneal@45
|
972 }
|
bgneal@45
|
973
|
bgneal@45
|
974 if (v = DOM.getAttrib(n, 'id'))
|
bgneal@45
|
975 ti += 'id: ' + v + ' ';
|
bgneal@45
|
976
|
bgneal@45
|
977 if (v = n.className) {
|
bgneal@45
|
978 v = v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g, '');
|
bgneal@45
|
979
|
bgneal@45
|
980 if (v && v.indexOf('mceItem') == -1) {
|
bgneal@45
|
981 ti += 'class: ' + v + ' ';
|
bgneal@45
|
982
|
bgneal@45
|
983 if (DOM.isBlock(n) || na == 'img' || na == 'span')
|
bgneal@45
|
984 na += '.' + v;
|
bgneal@45
|
985 }
|
bgneal@45
|
986 }
|
bgneal@45
|
987
|
bgneal@45
|
988 na = na.replace(/(html:)/g, '');
|
bgneal@45
|
989 na = {name : na, node : n, title : ti};
|
bgneal@45
|
990 t.onResolveName.dispatch(t, na);
|
bgneal@45
|
991 ti = na.title;
|
bgneal@45
|
992 na = na.name;
|
bgneal@45
|
993
|
bgneal@45
|
994 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";
|
bgneal@45
|
995 pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na);
|
bgneal@45
|
996
|
bgneal@45
|
997 if (p.hasChildNodes()) {
|
bgneal@45
|
998 p.insertBefore(DOM.doc.createTextNode(' \u00bb '), p.firstChild);
|
bgneal@45
|
999 p.insertBefore(pi, p.firstChild);
|
bgneal@45
|
1000 } else
|
bgneal@45
|
1001 p.appendChild(pi);
|
bgneal@45
|
1002 }, ed.getBody());
|
bgneal@45
|
1003 }
|
bgneal@45
|
1004 },
|
bgneal@45
|
1005
|
bgneal@45
|
1006 // Commands gets called by execCommand
|
bgneal@45
|
1007
|
bgneal@45
|
1008 _sel : function(v) {
|
bgneal@45
|
1009 this.editor.execCommand('mceSelectNodeDepth', false, v);
|
bgneal@45
|
1010 },
|
bgneal@45
|
1011
|
bgneal@45
|
1012 _mceInsertAnchor : function(ui, v) {
|
bgneal@45
|
1013 var ed = this.editor;
|
bgneal@45
|
1014
|
bgneal@45
|
1015 ed.windowManager.open({
|
bgneal@45
|
1016 url : tinymce.baseURL + '/themes/advanced/anchor.htm',
|
bgneal@45
|
1017 width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)),
|
bgneal@45
|
1018 height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)),
|
bgneal@45
|
1019 inline : true
|
bgneal@45
|
1020 }, {
|
bgneal@45
|
1021 theme_url : this.url
|
bgneal@45
|
1022 });
|
bgneal@45
|
1023 },
|
bgneal@45
|
1024
|
bgneal@45
|
1025 _mceCharMap : function() {
|
bgneal@45
|
1026 var ed = this.editor;
|
bgneal@45
|
1027
|
bgneal@45
|
1028 ed.windowManager.open({
|
bgneal@45
|
1029 url : tinymce.baseURL + '/themes/advanced/charmap.htm',
|
bgneal@45
|
1030 width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
|
bgneal@45
|
1031 height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
|
bgneal@45
|
1032 inline : true
|
bgneal@45
|
1033 }, {
|
bgneal@45
|
1034 theme_url : this.url
|
bgneal@45
|
1035 });
|
bgneal@45
|
1036 },
|
bgneal@45
|
1037
|
bgneal@45
|
1038 _mceHelp : function() {
|
bgneal@45
|
1039 var ed = this.editor;
|
bgneal@45
|
1040
|
bgneal@45
|
1041 ed.windowManager.open({
|
bgneal@45
|
1042 url : tinymce.baseURL + '/themes/advanced/about.htm',
|
bgneal@45
|
1043 width : 480,
|
bgneal@45
|
1044 height : 380,
|
bgneal@45
|
1045 inline : true
|
bgneal@45
|
1046 }, {
|
bgneal@45
|
1047 theme_url : this.url
|
bgneal@45
|
1048 });
|
bgneal@45
|
1049 },
|
bgneal@45
|
1050
|
bgneal@45
|
1051 _mceColorPicker : function(u, v) {
|
bgneal@45
|
1052 var ed = this.editor;
|
bgneal@45
|
1053
|
bgneal@45
|
1054 v = v || {};
|
bgneal@45
|
1055
|
bgneal@45
|
1056 ed.windowManager.open({
|
bgneal@45
|
1057 url : tinymce.baseURL + '/themes/advanced/color_picker.htm',
|
bgneal@45
|
1058 width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)),
|
bgneal@45
|
1059 height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)),
|
bgneal@45
|
1060 close_previous : false,
|
bgneal@45
|
1061 inline : true
|
bgneal@45
|
1062 }, {
|
bgneal@45
|
1063 input_color : v.color,
|
bgneal@45
|
1064 func : v.func,
|
bgneal@45
|
1065 theme_url : this.url
|
bgneal@45
|
1066 });
|
bgneal@45
|
1067 },
|
bgneal@45
|
1068
|
bgneal@45
|
1069 _mceCodeEditor : function(ui, val) {
|
bgneal@45
|
1070 var ed = this.editor;
|
bgneal@45
|
1071
|
bgneal@45
|
1072 ed.windowManager.open({
|
bgneal@45
|
1073 url : tinymce.baseURL + '/themes/advanced/source_editor.htm',
|
bgneal@45
|
1074 width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),
|
bgneal@45
|
1075 height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),
|
bgneal@45
|
1076 inline : true,
|
bgneal@45
|
1077 resizable : true,
|
bgneal@45
|
1078 maximizable : true
|
bgneal@45
|
1079 }, {
|
bgneal@45
|
1080 theme_url : this.url
|
bgneal@45
|
1081 });
|
bgneal@45
|
1082 },
|
bgneal@45
|
1083
|
bgneal@45
|
1084 _mceImage : function(ui, val) {
|
bgneal@45
|
1085 var ed = this.editor;
|
bgneal@45
|
1086
|
bgneal@45
|
1087 // Internal image object like a flash placeholder
|
bgneal@45
|
1088 if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)
|
bgneal@45
|
1089 return;
|
bgneal@45
|
1090
|
bgneal@45
|
1091 ed.windowManager.open({
|
bgneal@45
|
1092 url : tinymce.baseURL + '/themes/advanced/image.htm',
|
bgneal@45
|
1093 width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)),
|
bgneal@45
|
1094 height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)),
|
bgneal@45
|
1095 inline : true
|
bgneal@45
|
1096 }, {
|
bgneal@45
|
1097 theme_url : this.url
|
bgneal@45
|
1098 });
|
bgneal@45
|
1099 },
|
bgneal@45
|
1100
|
bgneal@45
|
1101 _mceLink : function(ui, val) {
|
bgneal@45
|
1102 var ed = this.editor;
|
bgneal@45
|
1103
|
bgneal@45
|
1104 ed.windowManager.open({
|
bgneal@45
|
1105 url : tinymce.baseURL + '/themes/advanced/link.htm',
|
bgneal@45
|
1106 width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)),
|
bgneal@45
|
1107 height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)),
|
bgneal@45
|
1108 inline : true
|
bgneal@45
|
1109 }, {
|
bgneal@45
|
1110 theme_url : this.url
|
bgneal@45
|
1111 });
|
bgneal@45
|
1112 },
|
bgneal@45
|
1113
|
bgneal@45
|
1114 _mceNewDocument : function() {
|
bgneal@45
|
1115 var ed = this.editor;
|
bgneal@45
|
1116
|
bgneal@45
|
1117 ed.windowManager.confirm('advanced.newdocument', function(s) {
|
bgneal@45
|
1118 if (s)
|
bgneal@45
|
1119 ed.execCommand('mceSetContent', false, '');
|
bgneal@45
|
1120 });
|
bgneal@45
|
1121 },
|
bgneal@45
|
1122
|
bgneal@45
|
1123 _mceForeColor : function() {
|
bgneal@45
|
1124 var t = this;
|
bgneal@45
|
1125
|
bgneal@45
|
1126 this._mceColorPicker(0, {
|
bgneal@45
|
1127 color: t.fgColor,
|
bgneal@45
|
1128 func : function(co) {
|
bgneal@45
|
1129 t.fgColor = co;
|
bgneal@45
|
1130 t.editor.execCommand('ForeColor', false, co);
|
bgneal@45
|
1131 }
|
bgneal@45
|
1132 });
|
bgneal@45
|
1133 },
|
bgneal@45
|
1134
|
bgneal@45
|
1135 _mceBackColor : function() {
|
bgneal@45
|
1136 var t = this;
|
bgneal@45
|
1137
|
bgneal@45
|
1138 this._mceColorPicker(0, {
|
bgneal@45
|
1139 color: t.bgColor,
|
bgneal@45
|
1140 func : function(co) {
|
bgneal@45
|
1141 t.bgColor = co;
|
bgneal@45
|
1142 t.editor.execCommand('HiliteColor', false, co);
|
bgneal@45
|
1143 }
|
bgneal@45
|
1144 });
|
bgneal@45
|
1145 },
|
bgneal@45
|
1146
|
bgneal@45
|
1147 _ufirst : function(s) {
|
bgneal@45
|
1148 return s.substring(0, 1).toUpperCase() + s.substring(1);
|
bgneal@45
|
1149 }
|
bgneal@45
|
1150 });
|
bgneal@45
|
1151
|
bgneal@45
|
1152 tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);
|
bgneal@45
|
1153 }(tinymce)); |