annotate media/js/tiny_mce/themes/advanced/editor_template_src.js @ 183:149c3567fec1

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