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

Side by Side Diff: third_party/polymer/v0_8/components-chromium/paper-input/paper-input-char-counter-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, 6 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
1 1
2 2
3 (function() { 3 (function() {
4 4
5 Polymer({ 5 Polymer({
6 6
7 is: 'paper-input-char-counter', 7 is: 'paper-input-char-counter',
8 8
9 enableCustomStyleProperties: true, 9 behaviors: [
10 10 Polymer.PaperInputAddonBehavior
11 hostAttributes: { 11 ],
12 'add-on': ''
13 },
14 12
15 properties: { 13 properties: {
16 14
17 /** 15 _charCounterStr: {
18 * The associated input element. 16 type: String,
19 */ 17 value: '0'
20 inputElement: {
21 type: Object
22 },
23
24 /**
25 * The current value of the input element.
26 */
27 value: {
28 type: String
29 },
30
31 /**
32 * The character counter string.
33 */
34 charCounter: {
35 computed: '_computeCharCounter(inputElement,value)',
36 type: String
37 } 18 }
38 19
39 }, 20 },
40 21
41 attached: function() { 22 update: function(state) {
42 this.fire('addon-attached'); 23 if (!state.inputElement) {
43 }, 24 return;
25 }
44 26
45 _computeCharCounter: function(inputElement,value) { 27 state.value = state.value || '';
46 var str = value.length; 28
47 if (inputElement.hasAttribute('maxlength')) { 29 // Account for the textarea's new lines.
48 str += '/' + inputElement.maxLength; 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');
49 } 34 }
50 return str; 35 this._charCounterStr = str;
51 } 36 }
52 37
53 }); 38 });
54 39
55 })(); 40 })();
56 41
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698