1( function( $ ) { 2 3 HappyForms.parts = HappyForms.parts || {}; 4 5 HappyForms.parts.multi_line_text = { 6 init: function() { 7 this.type = this.$el.data( 'happyforms-type' ); 8 this.$input = $( 'textarea', this.$el ); 9 this.$counter = $( '.happyforms-part__char-counter span', this.$el ); 10 11 this.$input.on( 'blur', this.onBlur.bind( this ) ); 12 this.$input.on( 'keyup', this.triggerChange.bind( this ) ); 13 this.$input.on( 'change', this.triggerChange.bind( this ) ); 14 15 this.$el.on( 'keyup', this.refreshCounter.bind( this ) ); 16 this.refreshCounter(); 17 }, 18 19 getValueLength: function() { 20 var mode = this.$input.attr( 'data-length-mode' ); 21 var value = this.$input.val(); 22 var length = value.length; 23 24 if ( 'word' === mode ) { 25 var matches = value.match( /\w+/g ); 26 length = matches ? matches.length : 0; 27 } 28 29 return length; 30 }, 31 32 refreshCounter: function() { 33 var hasLength = parseInt( this.$input.attr( 'data-length' ), 10 ); 34 35 if ( hasLength < 1 ) { 36 return; 37 } 38 39 var length = this.getValueLength(); 40 this.$counter.text( length ); 41 }, 42 }; 43 44} )( 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.