summaryrefslogtreecommitdiffstats
path: root/web/widget/table/row.js
blob: 7e617b2f607b9654b5a43d3f8e5d792d0fd19c33 (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
32
33
34
35
36
37
38
/*
 * Copyright (c) 2012-2014 Kaarle Ritvanen
 * See LICENSE file for license details
 */

define(
    ["acf2/dom", "acf2/widget/abstract/fields", "jquery"],
    function(dom, Base, $) {
	return Base.extend({
	    createEl: function() {
		this.prevAction = null;
		this.prevWidget = null;
		return $("<tr>").html($("<td>").prop("class", "placeholder"));
	    },

	    showHeading: false,

	    addActionButton: function(label, action) {
		(this.prevAction ?
		 this.prevAction : this.el.find(".placeholder")).after(
		     $("<td>").html(dom.href().text(label).click(action))
		 );
	    },

	    appendWidget: function(el, label) {
		if (!el.is("td")) return null;
		if (this.prevWidget) this.prevWidget.after(el);
		else {
		    var ph = this.el.find(".placeholder");
		    ph.after(el);
		    ph.remove();
		}
		this.prevWidget = el;
		return el;
	    }
	});
    }
);