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

Side by Side Diff: third_party/polymer/v0_8/components-chromium/paper-input/paper-input-container-extracted.js

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also remove polymer/explainer 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 unified diff | Download patch
OLDNEW
(Empty)
1
2 (function() {
3
4 Polymer({
5
6 is: 'paper-input-container',
7
8 enableCustomStyleProperties: true,
9
10 properties: {
11
12 /**
13 * Set to true to disable the floating label.
14 */
15 noLabelFloat: {
16 type: Boolean,
17 value: false
18 },
19
20 /**
21 * The attribute to listen for value changes on.
22 */
23 attrForValue: {
24 type: String,
25 value: 'bind-value'
26 },
27
28 /**
29 * Set to true to auto-validate the input value.
30 */
31 autoValidate: {
32 type: Boolean,
33 value: false
34 },
35
36 /**
37 * True if the input has focus.
38 */
39 focused: {
40 readOnly: true,
41 type: Boolean,
42 value: false
43 },
44
45 _addons: {
46 type: Array,
47 value: function() {
48 return [];
49 }
50 },
51
52 _inputHasContent: {
53 type: Boolean,
54 value: false
55 },
56
57 _inputIsInvalid: {
58 type: Boolean,
59 value: false
60 },
61
62 _inputSelector: {
63 type: String,
64 value: 'input,textarea,.paper-input-input'
65 },
66
67 _boundOnFocus: {
68 type: Function,
69 value: function() {
70 return this._onFocus.bind(this);
71 }
72 },
73
74 _boundOnBlur: {
75 type: Function,
76 value: function() {
77 return this._onBlur.bind(this);
78 }
79 },
80
81 _boundValueChanged: {
82 type: Function,
83 value: function() {
84 return this._onValueChanged.bind(this);
85 }
86 }
87
88 },
89
90 listeners: {
91 'addon-attached': '_onAddonAttached',
92 'input': '_onInput'
93 },
94
95 get _valueChangedEvent() {
96 return this.attrForValue + '-changed';
97 },
98
99 get _propertyForValue() {
100 return Polymer.CaseMap.dashToCamelCase(this.attrForValue);
101 },
102
103 get _inputElement() {
104 return Polymer.dom(this).querySelector(this._inputSelector);
105 },
106
107 ready: function() {
108 this.addEventListener('focus', this._boundOnFocus, true);
109 this.addEventListener('blur', this._boundOnBlur, true);
110 this.addEventListener(this._valueChangedEvent, this._boundValueChanged, tr ue);
111 },
112
113 attached: function() {
114 this._handleInput(this._inputElement);
115 },
116
117 _onAddonAttached: function(event) {
118 this._addons.push(event.target);
119 this._handleInput(this._inputElement);
120 },
121
122 _onFocus: function() {
123 this._setFocused(true);
124 },
125
126 _onBlur: function() {
127 this._setFocused(false);
128 },
129
130 _onInput: function(event) {
131 this._handleInput(event.target);
132 },
133
134 _onValueChanged: function(event) {
135 this._handleInput(event.target);
136 },
137
138 _handleInput: function(inputElement) {
139 var value = inputElement[this._propertyForValue] || inputElement.value;
140 var valid = inputElement.checkValidity();
141
142 // type="number" hack needed because this.value is empty until it's valid
143 if (value || inputElement.type === 'number' && !valid) {
144 this._inputHasContent = true;
145 } else {
146 this._inputHasContent = false;
147 }
148
149 if (this.autoValidate) {
150 this._inputIsInvalid = !valid;
151 }
152
153 // notify add-ons
154 for (var addon, i = 0; addon = this._addons[i]; i++) {
155 // need to set all of these, or call method... thanks input type="number "!
156 addon.inputElement = inputElement;
157 addon.value = value;
158 addon.invalid = !valid;
159 }
160 },
161
162 _computeInputContentClass: function(noLabelFloat, focused, _inputHasContent, _inputIsInvalid) {
163 var cls = 'input-content relative';
164 if (!noLabelFloat) {
165 if (_inputHasContent) {
166 cls += ' label-is-floating';
167 if (_inputIsInvalid) {
168 cls += ' is-invalid';
169 } else if (focused) {
170 cls += " label-is-highlighted";
171 }
172 }
173 } else {
174 if (_inputHasContent) {
175 cls += ' label-is-hidden';
176 }
177 }
178 return cls;
179 },
180
181 _computeUnderlineClass: function(focused, _inputIsInvalid) {
182 var cls = 'relative';
183 if (_inputIsInvalid) {
184 cls += ' is-invalid';
185 } else if (focused) {
186 cls += ' is-highlighted'
187 }
188 return cls;
189 },
190
191 _computeAddOnContentClass: function(focused, _inputIsInvalid) {
192 var cls = 'add-on-content';
193 if (_inputIsInvalid) {
194 cls += ' is-invalid';
195 } else if (focused) {
196 cls += ' is-highlighted'
197 }
198 return cls;
199 }
200
201 });
202
203 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698