| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 // Whether to hide bubble when key is pressed. | 55 // Whether to hide bubble when key is pressed. |
| 56 hideOnKeyPress_: true, | 56 hideOnKeyPress_: true, |
| 57 | 57 |
| 58 /** @override */ | 58 /** @override */ |
| 59 decorate: function() { | 59 decorate: function() { |
| 60 this.docKeyDownHandler_ = this.handleDocKeyDown_.bind(this); | 60 this.docKeyDownHandler_ = this.handleDocKeyDown_.bind(this); |
| 61 this.selfClickHandler_ = this.handleSelfClick_.bind(this); | 61 this.selfClickHandler_ = this.handleSelfClick_.bind(this); |
| 62 this.ownerDocument.addEventListener('click', | 62 this.ownerDocument.addEventListener('click', |
| 63 this.handleDocClick_.bind(this)); | 63 this.handleDocClick_.bind(this)); |
| 64 // Set useCapture to true because scroll event does not bubble. |
| 65 this.ownerDocument.addEventListener('scroll', |
| 66 this.handleScroll_.bind(this), |
| 67 true); |
| 64 this.ownerDocument.addEventListener('keydown', | 68 this.ownerDocument.addEventListener('keydown', |
| 65 this.docKeyDownHandler_); | 69 this.docKeyDownHandler_); |
| 66 window.addEventListener('blur', this.handleWindowBlur_.bind(this)); | 70 window.addEventListener('blur', this.handleWindowBlur_.bind(this)); |
| 67 this.addEventListener('webkitTransitionEnd', | 71 this.addEventListener('webkitTransitionEnd', |
| 68 this.handleTransitionEnd_.bind(this)); | 72 this.handleTransitionEnd_.bind(this)); |
| 69 // Guard timer for 200ms + epsilon. | 73 // Guard timer for 200ms + epsilon. |
| 70 ensureTransitionEndEvent(this, 250); | 74 ensureTransitionEndEvent(this, 250); |
| 71 }, | 75 }, |
| 72 | 76 |
| 73 /** | 77 /** |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 */ | 298 */ |
| 295 handleTransitionEnd_: function(e) { | 299 handleTransitionEnd_: function(e) { |
| 296 if (this.classList.contains('faded')) { | 300 if (this.classList.contains('faded')) { |
| 297 this.hidden = true; | 301 this.hidden = true; |
| 298 if (this.elementToFocusOnHide_) | 302 if (this.elementToFocusOnHide_) |
| 299 this.elementToFocusOnHide_.focus(); | 303 this.elementToFocusOnHide_.focus(); |
| 300 } | 304 } |
| 301 }, | 305 }, |
| 302 | 306 |
| 303 /** | 307 /** |
| 308 * Handler of scroll event. |
| 309 * @private |
| 310 */ |
| 311 handleScroll_: function(e) { |
| 312 if (!this.hidden) |
| 313 this.hide(); |
| 314 }, |
| 315 |
| 316 /** |
| 304 * Handler of document click event. | 317 * Handler of document click event. |
| 305 * @private | 318 * @private |
| 306 */ | 319 */ |
| 307 handleDocClick_: function(e) { | 320 handleDocClick_: function(e) { |
| 308 // Ignore clicks on anchor element. | 321 // Ignore clicks on anchor element. |
| 309 if (e.target == this.anchor_) | 322 if (e.target == this.anchor_) |
| 310 return; | 323 return; |
| 311 | 324 |
| 312 if (!this.hidden) | 325 if (!this.hidden) |
| 313 this.hide(); | 326 this.hide(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 handleWindowBlur_: function(e) { | 365 handleWindowBlur_: function(e) { |
| 353 if (!this.hidden) | 366 if (!this.hidden) |
| 354 this.hide(); | 367 this.hide(); |
| 355 } | 368 } |
| 356 }; | 369 }; |
| 357 | 370 |
| 358 return { | 371 return { |
| 359 Bubble: Bubble | 372 Bubble: Bubble |
| 360 }; | 373 }; |
| 361 }); | 374 }); |
| OLD | NEW |