Mercurial > public > sg101
comparison media/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js @ 45:a5b4c5ce0658
Breaking down and controlling all media files, including javascript libraries.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 19 Jun 2009 03:16:03 +0000 |
parents | |
children | 149c3567fec1 |
comparison
equal
deleted
inserted
replaced
44:08cd19c1ee50 | 45:a5b4c5ce0658 |
---|---|
1 /** | |
2 * $Id: editor_plugin_src.js 848 2008-05-15 11:54:40Z spocke $ | |
3 * | |
4 * @author Moxiecode | |
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. | |
6 */ | |
7 | |
8 (function() { | |
9 var Event = tinymce.dom.Event, each = tinymce.each, DOM = tinymce.DOM; | |
10 | |
11 tinymce.create('tinymce.plugins.ContextMenu', { | |
12 init : function(ed) { | |
13 var t = this; | |
14 | |
15 t.editor = ed; | |
16 t.onContextMenu = new tinymce.util.Dispatcher(this); | |
17 | |
18 ed.onContextMenu.add(function(ed, e) { | |
19 if (!e.ctrlKey) { | |
20 t._getMenu(ed).showMenu(e.clientX, e.clientY); | |
21 Event.add(ed.getDoc(), 'click', hide); | |
22 Event.cancel(e); | |
23 } | |
24 }); | |
25 | |
26 function hide() { | |
27 if (t._menu) { | |
28 t._menu.removeAll(); | |
29 t._menu.destroy(); | |
30 Event.remove(ed.getDoc(), 'click', hide); | |
31 } | |
32 }; | |
33 | |
34 ed.onMouseDown.add(hide); | |
35 ed.onKeyDown.add(hide); | |
36 }, | |
37 | |
38 getInfo : function() { | |
39 return { | |
40 longname : 'Contextmenu', | |
41 author : 'Moxiecode Systems AB', | |
42 authorurl : 'http://tinymce.moxiecode.com', | |
43 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/contextmenu', | |
44 version : tinymce.majorVersion + "." + tinymce.minorVersion | |
45 }; | |
46 }, | |
47 | |
48 _getMenu : function(ed) { | |
49 var t = this, m = t._menu, se = ed.selection, col = se.isCollapsed(), el = se.getNode() || ed.getBody(), am, p1, p2; | |
50 | |
51 if (m) { | |
52 m.removeAll(); | |
53 m.destroy(); | |
54 } | |
55 | |
56 p1 = DOM.getPos(ed.getContentAreaContainer()); | |
57 p2 = DOM.getPos(ed.getContainer()); | |
58 | |
59 m = ed.controlManager.createDropMenu('contextmenu', { | |
60 offset_x : p1.x + ed.getParam('contextmenu_offset_x', 0), | |
61 offset_y : p1.y + ed.getParam('contextmenu_offset_y', 0), | |
62 constrain : 1 | |
63 }); | |
64 | |
65 t._menu = m; | |
66 | |
67 m.add({title : 'advanced.cut_desc', icon : 'cut', cmd : 'Cut'}).setDisabled(col); | |
68 m.add({title : 'advanced.copy_desc', icon : 'copy', cmd : 'Copy'}).setDisabled(col); | |
69 m.add({title : 'advanced.paste_desc', icon : 'paste', cmd : 'Paste'}); | |
70 | |
71 if ((el.nodeName == 'A' && !ed.dom.getAttrib(el, 'name')) || !col) { | |
72 m.addSeparator(); | |
73 m.add({title : 'advanced.link_desc', icon : 'link', cmd : ed.plugins.advlink ? 'mceAdvLink' : 'mceLink', ui : true}); | |
74 m.add({title : 'advanced.unlink_desc', icon : 'unlink', cmd : 'UnLink'}); | |
75 } | |
76 | |
77 m.addSeparator(); | |
78 m.add({title : 'advanced.image_desc', icon : 'image', cmd : ed.plugins.advimage ? 'mceAdvImage' : 'mceImage', ui : true}); | |
79 | |
80 m.addSeparator(); | |
81 am = m.addMenu({title : 'contextmenu.align'}); | |
82 am.add({title : 'contextmenu.left', icon : 'justifyleft', cmd : 'JustifyLeft'}); | |
83 am.add({title : 'contextmenu.center', icon : 'justifycenter', cmd : 'JustifyCenter'}); | |
84 am.add({title : 'contextmenu.right', icon : 'justifyright', cmd : 'JustifyRight'}); | |
85 am.add({title : 'contextmenu.full', icon : 'justifyfull', cmd : 'JustifyFull'}); | |
86 | |
87 t.onContextMenu.dispatch(t, m, el, col); | |
88 | |
89 return m; | |
90 } | |
91 }); | |
92 | |
93 // Register plugin | |
94 tinymce.PluginManager.add('contextmenu', tinymce.plugins.ContextMenu); | |
95 })(); |