diagram.js.coffee 752 B

12345678910111213141516171819202122
  1. # This is not included in the core application.js bundle.
  2. $ ->
  3. svg = document.querySelector('.agent-diagram svg.diagram')
  4. overlay = document.querySelector('.agent-diagram .overlay')
  5. getTopLeft = (node) ->
  6. bbox = node.getBBox()
  7. point = svg.createSVGPoint()
  8. point.x = bbox.x + bbox.width
  9. point.y = bbox.y
  10. point.matrixTransform(node.getCTM())
  11. $(svg).find('g.node[data-badge-id]').each ->
  12. tl = getTopLeft(this)
  13. $('#' + this.getAttribute('data-badge-id'), overlay).each ->
  14. badge = $(this)
  15. badge.css
  16. left: tl.x - badge.outerWidth() * (2/3)
  17. top: tl.y - badge.outerHeight() * (1/3)
  18. 'background-color': badge.find('.label').css('background-color')
  19. .show()
  20. return
  21. return