|
|
@ -185,27 +185,38 @@ angular.module('izhukov.utils', []) |
|
|
|
function downloadFile (blob, mimeType, fileName) { |
|
|
|
function downloadFile (blob, mimeType, fileName) { |
|
|
|
if (window.navigator && navigator.msSaveBlob !== undefined) { |
|
|
|
if (window.navigator && navigator.msSaveBlob !== undefined) { |
|
|
|
window.navigator.msSaveBlob(blob, fileName); |
|
|
|
window.navigator.msSaveBlob(blob, fileName); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var url = getUrl(blob, mimeType); |
|
|
|
var url = getUrl(blob, mimeType); |
|
|
|
|
|
|
|
|
|
|
|
var anchor = $('<a>Download</a>') |
|
|
|
var anchor = document.createElementNS('http://www.w3.org/1999/xhtml', 'a'); |
|
|
|
.css({position: 'absolute', top: 1, left: 1}) |
|
|
|
anchor.href = url; |
|
|
|
.attr('href', url) |
|
|
|
anchor.target = '_blank'; |
|
|
|
.attr('target', '_blank') |
|
|
|
anchor.download = fileName; |
|
|
|
.attr('download', fileName) |
|
|
|
if (anchor.dataset) { |
|
|
|
.appendTo('body'); |
|
|
|
anchor.dataset.downloadurl = ["video/quicktime", fileName, url].join(':'); |
|
|
|
|
|
|
|
|
|
|
|
if (anchor[0].dataset) { |
|
|
|
|
|
|
|
anchor[0].dataset.downloadurl = [mimeType, fileName, url].join(':'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$(anchor).css({position: 'absolute', top: 1, left: 1}).appendTo('body'); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
var clickEvent = document.createEvent('MouseEvents'); |
|
|
|
|
|
|
|
clickEvent.initMouseEvent( |
|
|
|
|
|
|
|
'click', true, false, window, 0, 0, 0, 0, 0 |
|
|
|
|
|
|
|
, false, false, false, false, 0, null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
anchor.dispatchEvent(clickEvent); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error('Download click error', e); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
console.error('Download click error', e); |
|
|
|
anchor[0].click(); |
|
|
|
anchor[0].click(); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
window.open(url, '_blank'); |
|
|
|
window.open(url, '_blank'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
$timeout(function () { |
|
|
|
$timeout(function () { |
|
|
|
anchor.remove(); |
|
|
|
$(anchor).remove(); |
|
|
|
}, 100); |
|
|
|
}, 100); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|