From 5c122667d3fa245d988fc9c90e3c5e8bfcb2bbf5 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Sun, 23 Feb 2014 00:22:19 +0200 Subject: web client: access actions in tabular layout --- web/widget/table/row.js | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'web/widget/table/row.js') 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 $("").html($("").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 $("").html($("").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( + $("").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; - } - }); -}); + }); + } +); -- cgit v1.2.3