summaryrefslogtreecommitdiffstats
path: root/web/dom.js
blob: 44f8491552aae2d29882d788bda652a8dff7a40c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * Copyright (c) 2012-2014 Kaarle Ritvanen
 * See LICENSE file for license details
 */

define(["jquery", "jquery-bbq"], function($) {
    function href() {
	return $("<a>").attr({href: "javascript:void(0);"});
    }

    return {
	href: href,

	objectRef: function(value, el) {
	    el = el || href();
	    if (value) {
		el.click(function() {
		    $.bbq.pushState("#" + value);
		}).text("Show");
	    }
	    return el;
	},

	makeRow: function(el) {
	    if (el.is("td")) return $("<tr>").html(el);
	    return el;
	},

	setStatus: function(el, status) { el.prop("class", status); }
    };
});