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
This commit is contained in:
Odysseas 2015-10-21 00:18:46 +03:00 committed by lilia
parent a32780d174
commit 49585c8c57

View file

@ -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;