Skip to content
Permalink
Browse files

tweak(Tinebase): show native context-menu on second ctx click

Change-Id: I5aea851c26201db43c7d4c900fc834b85f3179c4
Reviewed-on: http://gerrit.tine20.com/customers/12779
Tested-by: Jenkins CI (http://ci.tine20.com/) <tine20-jenkins@metaways.de>
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
  • Loading branch information...
corneliusweiss committed May 8, 2019
1 parent c711b58 commit f9087b5242579c70aa87de37190072e0cc38b2d9
Showing with 40 additions and 6 deletions.
  1. +23 −2 tine20/Tinebase/js/MainContextMenu.js
  2. +7 −1 tine20/Tinebase/js/extFixes.js
  3. +10 −3 tine20/Tinebase/js/tineInit.js
@@ -33,7 +33,15 @@ Tine.Tinebase.MainContextMenu = Ext.extend(Ext.menu.Menu, {
this.items.get(0).hide();
}
this.supr().onRender.call(this);
},

onHide : function(){
if (this.isVisible()) {
Tine.Tinebase.MainContextMenu.hideEventSignature = Ext.EventObject.getSignature();
}
this.supr().onHide.call(this);
}

});

/**
@@ -44,10 +52,11 @@ Tine.Tinebase.MainContextMenu = Ext.extend(Ext.menu.Menu, {
* @returns {Ext.Component}
*/
Tine.Tinebase.MainContextMenu.showIf = function(e) {
var menu = new Tine.Tinebase.MainContextMenu({});
var menu = Tine.Tinebase.MainContextMenu.menu = new Tine.Tinebase.MainContextMenu({});

if (menu.items.length) {
menu.showAt(e.getXY());
return menu;
}
};

@@ -59,7 +68,7 @@ Tine.Tinebase.MainContextMenu.showIf = function(e) {
* @returns {Ext.util.MixedCollection}
*/
Tine.Tinebase.MainContextMenu.getItems = function(e) {
var menu = new Tine.Tinebase.MainContextMenu({});
var menu = Tine.Tinebase.MainContextMenu.menu = new Tine.Tinebase.MainContextMenu({});

return menu.items;
};
@@ -77,3 +86,15 @@ Tine.Tinebase.MainContextMenu.getCmp = function(e) {

return component;
};

Tine.Tinebase.MainContextMenu.isVisible = function() {
return Tine.Tinebase.MainContextMenu.hideEventSignature
&& Tine.Tinebase.MainContextMenu.hideEventSignature == Ext.EventObject.getSignature();
};


Tine.Tinebase.MainContextMenu.hide = function() {
if (Tine.Tinebase.MainContextMenu.menu && Tine.Tinebase.MainContextMenu.menu.hide) {
Tine.Tinebase.MainContextMenu.menu.hide();
}
};
@@ -1140,4 +1140,10 @@ Ext.form.Field.prototype.getAutoCreate = function() {
cfg.autocomplete = this.autocomplete;
}
return cfg;
};
};

Ext.override(Ext.EventObject, {
getSignature: function() {
return String(this.browserEvent.timeStamp) + '-' + this.getXY();
}
});
@@ -127,10 +127,17 @@ Tine.Tinebase.tineInit = {
return;
}

e.stopPropagation();
e.preventDefault();
// allow native context menu on second context click
if (Tine.Tinebase.MainContextMenu.isVisible()) {
Tine.Tinebase.MainContextMenu.hide();
return;
}

Tine.Tinebase.MainContextMenu.showIf(e);
// deny native context menu if we have an oown one
if (Tine.Tinebase.MainContextMenu.showIf(e)) {
e.stopPropagation();
e.preventDefault();
}
}, this);

Ext.getBody().on('click', function(e) {

0 comments on commit f9087b5

Please sign in to comment.
You can’t perform that action at this time.