define('jira/field/init-assignee-pickers', ['jira/field/assignee-picker', 'jira/util/users/logged-in-user', 'jira/util/events', 'jira/util/events/types', 'jira/util/events/reasons', 'jquery', 'jira/skate'], function (AssigneePicker, LoggedInUser, Events, Types, Reasons, $, skate) { /** * On IE7 it takes a href like '#assignee' and returns http:/x.x.x./x/x#assignee. Why. why */ function getHashedLinkTarget(url) { var hashIndex = url.indexOf('#'); return hashIndex !== -1 ? url.substring(hashIndex) : url; } /** * This will add a click vent to the the assigned to me link of the assignee field so that it selects * the current user in the assignee select box * * @param {jQuery | HTMLElement} context - the context used for selection */ function wireAssignToMeLink(context) { $('#assign-to-me-trigger', context).click(function (e) { e.preventDefault(); var url = $(this).attr('href'); var assigneeId = getHashedLinkTarget(url); var username = LoggedInUser.username(); var assigneeSelect = $(assigneeId, context); if ($(assigneeId + '-single-select', context).length) { assigneeSelect.trigger('set-selection-value', username); } else { // Set the old-school