From c790d07389a7d0bbf5298de83dbcfa8be1e7696b Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Fri, 9 Feb 2018 17:38:35 -0500 Subject: [PATCH] Make second `View` argument an `options` object --- js/views/attachment_view.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js index 6fac465715..db25bad541 100644 --- a/js/views/attachment_view.js +++ b/js/views/attachment_view.js @@ -15,8 +15,9 @@ var ImageView = Backbone.View.extend({ tagName: 'img', - initialize: function(objectUrl, contentType, blob) { - window.autoOrientImage(blob).then(dataURL => { + // TODO: Disable JSHint to allow for `{blob}={}` syntax: + initialize: function(blobUrl, options) { + window.autoOrientImage(options.blob).then(dataURL => { this.source = dataURL; this.render(); }); @@ -38,9 +39,10 @@ }); var MediaView = Backbone.View.extend({ - initialize: function(dataUrl, contentType) { + // TODO: Disable JSHint to allow for `{contentType}={}` syntax: + initialize: function(dataUrl, options) { this.dataUrl = dataUrl; - this.contentType = contentType; + this.contentType = options.contentType; this.$el.attr('controls', ''); }, events: { @@ -204,7 +206,8 @@ if (!this.objectUrl) { this.objectUrl = window.URL.createObjectURL(this.blob); } - this.view = new View(this.objectUrl, this.model.contentType, this.blob); + const {blob, contentType} = this; + this.view = new View(this.objectUrl, {blob, contentType}); this.view.$el.appendTo(this.$el); this.listenTo(this.view, 'update', this.update); this.view.render();