Sha256: eb6d71bcd28a30ef3f554909b2cd8dc4083e240a4709ef571d6ed4531e2f5f43
Contents?: true
Size: 1.46 KB
Versions: 9
Compression:
Stored size: 1.46 KB
Contents
jQuery -> Mousetrap.bind ['ctrl+s', 'command+s'], (e) -> $('form').submit() false # Hotkey binding to links with 'data-keybinding' attribute # Navigate link when hotkey pressed $('a[data-keybinding]').each (i, el) -> Mousetrap.bind $(el).data('keybinding'), (e) -> el.click() # Hotkey binding to inputs with 'data-keybinding' attribute # Focus input when hotkey pressed $('input[data-keybinding]').each (i, el) -> Mousetrap.bind $(el).data('keybinding'), (e) -> el.focus() if e.preventDefault e.preventDefault() else e.returnValue = false # Toggle show/hide hotkey hints window.mouseTrapRails = showOnLoad: false # Show/hide hotkey hints by default (on page load). Mostly for debugging purposes. toggleKeys: 'alt+shift+h' # Key sequence to toggle hints visibility. keysShown: false toggleHints: -> $('a[data-keybinding]').each (i, el) -> $el = $(el) if mouseTrapRails.keysShown $el.removeClass('mt-hotkey-el').find('.mt-hotkey-hint').remove() else mtKey = $el.data('keybinding') $hint = "<i class='mt-hotkey-hint' title='Press \<#{mtKey}\> to open link'>#{mtKey}</i>" $el.addClass('mt-hotkey-el') unless $el.css('position') is 'absolute' $el.append $hint @keysShown ^= true Mousetrap.bind mouseTrapRails.toggleKeys, -> mouseTrapRails.toggleHints() mouseTrapRails.toggleHints() if mouseTrapRails.showOnLoad
Version data entries
9 entries across 9 versions & 1 rubygems