blob: af168f7c0ebe5bb9f61c6116b8809bc4667dc67f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* Copyright 2015 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
Polymer('gaia-input', (function() {
var INPUT_EMAIL_PATTERN = "^[a-zA-Z0-9.!#$%&'*+=?^_`{|}~-]+(@[^\\s@]+)?$";
return {
required: false,
ready: function() {
this.typeChanged();
},
onKeyDown: function(e) {
this.isInvalid = false;
},
setDomainVisibility: function() {
this.$.domainLabel.hidden = (this.type !== 'email') || !this.domain ||
(this.value.indexOf('@') !== -1);
},
onTap: function() {
this.isInvalid = false;
},
focus: function() {
this.$.input.focus();
},
checkValidity: function() {
var isValid = this.$.input.validity.valid;
this.isInvalid = !isValid;
return isValid;
},
typeChanged: function() {
if (this.type == 'email') {
this.$.input.pattern = INPUT_EMAIL_PATTERN;
this.$.input.type = 'text';
} else {
this.$.input.removeAttribute('pattern');
this.$.input.type = this.type;
}
this.setDomainVisibility();
},
valueChanged: function() {
this.setDomainVisibility();
},
domainChanged: function() {
this.setDomainVisibility();
},
};
})());
|