/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. * * This Source Code Form is "Incompatible With Secondary Licenses", as * defined by the Mozilla Public License, v. 2.0. */ /** * Reference or define the Bugzilla app namespace. * @namespace */ var Bugzilla = Bugzilla || {}; // eslint-disable-line no-var /** * Provide the ability to insert a comment template when a patch's approval flag is selected. */ Bugzilla.FlagTypeComment = class FlagTypeComment { /** * Initialize a new FlagTypeComment instance. */ constructor() { this.templates = [...document.querySelectorAll('template.approval-request')]; this.$flags = document.querySelector('#flags'); this.$comment = document.querySelector('#comment'); if (this.$flags && this.$comment) { this.selects = [...this.$flags.querySelectorAll('.flag_select')]; this.selects.forEach($select => $select.addEventListener('change', () => this.flag_onselect($select))); this.$comment.form.addEventListener('submit', () => this.form_onsubmit()); } } /** * Check if a `
` is compatible with the given flag. For example, `approval‑mozilla‑beta` matches * `
` while `approval‑mozilla‑esr60` * matches `
`. * @param {String} name Flag name, such as `approval‑mozilla‑beta`. * @param {(HTMLFieldSetElement|HTMLTemplateElement)} $element `
` or `