Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding vertical option for checkboxes #584

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/css/alpaca-fields.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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);