Newer
Older
if(areHotKeysEnabled())
{
window.location.href = rootURL + '/transactions/newTransaction/normal';
}
if(areHotKeysEnabled())
{
window.location.href = rootURL + '/transactions/newTransaction/transfer';
}

Robert Goldmann
committed
Mousetrap.bind('v', function()
{
if(areHotKeysEnabled())
{
window.location.href = rootURL + '/templates';

Robert Goldmann
committed
}
});
Mousetrap.bind('f', function()
{
if(areHotKeysEnabled())
{
window.location.href = rootURL + '/transactions#modalFilter';
}
if(areHotKeysEnabled())
{
document.getElementById('search').focus();
Mousetrap.bind('esc', function()
{
if(isSearchFocused())
{
document.getElementById('nav-logo-container').focus();
}
});
Mousetrap.bind('o', function()
{
if(areHotKeysEnabled())
{
window.location.href = rootURL + '/transactions';
}
});
let saveTransactionOrTemplateButton = document.getElementById('button-save-transaction');
if(saveTransactionOrTemplateButton !== null)
{
Mousetrap(document.querySelector('body')).bind('mod+enter', function(e)
{
document.getElementById('button-save-transaction').click();
});
}
function areHotKeysEnabled()
{
return !isSearchFocused() && !isCustomSelectFocused() && !isTemplateSearchFocused();
let searchElement = document.getElementById('search');
return document.activeElement === searchElement;
}
function isTemplateSearchFocused()
{
let templateSearchElement = document.getElementById('searchTemplate');
return document.activeElement === templateSearchElement;
}
function isCustomSelectFocused()
let customSelects = document.querySelectorAll('.custom-select');
for(let i = 0; i < customSelects.length; i++)
if(customSelects[i].classList.contains('open'))
{
return true;
}
return false;