]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/plugins/contextmenu/plugin.js
baculum: Add missing-sources directory in debian metadata structure
[bacula/bacula] / gui / baculum / debian / missing-sources / framework / Web / Javascripts / source / tinymce-405 / plugins / contextmenu / plugin.js
1 /**
2  * plugin.js
3  *
4  * Copyright, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://www.tinymce.com/license
8  * Contributing: http://www.tinymce.com/contributing
9  */
10
11 /*global tinymce:true */
12
13 tinymce.PluginManager.add('contextmenu', function(editor) {
14         var menu;
15
16         editor.on('contextmenu', function(e) {
17                 var contextmenu;
18
19                 e.preventDefault();
20
21                 contextmenu = editor.settings.contextmenu || 'link image inserttable | cell row column deletetable';
22
23                 // Render menu
24                 if (!menu) {
25                         var items = [];
26
27                         tinymce.each(contextmenu.split(/[ ,]/), function(name) {
28                                 var item = editor.menuItems[name];
29
30                                 if (name == '|') {
31                                         item = {text: name};
32                                 }
33
34                                 if (item) {
35                                         item.shortcut = ''; // Hide shortcuts
36                                         items.push(item);
37                                 }
38                         });
39
40                         for (var i = 0; i < items.length; i++) {
41                                 if (items[i].text == '|') {
42                                         if (i === 0 || i == items.length - 1) {
43                                                 items.splice(i, 1);
44                                         }
45                                 }
46                         }
47
48                         menu = new tinymce.ui.Menu({
49                                 items: items,
50                                 context: 'contextmenu'
51                         });
52
53                         menu.renderTo(document.body);
54                 } else {
55                         menu.show();
56                 }
57
58                 // Position menu
59                 var pos = {x: e.pageX, y: e.pageY};
60
61                 if (!editor.inline) {
62                         pos = tinymce.DOM.getPos(editor.getContentAreaContainer());
63                         pos.x += e.clientX;
64                         pos.y += e.clientY;
65                 }
66
67                 menu.moveTo(pos.x, pos.y);
68
69                 editor.on('remove', function() {
70                         menu.remove();
71                         menu = null;
72                 });
73         });
74 });