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({
|
var ImageView = Backbone.View.extend({
|
||||||
tagName: 'img',
|
tagName: 'img',
|
||||||
|
events: {
|
||||||
|
'load': 'update'
|
||||||
|
},
|
||||||
|
update: function() {
|
||||||
|
this.$el.trigger('update');
|
||||||
|
},
|
||||||
render: function(dataUrl) {
|
render: function(dataUrl) {
|
||||||
this.$el.attr('src', dataUrl);
|
this.$el.attr('src', dataUrl);
|
||||||
return this;
|
return this;
|
||||||
|
@ -27,6 +33,15 @@
|
||||||
var MediaView = Backbone.View.extend({
|
var MediaView = Backbone.View.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.$el.attr('controls', '');
|
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) {
|
render: function(dataUrl, contentType) {
|
||||||
var $el = $('<source>');
|
var $el = $('<source>');
|
||||||
|
@ -52,9 +67,9 @@
|
||||||
default:
|
default:
|
||||||
throw 'Unsupported attachment type';
|
throw 'Unsupported attachment type';
|
||||||
}
|
}
|
||||||
|
view.$el.appendTo(this.$el);
|
||||||
var blob = new Blob([this.model.data], {type: this.model.contentType});
|
var blob = new Blob([this.model.data], {type: this.model.contentType});
|
||||||
view.render(window.URL.createObjectURL(blob), this.model.contentType);
|
view.render(window.URL.createObjectURL(blob), this.model.contentType);
|
||||||
view.$el.appendTo(this.$el);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue