1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix tab access on touch screens

This commit is contained in:
Nick O'Leary 2019-09-20 12:58:03 +01:00
parent 30c402eb83
commit 7178c63e10
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -19,6 +19,9 @@
RED.tabs = (function() { RED.tabs = (function() {
var defaultTabIcon = "fa fa-lemon-o"; var defaultTabIcon = "fa fa-lemon-o";
var dragActive = false;
var dblClickTime;
var dblClickArmed = false;
function createTabs(options) { function createTabs(options) {
var tabs = {}; var tabs = {};
@ -201,7 +204,16 @@ RED.tabs = (function() {
} }
function onTabClick(evt) { function onTabClick(evt) {
evt.preventDefault(); if (dragActive) {
return
}
if (dblClickTime && Date.now()-dblClickTime < 400) {
dblClickTime = 0;
dblClickArmed = true;
return onTabDblClick.call(this,evt);
}
dblClickTime = Date.now();
var currentTab = ul.find("li.red-ui-tab.active"); var currentTab = ul.find("li.red-ui-tab.active");
var thisTab = $(this).parent(); var thisTab = $(this).parent();
var fireSelectionChanged = false; var fireSelectionChanged = false;
@ -267,7 +279,6 @@ RED.tabs = (function() {
if (fireSelectionChanged) { if (fireSelectionChanged) {
selectionChanged(); selectionChanged();
} }
return false;
} }
function updateScroll() { function updateScroll() {
@ -289,7 +300,6 @@ RED.tabs = (function() {
} }
function onTabDblClick(evt) { function onTabDblClick(evt) {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation();
if (evt.metaKey || evt.shiftKey) { if (evt.metaKey || evt.shiftKey) {
return; return;
} }
@ -418,7 +428,11 @@ RED.tabs = (function() {
} }
ul.find("li.red-ui-tab a").on("click",onTabClick).on("dblclick",onTabDblClick); ul.find("li.red-ui-tab a")
.on("mouseup",onTabClick)
.on("click", function(evt) {evt.preventDefault(); })
.on("dblclick", function(evt) {evt.stopPropagation(); evt.preventDefault(); })
setTimeout(function() { setTimeout(function() {
updateTabWidths(); updateTabWidths();
},0); },0);
@ -524,8 +538,9 @@ RED.tabs = (function() {
RED.popover.tooltip($(pinnedLink), tab.name, tab.action); RED.popover.tooltip($(pinnedLink), tab.name, tab.action);
} }
link.on("click",onTabClick); link.on("mouseup",onTabClick);
link.on("dblclick",onTabDblClick); link.on("click", function(evt) { evt.preventDefault(); })
link.on("dblclick", function(evt) { evt.stopPropagation(); evt.preventDefault(); })
if (tab.closeable) { if (tab.closeable) {
@ -560,6 +575,8 @@ RED.tabs = (function() {
axis:"x", axis:"x",
distance: 20, distance: 20,
start: function(event,ui) { start: function(event,ui) {
if (dblClickArmed) { dblClickArmed = false; return false }
dragActive = true;
originalTabOrder = []; originalTabOrder = [];
tabElements = []; tabElements = [];
ul.children().each(function(i) { ul.children().each(function(i) {
@ -615,6 +632,7 @@ RED.tabs = (function() {
} }
}, },
stop: function(event,ui) { stop: function(event,ui) {
dragActive = false;
ul.children().css({position:"relative",left:"",transition:""}); ul.children().css({position:"relative",left:"",transition:""});
if (!li.hasClass('active')) { if (!li.hasClass('active')) {
li.css({zIndex:""}); li.css({zIndex:""});