- fixed Firefox bug where new systems were added to x:0, y:0 coordinates, closed #415

This commit is contained in:
Exodus4D
2017-01-14 19:50:45 +01:00
parent 96b116584c
commit e0b30127f9
2 changed files with 46 additions and 32 deletions

View File

@@ -11,10 +11,10 @@ define([
$.fn.contextMenu = function (settings) {
// animation
var animationInType = 'transition.flipXIn';
var animationInDuration = 150;
var animationOutType = 'transition.flipXOut';
var animationOutDuration = 150;
let animationInType = 'transition.flipXIn';
let animationInDuration = 150;
let animationOutType = 'transition.flipXOut';
let animationOutDuration = 150;
return this.each(function () {
@@ -24,15 +24,15 @@ define([
// hide all other open context menus
$('#pf-dialog-wrapper > .dropdown-menu').hide();
var contextMenu = $(settings.menuSelector);
let contextMenu = $(settings.menuSelector);
var menuLiElements = contextMenu.find('li');
let menuLiElements = contextMenu.find('li');
// show all menu entries
menuLiElements.show();
// disable specific menu entries
for(var i = 0; i < hiddenOptions.length; i++){
for(let i = 0; i < hiddenOptions.length; i++){
contextMenu.find('li[data-action="' + hiddenOptions[i] + '"]').hide();
}
@@ -40,7 +40,7 @@ define([
menuLiElements.removeClass('active');
//set active specific menu entries
for(var j = 0; j < activeOptions.length; j++){
for(let j = 0; j < activeOptions.length; j++){
contextMenu.find('li[data-action="' + activeOptions[j] + '"]').addClass('active');
}
@@ -53,11 +53,18 @@ define([
duration: animationInDuration,
complete: function(){
// set context menu "click" observer
$(this).off('click').one('click', {component: component, position:{x: originalEvent.offsetX, y: originalEvent.offsetY}}, function (e) {
// Firefox has a "nested" originalEvent ?! -> #415
let position = {
x: originalEvent.offsetX || originalEvent.originalEvent.layerX,
y: originalEvent.offsetY || originalEvent.originalEvent.layerY
};
$(this).off('click').one('click', {component: component, position: position}, function (e) {
// hide contextmenu
$(this).hide();
var params = {
let params = {
selectedMenu: $(e.target),
component: e.data.component,
position: e.data.position
@@ -81,9 +88,9 @@ define([
});
function getLeftLocation(e) {
var mouseWidth = e.pageX;
var pageWidth = $(window).width();
var menuWidth = $(settings.menuSelector).width();
let mouseWidth = e.pageX;
let pageWidth = $(window).width();
let menuWidth = $(settings.menuSelector).width();
// opening menu would pass the side of the page
if (mouseWidth + menuWidth > pageWidth &&
@@ -94,9 +101,9 @@ define([
}
function getTopLocation(e) {
var mouseHeight = e.pageY;
var pageHeight = $(window).height();
var menuHeight = $(settings.menuSelector).height();
let mouseHeight = e.pageY;
let pageHeight = $(window).height();
let menuHeight = $(settings.menuSelector).height();
// opening menu would pass the bottom of the page
if (mouseHeight + menuHeight > pageHeight &&

View File

@@ -11,10 +11,10 @@ define([
$.fn.contextMenu = function (settings) {
// animation
var animationInType = 'transition.flipXIn';
var animationInDuration = 150;
var animationOutType = 'transition.flipXOut';
var animationOutDuration = 150;
let animationInType = 'transition.flipXIn';
let animationInDuration = 150;
let animationOutType = 'transition.flipXOut';
let animationOutDuration = 150;
return this.each(function () {
@@ -24,15 +24,15 @@ define([
// hide all other open context menus
$('#pf-dialog-wrapper > .dropdown-menu').hide();
var contextMenu = $(settings.menuSelector);
let contextMenu = $(settings.menuSelector);
var menuLiElements = contextMenu.find('li');
let menuLiElements = contextMenu.find('li');
// show all menu entries
menuLiElements.show();
// disable specific menu entries
for(var i = 0; i < hiddenOptions.length; i++){
for(let i = 0; i < hiddenOptions.length; i++){
contextMenu.find('li[data-action="' + hiddenOptions[i] + '"]').hide();
}
@@ -40,7 +40,7 @@ define([
menuLiElements.removeClass('active');
//set active specific menu entries
for(var j = 0; j < activeOptions.length; j++){
for(let j = 0; j < activeOptions.length; j++){
contextMenu.find('li[data-action="' + activeOptions[j] + '"]').addClass('active');
}
@@ -53,11 +53,18 @@ define([
duration: animationInDuration,
complete: function(){
// set context menu "click" observer
$(this).off('click').one('click', {component: component, position:{x: originalEvent.offsetX, y: originalEvent.offsetY}}, function (e) {
// Firefox has a "nested" originalEvent ?! -> #415
let position = {
x: originalEvent.offsetX || originalEvent.originalEvent.layerX,
y: originalEvent.offsetY || originalEvent.originalEvent.layerY
};
$(this).off('click').one('click', {component: component, position: position}, function (e) {
// hide contextmenu
$(this).hide();
var params = {
let params = {
selectedMenu: $(e.target),
component: e.data.component,
position: e.data.position
@@ -81,9 +88,9 @@ define([
});
function getLeftLocation(e) {
var mouseWidth = e.pageX;
var pageWidth = $(window).width();
var menuWidth = $(settings.menuSelector).width();
let mouseWidth = e.pageX;
let pageWidth = $(window).width();
let menuWidth = $(settings.menuSelector).width();
// opening menu would pass the side of the page
if (mouseWidth + menuWidth > pageWidth &&
@@ -94,9 +101,9 @@ define([
}
function getTopLocation(e) {
var mouseHeight = e.pageY;
var pageHeight = $(window).height();
var menuHeight = $(settings.menuSelector).height();
let mouseHeight = e.pageY;
let pageHeight = $(window).height();
let menuHeight = $(settings.menuSelector).height();
// opening menu would pass the bottom of the page
if (mouseHeight + menuHeight > pageHeight &&