| Index: third_party/polymer/v0_8/components-chromium/iron-autogrow-textarea/iron-autogrow-textarea-extracted.js
|
| diff --git a/third_party/polymer/v0_8/components-chromium/iron-autogrow-textarea/iron-autogrow-textarea-extracted.js b/third_party/polymer/v0_8/components-chromium/iron-autogrow-textarea/iron-autogrow-textarea-extracted.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..70ed2093d7fb56567c17deaa5a0c5531af8d766c
|
| --- /dev/null
|
| +++ b/third_party/polymer/v0_8/components-chromium/iron-autogrow-textarea/iron-autogrow-textarea-extracted.js
|
| @@ -0,0 +1,130 @@
|
| +
|
| +
|
| + Polymer({
|
| +
|
| + is: 'iron-autogrow-textarea',
|
| +
|
| + behaviors: [
|
| + Polymer.IronValidatableBehavior
|
| + ],
|
| +
|
| + properties: {
|
| +
|
| + /**
|
| + * Use this property instead of `value` for two-way data binding.
|
| + */
|
| + bindValue: {
|
| + observer: '_bindValueChanged',
|
| + type: String
|
| + },
|
| +
|
| + /**
|
| + * The initial number of rows.
|
| + *
|
| + * @attribute rows
|
| + * @type number
|
| + * @default 1
|
| + */
|
| + rows: {
|
| + type: Number,
|
| + value: 1,
|
| + observer: '_updateCached'
|
| + },
|
| +
|
| + /**
|
| + * The maximum number of rows this element can grow to until it
|
| + * scrolls. 0 means no maximum.
|
| + *
|
| + * @attribute maxRows
|
| + * @type number
|
| + * @default 0
|
| + */
|
| + maxRows: {
|
| + type: Number,
|
| + value: 0,
|
| + observer: '_updateCached'
|
| + },
|
| +
|
| + /**
|
| + * Set to true to mark the textarea as required.
|
| + */
|
| + required: {
|
| + type: Boolean
|
| + },
|
| +
|
| + /**
|
| + * The maximum length of the input value.
|
| + */
|
| + maxlength: {
|
| + type: Number
|
| + }
|
| +
|
| + },
|
| +
|
| + listeners: {
|
| + 'input': '_onInput'
|
| + },
|
| +
|
| + /**
|
| + * Returns the underlying textarea.
|
| + */
|
| + get textarea() {
|
| + return this.$.textarea;
|
| + },
|
| +
|
| + _update: function() {
|
| + this.$.mirror.innerHTML = this._valueForMirror();
|
| +
|
| + var textarea = this.textarea;
|
| + // If the value of the textarea was updated imperatively, then we
|
| + // need to manually update bindValue as well.
|
| + if (textarea && this.bindValue != textarea.value) {
|
| + this.bindValue = textarea.value;
|
| + }
|
| + },
|
| +
|
| + _bindValueChanged: function() {
|
| + var textarea = this.textarea;
|
| + if (!textarea) {
|
| + return;
|
| + }
|
| +
|
| + textarea.value = this.bindValue;
|
| + this._update();
|
| + // manually notify because we don't want to notify until after setting value
|
| + this.fire('bind-value-changed', {value: this.bindValue});
|
| + },
|
| +
|
| + _onInput: function(event) {
|
| + this.bindValue = event.path ? event.path[0].value : event.target.value;
|
| + this._update();
|
| + },
|
| +
|
| + _constrain: function(tokens) {
|
| + var _tokens;
|
| + tokens = tokens || [''];
|
| + // Enforce the min and max heights for a multiline input to avoid measurement
|
| + if (this.maxRows > 0 && tokens.length > this.maxRows) {
|
| + _tokens = tokens.slice(0, this.maxRows);
|
| + } else {
|
| + _tokens = tokens.slice(0);
|
| + }
|
| + while (this.rows > 0 && _tokens.length < this.rows) {
|
| + _tokens.push('');
|
| + }
|
| + return _tokens.join('<br>') + ' ';
|
| + },
|
| +
|
| + _valueForMirror: function() {
|
| + var input = this.textarea;
|
| + if (!input) {
|
| + return;
|
| + }
|
| + this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&').replace(/"/gm, '"').replace(/'/gm, ''').replace(/</gm, '<').replace(/>/gm, '>').split('\n') : [''];
|
| + return this._constrain(this.tokens);
|
| + },
|
| +
|
| + _updateCached: function() {
|
| + this.$.mirror.innerHTML = this._constrain(this.tokens);
|
| + }
|
| + })
|
|
|