Skip to content

Commit 31da46b

Browse files
author
=
committed
Added vertical option for checkboxes
1 parent 8534d43 commit 31da46b

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/css/alpaca-fields.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ table.dt-rowReorder-float .alpaca-table-reorder-draggable-cell
316316
margin-left: 10px;
317317
}
318318

319+
.alpaca-control.checkbox
320+
{
321+
margin-left: 10px;
322+
}
323+
319324
.alpaca-control.radio label
320325
{
321326
line-height: 20px;

src/js/fields/list/CheckBoxField.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@
4444
this.options.rightLabel = "";
4545
}
4646
}
47+
48+
// assume vertical orientation
49+
// empty select first to false by default
50+
if (Alpaca.isUndefined(this.options.vertical))
51+
{
52+
this.options.vertical = true;
53+
}
4754
},
4855

4956
prepareControlModel: function(callback)
@@ -108,6 +115,16 @@
108115
afterChangeHandler();
109116
});
110117

118+
// stack checkbox selectors vertically
119+
if (self.options.vertical)
120+
{
121+
$(self.control).css("display", "block");
122+
}
123+
else
124+
{
125+
$(self.control).css("display", "inline-block");
126+
}
127+
111128
callback();
112129
});
113130
},
@@ -216,6 +233,12 @@
216233
"description": "Whether to constrain the field's schema enum property to the values that come back from the data source.",
217234
"type": "boolean",
218235
"default": true
236+
},
237+
"vertical": {
238+
"title": "Position the checkbox selector items vertically",
239+
"description": "By default, checkbox controls are stacked vertically. Set to false if you'd like checkbox controls to lay out horizontally.",
240+
"type": "boolean",
241+
"default": true
219242
}
220243
}
221244
});
@@ -248,4 +271,4 @@
248271
Alpaca.registerFieldClass("checkbox", Alpaca.Fields.CheckBoxField);
249272
Alpaca.registerDefaultSchemaFieldMapping("boolean", "checkbox");
250273

251-
})(jQuery);
274+
})(jQuery);

0 commit comments

Comments
 (0)