Mercurial > public > sg101
comparison static/js/tiny_mce/themes/advanced/editor_template_src.js @ 442:6c182ceb7147
Fixing #217; upgrade TinyMCE to 3.4.2 and enable the paste plugin.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 26 May 2011 00:43:49 +0000 |
parents | 88b2b9cb8c1f |
children |
comparison
equal
deleted
inserted
replaced
441:33d0c55e57a9 | 442:6c182ceb7147 |
---|---|
64 | 64 |
65 t.editor = ed; | 65 t.editor = ed; |
66 t.url = url; | 66 t.url = url; |
67 t.onResolveName = new tinymce.util.Dispatcher(this); | 67 t.onResolveName = new tinymce.util.Dispatcher(this); |
68 | 68 |
69 ed.forcedHighContrastMode = ed.settings.detect_highcontrast && t._isHighContrast(); | |
70 ed.settings.skin = ed.forcedHighContrastMode ? 'highcontrast' : ed.settings.skin; | |
71 | |
69 // Default settings | 72 // Default settings |
70 t.settings = s = extend({ | 73 t.settings = s = extend({ |
71 theme_advanced_path : true, | 74 theme_advanced_path : true, |
72 theme_advanced_toolbar_location : 'bottom', | 75 theme_advanced_toolbar_location : 'bottom', |
73 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect", | 76 theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect", |
79 theme_advanced_more_colors : 1, | 82 theme_advanced_more_colors : 1, |
80 theme_advanced_row_height : 23, | 83 theme_advanced_row_height : 23, |
81 theme_advanced_resize_horizontal : 1, | 84 theme_advanced_resize_horizontal : 1, |
82 theme_advanced_resizing_use_cookie : 1, | 85 theme_advanced_resizing_use_cookie : 1, |
83 theme_advanced_font_sizes : "1,2,3,4,5,6,7", | 86 theme_advanced_font_sizes : "1,2,3,4,5,6,7", |
87 theme_advanced_font_selector : "span", | |
88 theme_advanced_show_current_color: 0, | |
84 readonly : ed.settings.readonly | 89 readonly : ed.settings.readonly |
85 }, ed.settings); | 90 }, ed.settings); |
86 | 91 |
87 // Setup default font_size_style_values | 92 // Setup default font_size_style_values |
88 if (!s.font_size_style_values) | 93 if (!s.font_size_style_values) |
117 s.theme_advanced_statusbar_location = s.theme_advanced_path_location; | 122 s.theme_advanced_statusbar_location = s.theme_advanced_path_location; |
118 | 123 |
119 if (s.theme_advanced_statusbar_location == 'none') | 124 if (s.theme_advanced_statusbar_location == 'none') |
120 s.theme_advanced_statusbar_location = 0; | 125 s.theme_advanced_statusbar_location = 0; |
121 | 126 |
127 if (ed.settings.content_css !== false) | |
128 ed.contentCSS.push(ed.baseURI.toAbsolute(url + "/skins/" + ed.settings.skin + "/content.css")); | |
129 | |
122 // Init editor | 130 // Init editor |
123 ed.onInit.add(function() { | 131 ed.onInit.add(function() { |
124 if (!ed.settings.readonly) | 132 if (!ed.settings.readonly) { |
125 ed.onNodeChange.add(t._nodeChanged, t); | 133 ed.onNodeChange.add(t._nodeChanged, t); |
126 | 134 ed.onKeyUp.add(t._updateUndoStatus, t); |
127 if (ed.settings.content_css !== false) | 135 ed.onMouseUp.add(t._updateUndoStatus, t); |
128 ed.dom.loadCSS(ed.baseURI.toAbsolute(url + "/skins/" + ed.settings.skin + "/content.css")); | 136 ed.dom.bind(ed.dom.getRoot(), 'dragend', function() { |
137 t._updateUndoStatus(ed); | |
138 }); | |
139 } | |
129 }); | 140 }); |
130 | 141 |
131 ed.onSetProgressState.add(function(ed, b, ti) { | 142 ed.onSetProgressState.add(function(ed, b, ti) { |
132 var co, id = ed.id, tb; | 143 var co, id = ed.id, tb; |
133 | 144 |
151 | 162 |
152 if (s.skin_variant) | 163 if (s.skin_variant) |
153 DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css"); | 164 DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css"); |
154 }, | 165 }, |
155 | 166 |
167 _isHighContrast : function() { | |
168 var actualColor, div = DOM.add(DOM.getRoot(), 'div', {'style': 'background-color: rgb(171,239,86);'}); | |
169 | |
170 actualColor = (DOM.getStyle(div, 'background-color', true) + '').toLowerCase().replace(/ /g, ''); | |
171 DOM.remove(div); | |
172 | |
173 return actualColor != 'rgb(171,239,86)' && actualColor != '#abef56'; | |
174 }, | |
175 | |
156 createControl : function(n, cf) { | 176 createControl : function(n, cf) { |
157 var cd, c; | 177 var cd, c; |
158 | 178 |
159 if (c = cf.createControl(n)) | 179 if (c = cf.createControl(n)) |
160 return c; | 180 return c; |
228 ed.focus(); | 248 ed.focus(); |
229 ed.undoManager.add(); | 249 ed.undoManager.add(); |
230 | 250 |
231 // Toggle off the current format | 251 // Toggle off the current format |
232 matches = ed.formatter.matchAll(formatNames); | 252 matches = ed.formatter.matchAll(formatNames); |
233 if (!name || matches[0] == name) | 253 if (!name || matches[0] == name) { |
234 ed.formatter.remove(matches[0]); | 254 if (matches[0]) |
235 else | 255 ed.formatter.remove(matches[0]); |
256 } else | |
236 ed.formatter.apply(name); | 257 ed.formatter.apply(name); |
237 | 258 |
238 ed.undoManager.add(); | 259 ed.undoManager.add(); |
239 ed.nodeChanged(); | 260 ed.nodeChanged(); |
240 | 261 |
312 // Fake selection, execCommand will fire a nodeChange and update the selection | 333 // Fake selection, execCommand will fire a nodeChange and update the selection |
313 c.select(function(sv) { | 334 c.select(function(sv) { |
314 return v == sv; | 335 return v == sv; |
315 }); | 336 }); |
316 | 337 |
338 if (cur && cur.value == v) { | |
339 c.select(null); | |
340 } | |
341 | |
317 return false; // No auto select | 342 return false; // No auto select |
318 } | 343 } |
319 }); | 344 }); |
320 | 345 |
321 if (c) { | 346 if (c) { |
358 | 383 |
359 // Fake selection, execCommand will fire a nodeChange and update the selection | 384 // Fake selection, execCommand will fire a nodeChange and update the selection |
360 c.select(function(sv) { | 385 c.select(function(sv) { |
361 return v == sv; | 386 return v == sv; |
362 }); | 387 }); |
388 | |
389 if (cur && (cur.value.fontSize == v.fontSize || cur.value['class'] == v['class'])) { | |
390 c.select(null); | |
391 } | |
363 | 392 |
364 return false; // No auto select | 393 return false; // No auto select |
365 }}); | 394 }}); |
366 | 395 |
367 if (c) { | 396 if (c) { |
395 dt : 'advanced.dt', | 424 dt : 'advanced.dt', |
396 dd : 'advanced.dd', | 425 dd : 'advanced.dd', |
397 samp : 'advanced.samp' | 426 samp : 'advanced.samp' |
398 }, t = this; | 427 }, t = this; |
399 | 428 |
400 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'}); | 429 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', onselect : function(v) { |
430 t.editor.execCommand('FormatBlock', false, v); | |
431 return false; | |
432 }}); | |
433 | |
401 if (c) { | 434 if (c) { |
402 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) { | 435 each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) { |
403 c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v}); | 436 c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v}); |
404 }); | 437 }); |
405 } | 438 } |
466 }, | 499 }, |
467 | 500 |
468 renderUI : function(o) { | 501 renderUI : function(o) { |
469 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; | 502 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; |
470 | 503 |
471 n = p = DOM.create('span', {id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '')}); | 504 if (ed.settings) { |
505 ed.settings.aria_label = s.aria_label + ed.getLang('advanced.help_shortcut'); | |
506 } | |
507 | |
508 // TODO: ACC Should have an aria-describedby attribute which is user-configurable to describe what this field is actually for. | |
509 // Maybe actually inherit it from the original textara? | |
510 n = p = DOM.create('span', {role : 'application', 'aria-labelledby' : ed.id + '_voice', id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '')}); | |
511 DOM.add(n, 'span', {'class': 'mceVoiceLabel', 'style': 'display:none;', id: ed.id + '_voice'}, s.aria_label); | |
472 | 512 |
473 if (!DOM.boxModel) | 513 if (!DOM.boxModel) |
474 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'}); | 514 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'}); |
475 | 515 |
476 n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0}); | 516 n = sc = DOM.add(n, 'table', {role : "presentation", id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0}); |
477 n = tb = DOM.add(n, 'tbody'); | 517 n = tb = DOM.add(n, 'tbody'); |
478 | 518 |
479 switch ((s.theme_advanced_layout_manager || '').toLowerCase()) { | 519 switch ((s.theme_advanced_layout_manager || '').toLowerCase()) { |
480 case "rowlayout": | 520 case "rowlayout": |
481 ic = t._rowLayout(s, tb, o); | 521 ic = t._rowLayout(s, tb, o); |
490 } | 530 } |
491 | 531 |
492 n = o.targetNode; | 532 n = o.targetNode; |
493 | 533 |
494 // Add classes to first and last TRs | 534 // Add classes to first and last TRs |
495 nl = DOM.stdMode ? sc.getElementsByTagName('tr') : sc.rows; // Quick fix for IE 8 | 535 nl = sc.rows; |
496 DOM.addClass(nl[0], 'mceFirst'); | 536 DOM.addClass(nl[0], 'mceFirst'); |
497 DOM.addClass(nl[nl.length - 1], 'mceLast'); | 537 DOM.addClass(nl[nl.length - 1], 'mceLast'); |
498 | 538 |
499 // Add classes to first and last TDs | 539 // Add classes to first and last TDs |
500 each(DOM.select('tr', tb), function(n) { | 540 each(DOM.select('tr', tb), function(n) { |
546 o.deltaHeight = 0; | 586 o.deltaHeight = 0; |
547 | 587 |
548 t.deltaHeight = o.deltaHeight; | 588 t.deltaHeight = o.deltaHeight; |
549 o.targetNode = null; | 589 o.targetNode = null; |
550 | 590 |
591 ed.onKeyDown.add(function(ed, evt) { | |
592 var DOM_VK_F10 = 121, DOM_VK_F11 = 122; | |
593 | |
594 if (evt.altKey) { | |
595 if (evt.keyCode === DOM_VK_F10) { | |
596 t.toolbarGroup.focus(); | |
597 return Event.cancel(evt); | |
598 } else if (evt.keyCode === DOM_VK_F11) { | |
599 DOM.get(ed.id + '_path_row').focus(); | |
600 return Event.cancel(evt); | |
601 } | |
602 } | |
603 }); | |
604 | |
605 // alt+0 is the UK recommended shortcut for accessing the list of access controls. | |
606 ed.addShortcut('alt+0', '', 'mceShortcuts', t); | |
607 | |
551 return { | 608 return { |
552 iframeContainer : ic, | 609 iframeContainer : ic, |
553 editorContainer : ed.id + '_parent', | 610 editorContainer : ed.id + '_parent', |
554 sizeContainer : sc, | 611 sizeContainer : sc, |
555 deltaHeight : o.deltaHeight | 612 deltaHeight : o.deltaHeight |
564 version : tinymce.majorVersion + "." + tinymce.minorVersion | 621 version : tinymce.majorVersion + "." + tinymce.minorVersion |
565 } | 622 } |
566 }, | 623 }, |
567 | 624 |
568 resizeBy : function(dw, dh) { | 625 resizeBy : function(dw, dh) { |
569 var e = DOM.get(this.editor.id + '_tbl'); | 626 var e = DOM.get(this.editor.id + '_ifr'); |
570 | 627 |
571 this.resizeTo(e.clientWidth + dw, e.clientHeight + dh); | 628 this.resizeTo(e.clientWidth + dw, e.clientHeight + dh); |
572 }, | 629 }, |
573 | 630 |
574 resizeTo : function(w, h) { | 631 resizeTo : function(w, h, store) { |
575 var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'); | 632 var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'); |
576 | 633 |
577 // Boundery fix box | 634 // Boundery fix box |
578 w = Math.max(s.theme_advanced_resizing_min_width || 100, w); | 635 w = Math.max(s.theme_advanced_resizing_min_width || 100, w); |
579 h = Math.max(s.theme_advanced_resizing_min_height || 100, h); | 636 h = Math.max(s.theme_advanced_resizing_min_height || 100, h); |
587 if (s.theme_advanced_resize_horizontal) { | 644 if (s.theme_advanced_resize_horizontal) { |
588 DOM.setStyle(e, 'width', ''); | 645 DOM.setStyle(e, 'width', ''); |
589 DOM.setStyle(ifr, 'width', w); | 646 DOM.setStyle(ifr, 'width', w); |
590 | 647 |
591 // Make sure that the size is never smaller than the over all ui | 648 // Make sure that the size is never smaller than the over all ui |
592 if (w < e.clientWidth) | 649 if (w < e.clientWidth) { |
650 w = e.clientWidth; | |
593 DOM.setStyle(ifr, 'width', e.clientWidth); | 651 DOM.setStyle(ifr, 'width', e.clientWidth); |
652 } | |
653 } | |
654 | |
655 // Store away the size | |
656 if (store && s.theme_advanced_resizing_use_cookie) { | |
657 Cookie.setHash("TinyMCE_" + ed.id + "_size", { | |
658 cw : w, | |
659 ch : h | |
660 }); | |
594 } | 661 } |
595 }, | 662 }, |
596 | 663 |
597 destroy : function() { | 664 destroy : function() { |
598 var id = this.editor.id; | 665 var id = this.editor.id; |
683 da = s.theme_advanced_containers_default_align || 'center'; | 750 da = s.theme_advanced_containers_default_align || 'center'; |
684 | 751 |
685 each(explode(s.theme_advanced_containers || ''), function(c, i) { | 752 each(explode(s.theme_advanced_containers || ''), function(c, i) { |
686 var v = s['theme_advanced_container_' + c] || ''; | 753 var v = s['theme_advanced_container_' + c] || ''; |
687 | 754 |
688 switch (v.toLowerCase()) { | 755 switch (c.toLowerCase()) { |
689 case 'mceeditor': | 756 case 'mceeditor': |
690 n = DOM.add(tb, 'tr'); | 757 n = DOM.add(tb, 'tr'); |
691 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); | 758 n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); |
692 break; | 759 break; |
693 | 760 |
751 tb.add(c); | 818 tb.add(c); |
752 }); | 819 }); |
753 }, | 820 }, |
754 | 821 |
755 _addToolbars : function(c, o) { | 822 _addToolbars : function(c, o) { |
756 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a; | 823 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a, toolbarGroup; |
824 | |
825 toolbarGroup = cf.createToolbarGroup('toolbargroup', { | |
826 'name': ed.getLang('advanced.toolbar'), | |
827 'tab_focus_toolbar':ed.getParam('theme_advanced_tab_focus_toolbar') | |
828 }); | |
829 | |
830 t.toolbarGroup = toolbarGroup; | |
757 | 831 |
758 a = s.theme_advanced_toolbar_align.toLowerCase(); | 832 a = s.theme_advanced_toolbar_align.toLowerCase(); |
759 a = 'mce' + t._ufirst(a); | 833 a = 'mce' + t._ufirst(a); |
760 | 834 |
761 n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a}); | 835 n = DOM.add(DOM.add(c, 'tr', {role: 'presentation'}), 'td', {'class' : 'mceToolbar ' + a, "role":"presentation"}); |
762 | |
763 if (!ed.getParam('accessibility_focus')) | |
764 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->')); | |
765 | |
766 h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->')); | |
767 | 836 |
768 // Create toolbar and add the controls | 837 // Create toolbar and add the controls |
769 for (i=1; (v = s['theme_advanced_buttons' + i]); i++) { | 838 for (i=1; (v = s['theme_advanced_buttons' + i]); i++) { |
770 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i}); | 839 tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i}); |
771 | 840 |
774 | 843 |
775 if (s['theme_advanced_buttons' + i + '_add_before']) | 844 if (s['theme_advanced_buttons' + i + '_add_before']) |
776 v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v; | 845 v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v; |
777 | 846 |
778 t._addControls(v, tb); | 847 t._addControls(v, tb); |
779 | 848 toolbarGroup.add(tb); |
780 //n.appendChild(n = tb.render()); | |
781 h.push(tb.renderHTML()); | |
782 | 849 |
783 o.deltaHeight -= s.theme_advanced_row_height; | 850 o.deltaHeight -= s.theme_advanced_row_height; |
784 } | 851 } |
785 | 852 h.push(toolbarGroup.renderHTML()); |
786 h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->')); | 853 h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->')); |
787 DOM.setHTML(n, h.join('')); | 854 DOM.setHTML(n, h.join('')); |
788 }, | 855 }, |
789 | 856 |
790 _addStatusBar : function(tb, o) { | 857 _addStatusBar : function(tb, o) { |
791 var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td; | 858 var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td; |
792 | 859 |
793 n = DOM.add(tb, 'tr'); | 860 n = DOM.add(tb, 'tr'); |
794 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); | 861 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); |
795 n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' '); | 862 n = DOM.add(n, 'div', {id : ed.id + '_path_row', 'role': 'group', 'aria-labelledby': ed.id + '_path_voice'}); |
796 DOM.add(n, 'a', {href : '#', accesskey : 'x'}); | 863 if (s.theme_advanced_path) { |
864 DOM.add(n, 'span', {id: ed.id + '_path_voice'}, ed.translate('advanced.path')); | |
865 DOM.add(n, 'span', {}, ': '); | |
866 } else { | |
867 DOM.add(n, 'span', {}, ' '); | |
868 } | |
869 | |
797 | 870 |
798 if (s.theme_advanced_resizing) { | 871 if (s.theme_advanced_resizing) { |
799 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'}); | 872 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'}); |
800 | 873 |
801 if (s.theme_advanced_resizing_use_cookie) { | 874 if (s.theme_advanced_resizing_use_cookie) { |
808 t.resizeTo(o.cw, o.ch); | 881 t.resizeTo(o.cw, o.ch); |
809 }); | 882 }); |
810 } | 883 } |
811 | 884 |
812 ed.onPostRender.add(function() { | 885 ed.onPostRender.add(function() { |
886 Event.add(ed.id + '_resize', 'click', function(e) { | |
887 e.preventDefault(); | |
888 }); | |
889 | |
813 Event.add(ed.id + '_resize', 'mousedown', function(e) { | 890 Event.add(ed.id + '_resize', 'mousedown', function(e) { |
814 var mouseMoveHandler1, mouseMoveHandler2, | 891 var mouseMoveHandler1, mouseMoveHandler2, |
815 mouseUpHandler1, mouseUpHandler2, | 892 mouseUpHandler1, mouseUpHandler2, |
816 startX, startY, startWidth, startHeight, width, height, ifrElm; | 893 startX, startY, startWidth, startHeight, width, height, ifrElm; |
817 | 894 |
818 function resizeOnMove(e) { | 895 function resizeOnMove(e) { |
896 e.preventDefault(); | |
897 | |
819 width = startWidth + (e.screenX - startX); | 898 width = startWidth + (e.screenX - startX); |
820 height = startHeight + (e.screenY - startY); | 899 height = startHeight + (e.screenY - startY); |
821 | 900 |
822 t.resizeTo(width, height); | 901 t.resizeTo(width, height); |
823 }; | 902 }; |
827 Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1); | 906 Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1); |
828 Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2); | 907 Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2); |
829 Event.remove(DOM.doc, 'mouseup', mouseUpHandler1); | 908 Event.remove(DOM.doc, 'mouseup', mouseUpHandler1); |
830 Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2); | 909 Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2); |
831 | 910 |
832 // Store away the size | 911 width = startWidth + (e.screenX - startX); |
833 if (s.theme_advanced_resizing_use_cookie) { | 912 height = startHeight + (e.screenY - startY); |
834 Cookie.setHash("TinyMCE_" + ed.id + "_size", { | 913 t.resizeTo(width, height, true); |
835 cw : width, | |
836 ch : height | |
837 }); | |
838 } | |
839 }; | 914 }; |
840 | 915 |
841 e.preventDefault(); | 916 e.preventDefault(); |
842 | 917 |
843 // Get the current rect size | 918 // Get the current rect size |
858 | 933 |
859 o.deltaHeight -= 21; | 934 o.deltaHeight -= 21; |
860 n = tb = null; | 935 n = tb = null; |
861 }, | 936 }, |
862 | 937 |
938 _updateUndoStatus : function(ed) { | |
939 var cm = ed.controlManager; | |
940 | |
941 cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing); | |
942 cm.setDisabled('redo', !ed.undoManager.hasRedo()); | |
943 }, | |
944 | |
863 _nodeChanged : function(ed, cm, n, co, ob) { | 945 _nodeChanged : function(ed, cm, n, co, ob) { |
864 var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, formatNames, matches; | 946 var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, fc, bc, formatNames, matches; |
865 | 947 |
866 tinymce.each(t.stateControls, function(c) { | 948 tinymce.each(t.stateControls, function(c) { |
867 cm.setActive(c, ed.queryCommandState(t.controls[c][1])); | 949 cm.setActive(c, ed.queryCommandState(t.controls[c][1])); |
868 }); | 950 }); |
869 | 951 |
881 return parents[i]; | 963 return parents[i]; |
882 } | 964 } |
883 }; | 965 }; |
884 | 966 |
885 cm.setActive('visualaid', ed.hasVisual); | 967 cm.setActive('visualaid', ed.hasVisual); |
886 cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing); | 968 t._updateUndoStatus(ed); |
887 cm.setDisabled('redo', !ed.undoManager.hasRedo()); | |
888 cm.setDisabled('outdent', !ed.queryCommandState('Outdent')); | 969 cm.setDisabled('outdent', !ed.queryCommandState('Outdent')); |
889 | 970 |
890 p = getParent('A'); | 971 p = getParent('A'); |
891 if (c = cm.get('link')) { | 972 if (c = cm.get('link')) { |
892 if (!p || !p.name) { | 973 if (!p || !p.name) { |
899 c.setDisabled(!p && co); | 980 c.setDisabled(!p && co); |
900 c.setActive(!!p && !p.name); | 981 c.setActive(!!p && !p.name); |
901 } | 982 } |
902 | 983 |
903 if (c = cm.get('anchor')) { | 984 if (c = cm.get('anchor')) { |
904 c.setActive(!!p && p.name); | 985 c.setActive(!co && !!p && p.name); |
905 } | 986 } |
906 | 987 |
907 p = getParent('IMG'); | 988 p = getParent('IMG'); |
908 if (c = cm.get('image')) | 989 if (c = cm.get('image')) |
909 c.setActive(!!p && n.className.indexOf('mceItem') == -1); | 990 c.setActive(!co && !!p && n.className.indexOf('mceItem') == -1); |
910 | 991 |
911 if (c = cm.get('styleselect')) { | 992 if (c = cm.get('styleselect')) { |
912 t._importClasses(); | 993 t._importClasses(); |
913 | 994 |
914 formatNames = []; | 995 formatNames = []; |
930 // Find out current fontSize, fontFamily and fontClass | 1011 // Find out current fontSize, fontFamily and fontClass |
931 getParent(function(n) { | 1012 getParent(function(n) { |
932 if (n.nodeName === 'SPAN') { | 1013 if (n.nodeName === 'SPAN') { |
933 if (!cl && n.className) | 1014 if (!cl && n.className) |
934 cl = n.className; | 1015 cl = n.className; |
935 | 1016 } |
1017 | |
1018 if (ed.dom.is(n, s.theme_advanced_font_selector)) { | |
936 if (!fz && n.style.fontSize) | 1019 if (!fz && n.style.fontSize) |
937 fz = n.style.fontSize; | 1020 fz = n.style.fontSize; |
938 | 1021 |
939 if (!fn && n.style.fontFamily) | 1022 if (!fn && n.style.fontFamily) |
940 fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase(); | 1023 fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase(); |
1024 | |
1025 if (!fc && n.style.color) | |
1026 fc = n.style.color; | |
1027 | |
1028 if (!bc && n.style.backgroundColor) | |
1029 bc = n.style.backgroundColor; | |
941 } | 1030 } |
942 | 1031 |
943 return false; | 1032 return false; |
944 }); | 1033 }); |
945 | 1034 |
961 | 1050 |
962 if (v['class'] && v['class'] === cl) | 1051 if (v['class'] && v['class'] === cl) |
963 return true; | 1052 return true; |
964 }); | 1053 }); |
965 } | 1054 } |
1055 | |
1056 if (s.theme_advanced_show_current_color) { | |
1057 function updateColor(controlId, color) { | |
1058 if (c = cm.get(controlId)) { | |
1059 if (!color) | |
1060 color = c.settings.default_color; | |
1061 if (color !== c.value) { | |
1062 c.displayColor(color); | |
1063 } | |
1064 } | |
1065 } | |
1066 updateColor('forecolor', fc); | |
1067 updateColor('backcolor', bc); | |
1068 } | |
1069 | |
1070 if (s.theme_advanced_show_current_color) { | |
1071 function updateColor(controlId, color) { | |
1072 if (c = cm.get(controlId)) { | |
1073 if (!color) | |
1074 color = c.settings.default_color; | |
1075 if (color !== c.value) { | |
1076 c.displayColor(color); | |
1077 } | |
1078 } | |
1079 }; | |
1080 | |
1081 updateColor('forecolor', fc); | |
1082 updateColor('backcolor', bc); | |
1083 } | |
966 | 1084 |
967 if (s.theme_advanced_path && s.theme_advanced_statusbar_location) { | 1085 if (s.theme_advanced_path && s.theme_advanced_statusbar_location) { |
968 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'}); | 1086 p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'}); |
1087 | |
1088 if (t.statusKeyboardNavigation) { | |
1089 t.statusKeyboardNavigation.destroy(); | |
1090 t.statusKeyboardNavigation = null; | |
1091 } | |
1092 | |
969 DOM.setHTML(p, ''); | 1093 DOM.setHTML(p, ''); |
970 | 1094 |
971 getParent(function(n) { | 1095 getParent(function(n) { |
972 var na = n.nodeName.toLowerCase(), u, pi, ti = ''; | 1096 var na = n.nodeName.toLowerCase(), u, pi, ti = ''; |
973 | 1097 |
974 /*if (n.getAttribute('_mce_bogus')) | 1098 if (n.getAttribute('data-mce-bogus')) |
975 return; | 1099 return; |
976 */ | 1100 |
977 // Ignore non element and hidden elements | 1101 // Ignore non element and hidden elements |
978 if (n.nodeType != 1 || n.nodeName === 'BR' || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved'))) | 1102 if (n.nodeType != 1 || n.nodeName === 'BR' || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved'))) |
979 return; | 1103 return; |
980 | |
981 // Fake name | |
982 if (v = DOM.getAttrib(n, 'mce_name')) | |
983 na = v; | |
984 | 1104 |
985 // Handle prefix | 1105 // Handle prefix |
986 if (tinymce.isIE && n.scopeName !== 'HTML') | 1106 if (tinymce.isIE && n.scopeName !== 'HTML') |
987 na = n.scopeName + ':' + na; | 1107 na = n.scopeName + ':' + na; |
988 | 1108 |
1054 t.onResolveName.dispatch(t, na); | 1174 t.onResolveName.dispatch(t, na); |
1055 ti = na.title; | 1175 ti = na.title; |
1056 na = na.name; | 1176 na = na.name; |
1057 | 1177 |
1058 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');"; | 1178 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');"; |
1059 pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na); | 1179 pi = DOM.create('a', {'href' : "javascript:;", role: 'button', onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na); |
1060 | 1180 |
1061 if (p.hasChildNodes()) { | 1181 if (p.hasChildNodes()) { |
1062 p.insertBefore(DOM.doc.createTextNode(' \u00bb '), p.firstChild); | 1182 p.insertBefore(DOM.create('span', {'aria-hidden': 'true'}, '\u00a0\u00bb '), p.firstChild); |
1063 p.insertBefore(pi, p.firstChild); | 1183 p.insertBefore(pi, p.firstChild); |
1064 } else | 1184 } else |
1065 p.appendChild(pi); | 1185 p.appendChild(pi); |
1066 }, ed.getBody()); | 1186 }, ed.getBody()); |
1187 | |
1188 if (DOM.select('a', p).length > 0) { | |
1189 t.statusKeyboardNavigation = new tinymce.ui.KeyboardNavigation({ | |
1190 root: ed.id + "_path_row", | |
1191 items: DOM.select('a', p), | |
1192 excludeFromTabOrder: true, | |
1193 onCancel: function() { | |
1194 ed.focus(); | |
1195 } | |
1196 }, DOM); | |
1197 } | |
1067 } | 1198 } |
1068 }, | 1199 }, |
1069 | 1200 |
1070 // Commands gets called by execCommand | 1201 // Commands gets called by execCommand |
1071 | 1202 |
1107 width : 480, | 1238 width : 480, |
1108 height : 380, | 1239 height : 380, |
1109 inline : true | 1240 inline : true |
1110 }, { | 1241 }, { |
1111 theme_url : this.url | 1242 theme_url : this.url |
1243 }); | |
1244 }, | |
1245 | |
1246 _mceShortcuts : function() { | |
1247 var ed = this.editor; | |
1248 ed.windowManager.open({ | |
1249 url: this.url + '/shortcuts.htm', | |
1250 width: 480, | |
1251 height: 380, | |
1252 inline: true | |
1253 }, { | |
1254 theme_url: this.url | |
1112 }); | 1255 }); |
1113 }, | 1256 }, |
1114 | 1257 |
1115 _mceColorPicker : function(u, v) { | 1258 _mceColorPicker : function(u, v) { |
1116 var ed = this.editor; | 1259 var ed = this.editor; |