test basic highlighting - svg does not seem to allow a class attr..

This commit is contained in:
Sanj 2011-06-24 21:38:29 +05:30
parent ba079a4ae9
commit 23e38e90e4
2 changed files with 28 additions and 7 deletions

View File

@ -4,3 +4,7 @@
position: absolute; position: absolute;
display: none; display: none;
} }
.highlighted {
font-weight: bold;
}

View File

@ -1,8 +1,10 @@
var R; var R;
$(function() { $(function() {
$.getJSON("radia.json", {}, function(data) { $.getJSON("radia.json", {}, function(data) {
R = data; R = data;
var $texts = [];
$('text').each(function() { $('text').each(function() {
var $tspan = $(this).children('tspan').eq(0); var $tspan = $(this).children('tspan').eq(0);
var key = $.trim($tspan.text()); var key = $.trim($tspan.text());
@ -13,7 +15,7 @@ $(function() {
$this.data("name", thisData.name); $this.data("name", thisData.name);
$this.data("type", thisData.type); $this.data("type", thisData.type);
$this.data("link", thisData.link); $this.data("link", thisData.link);
$this.addClass(thisData.type);
$this.tooltip({ $this.tooltip({
'delay': 0, 'delay': 0,
'showURL': false, 'showURL': false,
@ -21,17 +23,31 @@ $(function() {
return $(this).data("name"); return $(this).data("name");
} }
}); });
/* $texts.push($this);
$this.mouseover(function(e) { $this.mouseover(function(e) {
var tooltipText = $(this).data("name"); var typ = $(this).data("type");
// console.log(tooltipText); for (var i=0; i<$texts.length;i++) {
$('#tooltip').text(tooltipText).css({'left': e.clientX + "px", "top": e.clientY + "px"}).show(); var $t = $texts[i];
if ($t.data("type") == typ) {
$t.css({'fontWeight': 'bold'});
}
}
// $('.' + cls).addClass("highlighted");
// console.log($('.' + cls).length);
}); });
$this.mouseout(function(e) { $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() { $this.click(function() {
console.log($(this).data("link")); console.log($(this).data("link"));
}); });
@ -39,3 +55,4 @@ $(function() {
}); });
}); });
}); });