Added custom control type for rows of controls
This allows horizontal placement of buttons. Custom controls in rows can have specified two new attributes: width which is the width of their container in the bootstrap 12-slot grid, and offset to specify offsets to the former control on the row.
This commit is contained in:
parent
4829c21db7
commit
e476e4154e
3 changed files with 34 additions and 2 deletions
File diff suppressed because one or more lines are too long
|
|
@ -123,7 +123,7 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
|||
} else if (control.type == "feedback_command" || control.type == "feedback") {
|
||||
control.output = ko.observable("");
|
||||
self.feedbackControlLookup[control.name] = control.output;
|
||||
} else if (control.type == "section") {
|
||||
} else if (control.type == "section" || control.type == "row" || control.type == "section_row") {
|
||||
control.children = self._processControls(control.children);
|
||||
}
|
||||
|
||||
|
|
@ -300,6 +300,10 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
|||
switch (customControl.type) {
|
||||
case "section":
|
||||
return "customControls_sectionTemplate";
|
||||
case "row":
|
||||
return "customControls_rowTemplate";
|
||||
case "section_row":
|
||||
return "customControls_sectionRowTemplate";
|
||||
case "command":
|
||||
case "commands":
|
||||
return "customControls_commandTemplate";
|
||||
|
|
@ -315,6 +319,18 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
|||
}
|
||||
};
|
||||
|
||||
self.rowCss = function(customControl) {
|
||||
var span = "span2";
|
||||
var offset = "";
|
||||
if (customControl.hasOwnProperty("width")) {
|
||||
span = "span" + customControl.width;
|
||||
}
|
||||
if (customControl.hasOwnProperty("offset")) {
|
||||
offset = "offset" + customControl.offset;
|
||||
}
|
||||
return span + " " + offset;
|
||||
};
|
||||
|
||||
self.onStartup = function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -103,6 +103,22 @@
|
|||
|
||||
<div data-bind="template: { name: $root.displayMode, foreach: children }"></div>
|
||||
</script>
|
||||
<script type="text/html" id="customControls_rowTemplate">
|
||||
<div class="row-fluid">
|
||||
<!-- ko foreach: children -->
|
||||
<div data-bind="template: { name: $root.displayMode }, css: $root.rowCss($data)"></div>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="customControls_sectionRowTemplate">
|
||||
<h1 data-bind="text: name"></h1>
|
||||
|
||||
<div class="row-fluid">
|
||||
<!-- ko foreach: children -->
|
||||
<div data-bind="template: { name: $root.displayMode }, css: $root.rowCss($data)"></div>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="customControls_commandTemplate">
|
||||
<form class="form-inline">
|
||||
<button class="btn" data-bind="text: name, enable: $root.isCustomEnabled($data), click: function() { $root.clickCustom($data) }"></button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue