Sha256: 5ffc1e25cd2770aacb20e4f3256ba7a1a3fb4ba71447a1e72f39de6a45ed35ea
Contents?: true
Size: 877 Bytes
Versions: 2
Compression:
Stored size: 877 Bytes
Contents
# Autogrowing textarea. class modularity.AutogrowTextArea extends modularity.Module constructor: (container) -> super @textarea = @container[0] @textarea.style.height = "auto" @textarea.style.overflow = "hidden" @container.keyup @grow @container.focus @grow @container.blur @grow # How many characters per line. @characters_per_line = this.textarea.cols # The initial (minimal) number of rows. @min_rows = this.textarea.rows @grow() # Sets the height of the textarea according to the content. grow: => @textarea.rows = Math.max modularity.AutogrowTextArea.lines(@characters_per_line, @textarea.value), @min_rows # Returns the number of lines @lines: (width, text) -> lines_count = 0 lines = text.split(/\n/) lines_count += Math.floor((line.length / width) + 1) for line in lines lines_count
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
modularity-rails-0.9.2 | vendor/assets/javascripts/modules/autogrow_textarea.coffee |
modularity-rails-0.9.1 | vendor/assets/javascripts/modules/autogrow_textarea.coffee |