Browse Source

HUE-3788 [home] No way to middle click to open document in a new tab

Enrico Berti 9 years ago
parent
commit
fc2d67a89e

+ 1 - 1
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -801,7 +801,7 @@ from django.utils.translation import ugettext as _
         url: breadcrumb.url,
         url: breadcrumb.url,
         label: breadcrumb.label,
         label: breadcrumb.label,
         show: function (breadcrumb, e) {
         show: function (breadcrumb, e) {
-          var isLeftButton = (e.which || evt.button) === 1;
+          var isLeftButton = (e.which || e.button) === 1;
           if (isLeftButton) {
           if (isLeftButton) {
             e.stopPropagation();
             e.stopPropagation();
             e.preventDefault();
             e.preventDefault();

+ 19 - 8
desktop/core/src/desktop/static/desktop/js/fileBrowser/hueFileEntry.js

@@ -365,16 +365,27 @@
     }
     }
   };
   };
 
 
-  HueFileEntry.prototype.open = function () {
+  HueFileEntry.prototype.open = function (entry, e) {
+    var isLeftButton = (e.which || e.button) === 1;
+    var hasModifierKey = e.ctrlKey || e.shiftKey || e.metaKey;
     var self = this;
     var self = this;
-    if (self.definition().type === 'directory') {
-      self.makeActive();
-      huePubSub.publish('file.browser.directory.opened');
-      if (! self.loaded()) {
-        self.load();
+    if (isLeftButton && !hasModifierKey) {
+      e.stopPropagation();
+      e.preventDefault();
+      if (self.definition().type === 'directory') {
+        self.makeActive();
+        huePubSub.publish('file.browser.directory.opened');
+        if (! self.loaded()) {
+          self.load();
+        }
+      } else {
+        window.location.href = self.definition().absoluteUrl;
+      }
+    }
+    else {
+      if (self.definition().type !== 'directory') {
+        window.open(self.definition().absoluteUrl);
       }
       }
-    } else {
-      window.location.href = self.definition().absoluteUrl;
     }
     }
   };
   };
 
 

+ 1 - 1
desktop/core/src/desktop/templates/file_browser.mako

@@ -652,7 +652,7 @@ from desktop.views import _ko
                   <use xlink:href="#hi-share-addon"></use>
                   <use xlink:href="#hi-share-addon"></use>
                   <!-- /ko -->
                   <!-- /ko -->
                 </svg>
                 </svg>
-                <a href="javascript: void(0);" data-bind="text: definition().name, click: open, attr: { 'title': definition().name }" class="margin-left-5"></a>
+                <a href="javascript: void(0);" data-bind="text: definition().name, click: open, attr: { 'title': definition().name, 'href': definition().type === 'directory' ? '#' : definition().absoluteUrl }" class="margin-left-5"></a>
               </div>
               </div>
               <div class="fb-attr-group">
               <div class="fb-attr-group">
                 <!-- ko with: definition -->
                 <!-- ko with: definition -->