File size: 1,639 Bytes
465d267 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /*!
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
import { DirectiveBinding } from 'vue';
import { Matomo } from 'CoreHome';
import ClickEvent = JQuery.ClickEvent;
const { $ } = window;
interface PluginManagementState {
uninstallConfirmMessage?: string;
}
function onClickUninstall(binding: DirectiveBinding<PluginManagementState>, event: ClickEvent) {
event.preventDefault();
const link = $(event.target as HTMLElement).attr('href');
const pluginName = $(event.target as HTMLElement).attr('data-plugin-name');
if (!link || !pluginName) {
return;
}
if (!binding.value.uninstallConfirmMessage) {
binding.value.uninstallConfirmMessage = $('#uninstallPluginConfirm').text();
}
const messageToDisplay = (binding.value.uninstallConfirmMessage || '').replace('%s', pluginName);
$('#uninstallPluginConfirm').text(messageToDisplay);
Matomo.helper.modalConfirm('#confirmUninstallPlugin', {
yes: () => {
window.location.href = link;
},
});
}
function onDonateLinkClick(event: ClickEvent) {
event.preventDefault();
const overlayId = $(event.target as HTMLElement).data('overlay-id') as string;
Matomo.helper.modalConfirm(`#${overlayId}`, {});
}
export default {
mounted(el: HTMLElement, binding: DirectiveBinding<PluginManagementState>): void {
setTimeout(() => {
binding.value.uninstallConfirmMessage = '';
$(el).find('.uninstall').click(onClickUninstall.bind(null, binding));
$(el).find('.plugin-donation-link').click(onDonateLinkClick);
});
},
};
|