Sha256: 48419fde1392f35382ed70a5cf35750f16b625e5f9e5fc63331f35f5b3049d13

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

CodeSync.plugins.KeymapSelector = Backbone.View.extend
  className: "config-select 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)

  hideLabel: ()->
    @$('label').hide()

  showLabel: ()->
    @$('label').show()

  render: ()->
    options = ""

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

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

    @hideLabel() unless @visibleLabel

    @


CodeSync.plugins.KeymapSelector.setup = (editor)->
  v = @views.keymapSelector = new CodeSync.plugins.KeymapSelector({editor})
  @$('.toolbar-wrapper').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/plugins/keymap_selector.coffee