Trigger update events after attachments load
Mostly so we can ensure we're scrolled to the bottom when the conversation is loaded.
This commit is contained in:
parent
f9ca13a86f
commit
258a872ce3
1 changed files with 16 additions and 1 deletions
|
@ -18,6 +18,12 @@
|
|||
|
||||
var ImageView = Backbone.View.extend({
|
||||
tagName: 'img',
|
||||
events: {
|
||||
'load': 'update'
|
||||
},
|
||||
update: function() {
|
||||
this.$el.trigger('update');
|
||||
},
|
||||
render: function(dataUrl) {
|
||||
this.$el.attr('src', dataUrl);
|
||||
return this;
|
||||
|
@ -27,6 +33,15 @@
|
|||
var MediaView = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.$el.attr('controls', '');
|
||||
this.$el.on('loadeddata', function() {
|
||||
this.$el.trigger('update');
|
||||
}.bind(this));
|
||||
},
|
||||
events: {
|
||||
'loadeddata': 'update'
|
||||
},
|
||||
update: function() {
|
||||
this.$el.trigger('update');
|
||||
},
|
||||
render: function(dataUrl, contentType) {
|
||||
var $el = $('<source>');
|
||||
|
@ -52,9 +67,9 @@
|
|||
default:
|
||||
throw 'Unsupported attachment type';
|
||||
}
|
||||
view.$el.appendTo(this.$el);
|
||||
var blob = new Blob([this.model.data], {type: this.model.contentType});
|
||||
view.render(window.URL.createObjectURL(blob), this.model.contentType);
|
||||
view.$el.appendTo(this.$el);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue