changeset 543 | dffcbfbc4e59 |
parent 476 | f26a69c40431 |
child 588 | 20484deb89cd |
542:5841df0ab575 | 543:dffcbfbc4e59 |
---|---|
1 |
1 |
2 /* file:jscripts/tiny_mce/classes/tinymce.js */ |
2 /* file:jscripts/tiny_mce/classes/tinymce.js */ |
3 |
3 |
4 var tinymce = { |
4 var tinymce = { |
5 majorVersion : '3', |
5 majorVersion : '3', |
6 minorVersion : '0.3', |
6 minorVersion : '0.8', |
7 releaseDate : '2008-03-03', |
7 releaseDate : '2008-04-30', |
8 |
8 |
9 _init : function() { |
9 _init : function() { |
10 var t = this, ua = navigator.userAgent, i, nl, n, base; |
10 var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p; |
11 |
11 |
12 // Browser checks |
12 // Browser checks |
13 t.isOpera = window.opera && opera.buildNumber; |
13 t.isOpera = w.opera && opera.buildNumber; |
14 t.isWebKit = /WebKit/.test(ua); |
14 t.isWebKit = /WebKit/.test(ua); |
15 t.isOldWebKit = t.isWebKit && !window.getSelection().getRangeAt; |
15 t.isOldWebKit = t.isWebKit && !w.getSelection().getRangeAt; |
16 t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(navigator.appName); |
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); |
17 t.isIE6 = t.isIE && /MSIE [56]/.test(ua); |
18 t.isGecko = !t.isWebKit && /Gecko/.test(ua); |
18 t.isGecko = !t.isWebKit && /Gecko/.test(ua); |
19 t.isMac = ua.indexOf('Mac') != -1; |
19 t.isMac = ua.indexOf('Mac') != -1; |
20 |
20 |
21 // TinyMCE .NET webcontrol might be setting the values for TinyMCE |
21 // TinyMCE .NET webcontrol might be setting the values for TinyMCE |
22 if (window.tinyMCEPreInit) { |
22 if (w.tinyMCEPreInit) { |
23 t.suffix = tinyMCEPreInit.suffix; |
23 t.suffix = tinyMCEPreInit.suffix; |
24 t.baseURL = tinyMCEPreInit.base; |
24 t.baseURL = tinyMCEPreInit.base; |
25 t.query = tinyMCEPreInit.query; |
|
25 return; |
26 return; |
26 } |
27 } |
27 |
28 |
28 // Get suffix and base |
29 // Get suffix and base |
29 t.suffix = ''; |
30 t.suffix = ''; |
30 |
31 |
31 // If base element found, add that infront of baseURL |
32 // If base element found, add that infront of baseURL |
32 nl = document.getElementsByTagName('base'); |
33 nl = d.getElementsByTagName('base'); |
33 for (i=0; i<nl.length; i++) { |
34 for (i=0; i<nl.length; i++) { |
34 if (nl[i].href) |
35 if (nl[i].href) |
35 base = nl[i].href; |
36 base = nl[i].href; |
36 } |
37 } |
37 |
38 |
38 function getBase(n) { |
39 function getBase(n) { |
39 if (n.src && /tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)) { |
40 if (n.src && /tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)) { |
40 if (/_(src|dev)\.js/g.test(n.src)) |
41 if (/_(src|dev)\.js/g.test(n.src)) |
41 t.suffix = '_src'; |
42 t.suffix = '_src'; |
42 |
43 |
44 if ((p = n.src.indexOf('?')) != -1) |
|
45 t.query = n.src.substring(p + 1); |
|
46 |
|
43 t.baseURL = n.src.substring(0, n.src.lastIndexOf('/')); |
47 t.baseURL = n.src.substring(0, n.src.lastIndexOf('/')); |
44 |
48 |
45 // If path to script is relative and a base href was found add that one infront |
49 // If path to script is relative and a base href was found add that one infront |
46 if (base && t.baseURL.indexOf('://') == -1) |
50 if (base && t.baseURL.indexOf('://') == -1) |
47 t.baseURL = base + t.baseURL; |
51 t.baseURL = base + t.baseURL; |
51 |
55 |
52 return null; |
56 return null; |
53 }; |
57 }; |
54 |
58 |
55 // Check document |
59 // Check document |
56 nl = document.getElementsByTagName('script'); |
60 nl = d.getElementsByTagName('script'); |
57 for (i=0; i<nl.length; i++) { |
61 for (i=0; i<nl.length; i++) { |
58 if (getBase(nl[i])) |
62 if (getBase(nl[i])) |
59 return; |
63 return; |
60 } |
64 } |
61 |
65 |
62 // Check head |
66 // Check head |
63 n = document.getElementsByTagName('head')[0]; |
67 n = d.getElementsByTagName('head')[0]; |
64 if (n) { |
68 if (n) { |
65 nl = n.getElementsByTagName('script'); |
69 nl = n.getElementsByTagName('script'); |
66 for (i=0; i<nl.length; i++) { |
70 for (i=0; i<nl.length; i++) { |
67 if (getBase(nl[i])) |
71 if (getBase(nl[i])) |
68 return; |
72 return; |
223 } |
227 } |
224 ns[cn].prototype[cn] = ns[cn]; |
228 ns[cn].prototype[cn] = ns[cn]; |
225 |
229 |
226 // Add super methods |
230 // Add super methods |
227 t.each(sp, function(f, n) { |
231 t.each(sp, function(f, n) { |
228 if (n != scn) |
232 ns[cn].prototype[n] = sp[n]; |
229 ns[cn].prototype[n] = sp[n]; |
|
230 }); |
233 }); |
231 |
234 |
232 // Add overridden methods |
235 // Add overridden methods |
233 t.each(p, function(f, n) { |
236 t.each(p, function(f, n) { |
234 // Extend methods if needed |
237 // Extend methods if needed |
302 |
305 |
303 return o; |
306 return o; |
304 }, |
307 }, |
305 |
308 |
306 addUnload : function(f, s) { |
309 addUnload : function(f, s) { |
307 var t = this, w = window, unload; |
310 var t = this, w = window; |
308 |
311 |
309 f = {func : f, scope : s || this}; |
312 f = {func : f, scope : s || this}; |
310 |
313 |
311 if (!t.unloads) { |
314 if (!t.unloads) { |
312 unload = function() { |
315 function unload() { |
313 var li = t.unloads, o, n; |
316 var li = t.unloads, o, n; |
314 |
317 |
315 // Call unload handlers |
318 if (li) { |
316 for (n in li) { |
319 // Call unload handlers |
317 o = li[n]; |
320 for (n in li) { |
318 |
321 o = li[n]; |
319 if (o && o.func) |
322 |
320 o.func.call(o.scope); |
323 if (o && o.func) |
321 } |
324 o.func.call(o.scope, 1); // Send in one arg to distinct unload and user destroy |
322 |
325 } |
323 // Detach unload function |
326 |
324 if (w.detachEvent) |
327 // Detach unload function |
325 w.detachEvent('onunload', unload); |
328 if (w.detachEvent) { |
326 else if (w.removeEventListener) |
329 w.detachEvent('onbeforeunload', fakeUnload); |
327 w.removeEventListener('unload', unload, false); |
330 w.detachEvent('onunload', unload); |
328 |
331 } else if (w.removeEventListener) |
329 // Destroy references |
332 w.removeEventListener('unload', unload, false); |
330 o = li = w = unload = null; |
333 |
331 |
334 // Destroy references |
332 // Run garbarge collector on IE |
335 t.unloads = o = li = w = unload = null; |
333 if (window.CollectGarbage) |
336 |
334 window.CollectGarbage(); |
337 // Run garbarge collector on IE |
338 if (window.CollectGarbage) |
|
339 window.CollectGarbage(); |
|
340 } |
|
335 }; |
341 }; |
336 |
342 |
343 function fakeUnload() { |
|
344 var d = document; |
|
345 |
|
346 // Is there things still loading, then do some magic |
|
347 if (d.readyState == 'interactive') { |
|
348 function stop() { |
|
349 // Prevent memory leak |
|
350 d.detachEvent('onstop', stop); |
|
351 |
|
352 // Call unload handler |
|
353 unload(); |
|
354 |
|
355 d = null; |
|
356 }; |
|
357 |
|
358 // Fire unload when the currently loading page is stopped |
|
359 d.attachEvent('onstop', stop); |
|
360 |
|
361 // Remove onstop listener after a while to prevent the unload function |
|
362 // to execute if the user presses cancel in an onbeforeunload |
|
363 // confirm dialog and then presses the browser stop button |
|
364 window.setTimeout(function() { |
|
365 d.detachEvent('onstop', stop); |
|
366 }, 0); |
|
367 } |
|
368 }; |
|
369 |
|
337 // Attach unload handler |
370 // Attach unload handler |
338 if (w.attachEvent) |
371 if (w.attachEvent) { |
339 w.attachEvent('onunload', unload); |
372 w.attachEvent('onunload', unload); |
340 else if (w.addEventListener) |
373 w.attachEvent('onbeforeunload', fakeUnload); |
374 } else if (w.addEventListener) |
|
341 w.addEventListener('unload', unload, false); |
375 w.addEventListener('unload', unload, false); |
342 |
376 |
343 // Setup initial unload handler array |
377 // Setup initial unload handler array |
344 t.unloads = [f]; |
378 t.unloads = [f]; |
345 } else |
379 } else |
358 return false; |
392 return false; |
359 } |
393 } |
360 }); |
394 }); |
361 |
395 |
362 return r; |
396 return r; |
397 }, |
|
398 |
|
399 explode : function(s, d) { |
|
400 return s ? tinymce.map(s.split(d || ','), tinymce.trim) : s; |
|
401 }, |
|
402 |
|
403 _addVer : function(u) { |
|
404 var v; |
|
405 |
|
406 if (!this.query) |
|
407 return u; |
|
408 |
|
409 v = (u.indexOf('?') == -1 ? '?' : '&') + this.query; |
|
410 |
|
411 if (u.indexOf('#') == -1) |
|
412 return u + v; |
|
413 |
|
414 return u.replace('#', v + '#'); |
|
363 } |
415 } |
364 |
416 |
365 }; |
417 }; |
366 |
418 |
367 // Required for GZip AJAX loading |
419 // Required for GZip AJAX loading |
412 |
464 |
413 return o; |
465 return o; |
414 }, |
466 }, |
415 |
467 |
416 dispatch : function() { |
468 dispatch : function() { |
417 var s, a = arguments; |
469 var s, a = arguments, i, li = this.listeners, c; |
418 |
470 |
419 tinymce.each(this.listeners, function(c) { |
471 // Needs to be a real loop since the listener count might change while looping |
420 return s = c.cb.apply(c.scope, a); |
472 // And this is also more efficient |
421 }); |
473 for (i = 0; i<li.length; i++) { |
474 c = li[i]; |
|
475 s = c.cb.apply(c.scope, a); |
|
476 |
|
477 if (s === false) |
|
478 break; |
|
479 } |
|
422 |
480 |
423 return s; |
481 return s; |
424 } |
482 } |
425 |
483 |
426 }); |
484 }); |
912 |
970 |
913 DOMUtils : function(d, s) { |
971 DOMUtils : function(d, s) { |
914 var t = this; |
972 var t = this; |
915 |
973 |
916 t.doc = d; |
974 t.doc = d; |
975 t.win = window; |
|
917 t.files = {}; |
976 t.files = {}; |
918 t.cssFlicker = false; |
977 t.cssFlicker = false; |
919 t.counter = 0; |
978 t.counter = 0; |
920 t.boxModel = !tinymce.isIE || d.compatMode == "CSS1Compat"; |
979 t.boxModel = !tinymce.isIE || d.compatMode == "CSS1Compat"; |
980 t.stdMode = d.documentMode === 8; |
|
921 |
981 |
922 this.settings = s = tinymce.extend({ |
982 this.settings = s = tinymce.extend({ |
923 keep_values : false, |
983 keep_values : false, |
924 hex_colors : 1, |
984 hex_colors : 1, |
925 process_html : 1 |
985 process_html : 1 |
932 } catch (e) { |
992 } catch (e) { |
933 t.cssFlicker = true; |
993 t.cssFlicker = true; |
934 } |
994 } |
935 } |
995 } |
936 |
996 |
937 tinymce.addUnload(function() { |
997 tinymce.addUnload(t.destroy, t); |
938 t.doc = t.root = null; |
|
939 }); |
|
940 }, |
998 }, |
941 |
999 |
942 getRoot : function() { |
1000 getRoot : function() { |
943 var t = this, s = t.settings; |
1001 var t = this, s = t.settings; |
944 |
1002 |
946 }, |
1004 }, |
947 |
1005 |
948 getViewPort : function(w) { |
1006 getViewPort : function(w) { |
949 var d, b; |
1007 var d, b; |
950 |
1008 |
951 w = !w ? window : w; |
1009 w = !w ? this.win : w; |
952 d = w.document; |
1010 d = w.document; |
953 b = this.boxModel ? d.documentElement : d.body; |
1011 b = this.boxModel ? d.documentElement : d.body; |
954 |
1012 |
955 // Returns viewport size excluding scrollbars |
1013 // Returns viewport size excluding scrollbars |
956 return { |
1014 return { |
1031 }, |
1089 }, |
1032 |
1090 |
1033 get : function(e) { |
1091 get : function(e) { |
1034 var n; |
1092 var n; |
1035 |
1093 |
1036 if (typeof(e) == 'string') { |
1094 if (e && this.doc && typeof(e) == 'string') { |
1037 n = e; |
1095 n = e; |
1038 e = this.doc.getElementById(e); |
1096 e = this.doc.getElementById(e); |
1039 |
1097 |
1040 // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick |
1098 // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick |
1041 if (e && e.id !== n) |
1099 if (e && e.id !== n) |
1065 |
1123 |
1066 // Select elements |
1124 // Select elements |
1067 l = tinymce.grep(s.querySelectorAll(pa)); |
1125 l = tinymce.grep(s.querySelectorAll(pa)); |
1068 |
1126 |
1069 // Restore old id |
1127 // Restore old id |
1070 if (i) |
1128 s.id = i; |
1071 s.id = i; |
|
1072 |
1129 |
1073 return l; |
1130 return l; |
1074 } |
1131 } |
1075 |
1132 |
1076 if (t.settings.strict) { |
1133 if (t.settings.strict) { |
1262 return o + ' />'; |
1319 return o + ' />'; |
1263 }, |
1320 }, |
1264 |
1321 |
1265 remove : function(n, k) { |
1322 remove : function(n, k) { |
1266 return this.run(n, function(n) { |
1323 return this.run(n, function(n) { |
1267 var p; |
1324 var p, g; |
1268 |
1325 |
1269 p = n.parentNode; |
1326 p = n.parentNode; |
1270 |
1327 |
1271 if (!p) |
1328 if (!p) |
1272 return null; |
1329 return null; |
1274 if (k) { |
1331 if (k) { |
1275 each (n.childNodes, function(c) { |
1332 each (n.childNodes, function(c) { |
1276 p.insertBefore(c.cloneNode(true), n); |
1333 p.insertBefore(c.cloneNode(true), n); |
1277 }); |
1334 }); |
1278 } |
1335 } |
1336 |
|
1337 // Fix IE psuedo leak |
|
1338 /* if (isIE) { |
|
1339 p = n.cloneNode(true); |
|
1340 n.outerHTML = ''; |
|
1341 |
|
1342 return p; |
|
1343 }*/ |
|
1279 |
1344 |
1280 return p.removeChild(n); |
1345 return p.removeChild(n); |
1281 }); |
1346 }); |
1282 }, |
1347 }, |
1283 |
1348 |
1390 return this.run(e, function(e) { |
1455 return this.run(e, function(e) { |
1391 var s = t.settings; |
1456 var s = t.settings; |
1392 |
1457 |
1393 switch (n) { |
1458 switch (n) { |
1394 case "style": |
1459 case "style": |
1460 // No mce_style for elements with these since they might get resized by the user |
|
1395 if (s.keep_values) { |
1461 if (s.keep_values) { |
1396 if (v) |
1462 if (v && !t._isRes(v)) |
1397 e.setAttribute('mce_style', v, 2); |
1463 e.setAttribute('mce_style', v, 2); |
1398 else |
1464 else |
1399 e.removeAttribute('mce_style', 2); |
1465 e.removeAttribute('mce_style', 2); |
1400 } |
1466 } |
1401 |
1467 |
1402 e.style.cssText = v; |
1468 e.style.cssText = v; |
1403 break; |
1469 break; |
1404 |
1470 |
1405 case "class": |
1471 case "class": |
1406 e.className = v; |
1472 e.className = v || ''; // Fix IE null bug |
1407 break; |
1473 break; |
1408 |
1474 |
1409 case "src": |
1475 case "src": |
1410 case "href": |
1476 case "href": |
1411 if (s.keep_values) { |
1477 if (s.keep_values) { |
1440 getAttrib : function(e, n, dv) { |
1506 getAttrib : function(e, n, dv) { |
1441 var v, t = this; |
1507 var v, t = this; |
1442 |
1508 |
1443 e = t.get(e); |
1509 e = t.get(e); |
1444 |
1510 |
1445 if (!e) |
1511 if (!e || e.nodeType !== 1) |
1446 return false; |
1512 return false; |
1447 |
1513 |
1448 if (!is(dv)) |
1514 if (!is(dv)) |
1449 dv = ""; |
1515 dv = ""; |
1450 |
1516 |
1481 v = v || e.style.cssText; |
1547 v = v || e.style.cssText; |
1482 |
1548 |
1483 if (v) { |
1549 if (v) { |
1484 v = t.serializeStyle(t.parseStyle(v)); |
1550 v = t.serializeStyle(t.parseStyle(v)); |
1485 |
1551 |
1486 if (t.settings.keep_values) |
1552 if (t.settings.keep_values && !t._isRes(v)) |
1487 e.setAttribute('mce_style', v); |
1553 e.setAttribute('mce_style', v); |
1488 } |
1554 } |
1489 |
1555 |
1490 break; |
1556 break; |
1491 } |
1557 } |
1549 if (n && isIE) { |
1615 if (n && isIE) { |
1550 n = n.getBoundingClientRect(); |
1616 n = n.getBoundingClientRect(); |
1551 e = t.boxModel ? d.documentElement : d.body; |
1617 e = t.boxModel ? d.documentElement : d.body; |
1552 x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border |
1618 x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border |
1553 x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x; |
1619 x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x; |
1554 n.top += window.self != window.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset |
1620 n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset |
1555 |
1621 |
1556 return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x}; |
1622 return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x}; |
1557 } |
1623 } |
1558 |
1624 |
1559 r = n; |
1625 r = n; |
1560 while (r) { |
1626 while (r) { |
1561 x += r.offsetLeft || 0; |
1627 x += r.offsetLeft || 0; |
1562 y += r.offsetTop || 0; |
1628 y += r.offsetTop || 0; |
1563 |
|
1564 r = r.offsetParent; |
1629 r = r.offsetParent; |
1565 } |
1630 } |
1566 |
1631 |
1567 r = n; |
1632 r = n; |
1568 while (r) { |
1633 while (r) { |
1569 // Opera 9.25 bug fix, fixed in 9.50 seems to be fixed in Opera 9.26 too |
1634 // Opera 9.25 bug fix, fixed in 9.50 |
1570 /* if (!tinymce.isOpera || r.nodeName != 'TR') { |
1635 if (!/^table-row|inline.*/i.test(t.getStyle(r, "display", 1))) { |
1571 x -= r.scrollLeft || 0; |
1636 x -= r.scrollLeft || 0; |
1572 y -= r.scrollTop || 0; |
1637 y -= r.scrollTop || 0; |
1573 }*/ |
1638 } |
1574 |
1639 |
1575 r = r.parentNode; |
1640 r = r.parentNode; |
1576 |
1641 |
1577 if (r == d.body) |
1642 if (r == d.body) |
1578 break; |
1643 break; |
1695 |
1760 |
1696 return s; |
1761 return s; |
1697 }, |
1762 }, |
1698 |
1763 |
1699 loadCSS : function(u) { |
1764 loadCSS : function(u) { |
1700 var t = this, d = this.doc; |
1765 var t = this, d = t.doc; |
1701 |
1766 |
1702 if (!u) |
1767 if (!u) |
1703 u = ''; |
1768 u = ''; |
1704 |
1769 |
1705 each(u.split(','), function(u) { |
1770 each(u.split(','), function(u) { |
1706 if (t.files[u]) |
1771 if (t.files[u]) |
1707 return; |
1772 return; |
1708 |
1773 |
1709 t.files[u] = true; |
1774 t.files[u] = true; |
1710 |
1775 t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : tinymce._addVer(u)}); |
1711 if (!d.createStyleSheet) |
|
1712 t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : u}); |
|
1713 else |
|
1714 d.createStyleSheet(u); |
|
1715 }); |
1776 }); |
1716 }, |
1777 }, |
1717 |
1778 |
1718 // #if !jquery |
1779 // #if !jquery |
1719 |
1780 |
1865 // Create new paragraph |
1926 // Create new paragraph |
1866 p = t.doc.createElement('p'); |
1927 p = t.doc.createElement('p'); |
1867 |
1928 |
1868 // Copy all attributes |
1929 // Copy all attributes |
1869 n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) { |
1930 n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) { |
1870 if (b !== 'mce_tmp') |
1931 var v; |
1871 p.setAttribute(b, n.getAttribute(b)); |
1932 |
1933 if (b !== 'mce_tmp') { |
|
1934 v = n.getAttribute(b); |
|
1935 |
|
1936 if (!v && b === 'class') |
|
1937 v = n.className; |
|
1938 |
|
1939 p.setAttribute(b, v); |
|
1940 } |
|
1872 }); |
1941 }); |
1873 |
1942 |
1874 // Append all children to new paragraph |
1943 // Append all children to new paragraph |
1875 for (x = 0; x<n.childNodes.length; x++) |
1944 for (x = 0; x<n.childNodes.length; x++) |
1876 p.appendChild(n.childNodes[x].cloneNode(true)); |
1945 p.appendChild(n.childNodes[x].cloneNode(true)); |
1896 |
1965 |
1897 // Convert strong and em to b and i in FF since it can't handle them |
1966 // Convert strong and em to b and i in FF since it can't handle them |
1898 if (tinymce.isGecko) { |
1967 if (tinymce.isGecko) { |
1899 h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>'); |
1968 h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>'); |
1900 h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>'); |
1969 h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>'); |
1901 } |
1970 } else if (isIE) |
1971 h = h.replace(/'/g, '''); // IE can't handle apos |
|
1902 |
1972 |
1903 // Fix some issues |
1973 // Fix some issues |
1904 h = h.replace(/<a( )([^>]+)\/>|<a\/>/gi, '<a$1$2></a>'); // Force open |
1974 h = h.replace(/<a( )([^>]+)\/>|<a\/>/gi, '<a$1$2></a>'); // Force open |
1905 |
1975 |
1906 // Store away src and href in mce_src and mce_href since browsers mess them up |
1976 // Store away src and href in mce_src and mce_href since browsers mess them up |
1924 |
1994 |
1925 if (b == 'style') { |
1995 if (b == 'style') { |
1926 // Why did I need this one? |
1996 // Why did I need this one? |
1927 //if (isIE) |
1997 //if (isIE) |
1928 // u = t.serializeStyle(t.parseStyle(u)); |
1998 // u = t.serializeStyle(t.parseStyle(u)); |
1999 |
|
2000 // No mce_style for elements with these since they might get resized by the user |
|
2001 if (t._isRes(c)) |
|
2002 return m; |
|
1929 |
2003 |
1930 if (s.hex_colors) { |
2004 if (s.hex_colors) { |
1931 u = u.replace(/rgb\([^\)]+\)/g, function(v) { |
2005 u = u.replace(/rgb\([^\)]+\)/g, function(v) { |
1932 return t.toHex(v); |
2006 return t.toHex(v); |
1933 }); |
2007 }); |
2078 each(o.childNodes, function(c) { |
2152 each(o.childNodes, function(c) { |
2079 n.appendChild(c.cloneNode(true)); |
2153 n.appendChild(c.cloneNode(true)); |
2080 }); |
2154 }); |
2081 } |
2155 } |
2082 |
2156 |
2157 // Fix IE psuedo leak for elements since replacing elements if fairly common |
|
2158 // Will break parentNode for some unknown reason |
|
2159 /* if (isIE && o.nodeType === 1) { |
|
2160 o.parentNode.insertBefore(n, o); |
|
2161 o.outerHTML = ''; |
|
2162 return n; |
|
2163 }*/ |
|
2164 |
|
2083 return o.parentNode.replaceChild(n, o); |
2165 return o.parentNode.replaceChild(n, o); |
2084 }); |
2166 }); |
2085 }, |
2167 }, |
2086 |
2168 |
2087 // #endif |
2169 // #endif |
2166 }, |
2248 }, |
2167 |
2249 |
2168 run : function(e, f, s) { |
2250 run : function(e, f, s) { |
2169 var t = this, o; |
2251 var t = this, o; |
2170 |
2252 |
2171 if (typeof(e) === 'string') |
2253 if (t.doc && typeof(e) === 'string') |
2172 e = t.doc.getElementById(e); |
2254 e = t.doc.getElementById(e); |
2173 |
2255 |
2174 if (!e) |
2256 if (!e) |
2175 return false; |
2257 return false; |
2176 |
2258 |
2189 |
2271 |
2190 return o; |
2272 return o; |
2191 } |
2273 } |
2192 |
2274 |
2193 return f.call(s, e); |
2275 return f.call(s, e); |
2276 }, |
|
2277 |
|
2278 getAttribs : function(n) { |
|
2279 var o; |
|
2280 |
|
2281 n = this.get(n); |
|
2282 |
|
2283 if (!n) |
|
2284 return []; |
|
2285 |
|
2286 if (isIE) { |
|
2287 o = []; |
|
2288 |
|
2289 // Object will throw exception in IE |
|
2290 if (n.nodeName == 'OBJECT') |
|
2291 return n.attributes; |
|
2292 |
|
2293 // It's crazy that this is faster in IE but it's because it returns all attributes all the time |
|
2294 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) { |
|
2295 o.push({specified : 1, nodeName : b}); |
|
2296 }); |
|
2297 |
|
2298 return o; |
|
2299 } |
|
2300 |
|
2301 return n.attributes; |
|
2302 }, |
|
2303 |
|
2304 destroy : function(s) { |
|
2305 var t = this; |
|
2306 |
|
2307 t.win = t.doc = t.root = null; |
|
2308 |
|
2309 // Manual destroy then remove unload handler |
|
2310 if (!s) |
|
2311 tinymce.removeUnload(t.destroy); |
|
2312 }, |
|
2313 |
|
2314 _isRes : function(c) { |
|
2315 // Is live resizble element |
|
2316 |
|
2317 return /^(top|left|bottom|right|width|height)/i.test(c) || /^[;\s](top|left|bottom|right|width|height)/i.test(c); |
|
2194 } |
2318 } |
2195 |
2319 |
2196 /* |
2320 /* |
2197 walk : function(n, f, s) { |
2321 walk : function(n, f, s) { |
2198 var d = this.doc, w; |
2322 var d = this.doc, w; |
2330 }); |
2454 }); |
2331 |
2455 |
2332 return s; |
2456 return s; |
2333 }, |
2457 }, |
2334 |
2458 |
2459 clear : function(o) { |
|
2460 var t = this, a = t.events, i, e; |
|
2461 |
|
2462 if (o) { |
|
2463 o = DOM.get(o); |
|
2464 |
|
2465 for (i = a.length - 1; i >= 0; i--) { |
|
2466 e = a[i]; |
|
2467 |
|
2468 if (e.obj === o) { |
|
2469 t._remove(e.obj, e.name, e.cfunc); |
|
2470 e.obj = e.cfunc = null; |
|
2471 a.splice(i, 1); |
|
2472 } |
|
2473 } |
|
2474 } |
|
2475 }, |
|
2476 |
|
2335 // #endif |
2477 // #endif |
2336 |
2478 |
2337 cancel : function(e) { |
2479 cancel : function(e) { |
2338 if (!e) |
2480 if (!e) |
2339 return false; |
2481 return false; |
2380 else |
2522 else |
2381 o['on' + n] = f; |
2523 o['on' + n] = f; |
2382 }, |
2524 }, |
2383 |
2525 |
2384 _remove : function(o, n, f) { |
2526 _remove : function(o, n, f) { |
2385 if (o.detachEvent) |
2527 if (o) { |
2386 o.detachEvent('on' + n, f); |
2528 try { |
2387 else if (o.removeEventListener) |
2529 if (o.detachEvent) |
2388 o.removeEventListener(n, f, false); |
2530 o.detachEvent('on' + n, f); |
2389 else |
2531 else if (o.removeEventListener) |
2390 o['on' + n] = null; |
2532 o.removeEventListener(n, f, false); |
2533 else |
|
2534 o['on' + n] = null; |
|
2535 } catch (ex) { |
|
2536 // Might fail with permission denined on IE so we just ignore that |
|
2537 } |
|
2538 } |
|
2391 }, |
2539 }, |
2392 |
2540 |
2393 _pageInit : function() { |
2541 _pageInit : function() { |
2394 var e = Event; |
2542 var e = Event; |
2395 |
2543 |
2581 })(); |
2729 })(); |
2582 |
2730 |
2583 /* file:jscripts/tiny_mce/classes/dom/Selection.js */ |
2731 /* file:jscripts/tiny_mce/classes/dom/Selection.js */ |
2584 |
2732 |
2585 (function() { |
2733 (function() { |
2734 function trimNl(s) { |
|
2735 return s.replace(/[\n\r]+/g, ''); |
|
2736 }; |
|
2737 |
|
2586 // Shorten names |
2738 // Shorten names |
2587 var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each; |
2739 var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each; |
2588 |
2740 |
2589 tinymce.create('tinymce.dom.Selection', { |
2741 tinymce.create('tinymce.dom.Selection', { |
2590 Selection : function(dom, win, serializer) { |
2742 Selection : function(dom, win, serializer) { |
2593 t.dom = dom; |
2745 t.dom = dom; |
2594 t.win = win; |
2746 t.win = win; |
2595 t.serializer = serializer; |
2747 t.serializer = serializer; |
2596 |
2748 |
2597 // Prevent leaks |
2749 // Prevent leaks |
2598 tinymce.addUnload(function() { |
2750 tinymce.addUnload(t.destroy, t); |
2599 t.win = null; |
|
2600 }); |
|
2601 }, |
2751 }, |
2602 |
2752 |
2603 getContent : function(s) { |
2753 getContent : function(s) { |
2604 var t = this, r = t.getRng(), e = t.dom.create("body"), se = t.getSel(), wb, wa, n; |
2754 var t = this, r = t.getRng(), e = t.dom.create("body"), se = t.getSel(), wb, wa, n; |
2605 |
2755 |
2680 |
2830 |
2681 r = r.duplicate(); |
2831 r = r.duplicate(); |
2682 r.collapse(1); |
2832 r.collapse(1); |
2683 e = r.parentElement(); |
2833 e = r.parentElement(); |
2684 |
2834 |
2685 if (e.nodeName == 'BODY') |
2835 if (e && e.nodeName == 'BODY') |
2686 return e.firstChild; |
2836 return e.firstChild; |
2687 |
2837 |
2688 return e; |
2838 return e; |
2689 } else { |
2839 } else { |
2690 e = r.startContainer; |
2840 e = r.startContainer; |
2705 |
2855 |
2706 r = r.duplicate(); |
2856 r = r.duplicate(); |
2707 r.collapse(0); |
2857 r.collapse(0); |
2708 e = r.parentElement(); |
2858 e = r.parentElement(); |
2709 |
2859 |
2710 if (e.nodeName == 'BODY') |
2860 if (e && e.nodeName == 'BODY') |
2711 return e.lastChild; |
2861 return e.lastChild; |
2712 |
2862 |
2713 return e; |
2863 return e; |
2714 } else { |
2864 } else { |
2715 e = r.endContainer; |
2865 e = r.endContainer; |
2720 return t.dom.getParent(e, function(n) {return n.nodeType == 1;}); |
2870 return t.dom.getParent(e, function(n) {return n.nodeType == 1;}); |
2721 } |
2871 } |
2722 }, |
2872 }, |
2723 |
2873 |
2724 getBookmark : function(si) { |
2874 getBookmark : function(si) { |
2725 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(); |
2875 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; |
2726 |
|
2727 sx = vp.x; |
2876 sx = vp.x; |
2728 sy = vp.y; |
2877 sy = vp.y; |
2729 |
2878 |
2730 // Simple bookmark fast but not as persistent |
2879 // Simple bookmark fast but not as persistent |
2731 if (si == 'simple') |
2880 if (si == 'simple') |
2790 } |
2939 } |
2791 |
2940 |
2792 // Text selection |
2941 // Text selection |
2793 |
2942 |
2794 function getPos(r, sn, en) { |
2943 function getPos(r, sn, en) { |
2795 var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; |
2944 var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; |
2796 |
2945 |
2797 while ((n = w.nextNode()) != null) { |
2946 while ((n = w.nextNode()) != null) { |
2798 if (n == sn) |
2947 if (n == sn) |
2799 d.start = p; |
2948 d.start = p; |
2800 |
2949 |
2801 if (n == en) { |
2950 if (n == en) { |
2802 d.end = p; |
2951 d.end = p; |
2803 return d; |
2952 return d; |
2804 } |
2953 } |
2805 |
2954 |
2806 p += n.nodeValue ? tinymce.trim(n.nodeValue).length : 0; |
2955 p += (n.nodeValue || '').length; |
2807 } |
2956 } |
2808 |
2957 |
2809 return null; |
2958 return null; |
2810 }; |
2959 }; |
2811 |
2960 |
2814 e = getPos(ro, s.anchorNode, s.focusNode); |
2963 e = getPos(ro, s.anchorNode, s.focusNode); |
2815 |
2964 |
2816 if (!e) |
2965 if (!e) |
2817 return {scrollX : sx, scrollY : sy}; |
2966 return {scrollX : sx, scrollY : sy}; |
2818 |
2967 |
2968 // Count whitespace before |
|
2969 trimNl(s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;}); |
|
2970 |
|
2819 return { |
2971 return { |
2820 start : e.start + s.anchorOffset, |
2972 start : Math.max(e.start + s.anchorOffset - wb, 0), |
2821 end : e.end + s.focusOffset, |
2973 end : Math.max(e.end + s.focusOffset - wb, 0), |
2822 scrollX : sx, |
2974 scrollX : sx, |
2823 scrollY : sy, |
2975 scrollY : sy, |
2824 beg : s.anchorOffset == 0 |
2976 beg : s.anchorOffset - wb == 0 |
2825 }; |
2977 }; |
2826 } else { |
2978 } else { |
2827 e = getPos(ro, r.startContainer, r.endContainer); |
2979 e = getPos(ro, r.startContainer, r.endContainer); |
2828 |
2980 |
2981 // Count whitespace before start and end container |
|
2982 //(r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;}); |
|
2983 //(r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;}); |
|
2984 |
|
2829 if (!e) |
2985 if (!e) |
2830 return {scrollX : sx, scrollY : sy}; |
2986 return {scrollX : sx, scrollY : sy}; |
2831 |
2987 |
2832 return { |
2988 return { |
2833 start : e.start + r.startOffset, |
2989 start : Math.max(e.start + r.startOffset - wb, 0), |
2834 end : e.end + r.endOffset, |
2990 end : Math.max(e.end + r.endOffset - wa, 0), |
2835 scrollX : sx, |
2991 scrollX : sx, |
2836 scrollY : sy, |
2992 scrollY : sy, |
2837 beg : r.startOffset == 0 |
2993 beg : r.startOffset - wb == 0 |
2838 }; |
2994 }; |
2839 } |
2995 } |
2840 }, |
2996 }, |
2841 |
2997 |
2842 moveToBookmark : function(b) { |
2998 moveToBookmark : function(b) { |
2843 var t = this, r = t.getRng(), s = t.getSel(), ro = t.dom.getRoot(), sd; |
2999 var t = this, r = t.getRng(), s = t.getSel(), ro = t.dom.getRoot(), sd, nvl, nv; |
2844 |
3000 |
2845 function getPos(r, sp, ep) { |
3001 function getPos(r, sp, ep) { |
2846 var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}, o, v; |
3002 var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}, o, v, wa, wb; |
2847 |
3003 |
2848 while ((n = w.nextNode()) != null) { |
3004 while ((n = w.nextNode()) != null) { |
2849 p += n.nodeValue ? tinymce.trim(n.nodeValue).length : 0; |
3005 wa = wb = 0; |
3006 |
|
3007 nv = n.nodeValue || ''; |
|
3008 //nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;}); |
|
3009 //nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;}); |
|
3010 |
|
3011 nvl = trimNl(nv).length; |
|
3012 p += nvl; |
|
2850 |
3013 |
2851 if (p >= sp && !d.startNode) { |
3014 if (p >= sp && !d.startNode) { |
2852 o = sp - (p - n.nodeValue.length); |
3015 o = sp - (p - nvl); |
2853 |
3016 |
2854 // Fix for odd quirk in FF |
3017 // Fix for odd quirk in FF |
2855 if (b.beg && o >= n.nodeValue.length) |
3018 if (b.beg && o >= nvl) |
2856 continue; |
3019 continue; |
2857 |
3020 |
2858 d.startNode = n; |
3021 d.startNode = n; |
2859 d.startOffset = o; |
3022 d.startOffset = o + wb; |
2860 } |
3023 } |
2861 |
3024 |
2862 if (p >= ep) { |
3025 if (p >= ep) { |
2863 d.endNode = n; |
3026 d.endNode = n; |
2864 d.endOffset = ep - (p - n.nodeValue.length); |
3027 d.endOffset = ep - (p - nvl) + wb; |
2865 return d; |
3028 return d; |
2866 } |
3029 } |
2867 } |
3030 } |
2868 |
3031 |
2869 return null; |
3032 return null; |
3109 return n.nodeType == 1; |
3272 return n.nodeType == 1; |
3110 }); |
3273 }); |
3111 } |
3274 } |
3112 |
3275 |
3113 return r.item ? r.item(0) : r.parentElement(); |
3276 return r.item ? r.item(0) : r.parentElement(); |
3277 }, |
|
3278 |
|
3279 destroy : function(s) { |
|
3280 var t = this; |
|
3281 |
|
3282 t.win = null; |
|
3283 |
|
3284 // Manual destroy then remove unload handler |
|
3285 if (!s) |
|
3286 tinymce.removeUnload(t.destroy); |
|
3114 } |
3287 } |
3115 |
3288 |
3116 }); |
3289 }); |
3117 })(); |
3290 })(); |
3118 |
3291 |
3186 writeCDATA : function(v) { |
3359 writeCDATA : function(v) { |
3187 this.node.appendChild(this.doc.createCDATA(v)); |
3360 this.node.appendChild(this.doc.createCDATA(v)); |
3188 }, |
3361 }, |
3189 |
3362 |
3190 writeComment : function(v) { |
3363 writeComment : function(v) { |
3191 this.node.appendChild(this.doc.createComment(v)); |
3364 this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g, ' '))); |
3192 }, |
3365 }, |
3193 |
3366 |
3194 getContent : function() { |
3367 getContent : function() { |
3195 var h; |
3368 var h; |
3196 |
3369 |
3339 |
3512 |
3340 /* file:jscripts/tiny_mce/classes/dom/Serializer.js */ |
3513 /* file:jscripts/tiny_mce/classes/dom/Serializer.js */ |
3341 |
3514 |
3342 (function() { |
3515 (function() { |
3343 // Shorten names |
3516 // Shorten names |
3344 var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE; |
3517 var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE, isGecko = tinymce.isGecko; |
3345 |
3518 |
3346 // Returns only attribites that have values not all attributes in IE |
3519 // Returns only attribites that have values not all attributes in IE |
3347 function getIEAtts(n) { |
3520 function getIEAtts(n) { |
3348 var o = []; |
3521 var o = []; |
3349 |
3522 |
3350 // Object will throw exception in IE |
3523 // Object will throw exception in IE |
3351 if (n.nodeName == 'OBJECT') |
3524 if (n.nodeName == 'OBJECT') |
3352 return n.attributes; |
3525 return n.attributes; |
3353 |
3526 |
3354 n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) { |
3527 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) { |
3355 o.push({specified : 1, nodeName : b}); |
3528 o.push({specified : 1, nodeName : b}); |
3356 }); |
3529 }); |
3357 |
3530 |
3358 return o; |
3531 return o; |
3359 }; |
3532 }; |
3633 |
3806 |
3634 at = at || []; |
3807 at = at || []; |
3635 |
3808 |
3636 // Parse attribute rule |
3809 // Parse attribute rule |
3637 s = s.replace(/::/g, '~'); |
3810 s = s.replace(/::/g, '~'); |
3638 s = /^([!\-])?([\w*.?~]+|)([=:<])?(.+)?$/.exec(s); |
3811 s = /^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s); |
3639 s[2] = s[2].replace(/~/g, ':'); |
3812 s[2] = s[2].replace(/~/g, ':'); |
3640 |
3813 |
3641 // Add required attributes |
3814 // Add required attributes |
3642 if (s[1] == '!') { |
3815 if (s[1] == '!') { |
3643 ra = ra || []; |
3816 ra = ra || []; |
3761 each(t.validElements, function(v, k) { |
3934 each(t.validElements, function(v, k) { |
3762 if (s) |
3935 if (s) |
3763 s += '|'; |
3936 s += '|'; |
3764 |
3937 |
3765 if (k != '@') |
3938 if (k != '@') |
3766 s += k; |
3939 s += k; |
3767 }); |
3940 }); |
3768 t.validElementsRE = new RegExp('^(' + wildcardToRE(s.toLowerCase()) + ')$'); |
3941 t.validElementsRE = new RegExp('^(' + wildcardToRE(s.toLowerCase()) + ')$'); |
3769 |
3942 |
3770 //console.debug(t.validElementsRE.toString()); |
3943 //console.debug(t.validElementsRE.toString()); |
3771 //console.dir(t.rules); |
3944 //console.dir(t.rules); |
3836 }, |
4009 }, |
3837 |
4010 |
3838 // Internal functions |
4011 // Internal functions |
3839 |
4012 |
3840 _postProcess : function(o) { |
4013 _postProcess : function(o) { |
3841 var t = this, s = t.settings, h = o.content, sc = [], p, l; |
4014 var t = this, s = t.settings, h = o.content, sc = [], p; |
3842 |
4015 |
3843 if (o.format == 'html') { |
4016 if (o.format == 'html') { |
3844 // Protect some elements |
4017 // Protect some elements |
3845 p = t._protect({ |
4018 p = t._protect({ |
3846 content : h, |
4019 content : h, |
3847 patterns : [ |
4020 patterns : [ |
3848 /(<script[^>]*>)(.*?)(<\/script>)/g, |
4021 {pattern : /(<script[^>]*>)(.*?)(<\/script>)/g}, |
3849 /(<style[^>]*>)(.*?)(<\/style>)/g, |
4022 {pattern : /(<style[^>]*>)(.*?)(<\/style>)/g}, |
3850 /(<pre[^>]*>)(.*?)(<\/pre>)/g |
4023 {pattern : /(<pre[^>]*>)(.*?)(<\/pre>)/g, encode : 1} |
3851 ] |
4024 ] |
3852 }); |
4025 }); |
3853 |
4026 |
3854 h = p.content; |
4027 h = p.content; |
3855 |
4028 |
3856 // Entity encode |
4029 // Entity encode |
3857 if (s.entity_encoding !== 'raw') { |
4030 if (s.entity_encoding !== 'raw') |
3858 if (s.entity_encoding.indexOf('named') != -1) { |
4031 h = t._encode(h); |
3859 t.setEntities(s.entities); |
|
3860 l = t.entityLookup; |
|
3861 |
|
3862 h = h.replace(t.entitiesRE, function(a) { |
|
3863 var v; |
|
3864 |
|
3865 if (v = l[a]) |
|
3866 a = '&' + v + ';'; |
|
3867 |
|
3868 return a; |
|
3869 }); |
|
3870 } |
|
3871 |
|
3872 if (s.entity_encoding.indexOf('numeric') != -1) { |
|
3873 h = h.replace(/[\u007E-\uFFFF]/g, function(a) { |
|
3874 return '&#' + a.charCodeAt(0) + ';'; |
|
3875 }); |
|
3876 } |
|
3877 } |
|
3878 |
4032 |
3879 // Use BR instead of padded P elements inside editor and use <p> </p> outside editor |
4033 // Use BR instead of padded P elements inside editor and use <p> </p> outside editor |
3880 if (o.set) |
4034 /* if (o.set) |
3881 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p><br /></p>'); |
4035 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p><br /></p>'); |
3882 else |
4036 else |
3883 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p>$1</p>'); |
4037 h = h.replace(/<p>\s+( | |\u00a0|<br \/>)\s+<\/p>/g, '<p>$1</p>');*/ |
3884 |
4038 |
3885 // Since Gecko and Safari keeps whitespace in the DOM we need to |
4039 // Since Gecko and Safari keeps whitespace in the DOM we need to |
3886 // remove it inorder to match other browsers. But I think Gecko and Safari is right. |
4040 // remove it inorder to match other browsers. But I think Gecko and Safari is right. |
3887 // This process is only done when getting contents out from the editor. |
4041 // This process is only done when getting contents out from the editor. |
3888 if (!o.set) { |
4042 if (!o.set) { |
4043 // We need to replace paragraph whitespace with an nbsp before indentation to keep the \u00a0 char |
|
4044 h = h.replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g, s.entity_encoding == 'numeric' ? '<p$1> </p>' : '<p$1> </p>'); |
|
4045 |
|
3889 if (s.remove_linebreaks) { |
4046 if (s.remove_linebreaks) { |
4047 h = h.replace(/\r?\n|\r/g, ' '); |
|
3890 h = h.replace(/(<[^>]+>)\s+/g, '$1 '); |
4048 h = h.replace(/(<[^>]+>)\s+/g, '$1 '); |
3891 h = h.replace(/\s+(<\/[^>]+>)/g, ' $1'); |
4049 h = h.replace(/\s+(<\/[^>]+>)/g, ' $1'); |
3892 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 |
4050 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 |
3893 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 |
4051 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 |
3894 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 |
4052 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 |
3903 h = h.replace(/\n\n/g, '\n'); |
4061 h = h.replace(/\n\n/g, '\n'); |
3904 } |
4062 } |
3905 } |
4063 } |
3906 |
4064 |
3907 h = t._unprotect(h, p); |
4065 h = t._unprotect(h, p); |
4066 |
|
4067 // Restore the \u00a0 character if raw mode is enabled |
|
4068 if (s.entity_encoding == 'raw') |
|
4069 h = h.replace(/<p> <\/p>|<p([^>]+)> <\/p>/g, '<p$1>\u00a0</p>'); |
|
3908 } |
4070 } |
3909 |
4071 |
3910 o.content = h; |
4072 o.content = h; |
3911 }, |
4073 }, |
3912 |
4074 |
3949 } |
4111 } |
3950 |
4112 |
3951 // IE sometimes adds a / infront of the node name |
4113 // IE sometimes adds a / infront of the node name |
3952 if (nn.charAt(0) == '/') |
4114 if (nn.charAt(0) == '/') |
3953 nn = nn.substring(1); |
4115 nn = nn.substring(1); |
4116 } else if (isGecko) { |
|
4117 // Ignore br elements |
|
4118 if (n.nodeName === 'BR' && n.getAttribute('type') == '_moz') |
|
4119 return; |
|
3954 } |
4120 } |
3955 |
4121 |
3956 // Check if valid child |
4122 // Check if valid child |
3957 if (t.childRules) { |
4123 if (t.childRules) { |
3958 if (t.parentElementsRE.test(t.elementName)) { |
4124 if (t.parentElementsRE.test(t.elementName)) { |
4066 w.writeEndElement(); |
4232 w.writeEndElement(); |
4067 } |
4233 } |
4068 }, |
4234 }, |
4069 |
4235 |
4070 _protect : function(o) { |
4236 _protect : function(o) { |
4237 var t = this; |
|
4238 |
|
4071 o.items = o.items || []; |
4239 o.items = o.items || []; |
4072 |
4240 |
4073 function enc(s) { |
4241 function enc(s) { |
4074 return s.replace(/[\r\n\\]/g, function(c) { |
4242 return s.replace(/[\r\n\\]/g, function(c) { |
4075 if (c === '\n') |
4243 if (c === '\n') |
4091 return '\r'; |
4259 return '\r'; |
4092 }); |
4260 }); |
4093 }; |
4261 }; |
4094 |
4262 |
4095 each(o.patterns, function(p) { |
4263 each(o.patterns, function(p) { |
4096 o.content = dec(enc(o.content).replace(p, function(x, a, b, c) { |
4264 o.content = dec(enc(o.content).replace(p.pattern, function(x, a, b, c) { |
4097 o.items.push(dec(b)); |
4265 b = dec(b); |
4266 |
|
4267 if (p.encode) |
|
4268 b = t._encode(b); |
|
4269 |
|
4270 o.items.push(b); |
|
4098 return a + '<!--mce:' + (o.items.length - 1) + '-->' + c; |
4271 return a + '<!--mce:' + (o.items.length - 1) + '-->' + c; |
4099 })); |
4272 })); |
4100 }); |
4273 }); |
4101 |
4274 |
4102 return o; |
4275 return o; |
4106 h = h.replace(/\<!--mce:([0-9]+)--\>/g, function(a, b) { |
4279 h = h.replace(/\<!--mce:([0-9]+)--\>/g, function(a, b) { |
4107 return o.items[parseInt(b)]; |
4280 return o.items[parseInt(b)]; |
4108 }); |
4281 }); |
4109 |
4282 |
4110 o.items = []; |
4283 o.items = []; |
4284 |
|
4285 return h; |
|
4286 }, |
|
4287 |
|
4288 _encode : function(h) { |
|
4289 var t = this, s = t.settings, l; |
|
4290 |
|
4291 // Entity encode |
|
4292 if (s.entity_encoding !== 'raw') { |
|
4293 if (s.entity_encoding.indexOf('named') != -1) { |
|
4294 t.setEntities(s.entities); |
|
4295 l = t.entityLookup; |
|
4296 |
|
4297 h = h.replace(t.entitiesRE, function(a) { |
|
4298 var v; |
|
4299 |
|
4300 if (v = l[a]) |
|
4301 a = '&' + v + ';'; |
|
4302 |
|
4303 return a; |
|
4304 }); |
|
4305 } |
|
4306 |
|
4307 if (s.entity_encoding.indexOf('numeric') != -1) { |
|
4308 h = h.replace(/[\u007E-\uFFFF]/g, function(a) { |
|
4309 return '&#' + a.charCodeAt(0) + ';'; |
|
4310 }); |
|
4311 } |
|
4312 } |
|
4111 |
4313 |
4112 return h; |
4314 return h; |
4113 }, |
4315 }, |
4114 |
4316 |
4115 _setup : function() { |
4317 _setup : function() { |
4235 }, |
4437 }, |
4236 |
4438 |
4237 load : function(u, cb, s) { |
4439 load : function(u, cb, s) { |
4238 var t = this, o; |
4440 var t = this, o; |
4239 |
4441 |
4442 if (o = t.lookup[u]) { |
|
4443 // Is loaded fire callback |
|
4444 if (cb && o.state == 2) |
|
4445 cb.call(s || t); |
|
4446 |
|
4447 return o; |
|
4448 } |
|
4449 |
|
4240 function loadScript(u) { |
4450 function loadScript(u) { |
4241 if (tinymce.dom.Event.domLoaded || t.settings.strict_mode) { |
4451 if (tinymce.dom.Event.domLoaded || t.settings.strict_mode) { |
4242 tinymce.util.XHR.send({ |
4452 tinymce.util.XHR.send({ |
4243 url : u, |
4453 url : tinymce._addVer(u), |
4244 error : t.settings.error, |
4454 error : t.settings.error, |
4245 async : false, |
4455 async : false, |
4246 success : function(co) { |
4456 success : function(co) { |
4247 t.eval(co); |
4457 t.eval(co); |
4248 } |
4458 } |
4249 }); |
4459 }); |
4250 } else |
4460 } else |
4251 document.write('<script type="text/javascript" src="' + u + '"></script>'); |
4461 document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>'); |
4252 }; |
4462 }; |
4253 |
4463 |
4254 if (!tinymce.is(u, 'string')) { |
4464 if (!tinymce.is(u, 'string')) { |
4255 each(u, function(u) { |
4465 each(u, function(u) { |
4256 loadScript(u); |
4466 loadScript(u); |
4383 ol = ' onload="'; |
4593 ol = ' onload="'; |
4384 |
4594 |
4385 ol += 'tinymce.dom.ScriptLoader._onLoad(this,\'' + u + '\',' + ix + ');"'; |
4595 ol += 'tinymce.dom.ScriptLoader._onLoad(this,\'' + u + '\',' + ix + ');"'; |
4386 } |
4596 } |
4387 |
4597 |
4388 document.write('<script type="text/javascript" src="' + u + '"' + ol + '></script>'); |
4598 document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"' + ol + '></script>'); |
4389 |
4599 |
4390 if (!o.func) |
4600 if (!o.func) |
4391 done(o); |
4601 done(o); |
4392 } else |
4602 } else |
4393 load(o); |
4603 load(o); |
4510 t.active = -1; |
4720 t.active = -1; |
4511 t.setActive(b); |
4721 t.setActive(b); |
4512 } |
4722 } |
4513 }, |
4723 }, |
4514 |
4724 |
4725 remove : function() { |
|
4726 DOM.remove(this.id); |
|
4727 this.destroy(); |
|
4728 }, |
|
4729 |
|
4515 destroy : function() { |
4730 destroy : function() { |
4516 DOM.remove(this.id); |
4731 tinymce.dom.Event.clear(this.id); |
4517 } |
4732 } |
4518 |
4733 |
4519 }); |
4734 }); |
4520 })(); |
4735 })(); |
4521 /* file:jscripts/tiny_mce/classes/ui/Container.js */ |
4736 /* file:jscripts/tiny_mce/classes/ui/Container.js */ |
4542 |
4757 |
4543 |
4758 |
4544 /* file:jscripts/tiny_mce/classes/ui/Separator.js */ |
4759 /* file:jscripts/tiny_mce/classes/ui/Separator.js */ |
4545 |
4760 |
4546 tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', { |
4761 tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', { |
4762 Separator : function(id, s) { |
|
4763 this.parent(id, s); |
|
4764 this.classPrefix = 'mceSeparator'; |
|
4765 }, |
|
4766 |
|
4547 renderHTML : function() { |
4767 renderHTML : function() { |
4548 return tinymce.DOM.createHTML('span', {'class' : 'mceSeparator'}); |
4768 return tinymce.DOM.createHTML('span', {'class' : this.classPrefix}); |
4549 } |
4769 } |
4550 |
4770 |
4551 }); |
4771 }); |
4552 |
4772 |
4553 /* file:jscripts/tiny_mce/classes/ui/MenuItem.js */ |
4773 /* file:jscripts/tiny_mce/classes/ui/MenuItem.js */ |
4663 var t = this; |
4883 var t = this; |
4664 |
4884 |
4665 walk(t, function(o) { |
4885 walk(t, function(o) { |
4666 if (o.removeAll) |
4886 if (o.removeAll) |
4667 o.removeAll(); |
4887 o.removeAll(); |
4888 else |
|
4889 o.remove(); |
|
4668 |
4890 |
4669 o.destroy(); |
4891 o.destroy(); |
4670 }, 'items', t); |
4892 }, 'items', t); |
4671 |
4893 |
4672 t.items = {}; |
4894 t.items = {}; |
4688 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element; |
4910 var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element; |
4689 |
4911 |
4690 tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', { |
4912 tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', { |
4691 DropMenu : function(id, s) { |
4913 DropMenu : function(id, s) { |
4692 s = s || {}; |
4914 s = s || {}; |
4693 s.container = s.container || document.body; |
4915 s.container = s.container || DOM.doc.body; |
4694 s.offset_x = s.offset_x || 0; |
4916 s.offset_x = s.offset_x || 0; |
4695 s.offset_y = s.offset_y || 0; |
4917 s.offset_y = s.offset_y || 0; |
4696 s.vp_offset_x = s.vp_offset_x || 0; |
4918 s.vp_offset_x = s.vp_offset_x || 0; |
4697 s.vp_offset_y = s.vp_offset_y || 0; |
4919 s.vp_offset_y = s.vp_offset_y || 0; |
4698 |
4920 |
4702 this.parent(id, s); |
4924 this.parent(id, s); |
4703 this.onShowMenu = new tinymce.util.Dispatcher(this); |
4925 this.onShowMenu = new tinymce.util.Dispatcher(this); |
4704 this.onHideMenu = new tinymce.util.Dispatcher(this); |
4926 this.onHideMenu = new tinymce.util.Dispatcher(this); |
4705 this.classPrefix = 'mceMenu'; |
4927 this.classPrefix = 'mceMenu'; |
4706 |
4928 |
4707 // Fix for odd IE bug: #1903622 |
4929 // Fix for odd IE bug: #1903622 (Frames selection) |
4708 this.fixIE = tinymce.isIE && window.top != window; |
4930 this.fixIE = tinymce.isIE && (DOM.win.top != DOM.win); |
4709 }, |
4931 }, |
4710 |
4932 |
4711 createMenu : function(s) { |
4933 createMenu : function(s) { |
4712 var t = this, cs = t.settings, m; |
4934 var t = this, cs = t.settings, m; |
4713 |
4935 |
4745 DOM.setStyle(co, 'overflow', 'hidden'); |
4967 DOM.setStyle(co, 'overflow', 'hidden'); |
4746 } |
4968 } |
4747 }, |
4969 }, |
4748 |
4970 |
4749 showMenu : function(x, y, px) { |
4971 showMenu : function(x, y, px) { |
4750 var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb; |
4972 var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb, cp = t.classPrefix; |
4751 |
4973 |
4752 t.collapse(1); |
4974 t.collapse(1); |
4753 |
4975 |
4754 if (t.isMenuVisible) |
4976 if (t.isMenuVisible) |
4755 return; |
4977 return; |
4798 t.mouseClickFunc = Event.add(co, t.fixIE ? 'mousedown' : 'click', function(e) { |
5020 t.mouseClickFunc = Event.add(co, t.fixIE ? 'mousedown' : 'click', function(e) { |
4799 var m; |
5021 var m; |
4800 |
5022 |
4801 e = e.target; |
5023 e = e.target; |
4802 |
5024 |
4803 if (e && (e = DOM.getParent(e, 'TR')) && !DOM.hasClass(e, 'mceMenuItemSub')) { |
5025 if (e && (e = DOM.getParent(e, 'TR')) && !DOM.hasClass(e, cp + 'ItemSub')) { |
4804 m = t.items[e.id]; |
5026 m = t.items[e.id]; |
4805 |
5027 |
4806 if (m.isDisabled()) |
5028 if (m.isDisabled()) |
4807 return; |
5029 return; |
4808 |
5030 |
4809 dm = t; |
5031 dm = t; |
4810 |
5032 |
4811 while (dm) { |
5033 // Wait a while to fix IE bug where it looses the selection if the user clicks on a menu |
4812 if (dm.hideMenu) |
5034 // item when the editor is placed within an frame or iframe |
4813 dm.hideMenu(); |
5035 DOM.win.setTimeout(function() { |
4814 |
5036 while (dm) { |
4815 dm = dm.settings.parent; |
5037 if (dm.hideMenu) |
4816 } |
5038 dm.hideMenu(); |
4817 |
5039 |
4818 if (m.settings.onclick) |
5040 dm = dm.settings.parent; |
4819 m.settings.onclick(e); |
5041 } |
5042 }, 0); |
|
5043 |
|
5044 // Yield on IE to prevent loosing image focus when context menu is used |
|
5045 window.setTimeout(function() { |
|
5046 if (m.settings.onclick) |
|
5047 m.settings.onclick(e); |
|
5048 }, 0); |
|
4820 |
5049 |
4821 return Event.cancel(e); // Cancel to fix onbeforeunload problem |
5050 return Event.cancel(e); // Cancel to fix onbeforeunload problem |
4822 } |
5051 } |
4823 }); |
5052 }); |
4824 |
5053 |
4834 t.lastMenu.collapse(1); |
5063 t.lastMenu.collapse(1); |
4835 |
5064 |
4836 if (m.isDisabled()) |
5065 if (m.isDisabled()) |
4837 return; |
5066 return; |
4838 |
5067 |
4839 if (e && DOM.hasClass(e, 'mceMenuItemSub')) { |
5068 if (e && DOM.hasClass(e, cp + 'ItemSub')) { |
4840 //p = DOM.getPos(s.container); |
5069 //p = DOM.getPos(s.container); |
4841 r = DOM.getRect(e); |
5070 r = DOM.getRect(e); |
4842 m.showMenu((r.x + r.w - ot), r.y - ot, r.x); |
5071 m.showMenu((r.x + r.w - ot), r.y - ot, r.x); |
4843 t.lastMenu = m; |
5072 t.lastMenu = m; |
4844 DOM.addClass(DOM.get(m.id).firstChild, 'mceMenuItemActive'); |
5073 DOM.addClass(DOM.get(m.id).firstChild, cp + 'ItemActive'); |
4845 } |
5074 } |
4846 } |
5075 } |
4847 }); |
5076 }); |
4848 } |
5077 } |
4849 |
5078 |
4850 t.onShowMenu.dispatch(t); |
5079 t.onShowMenu.dispatch(t); |
5080 |
|
5081 if (s.keyboard_focus) { |
|
5082 Event.add(co, 'keydown', t._keyHandler, t); |
|
5083 DOM.select('a', 'menu_' + t.id)[0].focus(); // Select first link |
|
5084 } |
|
4851 }, |
5085 }, |
4852 |
5086 |
4853 hideMenu : function(c) { |
5087 hideMenu : function(c) { |
4854 var t = this, co = DOM.get('menu_' + t.id), e; |
5088 var t = this, co = DOM.get('menu_' + t.id), e; |
4855 |
5089 |
4856 if (!t.isMenuVisible) |
5090 if (!t.isMenuVisible) |
4857 return; |
5091 return; |
4858 |
5092 |
4859 Event.remove(co, 'mouseover', t.mouseOverFunc); |
5093 Event.remove(co, 'mouseover', t.mouseOverFunc); |
4860 Event.remove(co, t.fixIE ? 'mousedown' : 'click', t.mouseClickFunc); |
5094 Event.remove(co, t.fixIE ? 'mousedown' : 'click', t.mouseClickFunc); |
5095 Event.remove(co, 'keydown', t._keyHandler); |
|
4861 DOM.hide(co); |
5096 DOM.hide(co); |
4862 t.isMenuVisible = 0; |
5097 t.isMenuVisible = 0; |
4863 |
5098 |
4864 if (!c) |
5099 if (!c) |
4865 t.collapse(1); |
5100 t.collapse(1); |
4866 |
5101 |
4867 if (t.element) |
5102 if (t.element) |
4868 t.element.hide(); |
5103 t.element.hide(); |
4869 |
5104 |
4870 if (e = DOM.get(t.id)) |
5105 if (e = DOM.get(t.id)) |
4871 DOM.removeClass(e.firstChild, 'mceMenuItemActive'); |
5106 DOM.removeClass(e.firstChild, t.classPrefix + 'ItemActive'); |
4872 |
5107 |
4873 t.onHideMenu.dispatch(t); |
5108 t.onHideMenu.dispatch(t); |
4874 }, |
5109 }, |
4875 |
5110 |
4876 add : function(o) { |
5111 add : function(o) { |
4889 this.hideMenu(1); |
5124 this.hideMenu(1); |
4890 }, |
5125 }, |
4891 |
5126 |
4892 remove : function(o) { |
5127 remove : function(o) { |
4893 DOM.remove(o.id); |
5128 DOM.remove(o.id); |
5129 this.destroy(); |
|
4894 |
5130 |
4895 return this.parent(o); |
5131 return this.parent(o); |
4896 }, |
5132 }, |
4897 |
5133 |
4898 destroy : function() { |
5134 destroy : function() { |
4908 }, |
5144 }, |
4909 |
5145 |
4910 renderNode : function() { |
5146 renderNode : function() { |
4911 var t = this, s = t.settings, n, tb, co, w; |
5147 var t = this, s = t.settings, n, tb, co, w; |
4912 |
5148 |
4913 w = DOM.create('div', {id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:150'}); |
5149 w = DOM.create('div', {id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:200000'}); |
4914 co = DOM.add(w, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenu' + (s['class'] ? ' ' + s['class'] : '')}); |
5150 co = DOM.add(w, 'div', {id : 'menu_' + t.id + '_co', 'class' : t.classPrefix + (s['class'] ? ' ' + s['class'] : '')}); |
4915 t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container}); |
5151 t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container}); |
4916 |
5152 |
4917 if (s.menu_line) |
5153 if (s.menu_line) |
4918 DOM.add(co, 'span', {'class' : 'mceMenuLine'}); |
5154 DOM.add(co, 'span', {'class' : t.classPrefix + 'Line'}); |
4919 |
5155 |
4920 // n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'}); |
5156 // n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'}); |
4921 n = DOM.add(co, 'table', {id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0}); |
5157 n = DOM.add(co, 'table', {id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0}); |
4922 tb = DOM.add(n, 'tbody'); |
5158 tb = DOM.add(n, 'tbody'); |
4923 |
5159 |
4930 return w; |
5166 return w; |
4931 }, |
5167 }, |
4932 |
5168 |
4933 // Internal functions |
5169 // Internal functions |
4934 |
5170 |
5171 _keyHandler : function(e) { |
|
5172 // Accessibility feature |
|
5173 if (e.keyCode == 27) |
|
5174 this.hideMenu(); |
|
5175 }, |
|
5176 |
|
4935 _add : function(tb, o) { |
5177 _add : function(tb, o) { |
4936 var n, s = o.settings, a, ro, it; |
5178 var n, s = o.settings, a, ro, it, cp = this.classPrefix; |
4937 |
5179 |
4938 if (s.separator) { |
5180 if (s.separator) { |
4939 ro = DOM.add(tb, 'tr', {id : o.id, 'class' : 'mceMenuItemSeparator'}); |
5181 ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'}); |
4940 DOM.add(ro, 'td', {'class' : 'mceMenuItemSeparator'}); |
5182 DOM.add(ro, 'td', {'class' : cp + 'ItemSeparator'}); |
4941 |
5183 |
4942 if (n = ro.previousSibling) |
5184 if (n = ro.previousSibling) |
4943 DOM.addClass(n, 'mceLast'); |
5185 DOM.addClass(n, 'mceLast'); |
4944 |
5186 |
4945 return; |
5187 return; |
4946 } |
5188 } |
4947 |
5189 |
4948 n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : 'mceMenuItem mceMenuItemEnabled'}); |
5190 n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'Item ' + cp + 'ItemEnabled'}); |
4949 n = it = DOM.add(n, 'td'); |
5191 n = it = DOM.add(n, 'td'); |
4950 n = a = DOM.add(n, 'a', {href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'}); |
5192 n = a = DOM.add(n, 'a', {href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'}); |
4951 |
5193 |
4952 DOM.addClass(it, s['class']); |
5194 DOM.addClass(it, s['class']); |
4953 // n = DOM.add(n, 'span', {'class' : 'item'}); |
5195 // n = DOM.add(n, 'span', {'class' : 'item'}); |
4958 DOM.setAttrib(n, 'style', o.settings.style); |
5200 DOM.setAttrib(n, 'style', o.settings.style); |
4959 |
5201 |
4960 if (tb.childNodes.length == 1) |
5202 if (tb.childNodes.length == 1) |
4961 DOM.addClass(ro, 'mceFirst'); |
5203 DOM.addClass(ro, 'mceFirst'); |
4962 |
5204 |
4963 if ((n = ro.previousSibling) && DOM.hasClass(n, 'mceMenuItemSeparator')) |
5205 if ((n = ro.previousSibling) && DOM.hasClass(n, cp + 'ItemSeparator')) |
4964 DOM.addClass(ro, 'mceFirst'); |
5206 DOM.addClass(ro, 'mceFirst'); |
4965 |
5207 |
4966 if (o.collapse) |
5208 if (o.collapse) |
4967 DOM.addClass(ro, 'mceMenuItemSub'); |
5209 DOM.addClass(ro, cp + 'ItemSub'); |
4968 |
5210 |
4969 if (n = ro.previousSibling) |
5211 if (n = ro.previousSibling) |
4970 DOM.removeClass(n, 'mceLast'); |
5212 DOM.removeClass(n, 'mceLast'); |
4971 |
5213 |
4972 DOM.addClass(ro, 'mceLast'); |
5214 DOM.addClass(ro, 'mceLast'); |
4984 this.parent(id, s); |
5226 this.parent(id, s); |
4985 this.classPrefix = 'mceButton'; |
5227 this.classPrefix = 'mceButton'; |
4986 }, |
5228 }, |
4987 |
5229 |
4988 renderHTML : function() { |
5230 renderHTML : function() { |
4989 var s = this.settings, h = '<a id="' + this.id + '" href="javascript:;" class="mceButton mceButtonEnabled ' + s['class'] + '" onmousedown="return false;" onclick="return false;" title="' + DOM.encode(s.title) + '">'; |
5231 var cp = this.classPrefix, s = this.settings, h, l; |
5232 |
|
5233 l = DOM.encode(s.label || ''); |
|
5234 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) + '">'; |
|
4990 |
5235 |
4991 if (s.image) |
5236 if (s.image) |
4992 h += '<img class="mceIcon" src="' + s.image + '" /></a>'; |
5237 h += '<img class="mceIcon" src="' + s.image + '" />' + l + '</a>'; |
4993 else |
5238 else |
4994 h += '<span class="mceIcon ' + s['class'] + '"></span></a>'; |
5239 h += '<span class="mceIcon ' + s['class'] + '"></span>' + (l ? '<span class="' + cp + 'Label">' + l + '</span>' : '') + '</a>'; |
4995 |
5240 |
4996 return h; |
5241 return h; |
4997 }, |
5242 }, |
4998 |
5243 |
4999 postRender : function() { |
5244 postRender : function() { |
5072 getLength : function() { |
5317 getLength : function() { |
5073 return this.items.length; |
5318 return this.items.length; |
5074 }, |
5319 }, |
5075 |
5320 |
5076 renderHTML : function() { |
5321 renderHTML : function() { |
5077 var h = '', t = this, s = t.settings; |
5322 var h = '', t = this, s = t.settings, cp = t.classPrefix; |
5078 |
5323 |
5079 h = '<table id="' + t.id + '" cellpadding="0" cellspacing="0" class="mceListBox mceListBoxEnabled' + (s['class'] ? (' ' + s['class']) : '') + '"><tbody><tr>'; |
5324 h = '<table id="' + t.id + '" cellpadding="0" cellspacing="0" class="' + cp + ' ' + cp + 'Enabled' + (s['class'] ? (' ' + s['class']) : '') + '"><tbody><tr>'; |
5080 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>'; |
5325 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>'; |
5081 h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', href : 'javascript:;', 'class' : 'mceOpen', onclick : "return false;", onmousedown : 'return false;'}, '<span></span>') + '</td>'; |
5326 h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', tabindex : -1, href : 'javascript:;', 'class' : 'mceOpen', onclick : "return false;", onmousedown : 'return false;'}, '<span></span>') + '</td>'; |
5082 h += '</tr></tbody></table>'; |
5327 h += '</tr></tbody></table>'; |
5083 |
5328 |
5084 return h; |
5329 return h; |
5085 }, |
5330 }, |
5086 |
5331 |
5087 showMenu : function() { |
5332 showMenu : function() { |
5088 var t = this, p1, p2, e = DOM.get(this.id), m; |
5333 var t = this, p1, p2, e = DOM.get(this.id), m; |
5089 |
5334 |
5090 if (t.isDisabled() || t.items.length == 0) |
5335 if (t.isDisabled() || t.items.length == 0) |
5091 return; |
5336 return; |
5337 |
|
5338 if (t.menu && t.menu.isMenuVisible) |
|
5339 return t.hideMenu(); |
|
5092 |
5340 |
5093 if (!t.isMenuRendered) { |
5341 if (!t.isMenuRendered) { |
5094 t.renderMenu(); |
5342 t.renderMenu(); |
5095 t.isMenuRendered = true; |
5343 t.isMenuRendered = true; |
5096 } |
5344 } |
5099 p2 = DOM.getPos(e); |
5347 p2 = DOM.getPos(e); |
5100 |
5348 |
5101 m = t.menu; |
5349 m = t.menu; |
5102 m.settings.offset_x = p2.x; |
5350 m.settings.offset_x = p2.x; |
5103 m.settings.offset_y = p2.y; |
5351 m.settings.offset_y = p2.y; |
5352 m.settings.keyboard_focus = t._focused; |
|
5104 |
5353 |
5105 // Select in menu |
5354 // Select in menu |
5106 if (t.oldID) |
5355 if (t.oldID) |
5107 m.items[t.oldID].setSelected(0); |
5356 m.items[t.oldID].setSelected(0); |
5108 |
5357 |
5113 } |
5362 } |
5114 }); |
5363 }); |
5115 |
5364 |
5116 m.showMenu(0, e.clientHeight); |
5365 m.showMenu(0, e.clientHeight); |
5117 |
5366 |
5118 Event.add(document, 'mousedown', t.hideMenu, t); |
5367 Event.add(DOM.doc, 'mousedown', t.hideMenu, t); |
5119 DOM.addClass(t.id, 'mceListBoxSelected'); |
5368 DOM.addClass(t.id, t.classPrefix + 'Selected'); |
5120 }, |
5369 }, |
5121 |
5370 |
5122 hideMenu : function(e) { |
5371 hideMenu : function(e) { |
5123 var t = this; |
5372 var t = this; |
5124 |
5373 |
5374 // Prevent double toogles by canceling the mouse click event to the button |
|
5375 if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open')) |
|
5376 return; |
|
5377 |
|
5125 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) { |
5378 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) { |
5126 DOM.removeClass(t.id, 'mceListBoxSelected'); |
5379 DOM.removeClass(t.id, t.classPrefix + 'Selected'); |
5127 Event.remove(document, 'mousedown', t.hideMenu, t); |
5380 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t); |
5128 |
5381 |
5129 if (t.menu) |
5382 if (t.menu) |
5130 t.menu.hideMenu(); |
5383 t.menu.hideMenu(); |
5131 } |
5384 } |
5132 }, |
5385 }, |
5134 renderMenu : function() { |
5387 renderMenu : function() { |
5135 var t = this, m; |
5388 var t = this, m; |
5136 |
5389 |
5137 m = t.settings.control_manager.createDropMenu(t.id + '_menu', { |
5390 m = t.settings.control_manager.createDropMenu(t.id + '_menu', { |
5138 menu_line : 1, |
5391 menu_line : 1, |
5139 'class' : 'mceListBoxMenu mceNoIcons', |
5392 'class' : t.classPrefix + 'Menu mceNoIcons', |
5140 max_width : 150, |
5393 max_width : 150, |
5141 max_height : 150 |
5394 max_height : 150 |
5142 }); |
5395 }); |
5143 |
5396 |
5144 m.onHideMenu.add(t.hideMenu, t); |
5397 m.onHideMenu.add(t.hideMenu, t); |
5161 t.onRenderMenu.dispatch(t, m); |
5414 t.onRenderMenu.dispatch(t, m); |
5162 t.menu = m; |
5415 t.menu = m; |
5163 }, |
5416 }, |
5164 |
5417 |
5165 postRender : function() { |
5418 postRender : function() { |
5166 var t = this; |
5419 var t = this, cp = t.classPrefix; |
5167 |
5420 |
5168 Event.add(t.id, 'click', t.showMenu, t); |
5421 Event.add(t.id, 'click', t.showMenu, t); |
5422 Event.add(t.id + '_text', 'focus', function() {t._focused = 1;}); |
|
5423 Event.add(t.id + '_text', 'blur', function() {t._focused = 0;}); |
|
5169 |
5424 |
5170 // Old IE doesn't have hover on all elements |
5425 // Old IE doesn't have hover on all elements |
5171 if (tinymce.isIE6 || !DOM.boxModel) { |
5426 if (tinymce.isIE6 || !DOM.boxModel) { |
5172 Event.add(t.id, 'mouseover', function() { |
5427 Event.add(t.id, 'mouseover', function() { |
5173 if (!DOM.hasClass(t.id, 'mceListBoxDisabled')) |
5428 if (!DOM.hasClass(t.id, cp + 'Disabled')) |
5174 DOM.addClass(t.id, 'mceListBoxHover'); |
5429 DOM.addClass(t.id, cp + 'Hover'); |
5175 }); |
5430 }); |
5176 |
5431 |
5177 Event.add(t.id, 'mouseout', function() { |
5432 Event.add(t.id, 'mouseout', function() { |
5178 if (!DOM.hasClass(t.id, 'mceListBoxDisabled')) |
5433 if (!DOM.hasClass(t.id, cp + 'Disabled')) |
5179 DOM.removeClass(t.id, 'mceListBoxHover'); |
5434 DOM.removeClass(t.id, cp + 'Hover'); |
5180 }); |
5435 }); |
5181 } |
5436 } |
5182 |
5437 |
5183 t.onPostRender.dispatch(t, DOM.get(t.id)); |
5438 t.onPostRender.dispatch(t, DOM.get(t.id)); |
5439 }, |
|
5440 |
|
5441 destroy : function() { |
|
5442 this.parent(); |
|
5443 |
|
5444 Event.clear(this.id + '_text'); |
|
5184 } |
5445 } |
5185 |
5446 |
5186 }); |
5447 }); |
5187 })(); |
5448 })(); |
5188 /* file:jscripts/tiny_mce/classes/ui/NativeListBox.js */ |
5449 /* file:jscripts/tiny_mce/classes/ui/NativeListBox.js */ |
5300 |
5561 |
5301 tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', { |
5562 tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', { |
5302 MenuButton : function(id, s) { |
5563 MenuButton : function(id, s) { |
5303 this.parent(id, s); |
5564 this.parent(id, s); |
5304 this.onRenderMenu = new tinymce.util.Dispatcher(this); |
5565 this.onRenderMenu = new tinymce.util.Dispatcher(this); |
5305 s.menu_container = s.menu_container || document.body; |
5566 s.menu_container = s.menu_container || DOM.doc.body; |
5306 }, |
5567 }, |
5307 |
5568 |
5308 showMenu : function() { |
5569 showMenu : function() { |
5309 var t = this, p1, p2, e = DOM.get(t.id), m; |
5570 var t = this, p1, p2, e = DOM.get(t.id), m; |
5310 |
5571 |
5313 |
5574 |
5314 if (!t.isMenuRendered) { |
5575 if (!t.isMenuRendered) { |
5315 t.renderMenu(); |
5576 t.renderMenu(); |
5316 t.isMenuRendered = true; |
5577 t.isMenuRendered = true; |
5317 } |
5578 } |
5579 |
|
5580 if (t.isMenuVisible) |
|
5581 return t.hideMenu(); |
|
5318 |
5582 |
5319 p1 = DOM.getPos(t.settings.menu_container); |
5583 p1 = DOM.getPos(t.settings.menu_container); |
5320 p2 = DOM.getPos(e); |
5584 p2 = DOM.getPos(e); |
5321 |
5585 |
5322 m = t.menu; |
5586 m = t.menu; |
5323 m.settings.offset_x = p2.x; |
5587 m.settings.offset_x = p2.x; |
5324 m.settings.offset_y = p2.y; |
5588 m.settings.offset_y = p2.y; |
5325 m.settings.vp_offset_x = p2.x; |
5589 m.settings.vp_offset_x = p2.x; |
5326 m.settings.vp_offset_y = p2.y; |
5590 m.settings.vp_offset_y = p2.y; |
5591 m.settings.keyboard_focus = t._focused; |
|
5327 m.showMenu(0, e.clientHeight); |
5592 m.showMenu(0, e.clientHeight); |
5328 |
5593 |
5329 Event.add(document, 'mousedown', t.hideMenu, t); |
5594 Event.add(DOM.doc, 'mousedown', t.hideMenu, t); |
5330 t.setState('Selected', 1); |
5595 t.setState('Selected', 1); |
5596 |
|
5597 t.isMenuVisible = 1; |
|
5331 }, |
5598 }, |
5332 |
5599 |
5333 renderMenu : function() { |
5600 renderMenu : function() { |
5334 var t = this, m; |
5601 var t = this, m; |
5335 |
5602 |
5346 }, |
5613 }, |
5347 |
5614 |
5348 hideMenu : function(e) { |
5615 hideMenu : function(e) { |
5349 var t = this; |
5616 var t = this; |
5350 |
5617 |
5618 // Prevent double toogles by canceling the mouse click event to the button |
|
5619 if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';})) |
|
5620 return; |
|
5621 |
|
5351 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) { |
5622 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) { |
5352 t.setState('Selected', 0); |
5623 t.setState('Selected', 0); |
5353 Event.remove(document, 'mousedown', t.hideMenu, t); |
5624 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t); |
5354 if (t.menu) |
5625 if (t.menu) |
5355 t.menu.hideMenu(); |
5626 t.menu.hideMenu(); |
5356 } |
5627 } |
5628 |
|
5629 t.isMenuVisible = 0; |
|
5357 }, |
5630 }, |
5358 |
5631 |
5359 postRender : function() { |
5632 postRender : function() { |
5360 var t = this, s = t.settings; |
5633 var t = this, s = t.settings; |
5361 |
5634 |
5389 h = '<tbody><tr>'; |
5662 h = '<tbody><tr>'; |
5390 |
5663 |
5391 if (s.image) |
5664 if (s.image) |
5392 h1 = DOM.createHTML('img ', {src : s.image, 'class' : 'mceAction ' + s['class']}); |
5665 h1 = DOM.createHTML('img ', {src : s.image, 'class' : 'mceAction ' + s['class']}); |
5393 else |
5666 else |
5394 h1 = DOM.createHTML('span', {'class' : 'mceAction ' + s['class']}); |
5667 h1 = DOM.createHTML('span', {'class' : 'mceAction ' + s['class']}, ''); |
5395 |
5668 |
5396 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>'; |
5669 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>'; |
5397 |
5670 |
5398 h1 = DOM.createHTML('span', {'class' : 'mceOpen ' + s['class']}); |
5671 h1 = DOM.createHTML('span', {'class' : 'mceOpen ' + s['class']}); |
5399 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>'; |
5672 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>'; |
5412 s.onclick(t.value); |
5685 s.onclick(t.value); |
5413 }); |
5686 }); |
5414 } |
5687 } |
5415 |
5688 |
5416 Event.add(t.id + '_open', 'click', t.showMenu, t); |
5689 Event.add(t.id + '_open', 'click', t.showMenu, t); |
5690 Event.add(t.id + '_open', 'focus', function() {t._focused = 1;}); |
|
5691 Event.add(t.id + '_open', 'blur', function() {t._focused = 0;}); |
|
5417 |
5692 |
5418 // Old IE doesn't have hover on all elements |
5693 // Old IE doesn't have hover on all elements |
5419 if (tinymce.isIE6 || !DOM.boxModel) { |
5694 if (tinymce.isIE6 || !DOM.boxModel) { |
5420 Event.add(t.id, 'mouseover', function() { |
5695 Event.add(t.id, 'mouseover', function() { |
5421 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled')) |
5696 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled')) |
5425 Event.add(t.id, 'mouseout', function() { |
5700 Event.add(t.id, 'mouseout', function() { |
5426 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled')) |
5701 if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled')) |
5427 DOM.removeClass(t.id, 'mceSplitButtonHover'); |
5702 DOM.removeClass(t.id, 'mceSplitButtonHover'); |
5428 }); |
5703 }); |
5429 } |
5704 } |
5705 }, |
|
5706 |
|
5707 destroy : function() { |
|
5708 this.parent(); |
|
5709 |
|
5710 Event.clear(this.id + '_action'); |
|
5711 Event.clear(this.id + '_open'); |
|
5430 } |
5712 } |
5431 |
5713 |
5432 }); |
5714 }); |
5433 })(); |
5715 })(); |
5434 |
5716 |
5451 |
5733 |
5452 t.value = s.default_color; |
5734 t.value = s.default_color; |
5453 }, |
5735 }, |
5454 |
5736 |
5455 showMenu : function() { |
5737 showMenu : function() { |
5456 var t = this, r, p, e; |
5738 var t = this, r, p, e, p2; |
5457 |
5739 |
5458 if (t.isDisabled()) |
5740 if (t.isDisabled()) |
5459 return; |
5741 return; |
5460 |
5742 |
5461 if (!t.isMenuRendered) { |
5743 if (!t.isMenuRendered) { |
5462 t.renderMenu(); |
5744 t.renderMenu(); |
5463 t.isMenuRendered = true; |
5745 t.isMenuRendered = true; |
5464 } |
5746 } |
5747 |
|
5748 if (t.isMenuVisible) |
|
5749 return t.hideMenu(); |
|
5465 |
5750 |
5466 e = DOM.get(t.id); |
5751 e = DOM.get(t.id); |
5467 DOM.show(t.id + '_menu'); |
5752 DOM.show(t.id + '_menu'); |
5468 DOM.addClass(e, 'mceSplitButtonSelected'); |
5753 DOM.addClass(e, 'mceSplitButtonSelected'); |
5469 p2 = DOM.getPos(e); |
5754 p2 = DOM.getPos(e); |
5470 DOM.setStyles(t.id + '_menu', { |
5755 DOM.setStyles(t.id + '_menu', { |
5471 left : p2.x, |
5756 left : p2.x, |
5472 top : p2.y + e.clientHeight, |
5757 top : p2.y + e.clientHeight, |
5473 zIndex : 150 |
5758 zIndex : 200000 |
5474 }); |
5759 }); |
5475 e = 0; |
5760 e = 0; |
5476 |
5761 |
5477 Event.add(document, 'mousedown', t.hideMenu, t); |
5762 Event.add(DOM.doc, 'mousedown', t.hideMenu, t); |
5763 |
|
5764 if (t._focused) { |
|
5765 t._keyHandler = Event.add(t.id + '_menu', 'keydown', function(e) { |
|
5766 if (e.keyCode == 27) |
|
5767 t.hideMenu(); |
|
5768 }); |
|
5769 |
|
5770 DOM.select('a', t.id + '_menu')[0].focus(); // Select first link |
|
5771 } |
|
5772 |
|
5773 t.isMenuVisible = 1; |
|
5478 }, |
5774 }, |
5479 |
5775 |
5480 hideMenu : function(e) { |
5776 hideMenu : function(e) { |
5481 var t = this; |
5777 var t = this; |
5482 |
5778 |
5779 // Prevent double toogles by canceling the mouse click event to the button |
|
5780 if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';})) |
|
5781 return; |
|
5782 |
|
5483 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceSplitButtonMenu');})) { |
5783 if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceSplitButtonMenu');})) { |
5484 DOM.removeClass(t.id, 'mceSplitButtonSelected'); |
5784 DOM.removeClass(t.id, 'mceSplitButtonSelected'); |
5485 Event.remove(document, 'mousedown', t.hideMenu, t); |
5785 Event.remove(DOM.doc, 'mousedown', t.hideMenu, t); |
5786 Event.remove(t.id + '_menu', 'keydown', t._keyHandler); |
|
5486 DOM.hide(t.id + '_menu'); |
5787 DOM.hide(t.id + '_menu'); |
5487 } |
5788 } |
5789 |
|
5790 t.isMenuVisible = 0; |
|
5488 }, |
5791 }, |
5489 |
5792 |
5490 renderMenu : function() { |
5793 renderMenu : function() { |
5491 var t = this, m, i = 0, s = t.settings, n, tb, tr, w; |
5794 var t = this, m, i = 0, s = t.settings, n, tb, tr, w; |
5492 |
5795 |
5511 |
5814 |
5512 n = DOM.add(n, 'a', { |
5815 n = DOM.add(n, 'a', { |
5513 href : 'javascript:;', |
5816 href : 'javascript:;', |
5514 style : { |
5817 style : { |
5515 backgroundColor : '#' + c |
5818 backgroundColor : '#' + c |
5516 } |
5819 }, |
5517 }); |
5820 mce_color : '#' + c |
5518 |
|
5519 Event.add(n, 'mousedown', function() { |
|
5520 t.setColor('#' + c); |
|
5521 }); |
5821 }); |
5522 }); |
5822 }); |
5523 |
5823 |
5524 if (s.more_colors_func) { |
5824 if (s.more_colors_func) { |
5525 n = DOM.add(tb, 'tr'); |
5825 n = DOM.add(tb, 'tr'); |
5526 n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'}); |
5826 n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'}); |
5527 n = DOM.add(n, 'a', {href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title); |
5827 n = DOM.add(n, 'a', {id : t.id + '_more', href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title); |
5528 |
5828 |
5529 Event.add(n, 'click', function(e) { |
5829 Event.add(n, 'click', function(e) { |
5530 s.more_colors_func.call(s.more_colors_scope || this); |
5830 s.more_colors_func.call(s.more_colors_scope || this); |
5531 return Event.cancel(e); // Cancel to fix onbeforeunload problem |
5831 return Event.cancel(e); // Cancel to fix onbeforeunload problem |
5532 }); |
5832 }); |
5533 } |
5833 } |
5534 |
5834 |
5535 DOM.addClass(m, 'mceColorSplitMenu'); |
5835 DOM.addClass(m, 'mceColorSplitMenu'); |
5536 |
5836 |
5837 Event.add(t.id + '_menu', 'click', function(e) { |
|
5838 var c; |
|
5839 |
|
5840 e = e.target; |
|
5841 |
|
5842 if (e.nodeName == 'A' && (c = e.getAttribute('mce_color'))) |
|
5843 t.setColor(c); |
|
5844 |
|
5845 return Event.cancel(e); // Prevent IE auto save warning |
|
5846 }); |
|
5847 |
|
5537 return w; |
5848 return w; |
5538 }, |
5849 }, |
5539 |
5850 |
5540 setColor : function(c) { |
5851 setColor : function(c) { |
5541 var t = this, p, s = this.settings, co = s.menu_container, po, cp, id = t.id + '_preview'; |
5852 var t = this; |
5542 |
5853 |
5543 if (!(p = DOM.get(id))) { |
5854 DOM.setStyle(t.id + '_preview', 'backgroundColor', c); |
5544 DOM.setStyle(t.id + '_action', 'position', 'relative'); |
|
5545 p = DOM.add(t.id + '_action', 'div', {id : id, 'class' : 'mceColorPreview'}); |
|
5546 } |
|
5547 |
|
5548 p.style.backgroundColor = c; |
|
5549 |
5855 |
5550 t.value = c; |
5856 t.value = c; |
5551 t.hideMenu(); |
5857 t.hideMenu(); |
5552 s.onselect(c); |
5858 t.settings.onselect(c); |
5859 }, |
|
5860 |
|
5861 postRender : function() { |
|
5862 var t = this, id = t.id; |
|
5863 |
|
5864 t.parent(); |
|
5865 DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'}); |
|
5866 }, |
|
5867 |
|
5868 destroy : function() { |
|
5869 this.parent(); |
|
5870 |
|
5871 Event.clear(this.id + '_menu'); |
|
5872 Event.clear(this.id + '_more'); |
|
5873 DOM.remove(this.id + '_menu'); |
|
5553 } |
5874 } |
5554 |
5875 |
5555 }); |
5876 }); |
5556 })(); |
5877 })(); |
5557 |
5878 |
5558 /* file:jscripts/tiny_mce/classes/ui/Toolbar.js */ |
5879 /* file:jscripts/tiny_mce/classes/ui/Toolbar.js */ |
5559 |
5880 |
5560 tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', { |
5881 tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', { |
5561 renderHTML : function() { |
5882 renderHTML : function() { |
5562 var t = this, h = '', c = 'mceToolbarEnd', co, dom = tinymce.DOM, s = t.settings; |
5883 var t = this, h = '', c, co, dom = tinymce.DOM, s = t.settings, i, pr, nx, cl; |
5563 |
5884 |
5564 h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '<!-- IE -->')); |
5885 cl = t.controls; |
5565 |
5886 for (i=0; i<cl.length; i++) { |
5566 tinymce.each(t.controls, function(c) { |
5887 // Get current control, prev control, next control and if the control is a list box or not |
5567 h += '<td>' + c.renderHTML() + '</td>'; |
5888 co = cl[i]; |
5568 }); |
5889 pr = cl[i - 1]; |
5569 |
5890 nx = cl[i + 1]; |
5570 co = t.controls[t.controls.length - 1].constructor; |
5891 |
5571 |
5892 // Add toolbar start |
5572 if (co === tinymce.ui.Button) |
5893 if (i === 0) { |
5894 c = 'mceToolbarStart'; |
|
5895 |
|
5896 if (co.Button) |
|
5897 c += ' mceToolbarStartButton'; |
|
5898 else if (co.SplitButton) |
|
5899 c += ' mceToolbarStartSplitButton'; |
|
5900 else if (co.ListBox) |
|
5901 c += ' mceToolbarStartListBox'; |
|
5902 |
|
5903 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->')); |
|
5904 } |
|
5905 |
|
5906 // Add toolbar end before list box and after the previous button |
|
5907 // This is to fix the o2k7 editor skins |
|
5908 if (pr && co.ListBox) { |
|
5909 if (pr.Button || pr.SplitButton) |
|
5910 h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, '<!-- IE -->')); |
|
5911 } |
|
5912 |
|
5913 // Render control HTML |
|
5914 |
|
5915 // IE 8 quick fix, needed to propertly generate a hit area for anchors |
|
5916 if (dom.stdMode) |
|
5917 h += '<td style="position: relative">' + co.renderHTML() + '</td>'; |
|
5918 else |
|
5919 h += '<td>' + co.renderHTML() + '</td>'; |
|
5920 |
|
5921 // Add toolbar start after list box and before the next button |
|
5922 // This is to fix the o2k7 editor skins |
|
5923 if (nx && co.ListBox) { |
|
5924 if (nx.Button || nx.SplitButton) |
|
5925 h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '<!-- IE -->')); |
|
5926 } |
|
5927 } |
|
5928 |
|
5929 c = 'mceToolbarEnd'; |
|
5930 |
|
5931 if (co.Button) |
|
5573 c += ' mceToolbarEndButton'; |
5932 c += ' mceToolbarEndButton'; |
5574 else if (co === tinymce.ui.SplitButton) |
5933 else if (co.SplitButton) |
5575 c += ' mceToolbarEndSplitButton'; |
5934 c += ' mceToolbarEndSplitButton'; |
5576 else if (co === tinymce.ui.ListBox) |
5935 else if (co.ListBox) |
5577 c += ' mceToolbarEndListBox'; |
5936 c += ' mceToolbarEndListBox'; |
5578 |
5937 |
5579 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->')); |
5938 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->')); |
5580 |
5939 |
5581 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>'); |
5940 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>'); |
5621 |
5980 |
5622 return o; |
5981 return o; |
5623 }, |
5982 }, |
5624 |
5983 |
5625 load : function(n, u, cb, s) { |
5984 load : function(n, u, cb, s) { |
5985 var t = this; |
|
5986 |
|
5987 if (t.urls[n]) |
|
5988 return; |
|
5989 |
|
5626 if (u.indexOf('/') != 0 && u.indexOf('://') == -1) |
5990 if (u.indexOf('/') != 0 && u.indexOf('://') == -1) |
5627 u = tinymce.baseURL + '/' + u; |
5991 u = tinymce.baseURL + '/' + u; |
5628 |
5992 |
5629 this.urls[n] = u.substring(0, u.lastIndexOf('/')); |
5993 t.urls[n] = u.substring(0, u.lastIndexOf('/')); |
5630 tinymce.ScriptLoader.add(u, cb, s); |
5994 tinymce.ScriptLoader.add(u, cb, s); |
5631 } |
5995 } |
5632 |
5996 |
5633 }); |
5997 }); |
5634 |
5998 |
5638 }()); |
6002 }()); |
5639 /* file:jscripts/tiny_mce/classes/EditorManager.js */ |
6003 /* file:jscripts/tiny_mce/classes/EditorManager.js */ |
5640 |
6004 |
5641 (function() { |
6005 (function() { |
5642 // Shorten names |
6006 // Shorten names |
5643 var each = tinymce.each, extend = tinymce.extend, DOM = tinymce.DOM, Event = tinymce.dom.Event, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager; |
6007 var each = tinymce.each, extend = tinymce.extend, DOM = tinymce.DOM, Event = tinymce.dom.Event, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, explode = tinymce.explode; |
5644 |
6008 |
5645 tinymce.create('static tinymce.EditorManager', { |
6009 tinymce.create('static tinymce.EditorManager', { |
5646 editors : {}, |
6010 editors : {}, |
5647 i18n : {}, |
6011 i18n : {}, |
5648 activeEditor : null, |
6012 activeEditor : null, |
5649 |
6013 |
6014 preInit : function() { |
|
6015 var t = this, lo = window.location; |
|
6016 |
|
6017 // Setup some URLs where the editor API is located and where the document is |
|
6018 tinymce.documentBaseURL = lo.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, ''); |
|
6019 if (!/[\/\\]$/.test(tinymce.documentBaseURL)) |
|
6020 tinymce.documentBaseURL += '/'; |
|
6021 |
|
6022 tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL); |
|
6023 tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL); |
|
6024 |
|
6025 // Setup document domain |
|
6026 if (tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname) |
|
6027 document.domain = tinymce.relaxedDomain = lo.hostname.replace(/.*\.(.+\..+)$/, '$1'); |
|
6028 |
|
6029 // Add before unload listener |
|
6030 // This was required since IE was leaking memory if you added and removed beforeunload listeners |
|
6031 // with attachEvent/detatchEvent so this only adds one listener and instances can the attach to the onBeforeUnload event |
|
6032 t.onBeforeUnload = new tinymce.util.Dispatcher(t); |
|
6033 |
|
6034 // Must be on window or IE will leak if the editor is placed in frame or iframe |
|
6035 Event.add(window, 'beforeunload', function(e) { |
|
6036 t.onBeforeUnload.dispatch(t, e); |
|
6037 }); |
|
6038 }, |
|
6039 |
|
5650 init : function(s) { |
6040 init : function(s) { |
5651 var t = this, pl, sl = tinymce.ScriptLoader, c; |
6041 var t = this, pl, sl = tinymce.ScriptLoader, c, e; |
5652 |
6042 |
5653 function execCallback(se, n, s) { |
6043 function execCallback(se, n, s) { |
5654 var f = se[n]; |
6044 var f = se[n]; |
5655 |
6045 |
5656 if (!f) |
6046 if (!f) |
5683 if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme]) |
6073 if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme]) |
5684 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js'); |
6074 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js'); |
5685 |
6075 |
5686 // Load plugins |
6076 // Load plugins |
5687 if (s.plugins) { |
6077 if (s.plugins) { |
5688 pl = s.plugins.split(','); |
6078 pl = explode(s.plugins); |
5689 |
6079 |
5690 // Load compat2x first |
6080 // Load compat2x first |
5691 if (tinymce.inArray(pl, 'compat2x') != -1) |
6081 if (tinymce.inArray(pl, 'compat2x') != -1) |
5692 PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js'); |
6082 PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js'); |
5693 |
6083 |
5714 |
6104 |
5715 // Verify that it's a valid browser |
6105 // Verify that it's a valid browser |
5716 if (s.browsers) { |
6106 if (s.browsers) { |
5717 l = false; |
6107 l = false; |
5718 |
6108 |
5719 each(s.browsers.split(','), function(v) { |
6109 each(explode(s.browsers), function(v) { |
5720 switch (v) { |
6110 switch (v) { |
5721 case 'ie': |
6111 case 'ie': |
5722 case 'msie': |
6112 case 'msie': |
5723 if (tinymce.isIE) |
6113 if (tinymce.isIE) |
5724 l = true; |
6114 l = true; |
5751 switch (s.mode) { |
6141 switch (s.mode) { |
5752 case "exact": |
6142 case "exact": |
5753 l = s.elements || ''; |
6143 l = s.elements || ''; |
5754 |
6144 |
5755 if(l.length > 0) { |
6145 if(l.length > 0) { |
5756 each(l.split(','), function(v) { |
6146 each(explode(l), function(v) { |
5757 if (DOM.get(v)) |
6147 if (DOM.get(v)) |
5758 new tinymce.Editor(v, s).render(1); |
6148 new tinymce.Editor(v, s).render(1); |
5759 else { |
6149 else { |
5760 c = 0; |
6150 c = 0; |
5761 |
6151 |
5774 break; |
6164 break; |
5775 |
6165 |
5776 case "textareas": |
6166 case "textareas": |
5777 case "specific_textareas": |
6167 case "specific_textareas": |
5778 function hasClass(n, c) { |
6168 function hasClass(n, c) { |
5779 return new RegExp('\\b' + c + '\\b', 'g').test(n.className); |
6169 return c.constructor === RegExp ? c.test(n.className) : DOM.hasClass(n, c); |
5780 }; |
6170 }; |
5781 |
6171 |
5782 each(DOM.select('textarea'), function(v) { |
6172 each(DOM.select('textarea'), function(v) { |
5783 if (s.editor_deselector && hasClass(v, s.editor_deselector)) |
6173 if (s.editor_deselector && hasClass(v, s.editor_deselector)) |
5784 return; |
6174 return; |
5785 |
6175 |
5786 if (!s.editor_selector || hasClass(v, s.editor_selector)) |
6176 if (!s.editor_selector || hasClass(v, s.editor_selector)) { |
5787 new tinymce.Editor(v.id = (v.id || v.name || (v.id = DOM.uniqueId())), s).render(1); |
6177 // Can we use the name |
6178 e = DOM.get(v.name); |
|
6179 if (!v.id && !e) |
|
6180 v.id = v.name; |
|
6181 |
|
6182 // Generate unique name if missing or already exists |
|
6183 if (!v.id || t.get(v.id)) |
|
6184 v.id = DOM.uniqueId(); |
|
6185 |
|
6186 new tinymce.Editor(v.id, s).render(1); |
|
6187 } |
|
5788 }); |
6188 }); |
5789 break; |
6189 break; |
5790 } |
6190 } |
5791 |
6191 |
5792 // Call onInit when all editors are initialized |
6192 // Call onInit when all editors are initialized |
5846 t._setActive(e); |
6246 t._setActive(e); |
5847 return false; // Break |
6247 return false; // Break |
5848 }); |
6248 }); |
5849 } |
6249 } |
5850 |
6250 |
5851 e._destroy(); |
6251 e.destroy(); |
5852 |
6252 |
5853 return e; |
6253 return e; |
5854 }, |
6254 }, |
5855 |
6255 |
5856 execCommand : function(c, u, v) { |
6256 execCommand : function(c, u, v) { |
5857 var t = this, ed = t.get(v); |
6257 var t = this, ed = t.get(v), w; |
5858 |
6258 |
5859 // Manager commands |
6259 // Manager commands |
5860 switch (c) { |
6260 switch (c) { |
5861 case "mceFocus": |
6261 case "mceFocus": |
5862 ed.focus(); |
6262 ed.focus(); |
5863 return true; |
6263 return true; |
5864 |
6264 |
5865 case "mceAddEditor": |
6265 case "mceAddEditor": |
5866 case "mceAddControl": |
6266 case "mceAddControl": |
5867 new tinymce.Editor(v, t.settings).render(); |
6267 if (!t.get(v)) |
6268 new tinymce.Editor(v, t.settings).render(); |
|
6269 |
|
5868 return true; |
6270 return true; |
5869 |
6271 |
5870 case "mceAddFrameControl": |
6272 case "mceAddFrameControl": |
5871 // TODO: Implement this |
6273 w = v.window; |
6274 |
|
6275 // Add tinyMCE global instance and tinymce namespace to specified window |
|
6276 w.tinyMCE = tinyMCE; |
|
6277 w.tinymce = tinymce; |
|
6278 |
|
6279 tinymce.DOM.doc = w.document; |
|
6280 tinymce.DOM.win = w; |
|
6281 |
|
6282 ed = new tinymce.Editor(v.element_id, v); |
|
6283 ed.render(); |
|
6284 |
|
6285 // Fix IE memory leaks |
|
6286 if (tinymce.isIE) { |
|
6287 function clr() { |
|
6288 ed.destroy(); |
|
6289 w.detachEvent('onunload', clr); |
|
6290 w = w.tinyMCE = w.tinymce = null; // IE leak |
|
6291 }; |
|
6292 |
|
6293 w.attachEvent('onunload', clr); |
|
6294 } |
|
6295 |
|
6296 v.page_window = null; |
|
6297 |
|
5872 return true; |
6298 return true; |
5873 |
6299 |
5874 case "mceRemoveEditor": |
6300 case "mceRemoveEditor": |
5875 case "mceRemoveControl": |
6301 case "mceRemoveControl": |
5876 ed.remove(); |
6302 ed.remove(); |
5939 this.selectedInstance = this.activeEditor = e; |
6365 this.selectedInstance = this.activeEditor = e; |
5940 } |
6366 } |
5941 |
6367 |
5942 }); |
6368 }); |
5943 |
6369 |
5944 // Setup some URLs where the editor API is located and where the document is |
6370 tinymce.EditorManager.preInit(); |
5945 tinymce.documentBaseURL = window.location.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, ''); |
|
5946 if (!/[\/\\]$/.test(tinymce.documentBaseURL)) |
|
5947 tinymce.documentBaseURL += '/'; |
|
5948 |
|
5949 tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL); |
|
5950 tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL); |
|
5951 |
|
5952 if (tinymce.EditorManager.baseURI.host != window.location.hostname) |
|
5953 document.domain = tinymce.relaxedDomain = window.location.hostname.replace(/.*\.(.+\..+)$/, '$1'); |
|
5954 })(); |
6371 })(); |
5955 |
6372 |
5956 // Short for editor manager window.tinyMCE is needed when TinyMCE gets loaded though a XHR call |
6373 // Short for editor manager window.tinyMCE is needed when TinyMCE gets loaded though a XHR call |
5957 var tinyMCE = window.tinyMCE = tinymce.EditorManager; |
6374 var tinyMCE = window.tinyMCE = tinymce.EditorManager; |
5958 |
6375 |
5960 |
6377 |
5961 (function() { |
6378 (function() { |
5962 var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher; |
6379 var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher; |
5963 var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit; |
6380 var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit; |
5964 var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager; |
6381 var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager; |
5965 var inArray = tinymce.inArray, grep = tinymce.grep; |
6382 var inArray = tinymce.inArray, grep = tinymce.grep, explode = tinymce.explode; |
5966 |
6383 |
5967 tinymce.create('tinymce.Editor', { |
6384 tinymce.create('tinymce.Editor', { |
5968 Editor : function(id, s) { |
6385 Editor : function(id, s) { |
5969 var t = this; |
6386 var t = this; |
5970 |
6387 |
6048 convert_fonts_to_spans : true, |
6465 convert_fonts_to_spans : true, |
6049 font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large', |
6466 font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large', |
6050 apply_source_formatting : 1, |
6467 apply_source_formatting : 1, |
6051 directionality : 'ltr', |
6468 directionality : 'ltr', |
6052 forced_root_block : 'p', |
6469 forced_root_block : 'p', |
6053 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,-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,-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]', |
6470 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,-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', |
6054 hidden_input : 1, |
6471 hidden_input : 1, |
6055 padd_empty_editor : 1, |
6472 padd_empty_editor : 1, |
6056 render_ui : 1, |
6473 render_ui : 1, |
6057 init_theme : 1, |
6474 init_theme : 1, |
6058 force_p_newlines : 1, |
6475 force_p_newlines : 1, |
6116 } |
6533 } |
6117 }); |
6534 }); |
6118 } |
6535 } |
6119 |
6536 |
6120 if (s.add_unload_trigger) { |
6537 if (s.add_unload_trigger) { |
6121 Event.add(document, 'beforeunload', function() { |
6538 t._beforeUnload = tinyMCE.onBeforeUnload.add(function() { |
6122 if (t.initialized && !t.destroyed) |
6539 if (t.initialized && !t.destroyed && !t.isHidden()) |
6123 t.save({format : 'raw', no_events : true}); |
6540 t.save({format : 'raw', no_events : true}); |
6124 }); |
6541 }); |
6125 } |
6542 } |
6126 |
6543 |
6127 tinymce.addUnload(t._destroy, t); |
6544 tinymce.addUnload(t.destroy, t); |
6128 |
6545 |
6129 if (s.submit_patch) { |
6546 if (s.submit_patch) { |
6130 t.onBeforeRenderUI.add(function() { |
6547 t.onBeforeRenderUI.add(function() { |
6131 var n = t.getElement().form; |
6548 var n = t.getElement().form; |
6132 |
6549 |
6160 sl.add(tinymce.baseURL + '/langs/' + s.language + '.js'); |
6577 sl.add(tinymce.baseURL + '/langs/' + s.language + '.js'); |
6161 |
6578 |
6162 if (s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme]) |
6579 if (s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme]) |
6163 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js'); |
6580 ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js'); |
6164 |
6581 |
6165 each(s.plugins.split(','), function(p) { |
6582 each(explode(s.plugins), function(p) { |
6166 if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) { |
6583 if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) { |
6167 // Skip safari plugin for other browsers |
6584 // Skip safari plugin for other browsers |
6168 if (!isWebKit && p == 'safari') |
6585 if (!isWebKit && p == 'safari') |
6169 return; |
6586 return; |
6170 |
6587 |
6213 |
6630 |
6214 if (t.theme.init && s.init_theme) |
6631 if (t.theme.init && s.init_theme) |
6215 t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, '')); |
6632 t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, '')); |
6216 |
6633 |
6217 // Create all plugins |
6634 // Create all plugins |
6218 each(s.plugins.replace(/\-/g, '').split(','), function(p) { |
6635 each(explode(s.plugins.replace(/\-/g, '')), function(p) { |
6219 var c = PluginManager.get(p), u = PluginManager.urls[p] || tinymce.documentBaseURL.replace(/\/$/, ''), po; |
6636 var c = PluginManager.get(p), u = PluginManager.urls[p] || tinymce.documentBaseURL.replace(/\/$/, ''), po; |
6220 |
6637 |
6221 if (c) { |
6638 if (c) { |
6222 po = new c(t, u); |
6639 po = new c(t, u); |
6223 |
6640 |
6227 po.init(t, u); |
6644 po.init(t, u); |
6228 } |
6645 } |
6229 }); |
6646 }); |
6230 |
6647 |
6231 // Setup popup CSS path(s) |
6648 // Setup popup CSS path(s) |
6232 s.popup_css = t.baseURI.toAbsolute(s.popup_css || "themes/" + s.theme + "/skins/" + s.skin + "/dialog.css"); |
6649 if (s.popup_css) |
6650 s.popup_css = t.documentBaseURI.toAbsolute(s.popup_css); |
|
6651 else |
|
6652 s.popup_css = t.baseURI.toAbsolute("themes/" + s.theme + "/skins/" + s.skin + "/dialog.css"); |
|
6233 |
6653 |
6234 if (s.popup_css_add) |
6654 if (s.popup_css_add) |
6235 s.popup_css += ',' + s.popup_css_add; |
6655 s.popup_css += ',' + t.documentBaseURI.toAbsolute(s.popup_css_add); |
6236 |
6656 |
6237 // Setup control factory |
6657 // Setup control factory |
6238 t.controlManager = new tinymce.ControlManager(t); |
6658 t.controlManager = new tinymce.ControlManager(t); |
6239 t.undoManager = new tinymce.UndoManager(t); |
6659 t.undoManager = new tinymce.UndoManager(t); |
6240 |
6660 |
6241 // Pass through |
6661 // Pass through |
6242 t.undoManager.onAdd.add(function(um, l) { |
6662 t.undoManager.onAdd.add(function(um, l) { |
6243 return t.onChange.dispatch(t, l, um); |
6663 if (!l.initial) |
6664 return t.onChange.dispatch(t, l, um); |
|
6244 }); |
6665 }); |
6245 |
6666 |
6246 t.undoManager.onUndo.add(function(um, l) { |
6667 t.undoManager.onUndo.add(function(um, l) { |
6247 return t.onUndo.dispatch(t, l, um); |
6668 return t.onUndo.dispatch(t, l, um); |
6248 }); |
6669 }); |
6279 // Enables users to override the control factory |
6700 // Enables users to override the control factory |
6280 t.onBeforeRenderUI.dispatch(t, t.controlManager); |
6701 t.onBeforeRenderUI.dispatch(t, t.controlManager); |
6281 |
6702 |
6282 // Measure box |
6703 // Measure box |
6283 if (s.render_ui) { |
6704 if (s.render_ui) { |
6284 w = s.width || e.style.width || e.clientWidth; |
6705 w = s.width || e.style.width || e.offsetWidth; |
6285 h = s.height || e.style.height || e.clientHeight; |
6706 h = s.height || e.style.height || e.offsetHeight; |
6286 t.orgDisplay = e.style.display; |
6707 t.orgDisplay = e.style.display; |
6287 re = new RegExp('%|px|auto', 'gi'); |
6708 re = /^[0-9\.]+(|px)$/i; |
6288 |
6709 |
6289 if (!re.test('' + w)) |
6710 if (re.test('' + w)) |
6290 w = Math.max(parseInt(w) + (o.deltaWidth || 0), 100); |
6711 w = Math.max(parseInt(w) + (o.deltaWidth || 0), 100); |
6291 |
6712 |
6292 if (!re.test('' + h)) |
6713 if (re.test('' + h)) |
6293 h = Math.max(parseInt(h) + (o.deltaHeight || 0), 100); |
6714 h = Math.max(parseInt(h) + (o.deltaHeight || 0), 100); |
6294 |
6715 |
6295 // Render UI |
6716 // Render UI |
6296 o = t.theme.renderUI({ |
6717 o = t.theme.renderUI({ |
6297 targetNode : e, |
6718 targetNode : e, |
6313 |
6734 |
6314 h = (o.iframeHeight || h) + ((h + '').indexOf('%') == -1 ? (o.deltaHeight || 0) : ''); |
6735 h = (o.iframeHeight || h) + ((h + '').indexOf('%') == -1 ? (o.deltaHeight || 0) : ''); |
6315 if (h < 100) |
6736 if (h < 100) |
6316 h = 100; |
6737 h = 100; |
6317 |
6738 |
6318 t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '" />'; |
6739 t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '"></base>'; |
6319 t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; |
6740 t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; |
6320 |
6741 |
6321 if (tinymce.relaxedDomain) |
6742 if (tinymce.relaxedDomain) |
6322 t.iframeHTML += '<script type="text/javascript">document.domain = "' + tinymce.relaxedDomain + '";</script>'; |
6743 t.iframeHTML += '<script type="text/javascript">document.domain = "' + tinymce.relaxedDomain + '";</script>'; |
6323 |
6744 |
6370 e = n = o = null; // Cleanup |
6791 e = n = o = null; // Cleanup |
6371 } |
6792 } |
6372 }, |
6793 }, |
6373 |
6794 |
6374 setupIframe : function() { |
6795 setupIframe : function() { |
6375 var t = this, s = t.settings, e = DOM.get(t.id), d = t.getDoc(), h; |
6796 var t = this, s = t.settings, e = DOM.get(t.id), d = t.getDoc(), h, b; |
6376 |
6797 |
6377 // Setup iframe body |
6798 // Setup iframe body |
6378 if (!isIE || !tinymce.relaxedDomain) { |
6799 if (!isIE || !tinymce.relaxedDomain) { |
6379 d.open(); |
6800 d.open(); |
6380 d.write(t.iframeHTML); |
6801 d.write(t.iframeHTML); |
6390 // The design mode will be set ones the editor is focused |
6811 // The design mode will be set ones the editor is focused |
6391 } |
6812 } |
6392 } |
6813 } |
6393 |
6814 |
6394 // IE needs to use contentEditable or it will display non secure items for HTTPS |
6815 // IE needs to use contentEditable or it will display non secure items for HTTPS |
6395 if (isIE) |
6816 if (isIE) { |
6396 t.getBody().contentEditable = true; |
6817 // It will not steal focus if we hide it while setting contentEditable |
6818 b = t.getBody(); |
|
6819 DOM.hide(b); |
|
6820 b.contentEditable = true; |
|
6821 DOM.show(b); |
|
6822 } |
|
6397 |
6823 |
6398 // Setup objects |
6824 // Setup objects |
6399 t.dom = new tinymce.DOM.DOMUtils(t.getDoc(), { |
6825 t.dom = new tinymce.DOM.DOMUtils(t.getDoc(), { |
6400 keep_values : true, |
6826 keep_values : true, |
6401 url_converter : t.convertURL, |
6827 url_converter : t.convertURL, |
6458 if (s.auto_resize) |
6884 if (s.auto_resize) |
6459 t.onNodeChange.add(t.resizeToContent, t); |
6885 t.onNodeChange.add(t.resizeToContent, t); |
6460 |
6886 |
6461 if (s.custom_elements) { |
6887 if (s.custom_elements) { |
6462 function handleCustom(ed, o) { |
6888 function handleCustom(ed, o) { |
6463 each(s.custom_elements.split(','), function(v) { |
6889 each(explode(s.custom_elements), function(v) { |
6464 var n; |
6890 var n; |
6465 |
6891 |
6466 if (v.indexOf('~') === 0) { |
6892 if (v.indexOf('~') === 0) { |
6467 v = v.substring(1); |
6893 v = v.substring(1); |
6468 n = 'span'; |
6894 n = 'span'; |
6603 }); |
7029 }); |
6604 |
7030 |
6605 // Remove empty contents |
7031 // Remove empty contents |
6606 if (s.padd_empty_editor) { |
7032 if (s.padd_empty_editor) { |
6607 t.onPostProcess.add(function(ed, o) { |
7033 t.onPostProcess.add(function(ed, o) { |
6608 o.content = o.content.replace(/^<p>( |#160;|\s)<\/p>$/, ''); |
7034 o.content = o.content.replace(/^(<p>( | |\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/, ''); |
6609 }); |
7035 }); |
6610 } |
7036 } |
6611 |
7037 |
6612 if (isGecko) { |
7038 if (isGecko) { |
6613 try { |
7039 try { |
6637 t.focus(true); |
7063 t.focus(true); |
6638 t.nodeChanged({initial : 1}); |
7064 t.nodeChanged({initial : 1}); |
6639 |
7065 |
6640 // Load specified content CSS last |
7066 // Load specified content CSS last |
6641 if (s.content_css) { |
7067 if (s.content_css) { |
6642 tinymce.each(s.content_css.split(','), function(u) { |
7068 tinymce.each(explode(s.content_css), function(u) { |
6643 t.dom.loadCSS(t.documentBaseURI.toAbsolute(u)); |
7069 t.dom.loadCSS(t.documentBaseURI.toAbsolute(u)); |
6644 }); |
7070 }); |
6645 } |
7071 } |
6646 |
7072 |
6647 // Handle auto focus |
7073 // Handle auto focus |
6721 |
7147 |
6722 if (ty === 'hash') { |
7148 if (ty === 'hash') { |
6723 o = {}; |
7149 o = {}; |
6724 |
7150 |
6725 if (is(v, 'string')) { |
7151 if (is(v, 'string')) { |
6726 each(v.split(/[;,]/), function(v) { |
7152 each(v.indexOf('=') > 0 ? v.split(/[;,](?![^=;,]*(?:[;,]|$))/) : v.split(','), function(v) { |
6727 v = v.split('='); |
7153 v = v.split('='); |
6728 |
7154 |
6729 if (v.length > 1) |
7155 if (v.length > 1) |
6730 o[tr(v[0])] = tr(v[1]); |
7156 o[tr(v[0])] = tr(v[1]); |
6731 else |
7157 else |
6796 cmd_func = function() { |
7222 cmd_func = function() { |
6797 t.execCommand(c[0], c[1], c[2]); |
7223 t.execCommand(c[0], c[1], c[2]); |
6798 }; |
7224 }; |
6799 } |
7225 } |
6800 |
7226 |
6801 each(pa.split(','), function(pa) { |
7227 each(explode(pa), function(pa) { |
6802 var o = { |
7228 var o = { |
6803 func : cmd_func, |
7229 func : cmd_func, |
6804 scope : sc || this, |
7230 scope : sc || this, |
6805 desc : desc, |
7231 desc : desc, |
6806 alt : false, |
7232 alt : false, |
6807 ctrl : false, |
7233 ctrl : false, |
6808 shift : false |
7234 shift : false |
6809 }; |
7235 }; |
6810 |
7236 |
6811 each(pa.split('+'), function(v) { |
7237 each(explode(pa, '+'), function(v) { |
6812 switch (v) { |
7238 switch (v) { |
6813 case 'alt': |
7239 case 'alt': |
6814 case 'ctrl': |
7240 case 'ctrl': |
6815 case 'shift': |
7241 case 'shift': |
6816 o[v] = true; |
7242 o[v] = true; |
6827 |
7253 |
6828 return true; |
7254 return true; |
6829 }, |
7255 }, |
6830 |
7256 |
6831 execCommand : function(cmd, ui, val, a) { |
7257 execCommand : function(cmd, ui, val, a) { |
6832 var t = this, s = 0, o; |
7258 var t = this, s = 0, o, st; |
6833 |
7259 |
6834 if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd) && (!a || !a.skip_focus)) |
7260 if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd) && (!a || !a.skip_focus)) |
6835 t.focus(); |
7261 t.focus(); |
6836 |
7262 |
6837 o = {}; |
7263 o = {}; |
6845 return true; |
7271 return true; |
6846 } |
7272 } |
6847 |
7273 |
6848 // Registred commands |
7274 // Registred commands |
6849 if (o = t.execCommands[cmd]) { |
7275 if (o = t.execCommands[cmd]) { |
6850 s = o.func.call(o.scope, ui, val); |
7276 st = o.func.call(o.scope, ui, val); |
6851 t.onExecCommand.dispatch(t, cmd, ui, val, a); |
7277 |
6852 return s; |
7278 // Fall through on true |
7279 if (st !== true) { |
|
7280 t.onExecCommand.dispatch(t, cmd, ui, val, a); |
|
7281 return st; |
|
7282 } |
|
6853 } |
7283 } |
6854 |
7284 |
6855 // Plugin commands |
7285 // Plugin commands |
6856 each(t.plugins, function(p) { |
7286 each(t.plugins, function(p) { |
6857 if (p.execCommand && p.execCommand(cmd, ui, val)) { |
7287 if (p.execCommand && p.execCommand(cmd, ui, val)) { |
6880 t.getDoc().execCommand(cmd, ui, val); |
7310 t.getDoc().execCommand(cmd, ui, val); |
6881 t.onExecCommand.dispatch(t, cmd, ui, val, a); |
7311 t.onExecCommand.dispatch(t, cmd, ui, val, a); |
6882 }, |
7312 }, |
6883 |
7313 |
6884 queryCommandState : function(c) { |
7314 queryCommandState : function(c) { |
6885 var t = this, o; |
7315 var t = this, o, s; |
6886 |
7316 |
6887 // Is hidden then return undefined |
7317 // Is hidden then return undefined |
6888 if (t._isHidden()) |
7318 if (t._isHidden()) |
6889 return; |
7319 return; |
6890 |
7320 |
6891 // Registred commands |
7321 // Registred commands |
6892 if (o = t.queryStateCommands[c]) |
7322 if (o = t.queryStateCommands[c]) { |
6893 return o.func.call(o.scope); |
7323 s = o.func.call(o.scope); |
7324 |
|
7325 // Fall though on true |
|
7326 if (s !== true) |
|
7327 return s; |
|
7328 } |
|
6894 |
7329 |
6895 // Registred commands |
7330 // Registred commands |
6896 o = t.editorCommands.queryCommandState(c); |
7331 o = t.editorCommands.queryCommandState(c); |
6897 if (o !== -1) |
7332 if (o !== -1) |
6898 return o; |
7333 return o; |
6904 // Fails sometimes see bug: 1896577 |
7339 // Fails sometimes see bug: 1896577 |
6905 } |
7340 } |
6906 }, |
7341 }, |
6907 |
7342 |
6908 queryCommandValue : function(c) { |
7343 queryCommandValue : function(c) { |
6909 var t = this, o; |
7344 var t = this, o, s; |
6910 |
7345 |
6911 // Is hidden then return undefined |
7346 // Is hidden then return undefined |
6912 if (t._isHidden()) |
7347 if (t._isHidden()) |
6913 return; |
7348 return; |
6914 |
7349 |
6915 // Registred commands |
7350 // Registred commands |
6916 if (o = t.queryValueCommands[c]) |
7351 if (o = t.queryValueCommands[c]) { |
6917 return o.func.call(o.scope); |
7352 s = o.func.call(o.scope); |
7353 |
|
7354 // Fall though on true |
|
7355 if (s !== true) |
|
7356 return s; |
|
7357 } |
|
6918 |
7358 |
6919 // Registred commands |
7359 // Registred commands |
6920 o = t.editorCommands.queryCommandValue(c); |
7360 o = t.editorCommands.queryCommandValue(c); |
6921 if (is(o)) |
7361 if (is(o)) |
6922 return o; |
7362 return o; |
6956 |
7396 |
6957 setProgressState : function(b, ti, o) { |
7397 setProgressState : function(b, ti, o) { |
6958 this.onSetProgressState.dispatch(this, b, ti, o); |
7398 this.onSetProgressState.dispatch(this, b, ti, o); |
6959 |
7399 |
6960 return b; |
7400 return b; |
6961 }, |
|
6962 |
|
6963 remove : function() { |
|
6964 var t = this; |
|
6965 |
|
6966 t.removed = 1; // Cancels post remove event execution |
|
6967 t.hide(); |
|
6968 DOM.remove(t.getContainer()); |
|
6969 |
|
6970 t.execCallback('remove_instance_callback', t); |
|
6971 t.onRemove.dispatch(t); |
|
6972 |
|
6973 // Clear all execCommand listeners this is required to avoid errors if the editor was removed inside another command |
|
6974 t.onExecCommand.listeners = []; |
|
6975 |
|
6976 EditorManager.remove(t); |
|
6977 }, |
7401 }, |
6978 |
7402 |
6979 resizeToContent : function() { |
7403 resizeToContent : function() { |
6980 var t = this; |
7404 var t = this; |
6981 |
7405 |
7201 return; |
7625 return; |
7202 } |
7626 } |
7203 }); |
7627 }); |
7204 |
7628 |
7205 t.onVisualAid.dispatch(t, e, t.hasVisual); |
7629 t.onVisualAid.dispatch(t, e, t.hasVisual); |
7630 }, |
|
7631 |
|
7632 remove : function() { |
|
7633 var t = this, e = t.getContainer(); |
|
7634 |
|
7635 t.removed = 1; // Cancels post remove event execution |
|
7636 t.hide(); |
|
7637 |
|
7638 t.execCallback('remove_instance_callback', t); |
|
7639 t.onRemove.dispatch(t); |
|
7640 |
|
7641 // Clear all execCommand listeners this is required to avoid errors if the editor was removed inside another command |
|
7642 t.onExecCommand.listeners = []; |
|
7643 |
|
7644 EditorManager.remove(t); |
|
7645 DOM.remove(e); |
|
7646 }, |
|
7647 |
|
7648 destroy : function(s) { |
|
7649 var t = this; |
|
7650 |
|
7651 // One time is enough |
|
7652 if (t.destroyed) |
|
7653 return; |
|
7654 |
|
7655 if (!s) { |
|
7656 tinymce.removeUnload(t.destroy); |
|
7657 tinyMCE.onBeforeUnload.remove(t._beforeUnload); |
|
7658 |
|
7659 // Manual destroy |
|
7660 if (t.theme.destroy) |
|
7661 t.theme.destroy(); |
|
7662 |
|
7663 // Destroy controls, selection and dom |
|
7664 t.controlManager.destroy(); |
|
7665 t.selection.destroy(); |
|
7666 t.dom.destroy(); |
|
7667 |
|
7668 // Remove all events |
|
7669 |
|
7670 // Don't clear the window or document if content editable |
|
7671 // is enabled since other instances might still be present |
|
7672 if (!t.settings.content_editable) { |
|
7673 Event.clear(t.getWin()); |
|
7674 Event.clear(t.getDoc()); |
|
7675 } |
|
7676 |
|
7677 Event.clear(t.getBody()); |
|
7678 Event.clear(t.formElement); |
|
7679 } |
|
7680 |
|
7681 if (t.formElement) { |
|
7682 t.formElement.submit = t.formElement._mceOldSubmit; |
|
7683 t.formElement._mceOldSubmit = null; |
|
7684 } |
|
7685 |
|
7686 t.contentAreaContainer = t.formElement = t.container = t.settings.content_element = t.bodyElement = t.contentDocument = t.contentWindow = null; |
|
7687 |
|
7688 if (t.selection) |
|
7689 t.selection = t.selection.win = t.selection.dom = t.selection.dom.doc = null; |
|
7690 |
|
7691 t.destroyed = 1; |
|
7206 }, |
7692 }, |
7207 |
7693 |
7208 // Internal functions |
7694 // Internal functions |
7209 |
7695 |
7210 _addEvents : function() { |
7696 _addEvents : function() { |
7263 else if (tinymce.isIE) |
7749 else if (tinymce.isIE) |
7264 tx = t.getWin().clipboardData.getData('Text'); |
7750 tx = t.getWin().clipboardData.getData('Text'); |
7265 |
7751 |
7266 // Get HTML data |
7752 // Get HTML data |
7267 /*if (tinymce.isIE) { |
7753 /*if (tinymce.isIE) { |
7268 el = DOM.add(document.body, 'div', {style : 'visibility:hidden;overflow:hidden;position:absolute;width:1px;height:1px'}); |
7754 el = DOM.add(DOM.doc.body, 'div', {style : 'visibility:hidden;overflow:hidden;position:absolute;width:1px;height:1px'}); |
7269 r = document.body.createTextRange(); |
7755 r = DOM.doc.body.createTextRange(); |
7270 r.moveToElementText(el); |
7756 r.moveToElementText(el); |
7271 r.execCommand('Paste'); |
7757 r.execCommand('Paste'); |
7272 h = el.innerHTML; |
7758 h = el.innerHTML; |
7273 DOM.remove(el); |
7759 DOM.remove(el); |
7274 }*/ |
7760 }*/ |
7289 |
7775 |
7290 Event.add(s.content_editable ? t.getBody() : (isGecko ? t.getDoc() : t.getWin()), 'focus', function(e) { |
7776 Event.add(s.content_editable ? t.getBody() : (isGecko ? t.getDoc() : t.getWin()), 'focus', function(e) { |
7291 t.focus(true); |
7777 t.focus(true); |
7292 }); |
7778 }); |
7293 |
7779 |
7780 |
|
7294 // Fixes bug where a specified document_base_uri could result in broken images |
7781 // Fixes bug where a specified document_base_uri could result in broken images |
7295 // This will also fix drag drop of images in Gecko |
7782 // This will also fix drag drop of images in Gecko |
7296 if (tinymce.isGecko) { |
7783 if (tinymce.isGecko) { |
7297 // Convert all images to absolute URLs |
7784 // Convert all images to absolute URLs |
7298 /* t.onSetContent.add(function(ed, o) { |
7785 /* t.onSetContent.add(function(ed, o) { |
7320 var t = this, d = t.getDoc(), s = t.settings; |
7807 var t = this, d = t.getDoc(), s = t.settings; |
7321 |
7808 |
7322 if (isGecko) { |
7809 if (isGecko) { |
7323 if (t._isHidden()) { |
7810 if (t._isHidden()) { |
7324 try { |
7811 try { |
7325 d.designMode = 'On'; |
7812 if (!s.content_editable) |
7813 d.designMode = 'On'; |
|
7326 } catch (ex) { |
7814 } catch (ex) { |
7327 // Fails if it's hidden |
7815 // Fails if it's hidden |
7328 } |
7816 } |
7329 } |
7817 } |
7330 |
7818 |
7398 |
7886 |
7399 return null; |
7887 return null; |
7400 }; |
7888 }; |
7401 |
7889 |
7402 if (e.keyCode === 9) { |
7890 if (e.keyCode === 9) { |
7403 v = ed.getParam('tab_focus').split(','); |
7891 v = explode(ed.getParam('tab_focus')); |
7404 |
7892 |
7405 if (v.length == 1) { |
7893 if (v.length == 1) { |
7406 v[1] = v[0]; |
7894 v[1] = v[0]; |
7407 v[0] = ':prev'; |
7895 v[0] = ':prev'; |
7408 } |
7896 } |
7517 Event.add(t.getDoc(), 'controlselect', function(e) { |
8005 Event.add(t.getDoc(), 'controlselect', function(e) { |
7518 var re = t.resizeInfo, cb; |
8006 var re = t.resizeInfo, cb; |
7519 |
8007 |
7520 e = e.target; |
8008 e = e.target; |
7521 |
8009 |
8010 // Don't do this action for non image elements |
|
8011 if (e.nodeName !== 'IMG') |
|
8012 return; |
|
8013 |
|
7522 if (re) |
8014 if (re) |
7523 Event.remove(re.node, re.ev, re.cb); |
8015 Event.remove(re.node, re.ev, re.cb); |
7524 |
8016 |
7525 if (!t.dom.hasClass(e, 'mceItemNoResize')) { |
8017 if (!t.dom.hasClass(e, 'mceItemNoResize')) { |
7526 ev = 'resizeend'; |
8018 ev = 'resizeend'; |
7623 } |
8115 } |
7624 }); |
8116 }); |
7625 } |
8117 } |
7626 }, |
8118 }, |
7627 |
8119 |
7628 _destroy : function() { |
|
7629 var t = this; |
|
7630 |
|
7631 if (t.formElement) { |
|
7632 t.formElement.submit = t.formElement._mceOldSubmit; |
|
7633 t.formElement._mceOldSubmit = null; |
|
7634 } |
|
7635 |
|
7636 t.contentAreaContainer = t.formElement = t.container = t.contentDocument = t.contentWindow = null; |
|
7637 |
|
7638 if (t.selection) |
|
7639 t.selection = t.selection.win = t.selection.dom = t.selection.dom.doc = null; |
|
7640 |
|
7641 t.destroyed = 1; |
|
7642 }, |
|
7643 |
|
7644 _convertInlineElements : function() { |
8120 _convertInlineElements : function() { |
7645 var t = this, s = t.settings, dom = t.dom, v, e, na, st, sp; |
8121 var t = this, s = t.settings, dom = t.dom, v, e, na, st, sp; |
7646 |
8122 |
7647 function convert(ed, o) { |
8123 function convert(ed, o) { |
7648 if (!s.inline_styles) |
8124 if (!s.inline_styles) |
7658 } |
8134 } |
7659 break; |
8135 break; |
7660 |
8136 |
7661 case 'U': |
8137 case 'U': |
7662 case 'STRIKE': |
8138 case 'STRIKE': |
7663 sp = dom.create('span', {style : dom.getAttrib(n, 'style')}); |
8139 //sp = dom.create('span', {style : dom.getAttrib(n, 'style')}); |
7664 sp.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through'; |
8140 n.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through'; |
7665 dom.setAttrib(sp, 'mce_style', ''); |
8141 dom.setAttrib(n, 'mce_style', ''); |
7666 dom.replace(sp, n, 1); |
8142 dom.setAttrib(n, 'mce_name', 'span'); |
7667 break; |
8143 break; |
7668 } |
8144 } |
7669 }); |
8145 }); |
7670 } else if (o.set) { |
8146 } else if (o.set) { |
7671 each(t.dom.select('table,span', o.node), function(n) { |
8147 each(t.dom.select('table,span', o.node).reverse(), function(n) { |
7672 if (n.nodeName == 'TABLE') { |
8148 if (n.nodeName == 'TABLE') { |
7673 if (v = dom.getStyle(n, 'height')) |
8149 if (v = dom.getStyle(n, 'height')) |
7674 dom.setAttrib(n, 'height', v.replace(/[^0-9%]+/g, '')); |
8150 dom.setAttrib(n, 'height', v.replace(/[^0-9%]+/g, '')); |
7675 } else { |
8151 } else { |
7676 // Convert spans to elements |
8152 // Convert spans to elements |
7697 }; |
8173 }; |
7698 |
8174 |
7699 t.onPreProcess.add(convert); |
8175 t.onPreProcess.add(convert); |
7700 |
8176 |
7701 if (!s.cleanup_on_startup) { |
8177 if (!s.cleanup_on_startup) { |
7702 t.onInit.add(function() { |
8178 t.onSetContent.add(function(ed, o) { |
7703 convert(t, {node : t.getBody(), set : 1}); |
8179 if (o.initial) |
8180 convert(t, {node : t.getBody(), set : 1}); |
|
7704 }); |
8181 }); |
7705 } |
8182 } |
7706 }, |
8183 }, |
7707 |
8184 |
7708 _convertFonts : function() { |
8185 _convertFonts : function() { |
7709 var t = this, s = t.settings, dom = t.dom, sl, cl, fz, fzn, v, i, st, x, nl, sp, f, n; |
8186 var t = this, s = t.settings, dom = t.dom, fz, fzn, sl, cl; |
7710 |
8187 |
7711 // No need |
8188 // No need |
7712 if (!s.inline_styles) |
8189 if (!s.inline_styles) |
7713 return; |
8190 return; |
7714 |
8191 |
7715 // Font pt values and font size names |
8192 // Font pt values and font size names |
7716 fz = [8, 10, 12, 14, 18, 24, 36]; |
8193 fz = [8, 10, 12, 14, 18, 24, 36]; |
7717 fzn = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large']; |
8194 fzn = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large']; |
7718 |
8195 |
7719 if (sl = s.font_size_style_values) |
8196 if (sl = s.font_size_style_values) |
7720 sl = sl.split(','); |
8197 sl = explode(sl); |
7721 |
8198 |
7722 if (cl = s.font_size_classes) |
8199 if (cl = s.font_size_classes) |
7723 cl = cl.split(','); |
8200 cl = explode(cl); |
7724 |
8201 |
7725 function convertToFonts(no) { |
8202 function convertToFonts(no) { |
8203 var n, f, nl, x, i, v, st; |
|
8204 |
|
7726 // Convert spans to fonts on non WebKit browsers |
8205 // Convert spans to fonts on non WebKit browsers |
7727 if (tinymce.isWebKit || !s.inline_styles) |
8206 if (tinymce.isWebKit || !s.inline_styles) |
7728 return; |
8207 return; |
7729 |
8208 |
7730 nl = t.dom.select('span', no); |
8209 nl = t.dom.select('span', no); |
7732 n = nl[x]; |
8211 n = nl[x]; |
7733 |
8212 |
7734 f = dom.create('font', { |
8213 f = dom.create('font', { |
7735 color : dom.toHex(dom.getStyle(n, 'color')), |
8214 color : dom.toHex(dom.getStyle(n, 'color')), |
7736 face : dom.getStyle(n, 'fontFamily'), |
8215 face : dom.getStyle(n, 'fontFamily'), |
7737 style : dom.getAttrib(n, 'style') |
8216 style : dom.getAttrib(n, 'style'), |
8217 'class' : dom.getAttrib(n, 'class') |
|
7738 }); |
8218 }); |
8219 |
|
8220 // Clear color and font family |
|
8221 st = f.style; |
|
8222 if (st.color || st.fontFamily) { |
|
8223 st.color = st.fontFamily = ''; |
|
8224 dom.setAttrib(f, 'mce_style', ''); // Remove cached style data |
|
8225 } |
|
7739 |
8226 |
7740 if (sl) { |
8227 if (sl) { |
7741 i = inArray(sl, dom.getStyle(n, 'fontSize')); |
8228 i = inArray(sl, dom.getStyle(n, 'fontSize')); |
7742 |
8229 |
7743 if (i != -1) { |
8230 if (i != -1) { |
7744 dom.setAttrib(f, 'size', '' + (i + 1 || 1)); |
8231 dom.setAttrib(f, 'size', '' + (i + 1 || 1)); |
7745 f.style.fontSize = ''; |
8232 //f.style.fontSize = ''; |
7746 } |
8233 } |
7747 } else if (cl) { |
8234 } else if (cl) { |
7748 i = inArray(cl, dom.getAttrib(n, 'class')); |
8235 i = inArray(cl, dom.getAttrib(n, 'class')); |
7749 v = dom.getStyle(n, 'fontSize'); |
8236 v = dom.getStyle(n, 'fontSize'); |
7750 |
8237 |
7763 if (f.color || f.face || f.size) { |
8250 if (f.color || f.face || f.size) { |
7764 f.style.fontFamily = ''; |
8251 f.style.fontFamily = ''; |
7765 dom.setAttrib(f, 'mce_style', ''); |
8252 dom.setAttrib(f, 'mce_style', ''); |
7766 dom.replace(f, n, 1); |
8253 dom.replace(f, n, 1); |
7767 } |
8254 } |
8255 |
|
8256 f = n = null; |
|
7768 } |
8257 } |
7769 }; |
8258 }; |
7770 |
8259 |
7771 // Run on setup |
8260 // Run on setup |
7772 t.onSetContent.add(function(ed, o) { |
8261 t.onSetContent.add(function(ed, o) { |
7773 convertToFonts(ed.getBody()); |
8262 convertToFonts(ed.getBody()); |
7774 }); |
8263 }); |
7775 |
8264 |
7776 // Run on cleanup |
8265 // Run on cleanup |
7777 t.onPreProcess.add(function(ed, o) { |
8266 t.onPreProcess.add(function(ed, o) { |
8267 var n, sp, nl, x; |
|
8268 |
|
7778 // Keep unit tests happy |
8269 // Keep unit tests happy |
7779 if (!s.inline_styles) |
8270 if (!s.inline_styles) |
7780 return; |
8271 return; |
7781 |
8272 |
7782 if (o.get) { |
8273 if (o.get) { |
7783 nl = t.dom.select('font', o.node); |
8274 nl = t.dom.select('font', o.node); |
7784 for (x = nl.length - 1; x >= 0; x--) { |
8275 for (x = nl.length - 1; x >= 0; x--) { |
7785 n = nl[x]; |
8276 n = nl[x]; |
7786 |
8277 |
7787 sp = dom.create('span', { |
8278 sp = dom.create('span', { |
7788 style : dom.getAttrib(n, 'style') |
8279 style : dom.getAttrib(n, 'style'), |
8280 'class' : dom.getAttrib(n, 'class') |
|
7789 }); |
8281 }); |
7790 |
8282 |
7791 dom.setStyles(sp, { |
8283 dom.setStyles(sp, { |
7792 fontFamily : dom.getAttrib(n, 'face'), |
8284 fontFamily : dom.getAttrib(n, 'face'), |
7793 color : dom.getAttrib(n, 'color'), |
8285 color : dom.getAttrib(n, 'color'), |
8009 |
8501 |
8010 s.setContent(v.replace(/\{\$selection\}/g, s.getContent({format : 'text'}))); |
8502 s.setContent(v.replace(/\{\$selection\}/g, s.getContent({format : 'text'}))); |
8011 }, |
8503 }, |
8012 |
8504 |
8013 mceInsertLink : function(u, v) { |
8505 mceInsertLink : function(u, v) { |
8014 var ed = this.editor, e = ed.dom.getParent(ed.selection.getNode(), 'A'); |
8506 var ed = this.editor, s = ed.selection, e = ed.dom.getParent(s.getNode(), 'A'); |
8015 |
8507 |
8016 if (tinymce.is(v, 'string')) |
8508 if (tinymce.is(v, 'string')) |
8017 v = {href : v}; |
8509 v = {href : v}; |
8018 |
8510 |
8019 function set(e) { |
8511 function set(e) { |
8056 t.RemoveFormat(); |
8548 t.RemoveFormat(); |
8057 } else |
8549 } else |
8058 ed.getDoc().execCommand('FontName', false, v); |
8550 ed.getDoc().execCommand('FontName', false, v); |
8059 }, |
8551 }, |
8060 |
8552 |
8553 FontSize : function(u, v) { |
|
8554 var ed = this.editor, s = ed.settings, fz = tinymce.explode(s.font_size_style_values), fzc = tinymce.explode(s.font_size_classes); |
|
8555 |
|
8556 ed.getDoc().execCommand('FontSize', false, v); |
|
8557 |
|
8558 // Add style values |
|
8559 if (s.inline_styles) { |
|
8560 each(ed.dom.select('font'), function(e) { |
|
8561 if (e.size === v) { |
|
8562 if (fzc && fzc.length > 0) |
|
8563 ed.dom.setAttrib(e, 'class', fzc[parseInt(v) - 1]); |
|
8564 else |
|
8565 ed.dom.setStyle(e, 'fontSize', fz[parseInt(v) - 1]); |
|
8566 } |
|
8567 }); |
|
8568 } |
|
8569 }, |
|
8570 |
|
8061 queryCommandValue : function(c) { |
8571 queryCommandValue : function(c) { |
8062 var f = this['queryValue' + c]; |
8572 var f = this['queryValue' + c]; |
8063 |
8573 |
8064 if (f) |
8574 if (f) |
8065 return f.call(this, c); |
8575 return f.call(this, c); |
8084 } |
8594 } |
8085 |
8595 |
8086 return -1; |
8596 return -1; |
8087 }, |
8597 }, |
8088 |
8598 |
8599 _queryState : function(c) { |
|
8600 try { |
|
8601 return this.editor.getDoc().queryCommandState(c); |
|
8602 } catch (ex) { |
|
8603 // Ignore exception |
|
8604 } |
|
8605 }, |
|
8606 |
|
8607 _queryVal : function(c) { |
|
8608 try { |
|
8609 return this.editor.getDoc().queryCommandValue(c); |
|
8610 } catch (ex) { |
|
8611 // Ignore exception |
|
8612 } |
|
8613 }, |
|
8614 |
|
8089 queryValueFontSize : function() { |
8615 queryValueFontSize : function() { |
8090 var ed = this.editor, v = 0, p; |
8616 var ed = this.editor, v = 0, p; |
8091 |
8617 |
8092 if (isOpera || isWebKit) { |
8618 if (isOpera || isWebKit) { |
8093 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT')) |
8619 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT')) |
8094 v = p.size; |
8620 v = p.size; |
8095 |
8621 |
8096 return v; |
8622 return v; |
8097 } |
8623 } |
8098 |
8624 |
8099 return ed.getDoc().queryCommandValue('FontSize'); |
8625 return this._queryVal('FontSize'); |
8100 }, |
8626 }, |
8101 |
8627 |
8102 queryValueFontName : function() { |
8628 queryValueFontName : function() { |
8103 var ed = this.editor, v = 0, p; |
8629 var ed = this.editor, v = 0, p; |
8104 |
8630 |
8105 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT')) |
8631 if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT')) |
8106 v = p.face; |
8632 v = p.face; |
8107 |
8633 |
8108 if (!v) |
8634 if (!v) |
8109 v = ed.getDoc().queryCommandValue('FontName'); |
8635 v = this._queryVal('FontName'); |
8110 |
8636 |
8111 return v; |
8637 return v; |
8112 }, |
8638 }, |
8113 |
8639 |
8114 mceJustify : function(c, v) { |
8640 mceJustify : function(c, v) { |
8365 |
8891 |
8366 // Remove wrappers inside new ones |
8892 // Remove wrappers inside new ones |
8367 each(dom.select(nn).reverse(), function(n) { |
8893 each(dom.select(nn).reverse(), function(n) { |
8368 var p = n.parentNode; |
8894 var p = n.parentNode; |
8369 |
8895 |
8370 dom.setAttrib(n, 'mce_new', ''); |
|
8371 |
|
8372 // Check if it's an old span in a new wrapper |
8896 // Check if it's an old span in a new wrapper |
8373 if (!dom.getAttrib(n, 'mce_new')) { |
8897 if (!dom.getAttrib(n, 'mce_new')) { |
8374 // Find new wrapper |
8898 // Find new wrapper |
8375 p = dom.getParent(n, function(n) { |
8899 p = dom.getParent(n, function(n) { |
8376 return n.nodeType == 1 && dom.getAttrib(n, 'mce_new'); |
8900 return n.nodeType == 1 && dom.getAttrib(n, 'mce_new'); |
8383 |
8907 |
8384 // Merge wrappers with parent wrappers |
8908 // Merge wrappers with parent wrappers |
8385 each(dom.select(nn).reverse(), function(n) { |
8909 each(dom.select(nn).reverse(), function(n) { |
8386 var p = n.parentNode; |
8910 var p = n.parentNode; |
8387 |
8911 |
8388 if (!p) |
8912 if (!p || !dom.getAttrib(n, 'mce_new')) |
8389 return; |
8913 return; |
8390 |
8914 |
8391 // Has parent of the same type and only child |
8915 // Has parent of the same type and only child |
8392 if (p.nodeName == nn.toUpperCase() && p.childNodes.length == 1) |
8916 if (p.nodeName == nn.toUpperCase() && p.childNodes.length == 1) |
8393 return dom.remove(p, 1); |
8917 return dom.remove(p, 1); |
8399 } |
8923 } |
8400 }); |
8924 }); |
8401 |
8925 |
8402 // Remove empty wrappers |
8926 // Remove empty wrappers |
8403 each(dom.select(nn).reverse(), function(n) { |
8927 each(dom.select(nn).reverse(), function(n) { |
8404 if (!dom.getAttrib(n, 'class') && !dom.getAttrib(n, 'style')) |
8928 if (dom.getAttrib(n, 'mce_new') || (dom.getAttribs(n).length <= 1 && n.className === '')) { |
8405 return dom.remove(n, 1); |
8929 if (!dom.getAttrib(n, 'class') && !dom.getAttrib(n, 'style')) |
8930 return dom.remove(n, 1); |
|
8931 |
|
8932 dom.setAttrib(n, 'mce_new', ''); // Remove mce_new marker |
|
8933 } |
|
8406 }); |
8934 }); |
8407 |
8935 |
8408 s.moveToBookmark(b); |
8936 s.moveToBookmark(b); |
8409 }, |
8937 }, |
8410 |
8938 |
8426 v = 'justify'; |
8954 v = 'justify'; |
8427 |
8955 |
8428 if (ed.settings.inline_styles) |
8956 if (ed.settings.inline_styles) |
8429 return (n && n.style.textAlign == v); |
8957 return (n && n.style.textAlign == v); |
8430 |
8958 |
8431 return ed.getDoc().queryCommandState(c); |
8959 return this._queryState(c); |
8432 }, |
8960 }, |
8433 |
8961 |
8434 HiliteColor : function(ui, val) { |
8962 HiliteColor : function(ui, val) { |
8435 var t = this, ed = t.editor, d = ed.getDoc(); |
8963 var t = this, ed = t.editor, d = ed.getDoc(); |
8436 |
8964 |
8556 } |
9084 } |
8557 } |
9085 } |
8558 }, |
9086 }, |
8559 |
9087 |
8560 queryStateUnderline : function() { |
9088 queryStateUnderline : function() { |
8561 var ed = this.editor, n; |
9089 var ed = this.editor, n = ed.selection.getNode(); |
8562 |
9090 |
8563 if (n && n.nodeName == 'A') |
9091 if (n && n.nodeName == 'A') |
8564 return false; |
9092 return false; |
8565 |
9093 |
8566 return ed.getDoc().queryCommandState('Underline'); |
9094 return this._queryState('Underline'); |
8567 }, |
9095 }, |
8568 |
9096 |
8569 queryStateOutdent : function() { |
9097 queryStateOutdent : function() { |
8570 var ed = this.editor, n; |
9098 var ed = this.editor, n; |
8571 |
9099 |
8825 l = l || {}; |
9353 l = l || {}; |
8826 l.content = l.content || ed.getContent({format : 'raw', no_events : 1}); |
9354 l.content = l.content || ed.getContent({format : 'raw', no_events : 1}); |
8827 |
9355 |
8828 // Add undo level if needed |
9356 // Add undo level if needed |
8829 l.content = l.content.replace(/^\s*|\s*$/g, ''); |
9357 l.content = l.content.replace(/^\s*|\s*$/g, ''); |
8830 la = t.data[t.index > 0 ? t.index - 1 : 0]; |
9358 la = t.data[t.index > 0 && (t.index == 0 || t.index == t.data.length) ? t.index - 1 : t.index]; |
8831 if (!l.initial && la && l.content == la.content) |
9359 if (!l.initial && la && l.content == la.content) |
8832 return null; |
9360 return null; |
8833 |
9361 |
8834 // Time to compress |
9362 // Time to compress |
8835 if (s.custom_undo_redo_levels) { |
9363 if (s.custom_undo_redo_levels) { |
8843 } |
9371 } |
8844 |
9372 |
8845 if (s.custom_undo_redo_restore_selection && !l.initial) |
9373 if (s.custom_undo_redo_restore_selection && !l.initial) |
8846 l.bookmark = b = l.bookmark || ed.selection.getBookmark(); |
9374 l.bookmark = b = l.bookmark || ed.selection.getBookmark(); |
8847 |
9375 |
8848 if (t.index < t.data.length && t.data[t.index].initial) |
9376 if (t.index < t.data.length) |
8849 t.index++; |
9377 t.index++; |
9378 |
|
9379 // Only initial marked undo levels should be allowed as first item |
|
9380 // This to workaround a bug with Firefox and the blur event |
|
9381 if (t.data.length === 0 && !l.initial) |
|
9382 return null; |
|
8850 |
9383 |
8851 // Add level |
9384 // Add level |
8852 t.data.length = t.index + 1; |
9385 t.data.length = t.index + 1; |
8853 t.data[t.index++] = l; |
9386 t.data[t.index++] = l; |
8854 |
9387 |
8951 elm = (s.forced_root_block || 'p').toLowerCase(); |
9484 elm = (s.forced_root_block || 'p').toLowerCase(); |
8952 s.element = elm.toUpperCase(); |
9485 s.element = elm.toUpperCase(); |
8953 |
9486 |
8954 ed.onPreInit.add(t.setup, t); |
9487 ed.onPreInit.add(t.setup, t); |
8955 |
9488 |
8956 t.reOpera = new RegExp('(\u00a0| | )<\/' + elm + '>', 'gi'); |
9489 t.reOpera = new RegExp('(\\u00a0| | )<\/' + elm + '>', 'gi'); |
8957 t.rePadd = new RegExp('<p( )([^>]+)><\/p>|<p( )([^>]+)\/>|<p( )([^>]+)>\s+<\/p>|<p><\/p>|<p\/>|<p>\s+<\/p>'.replace(/p/g, elm), 'gi'); |
9490 t.rePadd = new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g, elm), 'gi'); |
8958 t.reNbsp2BR = new RegExp('<p( )([^>]+)>[\s\u00a0]+<\/p>|<p>[\s\u00a0]+<\/p>'.replace(/p/g, elm), 'gi'); |
9491 t.reNbsp2BR1 = new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g, elm), 'gi'); |
8959 t.reBR2Nbsp = new RegExp('<p( )([^>]+)>\s*<br \/>\s*<\/p>|<p>\s*<br \/>\s*<\/p>'.replace(/p/g, elm), 'gi'); |
9492 t.reNbsp2BR2 = new RegExp('<p( )([^>]+)>( | )<\\\/p>|<p>( | )<\\\/p>'.replace(/p/g, elm), 'gi'); |
8960 t.reTrailBr = new RegExp('\s*<br \/>\s*<\/p>'.replace(/p/g, elm), 'gi'); |
9493 t.reBR2Nbsp = new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi'); |
9494 t.reTrailBr = new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi'); |
|
8961 |
9495 |
8962 function padd(ed, o) { |
9496 function padd(ed, o) { |
8963 if (isOpera) |
9497 if (isOpera) |
8964 o.content = o.content.replace(t.reOpera, '</' + elm + '>'); |
9498 o.content = o.content.replace(t.reOpera, '</' + elm + '>'); |
8965 |
9499 |
8966 o.content = o.content.replace(t.rePadd, '<' + elm + '$1$2$3$4$5$6>\u00a0</' + elm + '>'); |
9500 o.content = o.content.replace(t.rePadd, '<' + elm + '$1$2$3$4$5$6>\u00a0</' + elm + '>'); |
8967 |
9501 |
8968 if (!isIE && o.set) { |
9502 if (!isIE && !isOpera && o.set) { |
8969 // Use instead of BR in padded paragraphs |
9503 // Use instead of BR in padded paragraphs |
8970 o.content = o.content.replace(t.reNbsp2BR, '<' + elm + '$1$2><br /></' + elm + '>'); |
9504 o.content = o.content.replace(t.reNbsp2BR1, '<' + elm + '$1$2><br /></' + elm + '>'); |
9505 o.content = o.content.replace(t.reNbsp2BR2, '<' + elm + '$1$2><br /></' + elm + '>'); |
|
8971 } else { |
9506 } else { |
8972 o.content = o.content.replace(t.reBR2Nbsp, '<' + elm + '$1$2>\u00a0</' + elm + '>'); |
9507 o.content = o.content.replace(t.reBR2Nbsp, '<' + elm + '$1$2>\u00a0</' + elm + '>'); |
8973 o.content = o.content.replace(t.reTrailBr, '</' + elm + '>'); |
9508 o.content = o.content.replace(t.reTrailBr, '</' + elm + '>'); |
8974 } |
9509 } |
8975 }; |
9510 }; |
9112 // Wrap non blocks into blocks |
9647 // Wrap non blocks into blocks |
9113 for (i = nl.length - 1; i >= 0; i--) { |
9648 for (i = nl.length - 1; i >= 0; i--) { |
9114 nx = nl[i]; |
9649 nx = nl[i]; |
9115 |
9650 |
9116 // Is text or non block element |
9651 // Is text or non block element |
9117 if (nx.nodeType == 3 || !t.dom.isBlock(nx)) { |
9652 if (nx.nodeType == 3 || (!t.dom.isBlock(nx) && nx.nodeType != 8)) { |
9118 if (!bl) { |
9653 if (!bl) { |
9119 // Create new block but ignore whitespace |
9654 // Create new block but ignore whitespace |
9120 if (nx.nodeType != 3 || /[^\s]/g.test(nx.nodeValue)) { |
9655 if (nx.nodeType != 3 || /[^\s]/g.test(nx.nodeValue)) { |
9121 // Store selection |
9656 // Store selection |
9122 if (si == -2 && r) { |
9657 if (si == -2 && r) { |
9200 |
9735 |
9201 return d.getParent(n, d.isBlock); |
9736 return d.getParent(n, d.isBlock); |
9202 }, |
9737 }, |
9203 |
9738 |
9204 insertPara : function(e) { |
9739 insertPara : function(e) { |
9205 var t = this, ed = t.editor, d = ed.getDoc(), se = ed.settings, s = ed.selection.getSel(), r = s.getRangeAt(0), b = d.body; |
9740 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; |
9206 var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n; |
9741 var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n, vp = dom.getViewPort(ed.getWin()), y, ch; |
9207 |
9742 |
9208 function isEmpty(n) { |
9743 function isEmpty(n) { |
9209 n = n.innerHTML; |
9744 n = n.innerHTML; |
9210 n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars |
9745 n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars |
9211 n = n.replace(/<[^>]+>/g, ''); // Remove all tags |
9746 n = n.replace(/<[^>]+>/g, ''); // Remove all tags |
9236 dir = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0; |
9771 dir = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0; |
9237 sn = dir ? s.anchorNode : s.focusNode; |
9772 sn = dir ? s.anchorNode : s.focusNode; |
9238 so = dir ? s.anchorOffset : s.focusOffset; |
9773 so = dir ? s.anchorOffset : s.focusOffset; |
9239 en = dir ? s.focusNode : s.anchorNode; |
9774 en = dir ? s.focusNode : s.anchorNode; |
9240 eo = dir ? s.focusOffset : s.anchorOffset; |
9775 eo = dir ? s.focusOffset : s.anchorOffset; |
9776 |
|
9777 // If selection is in empty table cell |
|
9778 if (sn === en && /^(TD|TH)$/.test(sn.nodeName)) { |
|
9779 dom.remove(sn.firstChild); // Remove BR |
|
9780 |
|
9781 // Create two new block elements |
|
9782 ed.dom.add(sn, se.element, null, '<br />'); |
|
9783 aft = ed.dom.add(sn, se.element, null, '<br />'); |
|
9784 |
|
9785 // Move caret into the last one |
|
9786 r = d.createRange(); |
|
9787 r.selectNodeContents(aft); |
|
9788 r.collapse(1); |
|
9789 ed.selection.setRng(r); |
|
9790 |
|
9791 return false; |
|
9792 } |
|
9241 |
9793 |
9242 // If the caret is in an invalid location in FF we need to move it into the first block |
9794 // If the caret is in an invalid location in FF we need to move it into the first block |
9243 if (sn == b && en == b && b.firstChild && ed.dom.isBlock(b.firstChild)) { |
9795 if (sn == b && en == b && b.firstChild && ed.dom.isBlock(b.firstChild)) { |
9244 sn = en = sn.firstChild; |
9796 sn = en = sn.firstChild; |
9245 so = eo = 0; |
9797 so = eo = 0; |
9347 r.setEnd(ra.endContainer, ra.endOffset); |
9899 r.setEnd(ra.endContainer, ra.endOffset); |
9348 |
9900 |
9349 // Delete and replace it with new block elements |
9901 // Delete and replace it with new block elements |
9350 r.deleteContents(); |
9902 r.deleteContents(); |
9351 |
9903 |
9904 if (isOpera) |
|
9905 ed.getWin().scrollTo(0, vp.y); |
|
9906 |
|
9352 // Never wrap blocks in blocks |
9907 // Never wrap blocks in blocks |
9353 if (bef.firstChild && bef.firstChild.nodeName == bn) |
9908 if (bef.firstChild && bef.firstChild.nodeName == bn) |
9354 bef.innerHTML = bef.firstChild.innerHTML; |
9909 bef.innerHTML = bef.firstChild.innerHTML; |
9355 |
9910 |
9356 if (aft.firstChild && aft.firstChild.nodeName == bn) |
9911 if (aft.firstChild && aft.firstChild.nodeName == bn) |
9374 |
9929 |
9375 // Normalize |
9930 // Normalize |
9376 aft.normalize(); |
9931 aft.normalize(); |
9377 bef.normalize(); |
9932 bef.normalize(); |
9378 |
9933 |
9934 function first(n) { |
|
9935 return d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() || n; |
|
9936 }; |
|
9937 |
|
9379 // Move cursor and scroll into view |
9938 // Move cursor and scroll into view |
9380 r = d.createRange(); |
9939 r = d.createRange(); |
9381 r.selectNodeContents(aft); |
9940 r.selectNodeContents(isGecko ? first(aft) : aft); |
9382 r.collapse(1); |
9941 r.collapse(1); |
9383 s.removeAllRanges(); |
9942 s.removeAllRanges(); |
9384 s.addRange(r); |
9943 s.addRange(r); |
9385 |
9944 |
9386 // Safari bug fix, http://bugs.webkit.org/show_bug.cgi?id=16117 |
9945 // 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 |
9387 if (tinymce.isWebKit) |
9946 y = ed.dom.getPos(aft).y; |
9388 ed.getWin().scrollTo(0, ed.dom.getPos(aft).y); |
9947 ch = aft.clientHeight; |
9389 else |
9948 |
9390 aft.scrollIntoView(0); |
9949 // Is element within viewport |
9950 if (y < vp.y || y + ch > vp.y + vp.h) { |
|
9951 ed.getWin().scrollTo(0, y < vp.y ? y : y - vp.h + ch); |
|
9952 //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)); |
|
9953 } |
|
9391 |
9954 |
9392 return false; |
9955 return false; |
9393 }, |
9956 }, |
9394 |
9957 |
9395 backspaceDelete : function(e, bs) { |
9958 backspaceDelete : function(e, bs) { |
9396 var t = this, ed = t.editor, b = ed.getBody(), n, se = ed.selection, r = se.getRng(), sc = r.startContainer, n; |
9959 var t = this, ed = t.editor, b = ed.getBody(), n, se = ed.selection, r = se.getRng(), sc = r.startContainer, n, w, tn; |
9397 |
9960 |
9398 // The caret sometimes gets stuck in Gecko if you delete empty paragraphs |
9961 // The caret sometimes gets stuck in Gecko if you delete empty paragraphs |
9399 // This workaround removes the element by hand and moves the caret to the previous element |
9962 // This workaround removes the element by hand and moves the caret to the previous element |
9400 if (sc && ed.dom.isBlock(sc) && bs) { |
9963 if (sc && ed.dom.isBlock(sc) && !/^(TD|TH)$/.test(sc.nodeName) && bs) { |
9401 if (sc.childNodes.length == 1 && sc.firstChild.nodeName == 'BR') { |
9964 if (sc.childNodes.length == 0 || (sc.childNodes.length == 1 && sc.firstChild.nodeName == 'BR')) { |
9402 n = sc.previousSibling; |
9965 // Find previous block element |
9966 n = sc; |
|
9967 while ((n = n.previousSibling) && !ed.dom.isBlock(n)) ; |
|
9968 |
|
9403 if (n) { |
9969 if (n) { |
9404 ed.dom.remove(sc); |
9970 if (sc != b.firstChild) { |
9405 se.select(n.firstChild); |
9971 // Find last text node |
9406 se.collapse(0); |
9972 w = ed.dom.doc.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false); |
9973 while (tn = w.nextNode()) |
|
9974 n = tn; |
|
9975 |
|
9976 // Place caret at the end of last text node |
|
9977 r = ed.getDoc().createRange(); |
|
9978 r.setStart(n, n.nodeValue ? n.nodeValue.length : 0); |
|
9979 r.setEnd(n, n.nodeValue ? n.nodeValue.length : 0); |
|
9980 se.setRng(r); |
|
9981 |
|
9982 // Remove the target container |
|
9983 ed.dom.remove(sc); |
|
9984 } |
|
9985 |
|
9407 return Event.cancel(e); |
9986 return Event.cancel(e); |
9408 } |
9987 } |
9409 } |
9988 } |
9410 } |
9989 } |
9411 |
9990 |
9412 // Gecko generates BR elements here and there, we don't like those so lets remove them |
9991 // Gecko generates BR elements here and there, we don't like those so lets remove them |
9413 function handler(e) { |
9992 function handler(e) { |
9414 e = e.target; |
9993 e = e.target; |
9415 |
9994 |
9416 // A new BR was created in a block element, remove it |
9995 // A new BR was created in a block element, remove it |
9417 if (e && e.parentNode && e.nodeName == 'BR' && t.getParentBlock(e)) { |
9996 if (e && e.parentNode && e.nodeName == 'BR' && (n = t.getParentBlock(e))) { |
9418 ed.dom.remove(e); |
|
9419 Event.remove(b, 'DOMNodeInserted', handler); |
9997 Event.remove(b, 'DOMNodeInserted', handler); |
9998 |
|
9999 // Only remove BR elements that got inserted in the middle of the text |
|
10000 if (e.previousSibling || e.nextSibling) |
|
10001 ed.dom.remove(e); |
|
9420 } |
10002 } |
9421 }; |
10003 }; |
9422 |
10004 |
9423 // Listen for new nodes |
10005 // Listen for new nodes |
9424 Event._add(b, 'DOMNodeInserted', handler); |
10006 Event._add(b, 'DOMNodeInserted', handler); |
9445 t.editor = ed; |
10027 t.editor = ed; |
9446 t.controls = {}; |
10028 t.controls = {}; |
9447 t.onAdd = new tinymce.util.Dispatcher(t); |
10029 t.onAdd = new tinymce.util.Dispatcher(t); |
9448 t.onPostRender = new tinymce.util.Dispatcher(t); |
10030 t.onPostRender = new tinymce.util.Dispatcher(t); |
9449 t.prefix = s.prefix || ed.id + '_'; |
10031 t.prefix = s.prefix || ed.id + '_'; |
10032 t._cls = {}; |
|
9450 |
10033 |
9451 t.onPostRender.add(function() { |
10034 t.onPostRender.add(function() { |
9452 each(t.controls, function(c) { |
10035 each(t.controls, function(c) { |
9453 c.postRender(); |
10036 c.postRender(); |
9454 }); |
10037 }); |
9510 return t.createButton(n, c); |
10093 return t.createButton(n, c); |
9511 |
10094 |
9512 return t.add(c); |
10095 return t.add(c); |
9513 }, |
10096 }, |
9514 |
10097 |
9515 createDropMenu : function(id, s) { |
10098 createDropMenu : function(id, s, cc) { |
9516 var t = this, ed = t.editor, c, bm, v; |
10099 var t = this, ed = t.editor, c, bm, v, cls; |
9517 |
10100 |
9518 s = extend({ |
10101 s = extend({ |
9519 'class' : 'mceDropDown' |
10102 'class' : 'mceDropDown', |
10103 constrain : ed.settings.constrain_menus |
|
9520 }, s); |
10104 }, s); |
9521 |
10105 |
9522 s['class'] = s['class'] + ' ' + ed.getParam('skin') + 'Skin'; |
10106 s['class'] = s['class'] + ' ' + ed.getParam('skin') + 'Skin'; |
9523 if (v = ed.getParam('skin_variant')) |
10107 if (v = ed.getParam('skin_variant')) |
9524 s['class'] += ' ' + ed.getParam('skin') + 'Skin' + v.substring(0, 1).toUpperCase() + v.substring(1); |
10108 s['class'] += ' ' + ed.getParam('skin') + 'Skin' + v.substring(0, 1).toUpperCase() + v.substring(1); |
9525 |
10109 |
9526 id = t.prefix + id; |
10110 id = t.prefix + id; |
9527 c = t.controls[id] = new tinymce.ui.DropMenu(id, s); |
10111 cls = cc || t._cls.dropmenu || tinymce.ui.DropMenu; |
10112 c = t.controls[id] = new cls(id, s); |
|
9528 c.onAddItem.add(function(c, o) { |
10113 c.onAddItem.add(function(c, o) { |
9529 var s = o.settings; |
10114 var s = o.settings; |
9530 |
10115 |
9531 s.title = ed.getLang(s.title, s.title); |
10116 s.title = ed.getLang(s.title, s.title); |
9532 |
10117 |
9559 } |
10144 } |
9560 |
10145 |
9561 return t.add(c); |
10146 return t.add(c); |
9562 }, |
10147 }, |
9563 |
10148 |
9564 createListBox : function(id, s) { |
10149 createListBox : function(id, s, cc) { |
9565 var t = this, ed = t.editor, cmd, c; |
10150 var t = this, ed = t.editor, cmd, c, cls; |
9566 |
10151 |
9567 if (t.get(id)) |
10152 if (t.get(id)) |
9568 return null; |
10153 return null; |
9569 |
10154 |
9570 s.title = ed.translate(s.title); |
10155 s.title = ed.translate(s.title); |
9585 |
10170 |
9586 id = t.prefix + id; |
10171 id = t.prefix + id; |
9587 |
10172 |
9588 if (ed.settings.use_native_selects) |
10173 if (ed.settings.use_native_selects) |
9589 c = new tinymce.ui.NativeListBox(id, s); |
10174 c = new tinymce.ui.NativeListBox(id, s); |
9590 else |
10175 else { |
9591 c = new tinymce.ui.ListBox(id, s); |
10176 cls = cc || t._cls.listbox || tinymce.ui.ListBox; |
10177 c = new cls(id, s); |
|
10178 } |
|
9592 |
10179 |
9593 t.controls[id] = c; |
10180 t.controls[id] = c; |
9594 |
10181 |
9595 // Fix focus problem in Safari |
10182 // Fix focus problem in Safari |
9596 if (tinymce.isWebKit) { |
10183 if (tinymce.isWebKit) { |
9612 ed.onMouseDown.add(c.hideMenu, c); |
10199 ed.onMouseDown.add(c.hideMenu, c); |
9613 |
10200 |
9614 return t.add(c); |
10201 return t.add(c); |
9615 }, |
10202 }, |
9616 |
10203 |
9617 createButton : function(id, s) { |
10204 createButton : function(id, s, cc) { |
9618 var t = this, ed = t.editor, o, c; |
10205 var t = this, ed = t.editor, o, c, cls; |
9619 |
10206 |
9620 if (t.get(id)) |
10207 if (t.get(id)) |
9621 return null; |
10208 return null; |
9622 |
10209 |
9623 s.title = ed.translate(s.title); |
10210 s.title = ed.translate(s.title); |
10211 s.label = ed.translate(s.label); |
|
9624 s.scope = s.scope || ed; |
10212 s.scope = s.scope || ed; |
9625 |
10213 |
9626 if (!s.onclick && !s.menu_button) { |
10214 if (!s.onclick && !s.menu_button) { |
9627 s.onclick = function() { |
10215 s.onclick = function() { |
9628 ed.execCommand(s.cmd, s.ui || false, s.value); |
10216 ed.execCommand(s.cmd, s.ui || false, s.value); |
9638 }, s); |
10226 }, s); |
9639 |
10227 |
9640 id = t.prefix + id; |
10228 id = t.prefix + id; |
9641 |
10229 |
9642 if (s.menu_button) { |
10230 if (s.menu_button) { |
9643 c = new tinymce.ui.MenuButton(id, s); |
10231 cls = cc || t._cls.menubutton || tinymce.ui.MenuButton; |
10232 c = new cls(id, s); |
|
9644 ed.onMouseDown.add(c.hideMenu, c); |
10233 ed.onMouseDown.add(c.hideMenu, c); |
9645 } else |
10234 } else { |
9646 c = new tinymce.ui.Button(id, s); |
10235 cls = t._cls.button || tinymce.ui.Button; |
10236 c = new cls(id, s); |
|
10237 } |
|
9647 |
10238 |
9648 return t.add(c); |
10239 return t.add(c); |
9649 }, |
10240 }, |
9650 |
10241 |
9651 createMenuButton : function(id, s) { |
10242 createMenuButton : function(id, s) { |
9653 s.menu_button = 1; |
10244 s.menu_button = 1; |
9654 |
10245 |
9655 return this.createButton(id, s); |
10246 return this.createButton(id, s); |
9656 }, |
10247 }, |
9657 |
10248 |
9658 createSplitButton : function(id, s) { |
10249 createSplitButton : function(id, s, cc) { |
9659 var t = this, ed = t.editor, cmd, c; |
10250 var t = this, ed = t.editor, cmd, c, cls; |
9660 |
10251 |
9661 if (t.get(id)) |
10252 if (t.get(id)) |
9662 return null; |
10253 return null; |
9663 |
10254 |
9664 s.title = ed.translate(s.title); |
10255 s.title = ed.translate(s.title); |
9682 scope : s.scope, |
10273 scope : s.scope, |
9683 control_manager : t |
10274 control_manager : t |
9684 }, s); |
10275 }, s); |
9685 |
10276 |
9686 id = t.prefix + id; |
10277 id = t.prefix + id; |
9687 c = t.add(new tinymce.ui.SplitButton(id, s)); |
10278 cls = cc || t._cls.splitbutton || tinymce.ui.SplitButton; |
10279 c = t.add(new cls(id, s)); |
|
9688 ed.onMouseDown.add(c.hideMenu, c); |
10280 ed.onMouseDown.add(c.hideMenu, c); |
9689 |
10281 |
9690 return c; |
10282 return c; |
9691 }, |
10283 }, |
9692 |
10284 |
9693 createColorSplitButton : function(id, s) { |
10285 createColorSplitButton : function(id, s, cc) { |
9694 var t = this, ed = t.editor, cmd, c; |
10286 var t = this, ed = t.editor, cmd, c, cls; |
9695 |
10287 |
9696 if (t.get(id)) |
10288 if (t.get(id)) |
9697 return null; |
10289 return null; |
9698 |
10290 |
9699 s.title = ed.translate(s.title); |
10291 s.title = ed.translate(s.title); |
9718 scope : s.scope, |
10310 scope : s.scope, |
9719 more_colors_title : ed.getLang('more_colors') |
10311 more_colors_title : ed.getLang('more_colors') |
9720 }, s); |
10312 }, s); |
9721 |
10313 |
9722 id = t.prefix + id; |
10314 id = t.prefix + id; |
9723 c = new tinymce.ui.ColorSplitButton(id, s); |
10315 cls = cc || t._cls.colorsplitbutton || tinymce.ui.ColorSplitButton; |
10316 c = new cls(id, s); |
|
9724 ed.onMouseDown.add(c.hideMenu, c); |
10317 ed.onMouseDown.add(c.hideMenu, c); |
9725 |
10318 |
10319 // Remove the menu element when the editor is removed |
|
10320 ed.onRemove.add(function() { |
|
10321 c.destroy(); |
|
10322 }); |
|
10323 |
|
9726 return t.add(c); |
10324 return t.add(c); |
9727 }, |
10325 }, |
9728 |
10326 |
9729 createToolbar : function(id, s) { |
10327 createToolbar : function(id, s, cc) { |
9730 var c, t = this; |
10328 var c, t = this, cls; |
9731 |
10329 |
9732 id = t.prefix + id; |
10330 id = t.prefix + id; |
9733 c = new tinymce.ui.Toolbar(id, s); |
10331 cls = cc || t._cls.toolbar || tinymce.ui.Toolbar; |
10332 c = new cls(id, s); |
|
9734 |
10333 |
9735 if (t.get(id)) |
10334 if (t.get(id)) |
9736 return null; |
10335 return null; |
9737 |
10336 |
9738 return t.add(c); |
10337 return t.add(c); |
9739 }, |
10338 }, |
9740 |
10339 |
9741 createSeparator : function() { |
10340 createSeparator : function(cc) { |
9742 return new tinymce.ui.Separator(); |
10341 var cls = cc || this._cls.separator || tinymce.ui.Separator; |
10342 |
|
10343 return new cls(); |
|
10344 }, |
|
10345 |
|
10346 setControlType : function(n, c) { |
|
10347 return this._cls[n.toLowerCase()] = c; |
|
10348 }, |
|
10349 |
|
10350 destroy : function() { |
|
10351 each(this.controls, function(c) { |
|
10352 c.destroy(); |
|
10353 }); |
|
10354 |
|
10355 this.controls = null; |
|
9743 } |
10356 } |
9744 |
10357 |
9745 }); |
10358 }); |
9746 })(); |
10359 })(); |
9747 |
10360 |
9776 s.left = s.left || parseInt(sw / 2.0) - (s.width / 2.0); |
10389 s.left = s.left || parseInt(sw / 2.0) - (s.width / 2.0); |
9777 s.top = s.top || parseInt(sh / 2.0) - (s.height / 2.0); |
10390 s.top = s.top || parseInt(sh / 2.0) - (s.height / 2.0); |
9778 p.inline = false; |
10391 p.inline = false; |
9779 p.mce_width = s.width; |
10392 p.mce_width = s.width; |
9780 p.mce_height = s.height; |
10393 p.mce_height = s.height; |
10394 p.mce_auto_focus = s.auto_focus; |
|
9781 |
10395 |
9782 if (mo) { |
10396 if (mo) { |
9783 if (isIE) { |
10397 if (isIE) { |
9784 s.center = true; |
10398 s.center = true; |
9785 s.help = false; |
10399 s.help = false; |
9809 |
10423 |
9810 u = s.url || s.file; |
10424 u = s.url || s.file; |
9811 if (tinymce.relaxedDomain) |
10425 if (tinymce.relaxedDomain) |
9812 u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain; |
10426 u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain; |
9813 |
10427 |
10428 u = tinymce._addVer(u); |
|
10429 |
|
9814 try { |
10430 try { |
9815 if (isIE && mo) { |
10431 if (isIE && mo) { |
9816 w = 1; |
10432 w = 1; |
9817 window.showModalDialog(s.url || s.file, window, f); |
10433 window.showModalDialog(u, window, f); |
9818 } else |
10434 } else |
9819 w = window.open(u, s.name, f); |
10435 w = window.open(u, s.name, f); |
9820 } catch (ex) { |
10436 } catch (ex) { |
9821 // Ignore |
10437 // Ignore |
9822 } |
10438 } |
9838 |
10454 |
9839 confirm : function(t, cb, s) { |
10455 confirm : function(t, cb, s) { |
9840 cb.call(s || this, confirm(this._decode(this.editor.getLang(t, t)))); |
10456 cb.call(s || this, confirm(this._decode(this.editor.getLang(t, t)))); |
9841 }, |
10457 }, |
9842 |
10458 |
9843 alert : function(t, cb, s) { |
10459 alert : function(tx, cb, s) { |
9844 alert(this._decode(t)); |
10460 var t = this; |
10461 |
|
10462 alert(t._decode(t.editor.getLang(tx, tx))); |
|
9845 |
10463 |
9846 if (cb) |
10464 if (cb) |
9847 cb.call(s || this); |
10465 cb.call(s || t); |
9848 }, |
10466 }, |
9849 |
10467 |
9850 // Internal functions |
10468 // Internal functions |
9851 |
10469 |
9852 _decode : function(s) { |
10470 _decode : function(s) { |