/* global jQuery */
'use strict';
/**
* Adds feedback functionality to all pages using jQuery.
* @namespace atlassianFeedback
* @memberof UCASDesignFramework
* @param {object} global - UCASDesignFramework object.
* @param {object} $ - jQuery.
*/
(function (global, $) {
global.atlassianFeedback = {}
/**
* Initialise the feedback system.
* See {@link https://confluence.atlassian.com/adminjiracloud/advanced-use-of-the-jira-issue-collector-788726105.html}
* We're only allowing for one feedback button with this.
* @function init
* @memberof! UCASDesignFramework.atlassianFeedback
* @public
*/
function init () {
var feedbackButton = $('[data-feedback-button]:first-of-type')
if (feedbackButton.length === 1) {
var feedbackUrl = feedbackButton.data('feedback-button')
// Create the script tag and add it to the body.
var script = document.createElement('script')
script.src = feedbackUrl
script.async = true
document.body.appendChild(script)
// Class is needed to override some of Atlassian's styling.
document.body.classList.add('atlassian-feedback')
// Add the Atlassian-provided code for the click handler.
window.ATL_JQ_PAGE_PROPS = {
'triggerFunction': function (showCollectorDialog) {
feedbackButton.click(function (e) {
showCollectorDialog()
e.preventDefault()
})
}
}
} else {
window.ATL_JQ_PAGE_PROPS = {
'triggerFunction': function (showCollectorDialog) {
$('.global-menu--feedback').click(function (e) {
showCollectorDialog()
e.preventDefault()
})
}
}
}
}
/**
* Assign public methods.
*/
global.atlassianFeedback = {
init: init
}
})(UCASDesignFramework, jQuery)