Index: third_party/polymer/v0_8/components/iron-behaviors/iron-control-state.html |
diff --git a/third_party/polymer/v0_8/components/iron-behaviors/iron-control-state.html b/third_party/polymer/v0_8/components/iron-behaviors/iron-control-state.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4b98a09a9728a1fa3b63d7b107279681ce4c840b |
--- /dev/null |
+++ b/third_party/polymer/v0_8/components/iron-behaviors/iron-control-state.html |
@@ -0,0 +1,99 @@ |
+<!-- |
+Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
+Code distributed by Google as part of the polymer project is also |
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
+--> |
+ |
+<link rel="import" href="../polymer/polymer.html"> |
+ |
+<script> |
+ |
+ Polymer.IronControlState = { |
+ |
+ properties: { |
+ |
+ /** |
+ * If true, the element currently has focus. |
+ * |
+ * @attribute focused |
+ * @type boolean |
+ * @default false |
+ */ |
+ focused: { |
+ type: Boolean, |
+ value: false, |
+ notify: true, |
+ readOnly: true, |
+ reflectToAttribute: true |
+ }, |
+ |
+ /** |
+ * If true, the user cannot interact with this element. |
+ * |
+ * @attribute disabled |
+ * @type boolean |
+ * @default false |
+ */ |
+ disabled: { |
+ type: Boolean, |
+ value: false, |
+ notify: true, |
+ observer: '_disabledChanged', |
+ reflectToAttribute: true |
+ }, |
+ |
+ _oldTabIndex: { |
+ type: String |
+ } |
+ }, |
+ |
+ observers: [ |
+ '_changedControlState(focused, disabled)' |
+ ], |
+ |
+ listeners: { |
+ focus: '_focusHandler', |
+ blur: '_blurHandler' |
+ }, |
+ |
+ ready: function() { |
+ // TODO(sjmiles): ensure read-only property is valued so the compound |
+ // observer will fire |
+ if (this.focused === undefined) { |
+ this._setFocused(false); |
+ } |
+ }, |
+ |
+ _focusHandler: function() { |
+ this._setFocused(true); |
+ }, |
+ |
+ _blurHandler: function() { |
+ this._setFocused(false); |
+ }, |
+ |
+ _disabledChanged: function(disabled, old) { |
+ this.setAttribute('aria-disabled', disabled ? 'true' : 'false'); |
+ this.style.pointerEvents = disabled ? 'none' : ''; |
+ if (disabled) { |
+ this._oldTabIndex = this.tabIndex; |
+ this.focused = false; |
+ this.tabIndex = -1; |
+ } else if (this._oldTabIndex !== undefined) { |
+ this.tabIndex = this._oldTabIndex; |
+ } |
+ }, |
+ |
+ _changedControlState: function() { |
+ // _controlStateChanged is abstract, follow-on behaviors may implement it |
+ if (this._controlStateChanged) { |
+ this._controlStateChanged(); |
+ } |
+ } |
+ |
+ }; |
+ |
+</script> |