Clean up the unwanted extended versions of Backform Switch controls.

The Bootstrap Switch Control was extended only for alignment in most
places. IIntroduce a configurable option to set the necessary class
on the main div and also remove the extra extended controls.
This commit is contained in:
Khushboo Vashi
2019-02-05 16:22:35 +00:00
committed by Dave Page
parent 3fae181c27
commit 4a75053514
7 changed files with 234 additions and 127 deletions

View File

@@ -439,10 +439,11 @@ define([
controlsClassName: Backform.controlsClassName,
extraClasses: [],
helpMessage: null,
extraToggleClasses: null,
},
template: _.template([
'<label class="<%=controlLabelClassName%>"><%=label%></label>',
'<div class="<%=controlsClassName%>">',
'<div class="<%=controlsClassName%> <%=extraClasses.join(\' \')%>">',
' <input tabindex="0" type="checkbox" data-style="quick" data-toggle="toggle"',
' data-size="<%=options.size%>" data-height="<%=options.height%>" ',
' data-on="<%=options.onText%>" data-off="<%=options.offText%>" ',
@@ -513,6 +514,10 @@ define([
$.fn.bootstrapToggle.defaults);
this.$el.html(this.template(data)).addClass(field.name);
// Add Extra Toggle classes to render multiple toggles in a single row
if(!_.isNull(field.extraToggleClasses)) this.$el.addClass(field.extraToggleClasses);
this.$input = this.$el.find('input[type=checkbox]').first();
this.$input.bootstrapToggle();
this.updateInvalid();