From b92c02987c89b3d8018e0603c266c394502d85eb Mon Sep 17 00:00:00 2001 From: Julia Date: Thu, 22 Feb 2024 16:07:05 +0100 Subject: [PATCH 1/5] working base functionality --- config/testreport/css/default.css | 30 ++++++++++++++ config/testreport/js/crosshair.js | 64 +++++++++++++++++++++++++++++ config/xsl/common/sections/head.xsl | 1 + 3 files changed, 95 insertions(+) create mode 100644 config/testreport/js/crosshair.js diff --git a/config/testreport/css/default.css b/config/testreport/css/default.css index 2a6b2af0d..37a5ea800 100644 --- a/config/testreport/css/default.css +++ b/config/testreport/css/default.css @@ -1775,3 +1775,33 @@ tr:hover .infinity { background: linear-gradient(rgb(200,120,120), rgba(0,0,0,0) transform: rotate(360deg); } } + +.crosshair { + display: block; + position: relative; + overflow: hidden; +} +.crosshair img { + width: 100%; +} +.crosshair .hair { + display: none; + position: absolute; + top: 0; + left: 0; + margin-top: -1px; + margin-left: -1px; + background: transparent; + border-top: 1px solid black; + border-left: 1px solid black; + pointer-events: none; + z-index: 2; + opacity: 0.3; +} +.crosshair .hair.hair-vertical { + height: 100%; +} +.crosshair .hair.hair-horizontal { + width: 100%; +} + diff --git a/config/testreport/js/crosshair.js b/config/testreport/js/crosshair.js new file mode 100644 index 000000000..26b1cd70d --- /dev/null +++ b/config/testreport/js/crosshair.js @@ -0,0 +1,64 @@ +/* + * Based on crosshair.js - v0.1.0 + * https://github.com/eschmar/crosshair + */ + +(function ($) { + // constructor + function Plugin(element){ + $(element).wrap('
'); + this.element = $(element).parent(); + this.init(); + } + + Plugin.prototype = { + init: function() { + var app = this; + this.spawnCrosshair(); + + // hide crosshair onmouseleave + this.element.hover(function() { + app.element.find('.hair').show(); + }, function() { + app.element.find('.hair').hide(); + }); + }, + + spawnCrosshair: function() { + this.element.append('
'); + this.element.append('
'); + + this.initCrosshair(); + }, + + initCrosshair: function() { + var app = this; + $(this.element).on('mousemove touchmove', function(event) { + // calculate relative position + var offset, left, top; + offset = app.element.offset(); + left = event.pageX - offset.left; + top = event.pageY - offset.top; + + // update position + app.element.find('.hair.hair-horizontal').css('top', top); + app.element.find('.hair.hair-vertical').css('left', left); + + event.stopPropagation(); + }); + } + } + + // lightweight plugin wrapper, preventing against multiple instantiations + $.fn["crosshair"] = function () { + return this.each(function() { + if (!$.data(this, "crosshair")) { + $.data(this, "crosshair", new Plugin(this)) + }; + }); + }; + + $(function(){ + $('.chart').crosshair(); + }); +})( jQuery ); diff --git a/config/xsl/common/sections/head.xsl b/config/xsl/common/sections/head.xsl index 737bcaf75..2286bb2d7 100644 --- a/config/xsl/common/sections/head.xsl +++ b/config/xsl/common/sections/head.xsl @@ -36,6 +36,7 @@