annotate media/js/tiny_mce/plugins/compat2x/editor_plugin_src.js @ 132:06503edcc56b

A previous commit broke the comment preview function. Fixing this now.
author Brian Neal <bgneal@gmail.com>
date Thu, 26 Nov 2009 22:51:07 +0000
parents a5b4c5ce0658
children
rev   line source
bgneal@45 1 /**
bgneal@45 2 * $Id: editor_plugin_src.js 264 2007-04-26 20:53:09Z spocke $
bgneal@45 3 *
bgneal@45 4 * @author Moxiecode
bgneal@45 5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
bgneal@45 6 */
bgneal@45 7
bgneal@45 8 (function() {
bgneal@45 9 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, is = tinymce.is;
bgneal@45 10
bgneal@45 11 tinymce.create('tinymce.plugins.Compat2x', {
bgneal@45 12 getInfo : function() {
bgneal@45 13 return {
bgneal@45 14 longname : 'Compat2x',
bgneal@45 15 author : 'Moxiecode Systems AB',
bgneal@45 16 authorurl : 'http://tinymce.moxiecode.com',
bgneal@45 17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/compat2x',
bgneal@45 18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
bgneal@45 19 };
bgneal@45 20 }
bgneal@45 21 });
bgneal@45 22
bgneal@45 23 (function() {
bgneal@45 24 // Extend tinyMCE/EditorManager
bgneal@45 25 tinymce.extend(tinyMCE, {
bgneal@45 26 addToLang : function(p, l) {
bgneal@45 27 each(l, function(v, k) {
bgneal@45 28 tinyMCE.i18n[(tinyMCE.settings.language || 'en') + '.' + (p ? p + '_' : '') + k] = v;
bgneal@45 29 });
bgneal@45 30 },
bgneal@45 31
bgneal@45 32 getInstanceById : function(n) {
bgneal@45 33 return this.get(n);
bgneal@45 34 }
bgneal@45 35 });
bgneal@45 36 })();
bgneal@45 37
bgneal@45 38 (function() {
bgneal@45 39 var EditorManager = tinymce.EditorManager;
bgneal@45 40
bgneal@45 41 tinyMCE.instances = {};
bgneal@45 42 tinyMCE.plugins = {};
bgneal@45 43 tinymce.PluginManager.onAdd.add(function(pm, n, p) {
bgneal@45 44 tinyMCE.plugins[n] = p;
bgneal@45 45 });
bgneal@45 46
bgneal@45 47 tinyMCE.majorVersion = tinymce.majorVersion;
bgneal@45 48 tinyMCE.minorVersion = tinymce.minorVersion;
bgneal@45 49 tinyMCE.releaseDate = tinymce.releaseDate;
bgneal@45 50 tinyMCE.baseURL = tinymce.baseURL;
bgneal@45 51 tinyMCE.isIE = tinyMCE.isMSIE = tinymce.isIE || tinymce.isOpera;
bgneal@45 52 tinyMCE.isMSIE5 = tinymce.isIE;
bgneal@45 53 tinyMCE.isMSIE5_0 = tinymce.isIE;
bgneal@45 54 tinyMCE.isMSIE7 = tinymce.isIE;
bgneal@45 55 tinyMCE.isGecko = tinymce.isGecko;
bgneal@45 56 tinyMCE.isSafari = tinymce.isWebKit;
bgneal@45 57 tinyMCE.isOpera = tinymce.isOpera;
bgneal@45 58 tinyMCE.isMac = false;
bgneal@45 59 tinyMCE.isNS7 = false;
bgneal@45 60 tinyMCE.isNS71 = false;
bgneal@45 61 tinyMCE.compat = true;
bgneal@45 62
bgneal@45 63 // Extend tinyMCE class
bgneal@45 64 TinyMCE_Engine = tinyMCE;
bgneal@45 65 tinymce.extend(tinyMCE, {
bgneal@45 66 getParam : function(n, dv) {
bgneal@45 67 return this.activeEditor.getParam(n, dv);
bgneal@45 68 },
bgneal@45 69
bgneal@45 70 addEvent : function(e, na, f, sc) {
bgneal@45 71 tinymce.dom.Event.add(e, na, f, sc || this);
bgneal@45 72 },
bgneal@45 73
bgneal@45 74 getControlHTML : function(n) {
bgneal@45 75 return EditorManager.activeEditor.controlManager.createControl(n);
bgneal@45 76 },
bgneal@45 77
bgneal@45 78 loadCSS : function(u) {
bgneal@45 79 tinymce.DOM.loadCSS(u);
bgneal@45 80 },
bgneal@45 81
bgneal@45 82 importCSS : function(doc, u) {
bgneal@45 83 if (doc == document)
bgneal@45 84 this.loadCSS(u);
bgneal@45 85 else
bgneal@45 86 new tinymce.dom.DOMUtils(doc).loadCSS(u);
bgneal@45 87 },
bgneal@45 88
bgneal@45 89 log : function() {
bgneal@45 90 console.debug.apply(console, arguments);
bgneal@45 91 },
bgneal@45 92
bgneal@45 93 getLang : function(n, dv) {
bgneal@45 94 var v = EditorManager.activeEditor.getLang(n.replace(/^lang_/g, ''), dv);
bgneal@45 95
bgneal@45 96 // Is number
bgneal@45 97 if (/^[0-9\-.]+$/g.test(v))
bgneal@45 98 return parseInt(v);
bgneal@45 99
bgneal@45 100 return v;
bgneal@45 101 },
bgneal@45 102
bgneal@45 103 isInstance : function(o) {
bgneal@45 104 return o != null && typeof(o) == "object" && o.execCommand;
bgneal@45 105 },
bgneal@45 106
bgneal@45 107 triggerNodeChange : function() {
bgneal@45 108 EditorManager.activeEditor.nodeChanged();
bgneal@45 109 },
bgneal@45 110
bgneal@45 111 regexpReplace : function(in_str, reg_exp, replace_str, opts) {
bgneal@45 112 var re;
bgneal@45 113
bgneal@45 114 if (in_str == null)
bgneal@45 115 return in_str;
bgneal@45 116
bgneal@45 117 if (typeof(opts) == "undefined")
bgneal@45 118 opts = 'g';
bgneal@45 119
bgneal@45 120 re = new RegExp(reg_exp, opts);
bgneal@45 121
bgneal@45 122 return in_str.replace(re, replace_str);
bgneal@45 123 },
bgneal@45 124
bgneal@45 125 trim : function(s) {
bgneal@45 126 return tinymce.trim(s);
bgneal@45 127 },
bgneal@45 128
bgneal@45 129 xmlEncode : function(s) {
bgneal@45 130 return tinymce.DOM.encode(s);
bgneal@45 131 },
bgneal@45 132
bgneal@45 133 explode : function(s, d) {
bgneal@45 134 var o = [];
bgneal@45 135
bgneal@45 136 tinymce.each(s.split(d), function(v) {
bgneal@45 137 if (v != '')
bgneal@45 138 o.push(v);
bgneal@45 139 });
bgneal@45 140
bgneal@45 141 return o;
bgneal@45 142 },
bgneal@45 143
bgneal@45 144 switchClass : function(id, cls) {
bgneal@45 145 var b;
bgneal@45 146
bgneal@45 147 if (/^mceButton/.test(cls)) {
bgneal@45 148 b = EditorManager.activeEditor.controlManager.get(id);
bgneal@45 149
bgneal@45 150 if (!b)
bgneal@45 151 return;
bgneal@45 152
bgneal@45 153 switch (cls) {
bgneal@45 154 case "mceButtonNormal":
bgneal@45 155 b.setDisabled(false);
bgneal@45 156 b.setActive(false);
bgneal@45 157 return;
bgneal@45 158
bgneal@45 159 case "mceButtonDisabled":
bgneal@45 160 b.setDisabled(true);
bgneal@45 161 return;
bgneal@45 162
bgneal@45 163 case "mceButtonSelected":
bgneal@45 164 b.setActive(true);
bgneal@45 165 b.setDisabled(false);
bgneal@45 166 return;
bgneal@45 167 }
bgneal@45 168 }
bgneal@45 169 },
bgneal@45 170
bgneal@45 171 addCSSClass : function(e, n, b) {
bgneal@45 172 return tinymce.DOM.addClass(e, n, b);
bgneal@45 173 },
bgneal@45 174
bgneal@45 175 hasCSSClass : function(e, n) {
bgneal@45 176 return tinymce.DOM.hasClass(e, n);
bgneal@45 177 },
bgneal@45 178
bgneal@45 179 removeCSSClass : function(e, n) {
bgneal@45 180 return tinymce.DOM.removeClass(e, n);
bgneal@45 181 },
bgneal@45 182
bgneal@45 183 getCSSClasses : function() {
bgneal@45 184 var cl = EditorManager.activeEditor.dom.getClasses(), o = [];
bgneal@45 185
bgneal@45 186 each(cl, function(c) {
bgneal@45 187 o.push(c['class']);
bgneal@45 188 });
bgneal@45 189
bgneal@45 190 return o;
bgneal@45 191 },
bgneal@45 192
bgneal@45 193 setWindowArg : function(n, v) {
bgneal@45 194 EditorManager.activeEditor.windowManager.params[n] = v;
bgneal@45 195 },
bgneal@45 196
bgneal@45 197 getWindowArg : function(n, dv) {
bgneal@45 198 var wm = EditorManager.activeEditor.windowManager, v;
bgneal@45 199
bgneal@45 200 v = wm.getParam(n);
bgneal@45 201 if (v === '')
bgneal@45 202 return '';
bgneal@45 203
bgneal@45 204 return v || wm.getFeature(n) || dv;
bgneal@45 205 },
bgneal@45 206
bgneal@45 207 getParentNode : function(n, f) {
bgneal@45 208 return this._getDOM().getParent(n, f);
bgneal@45 209 },
bgneal@45 210
bgneal@45 211 selectElements : function(n, na, f) {
bgneal@45 212 var i, a = [], nl, x;
bgneal@45 213
bgneal@45 214 for (x=0, na = na.split(','); x<na.length; x++)
bgneal@45 215 for (i=0, nl = n.getElementsByTagName(na[x]); i<nl.length; i++)
bgneal@45 216 (!f || f(nl[i])) && a.push(nl[i]);
bgneal@45 217
bgneal@45 218 return a;
bgneal@45 219 },
bgneal@45 220
bgneal@45 221 getNodeTree : function(n, na, t, nn) {
bgneal@45 222 return this.selectNodes(n, function(n) {
bgneal@45 223 return (!t || n.nodeType == t) && (!nn || n.nodeName == nn);
bgneal@45 224 }, na ? na : []);
bgneal@45 225 },
bgneal@45 226
bgneal@45 227 getAttrib : function(e, n, dv) {
bgneal@45 228 return this._getDOM().getAttrib(e, n, dv);
bgneal@45 229 },
bgneal@45 230
bgneal@45 231 setAttrib : function(e, n, v) {
bgneal@45 232 return this._getDOM().setAttrib(e, n, v);
bgneal@45 233 },
bgneal@45 234
bgneal@45 235 getElementsByAttributeValue : function(n, e, a, v) {
bgneal@45 236 var i, nl = n.getElementsByTagName(e), o = [];
bgneal@45 237
bgneal@45 238 for (i=0; i<nl.length; i++) {
bgneal@45 239 if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1)
bgneal@45 240 o[o.length] = nl[i];
bgneal@45 241 }
bgneal@45 242
bgneal@45 243 return o;
bgneal@45 244 },
bgneal@45 245
bgneal@45 246 selectNodes : function(n, f, a) {
bgneal@45 247 var i;
bgneal@45 248
bgneal@45 249 if (!a)
bgneal@45 250 a = [];
bgneal@45 251
bgneal@45 252 if (f(n))
bgneal@45 253 a[a.length] = n;
bgneal@45 254
bgneal@45 255 if (n.hasChildNodes()) {
bgneal@45 256 for (i=0; i<n.childNodes.length; i++)
bgneal@45 257 tinyMCE.selectNodes(n.childNodes[i], f, a);
bgneal@45 258 }
bgneal@45 259
bgneal@45 260 return a;
bgneal@45 261 },
bgneal@45 262
bgneal@45 263 getContent : function() {
bgneal@45 264 return EditorManager.activeEditor.getContent();
bgneal@45 265 },
bgneal@45 266
bgneal@45 267 getParentElement : function(n, na, f) {
bgneal@45 268 if (na)
bgneal@45 269 na = new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$', 'g');
bgneal@45 270
bgneal@45 271 return this._getDOM().getParent(n, function(n) {
bgneal@45 272 return n.nodeType == 1 && (!na || na.test(n.nodeName)) && (!f || f(n));
bgneal@45 273 }, this.activeEditor.getBody());
bgneal@45 274 },
bgneal@45 275
bgneal@45 276 importPluginLanguagePack : function(n) {
bgneal@45 277 tinymce.PluginManager.requireLangPack(n);
bgneal@45 278 },
bgneal@45 279
bgneal@45 280 getButtonHTML : function(cn, lang, img, c, u, v) {
bgneal@45 281 var ed = EditorManager.activeEditor;
bgneal@45 282
bgneal@45 283 img = img.replace(/\{\$pluginurl\}/g, tinyMCE.pluginURL);
bgneal@45 284 img = img.replace(/\{\$themeurl\}/g, tinyMCE.themeURL);
bgneal@45 285 lang = lang.replace(/^lang_/g, '');
bgneal@45 286
bgneal@45 287 return ed.controlManager.createButton(cn, {
bgneal@45 288 title : lang,
bgneal@45 289 command : c,
bgneal@45 290 ui : u,
bgneal@45 291 value : v,
bgneal@45 292 scope : this,
bgneal@45 293 'class' : 'compat',
bgneal@45 294 image : img
bgneal@45 295 });
bgneal@45 296 },
bgneal@45 297
bgneal@45 298 addSelectAccessibility : function(e, s, w) {
bgneal@45 299 // Add event handlers
bgneal@45 300 if (!s._isAccessible) {
bgneal@45 301 s.onkeydown = tinyMCE.accessibleEventHandler;
bgneal@45 302 s.onblur = tinyMCE.accessibleEventHandler;
bgneal@45 303 s._isAccessible = true;
bgneal@45 304 s._win = w;
bgneal@45 305 }
bgneal@45 306
bgneal@45 307 return false;
bgneal@45 308 },
bgneal@45 309
bgneal@45 310 accessibleEventHandler : function(e) {
bgneal@45 311 var elm, win = this._win;
bgneal@45 312
bgneal@45 313 e = tinymce.isIE ? win.event : e;
bgneal@45 314 elm = tinymce.isIE ? e.srcElement : e.target;
bgneal@45 315
bgneal@45 316 // Unpiggyback onchange on blur
bgneal@45 317 if (e.type == "blur") {
bgneal@45 318 if (elm.oldonchange) {
bgneal@45 319 elm.onchange = elm.oldonchange;
bgneal@45 320 elm.oldonchange = null;
bgneal@45 321 }
bgneal@45 322
bgneal@45 323 return true;
bgneal@45 324 }
bgneal@45 325
bgneal@45 326 // Piggyback onchange
bgneal@45 327 if (elm.nodeName == "SELECT" && !elm.oldonchange) {
bgneal@45 328 elm.oldonchange = elm.onchange;
bgneal@45 329 elm.onchange = null;
bgneal@45 330 }
bgneal@45 331
bgneal@45 332 // Execute onchange and remove piggyback
bgneal@45 333 if (e.keyCode == 13 || e.keyCode == 32) {
bgneal@45 334 elm.onchange = elm.oldonchange;
bgneal@45 335 elm.onchange();
bgneal@45 336 elm.oldonchange = null;
bgneal@45 337
bgneal@45 338 tinyMCE.cancelEvent(e);
bgneal@45 339 return false;
bgneal@45 340 }
bgneal@45 341
bgneal@45 342 return true;
bgneal@45 343 },
bgneal@45 344
bgneal@45 345 cancelEvent : function(e) {
bgneal@45 346 return tinymce.dom.Event.cancel(e);
bgneal@45 347 },
bgneal@45 348
bgneal@45 349 handleVisualAid : function(e) {
bgneal@45 350 EditorManager.activeEditor.addVisual(e);
bgneal@45 351 },
bgneal@45 352
bgneal@45 353 getAbsPosition : function(n, r) {
bgneal@45 354 return tinymce.DOM.getPos(n, r);
bgneal@45 355 },
bgneal@45 356
bgneal@45 357 cleanupEventStr : function(s) {
bgneal@45 358 s = "" + s;
bgneal@45 359 s = s.replace('function anonymous()\n{\n', '');
bgneal@45 360 s = s.replace('\n}', '');
bgneal@45 361 s = s.replace(/^return true;/gi, ''); // Remove event blocker
bgneal@45 362
bgneal@45 363 return s;
bgneal@45 364 },
bgneal@45 365
bgneal@45 366 getVisualAidClass : function(s) {
bgneal@45 367 // TODO: Implement
bgneal@45 368 return s;
bgneal@45 369 },
bgneal@45 370
bgneal@45 371 parseStyle : function(s) {
bgneal@45 372 return this._getDOM().parseStyle(s);
bgneal@45 373 },
bgneal@45 374
bgneal@45 375 serializeStyle : function(s) {
bgneal@45 376 return this._getDOM().serializeStyle(s);
bgneal@45 377 },
bgneal@45 378
bgneal@45 379 openWindow : function(tpl, args) {
bgneal@45 380 var ed = EditorManager.activeEditor, o = {}, n;
bgneal@45 381
bgneal@45 382 // Convert name/value array to object
bgneal@45 383 for (n in tpl)
bgneal@45 384 o[n] = tpl[n];
bgneal@45 385
bgneal@45 386 tpl = o;
bgneal@45 387
bgneal@45 388 args = args || {};
bgneal@45 389 tpl.url = new tinymce.util.URI(tinymce.ThemeManager.themeURLs[ed.settings.theme]).toAbsolute(tpl.file);
bgneal@45 390 tpl.inline = tpl.inline || args.inline;
bgneal@45 391
bgneal@45 392 ed.windowManager.open(tpl, args);
bgneal@45 393 },
bgneal@45 394
bgneal@45 395 closeWindow : function(win) {
bgneal@45 396 EditorManager.activeEditor.windowManager.close(win);
bgneal@45 397 },
bgneal@45 398
bgneal@45 399 getOuterHTML : function(e) {
bgneal@45 400 return tinymce.DOM.getOuterHTML(e);
bgneal@45 401 },
bgneal@45 402
bgneal@45 403 setOuterHTML : function(e, h, d) {
bgneal@45 404 return tinymce.DOM.setOuterHTML(e, h, d);
bgneal@45 405 },
bgneal@45 406
bgneal@45 407 hasPlugin : function(n) {
bgneal@45 408 return tinymce.PluginManager.get(n) != null;
bgneal@45 409 },
bgneal@45 410
bgneal@45 411 _setEventsEnabled : function() {
bgneal@45 412 // Ignore it!!
bgneal@45 413 },
bgneal@45 414
bgneal@45 415 addPlugin : function(pn, f) {
bgneal@45 416 var t = this;
bgneal@45 417
bgneal@45 418 function PluginWrapper(ed) {
bgneal@45 419 tinyMCE.selectedInstance = ed;
bgneal@45 420
bgneal@45 421 ed.onInit.add(function() {
bgneal@45 422 t.settings = ed.settings;
bgneal@45 423 t.settings['base_href'] = tinyMCE.documentBasePath;
bgneal@45 424 tinyMCE.settings = t.settings;
bgneal@45 425 tinyMCE.documentBasePath = ed.documentBasePath;
bgneal@45 426 //ed.formElement = DOM.get(ed.id);
bgneal@45 427
bgneal@45 428 if (f.initInstance)
bgneal@45 429 f.initInstance(ed);
bgneal@45 430
bgneal@45 431 ed.contentDocument = ed.getDoc();
bgneal@45 432 ed.contentWindow = ed.getWin();
bgneal@45 433 ed.undoRedo = ed.undoManager;
bgneal@45 434 ed.startContent = ed.getContent({format : 'raw'});
bgneal@45 435
bgneal@45 436 tinyMCE.instances[ed.id] = ed;
bgneal@45 437 tinyMCE.loadedFiles = [];
bgneal@45 438 });
bgneal@45 439
bgneal@45 440 ed.onActivate.add(function() {
bgneal@45 441 tinyMCE.settings = ed.settings;
bgneal@45 442 tinyMCE.selectedInstance = ed;
bgneal@45 443 });
bgneal@45 444
bgneal@45 445 /* if (f.removeInstance) {
bgneal@45 446 ed.onDestroy.add(function() {
bgneal@45 447 return f.removeInstance(ed.id);
bgneal@45 448 });
bgneal@45 449 }*/
bgneal@45 450
bgneal@45 451 if (f.handleNodeChange) {
bgneal@45 452 ed.onNodeChange.add(function(ed, cm, n) {
bgneal@45 453 f.handleNodeChange(ed.id, n, 0, 0, false, !ed.selection.isCollapsed());
bgneal@45 454 });
bgneal@45 455 }
bgneal@45 456
bgneal@45 457 if (f.onChange) {
bgneal@45 458 ed.onChange.add(function(ed, n) {
bgneal@45 459 return f.onChange(ed);
bgneal@45 460 });
bgneal@45 461 }
bgneal@45 462
bgneal@45 463 if (f.cleanup) {
bgneal@45 464 ed.onGetContent.add(function() {
bgneal@45 465 //f.cleanup(type, content, inst);
bgneal@45 466 });
bgneal@45 467 }
bgneal@45 468
bgneal@45 469 this.getInfo = function() {
bgneal@45 470 return f.getInfo();
bgneal@45 471 };
bgneal@45 472
bgneal@45 473 this.createControl = function(n) {
bgneal@45 474 tinyMCE.pluginURL = tinymce.baseURL + '/plugins/' + pn;
bgneal@45 475 tinyMCE.themeURL = tinymce.baseURL + '/themes/' + tinyMCE.activeEditor.settings.theme;
bgneal@45 476
bgneal@45 477 if (f.getControlHTML)
bgneal@45 478 return f.getControlHTML(n);
bgneal@45 479
bgneal@45 480 return null;
bgneal@45 481 };
bgneal@45 482
bgneal@45 483 this.execCommand = function(cmd, ui, val) {
bgneal@45 484 if (f.execCommand)
bgneal@45 485 return f.execCommand(ed.id, ed.getBody(), cmd, ui, val);
bgneal@45 486
bgneal@45 487 return false;
bgneal@45 488 };
bgneal@45 489 };
bgneal@45 490
bgneal@45 491 tinymce.PluginManager.add(pn, PluginWrapper);
bgneal@45 492 },
bgneal@45 493
bgneal@45 494 _getDOM : function() {
bgneal@45 495 return tinyMCE.activeEditor ? tinyMCE.activeEditor.dom : tinymce.DOM;
bgneal@45 496 },
bgneal@45 497
bgneal@45 498 convertRelativeToAbsoluteURL : function(b, u) {
bgneal@45 499 return new tinymce.util.URI(b).toAbsolute(u);
bgneal@45 500 },
bgneal@45 501
bgneal@45 502 convertAbsoluteURLToRelativeURL : function(b, u) {
bgneal@45 503 return new tinymce.util.URI(b).toRelative(u);
bgneal@45 504 }
bgneal@45 505 });
bgneal@45 506
bgneal@45 507 // Extend Editor class
bgneal@45 508 tinymce.extend(tinymce.Editor.prototype, {
bgneal@45 509 getFocusElement : function() {
bgneal@45 510 return this.selection.getNode();
bgneal@45 511 },
bgneal@45 512
bgneal@45 513 getData : function(n) {
bgneal@45 514 if (!this.data)
bgneal@45 515 this.data = [];
bgneal@45 516
bgneal@45 517 if (!this.data[n])
bgneal@45 518 this.data[n] = [];
bgneal@45 519
bgneal@45 520 return this.data[n];
bgneal@45 521 },
bgneal@45 522
bgneal@45 523 hasPlugin : function(n) {
bgneal@45 524 return this.plugins[n] != null;
bgneal@45 525 },
bgneal@45 526
bgneal@45 527 getContainerWin : function() {
bgneal@45 528 return window;
bgneal@45 529 },
bgneal@45 530
bgneal@45 531 getHTML : function(raw) {
bgneal@45 532 return this.getContent({ format : raw ? 'raw' : 'html'});
bgneal@45 533 },
bgneal@45 534
bgneal@45 535 setHTML : function(h) {
bgneal@45 536 this.setContent(h);
bgneal@45 537 },
bgneal@45 538
bgneal@45 539 getSel : function() {
bgneal@45 540 return this.selection.getSel();
bgneal@45 541 },
bgneal@45 542
bgneal@45 543 getRng : function() {
bgneal@45 544 return this.selection.getRng();
bgneal@45 545 },
bgneal@45 546
bgneal@45 547 isHidden : function() {
bgneal@45 548 var s;
bgneal@45 549
bgneal@45 550 if (!tinymce.isGecko)
bgneal@45 551 return false;
bgneal@45 552
bgneal@45 553 s = this.getSel();
bgneal@45 554
bgneal@45 555 // Weird, wheres that cursor selection?
bgneal@45 556 return (!s || !s.rangeCount || s.rangeCount == 0);
bgneal@45 557 },
bgneal@45 558
bgneal@45 559 translate : function(s) {
bgneal@45 560 var c = this.settings.language, o;
bgneal@45 561
bgneal@45 562 if (!s)
bgneal@45 563 return s;
bgneal@45 564
bgneal@45 565 o = tinymce.EditorManager.i18n[c + '.' + s] || s.replace(/{\#([^}]+)\}/g, function(a, b) {
bgneal@45 566 return tinymce.EditorManager.i18n[c + '.' + b] || '{#' + b + '}';
bgneal@45 567 });
bgneal@45 568
bgneal@45 569 o = o.replace(/{\$lang_([^}]+)\}/g, function(a, b) {
bgneal@45 570 return tinymce.EditorManager.i18n[c + '.' + b] || '{$lang_' + b + '}';
bgneal@45 571 });
bgneal@45 572
bgneal@45 573 return o;
bgneal@45 574 },
bgneal@45 575
bgneal@45 576 repaint : function() {
bgneal@45 577 this.execCommand('mceRepaint');
bgneal@45 578 }
bgneal@45 579 });
bgneal@45 580
bgneal@45 581 // Extend selection
bgneal@45 582 tinymce.extend(tinymce.dom.Selection.prototype, {
bgneal@45 583 getSelectedText : function() {
bgneal@45 584 return this.getContent({format : 'text'});
bgneal@45 585 },
bgneal@45 586
bgneal@45 587 getSelectedHTML : function() {
bgneal@45 588 return this.getContent({format : 'html'});
bgneal@45 589 },
bgneal@45 590
bgneal@45 591 getFocusElement : function() {
bgneal@45 592 return this.getNode();
bgneal@45 593 },
bgneal@45 594
bgneal@45 595 selectNode : function(node, collapse, select_text_node, to_start) {
bgneal@45 596 var t = this;
bgneal@45 597
bgneal@45 598 t.select(node, select_text_node || 0);
bgneal@45 599
bgneal@45 600 if (!is(collapse))
bgneal@45 601 collapse = true;
bgneal@45 602
bgneal@45 603 if (collapse) {
bgneal@45 604 if (!is(to_start))
bgneal@45 605 to_start = true;
bgneal@45 606
bgneal@45 607 t.collapse(to_start);
bgneal@45 608 }
bgneal@45 609 }
bgneal@45 610 });
bgneal@45 611 }).call(this);
bgneal@45 612
bgneal@45 613 // Register plugin
bgneal@45 614 tinymce.PluginManager.add('compat2x', tinymce.plugins.Compat2x);
bgneal@45 615 })();
bgneal@45 616