Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

add validation support to templates #1959

Merged
Merged
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<h2>Checkboxes</h2>
<div class="thin-box">
<section id="checkboxes-block">

<div id="myCheckbox1Wrapper" style="width: 300px;"></div>
<div class="checkbox" id="myCheckbox">
<label class="checkbox-custom" data-initialize="checkbox" id="myCustomCheckbox1">
<input class="sr-only" type="checkbox" value="" />
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ define(function (require) {
CHECKBOX
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

var checkbox = require('hbs!fuelux_templates/checkbox');
var $myCheckbox1Wrapper = $('#myCheckbox1Wrapper');
$myCheckbox1Wrapper.html(checkbox({ id: 'myCheckbox1', required: true, validation: 'error', label: 'Checkboxes', checkboxes: [{label: 'Checkbox Label 1' }, {label: 'Checkbox Label 2' }]}));

// sample method buttons
$('#btnCheckboxToggle').on('click', function () {
$('#myCustomCheckbox1').checkbox('toggle');
Expand Down
27 changes: 20 additions & 7 deletions less/forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
.checkbox-radio-hover();
}
}

label, .input-label, label& {
cursor: pointer;
font-weight: normal;
Expand Down Expand Up @@ -102,7 +102,7 @@
color: @text-color;
color: @checkbox-primary-color;
cursor: pointer;

&:before {
.checkbox-radio-focus();
outline: none;
Expand Down Expand Up @@ -176,12 +176,12 @@



// Allows multiline labels next to checkboxes and radio
// Allows multiline labels next to checkboxes and radio
// Should be wrapped in `<form class="form-horizontal"><div class="form-group">`
.fuelux {

.checkbox.multiline, .radio.multiline {
float: left;
float: left;
margin-left: 15px;
}

Expand All @@ -191,9 +191,9 @@
.fuelux {

.checkbox.multiline ~ .control-label, .radio.multiline ~ .control-label {
float: left;
width: 80%;
margin-left: 10px;
float: left;
width: 80%;
margin-left: 10px;
text-align: left;

& > label {
Expand All @@ -204,3 +204,16 @@

}

.fuelux {
.form-group {
&.required {
.control-label {
&:before {
content: '*';
color: @text-danger;
margin-right: @margin-xs;
}
}
}
}
}
4 changes: 2 additions & 2 deletions templates/handlebars/bootstrap/input.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group{{#if horizontal}}{{#if inputsize}} form-group-{{inputsize}}{{/if}}{{/if}}{{#if validation}} has-{{validation}}{{#if feedback}} has-feedback{{/if}}{{/if}}">
<div class="form-group{{#if horizontal}}{{#if inputsize}} form-group-{{inputsize}}{{/if}}{{/if}}{{#if validation}} has-{{validation}}{{#if feedback}} has-feedback{{/if}}{{/if}}{{#if required}} required{{/if}}">
{{#if label}}<label for="{{#if id}}{{id}}{{else}}myInput{{/if}}" class="control-label{{#if horizontal}} col-sm-2{{/if}}">{{label}}</label>{{/if}}
{{#if horizontal}}<div class="col-sm-10">{{/if}}
{{#if hasAside}}<div class="input-group">{{/if}}
Expand Down Expand Up @@ -29,4 +29,4 @@
{{#if feedback}}<span class="glyphicon glyphicon-{{feedback}} form-control-feedback" aria-hidden="true"></span><span id="{{#if id}}{{id}}{{else}}myInput{{/if}}Status" class="sr-only">({{#if validation}}{{validation}}{{/if}})</span>{{/if}}
{{#if helptext}}<p class="help-block">{{helptext}}</p>{{/if}}
{{#if horizontal}}</div>{{/if}}
</div>
</div>
4 changes: 2 additions & 2 deletions templates/handlebars/bootstrap/textarea.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="form-group{{#if validation}} has-{{validation}}{{/if}}">
<div class="form-group{{#if validation}} has-{{validation}}{{/if}}{{#if required}} required{{/if}}">
<label class="control-label{{#if horizontal}} col-sm-2{{/if}}" for="{{#if id}}{{id}}{{else}}myTextarea{{/if}}">{{#if label}}{{label}}{{/if}}</label>
{{#if horizontal}}<div class="col-sm-10">{{/if}}
<textarea class="form-control" id="{{#if id}}{{id}}{{else}}myTextarea{{/if}}" name="{{#if name}}{{name}}{{else}}{{#if id}}{{id}}{{else}}myTextarea{{/if}}{{/if}}" rows="{{#if rows}}{{rows}}{{/if}}"{{#if required}} required{{/if}}{{#if readonly}} readonly{{/if}}{{#if disabled}} disabled{{/if}}>{{#if text}}{{text}}{{/if}}</textarea>
{{#if helptext}}<p class="help-block">{{helptext}}</p>{{/if}}
{{#if horizontal}}</div>{{/if}}
</div>
</div>
4 changes: 2 additions & 2 deletions templates/handlebars/fuelux/checkbox.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group{{#if validation}} has-{{validation}}{{/if}}">
<div class="form-group{{#if validation}} has-{{validation}}{{/if}}{{#if required}} required{{/if}}">
<label for="{{#if id}}{{id}}{{else}}myCustomCheckboxWrapper{{/if}}" class="control-label{{#if horizontal}} col-sm-2{{/if}}">{{#if label}}{{label}}{{/if}}</label>

<div class="{{#if inline}}checkbox{{/if}}{{#if horizontal}} col-sm-10{{/if}}"{{#if required}} required{{/if}}>
Expand All @@ -12,4 +12,4 @@
{{/each}}
{{#if helptext}}<p class="help-block">{{helptext}}</p>{{/if}}
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions templates/handlebars/fuelux/combobox.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group{{#if horizontal}}{{#if inputsize}} form-group-{{inputsize}}{{/if}}{{/if}}{{#if validation}} has-{{validation}}{{#if feedback}} has-feedback{{/if}}{{/if}}">
<div class="form-group{{#if horizontal}}{{#if inputsize}} form-group-{{inputsize}}{{/if}}{{/if}}{{#if validation}} has-{{validation}}{{#if feedback}} has-feedback{{/if}}{{/if}}{{#if required}} required{{/if}}">
<label for="{{#if id}}{{id}}{{else}}myCombobox{{/if}}Input" class="control-label{{#if horizontal}} col-sm-2{{/if}}">{{#if label}}{{label}}{{/if}}</label>

{{#if horizontal}}<div class="col-sm-10">{{/if}}
Expand All @@ -17,4 +17,4 @@
{{#if feedback}}<span class="glyphicon glyphicon-{{feedback}} form-control-feedback" aria-hidden="true"></span><span id="{{#if id}}{{id}}{{else}}myCombobox{{/if}}Status" class="sr-only">({{#if validation}}{{validation}}{{/if}})</span>{{/if}}
{{#if helptext}}<p class="help-block">{{helptext}}</p>{{/if}}
{{#if horizontal}}</div>{{/if}}
</div>
</div>
4 changes: 2 additions & 2 deletions templates/handlebars/fuelux/radio.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group{{#if validation}} has-{{validation}}{{/if}}">
<div class="form-group{{#if validation}} has-{{validation}}{{/if}}{{#if required}} required{{/if}}">
<label for="{{#if id}}{{id}}{{else}}myCustomRadioWrapper{{/if}}" class="control-label{{#if horizontal}} col-sm-2{{/if}}">{{#if label}}{{label}}{{/if}}</label>

<div class="{{#if inline}}radio{{/if}}{{#if horizontal}} col-sm-10{{/if}}"{{#if required}} required{{/if}}>
Expand All @@ -12,4 +12,4 @@
{{/each}}
{{#if helptext}}<p class="help-block">{{helptext}}</p>{{/if}}
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions templates/handlebars/fuelux/selectlist.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group{{#if validation}} has-{{validation}}{{/if}}">
<div class="form-group{{#if validation}} has-{{validation}}{{/if}}{{#if required}} required{{/if}}">
<label class="control-label{{#if horizontal}} col-sm-2{{/if}}" for="{{#if id}}{{id}}{{else}}mySelectlist{{/if}}">{{#if label}}{{label}}{{/if}}</label>
<div class="controls text-{{#if buttonalign}}{{buttonalign}}{{else}}left{{/if}}{{#if horizontal}} col-sm-10{{/if}}">
<div class="btn-group selectlist"{{#unless doNotInit}} data-initialize="selectlist"{{/unless}} data-resize="auto" id="{{#if id}}{{id}}{{else}}mySelectlist{{/if}}">
Expand All @@ -16,4 +16,4 @@
</div>
{{#if helptext}}<p class="help-block">{{helptext}}</p>{{/if}}
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions templates/handlebars/fuelux/spinbox.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group{{#if validation}} has-{{validation}}{{#if feedback}} has-feedback{{/if}}{{/if}}">
<div class="form-group{{#if validation}} has-{{validation}}{{#if feedback}} has-feedback{{/if}}{{/if}}{{#if required}} required{{/if}}">
<label class="control-label{{#if horizontal}} col-sm-2{{/if}}" for="{{#if id}}{{id}}{{else}}mySpinbox{{/if}}Input">{{#if label}}{{label}}{{/if}}</label>
<div{{#if horizontal}} class="col-sm-10"{{/if}}>
<div class="spinbox" {{#unless doNotInit}}data-initialize="spinbox"{{/unless}} id="{{#if id}}{{id}}{{else}}mySpinbox{{/if}}">
Expand All @@ -15,4 +15,4 @@
</div>
{{#if helptext}}<p class="help-block">{{helptext}}</p>{{/if}}
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions templates/underscore/bootstrap/input.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Text input http://getbootstrap.com/css/#forms -->
<div class="form-group<% if(horizontal && inputsize.length > 0) {%> form-group-<%= inputsize %><% } %>">
<div class="form-group<% if(horizontal && inputsize.length > 0) {%> form-group-<%= inputsize %><% } %><% if(validation) {%> has-<%= validation %><% } %><% if(required) {%> required<% } %>">
<label for="<%= id %>" class="control-label<% if(horizontal) { %> col-sm-2<% } %>"><%= label %></label>
<% if(horizontal) {%><div class="col-sm-10"><% } %>
<input type="<%= inputtype %>" class="<% if(!horizontal && inputsize.length > 0) {%>input-<%= inputsize %> <% } %>form-control" id="<%= id %>" placeholder="<%= placeholder %>"<% if(required) {%> required <% } %><% if(readonly) {%> readonly <% } %><% if(isDisabled) {%> disabled <% } %>>
<% if (helptext.length > 0) { %><p class="help-block"><%= helptext %></p><% } %>
<% if(horizontal) {%></div><% } %>
</div>
</div>
2 changes: 1 addition & 1 deletion templates/underscore/bootstrap/textarea.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Textarea http://getbootstrap.com/css/#textarea -->
<div class="form-group">
<div class="form-group<% if(validation) {%> has-<%= validation %><% } %><% if(required) {%> required<% } %>">
<label class="control-label<% if(horizontal) { %> col-sm-2<% } %>" for="<%= id %>"><%= label %></label>
<% if(horizontal) {%><div class="col-sm-10"><% } %>
<textarea class="form-control" id="<%= id %>" name="<%= id %>" rows="<%= rows %>"<% if(required) {%> required <% } %><% if(readonly) {%> readonly <% } %><% if(isDisabled) {%> disabled <% } %>><%= textarea %></textarea>
Expand Down
4 changes: 2 additions & 2 deletions templates/underscore/fuelux/checkboxes.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Fuel UX Checkboxes http://getfuelux.com/javascript.html#checkbox -->
<div class="form-group">
<div class="form-group<% if(validation) {%> has-<%= validation %><% } %><% if(required) {%> required<% } %>">
<label for="<%= name %>" class="control-label<% if(horizontal) { %> col-sm-2<% } %>"><%= label %></label>
<div class="<% if(horizontal) {%> col-sm-10<% } %><% if(required) {%> required<% } %>">
<% _.each(checkboxes, function(checkbox, i){ %><div class="checkbox">
Expand All @@ -10,4 +10,4 @@
</div><% }); %>
<% if (helptext.length > 0) { %><p class="help-block"><%= helptext %></p><% } %>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions templates/underscore/fuelux/input-with-combobox.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Input With Combobox http://getfuelux.com/javascript.html#combobox -->
<div class="form-group<% if(horizontal && inputsize.length > 0) {%> form-group-<%= inputsize %><% } %>">
<div class="form-group<% if(horizontal && inputsize.length > 0) {%> form-group-<%= inputsize %><% } %><% if(validation) {%> has-<%= validation %><% } %><% if(required) {%> required<% } %>">
<label class="control-label<% if(horizontal) { %> col-sm-2<% } %>" for="<%= id %>Input"><%= label %></label>
<% if(horizontal) {%><div class="col-sm-10"><% } %>
<div class="input-group <% if(placement=="appended") { %>input-append<% } else { %>input-prepend<% } %> dropdown combobox<% if(inputsize.length > 0) {%> input-group-<%= inputsize %><% } %>" data-initialize="combobox" id="<%= id %>">
Expand All @@ -14,4 +14,4 @@
</div>
<% if (helptext.length > 0) { %><p class="help-block"><%= helptext %></p><% } %>
<% if(horizontal) {%></div><% } %>
</div>
</div>
4 changes: 2 additions & 2 deletions templates/underscore/fuelux/radios.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Fuel UX Radios http://getfuelux.com/javascript.html#radio -->
<div class="form-group">
<div class="form-group<% if(validation) {%> has-<%= validation %><% } %><% if(required) {%> required<% } %>">
<label for="<%= name %>" class="control-label<% if(horizontal) { %> col-sm-2<% } %>"><%= label %></label>
<div class="<% if(horizontal) {%> col-sm-10<% } %><% if(required) {%> required<% } %>">
<% _.each(radios, function(radio, i){ %><div class="radio">
Expand All @@ -10,4 +10,4 @@
</div><% }); %>
<% if (helptext.length > 0) { %><p class="help-block"><%= helptext %></p><% } %>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions templates/underscore/fuelux/selectlist.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Fuel UX Select http://getfuelux.com/javascript.html#selectlist -->
<div class="form-group">
<div class="form-group<% if(validation) {%> has-<%= validation %><% } %><% if(required) {%> required<% } %>">
<label class="control-label<% if(horizontal) { %> col-sm-2<% } %>" for="<%= id %>"><%= label %></label>
<div class="controls <%= buttonalign %><% if(horizontal) {%> col-sm-10<% } %>">
<div class="btn-group selectlist" data-initialize="selectlist" data-resize="auto" id="<%= id %>">
Expand All @@ -15,4 +15,4 @@
</div>
<% if (helptext.length > 0) { %><p class="help-block"><%= helptext %></p><% } %>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions templates/underscore/fuelux/spinbox.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Spinbox http://getfuelux.com/javascript.html#spinbox -->
<div class="form-group">
<div class="form-group<% if(validation) {%> has-<%= validation %><% } %><% if(required) {%> required<% } %>">
<label for="<%= id %>" class="control-label<% if(horizontal) { %> col-sm-2<% } %>"><%= label %></label>
<div<% if(horizontal) {%> class="col-sm-10"<% } %>>
<div class="spinbox" data-initialize="spinbox" id="<%= id %>">
Expand All @@ -15,4 +15,4 @@
</div>
<% if (helptext.length > 0) { %><p class="help-block"><%= helptext %></p><% } %>
</div>
</div>
</div>