1/*! 2 * jQuery textarea autoResize plugin v0.0.2 - 2016-08-31 3 * http://github.com/kipruss/jquery-autoresize 4 * Author: Konstantin Baev for Magic Web Solutions ( http://magicwebsolutions.co.uk/ ) 5 * Licensed under the MIT license 6 */ 7 8;(function() { 9 'use strict'; 10 11 var $ = this.$, 12 13 defaults = { 14 resize: $.noop, 15 'minRows': 1, 16 'maxRows': 0 17 }; 18 19 $.fn.autoResize = function(options) { 20 var settings = $.extend({}, defaults, options); 21 22 this.filter('textarea').each(function() { 23 24 var $textarea = $(this).css({ 25 'overflow-y': 'hidden', 26 'height': 'auto', 27 'resize': 'none' 28 }); 29 30 var textarea = $textarea.get(0); 31 32 var setBaseScrollHeight = function () { 33 var savedValue = textarea.value; 34 var savedRows = textarea.rows; 35 textarea.value = ''; 36 textarea.rows = 1; 37 textarea.baseScrollHeight = textarea.scrollHeight; 38 textarea.value = savedValue; 39 textarea.rows = savedRows; 40 }; 41 42 var init = function () { 43 if (!textarea.scrollHeight) return false; 44 if (textarea.baseScrollHeight) return true; 45 setBaseScrollHeight(); 46 return true; 47 }; 48 49 var setRows = function () { 50 if (!init()) return false; 51 var lineHeight = parseFloat($textarea.css('line-height')); 52 textarea.rows = settings.minRows; 53 var rows = Math.round((textarea.scrollHeight - textarea.baseScrollHeight) / lineHeight) + 1; 54 if (settings.maxRows > settings.minRows && rows > settings.maxRows) { 55 textarea.rows = settings.maxRows; 56 $textarea.css({ 'overflow-y': 'auto' }); 57 } else { 58 textarea.rows = Math.max(rows, settings.minRows); 59 $textarea.css({ 'overflow-y': 'hidden' }); 60 } 61 }; 62 63 if (!textarea.rows || textarea.rows < settings.minRows) { 64 textarea.rows = settings.minRows; 65 } 66 $textarea.off('.resize'); 67 68 if (supportsInputEvent()) { 69 $textarea.on('input.resize', setRows); 70 } else if (supportsPropertyChangeEvent()) { 71 $textarea.on('propertychange.resize', setRows); 72 } else { 73 $textarea.on('keypress.resize', setRows); 74 } 75 $textarea.one('focus', setRows); 76 setRows(); 77 }); 78 79 return this; 80 }; 81 82 function supportsInputEvent() { 83 if ('oninput' in document.body) { 84 return true; 85 } 86 87 document.body.setAttribute('oninput', 'return'); 88 89 var supports = typeof document.body.oninput === 'function'; 90 delete document.body.oninput; 91 return supports; 92 } 93 94 function supportsPropertyChangeEvent() { 95 return 'onpropertychange' in document.body; 96 } 97 98}).call(this);
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.