From 2c664117fc8644df70ac2b84db8f65c5f708163c Mon Sep 17 00:00:00 2001 From: = Date: Wed, 13 Dec 2017 17:30:13 -0500 Subject: [PATCH] Adding vertical option for checkboxes --- src/css/alpaca-fields.css | 4 ++++ src/js/fields/list/CheckBoxField.js | 25 ++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/css/alpaca-fields.css b/src/css/alpaca-fields.css index 52194db83..d89400b98 100644 --- a/src/css/alpaca-fields.css +++ b/src/css/alpaca-fields.css @@ -316,6 +316,10 @@ table.dt-rowReorder-float .alpaca-table-reorder-draggable-cell margin-left: 10px; } +.alpaca-control.checkbox { + margin-left: 10px; +} + .alpaca-control.radio label { line-height: 20px; diff --git a/src/js/fields/list/CheckBoxField.js b/src/js/fields/list/CheckBoxField.js index 50d554483..f3c74c92f 100644 --- a/src/js/fields/list/CheckBoxField.js +++ b/src/js/fields/list/CheckBoxField.js @@ -44,6 +44,13 @@ this.options.rightLabel = ""; } } + + // assume vertical orientation + // empty select first to false by default + if (Alpaca.isUndefined(this.options.vertical)) + { + this.options.vertical = true; + } }, prepareControlModel: function(callback) @@ -108,6 +115,16 @@ afterChangeHandler(); }); + // stack checkbox selectors vertically + if (self.options.vertical) + { + $(self.control).css("display", "block"); + } + else + { + $(self.control).css("display", "inline-block"); + } + callback(); }); }, @@ -216,6 +233,12 @@ "description": "Whether to constrain the field's schema enum property to the values that come back from the data source.", "type": "boolean", "default": true + }, + "vertical": { + "title": "Position the checkbox selector items vertically", + "description": "By default, checkbox controls are stacked vertically. Set to false if you'd like checkbox controls to lay out horizontally.", + "type": "boolean", + "default": true } } }); @@ -248,4 +271,4 @@ Alpaca.registerFieldClass("checkbox", Alpaca.Fields.CheckBoxField); Alpaca.registerDefaultSchemaFieldMapping("boolean", "checkbox"); -})(jQuery); \ No newline at end of file +})(jQuery);