From e0b30127f9692fdd25de040988917059028766c2 Mon Sep 17 00:00:00 2001 From: Exodus4D Date: Sat, 14 Jan 2017 19:50:45 +0100 Subject: [PATCH] - fixed Firefox bug where new systems were added to x:0, y:0 coordinates, closed #415 --- js/app/map/contextmenu.js | 39 +++++++++++++++---------- public/js/v1.2.0/app/map/contextmenu.js | 39 +++++++++++++++---------- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/js/app/map/contextmenu.js b/js/app/map/contextmenu.js index 0fa9f819..5b9595dd 100644 --- a/js/app/map/contextmenu.js +++ b/js/app/map/contextmenu.js @@ -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 && diff --git a/public/js/v1.2.0/app/map/contextmenu.js b/public/js/v1.2.0/app/map/contextmenu.js index 0fa9f819..5b9595dd 100644 --- a/public/js/v1.2.0/app/map/contextmenu.js +++ b/public/js/v1.2.0/app/map/contextmenu.js @@ -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 &&