polymer-paper-rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +69 -0
  3. data/Rakefile +1 -0
  4. data/app/assets/components/core/animation/web-animations.html.erb +1 -0
  5. data/app/assets/components/core/animation/web-animations.js +5666 -0
  6. data/app/assets/components/core/icon/core-icon.css +25 -0
  7. data/app/assets/components/core/icon/core-icon.html.erb +126 -0
  8. data/app/assets/components/core/iconset/core-iconset.html.erb +236 -0
  9. data/app/assets/components/core/input/core-input.css +35 -0
  10. data/app/assets/components/core/input/core-input.html.erb +385 -0
  11. data/app/assets/components/core/list/core-list.css +20 -0
  12. data/app/assets/components/core/list/core-list.html.erb +403 -0
  13. data/app/assets/components/core/media-query/core-media-query.html +86 -0
  14. data/app/assets/components/core/menu/core-menu.css +18 -0
  15. data/app/assets/components/core/menu/core-menu.html.erb +62 -0
  16. data/app/assets/components/core/menu/core-submenu.css +29 -0
  17. data/app/assets/components/core/menu/core-submenu.html.erb +106 -0
  18. data/app/assets/components/core/meta/core-meta.html +143 -0
  19. data/app/assets/components/core/overlay/core-key-helper.html +17 -0
  20. data/app/assets/components/core/overlay/core-overlay-layer.html +112 -0
  21. data/app/assets/components/core/overlay/core-overlay.html.erb +661 -0
  22. data/app/assets/components/core/range/core-range.html +106 -0
  23. data/app/assets/components/core/selection/core-selection.html +148 -0
  24. data/app/assets/components/core/selector/core-selector.html.erb +423 -0
  25. data/app/assets/components/core/style/core-style.html +386 -0
  26. data/app/assets/components/core/transition/core-transition-css.html.erb +76 -0
  27. data/app/assets/components/core/transition/core-transition-overlay.css +46 -0
  28. data/app/assets/components/core/transition/core-transition.html.erb +44 -0
  29. data/app/assets/components/paper-button/paper-button.css +115 -0
  30. data/app/assets/components/paper-button/paper-button.html.erb +210 -0
  31. data/app/assets/components/paper-checkbox/paper-checkbox.css +262 -0
  32. data/app/assets/components/paper-checkbox/paper-checkbox.html.erb +104 -0
  33. data/app/assets/components/paper-dialog/paper-dialog-transition.css +59 -0
  34. data/app/assets/components/paper-dialog/paper-dialog-transition.html.erb +27 -0
  35. data/app/assets/components/paper-dialog/paper-dialog.css +0 -0
  36. data/app/assets/components/paper-dialog/paper-dialog.html.erb +176 -0
  37. data/app/assets/components/paper-fab/paper-fab.css +27 -0
  38. data/app/assets/components/paper-fab/paper-fab.html.erb +55 -0
  39. data/app/assets/components/paper-focusable/paper-focusable.html +144 -0
  40. data/app/assets/components/paper-icon-button/paper-icon-button.css +17 -0
  41. data/app/assets/components/paper-icon-button/paper-icon-button.html.erb +87 -0
  42. data/app/assets/components/paper-input/error-100.png +0 -0
  43. data/app/assets/components/paper-input/error-200.png +0 -0
  44. data/app/assets/components/paper-input/paper-input.html.erb +398 -0
  45. data/app/assets/components/paper-input/paper-input.scss +203 -0
  46. data/app/assets/components/paper-item/paper-item.css +30 -0
  47. data/app/assets/components/paper-item/paper-item.html.erb +103 -0
  48. data/app/assets/components/paper-menu-button/paper-menu-button-overlay.html.erb +86 -0
  49. data/app/assets/components/paper-menu-button/paper-menu-button-transition.css +19 -0
  50. data/app/assets/components/paper-menu-button/paper-menu-button-transition.html.erb +118 -0
  51. data/app/assets/components/paper-menu-button/paper-menu-button.css +86 -0
  52. data/app/assets/components/paper-menu-button/paper-menu-button.html.erb +128 -0
  53. data/app/assets/components/paper-progress/paper-progress.css +35 -0
  54. data/app/assets/components/paper-progress/paper-progress.html.erb +98 -0
  55. data/app/assets/components/paper-radio-button/paper-radio-button.css +98 -0
  56. data/app/assets/components/paper-radio-button/paper-radio-button.html.erb +148 -0
  57. data/app/assets/components/paper-radio-group/paper-radio-group.html.erb +68 -0
  58. data/app/assets/components/paper-ripple/paper-ripple.html +426 -0
  59. data/app/assets/components/paper-shadow/paper-shadow.css +81 -0
  60. data/app/assets/components/paper-shadow/paper-shadow.html.erb +212 -0
  61. data/app/assets/components/paper-slider/paper-slider.css +193 -0
  62. data/app/assets/components/paper-slider/paper-slider.html.erb +310 -0
  63. data/app/assets/components/paper-tabs/paper-tab.css +49 -0
  64. data/app/assets/components/paper-tabs/paper-tab.html.erb +66 -0
  65. data/app/assets/components/paper-tabs/paper-tabs.css +57 -0
  66. data/app/assets/components/paper-tabs/paper-tabs.html.erb +127 -0
  67. data/app/assets/components/paper-toast/paper-toast.css +0 -0
  68. data/app/assets/components/paper-toast/paper-toast.html.erb +258 -0
  69. data/app/assets/components/paper-toggle-button/paper-toggle-button.css +61 -0
  70. data/app/assets/components/paper-toggle-button/paper-toggle-button.html.erb +125 -0
  71. data/lib/polymer-paper-rails/engine.rb +4 -0
  72. data/lib/polymer-paper-rails/version.rb +3 -0
  73. data/lib/polymer-paper-rails.rb +2 -0
  74. metadata +158 -0
@@ -0,0 +1,144 @@
1
+ <!--
2
+ Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6
+ Code distributed by Google as part of the polymer project is also
7
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8
+ -->
9
+
10
+ <!--
11
+ /**
12
+ * @group Paper Elements
13
+ *
14
+ * paper-focusable is a base class for paper elements that can be focused.
15
+ *
16
+ * @element paper-focusable
17
+ * @status beta
18
+ * @homepage github.io
19
+ */
20
+ -->
21
+
22
+ <polymer-element name="paper-focusable" attributes="active focused disabled isToggle" tabindex="0" on-down="{{downAction}}" on-up="{{upAction}}" on-focus="{{focusAction}}" on-blur="{{blurAction}}" on-contextmenu="{{contextMenuAction}}">
23
+
24
+ <template>
25
+ <style>
26
+ :host([disabled]) {
27
+ pointer-events: none;
28
+ }
29
+ </style>
30
+ <content></content>
31
+ </template>
32
+
33
+ <script>
34
+ Polymer('paper-focusable', {
35
+
36
+ publish: {
37
+
38
+ /**
39
+ * If true, the button is currently active either because the
40
+ * user is holding down the button, or the button is a toggle
41
+ * and is currently in the active state.
42
+ *
43
+ * @attribute active
44
+ * @type boolean
45
+ * @default false
46
+ */
47
+ active: {value: false, reflect: true},
48
+
49
+ /**
50
+ * If true, the element currently has focus due to keyboard
51
+ * navigation.
52
+ *
53
+ * @attribute focused
54
+ * @type boolean
55
+ * @default false
56
+ */
57
+ focused: {value: false, reflect: true},
58
+
59
+ /**
60
+ * If true, the user is currently holding down the button.
61
+ *
62
+ * @attribute pressed
63
+ * @type boolean
64
+ * @default false
65
+ */
66
+ pressed: {value: false, reflect: true},
67
+
68
+ /**
69
+ * If true, the user cannot interact with this element.
70
+ *
71
+ * @attribute disabled
72
+ * @type boolean
73
+ * @default false
74
+ */
75
+ disabled: {value: false, reflect: true},
76
+
77
+ /**
78
+ * If true, the button toggles the active state with each tap.
79
+ * Otherwise, the button becomes active when the user is holding
80
+ * it down.
81
+ *
82
+ * @attribute isToggle
83
+ * @type boolean
84
+ * @default false
85
+ */
86
+ isToggle: {value: false, reflect: false}
87
+
88
+ },
89
+
90
+ disabledChanged: function() {
91
+ if (this.disabled) {
92
+ this.removeAttribute('tabindex');
93
+ } else {
94
+ this.setAttribute('tabindex', 0);
95
+ }
96
+ },
97
+
98
+ downAction: function() {
99
+ this.pressed = true;
100
+ this.focused = false;
101
+
102
+ if (this.isToggle) {
103
+ this.active = !this.active;
104
+ } else {
105
+ this.active = true;
106
+ }
107
+ },
108
+
109
+ // Pulling up the context menu for an item should focus it; but we need to
110
+ // be careful about how we deal with down/up events surrounding context
111
+ // menus. The up event typically does not fire until the context menu
112
+ // closes: so we focus immediately.
113
+ //
114
+ // This fires _after_ downAction.
115
+ contextMenuAction: function(e) {
116
+ // Note that upAction may fire _again_ on the actual up event.
117
+ this.upAction(e);
118
+ this.focusAction();
119
+ },
120
+
121
+ upAction: function() {
122
+ this.pressed = false;
123
+
124
+ if (!this.isToggle) {
125
+ this.active = false;
126
+ }
127
+ },
128
+
129
+ focusAction: function() {
130
+ if (!this.pressed) {
131
+ // Only render the "focused" state if the element gains focus due to
132
+ // keyboard navigation.
133
+ this.focused = true;
134
+ }
135
+ },
136
+
137
+ blurAction: function() {
138
+ this.focused = false;
139
+ }
140
+
141
+ });
142
+
143
+ </script>
144
+ </polymer-element>
@@ -0,0 +1,17 @@
1
+ /*
2
+ Copyright 2013 The Polymer Authors. All rights reserved.
3
+ Use of this source code is governed by a BSD-style
4
+ license that can be found in the LICENSE file.
5
+ */
6
+
7
+ :host([disabled]) {
8
+ background: none !important;
9
+ }
10
+
11
+ :host([disabled]) /deep/ #icon {
12
+ fill: #c9c9c9;
13
+ }
14
+
15
+ :host(:not([fill])) /deep/ #focusBg {
16
+ border-radius: 50%;
17
+ }
@@ -0,0 +1,87 @@
1
+ <!--
2
+ Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
4
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS
5
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
6
+ Code distributed by Google as part of the polymer project is also
7
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
8
+ -->
9
+
10
+ <!--
11
+ @group Paper Elements
12
+ `paper-icon-button` is a button with an image placed at the center.
13
+
14
+ Example:
15
+
16
+ <paper-icon-button iconSrc="star.png"></paper-icon-button>
17
+
18
+ `paper-icon-button` includes a default icon set. Use `icon` to specify
19
+ which icon from the icon set to use.
20
+
21
+ Example:
22
+
23
+ <paper-icon-button icon="menu"></paper-icon-button>
24
+
25
+ The icons provided by `core-icons` are SVG, and you can style them with CSS.
26
+
27
+ Example:
28
+
29
+ <paper-icon-button icon="favorite" style="fill:red;"></paper-icon-button>
30
+
31
+ See `core-iconset` for more information about how to use a custom icon set.
32
+
33
+ @element paper-icon-button
34
+ @extends paper-button
35
+ @homepage github.io
36
+ -->
37
+
38
+ <%= html_import_tag "core/icon/core-icon" %>
39
+ <%= html_import_tag "paper-button/paper-button" %>
40
+
41
+ <polymer-element name="paper-icon-button" extends="paper-button" attributes="fill">
42
+
43
+ <template>
44
+
45
+ <%= stylesheet_link_tag "paper-icon-button/paper-icon-button" %>
46
+
47
+ <shadow></shadow>
48
+
49
+ </template>
50
+
51
+ <script>
52
+
53
+ Polymer('paper-icon-button', {
54
+
55
+ publish: {
56
+
57
+ /**
58
+ * If true, the ripple expands to a square to fill the containing box.
59
+ *
60
+ * @attribute fill
61
+ * @type boolean
62
+ * @default false
63
+ */
64
+ fill: {value: false, reflect: true}
65
+
66
+ },
67
+
68
+ ready: function() {
69
+ this.$.ripple.classList.add('recenteringTouch');
70
+ this.fillChanged();
71
+ },
72
+
73
+ fillChanged: function() {
74
+ this.$.ripple.classList.toggle('circle', !this.fill);
75
+ },
76
+
77
+ iconChanged: function(oldIcon) {
78
+ if (!this.label) {
79
+ this.setAttribute('aria-label', this.icon);
80
+ }
81
+ }
82
+
83
+ });
84
+
85
+ </script>
86
+
87
+ </polymer-element>
@@ -0,0 +1,398 @@
1
+ <!--
2
+ Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
4
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS
5
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
6
+ Code distributed by Google as part of the polymer project is also
7
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
8
+ -->
9
+
10
+ <!--
11
+ `paper-input` is a single- or multi-line text field where user can enter input.
12
+ It can optionally have a label.
13
+
14
+ Example:
15
+
16
+ <paper-input label="Your Name"></paper-input>
17
+ <paper-input multiline label="Enter multiple lines here"></paper-input>
18
+
19
+ Theming
20
+ --------
21
+
22
+ Set `CoreStyle.g.paperInput.focusedColor` and `CoreStyle.g.paperInput.invalidColor` to theme
23
+ the focused and invalid states.
24
+
25
+ @group Paper Elements
26
+ @element paper-input
27
+ @extends core-input
28
+ @homepage github.io
29
+ -->
30
+
31
+ <%= html_import_tag "core/input/core-input" %>
32
+ <%= html_import_tag "core/style/core-style" %>
33
+
34
+ <core-style id="paper-input">
35
+
36
+ #label.focused,
37
+ #floatedLabel.focused {
38
+ color: {{g.paperInput.focusedColor}};
39
+ }
40
+
41
+ #underlineHighlight.focused,
42
+ #caretInner {
43
+ background-color: {{g.paperInput.focusedColor}};
44
+ }
45
+
46
+ #error,
47
+ :host(.invalid) #label.focused,
48
+ :host(.invalid) #floatedLabel.focused {
49
+ color: {{g.paperInput.invalidColor}};
50
+ }
51
+ :host(.invalid) #underlineHighlight.focused,
52
+ :host(.invalid) #caretInner {
53
+ background-color: {{g.paperInput.invalidColor}};
54
+ }
55
+
56
+ </core-style>
57
+
58
+ <polymer-element name="paper-input" extends="core-input" attributes="label floatingLabel maxRows error" on-down="{{downAction}}" on-up="{{upAction}}">
59
+
60
+ <template>
61
+
62
+ <%= stylesheet_link_tag "paper-input/paper-input" %>
63
+
64
+ <core-style ref="paper-input"></core-style>
65
+
66
+ <div id="floatedLabel" class="hidden" hidden?="{{!floatingLabel}}"><span id="floatedLabelSpan">{{label}}</span></div>
67
+
68
+ <div id="container" on-transitionend="{{transitionEndAction}}" on-webkitTransitionEnd="{{transitionEndAction}}">
69
+
70
+ <div id="label"><span id="labelSpan">{{label}}</span></div>
71
+
72
+ <div id="inputContainer">
73
+
74
+ <div id="inputClone">
75
+ <span id="inputCloneSpan" aria-hidden="true">&nbsp;</span>
76
+ </div>
77
+
78
+ <template if="{{multiline}}">
79
+ <div id="minInputHeight"></div>
80
+ <div id="maxInputHeight"></div>
81
+ </template>
82
+
83
+ <shadow></shadow>
84
+
85
+ </div>
86
+
87
+ <div id="underlineContainer">
88
+ <div id="underline"></div>
89
+ <div id="underlineHighlight" class="focusedColor"></div>
90
+ </div>
91
+
92
+ <div id="caret">
93
+ <div id="caretInner" class="focusedColor"></div>
94
+ </div>
95
+
96
+ </div>
97
+
98
+ <div id="errorContainer">
99
+ <div id="error" role="alert" aria-hidden="{{!invalid}}">{{error}}</div>
100
+ <div id="errorIcon"></div>
101
+ </div>
102
+
103
+ </template>
104
+
105
+ <script>
106
+
107
+ (function() {
108
+
109
+ var paperInput = CoreStyle.g.paperInput = CoreStyle.g.paperInput || {};
110
+ paperInput.focusedColor = '#4059a9';
111
+ paperInput.invalidColor = '#d34336';
112
+
113
+ Polymer('paper-input', {
114
+
115
+ /**
116
+ * The label for this input. It normally appears as grey text inside
117
+ * the text input and disappears once the user enters text.
118
+ *
119
+ * @attribute label
120
+ * @type string
121
+ * @default ''
122
+ */
123
+ label: '',
124
+
125
+ /**
126
+ * If true, the label will "float" above the text input once the
127
+ * user enters text instead of disappearing.
128
+ *
129
+ * @attribute floatingLabel
130
+ * @type boolean
131
+ * @default false
132
+ */
133
+ floatingLabel: false,
134
+
135
+ /**
136
+ * (multiline only) If set to a non-zero value, the height of this
137
+ * text input will grow with the value changes until it is maxRows
138
+ * rows tall. If the maximum size does not fit the value, the text
139
+ * input will scroll internally.
140
+ *
141
+ * @attribute maxRows
142
+ * @type number
143
+ * @default 0
144
+ */
145
+ maxRows: 0,
146
+
147
+ focused: false,
148
+ pressed: false,
149
+
150
+ attached: function() {
151
+ if (this.multiline) {
152
+ this.resizeInput();
153
+ window.requestAnimationFrame(function() {
154
+ this.$.underlineContainer.classList.add('animating');
155
+ }.bind(this));
156
+ }
157
+ },
158
+
159
+ resizeInput: function() {
160
+ var height = this.$.inputClone.getBoundingClientRect().height;
161
+ var bounded = this.maxRows > 0 || this.rows > 0;
162
+ if (bounded) {
163
+ var minHeight = this.$.minInputHeight.getBoundingClientRect().height;
164
+ var maxHeight = this.$.maxInputHeight.getBoundingClientRect().height;
165
+ height = Math.max(minHeight, Math.min(height, maxHeight));
166
+ }
167
+ this.$.inputContainer.style.height = height + 'px';
168
+ this.$.underlineContainer.style.top = height + 'px';
169
+ },
170
+
171
+ prepareLabelTransform: function() {
172
+ var toRect = this.$.floatedLabelSpan.getBoundingClientRect();
173
+ var fromRect = this.$.labelSpan.getBoundingClientRect();
174
+ if (toRect.width !== 0) {
175
+ this.$.label.cachedTransform = 'scale(' + (toRect.width / fromRect.width) + ') ' +
176
+ 'translateY(' + (toRect.bottom - fromRect.bottom) + 'px)';
177
+ }
178
+ },
179
+
180
+ rowsChanged: function() {
181
+ if (this.multiline && !isNaN(parseInt(this.rows))) {
182
+ this.$.minInputHeight.innerHTML = '';
183
+ for (var i = 0; i < this.rows; i++) {
184
+ this.$.minInputHeight.appendChild(document.createElement('br'));
185
+ }
186
+ this.resizeInput();
187
+ }
188
+ },
189
+
190
+ maxRowsChanged: function() {
191
+ if (this.multiline && !isNaN(parseInt(this.maxRows))) {
192
+ this.$.maxInputHeight.innerHTML = '';
193
+ for (var i = 0; i < this.maxRows; i++) {
194
+ this.$.maxInputHeight.appendChild(document.createElement('br'));
195
+ }
196
+ this.resizeInput();
197
+ }
198
+ },
199
+
200
+ inputValueChanged: function() {
201
+ this.super();
202
+
203
+ if (this.multiline) {
204
+ var escaped = this.inputValue.replace(/\n/gm, '<br>');
205
+ if (!escaped || escaped.lastIndexOf('<br>') === escaped.length - 4) {
206
+ escaped += '&nbsp';
207
+ }
208
+ this.$.inputCloneSpan.innerHTML = escaped;
209
+ this.resizeInput();
210
+ }
211
+
212
+ if (!this.floatingLabel) {
213
+ this.$.label.classList.toggle('hidden', this.inputValue);
214
+ }
215
+
216
+ if (this.floatingLabel && !this.focused) {
217
+ this.$.label.classList.toggle('hidden', this.inputValue);
218
+ this.$.floatedLabel.classList.toggle('hidden', !this.inputValue);
219
+ }
220
+ },
221
+
222
+ labelChanged: function() {
223
+ if (this.floatingLabel && this.$.floatedLabel && this.$.label) {
224
+ // If the element is created programmatically, labelChanged is called before
225
+ // binding. Run the measuring code in async so the DOM is ready.
226
+ this.async(function() {
227
+ this.prepareLabelTransform();
228
+ });
229
+ }
230
+ },
231
+
232
+ placeholderChanged: function() {
233
+ this.label = this.placeholder;
234
+ },
235
+
236
+ inputFocusAction: function() {
237
+ if (!this.pressed) {
238
+ if (this.floatingLabel) {
239
+ this.$.floatedLabel.classList.remove('hidden');
240
+ this.$.floatedLabel.classList.add('focused');
241
+ this.$.floatedLabel.classList.add('focusedColor');
242
+ }
243
+ this.$.label.classList.add('hidden');
244
+ this.$.underlineHighlight.classList.add('focused');
245
+ this.$.caret.classList.add('focused');
246
+
247
+ this.super(arguments);
248
+ }
249
+ this.focused = true;
250
+ },
251
+
252
+ inputBlurAction: function() {
253
+ this.super(arguments);
254
+
255
+ this.$.underlineHighlight.classList.remove('focused');
256
+ this.$.caret.classList.remove('focused');
257
+ if (this.floatingLabel) {
258
+ this.$.floatedLabel.classList.remove('focused');
259
+ this.$.floatedLabel.classList.remove('focusedColor');
260
+ if (!this.inputValue) {
261
+ this.$.floatedLabel.classList.add('hidden');
262
+ }
263
+ }
264
+ if (!this.inputValue) {
265
+ this.$.label.classList.remove('hidden');
266
+ this.$.label.classList.add('animating');
267
+ this.async(function() {
268
+ this.$.label.style.webkitTransform = 'none';
269
+ this.$.label.style.transform = 'none';
270
+ });
271
+ }
272
+ this.focused = false;
273
+ },
274
+
275
+ downAction: function(e) {
276
+ if (this.disabled) {
277
+ return;
278
+ }
279
+
280
+ if (this.focused) {
281
+ return;
282
+ }
283
+
284
+ this.pressed = true;
285
+ var rect = this.$.underline.getBoundingClientRect();
286
+ var right = e.x - rect.left;
287
+ this.$.underlineHighlight.style.webkitTransformOriginX = right + 'px';
288
+ this.$.underlineHighlight.style.transformOriginX = right + 'px';
289
+ this.$.underlineHighlight.classList.remove('focused');
290
+ this.underlineAsync = this.async(function() {
291
+ this.$.underlineHighlight.classList.add('pressed');
292
+ }, null, 200);
293
+
294
+ // No caret animation if there is text in the input.
295
+ if (!this.inputValue) {
296
+ var width = this.$.inputCloneSpan.getBoundingClientRect().width;
297
+ if (width < right) {
298
+ this.$.caret.style.left = width + 'px';
299
+ this.$.caret.classList.remove('focused');
300
+ }
301
+ }
302
+ },
303
+
304
+ upAction: function(e) {
305
+ if (this.disabled) {
306
+ return;
307
+ }
308
+
309
+ if (!this.pressed) {
310
+ return;
311
+ }
312
+
313
+ // if a touchevent caused the up, the synthentic mouseevents will blur
314
+ // the input, make sure to prevent those from being generated.
315
+ if (e._source === 'touch') {
316
+ e.preventDefault();
317
+ }
318
+
319
+ if (this.underlineAsync) {
320
+ clearTimeout(this.underlineAsync);
321
+ this.underlineAsync = null;
322
+ }
323
+
324
+ // Focus the input here to bring up the virtual keyboard.
325
+ this.$.input.focus();
326
+ this.pressed = false;
327
+ this.animating = true;
328
+
329
+ this.$.underlineHighlight.classList.remove('pressed');
330
+ this.$.underlineHighlight.classList.add('animating');
331
+ this.async(function() {
332
+ this.$.underlineHighlight.classList.add('focused');
333
+ });
334
+
335
+ // No caret animation if there is text in the input.
336
+ if (!this.inputValue) {
337
+ this.$.caret.classList.add('animating');
338
+ this.async(function() {
339
+ this.$.caret.classList.add('focused');
340
+ }, null, 100);
341
+ }
342
+
343
+ if (this.floatingLabel) {
344
+ this.$.label.classList.add('focusedColor');
345
+ this.$.label.classList.add('animating');
346
+ if (!this.$.label.cachedTransform) {
347
+ this.prepareLabelTransform();
348
+ }
349
+ this.$.label.style.webkitTransform = this.$.label.cachedTransform;
350
+ this.$.label.style.transform = this.$.label.cachedTransform;
351
+ }
352
+ },
353
+
354
+ keypressAction: function() {
355
+ if (this.animating) {
356
+ this.transitionEndAction();
357
+ }
358
+ },
359
+
360
+ transitionEndAction: function(e) {
361
+ this.animating = false;
362
+ if (this.pressed) {
363
+ return;
364
+ }
365
+
366
+ if (this.focused) {
367
+
368
+ if (this.floatingLabel || this.inputValue) {
369
+ this.$.label.classList.add('hidden');
370
+ }
371
+
372
+ if (this.floatingLabel) {
373
+ this.$.label.classList.remove('focusedColor');
374
+ this.$.label.classList.remove('animating');
375
+ this.$.floatedLabel.classList.remove('hidden');
376
+ this.$.floatedLabel.classList.add('focused');
377
+ this.$.floatedLabel.classList.add('focusedColor');
378
+ }
379
+
380
+ this.async(function() {
381
+ this.$.underlineHighlight.classList.remove('animating');
382
+ this.$.caret.classList.remove('animating');
383
+ }, null, 100);
384
+
385
+ } else {
386
+
387
+ this.$.label.classList.remove('animating');
388
+
389
+ }
390
+ }
391
+
392
+ });
393
+
394
+ }());
395
+
396
+ </script>
397
+
398
+ </polymer-element>