OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Bubble implementation. | 6 * @fileoverview Bubble implementation. |
7 */ | 7 */ |
8 | 8 |
9 // TODO(xiyuan): Move this into shared. | 9 // TODO(xiyuan): Move this into shared. |
10 cr.define('cr.ui', function() { | 10 cr.define('cr.ui', function() { |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // Anchor element | 32 // Anchor element |
33 anchor_: undefined, | 33 anchor_: undefined, |
34 | 34 |
35 /** @inheritDoc */ | 35 /** @inheritDoc */ |
36 decorate: function() { | 36 decorate: function() { |
37 this.ownerDocument.addEventListener('click', | 37 this.ownerDocument.addEventListener('click', |
38 this.handleDocClick_.bind(this)); | 38 this.handleDocClick_.bind(this)); |
39 this.ownerDocument.addEventListener('keydown', | 39 this.ownerDocument.addEventListener('keydown', |
40 this.handleDocKeyDown_.bind(this)); | 40 this.handleDocKeyDown_.bind(this)); |
| 41 window.addEventListener('blur', this.handleWindowBlur_.bind(this)); |
41 this.addEventListener('webkitTransitionEnd', | 42 this.addEventListener('webkitTransitionEnd', |
42 this.handleTransitionEnd_.bind(this)); | 43 this.handleTransitionEnd_.bind(this)); |
43 }, | 44 }, |
44 | 45 |
45 /** | 46 /** |
46 * Sets the attachment of the bubble. | 47 * Sets the attachment of the bubble. |
47 * @param {!Attachment} attachment Bubble attachment. | 48 * @param {!Attachment} attachment Bubble attachment. |
48 */ | 49 */ |
49 setAttachment_: function (attachment) { | 50 setAttachment_: function (attachment) { |
50 for (var k in Bubble.Attachment) { | 51 for (var k in Bubble.Attachment) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 this.hide(); | 209 this.hide(); |
209 }, | 210 }, |
210 | 211 |
211 /** | 212 /** |
212 * Handle of document keydown event. | 213 * Handle of document keydown event. |
213 * @private | 214 * @private |
214 */ | 215 */ |
215 handleDocKeyDown_: function(e) { | 216 handleDocKeyDown_: function(e) { |
216 if (!this.hidden) | 217 if (!this.hidden) |
217 this.hide(); | 218 this.hide(); |
| 219 }, |
| 220 |
| 221 /** |
| 222 * Handler of window blur event. |
| 223 * @private |
| 224 */ |
| 225 handleWindowBlur_: function(e) { |
| 226 if (!this.hidden) |
| 227 this.hide(); |
218 } | 228 } |
219 }; | 229 }; |
220 | 230 |
221 return { | 231 return { |
222 Bubble: Bubble | 232 Bubble: Bubble |
223 }; | 233 }; |
224 }); | 234 }); |
OLD | NEW |