Index: chrome/browser/resources/chromeos/login/gaia_input_form.js |
diff --git a/chrome/browser/resources/chromeos/login/gaia_input_form.js b/chrome/browser/resources/chromeos/login/gaia_input_form.js |
index 811f08b989c7aa1139666a534129548a9d013f9c..5d03c6b6baba49e7abce0dea4796484067a69a9c 100644 |
--- a/chrome/browser/resources/chromeos/login/gaia_input_form.js |
+++ b/chrome/browser/resources/chromeos/login/gaia_input_form.js |
@@ -1,24 +1,47 @@ |
-/* 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-form', (function() { |
- return { |
- onButtonClicked: function() { |
- this.fire('submit'); |
- }, |
+// 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. |
- onKeyDown: function(e) { |
- if (e.keyCode == 13 && !this.$.button.disabled) |
- this.onButtonClicked(); |
- }, |
+Polymer({ |
+ is: 'gaia-input-form', |
- set disabled(value) { |
- var controls = this.querySelectorAll( |
- ':host /deep/ [role="button"], :host /deep/ [is="core-input"]'); |
- for (var i = 0, control; control = controls[i]; ++i) |
- control.disabled = value; |
+ properties: { |
+ disabled: { |
+ type: Boolean, |
+ observer: 'onDisabledChanged_', |
}, |
- }; |
-})()); |
+ |
+ buttonText: { |
+ type: String, |
+ reflectToAttribute: true |
michaelpg
2015/06/22 20:39:25
Why does this need reflectToAttribute?
dzhioev (left Google)
2015/06/22 21:17:44
it doesn't. Removed.
|
+ } |
+ }, |
+ |
+ onButtonClicked_: function() { |
+ this.fire('submit'); |
+ }, |
+ |
+ getInputs_: function() { |
+ return Polymer.dom(this.$.inputs).getDistributedNodes(); |
+ }, |
+ |
+ onKeyDown_: function(e) { |
+ if (e.keyCode != 13 || this.$.button.disabled) |
+ return; |
+ if (this.getInputs_().indexOf(e.target) == -1) |
+ return; |
+ this.onButtonClicked_(); |
+ }, |
+ |
+ getControls_: function() { |
+ var controls = this.getInputs_(); |
+ controls.push(this.$.button); |
+ return controls.concat(Polymer.dom(this).querySelectorAll('gaia-button')); |
+ }, |
+ |
+ onDisabledChanged_: function(disabled) { |
+ this.getControls_().forEach(function(control) { |
+ control.disabled = disabled; |
+ }); |
+ } |
+}); |