30
app/assets/javascripts/forms/animations.js
Normal file
30
app/assets/javascripts/forms/animations.js
Normal file
@ -0,0 +1,30 @@
|
||||
var $textInput = $('[type="color"], [type="date"], [type="datetime"], [type="datetime-local"], [type="email"], [type="month"], [type="number"], [type="password"], [type="search"], [type="tel"], [type="text"], [type="time"], [type="url"], [type="week"], input:not([type]), textarea');
|
||||
|
||||
// Text Input Label Animation
|
||||
$textInput.prev('label').addClass('loaded');
|
||||
$textInput.each(function() {
|
||||
if( $(this).val() ) {
|
||||
$(this).prev('label').addClass('animate');
|
||||
}
|
||||
});
|
||||
|
||||
$textInput.on('focus', function() {
|
||||
$(this).prev('label').addClass('animate');
|
||||
}).on('focusout', function() {
|
||||
if( !$(this).val() ) {
|
||||
$(this).prev('label').removeClass('animate');
|
||||
}
|
||||
});
|
||||
|
||||
// form error resolutions
|
||||
$('form').has('.error').each(function(){
|
||||
var $form = $(this);
|
||||
|
||||
$form.on('keyup', $textInput, function(){
|
||||
$form.find(".error").addClass('resolve-error');
|
||||
});
|
||||
|
||||
$form.on('change', $("[type=radio], [type=checkbox]"), function(){
|
||||
$form.find(".error").addClass('resolve-error');
|
||||
});
|
||||
});
|
8
app/assets/javascripts/forms/button-group.js
Normal file
8
app/assets/javascripts/forms/button-group.js
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Button Group Functionality
|
||||
*/
|
||||
|
||||
$('.btn-group button').click(function() {
|
||||
$(this).siblings().removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
});
|
25
app/assets/javascripts/forms/textarea-limit.js
Normal file
25
app/assets/javascripts/forms/textarea-limit.js
Normal file
@ -0,0 +1,25 @@
|
||||
$.fn.extend({
|
||||
characterLimiter: function(limit, label) {
|
||||
this.on("keyup focus show", function() {
|
||||
setCount(this, label);
|
||||
});
|
||||
|
||||
// TODO: append label container after $this, instead of hard HTML
|
||||
function setCount(src, label) {
|
||||
if(src !== undefined) {
|
||||
var chars = src.value.length;
|
||||
if (chars >= limit) {
|
||||
src.value = src.value.substr(0, limit);
|
||||
chars = limit;
|
||||
}
|
||||
label.html(limit - chars);
|
||||
}
|
||||
}
|
||||
|
||||
setCount(this[0], label);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$('textarea').characterLimiter(1000, $(".chars span"));
|
||||
});
|
Reference in New Issue
Block a user