浏览代码

HUE-6571 [frontend] Improve reliability of openInHue4 JS

Enrico Berti 8 年之前
父节点
当前提交
e1e7091
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      desktop/core/src/desktop/static/desktop/js/document/hueFileEntry.js

+ 10 - 2
desktop/core/src/desktop/static/desktop/js/document/hueFileEntry.js

@@ -554,12 +554,20 @@ var HueFileEntry = (function () {
 
 
   HueFileEntry.prototype.openExternalLink = function (entry, event) {
   HueFileEntry.prototype.openExternalLink = function (entry, event) {
     event.preventDefault();
     event.preventDefault();
-    location.href = $(event.target).attr('href');
+    var $target = $(event.target);
+    if (!$target.is('a')) {
+      $target = $target.closest('a');
+    }
+    location.href = $target.attr('href');
   };
   };
 
 
   HueFileEntry.prototype.openHue4Link = function (entry, event) {
   HueFileEntry.prototype.openHue4Link = function (entry, event) {
     event.preventDefault();
     event.preventDefault();
-    huePubSub.publish('open.link', $(event.target).attr('href'));
+    var $target = $(event.target);
+    if (!$target.is('a')) {
+      $target = $target.closest('a');
+    }
+    huePubSub.publish('open.link', $target.attr('href'));
   };
   };
 
 
   HueFileEntry.prototype.showRestoreConfirmation = function () {
   HueFileEntry.prototype.showRestoreConfirmation = function () {