OLD | NEW |
| (Empty) |
1 | |
2 | |
3 (function() { | |
4 | |
5 Polymer({ | |
6 | |
7 is: 'paper-input-char-counter', | |
8 | |
9 behaviors: [ | |
10 Polymer.PaperInputAddonBehavior | |
11 ], | |
12 | |
13 properties: { | |
14 | |
15 _charCounterStr: { | |
16 type: String, | |
17 value: '0' | |
18 } | |
19 | |
20 }, | |
21 | |
22 update: function(state) { | |
23 if (!state.inputElement) { | |
24 return; | |
25 } | |
26 | |
27 state.value = state.value || ''; | |
28 | |
29 // Account for the textarea's new lines. | |
30 var str = state.value.replace(/(\r\n|\n|\r)/g, '--').length; | |
31 | |
32 if (state.inputElement.hasAttribute('maxlength')) { | |
33 str += '/' + state.inputElement.getAttribute('maxlength'); | |
34 } | |
35 this._charCounterStr = str; | |
36 } | |
37 | |
38 }); | |
39 | |
40 })(); | |
41 | |
OLD | NEW |