organized js assets

completes #11
This commit is contained in:
Mark Moser
2016-09-07 17:45:22 -05:00
parent a977c0ceb3
commit 1ded44610b
16 changed files with 38 additions and 14 deletions

View 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"));
});