22 lines
778 B
JavaScript
22 lines
778 B
JavaScript
(function () {
|
|
function init() {
|
|
var logout = document.querySelector('[data-cab-logout]');
|
|
if (!logout || !window.BX || !BX.ajax || !BX.ajax.runAction) return;
|
|
logout.addEventListener('click', function () {
|
|
if (logout.getAttribute('aria-disabled') === 'true') return;
|
|
logout.setAttribute('aria-disabled', 'true');
|
|
BX.ajax.runAction('jinove:vinoteca.profile.logout', { data: { lang: document.documentElement.lang || 'en' } }).then(function (response) {
|
|
window.location.href = (response.data && response.data.redirect) || '/';
|
|
}, function () {
|
|
window.location.reload();
|
|
});
|
|
});
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', init);
|
|
} else {
|
|
init();
|
|
}
|
|
})();
|