define("core/userfeedback",["exports","core/ajax","core/notification"],(function(_exports,_ajax,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} /** * Handle clicking on action links of the feedback alert. * * @module core/userfeedback * @copyright 2020 Shamim Rezaie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.registerEventListeners=void 0,_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification);const Selectors={regions:{root:'[data-region="core/userfeedback"]'},actions:{}};Selectors.actions.give="".concat(Selectors.regions.root,' [data-action="give"]'),Selectors.actions.remind="".concat(Selectors.regions.root,' [data-action="remind"]');_exports.registerEventListeners=()=>{document.addEventListener("click",(e=>{const giveAction=e.target.closest(Selectors.actions.give);if(giveAction){if(e.preventDefault(),!window.open(giveAction.href))throw new Error("Unable to open popup");Promise.resolve(giveAction).then(hideRoot).then(recordAction).catch(_notification.default.exception)}const remindAction=e.target.closest(Selectors.actions.remind);remindAction&&(e.preventDefault(),Promise.resolve(remindAction).then(hideRoot).then(recordAction).catch(_notification.default.exception))}))};const recordAction=clickedItem=>clickedItem.dataset.record?_ajax.default.call([{methodname:"core_create_userfeedback_action_record",args:{action:clickedItem.dataset.action,contextid:M.cfg.contextid}}])[0]:Promise.resolve(),hideRoot=clickedItem=>(clickedItem.dataset.hide&&clickedItem.closest(Selectors.regions.root).remove(),clickedItem)})); //# sourceMappingURL=userfeedback.min.js.map