Sha256: ff47b398883f7f11b7970ccf4ed20708f74f4f45213533504c4b0d39d1169fca

Contents?: true

Size: 816 Bytes

Versions: 1

Compression:

Stored size: 816 Bytes

Contents

CodeSync.plugins.KeymapSelector = Backbone.View.extend
  className: "keymap-selector"

  events:
    "change select" : "onSelect"

  initialize: (options={})->
    @editor = options.editor

    @editor.on "change:keymap",  (keyMap)=>
      @setValue(keyMap)

    Backbone.View::initialize.apply(@, arguments)

  onSelect: ()->
    selected = @$('select').val()
    @editor.setKeyMap(selected)

  setValue: (val)->
    @$('select').val(val)

  render: ()->
    options = ""

    for mode in ["default","vim"]
      options += "<option value='#{ mode }'>#{ mode }</option>"

    @$el.html("<select>#{ options }</select>")

    @


CodeSync.plugins.KeymapSelector.setup = (editor)->
  v = @views.keymapSelector = new CodeSync.plugins.KeymapSelector({editor})

  editor.$('.codesync-asset-editor').append v.render().el

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
code_sync-0.6.7 lib/assets/javascripts/code_sync/editor/views/keymap_selector.coffee