From 3596ca8383346a0d515b26cf899e477c6cb62b29 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 13 Aug 2015 12:40:15 -0700 Subject: [PATCH] GUAC-1293: Do not use double click - use click when file is focused. --- .../app/client/directives/guacFileBrowser.js | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/guacamole/src/main/webapp/app/client/directives/guacFileBrowser.js b/guacamole/src/main/webapp/app/client/directives/guacFileBrowser.js index 894469300..4469cecbd 100644 --- a/guacamole/src/main/webapp/app/client/directives/guacFileBrowser.js +++ b/guacamole/src/main/webapp/app/client/directives/guacFileBrowser.js @@ -142,26 +142,42 @@ angular.module('client').directive('guacFileBrowser', [function guacFileBrowser( // Create from internal template var element = angular.element($interpolate(fileTemplate)(file)); + // Double-clicking on unknown file types will do nothing + var fileAction = function doNothing() {}; + // Change current directory when directories are clicked if ($scope.isDirectory(file)) { element.addClass('directory'); - element.on('dblclick', function changeDirectory() { + fileAction = function changeDirectory() { $scope.changeDirectory(file); - }); + }; } // Initiate downloads when normal files are clicked else if ($scope.isNormalFile(file)) { element.addClass('normal-file'); - element.on('dblclick', function downloadFile() { + fileAction = function downloadFile() { $scope.downloadFile(file); - }); + }; } // Mark file as focused upon click - element.on('click', function focusFile() { - element.parent().children().removeClass('focused'); - element.addClass('focused'); + element.on('click', function focusFile(e) { + + // Fire file-specific action if already focused + if (element.hasClass('focused')) + fileAction(); + + // Otherwise mark as focused + else { + element.parent().children().removeClass('focused'); + element.addClass('focused'); + } + + // Do not allow default action + e.preventDefault(); + e.stopPropagation(); + }); // Prevent text selection during navigation