Sha256: fb7a35fd6bb02d9146773ecc3253adb56a85b5ead57276df927bfee82e5f3cd6

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

class Ponytail.Views.PreviewCreateFile extends Backbone.View
  events:
    "click .edit_checkbox input": "clickEditCheckbox"
    "keyup .classname input": (e) ->
      @model.set({name: e.target.value})
    "keyup .raw_content textarea": (e) ->
      @model.set({raw_content: e.target.value})
    "click .create_button": "clickCreateButton"

  initialize: ->
    @model.bind("change", @render)

  render: =>
    @$(".raw_content pre code").text(@model.get("raw_content"))
    if !(@$(".raw_content textarea").is(":visible"))
      @$(".raw_content textarea").val(@model.get("raw_content"))
    @highlightCode()
    @

  highlightCode: ->
    for el in $('pre code')
      hljs.highlightBlock(el)

  clickEditCheckbox: ->
    @$(".raw_content pre").toggle()
    @$(".raw_content textarea").toggle()

  clickCreateButton: ->
    $.ajax
      dataType: 'json'
      url: '/ponytail/migrations'
      data:
        ponytail_migration:
          name: @model.get("name")
          raw_content: @model.get("raw_content")
      type: 'POST'
      success: -> window.location.href = "/ponytail/migrations"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ponytail-0.6.0 app/assets/javascripts/ponytail/views/preview_create_file.coffee