Skip to content

Commit

Permalink
[skip] Made cancelOnEsc and saveOnEnter options as well (5m)
Browse files Browse the repository at this point in the history
  • Loading branch information
boblail committed Apr 14, 2015
1 parent d9ec4be commit 33666a7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions vendor/assets/javascripts/neat/collection_editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ class window.Neat.CollectionEditor extends Backbone.View
templateOptions: {}
pageSize: 30
useKeyboardToChangeRows: true

keyDownHandlers:
ESC: -> @viewInEdit?.cancelEdit()
RETURN: -> @viewInEdit?.save()
cancelOnEsc: true
saveOnEnter: true
keyDownHandlers: {}

initialize: ->
@viewPath = @viewPath ? @resource
Expand Down Expand Up @@ -74,9 +73,15 @@ class window.Neat.CollectionEditor extends Backbone.View
$(@el).delegate '.header a', 'click', _.bind(@sort, @)
$(@el).delegate '.editor', 'keydown', _.bind(@onKeyDown, @)

if @cancelOnEsc
@keyDownHandlers['ESC'] = -> @viewInEdit?.cancelEdit()

if @saveOnEnter
@keyDownHandlers['RETURN'] = -> @viewInEdit?.save()

if @useKeyboardToChangeRows
@keyDownHandlers['UP'] = -> @edit @prevView()
@keyDownHandlers['DOWN'] = -> @edit @nextView()
@keyDownHandlers['UP'] = -> @edit @prevView()
@keyDownHandlers['DOWN'] = -> @edit @nextView()

@views = []
@viewInEdit = null
Expand Down

0 comments on commit 33666a7

Please sign in to comment.