Sha256: 8cb6889426373f64154893841b8c3658de89b7a751cb497fd08312dce82415ff
Contents?: true
Size: 1.2 KB
Versions: 66
Compression:
Stored size: 1.2 KB
Contents
(($) -> $.fn.extend limit: -> $(this).each (i, e) -> input = $(this) limit = $(this).data("limit") label = $(this).closest("*:has(label)").find("label") horizontal = ($(this).closest(".form-horizontal").length > 0) counter = undefined counter = $("<span class=\"badge badge-info badge-mini\" data-tip=\"Caratteri disponibili\">" + limit + "</span>") if horizontal label.append "<br/>" else label.append " " label.append counter element = counter interval = undefined f = undefined self = $(this) $(this).focus -> interval = window.setInterval(substring, 100) $(this).blur -> clearInterval interval substring() substringFunction = "function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}" substringFunction += "if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}" unless typeof element is "undefined" substringFunction += "}" eval substringFunction substring() ) jQuery
Version data entries
66 entries across 66 versions & 1 rubygems