| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,10605 @@ |
| 1 |
+ |
|
| 2 |
+/* file:jscripts/tiny_mce/classes/tinymce.js */ |
|
| 3 |
+ |
|
| 4 |
+var tinymce = {
|
|
| 5 |
+ majorVersion : '3', |
|
| 6 |
+ minorVersion : '0.9', |
|
| 7 |
+ releaseDate : '2008-06-02', |
|
| 8 |
+ |
|
| 9 |
+ _init : function() {
|
|
| 10 |
+ var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v; |
|
| 11 |
+ |
|
| 12 |
+ // Browser checks |
|
| 13 |
+ t.isOpera = w.opera && opera.buildNumber; |
|
| 14 |
+ t.isWebKit = /WebKit/.test(ua); |
|
| 15 |
+ t.isOldWebKit = t.isWebKit && !w.getSelection().getRangeAt; |
|
| 16 |
+ t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName); |
|
| 17 |
+ t.isIE6 = t.isIE && /MSIE [56]/.test(ua); |
|
| 18 |
+ t.isGecko = !t.isWebKit && /Gecko/.test(ua); |
|
| 19 |
+ t.isMac = ua.indexOf('Mac') != -1;
|
|
| 20 |
+ |
|
| 21 |
+ // TinyMCE .NET webcontrol might be setting the values for TinyMCE |
|
| 22 |
+ if (w.tinyMCEPreInit) {
|
|
| 23 |
+ t.suffix = tinyMCEPreInit.suffix; |
|
| 24 |
+ t.baseURL = tinyMCEPreInit.base; |
|
| 25 |
+ t.query = tinyMCEPreInit.query; |
|
| 26 |
+ return; |
|
| 27 |
+ } |
|
| 28 |
+ |
|
| 29 |
+ // Get suffix and base |
|
| 30 |
+ t.suffix = ''; |
|
| 31 |
+ |
|
| 32 |
+ // If base element found, add that infront of baseURL |
|
| 33 |
+ nl = d.getElementsByTagName('base');
|
|
| 34 |
+ for (i=0; i<nl.length; i++) {
|
|
| 35 |
+ if (v = nl[i].href) {
|
|
| 36 |
+ // Host only value like http://site.com or http://site.com:8008 |
|
| 37 |
+ if (/^https?:\/\/[^\/]+$/.test(v)) |
|
| 38 |
+ v += '/'; |
|
| 39 |
+ |
|
| 40 |
+ base = v ? v.match(/.*\//)[0] : ''; // Get only directory |
|
| 41 |
+ } |
|
| 42 |
+ } |
|
| 43 |
+ |
|
| 44 |
+ function getBase(n) {
|
|
| 45 |
+ if (n.src && /tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)) {
|
|
| 46 |
+ if (/_(src|dev)\.js/g.test(n.src)) |
|
| 47 |
+ t.suffix = '_src'; |
|
| 48 |
+ |
|
| 49 |
+ if ((p = n.src.indexOf('?')) != -1)
|
|
| 50 |
+ t.query = n.src.substring(p + 1); |
|
| 51 |
+ |
|
| 52 |
+ t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
|
|
| 53 |
+ |
|
| 54 |
+ // If path to script is relative and a base href was found add that one infront |
|
| 55 |
+ if (base && t.baseURL.indexOf('://') == -1)
|
|
| 56 |
+ t.baseURL = base + t.baseURL; |
|
| 57 |
+ |
|
| 58 |
+ return t.baseURL; |
|
| 59 |
+ } |
|
| 60 |
+ |
|
| 61 |
+ return null; |
|
| 62 |
+ }; |
|
| 63 |
+ |
|
| 64 |
+ // Check document |
|
| 65 |
+ nl = d.getElementsByTagName('script');
|
|
| 66 |
+ for (i=0; i<nl.length; i++) {
|
|
| 67 |
+ if (getBase(nl[i])) |
|
| 68 |
+ return; |
|
| 69 |
+ } |
|
| 70 |
+ |
|
| 71 |
+ // Check head |
|
| 72 |
+ n = d.getElementsByTagName('head')[0];
|
|
| 73 |
+ if (n) {
|
|
| 74 |
+ nl = n.getElementsByTagName('script');
|
|
| 75 |
+ for (i=0; i<nl.length; i++) {
|
|
| 76 |
+ if (getBase(nl[i])) |
|
| 77 |
+ return; |
|
| 78 |
+ } |
|
| 79 |
+ } |
|
| 80 |
+ |
|
| 81 |
+ return; |
|
| 82 |
+ }, |
|
| 83 |
+ |
|
| 84 |
+ is : function(o, t) {
|
|
| 85 |
+ var n = typeof(o); |
|
| 86 |
+ |
|
| 87 |
+ if (!t) |
|
| 88 |
+ return n != 'undefined'; |
|
| 89 |
+ |
|
| 90 |
+ if (t == 'array' && (o instanceof Array)) |
|
| 91 |
+ return true; |
|
| 92 |
+ |
|
| 93 |
+ return n == t; |
|
| 94 |
+ }, |
|
| 95 |
+ |
|
| 96 |
+ // #if !jquery |
|
| 97 |
+ |
|
| 98 |
+ each : function(o, cb, s) {
|
|
| 99 |
+ var n, l; |
|
| 100 |
+ |
|
| 101 |
+ if (!o) |
|
| 102 |
+ return 0; |
|
| 103 |
+ |
|
| 104 |
+ s = s || o; |
|
| 105 |
+ |
|
| 106 |
+ if (typeof(o.length) != 'undefined') {
|
|
| 107 |
+ // Indexed arrays, needed for Safari |
|
| 108 |
+ for (n=0, l = o.length; n<l; n++) {
|
|
| 109 |
+ if (cb.call(s, o[n], n, o) === false) |
|
| 110 |
+ return 0; |
|
| 111 |
+ } |
|
| 112 |
+ } else {
|
|
| 113 |
+ // Hashtables |
|
| 114 |
+ for (n in o) {
|
|
| 115 |
+ if (o.hasOwnProperty(n)) {
|
|
| 116 |
+ if (cb.call(s, o[n], n, o) === false) |
|
| 117 |
+ return 0; |
|
| 118 |
+ } |
|
| 119 |
+ } |
|
| 120 |
+ } |
|
| 121 |
+ |
|
| 122 |
+ return 1; |
|
| 123 |
+ }, |
|
| 124 |
+ |
|
| 125 |
+ map : function(a, f) {
|
|
| 126 |
+ var o = []; |
|
| 127 |
+ |
|
| 128 |
+ tinymce.each(a, function(v) {
|
|
| 129 |
+ o.push(f(v)); |
|
| 130 |
+ }); |
|
| 131 |
+ |
|
| 132 |
+ return o; |
|
| 133 |
+ }, |
|
| 134 |
+ |
|
| 135 |
+ grep : function(a, f) {
|
|
| 136 |
+ var o = []; |
|
| 137 |
+ |
|
| 138 |
+ tinymce.each(a, function(v) {
|
|
| 139 |
+ if (!f || f(v)) |
|
| 140 |
+ o.push(v); |
|
| 141 |
+ }); |
|
| 142 |
+ |
|
| 143 |
+ return o; |
|
| 144 |
+ }, |
|
| 145 |
+ |
|
| 146 |
+ inArray : function(a, v) {
|
|
| 147 |
+ var i, l; |
|
| 148 |
+ |
|
| 149 |
+ if (a) {
|
|
| 150 |
+ for (i = 0, l = a.length; i < l; i++) {
|
|
| 151 |
+ if (a[i] === v) |
|
| 152 |
+ return i; |
|
| 153 |
+ } |
|
| 154 |
+ } |
|
| 155 |
+ |
|
| 156 |
+ return -1; |
|
| 157 |
+ }, |
|
| 158 |
+ |
|
| 159 |
+ extend : function(o, e) {
|
|
| 160 |
+ var i, a = arguments; |
|
| 161 |
+ |
|
| 162 |
+ for (i=1; i<a.length; i++) {
|
|
| 163 |
+ e = a[i]; |
|
| 164 |
+ |
|
| 165 |
+ tinymce.each(e, function(v, n) {
|
|
| 166 |
+ if (typeof(v) !== 'undefined') |
|
| 167 |
+ o[n] = v; |
|
| 168 |
+ }); |
|
| 169 |
+ } |
|
| 170 |
+ |
|
| 171 |
+ return o; |
|
| 172 |
+ }, |
|
| 173 |
+ |
|
| 174 |
+ trim : function(s) {
|
|
| 175 |
+ return (s ? '' + s : '').replace(/^\s*|\s*$/g, ''); |
|
| 176 |
+ }, |
|
| 177 |
+ |
|
| 178 |
+ // #endif |
|
| 179 |
+ |
|
| 180 |
+ create : function(s, p) {
|
|
| 181 |
+ var t = this, sp, ns, cn, scn, c, de = 0; |
|
| 182 |
+ |
|
| 183 |
+ // Parse : <prefix> <class>:<super class> |
|
| 184 |
+ s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s); |
|
| 185 |
+ cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name |
|
| 186 |
+ |
|
| 187 |
+ // Create namespace for new class |
|
| 188 |
+ ns = t.createNS(s[3].replace(/\.\w+$/, '')); |
|
| 189 |
+ |
|
| 190 |
+ // Class already exists |
|
| 191 |
+ if (ns[cn]) |
|
| 192 |
+ return; |
|
| 193 |
+ |
|
| 194 |
+ // Make pure static class |
|
| 195 |
+ if (s[2] == 'static') {
|
|
| 196 |
+ ns[cn] = p; |
|
| 197 |
+ |
|
| 198 |
+ if (this.onCreate) |
|
| 199 |
+ this.onCreate(s[2], s[3], ns[cn]); |
|
| 200 |
+ |
|
| 201 |
+ return; |
|
| 202 |
+ } |
|
| 203 |
+ |
|
| 204 |
+ // Create default constructor |
|
| 205 |
+ if (!p[cn]) {
|
|
| 206 |
+ p[cn] = function() {};
|
|
| 207 |
+ de = 1; |
|
| 208 |
+ } |
|
| 209 |
+ |
|
| 210 |
+ // Add constructor and methods |
|
| 211 |
+ ns[cn] = p[cn]; |
|
| 212 |
+ t.extend(ns[cn].prototype, p); |
|
| 213 |
+ |
|
| 214 |
+ // Extend |
|
| 215 |
+ if (s[5]) {
|
|
| 216 |
+ sp = t.resolve(s[5]).prototype; |
|
| 217 |
+ scn = s[5].match(/\.(\w+)$/i)[1]; // Class name |
|
| 218 |
+ |
|
| 219 |
+ // Extend constructor |
|
| 220 |
+ c = ns[cn]; |
|
| 221 |
+ if (de) {
|
|
| 222 |
+ // Add passthrough constructor |
|
| 223 |
+ ns[cn] = function() {
|
|
| 224 |
+ return sp[scn].apply(this, arguments); |
|
| 225 |
+ }; |
|
| 226 |
+ } else {
|
|
| 227 |
+ // Add inherit constructor |
|
| 228 |
+ ns[cn] = function() {
|
|
| 229 |
+ this.parent = sp[scn]; |
|
| 230 |
+ return c.apply(this, arguments); |
|
| 231 |
+ }; |
|
| 232 |
+ } |
|
| 233 |
+ ns[cn].prototype[cn] = ns[cn]; |
|
| 234 |
+ |
|
| 235 |
+ // Add super methods |
|
| 236 |
+ t.each(sp, function(f, n) {
|
|
| 237 |
+ ns[cn].prototype[n] = sp[n]; |
|
| 238 |
+ }); |
|
| 239 |
+ |
|
| 240 |
+ // Add overridden methods |
|
| 241 |
+ t.each(p, function(f, n) {
|
|
| 242 |
+ // Extend methods if needed |
|
| 243 |
+ if (sp[n]) {
|
|
| 244 |
+ ns[cn].prototype[n] = function() {
|
|
| 245 |
+ this.parent = sp[n]; |
|
| 246 |
+ return f.apply(this, arguments); |
|
| 247 |
+ }; |
|
| 248 |
+ } else {
|
|
| 249 |
+ if (n != cn) |
|
| 250 |
+ ns[cn].prototype[n] = f; |
|
| 251 |
+ } |
|
| 252 |
+ }); |
|
| 253 |
+ } |
|
| 254 |
+ |
|
| 255 |
+ // Add static methods |
|
| 256 |
+ t.each(p['static'], function(f, n) {
|
|
| 257 |
+ ns[cn][n] = f; |
|
| 258 |
+ }); |
|
| 259 |
+ |
|
| 260 |
+ if (this.onCreate) |
|
| 261 |
+ this.onCreate(s[2], s[3], ns[cn].prototype); |
|
| 262 |
+ }, |
|
| 263 |
+ |
|
| 264 |
+ walk : function(o, f, n, s) {
|
|
| 265 |
+ s = s || this; |
|
| 266 |
+ |
|
| 267 |
+ if (o) {
|
|
| 268 |
+ if (n) |
|
| 269 |
+ o = o[n]; |
|
| 270 |
+ |
|
| 271 |
+ tinymce.each(o, function(o, i) {
|
|
| 272 |
+ if (f.call(s, o, i, n) === false) |
|
| 273 |
+ return false; |
|
| 274 |
+ |
|
| 275 |
+ tinymce.walk(o, f, n, s); |
|
| 276 |
+ }); |
|
| 277 |
+ } |
|
| 278 |
+ }, |
|
| 279 |
+ |
|
| 280 |
+ createNS : function(n, o) {
|
|
| 281 |
+ var i, v; |
|
| 282 |
+ |
|
| 283 |
+ o = o || window; |
|
| 284 |
+ |
|
| 285 |
+ n = n.split('.');
|
|
| 286 |
+ for (i=0; i<n.length; i++) {
|
|
| 287 |
+ v = n[i]; |
|
| 288 |
+ |
|
| 289 |
+ if (!o[v]) |
|
| 290 |
+ o[v] = {};
|
|
| 291 |
+ |
|
| 292 |
+ o = o[v]; |
|
| 293 |
+ } |
|
| 294 |
+ |
|
| 295 |
+ return o; |
|
| 296 |
+ }, |
|
| 297 |
+ |
|
| 298 |
+ resolve : function(n, o) {
|
|
| 299 |
+ var i, l; |
|
| 300 |
+ |
|
| 301 |
+ o = o || window; |
|
| 302 |
+ |
|
| 303 |
+ n = n.split('.');
|
|
| 304 |
+ for (i=0, l = n.length; i<l; i++) {
|
|
| 305 |
+ o = o[n[i]]; |
|
| 306 |
+ |
|
| 307 |
+ if (!o) |
|
| 308 |
+ break; |
|
| 309 |
+ } |
|
| 310 |
+ |
|
| 311 |
+ return o; |
|
| 312 |
+ }, |
|
| 313 |
+ |
|
| 314 |
+ addUnload : function(f, s) {
|
|
| 315 |
+ var t = this, w = window; |
|
| 316 |
+ |
|
| 317 |
+ f = {func : f, scope : s || this};
|
|
| 318 |
+ |
|
| 319 |
+ if (!t.unloads) {
|
|
| 320 |
+ function unload() {
|
|
| 321 |
+ var li = t.unloads, o, n; |
|
| 322 |
+ |
|
| 323 |
+ if (li) {
|
|
| 324 |
+ // Call unload handlers |
|
| 325 |
+ for (n in li) {
|
|
| 326 |
+ o = li[n]; |
|
| 327 |
+ |
|
| 328 |
+ if (o && o.func) |
|
| 329 |
+ o.func.call(o.scope, 1); // Send in one arg to distinct unload and user destroy |
|
| 330 |
+ } |
|
| 331 |
+ |
|
| 332 |
+ // Detach unload function |
|
| 333 |
+ if (w.detachEvent) {
|
|
| 334 |
+ w.detachEvent('onbeforeunload', fakeUnload);
|
|
| 335 |
+ w.detachEvent('onunload', unload);
|
|
| 336 |
+ } else if (w.removeEventListener) |
|
| 337 |
+ w.removeEventListener('unload', unload, false);
|
|
| 338 |
+ |
|
| 339 |
+ // Destroy references |
|
| 340 |
+ t.unloads = o = li = w = unload = null; |
|
| 341 |
+ |
|
| 342 |
+ // Run garbarge collector on IE |
|
| 343 |
+ if (window.CollectGarbage) |
|
| 344 |
+ window.CollectGarbage(); |
|
| 345 |
+ } |
|
| 346 |
+ }; |
|
| 347 |
+ |
|
| 348 |
+ function fakeUnload() {
|
|
| 349 |
+ var d = document; |
|
| 350 |
+ |
|
| 351 |
+ // Is there things still loading, then do some magic |
|
| 352 |
+ if (d.readyState == 'interactive') {
|
|
| 353 |
+ function stop() {
|
|
| 354 |
+ // Prevent memory leak |
|
| 355 |
+ d.detachEvent('onstop', stop);
|
|
| 356 |
+ |
|
| 357 |
+ // Call unload handler |
|
| 358 |
+ unload(); |
|
| 359 |
+ |
|
| 360 |
+ d = null; |
|
| 361 |
+ }; |
|
| 362 |
+ |
|
| 363 |
+ // Fire unload when the currently loading page is stopped |
|
| 364 |
+ d.attachEvent('onstop', stop);
|
|
| 365 |
+ |
|
| 366 |
+ // Remove onstop listener after a while to prevent the unload function |
|
| 367 |
+ // to execute if the user presses cancel in an onbeforeunload |
|
| 368 |
+ // confirm dialog and then presses the browser stop button |
|
| 369 |
+ window.setTimeout(function() {
|
|
| 370 |
+ d.detachEvent('onstop', stop);
|
|
| 371 |
+ }, 0); |
|
| 372 |
+ } |
|
| 373 |
+ }; |
|
| 374 |
+ |
|
| 375 |
+ // Attach unload handler |
|
| 376 |
+ if (w.attachEvent) {
|
|
| 377 |
+ w.attachEvent('onunload', unload);
|
|
| 378 |
+ w.attachEvent('onbeforeunload', fakeUnload);
|
|
| 379 |
+ } else if (w.addEventListener) |
|
| 380 |
+ w.addEventListener('unload', unload, false);
|
|
| 381 |
+ |
|
| 382 |
+ // Setup initial unload handler array |
|
| 383 |
+ t.unloads = [f]; |
|
| 384 |
+ } else |
|
| 385 |
+ t.unloads.push(f); |
|
| 386 |
+ |
|
| 387 |
+ return f; |
|
| 388 |
+ }, |
|
| 389 |
+ |
|
| 390 |
+ removeUnload : function(f) {
|
|
| 391 |
+ var u = this.unloads, r = null; |
|
| 392 |
+ |
|
| 393 |
+ tinymce.each(u, function(o, i) {
|
|
| 394 |
+ if (o && o.func == f) {
|
|
| 395 |
+ u.splice(i, 1); |
|
| 396 |
+ r = f; |
|
| 397 |
+ return false; |
|
| 398 |
+ } |
|
| 399 |
+ }); |
|
| 400 |
+ |
|
| 401 |
+ return r; |
|
| 402 |
+ }, |
|
| 403 |
+ |
|
| 404 |
+ explode : function(s, d) {
|
|
| 405 |
+ return s ? tinymce.map(s.split(d || ','), tinymce.trim) : s; |
|
| 406 |
+ }, |
|
| 407 |
+ |
|
| 408 |
+ _addVer : function(u) {
|
|
| 409 |
+ var v; |
|
| 410 |
+ |
|
| 411 |
+ if (!this.query) |
|
| 412 |
+ return u; |
|
| 413 |
+ |
|
| 414 |
+ v = (u.indexOf('?') == -1 ? '?' : '&') + this.query;
|
|
| 415 |
+ |
|
| 416 |
+ if (u.indexOf('#') == -1)
|
|
| 417 |
+ return u + v; |
|
| 418 |
+ |
|
| 419 |
+ return u.replace('#', v + '#');
|
|
| 420 |
+ } |
|
| 421 |
+ |
|
| 422 |
+ }; |
|
| 423 |
+ |
|
| 424 |
+// Required for GZip AJAX loading |
|
| 425 |
+window.tinymce = tinymce; |
|
| 426 |
+ |
|
| 427 |
+// Initialize the API |
|
| 428 |
+tinymce._init(); |
|
| 429 |
+ |
|
| 430 |
+/* file:jscripts/tiny_mce/classes/adapter/jquery/adapter.js */ |
|
| 431 |
+ |
|
| 432 |
+ |
|
| 433 |
+/* file:jscripts/tiny_mce/classes/adapter/prototype/adapter.js */ |
|
| 434 |
+ |
|
| 435 |
+ |
|
| 436 |
+/* file:jscripts/tiny_mce/classes/util/Dispatcher.js */ |
|
| 437 |
+ |
|
| 438 |
+tinymce.create('tinymce.util.Dispatcher', {
|
|
| 439 |
+ scope : null, |
|
| 440 |
+ listeners : null, |
|
| 441 |
+ |
|
| 442 |
+ Dispatcher : function(s) {
|
|
| 443 |
+ this.scope = s || this; |
|
| 444 |
+ this.listeners = []; |
|
| 445 |
+ }, |
|
| 446 |
+ |
|
| 447 |
+ add : function(cb, s) {
|
|
| 448 |
+ this.listeners.push({cb : cb, scope : s || this.scope});
|
|
| 449 |
+ |
|
| 450 |
+ return cb; |
|
| 451 |
+ }, |
|
| 452 |
+ |
|
| 453 |
+ addToTop : function(cb, s) {
|
|
| 454 |
+ this.listeners.unshift({cb : cb, scope : s || this.scope});
|
|
| 455 |
+ |
|
| 456 |
+ return cb; |
|
| 457 |
+ }, |
|
| 458 |
+ |
|
| 459 |
+ remove : function(cb) {
|
|
| 460 |
+ var l = this.listeners, o = null; |
|
| 461 |
+ |
|
| 462 |
+ tinymce.each(l, function(c, i) {
|
|
| 463 |
+ if (cb == c.cb) {
|
|
| 464 |
+ o = cb; |
|
| 465 |
+ l.splice(i, 1); |
|
| 466 |
+ return false; |
|
| 467 |
+ } |
|
| 468 |
+ }); |
|
| 469 |
+ |
|
| 470 |
+ return o; |
|
| 471 |
+ }, |
|
| 472 |
+ |
|
| 473 |
+ dispatch : function() {
|
|
| 474 |
+ var s, a = arguments, i, li = this.listeners, c; |
|
| 475 |
+ |
|
| 476 |
+ // Needs to be a real loop since the listener count might change while looping |
|
| 477 |
+ // And this is also more efficient |
|
| 478 |
+ for (i = 0; i<li.length; i++) {
|
|
| 479 |
+ c = li[i]; |
|
| 480 |
+ s = c.cb.apply(c.scope, a); |
|
| 481 |
+ |
|
| 482 |
+ if (s === false) |
|
| 483 |
+ break; |
|
| 484 |
+ } |
|
| 485 |
+ |
|
| 486 |
+ return s; |
|
| 487 |
+ } |
|
| 488 |
+ |
|
| 489 |
+ }); |
|
| 490 |
+ |
|
| 491 |
+/* file:jscripts/tiny_mce/classes/util/URI.js */ |
|
| 492 |
+ |
|
| 493 |
+(function() {
|
|
| 494 |
+ var each = tinymce.each; |
|
| 495 |
+ |
|
| 496 |
+ tinymce.create('tinymce.util.URI', {
|
|
| 497 |
+ URI : function(u, s) {
|
|
| 498 |
+ var t = this, o, a, b; |
|
| 499 |
+ |
|
| 500 |
+ // Default settings |
|
| 501 |
+ s = t.settings = s || {};
|
|
| 502 |
+ |
|
| 503 |
+ // Strange app protocol or local anchor |
|
| 504 |
+ if (/^(mailto|news|javascript|about):/i.test(u) || /^\s*#/.test(u)) {
|
|
| 505 |
+ t.source = u; |
|
| 506 |
+ return; |
|
| 507 |
+ } |
|
| 508 |
+ |
|
| 509 |
+ // Absolute path with no host, fake host and protocol |
|
| 510 |
+ if (u.indexOf('/') === 0 && u.indexOf('//') !== 0)
|
|
| 511 |
+ u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u; |
|
| 512 |
+ |
|
| 513 |
+ // Relative path |
|
| 514 |
+ if (u.indexOf('://') === -1 && u.indexOf('//') !== 0)
|
|
| 515 |
+ u = (s.base_uri.protocol || 'http') + '://mce_host' + t.toAbsPath(s.base_uri.path, u); |
|
| 516 |
+ |
|
| 517 |
+ // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri) |
|
| 518 |
+ u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something |
|
| 519 |
+ u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u); |
|
| 520 |
+ each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], function(v, i) {
|
|
| 521 |
+ var s = u[i]; |
|
| 522 |
+ |
|
| 523 |
+ // Zope 3 workaround, they use @@something |
|
| 524 |
+ if (s) |
|
| 525 |
+ s = s.replace(/\(mce_at\)/g, '@@'); |
|
| 526 |
+ |
|
| 527 |
+ t[v] = s; |
|
| 528 |
+ }); |
|
| 529 |
+ |
|
| 530 |
+ if (b = s.base_uri) {
|
|
| 531 |
+ if (!t.protocol) |
|
| 532 |
+ t.protocol = b.protocol; |
|
| 533 |
+ |
|
| 534 |
+ if (!t.userInfo) |
|
| 535 |
+ t.userInfo = b.userInfo; |
|
| 536 |
+ |
|
| 537 |
+ if (!t.port && t.host == 'mce_host') |
|
| 538 |
+ t.port = b.port; |
|
| 539 |
+ |
|
| 540 |
+ if (!t.host || t.host == 'mce_host') |
|
| 541 |
+ t.host = b.host; |
|
| 542 |
+ |
|
| 543 |
+ t.source = ''; |
|
| 544 |
+ } |
|
| 545 |
+ |
|
| 546 |
+ //t.path = t.path || '/'; |
|
| 547 |
+ }, |
|
| 548 |
+ |
|
| 549 |
+ setPath : function(p) {
|
|
| 550 |
+ var t = this; |
|
| 551 |
+ |
|
| 552 |
+ p = /^(.*?)\/?(\w+)?$/.exec(p); |
|
| 553 |
+ |
|
| 554 |
+ // Update path parts |
|
| 555 |
+ t.path = p[0]; |
|
| 556 |
+ t.directory = p[1]; |
|
| 557 |
+ t.file = p[2]; |
|
| 558 |
+ |
|
| 559 |
+ // Rebuild source |
|
| 560 |
+ t.source = ''; |
|
| 561 |
+ t.getURI(); |
|
| 562 |
+ }, |
|
| 563 |
+ |
|
| 564 |
+ toRelative : function(u) {
|
|
| 565 |
+ var t = this, o; |
|
| 566 |
+ |
|
| 567 |
+ u = new tinymce.util.URI(u, {base_uri : t});
|
|
| 568 |
+ |
|
| 569 |
+ // Not on same domain/port or protocol |
|
| 570 |
+ if ((u.host != 'mce_host' && t.host != u.host && u.host) || t.port != u.port || t.protocol != u.protocol) |
|
| 571 |
+ return u.getURI(); |
|
| 572 |
+ |
|
| 573 |
+ o = t.toRelPath(t.path, u.path); |
|
| 574 |
+ |
|
| 575 |
+ // Add query |
|
| 576 |
+ if (u.query) |
|
| 577 |
+ o += '?' + u.query; |
|
| 578 |
+ |
|
| 579 |
+ // Add anchor |
|
| 580 |
+ if (u.anchor) |
|
| 581 |
+ o += '#' + u.anchor; |
|
| 582 |
+ |
|
| 583 |
+ return o; |
|
| 584 |
+ }, |
|
| 585 |
+ |
|
| 586 |
+ toAbsolute : function(u, nh) {
|
|
| 587 |
+ var u = new tinymce.util.URI(u, {base_uri : this});
|
|
| 588 |
+ |
|
| 589 |
+ return u.getURI(this.host == u.host ? nh : 0); |
|
| 590 |
+ }, |
|
| 591 |
+ |
|
| 592 |
+ toRelPath : function(base, path) {
|
|
| 593 |
+ var items, bp = 0, out = '', i; |
|
| 594 |
+ |
|
| 595 |
+ // Split the paths |
|
| 596 |
+ base = base.substring(0, base.lastIndexOf('/'));
|
|
| 597 |
+ base = base.split('/');
|
|
| 598 |
+ items = path.split('/');
|
|
| 599 |
+ |
|
| 600 |
+ if (base.length >= items.length) {
|
|
| 601 |
+ for (i = 0; i < base.length; i++) {
|
|
| 602 |
+ if (i >= items.length || base[i] != items[i]) {
|
|
| 603 |
+ bp = i + 1; |
|
| 604 |
+ break; |
|
| 605 |
+ } |
|
| 606 |
+ } |
|
| 607 |
+ } |
|
| 608 |
+ |
|
| 609 |
+ if (base.length < items.length) {
|
|
| 610 |
+ for (i = 0; i < items.length; i++) {
|
|
| 611 |
+ if (i >= base.length || base[i] != items[i]) {
|
|
| 612 |
+ bp = i + 1; |
|
| 613 |
+ break; |
|
| 614 |
+ } |
|
| 615 |
+ } |
|
| 616 |
+ } |
|
| 617 |
+ |
|
| 618 |
+ if (bp == 1) |
|
| 619 |
+ return path; |
|
| 620 |
+ |
|
| 621 |
+ for (i = 0; i < base.length - (bp - 1); i++) |
|
| 622 |
+ out += "../"; |
|
| 623 |
+ |
|
| 624 |
+ for (i = bp - 1; i < items.length; i++) {
|
|
| 625 |
+ if (i != bp - 1) |
|
| 626 |
+ out += "/" + items[i]; |
|
| 627 |
+ else |
|
| 628 |
+ out += items[i]; |
|
| 629 |
+ } |
|
| 630 |
+ |
|
| 631 |
+ return out; |
|
| 632 |
+ }, |
|
| 633 |
+ |
|
| 634 |
+ toAbsPath : function(base, path) {
|
|
| 635 |
+ var i, nb = 0, o = []; |
|
| 636 |
+ |
|
| 637 |
+ // Split paths |
|
| 638 |
+ base = base.split('/');
|
|
| 639 |
+ path = path.split('/');
|
|
| 640 |
+ |
|
| 641 |
+ // Remove empty chunks |
|
| 642 |
+ each(base, function(k) {
|
|
| 643 |
+ if (k) |
|
| 644 |
+ o.push(k); |
|
| 645 |
+ }); |
|
| 646 |
+ |
|
| 647 |
+ base = o; |
|
| 648 |
+ |
|
| 649 |
+ // Merge relURLParts chunks |
|
| 650 |
+ for (i = path.length - 1, o = []; i >= 0; i--) {
|
|
| 651 |
+ // Ignore empty or . |
|
| 652 |
+ if (path[i].length == 0 || path[i] == ".") |
|
| 653 |
+ continue; |
|
| 654 |
+ |
|
| 655 |
+ // Is parent |
|
| 656 |
+ if (path[i] == '..') {
|
|
| 657 |
+ nb++; |
|
| 658 |
+ continue; |
|
| 659 |
+ } |
|
| 660 |
+ |
|
| 661 |
+ // Move up |
|
| 662 |
+ if (nb > 0) {
|
|
| 663 |
+ nb--; |
|
| 664 |
+ continue; |
|
| 665 |
+ } |
|
| 666 |
+ |
|
| 667 |
+ o.push(path[i]); |
|
| 668 |
+ } |
|
| 669 |
+ |
|
| 670 |
+ i = base.length - nb; |
|
| 671 |
+ |
|
| 672 |
+ // If /a/b/c or / |
|
| 673 |
+ if (i <= 0) |
|
| 674 |
+ return '/' + o.reverse().join('/');
|
|
| 675 |
+ |
|
| 676 |
+ return '/' + base.slice(0, i).join('/') + '/' + o.reverse().join('/');
|
|
| 677 |
+ }, |
|
| 678 |
+ |
|
| 679 |
+ getURI : function(nh) {
|
|
| 680 |
+ var s, t = this; |
|
| 681 |
+ |
|
| 682 |
+ // Rebuild source |
|
| 683 |
+ if (!t.source || nh) {
|
|
| 684 |
+ s = ''; |
|
| 685 |
+ |
|
| 686 |
+ if (!nh) {
|
|
| 687 |
+ if (t.protocol) |
|
| 688 |
+ s += t.protocol + '://'; |
|
| 689 |
+ |
|
| 690 |
+ if (t.userInfo) |
|
| 691 |
+ s += t.userInfo + '@'; |
|
| 692 |
+ |
|
| 693 |
+ if (t.host) |
|
| 694 |
+ s += t.host; |
|
| 695 |
+ |
|
| 696 |
+ if (t.port) |
|
| 697 |
+ s += ':' + t.port; |
|
| 698 |
+ } |
|
| 699 |
+ |
|
| 700 |
+ if (t.path) |
|
| 701 |
+ s += t.path; |
|
| 702 |
+ |
|
| 703 |
+ if (t.query) |
|
| 704 |
+ s += '?' + t.query; |
|
| 705 |
+ |
|
| 706 |
+ if (t.anchor) |
|
| 707 |
+ s += '#' + t.anchor; |
|
| 708 |
+ |
|
| 709 |
+ t.source = s; |
|
| 710 |
+ } |
|
| 711 |
+ |
|
| 712 |
+ return t.source; |
|
| 713 |
+ } |
|
| 714 |
+ |
|
| 715 |
+ }); |
|
| 716 |
+})(); |
|
| 717 |
+ |
|
| 718 |
+/* file:jscripts/tiny_mce/classes/util/Cookie.js */ |
|
| 719 |
+ |
|
| 720 |
+(function() {
|
|
| 721 |
+ var each = tinymce.each; |
|
| 722 |
+ |
|
| 723 |
+ tinymce.create('static tinymce.util.Cookie', {
|
|
| 724 |
+ getHash : function(n) {
|
|
| 725 |
+ var v = this.get(n), h; |
|
| 726 |
+ |
|
| 727 |
+ if (v) {
|
|
| 728 |
+ each(v.split('&'), function(v) {
|
|
| 729 |
+ v = v.split('=');
|
|
| 730 |
+ h = h || {};
|
|
| 731 |
+ h[unescape(v[0])] = unescape(v[1]); |
|
| 732 |
+ }); |
|
| 733 |
+ } |
|
| 734 |
+ |
|
| 735 |
+ return h; |
|
| 736 |
+ }, |
|
| 737 |
+ |
|
| 738 |
+ setHash : function(n, v, e, p, d, s) {
|
|
| 739 |
+ var o = ''; |
|
| 740 |
+ |
|
| 741 |
+ each(v, function(v, k) {
|
|
| 742 |
+ o += (!o ? '' : '&') + escape(k) + '=' + escape(v); |
|
| 743 |
+ }); |
|
| 744 |
+ |
|
| 745 |
+ this.set(n, o, e, p, d, s); |
|
| 746 |
+ }, |
|
| 747 |
+ |
|
| 748 |
+ get : function(n) {
|
|
| 749 |
+ var c = document.cookie, e, p = n + "=", b; |
|
| 750 |
+ |
|
| 751 |
+ // Strict mode |
|
| 752 |
+ if (!c) |
|
| 753 |
+ return; |
|
| 754 |
+ |
|
| 755 |
+ b = c.indexOf("; " + p);
|
|
| 756 |
+ |
|
| 757 |
+ if (b == -1) {
|
|
| 758 |
+ b = c.indexOf(p); |
|
| 759 |
+ |
|
| 760 |
+ if (b != 0) |
|
| 761 |
+ return null; |
|
| 762 |
+ } else |
|
| 763 |
+ b += 2; |
|
| 764 |
+ |
|
| 765 |
+ e = c.indexOf(";", b);
|
|
| 766 |
+ |
|
| 767 |
+ if (e == -1) |
|
| 768 |
+ e = c.length; |
|
| 769 |
+ |
|
| 770 |
+ return unescape(c.substring(b + p.length, e)); |
|
| 771 |
+ }, |
|
| 772 |
+ |
|
| 773 |
+ set : function(n, v, e, p, d, s) {
|
|
| 774 |
+ document.cookie = n + "=" + escape(v) + |
|
| 775 |
+ ((e) ? "; expires=" + e.toGMTString() : "") + |
|
| 776 |
+ ((p) ? "; path=" + escape(p) : "") + |
|
| 777 |
+ ((d) ? "; domain=" + d : "") + |
|
| 778 |
+ ((s) ? "; secure" : ""); |
|
| 779 |
+ }, |
|
| 780 |
+ |
|
| 781 |
+ remove : function(n, p) {
|
|
| 782 |
+ var d = new Date(); |
|
| 783 |
+ |
|
| 784 |
+ d.setTime(d.getTime() - 1000); |
|
| 785 |
+ |
|
| 786 |
+ this.set(n, '', d, p, d); |
|
| 787 |
+ } |
|
| 788 |
+ |
|
| 789 |
+ }); |
|
| 790 |
+})(); |
|
| 791 |
+ |
|
| 792 |
+/* file:jscripts/tiny_mce/classes/util/JSON.js */ |
|
| 793 |
+ |
|
| 794 |
+tinymce.create('static tinymce.util.JSON', {
|
|
| 795 |
+ serialize : function(o) {
|
|
| 796 |
+ var i, v, s = tinymce.util.JSON.serialize, t; |
|
| 797 |
+ |
|
| 798 |
+ if (o == null) |
|
| 799 |
+ return 'null'; |
|
| 800 |
+ |
|
| 801 |
+ t = typeof o; |
|
| 802 |
+ |
|
| 803 |
+ if (t == 'string') {
|
|
| 804 |
+ v = '\bb\tt\nn\ff\rr\""\'\'\\\\'; |
|
| 805 |
+ |
|
| 806 |
+ return '"' + o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'])/g, function(a, b) {
|
|
| 807 |
+ i = v.indexOf(b); |
|
| 808 |
+ |
|
| 809 |
+ if (i + 1) |
|
| 810 |
+ return '\\' + v.charAt(i + 1); |
|
| 811 |
+ |
|
| 812 |
+ a = b.charCodeAt().toString(16); |
|
| 813 |
+ |
|
| 814 |
+ return '\\u' + '0000'.substring(a.length) + a; |
|
| 815 |
+ }) + '"'; |
|
| 816 |
+ } |
|
| 817 |
+ |
|
| 818 |
+ if (t == 'object') {
|
|
| 819 |
+ if (o instanceof Array) {
|
|
| 820 |
+ for (i=0, v = '['; i<o.length; i++) |
|
| 821 |
+ v += (i > 0 ? ',' : '') + s(o[i]); |
|
| 822 |
+ |
|
| 823 |
+ return v + ']'; |
|
| 824 |
+ } |
|
| 825 |
+ |
|
| 826 |
+ v = '{';
|
|
| 827 |
+ |
|
| 828 |
+ for (i in o) |
|
| 829 |
+ v += typeof o[i] != 'function' ? (v.length > 1 ? ',"' : '"') + i + '":' + s(o[i]) : ''; |
|
| 830 |
+ |
|
| 831 |
+ return v + '}'; |
|
| 832 |
+ } |
|
| 833 |
+ |
|
| 834 |
+ return '' + o; |
|
| 835 |
+ }, |
|
| 836 |
+ |
|
| 837 |
+ parse : function(s) {
|
|
| 838 |
+ try {
|
|
| 839 |
+ return eval('(' + s + ')');
|
|
| 840 |
+ } catch (ex) {
|
|
| 841 |
+ // Ignore |
|
| 842 |
+ } |
|
| 843 |
+ } |
|
| 844 |
+ |
|
| 845 |
+ }); |
|
| 846 |
+ |
|
| 847 |
+/* file:jscripts/tiny_mce/classes/util/XHR.js */ |
|
| 848 |
+ |
|
| 849 |
+tinymce.create('static tinymce.util.XHR', {
|
|
| 850 |
+ send : function(o) {
|
|
| 851 |
+ var x, t, w = window, c = 0; |
|
| 852 |
+ |
|
| 853 |
+ // Default settings |
|
| 854 |
+ o.scope = o.scope || this; |
|
| 855 |
+ o.success_scope = o.success_scope || o.scope; |
|
| 856 |
+ o.error_scope = o.error_scope || o.scope; |
|
| 857 |
+ o.async = o.async === false ? false : true; |
|
| 858 |
+ o.data = o.data || ''; |
|
| 859 |
+ |
|
| 860 |
+ function get(s) {
|
|
| 861 |
+ x = 0; |
|
| 862 |
+ |
|
| 863 |
+ try {
|
|
| 864 |
+ x = new ActiveXObject(s); |
|
| 865 |
+ } catch (ex) {
|
|
| 866 |
+ } |
|
| 867 |
+ |
|
| 868 |
+ return x; |
|
| 869 |
+ }; |
|
| 870 |
+ |
|
| 871 |
+ x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Microsoft.XMLHTTP') || get('Msxml2.XMLHTTP');
|
|
| 872 |
+ |
|
| 873 |
+ if (x) {
|
|
| 874 |
+ if (x.overrideMimeType) |
|
| 875 |
+ x.overrideMimeType(o.content_type); |
|
| 876 |
+ |
|
| 877 |
+ x.open(o.type || (o.data ? 'POST' : 'GET'), o.url, o.async); |
|
| 878 |
+ |
|
| 879 |
+ if (o.content_type) |
|
| 880 |
+ x.setRequestHeader('Content-Type', o.content_type);
|
|
| 881 |
+ |
|
| 882 |
+ x.send(o.data); |
|
| 883 |
+ |
|
| 884 |
+ function ready() {
|
|
| 885 |
+ if (!o.async || x.readyState == 4 || c++ > 10000) {
|
|
| 886 |
+ if (o.success && c < 10000 && x.status == 200) |
|
| 887 |
+ o.success.call(o.success_scope, '' + x.responseText, x, o); |
|
| 888 |
+ else if (o.error) |
|
| 889 |
+ o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o); |
|
| 890 |
+ |
|
| 891 |
+ x = null; |
|
| 892 |
+ } else |
|
| 893 |
+ w.setTimeout(ready, 10); |
|
| 894 |
+ }; |
|
| 895 |
+ |
|
| 896 |
+ // Syncronous request |
|
| 897 |
+ if (!o.async) |
|
| 898 |
+ return ready(); |
|
| 899 |
+ |
|
| 900 |
+ // Wait for response, onReadyStateChange can not be used since it leaks memory in IE |
|
| 901 |
+ t = w.setTimeout(ready, 10); |
|
| 902 |
+ } |
|
| 903 |
+ |
|
| 904 |
+ } |
|
| 905 |
+}); |
|
| 906 |
+ |
|
| 907 |
+/* file:jscripts/tiny_mce/classes/util/JSONRequest.js */ |
|
| 908 |
+ |
|
| 909 |
+(function() {
|
|
| 910 |
+ var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR; |
|
| 911 |
+ |
|
| 912 |
+ tinymce.create('tinymce.util.JSONRequest', {
|
|
| 913 |
+ JSONRequest : function(s) {
|
|
| 914 |
+ this.settings = extend({
|
|
| 915 |
+ }, s); |
|
| 916 |
+ this.count = 0; |
|
| 917 |
+ }, |
|
| 918 |
+ |
|
| 919 |
+ send : function(o) {
|
|
| 920 |
+ var ecb = o.error, scb = o.success; |
|
| 921 |
+ |
|
| 922 |
+ o = extend(this.settings, o); |
|
| 923 |
+ |
|
| 924 |
+ o.success = function(c, x) {
|
|
| 925 |
+ c = JSON.parse(c); |
|
| 926 |
+ |
|
| 927 |
+ if (typeof(c) == 'undefined') {
|
|
| 928 |
+ c = {
|
|
| 929 |
+ error : 'JSON Parse error.' |
|
| 930 |
+ }; |
|
| 931 |
+ } |
|
| 932 |
+ |
|
| 933 |
+ if (c.error) |
|
| 934 |
+ ecb.call(o.error_scope || o.scope, c.error, x); |
|
| 935 |
+ else |
|
| 936 |
+ scb.call(o.success_scope || o.scope, c.result); |
|
| 937 |
+ }; |
|
| 938 |
+ |
|
| 939 |
+ o.error = function(ty, x) {
|
|
| 940 |
+ ecb.call(o.error_scope || o.scope, ty, x); |
|
| 941 |
+ }; |
|
| 942 |
+ |
|
| 943 |
+ o.data = JSON.serialize({
|
|
| 944 |
+ id : o.id || 'c' + (this.count++), |
|
| 945 |
+ method : o.method, |
|
| 946 |
+ params : o.params |
|
| 947 |
+ }); |
|
| 948 |
+ |
|
| 949 |
+ // JSON content type for Ruby on rails. Bug: #1883287 |
|
| 950 |
+ o.content_type = 'application/json'; |
|
| 951 |
+ |
|
| 952 |
+ XHR.send(o); |
|
| 953 |
+ }, |
|
| 954 |
+ |
|
| 955 |
+ 'static' : {
|
|
| 956 |
+ sendRPC : function(o) {
|
|
| 957 |
+ return new tinymce.util.JSONRequest().send(o); |
|
| 958 |
+ } |
|
| 959 |
+ } |
|
| 960 |
+ |
|
| 961 |
+ }); |
|
| 962 |
+}()); |
|
| 963 |
+/* file:jscripts/tiny_mce/classes/dom/DOMUtils.js */ |
|
| 964 |
+ |
|
| 965 |
+(function() {
|
|
| 966 |
+ // Shorten names |
|
| 967 |
+ var each = tinymce.each, is = tinymce.is; |
|
| 968 |
+ var isWebKit = tinymce.isWebKit, isIE = tinymce.isIE; |
|
| 969 |
+ |
|
| 970 |
+ tinymce.create('tinymce.dom.DOMUtils', {
|
|
| 971 |
+ doc : null, |
|
| 972 |
+ root : null, |
|
| 973 |
+ files : null, |
|
| 974 |
+ listeners : {},
|
|
| 975 |
+ pixelStyles : /^(top|left|bottom|right|width|height|borderWidth)$/, |
|
| 976 |
+ cache : {},
|
|
| 977 |
+ idPattern : /^#[\w]+$/, |
|
| 978 |
+ elmPattern : /^[\w_*]+$/, |
|
| 979 |
+ elmClassPattern : /^([\w_]*)\.([\w_]+)$/, |
|
| 980 |
+ |
|
| 981 |
+ DOMUtils : function(d, s) {
|
|
| 982 |
+ var t = this; |
|
| 983 |
+ |
|
| 984 |
+ t.doc = d; |
|
| 985 |
+ t.win = window; |
|
| 986 |
+ t.files = {};
|
|
| 987 |
+ t.cssFlicker = false; |
|
| 988 |
+ t.counter = 0; |
|
| 989 |
+ t.boxModel = !tinymce.isIE || d.compatMode == "CSS1Compat"; |
|
| 990 |
+ t.stdMode = d.documentMode === 8; |
|
| 991 |
+ |
|
| 992 |
+ this.settings = s = tinymce.extend({
|
|
| 993 |
+ keep_values : false, |
|
| 994 |
+ hex_colors : 1, |
|
| 995 |
+ process_html : 1 |
|
| 996 |
+ }, s); |
|
| 997 |
+ |
|
| 998 |
+ // Fix IE6SP2 flicker and check it failed for pre SP2 |
|
| 999 |
+ if (tinymce.isIE6) {
|
|
| 1000 |
+ try {
|
|
| 1001 |
+ d.execCommand('BackgroundImageCache', false, true);
|
|
| 1002 |
+ } catch (e) {
|
|
| 1003 |
+ t.cssFlicker = true; |
|
| 1004 |
+ } |
|
| 1005 |
+ } |
|
| 1006 |
+ |
|
| 1007 |
+ tinymce.addUnload(t.destroy, t); |
|
| 1008 |
+ }, |
|
| 1009 |
+ |
|
| 1010 |
+ getRoot : function() {
|
|
| 1011 |
+ var t = this, s = t.settings; |
|
| 1012 |
+ |
|
| 1013 |
+ return (s && t.get(s.root_element)) || t.doc.body; |
|
| 1014 |
+ }, |
|
| 1015 |
+ |
|
| 1016 |
+ getViewPort : function(w) {
|
|
| 1017 |
+ var d, b; |
|
| 1018 |
+ |
|
| 1019 |
+ w = !w ? this.win : w; |
|
| 1020 |
+ d = w.document; |
|
| 1021 |
+ b = this.boxModel ? d.documentElement : d.body; |
|
| 1022 |
+ |
|
| 1023 |
+ // Returns viewport size excluding scrollbars |
|
| 1024 |
+ return {
|
|
| 1025 |
+ x : w.pageXOffset || b.scrollLeft, |
|
| 1026 |
+ y : w.pageYOffset || b.scrollTop, |
|
| 1027 |
+ w : w.innerWidth || b.clientWidth, |
|
| 1028 |
+ h : w.innerHeight || b.clientHeight |
|
| 1029 |
+ }; |
|
| 1030 |
+ }, |
|
| 1031 |
+ |
|
| 1032 |
+ getRect : function(e) {
|
|
| 1033 |
+ var p, t = this, w, h; |
|
| 1034 |
+ |
|
| 1035 |
+ e = t.get(e); |
|
| 1036 |
+ p = t.getPos(e); |
|
| 1037 |
+ w = t.getStyle(e, 'width'); |
|
| 1038 |
+ h = t.getStyle(e, 'height'); |
|
| 1039 |
+ |
|
| 1040 |
+ // Non pixel value, then force offset/clientWidth |
|
| 1041 |
+ if (w.indexOf('px') === -1)
|
|
| 1042 |
+ w = 0; |
|
| 1043 |
+ |
|
| 1044 |
+ // Non pixel value, then force offset/clientWidth |
|
| 1045 |
+ if (h.indexOf('px') === -1)
|
|
| 1046 |
+ h = 0; |
|
| 1047 |
+ |
|
| 1048 |
+ return {
|
|
| 1049 |
+ x : p.x, |
|
| 1050 |
+ y : p.y, |
|
| 1051 |
+ w : parseInt(w) || e.offsetWidth || e.clientWidth, |
|
| 1052 |
+ h : parseInt(h) || e.offsetHeight || e.clientHeight |
|
| 1053 |
+ }; |
|
| 1054 |
+ }, |
|
| 1055 |
+ |
|
| 1056 |
+ getParent : function(n, f, r) {
|
|
| 1057 |
+ var na, se = this.settings; |
|
| 1058 |
+ |
|
| 1059 |
+ n = this.get(n); |
|
| 1060 |
+ |
|
| 1061 |
+ if (se.strict_root) |
|
| 1062 |
+ r = r || this.getRoot(); |
|
| 1063 |
+ |
|
| 1064 |
+ // Wrap node name as func |
|
| 1065 |
+ if (is(f, 'string')) {
|
|
| 1066 |
+ na = f.toUpperCase(); |
|
| 1067 |
+ |
|
| 1068 |
+ f = function(n) {
|
|
| 1069 |
+ var s = false; |
|
| 1070 |
+ |
|
| 1071 |
+ // Any element |
|
| 1072 |
+ if (n.nodeType == 1 && na === '*') {
|
|
| 1073 |
+ s = true; |
|
| 1074 |
+ return false; |
|
| 1075 |
+ } |
|
| 1076 |
+ |
|
| 1077 |
+ each(na.split(','), function(v) {
|
|
| 1078 |
+ if (n.nodeType == 1 && ((se.strict && n.nodeName.toUpperCase() == v) || n.nodeName.toUpperCase() == v)) {
|
|
| 1079 |
+ s = true; |
|
| 1080 |
+ return false; // Break loop |
|
| 1081 |
+ } |
|
| 1082 |
+ }); |
|
| 1083 |
+ |
|
| 1084 |
+ return s; |
|
| 1085 |
+ }; |
|
| 1086 |
+ } |
|
| 1087 |
+ |
|
| 1088 |
+ while (n) {
|
|
| 1089 |
+ if (n == r) |
|
| 1090 |
+ return null; |
|
| 1091 |
+ |
|
| 1092 |
+ if (f(n)) |
|
| 1093 |
+ return n; |
|
| 1094 |
+ |
|
| 1095 |
+ n = n.parentNode; |
|
| 1096 |
+ } |
|
| 1097 |
+ |
|
| 1098 |
+ return null; |
|
| 1099 |
+ }, |
|
| 1100 |
+ |
|
| 1101 |
+ get : function(e) {
|
|
| 1102 |
+ var n; |
|
| 1103 |
+ |
|
| 1104 |
+ if (e && this.doc && typeof(e) == 'string') {
|
|
| 1105 |
+ n = e; |
|
| 1106 |
+ e = this.doc.getElementById(e); |
|
| 1107 |
+ |
|
| 1108 |
+ // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick |
|
| 1109 |
+ if (e && e.id !== n) |
|
| 1110 |
+ return this.doc.getElementsByName(n)[1]; |
|
| 1111 |
+ } |
|
| 1112 |
+ |
|
| 1113 |
+ return e; |
|
| 1114 |
+ }, |
|
| 1115 |
+ |
|
| 1116 |
+ // #if !jquery |
|
| 1117 |
+ |
|
| 1118 |
+ select : function(pa, s) {
|
|
| 1119 |
+ var t = this, cs, c, pl, o = [], x, i, l, n; |
|
| 1120 |
+ |
|
| 1121 |
+ s = t.get(s) || t.doc; |
|
| 1122 |
+ |
|
| 1123 |
+ // Look for native support and use that if it's found |
|
| 1124 |
+ if (s.querySelectorAll) {
|
|
| 1125 |
+ // Element scope then use temp id |
|
| 1126 |
+ // We need to do this to be compatible with other implementations |
|
| 1127 |
+ // See bug report: http://bugs.webkit.org/show_bug.cgi?id=17461 |
|
| 1128 |
+ if (s != t.doc) {
|
|
| 1129 |
+ i = s.id; |
|
| 1130 |
+ s.id = '_mc_tmp'; |
|
| 1131 |
+ pa = '#_mc_tmp ' + pa; |
|
| 1132 |
+ } |
|
| 1133 |
+ |
|
| 1134 |
+ // Select elements |
|
| 1135 |
+ l = tinymce.grep(s.querySelectorAll(pa)); |
|
| 1136 |
+ |
|
| 1137 |
+ // Restore old id |
|
| 1138 |
+ s.id = i; |
|
| 1139 |
+ |
|
| 1140 |
+ return l; |
|
| 1141 |
+ } |
|
| 1142 |
+ |
|
| 1143 |
+ if (t.settings.strict) {
|
|
| 1144 |
+ function get(s, n) {
|
|
| 1145 |
+ return s.getElementsByTagName(n.toLowerCase()); |
|
| 1146 |
+ }; |
|
| 1147 |
+ } else {
|
|
| 1148 |
+ function get(s, n) {
|
|
| 1149 |
+ return s.getElementsByTagName(n); |
|
| 1150 |
+ }; |
|
| 1151 |
+ } |
|
| 1152 |
+ |
|
| 1153 |
+ // Simple element pattern. For example: "p" or "*" |
|
| 1154 |
+ if (t.elmPattern.test(pa)) {
|
|
| 1155 |
+ x = get(s, pa); |
|
| 1156 |
+ |
|
| 1157 |
+ for (i = 0, l = x.length; i<l; i++) |
|
| 1158 |
+ o.push(x[i]); |
|
| 1159 |
+ |
|
| 1160 |
+ return o; |
|
| 1161 |
+ } |
|
| 1162 |
+ |
|
| 1163 |
+ // Simple class pattern. For example: "p.class" or ".class" |
|
| 1164 |
+ if (t.elmClassPattern.test(pa)) {
|
|
| 1165 |
+ pl = t.elmClassPattern.exec(pa); |
|
| 1166 |
+ x = get(s, pl[1] || '*'); |
|
| 1167 |
+ c = ' ' + pl[2] + ' '; |
|
| 1168 |
+ |
|
| 1169 |
+ for (i = 0, l = x.length; i<l; i++) {
|
|
| 1170 |
+ n = x[i]; |
|
| 1171 |
+ |
|
| 1172 |
+ if (n.className && (' ' + n.className + ' ').indexOf(c) !== -1)
|
|
| 1173 |
+ o.push(n); |
|
| 1174 |
+ } |
|
| 1175 |
+ |
|
| 1176 |
+ return o; |
|
| 1177 |
+ } |
|
| 1178 |
+ |
|
| 1179 |
+ function collect(n) {
|
|
| 1180 |
+ if (!n.mce_save) {
|
|
| 1181 |
+ n.mce_save = 1; |
|
| 1182 |
+ o.push(n); |
|
| 1183 |
+ } |
|
| 1184 |
+ }; |
|
| 1185 |
+ |
|
| 1186 |
+ function collectIE(n) {
|
|
| 1187 |
+ if (!n.getAttribute('mce_save')) {
|
|
| 1188 |
+ n.setAttribute('mce_save', '1');
|
|
| 1189 |
+ o.push(n); |
|
| 1190 |
+ } |
|
| 1191 |
+ }; |
|
| 1192 |
+ |
|
| 1193 |
+ function find(n, f, r) {
|
|
| 1194 |
+ var i, l, nl = get(r, n); |
|
| 1195 |
+ |
|
| 1196 |
+ for (i = 0, l = nl.length; i < l; i++) |
|
| 1197 |
+ f(nl[i]); |
|
| 1198 |
+ }; |
|
| 1199 |
+ |
|
| 1200 |
+ each(pa.split(','), function(v, i) {
|
|
| 1201 |
+ v = tinymce.trim(v); |
|
| 1202 |
+ |
|
| 1203 |
+ // Simple element pattern, most common in TinyMCE |
|
| 1204 |
+ if (t.elmPattern.test(v)) {
|
|
| 1205 |
+ each(get(s, v), function(n) {
|
|
| 1206 |
+ collect(n); |
|
| 1207 |
+ }); |
|
| 1208 |
+ |
|
| 1209 |
+ return; |
|
| 1210 |
+ } |
|
| 1211 |
+ |
|
| 1212 |
+ // Simple element pattern with class, fairly common in TinyMCE |
|
| 1213 |
+ if (t.elmClassPattern.test(v)) {
|
|
| 1214 |
+ x = t.elmClassPattern.exec(v); |
|
| 1215 |
+ |
|
| 1216 |
+ each(get(s, x[1]), function(n) {
|
|
| 1217 |
+ if (t.hasClass(n, x[2])) |
|
| 1218 |
+ collect(n); |
|
| 1219 |
+ }); |
|
| 1220 |
+ |
|
| 1221 |
+ return; |
|
| 1222 |
+ } |
|
| 1223 |
+ |
|
| 1224 |
+ if (!(cs = t.cache[pa])) {
|
|
| 1225 |
+ cs = 'x=(function(cf, s) {';
|
|
| 1226 |
+ pl = v.split(' ');
|
|
| 1227 |
+ |
|
| 1228 |
+ each(pl, function(v) {
|
|
| 1229 |
+ var p = /^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@([\w\\]+)([\^\$\*!]?=)([\w\\]+)\])?(?:\:([\w\\]+))?/i.exec(v); |
|
| 1230 |
+ |
|
| 1231 |
+ // Find elements |
|
| 1232 |
+ p[1] = p[1] || '*'; |
|
| 1233 |
+ cs += 'find("' + p[1] + '", function(n) {';
|
|
| 1234 |
+ |
|
| 1235 |
+ // Check id |
|
| 1236 |
+ if (p[2]) |
|
| 1237 |
+ cs += 'if (n.id !== "' + p[2] + '") return;'; |
|
| 1238 |
+ |
|
| 1239 |
+ // Check classes |
|
| 1240 |
+ if (p[3]) {
|
|
| 1241 |
+ cs += 'var c = " " + n.className + " ";'; |
|
| 1242 |
+ cs += 'if (';
|
|
| 1243 |
+ c = ''; |
|
| 1244 |
+ each(p[3].split('.'), function(v) {
|
|
| 1245 |
+ if (v) |
|
| 1246 |
+ c += (c ? '||' : '') + 'c.indexOf(" ' + v + ' ") === -1';
|
|
| 1247 |
+ }); |
|
| 1248 |
+ cs += c + ') return;'; |
|
| 1249 |
+ } |
|
| 1250 |
+ }); |
|
| 1251 |
+ |
|
| 1252 |
+ cs += 'cf(n);'; |
|
| 1253 |
+ |
|
| 1254 |
+ for (i = pl.length - 1; i >= 0; i--) |
|
| 1255 |
+ cs += '}, ' + (i ? 'n' : 's') + ');'; |
|
| 1256 |
+ |
|
| 1257 |
+ cs += '})'; |
|
| 1258 |
+ |
|
| 1259 |
+ // Compile CSS pattern function |
|
| 1260 |
+ t.cache[pa] = cs = eval(cs); |
|
| 1261 |
+ } |
|
| 1262 |
+ |
|
| 1263 |
+ // Run selector function |
|
| 1264 |
+ cs(isIE ? collectIE : collect, s); |
|
| 1265 |
+ }); |
|
| 1266 |
+ |
|
| 1267 |
+ // Cleanup |
|
| 1268 |
+ each(o, function(n) {
|
|
| 1269 |
+ if (isIE) |
|
| 1270 |
+ n.removeAttribute('mce_save');
|
|
| 1271 |
+ else |
|
| 1272 |
+ delete n.mce_save; |
|
| 1273 |
+ }); |
|
| 1274 |
+ |
|
| 1275 |
+ return o; |
|
| 1276 |
+ }, |
|
| 1277 |
+ |
|
| 1278 |
+ // #endif |
|
| 1279 |
+ |
|
| 1280 |
+ add : function(p, n, a, h, c) {
|
|
| 1281 |
+ var t = this; |
|
| 1282 |
+ |
|
| 1283 |
+ return this.run(p, function(p) {
|
|
| 1284 |
+ var e, k; |
|
| 1285 |
+ |
|
| 1286 |
+ e = is(n, 'string') ? t.doc.createElement(n) : n; |
|
| 1287 |
+ |
|
| 1288 |
+ if (a) {
|
|
| 1289 |
+ for (k in a) {
|
|
| 1290 |
+ if (a.hasOwnProperty(k) && !is(a[k], 'object')) |
|
| 1291 |
+ t.setAttrib(e, k, '' + a[k]); |
|
| 1292 |
+ } |
|
| 1293 |
+ |
|
| 1294 |
+ if (a.style && !is(a.style, 'string')) {
|
|
| 1295 |
+ each(a.style, function(v, n) {
|
|
| 1296 |
+ t.setStyle(e, n, v); |
|
| 1297 |
+ }); |
|
| 1298 |
+ } |
|
| 1299 |
+ } |
|
| 1300 |
+ |
|
| 1301 |
+ if (h) {
|
|
| 1302 |
+ if (h.nodeType) |
|
| 1303 |
+ e.appendChild(h); |
|
| 1304 |
+ else |
|
| 1305 |
+ t.setHTML(e, h); |
|
| 1306 |
+ } |
|
| 1307 |
+ |
|
| 1308 |
+ return !c ? p.appendChild(e) : e; |
|
| 1309 |
+ }); |
|
| 1310 |
+ }, |
|
| 1311 |
+ |
|
| 1312 |
+ create : function(n, a, h) {
|
|
| 1313 |
+ return this.add(this.doc.createElement(n), n, a, h, 1); |
|
| 1314 |
+ }, |
|
| 1315 |
+ |
|
| 1316 |
+ createHTML : function(n, a, h) {
|
|
| 1317 |
+ var o = '', t = this, k; |
|
| 1318 |
+ |
|
| 1319 |
+ o += '<' + n; |
|
| 1320 |
+ |
|
| 1321 |
+ for (k in a) {
|
|
| 1322 |
+ if (a.hasOwnProperty(k)) |
|
| 1323 |
+ o += ' ' + k + '="' + t.encode(a[k]) + '"'; |
|
| 1324 |
+ } |
|
| 1325 |
+ |
|
| 1326 |
+ if (tinymce.is(h)) |
|
| 1327 |
+ return o + '>' + h + '</' + n + '>'; |
|
| 1328 |
+ |
|
| 1329 |
+ return o + ' />'; |
|
| 1330 |
+ }, |
|
| 1331 |
+ |
|
| 1332 |
+ remove : function(n, k) {
|
|
| 1333 |
+ return this.run(n, function(n) {
|
|
| 1334 |
+ var p, g; |
|
| 1335 |
+ |
|
| 1336 |
+ p = n.parentNode; |
|
| 1337 |
+ |
|
| 1338 |
+ if (!p) |
|
| 1339 |
+ return null; |
|
| 1340 |
+ |
|
| 1341 |
+ if (k) {
|
|
| 1342 |
+ each (n.childNodes, function(c) {
|
|
| 1343 |
+ p.insertBefore(c.cloneNode(true), n); |
|
| 1344 |
+ }); |
|
| 1345 |
+ } |
|
| 1346 |
+ |
|
| 1347 |
+ // Fix IE psuedo leak |
|
| 1348 |
+ /* if (isIE) {
|
|
| 1349 |
+ p = n.cloneNode(true); |
|
| 1350 |
+ n.outerHTML = ''; |
|
| 1351 |
+ |
|
| 1352 |
+ return p; |
|
| 1353 |
+ }*/ |
|
| 1354 |
+ |
|
| 1355 |
+ return p.removeChild(n); |
|
| 1356 |
+ }); |
|
| 1357 |
+ }, |
|
| 1358 |
+ |
|
| 1359 |
+ // #if !jquery |
|
| 1360 |
+ |
|
| 1361 |
+ setStyle : function(n, na, v) {
|
|
| 1362 |
+ var t = this; |
|
| 1363 |
+ |
|
| 1364 |
+ return t.run(n, function(e) {
|
|
| 1365 |
+ var s, i; |
|
| 1366 |
+ |
|
| 1367 |
+ s = e.style; |
|
| 1368 |
+ |
|
| 1369 |
+ // Camelcase it, if needed |
|
| 1370 |
+ na = na.replace(/-(\D)/g, function(a, b){
|
|
| 1371 |
+ return b.toUpperCase(); |
|
| 1372 |
+ }); |
|
| 1373 |
+ |
|
| 1374 |
+ // Default px suffix on these |
|
| 1375 |
+ if (t.pixelStyles.test(na) && (tinymce.is(v, 'number') || /^[\-0-9\.]+$/.test(v))) |
|
| 1376 |
+ v += 'px'; |
|
| 1377 |
+ |
|
| 1378 |
+ switch (na) {
|
|
| 1379 |
+ case 'opacity': |
|
| 1380 |
+ // IE specific opacity |
|
| 1381 |
+ if (isIE) {
|
|
| 1382 |
+ s.filter = v === '' ? '' : "alpha(opacity=" + (v * 100) + ")"; |
|
| 1383 |
+ |
|
| 1384 |
+ if (!n.currentStyle || !n.currentStyle.hasLayout) |
|
| 1385 |
+ s.display = 'inline-block'; |
|
| 1386 |
+ } |
|
| 1387 |
+ |
|
| 1388 |
+ // Fix for older browsers |
|
| 1389 |
+ s[na] = s['-moz-opacity'] = s['-khtml-opacity'] = v || ''; |
|
| 1390 |
+ break; |
|
| 1391 |
+ |
|
| 1392 |
+ case 'float': |
|
| 1393 |
+ isIE ? s.styleFloat = v : s.cssFloat = v; |
|
| 1394 |
+ break; |
|
| 1395 |
+ |
|
| 1396 |
+ default: |
|
| 1397 |
+ s[na] = v || ''; |
|
| 1398 |
+ } |
|
| 1399 |
+ |
|
| 1400 |
+ // Force update of the style data |
|
| 1401 |
+ if (t.settings.update_styles) |
|
| 1402 |
+ t.setAttrib(e, 'mce_style'); |
|
| 1403 |
+ }); |
|
| 1404 |
+ }, |
|
| 1405 |
+ |
|
| 1406 |
+ getStyle : function(n, na, c) {
|
|
| 1407 |
+ n = this.get(n); |
|
| 1408 |
+ |
|
| 1409 |
+ if (!n) |
|
| 1410 |
+ return false; |
|
| 1411 |
+ |
|
| 1412 |
+ // Gecko |
|
| 1413 |
+ if (this.doc.defaultView && c) {
|
|
| 1414 |
+ // Remove camelcase |
|
| 1415 |
+ na = na.replace(/[A-Z]/g, function(a){
|
|
| 1416 |
+ return '-' + a; |
|
| 1417 |
+ }); |
|
| 1418 |
+ |
|
| 1419 |
+ try {
|
|
| 1420 |
+ return this.doc.defaultView.getComputedStyle(n, null).getPropertyValue(na); |
|
| 1421 |
+ } catch (ex) {
|
|
| 1422 |
+ // Old safari might fail |
|
| 1423 |
+ return null; |
|
| 1424 |
+ } |
|
| 1425 |
+ } |
|
| 1426 |
+ |
|
| 1427 |
+ // Camelcase it, if needed |
|
| 1428 |
+ na = na.replace(/-(\D)/g, function(a, b){
|
|
| 1429 |
+ return b.toUpperCase(); |
|
| 1430 |
+ }); |
|
| 1431 |
+ |
|
| 1432 |
+ if (na == 'float') |
|
| 1433 |
+ na = isIE ? 'styleFloat' : 'cssFloat'; |
|
| 1434 |
+ |
|
| 1435 |
+ // IE & Opera |
|
| 1436 |
+ if (n.currentStyle && c) |
|
| 1437 |
+ return n.currentStyle[na]; |
|
| 1438 |
+ |
|
| 1439 |
+ return n.style[na]; |
|
| 1440 |
+ }, |
|
| 1441 |
+ |
|
| 1442 |
+ setStyles : function(e, o) {
|
|
| 1443 |
+ var t = this, s = t.settings, ol; |
|
| 1444 |
+ |
|
| 1445 |
+ ol = s.update_styles; |
|
| 1446 |
+ s.update_styles = 0; |
|
| 1447 |
+ |
|
| 1448 |
+ each(o, function(v, n) {
|
|
| 1449 |
+ t.setStyle(e, n, v); |
|
| 1450 |
+ }); |
|
| 1451 |
+ |
|
| 1452 |
+ // Update style info |
|
| 1453 |
+ s.update_styles = ol; |
|
| 1454 |
+ if (s.update_styles) |
|
| 1455 |
+ t.setAttrib(e, s.cssText); |
|
| 1456 |
+ }, |
|
| 1457 |
+ |
|
| 1458 |
+ setAttrib : function(e, n, v) {
|
|
| 1459 |
+ var t = this; |
|
| 1460 |
+ |
|
| 1461 |
+ // Strict XML mode |
|
| 1462 |
+ if (t.settings.strict) |
|
| 1463 |
+ n = n.toLowerCase(); |
|
| 1464 |
+ |
|
| 1465 |
+ return this.run(e, function(e) {
|
|
| 1466 |
+ var s = t.settings; |
|
| 1467 |
+ |
|
| 1468 |
+ switch (n) {
|
|
| 1469 |
+ case "style": |
|
| 1470 |
+ // No mce_style for elements with these since they might get resized by the user |
|
| 1471 |
+ if (s.keep_values) {
|
|
| 1472 |
+ if (v && !t._isRes(v)) |
|
| 1473 |
+ e.setAttribute('mce_style', v, 2);
|
|
| 1474 |
+ else |
|
| 1475 |
+ e.removeAttribute('mce_style', 2);
|
|
| 1476 |
+ } |
|
| 1477 |
+ |
|
| 1478 |
+ e.style.cssText = v; |
|
| 1479 |
+ break; |
|
| 1480 |
+ |
|
| 1481 |
+ case "class": |
|
| 1482 |
+ e.className = v || ''; // Fix IE null bug |
|
| 1483 |
+ break; |
|
| 1484 |
+ |
|
| 1485 |
+ case "src": |
|
| 1486 |
+ case "href": |
|
| 1487 |
+ if (s.keep_values) {
|
|
| 1488 |
+ if (s.url_converter) |
|
| 1489 |
+ v = s.url_converter.call(s.url_converter_scope || t, v, n, e); |
|
| 1490 |
+ |
|
| 1491 |
+ t.setAttrib(e, 'mce_' + n, v, 2); |
|
| 1492 |
+ } |
|
| 1493 |
+ |
|
| 1494 |
+ break; |
|
| 1495 |
+ } |
|
| 1496 |
+ |
|
| 1497 |
+ if (is(v) && v !== null && v.length !== 0) |
|
| 1498 |
+ e.setAttribute(n, '' + v, 2); |
|
| 1499 |
+ else |
|
| 1500 |
+ e.removeAttribute(n, 2); |
|
| 1501 |
+ }); |
|
| 1502 |
+ }, |
|
| 1503 |
+ |
|
| 1504 |
+ setAttribs : function(e, o) {
|
|
| 1505 |
+ var t = this; |
|
| 1506 |
+ |
|
| 1507 |
+ return this.run(e, function(e) {
|
|
| 1508 |
+ each(o, function(v, n) {
|
|
| 1509 |
+ t.setAttrib(e, n, v); |
|
| 1510 |
+ }); |
|
| 1511 |
+ }); |
|
| 1512 |
+ }, |
|
| 1513 |
+ |
|
| 1514 |
+ // #endif |
|
| 1515 |
+ |
|
| 1516 |
+ getAttrib : function(e, n, dv) {
|
|
| 1517 |
+ var v, t = this; |
|
| 1518 |
+ |
|
| 1519 |
+ e = t.get(e); |
|
| 1520 |
+ |
|
| 1521 |
+ if (!e || e.nodeType !== 1) |
|
| 1522 |
+ return false; |
|
| 1523 |
+ |
|
| 1524 |
+ if (!is(dv)) |
|
| 1525 |
+ dv = ""; |
|
| 1526 |
+ |
|
| 1527 |
+ // Try the mce variant for these |
|
| 1528 |
+ if (/^(src|href|style|coords)$/.test(n)) {
|
|
| 1529 |
+ v = e.getAttribute("mce_" + n);
|
|
| 1530 |
+ |
|
| 1531 |
+ if (v) |
|
| 1532 |
+ return v; |
|
| 1533 |
+ } |
|
| 1534 |
+ |
|
| 1535 |
+ v = e.getAttribute(n, 2); |
|
| 1536 |
+ |
|
| 1537 |
+ if (!v) {
|
|
| 1538 |
+ switch (n) {
|
|
| 1539 |
+ case 'class': |
|
| 1540 |
+ v = e.className; |
|
| 1541 |
+ break; |
|
| 1542 |
+ |
|
| 1543 |
+ default: |
|
| 1544 |
+ // Fix for IE crash Bug: #1884376 probably due to invalid DOM structure |
|
| 1545 |
+ if (isIE && n === 'name' && e.nodeName === 'A') {
|
|
| 1546 |
+ v = e.name; |
|
| 1547 |
+ break; |
|
| 1548 |
+ } |
|
| 1549 |
+ |
|
| 1550 |
+ v = e.attributes[n]; |
|
| 1551 |
+ v = v && is(v.nodeValue) ? v.nodeValue : v; |
|
| 1552 |
+ } |
|
| 1553 |
+ } |
|
| 1554 |
+ |
|
| 1555 |
+ switch (n) {
|
|
| 1556 |
+ case 'style': |
|
| 1557 |
+ v = v || e.style.cssText; |
|
| 1558 |
+ |
|
| 1559 |
+ if (v) {
|
|
| 1560 |
+ v = t.serializeStyle(t.parseStyle(v)); |
|
| 1561 |
+ |
|
| 1562 |
+ if (t.settings.keep_values && !t._isRes(v)) |
|
| 1563 |
+ e.setAttribute('mce_style', v);
|
|
| 1564 |
+ } |
|
| 1565 |
+ |
|
| 1566 |
+ break; |
|
| 1567 |
+ } |
|
| 1568 |
+ |
|
| 1569 |
+ // Remove Apple and WebKit stuff |
|
| 1570 |
+ if (isWebKit && n === "class" && v) |
|
| 1571 |
+ v = v.replace(/(apple|webkit)\-[a-z\-]+/gi, ''); |
|
| 1572 |
+ |
|
| 1573 |
+ // Handle IE issues |
|
| 1574 |
+ if (isIE) {
|
|
| 1575 |
+ switch (n) {
|
|
| 1576 |
+ case 'rowspan': |
|
| 1577 |
+ case 'colspan': |
|
| 1578 |
+ // IE returns 1 as default value |
|
| 1579 |
+ if (v === 1) |
|
| 1580 |
+ v = ''; |
|
| 1581 |
+ |
|
| 1582 |
+ break; |
|
| 1583 |
+ |
|
| 1584 |
+ case 'size': |
|
| 1585 |
+ // IE returns +0 as default value for size |
|
| 1586 |
+ if (v === '+0') |
|
| 1587 |
+ v = ''; |
|
| 1588 |
+ |
|
| 1589 |
+ break; |
|
| 1590 |
+ |
|
| 1591 |
+ case 'hspace': |
|
| 1592 |
+ // IE returns -1 as default value |
|
| 1593 |
+ if (v === -1) |
|
| 1594 |
+ v = ''; |
|
| 1595 |
+ |
|
| 1596 |
+ break; |
|
| 1597 |
+ |
|
| 1598 |
+ case 'tabindex': |
|
| 1599 |
+ // IE returns 32768 as default value |
|
| 1600 |
+ if (v === 32768) |
|
| 1601 |
+ v = ''; |
|
| 1602 |
+ |
|
| 1603 |
+ break; |
|
| 1604 |
+ |
|
| 1605 |
+ case 'shape': |
|
| 1606 |
+ v = v.toLowerCase(); |
|
| 1607 |
+ break; |
|
| 1608 |
+ |
|
| 1609 |
+ default: |
|
| 1610 |
+ // IE has odd anonymous function for event attributes |
|
| 1611 |
+ if (n.indexOf('on') === 0 && v)
|
|
| 1612 |
+ v = ('' + v).replace(/^function\s+anonymous\(\)\s+\{\s+(.*)\s+\}$/, '$1');
|
|
| 1613 |
+ } |
|
| 1614 |
+ } |
|
| 1615 |
+ |
|
| 1616 |
+ return (v && v != '') ? '' + v : dv; |
|
| 1617 |
+ }, |
|
| 1618 |
+ |
|
| 1619 |
+ getPos : function(n) {
|
|
| 1620 |
+ var t = this, x = 0, y = 0, e, d = t.doc, r; |
|
| 1621 |
+ |
|
| 1622 |
+ n = t.get(n); |
|
| 1623 |
+ |
|
| 1624 |
+ // Use getBoundingClientRect on IE, Opera has it but it's not perfect |
|
| 1625 |
+ if (n && isIE) {
|
|
| 1626 |
+ n = n.getBoundingClientRect(); |
|
| 1627 |
+ e = t.boxModel ? d.documentElement : d.body; |
|
| 1628 |
+ x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border
|
|
| 1629 |
+ x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x; |
|
| 1630 |
+ n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset |
|
| 1631 |
+ |
|
| 1632 |
+ return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
|
|
| 1633 |
+ } |
|
| 1634 |
+ |
|
| 1635 |
+ r = n; |
|
| 1636 |
+ while (r) {
|
|
| 1637 |
+ x += r.offsetLeft || 0; |
|
| 1638 |
+ y += r.offsetTop || 0; |
|
| 1639 |
+ r = r.offsetParent; |
|
| 1640 |
+ } |
|
| 1641 |
+ |
|
| 1642 |
+ r = n; |
|
| 1643 |
+ while (r) {
|
|
| 1644 |
+ // Opera 9.25 bug fix, fixed in 9.50 |
|
| 1645 |
+ if (!/^table-row|inline.*/i.test(t.getStyle(r, "display", 1))) {
|
|
| 1646 |
+ x -= r.scrollLeft || 0; |
|
| 1647 |
+ y -= r.scrollTop || 0; |
|
| 1648 |
+ } |
|
| 1649 |
+ |
|
| 1650 |
+ r = r.parentNode; |
|
| 1651 |
+ |
|
| 1652 |
+ if (r == d.body) |
|
| 1653 |
+ break; |
|
| 1654 |
+ } |
|
| 1655 |
+ |
|
| 1656 |
+ return {x : x, y : y};
|
|
| 1657 |
+ }, |
|
| 1658 |
+ |
|
| 1659 |
+ parseStyle : function(st) {
|
|
| 1660 |
+ var t = this, s = t.settings, o = {};
|
|
| 1661 |
+ |
|
| 1662 |
+ if (!st) |
|
| 1663 |
+ return o; |
|
| 1664 |
+ |
|
| 1665 |
+ function compress(p, s, ot) {
|
|
| 1666 |
+ var t, r, b, l; |
|
| 1667 |
+ |
|
| 1668 |
+ // Get values and check it it needs compressing |
|
| 1669 |
+ t = o[p + '-top' + s]; |
|
| 1670 |
+ if (!t) |
|
| 1671 |
+ return; |
|
| 1672 |
+ |
|
| 1673 |
+ r = o[p + '-right' + s]; |
|
| 1674 |
+ if (t != r) |
|
| 1675 |
+ return; |
|
| 1676 |
+ |
|
| 1677 |
+ b = o[p + '-bottom' + s]; |
|
| 1678 |
+ if (r != b) |
|
| 1679 |
+ return; |
|
| 1680 |
+ |
|
| 1681 |
+ l = o[p + '-left' + s]; |
|
| 1682 |
+ if (b != l) |
|
| 1683 |
+ return; |
|
| 1684 |
+ |
|
| 1685 |
+ // Compress |
|
| 1686 |
+ o[ot] = l; |
|
| 1687 |
+ delete o[p + '-top' + s]; |
|
| 1688 |
+ delete o[p + '-right' + s]; |
|
| 1689 |
+ delete o[p + '-bottom' + s]; |
|
| 1690 |
+ delete o[p + '-left' + s]; |
|
| 1691 |
+ }; |
|
| 1692 |
+ |
|
| 1693 |
+ function compress2(ta, a, b, c) {
|
|
| 1694 |
+ var t; |
|
| 1695 |
+ |
|
| 1696 |
+ t = o[a]; |
|
| 1697 |
+ if (!t) |
|
| 1698 |
+ return; |
|
| 1699 |
+ |
|
| 1700 |
+ t = o[b]; |
|
| 1701 |
+ if (!t) |
|
| 1702 |
+ return; |
|
| 1703 |
+ |
|
| 1704 |
+ t = o[c]; |
|
| 1705 |
+ if (!t) |
|
| 1706 |
+ return; |
|
| 1707 |
+ |
|
| 1708 |
+ // Compress |
|
| 1709 |
+ o[ta] = o[a] + ' ' + o[b] + ' ' + o[c]; |
|
| 1710 |
+ delete o[a]; |
|
| 1711 |
+ delete o[b]; |
|
| 1712 |
+ delete o[c]; |
|
| 1713 |
+ }; |
|
| 1714 |
+ |
|
| 1715 |
+ each(st.split(';'), function(v) {
|
|
| 1716 |
+ var sv, ur = []; |
|
| 1717 |
+ |
|
| 1718 |
+ if (v) {
|
|
| 1719 |
+ v = v.replace(/url\([^\)]+\)/g, function(v) {ur.push(v);return 'url(' + ur.length + ')';});
|
|
| 1720 |
+ v = v.split(':');
|
|
| 1721 |
+ sv = tinymce.trim(v[1]); |
|
| 1722 |
+ sv = sv.replace(/url\(([^\)]+)\)/g, function(a, b) {return ur[parseInt(b) - 1];});
|
|
| 1723 |
+ |
|
| 1724 |
+ sv = sv.replace(/rgb\([^\)]+\)/g, function(v) {
|
|
| 1725 |
+ return t.toHex(v); |
|
| 1726 |
+ }); |
|
| 1727 |
+ |
|
| 1728 |
+ if (s.url_converter) {
|
|
| 1729 |
+ sv = sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g, function(x, c) {
|
|
| 1730 |
+ return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), 'style', null)) + ')';
|
|
| 1731 |
+ }); |
|
| 1732 |
+ } |
|
| 1733 |
+ |
|
| 1734 |
+ o[tinymce.trim(v[0]).toLowerCase()] = sv; |
|
| 1735 |
+ } |
|
| 1736 |
+ }); |
|
| 1737 |
+ |
|
| 1738 |
+ compress("border", "", "border");
|
|
| 1739 |
+ compress("border", "-width", "border-width");
|
|
| 1740 |
+ compress("border", "-color", "border-color");
|
|
| 1741 |
+ compress("border", "-style", "border-style");
|
|
| 1742 |
+ compress("padding", "", "padding");
|
|
| 1743 |
+ compress("margin", "", "margin");
|
|
| 1744 |
+ compress2('border', 'border-width', 'border-style', 'border-color');
|
|
| 1745 |
+ |
|
| 1746 |
+ if (isIE) {
|
|
| 1747 |
+ // Remove pointless border |
|
| 1748 |
+ if (o.border == 'medium none') |
|
| 1749 |
+ o.border = ''; |
|
| 1750 |
+ } |
|
| 1751 |
+ |
|
| 1752 |
+ return o; |
|
| 1753 |
+ }, |
|
| 1754 |
+ |
|
| 1755 |
+ serializeStyle : function(o) {
|
|
| 1756 |
+ var s = ''; |
|
| 1757 |
+ |
|
| 1758 |
+ each(o, function(v, k) {
|
|
| 1759 |
+ if (k && v) {
|
|
| 1760 |
+ switch (k) {
|
|
| 1761 |
+ case 'color': |
|
| 1762 |
+ case 'background-color': |
|
| 1763 |
+ v = v.toLowerCase(); |
|
| 1764 |
+ break; |
|
| 1765 |
+ } |
|
| 1766 |
+ |
|
| 1767 |
+ s += (s ? ' ' : '') + k + ': ' + v + ';'; |
|
| 1768 |
+ } |
|
| 1769 |
+ }); |
|
| 1770 |
+ |
|
| 1771 |
+ return s; |
|
| 1772 |
+ }, |
|
| 1773 |
+ |
|
| 1774 |
+ loadCSS : function(u) {
|
|
| 1775 |
+ var t = this, d = t.doc; |
|
| 1776 |
+ |
|
| 1777 |
+ if (!u) |
|
| 1778 |
+ u = ''; |
|
| 1779 |
+ |
|
| 1780 |
+ each(u.split(','), function(u) {
|
|
| 1781 |
+ if (t.files[u]) |
|
| 1782 |
+ return; |
|
| 1783 |
+ |
|
| 1784 |
+ t.files[u] = true; |
|
| 1785 |
+ t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : tinymce._addVer(u)});
|
|
| 1786 |
+ }); |
|
| 1787 |
+ }, |
|
| 1788 |
+ |
|
| 1789 |
+ // #if !jquery |
|
| 1790 |
+ |
|
| 1791 |
+ addClass : function(e, c) {
|
|
| 1792 |
+ return this.run(e, function(e) {
|
|
| 1793 |
+ var o; |
|
| 1794 |
+ |
|
| 1795 |
+ if (!c) |
|
| 1796 |
+ return 0; |
|
| 1797 |
+ |
|
| 1798 |
+ if (this.hasClass(e, c)) |
|
| 1799 |
+ return e.className; |
|
| 1800 |
+ |
|
| 1801 |
+ o = this.removeClass(e, c); |
|
| 1802 |
+ |
|
| 1803 |
+ return e.className = (o != '' ? (o + ' ') : '') + c; |
|
| 1804 |
+ }); |
|
| 1805 |
+ }, |
|
| 1806 |
+ |
|
| 1807 |
+ removeClass : function(e, c) {
|
|
| 1808 |
+ var t = this, re; |
|
| 1809 |
+ |
|
| 1810 |
+ return t.run(e, function(e) {
|
|
| 1811 |
+ var v; |
|
| 1812 |
+ |
|
| 1813 |
+ if (t.hasClass(e, c)) {
|
|
| 1814 |
+ if (!re) |
|
| 1815 |
+ re = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g");
|
|
| 1816 |
+ |
|
| 1817 |
+ v = e.className.replace(re, ' '); |
|
| 1818 |
+ |
|
| 1819 |
+ return e.className = tinymce.trim(v != ' ' ? v : ''); |
|
| 1820 |
+ } |
|
| 1821 |
+ |
|
| 1822 |
+ return e.className; |
|
| 1823 |
+ }); |
|
| 1824 |
+ }, |
|
| 1825 |
+ |
|
| 1826 |
+ hasClass : function(n, c) {
|
|
| 1827 |
+ n = this.get(n); |
|
| 1828 |
+ |
|
| 1829 |
+ if (!n || !c) |
|
| 1830 |
+ return false; |
|
| 1831 |
+ |
|
| 1832 |
+ return (' ' + n.className + ' ').indexOf(' ' + c + ' ') !== -1;
|
|
| 1833 |
+ }, |
|
| 1834 |
+ |
|
| 1835 |
+ show : function(e) {
|
|
| 1836 |
+ return this.setStyle(e, 'display', 'block'); |
|
| 1837 |
+ }, |
|
| 1838 |
+ |
|
| 1839 |
+ hide : function(e) {
|
|
| 1840 |
+ return this.setStyle(e, 'display', 'none'); |
|
| 1841 |
+ }, |
|
| 1842 |
+ |
|
| 1843 |
+ isHidden : function(e) {
|
|
| 1844 |
+ e = this.get(e); |
|
| 1845 |
+ |
|
| 1846 |
+ return e.style.display == 'none' || this.getStyle(e, 'display') == 'none'; |
|
| 1847 |
+ }, |
|
| 1848 |
+ |
|
| 1849 |
+ // #endif |
|
| 1850 |
+ |
|
| 1851 |
+ uniqueId : function(p) {
|
|
| 1852 |
+ return (!p ? 'mce_' : p) + (this.counter++); |
|
| 1853 |
+ }, |
|
| 1854 |
+ |
|
| 1855 |
+ setHTML : function(e, h) {
|
|
| 1856 |
+ var t = this; |
|
| 1857 |
+ |
|
| 1858 |
+ return this.run(e, function(e) {
|
|
| 1859 |
+ var x, i, nl, n, p, x; |
|
| 1860 |
+ |
|
| 1861 |
+ h = t.processHTML(h); |
|
| 1862 |
+ |
|
| 1863 |
+ if (isIE) {
|
|
| 1864 |
+ function set() {
|
|
| 1865 |
+ try {
|
|
| 1866 |
+ // IE will remove comments from the beginning |
|
| 1867 |
+ // unless you padd the contents with something |
|
| 1868 |
+ e.innerHTML = '<br />' + h; |
|
| 1869 |
+ e.removeChild(e.firstChild); |
|
| 1870 |
+ } catch (ex) {
|
|
| 1871 |
+ // IE sometimes produces an unknown runtime error on innerHTML if it's an block element within a block element for example a div inside a p |
|
| 1872 |
+ // This seems to fix this problem |
|
| 1873 |
+ |
|
| 1874 |
+ // Remove all child nodes |
|
| 1875 |
+ while (e.firstChild) |
|
| 1876 |
+ e.firstChild.removeNode(); |
|
| 1877 |
+ |
|
| 1878 |
+ // Create new div with HTML contents and a BR infront to keep comments |
|
| 1879 |
+ x = t.create('div');
|
|
| 1880 |
+ x.innerHTML = '<br />' + h; |
|
| 1881 |
+ |
|
| 1882 |
+ // Add all children from div to target |
|
| 1883 |
+ each (x.childNodes, function(n, i) {
|
|
| 1884 |
+ // Skip br element |
|
| 1885 |
+ if (i) |
|
| 1886 |
+ e.appendChild(n); |
|
| 1887 |
+ }); |
|
| 1888 |
+ } |
|
| 1889 |
+ }; |
|
| 1890 |
+ |
|
| 1891 |
+ // IE has a serious bug when it comes to paragraphs it can produce an invalid |
|
| 1892 |
+ // DOM tree if contents like this <p><ul><li>Item 1</li></ul></p> is inserted |
|
| 1893 |
+ // It seems to be that IE doesn't like a root block element placed inside another root block element |
|
| 1894 |
+ if (t.settings.fix_ie_paragraphs) |
|
| 1895 |
+ h = h.replace(/<p><\/p>|<p([^>]+)><\/p>|<p[^\/+]\/>/gi, '<p$1 mce_keep="true"> </p>'); |
|
| 1896 |
+ |
|
| 1897 |
+ set(); |
|
| 1898 |
+ |
|
| 1899 |
+ if (t.settings.fix_ie_paragraphs) {
|
|
| 1900 |
+ // Check for odd paragraphs this is a sign of a broken DOM |
|
| 1901 |
+ nl = e.getElementsByTagName("p");
|
|
| 1902 |
+ for (i = nl.length - 1, x = 0; i >= 0; i--) {
|
|
| 1903 |
+ n = nl[i]; |
|
| 1904 |
+ |
|
| 1905 |
+ if (!n.hasChildNodes()) {
|
|
| 1906 |
+ if (!n.mce_keep) {
|
|
| 1907 |
+ x = 1; // Is broken |
|
| 1908 |
+ break; |
|
| 1909 |
+ } |
|
| 1910 |
+ |
|
| 1911 |
+ n.removeAttribute('mce_keep');
|
|
| 1912 |
+ } |
|
| 1913 |
+ } |
|
| 1914 |
+ } |
|
| 1915 |
+ |
|
| 1916 |
+ // Time to fix the madness IE left us |
|
| 1917 |
+ if (x) {
|
|
| 1918 |
+ // So if we replace the p elements with divs and mark them and then replace them back to paragraphs |
|
| 1919 |
+ // after we use innerHTML we can fix the DOM tree |
|
| 1920 |
+ h = h.replace(/<p([^>]+)>|<p>/g, '<div$1 mce_tmp="1">'); |
|
| 1921 |
+ h = h.replace(/<\/p>/g, '</div>'); |
|
| 1922 |
+ |
|
| 1923 |
+ // Set the new HTML with DIVs |
|
| 1924 |
+ set(); |
|
| 1925 |
+ |
|
| 1926 |
+ // Replace all DIV elements with he mce_tmp attibute back to paragraphs |
|
| 1927 |
+ // This is needed since IE has a annoying bug see above for details |
|
| 1928 |
+ // This is a slow process but it has to be done. :( |
|
| 1929 |
+ if (t.settings.fix_ie_paragraphs) {
|
|
| 1930 |
+ nl = e.getElementsByTagName("DIV");
|
|
| 1931 |
+ for (i = nl.length - 1; i >= 0; i--) {
|
|
| 1932 |
+ n = nl[i]; |
|
| 1933 |
+ |
|
| 1934 |
+ // Is it a temp div |
|
| 1935 |
+ if (n.mce_tmp) {
|
|
| 1936 |
+ // Create new paragraph |
|
| 1937 |
+ p = t.doc.createElement('p');
|
|
| 1938 |
+ |
|
| 1939 |
+ // Copy all attributes |
|
| 1940 |
+ n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) {
|
|
| 1941 |
+ var v; |
|
| 1942 |
+ |
|
| 1943 |
+ if (b !== 'mce_tmp') {
|
|
| 1944 |
+ v = n.getAttribute(b); |
|
| 1945 |
+ |
|
| 1946 |
+ if (!v && b === 'class') |
|
| 1947 |
+ v = n.className; |
|
| 1948 |
+ |
|
| 1949 |
+ p.setAttribute(b, v); |
|
| 1950 |
+ } |
|
| 1951 |
+ }); |
|
| 1952 |
+ |
|
| 1953 |
+ // Append all children to new paragraph |
|
| 1954 |
+ for (x = 0; x<n.childNodes.length; x++) |
|
| 1955 |
+ p.appendChild(n.childNodes[x].cloneNode(true)); |
|
| 1956 |
+ |
|
| 1957 |
+ // Replace div with new paragraph |
|
| 1958 |
+ n.swapNode(p); |
|
| 1959 |
+ } |
|
| 1960 |
+ } |
|
| 1961 |
+ } |
|
| 1962 |
+ } |
|
| 1963 |
+ } else |
|
| 1964 |
+ e.innerHTML = h; |
|
| 1965 |
+ |
|
| 1966 |
+ return h; |
|
| 1967 |
+ }); |
|
| 1968 |
+ }, |
|
| 1969 |
+ |
|
| 1970 |
+ processHTML : function(h) {
|
|
| 1971 |
+ var t = this, s = t.settings; |
|
| 1972 |
+ |
|
| 1973 |
+ if (!s.process_html) |
|
| 1974 |
+ return h; |
|
| 1975 |
+ |
|
| 1976 |
+ // Convert strong and em to b and i in FF since it can't handle them |
|
| 1977 |
+ if (tinymce.isGecko) {
|
|
| 1978 |
+ h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>'); |
|
| 1979 |
+ h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>'); |
|
| 1980 |
+ } else if (isIE) |
|
| 1981 |
+ h = h.replace(/'/g, '''); // IE can't handle apos |
|
| 1982 |
+ |
|
| 1983 |
+ // Fix some issues |
|
| 1984 |
+ h = h.replace(/<a( )([^>]+)\/>|<a\/>/gi, '<a$1$2></a>'); // Force open |
|
| 1985 |
+ |
|
| 1986 |
+ // Store away src and href in mce_src and mce_href since browsers mess them up |
|
| 1987 |
+ if (s.keep_values) {
|
|
| 1988 |
+ // Wrap scripts in comments for serialization purposes |
|
| 1989 |
+ if (h.indexOf('<script') !== -1) {
|
|
| 1990 |
+ h = h.replace(/<script>/g, '<script type="text/javascript">'); |
|
| 1991 |
+ h = h.replace(/<script(|[^>]+)>(\s*<!--|\/\/\s*<\[CDATA\[)?[\r\n]*/g, '<mce:script$1><!--\n'); |
|
| 1992 |
+ h = h.replace(/\s*(\/\/\s*-->|\/\/\s*]]>)?<\/script>/g, '\n// --></mce:script>'); |
|
| 1993 |
+ h = h.replace(/<mce:script(|[^>]+)><!--\n\/\/ --><\/mce:script>/g, '<mce:script$1></mce:script>'); |
|
| 1994 |
+ } |
|
| 1995 |
+ |
|
| 1996 |
+ // Process all tags with src, href or style |
|
| 1997 |
+ h = h.replace(/<([\w:]+) [^>]*(src|href|style|coords)[^>]*>/gi, function(a, n) {
|
|
| 1998 |
+ function handle(m, b, c) {
|
|
| 1999 |
+ var u = c; |
|
| 2000 |
+ |
|
| 2001 |
+ // Tag already got a mce_ version |
|
| 2002 |
+ if (a.indexOf('mce_' + b) != -1)
|
|
| 2003 |
+ return m; |
|
| 2004 |
+ |
|
| 2005 |
+ if (b == 'style') {
|
|
| 2006 |
+ // Why did I need this one? |
|
| 2007 |
+ //if (isIE) |
|
| 2008 |
+ // u = t.serializeStyle(t.parseStyle(u)); |
|
| 2009 |
+ |
|
| 2010 |
+ // No mce_style for elements with these since they might get resized by the user |
|
| 2011 |
+ if (t._isRes(c)) |
|
| 2012 |
+ return m; |
|
| 2013 |
+ |
|
| 2014 |
+ if (s.hex_colors) {
|
|
| 2015 |
+ u = u.replace(/rgb\([^\)]+\)/g, function(v) {
|
|
| 2016 |
+ return t.toHex(v); |
|
| 2017 |
+ }); |
|
| 2018 |
+ } |
|
| 2019 |
+ |
|
| 2020 |
+ if (s.url_converter) {
|
|
| 2021 |
+ u = u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g, function(x, c) {
|
|
| 2022 |
+ return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)) + ')';
|
|
| 2023 |
+ }); |
|
| 2024 |
+ } |
|
| 2025 |
+ } else if (b != 'coords') {
|
|
| 2026 |
+ if (s.url_converter) |
|
| 2027 |
+ u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)); |
|
| 2028 |
+ } |
|
| 2029 |
+ |
|
| 2030 |
+ return ' ' + b + '="' + c + '" mce_' + b + '="' + u + '"'; |
|
| 2031 |
+ }; |
|
| 2032 |
+ |
|
| 2033 |
+ a = a.replace(/ (src|href|style|coords)=[\"]([^\"]+)[\"]/gi, handle); // W3C |
|
| 2034 |
+ a = a.replace(/ (src|href|style|coords)=[\']([^\']+)[\']/gi, handle); // W3C |
|
| 2035 |
+ |
|
| 2036 |
+ return a.replace(/ (src|href|style|coords)=([^\s\"\'>]+)/gi, handle); // IE |
|
| 2037 |
+ }); |
|
| 2038 |
+ } |
|
| 2039 |
+ |
|
| 2040 |
+ return h; |
|
| 2041 |
+ }, |
|
| 2042 |
+ |
|
| 2043 |
+ getOuterHTML : function(e) {
|
|
| 2044 |
+ var d; |
|
| 2045 |
+ |
|
| 2046 |
+ e = this.get(e); |
|
| 2047 |
+ |
|
| 2048 |
+ if (!e) |
|
| 2049 |
+ return null; |
|
| 2050 |
+ |
|
| 2051 |
+ if (isIE) |
|
| 2052 |
+ return e.outerHTML; |
|
| 2053 |
+ |
|
| 2054 |
+ d = (e.ownerDocument || this.doc).createElement("body");
|
|
| 2055 |
+ d.appendChild(e.cloneNode(true)); |
|
| 2056 |
+ |
|
| 2057 |
+ return d.innerHTML; |
|
| 2058 |
+ }, |
|
| 2059 |
+ |
|
| 2060 |
+ setOuterHTML : function(e, h, d) {
|
|
| 2061 |
+ var t = this; |
|
| 2062 |
+ |
|
| 2063 |
+ return this.run(e, function(e) {
|
|
| 2064 |
+ var n, tp; |
|
| 2065 |
+ |
|
| 2066 |
+ e = t.get(e); |
|
| 2067 |
+ d = d || e.ownerDocument || t.doc; |
|
| 2068 |
+ |
|
| 2069 |
+ if (isIE && e.nodeType == 1) |
|
| 2070 |
+ e.outerHTML = h; |
|
| 2071 |
+ else {
|
|
| 2072 |
+ tp = d.createElement("body");
|
|
| 2073 |
+ tp.innerHTML = h; |
|
| 2074 |
+ |
|
| 2075 |
+ n = tp.lastChild; |
|
| 2076 |
+ while (n) {
|
|
| 2077 |
+ t.insertAfter(n.cloneNode(true), e); |
|
| 2078 |
+ n = n.previousSibling; |
|
| 2079 |
+ } |
|
| 2080 |
+ |
|
| 2081 |
+ t.remove(e); |
|
| 2082 |
+ } |
|
| 2083 |
+ }); |
|
| 2084 |
+ }, |
|
| 2085 |
+ |
|
| 2086 |
+ decode : function(s) {
|
|
| 2087 |
+ var e; |
|
| 2088 |
+ |
|
| 2089 |
+ // Look for entities to decode |
|
| 2090 |
+ if (/&[^;]+;/.test(s)) {
|
|
| 2091 |
+ // Decode the entities using a div element not super efficient but less code |
|
| 2092 |
+ e = this.doc.createElement("div");
|
|
| 2093 |
+ e.innerHTML = s; |
|
| 2094 |
+ |
|
| 2095 |
+ return !e.firstChild ? s : e.firstChild.nodeValue; |
|
| 2096 |
+ } |
|
| 2097 |
+ |
|
| 2098 |
+ return s; |
|
| 2099 |
+ }, |
|
| 2100 |
+ |
|
| 2101 |
+ encode : function(s) {
|
|
| 2102 |
+ return s ? ('' + s).replace(/[<>&\"]/g, function (c, b) {
|
|
| 2103 |
+ switch (c) {
|
|
| 2104 |
+ case '&': |
|
| 2105 |
+ return '&'; |
|
| 2106 |
+ |
|
| 2107 |
+ case '"': |
|
| 2108 |
+ return '"'; |
|
| 2109 |
+ |
|
| 2110 |
+ case '<': |
|
| 2111 |
+ return '<'; |
|
| 2112 |
+ |
|
| 2113 |
+ case '>': |
|
| 2114 |
+ return '>'; |
|
| 2115 |
+ } |
|
| 2116 |
+ |
|
| 2117 |
+ return c; |
|
| 2118 |
+ }) : s; |
|
| 2119 |
+ }, |
|
| 2120 |
+ |
|
| 2121 |
+ // #if !jquery |
|
| 2122 |
+ |
|
| 2123 |
+ insertAfter : function(n, r) {
|
|
| 2124 |
+ var t = this; |
|
| 2125 |
+ |
|
| 2126 |
+ r = t.get(r); |
|
| 2127 |
+ |
|
| 2128 |
+ return this.run(n, function(n) {
|
|
| 2129 |
+ var p, ns; |
|
| 2130 |
+ |
|
| 2131 |
+ p = r.parentNode; |
|
| 2132 |
+ ns = r.nextSibling; |
|
| 2133 |
+ |
|
| 2134 |
+ if (ns) |
|
| 2135 |
+ p.insertBefore(n, ns); |
|
| 2136 |
+ else |
|
| 2137 |
+ p.appendChild(n); |
|
| 2138 |
+ |
|
| 2139 |
+ return n; |
|
| 2140 |
+ }); |
|
| 2141 |
+ }, |
|
| 2142 |
+ |
|
| 2143 |
+ // #endif |
|
| 2144 |
+ |
|
| 2145 |
+ isBlock : function(n) {
|
|
| 2146 |
+ if (n.nodeType && n.nodeType !== 1) |
|
| 2147 |
+ return false; |
|
| 2148 |
+ |
|
| 2149 |
+ n = n.nodeName || n; |
|
| 2150 |
+ |
|
| 2151 |
+ return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n); |
|
| 2152 |
+ }, |
|
| 2153 |
+ |
|
| 2154 |
+ // #if !jquery |
|
| 2155 |
+ |
|
| 2156 |
+ replace : function(n, o, k) {
|
|
| 2157 |
+ if (is(o, 'array')) |
|
| 2158 |
+ n = n.cloneNode(true); |
|
| 2159 |
+ |
|
| 2160 |
+ return this.run(o, function(o) {
|
|
| 2161 |
+ if (k) {
|
|
| 2162 |
+ each(o.childNodes, function(c) {
|
|
| 2163 |
+ n.appendChild(c.cloneNode(true)); |
|
| 2164 |
+ }); |
|
| 2165 |
+ } |
|
| 2166 |
+ |
|
| 2167 |
+ // Fix IE psuedo leak for elements since replacing elements if fairly common |
|
| 2168 |
+ // Will break parentNode for some unknown reason |
|
| 2169 |
+ /* if (isIE && o.nodeType === 1) {
|
|
| 2170 |
+ o.parentNode.insertBefore(n, o); |
|
| 2171 |
+ o.outerHTML = ''; |
|
| 2172 |
+ return n; |
|
| 2173 |
+ }*/ |
|
| 2174 |
+ |
|
| 2175 |
+ return o.parentNode.replaceChild(n, o); |
|
| 2176 |
+ }); |
|
| 2177 |
+ }, |
|
| 2178 |
+ |
|
| 2179 |
+ // #endif |
|
| 2180 |
+ |
|
| 2181 |
+ toHex : function(s) {
|
|
| 2182 |
+ var c = /^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s); |
|
| 2183 |
+ |
|
| 2184 |
+ function hex(s) {
|
|
| 2185 |
+ s = parseInt(s).toString(16); |
|
| 2186 |
+ |
|
| 2187 |
+ return s.length > 1 ? s : '0' + s; // 0 -> 00 |
|
| 2188 |
+ }; |
|
| 2189 |
+ |
|
| 2190 |
+ if (c) {
|
|
| 2191 |
+ s = '#' + hex(c[1]) + hex(c[2]) + hex(c[3]); |
|
| 2192 |
+ |
|
| 2193 |
+ return s; |
|
| 2194 |
+ } |
|
| 2195 |
+ |
|
| 2196 |
+ return s; |
|
| 2197 |
+ }, |
|
| 2198 |
+ |
|
| 2199 |
+ getClasses : function() {
|
|
| 2200 |
+ var t = this, cl = [], i, lo = {}, f = t.settings.class_filter, ov;
|
|
| 2201 |
+ |
|
| 2202 |
+ if (t.classes) |
|
| 2203 |
+ return t.classes; |
|
| 2204 |
+ |
|
| 2205 |
+ function addClasses(s) {
|
|
| 2206 |
+ // IE style imports |
|
| 2207 |
+ each(s.imports, function(r) {
|
|
| 2208 |
+ addClasses(r); |
|
| 2209 |
+ }); |
|
| 2210 |
+ |
|
| 2211 |
+ each(s.cssRules || s.rules, function(r) {
|
|
| 2212 |
+ // Real type or fake it on IE |
|
| 2213 |
+ switch (r.type || 1) {
|
|
| 2214 |
+ // Rule |
|
| 2215 |
+ case 1: |
|
| 2216 |
+ if (r.selectorText) {
|
|
| 2217 |
+ each(r.selectorText.split(','), function(v) {
|
|
| 2218 |
+ v = v.replace(/^\s*|\s*$|^\s\./g, ""); |
|
| 2219 |
+ |
|
| 2220 |
+ // Is internal or it doesn't contain a class |
|
| 2221 |
+ if (/\.mce/.test(v) || !/\.[\w\-]+$/.test(v)) |
|
| 2222 |
+ return; |
|
| 2223 |
+ |
|
| 2224 |
+ // Remove everything but class name |
|
| 2225 |
+ ov = v; |
|
| 2226 |
+ v = v.replace(/.*\.([a-z0-9_\-]+).*/i, '$1'); |
|
| 2227 |
+ |
|
| 2228 |
+ // Filter classes |
|
| 2229 |
+ if (f && !(v = f(v, ov))) |
|
| 2230 |
+ return; |
|
| 2231 |
+ |
|
| 2232 |
+ if (!lo[v]) {
|
|
| 2233 |
+ cl.push({'class' : v});
|
|
| 2234 |
+ lo[v] = 1; |
|
| 2235 |
+ } |
|
| 2236 |
+ }); |
|
| 2237 |
+ } |
|
| 2238 |
+ break; |
|
| 2239 |
+ |
|
| 2240 |
+ // Import |
|
| 2241 |
+ case 3: |
|
| 2242 |
+ addClasses(r.styleSheet); |
|
| 2243 |
+ break; |
|
| 2244 |
+ } |
|
| 2245 |
+ }); |
|
| 2246 |
+ }; |
|
| 2247 |
+ |
|
| 2248 |
+ try {
|
|
| 2249 |
+ each(t.doc.styleSheets, addClasses); |
|
| 2250 |
+ } catch (ex) {
|
|
| 2251 |
+ // Ignore |
|
| 2252 |
+ } |
|
| 2253 |
+ |
|
| 2254 |
+ if (cl.length > 0) |
|
| 2255 |
+ t.classes = cl; |
|
| 2256 |
+ |
|
| 2257 |
+ return cl; |
|
| 2258 |
+ }, |
|
| 2259 |
+ |
|
| 2260 |
+ run : function(e, f, s) {
|
|
| 2261 |
+ var t = this, o; |
|
| 2262 |
+ |
|
| 2263 |
+ if (t.doc && typeof(e) === 'string') |
|
| 2264 |
+ e = t.doc.getElementById(e); |
|
| 2265 |
+ |
|
| 2266 |
+ if (!e) |
|
| 2267 |
+ return false; |
|
| 2268 |
+ |
|
| 2269 |
+ s = s || this; |
|
| 2270 |
+ if (!e.nodeType && (e.length || e.length === 0)) {
|
|
| 2271 |
+ o = []; |
|
| 2272 |
+ |
|
| 2273 |
+ each(e, function(e, i) {
|
|
| 2274 |
+ if (e) {
|
|
| 2275 |
+ if (typeof(e) == 'string') |
|
| 2276 |
+ e = t.doc.getElementById(e); |
|
| 2277 |
+ |
|
| 2278 |
+ o.push(f.call(s, e, i)); |
|
| 2279 |
+ } |
|
| 2280 |
+ }); |
|
| 2281 |
+ |
|
| 2282 |
+ return o; |
|
| 2283 |
+ } |
|
| 2284 |
+ |
|
| 2285 |
+ return f.call(s, e); |
|
| 2286 |
+ }, |
|
| 2287 |
+ |
|
| 2288 |
+ getAttribs : function(n) {
|
|
| 2289 |
+ var o; |
|
| 2290 |
+ |
|
| 2291 |
+ n = this.get(n); |
|
| 2292 |
+ |
|
| 2293 |
+ if (!n) |
|
| 2294 |
+ return []; |
|
| 2295 |
+ |
|
| 2296 |
+ if (isIE) {
|
|
| 2297 |
+ o = []; |
|
| 2298 |
+ |
|
| 2299 |
+ // Object will throw exception in IE |
|
| 2300 |
+ if (n.nodeName == 'OBJECT') |
|
| 2301 |
+ return n.attributes; |
|
| 2302 |
+ |
|
| 2303 |
+ // It's crazy that this is faster in IE but it's because it returns all attributes all the time |
|
| 2304 |
+ n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
|
|
| 2305 |
+ o.push({specified : 1, nodeName : b});
|
|
| 2306 |
+ }); |
|
| 2307 |
+ |
|
| 2308 |
+ return o; |
|
| 2309 |
+ } |
|
| 2310 |
+ |
|
| 2311 |
+ return n.attributes; |
|
| 2312 |
+ }, |
|
| 2313 |
+ |
|
| 2314 |
+ destroy : function(s) {
|
|
| 2315 |
+ var t = this; |
|
| 2316 |
+ |
|
| 2317 |
+ t.win = t.doc = t.root = null; |
|
| 2318 |
+ |
|
| 2319 |
+ // Manual destroy then remove unload handler |
|
| 2320 |
+ if (!s) |
|
| 2321 |
+ tinymce.removeUnload(t.destroy); |
|
| 2322 |
+ }, |
|
| 2323 |
+ |
|
| 2324 |
+ _isRes : function(c) {
|
|
| 2325 |
+ // Is live resizble element |
|
| 2326 |
+ return /^(top|left|bottom|right|width|height)/i.test(c) || /;\s*(top|left|bottom|right|width|height)/i.test(c); |
|
| 2327 |
+ } |
|
| 2328 |
+ |
|
| 2329 |
+ /* |
|
| 2330 |
+ walk : function(n, f, s) {
|
|
| 2331 |
+ var d = this.doc, w; |
|
| 2332 |
+ |
|
| 2333 |
+ if (d.createTreeWalker) {
|
|
| 2334 |
+ w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false); |
|
| 2335 |
+ |
|
| 2336 |
+ while ((n = w.nextNode()) != null) |
|
| 2337 |
+ f.call(s || this, n); |
|
| 2338 |
+ } else |
|
| 2339 |
+ tinymce.walk(n, f, 'childNodes', s); |
|
| 2340 |
+ } |
|
| 2341 |
+ */ |
|
| 2342 |
+ |
|
| 2343 |
+ /* |
|
| 2344 |
+ toRGB : function(s) {
|
|
| 2345 |
+ var c = /^\s*?#([0-9A-F]{2})([0-9A-F]{1,2})([0-9A-F]{2})?\s*?$/.exec(s);
|
|
| 2346 |
+ |
|
| 2347 |
+ if (c) {
|
|
| 2348 |
+ // #FFF -> #FFFFFF |
|
| 2349 |
+ if (!is(c[3])) |
|
| 2350 |
+ c[3] = c[2] = c[1]; |
|
| 2351 |
+ |
|
| 2352 |
+ return "rgb(" + parseInt(c[1], 16) + "," + parseInt(c[2], 16) + "," + parseInt(c[3], 16) + ")";
|
|
| 2353 |
+ } |
|
| 2354 |
+ |
|
| 2355 |
+ return s; |
|
| 2356 |
+ } |
|
| 2357 |
+ */ |
|
| 2358 |
+ |
|
| 2359 |
+ }); |
|
| 2360 |
+ |
|
| 2361 |
+ // Setup page DOM |
|
| 2362 |
+ tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0});
|
|
| 2363 |
+})(); |
|
| 2364 |
+ |
|
| 2365 |
+/* file:jscripts/tiny_mce/classes/dom/Event.js */ |
|
| 2366 |
+ |
|
| 2367 |
+(function() {
|
|
| 2368 |
+ // Shorten names |
|
| 2369 |
+ var each = tinymce.each, DOM = tinymce.DOM, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit, Event; |
|
| 2370 |
+ |
|
| 2371 |
+ tinymce.create('static tinymce.dom.Event', {
|
|
| 2372 |
+ inits : [], |
|
| 2373 |
+ events : [], |
|
| 2374 |
+ |
|
| 2375 |
+ // #if !jquery |
|
| 2376 |
+ |
|
| 2377 |
+ add : function(o, n, f, s) {
|
|
| 2378 |
+ var cb, t = this, el = t.events, r; |
|
| 2379 |
+ |
|
| 2380 |
+ // Handle array |
|
| 2381 |
+ if (o && o instanceof Array) {
|
|
| 2382 |
+ r = []; |
|
| 2383 |
+ |
|
| 2384 |
+ each(o, function(o) {
|
|
| 2385 |
+ o = DOM.get(o); |
|
| 2386 |
+ r.push(t.add(o, n, f, s)); |
|
| 2387 |
+ }); |
|
| 2388 |
+ |
|
| 2389 |
+ return r; |
|
| 2390 |
+ } |
|
| 2391 |
+ |
|
| 2392 |
+ o = DOM.get(o); |
|
| 2393 |
+ |
|
| 2394 |
+ if (!o) |
|
| 2395 |
+ return; |
|
| 2396 |
+ |
|
| 2397 |
+ // Setup event callback |
|
| 2398 |
+ cb = function(e) {
|
|
| 2399 |
+ e = e || window.event; |
|
| 2400 |
+ |
|
| 2401 |
+ // Patch in target in IE it's W3C valid |
|
| 2402 |
+ if (e && !e.target && isIE) |
|
| 2403 |
+ e.target = e.srcElement; |
|
| 2404 |
+ |
|
| 2405 |
+ if (!s) |
|
| 2406 |
+ return f(e); |
|
| 2407 |
+ |
|
| 2408 |
+ return f.call(s, e); |
|
| 2409 |
+ }; |
|
| 2410 |
+ |
|
| 2411 |
+ if (n == 'unload') {
|
|
| 2412 |
+ tinymce.unloads.unshift({func : cb});
|
|
| 2413 |
+ return cb; |
|
| 2414 |
+ } |
|
| 2415 |
+ |
|
| 2416 |
+ if (n == 'init') {
|
|
| 2417 |
+ if (t.domLoaded) |
|
| 2418 |
+ cb(); |
|
| 2419 |
+ else |
|
| 2420 |
+ t.inits.push(cb); |
|
| 2421 |
+ |
|
| 2422 |
+ return cb; |
|
| 2423 |
+ } |
|
| 2424 |
+ |
|
| 2425 |
+ // Store away listener reference |
|
| 2426 |
+ el.push({
|
|
| 2427 |
+ obj : o, |
|
| 2428 |
+ name : n, |
|
| 2429 |
+ func : f, |
|
| 2430 |
+ cfunc : cb, |
|
| 2431 |
+ scope : s |
|
| 2432 |
+ }); |
|
| 2433 |
+ |
|
| 2434 |
+ t._add(o, n, cb); |
|
| 2435 |
+ |
|
| 2436 |
+ return f; |
|
| 2437 |
+ }, |
|
| 2438 |
+ |
|
| 2439 |
+ remove : function(o, n, f) {
|
|
| 2440 |
+ var t = this, a = t.events, s = false, r; |
|
| 2441 |
+ |
|
| 2442 |
+ // Handle array |
|
| 2443 |
+ if (o && o instanceof Array) {
|
|
| 2444 |
+ r = []; |
|
| 2445 |
+ |
|
| 2446 |
+ each(o, function(o) {
|
|
| 2447 |
+ o = DOM.get(o); |
|
| 2448 |
+ r.push(t.remove(o, n, f)); |
|
| 2449 |
+ }); |
|
| 2450 |
+ |
|
| 2451 |
+ return r; |
|
| 2452 |
+ } |
|
| 2453 |
+ |
|
| 2454 |
+ o = DOM.get(o); |
|
| 2455 |
+ |
|
| 2456 |
+ each(a, function(e, i) {
|
|
| 2457 |
+ if (e.obj == o && e.name == n && (!f || (e.func == f || e.cfunc == f))) {
|
|
| 2458 |
+ a.splice(i, 1); |
|
| 2459 |
+ t._remove(o, n, e.cfunc); |
|
| 2460 |
+ s = true; |
|
| 2461 |
+ return false; |
|
| 2462 |
+ } |
|
| 2463 |
+ }); |
|
| 2464 |
+ |
|
| 2465 |
+ return s; |
|
| 2466 |
+ }, |
|
| 2467 |
+ |
|
| 2468 |
+ clear : function(o) {
|
|
| 2469 |
+ var t = this, a = t.events, i, e; |
|
| 2470 |
+ |
|
| 2471 |
+ if (o) {
|
|
| 2472 |
+ o = DOM.get(o); |
|
| 2473 |
+ |
|
| 2474 |
+ for (i = a.length - 1; i >= 0; i--) {
|
|
| 2475 |
+ e = a[i]; |
|
| 2476 |
+ |
|
| 2477 |
+ if (e.obj === o) {
|
|
| 2478 |
+ t._remove(e.obj, e.name, e.cfunc); |
|
| 2479 |
+ e.obj = e.cfunc = null; |
|
| 2480 |
+ a.splice(i, 1); |
|
| 2481 |
+ } |
|
| 2482 |
+ } |
|
| 2483 |
+ } |
|
| 2484 |
+ }, |
|
| 2485 |
+ |
|
| 2486 |
+ // #endif |
|
| 2487 |
+ |
|
| 2488 |
+ cancel : function(e) {
|
|
| 2489 |
+ if (!e) |
|
| 2490 |
+ return false; |
|
| 2491 |
+ |
|
| 2492 |
+ this.stop(e); |
|
| 2493 |
+ return this.prevent(e); |
|
| 2494 |
+ }, |
|
| 2495 |
+ |
|
| 2496 |
+ stop : function(e) {
|
|
| 2497 |
+ if (e.stopPropagation) |
|
| 2498 |
+ e.stopPropagation(); |
|
| 2499 |
+ else |
|
| 2500 |
+ e.cancelBubble = true; |
|
| 2501 |
+ |
|
| 2502 |
+ return false; |
|
| 2503 |
+ }, |
|
| 2504 |
+ |
|
| 2505 |
+ prevent : function(e) {
|
|
| 2506 |
+ if (e.preventDefault) |
|
| 2507 |
+ e.preventDefault(); |
|
| 2508 |
+ else |
|
| 2509 |
+ e.returnValue = false; |
|
| 2510 |
+ |
|
| 2511 |
+ return false; |
|
| 2512 |
+ }, |
|
| 2513 |
+ |
|
| 2514 |
+ _unload : function() {
|
|
| 2515 |
+ var t = Event; |
|
| 2516 |
+ |
|
| 2517 |
+ each(t.events, function(e, i) {
|
|
| 2518 |
+ t._remove(e.obj, e.name, e.cfunc); |
|
| 2519 |
+ e.obj = e.cfunc = null; |
|
| 2520 |
+ }); |
|
| 2521 |
+ |
|
| 2522 |
+ t.events = []; |
|
| 2523 |
+ t = null; |
|
| 2524 |
+ }, |
|
| 2525 |
+ |
|
| 2526 |
+ _add : function(o, n, f) {
|
|
| 2527 |
+ if (o.attachEvent) |
|
| 2528 |
+ o.attachEvent('on' + n, f);
|
|
| 2529 |
+ else if (o.addEventListener) |
|
| 2530 |
+ o.addEventListener(n, f, false); |
|
| 2531 |
+ else |
|
| 2532 |
+ o['on' + n] = f; |
|
| 2533 |
+ }, |
|
| 2534 |
+ |
|
| 2535 |
+ _remove : function(o, n, f) {
|
|
| 2536 |
+ if (o) {
|
|
| 2537 |
+ try {
|
|
| 2538 |
+ if (o.detachEvent) |
|
| 2539 |
+ o.detachEvent('on' + n, f);
|
|
| 2540 |
+ else if (o.removeEventListener) |
|
| 2541 |
+ o.removeEventListener(n, f, false); |
|
| 2542 |
+ else |
|
| 2543 |
+ o['on' + n] = null; |
|
| 2544 |
+ } catch (ex) {
|
|
| 2545 |
+ // Might fail with permission denined on IE so we just ignore that |
|
| 2546 |
+ } |
|
| 2547 |
+ } |
|
| 2548 |
+ }, |
|
| 2549 |
+ |
|
| 2550 |
+ _pageInit : function() {
|
|
| 2551 |
+ var e = Event; |
|
| 2552 |
+ |
|
| 2553 |
+ e._remove(window, 'DOMContentLoaded', e._pageInit); |
|
| 2554 |
+ e.domLoaded = true; |
|
| 2555 |
+ |
|
| 2556 |
+ each(e.inits, function(c) {
|
|
| 2557 |
+ c(); |
|
| 2558 |
+ }); |
|
| 2559 |
+ |
|
| 2560 |
+ e.inits = []; |
|
| 2561 |
+ }, |
|
| 2562 |
+ |
|
| 2563 |
+ _wait : function() {
|
|
| 2564 |
+ var t; |
|
| 2565 |
+ |
|
| 2566 |
+ // No need since the document is already loaded |
|
| 2567 |
+ if (window.tinyMCE_GZ && tinyMCE_GZ.loaded) {
|
|
| 2568 |
+ Event.domLoaded = 1; |
|
| 2569 |
+ return; |
|
| 2570 |
+ } |
|
| 2571 |
+ |
|
| 2572 |
+ if (isIE && document.location.protocol != 'https:') {
|
|
| 2573 |
+ // Fake DOMContentLoaded on IE |
|
| 2574 |
+ document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
|
|
| 2575 |
+ DOM.get("__ie_onload").onreadystatechange = function() {
|
|
| 2576 |
+ if (this.readyState == "complete") {
|
|
| 2577 |
+ Event._pageInit(); |
|
| 2578 |
+ DOM.get("__ie_onload").onreadystatechange = null; // Prevent leak
|
|
| 2579 |
+ } |
|
| 2580 |
+ }; |
|
| 2581 |
+ } else {
|
|
| 2582 |
+ Event._add(window, 'DOMContentLoaded', Event._pageInit, Event); |
|
| 2583 |
+ |
|
| 2584 |
+ if (isIE || isWebKit) {
|
|
| 2585 |
+ t = setInterval(function() {
|
|
| 2586 |
+ if (/loaded|complete/.test(document.readyState)) {
|
|
| 2587 |
+ clearInterval(t); |
|
| 2588 |
+ Event._pageInit(); |
|
| 2589 |
+ } |
|
| 2590 |
+ }, 10); |
|
| 2591 |
+ } |
|
| 2592 |
+ } |
|
| 2593 |
+ } |
|
| 2594 |
+ |
|
| 2595 |
+ }); |
|
| 2596 |
+ |
|
| 2597 |
+ // Shorten name |
|
| 2598 |
+ Event = tinymce.dom.Event; |
|
| 2599 |
+ |
|
| 2600 |
+ // Dispatch DOM content loaded event for IE and Safari |
|
| 2601 |
+ Event._wait(); |
|
| 2602 |
+ tinymce.addUnload(Event._unload); |
|
| 2603 |
+})(); |
|
| 2604 |
+ |
|
| 2605 |
+/* file:jscripts/tiny_mce/classes/dom/Element.js */ |
|
| 2606 |
+ |
|
| 2607 |
+(function() {
|
|
| 2608 |
+ var each = tinymce.each; |
|
| 2609 |
+ |
|
| 2610 |
+ tinymce.create('tinymce.dom.Element', {
|
|
| 2611 |
+ Element : function(id, s) {
|
|
| 2612 |
+ var t = this, dom, el; |
|
| 2613 |
+ |
|
| 2614 |
+ s = s || {};
|
|
| 2615 |
+ t.id = id; |
|
| 2616 |
+ t.dom = dom = s.dom || tinymce.DOM; |
|
| 2617 |
+ t.settings = s; |
|
| 2618 |
+ |
|
| 2619 |
+ // Only IE leaks DOM references, this is a lot faster |
|
| 2620 |
+ if (!tinymce.isIE) |
|
| 2621 |
+ el = t.dom.get(t.id); |
|
| 2622 |
+ |
|
| 2623 |
+ each([ |
|
| 2624 |
+ 'getPos', |
|
| 2625 |
+ 'getRect', |
|
| 2626 |
+ 'getParent', |
|
| 2627 |
+ 'add', |
|
| 2628 |
+ 'setStyle', |
|
| 2629 |
+ 'getStyle', |
|
| 2630 |
+ 'setStyles', |
|
| 2631 |
+ 'setAttrib', |
|
| 2632 |
+ 'setAttribs', |
|
| 2633 |
+ 'getAttrib', |
|
| 2634 |
+ 'addClass', |
|
| 2635 |
+ 'removeClass', |
|
| 2636 |
+ 'hasClass', |
|
| 2637 |
+ 'getOuterHTML', |
|
| 2638 |
+ 'setOuterHTML', |
|
| 2639 |
+ 'remove', |
|
| 2640 |
+ 'show', |
|
| 2641 |
+ 'hide', |
|
| 2642 |
+ 'isHidden', |
|
| 2643 |
+ 'setHTML', |
|
| 2644 |
+ 'get' |
|
| 2645 |
+ ], function(k) {
|
|
| 2646 |
+ t[k] = function() {
|
|
| 2647 |
+ var a = arguments, o; |
|
| 2648 |
+ |
|
| 2649 |
+ // Opera fails |
|
| 2650 |
+ if (tinymce.isOpera) {
|
|
| 2651 |
+ a = [id]; |
|
| 2652 |
+ |
|
| 2653 |
+ each(arguments, function(v) {
|
|
| 2654 |
+ a.push(v); |
|
| 2655 |
+ }); |
|
| 2656 |
+ } else |
|
| 2657 |
+ Array.prototype.unshift.call(a, el || id); |
|
| 2658 |
+ |
|
| 2659 |
+ o = dom[k].apply(dom, a); |
|
| 2660 |
+ t.update(k); |
|
| 2661 |
+ |
|
| 2662 |
+ return o; |
|
| 2663 |
+ }; |
|
| 2664 |
+ }); |
|
| 2665 |
+ }, |
|
| 2666 |
+ |
|
| 2667 |
+ on : function(n, f, s) {
|
|
| 2668 |
+ return tinymce.dom.Event.add(this.id, n, f, s); |
|
| 2669 |
+ }, |
|
| 2670 |
+ |
|
| 2671 |
+ getXY : function() {
|
|
| 2672 |
+ return {
|
|
| 2673 |
+ x : parseInt(this.getStyle('left')),
|
|
| 2674 |
+ y : parseInt(this.getStyle('top'))
|
|
| 2675 |
+ }; |
|
| 2676 |
+ }, |
|
| 2677 |
+ |
|
| 2678 |
+ getSize : function() {
|
|
| 2679 |
+ var n = this.dom.get(this.id); |
|
| 2680 |
+ |
|
| 2681 |
+ return {
|
|
| 2682 |
+ w : parseInt(this.getStyle('width') || n.clientWidth),
|
|
| 2683 |
+ h : parseInt(this.getStyle('height') || n.clientHeight)
|
|
| 2684 |
+ }; |
|
| 2685 |
+ }, |
|
| 2686 |
+ |
|
| 2687 |
+ moveTo : function(x, y) {
|
|
| 2688 |
+ this.setStyles({left : x, top : y});
|
|
| 2689 |
+ }, |
|
| 2690 |
+ |
|
| 2691 |
+ moveBy : function(x, y) {
|
|
| 2692 |
+ var p = this.getXY(); |
|
| 2693 |
+ |
|
| 2694 |
+ this.moveTo(p.x + x, p.y + y); |
|
| 2695 |
+ }, |
|
| 2696 |
+ |
|
| 2697 |
+ resizeTo : function(w, h) {
|
|
| 2698 |
+ this.setStyles({width : w, height : h});
|
|
| 2699 |
+ }, |
|
| 2700 |
+ |
|
| 2701 |
+ resizeBy : function(w, h) {
|
|
| 2702 |
+ var s = this.getSize(); |
|
| 2703 |
+ |
|
| 2704 |
+ this.resizeTo(s.w + w, s.h + h); |
|
| 2705 |
+ }, |
|
| 2706 |
+ |
|
| 2707 |
+ update : function(k) {
|
|
| 2708 |
+ var t = this, b, dom = t.dom; |
|
| 2709 |
+ |
|
| 2710 |
+ if (tinymce.isIE6 && t.settings.blocker) {
|
|
| 2711 |
+ k = k || ''; |
|
| 2712 |
+ |
|
| 2713 |
+ // Ignore getters |
|
| 2714 |
+ if (k.indexOf('get') === 0 || k.indexOf('has') === 0 || k.indexOf('is') === 0)
|
|
| 2715 |
+ return; |
|
| 2716 |
+ |
|
| 2717 |
+ // Remove blocker on remove |
|
| 2718 |
+ if (k == 'remove') {
|
|
| 2719 |
+ dom.remove(t.blocker); |
|
| 2720 |
+ return; |
|
| 2721 |
+ } |
|
| 2722 |
+ |
|
| 2723 |
+ if (!t.blocker) {
|
|
| 2724 |
+ t.blocker = dom.uniqueId(); |
|
| 2725 |
+ b = dom.add(t.settings.container || dom.getRoot(), 'iframe', {id : t.blocker, style : 'position:absolute;', frameBorder : 0, src : 'javascript:""'});
|
|
| 2726 |
+ dom.setStyle(b, 'opacity', 0); |
|
| 2727 |
+ } else |
|
| 2728 |
+ b = dom.get(t.blocker); |
|
| 2729 |
+ |
|
| 2730 |
+ dom.setStyle(b, 'left', t.getStyle('left', 1));
|
|
| 2731 |
+ dom.setStyle(b, 'top', t.getStyle('top', 1));
|
|
| 2732 |
+ dom.setStyle(b, 'width', t.getStyle('width', 1));
|
|
| 2733 |
+ dom.setStyle(b, 'height', t.getStyle('height', 1));
|
|
| 2734 |
+ dom.setStyle(b, 'display', t.getStyle('display', 1));
|
|
| 2735 |
+ dom.setStyle(b, 'zIndex', parseInt(t.getStyle('zIndex', 1) || 0) - 1);
|
|
| 2736 |
+ } |
|
| 2737 |
+ } |
|
| 2738 |
+ |
|
| 2739 |
+ }); |
|
| 2740 |
+})(); |
|
| 2741 |
+ |
|
| 2742 |
+/* file:jscripts/tiny_mce/classes/dom/Selection.js */ |
|
| 2743 |
+ |
|
| 2744 |
+(function() {
|
|
| 2745 |
+ function trimNl(s) {
|
|
| 2746 |
+ return s.replace(/[\n\r]+/g, ''); |
|
| 2747 |
+ }; |
|
| 2748 |
+ |
|
| 2749 |
+ // Shorten names |
|
| 2750 |
+ var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each; |
|
| 2751 |
+ |
|
| 2752 |
+ tinymce.create('tinymce.dom.Selection', {
|
|
| 2753 |
+ Selection : function(dom, win, serializer) {
|
|
| 2754 |
+ var t = this; |
|
| 2755 |
+ |
|
| 2756 |
+ t.dom = dom; |
|
| 2757 |
+ t.win = win; |
|
| 2758 |
+ t.serializer = serializer; |
|
| 2759 |
+ |
|
| 2760 |
+ // Prevent leaks |
|
| 2761 |
+ tinymce.addUnload(t.destroy, t); |
|
| 2762 |
+ }, |
|
| 2763 |
+ |
|
| 2764 |
+ getContent : function(s) {
|
|
| 2765 |
+ var t = this, r = t.getRng(), e = t.dom.create("body"), se = t.getSel(), wb, wa, n;
|
|
| 2766 |
+ |
|
| 2767 |
+ s = s || {};
|
|
| 2768 |
+ wb = wa = ''; |
|
| 2769 |
+ s.get = true; |
|
| 2770 |
+ s.format = s.format || 'html'; |
|
| 2771 |
+ |
|
| 2772 |
+ if (s.format == 'text') |
|
| 2773 |
+ return t.isCollapsed() ? '' : (r.text || (se.toString ? se.toString() : '')); |
|
| 2774 |
+ |
|
| 2775 |
+ if (r.cloneContents) {
|
|
| 2776 |
+ n = r.cloneContents(); |
|
| 2777 |
+ |
|
| 2778 |
+ if (n) |
|
| 2779 |
+ e.appendChild(n); |
|
| 2780 |
+ } else if (is(r.item) || is(r.htmlText)) |
|
| 2781 |
+ e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText; |
|
| 2782 |
+ else |
|
| 2783 |
+ e.innerHTML = r.toString(); |
|
| 2784 |
+ |
|
| 2785 |
+ // Keep whitespace before and after |
|
| 2786 |
+ if (/^\s/.test(e.innerHTML)) |
|
| 2787 |
+ wb = ' '; |
|
| 2788 |
+ |
|
| 2789 |
+ if (/\s+$/.test(e.innerHTML)) |
|
| 2790 |
+ wa = ' '; |
|
| 2791 |
+ |
|
| 2792 |
+ s.getInner = true; |
|
| 2793 |
+ |
|
| 2794 |
+ return t.isCollapsed() ? '' : wb + t.serializer.serialize(e, s) + wa; |
|
| 2795 |
+ }, |
|
| 2796 |
+ |
|
| 2797 |
+ setContent : function(h, s) {
|
|
| 2798 |
+ var t = this, r = t.getRng(), d = t.win.document; |
|
| 2799 |
+ |
|
| 2800 |
+ s = s || {format : 'html'};
|
|
| 2801 |
+ s.set = true; |
|
| 2802 |
+ h = t.dom.processHTML(h); |
|
| 2803 |
+ |
|
| 2804 |
+ if (r.insertNode) {
|
|
| 2805 |
+ // Gecko has a bug where if you insert using InsertHTML it will insert a space instead |
|
| 2806 |
+ // So we simply check if the input is HTML or text and then insert text using the insertNode method |
|
| 2807 |
+ if (tinymce.isGecko && h.indexOf('<') == -1) {
|
|
| 2808 |
+ r.deleteContents(); |
|
| 2809 |
+ r.insertNode(t.getRng().createContextualFragment(h + '<span id="__caret">_</span>')); |
|
| 2810 |
+ t.select(t.dom.get('__caret'));
|
|
| 2811 |
+ t.getRng().deleteContents(); |
|
| 2812 |
+ return; |
|
| 2813 |
+ } |
|
| 2814 |
+ |
|
| 2815 |
+ // Use insert HTML if it exists (places cursor after content) |
|
| 2816 |
+ try {
|
|
| 2817 |
+ // This might fail with an exception see bug #1893736 |
|
| 2818 |
+ if (d.queryCommandEnabled('InsertHTML'))
|
|
| 2819 |
+ return d.execCommand('InsertHTML', false, h);
|
|
| 2820 |
+ } catch (ex) {
|
|
| 2821 |
+ // Use old school method |
|
| 2822 |
+ r.deleteContents(); |
|
| 2823 |
+ r.insertNode(t.getRng().createContextualFragment(h)); |
|
| 2824 |
+ } |
|
| 2825 |
+ } else {
|
|
| 2826 |
+ if (r.item) {
|
|
| 2827 |
+ // Delete content and get caret text selection |
|
| 2828 |
+ d.execCommand('Delete', false, null);
|
|
| 2829 |
+ r = t.getRng(); |
|
| 2830 |
+ } |
|
| 2831 |
+ |
|
| 2832 |
+ r.pasteHTML(h); |
|
| 2833 |
+ } |
|
| 2834 |
+ }, |
|
| 2835 |
+ |
|
| 2836 |
+ getStart : function() {
|
|
| 2837 |
+ var t = this, r = t.getRng(), e; |
|
| 2838 |
+ |
|
| 2839 |
+ if (isIE) {
|
|
| 2840 |
+ if (r.item) |
|
| 2841 |
+ return r.item(0); |
|
| 2842 |
+ |
|
| 2843 |
+ r = r.duplicate(); |
|
| 2844 |
+ r.collapse(1); |
|
| 2845 |
+ e = r.parentElement(); |
|
| 2846 |
+ |
|
| 2847 |
+ if (e && e.nodeName == 'BODY') |
|
| 2848 |
+ return e.firstChild; |
|
| 2849 |
+ |
|
| 2850 |
+ return e; |
|
| 2851 |
+ } else {
|
|
| 2852 |
+ e = r.startContainer; |
|
| 2853 |
+ |
|
| 2854 |
+ if (e.nodeName == 'BODY') |
|
| 2855 |
+ return e.firstChild; |
|
| 2856 |
+ |
|
| 2857 |
+ return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
|
|
| 2858 |
+ } |
|
| 2859 |
+ }, |
|
| 2860 |
+ |
|
| 2861 |
+ getEnd : function() {
|
|
| 2862 |
+ var t = this, r = t.getRng(), e; |
|
| 2863 |
+ |
|
| 2864 |
+ if (isIE) {
|
|
| 2865 |
+ if (r.item) |
|
| 2866 |
+ return r.item(0); |
|
| 2867 |
+ |
|
| 2868 |
+ r = r.duplicate(); |
|
| 2869 |
+ r.collapse(0); |
|
| 2870 |
+ e = r.parentElement(); |
|
| 2871 |
+ |
|
| 2872 |
+ if (e && e.nodeName == 'BODY') |
|
| 2873 |
+ return e.lastChild; |
|
| 2874 |
+ |
|
| 2875 |
+ return e; |
|
| 2876 |
+ } else {
|
|
| 2877 |
+ e = r.endContainer; |
|
| 2878 |
+ |
|
| 2879 |
+ if (e.nodeName == 'BODY') |
|
| 2880 |
+ return e.lastChild; |
|
| 2881 |
+ |
|
| 2882 |
+ return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
|
|
| 2883 |
+ } |
|
| 2884 |
+ }, |
|
| 2885 |
+ |
|
| 2886 |
+ getBookmark : function(si) {
|
|
| 2887 |
+ var t = this, r = t.getRng(), tr, sx, sy, vp = t.dom.getViewPort(t.win), e, sp, bp, le, c = -0xFFFFFF, s, ro = t.dom.getRoot(), wb = 0, wa = 0, nv; |
|
| 2888 |
+ sx = vp.x; |
|
| 2889 |
+ sy = vp.y; |
|
| 2890 |
+ |
|
| 2891 |
+ // Simple bookmark fast but not as persistent |
|
| 2892 |
+ if (si == 'simple') |
|
| 2893 |
+ return {rng : r, scrollX : sx, scrollY : sy};
|
|
| 2894 |
+ |
|
| 2895 |
+ // Handle IE |
|
| 2896 |
+ if (isIE) {
|
|
| 2897 |
+ // Control selection |
|
| 2898 |
+ if (r.item) {
|
|
| 2899 |
+ e = r.item(0); |
|
| 2900 |
+ |
|
| 2901 |
+ each(t.dom.select(e.nodeName), function(n, i) {
|
|
| 2902 |
+ if (e == n) {
|
|
| 2903 |
+ sp = i; |
|
| 2904 |
+ return false; |
|
| 2905 |
+ } |
|
| 2906 |
+ }); |
|
| 2907 |
+ |
|
| 2908 |
+ return {
|
|
| 2909 |
+ tag : e.nodeName, |
|
| 2910 |
+ index : sp, |
|
| 2911 |
+ scrollX : sx, |
|
| 2912 |
+ scrollY : sy |
|
| 2913 |
+ }; |
|
| 2914 |
+ } |
|
| 2915 |
+ |
|
| 2916 |
+ // Text selection |
|
| 2917 |
+ tr = t.dom.doc.body.createTextRange(); |
|
| 2918 |
+ tr.moveToElementText(ro); |
|
| 2919 |
+ tr.collapse(true); |
|
| 2920 |
+ bp = Math.abs(tr.move('character', c));
|
|
| 2921 |
+ |
|
| 2922 |
+ tr = r.duplicate(); |
|
| 2923 |
+ tr.collapse(true); |
|
| 2924 |
+ sp = Math.abs(tr.move('character', c));
|
|
| 2925 |
+ |
|
| 2926 |
+ tr = r.duplicate(); |
|
| 2927 |
+ tr.collapse(false); |
|
| 2928 |
+ le = Math.abs(tr.move('character', c)) - sp;
|
|
| 2929 |
+ |
|
| 2930 |
+ return {
|
|
| 2931 |
+ start : sp - bp, |
|
| 2932 |
+ length : le, |
|
| 2933 |
+ scrollX : sx, |
|
| 2934 |
+ scrollY : sy |
|
| 2935 |
+ }; |
|
| 2936 |
+ } |
|
| 2937 |
+ |
|
| 2938 |
+ // Handle W3C |
|
| 2939 |
+ e = t.getNode(); |
|
| 2940 |
+ s = t.getSel(); |
|
| 2941 |
+ |
|
| 2942 |
+ if (!s) |
|
| 2943 |
+ return null; |
|
| 2944 |
+ |
|
| 2945 |
+ // Image selection |
|
| 2946 |
+ if (e && e.nodeName == 'IMG') {
|
|
| 2947 |
+ return {
|
|
| 2948 |
+ scrollX : sx, |
|
| 2949 |
+ scrollY : sy |
|
| 2950 |
+ }; |
|
| 2951 |
+ } |
|
| 2952 |
+ |
|
| 2953 |
+ // Text selection |
|
| 2954 |
+ |
|
| 2955 |
+ function getPos(r, sn, en) {
|
|
| 2956 |
+ var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
|
|
| 2957 |
+ |
|
| 2958 |
+ while ((n = w.nextNode()) != null) {
|
|
| 2959 |
+ if (n == sn) |
|
| 2960 |
+ d.start = p; |
|
| 2961 |
+ |
|
| 2962 |
+ if (n == en) {
|
|
| 2963 |
+ d.end = p; |
|
| 2964 |
+ return d; |
|
| 2965 |
+ } |
|
| 2966 |
+ |
|
| 2967 |
+ p += trimNl(n.nodeValue || '').length; |
|
| 2968 |
+ } |
|
| 2969 |
+ |
|
| 2970 |
+ return null; |
|
| 2971 |
+ }; |
|
| 2972 |
+ |
|
| 2973 |
+ // Caret or selection |
|
| 2974 |
+ if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
|
|
| 2975 |
+ e = getPos(ro, s.anchorNode, s.focusNode); |
|
| 2976 |
+ |
|
| 2977 |
+ if (!e) |
|
| 2978 |
+ return {scrollX : sx, scrollY : sy};
|
|
| 2979 |
+ |
|
| 2980 |
+ // Count whitespace before |
|
| 2981 |
+ trimNl(s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
|
|
| 2982 |
+ |
|
| 2983 |
+ return {
|
|
| 2984 |
+ start : Math.max(e.start + s.anchorOffset - wb, 0), |
|
| 2985 |
+ end : Math.max(e.end + s.focusOffset - wb, 0), |
|
| 2986 |
+ scrollX : sx, |
|
| 2987 |
+ scrollY : sy, |
|
| 2988 |
+ beg : s.anchorOffset - wb == 0 |
|
| 2989 |
+ }; |
|
| 2990 |
+ } else {
|
|
| 2991 |
+ e = getPos(ro, r.startContainer, r.endContainer); |
|
| 2992 |
+ |
|
| 2993 |
+ // Count whitespace before start and end container |
|
| 2994 |
+ //(r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
|
|
| 2995 |
+ //(r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;});
|
|
| 2996 |
+ |
|
| 2997 |
+ if (!e) |
|
| 2998 |
+ return {scrollX : sx, scrollY : sy};
|
|
| 2999 |
+ |
|
| 3000 |
+ return {
|
|
| 3001 |
+ start : Math.max(e.start + r.startOffset - wb, 0), |
|
| 3002 |
+ end : Math.max(e.end + r.endOffset - wa, 0), |
|
| 3003 |
+ scrollX : sx, |
|
| 3004 |
+ scrollY : sy, |
|
| 3005 |
+ beg : r.startOffset - wb == 0 |
|
| 3006 |
+ }; |
|
| 3007 |
+ } |
|
| 3008 |
+ }, |
|
| 3009 |
+ |
|
| 3010 |
+ moveToBookmark : function(b) {
|
|
| 3011 |
+ var t = this, r = t.getRng(), s = t.getSel(), ro = t.dom.getRoot(), sd, nvl, nv; |
|
| 3012 |
+ |
|
| 3013 |
+ function getPos(r, sp, ep) {
|
|
| 3014 |
+ var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}, o, v, wa, wb;
|
|
| 3015 |
+ |
|
| 3016 |
+ while ((n = w.nextNode()) != null) {
|
|
| 3017 |
+ wa = wb = 0; |
|
| 3018 |
+ |
|
| 3019 |
+ nv = n.nodeValue || ''; |
|
| 3020 |
+ //nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;});
|
|
| 3021 |
+ //nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;});
|
|
| 3022 |
+ |
|
| 3023 |
+ nvl = trimNl(nv).length; |
|
| 3024 |
+ p += nvl; |
|
| 3025 |
+ |
|
| 3026 |
+ if (p >= sp && !d.startNode) {
|
|
| 3027 |
+ o = sp - (p - nvl); |
|
| 3028 |
+ |
|
| 3029 |
+ // Fix for odd quirk in FF |
|
| 3030 |
+ if (b.beg && o >= nvl) |
|
| 3031 |
+ continue; |
|
| 3032 |
+ |
|
| 3033 |
+ d.startNode = n; |
|
| 3034 |
+ d.startOffset = o + wb; |
|
| 3035 |
+ } |
|
| 3036 |
+ |
|
| 3037 |
+ if (p >= ep) {
|
|
| 3038 |
+ d.endNode = n; |
|
| 3039 |
+ d.endOffset = ep - (p - nvl) + wb; |
|
| 3040 |
+ return d; |
|
| 3041 |
+ } |
|
| 3042 |
+ } |
|
| 3043 |
+ |
|
| 3044 |
+ return null; |
|
| 3045 |
+ }; |
|
| 3046 |
+ |
|
| 3047 |
+ if (!b) |
|
| 3048 |
+ return false; |
|
| 3049 |
+ |
|
| 3050 |
+ t.win.scrollTo(b.scrollX, b.scrollY); |
|
| 3051 |
+ |
|
| 3052 |
+ // Handle explorer |
|
| 3053 |
+ if (isIE) {
|
|
| 3054 |
+ // Handle simple |
|
| 3055 |
+ if (r = b.rng) {
|
|
| 3056 |
+ try {
|
|
| 3057 |
+ r.select(); |
|
| 3058 |
+ } catch (ex) {
|
|
| 3059 |
+ // Ignore |
|
| 3060 |
+ } |
|
| 3061 |
+ |
|
| 3062 |
+ return true; |
|
| 3063 |
+ } |
|
| 3064 |
+ |
|
| 3065 |
+ t.win.focus(); |
|
| 3066 |
+ |
|
| 3067 |
+ // Handle control bookmark |
|
| 3068 |
+ if (b.tag) {
|
|
| 3069 |
+ r = ro.createControlRange(); |
|
| 3070 |
+ |
|
| 3071 |
+ each(t.dom.select(b.tag), function(n, i) {
|
|
| 3072 |
+ if (i == b.index) |
|
| 3073 |
+ r.addElement(n); |
|
| 3074 |
+ }); |
|
| 3075 |
+ } else {
|
|
| 3076 |
+ // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs |
|
| 3077 |
+ try {
|
|
| 3078 |
+ // Incorrect bookmark |
|
| 3079 |
+ if (b.start < 0) |
|
| 3080 |
+ return true; |
|
| 3081 |
+ |
|
| 3082 |
+ r = s.createRange(); |
|
| 3083 |
+ r.moveToElementText(ro); |
|
| 3084 |
+ r.collapse(true); |
|
| 3085 |
+ r.moveStart('character', b.start);
|
|
| 3086 |
+ r.moveEnd('character', b.length);
|
|
| 3087 |
+ } catch (ex2) {
|
|
| 3088 |
+ return true; |
|
| 3089 |
+ } |
|
| 3090 |
+ } |
|
| 3091 |
+ |
|
| 3092 |
+ try {
|
|
| 3093 |
+ r.select(); |
|
| 3094 |
+ } catch (ex) {
|
|
| 3095 |
+ // Needed for some odd IE bug #1843306 |
|
| 3096 |
+ } |
|
| 3097 |
+ |
|
| 3098 |
+ return true; |
|
| 3099 |
+ } |
|
| 3100 |
+ |
|
| 3101 |
+ // Handle W3C |
|
| 3102 |
+ if (!s) |
|
| 3103 |
+ return false; |
|
| 3104 |
+ |
|
| 3105 |
+ // Handle simple |
|
| 3106 |
+ if (b.rng) {
|
|
| 3107 |
+ s.removeAllRanges(); |
|
| 3108 |
+ s.addRange(b.rng); |
|
| 3109 |
+ } else {
|
|
| 3110 |
+ if (is(b.start) && is(b.end)) {
|
|
| 3111 |
+ try {
|
|
| 3112 |
+ sd = getPos(ro, b.start, b.end); |
|
| 3113 |
+ |
|
| 3114 |
+ if (sd) {
|
|
| 3115 |
+ r = t.dom.doc.createRange(); |
|
| 3116 |
+ r.setStart(sd.startNode, sd.startOffset); |
|
| 3117 |
+ r.setEnd(sd.endNode, sd.endOffset); |
|
| 3118 |
+ s.removeAllRanges(); |
|
| 3119 |
+ s.addRange(r); |
|
| 3120 |
+ } |
|
| 3121 |
+ |
|
| 3122 |
+ if (!tinymce.isOpera) |
|
| 3123 |
+ t.win.focus(); |
|
| 3124 |
+ } catch (ex) {
|
|
| 3125 |
+ // Ignore |
|
| 3126 |
+ } |
|
| 3127 |
+ } |
|
| 3128 |
+ } |
|
| 3129 |
+ }, |
|
| 3130 |
+ |
|
| 3131 |
+ select : function(n, c) {
|
|
| 3132 |
+ var t = this, r = t.getRng(), s = t.getSel(), b, fn, ln, d = t.win.document; |
|
| 3133 |
+ |
|
| 3134 |
+ function first(n) {
|
|
| 3135 |
+ return n ? d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() : null; |
|
| 3136 |
+ }; |
|
| 3137 |
+ |
|
| 3138 |
+ function last(n) {
|
|
| 3139 |
+ var c, o, w; |
|
| 3140 |
+ |
|
| 3141 |
+ if (!n) |
|
| 3142 |
+ return null; |
|
| 3143 |
+ |
|
| 3144 |
+ w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false); |
|
| 3145 |
+ while (c = w.nextNode()) |
|
| 3146 |
+ o = c; |
|
| 3147 |
+ |
|
| 3148 |
+ return o; |
|
| 3149 |
+ }; |
|
| 3150 |
+ |
|
| 3151 |
+ if (isIE) {
|
|
| 3152 |
+ try {
|
|
| 3153 |
+ b = d.body; |
|
| 3154 |
+ |
|
| 3155 |
+ if (/^(IMG|TABLE)$/.test(n.nodeName)) {
|
|
| 3156 |
+ r = b.createControlRange(); |
|
| 3157 |
+ r.addElement(n); |
|
| 3158 |
+ } else {
|
|
| 3159 |
+ r = b.createTextRange(); |
|
| 3160 |
+ r.moveToElementText(n); |
|
| 3161 |
+ } |
|
| 3162 |
+ |
|
| 3163 |
+ r.select(); |
|
| 3164 |
+ } catch (ex) {
|
|
| 3165 |
+ // Throws illigal agrument in IE some times |
|
| 3166 |
+ } |
|
| 3167 |
+ } else {
|
|
| 3168 |
+ if (c) {
|
|
| 3169 |
+ fn = first(n); |
|
| 3170 |
+ ln = last(n); |
|
| 3171 |
+ |
|
| 3172 |
+ if (fn && ln) {
|
|
| 3173 |
+ //console.debug(fn, ln); |
|
| 3174 |
+ r = d.createRange(); |
|
| 3175 |
+ r.setStart(fn, 0); |
|
| 3176 |
+ r.setEnd(ln, ln.nodeValue.length); |
|
| 3177 |
+ } else |
|
| 3178 |
+ r.selectNode(n); |
|
| 3179 |
+ } else |
|
| 3180 |
+ r.selectNode(n); |
|
| 3181 |
+ |
|
| 3182 |
+ t.setRng(r); |
|
| 3183 |
+ } |
|
| 3184 |
+ |
|
| 3185 |
+ return n; |
|
| 3186 |
+ }, |
|
| 3187 |
+ |
|
| 3188 |
+ isCollapsed : function() {
|
|
| 3189 |
+ var t = this, r = t.getRng(), s = t.getSel(); |
|
| 3190 |
+ |
|
| 3191 |
+ if (!r || r.item) |
|
| 3192 |
+ return false; |
|
| 3193 |
+ |
|
| 3194 |
+ return !s || r.boundingWidth == 0 || s.isCollapsed; |
|
| 3195 |
+ }, |
|
| 3196 |
+ |
|
| 3197 |
+ collapse : function(b) {
|
|
| 3198 |
+ var t = this, r = t.getRng(), n; |
|
| 3199 |
+ |
|
| 3200 |
+ // Control range on IE |
|
| 3201 |
+ if (r.item) {
|
|
| 3202 |
+ n = r.item(0); |
|
| 3203 |
+ r = this.win.document.body.createTextRange(); |
|
| 3204 |
+ r.moveToElementText(n); |
|
| 3205 |
+ } |
|
| 3206 |
+ |
|
| 3207 |
+ r.collapse(!!b); |
|
| 3208 |
+ t.setRng(r); |
|
| 3209 |
+ }, |
|
| 3210 |
+ |
|
| 3211 |
+ getSel : function() {
|
|
| 3212 |
+ var t = this, w = this.win; |
|
| 3213 |
+ |
|
| 3214 |
+ return w.getSelection ? w.getSelection() : w.document.selection; |
|
| 3215 |
+ }, |
|
| 3216 |
+ |
|
| 3217 |
+ getRng : function() {
|
|
| 3218 |
+ var t = this, s = t.getSel(), r; |
|
| 3219 |
+ |
|
| 3220 |
+ try {
|
|
| 3221 |
+ if (s) |
|
| 3222 |
+ r = s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : t.win.document.createRange()); |
|
| 3223 |
+ } catch (ex) {
|
|
| 3224 |
+ // IE throws unspecified error here if TinyMCE is placed in a frame/iframe |
|
| 3225 |
+ } |
|
| 3226 |
+ |
|
| 3227 |
+ // No range found then create an empty one |
|
| 3228 |
+ // This can occur when the editor is placed in a hidden container element on Gecko |
|
| 3229 |
+ // Or on IE when there was an exception |
|
| 3230 |
+ if (!r) |
|
| 3231 |
+ r = isIE ? t.win.document.body.createTextRange() : t.win.document.createRange(); |
|
| 3232 |
+ |
|
| 3233 |
+ return r; |
|
| 3234 |
+ }, |
|
| 3235 |
+ |
|
| 3236 |
+ setRng : function(r) {
|
|
| 3237 |
+ var s; |
|
| 3238 |
+ |
|
| 3239 |
+ if (!isIE) {
|
|
| 3240 |
+ s = this.getSel(); |
|
| 3241 |
+ |
|
| 3242 |
+ if (s) {
|
|
| 3243 |
+ s.removeAllRanges(); |
|
| 3244 |
+ s.addRange(r); |
|
| 3245 |
+ } |
|
| 3246 |
+ } else {
|
|
| 3247 |
+ try {
|
|
| 3248 |
+ r.select(); |
|
| 3249 |
+ } catch (ex) {
|
|
| 3250 |
+ // Needed for some odd IE bug #1843306 |
|
| 3251 |
+ } |
|
| 3252 |
+ } |
|
| 3253 |
+ }, |
|
| 3254 |
+ |
|
| 3255 |
+ setNode : function(n) {
|
|
| 3256 |
+ var t = this; |
|
| 3257 |
+ |
|
| 3258 |
+ t.setContent(t.dom.getOuterHTML(n)); |
|
| 3259 |
+ |
|
| 3260 |
+ return n; |
|
| 3261 |
+ }, |
|
| 3262 |
+ |
|
| 3263 |
+ getNode : function() {
|
|
| 3264 |
+ var t = this, r = t.getRng(), s = t.getSel(), e; |
|
| 3265 |
+ |
|
| 3266 |
+ if (!isIE) {
|
|
| 3267 |
+ // Range maybe lost after the editor is made visible again |
|
| 3268 |
+ if (!r) |
|
| 3269 |
+ return t.dom.getRoot(); |
|
| 3270 |
+ |
|
| 3271 |
+ e = r.commonAncestorContainer; |
|
| 3272 |
+ |
|
| 3273 |
+ // Handle selection a image or other control like element such as anchors |
|
| 3274 |
+ if (!r.collapsed) {
|
|
| 3275 |
+ if (r.startContainer == r.endContainer || (tinymce.isWebKit && r.startContainer == r.endContainer.parentNode)) {
|
|
| 3276 |
+ if (r.startOffset - r.endOffset < 2 || tinymce.isWebKit) {
|
|
| 3277 |
+ if (r.startContainer.hasChildNodes()) |
|
| 3278 |
+ e = r.startContainer.childNodes[r.startOffset]; |
|
| 3279 |
+ } |
|
| 3280 |
+ } |
|
| 3281 |
+ } |
|
| 3282 |
+ |
|
| 3283 |
+ return t.dom.getParent(e, function(n) {
|
|
| 3284 |
+ return n.nodeType == 1; |
|
| 3285 |
+ }); |
|
| 3286 |
+ } |
|
| 3287 |
+ |
|
| 3288 |
+ return r.item ? r.item(0) : r.parentElement(); |
|
| 3289 |
+ }, |
|
| 3290 |
+ |
|
| 3291 |
+ destroy : function(s) {
|
|
| 3292 |
+ var t = this; |
|
| 3293 |
+ |
|
| 3294 |
+ t.win = null; |
|
| 3295 |
+ |
|
| 3296 |
+ // Manual destroy then remove unload handler |
|
| 3297 |
+ if (!s) |
|
| 3298 |
+ tinymce.removeUnload(t.destroy); |
|
| 3299 |
+ } |
|
| 3300 |
+ |
|
| 3301 |
+ }); |
|
| 3302 |
+})(); |
|
| 3303 |
+ |
|
| 3304 |
+/* file:jscripts/tiny_mce/classes/dom/XMLWriter.js */ |
|
| 3305 |
+ |
|
| 3306 |
+(function() {
|
|
| 3307 |
+ tinymce.create('tinymce.dom.XMLWriter', {
|
|
| 3308 |
+ node : null, |
|
| 3309 |
+ |
|
| 3310 |
+ XMLWriter : function(s) {
|
|
| 3311 |
+ // Get XML document |
|
| 3312 |
+ function getXML() {
|
|
| 3313 |
+ var i = document.implementation; |
|
| 3314 |
+ |
|
| 3315 |
+ if (!i || !i.createDocument) {
|
|
| 3316 |
+ // Try IE objects |
|
| 3317 |
+ try {return new ActiveXObject('MSXML2.DOMDocument');} catch (ex) {}
|
|
| 3318 |
+ try {return new ActiveXObject('Microsoft.XmlDom');} catch (ex) {}
|
|
| 3319 |
+ } else |
|
| 3320 |
+ return i.createDocument('', '', null);
|
|
| 3321 |
+ }; |
|
| 3322 |
+ |
|
| 3323 |
+ this.doc = getXML(); |
|
| 3324 |
+ |
|
| 3325 |
+ // Since Opera and WebKit doesn't escape > into > we need to do it our self to normalize the output for all browsers |
|
| 3326 |
+ this.valid = tinymce.isOpera || tinymce.isWebKit; |
|
| 3327 |
+ |
|
| 3328 |
+ this.reset(); |
|
| 3329 |
+ }, |
|
| 3330 |
+ |
|
| 3331 |
+ reset : function() {
|
|
| 3332 |
+ var t = this, d = t.doc; |
|
| 3333 |
+ |
|
| 3334 |
+ if (d.firstChild) |
|
| 3335 |
+ d.removeChild(d.firstChild); |
|
| 3336 |
+ |
|
| 3337 |
+ t.node = d.appendChild(d.createElement("html"));
|
|
| 3338 |
+ }, |
|
| 3339 |
+ |
|
| 3340 |
+ writeStartElement : function(n) {
|
|
| 3341 |
+ var t = this; |
|
| 3342 |
+ |
|
| 3343 |
+ t.node = t.node.appendChild(t.doc.createElement(n)); |
|
| 3344 |
+ }, |
|
| 3345 |
+ |
|
| 3346 |
+ writeAttribute : function(n, v) {
|
|
| 3347 |
+ if (this.valid) |
|
| 3348 |
+ v = v.replace(/>/g, '%MCGT%'); |
|
| 3349 |
+ |
|
| 3350 |
+ this.node.setAttribute(n, v); |
|
| 3351 |
+ }, |
|
| 3352 |
+ |
|
| 3353 |
+ writeEndElement : function() {
|
|
| 3354 |
+ this.node = this.node.parentNode; |
|
| 3355 |
+ }, |
|
| 3356 |
+ |
|
| 3357 |
+ writeFullEndElement : function() {
|
|
| 3358 |
+ var t = this, n = t.node; |
|
| 3359 |
+ |
|
| 3360 |
+ n.appendChild(t.doc.createTextNode(""));
|
|
| 3361 |
+ t.node = n.parentNode; |
|
| 3362 |
+ }, |
|
| 3363 |
+ |
|
| 3364 |
+ writeText : function(v) {
|
|
| 3365 |
+ if (this.valid) |
|
| 3366 |
+ v = v.replace(/>/g, '%MCGT%'); |
|
| 3367 |
+ |
|
| 3368 |
+ this.node.appendChild(this.doc.createTextNode(v)); |
|
| 3369 |
+ }, |
|
| 3370 |
+ |
|
| 3371 |
+ writeCDATA : function(v) {
|
|
| 3372 |
+ this.node.appendChild(this.doc.createCDATA(v)); |
|
| 3373 |
+ }, |
|
| 3374 |
+ |
|
| 3375 |
+ writeComment : function(v) {
|
|
| 3376 |
+ this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g, ' '))); |
|
| 3377 |
+ }, |
|
| 3378 |
+ |
|
| 3379 |
+ getContent : function() {
|
|
| 3380 |
+ var h; |
|
| 3381 |
+ |
|
| 3382 |
+ h = this.doc.xml || new XMLSerializer().serializeToString(this.doc); |
|
| 3383 |
+ h = h.replace(/<\?[^?]+\?>|<html>|<\/html>|<html\/>|<!DOCTYPE[^>]+>/g, ''); |
|
| 3384 |
+ h = h.replace(/ ?\/>/g, ' />'); |
|
| 3385 |
+ |
|
| 3386 |
+ if (this.valid) |
|
| 3387 |
+ h = h.replace(/\%MCGT%/g, '>'); |
|
| 3388 |
+ |
|
| 3389 |
+ return h; |
|
| 3390 |
+ } |
|
| 3391 |
+ |
|
| 3392 |
+ }); |
|
| 3393 |
+})(); |
|
| 3394 |
+ |
|
| 3395 |
+/* file:jscripts/tiny_mce/classes/dom/StringWriter.js */ |
|
| 3396 |
+ |
|
| 3397 |
+(function() {
|
|
| 3398 |
+ tinymce.create('tinymce.dom.StringWriter', {
|
|
| 3399 |
+ str : null, |
|
| 3400 |
+ tags : null, |
|
| 3401 |
+ count : 0, |
|
| 3402 |
+ settings : null, |
|
| 3403 |
+ indent : null, |
|
| 3404 |
+ |
|
| 3405 |
+ StringWriter : function(s) {
|
|
| 3406 |
+ this.settings = tinymce.extend({
|
|
| 3407 |
+ indent_char : ' ', |
|
| 3408 |
+ indentation : 1 |
|
| 3409 |
+ }, s); |
|
| 3410 |
+ |
|
| 3411 |
+ this.reset(); |
|
| 3412 |
+ }, |
|
| 3413 |
+ |
|
| 3414 |
+ reset : function() {
|
|
| 3415 |
+ this.indent = ''; |
|
| 3416 |
+ this.str = ""; |
|
| 3417 |
+ this.tags = []; |
|
| 3418 |
+ this.count = 0; |
|
| 3419 |
+ }, |
|
| 3420 |
+ |
|
| 3421 |
+ writeStartElement : function(n) {
|
|
| 3422 |
+ this._writeAttributesEnd(); |
|
| 3423 |
+ this.writeRaw('<' + n);
|
|
| 3424 |
+ this.tags.push(n); |
|
| 3425 |
+ this.inAttr = true; |
|
| 3426 |
+ this.count++; |
|
| 3427 |
+ this.elementCount = this.count; |
|
| 3428 |
+ }, |
|
| 3429 |
+ |
|
| 3430 |
+ writeAttribute : function(n, v) {
|
|
| 3431 |
+ var t = this; |
|
| 3432 |
+ |
|
| 3433 |
+ t.writeRaw(" " + t.encode(n) + '="' + t.encode(v) + '"');
|
|
| 3434 |
+ }, |
|
| 3435 |
+ |
|
| 3436 |
+ writeEndElement : function() {
|
|
| 3437 |
+ var n; |
|
| 3438 |
+ |
|
| 3439 |
+ if (this.tags.length > 0) {
|
|
| 3440 |
+ n = this.tags.pop(); |
|
| 3441 |
+ |
|
| 3442 |
+ if (this._writeAttributesEnd(1)) |
|
| 3443 |
+ this.writeRaw('</' + n + '>');
|
|
| 3444 |
+ |
|
| 3445 |
+ if (this.settings.indentation > 0) |
|
| 3446 |
+ this.writeRaw('\n');
|
|
| 3447 |
+ } |
|
| 3448 |
+ }, |
|
| 3449 |
+ |
|
| 3450 |
+ writeFullEndElement : function() {
|
|
| 3451 |
+ if (this.tags.length > 0) {
|
|
| 3452 |
+ this._writeAttributesEnd(); |
|
| 3453 |
+ this.writeRaw('</' + this.tags.pop() + '>');
|
|
| 3454 |
+ |
|
| 3455 |
+ if (this.settings.indentation > 0) |
|
| 3456 |
+ this.writeRaw('\n');
|
|
| 3457 |
+ } |
|
| 3458 |
+ }, |
|
| 3459 |
+ |
|
| 3460 |
+ writeText : function(v) {
|
|
| 3461 |
+ this._writeAttributesEnd(); |
|
| 3462 |
+ this.writeRaw(this.encode(v)); |
|
| 3463 |
+ this.count++; |
|
| 3464 |
+ }, |
|
| 3465 |
+ |
|
| 3466 |
+ writeCDATA : function(v) {
|
|
| 3467 |
+ this._writeAttributesEnd(); |
|
| 3468 |
+ this.writeRaw('<![CDATA[' + v + ']]>');
|
|
| 3469 |
+ this.count++; |
|
| 3470 |
+ }, |
|
| 3471 |
+ |
|
| 3472 |
+ writeComment : function(v) {
|
|
| 3473 |
+ this._writeAttributesEnd(); |
|
| 3474 |
+ this.writeRaw('<!-- ' + v + '-->');
|
|
| 3475 |
+ this.count++; |
|
| 3476 |
+ }, |
|
| 3477 |
+ |
|
| 3478 |
+ writeRaw : function(v) {
|
|
| 3479 |
+ this.str += v; |
|
| 3480 |
+ }, |
|
| 3481 |
+ |
|
| 3482 |
+ encode : function(s) {
|
|
| 3483 |
+ return s.replace(/[<>&"]/g, function(v) {
|
|
| 3484 |
+ switch (v) {
|
|
| 3485 |
+ case '<': |
|
| 3486 |
+ return '<'; |
|
| 3487 |
+ |
|
| 3488 |
+ case '>': |
|
| 3489 |
+ return '>'; |
|
| 3490 |
+ |
|
| 3491 |
+ case '&': |
|
| 3492 |
+ return '&'; |
|
| 3493 |
+ |
|
| 3494 |
+ case '"': |
|
| 3495 |
+ return '"'; |
|
| 3496 |
+ } |
|
| 3497 |
+ |
|
| 3498 |
+ return v; |
|
| 3499 |
+ }); |
|
| 3500 |
+ }, |
|
| 3501 |
+ |
|
| 3502 |
+ getContent : function() {
|
|
| 3503 |
+ return this.str; |
|
| 3504 |
+ }, |
|
| 3505 |
+ |
|
| 3506 |
+ _writeAttributesEnd : function(s) {
|
|
| 3507 |
+ if (!this.inAttr) |
|
| 3508 |
+ return; |
|
| 3509 |
+ |
|
| 3510 |
+ this.inAttr = false; |
|
| 3511 |
+ |
|
| 3512 |
+ if (s && this.elementCount == this.count) {
|
|
| 3513 |
+ this.writeRaw(' />');
|
|
| 3514 |
+ return false; |
|
| 3515 |
+ } |
|
| 3516 |
+ |
|
| 3517 |
+ this.writeRaw('>');
|
|
| 3518 |
+ |
|
| 3519 |
+ return true; |
|
| 3520 |
+ } |
|
| 3521 |
+ |
|
| 3522 |
+ }); |
|
| 3523 |
+})(); |
|
| 3524 |
+ |
|
| 3525 |
+/* file:jscripts/tiny_mce/classes/dom/Serializer.js */ |
|
| 3526 |
+ |
|
| 3527 |
+(function() {
|
|
| 3528 |
+ // Shorten names |
|
| 3529 |
+ var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE, isGecko = tinymce.isGecko; |
|
| 3530 |
+ |
|
| 3531 |
+ // Returns only attribites that have values not all attributes in IE |
|
| 3532 |
+ function getIEAtts(n) {
|
|
| 3533 |
+ var o = []; |
|
| 3534 |
+ |
|
| 3535 |
+ // Object will throw exception in IE |
|
| 3536 |
+ if (n.nodeName == 'OBJECT') |
|
| 3537 |
+ return n.attributes; |
|
| 3538 |
+ |
|
| 3539 |
+ n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
|
|
| 3540 |
+ o.push({specified : 1, nodeName : b});
|
|
| 3541 |
+ }); |
|
| 3542 |
+ |
|
| 3543 |
+ return o; |
|
| 3544 |
+ }; |
|
| 3545 |
+ |
|
| 3546 |
+ function wildcardToRE(s) {
|
|
| 3547 |
+ return s.replace(/([?+*])/g, '.$1'); |
|
| 3548 |
+ }; |
|
| 3549 |
+ |
|
| 3550 |
+ tinymce.create('tinymce.dom.Serializer', {
|
|
| 3551 |
+ Serializer : function(s) {
|
|
| 3552 |
+ var t = this; |
|
| 3553 |
+ |
|
| 3554 |
+ t.key = 0; |
|
| 3555 |
+ t.onPreProcess = new Dispatcher(t); |
|
| 3556 |
+ t.onPostProcess = new Dispatcher(t); |
|
| 3557 |
+ |
|
| 3558 |
+ if (tinymce.relaxedDomain && tinymce.isGecko) {
|
|
| 3559 |
+ // Gecko has a bug where we can't create a new XML document if domain relaxing is used |
|
| 3560 |
+ t.writer = new tinymce.dom.StringWriter(); |
|
| 3561 |
+ } else {
|
|
| 3562 |
+ try {
|
|
| 3563 |
+ t.writer = new tinymce.dom.XMLWriter(); |
|
| 3564 |
+ } catch (ex) {
|
|
| 3565 |
+ // IE might throw exception if ActiveX is disabled so we then switch to the slightly slower StringWriter |
|
| 3566 |
+ t.writer = new tinymce.dom.StringWriter(); |
|
| 3567 |
+ } |
|
| 3568 |
+ } |
|
| 3569 |
+ |
|
| 3570 |
+ // Default settings |
|
| 3571 |
+ t.settings = s = extend({
|
|
| 3572 |
+ dom : tinymce.DOM, |
|
| 3573 |
+ valid_nodes : 0, |
|
| 3574 |
+ node_filter : 0, |
|
| 3575 |
+ attr_filter : 0, |
|
| 3576 |
+ invalid_attrs : /^(mce_|_moz_)/, |
|
| 3577 |
+ closed : /(br|hr|input|meta|img|link|param)/, |
|
| 3578 |
+ entity_encoding : 'named', |
|
| 3579 |
+ entities : '160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro', |
|
| 3580 |
+ valid_elements : '*[*]', |
|
| 3581 |
+ extended_valid_elements : 0, |
|
| 3582 |
+ valid_child_elements : 0, |
|
| 3583 |
+ invalid_elements : 0, |
|
| 3584 |
+ fix_table_elements : 0, |
|
| 3585 |
+ fix_list_elements : true, |
|
| 3586 |
+ fix_content_duplication : true, |
|
| 3587 |
+ convert_fonts_to_spans : false, |
|
| 3588 |
+ font_size_classes : 0, |
|
| 3589 |
+ font_size_style_values : 0, |
|
| 3590 |
+ apply_source_formatting : 0, |
|
| 3591 |
+ indent_mode : 'simple', |
|
| 3592 |
+ indent_char : '\t', |
|
| 3593 |
+ indent_levels : 1, |
|
| 3594 |
+ remove_linebreaks : 1 |
|
| 3595 |
+ }, s); |
|
| 3596 |
+ |
|
| 3597 |
+ t.dom = s.dom; |
|
| 3598 |
+ |
|
| 3599 |
+ if (s.fix_list_elements) {
|
|
| 3600 |
+ t.onPreProcess.add(function(se, o) {
|
|
| 3601 |
+ var nl, x, a = ['ol', 'ul'], i, n, p, r = /^(OL|UL)$/, np; |
|
| 3602 |
+ |
|
| 3603 |
+ function prevNode(e, n) {
|
|
| 3604 |
+ var a = n.split(','), i;
|
|
| 3605 |
+ |
|
| 3606 |
+ while ((e = e.previousSibling) != null) {
|
|
| 3607 |
+ for (i=0; i<a.length; i++) {
|
|
| 3608 |
+ if (e.nodeName == a[i]) |
|
| 3609 |
+ return e; |
|
| 3610 |
+ } |
|
| 3611 |
+ } |
|
| 3612 |
+ |
|
| 3613 |
+ return null; |
|
| 3614 |
+ }; |
|
| 3615 |
+ |
|
| 3616 |
+ for (x=0; x<a.length; x++) {
|
|
| 3617 |
+ nl = t.dom.select(a[x], o.node); |
|
| 3618 |
+ |
|
| 3619 |
+ for (i=0; i<nl.length; i++) {
|
|
| 3620 |
+ n = nl[i]; |
|
| 3621 |
+ p = n.parentNode; |
|
| 3622 |
+ |
|
| 3623 |
+ if (r.test(p.nodeName)) {
|
|
| 3624 |
+ np = prevNode(n, 'LI'); |
|
| 3625 |
+ |
|
| 3626 |
+ if (!np) {
|
|
| 3627 |
+ np = t.dom.create('li');
|
|
| 3628 |
+ np.innerHTML = ' '; |
|
| 3629 |
+ np.appendChild(n); |
|
| 3630 |
+ p.insertBefore(np, p.firstChild); |
|
| 3631 |
+ } else |
|
| 3632 |
+ np.appendChild(n); |
|
| 3633 |
+ } |
|
| 3634 |
+ } |
|
| 3635 |
+ } |
|
| 3636 |
+ }); |
|
| 3637 |
+ } |
|
| 3638 |
+ |
|
| 3639 |
+ if (s.fix_table_elements) {
|
|
| 3640 |
+ t.onPreProcess.add(function(se, o) {
|
|
| 3641 |
+ each(t.dom.select('table', o.node), function(e) {
|
|
| 3642 |
+ var pa = t.dom.getParent(e, 'H1,H2,H3,H4,H5,H6,P'), pa2, n, tm, pl = [], i, ns; |
|
| 3643 |
+ |
|
| 3644 |
+ if (pa) {
|
|
| 3645 |
+ pa2 = pa.cloneNode(false); |
|
| 3646 |
+ |
|
| 3647 |
+ pl.push(e); |
|
| 3648 |
+ for (n = e; n = n.parentNode;) {
|
|
| 3649 |
+ pl.push(n); |
|
| 3650 |
+ |
|
| 3651 |
+ if (n == pa) |
|
| 3652 |
+ break; |
|
| 3653 |
+ } |
|
| 3654 |
+ |
|
| 3655 |
+ tm = pa2; |
|
| 3656 |
+ for (i = pl.length - 1; i >= 0; i--) {
|
|
| 3657 |
+ if (i == pl.length - 1) {
|
|
| 3658 |
+ while (ns = pl[i - 1].nextSibling) |
|
| 3659 |
+ tm.appendChild(ns.parentNode.removeChild(ns)); |
|
| 3660 |
+ } else {
|
|
| 3661 |
+ n = pl[i].cloneNode(false); |
|
| 3662 |
+ |
|
| 3663 |
+ if (i != 0) {
|
|
| 3664 |
+ while (ns = pl[i - 1].nextSibling) |
|
| 3665 |
+ n.appendChild(ns.parentNode.removeChild(ns)); |
|
| 3666 |
+ } |
|
| 3667 |
+ |
|
| 3668 |
+ tm = tm.appendChild(n); |
|
| 3669 |
+ } |
|
| 3670 |
+ } |
|
| 3671 |
+ |
|
| 3672 |
+ e = t.dom.insertAfter(e.parentNode.removeChild(e), pa); |
|
| 3673 |
+ t.dom.insertAfter(e, pa); |
|
| 3674 |
+ t.dom.insertAfter(pa2, e); |
|
| 3675 |
+ } |
|
| 3676 |
+ }); |
|
| 3677 |
+ }); |
|
| 3678 |
+ } |
|
| 3679 |
+ }, |
|
| 3680 |
+ |
|
| 3681 |
+ setEntities : function(s) {
|
|
| 3682 |
+ var t = this, a, i, l = {}, re = '', v;
|
|
| 3683 |
+ |
|
| 3684 |
+ // No need to setup more than once |
|
| 3685 |
+ if (t.entityLookup) |
|
| 3686 |
+ return; |
|
| 3687 |
+ |
|
| 3688 |
+ // Build regex and lookup array |
|
| 3689 |
+ a = s.split(',');
|
|
| 3690 |
+ for (i = 0; i < a.length; i += 2) {
|
|
| 3691 |
+ v = a[i]; |
|
| 3692 |
+ |
|
| 3693 |
+ // Don't add default & " etc. |
|
| 3694 |
+ if (v == 34 || v == 38 || v == 60 || v == 62) |
|
| 3695 |
+ continue; |
|
| 3696 |
+ |
|
| 3697 |
+ l[String.fromCharCode(a[i])] = a[i + 1]; |
|
| 3698 |
+ |
|
| 3699 |
+ v = parseInt(a[i]).toString(16); |
|
| 3700 |
+ re += '\\u' + '0000'.substring(v.length) + v; |
|
| 3701 |
+ } |
|
| 3702 |
+ |
|
| 3703 |
+ if (!re) {
|
|
| 3704 |
+ t.settings.entity_encoding = 'raw'; |
|
| 3705 |
+ return; |
|
| 3706 |
+ } |
|
| 3707 |
+ |
|
| 3708 |
+ t.entitiesRE = new RegExp('[' + re + ']', 'g');
|
|
| 3709 |
+ t.entityLookup = l; |
|
| 3710 |
+ }, |
|
| 3711 |
+ |
|
| 3712 |
+ setValidChildRules : function(s) {
|
|
| 3713 |
+ this.childRules = null; |
|
| 3714 |
+ this.addValidChildRules(s); |
|
| 3715 |
+ }, |
|
| 3716 |
+ |
|
| 3717 |
+ addValidChildRules : function(s) {
|
|
| 3718 |
+ var t = this, inst, intr, bloc; |
|
| 3719 |
+ |
|
| 3720 |
+ if (!s) |
|
| 3721 |
+ return; |
|
| 3722 |
+ |
|
| 3723 |
+ inst = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment'; |
|
| 3724 |
+ intr = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment'; |
|
| 3725 |
+ bloc = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP'; |
|
| 3726 |
+ |
|
| 3727 |
+ each(s.split(','), function(s) {
|
|
| 3728 |
+ var p = s.split(/\[|\]/), re; |
|
| 3729 |
+ |
|
| 3730 |
+ s = ''; |
|
| 3731 |
+ each(p[1].split('|'), function(v) {
|
|
| 3732 |
+ if (s) |
|
| 3733 |
+ s += '|'; |
|
| 3734 |
+ |
|
| 3735 |
+ switch (v) {
|
|
| 3736 |
+ case '%itrans': |
|
| 3737 |
+ v = intr; |
|
| 3738 |
+ break; |
|
| 3739 |
+ |
|
| 3740 |
+ case '%itrans_na': |
|
| 3741 |
+ v = intr.substring(2); |
|
| 3742 |
+ break; |
|
| 3743 |
+ |
|
| 3744 |
+ case '%istrict': |
|
| 3745 |
+ v = inst; |
|
| 3746 |
+ break; |
|
| 3747 |
+ |
|
| 3748 |
+ case '%istrict_na': |
|
| 3749 |
+ v = inst.substring(2); |
|
| 3750 |
+ break; |
|
| 3751 |
+ |
|
| 3752 |
+ case '%btrans': |
|
| 3753 |
+ v = bloc; |
|
| 3754 |
+ break; |
|
| 3755 |
+ |
|
| 3756 |
+ case '%bstrict': |
|
| 3757 |
+ v = bloc; |
|
| 3758 |
+ break; |
|
| 3759 |
+ } |
|
| 3760 |
+ |
|
| 3761 |
+ s += v; |
|
| 3762 |
+ }); |
|
| 3763 |
+ re = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
|
|
| 3764 |
+ |
|
| 3765 |
+ each(p[0].split('/'), function(s) {
|
|
| 3766 |
+ t.childRules = t.childRules || {};
|
|
| 3767 |
+ t.childRules[s] = re; |
|
| 3768 |
+ }); |
|
| 3769 |
+ }); |
|
| 3770 |
+ |
|
| 3771 |
+ // Build regex |
|
| 3772 |
+ s = ''; |
|
| 3773 |
+ each(t.childRules, function(v, k) {
|
|
| 3774 |
+ if (s) |
|
| 3775 |
+ s += '|'; |
|
| 3776 |
+ |
|
| 3777 |
+ s += k; |
|
| 3778 |
+ }); |
|
| 3779 |
+ |
|
| 3780 |
+ t.parentElementsRE = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
|
|
| 3781 |
+ |
|
| 3782 |
+ /*console.debug(t.parentElementsRE.toString()); |
|
| 3783 |
+ each(t.childRules, function(v) {
|
|
| 3784 |
+ console.debug(v.toString()); |
|
| 3785 |
+ });*/ |
|
| 3786 |
+ }, |
|
| 3787 |
+ |
|
| 3788 |
+ setRules : function(s) {
|
|
| 3789 |
+ var t = this; |
|
| 3790 |
+ |
|
| 3791 |
+ t._setup(); |
|
| 3792 |
+ t.rules = {};
|
|
| 3793 |
+ t.wildRules = []; |
|
| 3794 |
+ t.validElements = {};
|
|
| 3795 |
+ |
|
| 3796 |
+ return t.addRules(s); |
|
| 3797 |
+ }, |
|
| 3798 |
+ |
|
| 3799 |
+ addRules : function(s) {
|
|
| 3800 |
+ var t = this, dr; |
|
| 3801 |
+ |
|
| 3802 |
+ if (!s) |
|
| 3803 |
+ return; |
|
| 3804 |
+ |
|
| 3805 |
+ t._setup(); |
|
| 3806 |
+ |
|
| 3807 |
+ each(s.split(','), function(s) {
|
|
| 3808 |
+ var p = s.split(/\[|\]/), tn = p[0].split('/'), ra, at, wat, va = [];
|
|
| 3809 |
+ |
|
| 3810 |
+ // Extend with default rules |
|
| 3811 |
+ if (dr) |
|
| 3812 |
+ at = tinymce.extend([], dr.attribs); |
|
| 3813 |
+ |
|
| 3814 |
+ // Parse attributes |
|
| 3815 |
+ if (p.length > 1) {
|
|
| 3816 |
+ each(p[1].split('|'), function(s) {
|
|
| 3817 |
+ var ar = {}, i;
|
|
| 3818 |
+ |
|
| 3819 |
+ at = at || []; |
|
| 3820 |
+ |
|
| 3821 |
+ // Parse attribute rule |
|
| 3822 |
+ s = s.replace(/::/g, '~'); |
|
| 3823 |
+ s = /^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s); |
|
| 3824 |
+ s[2] = s[2].replace(/~/g, ':'); |
|
| 3825 |
+ |
|
| 3826 |
+ // Add required attributes |
|
| 3827 |
+ if (s[1] == '!') {
|
|
| 3828 |
+ ra = ra || []; |
|
| 3829 |
+ ra.push(s[2]); |
|
| 3830 |
+ } |
|
| 3831 |
+ |
|
| 3832 |
+ // Remove inherited attributes |
|
| 3833 |
+ if (s[1] == '-') {
|
|
| 3834 |
+ for (i = 0; i <at.length; i++) {
|
|
| 3835 |
+ if (at[i].name == s[2]) {
|
|
| 3836 |
+ at.splice(i, 1); |
|
| 3837 |
+ return; |
|
| 3838 |
+ } |
|
| 3839 |
+ } |
|
| 3840 |
+ } |
|
| 3841 |
+ |
|
| 3842 |
+ switch (s[3]) {
|
|
| 3843 |
+ // Add default attrib values |
|
| 3844 |
+ case '=': |
|
| 3845 |
+ ar.defaultVal = s[4] || ''; |
|
| 3846 |
+ break; |
|
| 3847 |
+ |
|
| 3848 |
+ // Add forced attrib values |
|
| 3849 |
+ case ':': |
|
| 3850 |
+ ar.forcedVal = s[4]; |
|
| 3851 |
+ break; |
|
| 3852 |
+ |
|
| 3853 |
+ // Add validation values |
|
| 3854 |
+ case '<': |
|
| 3855 |
+ ar.validVals = s[4].split('?');
|
|
| 3856 |
+ break; |
|
| 3857 |
+ } |
|
| 3858 |
+ |
|
| 3859 |
+ if (/[*.?]/.test(s[2])) {
|
|
| 3860 |
+ wat = wat || []; |
|
| 3861 |
+ ar.nameRE = new RegExp('^' + wildcardToRE(s[2]) + '$');
|
|
| 3862 |
+ wat.push(ar); |
|
| 3863 |
+ } else {
|
|
| 3864 |
+ ar.name = s[2]; |
|
| 3865 |
+ at.push(ar); |
|
| 3866 |
+ } |
|
| 3867 |
+ |
|
| 3868 |
+ va.push(s[2]); |
|
| 3869 |
+ }); |
|
| 3870 |
+ } |
|
| 3871 |
+ |
|
| 3872 |
+ // Handle element names |
|
| 3873 |
+ each(tn, function(s, i) {
|
|
| 3874 |
+ var pr = s.charAt(0), x = 1, ru = {};
|
|
| 3875 |
+ |
|
| 3876 |
+ // Extend with default rule data |
|
| 3877 |
+ if (dr) {
|
|
| 3878 |
+ if (dr.noEmpty) |
|
| 3879 |
+ ru.noEmpty = dr.noEmpty; |
|
| 3880 |
+ |
|
| 3881 |
+ if (dr.fullEnd) |
|
| 3882 |
+ ru.fullEnd = dr.fullEnd; |
|
| 3883 |
+ |
|
| 3884 |
+ if (dr.padd) |
|
| 3885 |
+ ru.padd = dr.padd; |
|
| 3886 |
+ } |
|
| 3887 |
+ |
|
| 3888 |
+ // Handle prefixes |
|
| 3889 |
+ switch (pr) {
|
|
| 3890 |
+ case '-': |
|
| 3891 |
+ ru.noEmpty = true; |
|
| 3892 |
+ break; |
|
| 3893 |
+ |
|
| 3894 |
+ case '+': |
|
| 3895 |
+ ru.fullEnd = true; |
|
| 3896 |
+ break; |
|
| 3897 |
+ |
|
| 3898 |
+ case '#': |
|
| 3899 |
+ ru.padd = true; |
|
| 3900 |
+ break; |
|
| 3901 |
+ |
|
| 3902 |
+ default: |
|
| 3903 |
+ x = 0; |
|
| 3904 |
+ } |
|
| 3905 |
+ |
|
| 3906 |
+ tn[i] = s = s.substring(x); |
|
| 3907 |
+ t.validElements[s] = 1; |
|
| 3908 |
+ |
|
| 3909 |
+ // Add element name or element regex |
|
| 3910 |
+ if (/[*.?]/.test(tn[0])) {
|
|
| 3911 |
+ ru.nameRE = new RegExp('^' + wildcardToRE(tn[0]) + '$');
|
|
| 3912 |
+ t.wildRules = t.wildRules || {};
|
|
| 3913 |
+ t.wildRules.push(ru); |
|
| 3914 |
+ } else {
|
|
| 3915 |
+ ru.name = tn[0]; |
|
| 3916 |
+ |
|
| 3917 |
+ // Store away default rule |
|
| 3918 |
+ if (tn[0] == '@') |
|
| 3919 |
+ dr = ru; |
|
| 3920 |
+ |
|
| 3921 |
+ t.rules[s] = ru; |
|
| 3922 |
+ } |
|
| 3923 |
+ |
|
| 3924 |
+ ru.attribs = at; |
|
| 3925 |
+ |
|
| 3926 |
+ if (ra) |
|
| 3927 |
+ ru.requiredAttribs = ra; |
|
| 3928 |
+ |
|
| 3929 |
+ if (wat) {
|
|
| 3930 |
+ // Build valid attributes regexp |
|
| 3931 |
+ s = ''; |
|
| 3932 |
+ each(va, function(v) {
|
|
| 3933 |
+ if (s) |
|
| 3934 |
+ s += '|'; |
|
| 3935 |
+ |
|
| 3936 |
+ s += '(' + wildcardToRE(v) + ')';
|
|
| 3937 |
+ }); |
|
| 3938 |
+ ru.validAttribsRE = new RegExp('^' + s.toLowerCase() + '$');
|
|
| 3939 |
+ ru.wildAttribs = wat; |
|
| 3940 |
+ } |
|
| 3941 |
+ }); |
|
| 3942 |
+ }); |
|
| 3943 |
+ |
|
| 3944 |
+ // Build valid elements regexp |
|
| 3945 |
+ s = ''; |
|
| 3946 |
+ each(t.validElements, function(v, k) {
|
|
| 3947 |
+ if (s) |
|
| 3948 |
+ s += '|'; |
|
| 3949 |
+ |
|
| 3950 |
+ if (k != '@') |
|
| 3951 |
+ s += k; |
|
| 3952 |
+ }); |
|
| 3953 |
+ t.validElementsRE = new RegExp('^(' + wildcardToRE(s.toLowerCase()) + ')$');
|
|
| 3954 |
+ |
|
| 3955 |
+ //console.debug(t.validElementsRE.toString()); |
|
| 3956 |
+ //console.dir(t.rules); |
|
| 3957 |
+ //console.dir(t.wildRules); |
|
| 3958 |
+ }, |
|
| 3959 |
+ |
|
| 3960 |
+ findRule : function(n) {
|
|
| 3961 |
+ var t = this, rl = t.rules, i, r; |
|
| 3962 |
+ |
|
| 3963 |
+ t._setup(); |
|
| 3964 |
+ |
|
| 3965 |
+ // Exact match |
|
| 3966 |
+ r = rl[n]; |
|
| 3967 |
+ if (r) |
|
| 3968 |
+ return r; |
|
| 3969 |
+ |
|
| 3970 |
+ // Try wildcards |
|
| 3971 |
+ rl = t.wildRules; |
|
| 3972 |
+ for (i = 0; i < rl.length; i++) {
|
|
| 3973 |
+ if (rl[i].nameRE.test(n)) |
|
| 3974 |
+ return rl[i]; |
|
| 3975 |
+ } |
|
| 3976 |
+ |
|
| 3977 |
+ return null; |
|
| 3978 |
+ }, |
|
| 3979 |
+ |
|
| 3980 |
+ findAttribRule : function(ru, n) {
|
|
| 3981 |
+ var i, wa = ru.wildAttribs; |
|
| 3982 |
+ |
|
| 3983 |
+ for (i = 0; i < wa.length; i++) {
|
|
| 3984 |
+ if (wa[i].nameRE.test(n)) |
|
| 3985 |
+ return wa[i]; |
|
| 3986 |
+ } |
|
| 3987 |
+ |
|
| 3988 |
+ return null; |
|
| 3989 |
+ }, |
|
| 3990 |
+ |
|
| 3991 |
+ serialize : function(n, o) {
|
|
| 3992 |
+ var h, t = this; |
|
| 3993 |
+ |
|
| 3994 |
+ t._setup(); |
|
| 3995 |
+ o = o || {};
|
|
| 3996 |
+ o.format = o.format || 'html'; |
|
| 3997 |
+ t.processObj = o; |
|
| 3998 |
+ n = n.cloneNode(true); |
|
| 3999 |
+ t.key = '' + (parseInt(t.key) + 1); |
|
| 4000 |
+ |
|
| 4001 |
+ // Pre process |
|
| 4002 |
+ if (!o.no_events) {
|
|
| 4003 |
+ o.node = n; |
|
| 4004 |
+ t.onPreProcess.dispatch(t, o); |
|
| 4005 |
+ } |
|
| 4006 |
+ |
|
| 4007 |
+ // Serialize HTML DOM into a string |
|
| 4008 |
+ t.writer.reset(); |
|
| 4009 |
+ t._serializeNode(n, o.getInner); |
|
| 4010 |
+ |
|
| 4011 |
+ // Post process |
|
| 4012 |
+ o.content = t.writer.getContent(); |
|
| 4013 |
+ |
|
| 4014 |
+ if (!o.no_events) |
|
| 4015 |
+ t.onPostProcess.dispatch(t, o); |
|
| 4016 |
+ |
|
| 4017 |
+ t._postProcess(o); |
|
| 4018 |
+ o.node = null; |
|
| 4019 |
+ |
|
| 4020 |
+ return tinymce.trim(o.content); |
|
| 4021 |
+ }, |
|
| 4022 |
+ |
|
| 4023 |
+ // Internal functions |
|
| 4024 |
+ |
|
| 4025 |
+ _postProcess : function(o) {
|
|
| 4026 |
+ var t = this, s = t.settings, h = o.content, sc = [], p; |
|
| 4027 |
+ |
|
| 4028 |
+ if (o.format == 'html') {
|
|
| 4029 |
+ // Protect some elements |
|
| 4030 |
+ p = t._protect({
|
|
| 4031 |
+ content : h, |
|
| 4032 |
+ patterns : [ |
|
| 4033 |
+ {pattern : /(<script[^>]*>)(.*?)(<\/script>)/g},
|
|
| 4034 |
+ {pattern : /(<style[^>]*>)(.*?)(<\/style>)/g},
|
|
| 4035 |
+ {pattern : /(<pre[^>]*>)(.*?)(<\/pre>)/g, encode : 1}
|
|
| 4036 |
+ ] |
|
| 4037 |
+ }); |
|
| 4038 |
+ |
|
| 4039 |
+ h = p.content; |
|
| 4040 |
+ |
|
| 4041 |
+ // Entity encode |
|
| 4042 |
+ if (s.entity_encoding !== 'raw') |
|
| 4043 |
+ h = t._encode(h); |
|
| 4044 |
+ |
|
| 4045 |
+ // Use BR instead of padded P elements inside editor and use <p> </p> outside editor |
|
| 4046 |
+/* if (o.set) |
|
| 4047 |
+ h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p><br /></p>'); |
|
| 4048 |
+ else |
|
| 4049 |
+ h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p>$1</p>');*/ |
|
| 4050 |
+ |
|
| 4051 |
+ // Since Gecko and Safari keeps whitespace in the DOM we need to |
|
| 4052 |
+ // remove it inorder to match other browsers. But I think Gecko and Safari is right. |
|
| 4053 |
+ // This process is only done when getting contents out from the editor. |
|
| 4054 |
+ if (!o.set) {
|
|
| 4055 |
+ // We need to replace paragraph whitespace with an nbsp before indentation to keep the \u00a0 char |
|
| 4056 |
+ h = h.replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g, s.entity_encoding == 'numeric' ? '<p$1> </p>' : '<p$1> </p>'); |
|
| 4057 |
+ |
|
| 4058 |
+ if (s.remove_linebreaks) {
|
|
| 4059 |
+ h = h.replace(/\r?\n|\r/g, ' '); |
|
| 4060 |
+ h = h.replace(/(<[^>]+>)\s+/g, '$1 '); |
|
| 4061 |
+ h = h.replace(/\s+(<\/[^>]+>)/g, ' $1'); |
|
| 4062 |
+ h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g, '<$1 $2>'); // Trim block start |
|
| 4063 |
+ h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g, '<$1>'); // Trim block start |
|
| 4064 |
+ h = h.replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g, '</$1>'); // Trim block end |
|
| 4065 |
+ } |
|
| 4066 |
+ |
|
| 4067 |
+ // Simple indentation |
|
| 4068 |
+ if (s.apply_source_formatting && s.indent_mode == 'simple') {
|
|
| 4069 |
+ // Add line breaks before and after block elements |
|
| 4070 |
+ h = h.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g, '\n<$1$2$3>\n'); |
|
| 4071 |
+ h = h.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g, '\n<$1$2>'); |
|
| 4072 |
+ h = h.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g, '</$1>\n'); |
|
| 4073 |
+ h = h.replace(/\n\n/g, '\n'); |
|
| 4074 |
+ } |
|
| 4075 |
+ } |
|
| 4076 |
+ |
|
| 4077 |
+ h = t._unprotect(h, p); |
|
| 4078 |
+ |
|
| 4079 |
+ // Restore the \u00a0 character if raw mode is enabled |
|
| 4080 |
+ if (s.entity_encoding == 'raw') |
|
| 4081 |
+ h = h.replace(/<p> <\/p>|<p([^>]+)> <\/p>/g, '<p$1>\u00a0</p>'); |
|
| 4082 |
+ } |
|
| 4083 |
+ |
|
| 4084 |
+ o.content = h; |
|
| 4085 |
+ }, |
|
| 4086 |
+ |
|
| 4087 |
+ _serializeNode : function(n, inn) {
|
|
| 4088 |
+ var t = this, s = t.settings, w = t.writer, hc, el, cn, i, l, a, at, no, v, nn, ru, ar, iv; |
|
| 4089 |
+ |
|
| 4090 |
+ if (!s.node_filter || s.node_filter(n)) {
|
|
| 4091 |
+ switch (n.nodeType) {
|
|
| 4092 |
+ case 1: // Element |
|
| 4093 |
+ if (n.hasAttribute ? n.hasAttribute('mce_bogus') : n.getAttribute('mce_bogus'))
|
|
| 4094 |
+ return; |
|
| 4095 |
+ |
|
| 4096 |
+ iv = false; |
|
| 4097 |
+ hc = n.hasChildNodes(); |
|
| 4098 |
+ nn = n.getAttribute('mce_name') || n.nodeName.toLowerCase();
|
|
| 4099 |
+ |
|
| 4100 |
+ // Add correct prefix on IE |
|
| 4101 |
+ if (isIE) {
|
|
| 4102 |
+ if (n.scopeName !== 'HTML' && n.scopeName !== 'html') |
|
| 4103 |
+ nn = n.scopeName + ':' + nn; |
|
| 4104 |
+ } |
|
| 4105 |
+ |
|
| 4106 |
+ // Remove mce prefix on IE needed for the abbr element |
|
| 4107 |
+ if (nn.indexOf('mce:') === 0)
|
|
| 4108 |
+ nn = nn.substring(4); |
|
| 4109 |
+ |
|
| 4110 |
+ // Check if valid |
|
| 4111 |
+ if (!t.validElementsRE.test(nn) || (t.invalidElementsRE && t.invalidElementsRE.test(nn)) || inn) {
|
|
| 4112 |
+ iv = true; |
|
| 4113 |
+ break; |
|
| 4114 |
+ } |
|
| 4115 |
+ |
|
| 4116 |
+ if (isIE) {
|
|
| 4117 |
+ // Fix IE content duplication (DOM can have multiple copies of the same node) |
|
| 4118 |
+ if (s.fix_content_duplication) {
|
|
| 4119 |
+ if (n.mce_serialized == t.key) |
|
| 4120 |
+ return; |
|
| 4121 |
+ |
|
| 4122 |
+ n.mce_serialized = t.key; |
|
| 4123 |
+ } |
|
| 4124 |
+ |
|
| 4125 |
+ // IE sometimes adds a / infront of the node name |
|
| 4126 |
+ if (nn.charAt(0) == '/') |
|
| 4127 |
+ nn = nn.substring(1); |
|
| 4128 |
+ } else if (isGecko) {
|
|
| 4129 |
+ // Ignore br elements |
|
| 4130 |
+ if (n.nodeName === 'BR' && n.getAttribute('type') == '_moz')
|
|
| 4131 |
+ return; |
|
| 4132 |
+ } |
|
| 4133 |
+ |
|
| 4134 |
+ // Check if valid child |
|
| 4135 |
+ if (t.childRules) {
|
|
| 4136 |
+ if (t.parentElementsRE.test(t.elementName)) {
|
|
| 4137 |
+ if (!t.childRules[t.elementName].test(nn)) {
|
|
| 4138 |
+ iv = true; |
|
| 4139 |
+ break; |
|
| 4140 |
+ } |
|
| 4141 |
+ } |
|
| 4142 |
+ |
|
| 4143 |
+ t.elementName = nn; |
|
| 4144 |
+ } |
|
| 4145 |
+ |
|
| 4146 |
+ ru = t.findRule(nn); |
|
| 4147 |
+ nn = ru.name || nn; |
|
| 4148 |
+ |
|
| 4149 |
+ // Skip empty nodes or empty node name in IE |
|
| 4150 |
+ if ((!hc && ru.noEmpty) || (isIE && !nn)) {
|
|
| 4151 |
+ iv = true; |
|
| 4152 |
+ break; |
|
| 4153 |
+ } |
|
| 4154 |
+ |
|
| 4155 |
+ // Check required |
|
| 4156 |
+ if (ru.requiredAttribs) {
|
|
| 4157 |
+ a = ru.requiredAttribs; |
|
| 4158 |
+ |
|
| 4159 |
+ for (i = a.length - 1; i >= 0; i--) {
|
|
| 4160 |
+ if (this.dom.getAttrib(n, a[i]) !== '') |
|
| 4161 |
+ break; |
|
| 4162 |
+ } |
|
| 4163 |
+ |
|
| 4164 |
+ // None of the required was there |
|
| 4165 |
+ if (i == -1) {
|
|
| 4166 |
+ iv = true; |
|
| 4167 |
+ break; |
|
| 4168 |
+ } |
|
| 4169 |
+ } |
|
| 4170 |
+ |
|
| 4171 |
+ w.writeStartElement(nn); |
|
| 4172 |
+ |
|
| 4173 |
+ // Add ordered attributes |
|
| 4174 |
+ if (ru.attribs) {
|
|
| 4175 |
+ for (i=0, at = ru.attribs, l = at.length; i<l; i++) {
|
|
| 4176 |
+ a = at[i]; |
|
| 4177 |
+ v = t._getAttrib(n, a); |
|
| 4178 |
+ |
|
| 4179 |
+ if (v !== null) |
|
| 4180 |
+ w.writeAttribute(a.name, v); |
|
| 4181 |
+ } |
|
| 4182 |
+ } |
|
| 4183 |
+ |
|
| 4184 |
+ // Add wild attributes |
|
| 4185 |
+ if (ru.validAttribsRE) {
|
|
| 4186 |
+ at = isIE ? getIEAtts(n) : n.attributes; |
|
| 4187 |
+ for (i=at.length-1; i>-1; i--) {
|
|
| 4188 |
+ no = at[i]; |
|
| 4189 |
+ |
|
| 4190 |
+ if (no.specified) {
|
|
| 4191 |
+ a = no.nodeName.toLowerCase(); |
|
| 4192 |
+ |
|
| 4193 |
+ if (s.invalid_attrs.test(a) || !ru.validAttribsRE.test(a)) |
|
| 4194 |
+ continue; |
|
| 4195 |
+ |
|
| 4196 |
+ ar = t.findAttribRule(ru, a); |
|
| 4197 |
+ v = t._getAttrib(n, ar, a); |
|
| 4198 |
+ |
|
| 4199 |
+ if (v !== null) |
|
| 4200 |
+ w.writeAttribute(a, v); |
|
| 4201 |
+ } |
|
| 4202 |
+ } |
|
| 4203 |
+ } |
|
| 4204 |
+ |
|
| 4205 |
+ // Padd empty nodes with a |
|
| 4206 |
+ if (!hc && ru.padd) |
|
| 4207 |
+ w.writeText('\u00a0');
|
|
| 4208 |
+ |
|
| 4209 |
+ break; |
|
| 4210 |
+ |
|
| 4211 |
+ case 3: // Text |
|
| 4212 |
+ // Check if valid child |
|
| 4213 |
+ if (t.childRules && t.parentElementsRE.test(t.elementName)) {
|
|
| 4214 |
+ if (!t.childRules[t.elementName].test(n.nodeName)) |
|
| 4215 |
+ return; |
|
| 4216 |
+ } |
|
| 4217 |
+ |
|
| 4218 |
+ return w.writeText(n.nodeValue); |
|
| 4219 |
+ |
|
| 4220 |
+ case 4: // CDATA |
|
| 4221 |
+ return w.writeCDATA(n.nodeValue); |
|
| 4222 |
+ |
|
| 4223 |
+ case 8: // Comment |
|
| 4224 |
+ return w.writeComment(n.nodeValue); |
|
| 4225 |
+ } |
|
| 4226 |
+ } else if (n.nodeType == 1) |
|
| 4227 |
+ hc = n.hasChildNodes(); |
|
| 4228 |
+ |
|
| 4229 |
+ if (hc) {
|
|
| 4230 |
+ cn = n.firstChild; |
|
| 4231 |
+ |
|
| 4232 |
+ while (cn) {
|
|
| 4233 |
+ t._serializeNode(cn); |
|
| 4234 |
+ t.elementName = nn; |
|
| 4235 |
+ cn = cn.nextSibling; |
|
| 4236 |
+ } |
|
| 4237 |
+ } |
|
| 4238 |
+ |
|
| 4239 |
+ // Write element end |
|
| 4240 |
+ if (!iv) {
|
|
| 4241 |
+ if (hc || !s.closed.test(nn)) |
|
| 4242 |
+ w.writeFullEndElement(); |
|
| 4243 |
+ else |
|
| 4244 |
+ w.writeEndElement(); |
|
| 4245 |
+ } |
|
| 4246 |
+ }, |
|
| 4247 |
+ |
|
| 4248 |
+ _protect : function(o) {
|
|
| 4249 |
+ var t = this; |
|
| 4250 |
+ |
|
| 4251 |
+ o.items = o.items || []; |
|
| 4252 |
+ |
|
| 4253 |
+ function enc(s) {
|
|
| 4254 |
+ return s.replace(/[\r\n\\]/g, function(c) {
|
|
| 4255 |
+ if (c === '\n') |
|
| 4256 |
+ return '\\n'; |
|
| 4257 |
+ else if (c === '\\') |
|
| 4258 |
+ return '\\\\'; |
|
| 4259 |
+ |
|
| 4260 |
+ return '\\r'; |
|
| 4261 |
+ }); |
|
| 4262 |
+ }; |
|
| 4263 |
+ |
|
| 4264 |
+ function dec(s) {
|
|
| 4265 |
+ return s.replace(/\\[\\rn]/g, function(c) {
|
|
| 4266 |
+ if (c === '\\n') |
|
| 4267 |
+ return '\n'; |
|
| 4268 |
+ else if (c === '\\\\') |
|
| 4269 |
+ return '\\'; |
|
| 4270 |
+ |
|
| 4271 |
+ return '\r'; |
|
| 4272 |
+ }); |
|
| 4273 |
+ }; |
|
| 4274 |
+ |
|
| 4275 |
+ each(o.patterns, function(p) {
|
|
| 4276 |
+ o.content = dec(enc(o.content).replace(p.pattern, function(x, a, b, c) {
|
|
| 4277 |
+ b = dec(b); |
|
| 4278 |
+ |
|
| 4279 |
+ if (p.encode) |
|
| 4280 |
+ b = t._encode(b); |
|
| 4281 |
+ |
|
| 4282 |
+ o.items.push(b); |
|
| 4283 |
+ return a + '<!--mce:' + (o.items.length - 1) + '-->' + c; |
|
| 4284 |
+ })); |
|
| 4285 |
+ }); |
|
| 4286 |
+ |
|
| 4287 |
+ return o; |
|
| 4288 |
+ }, |
|
| 4289 |
+ |
|
| 4290 |
+ _unprotect : function(h, o) {
|
|
| 4291 |
+ h = h.replace(/\<!--mce:([0-9]+)--\>/g, function(a, b) {
|
|
| 4292 |
+ return o.items[parseInt(b)]; |
|
| 4293 |
+ }); |
|
| 4294 |
+ |
|
| 4295 |
+ o.items = []; |
|
| 4296 |
+ |
|
| 4297 |
+ return h; |
|
| 4298 |
+ }, |
|
| 4299 |
+ |
|
| 4300 |
+ _encode : function(h) {
|
|
| 4301 |
+ var t = this, s = t.settings, l; |
|
| 4302 |
+ |
|
| 4303 |
+ // Entity encode |
|
| 4304 |
+ if (s.entity_encoding !== 'raw') {
|
|
| 4305 |
+ if (s.entity_encoding.indexOf('named') != -1) {
|
|
| 4306 |
+ t.setEntities(s.entities); |
|
| 4307 |
+ l = t.entityLookup; |
|
| 4308 |
+ |
|
| 4309 |
+ h = h.replace(t.entitiesRE, function(a) {
|
|
| 4310 |
+ var v; |
|
| 4311 |
+ |
|
| 4312 |
+ if (v = l[a]) |
|
| 4313 |
+ a = '&' + v + ';'; |
|
| 4314 |
+ |
|
| 4315 |
+ return a; |
|
| 4316 |
+ }); |
|
| 4317 |
+ } |
|
| 4318 |
+ |
|
| 4319 |
+ if (s.entity_encoding.indexOf('numeric') != -1) {
|
|
| 4320 |
+ h = h.replace(/[\u007E-\uFFFF]/g, function(a) {
|
|
| 4321 |
+ return '&#' + a.charCodeAt(0) + ';'; |
|
| 4322 |
+ }); |
|
| 4323 |
+ } |
|
| 4324 |
+ } |
|
| 4325 |
+ |
|
| 4326 |
+ return h; |
|
| 4327 |
+ }, |
|
| 4328 |
+ |
|
| 4329 |
+ _setup : function() {
|
|
| 4330 |
+ var t = this, s = this.settings; |
|
| 4331 |
+ |
|
| 4332 |
+ if (t.done) |
|
| 4333 |
+ return; |
|
| 4334 |
+ |
|
| 4335 |
+ t.done = 1; |
|
| 4336 |
+ |
|
| 4337 |
+ t.setRules(s.valid_elements); |
|
| 4338 |
+ t.addRules(s.extended_valid_elements); |
|
| 4339 |
+ t.addValidChildRules(s.valid_child_elements); |
|
| 4340 |
+ |
|
| 4341 |
+ if (s.invalid_elements) |
|
| 4342 |
+ t.invalidElementsRE = new RegExp('^(' + wildcardToRE(s.invalid_elements.replace(/,/g, '|').toLowerCase()) + ')$');
|
|
| 4343 |
+ |
|
| 4344 |
+ if (s.attrib_value_filter) |
|
| 4345 |
+ t.attribValueFilter = s.attribValueFilter; |
|
| 4346 |
+ }, |
|
| 4347 |
+ |
|
| 4348 |
+ _getAttrib : function(n, a, na) {
|
|
| 4349 |
+ var i, v; |
|
| 4350 |
+ |
|
| 4351 |
+ na = na || a.name; |
|
| 4352 |
+ |
|
| 4353 |
+ if (a.forcedVal && (v = a.forcedVal)) {
|
|
| 4354 |
+ if (v === '{$uid}')
|
|
| 4355 |
+ return this.dom.uniqueId(); |
|
| 4356 |
+ |
|
| 4357 |
+ return v; |
|
| 4358 |
+ } |
|
| 4359 |
+ |
|
| 4360 |
+ v = this.dom.getAttrib(n, na); |
|
| 4361 |
+ |
|
| 4362 |
+ switch (na) {
|
|
| 4363 |
+ case 'rowspan': |
|
| 4364 |
+ case 'colspan': |
|
| 4365 |
+ // Whats the point? Remove usless attribute value |
|
| 4366 |
+ if (v == '1') |
|
| 4367 |
+ v = ''; |
|
| 4368 |
+ |
|
| 4369 |
+ break; |
|
| 4370 |
+ } |
|
| 4371 |
+ |
|
| 4372 |
+ if (this.attribValueFilter) |
|
| 4373 |
+ v = this.attribValueFilter(na, v, n); |
|
| 4374 |
+ |
|
| 4375 |
+ if (a.validVals) {
|
|
| 4376 |
+ for (i = a.validVals.length - 1; i >= 0; i--) {
|
|
| 4377 |
+ if (v == a.validVals[i]) |
|
| 4378 |
+ break; |
|
| 4379 |
+ } |
|
| 4380 |
+ |
|
| 4381 |
+ if (i == -1) |
|
| 4382 |
+ return null; |
|
| 4383 |
+ } |
|
| 4384 |
+ |
|
| 4385 |
+ if (v === '' && typeof(a.defaultVal) != 'undefined') {
|
|
| 4386 |
+ v = a.defaultVal; |
|
| 4387 |
+ |
|
| 4388 |
+ if (v === '{$uid}')
|
|
| 4389 |
+ return this.dom.uniqueId(); |
|
| 4390 |
+ |
|
| 4391 |
+ return v; |
|
| 4392 |
+ } else {
|
|
| 4393 |
+ // Remove internal mceItemXX classes when content is extracted from editor |
|
| 4394 |
+ if (na == 'class' && this.processObj.get) |
|
| 4395 |
+ v = v.replace(/\s?mceItem\w+\s?/g, ''); |
|
| 4396 |
+ } |
|
| 4397 |
+ |
|
| 4398 |
+ if (v === '') |
|
| 4399 |
+ return null; |
|
| 4400 |
+ |
|
| 4401 |
+ |
|
| 4402 |
+ return v; |
|
| 4403 |
+ } |
|
| 4404 |
+ |
|
| 4405 |
+ }); |
|
| 4406 |
+})(); |
|
| 4407 |
+ |
|
| 4408 |
+/* file:jscripts/tiny_mce/classes/dom/ScriptLoader.js */ |
|
| 4409 |
+ |
|
| 4410 |
+(function() {
|
|
| 4411 |
+ var each = tinymce.each; |
|
| 4412 |
+ |
|
| 4413 |
+ tinymce.create('tinymce.dom.ScriptLoader', {
|
|
| 4414 |
+ ScriptLoader : function(s) {
|
|
| 4415 |
+ this.settings = s || {};
|
|
| 4416 |
+ this.queue = []; |
|
| 4417 |
+ this.lookup = {};
|
|
| 4418 |
+ }, |
|
| 4419 |
+ |
|
| 4420 |
+ isDone : function(u) {
|
|
| 4421 |
+ return this.lookup[u] ? this.lookup[u].state == 2 : 0; |
|
| 4422 |
+ }, |
|
| 4423 |
+ |
|
| 4424 |
+ markDone : function(u) {
|
|
| 4425 |
+ this.lookup[u] = {state : 2, url : u};
|
|
| 4426 |
+ }, |
|
| 4427 |
+ |
|
| 4428 |
+ add : function(u, cb, s, pr) {
|
|
| 4429 |
+ var t = this, lo = t.lookup, o; |
|
| 4430 |
+ |
|
| 4431 |
+ if (o = lo[u]) {
|
|
| 4432 |
+ // Is loaded fire callback |
|
| 4433 |
+ if (cb && o.state == 2) |
|
| 4434 |
+ cb.call(s || this); |
|
| 4435 |
+ |
|
| 4436 |
+ return o; |
|
| 4437 |
+ } |
|
| 4438 |
+ |
|
| 4439 |
+ o = {state : 0, url : u, func : cb, scope : s || this};
|
|
| 4440 |
+ |
|
| 4441 |
+ if (pr) |
|
| 4442 |
+ t.queue.unshift(o); |
|
| 4443 |
+ else |
|
| 4444 |
+ t.queue.push(o); |
|
| 4445 |
+ |
|
| 4446 |
+ lo[u] = o; |
|
| 4447 |
+ |
|
| 4448 |
+ return o; |
|
| 4449 |
+ }, |
|
| 4450 |
+ |
|
| 4451 |
+ load : function(u, cb, s) {
|
|
| 4452 |
+ var t = this, o; |
|
| 4453 |
+ |
|
| 4454 |
+ if (o = t.lookup[u]) {
|
|
| 4455 |
+ // Is loaded fire callback |
|
| 4456 |
+ if (cb && o.state == 2) |
|
| 4457 |
+ cb.call(s || t); |
|
| 4458 |
+ |
|
| 4459 |
+ return o; |
|
| 4460 |
+ } |
|
| 4461 |
+ |
|
| 4462 |
+ function loadScript(u) {
|
|
| 4463 |
+ if (tinymce.dom.Event.domLoaded || t.settings.strict_mode) {
|
|
| 4464 |
+ tinymce.util.XHR.send({
|
|
| 4465 |
+ url : tinymce._addVer(u), |
|
| 4466 |
+ error : t.settings.error, |
|
| 4467 |
+ async : false, |
|
| 4468 |
+ success : function(co) {
|
|
| 4469 |
+ t.eval(co); |
|
| 4470 |
+ } |
|
| 4471 |
+ }); |
|
| 4472 |
+ } else |
|
| 4473 |
+ document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
|
|
| 4474 |
+ }; |
|
| 4475 |
+ |
|
| 4476 |
+ if (!tinymce.is(u, 'string')) {
|
|
| 4477 |
+ each(u, function(u) {
|
|
| 4478 |
+ loadScript(u); |
|
| 4479 |
+ }); |
|
| 4480 |
+ |
|
| 4481 |
+ if (cb) |
|
| 4482 |
+ cb.call(s || t); |
|
| 4483 |
+ } else {
|
|
| 4484 |
+ loadScript(u); |
|
| 4485 |
+ |
|
| 4486 |
+ if (cb) |
|
| 4487 |
+ cb.call(s || t); |
|
| 4488 |
+ } |
|
| 4489 |
+ }, |
|
| 4490 |
+ |
|
| 4491 |
+ loadQueue : function(cb, s) {
|
|
| 4492 |
+ var t = this; |
|
| 4493 |
+ |
|
| 4494 |
+ if (!t.queueLoading) {
|
|
| 4495 |
+ t.queueLoading = 1; |
|
| 4496 |
+ t.queueCallbacks = []; |
|
| 4497 |
+ |
|
| 4498 |
+ t.loadScripts(t.queue, function() {
|
|
| 4499 |
+ t.queueLoading = 0; |
|
| 4500 |
+ |
|
| 4501 |
+ if (cb) |
|
| 4502 |
+ cb.call(s || t); |
|
| 4503 |
+ |
|
| 4504 |
+ each(t.queueCallbacks, function(o) {
|
|
| 4505 |
+ o.func.call(o.scope); |
|
| 4506 |
+ }); |
|
| 4507 |
+ }); |
|
| 4508 |
+ } else if (cb) |
|
| 4509 |
+ t.queueCallbacks.push({func : cb, scope : s || t});
|
|
| 4510 |
+ }, |
|
| 4511 |
+ |
|
| 4512 |
+ eval : function(co) {
|
|
| 4513 |
+ var w = window; |
|
| 4514 |
+ |
|
| 4515 |
+ // Evaluate script |
|
| 4516 |
+ if (!w.execScript) {
|
|
| 4517 |
+ try {
|
|
| 4518 |
+ eval.call(w, co); |
|
| 4519 |
+ } catch (ex) {
|
|
| 4520 |
+ eval(co, w); // Firefox 3.0a8 |
|
| 4521 |
+ } |
|
| 4522 |
+ } else |
|
| 4523 |
+ w.execScript(co); // IE |
|
| 4524 |
+ }, |
|
| 4525 |
+ |
|
| 4526 |
+ loadScripts : function(sc, cb, s) {
|
|
| 4527 |
+ var t = this, lo = t.lookup; |
|
| 4528 |
+ |
|
| 4529 |
+ function done(o) {
|
|
| 4530 |
+ o.state = 2; // Has been loaded |
|
| 4531 |
+ |
|
| 4532 |
+ // Run callback |
|
| 4533 |
+ if (o.func) |
|
| 4534 |
+ o.func.call(o.scope || t); |
|
| 4535 |
+ }; |
|
| 4536 |
+ |
|
| 4537 |
+ function allDone() {
|
|
| 4538 |
+ var l; |
|
| 4539 |
+ |
|
| 4540 |
+ // Check if all files are loaded |
|
| 4541 |
+ l = sc.length; |
|
| 4542 |
+ each(sc, function(o) {
|
|
| 4543 |
+ o = lo[o.url]; |
|
| 4544 |
+ |
|
| 4545 |
+ if (o.state === 2) {// It has finished loading
|
|
| 4546 |
+ done(o); |
|
| 4547 |
+ l--; |
|
| 4548 |
+ } else |
|
| 4549 |
+ load(o); |
|
| 4550 |
+ }); |
|
| 4551 |
+ |
|
| 4552 |
+ // They are all loaded |
|
| 4553 |
+ if (l === 0 && cb) {
|
|
| 4554 |
+ cb.call(s || t); |
|
| 4555 |
+ cb = 0; |
|
| 4556 |
+ } |
|
| 4557 |
+ }; |
|
| 4558 |
+ |
|
| 4559 |
+ function load(o) {
|
|
| 4560 |
+ if (o.state > 0) |
|
| 4561 |
+ return; |
|
| 4562 |
+ |
|
| 4563 |
+ o.state = 1; // Is loading |
|
| 4564 |
+ |
|
| 4565 |
+ tinymce.util.XHR.send({
|
|
| 4566 |
+ url : o.url, |
|
| 4567 |
+ error : t.settings.error, |
|
| 4568 |
+ success : function(co) {
|
|
| 4569 |
+ t.eval(co); |
|
| 4570 |
+ done(o); |
|
| 4571 |
+ allDone(); |
|
| 4572 |
+ } |
|
| 4573 |
+ }); |
|
| 4574 |
+ }; |
|
| 4575 |
+ |
|
| 4576 |
+ each(sc, function(o) {
|
|
| 4577 |
+ var u = o.url; |
|
| 4578 |
+ |
|
| 4579 |
+ // Add to queue if needed |
|
| 4580 |
+ if (!lo[u]) {
|
|
| 4581 |
+ lo[u] = o; |
|
| 4582 |
+ t.queue.push(o); |
|
| 4583 |
+ } else |
|
| 4584 |
+ o = lo[u]; |
|
| 4585 |
+ |
|
| 4586 |
+ // Is already loading or has been loaded |
|
| 4587 |
+ if (o.state > 0) |
|
| 4588 |
+ return; |
|
| 4589 |
+ |
|
| 4590 |
+ if (!tinymce.dom.Event.domLoaded && !t.settings.strict_mode) {
|
|
| 4591 |
+ var ix, ol = ''; |
|
| 4592 |
+ |
|
| 4593 |
+ // Add onload events |
|
| 4594 |
+ if (cb || o.func) {
|
|
| 4595 |
+ o.state = 1; // Is loading |
|
| 4596 |
+ |
|
| 4597 |
+ ix = tinymce.dom.ScriptLoader._addOnLoad(function() {
|
|
| 4598 |
+ done(o); |
|
| 4599 |
+ allDone(); |
|
| 4600 |
+ }); |
|
| 4601 |
+ |
|
| 4602 |
+ if (tinymce.isIE) |
|
| 4603 |
+ ol = ' onreadystatechange="'; |
|
| 4604 |
+ else |
|
| 4605 |
+ ol = ' onload="'; |
|
| 4606 |
+ |
|
| 4607 |
+ ol += 'tinymce.dom.ScriptLoader._onLoad(this,\'' + u + '\',' + ix + ');"'; |
|
| 4608 |
+ } |
|
| 4609 |
+ |
|
| 4610 |
+ document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"' + ol + '></script>');
|
|
| 4611 |
+ |
|
| 4612 |
+ if (!o.func) |
|
| 4613 |
+ done(o); |
|
| 4614 |
+ } else |
|
| 4615 |
+ load(o); |
|
| 4616 |
+ }); |
|
| 4617 |
+ |
|
| 4618 |
+ allDone(); |
|
| 4619 |
+ }, |
|
| 4620 |
+ |
|
| 4621 |
+ // Static methods |
|
| 4622 |
+ 'static' : {
|
|
| 4623 |
+ _addOnLoad : function(f) {
|
|
| 4624 |
+ var t = this; |
|
| 4625 |
+ |
|
| 4626 |
+ t._funcs = t._funcs || []; |
|
| 4627 |
+ t._funcs.push(f); |
|
| 4628 |
+ |
|
| 4629 |
+ return t._funcs.length - 1; |
|
| 4630 |
+ }, |
|
| 4631 |
+ |
|
| 4632 |
+ _onLoad : function(e, u, ix) {
|
|
| 4633 |
+ if (!tinymce.isIE || e.readyState == 'complete') |
|
| 4634 |
+ this._funcs[ix].call(this); |
|
| 4635 |
+ } |
|
| 4636 |
+ } |
|
| 4637 |
+ |
|
| 4638 |
+ }); |
|
| 4639 |
+ |
|
| 4640 |
+ // Global script loader |
|
| 4641 |
+ tinymce.ScriptLoader = new tinymce.dom.ScriptLoader(); |
|
| 4642 |
+})(); |
|
| 4643 |
+ |
|
| 4644 |
+/* file:jscripts/tiny_mce/classes/ui/Control.js */ |
|
| 4645 |
+ |
|
| 4646 |
+(function() {
|
|
| 4647 |
+ // Shorten class names |
|
| 4648 |
+ var DOM = tinymce.DOM, is = tinymce.is; |
|
| 4649 |
+ |
|
| 4650 |
+ tinymce.create('tinymce.ui.Control', {
|
|
| 4651 |
+ Control : function(id, s) {
|
|
| 4652 |
+ this.id = id; |
|
| 4653 |
+ this.settings = s = s || {};
|
|
| 4654 |
+ this.rendered = false; |
|
| 4655 |
+ this.onRender = new tinymce.util.Dispatcher(this); |
|
| 4656 |
+ this.classPrefix = ''; |
|
| 4657 |
+ this.scope = s.scope || this; |
|
| 4658 |
+ this.disabled = 0; |
|
| 4659 |
+ this.active = 0; |
|
| 4660 |
+ }, |
|
| 4661 |
+ |
|
| 4662 |
+ setDisabled : function(s) {
|
|
| 4663 |
+ var e; |
|
| 4664 |
+ |
|
| 4665 |
+ if (s != this.disabled) {
|
|
| 4666 |
+ e = DOM.get(this.id); |
|
| 4667 |
+ |
|
| 4668 |
+ // Add accessibility title for unavailable actions |
|
| 4669 |
+ if (e && this.settings.unavailable_prefix) {
|
|
| 4670 |
+ if (s) {
|
|
| 4671 |
+ this.prevTitle = e.title; |
|
| 4672 |
+ e.title = this.settings.unavailable_prefix + ": " + e.title; |
|
| 4673 |
+ } else |
|
| 4674 |
+ e.title = this.prevTitle; |
|
| 4675 |
+ } |
|
| 4676 |
+ |
|
| 4677 |
+ this.setState('Disabled', s);
|
|
| 4678 |
+ this.setState('Enabled', !s);
|
|
| 4679 |
+ this.disabled = s; |
|
| 4680 |
+ } |
|
| 4681 |
+ }, |
|
| 4682 |
+ |
|
| 4683 |
+ isDisabled : function() {
|
|
| 4684 |
+ return this.disabled; |
|
| 4685 |
+ }, |
|
| 4686 |
+ |
|
| 4687 |
+ setActive : function(s) {
|
|
| 4688 |
+ if (s != this.active) {
|
|
| 4689 |
+ this.setState('Active', s);
|
|
| 4690 |
+ this.active = s; |
|
| 4691 |
+ } |
|
| 4692 |
+ }, |
|
| 4693 |
+ |
|
| 4694 |
+ isActive : function() {
|
|
| 4695 |
+ return this.active; |
|
| 4696 |
+ }, |
|
| 4697 |
+ |
|
| 4698 |
+ setState : function(c, s) {
|
|
| 4699 |
+ var n = DOM.get(this.id); |
|
| 4700 |
+ |
|
| 4701 |
+ c = this.classPrefix + c; |
|
| 4702 |
+ |
|
| 4703 |
+ if (s) |
|
| 4704 |
+ DOM.addClass(n, c); |
|
| 4705 |
+ else |
|
| 4706 |
+ DOM.removeClass(n, c); |
|
| 4707 |
+ }, |
|
| 4708 |
+ |
|
| 4709 |
+ isRendered : function() {
|
|
| 4710 |
+ return this.rendered; |
|
| 4711 |
+ }, |
|
| 4712 |
+ |
|
| 4713 |
+ renderHTML : function() {
|
|
| 4714 |
+ }, |
|
| 4715 |
+ |
|
| 4716 |
+ renderTo : function(n) {
|
|
| 4717 |
+ DOM.setHTML(n, this.renderHTML()); |
|
| 4718 |
+ }, |
|
| 4719 |
+ |
|
| 4720 |
+ postRender : function() {
|
|
| 4721 |
+ var t = this, b; |
|
| 4722 |
+ |
|
| 4723 |
+ // Set pending states |
|
| 4724 |
+ if (is(t.disabled)) {
|
|
| 4725 |
+ b = t.disabled; |
|
| 4726 |
+ t.disabled = -1; |
|
| 4727 |
+ t.setDisabled(b); |
|
| 4728 |
+ } |
|
| 4729 |
+ |
|
| 4730 |
+ if (is(t.active)) {
|
|
| 4731 |
+ b = t.active; |
|
| 4732 |
+ t.active = -1; |
|
| 4733 |
+ t.setActive(b); |
|
| 4734 |
+ } |
|
| 4735 |
+ }, |
|
| 4736 |
+ |
|
| 4737 |
+ remove : function() {
|
|
| 4738 |
+ DOM.remove(this.id); |
|
| 4739 |
+ this.destroy(); |
|
| 4740 |
+ }, |
|
| 4741 |
+ |
|
| 4742 |
+ destroy : function() {
|
|
| 4743 |
+ tinymce.dom.Event.clear(this.id); |
|
| 4744 |
+ } |
|
| 4745 |
+ |
|
| 4746 |
+ }); |
|
| 4747 |
+})(); |
|
| 4748 |
+/* file:jscripts/tiny_mce/classes/ui/Container.js */ |
|
| 4749 |
+ |
|
| 4750 |
+tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
|
|
| 4751 |
+ Container : function(id, s) {
|
|
| 4752 |
+ this.parent(id, s); |
|
| 4753 |
+ this.controls = []; |
|
| 4754 |
+ this.lookup = {};
|
|
| 4755 |
+ }, |
|
| 4756 |
+ |
|
| 4757 |
+ add : function(c) {
|
|
| 4758 |
+ this.lookup[c.id] = c; |
|
| 4759 |
+ this.controls.push(c); |
|
| 4760 |
+ |
|
| 4761 |
+ return c; |
|
| 4762 |
+ }, |
|
| 4763 |
+ |
|
| 4764 |
+ get : function(n) {
|
|
| 4765 |
+ return this.lookup[n]; |
|
| 4766 |
+ } |
|
| 4767 |
+ |
|
| 4768 |
+ }); |
|
| 4769 |
+ |
|
| 4770 |
+ |
|
| 4771 |
+/* file:jscripts/tiny_mce/classes/ui/Separator.js */ |
|
| 4772 |
+ |
|
| 4773 |
+tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
|
|
| 4774 |
+ Separator : function(id, s) {
|
|
| 4775 |
+ this.parent(id, s); |
|
| 4776 |
+ this.classPrefix = 'mceSeparator'; |
|
| 4777 |
+ }, |
|
| 4778 |
+ |
|
| 4779 |
+ renderHTML : function() {
|
|
| 4780 |
+ return tinymce.DOM.createHTML('span', {'class' : this.classPrefix});
|
|
| 4781 |
+ } |
|
| 4782 |
+ |
|
| 4783 |
+ }); |
|
| 4784 |
+ |
|
| 4785 |
+/* file:jscripts/tiny_mce/classes/ui/MenuItem.js */ |
|
| 4786 |
+ |
|
| 4787 |
+(function() {
|
|
| 4788 |
+ var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk; |
|
| 4789 |
+ |
|
| 4790 |
+ tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
|
|
| 4791 |
+ MenuItem : function(id, s) {
|
|
| 4792 |
+ this.parent(id, s); |
|
| 4793 |
+ this.classPrefix = 'mceMenuItem'; |
|
| 4794 |
+ }, |
|
| 4795 |
+ |
|
| 4796 |
+ setSelected : function(s) {
|
|
| 4797 |
+ this.setState('Selected', s);
|
|
| 4798 |
+ this.selected = s; |
|
| 4799 |
+ }, |
|
| 4800 |
+ |
|
| 4801 |
+ isSelected : function() {
|
|
| 4802 |
+ return this.selected; |
|
| 4803 |
+ }, |
|
| 4804 |
+ |
|
| 4805 |
+ postRender : function() {
|
|
| 4806 |
+ var t = this; |
|
| 4807 |
+ |
|
| 4808 |
+ t.parent(); |
|
| 4809 |
+ |
|
| 4810 |
+ // Set pending state |
|
| 4811 |
+ if (is(t.selected)) |
|
| 4812 |
+ t.setSelected(t.selected); |
|
| 4813 |
+ } |
|
| 4814 |
+ |
|
| 4815 |
+ }); |
|
| 4816 |
+})(); |
|
| 4817 |
+ |
|
| 4818 |
+/* file:jscripts/tiny_mce/classes/ui/Menu.js */ |
|
| 4819 |
+ |
|
| 4820 |
+(function() {
|
|
| 4821 |
+ var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk; |
|
| 4822 |
+ |
|
| 4823 |
+ tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
|
|
| 4824 |
+ Menu : function(id, s) {
|
|
| 4825 |
+ var t = this; |
|
| 4826 |
+ |
|
| 4827 |
+ t.parent(id, s); |
|
| 4828 |
+ t.items = {};
|
|
| 4829 |
+ t.collapsed = false; |
|
| 4830 |
+ t.menuCount = 0; |
|
| 4831 |
+ t.onAddItem = new tinymce.util.Dispatcher(this); |
|
| 4832 |
+ }, |
|
| 4833 |
+ |
|
| 4834 |
+ expand : function(d) {
|
|
| 4835 |
+ var t = this; |
|
| 4836 |
+ |
|
| 4837 |
+ if (d) {
|
|
| 4838 |
+ walk(t, function(o) {
|
|
| 4839 |
+ if (o.expand) |
|
| 4840 |
+ o.expand(); |
|
| 4841 |
+ }, 'items', t); |
|
| 4842 |
+ } |
|
| 4843 |
+ |
|
| 4844 |
+ t.collapsed = false; |
|
| 4845 |
+ }, |
|
| 4846 |
+ |
|
| 4847 |
+ collapse : function(d) {
|
|
| 4848 |
+ var t = this; |
|
| 4849 |
+ |
|
| 4850 |
+ if (d) {
|
|
| 4851 |
+ walk(t, function(o) {
|
|
| 4852 |
+ if (o.collapse) |
|
| 4853 |
+ o.collapse(); |
|
| 4854 |
+ }, 'items', t); |
|
| 4855 |
+ } |
|
| 4856 |
+ |
|
| 4857 |
+ t.collapsed = true; |
|
| 4858 |
+ }, |
|
| 4859 |
+ |
|
| 4860 |
+ isCollapsed : function() {
|
|
| 4861 |
+ return this.collapsed; |
|
| 4862 |
+ }, |
|
| 4863 |
+ |
|
| 4864 |
+ add : function(o) {
|
|
| 4865 |
+ if (!o.settings) |
|
| 4866 |
+ o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o); |
|
| 4867 |
+ |
|
| 4868 |
+ this.onAddItem.dispatch(this, o); |
|
| 4869 |
+ |
|
| 4870 |
+ return this.items[o.id] = o; |
|
| 4871 |
+ }, |
|
| 4872 |
+ |
|
| 4873 |
+ addSeparator : function() {
|
|
| 4874 |
+ return this.add({separator : true});
|
|
| 4875 |
+ }, |
|
| 4876 |
+ |
|
| 4877 |
+ addMenu : function(o) {
|
|
| 4878 |
+ if (!o.collapse) |
|
| 4879 |
+ o = this.createMenu(o); |
|
| 4880 |
+ |
|
| 4881 |
+ this.menuCount++; |
|
| 4882 |
+ |
|
| 4883 |
+ return this.add(o); |
|
| 4884 |
+ }, |
|
| 4885 |
+ |
|
| 4886 |
+ hasMenus : function() {
|
|
| 4887 |
+ return this.menuCount !== 0; |
|
| 4888 |
+ }, |
|
| 4889 |
+ |
|
| 4890 |
+ remove : function(o) {
|
|
| 4891 |
+ delete this.items[o.id]; |
|
| 4892 |
+ }, |
|
| 4893 |
+ |
|
| 4894 |
+ removeAll : function() {
|
|
| 4895 |
+ var t = this; |
|
| 4896 |
+ |
|
| 4897 |
+ walk(t, function(o) {
|
|
| 4898 |
+ if (o.removeAll) |
|
| 4899 |
+ o.removeAll(); |
|
| 4900 |
+ else |
|
| 4901 |
+ o.remove(); |
|
| 4902 |
+ |
|
| 4903 |
+ o.destroy(); |
|
| 4904 |
+ }, 'items', t); |
|
| 4905 |
+ |
|
| 4906 |
+ t.items = {};
|
|
| 4907 |
+ }, |
|
| 4908 |
+ |
|
| 4909 |
+ createMenu : function(o) {
|
|
| 4910 |
+ var m = new tinymce.ui.Menu(o.id || DOM.uniqueId(), o); |
|
| 4911 |
+ |
|
| 4912 |
+ m.onAddItem.add(this.onAddItem.dispatch, this.onAddItem); |
|
| 4913 |
+ |
|
| 4914 |
+ return m; |
|
| 4915 |
+ } |
|
| 4916 |
+ |
|
| 4917 |
+ }); |
|
| 4918 |
+})(); |
|
| 4919 |
+/* file:jscripts/tiny_mce/classes/ui/DropMenu.js */ |
|
| 4920 |
+ |
|
| 4921 |
+(function() {
|
|
| 4922 |
+ var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element; |
|
| 4923 |
+ |
|
| 4924 |
+ tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', {
|
|
| 4925 |
+ DropMenu : function(id, s) {
|
|
| 4926 |
+ s = s || {};
|
|
| 4927 |
+ s.container = s.container || DOM.doc.body; |
|
| 4928 |
+ s.offset_x = s.offset_x || 0; |
|
| 4929 |
+ s.offset_y = s.offset_y || 0; |
|
| 4930 |
+ s.vp_offset_x = s.vp_offset_x || 0; |
|
| 4931 |
+ s.vp_offset_y = s.vp_offset_y || 0; |
|
| 4932 |
+ |
|
| 4933 |
+ if (is(s.icons) && !s.icons) |
|
| 4934 |
+ s['class'] += ' mceNoIcons'; |
|
| 4935 |
+ |
|
| 4936 |
+ this.parent(id, s); |
|
| 4937 |
+ this.onShowMenu = new tinymce.util.Dispatcher(this); |
|
| 4938 |
+ this.onHideMenu = new tinymce.util.Dispatcher(this); |
|
| 4939 |
+ this.classPrefix = 'mceMenu'; |
|
| 4940 |
+ }, |
|
| 4941 |
+ |
|
| 4942 |
+ createMenu : function(s) {
|
|
| 4943 |
+ var t = this, cs = t.settings, m; |
|
| 4944 |
+ |
|
| 4945 |
+ s.container = s.container || cs.container; |
|
| 4946 |
+ s.parent = t; |
|
| 4947 |
+ s.constrain = s.constrain || cs.constrain; |
|
| 4948 |
+ s['class'] = s['class'] || cs['class']; |
|
| 4949 |
+ s.vp_offset_x = s.vp_offset_x || cs.vp_offset_x; |
|
| 4950 |
+ s.vp_offset_y = s.vp_offset_y || cs.vp_offset_y; |
|
| 4951 |
+ m = new tinymce.ui.DropMenu(s.id || DOM.uniqueId(), s); |
|
| 4952 |
+ |
|
| 4953 |
+ m.onAddItem.add(t.onAddItem.dispatch, t.onAddItem); |
|
| 4954 |
+ |
|
| 4955 |
+ return m; |
|
| 4956 |
+ }, |
|
| 4957 |
+ |
|
| 4958 |
+ update : function() {
|
|
| 4959 |
+ var t = this, s = t.settings, tb = DOM.get('menu_' + t.id + '_tbl'), co = DOM.get('menu_' + t.id + '_co'), tw, th;
|
|
| 4960 |
+ |
|
| 4961 |
+ tw = s.max_width ? Math.min(tb.clientWidth, s.max_width) : tb.clientWidth; |
|
| 4962 |
+ th = s.max_height ? Math.min(tb.clientHeight, s.max_height) : tb.clientHeight; |
|
| 4963 |
+ |
|
| 4964 |
+ if (!DOM.boxModel) |
|
| 4965 |
+ t.element.setStyles({width : tw + 2, height : th + 2});
|
|
| 4966 |
+ else |
|
| 4967 |
+ t.element.setStyles({width : tw, height : th});
|
|
| 4968 |
+ |
|
| 4969 |
+ if (s.max_width) |
|
| 4970 |
+ DOM.setStyle(co, 'width', tw); |
|
| 4971 |
+ |
|
| 4972 |
+ if (s.max_height) {
|
|
| 4973 |
+ DOM.setStyle(co, 'height', th); |
|
| 4974 |
+ |
|
| 4975 |
+ if (tb.clientHeight < s.max_height) |
|
| 4976 |
+ DOM.setStyle(co, 'overflow', 'hidden'); |
|
| 4977 |
+ } |
|
| 4978 |
+ }, |
|
| 4979 |
+ |
|
| 4980 |
+ showMenu : function(x, y, px) {
|
|
| 4981 |
+ var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb, cp = t.classPrefix; |
|
| 4982 |
+ |
|
| 4983 |
+ t.collapse(1); |
|
| 4984 |
+ |
|
| 4985 |
+ if (t.isMenuVisible) |
|
| 4986 |
+ return; |
|
| 4987 |
+ |
|
| 4988 |
+ if (!t.rendered) {
|
|
| 4989 |
+ co = DOM.add(t.settings.container, t.renderNode()); |
|
| 4990 |
+ |
|
| 4991 |
+ each(t.items, function(o) {
|
|
| 4992 |
+ o.postRender(); |
|
| 4993 |
+ }); |
|
| 4994 |
+ |
|
| 4995 |
+ t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
|
|
| 4996 |
+ } else |
|
| 4997 |
+ co = DOM.get('menu_' + t.id);
|
|
| 4998 |
+ |
|
| 4999 |
+ // Move layer out of sight unless it's Opera since it scrolls to top of page due to an bug |
|
| 5000 |
+ if (!tinymce.isOpera) |
|
| 5001 |
+ DOM.setStyles(co, {left : -0xFFFF , top : -0xFFFF});
|
|
| 5002 |
+ |
|
| 5003 |
+ DOM.show(co); |
|
| 5004 |
+ t.update(); |
|
| 5005 |
+ |
|
| 5006 |
+ x += s.offset_x || 0; |
|
| 5007 |
+ y += s.offset_y || 0; |
|
| 5008 |
+ vp.w -= 4; |
|
| 5009 |
+ vp.h -= 4; |
|
| 5010 |
+ |
|
| 5011 |
+ // Move inside viewport if not submenu |
|
| 5012 |
+ if (s.constrain) {
|
|
| 5013 |
+ w = co.clientWidth - ot; |
|
| 5014 |
+ h = co.clientHeight - ot; |
|
| 5015 |
+ mx = vp.x + vp.w; |
|
| 5016 |
+ my = vp.y + vp.h; |
|
| 5017 |
+ |
|
| 5018 |
+ if ((x + s.vp_offset_x + w) > mx) |
|
| 5019 |
+ x = px ? px - w : Math.max(0, (mx - s.vp_offset_x) - w); |
|
| 5020 |
+ |
|
| 5021 |
+ if ((y + s.vp_offset_y + h) > my) |
|
| 5022 |
+ y = Math.max(0, (my - s.vp_offset_y) - h); |
|
| 5023 |
+ } |
|
| 5024 |
+ |
|
| 5025 |
+ DOM.setStyles(co, {left : x , top : y});
|
|
| 5026 |
+ t.element.update(); |
|
| 5027 |
+ |
|
| 5028 |
+ t.isMenuVisible = 1; |
|
| 5029 |
+ t.mouseClickFunc = Event.add(co, 'click', function(e) {
|
|
| 5030 |
+ var m; |
|
| 5031 |
+ |
|
| 5032 |
+ e = e.target; |
|
| 5033 |
+ |
|
| 5034 |
+ if (e && (e = DOM.getParent(e, 'TR')) && !DOM.hasClass(e, cp + 'ItemSub')) {
|
|
| 5035 |
+ m = t.items[e.id]; |
|
| 5036 |
+ |
|
| 5037 |
+ if (m.isDisabled()) |
|
| 5038 |
+ return; |
|
| 5039 |
+ |
|
| 5040 |
+ dm = t; |
|
| 5041 |
+ |
|
| 5042 |
+ while (dm) {
|
|
| 5043 |
+ if (dm.hideMenu) |
|
| 5044 |
+ dm.hideMenu(); |
|
| 5045 |
+ |
|
| 5046 |
+ dm = dm.settings.parent; |
|
| 5047 |
+ } |
|
| 5048 |
+ |
|
| 5049 |
+ if (m.settings.onclick) |
|
| 5050 |
+ m.settings.onclick(e); |
|
| 5051 |
+ |
|
| 5052 |
+ return Event.cancel(e); // Cancel to fix onbeforeunload problem |
|
| 5053 |
+ } |
|
| 5054 |
+ }); |
|
| 5055 |
+ |
|
| 5056 |
+ if (t.hasMenus()) {
|
|
| 5057 |
+ t.mouseOverFunc = Event.add(co, 'mouseover', function(e) {
|
|
| 5058 |
+ var m, r, mi; |
|
| 5059 |
+ |
|
| 5060 |
+ e = e.target; |
|
| 5061 |
+ if (e && (e = DOM.getParent(e, 'TR'))) {
|
|
| 5062 |
+ m = t.items[e.id]; |
|
| 5063 |
+ |
|
| 5064 |
+ if (t.lastMenu) |
|
| 5065 |
+ t.lastMenu.collapse(1); |
|
| 5066 |
+ |
|
| 5067 |
+ if (m.isDisabled()) |
|
| 5068 |
+ return; |
|
| 5069 |
+ |
|
| 5070 |
+ if (e && DOM.hasClass(e, cp + 'ItemSub')) {
|
|
| 5071 |
+ //p = DOM.getPos(s.container); |
|
| 5072 |
+ r = DOM.getRect(e); |
|
| 5073 |
+ m.showMenu((r.x + r.w - ot), r.y - ot, r.x); |
|
| 5074 |
+ t.lastMenu = m; |
|
| 5075 |
+ DOM.addClass(DOM.get(m.id).firstChild, cp + 'ItemActive'); |
|
| 5076 |
+ } |
|
| 5077 |
+ } |
|
| 5078 |
+ }); |
|
| 5079 |
+ } |
|
| 5080 |
+ |
|
| 5081 |
+ t.onShowMenu.dispatch(t); |
|
| 5082 |
+ |
|
| 5083 |
+ if (s.keyboard_focus) {
|
|
| 5084 |
+ Event.add(co, 'keydown', t._keyHandler, t); |
|
| 5085 |
+ DOM.select('a', 'menu_' + t.id)[0].focus(); // Select first link
|
|
| 5086 |
+ t._focusIdx = 0; |
|
| 5087 |
+ } |
|
| 5088 |
+ }, |
|
| 5089 |
+ |
|
| 5090 |
+ hideMenu : function(c) {
|
|
| 5091 |
+ var t = this, co = DOM.get('menu_' + t.id), e;
|
|
| 5092 |
+ |
|
| 5093 |
+ if (!t.isMenuVisible) |
|
| 5094 |
+ return; |
|
| 5095 |
+ |
|
| 5096 |
+ Event.remove(co, 'mouseover', t.mouseOverFunc); |
|
| 5097 |
+ Event.remove(co, 'click', t.mouseClickFunc); |
|
| 5098 |
+ Event.remove(co, 'keydown', t._keyHandler); |
|
| 5099 |
+ DOM.hide(co); |
|
| 5100 |
+ t.isMenuVisible = 0; |
|
| 5101 |
+ |
|
| 5102 |
+ if (!c) |
|
| 5103 |
+ t.collapse(1); |
|
| 5104 |
+ |
|
| 5105 |
+ if (t.element) |
|
| 5106 |
+ t.element.hide(); |
|
| 5107 |
+ |
|
| 5108 |
+ if (e = DOM.get(t.id)) |
|
| 5109 |
+ DOM.removeClass(e.firstChild, t.classPrefix + 'ItemActive'); |
|
| 5110 |
+ |
|
| 5111 |
+ t.onHideMenu.dispatch(t); |
|
| 5112 |
+ }, |
|
| 5113 |
+ |
|
| 5114 |
+ add : function(o) {
|
|
| 5115 |
+ var t = this, co; |
|
| 5116 |
+ |
|
| 5117 |
+ o = t.parent(o); |
|
| 5118 |
+ |
|
| 5119 |
+ if (t.isRendered && (co = DOM.get('menu_' + t.id)))
|
|
| 5120 |
+ t._add(DOM.select('tbody', co)[0], o);
|
|
| 5121 |
+ |
|
| 5122 |
+ return o; |
|
| 5123 |
+ }, |
|
| 5124 |
+ |
|
| 5125 |
+ collapse : function(d) {
|
|
| 5126 |
+ this.parent(d); |
|
| 5127 |
+ this.hideMenu(1); |
|
| 5128 |
+ }, |
|
| 5129 |
+ |
|
| 5130 |
+ remove : function(o) {
|
|
| 5131 |
+ DOM.remove(o.id); |
|
| 5132 |
+ this.destroy(); |
|
| 5133 |
+ |
|
| 5134 |
+ return this.parent(o); |
|
| 5135 |
+ }, |
|
| 5136 |
+ |
|
| 5137 |
+ destroy : function() {
|
|
| 5138 |
+ var t = this, co = DOM.get('menu_' + t.id);
|
|
| 5139 |
+ |
|
| 5140 |
+ Event.remove(co, 'mouseover', t.mouseOverFunc); |
|
| 5141 |
+ Event.remove(co, 'click', t.mouseClickFunc); |
|
| 5142 |
+ |
|
| 5143 |
+ if (t.element) |
|
| 5144 |
+ t.element.remove(); |
|
| 5145 |
+ |
|
| 5146 |
+ DOM.remove(co); |
|
| 5147 |
+ }, |
|
| 5148 |
+ |
|
| 5149 |
+ renderNode : function() {
|
|
| 5150 |
+ var t = this, s = t.settings, n, tb, co, w; |
|
| 5151 |
+ |
|
| 5152 |
+ w = DOM.create('div', {id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:200000'});
|
|
| 5153 |
+ co = DOM.add(w, 'div', {id : 'menu_' + t.id + '_co', 'class' : t.classPrefix + (s['class'] ? ' ' + s['class'] : '')});
|
|
| 5154 |
+ t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
|
|
| 5155 |
+ |
|
| 5156 |
+ if (s.menu_line) |
|
| 5157 |
+ DOM.add(co, 'span', {'class' : t.classPrefix + 'Line'});
|
|
| 5158 |
+ |
|
| 5159 |
+// n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'});
|
|
| 5160 |
+ n = DOM.add(co, 'table', {id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0});
|
|
| 5161 |
+ tb = DOM.add(n, 'tbody'); |
|
| 5162 |
+ |
|
| 5163 |
+ each(t.items, function(o) {
|
|
| 5164 |
+ t._add(tb, o); |
|
| 5165 |
+ }); |
|
| 5166 |
+ |
|
| 5167 |
+ t.rendered = true; |
|
| 5168 |
+ |
|
| 5169 |
+ return w; |
|
| 5170 |
+ }, |
|
| 5171 |
+ |
|
| 5172 |
+ // Internal functions |
|
| 5173 |
+ |
|
| 5174 |
+ _keyHandler : function(e) {
|
|
| 5175 |
+ var t = this, kc = e.keyCode; |
|
| 5176 |
+ |
|
| 5177 |
+ function focus(d) {
|
|
| 5178 |
+ var i = t._focusIdx + d, e = DOM.select('a', 'menu_' + t.id)[i];
|
|
| 5179 |
+ |
|
| 5180 |
+ if (e) {
|
|
| 5181 |
+ t._focusIdx = i; |
|
| 5182 |
+ e.focus(); |
|
| 5183 |
+ } |
|
| 5184 |
+ }; |
|
| 5185 |
+ |
|
| 5186 |
+ switch (kc) {
|
|
| 5187 |
+ case 38: |
|
| 5188 |
+ focus(-1); // Select first link |
|
| 5189 |
+ return; |
|
| 5190 |
+ |
|
| 5191 |
+ case 40: |
|
| 5192 |
+ focus(1); |
|
| 5193 |
+ return; |
|
| 5194 |
+ |
|
| 5195 |
+ case 13: |
|
| 5196 |
+ return; |
|
| 5197 |
+ |
|
| 5198 |
+ case 27: |
|
| 5199 |
+ return this.hideMenu(); |
|
| 5200 |
+ } |
|
| 5201 |
+ }, |
|
| 5202 |
+ |
|
| 5203 |
+ _add : function(tb, o) {
|
|
| 5204 |
+ var n, s = o.settings, a, ro, it, cp = this.classPrefix; |
|
| 5205 |
+ |
|
| 5206 |
+ if (s.separator) {
|
|
| 5207 |
+ ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'});
|
|
| 5208 |
+ DOM.add(ro, 'td', {'class' : cp + 'ItemSeparator'});
|
|
| 5209 |
+ |
|
| 5210 |
+ if (n = ro.previousSibling) |
|
| 5211 |
+ DOM.addClass(n, 'mceLast'); |
|
| 5212 |
+ |
|
| 5213 |
+ return; |
|
| 5214 |
+ } |
|
| 5215 |
+ |
|
| 5216 |
+ n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'Item ' + cp + 'ItemEnabled'});
|
|
| 5217 |
+ n = it = DOM.add(n, 'td'); |
|
| 5218 |
+ n = a = DOM.add(n, 'a', {href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'});
|
|
| 5219 |
+ |
|
| 5220 |
+ DOM.addClass(it, s['class']); |
|
| 5221 |
+// n = DOM.add(n, 'span', {'class' : 'item'});
|
|
| 5222 |
+ DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
|
|
| 5223 |
+ n = DOM.add(n, s.element || 'span', {'class' : 'mceText', title : o.settings.title}, o.settings.title);
|
|
| 5224 |
+ |
|
| 5225 |
+ if (o.settings.style) |
|
| 5226 |
+ DOM.setAttrib(n, 'style', o.settings.style); |
|
| 5227 |
+ |
|
| 5228 |
+ if (tb.childNodes.length == 1) |
|
| 5229 |
+ DOM.addClass(ro, 'mceFirst'); |
|
| 5230 |
+ |
|
| 5231 |
+ if ((n = ro.previousSibling) && DOM.hasClass(n, cp + 'ItemSeparator')) |
|
| 5232 |
+ DOM.addClass(ro, 'mceFirst'); |
|
| 5233 |
+ |
|
| 5234 |
+ if (o.collapse) |
|
| 5235 |
+ DOM.addClass(ro, cp + 'ItemSub'); |
|
| 5236 |
+ |
|
| 5237 |
+ if (n = ro.previousSibling) |
|
| 5238 |
+ DOM.removeClass(n, 'mceLast'); |
|
| 5239 |
+ |
|
| 5240 |
+ DOM.addClass(ro, 'mceLast'); |
|
| 5241 |
+ } |
|
| 5242 |
+ |
|
| 5243 |
+ }); |
|
| 5244 |
+})(); |
|
| 5245 |
+/* file:jscripts/tiny_mce/classes/ui/Button.js */ |
|
| 5246 |
+ |
|
| 5247 |
+(function() {
|
|
| 5248 |
+ var DOM = tinymce.DOM; |
|
| 5249 |
+ |
|
| 5250 |
+ tinymce.create('tinymce.ui.Button:tinymce.ui.Control', {
|
|
| 5251 |
+ Button : function(id, s) {
|
|
| 5252 |
+ this.parent(id, s); |
|
| 5253 |
+ this.classPrefix = 'mceButton'; |
|
| 5254 |
+ }, |
|
| 5255 |
+ |
|
| 5256 |
+ renderHTML : function() {
|
|
| 5257 |
+ var cp = this.classPrefix, s = this.settings, h, l; |
|
| 5258 |
+ |
|
| 5259 |
+ l = DOM.encode(s.label || ''); |
|
| 5260 |
+ h = '<a id="' + this.id + '" href="javascript:;" class="' + cp + ' ' + cp + 'Enabled ' + s['class'] + (l ? ' ' + cp + 'Labeled' : '') +'" onmousedown="return false;" onclick="return false;" title="' + DOM.encode(s.title) + '">'; |
|
| 5261 |
+ |
|
| 5262 |
+ if (s.image) |
|
| 5263 |
+ h += '<img class="mceIcon" src="' + s.image + '" />' + l + '</a>'; |
|
| 5264 |
+ else |
|
| 5265 |
+ h += '<span class="mceIcon ' + s['class'] + '"></span>' + (l ? '<span class="' + cp + 'Label">' + l + '</span>' : '') + '</a>'; |
|
| 5266 |
+ |
|
| 5267 |
+ return h; |
|
| 5268 |
+ }, |
|
| 5269 |
+ |
|
| 5270 |
+ postRender : function() {
|
|
| 5271 |
+ var t = this, s = t.settings; |
|
| 5272 |
+ |
|
| 5273 |
+ tinymce.dom.Event.add(t.id, 'click', function(e) {
|
|
| 5274 |
+ if (!t.isDisabled()) |
|
| 5275 |
+ return s.onclick.call(s.scope, e); |
|
| 5276 |
+ }); |
|
| 5277 |
+ } |
|
| 5278 |
+ |
|
| 5279 |
+ }); |
|
| 5280 |
+})(); |
|
| 5281 |
+ |
|
| 5282 |
+/* file:jscripts/tiny_mce/classes/ui/ListBox.js */ |
|
| 5283 |
+ |
|
| 5284 |
+(function() {
|
|
| 5285 |
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher; |
|
| 5286 |
+ |
|
| 5287 |
+ tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control', {
|
|
| 5288 |
+ ListBox : function(id, s) {
|
|
| 5289 |
+ var t = this; |
|
| 5290 |
+ |
|
| 5291 |
+ t.parent(id, s); |
|
| 5292 |
+ t.items = []; |
|
| 5293 |
+ t.onChange = new Dispatcher(t); |
|
| 5294 |
+ t.onPostRender = new Dispatcher(t); |
|
| 5295 |
+ t.onAdd = new Dispatcher(t); |
|
| 5296 |
+ t.onRenderMenu = new tinymce.util.Dispatcher(this); |
|
| 5297 |
+ t.classPrefix = 'mceListBox'; |
|
| 5298 |
+ }, |
|
| 5299 |
+ |
|
| 5300 |
+ select : function(v) {
|
|
| 5301 |
+ var t = this, e, fv; |
|
| 5302 |
+ |
|
| 5303 |
+ // Do we need to do something? |
|
| 5304 |
+ if (v != t.selectedValue) {
|
|
| 5305 |
+ e = DOM.get(t.id + '_text'); |
|
| 5306 |
+ t.selectedValue = v; |
|
| 5307 |
+ |
|
| 5308 |
+ // Find item |
|
| 5309 |
+ each(t.items, function(o) {
|
|
| 5310 |
+ if (o.value == v) {
|
|
| 5311 |
+ DOM.setHTML(e, DOM.encode(o.title)); |
|
| 5312 |
+ fv = 1; |
|
| 5313 |
+ return false; |
|
| 5314 |
+ } |
|
| 5315 |
+ }); |
|
| 5316 |
+ |
|
| 5317 |
+ // If no item was found then present title |
|
| 5318 |
+ if (!fv) {
|
|
| 5319 |
+ DOM.setHTML(e, DOM.encode(t.settings.title)); |
|
| 5320 |
+ DOM.addClass(e, 'mceTitle'); |
|
| 5321 |
+ e = 0; |
|
| 5322 |
+ return; |
|
| 5323 |
+ } else |
|
| 5324 |
+ DOM.removeClass(e, 'mceTitle'); |
|
| 5325 |
+ } |
|
| 5326 |
+ |
|
| 5327 |
+ e = 0; |
|
| 5328 |
+ }, |
|
| 5329 |
+ |
|
| 5330 |
+ add : function(n, v, o) {
|
|
| 5331 |
+ var t = this; |
|
| 5332 |
+ |
|
| 5333 |
+ o = o || {};
|
|
| 5334 |
+ o = tinymce.extend(o, {
|
|
| 5335 |
+ title : n, |
|
| 5336 |
+ value : v |
|
| 5337 |
+ }); |
|
| 5338 |
+ |
|
| 5339 |
+ t.items.push(o); |
|
| 5340 |
+ t.onAdd.dispatch(t, o); |
|
| 5341 |
+ }, |
|
| 5342 |
+ |
|
| 5343 |
+ getLength : function() {
|
|
| 5344 |
+ return this.items.length; |
|
| 5345 |
+ }, |
|
| 5346 |
+ |
|
| 5347 |
+ renderHTML : function() {
|
|
| 5348 |
+ var h = '', t = this, s = t.settings, cp = t.classPrefix; |
|
| 5349 |
+ |
|
| 5350 |
+ h = '<table id="' + t.id + '" cellpadding="0" cellspacing="0" class="' + cp + ' ' + cp + 'Enabled' + (s['class'] ? (' ' + s['class']) : '') + '"><tbody><tr>';
|
|
| 5351 |
+ h += '<td>' + DOM.createHTML('a', {id : t.id + '_text', href : 'javascript:;', 'class' : 'mceText', onclick : "return false;", onmousedown : 'return false;'}, DOM.encode(t.settings.title)) + '</td>';
|
|
| 5352 |
+ h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', tabindex : -1, href : 'javascript:;', 'class' : 'mceOpen', onclick : "return false;", onmousedown : 'return false;'}, '<span></span>') + '</td>';
|
|
| 5353 |
+ h += '</tr></tbody></table>'; |
|
| 5354 |
+ |
|
| 5355 |
+ return h; |
|
| 5356 |
+ }, |
|
| 5357 |
+ |
|
| 5358 |
+ showMenu : function() {
|
|
| 5359 |
+ var t = this, p1, p2, e = DOM.get(this.id), m; |
|
| 5360 |
+ |
|
| 5361 |
+ if (t.isDisabled() || t.items.length == 0) |
|
| 5362 |
+ return; |
|
| 5363 |
+ |
|
| 5364 |
+ if (t.menu && t.menu.isMenuVisible) |
|
| 5365 |
+ return t.hideMenu(); |
|
| 5366 |
+ |
|
| 5367 |
+ if (!t.isMenuRendered) {
|
|
| 5368 |
+ t.renderMenu(); |
|
| 5369 |
+ t.isMenuRendered = true; |
|
| 5370 |
+ } |
|
| 5371 |
+ |
|
| 5372 |
+ p1 = DOM.getPos(this.settings.menu_container); |
|
| 5373 |
+ p2 = DOM.getPos(e); |
|
| 5374 |
+ |
|
| 5375 |
+ m = t.menu; |
|
| 5376 |
+ m.settings.offset_x = p2.x; |
|
| 5377 |
+ m.settings.offset_y = p2.y; |
|
| 5378 |
+ m.settings.keyboard_focus = !tinymce.isOpera; // Opera is buggy when it comes to auto focus |
|
| 5379 |
+ |
|
| 5380 |
+ // Select in menu |
|
| 5381 |
+ if (t.oldID) |
|
| 5382 |
+ m.items[t.oldID].setSelected(0); |
|
| 5383 |
+ |
|
| 5384 |
+ each(t.items, function(o) {
|
|
| 5385 |
+ if (o.value === t.selectedValue) {
|
|
| 5386 |
+ m.items[o.id].setSelected(1); |
|
| 5387 |
+ t.oldID = o.id; |
|
| 5388 |
+ } |
|
| 5389 |
+ }); |
|
| 5390 |
+ |
|
| 5391 |
+ m.showMenu(0, e.clientHeight); |
|
| 5392 |
+ |
|
| 5393 |
+ Event.add(DOM.doc, 'mousedown', t.hideMenu, t); |
|
| 5394 |
+ DOM.addClass(t.id, t.classPrefix + 'Selected'); |
|
| 5395 |
+ |
|
| 5396 |
+ //DOM.get(t.id + '_text').focus(); |
|
| 5397 |
+ }, |
|
| 5398 |
+ |
|
| 5399 |
+ hideMenu : function(e) {
|
|
| 5400 |
+ var t = this; |
|
| 5401 |
+ |
|
| 5402 |
+ // Prevent double toogles by canceling the mouse click event to the button |
|
| 5403 |
+ if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open')) |
|
| 5404 |
+ return; |
|
| 5405 |
+ |
|
| 5406 |
+ if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
|
|
| 5407 |
+ DOM.removeClass(t.id, t.classPrefix + 'Selected'); |
|
| 5408 |
+ Event.remove(DOM.doc, 'mousedown', t.hideMenu, t); |
|
| 5409 |
+ |
|
| 5410 |
+ if (t.menu) |
|
| 5411 |
+ t.menu.hideMenu(); |
|
| 5412 |
+ } |
|
| 5413 |
+ }, |
|
| 5414 |
+ |
|
| 5415 |
+ renderMenu : function() {
|
|
| 5416 |
+ var t = this, m; |
|
| 5417 |
+ |
|
| 5418 |
+ m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
|
|
| 5419 |
+ menu_line : 1, |
|
| 5420 |
+ 'class' : t.classPrefix + 'Menu mceNoIcons', |
|
| 5421 |
+ max_width : 150, |
|
| 5422 |
+ max_height : 150 |
|
| 5423 |
+ }); |
|
| 5424 |
+ |
|
| 5425 |
+ m.onHideMenu.add(t.hideMenu, t); |
|
| 5426 |
+ |
|
| 5427 |
+ m.add({
|
|
| 5428 |
+ title : t.settings.title, |
|
| 5429 |
+ 'class' : 'mceMenuItemTitle' |
|
| 5430 |
+ }).setDisabled(1); |
|
| 5431 |
+ |
|
| 5432 |
+ each(t.items, function(o) {
|
|
| 5433 |
+ o.id = DOM.uniqueId(); |
|
| 5434 |
+ o.onclick = function() {
|
|
| 5435 |
+ if (t.settings.onselect(o.value) !== false) |
|
| 5436 |
+ t.select(o.value); // Must be runned after |
|
| 5437 |
+ }; |
|
| 5438 |
+ |
|
| 5439 |
+ m.add(o); |
|
| 5440 |
+ }); |
|
| 5441 |
+ |
|
| 5442 |
+ t.onRenderMenu.dispatch(t, m); |
|
| 5443 |
+ t.menu = m; |
|
| 5444 |
+ }, |
|
| 5445 |
+ |
|
| 5446 |
+ postRender : function() {
|
|
| 5447 |
+ var t = this, cp = t.classPrefix; |
|
| 5448 |
+ |
|
| 5449 |
+ Event.add(t.id, 'click', t.showMenu, t); |
|
| 5450 |
+ Event.add(t.id + '_text', 'focus', function(e) {
|
|
| 5451 |
+ if (!t._focused) {
|
|
| 5452 |
+ t.keyDownHandler = Event.add(t.id + '_text', 'keydown', function(e) {
|
|
| 5453 |
+ var idx = -1, v, kc = e.keyCode; |
|
| 5454 |
+ |
|
| 5455 |
+ // Find current index |
|
| 5456 |
+ each(t.items, function(v, i) {
|
|
| 5457 |
+ if (t.selectedValue == v.value) |
|
| 5458 |
+ idx = i; |
|
| 5459 |
+ }); |
|
| 5460 |
+ |
|
| 5461 |
+ // Move up/down |
|
| 5462 |
+ if (kc == 38) |
|
| 5463 |
+ v = t.items[idx - 1]; |
|
| 5464 |
+ else if (kc == 40) |
|
| 5465 |
+ v = t.items[idx + 1]; |
|
| 5466 |
+ else if (kc == 13) {
|
|
| 5467 |
+ // Fake select on enter |
|
| 5468 |
+ v = t.selectedValue; |
|
| 5469 |
+ t.selectedValue = null; // Needs to be null to fake change |
|
| 5470 |
+ t.settings.onselect(v); |
|
| 5471 |
+ return Event.cancel(e); |
|
| 5472 |
+ } |
|
| 5473 |
+ |
|
| 5474 |
+ if (v) {
|
|
| 5475 |
+ t.hideMenu(); |
|
| 5476 |
+ t.select(v.value); |
|
| 5477 |
+ } |
|
| 5478 |
+ }); |
|
| 5479 |
+ } |
|
| 5480 |
+ |
|
| 5481 |
+ t._focused = 1; |
|
| 5482 |
+ }); |
|
| 5483 |
+ Event.add(t.id + '_text', 'blur', function() {Event.remove(t.id + '_text', 'keydown', t.keyDownHandler); t._focused = 0;});
|
|
| 5484 |
+ |
|
| 5485 |
+ // Old IE doesn't have hover on all elements |
|
| 5486 |
+ if (tinymce.isIE6 || !DOM.boxModel) {
|
|
| 5487 |
+ Event.add(t.id, 'mouseover', function() {
|
|
| 5488 |
+ if (!DOM.hasClass(t.id, cp + 'Disabled')) |
|
| 5489 |
+ DOM.addClass(t.id, cp + 'Hover'); |
|
| 5490 |
+ }); |
|
| 5491 |
+ |
|
| 5492 |
+ Event.add(t.id, 'mouseout', function() {
|
|
| 5493 |
+ if (!DOM.hasClass(t.id, cp + 'Disabled')) |
|
| 5494 |
+ DOM.removeClass(t.id, cp + 'Hover'); |
|
| 5495 |
+ }); |
|
| 5496 |
+ } |
|
| 5497 |
+ |
|
| 5498 |
+ t.onPostRender.dispatch(t, DOM.get(t.id)); |
|
| 5499 |
+ }, |
|
| 5500 |
+ |
|
| 5501 |
+ destroy : function() {
|
|
| 5502 |
+ this.parent(); |
|
| 5503 |
+ |
|
| 5504 |
+ Event.clear(this.id + '_text'); |
|
| 5505 |
+ } |
|
| 5506 |
+ |
|
| 5507 |
+ }); |
|
| 5508 |
+})(); |
|
| 5509 |
+/* file:jscripts/tiny_mce/classes/ui/NativeListBox.js */ |
|
| 5510 |
+ |
|
| 5511 |
+(function() {
|
|
| 5512 |
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher; |
|
| 5513 |
+ |
|
| 5514 |
+ tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox', {
|
|
| 5515 |
+ NativeListBox : function(id, s) {
|
|
| 5516 |
+ this.parent(id, s); |
|
| 5517 |
+ this.classPrefix = 'mceNativeListBox'; |
|
| 5518 |
+ }, |
|
| 5519 |
+ |
|
| 5520 |
+ setDisabled : function(s) {
|
|
| 5521 |
+ DOM.get(this.id).disabled = s; |
|
| 5522 |
+ }, |
|
| 5523 |
+ |
|
| 5524 |
+ isDisabled : function() {
|
|
| 5525 |
+ return DOM.get(this.id).disabled; |
|
| 5526 |
+ }, |
|
| 5527 |
+ |
|
| 5528 |
+ select : function(v) {
|
|
| 5529 |
+ var e = DOM.get(this.id), ol = e.options; |
|
| 5530 |
+ |
|
| 5531 |
+ v = '' + (v || ''); |
|
| 5532 |
+ |
|
| 5533 |
+ e.selectedIndex = 0; |
|
| 5534 |
+ each(ol, function(o, i) {
|
|
| 5535 |
+ if (o.value == v) {
|
|
| 5536 |
+ e.selectedIndex = i; |
|
| 5537 |
+ return false; |
|
| 5538 |
+ } |
|
| 5539 |
+ }); |
|
| 5540 |
+ }, |
|
| 5541 |
+ |
|
| 5542 |
+ add : function(n, v, a) {
|
|
| 5543 |
+ var o, t = this; |
|
| 5544 |
+ |
|
| 5545 |
+ a = a || {};
|
|
| 5546 |
+ a.value = v; |
|
| 5547 |
+ |
|
| 5548 |
+ if (t.isRendered()) |
|
| 5549 |
+ DOM.add(DOM.get(this.id), 'option', a, n); |
|
| 5550 |
+ |
|
| 5551 |
+ o = {
|
|
| 5552 |
+ title : n, |
|
| 5553 |
+ value : v, |
|
| 5554 |
+ attribs : a |
|
| 5555 |
+ }; |
|
| 5556 |
+ |
|
| 5557 |
+ t.items.push(o); |
|
| 5558 |
+ t.onAdd.dispatch(t, o); |
|
| 5559 |
+ }, |
|
| 5560 |
+ |
|
| 5561 |
+ getLength : function() {
|
|
| 5562 |
+ return DOM.get(this.id).options.length - 1; |
|
| 5563 |
+ }, |
|
| 5564 |
+ |
|
| 5565 |
+ renderHTML : function() {
|
|
| 5566 |
+ var h, t = this; |
|
| 5567 |
+ |
|
| 5568 |
+ h = DOM.createHTML('option', {value : ''}, '-- ' + t.settings.title + ' --');
|
|
| 5569 |
+ |
|
| 5570 |
+ each(t.items, function(it) {
|
|
| 5571 |
+ h += DOM.createHTML('option', {value : it.value}, it.title);
|
|
| 5572 |
+ }); |
|
| 5573 |
+ |
|
| 5574 |
+ h = DOM.createHTML('select', {id : t.id, 'class' : 'mceNativeListBox'}, h);
|
|
| 5575 |
+ |
|
| 5576 |
+ return h; |
|
| 5577 |
+ }, |
|
| 5578 |
+ |
|
| 5579 |
+ postRender : function() {
|
|
| 5580 |
+ var t = this, ch; |
|
| 5581 |
+ |
|
| 5582 |
+ t.rendered = true; |
|
| 5583 |
+ |
|
| 5584 |
+ function onChange(e) {
|
|
| 5585 |
+ var v = e.target.options[e.target.selectedIndex].value; |
|
| 5586 |
+ |
|
| 5587 |
+ t.onChange.dispatch(t, v); |
|
| 5588 |
+ |
|
| 5589 |
+ if (t.settings.onselect) |
|
| 5590 |
+ t.settings.onselect(v); |
|
| 5591 |
+ }; |
|
| 5592 |
+ |
|
| 5593 |
+ Event.add(t.id, 'change', onChange); |
|
| 5594 |
+ |
|
| 5595 |
+ // Accessibility keyhandler |
|
| 5596 |
+ Event.add(t.id, 'keydown', function(e) {
|
|
| 5597 |
+ var bf; |
|
| 5598 |
+ |
|
| 5599 |
+ Event.remove(t.id, 'change', ch); |
|
| 5600 |
+ |
|
| 5601 |
+ bf = Event.add(t.id, 'blur', function() {
|
|
| 5602 |
+ Event.add(t.id, 'change', onChange); |
|
| 5603 |
+ Event.remove(t.id, 'blur', bf); |
|
| 5604 |
+ }); |
|
| 5605 |
+ |
|
| 5606 |
+ if (e.keyCode == 13 || e.keyCode == 32) {
|
|
| 5607 |
+ onChange(e); |
|
| 5608 |
+ return Event.cancel(e); |
|
| 5609 |
+ } |
|
| 5610 |
+ }); |
|
| 5611 |
+ |
|
| 5612 |
+ t.onPostRender.dispatch(t, DOM.get(t.id)); |
|
| 5613 |
+ } |
|
| 5614 |
+ |
|
| 5615 |
+ }); |
|
| 5616 |
+})(); |
|
| 5617 |
+/* file:jscripts/tiny_mce/classes/ui/MenuButton.js */ |
|
| 5618 |
+ |
|
| 5619 |
+(function() {
|
|
| 5620 |
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each; |
|
| 5621 |
+ |
|
| 5622 |
+ tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', {
|
|
| 5623 |
+ MenuButton : function(id, s) {
|
|
| 5624 |
+ this.parent(id, s); |
|
| 5625 |
+ this.onRenderMenu = new tinymce.util.Dispatcher(this); |
|
| 5626 |
+ s.menu_container = s.menu_container || DOM.doc.body; |
|
| 5627 |
+ }, |
|
| 5628 |
+ |
|
| 5629 |
+ showMenu : function() {
|
|
| 5630 |
+ var t = this, p1, p2, e = DOM.get(t.id), m; |
|
| 5631 |
+ |
|
| 5632 |
+ if (t.isDisabled()) |
|
| 5633 |
+ return; |
|
| 5634 |
+ |
|
| 5635 |
+ if (!t.isMenuRendered) {
|
|
| 5636 |
+ t.renderMenu(); |
|
| 5637 |
+ t.isMenuRendered = true; |
|
| 5638 |
+ } |
|
| 5639 |
+ |
|
| 5640 |
+ if (t.isMenuVisible) |
|
| 5641 |
+ return t.hideMenu(); |
|
| 5642 |
+ |
|
| 5643 |
+ p1 = DOM.getPos(t.settings.menu_container); |
|
| 5644 |
+ p2 = DOM.getPos(e); |
|
| 5645 |
+ |
|
| 5646 |
+ m = t.menu; |
|
| 5647 |
+ m.settings.offset_x = p2.x; |
|
| 5648 |
+ m.settings.offset_y = p2.y; |
|
| 5649 |
+ m.settings.vp_offset_x = p2.x; |
|
| 5650 |
+ m.settings.vp_offset_y = p2.y; |
|
| 5651 |
+ m.settings.keyboard_focus = t._focused; |
|
| 5652 |
+ m.showMenu(0, e.clientHeight); |
|
| 5653 |
+ |
|
| 5654 |
+ Event.add(DOM.doc, 'mousedown', t.hideMenu, t); |
|
| 5655 |
+ t.setState('Selected', 1);
|
|
| 5656 |
+ |
|
| 5657 |
+ t.isMenuVisible = 1; |
|
| 5658 |
+ }, |
|
| 5659 |
+ |
|
| 5660 |
+ renderMenu : function() {
|
|
| 5661 |
+ var t = this, m; |
|
| 5662 |
+ |
|
| 5663 |
+ m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
|
|
| 5664 |
+ menu_line : 1, |
|
| 5665 |
+ 'class' : this.classPrefix + 'Menu', |
|
| 5666 |
+ icons : t.settings.icons |
|
| 5667 |
+ }); |
|
| 5668 |
+ |
|
| 5669 |
+ m.onHideMenu.add(t.hideMenu, t); |
|
| 5670 |
+ |
|
| 5671 |
+ t.onRenderMenu.dispatch(t, m); |
|
| 5672 |
+ t.menu = m; |
|
| 5673 |
+ }, |
|
| 5674 |
+ |
|
| 5675 |
+ hideMenu : function(e) {
|
|
| 5676 |
+ var t = this; |
|
| 5677 |
+ |
|
| 5678 |
+ // Prevent double toogles by canceling the mouse click event to the button |
|
| 5679 |
+ if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';}))
|
|
| 5680 |
+ return; |
|
| 5681 |
+ |
|
| 5682 |
+ if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
|
|
| 5683 |
+ t.setState('Selected', 0);
|
|
| 5684 |
+ Event.remove(DOM.doc, 'mousedown', t.hideMenu, t); |
|
| 5685 |
+ if (t.menu) |
|
| 5686 |
+ t.menu.hideMenu(); |
|
| 5687 |
+ } |
|
| 5688 |
+ |
|
| 5689 |
+ t.isMenuVisible = 0; |
|
| 5690 |
+ }, |
|
| 5691 |
+ |
|
| 5692 |
+ postRender : function() {
|
|
| 5693 |
+ var t = this, s = t.settings; |
|
| 5694 |
+ |
|
| 5695 |
+ Event.add(t.id, 'click', function() {
|
|
| 5696 |
+ if (!t.isDisabled()) {
|
|
| 5697 |
+ if (s.onclick) |
|
| 5698 |
+ s.onclick(t.value); |
|
| 5699 |
+ |
|
| 5700 |
+ t.showMenu(); |
|
| 5701 |
+ } |
|
| 5702 |
+ }); |
|
| 5703 |
+ } |
|
| 5704 |
+ |
|
| 5705 |
+ }); |
|
| 5706 |
+})(); |
|
| 5707 |
+ |
|
| 5708 |
+/* file:jscripts/tiny_mce/classes/ui/SplitButton.js */ |
|
| 5709 |
+ |
|
| 5710 |
+(function() {
|
|
| 5711 |
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each; |
|
| 5712 |
+ |
|
| 5713 |
+ tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton', {
|
|
| 5714 |
+ SplitButton : function(id, s) {
|
|
| 5715 |
+ this.parent(id, s); |
|
| 5716 |
+ this.classPrefix = 'mceSplitButton'; |
|
| 5717 |
+ }, |
|
| 5718 |
+ |
|
| 5719 |
+ renderHTML : function() {
|
|
| 5720 |
+ var h, t = this, s = t.settings, h1; |
|
| 5721 |
+ |
|
| 5722 |
+ h = '<tbody><tr>'; |
|
| 5723 |
+ |
|
| 5724 |
+ if (s.image) |
|
| 5725 |
+ h1 = DOM.createHTML('img ', {src : s.image, 'class' : 'mceAction ' + s['class']});
|
|
| 5726 |
+ else |
|
| 5727 |
+ h1 = DOM.createHTML('span', {'class' : 'mceAction ' + s['class']}, '');
|
|
| 5728 |
+ |
|
| 5729 |
+ h += '<td>' + DOM.createHTML('a', {id : t.id + '_action', href : 'javascript:;', 'class' : 'mceAction ' + s['class'], onclick : "return false;", onmousedown : 'return false;', title : s.title}, h1) + '</td>';
|
|
| 5730 |
+ |
|
| 5731 |
+ h1 = DOM.createHTML('span', {'class' : 'mceOpen ' + s['class']});
|
|
| 5732 |
+ h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', href : 'javascript:;', 'class' : 'mceOpen ' + s['class'], onclick : "return false;", onmousedown : 'return false;', title : s.title}, h1) + '</td>';
|
|
| 5733 |
+ |
|
| 5734 |
+ h += '</tr></tbody>'; |
|
| 5735 |
+ |
|
| 5736 |
+ return DOM.createHTML('table', {id : t.id, 'class' : 'mceSplitButton mceSplitButtonEnabled ' + s['class'], cellpadding : '0', cellspacing : '0', onmousedown : 'return false;', title : s.title}, h);
|
|
| 5737 |
+ }, |
|
| 5738 |
+ |
|
| 5739 |
+ postRender : function() {
|
|
| 5740 |
+ var t = this, s = t.settings; |
|
| 5741 |
+ |
|
| 5742 |
+ if (s.onclick) {
|
|
| 5743 |
+ Event.add(t.id + '_action', 'click', function() {
|
|
| 5744 |
+ if (!t.isDisabled()) |
|
| 5745 |
+ s.onclick(t.value); |
|
| 5746 |
+ }); |
|
| 5747 |
+ } |
|
| 5748 |
+ |
|
| 5749 |
+ Event.add(t.id + '_open', 'click', t.showMenu, t); |
|
| 5750 |
+ Event.add(t.id + '_open', 'focus', function() {t._focused = 1;});
|
|
| 5751 |
+ Event.add(t.id + '_open', 'blur', function() {t._focused = 0;});
|
|
| 5752 |
+ |
|
| 5753 |
+ // Old IE doesn't have hover on all elements |
|
| 5754 |
+ if (tinymce.isIE6 || !DOM.boxModel) {
|
|
| 5755 |
+ Event.add(t.id, 'mouseover', function() {
|
|
| 5756 |
+ if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled')) |
|
| 5757 |
+ DOM.addClass(t.id, 'mceSplitButtonHover'); |
|
| 5758 |
+ }); |
|
| 5759 |
+ |
|
| 5760 |
+ Event.add(t.id, 'mouseout', function() {
|
|
| 5761 |
+ if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled')) |
|
| 5762 |
+ DOM.removeClass(t.id, 'mceSplitButtonHover'); |
|
| 5763 |
+ }); |
|
| 5764 |
+ } |
|
| 5765 |
+ }, |
|
| 5766 |
+ |
|
| 5767 |
+ destroy : function() {
|
|
| 5768 |
+ this.parent(); |
|
| 5769 |
+ |
|
| 5770 |
+ Event.clear(this.id + '_action'); |
|
| 5771 |
+ Event.clear(this.id + '_open'); |
|
| 5772 |
+ } |
|
| 5773 |
+ |
|
| 5774 |
+ }); |
|
| 5775 |
+})(); |
|
| 5776 |
+ |
|
| 5777 |
+/* file:jscripts/tiny_mce/classes/ui/ColorSplitButton.js */ |
|
| 5778 |
+ |
|
| 5779 |
+(function() {
|
|
| 5780 |
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, is = tinymce.is, each = tinymce.each; |
|
| 5781 |
+ |
|
| 5782 |
+ tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton', {
|
|
| 5783 |
+ ColorSplitButton : function(id, s) {
|
|
| 5784 |
+ var t = this; |
|
| 5785 |
+ |
|
| 5786 |
+ t.parent(id, s); |
|
| 5787 |
+ |
|
| 5788 |
+ t.settings = s = tinymce.extend({
|
|
| 5789 |
+ colors : '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF', |
|
| 5790 |
+ grid_width : 8, |
|
| 5791 |
+ default_color : '#888888' |
|
| 5792 |
+ }, t.settings); |
|
| 5793 |
+ |
|
| 5794 |
+ t.onShowMenu = new tinymce.util.Dispatcher(t); |
|
| 5795 |
+ t.onHideMenu = new tinymce.util.Dispatcher(t); |
|
| 5796 |
+ |
|
| 5797 |
+ t.value = s.default_color; |
|
| 5798 |
+ }, |
|
| 5799 |
+ |
|
| 5800 |
+ showMenu : function() {
|
|
| 5801 |
+ var t = this, r, p, e, p2; |
|
| 5802 |
+ |
|
| 5803 |
+ if (t.isDisabled()) |
|
| 5804 |
+ return; |
|
| 5805 |
+ |
|
| 5806 |
+ if (!t.isMenuRendered) {
|
|
| 5807 |
+ t.renderMenu(); |
|
| 5808 |
+ t.isMenuRendered = true; |
|
| 5809 |
+ } |
|
| 5810 |
+ |
|
| 5811 |
+ if (t.isMenuVisible) |
|
| 5812 |
+ return t.hideMenu(); |
|
| 5813 |
+ |
|
| 5814 |
+ e = DOM.get(t.id); |
|
| 5815 |
+ DOM.show(t.id + '_menu'); |
|
| 5816 |
+ DOM.addClass(e, 'mceSplitButtonSelected'); |
|
| 5817 |
+ p2 = DOM.getPos(e); |
|
| 5818 |
+ DOM.setStyles(t.id + '_menu', {
|
|
| 5819 |
+ left : p2.x, |
|
| 5820 |
+ top : p2.y + e.clientHeight, |
|
| 5821 |
+ zIndex : 200000 |
|
| 5822 |
+ }); |
|
| 5823 |
+ e = 0; |
|
| 5824 |
+ |
|
| 5825 |
+ Event.add(DOM.doc, 'mousedown', t.hideMenu, t); |
|
| 5826 |
+ |
|
| 5827 |
+ if (t._focused) {
|
|
| 5828 |
+ t._keyHandler = Event.add(t.id + '_menu', 'keydown', function(e) {
|
|
| 5829 |
+ if (e.keyCode == 27) |
|
| 5830 |
+ t.hideMenu(); |
|
| 5831 |
+ }); |
|
| 5832 |
+ |
|
| 5833 |
+ DOM.select('a', t.id + '_menu')[0].focus(); // Select first link
|
|
| 5834 |
+ } |
|
| 5835 |
+ |
|
| 5836 |
+ t.onShowMenu.dispatch(t); |
|
| 5837 |
+ |
|
| 5838 |
+ t.isMenuVisible = 1; |
|
| 5839 |
+ }, |
|
| 5840 |
+ |
|
| 5841 |
+ hideMenu : function(e) {
|
|
| 5842 |
+ var t = this; |
|
| 5843 |
+ |
|
| 5844 |
+ // Prevent double toogles by canceling the mouse click event to the button |
|
| 5845 |
+ if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';}))
|
|
| 5846 |
+ return; |
|
| 5847 |
+ |
|
| 5848 |
+ if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceSplitButtonMenu');})) {
|
|
| 5849 |
+ DOM.removeClass(t.id, 'mceSplitButtonSelected'); |
|
| 5850 |
+ Event.remove(DOM.doc, 'mousedown', t.hideMenu, t); |
|
| 5851 |
+ Event.remove(t.id + '_menu', 'keydown', t._keyHandler); |
|
| 5852 |
+ DOM.hide(t.id + '_menu'); |
|
| 5853 |
+ } |
|
| 5854 |
+ |
|
| 5855 |
+ t.onHideMenu.dispatch(t); |
|
| 5856 |
+ |
|
| 5857 |
+ t.isMenuVisible = 0; |
|
| 5858 |
+ }, |
|
| 5859 |
+ |
|
| 5860 |
+ renderMenu : function() {
|
|
| 5861 |
+ var t = this, m, i = 0, s = t.settings, n, tb, tr, w; |
|
| 5862 |
+ |
|
| 5863 |
+ w = DOM.add(s.menu_container, 'div', {id : t.id + '_menu', 'class' : s['menu_class'] + ' ' + s['class'], style : 'position:absolute;left:0;top:-1000px;'});
|
|
| 5864 |
+ m = DOM.add(w, 'div', {'class' : s['class'] + ' mceSplitButtonMenu'});
|
|
| 5865 |
+ DOM.add(m, 'span', {'class' : 'mceMenuLine'});
|
|
| 5866 |
+ |
|
| 5867 |
+ n = DOM.add(m, 'table', {'class' : 'mceColorSplitMenu'});
|
|
| 5868 |
+ tb = DOM.add(n, 'tbody'); |
|
| 5869 |
+ |
|
| 5870 |
+ // Generate color grid |
|
| 5871 |
+ i = 0; |
|
| 5872 |
+ each(is(s.colors, 'array') ? s.colors : s.colors.split(','), function(c) {
|
|
| 5873 |
+ c = c.replace(/^#/, ''); |
|
| 5874 |
+ |
|
| 5875 |
+ if (!i--) {
|
|
| 5876 |
+ tr = DOM.add(tb, 'tr'); |
|
| 5877 |
+ i = s.grid_width - 1; |
|
| 5878 |
+ } |
|
| 5879 |
+ |
|
| 5880 |
+ n = DOM.add(tr, 'td'); |
|
| 5881 |
+ |
|
| 5882 |
+ n = DOM.add(n, 'a', {
|
|
| 5883 |
+ href : 'javascript:;', |
|
| 5884 |
+ style : {
|
|
| 5885 |
+ backgroundColor : '#' + c |
|
| 5886 |
+ }, |
|
| 5887 |
+ mce_color : '#' + c |
|
| 5888 |
+ }); |
|
| 5889 |
+ }); |
|
| 5890 |
+ |
|
| 5891 |
+ if (s.more_colors_func) {
|
|
| 5892 |
+ n = DOM.add(tb, 'tr'); |
|
| 5893 |
+ n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'});
|
|
| 5894 |
+ n = DOM.add(n, 'a', {id : t.id + '_more', href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title);
|
|
| 5895 |
+ |
|
| 5896 |
+ Event.add(n, 'click', function(e) {
|
|
| 5897 |
+ s.more_colors_func.call(s.more_colors_scope || this); |
|
| 5898 |
+ return Event.cancel(e); // Cancel to fix onbeforeunload problem |
|
| 5899 |
+ }); |
|
| 5900 |
+ } |
|
| 5901 |
+ |
|
| 5902 |
+ DOM.addClass(m, 'mceColorSplitMenu'); |
|
| 5903 |
+ |
|
| 5904 |
+ Event.add(t.id + '_menu', 'click', function(e) {
|
|
| 5905 |
+ var c; |
|
| 5906 |
+ |
|
| 5907 |
+ e = e.target; |
|
| 5908 |
+ |
|
| 5909 |
+ if (e.nodeName == 'A' && (c = e.getAttribute('mce_color')))
|
|
| 5910 |
+ t.setColor(c); |
|
| 5911 |
+ |
|
| 5912 |
+ return Event.cancel(e); // Prevent IE auto save warning |
|
| 5913 |
+ }); |
|
| 5914 |
+ |
|
| 5915 |
+ return w; |
|
| 5916 |
+ }, |
|
| 5917 |
+ |
|
| 5918 |
+ setColor : function(c) {
|
|
| 5919 |
+ var t = this; |
|
| 5920 |
+ |
|
| 5921 |
+ DOM.setStyle(t.id + '_preview', 'backgroundColor', c); |
|
| 5922 |
+ |
|
| 5923 |
+ t.value = c; |
|
| 5924 |
+ t.hideMenu(); |
|
| 5925 |
+ t.settings.onselect(c); |
|
| 5926 |
+ }, |
|
| 5927 |
+ |
|
| 5928 |
+ postRender : function() {
|
|
| 5929 |
+ var t = this, id = t.id; |
|
| 5930 |
+ |
|
| 5931 |
+ t.parent(); |
|
| 5932 |
+ DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'});
|
|
| 5933 |
+ }, |
|
| 5934 |
+ |
|
| 5935 |
+ destroy : function() {
|
|
| 5936 |
+ this.parent(); |
|
| 5937 |
+ |
|
| 5938 |
+ Event.clear(this.id + '_menu'); |
|
| 5939 |
+ Event.clear(this.id + '_more'); |
|
| 5940 |
+ DOM.remove(this.id + '_menu'); |
|
| 5941 |
+ } |
|
| 5942 |
+ |
|
| 5943 |
+ }); |
|
| 5944 |
+})(); |
|
| 5945 |
+ |
|
| 5946 |
+/* file:jscripts/tiny_mce/classes/ui/Toolbar.js */ |
|
| 5947 |
+ |
|
| 5948 |
+tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
|
|
| 5949 |
+ renderHTML : function() {
|
|
| 5950 |
+ var t = this, h = '', c, co, dom = tinymce.DOM, s = t.settings, i, pr, nx, cl; |
|
| 5951 |
+ |
|
| 5952 |
+ cl = t.controls; |
|
| 5953 |
+ for (i=0; i<cl.length; i++) {
|
|
| 5954 |
+ // Get current control, prev control, next control and if the control is a list box or not |
|
| 5955 |
+ co = cl[i]; |
|
| 5956 |
+ pr = cl[i - 1]; |
|
| 5957 |
+ nx = cl[i + 1]; |
|
| 5958 |
+ |
|
| 5959 |
+ // Add toolbar start |
|
| 5960 |
+ if (i === 0) {
|
|
| 5961 |
+ c = 'mceToolbarStart'; |
|
| 5962 |
+ |
|
| 5963 |
+ if (co.Button) |
|
| 5964 |
+ c += ' mceToolbarStartButton'; |
|
| 5965 |
+ else if (co.SplitButton) |
|
| 5966 |
+ c += ' mceToolbarStartSplitButton'; |
|
| 5967 |
+ else if (co.ListBox) |
|
| 5968 |
+ c += ' mceToolbarStartListBox'; |
|
| 5969 |
+ |
|
| 5970 |
+ h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
|
|
| 5971 |
+ } |
|
| 5972 |
+ |
|
| 5973 |
+ // Add toolbar end before list box and after the previous button |
|
| 5974 |
+ // This is to fix the o2k7 editor skins |
|
| 5975 |
+ if (pr && co.ListBox) {
|
|
| 5976 |
+ if (pr.Button || pr.SplitButton) |
|
| 5977 |
+ h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, '<!-- IE -->'));
|
|
| 5978 |
+ } |
|
| 5979 |
+ |
|
| 5980 |
+ // Render control HTML |
|
| 5981 |
+ |
|
| 5982 |
+ // IE 8 quick fix, needed to propertly generate a hit area for anchors |
|
| 5983 |
+ if (dom.stdMode) |
|
| 5984 |
+ h += '<td style="position: relative">' + co.renderHTML() + '</td>'; |
|
| 5985 |
+ else |
|
| 5986 |
+ h += '<td>' + co.renderHTML() + '</td>'; |
|
| 5987 |
+ |
|
| 5988 |
+ // Add toolbar start after list box and before the next button |
|
| 5989 |
+ // This is to fix the o2k7 editor skins |
|
| 5990 |
+ if (nx && co.ListBox) {
|
|
| 5991 |
+ if (nx.Button || nx.SplitButton) |
|
| 5992 |
+ h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '<!-- IE -->'));
|
|
| 5993 |
+ } |
|
| 5994 |
+ } |
|
| 5995 |
+ |
|
| 5996 |
+ c = 'mceToolbarEnd'; |
|
| 5997 |
+ |
|
| 5998 |
+ if (co.Button) |
|
| 5999 |
+ c += ' mceToolbarEndButton'; |
|
| 6000 |
+ else if (co.SplitButton) |
|
| 6001 |
+ c += ' mceToolbarEndSplitButton'; |
|
| 6002 |
+ else if (co.ListBox) |
|
| 6003 |
+ c += ' mceToolbarEndListBox'; |
|
| 6004 |
+ |
|
| 6005 |
+ h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
|
|
| 6006 |
+ |
|
| 6007 |
+ return dom.createHTML('table', {id : t.id, 'class' : 'mceToolbar' + (s['class'] ? ' ' + s['class'] : ''), cellpadding : '0', cellspacing : '0', align : t.settings.align || ''}, '<tbody><tr>' + h + '</tr></tbody>');
|
|
| 6008 |
+ } |
|
| 6009 |
+ |
|
| 6010 |
+ }); |
|
| 6011 |
+ |
|
| 6012 |
+/* file:jscripts/tiny_mce/classes/AddOnManager.js */ |
|
| 6013 |
+ |
|
| 6014 |
+(function() {
|
|
| 6015 |
+ var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each; |
|
| 6016 |
+ |
|
| 6017 |
+ tinymce.create('tinymce.AddOnManager', {
|
|
| 6018 |
+ items : [], |
|
| 6019 |
+ urls : {},
|
|
| 6020 |
+ lookup : {},
|
|
| 6021 |
+ onAdd : new Dispatcher(this), |
|
| 6022 |
+ |
|
| 6023 |
+ get : function(n) {
|
|
| 6024 |
+ return this.lookup[n]; |
|
| 6025 |
+ }, |
|
| 6026 |
+ |
|
| 6027 |
+ requireLangPack : function(n) {
|
|
| 6028 |
+ var u, s; |
|
| 6029 |
+ |
|
| 6030 |
+ if (tinymce.EditorManager.settings) {
|
|
| 6031 |
+ u = this.urls[n] + '/langs/' + tinymce.EditorManager.settings.language + '.js'; |
|
| 6032 |
+ s = tinymce.EditorManager.settings; |
|
| 6033 |
+ |
|
| 6034 |
+ if (s) {
|
|
| 6035 |
+ if (!tinymce.dom.Event.domLoaded && !s.strict_mode) |
|
| 6036 |
+ tinymce.ScriptLoader.load(u); |
|
| 6037 |
+ else |
|
| 6038 |
+ tinymce.ScriptLoader.add(u); |
|
| 6039 |
+ } |
|
| 6040 |
+ } |
|
| 6041 |
+ }, |
|
| 6042 |
+ |
|
| 6043 |
+ add : function(id, o) {
|
|
| 6044 |
+ this.items.push(o); |
|
| 6045 |
+ this.lookup[id] = o; |
|
| 6046 |
+ this.onAdd.dispatch(this, id, o); |
|
| 6047 |
+ |
|
| 6048 |
+ return o; |
|
| 6049 |
+ }, |
|
| 6050 |
+ |
|
| 6051 |
+ load : function(n, u, cb, s) {
|
|
| 6052 |
+ var t = this; |
|
| 6053 |
+ |
|
| 6054 |
+ if (t.urls[n]) |
|
| 6055 |
+ return; |
|
| 6056 |
+ |
|
| 6057 |
+ if (u.indexOf('/') != 0 && u.indexOf('://') == -1)
|
|
| 6058 |
+ u = tinymce.baseURL + '/' + u; |
|
| 6059 |
+ |
|
| 6060 |
+ t.urls[n] = u.substring(0, u.lastIndexOf('/'));
|
|
| 6061 |
+ tinymce.ScriptLoader.add(u, cb, s); |
|
| 6062 |
+ } |
|
| 6063 |
+ |
|
| 6064 |
+ }); |
|
| 6065 |
+ |
|
| 6066 |
+ // Create plugin and theme managers |
|
| 6067 |
+ tinymce.PluginManager = new tinymce.AddOnManager(); |
|
| 6068 |
+ tinymce.ThemeManager = new tinymce.AddOnManager(); |
|
| 6069 |
+}()); |
|
| 6070 |
+/* file:jscripts/tiny_mce/classes/EditorManager.js */ |
|
| 6071 |
+ |
|
| 6072 |
+(function() {
|
|
| 6073 |
+ // Shorten names |
|
| 6074 |
+ var each = tinymce.each, extend = tinymce.extend, DOM = tinymce.DOM, Event = tinymce.dom.Event, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, explode = tinymce.explode; |
|
| 6075 |
+ |
|
| 6076 |
+ tinymce.create('static tinymce.EditorManager', {
|
|
| 6077 |
+ editors : {},
|
|
| 6078 |
+ i18n : {},
|
|
| 6079 |
+ activeEditor : null, |
|
| 6080 |
+ |
|
| 6081 |
+ preInit : function() {
|
|
| 6082 |
+ var t = this, lo = window.location; |
|
| 6083 |
+ |
|
| 6084 |
+ // Setup some URLs where the editor API is located and where the document is |
|
| 6085 |
+ tinymce.documentBaseURL = lo.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, ''); |
|
| 6086 |
+ if (!/[\/\\]$/.test(tinymce.documentBaseURL)) |
|
| 6087 |
+ tinymce.documentBaseURL += '/'; |
|
| 6088 |
+ |
|
| 6089 |
+ tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL); |
|
| 6090 |
+ tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL); |
|
| 6091 |
+ |
|
| 6092 |
+ // Setup document domain |
|
| 6093 |
+ if (tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname) |
|
| 6094 |
+ document.domain = tinymce.relaxedDomain = lo.hostname.replace(/.*\.(.+\..+)$/, '$1'); |
|
| 6095 |
+ |
|
| 6096 |
+ // Add before unload listener |
|
| 6097 |
+ // This was required since IE was leaking memory if you added and removed beforeunload listeners |
|
| 6098 |
+ // with attachEvent/detatchEvent so this only adds one listener and instances can the attach to the onBeforeUnload event |
|
| 6099 |
+ t.onBeforeUnload = new tinymce.util.Dispatcher(t); |
|
| 6100 |
+ |
|
| 6101 |
+ // Must be on window or IE will leak if the editor is placed in frame or iframe |
|
| 6102 |
+ Event.add(window, 'beforeunload', function(e) {
|
|
| 6103 |
+ t.onBeforeUnload.dispatch(t, e); |
|
| 6104 |
+ }); |
|
| 6105 |
+ }, |
|
| 6106 |
+ |
|
| 6107 |
+ init : function(s) {
|
|
| 6108 |
+ var t = this, pl, sl = tinymce.ScriptLoader, c, e; |
|
| 6109 |
+ |
|
| 6110 |
+ function execCallback(se, n, s) {
|
|
| 6111 |
+ var f = se[n]; |
|
| 6112 |
+ |
|
| 6113 |
+ if (!f) |
|
| 6114 |
+ return; |
|
| 6115 |
+ |
|
| 6116 |
+ if (tinymce.is(f, 'string')) {
|
|
| 6117 |
+ s = f.replace(/\.\w+$/, ''); |
|
| 6118 |
+ s = s ? tinymce.resolve(s) : 0; |
|
| 6119 |
+ f = tinymce.resolve(f); |
|
| 6120 |
+ } |
|
| 6121 |
+ |
|
| 6122 |
+ return f.apply(s || this, Array.prototype.slice.call(arguments, 2)); |
|
| 6123 |
+ }; |
|
| 6124 |
+ |
|
| 6125 |
+ s = extend({
|
|
| 6126 |
+ theme : "simple", |
|
| 6127 |
+ language : "en", |
|
| 6128 |
+ strict_loading_mode : document.contentType == 'application/xhtml+xml' |
|
| 6129 |
+ }, s); |
|
| 6130 |
+ |
|
| 6131 |
+ t.settings = s; |
|
| 6132 |
+ |
|
| 6133 |
+ // If page not loaded and strict mode isn't enabled then load them |
|
| 6134 |
+ if (!Event.domLoaded && !s.strict_loading_mode) {
|
|
| 6135 |
+ // Load language |
|
| 6136 |
+ if (s.language) |
|
| 6137 |
+ sl.add(tinymce.baseURL + '/langs/' + s.language + '.js'); |
|
| 6138 |
+ |
|
| 6139 |
+ // Load theme |
|
| 6140 |
+ if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme]) |
|
| 6141 |
+ ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js'); |
|
| 6142 |
+ |
|
| 6143 |
+ // Load plugins |
|
| 6144 |
+ if (s.plugins) {
|
|
| 6145 |
+ pl = explode(s.plugins); |
|
| 6146 |
+ |
|
| 6147 |
+ // Load compat2x first |
|
| 6148 |
+ if (tinymce.inArray(pl, 'compat2x') != -1) |
|
| 6149 |
+ PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
|
|
| 6150 |
+ |
|
| 6151 |
+ // Load rest if plugins |
|
| 6152 |
+ each(pl, function(v) {
|
|
| 6153 |
+ if (v && v.charAt(0) != '-' && !PluginManager.urls[v]) {
|
|
| 6154 |
+ // Skip safari plugin for other browsers |
|
| 6155 |
+ if (!tinymce.isWebKit && v == 'safari') |
|
| 6156 |
+ return; |
|
| 6157 |
+ |
|
| 6158 |
+ PluginManager.load(v, 'plugins/' + v + '/editor_plugin' + tinymce.suffix + '.js'); |
|
| 6159 |
+ } |
|
| 6160 |
+ }); |
|
| 6161 |
+ } |
|
| 6162 |
+ |
|
| 6163 |
+ sl.loadQueue(); |
|
| 6164 |
+ } |
|
| 6165 |
+ |
|
| 6166 |
+ // Legacy call |
|
| 6167 |
+ Event.add(document, 'init', function() {
|
|
| 6168 |
+ var l, co; |
|
| 6169 |
+ |
|
| 6170 |
+ execCallback(s, 'onpageload'); |
|
| 6171 |
+ |
|
| 6172 |
+ // Verify that it's a valid browser |
|
| 6173 |
+ if (s.browsers) {
|
|
| 6174 |
+ l = false; |
|
| 6175 |
+ |
|
| 6176 |
+ each(explode(s.browsers), function(v) {
|
|
| 6177 |
+ switch (v) {
|
|
| 6178 |
+ case 'ie': |
|
| 6179 |
+ case 'msie': |
|
| 6180 |
+ if (tinymce.isIE) |
|
| 6181 |
+ l = true; |
|
| 6182 |
+ break; |
|
| 6183 |
+ |
|
| 6184 |
+ case 'gecko': |
|
| 6185 |
+ if (tinymce.isGecko) |
|
| 6186 |
+ l = true; |
|
| 6187 |
+ break; |
|
| 6188 |
+ |
|
| 6189 |
+ case 'safari': |
|
| 6190 |
+ case 'webkit': |
|
| 6191 |
+ if (tinymce.isWebKit) |
|
| 6192 |
+ l = true; |
|
| 6193 |
+ break; |
|
| 6194 |
+ |
|
| 6195 |
+ case 'opera': |
|
| 6196 |
+ if (tinymce.isOpera) |
|
| 6197 |
+ l = true; |
|
| 6198 |
+ |
|
| 6199 |
+ break; |
|
| 6200 |
+ } |
|
| 6201 |
+ }); |
|
| 6202 |
+ |
|
| 6203 |
+ // Not a valid one |
|
| 6204 |
+ if (!l) |
|
| 6205 |
+ return; |
|
| 6206 |
+ } |
|
| 6207 |
+ |
|
| 6208 |
+ switch (s.mode) {
|
|
| 6209 |
+ case "exact": |
|
| 6210 |
+ l = s.elements || ''; |
|
| 6211 |
+ |
|
| 6212 |
+ if(l.length > 0) {
|
|
| 6213 |
+ each(explode(l), function(v) {
|
|
| 6214 |
+ if (DOM.get(v)) |
|
| 6215 |
+ new tinymce.Editor(v, s).render(1); |
|
| 6216 |
+ else {
|
|
| 6217 |
+ c = 0; |
|
| 6218 |
+ |
|
| 6219 |
+ each(document.forms, function(f) {
|
|
| 6220 |
+ each(f.elements, function(e) {
|
|
| 6221 |
+ if (e.name === v) {
|
|
| 6222 |
+ v = 'mce_editor_' + c; |
|
| 6223 |
+ DOM.setAttrib(e, 'id', v); |
|
| 6224 |
+ new tinymce.Editor(v, s).render(1); |
|
| 6225 |
+ } |
|
| 6226 |
+ }); |
|
| 6227 |
+ }); |
|
| 6228 |
+ } |
|
| 6229 |
+ }); |
|
| 6230 |
+ } |
|
| 6231 |
+ break; |
|
| 6232 |
+ |
|
| 6233 |
+ case "textareas": |
|
| 6234 |
+ case "specific_textareas": |
|
| 6235 |
+ function hasClass(n, c) {
|
|
| 6236 |
+ return c.constructor === RegExp ? c.test(n.className) : DOM.hasClass(n, c); |
|
| 6237 |
+ }; |
|
| 6238 |
+ |
|
| 6239 |
+ each(DOM.select('textarea'), function(v) {
|
|
| 6240 |
+ if (s.editor_deselector && hasClass(v, s.editor_deselector)) |
|
| 6241 |
+ return; |
|
| 6242 |
+ |
|
| 6243 |
+ if (!s.editor_selector || hasClass(v, s.editor_selector)) {
|
|
| 6244 |
+ // Can we use the name |
|
| 6245 |
+ e = DOM.get(v.name); |
|
| 6246 |
+ if (!v.id && !e) |
|
| 6247 |
+ v.id = v.name; |
|
| 6248 |
+ |
|
| 6249 |
+ // Generate unique name if missing or already exists |
|
| 6250 |
+ if (!v.id || t.get(v.id)) |
|
| 6251 |
+ v.id = DOM.uniqueId(); |
|
| 6252 |
+ |
|
| 6253 |
+ new tinymce.Editor(v.id, s).render(1); |
|
| 6254 |
+ } |
|
| 6255 |
+ }); |
|
| 6256 |
+ break; |
|
| 6257 |
+ } |
|
| 6258 |
+ |
|
| 6259 |
+ // Call onInit when all editors are initialized |
|
| 6260 |
+ if (s.oninit) {
|
|
| 6261 |
+ l = co = 0; |
|
| 6262 |
+ |
|
| 6263 |
+ each (t.editors, function(ed) {
|
|
| 6264 |
+ co++; |
|
| 6265 |
+ |
|
| 6266 |
+ if (!ed.initialized) {
|
|
| 6267 |
+ // Wait for it |
|
| 6268 |
+ ed.onInit.add(function() {
|
|
| 6269 |
+ l++; |
|
| 6270 |
+ |
|
| 6271 |
+ // All done |
|
| 6272 |
+ if (l == co) |
|
| 6273 |
+ execCallback(s, 'oninit'); |
|
| 6274 |
+ }); |
|
| 6275 |
+ } else |
|
| 6276 |
+ l++; |
|
| 6277 |
+ |
|
| 6278 |
+ // All done |
|
| 6279 |
+ if (l == co) |
|
| 6280 |
+ execCallback(s, 'oninit'); |
|
| 6281 |
+ }); |
|
| 6282 |
+ } |
|
| 6283 |
+ }); |
|
| 6284 |
+ }, |
|
| 6285 |
+ |
|
| 6286 |
+ get : function(id) {
|
|
| 6287 |
+ return this.editors[id]; |
|
| 6288 |
+ }, |
|
| 6289 |
+ |
|
| 6290 |
+ getInstanceById : function(id) {
|
|
| 6291 |
+ return this.get(id); |
|
| 6292 |
+ }, |
|
| 6293 |
+ |
|
| 6294 |
+ add : function(e) {
|
|
| 6295 |
+ this.editors[e.id] = e; |
|
| 6296 |
+ this._setActive(e); |
|
| 6297 |
+ |
|
| 6298 |
+ return e; |
|
| 6299 |
+ }, |
|
| 6300 |
+ |
|
| 6301 |
+ remove : function(e) {
|
|
| 6302 |
+ var t = this; |
|
| 6303 |
+ |
|
| 6304 |
+ // Not in the collection |
|
| 6305 |
+ if (!t.editors[e.id]) |
|
| 6306 |
+ return null; |
|
| 6307 |
+ |
|
| 6308 |
+ delete t.editors[e.id]; |
|
| 6309 |
+ |
|
| 6310 |
+ // Select another editor since the active one was removed |
|
| 6311 |
+ if (t.activeEditor == e) {
|
|
| 6312 |
+ each(t.editors, function(e) {
|
|
| 6313 |
+ t._setActive(e); |
|
| 6314 |
+ return false; // Break |
|
| 6315 |
+ }); |
|
| 6316 |
+ } |
|
| 6317 |
+ |
|
| 6318 |
+ e.destroy(); |
|
| 6319 |
+ |
|
| 6320 |
+ return e; |
|
| 6321 |
+ }, |
|
| 6322 |
+ |
|
| 6323 |
+ execCommand : function(c, u, v) {
|
|
| 6324 |
+ var t = this, ed = t.get(v), w; |
|
| 6325 |
+ |
|
| 6326 |
+ // Manager commands |
|
| 6327 |
+ switch (c) {
|
|
| 6328 |
+ case "mceFocus": |
|
| 6329 |
+ ed.focus(); |
|
| 6330 |
+ return true; |
|
| 6331 |
+ |
|
| 6332 |
+ case "mceAddEditor": |
|
| 6333 |
+ case "mceAddControl": |
|
| 6334 |
+ if (!t.get(v)) |
|
| 6335 |
+ new tinymce.Editor(v, t.settings).render(); |
|
| 6336 |
+ |
|
| 6337 |
+ return true; |
|
| 6338 |
+ |
|
| 6339 |
+ case "mceAddFrameControl": |
|
| 6340 |
+ w = v.window; |
|
| 6341 |
+ |
|
| 6342 |
+ // Add tinyMCE global instance and tinymce namespace to specified window |
|
| 6343 |
+ w.tinyMCE = tinyMCE; |
|
| 6344 |
+ w.tinymce = tinymce; |
|
| 6345 |
+ |
|
| 6346 |
+ tinymce.DOM.doc = w.document; |
|
| 6347 |
+ tinymce.DOM.win = w; |
|
| 6348 |
+ |
|
| 6349 |
+ ed = new tinymce.Editor(v.element_id, v); |
|
| 6350 |
+ ed.render(); |
|
| 6351 |
+ |
|
| 6352 |
+ // Fix IE memory leaks |
|
| 6353 |
+ if (tinymce.isIE) {
|
|
| 6354 |
+ function clr() {
|
|
| 6355 |
+ ed.destroy(); |
|
| 6356 |
+ w.detachEvent('onunload', clr);
|
|
| 6357 |
+ w = w.tinyMCE = w.tinymce = null; // IE leak |
|
| 6358 |
+ }; |
|
| 6359 |
+ |
|
| 6360 |
+ w.attachEvent('onunload', clr);
|
|
| 6361 |
+ } |
|
| 6362 |
+ |
|
| 6363 |
+ v.page_window = null; |
|
| 6364 |
+ |
|
| 6365 |
+ return true; |
|
| 6366 |
+ |
|
| 6367 |
+ case "mceRemoveEditor": |
|
| 6368 |
+ case "mceRemoveControl": |
|
| 6369 |
+ ed.remove(); |
|
| 6370 |
+ return true; |
|
| 6371 |
+ |
|
| 6372 |
+ case 'mceToggleEditor': |
|
| 6373 |
+ if (!ed) {
|
|
| 6374 |
+ t.execCommand('mceAddControl', 0, v);
|
|
| 6375 |
+ return true; |
|
| 6376 |
+ } |
|
| 6377 |
+ |
|
| 6378 |
+ if (ed.isHidden()) |
|
| 6379 |
+ ed.show(); |
|
| 6380 |
+ else |
|
| 6381 |
+ ed.hide(); |
|
| 6382 |
+ |
|
| 6383 |
+ return true; |
|
| 6384 |
+ } |
|
| 6385 |
+ |
|
| 6386 |
+ // Run command on active editor |
|
| 6387 |
+ if (t.activeEditor) |
|
| 6388 |
+ return t.activeEditor.execCommand(c, u, v); |
|
| 6389 |
+ |
|
| 6390 |
+ return false; |
|
| 6391 |
+ }, |
|
| 6392 |
+ |
|
| 6393 |
+ execInstanceCommand : function(id, c, u, v) {
|
|
| 6394 |
+ var ed = this.get(id); |
|
| 6395 |
+ |
|
| 6396 |
+ if (ed) |
|
| 6397 |
+ return ed.execCommand(c, u, v); |
|
| 6398 |
+ |
|
| 6399 |
+ return false; |
|
| 6400 |
+ }, |
|
| 6401 |
+ |
|
| 6402 |
+ triggerSave : function() {
|
|
| 6403 |
+ each(this.editors, function(e) {
|
|
| 6404 |
+ e.save(); |
|
| 6405 |
+ }); |
|
| 6406 |
+ }, |
|
| 6407 |
+ |
|
| 6408 |
+ addI18n : function(p, o) {
|
|
| 6409 |
+ var lo, i18n = this.i18n; |
|
| 6410 |
+ |
|
| 6411 |
+ if (!tinymce.is(p, 'string')) {
|
|
| 6412 |
+ each(p, function(o, lc) {
|
|
| 6413 |
+ each(o, function(o, g) {
|
|
| 6414 |
+ each(o, function(o, k) {
|
|
| 6415 |
+ if (g === 'common') |
|
| 6416 |
+ i18n[lc + '.' + k] = o; |
|
| 6417 |
+ else |
|
| 6418 |
+ i18n[lc + '.' + g + '.' + k] = o; |
|
| 6419 |
+ }); |
|
| 6420 |
+ }); |
|
| 6421 |
+ }); |
|
| 6422 |
+ } else {
|
|
| 6423 |
+ each(o, function(o, k) {
|
|
| 6424 |
+ i18n[p + '.' + k] = o; |
|
| 6425 |
+ }); |
|
| 6426 |
+ } |
|
| 6427 |
+ }, |
|
| 6428 |
+ |
|
| 6429 |
+ // Private methods |
|
| 6430 |
+ |
|
| 6431 |
+ _setActive : function(e) {
|
|
| 6432 |
+ this.selectedInstance = this.activeEditor = e; |
|
| 6433 |
+ } |
|
| 6434 |
+ |
|
| 6435 |
+ }); |
|
| 6436 |
+ |
|
| 6437 |
+ tinymce.EditorManager.preInit(); |
|
| 6438 |
+})(); |
|
| 6439 |
+ |
|
| 6440 |
+// Short for editor manager window.tinyMCE is needed when TinyMCE gets loaded though a XHR call |
|
| 6441 |
+var tinyMCE = window.tinyMCE = tinymce.EditorManager; |
|
| 6442 |
+ |
|
| 6443 |
+/* file:jscripts/tiny_mce/classes/Editor.js */ |
|
| 6444 |
+ |
|
| 6445 |
+(function() {
|
|
| 6446 |
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher; |
|
| 6447 |
+ var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit; |
|
| 6448 |
+ var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager; |
|
| 6449 |
+ var inArray = tinymce.inArray, grep = tinymce.grep, explode = tinymce.explode; |
|
| 6450 |
+ |
|
| 6451 |
+ tinymce.create('tinymce.Editor', {
|
|
| 6452 |
+ Editor : function(id, s) {
|
|
| 6453 |
+ var t = this; |
|
| 6454 |
+ |
|
| 6455 |
+ t.id = t.editorId = id; |
|
| 6456 |
+ t.execCommands = {};
|
|
| 6457 |
+ t.queryStateCommands = {};
|
|
| 6458 |
+ t.queryValueCommands = {};
|
|
| 6459 |
+ t.plugins = {};
|
|
| 6460 |
+ |
|
| 6461 |
+ // Add events to the editor |
|
| 6462 |
+ each([ |
|
| 6463 |
+ 'onPreInit', |
|
| 6464 |
+ 'onBeforeRenderUI', |
|
| 6465 |
+ 'onPostRender', |
|
| 6466 |
+ 'onInit', |
|
| 6467 |
+ 'onRemove', |
|
| 6468 |
+ 'onActivate', |
|
| 6469 |
+ 'onDeactivate', |
|
| 6470 |
+ 'onClick', |
|
| 6471 |
+ 'onEvent', |
|
| 6472 |
+ 'onMouseUp', |
|
| 6473 |
+ 'onMouseDown', |
|
| 6474 |
+ 'onDblClick', |
|
| 6475 |
+ 'onKeyDown', |
|
| 6476 |
+ 'onKeyUp', |
|
| 6477 |
+ 'onKeyPress', |
|
| 6478 |
+ 'onContextMenu', |
|
| 6479 |
+ 'onSubmit', |
|
| 6480 |
+ 'onReset', |
|
| 6481 |
+ 'onPaste', |
|
| 6482 |
+ 'onPreProcess', |
|
| 6483 |
+ 'onPostProcess', |
|
| 6484 |
+ 'onBeforeSetContent', |
|
| 6485 |
+ 'onBeforeGetContent', |
|
| 6486 |
+ 'onSetContent', |
|
| 6487 |
+ 'onGetContent', |
|
| 6488 |
+ 'onLoadContent', |
|
| 6489 |
+ 'onSaveContent', |
|
| 6490 |
+ 'onNodeChange', |
|
| 6491 |
+ 'onChange', |
|
| 6492 |
+ 'onBeforeExecCommand', |
|
| 6493 |
+ 'onExecCommand', |
|
| 6494 |
+ 'onUndo', |
|
| 6495 |
+ 'onRedo', |
|
| 6496 |
+ 'onVisualAid', |
|
| 6497 |
+ 'onSetProgressState' |
|
| 6498 |
+ ], function(e) {
|
|
| 6499 |
+ t[e] = new Dispatcher(t); |
|
| 6500 |
+ }); |
|
| 6501 |
+ |
|
| 6502 |
+ // Default editor config |
|
| 6503 |
+ t.settings = s = extend({
|
|
| 6504 |
+ id : id, |
|
| 6505 |
+ language : 'en', |
|
| 6506 |
+ docs_language : 'en', |
|
| 6507 |
+ theme : 'simple', |
|
| 6508 |
+ skin : 'default', |
|
| 6509 |
+ delta_width : 0, |
|
| 6510 |
+ delta_height : 0, |
|
| 6511 |
+ popup_css : '', |
|
| 6512 |
+ plugins : '', |
|
| 6513 |
+ document_base_url : tinymce.documentBaseURL, |
|
| 6514 |
+ add_form_submit_trigger : 1, |
|
| 6515 |
+ submit_patch : 1, |
|
| 6516 |
+ add_unload_trigger : 1, |
|
| 6517 |
+ convert_urls : 1, |
|
| 6518 |
+ relative_urls : 1, |
|
| 6519 |
+ remove_script_host : 1, |
|
| 6520 |
+ table_inline_editing : 0, |
|
| 6521 |
+ object_resizing : 1, |
|
| 6522 |
+ cleanup : 1, |
|
| 6523 |
+ accessibility_focus : 1, |
|
| 6524 |
+ custom_shortcuts : 1, |
|
| 6525 |
+ custom_undo_redo_keyboard_shortcuts : 1, |
|
| 6526 |
+ custom_undo_redo_restore_selection : 1, |
|
| 6527 |
+ custom_undo_redo : 1, |
|
| 6528 |
+ doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', |
|
| 6529 |
+ visual_table_class : 'mceItemTable', |
|
| 6530 |
+ visual : 1, |
|
| 6531 |
+ inline_styles : true, |
|
| 6532 |
+ convert_fonts_to_spans : true, |
|
| 6533 |
+ font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large', |
|
| 6534 |
+ apply_source_formatting : 1, |
|
| 6535 |
+ directionality : 'ltr', |
|
| 6536 |
+ forced_root_block : 'p', |
|
| 6537 |
+ valid_elements : '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value|_value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big', |
|
| 6538 |
+ hidden_input : 1, |
|
| 6539 |
+ padd_empty_editor : 1, |
|
| 6540 |
+ render_ui : 1, |
|
| 6541 |
+ init_theme : 1, |
|
| 6542 |
+ force_p_newlines : 1, |
|
| 6543 |
+ indentation : '30px' |
|
| 6544 |
+ }, s); |
|
| 6545 |
+ |
|
| 6546 |
+ // Setup URIs |
|
| 6547 |
+ t.documentBaseURI = new tinymce.util.URI(s.document_base_url || tinymce.documentBaseURL, {
|
|
| 6548 |
+ base_uri : tinyMCE.baseURI |
|
| 6549 |
+ }); |
|
| 6550 |
+ t.baseURI = EditorManager.baseURI; |
|
| 6551 |
+ |
|
| 6552 |
+ // Call setup |
|
| 6553 |
+ t.execCallback('setup', t);
|
|
| 6554 |
+ }, |
|
| 6555 |
+ |
|
| 6556 |
+ render : function(nst) {
|
|
| 6557 |
+ var t = this, s = t.settings, id = t.id, sl = tinymce.ScriptLoader; |
|
| 6558 |
+ |
|
| 6559 |
+ // Page is not loaded yet, wait for it |
|
| 6560 |
+ if (!Event.domLoaded) {
|
|
| 6561 |
+ Event.add(document, 'init', function() {
|
|
| 6562 |
+ t.render(); |
|
| 6563 |
+ }); |
|
| 6564 |
+ return; |
|
| 6565 |
+ } |
|
| 6566 |
+ |
|
| 6567 |
+ // Force strict loading mode if render us called by user and not internally |
|
| 6568 |
+ if (!nst) {
|
|
| 6569 |
+ s.strict_loading_mode = 1; |
|
| 6570 |
+ tinyMCE.settings = s; |
|
| 6571 |
+ } |
|
| 6572 |
+ |
|
| 6573 |
+ // Element not found, then skip initialization |
|
| 6574 |
+ if (!t.getElement()) |
|
| 6575 |
+ return; |
|
| 6576 |
+ |
|
| 6577 |
+ if (s.strict_loading_mode) {
|
|
| 6578 |
+ sl.settings.strict_mode = s.strict_loading_mode; |
|
| 6579 |
+ tinymce.DOM.settings.strict = 1; |
|
| 6580 |
+ } |
|
| 6581 |
+ |
|
| 6582 |
+ // Add hidden input for non input elements inside form elements |
|
| 6583 |
+ if (!/TEXTAREA|INPUT/i.test(t.getElement().nodeName) && s.hidden_input && DOM.getParent(id, 'form')) |
|
| 6584 |
+ DOM.insertAfter(DOM.create('input', {type : 'hidden', name : id}), id);
|
|
| 6585 |
+ |
|
| 6586 |
+ t.windowManager = new tinymce.WindowManager(t); |
|
| 6587 |
+ |
|
| 6588 |
+ if (s.encoding == 'xml') {
|
|
| 6589 |
+ t.onGetContent.add(function(ed, o) {
|
|
| 6590 |
+ if (o.save) |
|
| 6591 |
+ o.content = DOM.encode(o.content); |
|
| 6592 |
+ }); |
|
| 6593 |
+ } |
|
| 6594 |
+ |
|
| 6595 |
+ if (s.add_form_submit_trigger) {
|
|
| 6596 |
+ t.onSubmit.addToTop(function() {
|
|
| 6597 |
+ if (t.initialized) {
|
|
| 6598 |
+ t.save(); |
|
| 6599 |
+ t.isNotDirty = 1; |
|
| 6600 |
+ } |
|
| 6601 |
+ }); |
|
| 6602 |
+ } |
|
| 6603 |
+ |
|
| 6604 |
+ if (s.add_unload_trigger && !s.ask) {
|
|
| 6605 |
+ t._beforeUnload = tinyMCE.onBeforeUnload.add(function() {
|
|
| 6606 |
+ if (t.initialized && !t.destroyed && !t.isHidden()) |
|
| 6607 |
+ t.save({format : 'raw', no_events : true});
|
|
| 6608 |
+ }); |
|
| 6609 |
+ } |
|
| 6610 |
+ |
|
| 6611 |
+ tinymce.addUnload(t.destroy, t); |
|
| 6612 |
+ |
|
| 6613 |
+ if (s.submit_patch) {
|
|
| 6614 |
+ t.onBeforeRenderUI.add(function() {
|
|
| 6615 |
+ var n = t.getElement().form; |
|
| 6616 |
+ |
|
| 6617 |
+ if (!n) |
|
| 6618 |
+ return; |
|
| 6619 |
+ |
|
| 6620 |
+ // Already patched |
|
| 6621 |
+ if (n._mceOldSubmit) |
|
| 6622 |
+ return; |
|
| 6623 |
+ |
|
| 6624 |
+ // Check page uses id="submit" or name="submit" for it's submit button |
|
| 6625 |
+ if (!n.submit.nodeType && !n.submit.length) {
|
|
| 6626 |
+ t.formElement = n; |
|
| 6627 |
+ n._mceOldSubmit = n.submit; |
|
| 6628 |
+ n.submit = function() {
|
|
| 6629 |
+ // Save all instances |
|
| 6630 |
+ EditorManager.triggerSave(); |
|
| 6631 |
+ t.isNotDirty = 1; |
|
| 6632 |
+ |
|
| 6633 |
+ return this._mceOldSubmit(this); |
|
| 6634 |
+ }; |
|
| 6635 |
+ } |
|
| 6636 |
+ |
|
| 6637 |
+ n = null; |
|
| 6638 |
+ }); |
|
| 6639 |
+ } |
|
| 6640 |
+ |
|
| 6641 |
+ // Load scripts |
|
| 6642 |
+ function loadScripts() {
|
|
| 6643 |
+ if (s.language) |
|
| 6644 |
+ sl.add(tinymce.baseURL + '/langs/' + s.language + '.js'); |
|
| 6645 |
+ |
|
| 6646 |
+ if (s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme]) |
|
| 6647 |
+ ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js'); |
|
| 6648 |
+ |
|
| 6649 |
+ each(explode(s.plugins), function(p) {
|
|
| 6650 |
+ if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) {
|
|
| 6651 |
+ // Skip safari plugin for other browsers |
|
| 6652 |
+ if (!isWebKit && p == 'safari') |
|
| 6653 |
+ return; |
|
| 6654 |
+ |
|
| 6655 |
+ PluginManager.load(p, 'plugins/' + p + '/editor_plugin' + tinymce.suffix + '.js'); |
|
| 6656 |
+ } |
|
| 6657 |
+ }); |
|
| 6658 |
+ |
|
| 6659 |
+ // Init when que is loaded |
|
| 6660 |
+ sl.loadQueue(function() {
|
|
| 6661 |
+ if (s.ask) {
|
|
| 6662 |
+ function ask() {
|
|
| 6663 |
+ // Yield for awhile to avoid focus bug on FF 3 when cancel is pressed |
|
| 6664 |
+ window.setTimeout(function() {
|
|
| 6665 |
+ Event.remove(t.id, 'focus', ask); |
|
| 6666 |
+ |
|
| 6667 |
+ t.windowManager.confirm(t.getLang('edit_confirm'), function(s) {
|
|
| 6668 |
+ if (s) |
|
| 6669 |
+ t.init(); |
|
| 6670 |
+ }); |
|
| 6671 |
+ }, 0); |
|
| 6672 |
+ }; |
|
| 6673 |
+ |
|
| 6674 |
+ Event.add(t.id, 'focus', ask); |
|
| 6675 |
+ return; |
|
| 6676 |
+ } |
|
| 6677 |
+ |
|
| 6678 |
+ if (!t.removed) |
|
| 6679 |
+ t.init(); |
|
| 6680 |
+ }); |
|
| 6681 |
+ }; |
|
| 6682 |
+ |
|
| 6683 |
+ // Load compat2x first |
|
| 6684 |
+ if (s.plugins.indexOf('compat2x') != -1) {
|
|
| 6685 |
+ PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
|
|
| 6686 |
+ sl.loadQueue(loadScripts); |
|
| 6687 |
+ } else |
|
| 6688 |
+ loadScripts(); |
|
| 6689 |
+ }, |
|
| 6690 |
+ |
|
| 6691 |
+ init : function() {
|
|
| 6692 |
+ var n, t = this, s = t.settings, w, h, e = t.getElement(), o, ti, u, bi, bc, re; |
|
| 6693 |
+ |
|
| 6694 |
+ EditorManager.add(t); |
|
| 6695 |
+ |
|
| 6696 |
+ // Create theme |
|
| 6697 |
+ s.theme = s.theme.replace(/-/, ''); |
|
| 6698 |
+ o = ThemeManager.get(s.theme); |
|
| 6699 |
+ t.theme = new o(); |
|
| 6700 |
+ |
|
| 6701 |
+ if (t.theme.init && s.init_theme) |
|
| 6702 |
+ t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, '')); |
|
| 6703 |
+ |
|
| 6704 |
+ // Create all plugins |
|
| 6705 |
+ each(explode(s.plugins.replace(/\-/g, '')), function(p) {
|
|
| 6706 |
+ var c = PluginManager.get(p), u = PluginManager.urls[p] || tinymce.documentBaseURL.replace(/\/$/, ''), po; |
|
| 6707 |
+ |
|
| 6708 |
+ if (c) {
|
|
| 6709 |
+ po = new c(t, u); |
|
| 6710 |
+ |
|
| 6711 |
+ t.plugins[p] = po; |
|
| 6712 |
+ |
|
| 6713 |
+ if (po.init) |
|
| 6714 |
+ po.init(t, u); |
|
| 6715 |
+ } |
|
| 6716 |
+ }); |
|
| 6717 |
+ |
|
| 6718 |
+ // Setup popup CSS path(s) |
|
| 6719 |
+ if (s.popup_css) |
|
| 6720 |
+ s.popup_css = t.documentBaseURI.toAbsolute(s.popup_css); |
|
| 6721 |
+ else |
|
| 6722 |
+ s.popup_css = t.baseURI.toAbsolute("themes/" + s.theme + "/skins/" + s.skin + "/dialog.css");
|
|
| 6723 |
+ |
|
| 6724 |
+ if (s.popup_css_add) |
|
| 6725 |
+ s.popup_css += ',' + t.documentBaseURI.toAbsolute(s.popup_css_add); |
|
| 6726 |
+ |
|
| 6727 |
+ // Setup control factory |
|
| 6728 |
+ t.controlManager = new tinymce.ControlManager(t); |
|
| 6729 |
+ t.undoManager = new tinymce.UndoManager(t); |
|
| 6730 |
+ |
|
| 6731 |
+ // Pass through |
|
| 6732 |
+ t.undoManager.onAdd.add(function(um, l) {
|
|
| 6733 |
+ if (!l.initial) |
|
| 6734 |
+ return t.onChange.dispatch(t, l, um); |
|
| 6735 |
+ }); |
|
| 6736 |
+ |
|
| 6737 |
+ t.undoManager.onUndo.add(function(um, l) {
|
|
| 6738 |
+ return t.onUndo.dispatch(t, l, um); |
|
| 6739 |
+ }); |
|
| 6740 |
+ |
|
| 6741 |
+ t.undoManager.onRedo.add(function(um, l) {
|
|
| 6742 |
+ return t.onRedo.dispatch(t, l, um); |
|
| 6743 |
+ }); |
|
| 6744 |
+ |
|
| 6745 |
+ if (s.custom_undo_redo) {
|
|
| 6746 |
+ t.onExecCommand.add(function(ed, cmd, ui, val, a) {
|
|
| 6747 |
+ if (cmd != 'Undo' && cmd != 'Redo' && cmd != 'mceRepaint' && (!a || !a.skip_undo)) |
|
| 6748 |
+ t.undoManager.add(); |
|
| 6749 |
+ }); |
|
| 6750 |
+ } |
|
| 6751 |
+ |
|
| 6752 |
+ t.onExecCommand.add(function(ed, c) {
|
|
| 6753 |
+ // Don't refresh the select lists until caret move |
|
| 6754 |
+ if (!/^(FontName|FontSize)$/.test(c)) |
|
| 6755 |
+ t.nodeChanged(); |
|
| 6756 |
+ }); |
|
| 6757 |
+ |
|
| 6758 |
+ // Remove ghost selections on images and tables in Gecko |
|
| 6759 |
+ if (isGecko) {
|
|
| 6760 |
+ function repaint(a, o) {
|
|
| 6761 |
+ if (!o || !o.initial) |
|
| 6762 |
+ t.execCommand('mceRepaint');
|
|
| 6763 |
+ }; |
|
| 6764 |
+ |
|
| 6765 |
+ t.onUndo.add(repaint); |
|
| 6766 |
+ t.onRedo.add(repaint); |
|
| 6767 |
+ t.onSetContent.add(repaint); |
|
| 6768 |
+ } |
|
| 6769 |
+ |
|
| 6770 |
+ // Enables users to override the control factory |
|
| 6771 |
+ t.onBeforeRenderUI.dispatch(t, t.controlManager); |
|
| 6772 |
+ |
|
| 6773 |
+ // Measure box |
|
| 6774 |
+ if (s.render_ui) {
|
|
| 6775 |
+ w = s.width || e.style.width || e.offsetWidth; |
|
| 6776 |
+ h = s.height || e.style.height || e.offsetHeight; |
|
| 6777 |
+ t.orgDisplay = e.style.display; |
|
| 6778 |
+ re = /^[0-9\.]+(|px)$/i; |
|
| 6779 |
+ |
|
| 6780 |
+ if (re.test('' + w))
|
|
| 6781 |
+ w = Math.max(parseInt(w) + (o.deltaWidth || 0), 100); |
|
| 6782 |
+ |
|
| 6783 |
+ if (re.test('' + h))
|
|
| 6784 |
+ h = Math.max(parseInt(h) + (o.deltaHeight || 0), 100); |
|
| 6785 |
+ |
|
| 6786 |
+ // Render UI |
|
| 6787 |
+ o = t.theme.renderUI({
|
|
| 6788 |
+ targetNode : e, |
|
| 6789 |
+ width : w, |
|
| 6790 |
+ height : h, |
|
| 6791 |
+ deltaWidth : s.delta_width, |
|
| 6792 |
+ deltaHeight : s.delta_height |
|
| 6793 |
+ }); |
|
| 6794 |
+ |
|
| 6795 |
+ t.editorContainer = o.editorContainer; |
|
| 6796 |
+ } |
|
| 6797 |
+ |
|
| 6798 |
+ |
|
| 6799 |
+ // Resize editor |
|
| 6800 |
+ DOM.setStyles(o.sizeContainer || o.editorContainer, {
|
|
| 6801 |
+ width : w, |
|
| 6802 |
+ height : h |
|
| 6803 |
+ }); |
|
| 6804 |
+ |
|
| 6805 |
+ h = (o.iframeHeight || h) + ((h + '').indexOf('%') == -1 ? (o.deltaHeight || 0) : '');
|
|
| 6806 |
+ if (h < 100) |
|
| 6807 |
+ h = 100; |
|
| 6808 |
+ |
|
| 6809 |
+ t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '"></base>'; |
|
| 6810 |
+ t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; |
|
| 6811 |
+ |
|
| 6812 |
+ if (tinymce.relaxedDomain) |
|
| 6813 |
+ t.iframeHTML += '<script type="text/javascript">document.domain = "' + tinymce.relaxedDomain + '";</script>'; |
|
| 6814 |
+ |
|
| 6815 |
+ bi = s.body_id || 'tinymce'; |
|
| 6816 |
+ if (bi.indexOf('=') != -1) {
|
|
| 6817 |
+ bi = t.getParam('body_id', '', 'hash');
|
|
| 6818 |
+ bi = bi[t.id] || bi; |
|
| 6819 |
+ } |
|
| 6820 |
+ |
|
| 6821 |
+ bc = s.body_class || ''; |
|
| 6822 |
+ if (bc.indexOf('=') != -1) {
|
|
| 6823 |
+ bc = t.getParam('body_class', '', 'hash');
|
|
| 6824 |
+ bc = bc[t.id] || ''; |
|
| 6825 |
+ } |
|
| 6826 |
+ |
|
| 6827 |
+ t.iframeHTML += '</head><body id="' + bi + '" class="mceContentBody ' + bc + '"></body></html>'; |
|
| 6828 |
+ |
|
| 6829 |
+ // Domain relaxing enabled, then set document domain |
|
| 6830 |
+ if (tinymce.relaxedDomain) {
|
|
| 6831 |
+ // We need to write the contents here in IE since multiple writes messes up refresh button and back button |
|
| 6832 |
+ if (isIE) |
|
| 6833 |
+ u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";var ed = window.parent.tinyMCE.get("' + t.id + '");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';
|
|
| 6834 |
+ else if (tinymce.isOpera) |
|
| 6835 |
+ u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";document.close();ed.setupIframe();})()';
|
|
| 6836 |
+ } |
|
| 6837 |
+ |
|
| 6838 |
+ // Create iframe |
|
| 6839 |
+ n = DOM.add(o.iframeContainer, 'iframe', {
|
|
| 6840 |
+ id : t.id + "_ifr", |
|
| 6841 |
+ src : u || 'javascript:""', // Workaround for HTTPS warning in IE6/7 |
|
| 6842 |
+ frameBorder : '0', |
|
| 6843 |
+ style : {
|
|
| 6844 |
+ width : '100%', |
|
| 6845 |
+ height : h |
|
| 6846 |
+ } |
|
| 6847 |
+ }); |
|
| 6848 |
+ |
|
| 6849 |
+ t.contentAreaContainer = o.iframeContainer; |
|
| 6850 |
+ DOM.get(o.editorContainer).style.display = t.orgDisplay; |
|
| 6851 |
+ DOM.get(t.id).style.display = 'none'; |
|
| 6852 |
+ |
|
| 6853 |
+ // Safari 2.x requires us to wait for the load event and load a real HTML doc |
|
| 6854 |
+ if (tinymce.isOldWebKit) {
|
|
| 6855 |
+ Event.add(n, 'load', t.setupIframe, t); |
|
| 6856 |
+ n.src = tinymce.baseURL + '/plugins/safari/blank.htm'; |
|
| 6857 |
+ } else {
|
|
| 6858 |
+ if (!isIE || !tinymce.relaxedDomain) |
|
| 6859 |
+ t.setupIframe(); |
|
| 6860 |
+ |
|
| 6861 |
+ e = n = o = null; // Cleanup |
|
| 6862 |
+ } |
|
| 6863 |
+ }, |
|
| 6864 |
+ |
|
| 6865 |
+ setupIframe : function() {
|
|
| 6866 |
+ var t = this, s = t.settings, e = DOM.get(t.id), d = t.getDoc(), h, b; |
|
| 6867 |
+ |
|
| 6868 |
+ // Setup iframe body |
|
| 6869 |
+ if (!isIE || !tinymce.relaxedDomain) {
|
|
| 6870 |
+ d.open(); |
|
| 6871 |
+ d.write(t.iframeHTML); |
|
| 6872 |
+ d.close(); |
|
| 6873 |
+ } |
|
| 6874 |
+ |
|
| 6875 |
+ // Design mode needs to be added here Ctrl+A will fail otherwise |
|
| 6876 |
+ if (!isIE) {
|
|
| 6877 |
+ try {
|
|
| 6878 |
+ d.designMode = 'On'; |
|
| 6879 |
+ } catch (ex) {
|
|
| 6880 |
+ // Will fail on Gecko if the editor is placed in an hidden container element |
|
| 6881 |
+ // The design mode will be set ones the editor is focused |
|
| 6882 |
+ } |
|
| 6883 |
+ } |
|
| 6884 |
+ |
|
| 6885 |
+ // IE needs to use contentEditable or it will display non secure items for HTTPS |
|
| 6886 |
+ if (isIE) {
|
|
| 6887 |
+ // It will not steal focus if we hide it while setting contentEditable |
|
| 6888 |
+ b = t.getBody(); |
|
| 6889 |
+ DOM.hide(b); |
|
| 6890 |
+ b.contentEditable = true; |
|
| 6891 |
+ DOM.show(b); |
|
| 6892 |
+ } |
|
| 6893 |
+ |
|
| 6894 |
+ // Setup objects |
|
| 6895 |
+ t.dom = new tinymce.DOM.DOMUtils(t.getDoc(), {
|
|
| 6896 |
+ keep_values : true, |
|
| 6897 |
+ url_converter : t.convertURL, |
|
| 6898 |
+ url_converter_scope : t, |
|
| 6899 |
+ hex_colors : s.force_hex_style_colors, |
|
| 6900 |
+ class_filter : s.class_filter, |
|
| 6901 |
+ update_styles : 1, |
|
| 6902 |
+ fix_ie_paragraphs : 1 |
|
| 6903 |
+ }); |
|
| 6904 |
+ |
|
| 6905 |
+ t.serializer = new tinymce.dom.Serializer({
|
|
| 6906 |
+ entity_encoding : s.entity_encoding, |
|
| 6907 |
+ entities : s.entities, |
|
| 6908 |
+ valid_elements : s.verify_html === false ? '*[*]' : s.valid_elements, |
|
| 6909 |
+ extended_valid_elements : s.extended_valid_elements, |
|
| 6910 |
+ valid_child_elements : s.valid_child_elements, |
|
| 6911 |
+ invalid_elements : s.invalid_elements, |
|
| 6912 |
+ fix_table_elements : s.fix_table_elements, |
|
| 6913 |
+ fix_list_elements : s.fix_list_elements, |
|
| 6914 |
+ fix_content_duplication : s.fix_content_duplication, |
|
| 6915 |
+ convert_fonts_to_spans : s.convert_fonts_to_spans, |
|
| 6916 |
+ font_size_classes : s.font_size_classes, |
|
| 6917 |
+ font_size_style_values : s.font_size_style_values, |
|
| 6918 |
+ apply_source_formatting : s.apply_source_formatting, |
|
| 6919 |
+ remove_linebreaks : s.remove_linebreaks, |
|
| 6920 |
+ dom : t.dom |
|
| 6921 |
+ }); |
|
| 6922 |
+ |
|
| 6923 |
+ t.selection = new tinymce.dom.Selection(t.dom, t.getWin(), t.serializer); |
|
| 6924 |
+ t.forceBlocks = new tinymce.ForceBlocks(t, {
|
|
| 6925 |
+ forced_root_block : s.forced_root_block |
|
| 6926 |
+ }); |
|
| 6927 |
+ t.editorCommands = new tinymce.EditorCommands(t); |
|
| 6928 |
+ |
|
| 6929 |
+ // Pass through |
|
| 6930 |
+ t.serializer.onPreProcess.add(function(se, o) {
|
|
| 6931 |
+ return t.onPreProcess.dispatch(t, o, se); |
|
| 6932 |
+ }); |
|
| 6933 |
+ |
|
| 6934 |
+ t.serializer.onPostProcess.add(function(se, o) {
|
|
| 6935 |
+ return t.onPostProcess.dispatch(t, o, se); |
|
| 6936 |
+ }); |
|
| 6937 |
+ |
|
| 6938 |
+ t.onPreInit.dispatch(t); |
|
| 6939 |
+ |
|
| 6940 |
+ if (!s.gecko_spellcheck) |
|
| 6941 |
+ t.getBody().spellcheck = 0; |
|
| 6942 |
+ |
|
| 6943 |
+ t._addEvents(); |
|
| 6944 |
+ |
|
| 6945 |
+ t.controlManager.onPostRender.dispatch(t, t.controlManager); |
|
| 6946 |
+ t.onPostRender.dispatch(t); |
|
| 6947 |
+ |
|
| 6948 |
+ if (s.directionality) |
|
| 6949 |
+ t.getBody().dir = s.directionality; |
|
| 6950 |
+ |
|
| 6951 |
+ if (s.nowrap) |
|
| 6952 |
+ t.getBody().style.whiteSpace = "nowrap"; |
|
| 6953 |
+ |
|
| 6954 |
+ if (s.auto_resize) |
|
| 6955 |
+ t.onNodeChange.add(t.resizeToContent, t); |
|
| 6956 |
+ |
|
| 6957 |
+ if (s.custom_elements) {
|
|
| 6958 |
+ function handleCustom(ed, o) {
|
|
| 6959 |
+ each(explode(s.custom_elements), function(v) {
|
|
| 6960 |
+ var n; |
|
| 6961 |
+ |
|
| 6962 |
+ if (v.indexOf('~') === 0) {
|
|
| 6963 |
+ v = v.substring(1); |
|
| 6964 |
+ n = 'span'; |
|
| 6965 |
+ } else |
|
| 6966 |
+ n = 'div'; |
|
| 6967 |
+ |
|
| 6968 |
+ o.content = o.content.replace(new RegExp('<(' + v + ')([^>]*)>', 'g'), '<' + n + ' mce_name="$1"$2>');
|
|
| 6969 |
+ o.content = o.content.replace(new RegExp('</(' + v + ')>', 'g'), '</' + n + '>');
|
|
| 6970 |
+ }); |
|
| 6971 |
+ }; |
|
| 6972 |
+ |
|
| 6973 |
+ t.onBeforeSetContent.add(handleCustom); |
|
| 6974 |
+ t.onPostProcess.add(function(ed, o) {
|
|
| 6975 |
+ if (o.set) |
|
| 6976 |
+ handleCustom(ed, o) |
|
| 6977 |
+ }); |
|
| 6978 |
+ } |
|
| 6979 |
+ |
|
| 6980 |
+ if (s.handle_node_change_callback) {
|
|
| 6981 |
+ t.onNodeChange.add(function(ed, cm, n) {
|
|
| 6982 |
+ t.execCallback('handle_node_change_callback', t.id, n, -1, -1, true, t.selection.isCollapsed());
|
|
| 6983 |
+ }); |
|
| 6984 |
+ } |
|
| 6985 |
+ |
|
| 6986 |
+ if (s.save_callback) {
|
|
| 6987 |
+ t.onSaveContent.add(function(ed, o) {
|
|
| 6988 |
+ var h = t.execCallback('save_callback', t.id, o.content, t.getBody());
|
|
| 6989 |
+ |
|
| 6990 |
+ if (h) |
|
| 6991 |
+ o.content = h; |
|
| 6992 |
+ }); |
|
| 6993 |
+ } |
|
| 6994 |
+ |
|
| 6995 |
+ if (s.onchange_callback) {
|
|
| 6996 |
+ t.onChange.add(function(ed, l) {
|
|
| 6997 |
+ t.execCallback('onchange_callback', t, l);
|
|
| 6998 |
+ }); |
|
| 6999 |
+ } |
|
| 7000 |
+ |
|
| 7001 |
+ if (s.convert_newlines_to_brs) {
|
|
| 7002 |
+ t.onBeforeSetContent.add(function(ed, o) {
|
|
| 7003 |
+ if (o.initial) |
|
| 7004 |
+ o.content = o.content.replace(/\r?\n/g, '<br />'); |
|
| 7005 |
+ }); |
|
| 7006 |
+ } |
|
| 7007 |
+ |
|
| 7008 |
+ if (s.fix_nesting && isIE) {
|
|
| 7009 |
+ t.onBeforeSetContent.add(function(ed, o) {
|
|
| 7010 |
+ o.content = t._fixNesting(o.content); |
|
| 7011 |
+ }); |
|
| 7012 |
+ } |
|
| 7013 |
+ |
|
| 7014 |
+ if (s.preformatted) {
|
|
| 7015 |
+ t.onPostProcess.add(function(ed, o) {
|
|
| 7016 |
+ o.content = o.content.replace(/^\s*<pre.*?>/, ''); |
|
| 7017 |
+ o.content = o.content.replace(/<\/pre>\s*$/, ''); |
|
| 7018 |
+ |
|
| 7019 |
+ if (o.set) |
|
| 7020 |
+ o.content = '<pre class="mceItemHidden">' + o.content + '</pre>'; |
|
| 7021 |
+ }); |
|
| 7022 |
+ } |
|
| 7023 |
+ |
|
| 7024 |
+ if (s.verify_css_classes) {
|
|
| 7025 |
+ t.serializer.attribValueFilter = function(n, v) {
|
|
| 7026 |
+ var s, cl; |
|
| 7027 |
+ |
|
| 7028 |
+ if (n == 'class') {
|
|
| 7029 |
+ // Build regexp for classes |
|
| 7030 |
+ if (!t.classesRE) {
|
|
| 7031 |
+ cl = t.dom.getClasses(); |
|
| 7032 |
+ |
|
| 7033 |
+ if (cl.length > 0) {
|
|
| 7034 |
+ s = ''; |
|
| 7035 |
+ |
|
| 7036 |
+ each (cl, function(o) {
|
|
| 7037 |
+ s += (s ? '|' : '') + o['class']; |
|
| 7038 |
+ }); |
|
| 7039 |
+ |
|
| 7040 |
+ t.classesRE = new RegExp('(' + s + ')', 'gi');
|
|
| 7041 |
+ } |
|
| 7042 |
+ } |
|
| 7043 |
+ |
|
| 7044 |
+ return !t.classesRE || /(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v) || t.classesRE.test(v) ? v : ''; |
|
| 7045 |
+ } |
|
| 7046 |
+ |
|
| 7047 |
+ return v; |
|
| 7048 |
+ }; |
|
| 7049 |
+ } |
|
| 7050 |
+ |
|
| 7051 |
+ if (s.convert_fonts_to_spans) |
|
| 7052 |
+ t._convertFonts(); |
|
| 7053 |
+ |
|
| 7054 |
+ if (s.inline_styles) |
|
| 7055 |
+ t._convertInlineElements(); |
|
| 7056 |
+ |
|
| 7057 |
+ if (s.cleanup_callback) {
|
|
| 7058 |
+ t.onBeforeSetContent.add(function(ed, o) {
|
|
| 7059 |
+ o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
|
|
| 7060 |
+ }); |
|
| 7061 |
+ |
|
| 7062 |
+ t.onPreProcess.add(function(ed, o) {
|
|
| 7063 |
+ if (o.set) |
|
| 7064 |
+ t.execCallback('cleanup_callback', 'insert_to_editor_dom', o.node, o);
|
|
| 7065 |
+ |
|
| 7066 |
+ if (o.get) |
|
| 7067 |
+ t.execCallback('cleanup_callback', 'get_from_editor_dom', o.node, o);
|
|
| 7068 |
+ }); |
|
| 7069 |
+ |
|
| 7070 |
+ t.onPostProcess.add(function(ed, o) {
|
|
| 7071 |
+ if (o.set) |
|
| 7072 |
+ o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
|
|
| 7073 |
+ |
|
| 7074 |
+ if (o.get) |
|
| 7075 |
+ o.content = t.execCallback('cleanup_callback', 'get_from_editor', o.content, o);
|
|
| 7076 |
+ }); |
|
| 7077 |
+ } |
|
| 7078 |
+ |
|
| 7079 |
+ if (s.save_callback) {
|
|
| 7080 |
+ t.onGetContent.add(function(ed, o) {
|
|
| 7081 |
+ if (o.save) |
|
| 7082 |
+ o.content = t.execCallback('save_callback', t.id, o.content, t.getBody());
|
|
| 7083 |
+ }); |
|
| 7084 |
+ } |
|
| 7085 |
+ |
|
| 7086 |
+ if (s.handle_event_callback) {
|
|
| 7087 |
+ t.onEvent.add(function(ed, e, o) {
|
|
| 7088 |
+ if (t.execCallback('handle_event_callback', e, ed, o) === false)
|
|
| 7089 |
+ Event.cancel(e); |
|
| 7090 |
+ }); |
|
| 7091 |
+ } |
|
| 7092 |
+ |
|
| 7093 |
+ t.onSetContent.add(function() {
|
|
| 7094 |
+ // Safari needs some time, it will crash the browser when a link is created otherwise |
|
| 7095 |
+ // I think this crash issue is resolved in the latest 3.0.4 |
|
| 7096 |
+ //window.setTimeout(function() {
|
|
| 7097 |
+ t.addVisual(t.getBody()); |
|
| 7098 |
+ //}, 1); |
|
| 7099 |
+ }); |
|
| 7100 |
+ |
|
| 7101 |
+ // Remove empty contents |
|
| 7102 |
+ if (s.padd_empty_editor) {
|
|
| 7103 |
+ t.onPostProcess.add(function(ed, o) {
|
|
| 7104 |
+ o.content = o.content.replace(/^(<p>( | |\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/, ''); |
|
| 7105 |
+ }); |
|
| 7106 |
+ } |
|
| 7107 |
+ |
|
| 7108 |
+ if (isGecko) {
|
|
| 7109 |
+ try {
|
|
| 7110 |
+ // Design mode must be set here once again to fix a bug where |
|
| 7111 |
+ // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again |
|
| 7112 |
+ d.designMode = 'Off'; |
|
| 7113 |
+ d.designMode = 'On'; |
|
| 7114 |
+ } catch (ex) {
|
|
| 7115 |
+ // Will fail on Gecko if the editor is placed in an hidden container element |
|
| 7116 |
+ // The design mode will be set ones the editor is focused |
|
| 7117 |
+ } |
|
| 7118 |
+ } |
|
| 7119 |
+ |
|
| 7120 |
+ // A small timeout was needed since firefox will remove. Bug: #1838304 |
|
| 7121 |
+ setTimeout(function () {
|
|
| 7122 |
+ if (t.removed) |
|
| 7123 |
+ return; |
|
| 7124 |
+ |
|
| 7125 |
+ t.load({initial : true, format : (s.cleanup_on_startup ? 'html' : 'raw')});
|
|
| 7126 |
+ t.startContent = t.getContent({format : 'raw'});
|
|
| 7127 |
+ t.undoManager.add({initial : true});
|
|
| 7128 |
+ t.initialized = true; |
|
| 7129 |
+ |
|
| 7130 |
+ t.onInit.dispatch(t); |
|
| 7131 |
+ t.execCallback('setupcontent_callback', t.id, t.getBody(), t.getDoc());
|
|
| 7132 |
+ t.execCallback('init_instance_callback', t);
|
|
| 7133 |
+ t.focus(true); |
|
| 7134 |
+ t.nodeChanged({initial : 1});
|
|
| 7135 |
+ |
|
| 7136 |
+ // Load specified content CSS last |
|
| 7137 |
+ if (s.content_css) {
|
|
| 7138 |
+ tinymce.each(explode(s.content_css), function(u) {
|
|
| 7139 |
+ t.dom.loadCSS(t.documentBaseURI.toAbsolute(u)); |
|
| 7140 |
+ }); |
|
| 7141 |
+ } |
|
| 7142 |
+ |
|
| 7143 |
+ // Handle auto focus |
|
| 7144 |
+ if (s.auto_focus) {
|
|
| 7145 |
+ setTimeout(function () {
|
|
| 7146 |
+ var ed = EditorManager.get(s.auto_focus); |
|
| 7147 |
+ |
|
| 7148 |
+ ed.selection.select(ed.getBody(), 1); |
|
| 7149 |
+ ed.selection.collapse(1); |
|
| 7150 |
+ ed.getWin().focus(); |
|
| 7151 |
+ }, 100); |
|
| 7152 |
+ } |
|
| 7153 |
+ }, 1); |
|
| 7154 |
+ |
|
| 7155 |
+ e = null; |
|
| 7156 |
+ }, |
|
| 7157 |
+ |
|
| 7158 |
+ |
|
| 7159 |
+ focus : function(sf) {
|
|
| 7160 |
+ var oed, t = this, ce = t.settings.content_editable; |
|
| 7161 |
+ |
|
| 7162 |
+ if (!sf) {
|
|
| 7163 |
+ if (!ce) |
|
| 7164 |
+ t.getWin().focus(); |
|
| 7165 |
+ |
|
| 7166 |
+ } |
|
| 7167 |
+ |
|
| 7168 |
+ if (EditorManager.activeEditor != t) {
|
|
| 7169 |
+ if ((oed = EditorManager.activeEditor) != null) |
|
| 7170 |
+ oed.onDeactivate.dispatch(oed, t); |
|
| 7171 |
+ |
|
| 7172 |
+ t.onActivate.dispatch(t, oed); |
|
| 7173 |
+ } |
|
| 7174 |
+ |
|
| 7175 |
+ EditorManager._setActive(t); |
|
| 7176 |
+ }, |
|
| 7177 |
+ |
|
| 7178 |
+ execCallback : function(n) {
|
|
| 7179 |
+ var t = this, f = t.settings[n], s; |
|
| 7180 |
+ |
|
| 7181 |
+ if (!f) |
|
| 7182 |
+ return; |
|
| 7183 |
+ |
|
| 7184 |
+ // Look through lookup |
|
| 7185 |
+ if (t.callbackLookup && (s = t.callbackLookup[n])) {
|
|
| 7186 |
+ f = s.func; |
|
| 7187 |
+ s = s.scope; |
|
| 7188 |
+ } |
|
| 7189 |
+ |
|
| 7190 |
+ if (is(f, 'string')) {
|
|
| 7191 |
+ s = f.replace(/\.\w+$/, ''); |
|
| 7192 |
+ s = s ? tinymce.resolve(s) : 0; |
|
| 7193 |
+ f = tinymce.resolve(f); |
|
| 7194 |
+ t.callbackLookup = t.callbackLookup || {};
|
|
| 7195 |
+ t.callbackLookup[n] = {func : f, scope : s};
|
|
| 7196 |
+ } |
|
| 7197 |
+ |
|
| 7198 |
+ return f.apply(s || t, Array.prototype.slice.call(arguments, 1)); |
|
| 7199 |
+ }, |
|
| 7200 |
+ |
|
| 7201 |
+ translate : function(s) {
|
|
| 7202 |
+ var c = this.settings.language, i18n = EditorManager.i18n; |
|
| 7203 |
+ |
|
| 7204 |
+ if (!s) |
|
| 7205 |
+ return ''; |
|
| 7206 |
+ |
|
| 7207 |
+ return i18n[c + '.' + s] || s.replace(/{\#([^}]+)\}/g, function(a, b) {
|
|
| 7208 |
+ return i18n[c + '.' + b] || '{#' + b + '}';
|
|
| 7209 |
+ }); |
|
| 7210 |
+ }, |
|
| 7211 |
+ |
|
| 7212 |
+ getLang : function(n, dv) {
|
|
| 7213 |
+ return EditorManager.i18n[this.settings.language + '.' + n] || (is(dv) ? dv : '{#' + n + '}');
|
|
| 7214 |
+ }, |
|
| 7215 |
+ |
|
| 7216 |
+ getParam : function(n, dv, ty) {
|
|
| 7217 |
+ var tr = tinymce.trim, v = is(this.settings[n]) ? this.settings[n] : dv, o; |
|
| 7218 |
+ |
|
| 7219 |
+ if (ty === 'hash') {
|
|
| 7220 |
+ o = {};
|
|
| 7221 |
+ |
|
| 7222 |
+ if (is(v, 'string')) {
|
|
| 7223 |
+ each(v.indexOf('=') > 0 ? v.split(/[;,](?![^=;,]*(?:[;,]|$))/) : v.split(','), function(v) {
|
|
| 7224 |
+ v = v.split('=');
|
|
| 7225 |
+ |
|
| 7226 |
+ if (v.length > 1) |
|
| 7227 |
+ o[tr(v[0])] = tr(v[1]); |
|
| 7228 |
+ else |
|
| 7229 |
+ o[tr(v[0])] = tr(v); |
|
| 7230 |
+ }); |
|
| 7231 |
+ } else |
|
| 7232 |
+ o = v; |
|
| 7233 |
+ |
|
| 7234 |
+ return o; |
|
| 7235 |
+ } |
|
| 7236 |
+ |
|
| 7237 |
+ return v; |
|
| 7238 |
+ }, |
|
| 7239 |
+ |
|
| 7240 |
+ nodeChanged : function(o) {
|
|
| 7241 |
+ var t = this, s = t.selection, n = s.getNode() || t.getBody(); |
|
| 7242 |
+ |
|
| 7243 |
+ // Fix for bug #1896577 it seems that this can not be fired while the editor is loading |
|
| 7244 |
+ if (t.initialized) {
|
|
| 7245 |
+ t.onNodeChange.dispatch( |
|
| 7246 |
+ t, |
|
| 7247 |
+ o ? o.controlManager || t.controlManager : t.controlManager, |
|
| 7248 |
+ isIE && n.ownerDocument != t.getDoc() ? t.getBody() : n, // Fix for IE initial state |
|
| 7249 |
+ s.isCollapsed(), |
|
| 7250 |
+ o |
|
| 7251 |
+ ); |
|
| 7252 |
+ } |
|
| 7253 |
+ }, |
|
| 7254 |
+ |
|
| 7255 |
+ addButton : function(n, s) {
|
|
| 7256 |
+ var t = this; |
|
| 7257 |
+ |
|
| 7258 |
+ t.buttons = t.buttons || {};
|
|
| 7259 |
+ t.buttons[n] = s; |
|
| 7260 |
+ }, |
|
| 7261 |
+ |
|
| 7262 |
+ addCommand : function(n, f, s) {
|
|
| 7263 |
+ this.execCommands[n] = {func : f, scope : s || this};
|
|
| 7264 |
+ }, |
|
| 7265 |
+ |
|
| 7266 |
+ addQueryStateHandler : function(n, f, s) {
|
|
| 7267 |
+ this.queryStateCommands[n] = {func : f, scope : s || this};
|
|
| 7268 |
+ }, |
|
| 7269 |
+ |
|
| 7270 |
+ addQueryValueHandler : function(n, f, s) {
|
|
| 7271 |
+ this.queryValueCommands[n] = {func : f, scope : s || this};
|
|
| 7272 |
+ }, |
|
| 7273 |
+ |
|
| 7274 |
+ addShortcut : function(pa, desc, cmd_func, sc) {
|
|
| 7275 |
+ var t = this, c; |
|
| 7276 |
+ |
|
| 7277 |
+ if (!t.settings.custom_shortcuts) |
|
| 7278 |
+ return false; |
|
| 7279 |
+ |
|
| 7280 |
+ t.shortcuts = t.shortcuts || {};
|
|
| 7281 |
+ |
|
| 7282 |
+ if (is(cmd_func, 'string')) {
|
|
| 7283 |
+ c = cmd_func; |
|
| 7284 |
+ |
|
| 7285 |
+ cmd_func = function() {
|
|
| 7286 |
+ t.execCommand(c, false, null); |
|
| 7287 |
+ }; |
|
| 7288 |
+ } |
|
| 7289 |
+ |
|
| 7290 |
+ if (is(cmd_func, 'object')) {
|
|
| 7291 |
+ c = cmd_func; |
|
| 7292 |
+ |
|
| 7293 |
+ cmd_func = function() {
|
|
| 7294 |
+ t.execCommand(c[0], c[1], c[2]); |
|
| 7295 |
+ }; |
|
| 7296 |
+ } |
|
| 7297 |
+ |
|
| 7298 |
+ each(explode(pa), function(pa) {
|
|
| 7299 |
+ var o = {
|
|
| 7300 |
+ func : cmd_func, |
|
| 7301 |
+ scope : sc || this, |
|
| 7302 |
+ desc : desc, |
|
| 7303 |
+ alt : false, |
|
| 7304 |
+ ctrl : false, |
|
| 7305 |
+ shift : false |
|
| 7306 |
+ }; |
|
| 7307 |
+ |
|
| 7308 |
+ each(explode(pa, '+'), function(v) {
|
|
| 7309 |
+ switch (v) {
|
|
| 7310 |
+ case 'alt': |
|
| 7311 |
+ case 'ctrl': |
|
| 7312 |
+ case 'shift': |
|
| 7313 |
+ o[v] = true; |
|
| 7314 |
+ break; |
|
| 7315 |
+ |
|
| 7316 |
+ default: |
|
| 7317 |
+ o.charCode = v.charCodeAt(0); |
|
| 7318 |
+ o.keyCode = v.toUpperCase().charCodeAt(0); |
|
| 7319 |
+ } |
|
| 7320 |
+ }); |
|
| 7321 |
+ |
|
| 7322 |
+ t.shortcuts[(o.ctrl ? 'ctrl' : '') + ',' + (o.alt ? 'alt' : '') + ',' + (o.shift ? 'shift' : '') + ',' + o.keyCode] = o; |
|
| 7323 |
+ }); |
|
| 7324 |
+ |
|
| 7325 |
+ return true; |
|
| 7326 |
+ }, |
|
| 7327 |
+ |
|
| 7328 |
+ execCommand : function(cmd, ui, val, a) {
|
|
| 7329 |
+ var t = this, s = 0, o, st; |
|
| 7330 |
+ |
|
| 7331 |
+ if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd) && (!a || !a.skip_focus)) |
|
| 7332 |
+ t.focus(); |
|
| 7333 |
+ |
|
| 7334 |
+ o = {};
|
|
| 7335 |
+ t.onBeforeExecCommand.dispatch(t, cmd, ui, val, o); |
|
| 7336 |
+ if (o.terminate) |
|
| 7337 |
+ return false; |
|
| 7338 |
+ |
|
| 7339 |
+ // Command callback |
|
| 7340 |
+ if (t.execCallback('execcommand_callback', t.id, t.selection.getNode(), cmd, ui, val)) {
|
|
| 7341 |
+ t.onExecCommand.dispatch(t, cmd, ui, val, a); |
|
| 7342 |
+ return true; |
|
| 7343 |
+ } |
|
| 7344 |
+ |
|
| 7345 |
+ // Registred commands |
|
| 7346 |
+ if (o = t.execCommands[cmd]) {
|
|
| 7347 |
+ st = o.func.call(o.scope, ui, val); |
|
| 7348 |
+ |
|
| 7349 |
+ // Fall through on true |
|
| 7350 |
+ if (st !== true) {
|
|
| 7351 |
+ t.onExecCommand.dispatch(t, cmd, ui, val, a); |
|
| 7352 |
+ return st; |
|
| 7353 |
+ } |
|
| 7354 |
+ } |
|
| 7355 |
+ |
|
| 7356 |
+ // Plugin commands |
|
| 7357 |
+ each(t.plugins, function(p) {
|
|
| 7358 |
+ if (p.execCommand && p.execCommand(cmd, ui, val)) {
|
|
| 7359 |
+ t.onExecCommand.dispatch(t, cmd, ui, val, a); |
|
| 7360 |
+ s = 1; |
|
| 7361 |
+ return false; |
|
| 7362 |
+ } |
|
| 7363 |
+ }); |
|
| 7364 |
+ |
|
| 7365 |
+ if (s) |
|
| 7366 |
+ return true; |
|
| 7367 |
+ |
|
| 7368 |
+ // Theme commands |
|
| 7369 |
+ if (t.theme.execCommand && t.theme.execCommand(cmd, ui, val)) {
|
|
| 7370 |
+ t.onExecCommand.dispatch(t, cmd, ui, val, a); |
|
| 7371 |
+ return true; |
|
| 7372 |
+ } |
|
| 7373 |
+ |
|
| 7374 |
+ // Editor commands |
|
| 7375 |
+ if (t.editorCommands.execCommand(cmd, ui, val)) {
|
|
| 7376 |
+ t.onExecCommand.dispatch(t, cmd, ui, val, a); |
|
| 7377 |
+ return true; |
|
| 7378 |
+ } |
|
| 7379 |
+ |
|
| 7380 |
+ // Browser commands |
|
| 7381 |
+ t.getDoc().execCommand(cmd, ui, val); |
|
| 7382 |
+ t.onExecCommand.dispatch(t, cmd, ui, val, a); |
|
| 7383 |
+ }, |
|
| 7384 |
+ |
|
| 7385 |
+ queryCommandState : function(c) {
|
|
| 7386 |
+ var t = this, o, s; |
|
| 7387 |
+ |
|
| 7388 |
+ // Is hidden then return undefined |
|
| 7389 |
+ if (t._isHidden()) |
|
| 7390 |
+ return; |
|
| 7391 |
+ |
|
| 7392 |
+ // Registred commands |
|
| 7393 |
+ if (o = t.queryStateCommands[c]) {
|
|
| 7394 |
+ s = o.func.call(o.scope); |
|
| 7395 |
+ |
|
| 7396 |
+ // Fall though on true |
|
| 7397 |
+ if (s !== true) |
|
| 7398 |
+ return s; |
|
| 7399 |
+ } |
|
| 7400 |
+ |
|
| 7401 |
+ // Registred commands |
|
| 7402 |
+ o = t.editorCommands.queryCommandState(c); |
|
| 7403 |
+ if (o !== -1) |
|
| 7404 |
+ return o; |
|
| 7405 |
+ |
|
| 7406 |
+ // Browser commands |
|
| 7407 |
+ try {
|
|
| 7408 |
+ return this.getDoc().queryCommandState(c); |
|
| 7409 |
+ } catch (ex) {
|
|
| 7410 |
+ // Fails sometimes see bug: 1896577 |
|
| 7411 |
+ } |
|
| 7412 |
+ }, |
|
| 7413 |
+ |
|
| 7414 |
+ queryCommandValue : function(c) {
|
|
| 7415 |
+ var t = this, o, s; |
|
| 7416 |
+ |
|
| 7417 |
+ // Is hidden then return undefined |
|
| 7418 |
+ if (t._isHidden()) |
|
| 7419 |
+ return; |
|
| 7420 |
+ |
|
| 7421 |
+ // Registred commands |
|
| 7422 |
+ if (o = t.queryValueCommands[c]) {
|
|
| 7423 |
+ s = o.func.call(o.scope); |
|
| 7424 |
+ |
|
| 7425 |
+ // Fall though on true |
|
| 7426 |
+ if (s !== true) |
|
| 7427 |
+ return s; |
|
| 7428 |
+ } |
|
| 7429 |
+ |
|
| 7430 |
+ // Registred commands |
|
| 7431 |
+ o = t.editorCommands.queryCommandValue(c); |
|
| 7432 |
+ if (is(o)) |
|
| 7433 |
+ return o; |
|
| 7434 |
+ |
|
| 7435 |
+ // Browser commands |
|
| 7436 |
+ try {
|
|
| 7437 |
+ return this.getDoc().queryCommandValue(c); |
|
| 7438 |
+ } catch (ex) {
|
|
| 7439 |
+ // Fails sometimes see bug: 1896577 |
|
| 7440 |
+ } |
|
| 7441 |
+ }, |
|
| 7442 |
+ |
|
| 7443 |
+ show : function() {
|
|
| 7444 |
+ var t = this; |
|
| 7445 |
+ |
|
| 7446 |
+ DOM.show(t.getContainer()); |
|
| 7447 |
+ DOM.hide(t.id); |
|
| 7448 |
+ t.load(); |
|
| 7449 |
+ }, |
|
| 7450 |
+ |
|
| 7451 |
+ hide : function() {
|
|
| 7452 |
+ var t = this, d = t.getDoc(); |
|
| 7453 |
+ |
|
| 7454 |
+ // Fixed bug where IE has a blinking cursor left from the editor |
|
| 7455 |
+ if (isIE && d) |
|
| 7456 |
+ d.execCommand('SelectAll');
|
|
| 7457 |
+ |
|
| 7458 |
+ // We must save before we hide so Safari doesn't crash |
|
| 7459 |
+ t.save(); |
|
| 7460 |
+ DOM.hide(t.getContainer()); |
|
| 7461 |
+ DOM.setStyle(t.id, 'display', t.orgDisplay); |
|
| 7462 |
+ }, |
|
| 7463 |
+ |
|
| 7464 |
+ isHidden : function() {
|
|
| 7465 |
+ return !DOM.isHidden(this.id); |
|
| 7466 |
+ }, |
|
| 7467 |
+ |
|
| 7468 |
+ setProgressState : function(b, ti, o) {
|
|
| 7469 |
+ this.onSetProgressState.dispatch(this, b, ti, o); |
|
| 7470 |
+ |
|
| 7471 |
+ return b; |
|
| 7472 |
+ }, |
|
| 7473 |
+ |
|
| 7474 |
+ resizeToContent : function() {
|
|
| 7475 |
+ var t = this; |
|
| 7476 |
+ |
|
| 7477 |
+ DOM.setStyle(t.id + "_ifr", 'height', t.getBody().scrollHeight); |
|
| 7478 |
+ }, |
|
| 7479 |
+ |
|
| 7480 |
+ load : function(o) {
|
|
| 7481 |
+ var t = this, e = t.getElement(), h; |
|
| 7482 |
+ |
|
| 7483 |
+ o = o || {};
|
|
| 7484 |
+ o.load = true; |
|
| 7485 |
+ |
|
| 7486 |
+ h = t.setContent(is(e.value) ? e.value : e.innerHTML, o); |
|
| 7487 |
+ o.element = e; |
|
| 7488 |
+ |
|
| 7489 |
+ if (!o.no_events) |
|
| 7490 |
+ t.onLoadContent.dispatch(t, o); |
|
| 7491 |
+ |
|
| 7492 |
+ o.element = e = null; |
|
| 7493 |
+ |
|
| 7494 |
+ return h; |
|
| 7495 |
+ }, |
|
| 7496 |
+ |
|
| 7497 |
+ save : function(o) {
|
|
| 7498 |
+ var t = this, e = t.getElement(), h, f; |
|
| 7499 |
+ |
|
| 7500 |
+ if (!t.initialized) |
|
| 7501 |
+ return; |
|
| 7502 |
+ |
|
| 7503 |
+ o = o || {};
|
|
| 7504 |
+ o.save = true; |
|
| 7505 |
+ |
|
| 7506 |
+ // Add undo level will trigger onchange event |
|
| 7507 |
+ if (!o.no_events) {
|
|
| 7508 |
+ t.undoManager.typing = 0; |
|
| 7509 |
+ t.undoManager.add(); |
|
| 7510 |
+ } |
|
| 7511 |
+ |
|
| 7512 |
+ o.element = e; |
|
| 7513 |
+ h = o.content = t.getContent(o); |
|
| 7514 |
+ |
|
| 7515 |
+ if (!o.no_events) |
|
| 7516 |
+ t.onSaveContent.dispatch(t, o); |
|
| 7517 |
+ |
|
| 7518 |
+ h = o.content; |
|
| 7519 |
+ |
|
| 7520 |
+ if (!/TEXTAREA|INPUT/i.test(e.nodeName)) {
|
|
| 7521 |
+ e.innerHTML = h; |
|
| 7522 |
+ |
|
| 7523 |
+ // Update hidden form element |
|
| 7524 |
+ if (f = DOM.getParent(t.id, 'form')) {
|
|
| 7525 |
+ each(f.elements, function(e) {
|
|
| 7526 |
+ if (e.name == t.id) {
|
|
| 7527 |
+ e.value = h; |
|
| 7528 |
+ return false; |
|
| 7529 |
+ } |
|
| 7530 |
+ }); |
|
| 7531 |
+ } |
|
| 7532 |
+ } else |
|
| 7533 |
+ e.value = h; |
|
| 7534 |
+ |
|
| 7535 |
+ o.element = e = null; |
|
| 7536 |
+ |
|
| 7537 |
+ return h; |
|
| 7538 |
+ }, |
|
| 7539 |
+ |
|
| 7540 |
+ setContent : function(h, o) {
|
|
| 7541 |
+ var t = this; |
|
| 7542 |
+ |
|
| 7543 |
+ o = o || {};
|
|
| 7544 |
+ o.format = o.format || 'html'; |
|
| 7545 |
+ o.set = true; |
|
| 7546 |
+ o.content = h; |
|
| 7547 |
+ |
|
| 7548 |
+ if (!o.no_events) |
|
| 7549 |
+ t.onBeforeSetContent.dispatch(t, o); |
|
| 7550 |
+ |
|
| 7551 |
+ // Padd empty content in Gecko and Safari. Commands will otherwise fail on the content |
|
| 7552 |
+ // It will also be impossible to place the caret in the editor unless there is a BR element present |
|
| 7553 |
+ if (!tinymce.isIE && (h.length === 0 || /^\s+$/.test(h))) {
|
|
| 7554 |
+ o.content = t.dom.setHTML(t.getBody(), '<br mce_bogus="1" />'); |
|
| 7555 |
+ o.format = 'raw'; |
|
| 7556 |
+ } |
|
| 7557 |
+ |
|
| 7558 |
+ o.content = t.dom.setHTML(t.getBody(), tinymce.trim(o.content)); |
|
| 7559 |
+ |
|
| 7560 |
+ if (o.format != 'raw' && t.settings.cleanup) {
|
|
| 7561 |
+ o.getInner = true; |
|
| 7562 |
+ o.content = t.dom.setHTML(t.getBody(), t.serializer.serialize(t.getBody(), o)); |
|
| 7563 |
+ } |
|
| 7564 |
+ |
|
| 7565 |
+ if (!o.no_events) |
|
| 7566 |
+ t.onSetContent.dispatch(t, o); |
|
| 7567 |
+ |
|
| 7568 |
+ return o.content; |
|
| 7569 |
+ }, |
|
| 7570 |
+ |
|
| 7571 |
+ getContent : function(o) {
|
|
| 7572 |
+ var t = this, h; |
|
| 7573 |
+ |
|
| 7574 |
+ o = o || {};
|
|
| 7575 |
+ o.format = o.format || 'html'; |
|
| 7576 |
+ o.get = true; |
|
| 7577 |
+ |
|
| 7578 |
+ if (!o.no_events) |
|
| 7579 |
+ t.onBeforeGetContent.dispatch(t, o); |
|
| 7580 |
+ |
|
| 7581 |
+ if (o.format != 'raw' && t.settings.cleanup) {
|
|
| 7582 |
+ o.getInner = true; |
|
| 7583 |
+ h = t.serializer.serialize(t.getBody(), o); |
|
| 7584 |
+ } else |
|
| 7585 |
+ h = t.getBody().innerHTML; |
|
| 7586 |
+ |
|
| 7587 |
+ h = h.replace(/^\s*|\s*$/g, ''); |
|
| 7588 |
+ o.content = h; |
|
| 7589 |
+ |
|
| 7590 |
+ if (!o.no_events) |
|
| 7591 |
+ t.onGetContent.dispatch(t, o); |
|
| 7592 |
+ |
|
| 7593 |
+ return o.content; |
|
| 7594 |
+ }, |
|
| 7595 |
+ |
|
| 7596 |
+ isDirty : function() {
|
|
| 7597 |
+ var t = this; |
|
| 7598 |
+ |
|
| 7599 |
+ return tinymce.trim(t.startContent) != tinymce.trim(t.getContent({format : 'raw', no_events : 1})) && !t.isNotDirty;
|
|
| 7600 |
+ }, |
|
| 7601 |
+ |
|
| 7602 |
+ getContainer : function() {
|
|
| 7603 |
+ var t = this; |
|
| 7604 |
+ |
|
| 7605 |
+ if (!t.container) |
|
| 7606 |
+ t.container = DOM.get(t.editorContainer || t.id + '_parent'); |
|
| 7607 |
+ |
|
| 7608 |
+ return t.container; |
|
| 7609 |
+ }, |
|
| 7610 |
+ |
|
| 7611 |
+ getContentAreaContainer : function() {
|
|
| 7612 |
+ return this.contentAreaContainer; |
|
| 7613 |
+ }, |
|
| 7614 |
+ |
|
| 7615 |
+ getElement : function() {
|
|
| 7616 |
+ return DOM.get(this.settings.content_element || this.id); |
|
| 7617 |
+ }, |
|
| 7618 |
+ |
|
| 7619 |
+ getWin : function() {
|
|
| 7620 |
+ var t = this, e; |
|
| 7621 |
+ |
|
| 7622 |
+ if (!t.contentWindow) {
|
|
| 7623 |
+ e = DOM.get(t.id + "_ifr"); |
|
| 7624 |
+ |
|
| 7625 |
+ if (e) |
|
| 7626 |
+ t.contentWindow = e.contentWindow; |
|
| 7627 |
+ } |
|
| 7628 |
+ |
|
| 7629 |
+ return t.contentWindow; |
|
| 7630 |
+ }, |
|
| 7631 |
+ |
|
| 7632 |
+ getDoc : function() {
|
|
| 7633 |
+ var t = this, w; |
|
| 7634 |
+ |
|
| 7635 |
+ if (!t.contentDocument) {
|
|
| 7636 |
+ w = t.getWin(); |
|
| 7637 |
+ |
|
| 7638 |
+ if (w) |
|
| 7639 |
+ t.contentDocument = w.document; |
|
| 7640 |
+ } |
|
| 7641 |
+ |
|
| 7642 |
+ return t.contentDocument; |
|
| 7643 |
+ }, |
|
| 7644 |
+ |
|
| 7645 |
+ getBody : function() {
|
|
| 7646 |
+ return this.bodyElement || this.getDoc().body; |
|
| 7647 |
+ }, |
|
| 7648 |
+ |
|
| 7649 |
+ convertURL : function(u, n, e) {
|
|
| 7650 |
+ var t = this, s = t.settings; |
|
| 7651 |
+ |
|
| 7652 |
+ // Use callback instead |
|
| 7653 |
+ if (s.urlconverter_callback) |
|
| 7654 |
+ return t.execCallback('urlconverter_callback', u, e, true, n);
|
|
| 7655 |
+ |
|
| 7656 |
+ // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs |
|
| 7657 |
+ if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
|
|
| 7658 |
+ return u; |
|
| 7659 |
+ |
|
| 7660 |
+ // Convert to relative |
|
| 7661 |
+ if (s.relative_urls) |
|
| 7662 |
+ return t.documentBaseURI.toRelative(u); |
|
| 7663 |
+ |
|
| 7664 |
+ // Convert to absolute |
|
| 7665 |
+ u = t.documentBaseURI.toAbsolute(u, s.remove_script_host); |
|
| 7666 |
+ |
|
| 7667 |
+ return u; |
|
| 7668 |
+ }, |
|
| 7669 |
+ |
|
| 7670 |
+ addVisual : function(e) {
|
|
| 7671 |
+ var t = this, s = t.settings; |
|
| 7672 |
+ |
|
| 7673 |
+ e = e || t.getBody(); |
|
| 7674 |
+ |
|
| 7675 |
+ if (!is(t.hasVisual)) |
|
| 7676 |
+ t.hasVisual = s.visual; |
|
| 7677 |
+ |
|
| 7678 |
+ each(t.dom.select('table,a', e), function(e) {
|
|
| 7679 |
+ var v; |
|
| 7680 |
+ |
|
| 7681 |
+ switch (e.nodeName) {
|
|
| 7682 |
+ case 'TABLE': |
|
| 7683 |
+ v = t.dom.getAttrib(e, 'border'); |
|
| 7684 |
+ |
|
| 7685 |
+ if (!v || v == '0') {
|
|
| 7686 |
+ if (t.hasVisual) |
|
| 7687 |
+ t.dom.addClass(e, s.visual_table_class); |
|
| 7688 |
+ else |
|
| 7689 |
+ t.dom.removeClass(e, s.visual_table_class); |
|
| 7690 |
+ } |
|
| 7691 |
+ |
|
| 7692 |
+ return; |
|
| 7693 |
+ |
|
| 7694 |
+ case 'A': |
|
| 7695 |
+ v = t.dom.getAttrib(e, 'name'); |
|
| 7696 |
+ |
|
| 7697 |
+ if (v) {
|
|
| 7698 |
+ if (t.hasVisual) |
|
| 7699 |
+ t.dom.addClass(e, 'mceItemAnchor'); |
|
| 7700 |
+ else |
|
| 7701 |
+ t.dom.removeClass(e, 'mceItemAnchor'); |
|
| 7702 |
+ } |
|
| 7703 |
+ |
|
| 7704 |
+ return; |
|
| 7705 |
+ } |
|
| 7706 |
+ }); |
|
| 7707 |
+ |
|
| 7708 |
+ t.onVisualAid.dispatch(t, e, t.hasVisual); |
|
| 7709 |
+ }, |
|
| 7710 |
+ |
|
| 7711 |
+ remove : function() {
|
|
| 7712 |
+ var t = this, e = t.getContainer(); |
|
| 7713 |
+ |
|
| 7714 |
+ t.removed = 1; // Cancels post remove event execution |
|
| 7715 |
+ t.hide(); |
|
| 7716 |
+ |
|
| 7717 |
+ t.execCallback('remove_instance_callback', t);
|
|
| 7718 |
+ t.onRemove.dispatch(t); |
|
| 7719 |
+ |
|
| 7720 |
+ // Clear all execCommand listeners this is required to avoid errors if the editor was removed inside another command |
|
| 7721 |
+ t.onExecCommand.listeners = []; |
|
| 7722 |
+ |
|
| 7723 |
+ EditorManager.remove(t); |
|
| 7724 |
+ DOM.remove(e); |
|
| 7725 |
+ }, |
|
| 7726 |
+ |
|
| 7727 |
+ destroy : function(s) {
|
|
| 7728 |
+ var t = this; |
|
| 7729 |
+ |
|
| 7730 |
+ // One time is enough |
|
| 7731 |
+ if (t.destroyed) |
|
| 7732 |
+ return; |
|
| 7733 |
+ |
|
| 7734 |
+ if (!s) {
|
|
| 7735 |
+ tinymce.removeUnload(t.destroy); |
|
| 7736 |
+ tinyMCE.onBeforeUnload.remove(t._beforeUnload); |
|
| 7737 |
+ |
|
| 7738 |
+ // Manual destroy |
|
| 7739 |
+ if (t.theme.destroy) |
|
| 7740 |
+ t.theme.destroy(); |
|
| 7741 |
+ |
|
| 7742 |
+ // Destroy controls, selection and dom |
|
| 7743 |
+ t.controlManager.destroy(); |
|
| 7744 |
+ t.selection.destroy(); |
|
| 7745 |
+ t.dom.destroy(); |
|
| 7746 |
+ |
|
| 7747 |
+ // Remove all events |
|
| 7748 |
+ |
|
| 7749 |
+ // Don't clear the window or document if content editable |
|
| 7750 |
+ // is enabled since other instances might still be present |
|
| 7751 |
+ if (!t.settings.content_editable) {
|
|
| 7752 |
+ Event.clear(t.getWin()); |
|
| 7753 |
+ Event.clear(t.getDoc()); |
|
| 7754 |
+ } |
|
| 7755 |
+ |
|
| 7756 |
+ Event.clear(t.getBody()); |
|
| 7757 |
+ Event.clear(t.formElement); |
|
| 7758 |
+ } |
|
| 7759 |
+ |
|
| 7760 |
+ if (t.formElement) {
|
|
| 7761 |
+ t.formElement.submit = t.formElement._mceOldSubmit; |
|
| 7762 |
+ t.formElement._mceOldSubmit = null; |
|
| 7763 |
+ } |
|
| 7764 |
+ |
|
| 7765 |
+ t.contentAreaContainer = t.formElement = t.container = t.settings.content_element = t.bodyElement = t.contentDocument = t.contentWindow = null; |
|
| 7766 |
+ |
|
| 7767 |
+ if (t.selection) |
|
| 7768 |
+ t.selection = t.selection.win = t.selection.dom = t.selection.dom.doc = null; |
|
| 7769 |
+ |
|
| 7770 |
+ t.destroyed = 1; |
|
| 7771 |
+ }, |
|
| 7772 |
+ |
|
| 7773 |
+ // Internal functions |
|
| 7774 |
+ |
|
| 7775 |
+ _addEvents : function() {
|
|
| 7776 |
+ // 'focus', 'blur', 'dblclick', 'beforedeactivate', submit, reset |
|
| 7777 |
+ var t = this, i, s = t.settings, lo = {
|
|
| 7778 |
+ mouseup : 'onMouseUp', |
|
| 7779 |
+ mousedown : 'onMouseDown', |
|
| 7780 |
+ click : 'onClick', |
|
| 7781 |
+ keyup : 'onKeyUp', |
|
| 7782 |
+ keydown : 'onKeyDown', |
|
| 7783 |
+ keypress : 'onKeyPress', |
|
| 7784 |
+ submit : 'onSubmit', |
|
| 7785 |
+ reset : 'onReset', |
|
| 7786 |
+ contextmenu : 'onContextMenu', |
|
| 7787 |
+ dblclick : 'onDblClick', |
|
| 7788 |
+ paste : 'onPaste' // Doesn't work in all browsers yet |
|
| 7789 |
+ }; |
|
| 7790 |
+ |
|
| 7791 |
+ function eventHandler(e, o) {
|
|
| 7792 |
+ var ty = e.type; |
|
| 7793 |
+ |
|
| 7794 |
+ // Don't fire events when it's removed |
|
| 7795 |
+ if (t.removed) |
|
| 7796 |
+ return; |
|
| 7797 |
+ |
|
| 7798 |
+ // Generic event handler |
|
| 7799 |
+ if (t.onEvent.dispatch(t, e, o) !== false) {
|
|
| 7800 |
+ // Specific event handler |
|
| 7801 |
+ t[lo[e.fakeType || e.type]].dispatch(t, e, o); |
|
| 7802 |
+ } |
|
| 7803 |
+ }; |
|
| 7804 |
+ |
|
| 7805 |
+ // Add DOM events |
|
| 7806 |
+ each(lo, function(v, k) {
|
|
| 7807 |
+ switch (k) {
|
|
| 7808 |
+ case 'contextmenu': |
|
| 7809 |
+ if (tinymce.isOpera) {
|
|
| 7810 |
+ // Fake contextmenu on Opera |
|
| 7811 |
+ Event.add(t.getBody(), 'mousedown', function(e) {
|
|
| 7812 |
+ if (e.ctrlKey) {
|
|
| 7813 |
+ e.fakeType = 'contextmenu'; |
|
| 7814 |
+ eventHandler(e); |
|
| 7815 |
+ } |
|
| 7816 |
+ }); |
|
| 7817 |
+ } else |
|
| 7818 |
+ Event.add(t.getBody(), k, eventHandler); |
|
| 7819 |
+ break; |
|
| 7820 |
+ |
|
| 7821 |
+ case 'paste': |
|
| 7822 |
+ Event.add(t.getBody(), k, function(e) {
|
|
| 7823 |
+ var tx, h, el, r; |
|
| 7824 |
+ |
|
| 7825 |
+ // Get plain text data |
|
| 7826 |
+ if (e.clipboardData) |
|
| 7827 |
+ tx = e.clipboardData.getData('text/plain');
|
|
| 7828 |
+ else if (tinymce.isIE) |
|
| 7829 |
+ tx = t.getWin().clipboardData.getData('Text');
|
|
| 7830 |
+ |
|
| 7831 |
+ // Get HTML data |
|
| 7832 |
+ /*if (tinymce.isIE) {
|
|
| 7833 |
+ el = DOM.add(DOM.doc.body, 'div', {style : 'visibility:hidden;overflow:hidden;position:absolute;width:1px;height:1px'});
|
|
| 7834 |
+ r = DOM.doc.body.createTextRange(); |
|
| 7835 |
+ r.moveToElementText(el); |
|
| 7836 |
+ r.execCommand('Paste');
|
|
| 7837 |
+ h = el.innerHTML; |
|
| 7838 |
+ DOM.remove(el); |
|
| 7839 |
+ }*/ |
|
| 7840 |
+ |
|
| 7841 |
+ eventHandler(e, {text : tx, html : h});
|
|
| 7842 |
+ }); |
|
| 7843 |
+ break; |
|
| 7844 |
+ |
|
| 7845 |
+ case 'submit': |
|
| 7846 |
+ case 'reset': |
|
| 7847 |
+ Event.add(t.getElement().form || DOM.getParent(t.id, 'form'), k, eventHandler); |
|
| 7848 |
+ break; |
|
| 7849 |
+ |
|
| 7850 |
+ default: |
|
| 7851 |
+ Event.add(s.content_editable ? t.getBody() : t.getDoc(), k, eventHandler); |
|
| 7852 |
+ } |
|
| 7853 |
+ }); |
|
| 7854 |
+ |
|
| 7855 |
+ Event.add(s.content_editable ? t.getBody() : (isGecko ? t.getDoc() : t.getWin()), 'focus', function(e) {
|
|
| 7856 |
+ t.focus(true); |
|
| 7857 |
+ }); |
|
| 7858 |
+ |
|
| 7859 |
+ |
|
| 7860 |
+ // Fixes bug where a specified document_base_uri could result in broken images |
|
| 7861 |
+ // This will also fix drag drop of images in Gecko |
|
| 7862 |
+ if (tinymce.isGecko) {
|
|
| 7863 |
+ // Convert all images to absolute URLs |
|
| 7864 |
+/* t.onSetContent.add(function(ed, o) {
|
|
| 7865 |
+ each(ed.dom.select('img'), function(e) {
|
|
| 7866 |
+ var v; |
|
| 7867 |
+ |
|
| 7868 |
+ if (v = e.getAttribute('mce_src'))
|
|
| 7869 |
+ e.src = t.documentBaseURI.toAbsolute(v); |
|
| 7870 |
+ }) |
|
| 7871 |
+ });*/ |
|
| 7872 |
+ |
|
| 7873 |
+ Event.add(t.getDoc(), 'DOMNodeInserted', function(e) {
|
|
| 7874 |
+ var v; |
|
| 7875 |
+ |
|
| 7876 |
+ e = e.target; |
|
| 7877 |
+ |
|
| 7878 |
+ if (e.nodeType === 1 && e.nodeName === 'IMG' && (v = e.getAttribute('mce_src')))
|
|
| 7879 |
+ e.src = t.documentBaseURI.toAbsolute(v); |
|
| 7880 |
+ }); |
|
| 7881 |
+ } |
|
| 7882 |
+ |
|
| 7883 |
+ // Set various midas options in Gecko |
|
| 7884 |
+ if (isGecko) {
|
|
| 7885 |
+ function setOpts() {
|
|
| 7886 |
+ var t = this, d = t.getDoc(), s = t.settings; |
|
| 7887 |
+ |
|
| 7888 |
+ if (isGecko) {
|
|
| 7889 |
+ if (t._isHidden()) {
|
|
| 7890 |
+ try {
|
|
| 7891 |
+ if (!s.content_editable) |
|
| 7892 |
+ d.designMode = 'On'; |
|
| 7893 |
+ } catch (ex) {
|
|
| 7894 |
+ // Fails if it's hidden |
|
| 7895 |
+ } |
|
| 7896 |
+ } |
|
| 7897 |
+ |
|
| 7898 |
+ try {
|
|
| 7899 |
+ // Try new Gecko method |
|
| 7900 |
+ d.execCommand("styleWithCSS", 0, false);
|
|
| 7901 |
+ } catch (ex) {
|
|
| 7902 |
+ // Use old method |
|
| 7903 |
+ if (!t._isHidden()) |
|
| 7904 |
+ try {d.execCommand("useCSS", 0, true);} catch (ex) {}
|
|
| 7905 |
+ } |
|
| 7906 |
+ |
|
| 7907 |
+ if (!s.table_inline_editing) |
|
| 7908 |
+ try {d.execCommand('enableInlineTableEditing', false, false);} catch (ex) {}
|
|
| 7909 |
+ |
|
| 7910 |
+ if (!s.object_resizing) |
|
| 7911 |
+ try {d.execCommand('enableObjectResizing', false, false);} catch (ex) {}
|
|
| 7912 |
+ } |
|
| 7913 |
+ }; |
|
| 7914 |
+ |
|
| 7915 |
+ t.onBeforeExecCommand.add(setOpts); |
|
| 7916 |
+ t.onMouseDown.add(setOpts); |
|
| 7917 |
+ } |
|
| 7918 |
+ |
|
| 7919 |
+ // Add node change handlers |
|
| 7920 |
+ t.onMouseUp.add(t.nodeChanged); |
|
| 7921 |
+ t.onClick.add(t.nodeChanged); |
|
| 7922 |
+ t.onKeyUp.add(function(ed, e) {
|
|
| 7923 |
+ if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45 || e.keyCode == 46 || e.keyCode == 8 || e.ctrlKey) |
|
| 7924 |
+ t.nodeChanged(); |
|
| 7925 |
+ }); |
|
| 7926 |
+ |
|
| 7927 |
+ // Add reset handler |
|
| 7928 |
+ t.onReset.add(function() {
|
|
| 7929 |
+ t.setContent(t.startContent, {format : 'raw'});
|
|
| 7930 |
+ }); |
|
| 7931 |
+ |
|
| 7932 |
+ if (t.getParam('tab_focus')) {
|
|
| 7933 |
+ function tabCancel(ed, e) {
|
|
| 7934 |
+ if (e.keyCode === 9) |
|
| 7935 |
+ return Event.cancel(e); |
|
| 7936 |
+ }; |
|
| 7937 |
+ |
|
| 7938 |
+ function tabHandler(ed, e) {
|
|
| 7939 |
+ var x, i, f, el, v; |
|
| 7940 |
+ |
|
| 7941 |
+ function find(d) {
|
|
| 7942 |
+ f = DOM.getParent(ed.id, 'form'); |
|
| 7943 |
+ el = f.elements; |
|
| 7944 |
+ |
|
| 7945 |
+ if (f) {
|
|
| 7946 |
+ each(el, function(e, i) {
|
|
| 7947 |
+ if (e.id == ed.id) {
|
|
| 7948 |
+ x = i; |
|
| 7949 |
+ return false; |
|
| 7950 |
+ } |
|
| 7951 |
+ }); |
|
| 7952 |
+ |
|
| 7953 |
+ if (d > 0) {
|
|
| 7954 |
+ for (i = x + 1; i < el.length; i++) {
|
|
| 7955 |
+ if (el[i].type != 'hidden') |
|
| 7956 |
+ return el[i]; |
|
| 7957 |
+ } |
|
| 7958 |
+ } else {
|
|
| 7959 |
+ for (i = x - 1; i >= 0; i--) {
|
|
| 7960 |
+ if (el[i].type != 'hidden') |
|
| 7961 |
+ return el[i]; |
|
| 7962 |
+ } |
|
| 7963 |
+ } |
|
| 7964 |
+ } |
|
| 7965 |
+ |
|
| 7966 |
+ return null; |
|
| 7967 |
+ }; |
|
| 7968 |
+ |
|
| 7969 |
+ if (e.keyCode === 9) {
|
|
| 7970 |
+ v = explode(ed.getParam('tab_focus'));
|
|
| 7971 |
+ |
|
| 7972 |
+ if (v.length == 1) {
|
|
| 7973 |
+ v[1] = v[0]; |
|
| 7974 |
+ v[0] = ':prev'; |
|
| 7975 |
+ } |
|
| 7976 |
+ |
|
| 7977 |
+ // Find element to focus |
|
| 7978 |
+ if (e.shiftKey) {
|
|
| 7979 |
+ if (v[0] == ':prev') |
|
| 7980 |
+ el = find(-1); |
|
| 7981 |
+ else |
|
| 7982 |
+ el = DOM.get(v[0]); |
|
| 7983 |
+ } else {
|
|
| 7984 |
+ if (v[1] == ':next') |
|
| 7985 |
+ el = find(1); |
|
| 7986 |
+ else |
|
| 7987 |
+ el = DOM.get(v[1]); |
|
| 7988 |
+ } |
|
| 7989 |
+ |
|
| 7990 |
+ if (el) {
|
|
| 7991 |
+ if (ed = EditorManager.get(el.id || el.name)) |
|
| 7992 |
+ ed.focus(); |
|
| 7993 |
+ else |
|
| 7994 |
+ window.setTimeout(function() {window.focus();el.focus();}, 10);
|
|
| 7995 |
+ |
|
| 7996 |
+ return Event.cancel(e); |
|
| 7997 |
+ } |
|
| 7998 |
+ } |
|
| 7999 |
+ }; |
|
| 8000 |
+ |
|
| 8001 |
+ t.onKeyUp.add(tabCancel); |
|
| 8002 |
+ |
|
| 8003 |
+ if (isGecko) {
|
|
| 8004 |
+ t.onKeyPress.add(tabHandler); |
|
| 8005 |
+ t.onKeyDown.add(tabCancel); |
|
| 8006 |
+ } else |
|
| 8007 |
+ t.onKeyDown.add(tabHandler); |
|
| 8008 |
+ } |
|
| 8009 |
+ |
|
| 8010 |
+ // Add shortcuts |
|
| 8011 |
+ if (s.custom_shortcuts) {
|
|
| 8012 |
+ if (s.custom_undo_redo_keyboard_shortcuts) {
|
|
| 8013 |
+ t.addShortcut('ctrl+z', t.getLang('undo_desc'), 'Undo');
|
|
| 8014 |
+ t.addShortcut('ctrl+y', t.getLang('redo_desc'), 'Redo');
|
|
| 8015 |
+ } |
|
| 8016 |
+ |
|
| 8017 |
+ // Add default shortcuts for gecko |
|
| 8018 |
+ if (isGecko) {
|
|
| 8019 |
+ t.addShortcut('ctrl+b', t.getLang('bold_desc'), 'Bold');
|
|
| 8020 |
+ t.addShortcut('ctrl+i', t.getLang('italic_desc'), 'Italic');
|
|
| 8021 |
+ t.addShortcut('ctrl+u', t.getLang('underline_desc'), 'Underline');
|
|
| 8022 |
+ } |
|
| 8023 |
+ |
|
| 8024 |
+ // BlockFormat shortcuts keys |
|
| 8025 |
+ for (i=1; i<=6; i++) |
|
| 8026 |
+ t.addShortcut('ctrl+' + i, '', ['FormatBlock', false, '<h' + i + '>']);
|
|
| 8027 |
+ |
|
| 8028 |
+ t.addShortcut('ctrl+7', '', ['FormatBlock', false, '<p>']);
|
|
| 8029 |
+ t.addShortcut('ctrl+8', '', ['FormatBlock', false, '<div>']);
|
|
| 8030 |
+ t.addShortcut('ctrl+9', '', ['FormatBlock', false, '<address>']);
|
|
| 8031 |
+ |
|
| 8032 |
+ function find(e) {
|
|
| 8033 |
+ var v = null; |
|
| 8034 |
+ |
|
| 8035 |
+ if (!e.altKey && !e.ctrlKey && !e.metaKey) |
|
| 8036 |
+ return v; |
|
| 8037 |
+ |
|
| 8038 |
+ each(t.shortcuts, function(o) {
|
|
| 8039 |
+ if (o.ctrl != e.ctrlKey && (!tinymce.isMac || o.ctrl == e.metaKey)) |
|
| 8040 |
+ return; |
|
| 8041 |
+ |
|
| 8042 |
+ if (o.alt != e.altKey) |
|
| 8043 |
+ return; |
|
| 8044 |
+ |
|
| 8045 |
+ if (o.shift != e.shiftKey) |
|
| 8046 |
+ return; |
|
| 8047 |
+ |
|
| 8048 |
+ if (e.keyCode == o.keyCode || (e.charCode && e.charCode == o.charCode)) {
|
|
| 8049 |
+ v = o; |
|
| 8050 |
+ return false; |
|
| 8051 |
+ } |
|
| 8052 |
+ }); |
|
| 8053 |
+ |
|
| 8054 |
+ return v; |
|
| 8055 |
+ }; |
|
| 8056 |
+ |
|
| 8057 |
+ t.onKeyUp.add(function(ed, e) {
|
|
| 8058 |
+ var o = find(e); |
|
| 8059 |
+ |
|
| 8060 |
+ if (o) |
|
| 8061 |
+ return Event.cancel(e); |
|
| 8062 |
+ }); |
|
| 8063 |
+ |
|
| 8064 |
+ t.onKeyPress.add(function(ed, e) {
|
|
| 8065 |
+ var o = find(e); |
|
| 8066 |
+ |
|
| 8067 |
+ if (o) |
|
| 8068 |
+ return Event.cancel(e); |
|
| 8069 |
+ }); |
|
| 8070 |
+ |
|
| 8071 |
+ t.onKeyDown.add(function(ed, e) {
|
|
| 8072 |
+ var o = find(e); |
|
| 8073 |
+ |
|
| 8074 |
+ if (o) {
|
|
| 8075 |
+ o.func.call(o.scope); |
|
| 8076 |
+ return Event.cancel(e); |
|
| 8077 |
+ } |
|
| 8078 |
+ }); |
|
| 8079 |
+ } |
|
| 8080 |
+ |
|
| 8081 |
+ if (tinymce.isIE) {
|
|
| 8082 |
+ // Fix so resize will only update the width and height attributes not the styles of an image |
|
| 8083 |
+ // It will also block mceItemNoResize items |
|
| 8084 |
+ Event.add(t.getDoc(), 'controlselect', function(e) {
|
|
| 8085 |
+ var re = t.resizeInfo, cb; |
|
| 8086 |
+ |
|
| 8087 |
+ e = e.target; |
|
| 8088 |
+ |
|
| 8089 |
+ // Don't do this action for non image elements |
|
| 8090 |
+ if (e.nodeName !== 'IMG') |
|
| 8091 |
+ return; |
|
| 8092 |
+ |
|
| 8093 |
+ if (re) |
|
| 8094 |
+ Event.remove(re.node, re.ev, re.cb); |
|
| 8095 |
+ |
|
| 8096 |
+ if (!t.dom.hasClass(e, 'mceItemNoResize')) {
|
|
| 8097 |
+ ev = 'resizeend'; |
|
| 8098 |
+ cb = Event.add(e, ev, function(e) {
|
|
| 8099 |
+ var v; |
|
| 8100 |
+ |
|
| 8101 |
+ e = e.target; |
|
| 8102 |
+ |
|
| 8103 |
+ if (v = t.dom.getStyle(e, 'width')) {
|
|
| 8104 |
+ t.dom.setAttrib(e, 'width', v.replace(/[^0-9%]+/g, '')); |
|
| 8105 |
+ t.dom.setStyle(e, 'width', ''); |
|
| 8106 |
+ } |
|
| 8107 |
+ |
|
| 8108 |
+ if (v = t.dom.getStyle(e, 'height')) {
|
|
| 8109 |
+ t.dom.setAttrib(e, 'height', v.replace(/[^0-9%]+/g, '')); |
|
| 8110 |
+ t.dom.setStyle(e, 'height', ''); |
|
| 8111 |
+ } |
|
| 8112 |
+ }); |
|
| 8113 |
+ } else {
|
|
| 8114 |
+ ev = 'resizestart'; |
|
| 8115 |
+ cb = Event.add(e, 'resizestart', Event.cancel, Event); |
|
| 8116 |
+ } |
|
| 8117 |
+ |
|
| 8118 |
+ re = t.resizeInfo = {
|
|
| 8119 |
+ node : e, |
|
| 8120 |
+ ev : ev, |
|
| 8121 |
+ cb : cb |
|
| 8122 |
+ }; |
|
| 8123 |
+ }); |
|
| 8124 |
+ |
|
| 8125 |
+ t.onKeyDown.add(function(ed, e) {
|
|
| 8126 |
+ switch (e.keyCode) {
|
|
| 8127 |
+ case 8: |
|
| 8128 |
+ // Fix IE control + backspace browser bug |
|
| 8129 |
+ if (t.selection.getRng().item) {
|
|
| 8130 |
+ t.selection.getRng().item(0).removeNode(); |
|
| 8131 |
+ return Event.cancel(e); |
|
| 8132 |
+ } |
|
| 8133 |
+ } |
|
| 8134 |
+ }); |
|
| 8135 |
+ } |
|
| 8136 |
+ |
|
| 8137 |
+ if (tinymce.isOpera) {
|
|
| 8138 |
+ t.onClick.add(function(ed, e) {
|
|
| 8139 |
+ Event.prevent(e); |
|
| 8140 |
+ }); |
|
| 8141 |
+ } |
|
| 8142 |
+ |
|
| 8143 |
+ // Add custom undo/redo handlers |
|
| 8144 |
+ if (s.custom_undo_redo) {
|
|
| 8145 |
+ function addUndo() {
|
|
| 8146 |
+ t.undoManager.typing = 0; |
|
| 8147 |
+ t.undoManager.add(); |
|
| 8148 |
+ }; |
|
| 8149 |
+ |
|
| 8150 |
+ // Add undo level on editor blur |
|
| 8151 |
+ if (tinymce.isIE) {
|
|
| 8152 |
+ Event.add(t.getWin(), 'blur', function(e) {
|
|
| 8153 |
+ var n; |
|
| 8154 |
+ |
|
| 8155 |
+ // Check added for fullscreen bug |
|
| 8156 |
+ if (t.selection) {
|
|
| 8157 |
+ n = t.selection.getNode(); |
|
| 8158 |
+ |
|
| 8159 |
+ // Add undo level is selection was lost to another document |
|
| 8160 |
+ if (!t.removed && n.ownerDocument && n.ownerDocument != t.getDoc()) |
|
| 8161 |
+ addUndo(); |
|
| 8162 |
+ } |
|
| 8163 |
+ }); |
|
| 8164 |
+ } else {
|
|
| 8165 |
+ Event.add(t.getDoc(), 'blur', function() {
|
|
| 8166 |
+ if (t.selection && !t.removed) |
|
| 8167 |
+ addUndo(); |
|
| 8168 |
+ }); |
|
| 8169 |
+ } |
|
| 8170 |
+ |
|
| 8171 |
+ t.onMouseDown.add(addUndo); |
|
| 8172 |
+ |
|
| 8173 |
+ t.onKeyUp.add(function(ed, e) {
|
|
| 8174 |
+ if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45 || e.ctrlKey) {
|
|
| 8175 |
+ t.undoManager.typing = 0; |
|
| 8176 |
+ t.undoManager.add(); |
|
| 8177 |
+ } |
|
| 8178 |
+ }); |
|
| 8179 |
+ |
|
| 8180 |
+ t.onKeyDown.add(function(ed, e) {
|
|
| 8181 |
+ // Is caracter positon keys |
|
| 8182 |
+ if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45) {
|
|
| 8183 |
+ if (t.undoManager.typing) {
|
|
| 8184 |
+ t.undoManager.add(); |
|
| 8185 |
+ t.undoManager.typing = 0; |
|
| 8186 |
+ } |
|
| 8187 |
+ |
|
| 8188 |
+ return; |
|
| 8189 |
+ } |
|
| 8190 |
+ |
|
| 8191 |
+ if (!t.undoManager.typing) {
|
|
| 8192 |
+ t.undoManager.add(); |
|
| 8193 |
+ t.undoManager.typing = 1; |
|
| 8194 |
+ } |
|
| 8195 |
+ }); |
|
| 8196 |
+ } |
|
| 8197 |
+ }, |
|
| 8198 |
+ |
|
| 8199 |
+ _convertInlineElements : function() {
|
|
| 8200 |
+ var t = this, s = t.settings, dom = t.dom, v, e, na, st, sp; |
|
| 8201 |
+ |
|
| 8202 |
+ function convert(ed, o) {
|
|
| 8203 |
+ if (!s.inline_styles) |
|
| 8204 |
+ return; |
|
| 8205 |
+ |
|
| 8206 |
+ if (o.get) {
|
|
| 8207 |
+ each(t.dom.select('table,u,strike', o.node), function(n) {
|
|
| 8208 |
+ switch (n.nodeName) {
|
|
| 8209 |
+ case 'TABLE': |
|
| 8210 |
+ if (v = dom.getAttrib(n, 'height')) {
|
|
| 8211 |
+ dom.setStyle(n, 'height', v); |
|
| 8212 |
+ dom.setAttrib(n, 'height', ''); |
|
| 8213 |
+ } |
|
| 8214 |
+ break; |
|
| 8215 |
+ |
|
| 8216 |
+ case 'U': |
|
| 8217 |
+ case 'STRIKE': |
|
| 8218 |
+ //sp = dom.create('span', {style : dom.getAttrib(n, 'style')});
|
|
| 8219 |
+ n.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through'; |
|
| 8220 |
+ dom.setAttrib(n, 'mce_style', ''); |
|
| 8221 |
+ dom.setAttrib(n, 'mce_name', 'span'); |
|
| 8222 |
+ break; |
|
| 8223 |
+ } |
|
| 8224 |
+ }); |
|
| 8225 |
+ } else if (o.set) {
|
|
| 8226 |
+ each(t.dom.select('table,span', o.node).reverse(), function(n) {
|
|
| 8227 |
+ if (n.nodeName == 'TABLE') {
|
|
| 8228 |
+ if (v = dom.getStyle(n, 'height')) |
|
| 8229 |
+ dom.setAttrib(n, 'height', v.replace(/[^0-9%]+/g, '')); |
|
| 8230 |
+ } else {
|
|
| 8231 |
+ // Convert spans to elements |
|
| 8232 |
+ if (n.style.textDecoration == 'underline') |
|
| 8233 |
+ na = 'u'; |
|
| 8234 |
+ else if (n.style.textDecoration == 'line-through') |
|
| 8235 |
+ na = 'strike'; |
|
| 8236 |
+ else |
|
| 8237 |
+ na = ''; |
|
| 8238 |
+ |
|
| 8239 |
+ if (na) {
|
|
| 8240 |
+ n.style.textDecoration = ''; |
|
| 8241 |
+ dom.setAttrib(n, 'mce_style', ''); |
|
| 8242 |
+ |
|
| 8243 |
+ e = dom.create(na, {
|
|
| 8244 |
+ style : dom.getAttrib(n, 'style') |
|
| 8245 |
+ }); |
|
| 8246 |
+ |
|
| 8247 |
+ dom.replace(e, n, 1); |
|
| 8248 |
+ } |
|
| 8249 |
+ } |
|
| 8250 |
+ }); |
|
| 8251 |
+ } |
|
| 8252 |
+ }; |
|
| 8253 |
+ |
|
| 8254 |
+ t.onPreProcess.add(convert); |
|
| 8255 |
+ |
|
| 8256 |
+ if (!s.cleanup_on_startup) {
|
|
| 8257 |
+ t.onSetContent.add(function(ed, o) {
|
|
| 8258 |
+ if (o.initial) |
|
| 8259 |
+ convert(t, {node : t.getBody(), set : 1});
|
|
| 8260 |
+ }); |
|
| 8261 |
+ } |
|
| 8262 |
+ }, |
|
| 8263 |
+ |
|
| 8264 |
+ _convertFonts : function() {
|
|
| 8265 |
+ var t = this, s = t.settings, dom = t.dom, fz, fzn, sl, cl; |
|
| 8266 |
+ |
|
| 8267 |
+ // No need |
|
| 8268 |
+ if (!s.inline_styles) |
|
| 8269 |
+ return; |
|
| 8270 |
+ |
|
| 8271 |
+ // Font pt values and font size names |
|
| 8272 |
+ fz = [8, 10, 12, 14, 18, 24, 36]; |
|
| 8273 |
+ fzn = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large']; |
|
| 8274 |
+ |
|
| 8275 |
+ if (sl = s.font_size_style_values) |
|
| 8276 |
+ sl = explode(sl); |
|
| 8277 |
+ |
|
| 8278 |
+ if (cl = s.font_size_classes) |
|
| 8279 |
+ cl = explode(cl); |
|
| 8280 |
+ |
|
| 8281 |
+ function convertToFonts(no) {
|
|
| 8282 |
+ var n, f, nl, x, i, v, st; |
|
| 8283 |
+ |
|
| 8284 |
+ // Convert spans to fonts on non WebKit browsers |
|
| 8285 |
+ if (tinymce.isWebKit || !s.inline_styles) |
|
| 8286 |
+ return; |
|
| 8287 |
+ |
|
| 8288 |
+ nl = t.dom.select('span', no);
|
|
| 8289 |
+ for (x = nl.length - 1; x >= 0; x--) {
|
|
| 8290 |
+ n = nl[x]; |
|
| 8291 |
+ |
|
| 8292 |
+ f = dom.create('font', {
|
|
| 8293 |
+ color : dom.toHex(dom.getStyle(n, 'color')), |
|
| 8294 |
+ face : dom.getStyle(n, 'fontFamily'), |
|
| 8295 |
+ style : dom.getAttrib(n, 'style'), |
|
| 8296 |
+ 'class' : dom.getAttrib(n, 'class') |
|
| 8297 |
+ }); |
|
| 8298 |
+ |
|
| 8299 |
+ // Clear color and font family |
|
| 8300 |
+ st = f.style; |
|
| 8301 |
+ if (st.color || st.fontFamily) {
|
|
| 8302 |
+ st.color = st.fontFamily = ''; |
|
| 8303 |
+ dom.setAttrib(f, 'mce_style', ''); // Remove cached style data |
|
| 8304 |
+ } |
|
| 8305 |
+ |
|
| 8306 |
+ if (sl) {
|
|
| 8307 |
+ i = inArray(sl, dom.getStyle(n, 'fontSize')); |
|
| 8308 |
+ |
|
| 8309 |
+ if (i != -1) {
|
|
| 8310 |
+ dom.setAttrib(f, 'size', '' + (i + 1 || 1)); |
|
| 8311 |
+ //f.style.fontSize = ''; |
|
| 8312 |
+ } |
|
| 8313 |
+ } else if (cl) {
|
|
| 8314 |
+ i = inArray(cl, dom.getAttrib(n, 'class')); |
|
| 8315 |
+ v = dom.getStyle(n, 'fontSize'); |
|
| 8316 |
+ |
|
| 8317 |
+ if (i == -1 && v.indexOf('pt') > 0)
|
|
| 8318 |
+ i = inArray(fz, parseInt(v)); |
|
| 8319 |
+ |
|
| 8320 |
+ if (i == -1) |
|
| 8321 |
+ i = inArray(fzn, v); |
|
| 8322 |
+ |
|
| 8323 |
+ if (i != -1) {
|
|
| 8324 |
+ dom.setAttrib(f, 'size', '' + (i + 1 || 1)); |
|
| 8325 |
+ f.style.fontSize = ''; |
|
| 8326 |
+ } |
|
| 8327 |
+ } |
|
| 8328 |
+ |
|
| 8329 |
+ if (f.color || f.face || f.size) {
|
|
| 8330 |
+ f.style.fontFamily = ''; |
|
| 8331 |
+ dom.setAttrib(f, 'mce_style', ''); |
|
| 8332 |
+ dom.replace(f, n, 1); |
|
| 8333 |
+ } |
|
| 8334 |
+ |
|
| 8335 |
+ f = n = null; |
|
| 8336 |
+ } |
|
| 8337 |
+ }; |
|
| 8338 |
+ |
|
| 8339 |
+ // Run on setup |
|
| 8340 |
+ t.onSetContent.add(function(ed, o) {
|
|
| 8341 |
+ convertToFonts(ed.getBody()); |
|
| 8342 |
+ }); |
|
| 8343 |
+ |
|
| 8344 |
+ // Run on cleanup |
|
| 8345 |
+ t.onPreProcess.add(function(ed, o) {
|
|
| 8346 |
+ var n, sp, nl, x; |
|
| 8347 |
+ |
|
| 8348 |
+ // Keep unit tests happy |
|
| 8349 |
+ if (!s.inline_styles) |
|
| 8350 |
+ return; |
|
| 8351 |
+ |
|
| 8352 |
+ if (o.get) {
|
|
| 8353 |
+ nl = t.dom.select('font', o.node);
|
|
| 8354 |
+ for (x = nl.length - 1; x >= 0; x--) {
|
|
| 8355 |
+ n = nl[x]; |
|
| 8356 |
+ |
|
| 8357 |
+ sp = dom.create('span', {
|
|
| 8358 |
+ style : dom.getAttrib(n, 'style'), |
|
| 8359 |
+ 'class' : dom.getAttrib(n, 'class') |
|
| 8360 |
+ }); |
|
| 8361 |
+ |
|
| 8362 |
+ dom.setStyles(sp, {
|
|
| 8363 |
+ fontFamily : dom.getAttrib(n, 'face'), |
|
| 8364 |
+ color : dom.getAttrib(n, 'color'), |
|
| 8365 |
+ backgroundColor : n.style.backgroundColor |
|
| 8366 |
+ }); |
|
| 8367 |
+ |
|
| 8368 |
+ if (n.size) {
|
|
| 8369 |
+ if (sl) |
|
| 8370 |
+ dom.setStyle(sp, 'fontSize', sl[parseInt(n.size) - 1]); |
|
| 8371 |
+ else |
|
| 8372 |
+ dom.setAttrib(sp, 'class', cl[parseInt(n.size) - 1]); |
|
| 8373 |
+ } |
|
| 8374 |
+ |
|
| 8375 |
+ dom.setAttrib(sp, 'mce_style', ''); |
|
| 8376 |
+ dom.replace(sp, n, 1); |
|
| 8377 |
+ } |
|
| 8378 |
+ } |
|
| 8379 |
+ }); |
|
| 8380 |
+ }, |
|
| 8381 |
+ |
|
| 8382 |
+ _isHidden : function() {
|
|
| 8383 |
+ var s; |
|
| 8384 |
+ |
|
| 8385 |
+ if (!isGecko) |
|
| 8386 |
+ return 0; |
|
| 8387 |
+ |
|
| 8388 |
+ // Weird, wheres that cursor selection? |
|
| 8389 |
+ s = this.selection.getSel(); |
|
| 8390 |
+ return (!s || !s.rangeCount || s.rangeCount == 0); |
|
| 8391 |
+ }, |
|
| 8392 |
+ |
|
| 8393 |
+ // Fix for bug #1867292 |
|
| 8394 |
+ _fixNesting : function(s) {
|
|
| 8395 |
+ var d = [], i; |
|
| 8396 |
+ |
|
| 8397 |
+ s = s.replace(/<(\/)?([^\s>]+)[^>]*?>/g, function(a, b, c) {
|
|
| 8398 |
+ var e; |
|
| 8399 |
+ |
|
| 8400 |
+ // Handle end element |
|
| 8401 |
+ if (b === '/') {
|
|
| 8402 |
+ if (!d.length) |
|
| 8403 |
+ return ''; |
|
| 8404 |
+ |
|
| 8405 |
+ if (c !== d[d.length - 1].tag) {
|
|
| 8406 |
+ for (i=d.length - 1; i>=0; i--) {
|
|
| 8407 |
+ if (d[i].tag === c) {
|
|
| 8408 |
+ d[i].close = 1; |
|
| 8409 |
+ break; |
|
| 8410 |
+ } |
|
| 8411 |
+ } |
|
| 8412 |
+ |
|
| 8413 |
+ return ''; |
|
| 8414 |
+ } else {
|
|
| 8415 |
+ d.pop(); |
|
| 8416 |
+ |
|
| 8417 |
+ if (d.length && d[d.length - 1].close) {
|
|
| 8418 |
+ a = a + '</' + d[d.length - 1].tag + '>'; |
|
| 8419 |
+ d.pop(); |
|
| 8420 |
+ } |
|
| 8421 |
+ } |
|
| 8422 |
+ } else {
|
|
| 8423 |
+ // Ignore these |
|
| 8424 |
+ if (/^(br|hr|input|meta|img|link|param)$/i.test(c)) |
|
| 8425 |
+ return a; |
|
| 8426 |
+ |
|
| 8427 |
+ // Ignore closed ones |
|
| 8428 |
+ if (/\/>$/.test(a)) |
|
| 8429 |
+ return a; |
|
| 8430 |
+ |
|
| 8431 |
+ d.push({tag : c}); // Push start element
|
|
| 8432 |
+ } |
|
| 8433 |
+ |
|
| 8434 |
+ return a; |
|
| 8435 |
+ }); |
|
| 8436 |
+ |
|
| 8437 |
+ // End all open tags |
|
| 8438 |
+ for (i=d.length - 1; i>=0; i--) |
|
| 8439 |
+ s += '</' + d[i].tag + '>'; |
|
| 8440 |
+ |
|
| 8441 |
+ return s; |
|
| 8442 |
+ } |
|
| 8443 |
+ |
|
| 8444 |
+ }); |
|
| 8445 |
+})(); |
|
| 8446 |
+ |
|
| 8447 |
+/* file:jscripts/tiny_mce/classes/EditorCommands.js */ |
|
| 8448 |
+ |
|
| 8449 |
+(function() {
|
|
| 8450 |
+ var each = tinymce.each, isIE = tinymce.isIE, isGecko = tinymce.isGecko, isOpera = tinymce.isOpera, isWebKit = tinymce.isWebKit; |
|
| 8451 |
+ |
|
| 8452 |
+ tinymce.create('tinymce.EditorCommands', {
|
|
| 8453 |
+ EditorCommands : function(ed) {
|
|
| 8454 |
+ this.editor = ed; |
|
| 8455 |
+ }, |
|
| 8456 |
+ |
|
| 8457 |
+ execCommand : function(cmd, ui, val) {
|
|
| 8458 |
+ var t = this, ed = t.editor, f; |
|
| 8459 |
+ |
|
| 8460 |
+ switch (cmd) {
|
|
| 8461 |
+ case 'Cut': |
|
| 8462 |
+ case 'Copy': |
|
| 8463 |
+ case 'Paste': |
|
| 8464 |
+ try {
|
|
| 8465 |
+ ed.getDoc().execCommand(cmd, ui, val); |
|
| 8466 |
+ } catch (ex) {
|
|
| 8467 |
+ if (isGecko) {
|
|
| 8468 |
+ ed.windowManager.confirm(ed.getLang('clipboard_msg'), function(s) {
|
|
| 8469 |
+ if (s) |
|
| 8470 |
+ window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
|
|
| 8471 |
+ }); |
|
| 8472 |
+ } else |
|
| 8473 |
+ ed.windowManager.alert(ed.getLang('clipboard_no_support'));
|
|
| 8474 |
+ } |
|
| 8475 |
+ |
|
| 8476 |
+ return true; |
|
| 8477 |
+ |
|
| 8478 |
+ // Ignore these |
|
| 8479 |
+ case 'mceResetDesignMode': |
|
| 8480 |
+ case 'mceBeginUndoLevel': |
|
| 8481 |
+ return true; |
|
| 8482 |
+ |
|
| 8483 |
+ // Ignore these |
|
| 8484 |
+ case 'unlink': |
|
| 8485 |
+ t.UnLink(); |
|
| 8486 |
+ return true; |
|
| 8487 |
+ |
|
| 8488 |
+ // Bundle these together |
|
| 8489 |
+ case 'JustifyLeft': |
|
| 8490 |
+ case 'JustifyCenter': |
|
| 8491 |
+ case 'JustifyRight': |
|
| 8492 |
+ case 'JustifyFull': |
|
| 8493 |
+ t.mceJustify(cmd, cmd.substring(7).toLowerCase()); |
|
| 8494 |
+ return true; |
|
| 8495 |
+ |
|
| 8496 |
+ case 'mceEndUndoLevel': |
|
| 8497 |
+ case 'mceAddUndoLevel': |
|
| 8498 |
+ ed.undoManager.add(); |
|
| 8499 |
+ return true; |
|
| 8500 |
+ |
|
| 8501 |
+ default: |
|
| 8502 |
+ f = this[cmd]; |
|
| 8503 |
+ |
|
| 8504 |
+ if (f) {
|
|
| 8505 |
+ f.call(this, ui, val); |
|
| 8506 |
+ return true; |
|
| 8507 |
+ } |
|
| 8508 |
+ } |
|
| 8509 |
+ |
|
| 8510 |
+ return false; |
|
| 8511 |
+ }, |
|
| 8512 |
+ |
|
| 8513 |
+ Indent : function() {
|
|
| 8514 |
+ var ed = this.editor, d = ed.dom, s = ed.selection, e, iv, iu; |
|
| 8515 |
+ |
|
| 8516 |
+ // Setup indent level |
|
| 8517 |
+ iv = ed.settings.indentation; |
|
| 8518 |
+ iu = /[a-z%]+$/i.exec(iv); |
|
| 8519 |
+ iv = parseInt(iv); |
|
| 8520 |
+ |
|
| 8521 |
+ if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
|
|
| 8522 |
+ each(this._getSelectedBlocks(), function(e) {
|
|
| 8523 |
+ d.setStyle(e, 'paddingLeft', (parseInt(e.style.paddingLeft || 0) + iv) + iu); |
|
| 8524 |
+ }); |
|
| 8525 |
+ |
|
| 8526 |
+ return; |
|
| 8527 |
+ } |
|
| 8528 |
+ |
|
| 8529 |
+ ed.getDoc().execCommand('Indent', false, null);
|
|
| 8530 |
+ |
|
| 8531 |
+ if (isIE) {
|
|
| 8532 |
+ d.getParent(s.getNode(), function(n) {
|
|
| 8533 |
+ if (n.nodeName == 'BLOCKQUOTE') {
|
|
| 8534 |
+ n.dir = n.style.cssText = ''; |
|
| 8535 |
+ } |
|
| 8536 |
+ }); |
|
| 8537 |
+ } |
|
| 8538 |
+ }, |
|
| 8539 |
+ |
|
| 8540 |
+ Outdent : function() {
|
|
| 8541 |
+ var ed = this.editor, d = ed.dom, s = ed.selection, e, v, iv, iu; |
|
| 8542 |
+ |
|
| 8543 |
+ // Setup indent level |
|
| 8544 |
+ iv = ed.settings.indentation; |
|
| 8545 |
+ iu = /[a-z%]+$/i.exec(iv); |
|
| 8546 |
+ iv = parseInt(iv); |
|
| 8547 |
+ |
|
| 8548 |
+ if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
|
|
| 8549 |
+ each(this._getSelectedBlocks(), function(e) {
|
|
| 8550 |
+ v = Math.max(0, parseInt(e.style.paddingLeft || 0) - iv); |
|
| 8551 |
+ d.setStyle(e, 'paddingLeft', v ? v + iu : ''); |
|
| 8552 |
+ }); |
|
| 8553 |
+ |
|
| 8554 |
+ return; |
|
| 8555 |
+ } |
|
| 8556 |
+ |
|
| 8557 |
+ ed.getDoc().execCommand('Outdent', false, null);
|
|
| 8558 |
+ }, |
|
| 8559 |
+ |
|
| 8560 |
+ mceSetAttribute : function(u, v) {
|
|
| 8561 |
+ var ed = this.editor, d = ed.dom, e; |
|
| 8562 |
+ |
|
| 8563 |
+ if (e = d.getParent(ed.selection.getNode(), d.isBlock)) |
|
| 8564 |
+ d.setAttrib(e, v.name, v.value); |
|
| 8565 |
+ }, |
|
| 8566 |
+ |
|
| 8567 |
+ mceSetContent : function(u, v) {
|
|
| 8568 |
+ this.editor.setContent(v); |
|
| 8569 |
+ }, |
|
| 8570 |
+ |
|
| 8571 |
+ mceToggleVisualAid : function() {
|
|
| 8572 |
+ var ed = this.editor; |
|
| 8573 |
+ |
|
| 8574 |
+ ed.hasVisual = !ed.hasVisual; |
|
| 8575 |
+ ed.addVisual(); |
|
| 8576 |
+ }, |
|
| 8577 |
+ |
|
| 8578 |
+ mceReplaceContent : function(u, v) {
|
|
| 8579 |
+ var s = this.editor.selection; |
|
| 8580 |
+ |
|
| 8581 |
+ s.setContent(v.replace(/\{\$selection\}/g, s.getContent({format : 'text'})));
|
|
| 8582 |
+ }, |
|
| 8583 |
+ |
|
| 8584 |
+ mceInsertLink : function(u, v) {
|
|
| 8585 |
+ var ed = this.editor, s = ed.selection, e = ed.dom.getParent(s.getNode(), 'A'); |
|
| 8586 |
+ |
|
| 8587 |
+ if (tinymce.is(v, 'string')) |
|
| 8588 |
+ v = {href : v};
|
|
| 8589 |
+ |
|
| 8590 |
+ function set(e) {
|
|
| 8591 |
+ each(v, function(v, k) {
|
|
| 8592 |
+ ed.dom.setAttrib(e, k, v); |
|
| 8593 |
+ }); |
|
| 8594 |
+ }; |
|
| 8595 |
+ |
|
| 8596 |
+ if (!e) {
|
|
| 8597 |
+ ed.execCommand('CreateLink', false, 'javascript:mctmp(0);');
|
|
| 8598 |
+ each(ed.dom.select('a'), function(e) {
|
|
| 8599 |
+ if (e.href == 'javascript:mctmp(0);') |
|
| 8600 |
+ set(e); |
|
| 8601 |
+ }); |
|
| 8602 |
+ } else {
|
|
| 8603 |
+ if (v.href) |
|
| 8604 |
+ set(e); |
|
| 8605 |
+ else |
|
| 8606 |
+ ed.dom.remove(e, 1); |
|
| 8607 |
+ } |
|
| 8608 |
+ }, |
|
| 8609 |
+ |
|
| 8610 |
+ UnLink : function() {
|
|
| 8611 |
+ var ed = this.editor, s = ed.selection; |
|
| 8612 |
+ |
|
| 8613 |
+ if (s.isCollapsed()) |
|
| 8614 |
+ s.select(s.getNode()); |
|
| 8615 |
+ |
|
| 8616 |
+ ed.getDoc().execCommand('unlink', false, null);
|
|
| 8617 |
+ s.collapse(0); |
|
| 8618 |
+ }, |
|
| 8619 |
+ |
|
| 8620 |
+ FontName : function(u, v) {
|
|
| 8621 |
+ var t = this, ed = t.editor, s = ed.selection, e; |
|
| 8622 |
+ |
|
| 8623 |
+ if (!v) {
|
|
| 8624 |
+ if (s.isCollapsed()) |
|
| 8625 |
+ s.select(s.getNode()); |
|
| 8626 |
+ |
|
| 8627 |
+ t.RemoveFormat(); |
|
| 8628 |
+ } else |
|
| 8629 |
+ ed.getDoc().execCommand('FontName', false, v);
|
|
| 8630 |
+ }, |
|
| 8631 |
+ |
|
| 8632 |
+ FontSize : function(u, v) {
|
|
| 8633 |
+ var ed = this.editor, s = ed.settings, fz = tinymce.explode(s.font_size_style_values), fzc = tinymce.explode(s.font_size_classes), h, bm; |
|
| 8634 |
+ |
|
| 8635 |
+ // Remove style sizes |
|
| 8636 |
+ each(ed.dom.select('font'), function(e) {
|
|
| 8637 |
+ e.style.fontSize = ''; |
|
| 8638 |
+ }); |
|
| 8639 |
+ |
|
| 8640 |
+ // Let the browser add new size it will remove unneded ones in some browsers |
|
| 8641 |
+ ed.getDoc().execCommand('FontSize', false, v);
|
|
| 8642 |
+ |
|
| 8643 |
+ // Add style values |
|
| 8644 |
+ if (s.inline_styles) {
|
|
| 8645 |
+ each(ed.dom.select('font'), function(e) {
|
|
| 8646 |
+ // Try remove redundant font elements |
|
| 8647 |
+ if (!e.size || e.parentNode.nodeName == 'FONT' && e.size == e.parentNode.size) {
|
|
| 8648 |
+ if (!bm) |
|
| 8649 |
+ bm = ed.selection.getBookmark(); |
|
| 8650 |
+ |
|
| 8651 |
+ ed.dom.remove(e, 1); |
|
| 8652 |
+ return; |
|
| 8653 |
+ } |
|
| 8654 |
+ |
|
| 8655 |
+ // Setup font size based on font size value |
|
| 8656 |
+ if (v = e.size) {
|
|
| 8657 |
+ if (fzc && fzc.length > 0) |
|
| 8658 |
+ ed.dom.setAttrib(e, 'class', fzc[parseInt(v) - 1]); |
|
| 8659 |
+ else |
|
| 8660 |
+ ed.dom.setStyle(e, 'fontSize', fz[parseInt(v) - 1]); |
|
| 8661 |
+ } |
|
| 8662 |
+ }); |
|
| 8663 |
+ } |
|
| 8664 |
+ |
|
| 8665 |
+ ed.selection.moveToBookmark(bm); |
|
| 8666 |
+ }, |
|
| 8667 |
+ |
|
| 8668 |
+ queryCommandValue : function(c) {
|
|
| 8669 |
+ var f = this['queryValue' + c]; |
|
| 8670 |
+ |
|
| 8671 |
+ if (f) |
|
| 8672 |
+ return f.call(this, c); |
|
| 8673 |
+ |
|
| 8674 |
+ return false; |
|
| 8675 |
+ }, |
|
| 8676 |
+ |
|
| 8677 |
+ queryCommandState : function(cmd) {
|
|
| 8678 |
+ var f; |
|
| 8679 |
+ |
|
| 8680 |
+ switch (cmd) {
|
|
| 8681 |
+ // Bundle these together |
|
| 8682 |
+ case 'JustifyLeft': |
|
| 8683 |
+ case 'JustifyCenter': |
|
| 8684 |
+ case 'JustifyRight': |
|
| 8685 |
+ case 'JustifyFull': |
|
| 8686 |
+ return this.queryStateJustify(cmd, cmd.substring(7).toLowerCase()); |
|
| 8687 |
+ |
|
| 8688 |
+ default: |
|
| 8689 |
+ if (f = this['queryState' + cmd]) |
|
| 8690 |
+ return f.call(this, cmd); |
|
| 8691 |
+ } |
|
| 8692 |
+ |
|
| 8693 |
+ return -1; |
|
| 8694 |
+ }, |
|
| 8695 |
+ |
|
| 8696 |
+ _queryState : function(c) {
|
|
| 8697 |
+ try {
|
|
| 8698 |
+ return this.editor.getDoc().queryCommandState(c); |
|
| 8699 |
+ } catch (ex) {
|
|
| 8700 |
+ // Ignore exception |
|
| 8701 |
+ } |
|
| 8702 |
+ }, |
|
| 8703 |
+ |
|
| 8704 |
+ _queryVal : function(c) {
|
|
| 8705 |
+ try {
|
|
| 8706 |
+ return this.editor.getDoc().queryCommandValue(c); |
|
| 8707 |
+ } catch (ex) {
|
|
| 8708 |
+ // Ignore exception |
|
| 8709 |
+ } |
|
| 8710 |
+ }, |
|
| 8711 |
+ |
|
| 8712 |
+ queryValueFontSize : function() {
|
|
| 8713 |
+ var ed = this.editor, v = 0, p; |
|
| 8714 |
+ |
|
| 8715 |
+ if (isOpera || isWebKit) {
|
|
| 8716 |
+ if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT')) |
|
| 8717 |
+ v = p.size; |
|
| 8718 |
+ |
|
| 8719 |
+ return v; |
|
| 8720 |
+ } |
|
| 8721 |
+ |
|
| 8722 |
+ return this._queryVal('FontSize');
|
|
| 8723 |
+ }, |
|
| 8724 |
+ |
|
| 8725 |
+ queryValueFontName : function() {
|
|
| 8726 |
+ var ed = this.editor, v = 0, p; |
|
| 8727 |
+ |
|
| 8728 |
+ if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT')) |
|
| 8729 |
+ v = p.face; |
|
| 8730 |
+ |
|
| 8731 |
+ if (!v) |
|
| 8732 |
+ v = this._queryVal('FontName');
|
|
| 8733 |
+ |
|
| 8734 |
+ return v; |
|
| 8735 |
+ }, |
|
| 8736 |
+ |
|
| 8737 |
+ mceJustify : function(c, v) {
|
|
| 8738 |
+ var ed = this.editor, se = ed.selection, n = se.getNode(), nn = n.nodeName, bl, nb, dom = ed.dom, rm; |
|
| 8739 |
+ |
|
| 8740 |
+ if (ed.settings.inline_styles && this.queryStateJustify(c, v)) |
|
| 8741 |
+ rm = 1; |
|
| 8742 |
+ |
|
| 8743 |
+ bl = dom.getParent(n, ed.dom.isBlock); |
|
| 8744 |
+ |
|
| 8745 |
+ if (nn == 'IMG') {
|
|
| 8746 |
+ if (v == 'full') |
|
| 8747 |
+ return; |
|
| 8748 |
+ |
|
| 8749 |
+ if (rm) {
|
|
| 8750 |
+ if (v == 'center') |
|
| 8751 |
+ dom.setStyle(n.parentNode, 'textAlign', ''); |
|
| 8752 |
+ |
|
| 8753 |
+ dom.setStyle(n, 'float', ''); |
|
| 8754 |
+ this.mceRepaint(); |
|
| 8755 |
+ return; |
|
| 8756 |
+ } |
|
| 8757 |
+ |
|
| 8758 |
+ if (v == 'center') {
|
|
| 8759 |
+ // Do not change table elements |
|
| 8760 |
+ if (/^(TD|TH)$/.test(bl.nodeName)) |
|
| 8761 |
+ bl = 0; |
|
| 8762 |
+ |
|
| 8763 |
+ if (!bl || bl.childNodes.length > 1) {
|
|
| 8764 |
+ nb = dom.create('p');
|
|
| 8765 |
+ nb.appendChild(n.cloneNode(false)); |
|
| 8766 |
+ |
|
| 8767 |
+ if (bl) |
|
| 8768 |
+ dom.insertAfter(nb, bl); |
|
| 8769 |
+ else |
|
| 8770 |
+ dom.insertAfter(nb, n); |
|
| 8771 |
+ |
|
| 8772 |
+ dom.remove(n); |
|
| 8773 |
+ n = nb.firstChild; |
|
| 8774 |
+ bl = nb; |
|
| 8775 |
+ } |
|
| 8776 |
+ |
|
| 8777 |
+ dom.setStyle(bl, 'textAlign', v); |
|
| 8778 |
+ dom.setStyle(n, 'float', ''); |
|
| 8779 |
+ } else {
|
|
| 8780 |
+ dom.setStyle(n, 'float', v); |
|
| 8781 |
+ dom.setStyle(n.parentNode, 'textAlign', ''); |
|
| 8782 |
+ } |
|
| 8783 |
+ |
|
| 8784 |
+ this.mceRepaint(); |
|
| 8785 |
+ return; |
|
| 8786 |
+ } |
|
| 8787 |
+ |
|
| 8788 |
+ // Handle the alignment outselfs, less quirks in all browsers |
|
| 8789 |
+ if (ed.settings.inline_styles && ed.settings.forced_root_block) {
|
|
| 8790 |
+ if (rm) |
|
| 8791 |
+ v = ''; |
|
| 8792 |
+ |
|
| 8793 |
+ each(this._getSelectedBlocks(dom.getParent(se.getStart(), dom.isBlock), dom.getParent(se.getEnd(), dom.isBlock)), function(e) {
|
|
| 8794 |
+ dom.setAttrib(e, 'align', ''); |
|
| 8795 |
+ dom.setStyle(e, 'textAlign', v == 'full' ? 'justify' : v); |
|
| 8796 |
+ }); |
|
| 8797 |
+ |
|
| 8798 |
+ return; |
|
| 8799 |
+ } else if (!rm) |
|
| 8800 |
+ ed.getDoc().execCommand(c, false, null); |
|
| 8801 |
+ |
|
| 8802 |
+ if (ed.settings.inline_styles) {
|
|
| 8803 |
+ if (rm) {
|
|
| 8804 |
+ dom.getParent(ed.selection.getNode(), function(n) {
|
|
| 8805 |
+ if (n.style && n.style.textAlign) |
|
| 8806 |
+ dom.setStyle(n, 'textAlign', ''); |
|
| 8807 |
+ }); |
|
| 8808 |
+ |
|
| 8809 |
+ return; |
|
| 8810 |
+ } |
|
| 8811 |
+ |
|
| 8812 |
+ each(dom.select('*'), function(n) {
|
|
| 8813 |
+ var v = n.align; |
|
| 8814 |
+ |
|
| 8815 |
+ if (v) {
|
|
| 8816 |
+ if (v == 'full') |
|
| 8817 |
+ v = 'justify'; |
|
| 8818 |
+ |
|
| 8819 |
+ dom.setStyle(n, 'textAlign', v); |
|
| 8820 |
+ dom.setAttrib(n, 'align', ''); |
|
| 8821 |
+ } |
|
| 8822 |
+ }); |
|
| 8823 |
+ } |
|
| 8824 |
+ }, |
|
| 8825 |
+ |
|
| 8826 |
+ mceSetCSSClass : function(u, v) {
|
|
| 8827 |
+ this.mceSetStyleInfo(0, {command : 'setattrib', name : 'class', value : v});
|
|
| 8828 |
+ }, |
|
| 8829 |
+ |
|
| 8830 |
+ getSelectedElement : function() {
|
|
| 8831 |
+ var t = this, ed = t.editor, dom = ed.dom, se = ed.selection, r = se.getRng(), r1, r2, sc, ec, so, eo, e, sp, ep, re; |
|
| 8832 |
+ |
|
| 8833 |
+ if (se.isCollapsed() || r.item) |
|
| 8834 |
+ return se.getNode(); |
|
| 8835 |
+ |
|
| 8836 |
+ // Setup regexp |
|
| 8837 |
+ re = ed.settings.merge_styles_invalid_parents; |
|
| 8838 |
+ if (tinymce.is(re, 'string')) |
|
| 8839 |
+ re = new RegExp(re, 'i'); |
|
| 8840 |
+ |
|
| 8841 |
+ if (isIE) {
|
|
| 8842 |
+ r1 = r.duplicate(); |
|
| 8843 |
+ r1.collapse(true); |
|
| 8844 |
+ sc = r1.parentElement(); |
|
| 8845 |
+ |
|
| 8846 |
+ r2 = r.duplicate(); |
|
| 8847 |
+ r2.collapse(false); |
|
| 8848 |
+ ec = r2.parentElement(); |
|
| 8849 |
+ |
|
| 8850 |
+ if (sc != ec) {
|
|
| 8851 |
+ r1.move('character', 1);
|
|
| 8852 |
+ sc = r1.parentElement(); |
|
| 8853 |
+ } |
|
| 8854 |
+ |
|
| 8855 |
+ if (sc == ec) {
|
|
| 8856 |
+ r1 = r.duplicate(); |
|
| 8857 |
+ r1.moveToElementText(sc); |
|
| 8858 |
+ |
|
| 8859 |
+ if (r1.compareEndPoints('StartToStart', r) == 0 && r1.compareEndPoints('EndToEnd', r) == 0)
|
|
| 8860 |
+ return re && re.test(sc.nodeName) ? null : sc; |
|
| 8861 |
+ } |
|
| 8862 |
+ } else {
|
|
| 8863 |
+ function getParent(n) {
|
|
| 8864 |
+ return dom.getParent(n, function(n) {return n.nodeType == 1;});
|
|
| 8865 |
+ }; |
|
| 8866 |
+ |
|
| 8867 |
+ sc = r.startContainer; |
|
| 8868 |
+ ec = r.endContainer; |
|
| 8869 |
+ so = r.startOffset; |
|
| 8870 |
+ eo = r.endOffset; |
|
| 8871 |
+ |
|
| 8872 |
+ if (!r.collapsed) {
|
|
| 8873 |
+ if (sc == ec) {
|
|
| 8874 |
+ if (so - eo < 2) {
|
|
| 8875 |
+ if (sc.hasChildNodes()) {
|
|
| 8876 |
+ sp = sc.childNodes[so]; |
|
| 8877 |
+ return re && re.test(sp.nodeName) ? null : sp; |
|
| 8878 |
+ } |
|
| 8879 |
+ } |
|
| 8880 |
+ } |
|
| 8881 |
+ } |
|
| 8882 |
+ |
|
| 8883 |
+ if (sc.nodeType != 3 || ec.nodeType != 3) |
|
| 8884 |
+ return null; |
|
| 8885 |
+ |
|
| 8886 |
+ if (so == 0) {
|
|
| 8887 |
+ sp = getParent(sc); |
|
| 8888 |
+ |
|
| 8889 |
+ if (sp && sp.firstChild != sc) |
|
| 8890 |
+ sp = null; |
|
| 8891 |
+ } |
|
| 8892 |
+ |
|
| 8893 |
+ if (so == sc.nodeValue.length) {
|
|
| 8894 |
+ e = sc.nextSibling; |
|
| 8895 |
+ |
|
| 8896 |
+ if (e && e.nodeType == 1) |
|
| 8897 |
+ sp = sc.nextSibling; |
|
| 8898 |
+ } |
|
| 8899 |
+ |
|
| 8900 |
+ if (eo == 0) {
|
|
| 8901 |
+ e = ec.previousSibling; |
|
| 8902 |
+ |
|
| 8903 |
+ if (e && e.nodeType == 1) |
|
| 8904 |
+ ep = e; |
|
| 8905 |
+ } |
|
| 8906 |
+ |
|
| 8907 |
+ if (eo == ec.nodeValue.length) {
|
|
| 8908 |
+ ep = getParent(ec); |
|
| 8909 |
+ |
|
| 8910 |
+ if (ep && ep.lastChild != ec) |
|
| 8911 |
+ ep = null; |
|
| 8912 |
+ } |
|
| 8913 |
+ |
|
| 8914 |
+ // Same element |
|
| 8915 |
+ if (sp == ep) |
|
| 8916 |
+ return re && sp && re.test(sp.nodeName) ? null : sp; |
|
| 8917 |
+ } |
|
| 8918 |
+ |
|
| 8919 |
+ return null; |
|
| 8920 |
+ }, |
|
| 8921 |
+ |
|
| 8922 |
+ InsertHorizontalRule : function() {
|
|
| 8923 |
+ // Fix for Gecko <hr size="1" /> issue and IE bug rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"); |
|
| 8924 |
+ if (isGecko || isIE) |
|
| 8925 |
+ this.editor.selection.setContent('<hr />');
|
|
| 8926 |
+ else |
|
| 8927 |
+ this.editor.getDoc().execCommand('InsertHorizontalRule', false, '');
|
|
| 8928 |
+ }, |
|
| 8929 |
+ |
|
| 8930 |
+ RemoveFormat : function() {
|
|
| 8931 |
+ var t = this, ed = t.editor, s = ed.selection, b; |
|
| 8932 |
+ |
|
| 8933 |
+ // Safari breaks tables |
|
| 8934 |
+ if (isWebKit) |
|
| 8935 |
+ s.setContent(s.getContent({format : 'raw'}).replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g, ''), {format : 'raw'});
|
|
| 8936 |
+ else |
|
| 8937 |
+ ed.getDoc().execCommand('RemoveFormat', false, null);
|
|
| 8938 |
+ |
|
| 8939 |
+ t.mceSetStyleInfo(0, {command : 'removeformat'});
|
|
| 8940 |
+ ed.addVisual(); |
|
| 8941 |
+ }, |
|
| 8942 |
+ |
|
| 8943 |
+ mceSetStyleInfo : function(u, v) {
|
|
| 8944 |
+ var t = this, ed = t.editor, d = ed.getDoc(), dom = ed.dom, e, b, s = ed.selection, nn = v.wrapper || 'span', b = s.getBookmark(), re; |
|
| 8945 |
+ |
|
| 8946 |
+ function set(n, e) {
|
|
| 8947 |
+ if (n.nodeType == 1) {
|
|
| 8948 |
+ switch (v.command) {
|
|
| 8949 |
+ case 'setattrib': |
|
| 8950 |
+ return dom.setAttrib(n, v.name, v.value); |
|
| 8951 |
+ |
|
| 8952 |
+ case 'setstyle': |
|
| 8953 |
+ return dom.setStyle(n, v.name, v.value); |
|
| 8954 |
+ |
|
| 8955 |
+ case 'removeformat': |
|
| 8956 |
+ return dom.setAttrib(n, 'class', ''); |
|
| 8957 |
+ } |
|
| 8958 |
+ } |
|
| 8959 |
+ }; |
|
| 8960 |
+ |
|
| 8961 |
+ // Setup regexp |
|
| 8962 |
+ re = ed.settings.merge_styles_invalid_parents; |
|
| 8963 |
+ if (tinymce.is(re, 'string')) |
|
| 8964 |
+ re = new RegExp(re, 'i'); |
|
| 8965 |
+ |
|
| 8966 |
+ // Set style info on selected element |
|
| 8967 |
+ if (e = t.getSelectedElement()) |
|
| 8968 |
+ set(e, 1); |
|
| 8969 |
+ else {
|
|
| 8970 |
+ // Generate wrappers and set styles on them |
|
| 8971 |
+ d.execCommand('FontName', false, '__');
|
|
| 8972 |
+ each(isWebKit ? dom.select('span') : dom.select('font'), function(n) {
|
|
| 8973 |
+ var sp, e; |
|
| 8974 |
+ |
|
| 8975 |
+ if (dom.getAttrib(n, 'face') == '__' || n.style.fontFamily === '__') {
|
|
| 8976 |
+ sp = dom.create(nn, {mce_new : '1'});
|
|
| 8977 |
+ |
|
| 8978 |
+ set(sp); |
|
| 8979 |
+ |
|
| 8980 |
+ each (n.childNodes, function(n) {
|
|
| 8981 |
+ sp.appendChild(n.cloneNode(true)); |
|
| 8982 |
+ }); |
|
| 8983 |
+ |
|
| 8984 |
+ dom.replace(sp, n); |
|
| 8985 |
+ } |
|
| 8986 |
+ }); |
|
| 8987 |
+ } |
|
| 8988 |
+ |
|
| 8989 |
+ // Remove wrappers inside new ones |
|
| 8990 |
+ each(dom.select(nn).reverse(), function(n) {
|
|
| 8991 |
+ var p = n.parentNode; |
|
| 8992 |
+ |
|
| 8993 |
+ // Check if it's an old span in a new wrapper |
|
| 8994 |
+ if (!dom.getAttrib(n, 'mce_new')) {
|
|
| 8995 |
+ // Find new wrapper |
|
| 8996 |
+ p = dom.getParent(n, function(n) {
|
|
| 8997 |
+ return n.nodeType == 1 && dom.getAttrib(n, 'mce_new'); |
|
| 8998 |
+ }); |
|
| 8999 |
+ |
|
| 9000 |
+ if (p) |
|
| 9001 |
+ dom.remove(n, 1); |
|
| 9002 |
+ } |
|
| 9003 |
+ }); |
|
| 9004 |
+ |
|
| 9005 |
+ // Merge wrappers with parent wrappers |
|
| 9006 |
+ each(dom.select(nn).reverse(), function(n) {
|
|
| 9007 |
+ var p = n.parentNode; |
|
| 9008 |
+ |
|
| 9009 |
+ if (!p || !dom.getAttrib(n, 'mce_new')) |
|
| 9010 |
+ return; |
|
| 9011 |
+ |
|
| 9012 |
+ // Has parent of the same type and only child |
|
| 9013 |
+ if (p.nodeName == nn.toUpperCase() && p.childNodes.length == 1) |
|
| 9014 |
+ return dom.remove(p, 1); |
|
| 9015 |
+ |
|
| 9016 |
+ // Has parent that is more suitable to have the class and only child |
|
| 9017 |
+ if (n.nodeType == 1 && (!re || !re.test(p.nodeName)) && p.childNodes.length == 1) {
|
|
| 9018 |
+ set(p); // Set style info on parent instead |
|
| 9019 |
+ dom.setAttrib(n, 'class', ''); |
|
| 9020 |
+ } |
|
| 9021 |
+ }); |
|
| 9022 |
+ |
|
| 9023 |
+ // Remove empty wrappers |
|
| 9024 |
+ each(dom.select(nn).reverse(), function(n) {
|
|
| 9025 |
+ if (dom.getAttrib(n, 'mce_new') || (dom.getAttribs(n).length <= 1 && n.className === '')) {
|
|
| 9026 |
+ if (!dom.getAttrib(n, 'class') && !dom.getAttrib(n, 'style')) |
|
| 9027 |
+ return dom.remove(n, 1); |
|
| 9028 |
+ |
|
| 9029 |
+ dom.setAttrib(n, 'mce_new', ''); // Remove mce_new marker |
|
| 9030 |
+ } |
|
| 9031 |
+ }); |
|
| 9032 |
+ |
|
| 9033 |
+ s.moveToBookmark(b); |
|
| 9034 |
+ }, |
|
| 9035 |
+ |
|
| 9036 |
+ queryStateJustify : function(c, v) {
|
|
| 9037 |
+ var ed = this.editor, n = ed.selection.getNode(), dom = ed.dom; |
|
| 9038 |
+ |
|
| 9039 |
+ if (n && n.nodeName == 'IMG') {
|
|
| 9040 |
+ if (dom.getStyle(n, 'float') == v) |
|
| 9041 |
+ return 1; |
|
| 9042 |
+ |
|
| 9043 |
+ return n.parentNode.style.textAlign == v; |
|
| 9044 |
+ } |
|
| 9045 |
+ |
|
| 9046 |
+ n = dom.getParent(ed.selection.getStart(), function(n) {
|
|
| 9047 |
+ return n.nodeType == 1 && n.style.textAlign; |
|
| 9048 |
+ }); |
|
| 9049 |
+ |
|
| 9050 |
+ if (v == 'full') |
|
| 9051 |
+ v = 'justify'; |
|
| 9052 |
+ |
|
| 9053 |
+ if (ed.settings.inline_styles) |
|
| 9054 |
+ return (n && n.style.textAlign == v); |
|
| 9055 |
+ |
|
| 9056 |
+ return this._queryState(c); |
|
| 9057 |
+ }, |
|
| 9058 |
+ |
|
| 9059 |
+ HiliteColor : function(ui, val) {
|
|
| 9060 |
+ var t = this, ed = t.editor, d = ed.getDoc(); |
|
| 9061 |
+ |
|
| 9062 |
+ function set(s) {
|
|
| 9063 |
+ if (!isGecko) |
|
| 9064 |
+ return; |
|
| 9065 |
+ |
|
| 9066 |
+ try {
|
|
| 9067 |
+ // Try new Gecko method |
|
| 9068 |
+ d.execCommand("styleWithCSS", 0, s);
|
|
| 9069 |
+ } catch (ex) {
|
|
| 9070 |
+ // Use old |
|
| 9071 |
+ d.execCommand("useCSS", 0, !s);
|
|
| 9072 |
+ } |
|
| 9073 |
+ }; |
|
| 9074 |
+ |
|
| 9075 |
+ if (isGecko || isOpera) {
|
|
| 9076 |
+ set(true); |
|
| 9077 |
+ d.execCommand('hilitecolor', false, val);
|
|
| 9078 |
+ set(false); |
|
| 9079 |
+ } else |
|
| 9080 |
+ d.execCommand('BackColor', false, val);
|
|
| 9081 |
+ }, |
|
| 9082 |
+ |
|
| 9083 |
+ Undo : function() {
|
|
| 9084 |
+ var ed = this.editor; |
|
| 9085 |
+ |
|
| 9086 |
+ if (ed.settings.custom_undo_redo) {
|
|
| 9087 |
+ ed.undoManager.undo(); |
|
| 9088 |
+ ed.nodeChanged(); |
|
| 9089 |
+ } else |
|
| 9090 |
+ ed.getDoc().execCommand('Undo', false, null);
|
|
| 9091 |
+ }, |
|
| 9092 |
+ |
|
| 9093 |
+ Redo : function() {
|
|
| 9094 |
+ var ed = this.editor; |
|
| 9095 |
+ |
|
| 9096 |
+ if (ed.settings.custom_undo_redo) {
|
|
| 9097 |
+ ed.undoManager.redo(); |
|
| 9098 |
+ ed.nodeChanged(); |
|
| 9099 |
+ } else |
|
| 9100 |
+ ed.getDoc().execCommand('Redo', false, null);
|
|
| 9101 |
+ }, |
|
| 9102 |
+ |
|
| 9103 |
+ FormatBlock : function(ui, val) {
|
|
| 9104 |
+ var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, bl, nb, b; |
|
| 9105 |
+ |
|
| 9106 |
+ function isBlock(n) {
|
|
| 9107 |
+ return /^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName); |
|
| 9108 |
+ }; |
|
| 9109 |
+ |
|
| 9110 |
+ bl = dom.getParent(s.getNode(), function(n) {
|
|
| 9111 |
+ return isBlock(n); |
|
| 9112 |
+ }); |
|
| 9113 |
+ |
|
| 9114 |
+ // IE has an issue where it removes the parent div if you change format on the paragrah in <div><p>Content</p></div> |
|
| 9115 |
+ // FF and Opera doesn't change parent DIV elements if you switch format |
|
| 9116 |
+ if (bl) {
|
|
| 9117 |
+ if ((isIE && isBlock(bl.parentNode)) || bl.nodeName == 'DIV') {
|
|
| 9118 |
+ // Rename block element |
|
| 9119 |
+ nb = ed.dom.create(val); |
|
| 9120 |
+ |
|
| 9121 |
+ each(dom.getAttribs(bl), function(v) {
|
|
| 9122 |
+ dom.setAttrib(nb, v.nodeName, dom.getAttrib(bl, v.nodeName)); |
|
| 9123 |
+ }); |
|
| 9124 |
+ |
|
| 9125 |
+ b = s.getBookmark(); |
|
| 9126 |
+ dom.replace(nb, bl, 1); |
|
| 9127 |
+ s.moveToBookmark(b); |
|
| 9128 |
+ ed.nodeChanged(); |
|
| 9129 |
+ return; |
|
| 9130 |
+ } |
|
| 9131 |
+ } |
|
| 9132 |
+ |
|
| 9133 |
+ val = ed.settings.forced_root_block ? (val || '<p>') : val; |
|
| 9134 |
+ |
|
| 9135 |
+ if (val.indexOf('<') == -1)
|
|
| 9136 |
+ val = '<' + val + '>'; |
|
| 9137 |
+ |
|
| 9138 |
+ if (tinymce.isGecko) |
|
| 9139 |
+ val = val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi, '$1'); |
|
| 9140 |
+ |
|
| 9141 |
+ ed.getDoc().execCommand('FormatBlock', false, val);
|
|
| 9142 |
+ }, |
|
| 9143 |
+ |
|
| 9144 |
+ mceCleanup : function() {
|
|
| 9145 |
+ var ed = this.editor, s = ed.selection, b = s.getBookmark(); |
|
| 9146 |
+ ed.setContent(ed.getContent()); |
|
| 9147 |
+ s.moveToBookmark(b); |
|
| 9148 |
+ }, |
|
| 9149 |
+ |
|
| 9150 |
+ mceRemoveNode : function(ui, val) {
|
|
| 9151 |
+ var ed = this.editor, s = ed.selection, b, n = val || s.getNode(); |
|
| 9152 |
+ |
|
| 9153 |
+ // Make sure that the body node isn't removed |
|
| 9154 |
+ if (n == ed.getBody()) |
|
| 9155 |
+ return; |
|
| 9156 |
+ |
|
| 9157 |
+ b = s.getBookmark(); |
|
| 9158 |
+ ed.dom.remove(n, 1); |
|
| 9159 |
+ s.moveToBookmark(b); |
|
| 9160 |
+ ed.nodeChanged(); |
|
| 9161 |
+ }, |
|
| 9162 |
+ |
|
| 9163 |
+ mceSelectNodeDepth : function(ui, val) {
|
|
| 9164 |
+ var ed = this.editor, s = ed.selection, c = 0; |
|
| 9165 |
+ |
|
| 9166 |
+ ed.dom.getParent(s.getNode(), function(n) {
|
|
| 9167 |
+ if (n.nodeType == 1 && c++ == val) {
|
|
| 9168 |
+ s.select(n); |
|
| 9169 |
+ ed.nodeChanged(); |
|
| 9170 |
+ return false; |
|
| 9171 |
+ } |
|
| 9172 |
+ }, ed.getBody()); |
|
| 9173 |
+ }, |
|
| 9174 |
+ |
|
| 9175 |
+ mceSelectNode : function(u, v) {
|
|
| 9176 |
+ this.editor.selection.select(v); |
|
| 9177 |
+ }, |
|
| 9178 |
+ |
|
| 9179 |
+ mceInsertContent : function(ui, val) {
|
|
| 9180 |
+ this.editor.selection.setContent(val); |
|
| 9181 |
+ }, |
|
| 9182 |
+ |
|
| 9183 |
+ mceInsertRawHTML : function(ui, val) {
|
|
| 9184 |
+ var ed = this.editor; |
|
| 9185 |
+ |
|
| 9186 |
+ ed.selection.setContent('tiny_mce_marker');
|
|
| 9187 |
+ ed.setContent(ed.getContent().replace(/tiny_mce_marker/g, val)); |
|
| 9188 |
+ }, |
|
| 9189 |
+ |
|
| 9190 |
+ mceRepaint : function() {
|
|
| 9191 |
+ var s, b, e = this.editor; |
|
| 9192 |
+ |
|
| 9193 |
+ if (tinymce.isGecko) {
|
|
| 9194 |
+ try {
|
|
| 9195 |
+ s = e.selection; |
|
| 9196 |
+ b = s.getBookmark(true); |
|
| 9197 |
+ |
|
| 9198 |
+ if (s.getSel()) |
|
| 9199 |
+ s.getSel().selectAllChildren(e.getBody()); |
|
| 9200 |
+ |
|
| 9201 |
+ s.collapse(true); |
|
| 9202 |
+ s.moveToBookmark(b); |
|
| 9203 |
+ } catch (ex) {
|
|
| 9204 |
+ // Ignore |
|
| 9205 |
+ } |
|
| 9206 |
+ } |
|
| 9207 |
+ }, |
|
| 9208 |
+ |
|
| 9209 |
+ queryStateUnderline : function() {
|
|
| 9210 |
+ var ed = this.editor, n = ed.selection.getNode(); |
|
| 9211 |
+ |
|
| 9212 |
+ if (n && n.nodeName == 'A') |
|
| 9213 |
+ return false; |
|
| 9214 |
+ |
|
| 9215 |
+ return this._queryState('Underline');
|
|
| 9216 |
+ }, |
|
| 9217 |
+ |
|
| 9218 |
+ queryStateOutdent : function() {
|
|
| 9219 |
+ var ed = this.editor, n; |
|
| 9220 |
+ |
|
| 9221 |
+ if (ed.settings.inline_styles) {
|
|
| 9222 |
+ if ((n = ed.dom.getParent(ed.selection.getStart(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0) |
|
| 9223 |
+ return true; |
|
| 9224 |
+ |
|
| 9225 |
+ if ((n = ed.dom.getParent(ed.selection.getEnd(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0) |
|
| 9226 |
+ return true; |
|
| 9227 |
+ } else |
|
| 9228 |
+ return !!ed.dom.getParent(ed.selection.getNode(), 'BLOCKQUOTE'); |
|
| 9229 |
+ |
|
| 9230 |
+ return this.queryStateInsertUnorderedList() || this.queryStateInsertOrderedList(); |
|
| 9231 |
+ }, |
|
| 9232 |
+ |
|
| 9233 |
+ queryStateInsertUnorderedList : function() {
|
|
| 9234 |
+ return this.editor.dom.getParent(this.editor.selection.getNode(), 'UL'); |
|
| 9235 |
+ }, |
|
| 9236 |
+ |
|
| 9237 |
+ queryStateInsertOrderedList : function() {
|
|
| 9238 |
+ return this.editor.dom.getParent(this.editor.selection.getNode(), 'OL'); |
|
| 9239 |
+ }, |
|
| 9240 |
+ |
|
| 9241 |
+ queryStatemceBlockQuote : function() {
|
|
| 9242 |
+ return !!this.editor.dom.getParent(this.editor.selection.getStart(), function(n) {return n.nodeName === 'BLOCKQUOTE';});
|
|
| 9243 |
+ }, |
|
| 9244 |
+ |
|
| 9245 |
+ mceBlockQuote : function() {
|
|
| 9246 |
+ var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, sb, eb, n, bm, bq, r, bq2, i, nl; |
|
| 9247 |
+ |
|
| 9248 |
+ function getBQ(e) {
|
|
| 9249 |
+ return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
|
|
| 9250 |
+ }; |
|
| 9251 |
+ |
|
| 9252 |
+ // Get start/end block |
|
| 9253 |
+ sb = dom.getParent(s.getStart(), dom.isBlock); |
|
| 9254 |
+ eb = dom.getParent(s.getEnd(), dom.isBlock); |
|
| 9255 |
+ |
|
| 9256 |
+ // Remove blockquote(s) |
|
| 9257 |
+ if (bq = getBQ(sb)) {
|
|
| 9258 |
+ if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR')) |
|
| 9259 |
+ bm = s.getBookmark(); |
|
| 9260 |
+ |
|
| 9261 |
+ // Move all elements after the end block into new bq |
|
| 9262 |
+ if (getBQ(eb)) {
|
|
| 9263 |
+ bq2 = bq.cloneNode(false); |
|
| 9264 |
+ |
|
| 9265 |
+ while (n = eb.nextSibling) |
|
| 9266 |
+ bq2.appendChild(n.parentNode.removeChild(n)); |
|
| 9267 |
+ } |
|
| 9268 |
+ |
|
| 9269 |
+ // Add new bq after |
|
| 9270 |
+ if (bq2) |
|
| 9271 |
+ dom.insertAfter(bq2, bq); |
|
| 9272 |
+ |
|
| 9273 |
+ // Move all selected blocks after the current bq |
|
| 9274 |
+ nl = t._getSelectedBlocks(sb, eb); |
|
| 9275 |
+ for (i = nl.length - 1; i >= 0; i--) {
|
|
| 9276 |
+ dom.insertAfter(nl[i], bq); |
|
| 9277 |
+ } |
|
| 9278 |
+ |
|
| 9279 |
+ // Empty bq, then remove it |
|
| 9280 |
+ if (/^\s*$/.test(bq.innerHTML)) |
|
| 9281 |
+ dom.remove(bq, 1); // Keep children so boomark restoration works correctly |
|
| 9282 |
+ |
|
| 9283 |
+ // Empty bq, then remote it |
|
| 9284 |
+ if (bq2 && /^\s*$/.test(bq2.innerHTML)) |
|
| 9285 |
+ dom.remove(bq2, 1); // Keep children so boomark restoration works correctly |
|
| 9286 |
+ |
|
| 9287 |
+ if (!bm) {
|
|
| 9288 |
+ // Move caret inside empty block element |
|
| 9289 |
+ if (!isIE) {
|
|
| 9290 |
+ r = ed.getDoc().createRange(); |
|
| 9291 |
+ r.setStart(sb, 0); |
|
| 9292 |
+ r.setEnd(sb, 0); |
|
| 9293 |
+ s.setRng(r); |
|
| 9294 |
+ } else {
|
|
| 9295 |
+ s.select(sb); |
|
| 9296 |
+ s.collapse(0); |
|
| 9297 |
+ |
|
| 9298 |
+ // IE misses the empty block some times element so we must move back the caret |
|
| 9299 |
+ if (dom.getParent(s.getStart(), dom.isBlock) != sb) {
|
|
| 9300 |
+ r = s.getRng(); |
|
| 9301 |
+ r.move('character', -1);
|
|
| 9302 |
+ r.select(); |
|
| 9303 |
+ } |
|
| 9304 |
+ } |
|
| 9305 |
+ } else |
|
| 9306 |
+ t.editor.selection.moveToBookmark(bm); |
|
| 9307 |
+ |
|
| 9308 |
+ return; |
|
| 9309 |
+ } |
|
| 9310 |
+ |
|
| 9311 |
+ // Since IE can start with a totally empty document we need to add the first bq and paragraph |
|
| 9312 |
+ if (isIE && !sb && !eb) {
|
|
| 9313 |
+ t.editor.getDoc().execCommand('Indent');
|
|
| 9314 |
+ n = getBQ(s.getNode()); |
|
| 9315 |
+ n.style.margin = n.dir = ''; // IE adds margin and dir to bq |
|
| 9316 |
+ return; |
|
| 9317 |
+ } |
|
| 9318 |
+ |
|
| 9319 |
+ if (!sb || !eb) |
|
| 9320 |
+ return; |
|
| 9321 |
+ |
|
| 9322 |
+ // If empty paragraph node then do not use bookmark |
|
| 9323 |
+ if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR')) |
|
| 9324 |
+ bm = s.getBookmark(); |
|
| 9325 |
+ |
|
| 9326 |
+ // Move selected block elements into a bq |
|
| 9327 |
+ each(t._getSelectedBlocks(getBQ(s.getStart()), getBQ(s.getEnd())), function(e) {
|
|
| 9328 |
+ // Found existing BQ add to this one |
|
| 9329 |
+ if (e.nodeName == 'BLOCKQUOTE' && !bq) {
|
|
| 9330 |
+ bq = e; |
|
| 9331 |
+ return; |
|
| 9332 |
+ } |
|
| 9333 |
+ |
|
| 9334 |
+ // No BQ found, create one |
|
| 9335 |
+ if (!bq) {
|
|
| 9336 |
+ bq = dom.create('blockquote');
|
|
| 9337 |
+ e.parentNode.insertBefore(bq, e); |
|
| 9338 |
+ } |
|
| 9339 |
+ |
|
| 9340 |
+ // Add children from existing BQ |
|
| 9341 |
+ if (e.nodeName == 'BLOCKQUOTE' && bq) {
|
|
| 9342 |
+ n = e.firstChild; |
|
| 9343 |
+ |
|
| 9344 |
+ while (n) {
|
|
| 9345 |
+ bq.appendChild(n.cloneNode(true)); |
|
| 9346 |
+ n = n.nextSibling; |
|
| 9347 |
+ } |
|
| 9348 |
+ |
|
| 9349 |
+ dom.remove(e); |
|
| 9350 |
+ return; |
|
| 9351 |
+ } |
|
| 9352 |
+ |
|
| 9353 |
+ // Add non BQ element to BQ |
|
| 9354 |
+ bq.appendChild(dom.remove(e)); |
|
| 9355 |
+ }); |
|
| 9356 |
+ |
|
| 9357 |
+ if (!bm) {
|
|
| 9358 |
+ // Move caret inside empty block element |
|
| 9359 |
+ if (!isIE) {
|
|
| 9360 |
+ r = ed.getDoc().createRange(); |
|
| 9361 |
+ r.setStart(sb, 0); |
|
| 9362 |
+ r.setEnd(sb, 0); |
|
| 9363 |
+ s.setRng(r); |
|
| 9364 |
+ } else {
|
|
| 9365 |
+ s.select(sb); |
|
| 9366 |
+ s.collapse(1); |
|
| 9367 |
+ } |
|
| 9368 |
+ } else |
|
| 9369 |
+ s.moveToBookmark(bm); |
|
| 9370 |
+ }, |
|
| 9371 |
+/* |
|
| 9372 |
+ _mceBlockQuote : function() {
|
|
| 9373 |
+ var t = this, s = t.editor.selection, b = s.getBookmark(), bq, dom = t.editor.dom; |
|
| 9374 |
+ |
|
| 9375 |
+ function findBQ(e) {
|
|
| 9376 |
+ return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
|
|
| 9377 |
+ }; |
|
| 9378 |
+ |
|
| 9379 |
+ // Remove blockquote(s) |
|
| 9380 |
+ if (findBQ(s.getStart())) {
|
|
| 9381 |
+ each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
|
|
| 9382 |
+ // Found BQ lets remove it |
|
| 9383 |
+ if (e.nodeName == 'BLOCKQUOTE') |
|
| 9384 |
+ dom.remove(e, 1); |
|
| 9385 |
+ }); |
|
| 9386 |
+ |
|
| 9387 |
+ t.editor.selection.moveToBookmark(b); |
|
| 9388 |
+ return; |
|
| 9389 |
+ } |
|
| 9390 |
+ |
|
| 9391 |
+ each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
|
|
| 9392 |
+ var n; |
|
| 9393 |
+ |
|
| 9394 |
+ // Found existing BQ add to this one |
|
| 9395 |
+ if (e.nodeName == 'BLOCKQUOTE' && !bq) {
|
|
| 9396 |
+ bq = e; |
|
| 9397 |
+ return; |
|
| 9398 |
+ } |
|
| 9399 |
+ |
|
| 9400 |
+ // No BQ found, create one |
|
| 9401 |
+ if (!bq) {
|
|
| 9402 |
+ bq = dom.create('blockquote');
|
|
| 9403 |
+ e.parentNode.insertBefore(bq, e); |
|
| 9404 |
+ } |
|
| 9405 |
+ |
|
| 9406 |
+ // Add children from existing BQ |
|
| 9407 |
+ if (e.nodeName == 'BLOCKQUOTE' && bq) {
|
|
| 9408 |
+ n = e.firstChild; |
|
| 9409 |
+ |
|
| 9410 |
+ while (n) {
|
|
| 9411 |
+ bq.appendChild(n.cloneNode(true)); |
|
| 9412 |
+ n = n.nextSibling; |
|
| 9413 |
+ } |
|
| 9414 |
+ |
|
| 9415 |
+ dom.remove(e); |
|
| 9416 |
+ |
|
| 9417 |
+ return; |
|
| 9418 |
+ } |
|
| 9419 |
+ |
|
| 9420 |
+ // Add non BQ element to BQ |
|
| 9421 |
+ bq.appendChild(dom.remove(e)); |
|
| 9422 |
+ }); |
|
| 9423 |
+ |
|
| 9424 |
+ t.editor.selection.moveToBookmark(b); |
|
| 9425 |
+ }, |
|
| 9426 |
+*/ |
|
| 9427 |
+ _getSelectedBlocks : function(st, en) {
|
|
| 9428 |
+ var ed = this.editor, dom = ed.dom, s = ed.selection, sb, eb, n, bl = []; |
|
| 9429 |
+ |
|
| 9430 |
+ sb = dom.getParent(st || s.getStart(), dom.isBlock); |
|
| 9431 |
+ eb = dom.getParent(en || s.getEnd(), dom.isBlock); |
|
| 9432 |
+ |
|
| 9433 |
+ if (sb) |
|
| 9434 |
+ bl.push(sb); |
|
| 9435 |
+ |
|
| 9436 |
+ if (sb && eb && sb != eb) {
|
|
| 9437 |
+ n = sb; |
|
| 9438 |
+ |
|
| 9439 |
+ while ((n = n.nextSibling) && n != eb) {
|
|
| 9440 |
+ if (dom.isBlock(n)) |
|
| 9441 |
+ bl.push(n); |
|
| 9442 |
+ } |
|
| 9443 |
+ } |
|
| 9444 |
+ |
|
| 9445 |
+ if (eb && sb != eb) |
|
| 9446 |
+ bl.push(eb); |
|
| 9447 |
+ |
|
| 9448 |
+ return bl; |
|
| 9449 |
+ } |
|
| 9450 |
+ }); |
|
| 9451 |
+})(); |
|
| 9452 |
+ |
|
| 9453 |
+ |
|
| 9454 |
+/* file:jscripts/tiny_mce/classes/UndoManager.js */ |
|
| 9455 |
+ |
|
| 9456 |
+tinymce.create('tinymce.UndoManager', {
|
|
| 9457 |
+ index : 0, |
|
| 9458 |
+ data : null, |
|
| 9459 |
+ typing : 0, |
|
| 9460 |
+ |
|
| 9461 |
+ UndoManager : function(ed) {
|
|
| 9462 |
+ var t = this, Dispatcher = tinymce.util.Dispatcher; |
|
| 9463 |
+ |
|
| 9464 |
+ t.editor = ed; |
|
| 9465 |
+ t.data = []; |
|
| 9466 |
+ t.onAdd = new Dispatcher(this); |
|
| 9467 |
+ t.onUndo = new Dispatcher(this); |
|
| 9468 |
+ t.onRedo = new Dispatcher(this); |
|
| 9469 |
+ }, |
|
| 9470 |
+ |
|
| 9471 |
+ add : function(l) {
|
|
| 9472 |
+ var t = this, i, ed = t.editor, b, s = ed.settings, la; |
|
| 9473 |
+ |
|
| 9474 |
+ l = l || {};
|
|
| 9475 |
+ l.content = l.content || ed.getContent({format : 'raw', no_events : 1});
|
|
| 9476 |
+ |
|
| 9477 |
+ // Add undo level if needed |
|
| 9478 |
+ l.content = l.content.replace(/^\s*|\s*$/g, ''); |
|
| 9479 |
+ la = t.data[t.index > 0 && (t.index == 0 || t.index == t.data.length) ? t.index - 1 : t.index]; |
|
| 9480 |
+ if (!l.initial && la && l.content == la.content) |
|
| 9481 |
+ return null; |
|
| 9482 |
+ |
|
| 9483 |
+ // Time to compress |
|
| 9484 |
+ if (s.custom_undo_redo_levels) {
|
|
| 9485 |
+ if (t.data.length > s.custom_undo_redo_levels) {
|
|
| 9486 |
+ for (i = 0; i < t.data.length - 1; i++) |
|
| 9487 |
+ t.data[i] = t.data[i + 1]; |
|
| 9488 |
+ |
|
| 9489 |
+ t.data.length--; |
|
| 9490 |
+ t.index = t.data.length; |
|
| 9491 |
+ } |
|
| 9492 |
+ } |
|
| 9493 |
+ |
|
| 9494 |
+ if (s.custom_undo_redo_restore_selection && !l.initial) |
|
| 9495 |
+ l.bookmark = b = l.bookmark || ed.selection.getBookmark(); |
|
| 9496 |
+ |
|
| 9497 |
+ if (t.index < t.data.length) |
|
| 9498 |
+ t.index++; |
|
| 9499 |
+ |
|
| 9500 |
+ // Only initial marked undo levels should be allowed as first item |
|
| 9501 |
+ // This to workaround a bug with Firefox and the blur event |
|
| 9502 |
+ if (t.data.length === 0 && !l.initial) |
|
| 9503 |
+ return null; |
|
| 9504 |
+ |
|
| 9505 |
+ // Add level |
|
| 9506 |
+ t.data.length = t.index + 1; |
|
| 9507 |
+ t.data[t.index++] = l; |
|
| 9508 |
+ |
|
| 9509 |
+ if (l.initial) |
|
| 9510 |
+ t.index = 0; |
|
| 9511 |
+ |
|
| 9512 |
+ // Set initial bookmark use first real undo level |
|
| 9513 |
+ if (t.data.length == 2 && t.data[0].initial) |
|
| 9514 |
+ t.data[0].bookmark = b; |
|
| 9515 |
+ |
|
| 9516 |
+ t.onAdd.dispatch(t, l); |
|
| 9517 |
+ ed.isNotDirty = 0; |
|
| 9518 |
+ |
|
| 9519 |
+ //console.dir(t.data); |
|
| 9520 |
+ |
|
| 9521 |
+ return l; |
|
| 9522 |
+ }, |
|
| 9523 |
+ |
|
| 9524 |
+ undo : function() {
|
|
| 9525 |
+ var t = this, ed = t.editor, l = l, i; |
|
| 9526 |
+ |
|
| 9527 |
+ if (t.typing) {
|
|
| 9528 |
+ t.add(); |
|
| 9529 |
+ t.typing = 0; |
|
| 9530 |
+ } |
|
| 9531 |
+ |
|
| 9532 |
+ if (t.index > 0) {
|
|
| 9533 |
+ // If undo on last index then take snapshot |
|
| 9534 |
+ if (t.index == t.data.length && t.index > 1) {
|
|
| 9535 |
+ i = t.index; |
|
| 9536 |
+ t.typing = 0; |
|
| 9537 |
+ |
|
| 9538 |
+ if (!t.add()) |
|
| 9539 |
+ t.index = i; |
|
| 9540 |
+ |
|
| 9541 |
+ --t.index; |
|
| 9542 |
+ } |
|
| 9543 |
+ |
|
| 9544 |
+ l = t.data[--t.index]; |
|
| 9545 |
+ ed.setContent(l.content, {format : 'raw'});
|
|
| 9546 |
+ ed.selection.moveToBookmark(l.bookmark); |
|
| 9547 |
+ |
|
| 9548 |
+ t.onUndo.dispatch(t, l); |
|
| 9549 |
+ } |
|
| 9550 |
+ |
|
| 9551 |
+ return l; |
|
| 9552 |
+ }, |
|
| 9553 |
+ |
|
| 9554 |
+ redo : function() {
|
|
| 9555 |
+ var t = this, ed = t.editor, l = null; |
|
| 9556 |
+ |
|
| 9557 |
+ if (t.index < t.data.length - 1) {
|
|
| 9558 |
+ l = t.data[++t.index]; |
|
| 9559 |
+ ed.setContent(l.content, {format : 'raw'});
|
|
| 9560 |
+ ed.selection.moveToBookmark(l.bookmark); |
|
| 9561 |
+ |
|
| 9562 |
+ t.onRedo.dispatch(t, l); |
|
| 9563 |
+ } |
|
| 9564 |
+ |
|
| 9565 |
+ return l; |
|
| 9566 |
+ }, |
|
| 9567 |
+ |
|
| 9568 |
+ clear : function() {
|
|
| 9569 |
+ var t = this; |
|
| 9570 |
+ |
|
| 9571 |
+ t.data = []; |
|
| 9572 |
+ t.index = 0; |
|
| 9573 |
+ t.typing = 0; |
|
| 9574 |
+ t.add({initial : true});
|
|
| 9575 |
+ }, |
|
| 9576 |
+ |
|
| 9577 |
+ hasUndo : function() {
|
|
| 9578 |
+ return this.index != 0 || this.typing; |
|
| 9579 |
+ }, |
|
| 9580 |
+ |
|
| 9581 |
+ hasRedo : function() {
|
|
| 9582 |
+ return this.index < this.data.length - 1; |
|
| 9583 |
+ } |
|
| 9584 |
+ |
|
| 9585 |
+ }); |
|
| 9586 |
+/* file:jscripts/tiny_mce/classes/ForceBlocks.js */ |
|
| 9587 |
+ |
|
| 9588 |
+(function() {
|
|
| 9589 |
+ // Shorten names |
|
| 9590 |
+ var Event, isIE, isGecko, isOpera, each, extend; |
|
| 9591 |
+ |
|
| 9592 |
+ Event = tinymce.dom.Event; |
|
| 9593 |
+ isIE = tinymce.isIE; |
|
| 9594 |
+ isGecko = tinymce.isGecko; |
|
| 9595 |
+ isOpera = tinymce.isOpera; |
|
| 9596 |
+ each = tinymce.each; |
|
| 9597 |
+ extend = tinymce.extend; |
|
| 9598 |
+ |
|
| 9599 |
+ tinymce.create('tinymce.ForceBlocks', {
|
|
| 9600 |
+ ForceBlocks : function(ed) {
|
|
| 9601 |
+ var t = this, s = ed.settings, elm; |
|
| 9602 |
+ |
|
| 9603 |
+ t.editor = ed; |
|
| 9604 |
+ t.dom = ed.dom; |
|
| 9605 |
+ elm = (s.forced_root_block || 'p').toLowerCase(); |
|
| 9606 |
+ s.element = elm.toUpperCase(); |
|
| 9607 |
+ |
|
| 9608 |
+ ed.onPreInit.add(t.setup, t); |
|
| 9609 |
+ |
|
| 9610 |
+ t.reOpera = new RegExp('(\\u00a0| | )<\/' + elm + '>', 'gi');
|
|
| 9611 |
+ t.rePadd = new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g, elm), 'gi');
|
|
| 9612 |
+ t.reNbsp2BR1 = new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g, elm), 'gi');
|
|
| 9613 |
+ t.reNbsp2BR2 = new RegExp('<p( )([^>]+)>( | )<\\\/p>|<p>( | )<\\\/p>'.replace(/p/g, elm), 'gi');
|
|
| 9614 |
+ t.reBR2Nbsp = new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
|
|
| 9615 |
+ t.reTrailBr = new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
|
|
| 9616 |
+ |
|
| 9617 |
+ function padd(ed, o) {
|
|
| 9618 |
+ if (isOpera) |
|
| 9619 |
+ o.content = o.content.replace(t.reOpera, '</' + elm + '>'); |
|
| 9620 |
+ |
|
| 9621 |
+ o.content = o.content.replace(t.rePadd, '<' + elm + '$1$2$3$4$5$6>\u00a0</' + elm + '>'); |
|
| 9622 |
+ |
|
| 9623 |
+ if (!isIE && !isOpera && o.set) {
|
|
| 9624 |
+ // Use instead of BR in padded paragraphs |
|
| 9625 |
+ o.content = o.content.replace(t.reNbsp2BR1, '<' + elm + '$1$2><br /></' + elm + '>'); |
|
| 9626 |
+ o.content = o.content.replace(t.reNbsp2BR2, '<' + elm + '$1$2><br /></' + elm + '>'); |
|
| 9627 |
+ } else {
|
|
| 9628 |
+ o.content = o.content.replace(t.reBR2Nbsp, '<' + elm + '$1$2>\u00a0</' + elm + '>'); |
|
| 9629 |
+ o.content = o.content.replace(t.reTrailBr, '</' + elm + '>'); |
|
| 9630 |
+ } |
|
| 9631 |
+ }; |
|
| 9632 |
+ |
|
| 9633 |
+ ed.onBeforeSetContent.add(padd); |
|
| 9634 |
+ ed.onPostProcess.add(padd); |
|
| 9635 |
+ |
|
| 9636 |
+ if (s.forced_root_block) {
|
|
| 9637 |
+ ed.onInit.add(t.forceRoots, t); |
|
| 9638 |
+ ed.onSetContent.add(t.forceRoots, t); |
|
| 9639 |
+ ed.onBeforeGetContent.add(t.forceRoots, t); |
|
| 9640 |
+ } |
|
| 9641 |
+ }, |
|
| 9642 |
+ |
|
| 9643 |
+ setup : function() {
|
|
| 9644 |
+ var t = this, ed = t.editor, s = ed.settings; |
|
| 9645 |
+ |
|
| 9646 |
+ // Force root blocks when typing and when getting output |
|
| 9647 |
+ if (s.forced_root_block) {
|
|
| 9648 |
+ ed.onKeyUp.add(t.forceRoots, t); |
|
| 9649 |
+ ed.onPreProcess.add(t.forceRoots, t); |
|
| 9650 |
+ } |
|
| 9651 |
+ |
|
| 9652 |
+ if (s.force_br_newlines) {
|
|
| 9653 |
+ // Force IE to produce BRs on enter |
|
| 9654 |
+ if (isIE) {
|
|
| 9655 |
+ ed.onKeyPress.add(function(ed, e) {
|
|
| 9656 |
+ var n, s = ed.selection; |
|
| 9657 |
+ |
|
| 9658 |
+ if (e.keyCode == 13 && s.getNode().nodeName != 'LI') {
|
|
| 9659 |
+ s.setContent('<br id="__" /> ', {format : 'raw'});
|
|
| 9660 |
+ n = ed.dom.get('__');
|
|
| 9661 |
+ n.removeAttribute('id');
|
|
| 9662 |
+ s.select(n); |
|
| 9663 |
+ s.collapse(); |
|
| 9664 |
+ return Event.cancel(e); |
|
| 9665 |
+ } |
|
| 9666 |
+ }); |
|
| 9667 |
+ } |
|
| 9668 |
+ |
|
| 9669 |
+ return; |
|
| 9670 |
+ } |
|
| 9671 |
+ |
|
| 9672 |
+ if (!isIE && s.force_p_newlines) {
|
|
| 9673 |
+/* ed.onPreProcess.add(function(ed, o) {
|
|
| 9674 |
+ each(ed.dom.select('br', o.node), function(n) {
|
|
| 9675 |
+ var p = n.parentNode; |
|
| 9676 |
+ |
|
| 9677 |
+ // Replace <p><br /></p> with <p> </p> |
|
| 9678 |
+ if (p && p.nodeName == 'p' && (p.childNodes.length == 1 || p.lastChild == n)) {
|
|
| 9679 |
+ p.replaceChild(ed.getDoc().createTextNode('\u00a0'), n);
|
|
| 9680 |
+ } |
|
| 9681 |
+ }); |
|
| 9682 |
+ });*/ |
|
| 9683 |
+ |
|
| 9684 |
+ ed.onKeyPress.add(function(ed, e) {
|
|
| 9685 |
+ if (e.keyCode == 13 && !e.shiftKey) {
|
|
| 9686 |
+ if (!t.insertPara(e)) |
|
| 9687 |
+ Event.cancel(e); |
|
| 9688 |
+ } |
|
| 9689 |
+ }); |
|
| 9690 |
+ |
|
| 9691 |
+ if (isGecko) {
|
|
| 9692 |
+ ed.onKeyDown.add(function(ed, e) {
|
|
| 9693 |
+ if ((e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) |
|
| 9694 |
+ t.backspaceDelete(e, e.keyCode == 8); |
|
| 9695 |
+ }); |
|
| 9696 |
+ } |
|
| 9697 |
+ } |
|
| 9698 |
+ |
|
| 9699 |
+ function ren(rn, na) {
|
|
| 9700 |
+ var ne = ed.dom.create(na); |
|
| 9701 |
+ |
|
| 9702 |
+ each(rn.attributes, function(a) {
|
|
| 9703 |
+ if (a.specified && a.nodeValue) |
|
| 9704 |
+ ne.setAttribute(a.nodeName.toLowerCase(), a.nodeValue); |
|
| 9705 |
+ }); |
|
| 9706 |
+ |
|
| 9707 |
+ each(rn.childNodes, function(n) {
|
|
| 9708 |
+ ne.appendChild(n.cloneNode(true)); |
|
| 9709 |
+ }); |
|
| 9710 |
+ |
|
| 9711 |
+ rn.parentNode.replaceChild(ne, rn); |
|
| 9712 |
+ |
|
| 9713 |
+ return ne; |
|
| 9714 |
+ }; |
|
| 9715 |
+ |
|
| 9716 |
+ // Replaces IE:s auto generated paragraphs with the specified element name |
|
| 9717 |
+ if (isIE && s.element != 'P') {
|
|
| 9718 |
+ ed.onKeyPress.add(function(ed, e) {
|
|
| 9719 |
+ t.lastElm = ed.selection.getNode().nodeName; |
|
| 9720 |
+ }); |
|
| 9721 |
+ |
|
| 9722 |
+ ed.onKeyUp.add(function(ed, e) {
|
|
| 9723 |
+ var bl, sel = ed.selection, n = sel.getNode(), b = ed.getBody(); |
|
| 9724 |
+ |
|
| 9725 |
+ if (b.childNodes.length === 1 && n.nodeName == 'P') {
|
|
| 9726 |
+ n = ren(n, s.element); |
|
| 9727 |
+ sel.select(n); |
|
| 9728 |
+ sel.collapse(); |
|
| 9729 |
+ ed.nodeChanged(); |
|
| 9730 |
+ } else if (e.keyCode == 13 && !e.shiftKey && t.lastElm != 'P') {
|
|
| 9731 |
+ bl = ed.dom.getParent(n, 'P'); |
|
| 9732 |
+ |
|
| 9733 |
+ if (bl) {
|
|
| 9734 |
+ ren(bl, s.element); |
|
| 9735 |
+ ed.nodeChanged(); |
|
| 9736 |
+ } |
|
| 9737 |
+ } |
|
| 9738 |
+ }); |
|
| 9739 |
+ } |
|
| 9740 |
+ }, |
|
| 9741 |
+ |
|
| 9742 |
+ find : function(n, t, s) {
|
|
| 9743 |
+ var ed = this.editor, w = ed.getDoc().createTreeWalker(n, 4, null, false), c = -1; |
|
| 9744 |
+ |
|
| 9745 |
+ while (n = w.nextNode()) {
|
|
| 9746 |
+ c++; |
|
| 9747 |
+ |
|
| 9748 |
+ // Index by node |
|
| 9749 |
+ if (t == 0 && n == s) |
|
| 9750 |
+ return c; |
|
| 9751 |
+ |
|
| 9752 |
+ // Node by index |
|
| 9753 |
+ if (t == 1 && c == s) |
|
| 9754 |
+ return n; |
|
| 9755 |
+ } |
|
| 9756 |
+ |
|
| 9757 |
+ return -1; |
|
| 9758 |
+ }, |
|
| 9759 |
+ |
|
| 9760 |
+ forceRoots : function(ed, e) {
|
|
| 9761 |
+ var t = this, ed = t.editor, b = ed.getBody(), d = ed.getDoc(), se = ed.selection, s = se.getSel(), r = se.getRng(), si = -2, ei, so, eo, tr, c = -0xFFFFFF; |
|
| 9762 |
+ var nx, bl, bp, sp, le, nl = b.childNodes, i; |
|
| 9763 |
+ |
|
| 9764 |
+ // Fix for bug #1863847 |
|
| 9765 |
+ if (e && e.keyCode == 13) |
|
| 9766 |
+ return true; |
|
| 9767 |
+ |
|
| 9768 |
+ // Wrap non blocks into blocks |
|
| 9769 |
+ for (i = nl.length - 1; i >= 0; i--) {
|
|
| 9770 |
+ nx = nl[i]; |
|
| 9771 |
+ |
|
| 9772 |
+ // Is text or non block element |
|
| 9773 |
+ if (nx.nodeType == 3 || (!t.dom.isBlock(nx) && nx.nodeType != 8)) {
|
|
| 9774 |
+ if (!bl) {
|
|
| 9775 |
+ // Create new block but ignore whitespace |
|
| 9776 |
+ if (nx.nodeType != 3 || /[^\s]/g.test(nx.nodeValue)) {
|
|
| 9777 |
+ // Store selection |
|
| 9778 |
+ if (si == -2 && r) {
|
|
| 9779 |
+ if (!isIE) {
|
|
| 9780 |
+ // If element is inside body, might not be the case in contentEdiable mode |
|
| 9781 |
+ if (ed.dom.getParent(r.startContainer, function(e) {return e === b;})) {
|
|
| 9782 |
+ so = r.startOffset; |
|
| 9783 |
+ eo = r.endOffset; |
|
| 9784 |
+ si = t.find(b, 0, r.startContainer); |
|
| 9785 |
+ ei = t.find(b, 0, r.endContainer); |
|
| 9786 |
+ } |
|
| 9787 |
+ } else {
|
|
| 9788 |
+ tr = d.body.createTextRange(); |
|
| 9789 |
+ tr.moveToElementText(b); |
|
| 9790 |
+ tr.collapse(1); |
|
| 9791 |
+ bp = tr.move('character', c) * -1;
|
|
| 9792 |
+ |
|
| 9793 |
+ tr = r.duplicate(); |
|
| 9794 |
+ tr.collapse(1); |
|
| 9795 |
+ sp = tr.move('character', c) * -1;
|
|
| 9796 |
+ |
|
| 9797 |
+ tr = r.duplicate(); |
|
| 9798 |
+ tr.collapse(0); |
|
| 9799 |
+ le = (tr.move('character', c) * -1) - sp;
|
|
| 9800 |
+ |
|
| 9801 |
+ si = sp - bp; |
|
| 9802 |
+ ei = le; |
|
| 9803 |
+ } |
|
| 9804 |
+ } |
|
| 9805 |
+ |
|
| 9806 |
+ bl = ed.dom.create(ed.settings.forced_root_block); |
|
| 9807 |
+ bl.appendChild(nx.cloneNode(1)); |
|
| 9808 |
+ nx.parentNode.replaceChild(bl, nx); |
|
| 9809 |
+ } |
|
| 9810 |
+ } else {
|
|
| 9811 |
+ if (bl.hasChildNodes()) |
|
| 9812 |
+ bl.insertBefore(nx, bl.firstChild); |
|
| 9813 |
+ else |
|
| 9814 |
+ bl.appendChild(nx); |
|
| 9815 |
+ } |
|
| 9816 |
+ } else |
|
| 9817 |
+ bl = null; // Time to create new block |
|
| 9818 |
+ } |
|
| 9819 |
+ |
|
| 9820 |
+ // Restore selection |
|
| 9821 |
+ if (si != -2) {
|
|
| 9822 |
+ if (!isIE) {
|
|
| 9823 |
+ bl = b.getElementsByTagName(ed.settings.element)[0]; |
|
| 9824 |
+ r = d.createRange(); |
|
| 9825 |
+ |
|
| 9826 |
+ // Select last location or generated block |
|
| 9827 |
+ if (si != -1) |
|
| 9828 |
+ r.setStart(t.find(b, 1, si), so); |
|
| 9829 |
+ else |
|
| 9830 |
+ r.setStart(bl, 0); |
|
| 9831 |
+ |
|
| 9832 |
+ // Select last location or generated block |
|
| 9833 |
+ if (ei != -1) |
|
| 9834 |
+ r.setEnd(t.find(b, 1, ei), eo); |
|
| 9835 |
+ else |
|
| 9836 |
+ r.setEnd(bl, 0); |
|
| 9837 |
+ |
|
| 9838 |
+ if (s) {
|
|
| 9839 |
+ s.removeAllRanges(); |
|
| 9840 |
+ s.addRange(r); |
|
| 9841 |
+ } |
|
| 9842 |
+ } else {
|
|
| 9843 |
+ try {
|
|
| 9844 |
+ r = s.createRange(); |
|
| 9845 |
+ r.moveToElementText(b); |
|
| 9846 |
+ r.collapse(1); |
|
| 9847 |
+ r.moveStart('character', si);
|
|
| 9848 |
+ r.moveEnd('character', ei);
|
|
| 9849 |
+ r.select(); |
|
| 9850 |
+ } catch (ex) {
|
|
| 9851 |
+ // Ignore |
|
| 9852 |
+ } |
|
| 9853 |
+ } |
|
| 9854 |
+ } |
|
| 9855 |
+ }, |
|
| 9856 |
+ |
|
| 9857 |
+ getParentBlock : function(n) {
|
|
| 9858 |
+ var d = this.dom; |
|
| 9859 |
+ |
|
| 9860 |
+ return d.getParent(n, d.isBlock); |
|
| 9861 |
+ }, |
|
| 9862 |
+ |
|
| 9863 |
+ insertPara : function(e) {
|
|
| 9864 |
+ var t = this, ed = t.editor, dom = ed.dom, d = ed.getDoc(), se = ed.settings, s = ed.selection.getSel(), r = s.getRangeAt(0), b = d.body; |
|
| 9865 |
+ var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n, vp = dom.getViewPort(ed.getWin()), y, ch; |
|
| 9866 |
+ |
|
| 9867 |
+ function isEmpty(n) {
|
|
| 9868 |
+ n = n.innerHTML; |
|
| 9869 |
+ n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars |
|
| 9870 |
+ n = n.replace(/<[^>]+>/g, ''); // Remove all tags |
|
| 9871 |
+ |
|
| 9872 |
+ return n.replace(/[ \t\r\n]+/g, '') == ''; |
|
| 9873 |
+ }; |
|
| 9874 |
+ |
|
| 9875 |
+ // If root blocks are forced then use Operas default behavior since it's really good |
|
| 9876 |
+// Removed due to bug: #1853816 |
|
| 9877 |
+// if (se.forced_root_block && isOpera) |
|
| 9878 |
+// return true; |
|
| 9879 |
+ |
|
| 9880 |
+ // Setup before range |
|
| 9881 |
+ rb = d.createRange(); |
|
| 9882 |
+ |
|
| 9883 |
+ // If is before the first block element and in body, then move it into first block element |
|
| 9884 |
+ rb.setStart(s.anchorNode, s.anchorOffset); |
|
| 9885 |
+ rb.collapse(true); |
|
| 9886 |
+ |
|
| 9887 |
+ // Setup after range |
|
| 9888 |
+ ra = d.createRange(); |
|
| 9889 |
+ |
|
| 9890 |
+ // If is before the first block element and in body, then move it into first block element |
|
| 9891 |
+ ra.setStart(s.focusNode, s.focusOffset); |
|
| 9892 |
+ ra.collapse(true); |
|
| 9893 |
+ |
|
| 9894 |
+ // Setup start/end points |
|
| 9895 |
+ dir = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0; |
|
| 9896 |
+ sn = dir ? s.anchorNode : s.focusNode; |
|
| 9897 |
+ so = dir ? s.anchorOffset : s.focusOffset; |
|
| 9898 |
+ en = dir ? s.focusNode : s.anchorNode; |
|
| 9899 |
+ eo = dir ? s.focusOffset : s.anchorOffset; |
|
| 9900 |
+ |
|
| 9901 |
+ // If selection is in empty table cell |
|
| 9902 |
+ if (sn === en && /^(TD|TH)$/.test(sn.nodeName)) {
|
|
| 9903 |
+ dom.remove(sn.firstChild); // Remove BR |
|
| 9904 |
+ |
|
| 9905 |
+ // Create two new block elements |
|
| 9906 |
+ ed.dom.add(sn, se.element, null, '<br />'); |
|
| 9907 |
+ aft = ed.dom.add(sn, se.element, null, '<br />'); |
|
| 9908 |
+ |
|
| 9909 |
+ // Move caret into the last one |
|
| 9910 |
+ r = d.createRange(); |
|
| 9911 |
+ r.selectNodeContents(aft); |
|
| 9912 |
+ r.collapse(1); |
|
| 9913 |
+ ed.selection.setRng(r); |
|
| 9914 |
+ |
|
| 9915 |
+ return false; |
|
| 9916 |
+ } |
|
| 9917 |
+ |
|
| 9918 |
+ // If the caret is in an invalid location in FF we need to move it into the first block |
|
| 9919 |
+ if (sn == b && en == b && b.firstChild && ed.dom.isBlock(b.firstChild)) {
|
|
| 9920 |
+ sn = en = sn.firstChild; |
|
| 9921 |
+ so = eo = 0; |
|
| 9922 |
+ rb = d.createRange(); |
|
| 9923 |
+ rb.setStart(sn, 0); |
|
| 9924 |
+ ra = d.createRange(); |
|
| 9925 |
+ ra.setStart(en, 0); |
|
| 9926 |
+ } |
|
| 9927 |
+ |
|
| 9928 |
+ // Never use body as start or end node |
|
| 9929 |
+ sn = sn.nodeName == "HTML" ? d.body : sn; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes |
|
| 9930 |
+ sn = sn.nodeName == "BODY" ? sn.firstChild : sn; |
|
| 9931 |
+ en = en.nodeName == "HTML" ? d.body : en; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes |
|
| 9932 |
+ en = en.nodeName == "BODY" ? en.firstChild : en; |
|
| 9933 |
+ |
|
| 9934 |
+ // Get start and end blocks |
|
| 9935 |
+ sb = t.getParentBlock(sn); |
|
| 9936 |
+ eb = t.getParentBlock(en); |
|
| 9937 |
+ bn = sb ? sb.nodeName : se.element; // Get block name to create |
|
| 9938 |
+ |
|
| 9939 |
+ // Return inside list use default browser behavior |
|
| 9940 |
+ if (t.dom.getParent(sb, function(n) { return /OL|UL|PRE/.test(n.nodeName); }))
|
|
| 9941 |
+ return true; |
|
| 9942 |
+ |
|
| 9943 |
+ // If caption or absolute layers then always generate new blocks within |
|
| 9944 |
+ if (sb && (sb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(sb.style.position))) {
|
|
| 9945 |
+ bn = se.element; |
|
| 9946 |
+ sb = null; |
|
| 9947 |
+ } |
|
| 9948 |
+ |
|
| 9949 |
+ // If caption or absolute layers then always generate new blocks within |
|
| 9950 |
+ if (eb && (eb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(eb.style.position))) {
|
|
| 9951 |
+ bn = se.element; |
|
| 9952 |
+ eb = null; |
|
| 9953 |
+ } |
|
| 9954 |
+ |
|
| 9955 |
+ // Use P instead |
|
| 9956 |
+ if (/(TD|TABLE|TH|CAPTION)/.test(bn) || (sb && bn == "DIV" && /left|right/gi.test(sb.style.cssFloat))) {
|
|
| 9957 |
+ bn = se.element; |
|
| 9958 |
+ sb = eb = null; |
|
| 9959 |
+ } |
|
| 9960 |
+ |
|
| 9961 |
+ // Setup new before and after blocks |
|
| 9962 |
+ bef = (sb && sb.nodeName == bn) ? sb.cloneNode(0) : ed.dom.create(bn); |
|
| 9963 |
+ aft = (eb && eb.nodeName == bn) ? eb.cloneNode(0) : ed.dom.create(bn); |
|
| 9964 |
+ |
|
| 9965 |
+ // Remove id from after clone |
|
| 9966 |
+ aft.removeAttribute('id');
|
|
| 9967 |
+ |
|
| 9968 |
+ // Is header and cursor is at the end, then force paragraph under |
|
| 9969 |
+ if (/^(H[1-6])$/.test(bn) && sn.nodeValue && so == sn.nodeValue.length) |
|
| 9970 |
+ aft = ed.dom.create(se.element); |
|
| 9971 |
+ |
|
| 9972 |
+ // Find start chop node |
|
| 9973 |
+ n = sc = sn; |
|
| 9974 |
+ do {
|
|
| 9975 |
+ if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName)) |
|
| 9976 |
+ break; |
|
| 9977 |
+ |
|
| 9978 |
+ sc = n; |
|
| 9979 |
+ } while ((n = n.previousSibling ? n.previousSibling : n.parentNode)); |
|
| 9980 |
+ |
|
| 9981 |
+ // Find end chop node |
|
| 9982 |
+ n = ec = en; |
|
| 9983 |
+ do {
|
|
| 9984 |
+ if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName)) |
|
| 9985 |
+ break; |
|
| 9986 |
+ |
|
| 9987 |
+ ec = n; |
|
| 9988 |
+ } while ((n = n.nextSibling ? n.nextSibling : n.parentNode)); |
|
| 9989 |
+ |
|
| 9990 |
+ // Place first chop part into before block element |
|
| 9991 |
+ if (sc.nodeName == bn) |
|
| 9992 |
+ rb.setStart(sc, 0); |
|
| 9993 |
+ else |
|
| 9994 |
+ rb.setStartBefore(sc); |
|
| 9995 |
+ |
|
| 9996 |
+ rb.setEnd(sn, so); |
|
| 9997 |
+ bef.appendChild(rb.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
|
|
| 9998 |
+ |
|
| 9999 |
+ // Place secnd chop part within new block element |
|
| 10000 |
+ try {
|
|
| 10001 |
+ ra.setEndAfter(ec); |
|
| 10002 |
+ } catch(ex) {
|
|
| 10003 |
+ //console.debug(s.focusNode, s.focusOffset); |
|
| 10004 |
+ } |
|
| 10005 |
+ |
|
| 10006 |
+ ra.setStart(en, eo); |
|
| 10007 |
+ aft.appendChild(ra.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
|
|
| 10008 |
+ |
|
| 10009 |
+ // Create range around everything |
|
| 10010 |
+ r = d.createRange(); |
|
| 10011 |
+ if (!sc.previousSibling && sc.parentNode.nodeName == bn) {
|
|
| 10012 |
+ r.setStartBefore(sc.parentNode); |
|
| 10013 |
+ } else {
|
|
| 10014 |
+ if (rb.startContainer.nodeName == bn && rb.startOffset == 0) |
|
| 10015 |
+ r.setStartBefore(rb.startContainer); |
|
| 10016 |
+ else |
|
| 10017 |
+ r.setStart(rb.startContainer, rb.startOffset); |
|
| 10018 |
+ } |
|
| 10019 |
+ |
|
| 10020 |
+ if (!ec.nextSibling && ec.parentNode.nodeName == bn) |
|
| 10021 |
+ r.setEndAfter(ec.parentNode); |
|
| 10022 |
+ else |
|
| 10023 |
+ r.setEnd(ra.endContainer, ra.endOffset); |
|
| 10024 |
+ |
|
| 10025 |
+ // Delete and replace it with new block elements |
|
| 10026 |
+ r.deleteContents(); |
|
| 10027 |
+ |
|
| 10028 |
+ if (isOpera) |
|
| 10029 |
+ ed.getWin().scrollTo(0, vp.y); |
|
| 10030 |
+ |
|
| 10031 |
+ // Never wrap blocks in blocks |
|
| 10032 |
+ if (bef.firstChild && bef.firstChild.nodeName == bn) |
|
| 10033 |
+ bef.innerHTML = bef.firstChild.innerHTML; |
|
| 10034 |
+ |
|
| 10035 |
+ if (aft.firstChild && aft.firstChild.nodeName == bn) |
|
| 10036 |
+ aft.innerHTML = aft.firstChild.innerHTML; |
|
| 10037 |
+ |
|
| 10038 |
+ // Padd empty blocks |
|
| 10039 |
+ if (isEmpty(bef)) |
|
| 10040 |
+ bef.innerHTML = '<br />'; |
|
| 10041 |
+ |
|
| 10042 |
+ if (isEmpty(aft)) |
|
| 10043 |
+ aft.innerHTML = isOpera ? ' ' : '<br />'; // Extra space for Opera so that the caret can move there |
|
| 10044 |
+ |
|
| 10045 |
+ // Opera needs this one backwards |
|
| 10046 |
+ if (isOpera) {
|
|
| 10047 |
+ r.insertNode(bef); |
|
| 10048 |
+ r.insertNode(aft); |
|
| 10049 |
+ } else {
|
|
| 10050 |
+ r.insertNode(aft); |
|
| 10051 |
+ r.insertNode(bef); |
|
| 10052 |
+ } |
|
| 10053 |
+ |
|
| 10054 |
+ // Normalize |
|
| 10055 |
+ aft.normalize(); |
|
| 10056 |
+ bef.normalize(); |
|
| 10057 |
+ |
|
| 10058 |
+ function first(n) {
|
|
| 10059 |
+ return d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() || n; |
|
| 10060 |
+ }; |
|
| 10061 |
+ |
|
| 10062 |
+ // Move cursor and scroll into view |
|
| 10063 |
+ r = d.createRange(); |
|
| 10064 |
+ r.selectNodeContents(isGecko ? first(aft) : aft); |
|
| 10065 |
+ r.collapse(1); |
|
| 10066 |
+ s.removeAllRanges(); |
|
| 10067 |
+ s.addRange(r); |
|
| 10068 |
+ |
|
| 10069 |
+ // scrollIntoView seems to scroll the parent window in most browsers now including FF 3.0b4 so it's time to stop using it and do it our selfs |
|
| 10070 |
+ y = ed.dom.getPos(aft).y; |
|
| 10071 |
+ ch = aft.clientHeight; |
|
| 10072 |
+ |
|
| 10073 |
+ // Is element within viewport |
|
| 10074 |
+ if (y < vp.y || y + ch > vp.y + vp.h) {
|
|
| 10075 |
+ ed.getWin().scrollTo(0, y < vp.y ? y : y - vp.h + ch); |
|
| 10076 |
+ //console.debug('SCROLL!', 'vp.y: ' + vp.y, 'y' + y, 'vp.h' + vp.h, 'clientHeight' + aft.clientHeight, 'yyy: ' + (y < vp.y ? y : y - vp.h + aft.clientHeight));
|
|
| 10077 |
+ } |
|
| 10078 |
+ |
|
| 10079 |
+ return false; |
|
| 10080 |
+ }, |
|
| 10081 |
+ |
|
| 10082 |
+ backspaceDelete : function(e, bs) {
|
|
| 10083 |
+ var t = this, ed = t.editor, b = ed.getBody(), n, se = ed.selection, r = se.getRng(), sc = r.startContainer, n, w, tn; |
|
| 10084 |
+ |
|
| 10085 |
+ // The caret sometimes gets stuck in Gecko if you delete empty paragraphs |
|
| 10086 |
+ // This workaround removes the element by hand and moves the caret to the previous element |
|
| 10087 |
+ if (sc && ed.dom.isBlock(sc) && !/^(TD|TH)$/.test(sc.nodeName) && bs) {
|
|
| 10088 |
+ if (sc.childNodes.length == 0 || (sc.childNodes.length == 1 && sc.firstChild.nodeName == 'BR')) {
|
|
| 10089 |
+ // Find previous block element |
|
| 10090 |
+ n = sc; |
|
| 10091 |
+ while ((n = n.previousSibling) && !ed.dom.isBlock(n)) ; |
|
| 10092 |
+ |
|
| 10093 |
+ if (n) {
|
|
| 10094 |
+ if (sc != b.firstChild) {
|
|
| 10095 |
+ // Find last text node |
|
| 10096 |
+ w = ed.dom.doc.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false); |
|
| 10097 |
+ while (tn = w.nextNode()) |
|
| 10098 |
+ n = tn; |
|
| 10099 |
+ |
|
| 10100 |
+ // Place caret at the end of last text node |
|
| 10101 |
+ r = ed.getDoc().createRange(); |
|
| 10102 |
+ r.setStart(n, n.nodeValue ? n.nodeValue.length : 0); |
|
| 10103 |
+ r.setEnd(n, n.nodeValue ? n.nodeValue.length : 0); |
|
| 10104 |
+ se.setRng(r); |
|
| 10105 |
+ |
|
| 10106 |
+ // Remove the target container |
|
| 10107 |
+ ed.dom.remove(sc); |
|
| 10108 |
+ } |
|
| 10109 |
+ |
|
| 10110 |
+ return Event.cancel(e); |
|
| 10111 |
+ } |
|
| 10112 |
+ } |
|
| 10113 |
+ } |
|
| 10114 |
+ |
|
| 10115 |
+ // Gecko generates BR elements here and there, we don't like those so lets remove them |
|
| 10116 |
+ function handler(e) {
|
|
| 10117 |
+ e = e.target; |
|
| 10118 |
+ |
|
| 10119 |
+ // A new BR was created in a block element, remove it |
|
| 10120 |
+ if (e && e.parentNode && e.nodeName == 'BR' && (n = t.getParentBlock(e))) {
|
|
| 10121 |
+ Event.remove(b, 'DOMNodeInserted', handler); |
|
| 10122 |
+ |
|
| 10123 |
+ // Only remove BR elements that got inserted in the middle of the text |
|
| 10124 |
+ if (e.previousSibling || e.nextSibling) |
|
| 10125 |
+ ed.dom.remove(e); |
|
| 10126 |
+ } |
|
| 10127 |
+ }; |
|
| 10128 |
+ |
|
| 10129 |
+ // Listen for new nodes |
|
| 10130 |
+ Event._add(b, 'DOMNodeInserted', handler); |
|
| 10131 |
+ |
|
| 10132 |
+ // Remove listener |
|
| 10133 |
+ window.setTimeout(function() {
|
|
| 10134 |
+ Event._remove(b, 'DOMNodeInserted', handler); |
|
| 10135 |
+ }, 1); |
|
| 10136 |
+ } |
|
| 10137 |
+ }); |
|
| 10138 |
+})(); |
|
| 10139 |
+ |
|
| 10140 |
+/* file:jscripts/tiny_mce/classes/ControlManager.js */ |
|
| 10141 |
+ |
|
| 10142 |
+(function() {
|
|
| 10143 |
+ // Shorten names |
|
| 10144 |
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, extend = tinymce.extend; |
|
| 10145 |
+ |
|
| 10146 |
+ tinymce.create('tinymce.ControlManager', {
|
|
| 10147 |
+ ControlManager : function(ed, s) {
|
|
| 10148 |
+ var t = this, i; |
|
| 10149 |
+ |
|
| 10150 |
+ s = s || {};
|
|
| 10151 |
+ t.editor = ed; |
|
| 10152 |
+ t.controls = {};
|
|
| 10153 |
+ t.onAdd = new tinymce.util.Dispatcher(t); |
|
| 10154 |
+ t.onPostRender = new tinymce.util.Dispatcher(t); |
|
| 10155 |
+ t.prefix = s.prefix || ed.id + '_'; |
|
| 10156 |
+ t._cls = {};
|
|
| 10157 |
+ |
|
| 10158 |
+ t.onPostRender.add(function() {
|
|
| 10159 |
+ each(t.controls, function(c) {
|
|
| 10160 |
+ c.postRender(); |
|
| 10161 |
+ }); |
|
| 10162 |
+ }); |
|
| 10163 |
+ }, |
|
| 10164 |
+ |
|
| 10165 |
+ get : function(id) {
|
|
| 10166 |
+ return this.controls[this.prefix + id] || this.controls[id]; |
|
| 10167 |
+ }, |
|
| 10168 |
+ |
|
| 10169 |
+ setActive : function(id, s) {
|
|
| 10170 |
+ var c = null; |
|
| 10171 |
+ |
|
| 10172 |
+ if (c = this.get(id)) |
|
| 10173 |
+ c.setActive(s); |
|
| 10174 |
+ |
|
| 10175 |
+ return c; |
|
| 10176 |
+ }, |
|
| 10177 |
+ |
|
| 10178 |
+ setDisabled : function(id, s) {
|
|
| 10179 |
+ var c = null; |
|
| 10180 |
+ |
|
| 10181 |
+ if (c = this.get(id)) |
|
| 10182 |
+ c.setDisabled(s); |
|
| 10183 |
+ |
|
| 10184 |
+ return c; |
|
| 10185 |
+ }, |
|
| 10186 |
+ |
|
| 10187 |
+ add : function(c) {
|
|
| 10188 |
+ var t = this; |
|
| 10189 |
+ |
|
| 10190 |
+ if (c) {
|
|
| 10191 |
+ t.controls[c.id] = c; |
|
| 10192 |
+ t.onAdd.dispatch(c, t); |
|
| 10193 |
+ } |
|
| 10194 |
+ |
|
| 10195 |
+ return c; |
|
| 10196 |
+ }, |
|
| 10197 |
+ |
|
| 10198 |
+ createControl : function(n) {
|
|
| 10199 |
+ var c, t = this, ed = t.editor; |
|
| 10200 |
+ |
|
| 10201 |
+ each(ed.plugins, function(p) {
|
|
| 10202 |
+ if (p.createControl) {
|
|
| 10203 |
+ c = p.createControl(n, t); |
|
| 10204 |
+ |
|
| 10205 |
+ if (c) |
|
| 10206 |
+ return false; |
|
| 10207 |
+ } |
|
| 10208 |
+ }); |
|
| 10209 |
+ |
|
| 10210 |
+ switch (n) {
|
|
| 10211 |
+ case "|": |
|
| 10212 |
+ case "separator": |
|
| 10213 |
+ return t.createSeparator(); |
|
| 10214 |
+ } |
|
| 10215 |
+ |
|
| 10216 |
+ if (!c && ed.buttons && (c = ed.buttons[n])) |
|
| 10217 |
+ return t.createButton(n, c); |
|
| 10218 |
+ |
|
| 10219 |
+ return t.add(c); |
|
| 10220 |
+ }, |
|
| 10221 |
+ |
|
| 10222 |
+ createDropMenu : function(id, s, cc) {
|
|
| 10223 |
+ var t = this, ed = t.editor, c, bm, v, cls; |
|
| 10224 |
+ |
|
| 10225 |
+ s = extend({
|
|
| 10226 |
+ 'class' : 'mceDropDown', |
|
| 10227 |
+ constrain : ed.settings.constrain_menus |
|
| 10228 |
+ }, s); |
|
| 10229 |
+ |
|
| 10230 |
+ s['class'] = s['class'] + ' ' + ed.getParam('skin') + 'Skin';
|
|
| 10231 |
+ if (v = ed.getParam('skin_variant'))
|
|
| 10232 |
+ s['class'] += ' ' + ed.getParam('skin') + 'Skin' + v.substring(0, 1).toUpperCase() + v.substring(1);
|
|
| 10233 |
+ |
|
| 10234 |
+ id = t.prefix + id; |
|
| 10235 |
+ cls = cc || t._cls.dropmenu || tinymce.ui.DropMenu; |
|
| 10236 |
+ c = t.controls[id] = new cls(id, s); |
|
| 10237 |
+ c.onAddItem.add(function(c, o) {
|
|
| 10238 |
+ var s = o.settings; |
|
| 10239 |
+ |
|
| 10240 |
+ s.title = ed.getLang(s.title, s.title); |
|
| 10241 |
+ |
|
| 10242 |
+ if (!s.onclick) {
|
|
| 10243 |
+ s.onclick = function(v) {
|
|
| 10244 |
+ ed.execCommand(s.cmd, s.ui || false, s.value); |
|
| 10245 |
+ }; |
|
| 10246 |
+ } |
|
| 10247 |
+ }); |
|
| 10248 |
+ |
|
| 10249 |
+ ed.onRemove.add(function() {
|
|
| 10250 |
+ c.destroy(); |
|
| 10251 |
+ }); |
|
| 10252 |
+ |
|
| 10253 |
+ // Fix for bug #1897785, #1898007 |
|
| 10254 |
+ if (tinymce.isIE) {
|
|
| 10255 |
+ c.onShowMenu.add(function() {
|
|
| 10256 |
+ bm = ed.selection.getBookmark(1); |
|
| 10257 |
+ }); |
|
| 10258 |
+ |
|
| 10259 |
+ c.onHideMenu.add(function() {
|
|
| 10260 |
+ if (bm) |
|
| 10261 |
+ ed.selection.moveToBookmark(bm); |
|
| 10262 |
+ }); |
|
| 10263 |
+ } |
|
| 10264 |
+ |
|
| 10265 |
+ return t.add(c); |
|
| 10266 |
+ }, |
|
| 10267 |
+ |
|
| 10268 |
+ createListBox : function(id, s, cc) {
|
|
| 10269 |
+ var t = this, ed = t.editor, cmd, c, cls; |
|
| 10270 |
+ |
|
| 10271 |
+ if (t.get(id)) |
|
| 10272 |
+ return null; |
|
| 10273 |
+ |
|
| 10274 |
+ s.title = ed.translate(s.title); |
|
| 10275 |
+ s.scope = s.scope || ed; |
|
| 10276 |
+ |
|
| 10277 |
+ if (!s.onselect) {
|
|
| 10278 |
+ s.onselect = function(v) {
|
|
| 10279 |
+ ed.execCommand(s.cmd, s.ui || false, v || s.value); |
|
| 10280 |
+ }; |
|
| 10281 |
+ } |
|
| 10282 |
+ |
|
| 10283 |
+ s = extend({
|
|
| 10284 |
+ title : s.title, |
|
| 10285 |
+ 'class' : 'mce_' + id, |
|
| 10286 |
+ scope : s.scope, |
|
| 10287 |
+ control_manager : t |
|
| 10288 |
+ }, s); |
|
| 10289 |
+ |
|
| 10290 |
+ id = t.prefix + id; |
|
| 10291 |
+ |
|
| 10292 |
+ if (ed.settings.use_native_selects) |
|
| 10293 |
+ c = new tinymce.ui.NativeListBox(id, s); |
|
| 10294 |
+ else {
|
|
| 10295 |
+ cls = cc || t._cls.listbox || tinymce.ui.ListBox; |
|
| 10296 |
+ c = new cls(id, s); |
|
| 10297 |
+ } |
|
| 10298 |
+ |
|
| 10299 |
+ t.controls[id] = c; |
|
| 10300 |
+ |
|
| 10301 |
+ // Fix focus problem in Safari |
|
| 10302 |
+ if (tinymce.isWebKit) {
|
|
| 10303 |
+ c.onPostRender.add(function(c, n) {
|
|
| 10304 |
+ // Store bookmark on mousedown |
|
| 10305 |
+ Event.add(n, 'mousedown', function() {
|
|
| 10306 |
+ ed.bookmark = ed.selection.getBookmark('simple');
|
|
| 10307 |
+ }); |
|
| 10308 |
+ |
|
| 10309 |
+ // Restore on focus, since it might be lost |
|
| 10310 |
+ Event.add(n, 'focus', function() {
|
|
| 10311 |
+ ed.selection.moveToBookmark(ed.bookmark); |
|
| 10312 |
+ ed.bookmark = null; |
|
| 10313 |
+ }); |
|
| 10314 |
+ }); |
|
| 10315 |
+ } |
|
| 10316 |
+ |
|
| 10317 |
+ if (c.hideMenu) |
|
| 10318 |
+ ed.onMouseDown.add(c.hideMenu, c); |
|
| 10319 |
+ |
|
| 10320 |
+ return t.add(c); |
|
| 10321 |
+ }, |
|
| 10322 |
+ |
|
| 10323 |
+ createButton : function(id, s, cc) {
|
|
| 10324 |
+ var t = this, ed = t.editor, o, c, cls; |
|
| 10325 |
+ |
|
| 10326 |
+ if (t.get(id)) |
|
| 10327 |
+ return null; |
|
| 10328 |
+ |
|
| 10329 |
+ s.title = ed.translate(s.title); |
|
| 10330 |
+ s.label = ed.translate(s.label); |
|
| 10331 |
+ s.scope = s.scope || ed; |
|
| 10332 |
+ |
|
| 10333 |
+ if (!s.onclick && !s.menu_button) {
|
|
| 10334 |
+ s.onclick = function() {
|
|
| 10335 |
+ ed.execCommand(s.cmd, s.ui || false, s.value); |
|
| 10336 |
+ }; |
|
| 10337 |
+ } |
|
| 10338 |
+ |
|
| 10339 |
+ s = extend({
|
|
| 10340 |
+ title : s.title, |
|
| 10341 |
+ 'class' : 'mce_' + id, |
|
| 10342 |
+ unavailable_prefix : ed.getLang('unavailable', ''),
|
|
| 10343 |
+ scope : s.scope, |
|
| 10344 |
+ control_manager : t |
|
| 10345 |
+ }, s); |
|
| 10346 |
+ |
|
| 10347 |
+ id = t.prefix + id; |
|
| 10348 |
+ |
|
| 10349 |
+ if (s.menu_button) {
|
|
| 10350 |
+ cls = cc || t._cls.menubutton || tinymce.ui.MenuButton; |
|
| 10351 |
+ c = new cls(id, s); |
|
| 10352 |
+ ed.onMouseDown.add(c.hideMenu, c); |
|
| 10353 |
+ } else {
|
|
| 10354 |
+ cls = t._cls.button || tinymce.ui.Button; |
|
| 10355 |
+ c = new cls(id, s); |
|
| 10356 |
+ } |
|
| 10357 |
+ |
|
| 10358 |
+ return t.add(c); |
|
| 10359 |
+ }, |
|
| 10360 |
+ |
|
| 10361 |
+ createMenuButton : function(id, s) {
|
|
| 10362 |
+ s = s || {};
|
|
| 10363 |
+ s.menu_button = 1; |
|
| 10364 |
+ |
|
| 10365 |
+ return this.createButton(id, s); |
|
| 10366 |
+ }, |
|
| 10367 |
+ |
|
| 10368 |
+ createSplitButton : function(id, s, cc) {
|
|
| 10369 |
+ var t = this, ed = t.editor, cmd, c, cls; |
|
| 10370 |
+ |
|
| 10371 |
+ if (t.get(id)) |
|
| 10372 |
+ return null; |
|
| 10373 |
+ |
|
| 10374 |
+ s.title = ed.translate(s.title); |
|
| 10375 |
+ s.scope = s.scope || ed; |
|
| 10376 |
+ |
|
| 10377 |
+ if (!s.onclick) {
|
|
| 10378 |
+ s.onclick = function(v) {
|
|
| 10379 |
+ ed.execCommand(s.cmd, s.ui || false, v || s.value); |
|
| 10380 |
+ }; |
|
| 10381 |
+ } |
|
| 10382 |
+ |
|
| 10383 |
+ if (!s.onselect) {
|
|
| 10384 |
+ s.onselect = function(v) {
|
|
| 10385 |
+ ed.execCommand(s.cmd, s.ui || false, v || s.value); |
|
| 10386 |
+ }; |
|
| 10387 |
+ } |
|
| 10388 |
+ |
|
| 10389 |
+ s = extend({
|
|
| 10390 |
+ title : s.title, |
|
| 10391 |
+ 'class' : 'mce_' + id, |
|
| 10392 |
+ scope : s.scope, |
|
| 10393 |
+ control_manager : t |
|
| 10394 |
+ }, s); |
|
| 10395 |
+ |
|
| 10396 |
+ id = t.prefix + id; |
|
| 10397 |
+ cls = cc || t._cls.splitbutton || tinymce.ui.SplitButton; |
|
| 10398 |
+ c = t.add(new cls(id, s)); |
|
| 10399 |
+ ed.onMouseDown.add(c.hideMenu, c); |
|
| 10400 |
+ |
|
| 10401 |
+ return c; |
|
| 10402 |
+ }, |
|
| 10403 |
+ |
|
| 10404 |
+ createColorSplitButton : function(id, s, cc) {
|
|
| 10405 |
+ var t = this, ed = t.editor, cmd, c, cls, bm; |
|
| 10406 |
+ |
|
| 10407 |
+ if (t.get(id)) |
|
| 10408 |
+ return null; |
|
| 10409 |
+ |
|
| 10410 |
+ s.title = ed.translate(s.title); |
|
| 10411 |
+ s.scope = s.scope || ed; |
|
| 10412 |
+ |
|
| 10413 |
+ if (!s.onclick) {
|
|
| 10414 |
+ s.onclick = function(v) {
|
|
| 10415 |
+ ed.execCommand(s.cmd, s.ui || false, v || s.value); |
|
| 10416 |
+ }; |
|
| 10417 |
+ } |
|
| 10418 |
+ |
|
| 10419 |
+ if (!s.onselect) {
|
|
| 10420 |
+ s.onselect = function(v) {
|
|
| 10421 |
+ ed.execCommand(s.cmd, s.ui || false, v || s.value); |
|
| 10422 |
+ }; |
|
| 10423 |
+ } |
|
| 10424 |
+ |
|
| 10425 |
+ s = extend({
|
|
| 10426 |
+ title : s.title, |
|
| 10427 |
+ 'class' : 'mce_' + id, |
|
| 10428 |
+ 'menu_class' : ed.getParam('skin') + 'Skin',
|
|
| 10429 |
+ scope : s.scope, |
|
| 10430 |
+ more_colors_title : ed.getLang('more_colors')
|
|
| 10431 |
+ }, s); |
|
| 10432 |
+ |
|
| 10433 |
+ id = t.prefix + id; |
|
| 10434 |
+ cls = cc || t._cls.colorsplitbutton || tinymce.ui.ColorSplitButton; |
|
| 10435 |
+ c = new cls(id, s); |
|
| 10436 |
+ ed.onMouseDown.add(c.hideMenu, c); |
|
| 10437 |
+ |
|
| 10438 |
+ // Remove the menu element when the editor is removed |
|
| 10439 |
+ ed.onRemove.add(function() {
|
|
| 10440 |
+ c.destroy(); |
|
| 10441 |
+ }); |
|
| 10442 |
+ |
|
| 10443 |
+ // Fix for bug #1897785, #1898007 |
|
| 10444 |
+ if (tinymce.isIE) {
|
|
| 10445 |
+ c.onShowMenu.add(function() {
|
|
| 10446 |
+ bm = ed.selection.getBookmark(1); |
|
| 10447 |
+ }); |
|
| 10448 |
+ |
|
| 10449 |
+ c.onHideMenu.add(function() {
|
|
| 10450 |
+ if (bm) |
|
| 10451 |
+ ed.selection.moveToBookmark(bm); |
|
| 10452 |
+ }); |
|
| 10453 |
+ } |
|
| 10454 |
+ |
|
| 10455 |
+ return t.add(c); |
|
| 10456 |
+ }, |
|
| 10457 |
+ |
|
| 10458 |
+ createToolbar : function(id, s, cc) {
|
|
| 10459 |
+ var c, t = this, cls; |
|
| 10460 |
+ |
|
| 10461 |
+ id = t.prefix + id; |
|
| 10462 |
+ cls = cc || t._cls.toolbar || tinymce.ui.Toolbar; |
|
| 10463 |
+ c = new cls(id, s); |
|
| 10464 |
+ |
|
| 10465 |
+ if (t.get(id)) |
|
| 10466 |
+ return null; |
|
| 10467 |
+ |
|
| 10468 |
+ return t.add(c); |
|
| 10469 |
+ }, |
|
| 10470 |
+ |
|
| 10471 |
+ createSeparator : function(cc) {
|
|
| 10472 |
+ var cls = cc || this._cls.separator || tinymce.ui.Separator; |
|
| 10473 |
+ |
|
| 10474 |
+ return new cls(); |
|
| 10475 |
+ }, |
|
| 10476 |
+ |
|
| 10477 |
+ setControlType : function(n, c) {
|
|
| 10478 |
+ return this._cls[n.toLowerCase()] = c; |
|
| 10479 |
+ }, |
|
| 10480 |
+ |
|
| 10481 |
+ destroy : function() {
|
|
| 10482 |
+ each(this.controls, function(c) {
|
|
| 10483 |
+ c.destroy(); |
|
| 10484 |
+ }); |
|
| 10485 |
+ |
|
| 10486 |
+ this.controls = null; |
|
| 10487 |
+ } |
|
| 10488 |
+ |
|
| 10489 |
+ }); |
|
| 10490 |
+})(); |
|
| 10491 |
+ |
|
| 10492 |
+/* file:jscripts/tiny_mce/classes/WindowManager.js */ |
|
| 10493 |
+ |
|
| 10494 |
+(function() {
|
|
| 10495 |
+ var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each, isIE = tinymce.isIE, isOpera = tinymce.isOpera; |
|
| 10496 |
+ |
|
| 10497 |
+ tinymce.create('tinymce.WindowManager', {
|
|
| 10498 |
+ WindowManager : function(ed) {
|
|
| 10499 |
+ var t = this; |
|
| 10500 |
+ |
|
| 10501 |
+ t.editor = ed; |
|
| 10502 |
+ t.onOpen = new Dispatcher(t); |
|
| 10503 |
+ t.onClose = new Dispatcher(t); |
|
| 10504 |
+ t.params = {};
|
|
| 10505 |
+ t.features = {};
|
|
| 10506 |
+ }, |
|
| 10507 |
+ |
|
| 10508 |
+ open : function(s, p) {
|
|
| 10509 |
+ var t = this, f = '', x, y, mo = t.editor.settings.dialog_type == 'modal', w, sw, sh, vp = tinymce.DOM.getViewPort(), u; |
|
| 10510 |
+ |
|
| 10511 |
+ // Default some options |
|
| 10512 |
+ s = s || {};
|
|
| 10513 |
+ p = p || {};
|
|
| 10514 |
+ sw = isOpera ? vp.w : screen.width; // Opera uses windows inside the Opera window |
|
| 10515 |
+ sh = isOpera ? vp.h : screen.height; |
|
| 10516 |
+ s.name = s.name || 'mc_' + new Date().getTime(); |
|
| 10517 |
+ s.width = parseInt(s.width || 320); |
|
| 10518 |
+ s.height = parseInt(s.height || 240); |
|
| 10519 |
+ s.resizable = true; |
|
| 10520 |
+ s.left = s.left || parseInt(sw / 2.0) - (s.width / 2.0); |
|
| 10521 |
+ s.top = s.top || parseInt(sh / 2.0) - (s.height / 2.0); |
|
| 10522 |
+ p.inline = false; |
|
| 10523 |
+ p.mce_width = s.width; |
|
| 10524 |
+ p.mce_height = s.height; |
|
| 10525 |
+ p.mce_auto_focus = s.auto_focus; |
|
| 10526 |
+ |
|
| 10527 |
+ if (mo) {
|
|
| 10528 |
+ if (isIE) {
|
|
| 10529 |
+ s.center = true; |
|
| 10530 |
+ s.help = false; |
|
| 10531 |
+ s.dialogWidth = s.width + 'px'; |
|
| 10532 |
+ s.dialogHeight = s.height + 'px'; |
|
| 10533 |
+ s.scroll = s.scrollbars || false; |
|
| 10534 |
+ } |
|
| 10535 |
+ } |
|
| 10536 |
+ |
|
| 10537 |
+ // Build features string |
|
| 10538 |
+ each(s, function(v, k) {
|
|
| 10539 |
+ if (tinymce.is(v, 'boolean')) |
|
| 10540 |
+ v = v ? 'yes' : 'no'; |
|
| 10541 |
+ |
|
| 10542 |
+ if (!/^(name|url)$/.test(k)) {
|
|
| 10543 |
+ if (isIE && mo) |
|
| 10544 |
+ f += (f ? ';' : '') + k + ':' + v; |
|
| 10545 |
+ else |
|
| 10546 |
+ f += (f ? ',' : '') + k + '=' + v; |
|
| 10547 |
+ } |
|
| 10548 |
+ }); |
|
| 10549 |
+ |
|
| 10550 |
+ t.features = s; |
|
| 10551 |
+ t.params = p; |
|
| 10552 |
+ t.onOpen.dispatch(t, s, p); |
|
| 10553 |
+ |
|
| 10554 |
+ u = s.url || s.file; |
|
| 10555 |
+ if (tinymce.relaxedDomain) |
|
| 10556 |
+ u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain;
|
|
| 10557 |
+ |
|
| 10558 |
+ u = tinymce._addVer(u); |
|
| 10559 |
+ |
|
| 10560 |
+ try {
|
|
| 10561 |
+ if (isIE && mo) {
|
|
| 10562 |
+ w = 1; |
|
| 10563 |
+ window.showModalDialog(u, window, f); |
|
| 10564 |
+ } else |
|
| 10565 |
+ w = window.open(u, s.name, f); |
|
| 10566 |
+ } catch (ex) {
|
|
| 10567 |
+ // Ignore |
|
| 10568 |
+ } |
|
| 10569 |
+ |
|
| 10570 |
+ if (!w) |
|
| 10571 |
+ alert(t.editor.getLang('popup_blocked'));
|
|
| 10572 |
+ }, |
|
| 10573 |
+ |
|
| 10574 |
+ close : function(w) {
|
|
| 10575 |
+ w.close(); |
|
| 10576 |
+ this.onClose.dispatch(this); |
|
| 10577 |
+ }, |
|
| 10578 |
+ |
|
| 10579 |
+ createInstance : function(cl, a, b, c, d, e) {
|
|
| 10580 |
+ var f = tinymce.resolve(cl); |
|
| 10581 |
+ |
|
| 10582 |
+ return new f(a, b, c, d, e); |
|
| 10583 |
+ }, |
|
| 10584 |
+ |
|
| 10585 |
+ confirm : function(t, cb, s) {
|
|
| 10586 |
+ cb.call(s || this, confirm(this._decode(this.editor.getLang(t, t)))); |
|
| 10587 |
+ }, |
|
| 10588 |
+ |
|
| 10589 |
+ alert : function(tx, cb, s) {
|
|
| 10590 |
+ var t = this; |
|
| 10591 |
+ |
|
| 10592 |
+ alert(t._decode(t.editor.getLang(tx, tx))); |
|
| 10593 |
+ |
|
| 10594 |
+ if (cb) |
|
| 10595 |
+ cb.call(s || t); |
|
| 10596 |
+ }, |
|
| 10597 |
+ |
|
| 10598 |
+ // Internal functions |
|
| 10599 |
+ |
|
| 10600 |
+ _decode : function(s) {
|
|
| 10601 |
+ return tinymce.DOM.decode(s).replace(/\\n/g, '\n'); |
|
| 10602 |
+ } |
|
| 10603 |
+ |
|
| 10604 |
+ }); |
|
| 10605 |
+}()); |
|
| 0 | 10606 |
\ No newline at end of file |