[
  {
    "path": ".gitignore",
    "content": "node_modules\r\n"
  },
  {
    "path": ".npmignore",
    "content": "bower_components/\nbower.json\nnode_modules/\nnpm-debug.log\ngulpfile.cofee\nsrc/\n.github\n"
  },
  {
    "path": "README.md",
    "content": "### Automatically adjust textarea width/height based on user input.\r\n#### Non-sucking version, still works great and used by a lot of people with no issues! Yes, it is old, but it works!\r\n\r\n\r\nThe only reason I wrote this jQuery plugin is that other plugins suck. They are wide-spread, but outdated and buggy.\r\n\r\nAdvantages of jquery.ns-autogrow:\r\n\r\n* Grows vertically, horizontally or both\r\n* Correctly handles 2 or more spaces\r\n* Copies more css and font styles to shadow div\r\n* Correctly handles long words on one line\r\n* Flickering can be disabled on Enter\r\n* Doesn't add more than one handler to textarea\r\n* Handles textarea scrollbar if any\r\n* Improved support of special characters\r\n\r\n## Download\r\nRun one of these commands in your bash according to your needs.\r\n\r\n`git clone https://github.com/ro31337/jquery.ns-autogrow.git`\r\n\r\n`bower install jquery.ns-autogrow`\r\n\r\n`npm install jquery.ns-autogrow`\r\n\r\nOr download the latest version from the [releases](https://github.com/ro31337/jquery.ns-autogrow/releases) page.\r\n\r\n### Options\r\n\r\nYou can provide multiple options to autogrow like:\r\n\r\n```\r\n  $('.example2 textarea').autogrow({vertical: true, horizontal: false});\r\n```\r\n\r\nList of options:\r\n\r\nOption | Description\r\n-------|------------\r\nvertical | (true/false) - Enable/Disable vertical autogrow (true by default)\r\nhorizontal | (true/false) - Enable/Disable horizontal autogrow (true by default)\r\npostGrowCallback | Post grow callback. Executes after dimensions of textarea have been adjusted.\r\nflickering | (true/false) - Enable/Disable flickering. If flickering is disabled, extra line will be added to textarea. Flickering is _enabled_ by default.\r\n\r\nThere are few more options reserved for debugging purposes. All debugging options start with `debug` prefix:\r\n\r\nOption | Description\r\n-------|------------\r\ndebugx | X position of shadow element (-10000 by default)\r\ndebugy | Y position of shadow element (-10000 by default)\r\ndebugcolor | Color of shadow element (yellow by default)\r\n\r\n\r\n### Demo\r\n\r\n[Click here](http://htmlpreview.github.io/?https://raw.githubusercontent.com/ro31337/jquery.ns-autogrow/master/demo/index.html)\r\n\r\n### Plans:\r\n\r\n* Test and support arabic languages\r\n\r\n### :heart: Like it? :heart:\r\n\r\n:star: Star it! :star:\r\n\r\n### The MIT License (MIT)\r\n\r\nThe MIT License (MIT)\r\n\r\nCopyright (c) 2015 Roman Pushkin\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n"
  },
  {
    "path": "bower.json",
    "content": "{\n  \"name\": \"jquery.ns-autogrow\",\n  \"description\": \"Automatically adjust textarea height based on user input. Non-sucking version.\",\n  \"main\": \"dist/jquery.ns-autogrow.js\",\n  \"keywords\": [\n    \"autogrow\",\n    \"textarea\",\n    \"form\",\n    \"autosize\",\n    \"ui\",\n    \"jquery-plugin\",\n    \"ecosystem:jquery\"\n  ],\n  \"author\": \"Roman Pushkin <roman.pushkin@gmail.com>\",\n  \"homepage\": \"https://github.com/ro31337/jquery.ns-autogrow\",\n  \"license\": \"MIT\",\n  \"ignore\": [\n    \"**/.*\",\n    \"bower_components\",\n    \"node_modules\",\n    \"npm-debug.log\",\n    \"gulpfile.coffee\",\n    \"package.json\",\n    \"src\"\n  ],\n  \"dependencies\": {\n    \"jquery\": \"1\"\n  }\n}\n"
  },
  {
    "path": "demo/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n  <head>\n    <script data-require=\"jquery@2.1.4\" data-semver=\"2.1.4\" src=\"http://code.jquery.com/jquery-2.1.4.min.js\"></script>\n    <script src=\"../dist/jquery.ns-autogrow.min.js\"></script>\n    <link rel=\"stylesheet\" href=\"http://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css\" />\n    <link rel=\"stylesheet\" href=\"style.css\" />\n    <script src=\"script.js\"></script>\n  </head>\n\n  <body>\n    <div class=\"example1\">\n      <textarea placeholder=\"horizontal and vertical\"></textarea>\n    </div>\n\n    <div class=\"example2\">\n      <textarea placeholder=\"vertical only\"></textarea>\n    </div>\n\n    <div class=\"example3\">\n      <textarea placeholder=\"horizontal only\"></textarea>\n    </div>\n\n    <div class=\"example4\">\n      <textarea placeholder=\"horizontal and vertical, no flickering\"></textarea>\n    </div>\n\n  </body>\n\n</html>\n"
  },
  {
    "path": "demo/script.js",
    "content": "$(function(){\n  $('.example1 textarea').autogrow();\n  $('.example2 textarea').autogrow({vertical: true, horizontal: false});\n  $('.example3 textarea').autogrow({vertical: false, horizontal: true});\n  $('.example4 textarea').autogrow({flickering: false});\n});\n"
  },
  {
    "path": "demo/style.css",
    "content": "body { padding: 20px; }\ntextarea { min-width: 240px; font-size: 18px; }\n.example3 textarea { min-height: 50px; }\n"
  },
  {
    "path": "dist/jquery.ns-autogrow.js",
    "content": "/*!\n  Non-Sucking Autogrow 1.1.6\n  license: MIT\n  author: Roman Pushkin\n  https://github.com/ro31337/jquery.ns-autogrow\n*/\n(function() {\n  var getVerticalScrollbarWidth;\n\n  (function($, window) {\n    return $.fn.autogrow = function(options) {\n      if (options == null) {\n        options = {};\n      }\n      if (options.horizontal == null) {\n        options.horizontal = true;\n      }\n      if (options.vertical == null) {\n        options.vertical = true;\n      }\n      if (options.debugx == null) {\n        options.debugx = -10000;\n      }\n      if (options.debugy == null) {\n        options.debugy = -10000;\n      }\n      if (options.debugcolor == null) {\n        options.debugcolor = 'yellow';\n      }\n      if (options.flickering == null) {\n        options.flickering = true;\n      }\n      if (options.postGrowCallback == null) {\n        options.postGrowCallback = function() {};\n      }\n      if (options.verticalScrollbarWidth == null) {\n        options.verticalScrollbarWidth = getVerticalScrollbarWidth();\n      }\n      if (options.horizontal === false && options.vertical === false) {\n        return;\n      }\n      return this.filter('textarea').each(function() {\n        var $e, $shadow, fontSize, heightPadding, minHeight, minWidth, update;\n        $e = $(this);\n        if ($e.data('autogrow-enabled')) {\n          return;\n        }\n        $e.data('autogrow-enabled');\n        minHeight = $e.height();\n        minWidth = $e.width();\n        heightPadding = $e.css('lineHeight') * 1 || 0;\n        $e.hasVerticalScrollBar = function() {\n          return $e[0].clientHeight < $e[0].scrollHeight;\n        };\n        $shadow = $('<div class=\"autogrow-shadow\"></div>').css({\n          position: 'absolute',\n          display: 'inline-block',\n          'background-color': options.debugcolor,\n          top: options.debugy,\n          left: options.debugx,\n          'max-width': $e.css('max-width'),\n          'padding': $e.css('padding'),\n          fontSize: $e.css('fontSize'),\n          fontFamily: $e.css('fontFamily'),\n          fontWeight: $e.css('fontWeight'),\n          lineHeight: $e.css('lineHeight'),\n          resize: 'none',\n          'word-wrap': 'break-word'\n        }).appendTo(document.body);\n        if (options.horizontal === false) {\n          $shadow.css({\n            'width': $e.width()\n          });\n        } else {\n          fontSize = $e.css('font-size');\n          $shadow.css('padding-right', '+=' + fontSize);\n          $shadow.normalPaddingRight = $shadow.css('padding-right');\n        }\n        update = (function(_this) {\n          return function(event) {\n            var height, val, width;\n            val = _this.value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\\n /g, '<br/>&nbsp;').replace(/\"/g, '&quot;').replace(/'/g, '&#39;').replace(/\\n$/, '<br/>&nbsp;').replace(/\\n/g, '<br/>').replace(/ {2,}/g, function(space) {\n              return Array(space.length - 1).join('&nbsp;') + ' ';\n            });\n            if (/(\\n|\\r)/.test(_this.value)) {\n              val += '<br />';\n              if (options.flickering === false) {\n                val += '<br />';\n              }\n            }\n            $shadow.html(val);\n            if (options.vertical === true) {\n              height = Math.max($shadow.height() + heightPadding, minHeight);\n              $e.height(height);\n            }\n            if (options.horizontal === true) {\n              $shadow.css('padding-right', $shadow.normalPaddingRight);\n              if (options.vertical === false && $e.hasVerticalScrollBar()) {\n                $shadow.css('padding-right', \"+=\" + options.verticalScrollbarWidth + \"px\");\n              }\n              width = Math.max($shadow.outerWidth(), minWidth);\n              $e.width(width);\n            }\n            return options.postGrowCallback($e);\n          };\n        })(this);\n        $e.change(update).keyup(update).keydown(update);\n        $(window).resize(update);\n        return update();\n      });\n    };\n  })(window.jQuery, window);\n\n  getVerticalScrollbarWidth = function() {\n    var inner, outer, w1, w2;\n    inner = document.createElement('p');\n    inner.style.width = \"100%\";\n    inner.style.height = \"200px\";\n    outer = document.createElement('div');\n    outer.style.position = \"absolute\";\n    outer.style.top = \"0px\";\n    outer.style.left = \"0px\";\n    outer.style.visibility = \"hidden\";\n    outer.style.width = \"200px\";\n    outer.style.height = \"150px\";\n    outer.style.overflow = \"hidden\";\n    outer.appendChild(inner);\n    document.body.appendChild(outer);\n    w1 = inner.offsetWidth;\n    outer.style.overflow = 'scroll';\n    w2 = inner.offsetWidth;\n    if (w1 === w2) {\n      w2 = outer.clientWidth;\n    }\n    document.body.removeChild(outer);\n    return w1 - w2;\n  };\n\n}).call(this);\n"
  },
  {
    "path": "gulpfile.coffee",
    "content": "gulp = require 'gulp'\r\ndel = require 'del'\r\ncoffee = require 'gulp-coffee'\r\ncoffeelint = require 'gulp-coffeelint'\r\nheader = require 'gulp-header'\r\nuglify = require 'gulp-uglify'\r\nrename = require 'gulp-rename'\r\npjson = require './package.json'\r\ncopyright = \"\"\"\r\n/*!\r\n  Non-Sucking Autogrow #{pjson.version}\r\n  license: #{pjson.license}\r\n  author: Roman Pushkin\r\n  #{pjson.homepage}\r\n*/\r\n\r\n\"\"\"\r\n\r\ndest = 'dist/'\r\nsource = 'src/'\r\ncode =\r\n  in: \"#{source}*.coffee\"\r\n  out: \"#{dest}\"\r\n\r\ngulp.task 'clean', ->\r\n  del [dest + '*']\r\n\r\ngulp.task 'build', ->\r\n  gulp\r\n    .src code.in\r\n    .pipe coffeelint()\r\n    .pipe coffeelint.reporter() # Show coffeelint errors\r\n    .pipe coffeelint.reporter('fail') # Make sure it fails in case of error\r\n    .pipe coffee()\r\n    .pipe header copyright\r\n    .pipe gulp.dest(code.out)\r\n\r\n  gulp\r\n    .src code.in\r\n    .pipe coffeelint()\r\n    .pipe coffeelint.reporter() # Show coffeelint errors\r\n    .pipe coffeelint.reporter('fail') # Make sure it fails in case of error\r\n    .pipe coffee()\r\n    .pipe uglify()\r\n    .pipe rename({ suffix: '.min' })\r\n    .pipe header copyright\r\n    .pipe gulp.dest(code.out)\r\n\r\ngulp.task 'watch', ->\r\n  gulp\r\n    .watch code.in, ['build']\r\n\r\ngulp.task 'default', ['clean', 'build', 'watch'], ->\r\n  \r\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"jquery.ns-autogrow\",\n  \"version\": \"1.1.6\",\n  \"description\": \"Automatically adjust textarea height based on user input. Non-sucking version.\",\n  \"main\": \"dist/jquery.ns-autogrow.js\",\n  \"keywords\": [\n    \"autogrow\",\n    \"textarea\",\n    \"form\",\n    \"autosize\",\n    \"ui\",\n    \"jquery-plugin\",\n    \"ecosystem:jquery\"\n  ],\n  \"author\": \"Roman Pushkin <roman.pushkin@gmail.com>\",\n  \"homepage\": \"https://github.com/ro31337/jquery.ns-autogrow\",\n  \"license\": \"MIT\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/ro31337/jquery.ns-autogrow.git\"\n  },\n  \"files\": [\n    \"demo\",\n    \"dist\"\n  ],\n  \"directories\": {\n    \"example\": \"demo\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/ro31337/jquery.ns-autogrow/issues\"\n  },\n  \"dependencies\": {\n    \"jquery\": \"^1.12.4\"\n  },\n  \"devDependencies\": {\n    \"coffee-script\": \"^1.10.0\",\n    \"del\": \"^2.0.2\",\n    \"gulp\": \"^3.9.0\",\n    \"gulp-coffee\": \"^2.3.1\",\n    \"gulp-coffeelint\": \"^0.5.0\",\n    \"gulp-header\": \"^1.7.1\",\n    \"gulp-rename\": \"^1.2.2\",\n    \"gulp-uglify\": \"^1.4.1\"\n  }\n}\n"
  },
  {
    "path": "src/jquery.ns-autogrow.coffee",
    "content": "(($, window) ->\r\n\r\n  $.fn.autogrow = (options) ->\r\n    options            ?= {}\r\n    options.horizontal ?= true\r\n    options.vertical   ?= true\r\n    options.debugx     ?= -10000\r\n    options.debugy     ?= -10000\r\n    options.debugcolor ?= 'yellow'\r\n    options.flickering ?= true\r\n    options.postGrowCallback ?= ->\r\n    options.verticalScrollbarWidth ?= getVerticalScrollbarWidth()\r\n\r\n    if options.horizontal is false and options.vertical is false\r\n      return\r\n\r\n    @.filter('textarea').each ->\r\n\r\n      $e = $(@)\r\n\r\n      return if $e.data 'autogrow-enabled'\r\n      $e.data 'autogrow-enabled'\r\n\r\n      minHeight     = $e.height()\r\n      minWidth      = $e.width()\r\n      heightPadding = $e.css('lineHeight') * 1 || 0\r\n      $e.hasVerticalScrollBar = ->\r\n        $e[0].clientHeight < $e[0].scrollHeight\r\n\r\n      $shadow = $('<div class=\"autogrow-shadow\"></div>')\r\n        .css (\r\n          position:           'absolute'\r\n          display:            'inline-block'\r\n          'background-color': options.debugcolor\r\n          top:                options.debugy\r\n          left:               options.debugx\r\n          'max-width':        $e.css 'max-width'\r\n          'padding':          $e.css 'padding'\r\n          fontSize:           $e.css 'fontSize'\r\n          fontFamily:         $e.css 'fontFamily'\r\n          fontWeight:         $e.css 'fontWeight'\r\n          lineHeight:         $e.css 'lineHeight'\r\n          resize:             'none'\r\n          'word-wrap':        'break-word' )\r\n        .appendTo document.body\r\n\r\n      if options.horizontal is false\r\n        # fix width of shadow div, so it will remain unchanged\r\n        $shadow.css({'width': $e.width()})\r\n      else\r\n        # make sure we have right padding to avoid flickering\r\n        fontSize = $e.css 'font-size' # => 20px\r\n        $shadow.css('padding-right', '+=' + fontSize)\r\n        $shadow.normalPaddingRight = $shadow.css 'padding-right'\r\n\r\n      update = (event) =>\r\n        val = @\r\n          .value\r\n          .replace /&/g,   '&amp;'\r\n          .replace /</g,   '&lt;'\r\n          .replace />/g,   '&gt;'\r\n          .replace /\\n /g, '<br/>&nbsp;'\r\n          .replace /\"/g,   '&quot;'\r\n          .replace /'/g,   '&#39;'\r\n          .replace /\\n$/,  '<br/>&nbsp;'\r\n          .replace /\\n/g,  '<br/>'\r\n          .replace(\r\n            / {2,}/g\r\n            (space) -> Array(space.length - 1).join('&nbsp;') + ' '\r\n          )\r\n\r\n        if /(\\n|\\r)/.test @.value\r\n          val += '<br />'\r\n\r\n          # no flickering, but one extra line will be added\r\n          if options.flickering is false\r\n            val += '<br />'\r\n\r\n        $shadow.html val\r\n\r\n        if options.vertical is true\r\n          height = Math.max($shadow.height() + heightPadding, minHeight)\r\n          $e.height height\r\n\r\n        if options.horizontal is true\r\n          $shadow.css 'padding-right', $shadow.normalPaddingRight\r\n\r\n          # if it should not grow vertically and if we have scrollbar,\r\n          # add additional padding to shadow div to emulate the scrollbar\r\n          if options.vertical is false and $e.hasVerticalScrollBar()\r\n            $shadow.css 'padding-right', \"+=#{options.verticalScrollbarWidth}px\"\r\n\r\n          # outerWidth is width with padding\r\n          width = Math.max $shadow.outerWidth(), minWidth\r\n          $e.width width\r\n\r\n        options.postGrowCallback $e\r\n\r\n      $e.change  update\r\n        .keyup   update\r\n        .keydown update\r\n\r\n      $(window).resize update\r\n      update()\r\n\r\n) window.jQuery, window\r\n\r\ngetVerticalScrollbarWidth = ->\r\n  inner = document.createElement('p')\r\n  inner.style.width = \"100%\"\r\n  inner.style.height = \"200px\"\r\n\r\n  outer = document.createElement('div')\r\n  outer.style.position = \"absolute\"\r\n  outer.style.top = \"0px\"\r\n  outer.style.left = \"0px\"\r\n  outer.style.visibility = \"hidden\"\r\n  outer.style.width = \"200px\"\r\n  outer.style.height = \"150px\"\r\n  outer.style.overflow = \"hidden\"\r\n  outer.appendChild (inner)\r\n\r\n  document.body.appendChild (outer)\r\n  w1 = inner.offsetWidth\r\n  outer.style.overflow = 'scroll'\r\n  w2 = inner.offsetWidth\r\n  if w1 is w2\r\n    w2 = outer.clientWidth\r\n\r\n  document.body.removeChild (outer)\r\n  w1 - w2\r\n"
  }
]