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

Unified Diff: chrome/browser/resources/chromeos/login/gaia_input.js

Issue 1129063003: <gaia-input> element extracted from <gaia-input-form>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected test. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/login/gaia_input.js
diff --git a/chrome/browser/resources/chromeos/login/gaia_input.js b/chrome/browser/resources/chromeos/login/gaia_input.js
new file mode 100644
index 0000000000000000000000000000000000000000..f251cd5e52ba682e2eaf8ef94d62ec61021d4edb
--- /dev/null
+++ b/chrome/browser/resources/chromeos/login/gaia_input.js
@@ -0,0 +1,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();
+ }
+ };
+})());
+
« no previous file with comments | « chrome/browser/resources/chromeos/login/gaia_input.html ('k') | chrome/browser/resources/chromeos/login/gaia_input_form.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698