2 * @group Polymer Mixins
4 * `Polymer.CoreFocusable` is a mixin for elements that the user can interact with.
5 * Elements using this mixin will receive attributes reflecting the focus, pressed
8 * @element Polymer.CoreFocusable
12 Polymer.CoreFocusable = {
17 * If true, the element is currently active either because the
18 * user is touching it, or the button is a toggle
19 * and is currently in the active state.
25 active: {value: false, reflect: true},
28 * If true, the element currently has focus due to keyboard
35 focused: {value: false, reflect: true},
38 * If true, the user is currently holding down the button.
44 pressed: {value: false, reflect: true},
47 * If true, the user cannot interact with this element.
53 disabled: {value: false, reflect: true},
56 * If true, the button toggles the active state with each tap.
57 * Otherwise, the button becomes active when the user is holding
69 contextMenu: '_contextMenuAction',
72 focus: '_focusAction',
77 disabled: '_disabledChanged'
80 _disabledChanged: function() {
82 this.style.pointerEvents = 'none';
83 this.removeAttribute('tabindex');
84 this.setAttribute('aria-disabled', '');
86 this.style.pointerEvents = '';
87 this.setAttribute('tabindex', 0);
88 this.removeAttribute('aria-disabled');
92 _downAction: function() {
96 this.active = !this.active;
102 // Pulling up the context menu for an item should focus it; but we need to
103 // be careful about how we deal with down/up events surrounding context
104 // menus. The up event typically does not fire until the context menu
105 // closes: so we focus immediately.
107 // This fires _after_ downAction.
108 _contextMenuAction: function(e) {
109 // Note that upAction may fire _again_ on the actual up event.
114 _upAction: function() {
115 this.pressed = false;
122 _focusAction: function() {
124 // Only render the "focused" state if the element gains focus due to
125 // keyboard navigation.
130 _blurAction: function() {
131 this.focused = false;