diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-02-23 00:22:19 +0200 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-02-24 13:05:52 +0200 |
commit | 5c122667d3fa245d988fc9c90e3c5e8bfcb2bbf5 (patch) | |
tree | baff504b4a7d5128bf832615987d14a6491579a3 /web/widget/table/row.js | |
parent | 22b17333e30c60e163b88af9ed88b325223d23ea (diff) | |
download | aconf-5c122667d3fa245d988fc9c90e3c5e8bfcb2bbf5.tar.bz2 aconf-5c122667d3fa245d988fc9c90e3c5e8bfcb2bbf5.tar.xz |
web client: access actions in tabular layout
Diffstat (limited to 'web/widget/table/row.js')
-rw-r--r-- | web/widget/table/row.js | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/web/widget/table/row.js b/web/widget/table/row.js index 717b4da..69c116e 100644 --- a/web/widget/table/row.js +++ b/web/widget/table/row.js @@ -3,25 +3,36 @@ * See LICENSE file for license details */ -define(["acf2/widget/abstract/fields", "jquery"], function(Base, $) { - return Base.extend({ - createEl: function() { - this.previous = null; - return $("<tr>").html($("<td>").prop("class", "placeholder")); - }, +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, + showHeading: false, - appendWidget: function(el, label, description) { - if (!el.is("td")) return null; - if (this.previous) this.previous.after(el); - else { - var ph = this.el.find(".placeholder"); - ph.after(el); - ph.remove(); + 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, description) { + 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; } - this.previous = el; - return el; - } - }); -}); + }); + } +); |