From 38ac196b2f00c1e13a0928cd892384bc296c8a98 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Thu, 6 Feb 2014 23:09:13 +0200 Subject: web client: extract each widget to a dedicated file --- web/layout/stacked.js | 17 +++++++++++++++++ web/layout/tabular.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 web/layout/stacked.js create mode 100644 web/layout/tabular.js (limited to 'web/layout') diff --git a/web/layout/stacked.js b/web/layout/stacked.js new file mode 100644 index 0000000..1fa8af9 --- /dev/null +++ b/web/layout/stacked.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2012-2014 Kaarle Ritvanen + * See LICENSE file for license details + */ + +define(["acf2/type", "acf2/widget/inline"], function(type, Base) { + var Class = Base.extend({ + widget: function(meta) { + return type.isTreeNode(meta) ? + Base : this.super(Class, "widget", meta); + } + }); + + return Class; +}); + + diff --git a/web/layout/tabular.js b/web/layout/tabular.js new file mode 100644 index 0000000..03fbe03 --- /dev/null +++ b/web/layout/tabular.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012-2014 Kaarle Ritvanen + * See LICENSE file for license details + */ + +define( + [ + "acf2/type", + "acf2/widget/inline", + "acf2/widget/table/header", + "acf2/widget/table/row" + ], + function(type, Base, TableHeader, TableRow) { + var Class = Base.extend({ + render: function(data, meta) { + this.header = true; + this.super(Class, "render", data, meta); + }, + + widget: function(meta) { + if (!type.isTreeNode(meta)) + return this.super(Class, "widget", meta); + if (!this.header) return TableRow; + this.header = false; + return TableHeader; + } + }); + + return Class; + } +); -- cgit v1.2.3