Mercurial > public > sg101
comparison static/js/tiny_mce/plugins/inlinepopups/editor_plugin_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 |
---|---|
40 t.count = 0; | 40 t.count = 0; |
41 t.windows = {}; | 41 t.windows = {}; |
42 }, | 42 }, |
43 | 43 |
44 open : function(f, p) { | 44 open : function(f, p) { |
45 var t = this, id, opt = '', ed = t.editor, dw = 0, dh = 0, vp, po, mdf, clf, we, w, u; | 45 var t = this, id, opt = '', ed = t.editor, dw = 0, dh = 0, vp, po, mdf, clf, we, w, u, parentWindow; |
46 | 46 |
47 f = f || {}; | 47 f = f || {}; |
48 p = p || {}; | 48 p = p || {}; |
49 | 49 |
50 // Run native windows | 50 // Run native windows |
51 if (!f.inline) | 51 if (!f.inline) |
52 return t.parent(f, p); | 52 return t.parent(f, p); |
53 | 53 |
54 parentWindow = t._frontWindow(); | |
55 if (parentWindow && DOM.get(parentWindow.id + '_ifr')) { | |
56 parentWindow.focussedElement = DOM.get(parentWindow.id + '_ifr').contentWindow.document.activeElement; | |
57 } | |
58 | |
54 // Only store selection if the type is a normal window | 59 // Only store selection if the type is a normal window |
55 if (!f.type) | 60 if (!f.type) |
56 t.bookmark = ed.selection.getBookmark(1); | 61 t.bookmark = ed.selection.getBookmark(1); |
57 | 62 |
58 id = DOM.uniqueId(); | 63 id = DOM.uniqueId(); |
105 if (f.movable) | 110 if (f.movable) |
106 opt += ' mceMovable'; | 111 opt += ' mceMovable'; |
107 | 112 |
108 // Create DOM objects | 113 // Create DOM objects |
109 t._addAll(DOM.doc.body, | 114 t._addAll(DOM.doc.body, |
110 ['div', {id : id, 'class' : ed.settings.inlinepopups_skin || 'clearlooks2', style : 'width:100px;height:100px'}, | 115 ['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'}, |
111 ['div', {id : id + '_wrapper', 'class' : 'mceWrapper' + opt}, | 116 ['div', {id : id + '_wrapper', 'class' : 'mceWrapper' + opt}, |
112 ['div', {id : id + '_top', 'class' : 'mceTop'}, | 117 ['div', {id : id + '_top', 'class' : 'mceTop'}, |
113 ['div', {'class' : 'mceLeft'}], | 118 ['div', {'class' : 'mceLeft'}], |
114 ['div', {'class' : 'mceCenter'}], | 119 ['div', {'class' : 'mceCenter'}], |
115 ['div', {'class' : 'mceRight'}], | 120 ['div', {'class' : 'mceRight'}], |
116 ['span', {id : id + '_title'}, f.title || ''] | 121 ['span', {id : id + '_title'}, f.title || ''] |
117 ], | 122 ], |
118 | 123 |
119 ['div', {id : id + '_middle', 'class' : 'mceMiddle'}, | 124 ['div', {id : id + '_middle', 'class' : 'mceMiddle'}, |
120 ['div', {id : id + '_left', 'class' : 'mceLeft'}], | 125 ['div', {id : id + '_left', 'class' : 'mceLeft', tabindex : '0'}], |
121 ['span', {id : id + '_content'}], | 126 ['span', {id : id + '_content'}], |
122 ['div', {id : id + '_right', 'class' : 'mceRight'}] | 127 ['div', {id : id + '_right', 'class' : 'mceRight', tabindex : '0'}] |
123 ], | 128 ], |
124 | 129 |
125 ['div', {id : id + '_bottom', 'class' : 'mceBottom'}, | 130 ['div', {id : id + '_bottom', 'class' : 'mceBottom'}, |
126 ['div', {'class' : 'mceLeft'}], | 131 ['div', {'class' : 'mceLeft'}], |
127 ['div', {'class' : 'mceCenter'}], | 132 ['div', {'class' : 'mceCenter'}], |
181 if (f.type == 'confirm') | 186 if (f.type == 'confirm') |
182 DOM.add(id + '_wrapper', 'a', {'class' : 'mceButton mceCancel', href : 'javascript:;', onmousedown : 'return false;'}, 'Cancel'); | 187 DOM.add(id + '_wrapper', 'a', {'class' : 'mceButton mceCancel', href : 'javascript:;', onmousedown : 'return false;'}, 'Cancel'); |
183 | 188 |
184 DOM.add(id + '_middle', 'div', {'class' : 'mceIcon'}); | 189 DOM.add(id + '_middle', 'div', {'class' : 'mceIcon'}); |
185 DOM.setHTML(id + '_content', f.content.replace('\n', '<br />')); | 190 DOM.setHTML(id + '_content', f.content.replace('\n', '<br />')); |
191 | |
192 Event.add(id, 'keyup', function(evt) { | |
193 var VK_ESCAPE = 27; | |
194 if (evt.keyCode === VK_ESCAPE) { | |
195 f.button_func(false); | |
196 return Event.cancel(evt); | |
197 } | |
198 }); | |
199 | |
200 Event.add(id, 'keydown', function(evt) { | |
201 var cancelButton, VK_TAB = 9; | |
202 if (evt.keyCode === VK_TAB) { | |
203 cancelButton = DOM.select('a.mceCancel', id + '_wrapper')[0]; | |
204 if (cancelButton && cancelButton !== evt.target) { | |
205 cancelButton.focus(); | |
206 } else { | |
207 DOM.get(id + '_ok').focus(); | |
208 } | |
209 return Event.cancel(evt); | |
210 } | |
211 }); | |
186 } | 212 } |
187 | 213 |
188 // Register events | 214 // Register events |
189 mdf = Event.add(id, 'mousedown', function(e) { | 215 mdf = Event.add(id, 'mousedown', function(e) { |
190 var n = e.target, w, vp; | 216 var n = e.target, w, vp; |
237 f.button_func(n.className == 'mceButton mceOk'); | 263 f.button_func(n.className == 'mceButton mceOk'); |
238 return Event.cancel(e); | 264 return Event.cancel(e); |
239 } | 265 } |
240 } | 266 } |
241 }); | 267 }); |
242 | 268 |
269 // Make sure the tab order loops within the dialog. | |
270 Event.add([id + '_left', id + '_right'], 'focus', function(evt) { | |
271 var iframe = DOM.get(id + '_ifr'); | |
272 if (iframe) { | |
273 var body = iframe.contentWindow.document.body; | |
274 var focusable = DOM.select(':input:enabled,*[tabindex=0]', body); | |
275 if (evt.target.id === (id + '_left')) { | |
276 focusable[focusable.length - 1].focus(); | |
277 } else { | |
278 focusable[0].focus(); | |
279 } | |
280 } else { | |
281 DOM.get(id + '_ok').focus(); | |
282 } | |
283 }); | |
284 | |
243 // Add window | 285 // Add window |
244 w = t.windows[id] = { | 286 w = t.windows[id] = { |
245 id : id, | 287 id : id, |
246 mousedown_func : mdf, | 288 mousedown_func : mdf, |
247 click_func : clf, | 289 click_func : clf, |
263 'class' : (t.editor.settings.inlinepopups_skin || 'clearlooks2') + '_modalBlocker', | 305 'class' : (t.editor.settings.inlinepopups_skin || 'clearlooks2') + '_modalBlocker', |
264 style : {zIndex : t.zIndex - 1} | 306 style : {zIndex : t.zIndex - 1} |
265 }); | 307 }); |
266 | 308 |
267 DOM.show('mceModalBlocker'); // Reduces flicker in IE | 309 DOM.show('mceModalBlocker'); // Reduces flicker in IE |
310 DOM.setAttrib(DOM.doc.body, 'aria-hidden', 'true'); | |
268 } else | 311 } else |
269 DOM.setStyle('mceModalBlocker', 'z-index', t.zIndex - 1); | 312 DOM.setStyle('mceModalBlocker', 'z-index', t.zIndex - 1); |
270 | 313 |
271 if (tinymce.isIE6 || /Firefox\/2\./.test(navigator.userAgent) || (tinymce.isIE && !DOM.boxModel)) | 314 if (tinymce.isIE6 || /Firefox\/2\./.test(navigator.userAgent) || (tinymce.isIE && !DOM.boxModel)) |
272 DOM.setStyles('mceModalBlocker', {position : 'absolute', left : vp.x, top : vp.y, width : vp.w - 2, height : vp.h - 2}); | 315 DOM.setStyles('mceModalBlocker', {position : 'absolute', left : vp.x, top : vp.y, width : vp.w - 2, height : vp.h - 2}); |
273 | 316 |
317 DOM.setAttrib(id, 'aria-hidden', 'false'); | |
274 t.focus(id); | 318 t.focus(id); |
275 t._fixIELayout(id, 1); | 319 t._fixIELayout(id, 1); |
276 | 320 |
277 // Focus ok button | 321 // Focus ok button |
278 if (DOM.get(id + '_ok')) | 322 if (DOM.get(id + '_ok')) |
279 DOM.get(id + '_ok').focus(); | 323 DOM.get(id + '_ok').focus(); |
280 | |
281 t.count++; | 324 t.count++; |
282 | 325 |
283 return w; | 326 return w; |
284 }, | 327 }, |
285 | 328 |
293 | 336 |
294 id = id + '_wrapper'; | 337 id = id + '_wrapper'; |
295 DOM.removeClass(t.lastId, 'mceFocus'); | 338 DOM.removeClass(t.lastId, 'mceFocus'); |
296 DOM.addClass(id, 'mceFocus'); | 339 DOM.addClass(id, 'mceFocus'); |
297 t.lastId = id; | 340 t.lastId = id; |
341 | |
342 if (w.focussedElement) { | |
343 w.focussedElement.focus(); | |
344 } else if (DOM.get(id + '_ok')) { | |
345 DOM.get(w.id + '_ok').focus(); | |
346 } else if (DOM.get(w.id + '_ifr')) { | |
347 DOM.get(w.id + '_ifr').focus(); | |
348 } | |
298 } | 349 } |
299 }, | 350 }, |
300 | 351 |
301 _addAll : function(te, ne) { | 352 _addAll : function(te, ne) { |
302 var i, n, t = this, dom = tinymce.DOM; | 353 var i, n, t = this, dom = tinymce.DOM; |
476 w.iframeElement.resizeBy(dw, dh); | 527 w.iframeElement.resizeBy(dw, dh); |
477 } | 528 } |
478 }, | 529 }, |
479 | 530 |
480 close : function(win, id) { | 531 close : function(win, id) { |
481 var t = this, w, d = DOM.doc, ix = 0, fw, id; | 532 var t = this, w, d = DOM.doc, fw, id; |
482 | 533 |
483 id = t._findId(id || win); | 534 id = t._findId(id || win); |
484 | 535 |
485 // Probably not inline | 536 // Probably not inline |
486 if (!t.windows[id]) { | 537 if (!t.windows[id]) { |
488 return; | 539 return; |
489 } | 540 } |
490 | 541 |
491 t.count--; | 542 t.count--; |
492 | 543 |
493 if (t.count == 0) | 544 if (t.count == 0) { |
494 DOM.remove('mceModalBlocker'); | 545 DOM.remove('mceModalBlocker'); |
546 DOM.setAttrib(DOM.doc.body, 'aria-hidden', 'false'); | |
547 t.editor.focus(); | |
548 } | |
495 | 549 |
496 if (w = t.windows[id]) { | 550 if (w = t.windows[id]) { |
497 t.onClose.dispatch(t); | 551 t.onClose.dispatch(t); |
498 Event.remove(d, 'mousedown', w.mousedownFunc); | 552 Event.remove(d, 'mousedown', w.mousedownFunc); |
499 Event.remove(d, 'click', w.clickFunc); | 553 Event.remove(d, 'click', w.clickFunc); |
502 | 556 |
503 DOM.setAttrib(id + '_ifr', 'src', 'javascript:""'); // Prevent leak | 557 DOM.setAttrib(id + '_ifr', 'src', 'javascript:""'); // Prevent leak |
504 w.element.remove(); | 558 w.element.remove(); |
505 delete t.windows[id]; | 559 delete t.windows[id]; |
506 | 560 |
507 // Find front most window and focus that | 561 fw = t._frontWindow(); |
508 each (t.windows, function(w) { | |
509 if (w.zIndex > ix) { | |
510 fw = w; | |
511 ix = w.zIndex; | |
512 } | |
513 }); | |
514 | 562 |
515 if (fw) | 563 if (fw) |
516 t.focus(fw.id); | 564 t.focus(fw.id); |
517 } | 565 } |
566 }, | |
567 | |
568 // Find front most window | |
569 _frontWindow : function() { | |
570 var fw, ix = 0; | |
571 // Find front most window and focus that | |
572 each (this.windows, function(w) { | |
573 if (w.zIndex > ix) { | |
574 fw = w; | |
575 ix = w.zIndex; | |
576 } | |
577 }); | |
578 return fw; | |
518 }, | 579 }, |
519 | 580 |
520 setTitle : function(w, ti) { | 581 setTitle : function(w, ti) { |
521 var e; | 582 var e; |
522 | 583 |