Created
May 5, 2016 17:23
-
-
Save nishanmiranda/9b022e0e9790bb7fdfe0a49e9bf1be2b to your computer and use it in GitHub Desktop.
autoexpand-textarea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.TextArea.extend({ | |
rows: 2, | |
keyDown(ev) { | |
let keyCode = ev.keyCode; | |
if (keyCode === 8 || keyCode === 45) { | |
this.$().attr('rows', 2); | |
} | |
}, | |
didInsertElement() { | |
this._super(...arguments); | |
let $this = this.$(); | |
let rows = this.get('rows') || '2'; | |
this.initialPaddingTop = parseInt($this.css('padding-top'), 10); | |
this.initialPaddingBottom = parseInt($this.css('padding-bottom'), 10); | |
this.initialHeightPerRow = ( this.element.clientHeight - this.initialPaddingTop - this.initialPaddingBottom ) / Number(rows); | |
this.input(); | |
}, | |
input() { | |
let rows = ((this.element.scrollHeight - this.initialPaddingTop - this.initialPaddingBottom) / this.initialHeightPerRow).toFixed(0); | |
this.$().attr('rows', rows); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.8.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.5.1", | |
"ember-data": "2.5.2", | |
"ember-template-compiler": "2.5.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment