Fixed servefiles urls
[bcms.git] / media / tinymce / themes / advanced / editor_template_src.js
blob381ba6ba72e05a1b836b2f80889077e05a148edb
1 /**\r
2  * $Id: editor_template_src.js 766 2008-04-03 20:37:06Z spocke $\r
3  *\r
4  * @author Moxiecode\r
5  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.\r
6  */\r
7 \r
8 (function() {\r
9         var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID, explode = tinymce.explode;\r
11         // Tell it to load theme specific language pack(s)\r
12         tinymce.ThemeManager.requireLangPack('advanced');\r
14         tinymce.create('tinymce.themes.AdvancedTheme', {\r
15                 // Control name lookup, format: title, command\r
16                 controls : {\r
17                         bold : ['bold_desc', 'Bold'],\r
18                         italic : ['italic_desc', 'Italic'],\r
19                         underline : ['underline_desc', 'Underline'],\r
20                         strikethrough : ['striketrough_desc', 'Strikethrough'],\r
21                         justifyleft : ['justifyleft_desc', 'JustifyLeft'],\r
22                         justifycenter : ['justifycenter_desc', 'JustifyCenter'],\r
23                         justifyright : ['justifyright_desc', 'JustifyRight'],\r
24                         justifyfull : ['justifyfull_desc', 'JustifyFull'],\r
25                         bullist : ['bullist_desc', 'InsertUnorderedList'],\r
26                         numlist : ['numlist_desc', 'InsertOrderedList'],\r
27                         outdent : ['outdent_desc', 'Outdent'],\r
28                         indent : ['indent_desc', 'Indent'],\r
29                         cut : ['cut_desc', 'Cut'],\r
30                         copy : ['copy_desc', 'Copy'],\r
31                         paste : ['paste_desc', 'Paste'],\r
32                         undo : ['undo_desc', 'Undo'],\r
33                         redo : ['redo_desc', 'Redo'],\r
34                         link : ['link_desc', 'mceLink'],\r
35                         unlink : ['unlink_desc', 'unlink'],\r
36                         image : ['image_desc', 'mceImage'],\r
37                         cleanup : ['cleanup_desc', 'mceCleanup'],\r
38                         help : ['help_desc', 'mceHelp'],\r
39                         code : ['code_desc', 'mceCodeEditor'],\r
40                         hr : ['hr_desc', 'InsertHorizontalRule'],\r
41                         removeformat : ['removeformat_desc', 'RemoveFormat'],\r
42                         sub : ['sub_desc', 'subscript'],\r
43                         sup : ['sup_desc', 'superscript'],\r
44                         forecolor : ['forecolor_desc', 'ForeColor'],\r
45                         forecolorpicker : ['forecolor_desc', 'mceForeColor'],\r
46                         backcolor : ['backcolor_desc', 'HiliteColor'],\r
47                         backcolorpicker : ['backcolor_desc', 'mceBackColor'],\r
48                         charmap : ['charmap_desc', 'mceCharMap'],\r
49                         visualaid : ['visualaid_desc', 'mceToggleVisualAid'],\r
50                         anchor : ['anchor_desc', 'mceInsertAnchor'],\r
51                         newdocument : ['newdocument_desc', 'mceNewDocument'],\r
52                         blockquote : ['blockquote_desc', 'mceBlockQuote']\r
53                 },\r
55                 stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'],\r
57                 init : function(ed, url) {\r
58                         var t = this, s, v;\r
59         \r
60                         t.editor = ed;\r
61                         t.url = url;\r
62                         t.onResolveName = new tinymce.util.Dispatcher(this);\r
64                         // Default settings\r
65                         t.settings = s = extend({\r
66                                 theme_advanced_path : true,\r
67                                 theme_advanced_toolbar_location : 'bottom',\r
68                                 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",\r
69                                 theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",\r
70                                 theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",\r
71                                 theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6",\r
72                                 theme_advanced_toolbar_align : "center",\r
73                                 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
74                                 theme_advanced_font_sizes : "1,2,3,4,5,6,7",\r
75                                 theme_advanced_more_colors : 1,\r
76                                 theme_advanced_row_height : 23,\r
77                                 theme_advanced_resize_horizontal : 1,\r
78                                 theme_advanced_resizing_use_cookie : 1\r
79                         }, ed.settings);\r
81                         if ((v = s.theme_advanced_path_location) && v != 'none')\r
82                                 s.theme_advanced_statusbar_location = s.theme_advanced_path_location;\r
84                         if (s.theme_advanced_statusbar_location == 'none')\r
85                                 s.theme_advanced_statusbar_location = 0;\r
87                         // Init editor\r
88                         ed.onInit.add(function() {\r
89                                 ed.onNodeChange.add(t._nodeChanged, t);\r
91                                 if (ed.settings.content_css !== false)\r
92                                         ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/" + ed.settings.skin + "/content.css"));\r
93                         });\r
95                         ed.onSetProgressState.add(function(ed, b, ti) {\r
96                                 var co, id = ed.id, tb;\r
98                                 if (b) {\r
99                                         t.progressTimer = setTimeout(function() {\r
100                                                 co = ed.getContainer();\r
101                                                 co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild);\r
102                                                 tb = DOM.get(ed.id + '_tbl');\r
104                                                 DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}});\r
105                                                 DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}});\r
106                                         }, ti || 0);\r
107                                 } else {\r
108                                         DOM.remove(id + '_blocker');\r
109                                         DOM.remove(id + '_progress');\r
110                                         clearTimeout(t.progressTimer);\r
111                                 }\r
112                         });\r
114                         DOM.loadCSS(ed.baseURI.toAbsolute(s.editor_css || "themes/advanced/skins/" + ed.settings.skin + "/ui.css"));\r
116                         if (s.skin_variant)\r
117                                 DOM.loadCSS(ed.baseURI.toAbsolute(s.editor_css || "themes/advanced/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css"));\r
118                 },\r
120                 createControl : function(n, cf) {\r
121                         var cd, c;\r
123                         if (c = cf.createControl(n))\r
124                                 return c;\r
126                         switch (n) {\r
127                                 case "styleselect":\r
128                                         return this._createStyleSelect();\r
130                                 case "formatselect":\r
131                                         return this._createBlockFormats();\r
133                                 case "fontselect":\r
134                                         return this._createFontSelect();\r
136                                 case "fontsizeselect":\r
137                                         return this._createFontSizeSelect();\r
139                                 case "forecolor":\r
140                                         return this._createForeColorMenu();\r
142                                 case "backcolor":\r
143                                         return this._createBackColorMenu();\r
144                         }\r
146                         if ((cd = this.controls[n]))\r
147                                 return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]});\r
148                 },\r
150                 execCommand : function(cmd, ui, val) {\r
151                         var f = this['_' + cmd];\r
153                         if (f) {\r
154                                 f.call(this, ui, val);\r
155                                 return true;\r
156                         }\r
158                         return false;\r
159                 },\r
161                 _importClasses : function() {\r
162                         var ed = this.editor, c = ed.controlManager.get('styleselect');\r
164                         if (c.getLength() == 0) {\r
165                                 each(ed.dom.getClasses(), function(o) {\r
166                                         c.add(o['class'], o['class']);\r
167                                 });\r
168                         }\r
169                 },\r
171                 _createStyleSelect : function(n) {\r
172                         var t = this, ed = t.editor, cf = ed.controlManager, c = cf.createListBox('styleselect', {\r
173                                 title : 'advanced.style_select',\r
174                                 onselect : function(v) {\r
175                                         if (c.selectedValue === v) {\r
176                                                 ed.execCommand('mceSetStyleInfo', 0, {command : 'removeformat'});\r
177                                                 c.select();\r
178                                                 return false;\r
179                                         } else\r
180                                                 ed.execCommand('mceSetCSSClass', 0, v);\r
181                                 }\r
182                         });\r
184                         if (c) {\r
185                                 each(ed.getParam('theme_advanced_styles', '', 'hash'), function(v, k) {\r
186                                         if (v)\r
187                                                 c.add(t.editor.translate(k), v);\r
188                                 });\r
190                                 c.onPostRender.add(function(ed, n) {\r
191                                         Event.add(n, 'focus', t._importClasses, t);\r
192                                         Event.add(n, 'mousedown', t._importClasses, t);\r
193                                 });\r
194                         }\r
196                         return c;\r
197                 },\r
199                 _createFontSelect : function() {\r
200                         var c, t = this, ed = t.editor;\r
202                         c = ed.controlManager.createListBox('fontselect', {title : 'advanced.fontdefault', cmd : 'FontName'});\r
203                         if (c) {\r
204                                 each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) {\r
205                                         c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''});\r
206                                 });\r
207                         }\r
209                         return c;\r
210                 },\r
212                 _createFontSizeSelect : function() {\r
213                         var c, t = this, lo = [\r
214                                 "1 (8 pt)",\r
215                                 "2 (10 pt)",\r
216                                 "3 (12 pt)",\r
217                                 "4 (14 pt)",\r
218                                 "5 (18 pt)",\r
219                                 "6 (24 pt)",\r
220                                 "7 (36 pt)"\r
221                         ], fz = [8, 10, 12, 14, 18, 24, 36];\r
223                         c = t.editor.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', cmd : 'FontSize'});\r
224                         if (c) {\r
225                                 each(explode(t.settings.theme_advanced_font_sizes), function(v) {\r
226                                         c.add(lo[parseInt(v) - 1], v, {'style' : 'font-size:' + fz[v - 1] + 'pt', 'class' : 'mceFontSize' + v});\r
227                                 });\r
228                         }\r
230                         return c;\r
231                 },\r
233                 _createBlockFormats : function() {\r
234                         var c, fmts = {\r
235                                 p : 'advanced.paragraph',\r
236                                 address : 'advanced.address',\r
237                                 pre : 'advanced.pre',\r
238                                 h1 : 'advanced.h1',\r
239                                 h2 : 'advanced.h2',\r
240                                 h3 : 'advanced.h3',\r
241                                 h4 : 'advanced.h4',\r
242                                 h5 : 'advanced.h5',\r
243                                 h6 : 'advanced.h6',\r
244                                 div : 'advanced.div',\r
245                                 blockquote : 'advanced.blockquote',\r
246                                 code : 'advanced.code',\r
247                                 dt : 'advanced.dt',\r
248                                 dd : 'advanced.dd',\r
249                                 samp : 'advanced.samp'\r
250                         }, t = this;\r
252                         c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'});\r
253                         if (c) {\r
254                                 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) {\r
255                                         c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v});\r
256                                 });\r
257                         }\r
259                         return c;\r
260                 },\r
262                 _createForeColorMenu : function() {\r
263                         var c, t = this, s = t.settings, o = {}, v;\r
265                         if (s.theme_advanced_more_colors) {\r
266                                 o.more_colors_func = function() {\r
267                                         t._mceColorPicker(0, {\r
268                                                 color : c.value,\r
269                                                 func : function(co) {\r
270                                                         c.setColor(co);\r
271                                                 }\r
272                                         });\r
273                                 };\r
274                         }\r
276                         if (v = s.theme_advanced_text_colors)\r
277                                 o.colors = v;\r
279                         o.title = 'advanced.forecolor_desc';\r
280                         o.cmd = 'ForeColor';\r
281                         o.scope = this;\r
283                         c = t.editor.controlManager.createColorSplitButton('forecolor', o);\r
285                         return c;\r
286                 },\r
288                 _createBackColorMenu : function() {\r
289                         var c, t = this, s = t.settings, o = {}, v;\r
291                         if (s.theme_advanced_more_colors) {\r
292                                 o.more_colors_func = function() {\r
293                                         t._mceColorPicker(0, {\r
294                                                 color : c.value,\r
295                                                 func : function(co) {\r
296                                                         c.setColor(co);\r
297                                                 }\r
298                                         });\r
299                                 };\r
300                         }\r
302                         if (v = s.theme_advanced_background_colors)\r
303                                 o.colors = v;\r
305                         o.title = 'advanced.backcolor_desc';\r
306                         o.cmd = 'HiliteColor';\r
307                         o.scope = this;\r
309                         c = t.editor.controlManager.createColorSplitButton('backcolor', o);\r
311                         return c;\r
312                 },\r
314                 renderUI : function(o) {\r
315                         var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;\r
317                         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
319                         if (!DOM.boxModel)\r
320                                 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});\r
322                         n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});\r
323                         n = tb = DOM.add(n, 'tbody');\r
325                         switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {\r
326                                 case "rowlayout":\r
327                                         ic = t._rowLayout(s, tb, o);\r
328                                         break;\r
330                                 case "customlayout":\r
331                                         ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);\r
332                                         break;\r
334                                 default:\r
335                                         ic = t._simpleLayout(s, tb, o, p);\r
336                         }\r
338                         n = o.targetNode;\r
340                         // Add classes to first and last TRs\r
341                         nl = DOM.stdMode ? sc.getElementsByTagName('tr') : sc.rows; // Quick fix for IE 8\r
342                         DOM.addClass(nl[0], 'mceFirst');\r
343                         DOM.addClass(nl[nl.length - 1], 'mceLast');\r
345                         // Add classes to first and last TDs\r
346                         each(DOM.select('tr', tb), function(n) {\r
347                                 DOM.addClass(n.firstChild, 'mceFirst');\r
348                                 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast');\r
349                         });\r
351                         if (DOM.get(s.theme_advanced_toolbar_container))\r
352                                 DOM.get(s.theme_advanced_toolbar_container).appendChild(p);\r
353                         else\r
354                                 DOM.insertAfter(p, n);\r
356                         Event.add(ed.id + '_path_row', 'click', function(e) {\r
357                                 e = e.target;\r
359                                 if (e.nodeName == 'A') {\r
360                                         t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));\r
362                                         return Event.cancel(e);\r
363                                 }\r
364                         });\r
365 /*\r
366                         if (DOM.get(ed.id + '_path_row')) {\r
367                                 Event.add(ed.id + '_tbl', 'mouseover', function(e) {\r
368                                         var re;\r
369         \r
370                                         e = e.target;\r
372                                         if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {\r
373                                                 re = DOM.get(ed.id + '_path_row');\r
374                                                 t.lastPath = re.innerHTML;\r
375                                                 DOM.setHTML(re, e.parentNode.title);\r
376                                         }\r
377                                 });\r
379                                 Event.add(ed.id + '_tbl', 'mouseout', function(e) {\r
380                                         if (t.lastPath) {\r
381                                                 DOM.setHTML(ed.id + '_path_row', t.lastPath);\r
382                                                 t.lastPath = 0;\r
383                                         }\r
384                                 });\r
385                         }\r
386 */\r
388                         if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))\r
389                                 Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});\r
391                         if (s.theme_advanced_toolbar_location == 'external')\r
392                                 o.deltaHeight = 0;\r
394                         t.deltaHeight = o.deltaHeight;\r
395                         o.targetNode = null;\r
397                         return {\r
398                                 iframeContainer : ic,\r
399                                 editorContainer : ed.id + '_parent',\r
400                                 sizeContainer : sc,\r
401                                 deltaHeight : o.deltaHeight\r
402                         };\r
403                 },\r
405                 getInfo : function() {\r
406                         return {\r
407                                 longname : 'Advanced theme',\r
408                                 author : 'Moxiecode Systems AB',\r
409                                 authorurl : 'http://tinymce.moxiecode.com',\r
410                                 version : tinymce.majorVersion + "." + tinymce.minorVersion\r
411                         }\r
412                 },\r
414                 resizeBy : function(dw, dh) {\r
415                         var e = DOM.get(this.editor.id + '_tbl');\r
417                         this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);\r
418                 },\r
420                 resizeTo : function(w, h) {\r
421                         var ed = this.editor, s = ed.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'), dh;\r
423                         // Boundery fix box\r
424                         w = Math.max(s.theme_advanced_resizing_min_width || 100, w);\r
425                         h = Math.max(s.theme_advanced_resizing_min_height || 100, h);\r
426                         w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);\r
427                         h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);\r
429                         // Calc difference between iframe and container\r
430                         dh = e.clientHeight - ifr.clientHeight;\r
432                         // Resize iframe and container\r
433                         DOM.setStyle(ifr, 'height', h - dh);\r
434                         DOM.setStyles(e, {width : w, height : h});\r
435                 },\r
437                 destroy : function() {\r
438                         var id = this.editor.id;\r
440                         Event.clear(id + '_resize');\r
441                         Event.clear(id + '_path_row');\r
442                         Event.clear(id + '_external_close');\r
443                 },\r
445                 // Internal functions\r
447                 _simpleLayout : function(s, tb, o, p) {\r
448                         var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;\r
450                         // Create toolbar container at top\r
451                         if (lo == 'top')\r
452                                 t._addToolbars(tb, o);\r
454                         // Create external toolbar\r
455                         if (lo == 'external') {\r
456                                 n = c = DOM.create('div', {style : 'position:relative'});\r
457                                 n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});\r
458                                 DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});\r
459                                 n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});\r
460                                 etb = DOM.add(n, 'tbody');\r
462                                 if (p.firstChild.className == 'mceOldBoxModel')\r
463                                         p.firstChild.appendChild(c);\r
464                                 else\r
465                                         p.insertBefore(c, p.firstChild);\r
467                                 t._addToolbars(etb, o);\r
469                                 ed.onMouseUp.add(function() {\r
470                                         var e = DOM.get(ed.id + '_external');\r
471                                         DOM.show(e);\r
473                                         DOM.hide(lastExtID);\r
475                                         var f = Event.add(ed.id + '_external_close', 'click', function() {\r
476                                                 DOM.hide(ed.id + '_external');\r
477                                                 Event.remove(ed.id + '_external_close', 'click', f);\r
478                                         });\r
480                                         DOM.show(e);\r
481                                         DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);\r
483                                         // Fixes IE rendering bug\r
484                                         DOM.hide(e);\r
485                                         DOM.show(e);\r
486                                         e.style.filter = '';\r
488                                         lastExtID = ed.id + '_external';\r
490                                         e = null;\r
491                                 });\r
492                         }\r
494                         if (sl == 'top')\r
495                                 t._addStatusBar(tb, o);\r
497                         // Create iframe container\r
498                         if (!s.theme_advanced_toolbar_container) {\r
499                                 n = DOM.add(tb, 'tr');\r
500                                 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});\r
501                         }\r
503                         // Create toolbar container at bottom\r
504                         if (lo == 'bottom')\r
505                                 t._addToolbars(tb, o);\r
507                         if (sl == 'bottom')\r
508                                 t._addStatusBar(tb, o);\r
510                         return ic;\r
511                 },\r
513                 _rowLayout : function(s, tb, o) {\r
514                         var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;\r
516                         dc = s.theme_advanced_containers_default_class || '';\r
517                         da = s.theme_advanced_containers_default_align || 'center';\r
519                         each(explode(s.theme_advanced_containers || ''), function(c, i) {\r
520                                 var v = s['theme_advanced_container_' + c] || '';\r
522                                 switch (c.toLowerCase()) {\r
523                                         case 'mceeditor':\r
524                                                 n = DOM.add(tb, 'tr');\r
525                                                 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});\r
526                                                 break;\r
528                                         case 'mceelementpath':\r
529                                                 t._addStatusBar(tb, o);\r
530                                                 break;\r
532                                         default:\r
533                                                 a = s['theme_advanced_container_' + c + '_align'].toLowerCase();\r
534                                                 a = 'mce' + t._ufirst(a);\r
536                                                 n = DOM.add(DOM.add(tb, 'tr'), 'td', {\r
537                                                         'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da\r
538                                                 });\r
540                                                 to = cf.createToolbar("toolbar" + i);\r
541                                                 t._addControls(v, to);\r
542                                                 DOM.setHTML(n, to.renderHTML());\r
543                                                 o.deltaHeight -= s.theme_advanced_row_height;\r
544                                 }\r
545                         });\r
547                         return ic;\r
548                 },\r
550                 _addControls : function(v, tb) {\r
551                         var t = this, s = t.settings, di, cf = t.editor.controlManager;\r
553                         if (s.theme_advanced_disable && !t._disabled) {\r
554                                 di = {};\r
556                                 each(explode(s.theme_advanced_disable), function(v) {\r
557                                         di[v] = 1;\r
558                                 });\r
560                                 t._disabled = di;\r
561                         } else\r
562                                 di = t._disabled;\r
564                         each(explode(v), function(n) {\r
565                                 var c;\r
567                                 if (di && di[n])\r
568                                         return;\r
570                                 // Compatiblity with 2.x\r
571                                 if (n == 'tablecontrols') {\r
572                                         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
573                                                 n = t.createControl(n, cf);\r
575                                                 if (n)\r
576                                                         tb.add(n);\r
577                                         });\r
579                                         return;\r
580                                 }\r
582                                 c = t.createControl(n, cf);\r
584                                 if (c)\r
585                                         tb.add(c);\r
586                         });\r
587                 },\r
589                 _addToolbars : function(c, o) {\r
590                         var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a;\r
592                         a = s.theme_advanced_toolbar_align.toLowerCase();\r
593                         a = 'mce' + t._ufirst(a);\r
595                         n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a});\r
597                         if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))\r
598                                 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));\r
600                         h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->'));\r
602                         // Create toolbar and add the controls\r
603                         for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {\r
604                                 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});\r
606                                 if (s['theme_advanced_buttons' + i + '_add'])\r
607                                         v += ',' + s['theme_advanced_buttons' + i + '_add'];\r
609                                 if (s['theme_advanced_buttons' + i + '_add_before'])\r
610                                         v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;\r
612                                 t._addControls(v, tb);\r
614                                 //n.appendChild(n = tb.render());\r
615                                 h.push(tb.renderHTML());\r
617                                 o.deltaHeight -= s.theme_advanced_row_height;\r
618                         }\r
620                         h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));\r
621                         DOM.setHTML(n, h.join(''));\r
622                 },\r
624                 _addStatusBar : function(tb, o) {\r
625                         var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;\r
627                         n = DOM.add(tb, 'tr');\r
628                         n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});\r
629                         n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : '&nbsp;');\r
630                         DOM.add(n, 'a', {href : '#', accesskey : 'x'});\r
632                         if (s.theme_advanced_resizing && !tinymce.isOldWebKit) {\r
633                                 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});\r
635                                 if (s.theme_advanced_resizing_use_cookie) {\r
636                                         ed.onPostRender.add(function() {\r
637                                                 var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');\r
639                                                 if (!o)\r
640                                                         return;\r
642                                                 if (s.theme_advanced_resize_horizontal)\r
643                                                         c.style.width = Math.max(10, o.cw) + 'px';\r
645                                                 c.style.height = Math.max(10, o.ch) + 'px';\r
646                                                 DOM.get(ed.id + '_ifr').style.height = Math.max(10, parseInt(o.ch) + t.deltaHeight) + 'px';\r
647                                         });\r
648                                 }\r
650                                 ed.onPostRender.add(function() {\r
651                                         Event.add(ed.id + '_resize', 'mousedown', function(e) {\r
652                                                 var c, p, w, h, n, pa;\r
654                                                 // Measure container\r
655                                                 c = DOM.get(ed.id + '_tbl');\r
656                                                 w = c.clientWidth;\r
657                                                 h = c.clientHeight;\r
659                                                 miw = s.theme_advanced_resizing_min_width || 100;\r
660                                                 mih = s.theme_advanced_resizing_min_height || 100;\r
661                                                 maw = s.theme_advanced_resizing_max_width || 0xFFFF;\r
662                                                 mah = s.theme_advanced_resizing_max_height || 0xFFFF;\r
664                                                 // Setup placeholder\r
665                                                 p = DOM.add(DOM.get(ed.id + '_parent'), 'div', {'class' : 'mcePlaceHolder'});\r
666                                                 DOM.setStyles(p, {width : w, height : h});\r
668                                                 // Replace with placeholder\r
669                                                 DOM.hide(c);\r
670                                                 DOM.show(p);\r
672                                                 // Create internal resize obj\r
673                                                 r = {\r
674                                                         x : e.screenX,\r
675                                                         y : e.screenY,\r
676                                                         w : w,\r
677                                                         h : h,\r
678                                                         dx : null,\r
679                                                         dy : null\r
680                                                 };\r
682                                                 // Start listening\r
683                                                 mf = Event.add(DOM.doc, 'mousemove', function(e) {\r
684                                                         var w, h;\r
686                                                         // Calc delta values\r
687                                                         r.dx = e.screenX - r.x;\r
688                                                         r.dy = e.screenY - r.y;\r
690                                                         // Boundery fix box\r
691                                                         w = Math.max(miw, r.w + r.dx);\r
692                                                         h = Math.max(mih, r.h + r.dy);\r
693                                                         w = Math.min(maw, w);\r
694                                                         h = Math.min(mah, h);\r
696                                                         // Resize placeholder\r
697                                                         if (s.theme_advanced_resize_horizontal)\r
698                                                                 p.style.width = w + 'px';\r
700                                                         p.style.height = h + 'px';\r
702                                                         return Event.cancel(e);\r
703                                                 });\r
705                                                 me = Event.add(DOM.doc, 'mouseup', function(e) {\r
706                                                         var ifr;\r
708                                                         // Stop listening\r
709                                                         Event.remove(DOM.doc, 'mousemove', mf);\r
710                                                         Event.remove(DOM.doc, 'mouseup', me);\r
712                                                         c.style.display = '';\r
713                                                         DOM.remove(p);\r
715                                                         if (r.dx === null)\r
716                                                                 return;\r
718                                                         ifr = DOM.get(ed.id + '_ifr');\r
720                                                         if (s.theme_advanced_resize_horizontal)\r
721                                                                 c.style.width = Math.max(10, r.w + r.dx) + 'px';\r
723                                                         c.style.height = Math.max(10, r.h + r.dy) + 'px';\r
724                                                         ifr.style.height = Math.max(10, ifr.clientHeight + r.dy) + 'px';\r
726                                                         if (s.theme_advanced_resizing_use_cookie) {\r
727                                                                 Cookie.setHash("TinyMCE_" + ed.id + "_size", {\r
728                                                                         cw : r.w + r.dx,\r
729                                                                         ch : r.h + r.dy\r
730                                                                 });\r
731                                                         }\r
732                                                 });\r
734                                                 return Event.cancel(e);\r
735                                         });\r
736                                 });\r
737                         }\r
739                         o.deltaHeight -= 21;\r
740                         n = tb = null;\r
741                 },\r
743                 _nodeChanged : function(ed, cm, n, co) {\r
744                         var t = this, p, de = 0, v, c, s = t.settings;\r
746                         tinymce.each(t.stateControls, function(c) {\r
747                                 cm.setActive(c, ed.queryCommandState(t.controls[c][1]));\r
748                         });\r
750                         cm.setActive('visualaid', ed.hasVisual);\r
751                         cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing);\r
752                         cm.setDisabled('redo', !ed.undoManager.hasRedo());\r
753                         cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));\r
755                         p = DOM.getParent(n, 'A');\r
756                         if (c = cm.get('link')) {\r
757                                 if (!p || !p.name) {\r
758                                         c.setDisabled(!p && co);\r
759                                         c.setActive(!!p);\r
760                                 }\r
761                         }\r
763                         if (c = cm.get('unlink')) {\r
764                                 c.setDisabled(!p && co);\r
765                                 c.setActive(!!p && !p.name);\r
766                         }\r
768                         if (c = cm.get('anchor')) {\r
769                                 c.setActive(!!p && p.name);\r
771                                 if (tinymce.isWebKit) {\r
772                                         p = DOM.getParent(n, 'IMG');\r
773                                         c.setActive(!!p && DOM.getAttrib(p, 'mce_name') == 'a');\r
774                                 }\r
775                         }\r
777                         p = DOM.getParent(n, 'IMG');\r
778                         if (c = cm.get('image'))\r
779                                 c.setActive(!!p && n.className.indexOf('mceItem') == -1);\r
781                         if (c = cm.get('styleselect')) {\r
782                                 if (n.className) {\r
783                                         t._importClasses();\r
784                                         c.select(n.className);\r
785                                 } else\r
786                                         c.select();\r
787                         }\r
789                         if (c = cm.get('formatselect')) {\r
790                                 p = DOM.getParent(n, DOM.isBlock);\r
792                                 if (p)\r
793                                         c.select(p.nodeName.toLowerCase());\r
794                         }\r
796                         if (c = cm.get('fontselect'))\r
797                                 c.select(ed.queryCommandValue('FontName'));\r
799                         if (c = cm.get('fontsizeselect'))\r
800                                 c.select(ed.queryCommandValue('FontSize'));\r
802                         if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {\r
803                                 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});\r
804                                 DOM.setHTML(p, '');\r
806                                 ed.dom.getParent(n, function(n) {\r
807                                         var na = n.nodeName.toLowerCase(), u, pi, ti = '';\r
809                                         // Ignore non element and hidden elements\r
810                                         if (n.nodeType != 1 || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')))\r
811                                                 return;\r
813                                         // Fake name\r
814                                         if (v = DOM.getAttrib(n, 'mce_name'))\r
815                                                 na = v;\r
816         \r
817                                         // Handle prefix\r
818                                         if (tinymce.isIE && n.scopeName !== 'HTML')\r
819                                                 na = n.scopeName + ':' + na;\r
821                                         // Remove internal prefix\r
822                                         na = na.replace(/mce\:/g, '');\r
824                                         // Handle node name\r
825                                         switch (na) {\r
826                                                 case 'b':\r
827                                                         na = 'strong';\r
828                                                         break;\r
830                                                 case 'i':\r
831                                                         na = 'em';\r
832                                                         break;\r
834                                                 case 'img':\r
835                                                         if (v = DOM.getAttrib(n, 'src'))\r
836                                                                 ti += 'src: ' + v + ' ';\r
838                                                         break;\r
840                                                 case 'a':\r
841                                                         if (v = DOM.getAttrib(n, 'name')) {\r
842                                                                 ti += 'name: ' + v + ' ';\r
843                                                                 na += '#' + v;\r
844                                                         }\r
846                                                         if (v = DOM.getAttrib(n, 'href'))\r
847                                                                 ti += 'href: ' + v + ' ';\r
849                                                         break;\r
851                                                 case 'font':\r
852                                                         if (s.convert_fonts_to_spans)\r
853                                                                 na = 'span';\r
855                                                         if (v = DOM.getAttrib(n, 'face'))\r
856                                                                 ti += 'font: ' + v + ' ';\r
858                                                         if (v = DOM.getAttrib(n, 'size'))\r
859                                                                 ti += 'size: ' + v + ' ';\r
861                                                         if (v = DOM.getAttrib(n, 'color'))\r
862                                                                 ti += 'color: ' + v + ' ';\r
864                                                         break;\r
866                                                 case 'span':\r
867                                                         if (v = DOM.getAttrib(n, 'style'))\r
868                                                                 ti += 'style: ' + v + ' ';\r
870                                                         break;\r
871                                         }\r
873                                         if (v = DOM.getAttrib(n, 'id'))\r
874                                                 ti += 'id: ' + v + ' ';\r
876                                         if (v = n.className) {\r
877                                                 v = v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g, '');\r
879                                                 if (v && v.indexOf('mceItem') == -1) {\r
880                                                         ti += 'class: ' + v + ' ';\r
882                                                         if (DOM.isBlock(n) || na == 'img' || na == 'span')\r
883                                                                 na += '.' + v;\r
884                                                 }\r
885                                         }\r
887                                         na = na.replace(/(html:)/g, '');\r
888                                         na = {name : na, node : n, title : ti};\r
889                                         t.onResolveName.dispatch(t, na);\r
890                                         ti = na.title;\r
891                                         na = na.name;\r
893                                         //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";\r
894                                         pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na);\r
896                                         if (p.hasChildNodes()) {\r
897                                                 p.insertBefore(DOM.doc.createTextNode(' \u00bb '), p.firstChild);\r
898                                                 p.insertBefore(pi, p.firstChild);\r
899                                         } else\r
900                                                 p.appendChild(pi);\r
901                                 }, ed.getBody());\r
902                         }\r
903                 },\r
905                 // Commands gets called by execCommand\r
907                 _sel : function(v) {\r
908                         this.editor.execCommand('mceSelectNodeDepth', false, v);\r
909                 },\r
911                 _mceInsertAnchor : function(ui, v) {\r
912                         var ed = this.editor;\r
914                         ed.windowManager.open({\r
915                                 url : tinymce.baseURL + '/themes/advanced/anchor.htm',\r
916                                 width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)),\r
917                                 height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)),\r
918                                 inline : true\r
919                         }, {\r
920                                 theme_url : this.url\r
921                         });\r
922                 },\r
924                 _mceCharMap : function() {\r
925                         var ed = this.editor;\r
927                         ed.windowManager.open({\r
928                                 url : tinymce.baseURL + '/themes/advanced/charmap.htm',\r
929                                 width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),\r
930                                 height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),\r
931                                 inline : true\r
932                         }, {\r
933                                 theme_url : this.url\r
934                         });\r
935                 },\r
937                 _mceHelp : function() {\r
938                         var ed = this.editor;\r
940                         ed.windowManager.open({\r
941                                 url : tinymce.baseURL + '/themes/advanced/about.htm',\r
942                                 width : 480,\r
943                                 height : 380,\r
944                                 inline : true\r
945                         }, {\r
946                                 theme_url : this.url\r
947                         });\r
948                 },\r
950                 _mceColorPicker : function(u, v) {\r
951                         var ed = this.editor;\r
953                         v = v || {};\r
955                         ed.windowManager.open({\r
956                                 url : tinymce.baseURL + '/themes/advanced/color_picker.htm',\r
957                                 width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)),\r
958                                 height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)),\r
959                                 close_previous : false,\r
960                                 inline : true\r
961                         }, {\r
962                                 input_color : v.color,\r
963                                 func : v.func,\r
964                                 theme_url : this.url\r
965                         });\r
966                 },\r
968                 _mceCodeEditor : function(ui, val) {\r
969                         var ed = this.editor;\r
971                         ed.windowManager.open({\r
972                                 url : tinymce.baseURL + '/themes/advanced/source_editor.htm',\r
973                                 width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),\r
974                                 height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),\r
975                                 inline : true,\r
976                                 resizable : true,\r
977                                 maximizable : true\r
978                         }, {\r
979                                 theme_url : this.url\r
980                         });\r
981                 },\r
983                 _mceImage : function(ui, val) {\r
984                         var ed = this.editor;\r
986                         // Internal image object like a flash placeholder\r
987                         if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)\r
988                                 return;\r
990                         ed.windowManager.open({\r
991                                 url : tinymce.baseURL + '/themes/advanced/image.htm',\r
992                                 width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)),\r
993                                 height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)),\r
994                                 inline : true\r
995                         }, {\r
996                                 theme_url : this.url\r
997                         });\r
998                 },\r
1000                 _mceLink : function(ui, val) {\r
1001                         var ed = this.editor;\r
1003                         ed.windowManager.open({\r
1004                                 url : tinymce.baseURL + '/themes/advanced/link.htm',\r
1005                                 width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)),\r
1006                                 height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)),\r
1007                                 inline : true\r
1008                         }, {\r
1009                                 theme_url : this.url\r
1010                         });\r
1011                 },\r
1013                 _mceNewDocument : function() {\r
1014                         var ed = this.editor;\r
1016                         ed.windowManager.confirm('advanced.newdocument', function(s) {\r
1017                                 if (s)\r
1018                                         ed.execCommand('mceSetContent', false, '');\r
1019                         });\r
1020                 },\r
1022                 _mceForeColor : function() {\r
1023                         var t = this;\r
1025                         this._mceColorPicker(0, {\r
1026                                 func : function(co) {\r
1027                                         t.editor.execCommand('ForeColor', false, co);\r
1028                                 }\r
1029                         });\r
1030                 },\r
1032                 _mceBackColor : function() {\r
1033                         var t = this;\r
1035                         this._mceColorPicker(0, {\r
1036                                 func : function(co) {\r
1037                                         t.editor.execCommand('HiliteColor', false, co);\r
1038                                 }\r
1039                         });\r
1040                 },\r
1042                 _ufirst : function(s) {\r
1043                         return s.substring(0, 1).toUpperCase() + s.substring(1);\r
1044                 }\r
1045         });\r
1047         tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);\r
1048 }());