PageSourceSearch

https://www.army-shop.cz/admin/js/jquery-ensure-max-length.min.js

js army-shop.cz collected 2026-10-02 21:21:04 UTC 1,520 bytes, 60 lines download raw bytes

1;( function ( $, undefined ) {
2	var defaults = { 
3		limit: 100,	
4		cssClass: '',
5		separator: '/',
6		placement: null
7	};
8	
9	function Plugin ( element, options ) {
10		this.element = $( element );
11		this.options = $.extend( {}, defaults, options );
12		this.$counter = $( '<small />' ).addClass( this.options.cssClass );
13		this.init();
14	}
15	
16	Plugin.prototype.init = function () {
17		var _self = this;
18		
19		this.showCount();
20		this.addMaxlengthAttribute();
21		this.element.on( 'keyup blur', function () {
22			_self.checkLength.call( _self, this );
23		});
24	};
25	
26	Plugin.prototype.addMaxlengthAttribute = function () {
27		this.element.attr('maxlength', this.options.limit);
28	};
29	
30	Plugin.prototype.showCount = function () {	
31		if ( this.options.placement ) this.$counter.appendTo( this.options.placement );
32		else this.$counter.insertAfter( this.element );
33
34		this.checkLength();
35	};
36	
37	Plugin.prototype.updateCountData = function ( count ) {
38		var text = count + this.options.separator + this.options.limit;
39		this.$counter.text( text );
40	};
41	
42	Plugin.prototype.checkLength = function () {
43		var val = this.element.val(), count = val.length;
44		
45		if ( count > this.options.limit ) {
46			this.element.val( val.substring( 0, this.options.limit ) );
47			count = this.options.limit;
48		}
49		
50		this.updateCountData( count );
51	};
52	
53	$.fn.EnsureMaxLength = function ( options ) {
54		return this.each( function () {
55			if ( ! $.data( this, "plugin" ) ) {
56				$.data( this, "plugin", new Plugin( this, options ) );
57			}
58		});
59	};
60} ( jQuery ));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.