Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js

Issue 1261403002: Add paper-menu-button and its dependencies to third_party/polymer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reproduce.sh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 2
3 /** 3 /**
4 * @demo demo/index.html 4 * @demo demo/index.html
5 * @polymerBehavior Polymer.IronButtonState 5 * @polymerBehavior Polymer.IronButtonState
6 */ 6 */
7 Polymer.IronButtonStateImpl = { 7 Polymer.IronButtonStateImpl = {
8 8
9 properties: { 9 properties: {
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 observers: [ 70 observers: [
71 '_detectKeyboardFocus(focused)' 71 '_detectKeyboardFocus(focused)'
72 ], 72 ],
73 73
74 keyBindings: { 74 keyBindings: {
75 'enter:keydown': '_asyncClick', 75 'enter:keydown': '_asyncClick',
76 'space:keydown': '_spaceKeyDownHandler', 76 'space:keydown': '_spaceKeyDownHandler',
77 'space:keyup': '_spaceKeyUpHandler', 77 'space:keyup': '_spaceKeyUpHandler',
78 }, 78 },
79 79
80 _mouseEventRe: /^mouse/,
81
80 _tapHandler: function() { 82 _tapHandler: function() {
81 if (this.toggles) { 83 if (this.toggles) {
82 // a tap is needed to toggle the active state 84 // a tap is needed to toggle the active state
83 this._userActivate(!this.active); 85 this._userActivate(!this.active);
84 } else { 86 } else {
85 this.active = false; 87 this.active = false;
86 } 88 }
87 }, 89 },
88 90
89 _detectKeyboardFocus: function(focused) { 91 _detectKeyboardFocus: function(focused) {
90 this._setReceivedFocusFromKeyboard(!this.pointerDown && focused); 92 this._setReceivedFocusFromKeyboard(!this.pointerDown && focused);
91 }, 93 },
92 94
93 // to emulate native checkbox, (de-)activations from a user interaction fire 95 // to emulate native checkbox, (de-)activations from a user interaction fire
94 // 'change' events 96 // 'change' events
95 _userActivate: function(active) { 97 _userActivate: function(active) {
96 this.active = active; 98 this.active = active;
97 this.fire('change'); 99 this.fire('change');
98 }, 100 },
99 101
100 _downHandler: function() { 102 _eventSourceIsPrimaryInput: function(event) {
103 event = event.detail.sourceEvent || event;
104
105 // Always true for non-mouse events....
106 if (!this._mouseEventRe.test(event.type)) {
107 return true;
108 }
109
110 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
111 if ('buttons' in event) {
112 return event.buttons === 1;
113 }
114
115 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
116 if (typeof event.which === 'number') {
117 return event.which < 2;
118 }
119
120 // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
121 return event.button < 1;
122 },
123
124 _downHandler: function(event) {
125 if (!this._eventSourceIsPrimaryInput(event)) {
126 return;
127 }
128
101 this._setPointerDown(true); 129 this._setPointerDown(true);
102 this._setPressed(true); 130 this._setPressed(true);
103 this._setReceivedFocusFromKeyboard(false); 131 this._setReceivedFocusFromKeyboard(false);
104 }, 132 },
105 133
106 _upHandler: function() { 134 _upHandler: function() {
107 this._setPointerDown(false); 135 this._setPointerDown(false);
108 this._setPressed(false); 136 this._setPressed(false);
109 }, 137 },
110 138
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 190 }
163 191
164 }; 192 };
165 193
166 /** @polymerBehavior */ 194 /** @polymerBehavior */
167 Polymer.IronButtonState = [ 195 Polymer.IronButtonState = [
168 Polymer.IronA11yKeysBehavior, 196 Polymer.IronA11yKeysBehavior,
169 Polymer.IronButtonStateImpl 197 Polymer.IronButtonStateImpl
170 ]; 198 ];
171 199
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698