From 23e38e90e4807f7b715bf5400cf5ae29a5bc0dee Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 24 Jun 2011 21:38:29 +0530 Subject: [PATCH] test basic highlighting - svg does not seem to allow a class attr.. --- radia.css | 4 ++++ radia.js | 31 ++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/radia.css b/radia.css index 4730c79..d5ef704 100644 --- a/radia.css +++ b/radia.css @@ -4,3 +4,7 @@ position: absolute; display: none; } + +.highlighted { + font-weight: bold; +} diff --git a/radia.js b/radia.js index d0003bc..ca26177 100644 --- a/radia.js +++ b/radia.js @@ -1,8 +1,10 @@ var R; + $(function() { $.getJSON("radia.json", {}, function(data) { R = data; + var $texts = []; $('text').each(function() { var $tspan = $(this).children('tspan').eq(0); var key = $.trim($tspan.text()); @@ -13,7 +15,7 @@ $(function() { $this.data("name", thisData.name); $this.data("type", thisData.type); $this.data("link", thisData.link); - + $this.addClass(thisData.type); $this.tooltip({ 'delay': 0, 'showURL': false, @@ -21,17 +23,31 @@ $(function() { return $(this).data("name"); } }); -/* + $texts.push($this); + $this.mouseover(function(e) { - var tooltipText = $(this).data("name"); -// console.log(tooltipText); - $('#tooltip').text(tooltipText).css({'left': e.clientX + "px", "top": e.clientY + "px"}).show(); + var typ = $(this).data("type"); + for (var i=0; i<$texts.length;i++) { + var $t = $texts[i]; + if ($t.data("type") == typ) { + $t.css({'fontWeight': 'bold'}); + } + } +// $('.' + cls).addClass("highlighted"); +// console.log($('.' + cls).length); }); $this.mouseout(function(e) { - $('#tooltip').hide(); + var typ = $(this).data("type"); + for (var i=0; i<$texts.length;i++) { + var $t = $texts[i]; + if ($t.data("type") == typ) { + $t.css({'fontWeight': 'normal'}); + } + } +// $('.' + cls).removeClass("highlighted"); }); -*/ + $this.click(function() { console.log($(this).data("link")); }); @@ -39,3 +55,4 @@ $(function() { }); }); }); +