Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: third_party/polymer/v0_8/components-chromium/iron-autogrow-textarea/iron-autogrow-textarea-extracted.js

Issue 1162563004: Upgrade to 1.0 and switch clients to dom-repeat where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a layout import and remove the gzipped webanimation in reproduce.sh Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>') + '&nbsp;';
+ },
+
+ _valueForMirror: function() {
+ var input = this.textarea;
+ if (!input) {
+ return;
+ }
+ this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&amp;').replace(/"/gm, '&quot;').replace(/'/gm, '&#39;').replace(/</gm, '&lt;').replace(/>/gm, '&gt;').split('\n') : [''];
+ return this._constrain(this.tokens);
+ },
+
+ _updateCached: function() {
+ this.$.mirror.innerHTML = this._constrain(this.tokens);
+ }
+ })

Powered by Google App Engine
This is Rietveld 408576698