Skip to content

Commit

Permalink
Merge pull request #40 in STRUC/icn3d from icn3d1310 to master
Browse files Browse the repository at this point in the history
* commit 'e9b1bcd6597f18b9f9220b07c35b201bd6f6671e':
  fixed the Save File issue since Chrome 60
  • Loading branch information
jiywang3 committed Oct 27, 2017
2 parents c6b5877 + e9b1bcd commit 155df83
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ gulp gh-pages

## Change log

The production version [icn3d-1.3.10](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-1.3.10.zip) was release on October 27, 2017. The "Save File" issue in Chrome 60 and after was fixed.

The production version [icn3d-1.3.9](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-1.3.9.zip) was release on September 5, 2017. The handling of residues with insertion codes was fixed in structure alignment.

The production version [icn3d-1.3.8](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-1.3.8.zip) was release on August 7, 2017. The handling of residues with insertion codes was fixed.
Expand Down
3 changes: 3 additions & 0 deletions icn3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,9 @@ <h2>API Documents of the advanced UI library iCn3DUI<img src="https://www.ncbi.n
<a name="log"></a>
<h2>Change Log:<img src="https://www.ncbi.nlm.nih.gov/Structure/IMG/spacer.gif" width="25" height="1" border="0"><a href="#Top"><img src="https://www.ncbi.nlm.nih.gov/Structure/IMG/arrowup_blue.gif" width="12" height="12" border="0" alt="back to top"></a></h2>

The production version <a href="https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-1.3.10.zip">icn3d-1.3.10</a> was release on October 27, 2017. The "Save File" issue in Chrome 60 and after was fixed.
<br><br>

The production version <a href="https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-1.3.9.zip">icn3d-1.3.9</a> was release on September 5, 2017. The handling of residues with insertion codes was fixed in structure alignment.
<br><br>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "icn3d",
"version": "1.3.9",
"version": "1.3.10",
"description": "iCn3D Structure Viewer",
"main": "index.html",
"scripts": {
Expand Down
54 changes: 41 additions & 13 deletions src/icn3dui/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ if (!$.ui.dialog.prototype._makeDraggableBase) {

iCn3DUI.prototype.saveFile = function(filename, type, text) { var me = this;
//Save file
if(me.isIE()) { // IE
if(window.navigator.msSaveBlob){
var blob;
// if(me.isIE() && window.navigator.msSaveBlob){
if(type === 'command') {
var dataStr = '';
for(var i = 0, il = me.icn3d.commands.length; i < il; ++i) {
Expand All @@ -194,30 +194,43 @@ if (!$.ui.dialog.prototype._makeDraggableBase) {
}
var data = decodeURIComponent(dataStr);

var blob = new Blob([data],{ type: "text;charset=utf-8;"});
navigator.msSaveBlob(blob, filename);
blob = new Blob([data],{ type: "text;charset=utf-8;"});
}
else if(type === 'png') {
me.icn3d.render();
var blob = me.icn3d.renderer.domElement.msToBlob();

navigator.msSaveBlob(blob, filename);
me.icn3d.render();
if(me.isIE()) {
blob = me.icn3d.renderer.domElement.msToBlob();
}
else {
me.icn3d.renderer.domElement.toBlob(function(data) {
blob = data;

var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});

return;
}
}
else if(type === 'html') {
var dataStr = text;
var data = decodeURIComponent(dataStr);

var blob = new Blob([data],{ type: "text/html;charset=utf-8;"});
navigator.msSaveBlob(blob, filename);
blob = new Blob([data],{ type: "text/html;charset=utf-8;"});
}
else if(type === 'text') {
var dataStr = text;
var data = decodeURIComponent(dataStr);

var blob = new Blob([data],{ type: "text;charset=utf-8;"});
navigator.msSaveBlob(blob, filename);
blob = new Blob([data],{ type: "text;charset=utf-8;"});
}
}

//navigator.msSaveBlob(blob, filename);
/*
}
else {
var data;
Expand Down Expand Up @@ -259,6 +272,21 @@ if (!$.ui.dialog.prototype._makeDraggableBase) {
window.open(data, '_blank');
}
*/

//https://github.com/mholt/PapaParse/issues/175
//IE11 & Edge
if(me.isIE() && window.navigator.msSaveBlob){
navigator.msSaveBlob(blob, filename);
} else {
//In FF link must be added to DOM to be clicked
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
};

iCn3DUI.prototype.isMobile = function() {
Expand Down

0 comments on commit 155df83

Please sign in to comment.