mise a jour pour mtweb.0.9.0
[mw_pages] / app / out / default / tiny_mce / plugins / contextmenu / editor_plugin_src.js
diff --git a/app/out/default/tiny_mce/plugins/contextmenu/editor_plugin_src.js b/app/out/default/tiny_mce/plugins/contextmenu/editor_plugin_src.js
new file mode 100644 (file)
index 0000000..13813a6
--- /dev/null
@@ -0,0 +1,147 @@
+/**\r
+ * editor_plugin_src.js\r
+ *\r
+ * Copyright 2009, Moxiecode Systems AB\r
+ * Released under LGPL License.\r
+ *\r
+ * License: http://tinymce.moxiecode.com/license\r
+ * Contributing: http://tinymce.moxiecode.com/contributing\r
+ */\r
+\r
+(function() {\r
+       var Event = tinymce.dom.Event, each = tinymce.each, DOM = tinymce.DOM;\r
+\r
+       /**\r
+        * This plugin a context menu to TinyMCE editor instances.\r
+        *\r
+        * @class tinymce.plugins.ContextMenu\r
+        */\r
+       tinymce.create('tinymce.plugins.ContextMenu', {\r
+               /**\r
+                * Initializes the plugin, this will be executed after the plugin has been created.\r
+                * This call is done before the editor instance has finished it's initialization so use the onInit event\r
+                * of the editor instance to intercept that event.\r
+                *\r
+                * @method init\r
+                * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.\r
+                * @param {string} url Absolute URL to where the plugin is located.\r
+                */\r
+               init : function(ed) {\r
+                       var t = this, lastRng;\r
+\r
+                       t.editor = ed;\r
+\r
+                       /**\r
+                        * This event gets fired when the context menu is shown.\r
+                        *\r
+                        * @event onContextMenu\r
+                        * @param {tinymce.plugins.ContextMenu} sender Plugin instance sending the event.\r
+                        * @param {tinymce.ui.DropMenu} menu Drop down menu to fill with more items if needed.\r
+                        */\r
+                       t.onContextMenu = new tinymce.util.Dispatcher(this);\r
+\r
+                       ed.onContextMenu.add(function(ed, e) {\r
+                               if (!e.ctrlKey) {\r
+                                       // Restore the last selection since it was removed\r
+                                       if (lastRng)\r
+                                               ed.selection.setRng(lastRng);\r
+\r
+                                       t._getMenu(ed).showMenu(e.clientX, e.clientY);\r
+                                       Event.add(ed.getDoc(), 'click', function(e) {\r
+                                               hide(ed, e);\r
+                                       });\r
+                                       Event.cancel(e);\r
+                               }\r
+                       });\r
+\r
+                       ed.onRemove.add(function() {\r
+                               if (t._menu)\r
+                                       t._menu.removeAll();\r
+                       });\r
+\r
+                       function hide(ed, e) {\r
+                               lastRng = null;\r
+\r
+                               // Since the contextmenu event moves\r
+                               // the selection we need to store it away\r
+                               if (e && e.button == 2) {\r
+                                       lastRng = ed.selection.getRng();\r
+                                       return;\r
+                               }\r
+\r
+                               if (t._menu) {\r
+                                       t._menu.removeAll();\r
+                                       t._menu.destroy();\r
+                                       Event.remove(ed.getDoc(), 'click', hide);\r
+                               }\r
+                       };\r
+\r
+                       ed.onMouseDown.add(hide);\r
+                       ed.onKeyDown.add(hide);\r
+               },\r
+\r
+               /**\r
+                * Returns information about the plugin as a name/value array.\r
+                * The current keys are longname, author, authorurl, infourl and version.\r
+                *\r
+                * @method getInfo\r
+                * @return {Object} Name/value array containing information about the plugin.\r
+                */\r
+               getInfo : function() {\r
+                       return {\r
+                               longname : 'Contextmenu',\r
+                               author : 'Moxiecode Systems AB',\r
+                               authorurl : 'http://tinymce.moxiecode.com',\r
+                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/contextmenu',\r
+                               version : tinymce.majorVersion + "." + tinymce.minorVersion\r
+                       };\r
+               },\r
+\r
+               _getMenu : function(ed) {\r
+                       var t = this, m = t._menu, se = ed.selection, col = se.isCollapsed(), el = se.getNode() || ed.getBody(), am, p1, p2;\r
+\r
+                       if (m) {\r
+                               m.removeAll();\r
+                               m.destroy();\r
+                       }\r
+\r
+                       p1 = DOM.getPos(ed.getContentAreaContainer());\r
+                       p2 = DOM.getPos(ed.getContainer());\r
+\r
+                       m = ed.controlManager.createDropMenu('contextmenu', {\r
+                               offset_x : p1.x + ed.getParam('contextmenu_offset_x', 0),\r
+                               offset_y : p1.y + ed.getParam('contextmenu_offset_y', 0),\r
+                               constrain : 1\r
+                       });\r
+\r
+                       t._menu = m;\r
+\r
+                       m.add({title : 'advanced.cut_desc', icon : 'cut', cmd : 'Cut'}).setDisabled(col);\r
+                       m.add({title : 'advanced.copy_desc', icon : 'copy', cmd : 'Copy'}).setDisabled(col);\r
+                       m.add({title : 'advanced.paste_desc', icon : 'paste', cmd : 'Paste'});\r
+\r
+                       if ((el.nodeName == 'A' && !ed.dom.getAttrib(el, 'name')) || !col) {\r
+                               m.addSeparator();\r
+                               m.add({title : 'advanced.link_desc', icon : 'link', cmd : ed.plugins.advlink ? 'mceAdvLink' : 'mceLink', ui : true});\r
+                               m.add({title : 'advanced.unlink_desc', icon : 'unlink', cmd : 'UnLink'});\r
+                       }\r
+\r
+                       m.addSeparator();\r
+                       m.add({title : 'advanced.image_desc', icon : 'image', cmd : ed.plugins.advimage ? 'mceAdvImage' : 'mceImage', ui : true});\r
+\r
+                       m.addSeparator();\r
+                       am = m.addMenu({title : 'contextmenu.align'});\r
+                       am.add({title : 'contextmenu.left', icon : 'justifyleft', cmd : 'JustifyLeft'});\r
+                       am.add({title : 'contextmenu.center', icon : 'justifycenter', cmd : 'JustifyCenter'});\r
+                       am.add({title : 'contextmenu.right', icon : 'justifyright', cmd : 'JustifyRight'});\r
+                       am.add({title : 'contextmenu.full', icon : 'justifyfull', cmd : 'JustifyFull'});\r
+\r
+                       t.onContextMenu.dispatch(t, m, el, col);\r
+\r
+                       return m;\r
+               }\r
+       });\r
+\r
+       // Register plugin\r
+       tinymce.PluginManager.add('contextmenu', tinymce.plugins.ContextMenu);\r
+})();
\ No newline at end of file