Skip to content

Instantly share code, notes, and snippets.

@mmun
Created December 19, 2013 04:07
Show Gist options
  • Save mmun/8034276 to your computer and use it in GitHub Desktop.
Save mmun/8034276 to your computer and use it in GitHub Desktop.
Cm.GradingSidebarView = Em.View.extend Cm.Shortcuts,
...
didInsertElement: ->
@registerShortcuts [
{ keys: ['shift+up', 'k'], action: 'goToPrevExam' }
{ keys: ['shift+down', 'j'], action: 'goToNextExam' }
{ keys: ['shift+left', 'h', '['], action: 'goToPrevQuestion' }
{ keys: ['shift+right', 'l', ']'], action: 'goToNextQuestion' }
{ keys: 'u', action: 'toggleSkipMarked' }
{ keys: 'f', action: 'toggleQuestionFlag' }
{ keys: 'c', action: 'toggleCommentMode' }
{ keys: 'x', action: 'clearPoints' }
], target: 'controller'
willDestroyElement: ->
@unregisterShortcuts()
...
Cm.CommentTextView = Em.TextArea.extend Cm.Shortcuts,
...
didInsertElement: ->
@$().focus()
Em.run.scheduleOnce 'afterRender', =>
text = @$().val()
@$().val("").val(text)
@registerShortcuts [
{ keys: 'shift+enter', action: 'save' }
{ keys: 'esc', action: 'cancel' }
], source: @get('element'), ignoreControls: false
willDestroyElement: ->
@unregisterShortcuts(source: @get('element'))
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment