mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #2871 from node-red-hitachi/fix-IE11-flow-downlod
add IE11 polyfill to support URI download scheme
This commit is contained in:
commit
e5471b44e0
@ -52,6 +52,5 @@
|
|||||||
Set.prototype = _Set.prototype;
|
Set.prototype = _Set.prototype;
|
||||||
Set.prototype.constructor = Set;
|
Set.prototype.constructor = Set;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -30,6 +30,27 @@ RED.clipboard = (function() {
|
|||||||
|
|
||||||
var pendingImportConfig;
|
var pendingImportConfig;
|
||||||
|
|
||||||
|
|
||||||
|
function downloadData(file, data) {
|
||||||
|
if (window.navigator.msSaveBlob) {
|
||||||
|
// IE11 workaround
|
||||||
|
// IE does not support data uri scheme for downloading data
|
||||||
|
var blob = new Blob([data], {
|
||||||
|
type: "data:text/plain;charset=utf-8"
|
||||||
|
});
|
||||||
|
navigator.msSaveBlob(blob, file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var element = document.createElement('a');
|
||||||
|
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(data));
|
||||||
|
element.setAttribute('download', file);
|
||||||
|
element.style.display = 'none';
|
||||||
|
document.body.appendChild(element);
|
||||||
|
element.click();
|
||||||
|
document.body.removeChild(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setupDialogs() {
|
function setupDialogs() {
|
||||||
dialog = $('<div id="red-ui-clipboard-dialog" class="hide"><form class="dialog-form form-horizontal"></form></div>')
|
dialog = $('<div id="red-ui-clipboard-dialog" class="hide"><form class="dialog-form form-horizontal"></form></div>')
|
||||||
.appendTo("#red-ui-editor")
|
.appendTo("#red-ui-editor")
|
||||||
@ -56,13 +77,8 @@ RED.clipboard = (function() {
|
|||||||
class: "primary",
|
class: "primary",
|
||||||
text: RED._("clipboard.download"),
|
text: RED._("clipboard.download"),
|
||||||
click: function() {
|
click: function() {
|
||||||
var element = document.createElement('a');
|
var data = $("#red-ui-clipboard-dialog-export-text").val();
|
||||||
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent($("#red-ui-clipboard-dialog-export-text").val()));
|
downloadData("flows.json", data);
|
||||||
element.setAttribute('download', "flows.json");
|
|
||||||
element.style.display = 'none';
|
|
||||||
document.body.appendChild(element);
|
|
||||||
element.click();
|
|
||||||
document.body.removeChild(element);
|
|
||||||
$( this ).dialog( "close" );
|
$( this ).dialog( "close" );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user