From 39d3de934ffb1d60dcd005dc88591b46a8114e3d Mon Sep 17 00:00:00 2001 From: Denis Hovart Date: Tue, 7 Jun 2022 16:53:49 +0200 Subject: [PATCH] Add Up / down arrows listeners on project page. Fix measurement tool --- package.json | 2 +- view/atlasmaker/src/atlasmaker-interaction.js | 19 -------- view/atlasmaker/src/atlasmaker.js | 43 ------------------- view/brainbox/src/pages/project-page.js | 22 ++++++++++ 4 files changed, 23 insertions(+), 63 deletions(-) diff --git a/package.json b/package.json index d69e6991..8d46571a 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "multer": "^1.4.2", "mustache-express": "^1.3.0", "neuroweblab": "github:neuroanatomy/neuroweblab", - "nwl-components": "^0.0.19", + "nwl-components": "^0.0.20", "pako": "^1.0.11", "passport": "^0.4.1", "passport-github": "^1.1.0", diff --git a/view/atlasmaker/src/atlasmaker-interaction.js b/view/atlasmaker/src/atlasmaker-interaction.js index 7d1bd30f..83f2734d 100644 --- a/view/atlasmaker/src/atlasmaker-interaction.js +++ b/view/atlasmaker/src/atlasmaker-interaction.js @@ -124,12 +124,6 @@ export var AtlasMakerInteraction = { case 'Measure': me.User.tool = 'measure'; break; - case 'Adjust': - me.User.tool = 'adjust'; - if($('#adjust').length === 0) { - me.loadScript('/lib/atlasmaker-tools/adjust.js'); - } - break; case 'Eyedrop': me.User.tool = 'eyedrop'; break; @@ -916,19 +910,6 @@ export var AtlasMakerInteraction = { me.paintxy(-1, 'le', x, y, me.User); }, - _adjustToolDown: function (x, y) { - const me = AtlasMakerWidget; - me.User.mouseIsDown = true; - me.info.x = x/me.brainW; - me.info.y = 1-y/me.brainH; - }, - _adjustToolMove: function (x, y) { - const me = AtlasMakerWidget; - me.info.x = x/me.brainW; - me.info.y = 1-y/me.brainH; - me.drawImages(); - }, - /** * @function eyedrop * @param {number} x X or horizontal coordinate diff --git a/view/atlasmaker/src/atlasmaker.js b/view/atlasmaker/src/atlasmaker.js index 002dfb52..907813e5 100755 --- a/view/atlasmaker/src/atlasmaker.js +++ b/view/atlasmaker/src/atlasmaker.js @@ -209,7 +209,6 @@ var me = { {name: 'erase', func: me._eraseToolDown}, {name: 'measure', func: me._measureToolDownHandler}, {name: 'landmark', func: me._landmarkToolDown}, - {name: 'adjust', func: me._adjustToolDown}, {name: 'eyedrop', func: me._eyedropToolDown} ]; for(const tool of arr) { @@ -362,52 +361,10 @@ var me = { me.drawImages(); }); - /* - // Init the toolbar - - // configure and append tools - let tools; - if(typeof me.useFullTools === 'undefined') { - me.useFullTools = true; - } - if(me.useFullTools) { - tools = toolsFull; - } else { - tools = toolsLight; - } - me.container.insertAdjacentHTML("beforeend", tools); - // event connect: get keyboard events $(document).keydown(function(e) { me.keyDown(e); }); - // event connect: configure annotation tools - me.push($(".push#display-minimize"), function() { me.changeToolbarDisplay("minimize"); }); - me.chose($(".chose#penSize"), me.changePenSize); - me.toggle($(".toggle#precise"), me.togglePreciseCursor); - me.toggle($(".toggle#fill"), me.toggleFill); - me.toggle($(".toggle#fullscreen"), me.toggleFullscreen); - me.chose3state($(".chose#text"), me.toggleTextInput); - me.push($(".push#3drender"), me.render3D); - me.push($(".push#link"), me.link); - me.push($(".push#upload"), me.upload); - me.push($(".push#download"), me.download); - me.push($(".push#color"), me.color); - me.push($(".push#undo"), me.sendUndoMessage); - me.push($(".push#save"), me.sendSaveMessage); - me.push($(".push#prev"), me.prevSlice); - me.push($(".push#next"), me.nextSlice); - - // event connect: chat message input - $("#msg").keypress((e) => { me.onkey(e); }); - - $("#tools-minimized").hide(); - - // load tools - me.loadTools(); - // event connect: register click tools - */ - me._registerAllToolsDown(); me._registerAllToolsMove(); me._registerAllToolsUp(); diff --git a/view/brainbox/src/pages/project-page.js b/view/brainbox/src/pages/project-page.js index 6eb681a8..54578a56 100644 --- a/view/brainbox/src/pages/project-page.js +++ b/view/brainbox/src/pages/project-page.js @@ -161,6 +161,24 @@ const PageContents = { window.addEventListener('newMessage', this.handleNewChatMessages); window.addEventListener('newNotification', this.handleNewNotification); + document.addEventListener('keydown', function(event) { + const selectedTr = document.querySelector('tr.selected'); + if (!selectedTr) { return; } + switch(event.key) { + case 'ArrowUp': + if (selectedTr.previousElementSibling) { + selectedTr.previousElementSibling.click(); + } + break; + case 'ArrowDown': + if (selectedTr.nextElementSibling) { + selectedTr.nextElementSibling.click(); + } + break; + default: + break; + } + }); }, getDefaultAtlas(annotation) { @@ -328,6 +346,10 @@ const PageContents = { AtlasMakerWidget.changeTool(tool); this.currentTool = tool; this.displayAdjustSettings = false; + if(tool === 'Measure') { + // remove focus from button + document.activeElement.blur(); + } }, changePenSize(size) {