MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / third_party / polymer / components-chromium / paper-focusable / paper-focusable-extracted.js
blob6b4173c596214d0f76bf650fa524b0d798649bc3
2 Polymer('paper-focusable', {
4 publish: {
6 /**
7 * If true, the button is currently active either because the
8 * user is holding down the button, or the button is a toggle
9 * and is currently in the active state.
11 * @attribute active
12 * @type boolean
13 * @default false
15 active: {value: false, reflect: true},
17 /**
18 * If true, the element currently has focus due to keyboard
19 * navigation.
21 * @attribute focused
22 * @type boolean
23 * @default false
25 focused: {value: false, reflect: true},
27 /**
28 * If true, the user is currently holding down the button.
30 * @attribute pressed
31 * @type boolean
32 * @default false
34 pressed: {value: false, reflect: true},
36 /**
37 * If true, the user cannot interact with this element.
39 * @attribute disabled
40 * @type boolean
41 * @default false
43 disabled: {value: false, reflect: true},
45 /**
46 * If true, the button toggles the active state with each tap.
47 * Otherwise, the button becomes active when the user is holding
48 * it down.
50 * @attribute isToggle
51 * @type boolean
52 * @default false
54 isToggle: {value: false, reflect: false}
58 disabledChanged: function() {
59 if (this.disabled) {
60 this.removeAttribute('tabindex');
61 } else {
62 this.setAttribute('tabindex', 0);
66 downAction: function() {
67 this.pressed = true;
68 this.focused = false;
70 if (this.isToggle) {
71 this.active = !this.active;
72 } else {
73 this.active = true;
77 // Pulling up the context menu for an item should focus it; but we need to
78 // be careful about how we deal with down/up events surrounding context
79 // menus. The up event typically does not fire until the context menu
80 // closes: so we focus immediately.
82 // This fires _after_ downAction.
83 contextMenuAction: function(e) {
84 // Note that upAction may fire _again_ on the actual up event.
85 this.upAction(e);
86 this.focusAction();
89 upAction: function() {
90 this.pressed = false;
92 if (!this.isToggle) {
93 this.active = false;
97 focusAction: function() {
98 if (!this.pressed) {
99 // Only render the "focused" state if the element gains focus due to
100 // keyboard navigation.
101 this.focused = true;
105 blurAction: function() {
106 this.focused = false;