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