]> _ Git - fluidbook-html5.git/commitdiff
wait #4884 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 16 Nov 2021 17:36:28 +0000 (18:36 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 16 Nov 2021 17:36:28 +0000 (18:36 +0100)
js/libs/fluidbook/fluidbook.js

index d8f682675a404208cda84b2b723d29e02a5292e9..4456511e3e7b8758956f13974568959d64a2436d 100644 (file)
@@ -1034,6 +1034,8 @@ Fluidbook.prototype = {
 
         url = url.replace('$uuid', this.stats.vid);
 
+        var attrs = "";
+
         if (target == undefined) {
             target = '_self';
         }
@@ -1041,6 +1043,15 @@ Fluidbook.prototype = {
             options = '';
         }
 
+        if (target === '_download') {
+            var e = url.split('/');
+            var last = e.pop();
+            e = last.split('?');
+            var name = e.shift();
+            this.clickFakeLink('<a href="' + url + '"  download="' + name + '"></a>');
+            return false;
+        }
+
         // fix #3407
         if (target === '_popupiframe' && Modernizr.ios && url.search(/\.pdf$/) >= 0) {
             target = '_blank';
@@ -1092,14 +1103,8 @@ Fluidbook.prototype = {
         if (options == undefined && replace == undefined) {
             if (this.support.IE == 0) {
                 w = win.open(url, mtarget);
-                console.log(w);
             } else {
-                $("#wopen").remove();
-                $('body').append('<a id="wopen" href="' + url + '" target="' + mtarget + '"></a>');
-                $("#wopen").get(0).click();
-                setTimeout(function () {
-                    $("#wopen").remove();
-                }, 200);
+                this.clickFakeLink('<a href="' + url + '" target="' + mtarget + '"></a>');
             }
         } else {
             w = win.open(url, mtarget, options, replace);
@@ -1116,6 +1121,17 @@ Fluidbook.prototype = {
         return w;
     },
 
+    clickFakeLink: function (html) {
+        var a = $(html);
+        $(a).attr('id', 'wopen');
+        $("#wopen").remove();
+        $('body').append(a);
+        $("#wopen").get(0).click();
+        setTimeout(function () {
+            $("#wopen").remove();
+        }, 200);
+    },
+
     openInPopupIframe: function (url, callback) {
         this.menu.openView('freeiframe', url, '', function () {
             if (callback !== undefined) {