30 lines
372 B
JavaScript
30 lines
372 B
JavaScript
|
//
|
||
|
// Form control
|
||
|
//
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
var FormControl = (function() {
|
||
|
|
||
|
// Variables
|
||
|
|
||
|
var $input = $('.form-control');
|
||
|
|
||
|
|
||
|
// Methods
|
||
|
|
||
|
function init($this) {
|
||
|
$this.on('focus blur', function(e) {
|
||
|
$(this).parents('.form-group').toggleClass('focused', (e.type === 'focus'));
|
||
|
}).trigger('blur');
|
||
|
}
|
||
|
|
||
|
|
||
|
// Events
|
||
|
|
||
|
if ($input.length) {
|
||
|
init($input);
|
||
|
}
|
||
|
|
||
|
})();
|