Skip to content
Snippets Groups Projects
Select Git revision
  • c607e4e09335a44e5bd2268530b7d083b9f8276f
  • master default
  • v1.0.0
3 results

README.md

Blame
  • To learn more about this project, read the wiki.
    hotkeys.js 2.01 KiB
    Mousetrap.bind('n', function()
    {
        if(areHotKeysEnabled())
        {
            window.location.href = rootURL + '/transactions/newTransaction/normal';
        }
    });
    
    Mousetrap.bind('t', function()
    {
        if(areHotKeysEnabled())
        {
            window.location.href = rootURL + '/transactions/newTransaction/transfer';
        }
    });
    
    Mousetrap.bind('v', function()
    {
        if(areHotKeysEnabled())
        {
            window.location.href = rootURL + '/templates';
        }
    });
    
    Mousetrap.bind('f', function()
    {
        if(areHotKeysEnabled())
        {
            window.location.href = rootURL + '/transactions#modalFilter';
        }
    });
    
    Mousetrap.bind('s', function(e)
    {
        if(areHotKeysEnabled())
        {
            document.getElementById('search').focus();
            e.preventDefault();
        }
    });
    
    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();
    }