anchor.diff:      name: "Quotes"
       openWith: "> "
       className: 'button secondary tiny'
  -  #,
  -    #separator: "---------------"
  -  #,
  -    #name: 'Preview'
  -    #call: 'preview'
  -    #className: 'button tiny'
  +  ,
  +    separator: "---------------"
  +  ,
  +    name: 'Preview'
  +    replaceWith: (markItUp)->
  +      Neighborly.MarkdownPreviewer.init(markItUp)
  +    className: 'button tiny'
     ]
   
   
  
positive.code:     @markItUp = markItUp
      @id = "markItUpPictureUpload_#{markItUp.textarea.id}"
      this.createHtmlModal()
      this.attashEvents(markItUp)
  
      $("##{@id}").foundation 'reveal', 'open',
        'url': '<%= Rails.application.routes.url_helpers.new_image_url %>'
  
negative.code: 
      $("##{@id}").foundation('reveal', 'close')
  
    bindEvents: ->
      that = this
      $(document).on 'opened', "##{@id}", ->
        Initjs.initializePartial()
        that.bindEventsToView()
  
      $(document).on 'closed', "##{@id}", ->
        $("##{@id}").remove()
  
    bindEventsToView: ->
      that = this
      $("##{@id} .insert-image.button").unbind('click')
      $("##{@id} .insert-image.button").on 'click', (e)->
        e.preventDefault()
        that.insertMarkdownImage()
        return false
  
  Neighborly.MarkdownPreviewer =
    init: (markItUp)->
      @markItUp = markItUp
      @id = "markItUpMarkdownPreviewer_#{markItUp.textarea.id}"
      this.createHtmlModal()
      this.bindEvents(markItUp)
  
      $("##{@id}").foundation 'reveal', 'open',
        url: '<%= Rails.application.routes.url_helpers.markdown_previewer_index_url %>'
        method: 'POST'
        data: { markdown: markItUp.textarea.value }
  
      return false
  
    createHtmlModal: ->
      html = $('<div>').attr('id', @id).
                      attr('data-reveal', '').
                      addClass('reveal-modal medium')
      $('body').append(html)
  
    bindEvents: ->
      that = this
      $(document).on 'opened', "##{@id}", ->
        that.bindEventsToView()
  
      $(document).on 'closed', "##{@id}", ->
        $("##{@id}").remove()
  
    bindEventsToView: ->
      $("##{@id} .close.button").unbind('click')
      $("##{@id} .close.button").on 'click', (e)->
        e.preventDefault()
        $("##{@id}").foundation('reveal', 'close')
        return false
  