Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / login / gaia_input.js
blobb0bdd3ab9d87aeb9dbcaa3b347f6e73625f732c7
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 Polymer((function() {
6 var INPUT_EMAIL_PATTERN = "^[a-zA-Z0-9.!#$%&'*+=?^_`{|}~-]+(@[^\\s@]+)?$";
8 return {
9 is: 'gaia-input',
11 properties: {
12 label: String,
13 value: {
14 notify: true,
15 observer: 'updateDomainVisibility_',
16 type: String
19 type: {
20 observer: 'typeChanged_',
21 type: String
24 domain: {
25 observer: 'updateDomainVisibility_',
26 type: String
29 disabled: Boolean,
31 required: Boolean,
33 error: String,
35 isInvalid: Boolean
38 attached: function() {
39 this.typeChanged_();
42 onKeyDown: function(e) {
43 this.isInvalid = false;
46 updateDomainVisibility_: function() {
47 this.$.domainLabel.hidden = (this.type !== 'email') || !this.domain ||
48 (this.value && this.value.indexOf('@') !== -1);
51 onTap: function() {
52 this.isInvalid = false;
55 focus: function() {
56 this.$.input.focus();
59 checkValidity: function() {
60 var valid = this.$.input.validate();
61 this.isInvalid = !valid;
62 return valid;
65 typeChanged_: function() {
66 if (this.type == 'email') {
67 this.$.input.pattern = INPUT_EMAIL_PATTERN;
68 this.$.input.type = 'text';
69 } else {
70 this.$.input.removeAttribute('pattern');
71 this.$.input.type = this.type;
73 this.updateDomainVisibility_();
76 })());