Dunlop.register_setup 'display_badges', (target)->
  target.find('.display-badge').click ->
    el = $(this)
    return if el.find('a').length # there is a link given in the badge
    content = $('.display-badge-info-content')
    popup = $('#display-badge-info-popup')
    data =
      resource: el.data('resource')
      id: el.data('id')
      state: el.data('state')
      workflow_instance_batch_id: el.data('workflowInstanceBatchId')
    data.target = el.data('target') if el.data('target')

    $.get "/dunlop/badge_info?#{$.param(data)}", (result)->
      content.html result
      popup.foundation 'reveal', 'open'
      Dunlop.setup content
