Sha256: 9296ea77c427ef769719e430dd8969e827c6a774c2c6f736e4a943589a1ce34b

Contents?: true

Size: 722 Bytes

Versions: 9

Compression:

Stored size: 722 Bytes

Contents

class Previewer
  constructor: (@el)->

  init: ->
    @el.on 'adhoq:updatePreview', => @update()

    @el.on 'click', =>
      @el.trigger 'adhoq:updatePreview'
      false

  update: ->
    jQuery.ajax(
      type: @el.data('method'),
      url:  @el.attr('href'),
      data: {query: @source()},
      complete: (xhr)=>
        @result().html(xhr.responseText)
    )

  source: ->
    $(@el.data('source')).val()

  result: ->
    $(@el.data('result'))

Adhoq.enablePreview = ($el)->
  (new Previewer($el)).init()

Adhoq.enablePreviewKeybordShortCut= ($textarea, previewSelector)->
  $textarea.on 'keyup', (ev)->
    if(ev.ctrlKey && ev.keyCode is 82)
      $(previewSelector).trigger('adhoq:updatePreview')

    false

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
adhoq-0.5.0 app/assets/javascripts/adhoq/previewer.js.coffee
adhoq-0.4.0 app/assets/javascripts/adhoq/previewer.js.coffee
adhoq-0.3.0 app/assets/javascripts/adhoq/previewer.js.coffee
adhoq-0.2.0 app/assets/javascripts/adhoq/previewer.js.coffee
adhoq-0.1.2 app/assets/javascripts/adhoq/previewer.js.coffee
adhoq-0.1.1 app/assets/javascripts/adhoq/previewer.js.coffee
adhoq-0.1.0 app/assets/javascripts/adhoq/previewer.js.coffee
adhoq-0.0.7 app/assets/javascripts/adhoq/previewer.js.coffee
adhoq-0.0.6 app/assets/javascripts/adhoq/previewer.js.coffee