highlight.js 928 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Creates a floating translucent div at the specified location in order to highlight a particular
  3. * element. Note that these scripts are run directly in the browser under test, so they need to
  4. * be ES5 compatible and serializable.
  5. */
  6. exports.HIGHLIGHT_FN = function(top, left, width, height) {
  7. console.log('Highlighting at ', top, left, width, height);
  8. var el = document.createElement('div');
  9. el.id = 'BP_ELEMENT_HIGHLIGHT__';
  10. document.body.appendChild(el);
  11. el.style['position'] = 'absolute';
  12. el.style['background-color'] = 'lightblue';
  13. el.style['opacity'] = '0.7';
  14. el.style['top'] = top + 'px';
  15. el.style['left'] = left + 'px';
  16. el.style['width'] = width + 'px';
  17. el.style['height'] = height + 'px';
  18. };
  19. /**
  20. * Removes the highlight
  21. */
  22. exports.REMOVE_HIGHLIGHT_FN = function() {
  23. var el = document.getElementById('BP_ELEMENT_HIGHLIGHT__');
  24. if (el) {
  25. el.parentElement.removeChild(el);
  26. }
  27. };