Index: chrome/browser/resources/chromeos/login/gaia_buttons.js |
diff --git a/chrome/browser/resources/chromeos/login/gaia_buttons.js b/chrome/browser/resources/chromeos/login/gaia_buttons.js |
index b94850e0d646a23efc392b507a0ae50fb54be2c6..8bf674dcefa8d0209d65a86b55785077ea413058 100644 |
--- a/chrome/browser/resources/chromeos/login/gaia_buttons.js |
+++ b/chrome/browser/resources/chromeos/login/gaia_buttons.js |
@@ -1,48 +1,73 @@ |
-/* 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-button', { |
- ready: function() { |
- this.typeChanged(); |
- }, |
+// 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 (!this.disabled && (e.keyCode == 13 || e.keyCode == 32)) { |
- this.fire('tap'); |
- this.fire('click'); |
- e.stopPropagation(); |
- } |
- }, |
+Polymer({ |
+ is: 'gaia-button', |
- onFocus: function() { |
- if (this.type == 'link' || this.type == 'dialog') |
- return; |
- this.raised = true; |
+ properties: { |
+ disabled: { |
+ type: Boolean, |
+ value: false, |
+ reflectToAttribute: true |
+ }, |
+ |
+ type: { |
+ type: String, |
+ value: '', |
+ reflectToAttribute: true, |
+ observer: 'typeChanged_' |
+ } |
}, |
- onBlur: function() { |
+ focusedChanged_: function() { |
if (this.type == 'link' || this.type == 'dialog') |
return; |
- this.raised = false; |
+ this.$.button.raised = this.$.button.focused; |
}, |
- typeChanged: function() { |
+ typeChanged_: function() { |
if (this.type == 'link') |
- this.setAttribute('noink', ''); |
+ this.$.button.setAttribute('noink', ''); |
else |
- this.removeAttribute('noink'); |
+ this.$.button.removeAttribute('noink'); |
}, |
+ |
+ onClick_: function(e) { |
+ if (this.disabled) |
+ e.stopPropagation(); |
+ } |
}); |
-Polymer('gaia-icon-button', { |
- ready: function() { |
- this.classList.add('custom-appearance'); |
+Polymer({ |
+ is: 'gaia-icon-button', |
+ |
+ properties: { |
+ disabled: { |
+ type: Boolean, |
+ value: false, |
+ observer: 'disabledChanged_', |
+ reflectToAttribute: true |
+ }, |
+ |
+ icon: String, |
+ |
+ ariaLabel: String |
}, |
- onMouseDown: function(e) { |
- /* Prevents button focusing after mouse click. */ |
- e.preventDefault(); |
+ onClick_: function(e) { |
+ if (this.disabled) |
+ e.stopPropagation(); |
+ }, |
+ |
+ disabledChanged_: function(disabled) { |
+ // TODO(dzhioev): remove after |
+ // https://github.com/PolymerElements/paper-icon-button/issues/20 is fixed. |
+ if (!disabled) { |
+ this.async(function() { |
+ this.$.iconButton.tabIndex = '0'; |
+ }); |
+ } |
} |
}); |
+ |