// TODO: think of a better term for this as it will also refer to queries\r
channels: undefined, // TODO: Limited access to panels list\r
\r
+ addMediaMessageType: function(match, buildHtml) {\r
+ _kiwi.view.MediaMessage.addType(match, buildHtml);\r
+ },\r
+\r
// Event managers for plugins\r
components: {\r
EventComponent: function(event_source, proxy_event_name) {\r
function proxyEvent(event_name, event_data) {\r
if (proxy_event_name !== 'all') {\r
event_data = event_name.event_data;\r
- event_name = event_name.event_name\r
+ event_name = event_name.event_name;\r
}\r
-//console.log(proxy_event_name, event_name, event_data);\r
+\r
this.trigger(event_name, event_data);\r
}\r
\r
}
}, {
+ /**
+ * 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
+ */
+ addType: function(match, buildHtml) {
+ if (typeof match !== 'function' || typeof buildHtml !== 'function')
+ return;
+
+ this.types = this.types || [];
+ this.types.push({match: match, buildHtml: buildHtml});
+ },
+
+
// Build the closed media HTML from a URL
buildHtml: function (url) {
var html = '', matches;
+ _.each(this.types || [], function(type) {
+ if (!type.match(url))
+ return;
+
+ html += type.buildHtml(url);
+ });
+
// Is it an image?
if (url.match(/(\.jpe?g|\.gif|\.bmp|\.png)\??$/i)) {
html += '<span class="media image" data-type="image" data-url="' + url + '" title="Open Image"><a class="open"><i class="icon-chevron-right"></i></a></span>';