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

Side by Side Diff: third_party/polymer/components-chromium/paper-input/paper-autogrow-textarea-extracted.js

Issue 1215543002: Remove Polymer 0.5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit test Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1
2
3 Polymer('paper-autogrow-textarea',{
4
5 publish: {
6
7 /**
8 * The textarea that should auto grow.
9 *
10 * @attribute target
11 * @type HTMLTextAreaElement
12 * @default null
13 */
14 target: null,
15
16 /**
17 * The initial number of rows.
18 *
19 * @attribute rows
20 * @type number
21 * @default 1
22 */
23 rows: 1,
24
25 /**
26 * The maximum number of rows this element can grow to until it
27 * scrolls. 0 means no maximum.
28 *
29 * @attribute maxRows
30 * @type number
31 * @default 0
32 */
33 maxRows: 0
34 },
35
36 tokens: null,
37
38 observe: {
39 rows: 'updateCached',
40 maxRows: 'updateCached'
41 },
42
43 constrain: function(tokens) {
44 var _tokens;
45 tokens = tokens || [''];
46 // Enforce the min and max heights for a multiline input to avoid measurem ent
47 if (this.maxRows > 0 && tokens.length > this.maxRows) {
48 _tokens = tokens.slice(0, this.maxRows);
49 } else {
50 _tokens = tokens.slice(0);
51 }
52 while (this.rows > 0 && _tokens.length < this.rows) {
53 _tokens.push('');
54 }
55 return _tokens.join('<br>') + '&nbsp;';
56 },
57
58 valueForMirror: function(input) {
59 this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&amp;') .replace(/"/gm, '&quot;').replace(/'/gm, '&#39;').replace(/</gm, '&lt;').replace (/>/gm, '&gt;').split('\n') : [''];
60 return this.constrain(this.tokens);
61 },
62
63 /**
64 * Sizes this element to fit the input value. This function is automatically called
65 * when the user types in new input, but you must call this function if the value
66 * is updated imperatively.
67 *
68 * @method update
69 * @param Element The input
70 */
71 update: function(input) {
72 this.$.mirror.innerHTML = this.valueForMirror(input);
73 },
74
75 updateCached: function() {
76 this.$.mirror.innerHTML = this.constrain(this.tokens);
77 },
78
79 inputAction: function(e) {
80 this.update(e.target);
81 }
82
83 });
84
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698