OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * Javascript for Snackbar controls, served from chrome://bluetooth-internals/. | 6 * Javascript for Snackbar controls, served from chrome://bluetooth-internals/. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('snackbar', function() { | 9 cr.define('snackbar', function() { |
10 /** @typedef {{ | 10 /** @typedef {{ |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 * snackbar is already hidden, a resolved Promise is returned. | 96 * snackbar is already hidden, a resolved Promise is returned. |
97 * @return {!Promise} | 97 * @return {!Promise} |
98 */ | 98 */ |
99 dismiss: function() { | 99 dismiss: function() { |
100 this.stopTimeout_(); | 100 this.stopTimeout_(); |
101 | 101 |
102 if (!this.classList.contains('open')) | 102 if (!this.classList.contains('open')) |
103 return Promise.resolve(); | 103 return Promise.resolve(); |
104 | 104 |
105 return new Promise(function(resolve) { | 105 return new Promise(function(resolve) { |
106 listenOnce(this, 'webkitTransitionEnd', function() { | 106 listenOnce(this, 'transitionend', function() { |
107 this.dispatchEvent(new CustomEvent('dismissed')); | 107 this.dispatchEvent(new CustomEvent('dismissed')); |
108 resolve(); | 108 resolve(); |
109 }.bind(this)); | 109 }.bind(this)); |
110 | 110 |
111 ensureTransitionEndEvent(this, TRANSITION_DURATION); | 111 ensureTransitionEndEvent(this, TRANSITION_DURATION); |
112 this.classList.remove('open'); | 112 this.classList.remove('open'); |
113 | 113 |
114 document.removeEventListener('contentfocus', this.boundStartTimeout_); | 114 document.removeEventListener('contentfocus', this.boundStartTimeout_); |
115 document.removeEventListener('contentblur', this.boundStopTimeout_); | 115 document.removeEventListener('contentblur', this.boundStopTimeout_); |
116 }.bind(this)); | 116 }.bind(this)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return Promise.resolve(); | 229 return Promise.resolve(); |
230 }; | 230 }; |
231 | 231 |
232 | 232 |
233 | 233 |
234 return { | 234 return { |
235 Snackbar: Snackbar, | 235 Snackbar: Snackbar, |
236 SnackbarType: SnackbarType, | 236 SnackbarType: SnackbarType, |
237 }; | 237 }; |
238 }); | 238 }); |
OLD | NEW |