Sha256: 990b3eeb6e7005ab8afda646853a4d3e44968cfbf13472a607177322214d348d

Contents?: true

Size: 1013 Bytes

Versions: 2

Compression:

Stored size: 1013 Bytes

Contents

CodeSync.NameInput = Backbone.View.extend
  className: "asset-name-input"

  events:
    "change input" : "updateEditor"
    "keyup input": "updateEditor"
    "blur input": "toggle"

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

    _.bindAll(@,"_updateEditor","updateEditor","toggle")
    @_updateEditor = _.debounce(CodeSync.NameInput::_updateEditor, 300)

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

  render: ()->
    @$el.append("<input type='text' placeholder='Enter the name of the asset' />")
    @$el.hide()
    @

  updateEditor: ()->
    @_updateEditor()

  _updateEditor: ()->
    assetName = @$('input').val()

    if assetName.match(/\./)
      @editor.currentName = assetName

      mode = @editor.determineModeFor(assetName)

  setValue: (value)->
    @$('input').val value

  getValue: ()->
    @$('input').val()

  toggle: ()->
    if @getValue()?.length is 0
      @editor.setDefaultExtension()
      @editor.currentName = @editor.currentPath = undefined

    @$el.toggle()

Version data entries

2 entries across 1 versions & 1 rubygems

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