X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit%2Ftiny_mce%2Fplugins%2Finlinepopups%2Feditor_plugin_src.js;h=67123ca3142ec46384858fda1a641ed6d2401700;hp=0c1de3703d439098563028b765efdf8ca82078d6;hb=b05f4eef4014db3885787ef15107cba93c932ac9;hpb=b347fec899815ec89b2738a0877880ee81e74b59 diff --git a/webcit/tiny_mce/plugins/inlinepopups/editor_plugin_src.js b/webcit/tiny_mce/plugins/inlinepopups/editor_plugin_src.js index 0c1de3703..67123ca31 100644 --- a/webcit/tiny_mce/plugins/inlinepopups/editor_plugin_src.js +++ b/webcit/tiny_mce/plugins/inlinepopups/editor_plugin_src.js @@ -42,7 +42,7 @@ }, open : function(f, p) { - var t = this, id, opt = '', ed = t.editor, dw = 0, dh = 0, vp, po, mdf, clf, we, w, u; + var t = this, id, opt = '', ed = t.editor, dw = 0, dh = 0, vp, po, mdf, clf, we, w, u, parentWindow; f = f || {}; p = p || {}; @@ -51,6 +51,11 @@ if (!f.inline) return t.parent(f, p); + parentWindow = t._frontWindow(); + if (parentWindow && DOM.get(parentWindow.id + '_ifr')) { + parentWindow.focussedElement = DOM.get(parentWindow.id + '_ifr').contentWindow.document.activeElement; + } + // Only store selection if the type is a normal window if (!f.type) t.bookmark = ed.selection.getBookmark(1); @@ -107,7 +112,7 @@ // Create DOM objects t._addAll(DOM.doc.body, - ['div', {id : id, 'class' : (ed.settings.inlinepopups_skin || 'clearlooks2') + (tinymce.isIE && window.getSelection ? ' ie9' : ''), style : 'width:100px;height:100px'}, + ['div', {id : id, role : 'dialog', 'aria-labelledby': f.type ? id + '_content' : id + '_title', 'class' : (ed.settings.inlinepopups_skin || 'clearlooks2') + (tinymce.isIE && window.getSelection ? ' ie9' : ''), style : 'width:100px;height:100px'}, ['div', {id : id + '_wrapper', 'class' : 'mceWrapper' + opt}, ['div', {id : id + '_top', 'class' : 'mceTop'}, ['div', {'class' : 'mceLeft'}], @@ -117,9 +122,9 @@ ], ['div', {id : id + '_middle', 'class' : 'mceMiddle'}, - ['div', {id : id + '_left', 'class' : 'mceLeft'}], + ['div', {id : id + '_left', 'class' : 'mceLeft', tabindex : '0'}], ['span', {id : id + '_content'}], - ['div', {id : id + '_right', 'class' : 'mceRight'}] + ['div', {id : id + '_right', 'class' : 'mceRight', tabindex : '0'}] ], ['div', {id : id + '_bottom', 'class' : 'mceBottom'}, @@ -183,6 +188,27 @@ DOM.add(id + '_middle', 'div', {'class' : 'mceIcon'}); DOM.setHTML(id + '_content', f.content.replace('\n', '
')); + + Event.add(id, 'keyup', function(evt) { + var VK_ESCAPE = 27; + if (evt.keyCode === VK_ESCAPE) { + f.button_func(false); + return Event.cancel(evt); + } + }); + + Event.add(id, 'keydown', function(evt) { + var cancelButton, VK_TAB = 9; + if (evt.keyCode === VK_TAB) { + cancelButton = DOM.select('a.mceCancel', id + '_wrapper')[0]; + if (cancelButton && cancelButton !== evt.target) { + cancelButton.focus(); + } else { + DOM.get(id + '_ok').focus(); + } + return Event.cancel(evt); + } + }); } // Register events @@ -193,7 +219,10 @@ t.focus(id); if (n.nodeName == 'A' || n.nodeName == 'a') { - if (n.className == 'mceMax') { + if (n.className == 'mceClose') { + t.close(null, id); + return Event.cancel(e); + } else if (n.className == 'mceMax') { w.oldPos = w.element.getXY(); w.oldSize = w.element.getSize(); @@ -239,7 +268,23 @@ } } }); - + + // Make sure the tab order loops within the dialog. + Event.add([id + '_left', id + '_right'], 'focus', function(evt) { + var iframe = DOM.get(id + '_ifr'); + if (iframe) { + var body = iframe.contentWindow.document.body; + var focusable = DOM.select(':input:enabled,*[tabindex=0]', body); + if (evt.target.id === (id + '_left')) { + focusable[focusable.length - 1].focus(); + } else { + focusable[0].focus(); + } + } else { + DOM.get(id + '_ok').focus(); + } + }); + // Add window w = t.windows[id] = { id : id, @@ -265,19 +310,20 @@ }); DOM.show('mceModalBlocker'); // Reduces flicker in IE + DOM.setAttrib(DOM.doc.body, 'aria-hidden', 'true'); } else DOM.setStyle('mceModalBlocker', 'z-index', t.zIndex - 1); if (tinymce.isIE6 || /Firefox\/2\./.test(navigator.userAgent) || (tinymce.isIE && !DOM.boxModel)) DOM.setStyles('mceModalBlocker', {position : 'absolute', left : vp.x, top : vp.y, width : vp.w - 2, height : vp.h - 2}); + DOM.setAttrib(id, 'aria-hidden', 'false'); t.focus(id); t._fixIELayout(id, 1); // Focus ok button if (DOM.get(id + '_ok')) DOM.get(id + '_ok').focus(); - t.count++; return w; @@ -295,6 +341,14 @@ DOM.removeClass(t.lastId, 'mceFocus'); DOM.addClass(id, 'mceFocus'); t.lastId = id; + + if (w.focussedElement) { + w.focussedElement.focus(); + } else if (DOM.get(id + '_ok')) { + DOM.get(w.id + '_ok').focus(); + } else if (DOM.get(w.id + '_ifr')) { + DOM.get(w.id + '_ifr').focus(); + } } }, @@ -478,7 +532,7 @@ }, close : function(win, id) { - var t = this, w, d = DOM.doc, ix = 0, fw, id; + var t = this, w, d = DOM.doc, fw, id; id = t._findId(id || win); @@ -490,8 +544,11 @@ t.count--; - if (t.count == 0) + if (t.count == 0) { DOM.remove('mceModalBlocker'); + DOM.setAttrib(DOM.doc.body, 'aria-hidden', 'false'); + t.editor.focus(); + } if (w = t.windows[id]) { t.onClose.dispatch(t); @@ -504,18 +561,25 @@ w.element.remove(); delete t.windows[id]; - // Find front most window and focus that - each (t.windows, function(w) { - if (w.zIndex > ix) { - fw = w; - ix = w.zIndex; - } - }); + fw = t._frontWindow(); if (fw) t.focus(fw.id); } }, + + // Find front most window + _frontWindow : function() { + var fw, ix = 0; + // Find front most window and focus that + each (this.windows, function(w) { + if (w.zIndex > ix) { + fw = w; + ix = w.zIndex; + } + }); + return fw; + }, setTitle : function(w, ti) { var e;