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.
6 var INPUT_EMAIL_PATTERN
= "^[a-zA-Z0-9.!#$%&'*+=?^_`{|}~-]+(@[^\\s@]+)?$";
15 observer
: 'updateDomainVisibility_',
20 observer
: 'typeChanged_',
25 observer
: 'updateDomainVisibility_',
38 attached: function() {
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);
52 this.isInvalid
= false;
59 checkValidity: function() {
60 var valid
= this.$.input
.validate();
61 this.isInvalid
= !valid
;
65 typeChanged_: function() {
66 if (this.type
== 'email') {
67 this.$.input
.pattern
= INPUT_EMAIL_PATTERN
;
68 this.$.input
.type
= 'text';
70 this.$.input
.removeAttribute('pattern');
71 this.$.input
.type
= this.type
;
73 this.updateDomainVisibility_();