# Code coverage report for lib/TooltipHandler.js

## Statements: 21.05% (4 / 19) Branches: 100% (0 / 0) Functions: 0% (0 / 2) Lines: 21.05% (4 / 19) Ignored: none

All files » lib/ » TooltipHandler.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43

    1
    1

    1

    1"use strict";

    var d3 = require("d3");
    var _ = require("underscore");

    var tooltipHandler = function(d) {
    	d3.select('.fv-tooltip-container')
    				.style('left',d3.event.pageX + 'px')
    				.style('top',d3.event.pageY + 'px')
    				.transition(200)
    				.style('opacity',1)
    				.style('display','block');

    	d3.select('.fv-tooltip-container table').remove();

    	var table = d3.select('.fv-tooltip-container').append('table');

    	var descRow = table.append('tr');

    	descRow.append('th')
    			.attr('colspan',2)
    			.text(d.description);

    	var startEndRow = table.append('tr');
    	startEndRow.append('td').text('Position');
    	startEndRow.append('td').text(d.begin + '-' + d.end);

    	_.each(d.evidences, function(e,i){
    		var typeRow = table.append('tr');
    		typeRow.append('td').text('Type');
    		typeRow.append('td').text(e.type);

    		var sourceRow = table.append('tr');
    		sourceRow.append('td').text('Source');
    		sourceRow.append('td').text(e.source.dbReferenceType + ': ')
    					.append('a')
    					.attr('href', e.source.url)
    					.text(e.source.dbReferenceId);
    	});

    };

    module.exports = tooltipHandler;