summaryrefslogtreecommitdiffstats
path: root/web/widget/audio.js
blob: 99e410d312049e190e23c82c491f862b1c644fbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Copyright (c) 2012-2014 Kaarle Ritvanen
 * See LICENSE file for license details
 */

define(
    ["aconf/dom", "aconf/widget/abstract/inline", "jquery", "underscore"],
    function(dom, Base, $, _) {
	return Base.extend({
	    render: function(value, meta) {
		if (!value) return;
		
		var self = this;

		this.el.html(_.isObject(value) ? $("<audio>").attr(
		    {src: value.data, autoplay: true, controls: true}
		) : dom.href().text("Play").click(function() {
		    self.refresh();
		}));
	    }
	});
    }
);