summaryrefslogtreecommitdiffstats
path: root/extensions/Review/web/js/badge.js
diff options
context:
space:
mode:
authorKohei Yoshino <kohei.yoshino@gmail.com>2018-01-18 06:14:54 +0100
committerDylan William Hardison <dylan@hardison.net>2018-01-18 06:14:54 +0100
commit756178234538ee61346c556f2bdf05a497900351 (patch)
tree5f970f9ef11d524923ae42a4a41505f85e5eafb7 /extensions/Review/web/js/badge.js
parente2b621f203f140e03ff3b23104791ef37e3668a4 (diff)
downloadbugzilla-756178234538ee61346c556f2bdf05a497900351.tar.gz
bugzilla-756178234538ee61346c556f2bdf05a497900351.tar.xz
Bug 1430495 - Make loading of Requests dropdown faster
Diffstat (limited to 'extensions/Review/web/js/badge.js')
-rw-r--r--extensions/Review/web/js/badge.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/extensions/Review/web/js/badge.js b/extensions/Review/web/js/badge.js
index ea09ed116..8580c0ba1 100644
--- a/extensions/Review/web/js/badge.js
+++ b/extensions/Review/web/js/badge.js
@@ -26,12 +26,14 @@ Bugzilla.Review.Badge = class Badge {
* @returns {Badge} New Badge instance.
*/
constructor() {
+ this.initialized = false;
this.$button = document.querySelector('#header-requests-menu-button');
this.$panel = document.querySelector('#header-requests .dropdown-panel');
this.$loading = document.querySelector('#header-requests .dropdown-panel .loading');
if (this.$loading) {
- this.$button.addEventListener('click', () => this.init(), { once: true });
+ this.$button.addEventListener('mouseover', () => this.init(), { once: true });
+ this.$button.addEventListener('focus', () => this.init(), { once: true });
}
}
@@ -39,6 +41,12 @@ Bugzilla.Review.Badge = class Badge {
* Initialize the Reviews dropdown menu.
*/
async init() {
+ if (this.initialized) {
+ return;
+ }
+
+ this.initialized = true;
+
const url = this.$panel.querySelector('footer a').href + '&ctype=json';
const response = await fetch(url, { credentials: 'same-origin' });
const _requests = response.ok ? await response.json() : [];