radiaSVG/radia.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2011-06-24 15:45:19 +00:00
var R;
$(function() {
$.getJSON("radia.json", {}, function(data) {
R = data;
$('text').each(function() {
var $tspan = $(this).children('tspan').eq(0);
var key = $.trim($tspan.text());
if (R.hasOwnProperty(key)) {
thisData = R[key];
var $this = $(this);
// $this.data("r", thisData);
$this.data("name", thisData.name);
$this.data("type", thisData.type);
$this.data("link", thisData.link);
$this.tooltip({
'delay': 0,
'showURL': false,
'bodyHandler': function() {
return $(this).data("name");
}
});
/*
$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();
});
$this.mouseout(function(e) {
$('#tooltip').hide();
});
*/
$this.click(function() {
console.log($(this).data("link"));
});
}
});
});
});