1/** 2 * jQuery flexText: Auto-height textareas 3 * -------------------------------------- 4 * Requires: jQuery 1.7+ 5 * Usage example: $('textarea').flexText() 6 * Info: https://github.com/alexdunphy/flexible-textareas 7 */ 8 9;(function ($) { 10 11 // Constructor 12 function FT(elem) { 13 this.$textarea = $(elem); 14 15 this._init(); 16 } 17 18 FT.prototype = { 19 _init: function () { 20 var _this = this; 21 22 // Insert wrapper elem & pre/span for textarea mirroring 23 this.$textarea.wrap('<div class="flex-text-wrap" />').before('<pre><span /><br /><br /></pre>'); 24 25 this.$span = this.$textarea.prev().find('span'); 26 27 // Add input event listeners 28 // * input for modern browsers 29 // * propertychange for IE 7 & 8 30 // * keyup for IE >= 9: catches keyboard-triggered undos/cuts/deletes 31 // * change for IE >= 9: catches mouse-triggered undos/cuts/deletions (when textarea loses focus) 32 this.$textarea.on('input propertychange keyup change', function () { 33 _this._mirror(); 34 }); 35 36 // jQuery val() strips carriage return chars by default (see http://api.jquery.com/val/) 37 // This causes issues in IE7, but a valHook can be used to preserve these chars 38 $.valHooks.textarea = { 39 get: function (elem) { 40 return elem.value.replace(/\r?\n/g, "\r\n"); 41 } 42 }; 43 44 // Mirror contents once on init 45 this._mirror(); 46 } 47 48 // Mirror pre/span & textarea contents 49 ,_mirror: function () { 50 this.$span.text(this.$textarea.val()); 51 } 52 }; 53 54 // jQuery plugin wrapper 55 $.fn.flexText = function () { 56 return this.each(function () { 57 // Check if already instantiated on this elem 58 if (!$.data(this, 'flexText')) { 59 // Instantiate & store elem + string 60 $.data(this, 'flexText', new FT(this)); 61 } 62 }); 63 }; 64 65})(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.