| OLD | NEW |
| (Empty) |
| 1 | |
| 2 | |
| 3 Polymer.IronControlState = { | |
| 4 | |
| 5 properties: { | |
| 6 | |
| 7 /** | |
| 8 * If true, the element currently has focus. | |
| 9 * | |
| 10 * @attribute focused | |
| 11 * @type boolean | |
| 12 * @default false | |
| 13 */ | |
| 14 focused: { | |
| 15 type: Boolean, | |
| 16 value: false, | |
| 17 notify: true, | |
| 18 readOnly: true, | |
| 19 reflectToAttribute: true | |
| 20 }, | |
| 21 | |
| 22 /** | |
| 23 * If true, the user cannot interact with this element. | |
| 24 * | |
| 25 * @attribute disabled | |
| 26 * @type boolean | |
| 27 * @default false | |
| 28 */ | |
| 29 disabled: { | |
| 30 type: Boolean, | |
| 31 value: false, | |
| 32 notify: true, | |
| 33 observer: '_disabledChanged', | |
| 34 reflectToAttribute: true | |
| 35 }, | |
| 36 | |
| 37 _oldTabIndex: { | |
| 38 type: String | |
| 39 } | |
| 40 }, | |
| 41 | |
| 42 observers: [ | |
| 43 '_changedControlState(focused, disabled)' | |
| 44 ], | |
| 45 | |
| 46 listeners: { | |
| 47 focus: '_focusHandler', | |
| 48 blur: '_blurHandler' | |
| 49 }, | |
| 50 | |
| 51 ready: function() { | |
| 52 // TODO(sjmiles): ensure read-only property is valued so the compound | |
| 53 // observer will fire | |
| 54 if (this.focused === undefined) { | |
| 55 this._setFocused(false); | |
| 56 } | |
| 57 }, | |
| 58 | |
| 59 _focusHandler: function() { | |
| 60 this._setFocused(true); | |
| 61 }, | |
| 62 | |
| 63 _blurHandler: function() { | |
| 64 this._setFocused(false); | |
| 65 }, | |
| 66 | |
| 67 _disabledChanged: function(disabled, old) { | |
| 68 this.setAttribute('aria-disabled', disabled ? 'true' : 'false'); | |
| 69 this.style.pointerEvents = disabled ? 'none' : ''; | |
| 70 if (disabled) { | |
| 71 this._oldTabIndex = this.tabIndex; | |
| 72 this.focused = false; | |
| 73 this.tabIndex = -1; | |
| 74 } else if (this._oldTabIndex !== undefined) { | |
| 75 this.tabIndex = this._oldTabIndex; | |
| 76 } | |
| 77 }, | |
| 78 | |
| 79 _changedControlState: function() { | |
| 80 // _controlStateChanged is abstract, follow-on behaviors may implement it | |
| 81 if (this._controlStateChanged) { | |
| 82 this._controlStateChanged(); | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 }; | |
| 87 | |
| OLD | NEW |