From 49585c8c57f9f510a3fbd1f8d0ea8d6a1cfc76fb Mon Sep 17 00:00:00 2001 From: Odysseas Date: Wed, 21 Oct 2015 00:18:46 +0300 Subject: [PATCH] Add feature to open image attachments Images that are attached to messages, either sent or received can be opened in a new tab by clicking on them. The previous approach that used Anchors to open the image attachmets failed in various systems because: - Chrome on Windows recognised "blob" as protocol and tried to find an app for it - Chromium on Ubuntu didn't open a new window to load the URL The new approach adds a "click" listener to the IMG element and opens the link using window.open (which seems to be working globaly). Resolves: #252 --- js/views/attachment_view.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js index 0d5290829..1a577d2b3 100644 --- a/js/views/attachment_view.js +++ b/js/views/attachment_view.js @@ -7,11 +7,15 @@ var ImageView = Backbone.View.extend({ tagName: 'img', events: { - 'load': 'update' + 'load': 'update', + 'click': 'open' }, update: function() { this.$el.trigger('update'); }, + open: function () { + window.open(this.$el.attr('src'), '_blank'); + }, render: function(dataUrl) { this.$el.attr('src', dataUrl); return this;