From 2ce6d6e4414b97cff8b3f28387a3fc5723947e80 Mon Sep 17 00:00:00 2001 From: Darren Date: Wed, 16 Apr 2014 23:29:23 +0100 Subject: [PATCH] Kiwi API: addMediaMessageType() --- client/src/views/mediamessage.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/client/src/views/mediamessage.js b/client/src/views/mediamessage.js index f7f09d4..908b83b 100644 --- a/client/src/views/mediamessage.js +++ b/client/src/views/mediamessage.js @@ -163,13 +163,23 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ }, + custom: function() { + var type = this.constructor.types[this.$el.data('index')]; + + if (!type) + return; + + return $(type.buildHtml(this.$el.data('url'))); + } + + } }, { /** * Add a media message type to append HTML after a matching URL - * match() should return true if it wants to handle this URL - * buildHtml() should return the HTML string to append after the URL in the message + * match() should return a truthy value if it wants to handle this URL + * buildHtml() should return the HTML string to be used within the drop down */ addType: function(match, buildHtml) { if (typeof match !== 'function' || typeof buildHtml !== 'function') @@ -184,11 +194,12 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ buildHtml: function (url) { var html = '', matches; - _.each(this.types || [], function(type) { + _.each(this.types || [], function(type, type_idx) { if (!type.match(url)) return; - html += type.buildHtml(url); + // Add which media type should handle this media message. Will be read when it's clicked on + html += ''; }); // Is it an image? -- 2.25.1