assets/javascripts/bookingsync/form.js in bootstrap-bookingsync-sass-1.0.3 vs assets/javascripts/bookingsync/form.js in bootstrap-bookingsync-sass-1.0.4
- old
+ new
@@ -3,18 +3,20 @@
* ========================================================================
* Copyright 2015 BookingSync SAS.
* Licensed under MIT (https://github.com/BookingSync/styleguide/blob/master/LICENSE)
* ======================================================================== */
+var setInputFilledValue = function(elt) {
+ $(elt).parents('.form-group').toggleClass('filled', !!$(elt).val());
+};
+
+function ($, document) {
'use strict';
$(document).on('DOMContentLoaded', function() {
$('.form-group .form-control').each(function (index, e) {
- if (!!$(e).val()) {
- $(e).parents('.form-group').addClass('filled');
- }
+ setInputFilledValue(e)
});
$('.checkbox input[type="checkbox"][disabled]').each(function (index, e) {
$(e).parents('.checkbox').addClass('disabled');
});
$('.radio input[type="radio"][disabled]').each(function (index, e) {
@@ -37,14 +39,12 @@
$(e.target).parents('.form-group').removeClass('focused');
}
});
$(document).on('blur', '.form-group .form-control', function (e) {
$(e.target).parents('.form-group').removeClass('focused');
-
- if (!$(e.target).val()) {
- $(e.target).parents('.form-group').removeClass('filled');
- } else {
- $(e.target).parents('.form-group').addClass('filled');
- }
+ setInputFilledValue(e.target)
+ });
+ $(document).on('change', '.select .form-group .form-control', function (e) {
+ setInputFilledValue(e.target)
});
});
}(jQuery, document);