Sha256: 35cfe750feccf771575933d7ea908ab5bc251174ba8f9648cf8b9a4c5de84695

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'

# Handles Alchemy hotkeys
#
Alchemy.Hotkeys = (scope) ->
  $search_fields = $('#search_field, #search_input_field', scope)
  $search_fields_clear = $('.search_field_clear, .js_filter_field_clear', scope)

  # Binds keyboard shortcuts to searchfields
  keymage 'alt-f',
    ->
      $search_fields.focus()
      keymage.setScope('search')
    ,
    preventDefault: true
  keymage 'search', 'esc', ->
    $search_fields_clear.click()
    $search_fields.blur()

  # Binds click events to hotkeys
  #
  # Simply add a data-alchemy-hotkey attribute to your link.
  # If a hotkey is triggered by user, the click event of the element gets triggerd.
  #
  $('[data-alchemy-hotkey]').each ->
    $this = $(this)
    key = $this.data('alchemy-hotkey')
    keymage key, ->
      $this.click()

  keymage 'alt-w', ->
    Alchemy.CurrentWindow.dialog('close')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alchemy_cms-2.6.0.rc5 app/assets/javascripts/alchemy/alchemy.hotkeys.js.coffee