Skip to content

Commit

Permalink
Added vertical option for checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Dec 13, 2017
1 parent 8534d43 commit 31da46b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/css/alpaca-fields.css
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ 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;
Expand Down
25 changes: 24 additions & 1 deletion src/js/fields/list/CheckBoxField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
});
},
Expand Down Expand Up @@ -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
}
}
});
Expand Down Expand Up @@ -248,4 +271,4 @@
Alpaca.registerFieldClass("checkbox", Alpaca.Fields.CheckBoxField);
Alpaca.registerDefaultSchemaFieldMapping("boolean", "checkbox");

})(jQuery);
})(jQuery);

0 comments on commit 31da46b

Please sign in to comment.