annotate media/js/tiny_mce/themes/advanced/editor_template_src.js @ 232:a46788862737

Implement a forum favorites feature for #82
author Brian Neal <bgneal@gmail.com>
date Sun, 01 Aug 2010 21:26:12 +0000
parents 237710206167
children 6ed2932901fa
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@217 206 attributes : {'class' : 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@217 222 var matches, formatNames = [];
bgneal@217 223
bgneal@217 224 each(ctrl.items, function(item) {
bgneal@217 225 formatNames.push(item.value);
bgneal@217 226 });
bgneal@217 227
bgneal@217 228 ed.focus();
bgneal@217 229
bgneal@217 230 // Toggle off the current format
bgneal@217 231 matches = ed.formatter.matchAll(formatNames);
bgneal@217 232 if (matches[0] == name)
bgneal@217 233 ed.formatter.remove(name);
bgneal@217 234 else
bgneal@217 235 ed.formatter.apply(name);
bgneal@183 236
bgneal@183 237 return false; // No auto select
bgneal@45 238 }
bgneal@45 239 });
bgneal@45 240
bgneal@183 241 // Handle specified format
bgneal@183 242 ed.onInit.add(function() {
bgneal@183 243 var counter = 0, formats = ed.getParam('style_formats');
bgneal@45 244
bgneal@183 245 if (formats) {
bgneal@183 246 each(formats, function(fmt) {
bgneal@183 247 var name, keys = 0;
bgneal@183 248
bgneal@183 249 each(fmt, function() {keys++;});
bgneal@183 250
bgneal@183 251 if (keys > 1) {
bgneal@183 252 name = fmt.name = fmt.name || 'style_' + (counter++);
bgneal@183 253 ed.formatter.register(name, fmt);
bgneal@183 254 ctrl.add(fmt.title, name);
bgneal@183 255 } else
bgneal@183 256 ctrl.add(fmt.title);
bgneal@183 257 });
bgneal@183 258 } else {
bgneal@183 259 each(ed.getParam('theme_advanced_styles', '', 'hash'), function(val, key) {
bgneal@183 260 var name;
bgneal@183 261
bgneal@183 262 if (val) {
bgneal@183 263 name = 'style_' + (counter++);
bgneal@183 264
bgneal@183 265 ed.formatter.register(name, {
bgneal@183 266 inline : 'span',
bgneal@217 267 classes : val,
bgneal@217 268 selector : '*'
bgneal@183 269 });
bgneal@183 270
bgneal@183 271 ctrl.add(t.editor.translate(key), name);
bgneal@183 272 }
bgneal@183 273 });
bgneal@183 274 }
bgneal@183 275 });
bgneal@183 276
bgneal@183 277 // Auto import classes if the ctrl box is empty
bgneal@183 278 if (ctrl.getLength() == 0) {
bgneal@183 279 ctrl.onPostRender.add(function(ed, n) {
bgneal@183 280 if (!ctrl.NativeListBox) {
bgneal@45 281 Event.add(n.id + '_text', 'focus', t._importClasses, t);
bgneal@45 282 Event.add(n.id + '_text', 'mousedown', t._importClasses, t);
bgneal@45 283 Event.add(n.id + '_open', 'focus', t._importClasses, t);
bgneal@45 284 Event.add(n.id + '_open', 'mousedown', t._importClasses, t);
bgneal@45 285 } else
bgneal@45 286 Event.add(n.id, 'focus', t._importClasses, t);
bgneal@45 287 });
bgneal@45 288 }
bgneal@45 289
bgneal@183 290 return ctrl;
bgneal@45 291 },
bgneal@45 292
bgneal@45 293 _createFontSelect : function() {
bgneal@45 294 var c, t = this, ed = t.editor;
bgneal@45 295
bgneal@183 296 c = ed.controlManager.createListBox('fontselect', {
bgneal@183 297 title : 'advanced.fontdefault',
bgneal@183 298 onselect : function(v) {
bgneal@183 299 ed.execCommand('FontName', false, v);
bgneal@183 300 return false; // No auto select
bgneal@183 301 }
bgneal@183 302 });
bgneal@183 303
bgneal@45 304 if (c) {
bgneal@45 305 each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) {
bgneal@45 306 c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''});
bgneal@45 307 });
bgneal@45 308 }
bgneal@45 309
bgneal@45 310 return c;
bgneal@45 311 },
bgneal@45 312
bgneal@45 313 _createFontSizeSelect : function() {
bgneal@45 314 var t = this, ed = t.editor, c, i = 0, cl = [];
bgneal@45 315
bgneal@45 316 c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) {
bgneal@217 317 if (v['class']) {
bgneal@217 318 ed.focus();
bgneal@217 319 ed.formatter.toggle('fontsize_class', {value : v['class']});
bgneal@217 320 } else
bgneal@45 321 ed.execCommand('FontSize', false, v.fontSize);
bgneal@183 322
bgneal@183 323 return false; // No auto select
bgneal@45 324 }});
bgneal@45 325
bgneal@45 326 if (c) {
bgneal@45 327 each(t.settings.theme_advanced_font_sizes, function(v, k) {
bgneal@45 328 var fz = v.fontSize;
bgneal@45 329
bgneal@45 330 if (fz >= 1 && fz <= 7)
bgneal@45 331 fz = t.sizes[parseInt(fz) - 1] + 'pt';
bgneal@45 332
bgneal@45 333 c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))});
bgneal@45 334 });
bgneal@45 335 }
bgneal@45 336
bgneal@45 337 return c;
bgneal@45 338 },
bgneal@45 339
bgneal@45 340 _createBlockFormats : function() {
bgneal@45 341 var c, fmts = {
bgneal@45 342 p : 'advanced.paragraph',
bgneal@45 343 address : 'advanced.address',
bgneal@45 344 pre : 'advanced.pre',
bgneal@45 345 h1 : 'advanced.h1',
bgneal@45 346 h2 : 'advanced.h2',
bgneal@45 347 h3 : 'advanced.h3',
bgneal@45 348 h4 : 'advanced.h4',
bgneal@45 349 h5 : 'advanced.h5',
bgneal@45 350 h6 : 'advanced.h6',
bgneal@45 351 div : 'advanced.div',
bgneal@45 352 blockquote : 'advanced.blockquote',
bgneal@45 353 code : 'advanced.code',
bgneal@45 354 dt : 'advanced.dt',
bgneal@45 355 dd : 'advanced.dd',
bgneal@45 356 samp : 'advanced.samp'
bgneal@45 357 }, t = this;
bgneal@45 358
bgneal@45 359 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'});
bgneal@45 360 if (c) {
bgneal@45 361 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) {
bgneal@45 362 c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v});
bgneal@45 363 });
bgneal@45 364 }
bgneal@45 365
bgneal@45 366 return c;
bgneal@45 367 },
bgneal@45 368
bgneal@45 369 _createForeColorMenu : function() {
bgneal@45 370 var c, t = this, s = t.settings, o = {}, v;
bgneal@45 371
bgneal@45 372 if (s.theme_advanced_more_colors) {
bgneal@45 373 o.more_colors_func = function() {
bgneal@45 374 t._mceColorPicker(0, {
bgneal@45 375 color : c.value,
bgneal@45 376 func : function(co) {
bgneal@45 377 c.setColor(co);
bgneal@45 378 }
bgneal@45 379 });
bgneal@45 380 };
bgneal@45 381 }
bgneal@45 382
bgneal@45 383 if (v = s.theme_advanced_text_colors)
bgneal@45 384 o.colors = v;
bgneal@45 385
bgneal@45 386 if (s.theme_advanced_default_foreground_color)
bgneal@45 387 o.default_color = s.theme_advanced_default_foreground_color;
bgneal@45 388
bgneal@45 389 o.title = 'advanced.forecolor_desc';
bgneal@45 390 o.cmd = 'ForeColor';
bgneal@45 391 o.scope = this;
bgneal@45 392
bgneal@45 393 c = t.editor.controlManager.createColorSplitButton('forecolor', o);
bgneal@45 394
bgneal@45 395 return c;
bgneal@45 396 },
bgneal@45 397
bgneal@45 398 _createBackColorMenu : function() {
bgneal@45 399 var c, t = this, s = t.settings, o = {}, v;
bgneal@45 400
bgneal@45 401 if (s.theme_advanced_more_colors) {
bgneal@45 402 o.more_colors_func = function() {
bgneal@45 403 t._mceColorPicker(0, {
bgneal@45 404 color : c.value,
bgneal@45 405 func : function(co) {
bgneal@45 406 c.setColor(co);
bgneal@45 407 }
bgneal@45 408 });
bgneal@45 409 };
bgneal@45 410 }
bgneal@45 411
bgneal@45 412 if (v = s.theme_advanced_background_colors)
bgneal@45 413 o.colors = v;
bgneal@45 414
bgneal@45 415 if (s.theme_advanced_default_background_color)
bgneal@45 416 o.default_color = s.theme_advanced_default_background_color;
bgneal@45 417
bgneal@45 418 o.title = 'advanced.backcolor_desc';
bgneal@45 419 o.cmd = 'HiliteColor';
bgneal@45 420 o.scope = this;
bgneal@45 421
bgneal@45 422 c = t.editor.controlManager.createColorSplitButton('backcolor', o);
bgneal@45 423
bgneal@45 424 return c;
bgneal@45 425 },
bgneal@45 426
bgneal@45 427 renderUI : function(o) {
bgneal@45 428 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;
bgneal@45 429
bgneal@45 430 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 431
bgneal@45 432 if (!DOM.boxModel)
bgneal@45 433 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});
bgneal@45 434
bgneal@45 435 n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});
bgneal@45 436 n = tb = DOM.add(n, 'tbody');
bgneal@45 437
bgneal@45 438 switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {
bgneal@45 439 case "rowlayout":
bgneal@45 440 ic = t._rowLayout(s, tb, o);
bgneal@45 441 break;
bgneal@45 442
bgneal@45 443 case "customlayout":
bgneal@45 444 ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);
bgneal@45 445 break;
bgneal@45 446
bgneal@45 447 default:
bgneal@45 448 ic = t._simpleLayout(s, tb, o, p);
bgneal@45 449 }
bgneal@45 450
bgneal@45 451 n = o.targetNode;
bgneal@45 452
bgneal@45 453 // Add classes to first and last TRs
bgneal@45 454 nl = DOM.stdMode ? sc.getElementsByTagName('tr') : sc.rows; // Quick fix for IE 8
bgneal@45 455 DOM.addClass(nl[0], 'mceFirst');
bgneal@45 456 DOM.addClass(nl[nl.length - 1], 'mceLast');
bgneal@45 457
bgneal@45 458 // Add classes to first and last TDs
bgneal@45 459 each(DOM.select('tr', tb), function(n) {
bgneal@45 460 DOM.addClass(n.firstChild, 'mceFirst');
bgneal@45 461 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast');
bgneal@45 462 });
bgneal@45 463
bgneal@45 464 if (DOM.get(s.theme_advanced_toolbar_container))
bgneal@45 465 DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
bgneal@45 466 else
bgneal@45 467 DOM.insertAfter(p, n);
bgneal@45 468
bgneal@45 469 Event.add(ed.id + '_path_row', 'click', function(e) {
bgneal@45 470 e = e.target;
bgneal@45 471
bgneal@45 472 if (e.nodeName == 'A') {
bgneal@45 473 t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));
bgneal@45 474
bgneal@45 475 return Event.cancel(e);
bgneal@45 476 }
bgneal@45 477 });
bgneal@45 478 /*
bgneal@45 479 if (DOM.get(ed.id + '_path_row')) {
bgneal@45 480 Event.add(ed.id + '_tbl', 'mouseover', function(e) {
bgneal@45 481 var re;
bgneal@45 482
bgneal@45 483 e = e.target;
bgneal@45 484
bgneal@45 485 if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
bgneal@45 486 re = DOM.get(ed.id + '_path_row');
bgneal@45 487 t.lastPath = re.innerHTML;
bgneal@45 488 DOM.setHTML(re, e.parentNode.title);
bgneal@45 489 }
bgneal@45 490 });
bgneal@45 491
bgneal@45 492 Event.add(ed.id + '_tbl', 'mouseout', function(e) {
bgneal@45 493 if (t.lastPath) {
bgneal@45 494 DOM.setHTML(ed.id + '_path_row', t.lastPath);
bgneal@45 495 t.lastPath = 0;
bgneal@45 496 }
bgneal@45 497 });
bgneal@45 498 }
bgneal@45 499 */
bgneal@45 500
bgneal@45 501 if (!ed.getParam('accessibility_focus'))
bgneal@45 502 Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});
bgneal@45 503
bgneal@45 504 if (s.theme_advanced_toolbar_location == 'external')
bgneal@45 505 o.deltaHeight = 0;
bgneal@45 506
bgneal@45 507 t.deltaHeight = o.deltaHeight;
bgneal@45 508 o.targetNode = null;
bgneal@45 509
bgneal@45 510 return {
bgneal@45 511 iframeContainer : ic,
bgneal@45 512 editorContainer : ed.id + '_parent',
bgneal@45 513 sizeContainer : sc,
bgneal@45 514 deltaHeight : o.deltaHeight
bgneal@45 515 };
bgneal@45 516 },
bgneal@45 517
bgneal@45 518 getInfo : function() {
bgneal@45 519 return {
bgneal@45 520 longname : 'Advanced theme',
bgneal@45 521 author : 'Moxiecode Systems AB',
bgneal@45 522 authorurl : 'http://tinymce.moxiecode.com',
bgneal@45 523 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@45 524 }
bgneal@45 525 },
bgneal@45 526
bgneal@45 527 resizeBy : function(dw, dh) {
bgneal@45 528 var e = DOM.get(this.editor.id + '_tbl');
bgneal@45 529
bgneal@45 530 this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);
bgneal@45 531 },
bgneal@45 532
bgneal@45 533 resizeTo : function(w, h) {
bgneal@183 534 var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr');
bgneal@45 535
bgneal@45 536 // Boundery fix box
bgneal@45 537 w = Math.max(s.theme_advanced_resizing_min_width || 100, w);
bgneal@45 538 h = Math.max(s.theme_advanced_resizing_min_height || 100, h);
bgneal@45 539 w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);
bgneal@45 540 h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);
bgneal@45 541
bgneal@183 542 // Resize iframe and container
bgneal@183 543 DOM.setStyle(e, 'height', '');
bgneal@183 544 DOM.setStyle(ifr, 'height', h);
bgneal@45 545
bgneal@183 546 if (s.theme_advanced_resize_horizontal) {
bgneal@183 547 DOM.setStyle(e, 'width', '');
bgneal@183 548 DOM.setStyle(ifr, 'width', w);
bgneal@183 549
bgneal@183 550 // Make sure that the size is never smaller than the over all ui
bgneal@183 551 if (w < e.clientWidth)
bgneal@183 552 DOM.setStyle(ifr, 'width', e.clientWidth);
bgneal@183 553 }
bgneal@45 554 },
bgneal@45 555
bgneal@45 556 destroy : function() {
bgneal@45 557 var id = this.editor.id;
bgneal@45 558
bgneal@45 559 Event.clear(id + '_resize');
bgneal@45 560 Event.clear(id + '_path_row');
bgneal@45 561 Event.clear(id + '_external_close');
bgneal@45 562 },
bgneal@45 563
bgneal@45 564 // Internal functions
bgneal@45 565
bgneal@45 566 _simpleLayout : function(s, tb, o, p) {
bgneal@45 567 var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
bgneal@45 568
bgneal@45 569 if (s.readonly) {
bgneal@45 570 n = DOM.add(tb, 'tr');
bgneal@45 571 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
bgneal@45 572 return ic;
bgneal@45 573 }
bgneal@45 574
bgneal@45 575 // Create toolbar container at top
bgneal@45 576 if (lo == 'top')
bgneal@45 577 t._addToolbars(tb, o);
bgneal@45 578
bgneal@45 579 // Create external toolbar
bgneal@45 580 if (lo == 'external') {
bgneal@45 581 n = c = DOM.create('div', {style : 'position:relative'});
bgneal@45 582 n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
bgneal@45 583 DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
bgneal@45 584 n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
bgneal@45 585 etb = DOM.add(n, 'tbody');
bgneal@45 586
bgneal@45 587 if (p.firstChild.className == 'mceOldBoxModel')
bgneal@45 588 p.firstChild.appendChild(c);
bgneal@45 589 else
bgneal@45 590 p.insertBefore(c, p.firstChild);
bgneal@45 591
bgneal@45 592 t._addToolbars(etb, o);
bgneal@45 593
bgneal@45 594 ed.onMouseUp.add(function() {
bgneal@45 595 var e = DOM.get(ed.id + '_external');
bgneal@45 596 DOM.show(e);
bgneal@45 597
bgneal@45 598 DOM.hide(lastExtID);
bgneal@45 599
bgneal@45 600 var f = Event.add(ed.id + '_external_close', 'click', function() {
bgneal@45 601 DOM.hide(ed.id + '_external');
bgneal@45 602 Event.remove(ed.id + '_external_close', 'click', f);
bgneal@45 603 });
bgneal@45 604
bgneal@45 605 DOM.show(e);
bgneal@45 606 DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
bgneal@45 607
bgneal@45 608 // Fixes IE rendering bug
bgneal@45 609 DOM.hide(e);
bgneal@45 610 DOM.show(e);
bgneal@45 611 e.style.filter = '';
bgneal@45 612
bgneal@45 613 lastExtID = ed.id + '_external';
bgneal@45 614
bgneal@45 615 e = null;
bgneal@45 616 });
bgneal@45 617 }
bgneal@45 618
bgneal@45 619 if (sl == 'top')
bgneal@45 620 t._addStatusBar(tb, o);
bgneal@45 621
bgneal@45 622 // Create iframe container
bgneal@45 623 if (!s.theme_advanced_toolbar_container) {
bgneal@45 624 n = DOM.add(tb, 'tr');
bgneal@45 625 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
bgneal@45 626 }
bgneal@45 627
bgneal@45 628 // Create toolbar container at bottom
bgneal@45 629 if (lo == 'bottom')
bgneal@45 630 t._addToolbars(tb, o);
bgneal@45 631
bgneal@45 632 if (sl == 'bottom')
bgneal@45 633 t._addStatusBar(tb, o);
bgneal@45 634
bgneal@45 635 return ic;
bgneal@45 636 },
bgneal@45 637
bgneal@45 638 _rowLayout : function(s, tb, o) {
bgneal@45 639 var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;
bgneal@45 640
bgneal@45 641 dc = s.theme_advanced_containers_default_class || '';
bgneal@45 642 da = s.theme_advanced_containers_default_align || 'center';
bgneal@45 643
bgneal@45 644 each(explode(s.theme_advanced_containers || ''), function(c, i) {
bgneal@45 645 var v = s['theme_advanced_container_' + c] || '';
bgneal@45 646
bgneal@45 647 switch (v.toLowerCase()) {
bgneal@45 648 case 'mceeditor':
bgneal@45 649 n = DOM.add(tb, 'tr');
bgneal@45 650 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
bgneal@45 651 break;
bgneal@45 652
bgneal@45 653 case 'mceelementpath':
bgneal@45 654 t._addStatusBar(tb, o);
bgneal@45 655 break;
bgneal@45 656
bgneal@45 657 default:
bgneal@45 658 a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase();
bgneal@45 659 a = 'mce' + t._ufirst(a);
bgneal@45 660
bgneal@45 661 n = DOM.add(DOM.add(tb, 'tr'), 'td', {
bgneal@45 662 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da
bgneal@45 663 });
bgneal@45 664
bgneal@45 665 to = cf.createToolbar("toolbar" + i);
bgneal@45 666 t._addControls(v, to);
bgneal@45 667 DOM.setHTML(n, to.renderHTML());
bgneal@45 668 o.deltaHeight -= s.theme_advanced_row_height;
bgneal@45 669 }
bgneal@45 670 });
bgneal@45 671
bgneal@45 672 return ic;
bgneal@45 673 },
bgneal@45 674
bgneal@45 675 _addControls : function(v, tb) {
bgneal@45 676 var t = this, s = t.settings, di, cf = t.editor.controlManager;
bgneal@45 677
bgneal@45 678 if (s.theme_advanced_disable && !t._disabled) {
bgneal@45 679 di = {};
bgneal@45 680
bgneal@45 681 each(explode(s.theme_advanced_disable), function(v) {
bgneal@45 682 di[v] = 1;
bgneal@45 683 });
bgneal@45 684
bgneal@45 685 t._disabled = di;
bgneal@45 686 } else
bgneal@45 687 di = t._disabled;
bgneal@45 688
bgneal@45 689 each(explode(v), function(n) {
bgneal@45 690 var c;
bgneal@45 691
bgneal@45 692 if (di && di[n])
bgneal@45 693 return;
bgneal@45 694
bgneal@45 695 // Compatiblity with 2.x
bgneal@45 696 if (n == 'tablecontrols') {
bgneal@45 697 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 698 n = t.createControl(n, cf);
bgneal@45 699
bgneal@45 700 if (n)
bgneal@45 701 tb.add(n);
bgneal@45 702 });
bgneal@45 703
bgneal@45 704 return;
bgneal@45 705 }
bgneal@45 706
bgneal@45 707 c = t.createControl(n, cf);
bgneal@45 708
bgneal@45 709 if (c)
bgneal@45 710 tb.add(c);
bgneal@45 711 });
bgneal@45 712 },
bgneal@45 713
bgneal@45 714 _addToolbars : function(c, o) {
bgneal@45 715 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a;
bgneal@45 716
bgneal@45 717 a = s.theme_advanced_toolbar_align.toLowerCase();
bgneal@45 718 a = 'mce' + t._ufirst(a);
bgneal@45 719
bgneal@45 720 n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a});
bgneal@45 721
bgneal@45 722 if (!ed.getParam('accessibility_focus'))
bgneal@45 723 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
bgneal@45 724
bgneal@45 725 h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->'));
bgneal@45 726
bgneal@45 727 // Create toolbar and add the controls
bgneal@45 728 for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
bgneal@45 729 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});
bgneal@45 730
bgneal@45 731 if (s['theme_advanced_buttons' + i + '_add'])
bgneal@45 732 v += ',' + s['theme_advanced_buttons' + i + '_add'];
bgneal@45 733
bgneal@45 734 if (s['theme_advanced_buttons' + i + '_add_before'])
bgneal@45 735 v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
bgneal@45 736
bgneal@45 737 t._addControls(v, tb);
bgneal@45 738
bgneal@45 739 //n.appendChild(n = tb.render());
bgneal@45 740 h.push(tb.renderHTML());
bgneal@45 741
bgneal@45 742 o.deltaHeight -= s.theme_advanced_row_height;
bgneal@45 743 }
bgneal@45 744
bgneal@45 745 h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
bgneal@45 746 DOM.setHTML(n, h.join(''));
bgneal@45 747 },
bgneal@45 748
bgneal@45 749 _addStatusBar : function(tb, o) {
bgneal@45 750 var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
bgneal@45 751
bgneal@45 752 n = DOM.add(tb, 'tr');
bgneal@45 753 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});
bgneal@45 754 n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : '&#160;');
bgneal@45 755 DOM.add(n, 'a', {href : '#', accesskey : 'x'});
bgneal@45 756
bgneal@45 757 if (s.theme_advanced_resizing) {
bgneal@45 758 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});
bgneal@45 759
bgneal@45 760 if (s.theme_advanced_resizing_use_cookie) {
bgneal@45 761 ed.onPostRender.add(function() {
bgneal@45 762 var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
bgneal@45 763
bgneal@45 764 if (!o)
bgneal@45 765 return;
bgneal@45 766
bgneal@183 767 t.resizeTo(o.cw, o.ch);
bgneal@45 768 });
bgneal@45 769 }
bgneal@45 770
bgneal@45 771 ed.onPostRender.add(function() {
bgneal@45 772 Event.add(ed.id + '_resize', 'mousedown', function(e) {
bgneal@183 773 var mouseMoveHandler1, mouseMoveHandler2,
bgneal@183 774 mouseUpHandler1, mouseUpHandler2,
bgneal@183 775 startX, startY, startWidth, startHeight, width, height, ifrElm;
bgneal@45 776
bgneal@183 777 function resizeOnMove(e) {
bgneal@183 778 width = startWidth + (e.screenX - startX);
bgneal@183 779 height = startHeight + (e.screenY - startY);
bgneal@45 780
bgneal@183 781 t.resizeTo(width, height);
bgneal@45 782 };
bgneal@45 783
bgneal@183 784 function endResize(e) {
bgneal@183 785 // Stop listening
bgneal@183 786 Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1);
bgneal@183 787 Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2);
bgneal@183 788 Event.remove(DOM.doc, 'mouseup', mouseUpHandler1);
bgneal@183 789 Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2);
bgneal@45 790
bgneal@183 791 // Store away the size
bgneal@45 792 if (s.theme_advanced_resizing_use_cookie) {
bgneal@45 793 Cookie.setHash("TinyMCE_" + ed.id + "_size", {
bgneal@183 794 cw : width,
bgneal@183 795 ch : height
bgneal@45 796 });
bgneal@45 797 }
bgneal@183 798 };
bgneal@45 799
bgneal@183 800 e.preventDefault();
bgneal@183 801
bgneal@183 802 // Get the current rect size
bgneal@183 803 startX = e.screenX;
bgneal@183 804 startY = e.screenY;
bgneal@183 805 ifrElm = DOM.get(t.editor.id + '_ifr');
bgneal@183 806 startWidth = width = ifrElm.clientWidth;
bgneal@183 807 startHeight = height = ifrElm.clientHeight;
bgneal@183 808
bgneal@183 809 // Register envent handlers
bgneal@183 810 mouseMoveHandler1 = Event.add(DOM.doc, 'mousemove', resizeOnMove);
bgneal@183 811 mouseMoveHandler2 = Event.add(ed.getDoc(), 'mousemove', resizeOnMove);
bgneal@183 812 mouseUpHandler1 = Event.add(DOM.doc, 'mouseup', endResize);
bgneal@183 813 mouseUpHandler2 = Event.add(ed.getDoc(), 'mouseup', endResize);
bgneal@45 814 });
bgneal@45 815 });
bgneal@45 816 }
bgneal@45 817
bgneal@45 818 o.deltaHeight -= 21;
bgneal@45 819 n = tb = null;
bgneal@45 820 },
bgneal@45 821
bgneal@183 822 _nodeChanged : function(ed, cm, n, co, ob) {
bgneal@183 823 var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, formatNames, matches;
bgneal@45 824
bgneal@45 825 tinymce.each(t.stateControls, function(c) {
bgneal@45 826 cm.setActive(c, ed.queryCommandState(t.controls[c][1]));
bgneal@45 827 });
bgneal@45 828
bgneal@183 829 function getParent(name) {
bgneal@183 830 var i, parents = ob.parents, func = name;
bgneal@183 831
bgneal@183 832 if (typeof(name) == 'string') {
bgneal@183 833 func = function(node) {
bgneal@183 834 return node.nodeName == name;
bgneal@183 835 };
bgneal@183 836 }
bgneal@183 837
bgneal@183 838 for (i = 0; i < parents.length; i++) {
bgneal@183 839 if (func(parents[i]))
bgneal@183 840 return parents[i];
bgneal@183 841 }
bgneal@183 842 };
bgneal@183 843
bgneal@45 844 cm.setActive('visualaid', ed.hasVisual);
bgneal@45 845 cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing);
bgneal@45 846 cm.setDisabled('redo', !ed.undoManager.hasRedo());
bgneal@45 847 cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));
bgneal@45 848
bgneal@183 849 p = getParent('A');
bgneal@45 850 if (c = cm.get('link')) {
bgneal@45 851 if (!p || !p.name) {
bgneal@45 852 c.setDisabled(!p && co);
bgneal@45 853 c.setActive(!!p);
bgneal@45 854 }
bgneal@45 855 }
bgneal@45 856
bgneal@45 857 if (c = cm.get('unlink')) {
bgneal@45 858 c.setDisabled(!p && co);
bgneal@45 859 c.setActive(!!p && !p.name);
bgneal@45 860 }
bgneal@45 861
bgneal@45 862 if (c = cm.get('anchor')) {
bgneal@45 863 c.setActive(!!p && p.name);
bgneal@45 864 }
bgneal@45 865
bgneal@183 866 p = getParent('IMG');
bgneal@45 867 if (c = cm.get('image'))
bgneal@45 868 c.setActive(!!p && n.className.indexOf('mceItem') == -1);
bgneal@45 869
bgneal@45 870 if (c = cm.get('styleselect')) {
bgneal@183 871 t._importClasses();
bgneal@183 872
bgneal@183 873 formatNames = [];
bgneal@183 874 each(c.items, function(item) {
bgneal@183 875 formatNames.push(item.value);
bgneal@183 876 });
bgneal@183 877
bgneal@183 878 matches = ed.formatter.matchAll(formatNames);
bgneal@183 879 c.select(matches[0]);
bgneal@45 880 }
bgneal@45 881
bgneal@45 882 if (c = cm.get('formatselect')) {
bgneal@183 883 p = getParent(DOM.isBlock);
bgneal@45 884
bgneal@45 885 if (p)
bgneal@45 886 c.select(p.nodeName.toLowerCase());
bgneal@45 887 }
bgneal@45 888
bgneal@183 889 // Find out current fontSize, fontFamily and fontClass
bgneal@183 890 getParent(function(n) {
bgneal@183 891 if (n.nodeName === 'SPAN') {
bgneal@183 892 if (!cl && n.className)
bgneal@183 893 cl = n.className;
bgneal@45 894
bgneal@183 895 if (!fz && n.style.fontSize)
bgneal@183 896 fz = n.style.fontSize;
bgneal@45 897
bgneal@183 898 if (!fn && n.style.fontFamily)
bgneal@183 899 fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase();
bgneal@45 900 }
bgneal@45 901
bgneal@183 902 return false;
bgneal@183 903 });
bgneal@45 904
bgneal@183 905 if (c = cm.get('fontselect')) {
bgneal@183 906 c.select(function(v) {
bgneal@183 907 return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn;
bgneal@183 908 });
bgneal@183 909 }
bgneal@45 910
bgneal@183 911 // Select font size
bgneal@183 912 if (c = cm.get('fontsizeselect')) {
bgneal@183 913 // Use computed style
bgneal@183 914 if (s.theme_advanced_runtime_fontsize && !fz && !cl)
bgneal@183 915 fz = ed.dom.getStyle(n, 'fontSize', true);
bgneal@183 916
bgneal@183 917 c.select(function(v) {
bgneal@183 918 if (v.fontSize && v.fontSize === fz)
bgneal@183 919 return true;
bgneal@183 920
bgneal@183 921 if (v['class'] && v['class'] === cl)
bgneal@183 922 return true;
bgneal@183 923 });
bgneal@45 924 }
bgneal@45 925
bgneal@45 926 if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {
bgneal@45 927 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});
bgneal@45 928 DOM.setHTML(p, '');
bgneal@45 929
bgneal@183 930 getParent(function(n) {
bgneal@45 931 var na = n.nodeName.toLowerCase(), u, pi, ti = '';
bgneal@45 932
bgneal@183 933 /*if (n.getAttribute('_mce_bogus'))
bgneal@183 934 return;
bgneal@183 935 */
bgneal@45 936 // Ignore non element and hidden elements
bgneal@45 937 if (n.nodeType != 1 || n.nodeName === 'BR' || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')))
bgneal@45 938 return;
bgneal@45 939
bgneal@45 940 // Fake name
bgneal@45 941 if (v = DOM.getAttrib(n, 'mce_name'))
bgneal@45 942 na = v;
bgneal@45 943
bgneal@45 944 // Handle prefix
bgneal@45 945 if (tinymce.isIE && n.scopeName !== 'HTML')
bgneal@45 946 na = n.scopeName + ':' + na;
bgneal@45 947
bgneal@45 948 // Remove internal prefix
bgneal@45 949 na = na.replace(/mce\:/g, '');
bgneal@45 950
bgneal@45 951 // Handle node name
bgneal@45 952 switch (na) {
bgneal@45 953 case 'b':
bgneal@45 954 na = 'strong';
bgneal@45 955 break;
bgneal@45 956
bgneal@45 957 case 'i':
bgneal@45 958 na = 'em';
bgneal@45 959 break;
bgneal@45 960
bgneal@45 961 case 'img':
bgneal@45 962 if (v = DOM.getAttrib(n, 'src'))
bgneal@45 963 ti += 'src: ' + v + ' ';
bgneal@45 964
bgneal@45 965 break;
bgneal@45 966
bgneal@45 967 case 'a':
bgneal@45 968 if (v = DOM.getAttrib(n, 'name')) {
bgneal@45 969 ti += 'name: ' + v + ' ';
bgneal@45 970 na += '#' + v;
bgneal@45 971 }
bgneal@45 972
bgneal@45 973 if (v = DOM.getAttrib(n, 'href'))
bgneal@45 974 ti += 'href: ' + v + ' ';
bgneal@45 975
bgneal@45 976 break;
bgneal@45 977
bgneal@45 978 case 'font':
bgneal@45 979 if (v = DOM.getAttrib(n, 'face'))
bgneal@45 980 ti += 'font: ' + v + ' ';
bgneal@45 981
bgneal@45 982 if (v = DOM.getAttrib(n, 'size'))
bgneal@45 983 ti += 'size: ' + v + ' ';
bgneal@45 984
bgneal@45 985 if (v = DOM.getAttrib(n, 'color'))
bgneal@45 986 ti += 'color: ' + v + ' ';
bgneal@45 987
bgneal@45 988 break;
bgneal@45 989
bgneal@45 990 case 'span':
bgneal@45 991 if (v = DOM.getAttrib(n, 'style'))
bgneal@45 992 ti += 'style: ' + v + ' ';
bgneal@45 993
bgneal@45 994 break;
bgneal@45 995 }
bgneal@45 996
bgneal@45 997 if (v = DOM.getAttrib(n, 'id'))
bgneal@45 998 ti += 'id: ' + v + ' ';
bgneal@45 999
bgneal@45 1000 if (v = n.className) {
bgneal@183 1001 v = v.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g, '')
bgneal@45 1002
bgneal@183 1003 if (v) {
bgneal@45 1004 ti += 'class: ' + v + ' ';
bgneal@45 1005
bgneal@45 1006 if (DOM.isBlock(n) || na == 'img' || na == 'span')
bgneal@45 1007 na += '.' + v;
bgneal@45 1008 }
bgneal@45 1009 }
bgneal@45 1010
bgneal@45 1011 na = na.replace(/(html:)/g, '');
bgneal@45 1012 na = {name : na, node : n, title : ti};
bgneal@45 1013 t.onResolveName.dispatch(t, na);
bgneal@45 1014 ti = na.title;
bgneal@45 1015 na = na.name;
bgneal@45 1016
bgneal@45 1017 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";
bgneal@45 1018 pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na);
bgneal@45 1019
bgneal@45 1020 if (p.hasChildNodes()) {
bgneal@45 1021 p.insertBefore(DOM.doc.createTextNode(' \u00bb '), p.firstChild);
bgneal@45 1022 p.insertBefore(pi, p.firstChild);
bgneal@45 1023 } else
bgneal@45 1024 p.appendChild(pi);
bgneal@45 1025 }, ed.getBody());
bgneal@45 1026 }
bgneal@45 1027 },
bgneal@45 1028
bgneal@45 1029 // Commands gets called by execCommand
bgneal@45 1030
bgneal@45 1031 _sel : function(v) {
bgneal@45 1032 this.editor.execCommand('mceSelectNodeDepth', false, v);
bgneal@45 1033 },
bgneal@45 1034
bgneal@45 1035 _mceInsertAnchor : function(ui, v) {
bgneal@45 1036 var ed = this.editor;
bgneal@45 1037
bgneal@45 1038 ed.windowManager.open({
bgneal@45 1039 url : tinymce.baseURL + '/themes/advanced/anchor.htm',
bgneal@45 1040 width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)),
bgneal@45 1041 height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)),
bgneal@45 1042 inline : true
bgneal@45 1043 }, {
bgneal@45 1044 theme_url : this.url
bgneal@45 1045 });
bgneal@45 1046 },
bgneal@45 1047
bgneal@45 1048 _mceCharMap : function() {
bgneal@45 1049 var ed = this.editor;
bgneal@45 1050
bgneal@45 1051 ed.windowManager.open({
bgneal@45 1052 url : tinymce.baseURL + '/themes/advanced/charmap.htm',
bgneal@45 1053 width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
bgneal@45 1054 height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
bgneal@45 1055 inline : true
bgneal@45 1056 }, {
bgneal@45 1057 theme_url : this.url
bgneal@45 1058 });
bgneal@45 1059 },
bgneal@45 1060
bgneal@45 1061 _mceHelp : function() {
bgneal@45 1062 var ed = this.editor;
bgneal@45 1063
bgneal@45 1064 ed.windowManager.open({
bgneal@45 1065 url : tinymce.baseURL + '/themes/advanced/about.htm',
bgneal@45 1066 width : 480,
bgneal@45 1067 height : 380,
bgneal@45 1068 inline : true
bgneal@45 1069 }, {
bgneal@45 1070 theme_url : this.url
bgneal@45 1071 });
bgneal@45 1072 },
bgneal@45 1073
bgneal@45 1074 _mceColorPicker : function(u, v) {
bgneal@45 1075 var ed = this.editor;
bgneal@45 1076
bgneal@45 1077 v = v || {};
bgneal@45 1078
bgneal@45 1079 ed.windowManager.open({
bgneal@45 1080 url : tinymce.baseURL + '/themes/advanced/color_picker.htm',
bgneal@45 1081 width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)),
bgneal@45 1082 height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)),
bgneal@45 1083 close_previous : false,
bgneal@45 1084 inline : true
bgneal@45 1085 }, {
bgneal@45 1086 input_color : v.color,
bgneal@45 1087 func : v.func,
bgneal@45 1088 theme_url : this.url
bgneal@45 1089 });
bgneal@45 1090 },
bgneal@45 1091
bgneal@45 1092 _mceCodeEditor : function(ui, val) {
bgneal@45 1093 var ed = this.editor;
bgneal@45 1094
bgneal@45 1095 ed.windowManager.open({
bgneal@45 1096 url : tinymce.baseURL + '/themes/advanced/source_editor.htm',
bgneal@45 1097 width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),
bgneal@45 1098 height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),
bgneal@45 1099 inline : true,
bgneal@45 1100 resizable : true,
bgneal@45 1101 maximizable : true
bgneal@45 1102 }, {
bgneal@45 1103 theme_url : this.url
bgneal@45 1104 });
bgneal@45 1105 },
bgneal@45 1106
bgneal@45 1107 _mceImage : function(ui, val) {
bgneal@45 1108 var ed = this.editor;
bgneal@45 1109
bgneal@45 1110 // Internal image object like a flash placeholder
bgneal@45 1111 if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)
bgneal@45 1112 return;
bgneal@45 1113
bgneal@45 1114 ed.windowManager.open({
bgneal@45 1115 url : tinymce.baseURL + '/themes/advanced/image.htm',
bgneal@45 1116 width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)),
bgneal@45 1117 height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)),
bgneal@45 1118 inline : true
bgneal@45 1119 }, {
bgneal@45 1120 theme_url : this.url
bgneal@45 1121 });
bgneal@45 1122 },
bgneal@45 1123
bgneal@45 1124 _mceLink : function(ui, val) {
bgneal@45 1125 var ed = this.editor;
bgneal@45 1126
bgneal@45 1127 ed.windowManager.open({
bgneal@45 1128 url : tinymce.baseURL + '/themes/advanced/link.htm',
bgneal@45 1129 width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)),
bgneal@45 1130 height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)),
bgneal@45 1131 inline : true
bgneal@45 1132 }, {
bgneal@45 1133 theme_url : this.url
bgneal@45 1134 });
bgneal@45 1135 },
bgneal@45 1136
bgneal@45 1137 _mceNewDocument : function() {
bgneal@45 1138 var ed = this.editor;
bgneal@45 1139
bgneal@45 1140 ed.windowManager.confirm('advanced.newdocument', function(s) {
bgneal@45 1141 if (s)
bgneal@45 1142 ed.execCommand('mceSetContent', false, '');
bgneal@45 1143 });
bgneal@45 1144 },
bgneal@45 1145
bgneal@45 1146 _mceForeColor : function() {
bgneal@45 1147 var t = this;
bgneal@45 1148
bgneal@45 1149 this._mceColorPicker(0, {
bgneal@45 1150 color: t.fgColor,
bgneal@45 1151 func : function(co) {
bgneal@45 1152 t.fgColor = co;
bgneal@45 1153 t.editor.execCommand('ForeColor', false, co);
bgneal@45 1154 }
bgneal@45 1155 });
bgneal@45 1156 },
bgneal@45 1157
bgneal@45 1158 _mceBackColor : function() {
bgneal@45 1159 var t = this;
bgneal@45 1160
bgneal@45 1161 this._mceColorPicker(0, {
bgneal@45 1162 color: t.bgColor,
bgneal@45 1163 func : function(co) {
bgneal@45 1164 t.bgColor = co;
bgneal@45 1165 t.editor.execCommand('HiliteColor', false, co);
bgneal@45 1166 }
bgneal@45 1167 });
bgneal@45 1168 },
bgneal@45 1169
bgneal@45 1170 _ufirst : function(s) {
bgneal@45 1171 return s.substring(0, 1).toUpperCase() + s.substring(1);
bgneal@45 1172 }
bgneal@45 1173 });
bgneal@45 1174
bgneal@45 1175 tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);
bgneal@45 1176 }(tinymce));