diagram.js.coffee 811 B

1234567891011121314151617181920212223
  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. $(overlay).width($(svg).width()).height($(svg).height())
  6. getTopLeft = (node) ->
  7. bbox = node.getBBox()
  8. point = svg.createSVGPoint()
  9. point.x = bbox.x + bbox.width
  10. point.y = bbox.y
  11. point.matrixTransform(node.getCTM())
  12. $(svg).find('g.node[data-badge-id]').each ->
  13. tl = getTopLeft(this)
  14. $('#' + this.getAttribute('data-badge-id'), overlay).each ->
  15. badge = $(this)
  16. badge.css
  17. left: tl.x - badge.outerWidth() * (2/3)
  18. top: tl.y - badge.outerHeight() * (1/3)
  19. 'background-color': badge.find('.label').css('background-color')
  20. .show()
  21. return
  22. return