Sha256: f22a732bef8d6daf7fbeef88fa24cec7d39c39f528c38b67f5272aea53a2e8de

Contents?: true

Size: 1.94 KB

Versions: 3

Compression:

Stored size: 1.94 KB

Contents

class window.HelpModal

  shortcuts: [
    {key: 'F'      , desc: 'Enter full screen mode'}
    {key: 'S'      , desc: 'Open the notes window'}
    {key: 'Esc'    , desc: 'Zoom to the overview screen'}
    {key: 'Return' , desc: 'Select slide from overview screen'}
    {key: 'Space'  , desc: 'Next slide or select slide from overview screen'}
    {key: '.'      , desc: 'Pause the presentation'   , key_alt: 'b'}
    {key: '→' , desc: 'Navigate right'           , key_alt: 'l'}
    {key: '←' , desc: 'Navigate left'            , key_alt: 'h'}
    {key: '↑' , desc: 'Navigate up'              , key_alt: 'k'}
    {key: '↓' , desc: 'Navigate down'            , key_alt: 'j'}
    {key: 'p'      , desc: 'Previous slide'           , key_alt: 'Page Up'}
    {key: 'n'      , desc: 'Next slide'               , key_alt: 'Page Down'}
    {key: 'home'   , desc: 'Jump to first slide'}
    {key: 'end'    , desc: 'Jump to last slide'}
    {key: '?'      , desc: 'Toggles the help modal'}
  ]


  constructor: (@reveal) ->
    @help = null
    @is_active = false
    document.addEventListener 'keydown', => @keyed arguments...


  keyed: (e) ->
    if e.shiftKey and e.keyCode is 191
      if @is_active then @remove() else @add()


  add: ->
    @is_active = true
    @render() unless @help
    document.body.appendChild @help


  remove: ->
    @is_active = false
    document.body.removeChild @help


  render: ->
    div = document.createElement 'div'
    div.className = 'help-modal'
    div.innerHTML = @markup()
    @help = document.body.appendChild div


  markup: ->
    html = """
           <p class="shortcut-title">Keyboard Shortcuts</p>
           #{@row shortcut for shortcut in @shortcuts}
           """
    html.replace /\,/g, ''


  row: (shortcut) ->
    """
    <p>
      <span>#{shortcut.desc}</span>
      <code>#{shortcut.key}</code>
      #{if shortcut.key_alt then ' <small>or</small> <code>' + shortcut.key_alt + '</code>' else ''}
    </p>
    """

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
showboat-0.0.3 app/assets/javascripts/showboat/plugins/help_modal.coffee
showboat-0.0.2 app/assets/javascripts/showboat/plugins/help_modal.coffee
showboat-0.0.1 app/assets/javascripts/showboat/plugins/help_modal.coffee