Skip to content
Snippets Groups Projects
Commit db14f764 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

fix on showing/hiding context menu

parent d3561ac2
No related branches found
No related tags found
1 merge request!291Resolve "selection menu doesn't disappear"
Pipeline #
......@@ -21,16 +21,16 @@ function ContextMenu(params) {
self._handledTimeStamp = undefined;
self.MIN_SHOW_TIME = 2000;
self.MIN_SHOW_TIME = 250;
self._documentClickListener = function (e) {
var className = e.target.className;
if (typeof className === 'string' || className instanceof String) {
if (className.indexOf("dropdown-link") === -1) {
self.hide(e.timeStamp - self.MIN_SHOW_TIME);
self.hide(new Date().getTime() - self.MIN_SHOW_TIME);
}
} else {
self.hide(e.timeStamp - self.MIN_SHOW_TIME);
self.hide(new Date().getTime() - self.MIN_SHOW_TIME);
}
};
$(document).on('click', self._documentClickListener);
......@@ -80,7 +80,7 @@ ContextMenu.prototype.open = function (x, y, timestamp) {
}).off('click').on('click', 'a', function (e) {
//close if this is not a submenu
if (this.parentNode === undefined || this.parentNode.className.indexOf("dropdown-submenu") === -1) {
self.hide(e.timeStamp);
self.hide(new Date().getTime());
if ($(this).data("handler") !== undefined) {
return $(this).data("handler")();
} else {
......
......@@ -85,7 +85,7 @@ Header.prototype._createHeaderGui = function (guiParams) {
var bottom = top + link.outerHeight();
return self._optionsMenu.open(left, bottom, e.timeStamp);
return self._optionsMenu.open(left, bottom, new Date().getTime());
},
xss: false
});
......
......@@ -412,20 +412,18 @@ AbstractCustomMap.prototype.registerMapClickEvents = function () {
});
// context menu event
self.getElement().oncontextmenu = function (event) {
self.getTopMap().getContextMenu().open(GuiConnector.xPos, GuiConnector.yPos, event.timeStamp);
};
google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function (mouseEvent) {
return self.getTopMap().getContextMenu().open(GuiConnector.xPos, GuiConnector.yPos, new Date().getTime());
});
//long click should open context menu https://stackoverflow.com/a/38457006/1127920
var mousedUp = false;
var touchStartTimestamp;
$(self.getElement()).on("touchstart", function (event) {
mousedUp = false;
touchStartTimestamp = event.timeStamp;
setTimeout(function () {
if (mousedUp === false && touchStartTimestamp === event.timeStamp) {
self.getTopMap().getContextMenu().open(GuiConnector.xPos, GuiConnector.yPos, event.timeStamp);
if (mousedUp === false) {
self.getTopMap().getContextMenu().open(GuiConnector.xPos, GuiConnector.yPos, new Date().getTime() + 250);
}
}, 500);
});
......@@ -468,7 +466,7 @@ function activateMolStarLink(coordinates, map) {
if (uniprotIds.length > 0) map.getContextMenu().getMolStar().activateInContextMenu(uniprotIds);
else map.getContextMenu().getMolStar().deactivateInContextMenu();
}).catch(function () {
return map.getContextMenu().getMolStar().deactivateInContextMenu();
return map.getTopMap().getContextMenu().getMolStar().deactivateInContextMenu();
});
}
......
......@@ -1034,6 +1034,10 @@ CustomMap.prototype.setContextMenu = function (contextMenu) {
this._contextMenu = contextMenu;
};
/**
*
* @returns {ContextMenu}
*/
CustomMap.prototype.getContextMenu = function () {
return this._contextMenu;
};
......
......@@ -45,7 +45,7 @@ Submap.prototype.open = function (htmlTag) {
var self = this;
if (!this.initialized) {
self.htmlTag = htmlTag;
self.setElement(htmlTag);
var mapOptions = self.createMapOptions();
......@@ -60,7 +60,7 @@ Submap.prototype.open = function (htmlTag) {
mapDiv.style.height = "100%";
contentDiv.appendChild(mapDiv);
$(self.htmlTag).dialog({
$(self.getElement()).dialog({
title: self.getModel().getName(),
width: Math.floor(window.innerWidth * 2 / 3),
height: Math.floor(window.innerHeight * 2 / 3),
......@@ -74,7 +74,7 @@ Submap.prototype.open = function (htmlTag) {
}
});
$(self.htmlTag).dialog("open");
$(self.getElement()).dialog("open");
self.setGoogleMap(new google.maps.Map(mapDiv, mapOptions));
......@@ -100,7 +100,7 @@ Submap.prototype.open = function (htmlTag) {
self.initialized = true;
} else {
$(self.htmlTag).dialog("open");
$(self.getElement()).dialog("open");
}
};
......@@ -131,7 +131,7 @@ Submap.prototype.destroy = function () {
var self = this;
AbstractCustomMap.prototype.destroy.call(self);
if (self.initialized) {
$(self.htmlTag).dialog("destroy");
$(self.getElement()).dialog("destroy");
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment