summaryrefslogtreecommitdiff
path: root/program/js/tiny_mce/plugins/contextmenu
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-04-20 19:11:10 +0000
committerthomascube <thomas@roundcube.net>2011-04-20 19:11:10 +0000
commita9251be2f09fb5f18a85d201c67668c70980efe3 (patch)
tree59d8e5e6de86e4bcde237f2b5793eccb98a7ca87 /program/js/tiny_mce/plugins/contextmenu
parent164b45964edc699db9e049dddd91e9de07635fcd (diff)
Update to TinyMCE 3.4.2 to fix errors in IE9v0.5.2@4679
Diffstat (limited to 'program/js/tiny_mce/plugins/contextmenu')
-rw-r--r--program/js/tiny_mce/plugins/contextmenu/editor_plugin.js2
-rw-r--r--program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js46
2 files changed, 31 insertions, 17 deletions
diff --git a/program/js/tiny_mce/plugins/contextmenu/editor_plugin.js b/program/js/tiny_mce/plugins/contextmenu/editor_plugin.js
index 9749e5164..8e041ea59 100644
--- a/program/js/tiny_mce/plugins/contextmenu/editor_plugin.js
+++ b/program/js/tiny_mce/plugins/contextmenu/editor_plugin.js
@@ -1 +1 @@
-(function(){var a=tinymce.dom.Event,c=tinymce.each,b=tinymce.DOM;tinymce.create("tinymce.plugins.ContextMenu",{init:function(d){var f=this,g;f.editor=d;f.onContextMenu=new tinymce.util.Dispatcher(this);d.onContextMenu.add(function(h,i){if(!i.ctrlKey){if(g){h.selection.setRng(g)}f._getMenu(h).showMenu(i.clientX,i.clientY);a.add(h.getDoc(),"click",function(j){e(h,j)});a.cancel(i)}});d.onRemove.add(function(){if(f._menu){f._menu.removeAll()}});function e(h,i){g=null;if(i&&i.button==2){g=h.selection.getRng();return}if(f._menu){f._menu.removeAll();f._menu.destroy();a.remove(h.getDoc(),"click",e)}}d.onMouseDown.add(e);d.onKeyDown.add(e)},getInfo:function(){return{longname:"Contextmenu",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/contextmenu",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_getMenu:function(h){var l=this,f=l._menu,i=h.selection,e=i.isCollapsed(),d=i.getNode()||h.getBody(),g,k,j;if(f){f.removeAll();f.destroy()}k=b.getPos(h.getContentAreaContainer());j=b.getPos(h.getContainer());f=h.controlManager.createDropMenu("contextmenu",{offset_x:k.x+h.getParam("contextmenu_offset_x",0),offset_y:k.y+h.getParam("contextmenu_offset_y",0),constrain:1});l._menu=f;f.add({title:"advanced.cut_desc",icon:"cut",cmd:"Cut"}).setDisabled(e);f.add({title:"advanced.copy_desc",icon:"copy",cmd:"Copy"}).setDisabled(e);f.add({title:"advanced.paste_desc",icon:"paste",cmd:"Paste"});if((d.nodeName=="A"&&!h.dom.getAttrib(d,"name"))||!e){f.addSeparator();f.add({title:"advanced.link_desc",icon:"link",cmd:h.plugins.advlink?"mceAdvLink":"mceLink",ui:true});f.add({title:"advanced.unlink_desc",icon:"unlink",cmd:"UnLink"})}f.addSeparator();f.add({title:"advanced.image_desc",icon:"image",cmd:h.plugins.advimage?"mceAdvImage":"mceImage",ui:true});f.addSeparator();g=f.addMenu({title:"contextmenu.align"});g.add({title:"contextmenu.left",icon:"justifyleft",cmd:"JustifyLeft"});g.add({title:"contextmenu.center",icon:"justifycenter",cmd:"JustifyCenter"});g.add({title:"contextmenu.right",icon:"justifyright",cmd:"JustifyRight"});g.add({title:"contextmenu.full",icon:"justifyfull",cmd:"JustifyFull"});l.onContextMenu.dispatch(l,f,d,e);return f}});tinymce.PluginManager.add("contextmenu",tinymce.plugins.ContextMenu)})(); \ No newline at end of file
+(function(){var a=tinymce.dom.Event,c=tinymce.each,b=tinymce.DOM;tinymce.create("tinymce.plugins.ContextMenu",{init:function(e){var h=this,f,d,i;h.editor=e;d=e.settings.contextmenu_never_use_native;h.onContextMenu=new tinymce.util.Dispatcher(this);f=e.onContextMenu.add(function(j,k){if((i!==0?i:k.ctrlKey)&&!d){return}a.cancel(k);if(k.target.nodeName=="IMG"){j.selection.select(k.target)}h._getMenu(j).showMenu(k.clientX||k.pageX,k.clientY||k.pageX);a.add(j.getDoc(),"click",function(l){g(j,l)});j.nodeChanged()});e.onRemove.add(function(){if(h._menu){h._menu.removeAll()}});function g(j,k){i=0;if(k&&k.button==2){i=k.ctrlKey;return}if(h._menu){h._menu.removeAll();h._menu.destroy();a.remove(j.getDoc(),"click",g)}}e.onMouseDown.add(g);e.onKeyDown.add(g);e.onKeyDown.add(function(j,k){if(k.shiftKey&&!k.ctrlKey&&!k.altKey&&k.keyCode===121){a.cancel(k);f(j,k)}})},getInfo:function(){return{longname:"Contextmenu",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/contextmenu",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_getMenu:function(h){var l=this,f=l._menu,i=h.selection,e=i.isCollapsed(),d=i.getNode()||h.getBody(),g,k,j;if(f){f.removeAll();f.destroy()}k=b.getPos(h.getContentAreaContainer());j=b.getPos(h.getContainer());f=h.controlManager.createDropMenu("contextmenu",{offset_x:k.x+h.getParam("contextmenu_offset_x",0),offset_y:k.y+h.getParam("contextmenu_offset_y",0),constrain:1,keyboard_focus:true});l._menu=f;f.add({title:"advanced.cut_desc",icon:"cut",cmd:"Cut"}).setDisabled(e);f.add({title:"advanced.copy_desc",icon:"copy",cmd:"Copy"}).setDisabled(e);f.add({title:"advanced.paste_desc",icon:"paste",cmd:"Paste"});if((d.nodeName=="A"&&!h.dom.getAttrib(d,"name"))||!e){f.addSeparator();f.add({title:"advanced.link_desc",icon:"link",cmd:h.plugins.advlink?"mceAdvLink":"mceLink",ui:true});f.add({title:"advanced.unlink_desc",icon:"unlink",cmd:"UnLink"})}f.addSeparator();f.add({title:"advanced.image_desc",icon:"image",cmd:h.plugins.advimage?"mceAdvImage":"mceImage",ui:true});f.addSeparator();g=f.addMenu({title:"contextmenu.align"});g.add({title:"contextmenu.left",icon:"justifyleft",cmd:"JustifyLeft"});g.add({title:"contextmenu.center",icon:"justifycenter",cmd:"JustifyCenter"});g.add({title:"contextmenu.right",icon:"justifyright",cmd:"JustifyRight"});g.add({title:"contextmenu.full",icon:"justifyfull",cmd:"JustifyFull"});l.onContextMenu.dispatch(l,f,d,e);return f}});tinymce.PluginManager.add("contextmenu",tinymce.plugins.ContextMenu)})(); \ No newline at end of file
diff --git a/program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js b/program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
index 13813a64e..4328f4b11 100644
--- a/program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
+++ b/program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
@@ -27,10 +27,12 @@
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed) {
- var t = this, lastRng;
+ var t = this, showMenu, contextmenuNeverUseNative, realCtrlKey;
t.editor = ed;
+ contextmenuNeverUseNative = ed.settings.contextmenu_never_use_native;
+
/**
* This event gets fired when the context menu is shown.
*
@@ -40,18 +42,23 @@
*/
t.onContextMenu = new tinymce.util.Dispatcher(this);
- ed.onContextMenu.add(function(ed, e) {
- if (!e.ctrlKey) {
- // Restore the last selection since it was removed
- if (lastRng)
- ed.selection.setRng(lastRng);
+ showMenu = ed.onContextMenu.add(function(ed, e) {
+ // Block TinyMCE menu on ctrlKey and work around Safari issue
+ if ((realCtrlKey !== 0 ? realCtrlKey : e.ctrlKey) && !contextmenuNeverUseNative)
+ return;
- t._getMenu(ed).showMenu(e.clientX, e.clientY);
- Event.add(ed.getDoc(), 'click', function(e) {
- hide(ed, e);
- });
- Event.cancel(e);
- }
+ Event.cancel(e);
+
+ // Select the image if it's clicked. WebKit would other wise expand the selection
+ if (e.target.nodeName == 'IMG')
+ ed.selection.select(e.target);
+
+ t._getMenu(ed).showMenu(e.clientX || e.pageX, e.clientY || e.pageX);
+ Event.add(ed.getDoc(), 'click', function(e) {
+ hide(ed, e);
+ });
+
+ ed.nodeChanged();
});
ed.onRemove.add(function() {
@@ -60,12 +67,12 @@
});
function hide(ed, e) {
- lastRng = null;
+ realCtrlKey = 0;
// Since the contextmenu event moves
// the selection we need to store it away
if (e && e.button == 2) {
- lastRng = ed.selection.getRng();
+ realCtrlKey = e.ctrlKey;
return;
}
@@ -78,6 +85,12 @@
ed.onMouseDown.add(hide);
ed.onKeyDown.add(hide);
+ ed.onKeyDown.add(function(ed, e) {
+ if (e.shiftKey && !e.ctrlKey && !e.altKey && e.keyCode === 121) {
+ Event.cancel(e);
+ showMenu(ed, e);
+ }
+ });
},
/**
@@ -111,7 +124,8 @@
m = ed.controlManager.createDropMenu('contextmenu', {
offset_x : p1.x + ed.getParam('contextmenu_offset_x', 0),
offset_y : p1.y + ed.getParam('contextmenu_offset_y', 0),
- constrain : 1
+ constrain : 1,
+ keyboard_focus: true
});
t._menu = m;
@@ -144,4 +158,4 @@
// Register plugin
tinymce.PluginManager.add('contextmenu', tinymce.plugins.ContextMenu);
-})(); \ No newline at end of file
+})();