annotate media/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js @ 64:58bc950c6d8b

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