Sha256: b942ad77dba5d06d84af2b4cc8c765a7f764f57d3cb203ab181efe7a48c87e30

Contents?: true

Size: 1007 Bytes

Versions: 3

Compression:

Stored size: 1007 Bytes

Contents

window.NoteView = Backbone.View.extend
  el: "body"
  events:
    "click .editor-toolbar .edit a": "toggleEditView"
    "click .editor-toolbar .preview a": "togglePreviewView"

  initialize: (opts) ->
    $("<div id='preview' class='markdown form-control' style='display:none;'></div>").insertAfter( $('#note_body') )
    window._editor = new Editor()

  toggleEditView: (e) ->
    $(e.target).parent().addClass('active')
    $('.preview a').parent().removeClass('active')
    $('#preview').hide()
    $('#note_body').show()
    false

  togglePreviewView: (e) ->
    $(e.target).parent().addClass('active')
    $('.edit a').parent().removeClass('active')
    $('#preview').html('Loading...')
    $('#note_body').hide()
    $('#preview').show()
    $.post '/notes/preview', {body: $('#note_body').val()}, (data)->
      $('#preview').html(data)
      false
    false

document.addEventListener 'turbolinks:load',  ->
  if $('body').data('controller-name') in ['notes']
    window._noteView = new NoteView()

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
homeland-note-0.2.0 app/assets/javascripts/homeland/note/application.coffee
homeland-note-0.1.3 app/assets/javascripts/homeland/note/application.coffee
homeland-note-0.1.2 app/assets/javascripts/homeland/note/application.coffee