Mercurial > public > sg101
comparison media/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js @ 217:237710206167
Update TinyMCE to 3.3.6
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 01 Jun 2010 04:49:29 +0000 |
parents | 149c3567fec1 |
children | 6ed2932901fa |
comparison
equal
deleted
inserted
replaced
216:fe900598f81c | 217:237710206167 |
---|---|
25 * @method init | 25 * @method init |
26 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. | 26 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. |
27 * @param {string} url Absolute URL to where the plugin is located. | 27 * @param {string} url Absolute URL to where the plugin is located. |
28 */ | 28 */ |
29 init : function(ed) { | 29 init : function(ed) { |
30 var t = this; | 30 var t = this, lastRng; |
31 | 31 |
32 t.editor = ed; | 32 t.editor = ed; |
33 | 33 |
34 /** | 34 /** |
35 * This event gets fired when the context menu is shown. | 35 * This event gets fired when the context menu is shown. |
40 */ | 40 */ |
41 t.onContextMenu = new tinymce.util.Dispatcher(this); | 41 t.onContextMenu = new tinymce.util.Dispatcher(this); |
42 | 42 |
43 ed.onContextMenu.add(function(ed, e) { | 43 ed.onContextMenu.add(function(ed, e) { |
44 if (!e.ctrlKey) { | 44 if (!e.ctrlKey) { |
45 // Restore the last selection since it was removed | |
46 if (lastRng) | |
47 ed.selection.setRng(lastRng); | |
48 | |
45 t._getMenu(ed).showMenu(e.clientX, e.clientY); | 49 t._getMenu(ed).showMenu(e.clientX, e.clientY); |
46 Event.add(ed.getDoc(), 'click', hide); | 50 Event.add(ed.getDoc(), 'click', hide); |
47 Event.cancel(e); | 51 Event.cancel(e); |
48 } | 52 } |
49 }); | 53 }); |
50 | 54 |
51 function hide() { | 55 function hide(ed, e) { |
56 lastRng = null; | |
57 | |
58 // Since the contextmenu event moves | |
59 // the selection we need to store it away | |
60 if (e && e.button == 2) { | |
61 lastRng = ed.selection.getRng(); | |
62 return; | |
63 } | |
64 | |
52 if (t._menu) { | 65 if (t._menu) { |
53 t._menu.removeAll(); | 66 t._menu.removeAll(); |
54 t._menu.destroy(); | 67 t._menu.destroy(); |
55 Event.remove(ed.getDoc(), 'click', hide); | 68 Event.remove(ed.getDoc(), 'click', hide); |
56 } | 69 } |