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

Unified Diff: ui/login/account_picker/user_pod_row.js

Issue 2254623003: Submit button added to user pod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Rebased. Created 4 years, 4 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
« no previous file with comments | « ui/login/account_picker/user_pod_row.css ('k') | ui/login/account_picker/user_pod_template.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/login/account_picker/user_pod_row.js
diff --git a/ui/login/account_picker/user_pod_row.js b/ui/login/account_picker/user_pod_row.js
index dbf03e91657250ff9b917a4631318018737ffcf5..e96521453eebd758c94a40bc9a450aaa474d6db1 100644
--- a/ui/login/account_picker/user_pod_row.js
+++ b/ui/login/account_picker/user_pod_row.js
@@ -757,6 +757,8 @@ cr.define('login', function() {
this.handlePasswordKeyPress_.bind(this));
this.passwordElement.addEventListener('input',
this.handleInputChanged_.bind(this));
+ this.submitButton.addEventListener('click',
+ this.handleSubmitButtonClick_.bind(this));
this.imageElement.addEventListener('load',
this.parentNode.handlePodImageLoad.bind(this.parentNode, this));
@@ -766,6 +768,17 @@ cr.define('login', function() {
this.setAuthType(initialAuthType, null);
this.userClickAuthAllowed_ = false;
+
+ // Lazy load the assets needed for the polymer submit button.
+ if (cr.ui.login.ResourceLoader.alreadyLoadedAssets('userpod-polymer'))
jdufault 2016/08/30 19:50:40 Use id 'custom-elements-user-pod'
jdufault 2016/08/30 19:50:40 I'd invert the if condition so it is if (!loade
sammiequon 2016/08/30 20:52:35 Done.
sammiequon 2016/08/30 20:52:35 Done.
+ return;
+
+ cr.ui.login.ResourceLoader.registerAssets({
+ id: 'userpod-polymer',
+ html: [{ url: 'chrome://oobe/custom_elements_user_pod.html'}]
jdufault 2016/08/30 19:50:40 space before }]
sammiequon 2016/08/30 20:52:35 Done.
+ });
+ cr.ui.login.ResourceLoader.loadAssetsOnIdle('userpod-polymer',
+ function() {});
jdufault 2016/08/30 19:50:40 Remove empty function.
sammiequon 2016/08/30 20:52:35 Done.
},
/**
@@ -793,6 +806,14 @@ cr.define('login', function() {
},
/**
+ * Handles a click event on submit button.
+ * @param {Event} e Click event.
+ */
+ handleSubmitButtonClick_: function(e) {
+ this.parentNode.setActivatedPod(this, e);
+ },
+
+ /**
* Top edge margin number of pixels.
* @type {?number}
*/
@@ -870,6 +891,14 @@ cr.define('login', function() {
},
/**
+ * Gets submit button.
+ * @type {!HTMLInputElement}
+ */
+ get submitButton() {
+ return this.querySelector('.submit-button');
+ },
+
+ /**
* Gets the password label, which is used to show a message where the
* password field is normally.
* @type {!HTMLInputElement}
@@ -1103,6 +1132,10 @@ cr.define('login', function() {
return this.pinKeyboard && this.pinKeyboard.offsetHeight > 0;
},
+ setErrorDisplay: function(visible) {
+ this.submitButton.classList.toggle('error-shown', visible);
+ },
+
toggleTransitions: function(enable) {
this.classList.toggle('flying-pin-pod', enable);
},
@@ -1830,6 +1863,8 @@ cr.define('login', function() {
handleInputChanged_: function(e) {
if (this.pinKeyboard)
this.pinKeyboard.value = this.passwordElement.value;
+ this.submitButton.disabled = this.passwordElement.value.length <= 0;
+ this.setErrorDisplay(false);
},
/**
@@ -2604,11 +2639,28 @@ cr.define('login', function() {
userPod.initialize();
},
+ /**
+ * Enables or disables transitions on the user pod.
+ * @param {boolean} enable
+ */
togglePinTransitions: function(enable) {
for (var i = 0; i < this.pods.length; ++i)
this.pods[i].toggleTransitions(enable);
},
+ /**
+ * Performs visual changes on the user pod if there is an error.
+ * @param {boolean} visible Whether to show or hide the display.
+ */
+ setFocusedPodErrorDisplay: function(visible) {
+ if (this.focusedPod_)
+ this.focusedPod_.setErrorDisplay(visible);
+ },
+
+ /**
+ * Shows or hides the pin keyboard for the current focused pod.
+ * @param {boolean} visible
+ */
setFocusedPodPinVisibility: function(visible) {
if (this.focusedPod_ && this.focusedPod_.user.showPin)
this.focusedPod_.setPinVisibility(visible);
@@ -2975,9 +3027,9 @@ cr.define('login', function() {
// Wrap this in a set timeout so the function is called after the pod is
// finished transitioning so that we work with the final pod dimensions.
- setTimeout(function(podrow) {
- podrow.scrollFocusedPodIntoView();
- }, 200, this);
+ setTimeout(function() {
+ this.scrollFocusedPodIntoView();
+ }.bind(this), 200);
},
/**
« no previous file with comments | « ui/login/account_picker/user_pod_row.css ('k') | ui/login/account_picker/user_pod_template.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698