From a1345c52b46bc3636f1698cdf926ab127842d96b Mon Sep 17 00:00:00 2001 From: Benedikt Radtke Date: Fri, 24 Jun 2016 15:44:47 +0200 Subject: [PATCH] Added Save-As dialog for unsupported filetypes Despite the "click to save"-description of unsupported file types, clicking them did not save them. This commit implements a Save-As dialog instead of opening the file in chrome. // FREEBIE --- js/views/attachment_view.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js index ee9e51ba..1bf038d7 100644 --- a/js/views/attachment_view.js +++ b/js/views/attachment_view.js @@ -10,13 +10,6 @@ this.dataUrl = dataUrl; this.$el.text(i18n('unsupportedAttachment')); }, - events: { - 'click': 'open' - }, - open: function (e) { - e.preventDefault(); - window.open(this.dataUrl, '_blank'); - }, render: function() { this.$el.attr('href', this.dataUrl); this.trigger('update'); @@ -90,6 +83,26 @@ view.render(); view.$el.appendTo(this.el); view.$el.trigger('show'); + } else if (this.contentType !== 'audio' && this.contentType !== 'video') { + var suggestedName; + if (this.fileType) { + suggestedName = 'signal.' + this.fileType; + } + var w = extension.windows.getViews()[0]; + if (w && w.chrome && w.chrome.fileSystem) { + w.chrome.fileSystem.chooseEntry({ + type: 'saveFile', suggestedName: suggestedName + }, function(entry) { + if (!entry) { + return; + } + entry.createWriter(function(fileWriter) { + fileWriter.write(this.blob); + }.bind(this)); + }.bind(this)); + } else { + console.log('Failed to get window'); + } } }, render: function() {