ugly hack to implement no tooltips for legend items; commented out console.logs

This commit is contained in:
Sanj 2011-06-27 03:55:16 +05:30
parent 37b25ae3f4
commit 59e5664c46

View File

@ -21,10 +21,10 @@ $(function() {
}
$(this).click(function() {
console.log($(this).attr("id"));
// console.log($(this).attr("id"));
});
$(this).mouseover(function() {
console.log($(this).attr("id"));
// console.log($(this).attr("id"));
});
});
@ -46,23 +46,32 @@ $(function() {
if (R.hasOwnProperty(key)) {
thisData = R[key];
var $this = $(this);
if (key == 'Journalists') {
J = $this;
}
// $this.data("r", thisData);
$this.data("key", key);
$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,
'bodyHandler': function() {
var html = "<div class='ttWrapper'>";
html += "<div class='tooltipName'>" + $(this).data("name") + "</div>";
html += "<div class='padmaPosters'>" + getPostersHTML(PADMA[$(this).data("key")]) + "</div>";
html += "</div>";
return html;
}
});
// console.log($this.data("key"));
// console.log($this.hasTooltip());
if ($this.hasTooltip()) {
$this.tooltip({
'delay': 0,
'showURL': false,
'bodyHandler': function() {
var html = "<div class='ttWrapper'>";
html += "<div class='tooltipName'>" + $(this).data("name") + "</div>";
html += "<div class='padmaPosters'>" + getPostersHTML(PADMA[$(this).data("key")]) + "</div>";
html += "</div>";
return html;
}
});
} else {
// console.log(key);
}
$texts.push($this);
var highlightShadow = '2px 2px 1px #666';
@ -78,6 +87,7 @@ $(function() {
$this.mouseover(function(e) {
var typ = $(this).data("type");
if (typ === "") { return }
for (var i=0; i<$texts.length;i++) {
var $t = $texts[i];
if ($t.data("type") == typ) {
@ -90,6 +100,7 @@ $(function() {
$this.mouseout(function(e) {
var typ = $(this).data("type");
if (typ === '') { return; }
for (var i=0; i<$texts.length;i++) {
var $t = $texts[i];
if ($t.data("type") == typ) {
@ -121,3 +132,19 @@ function getPostersHTML(padma_ids) {
}
return html;
}
//silly hack to implement no tooltips for legend - but can also be extended to disable tooltips for some items.
jQuery.fn.hasTooltip = function() {
if (typeof(this.data("key")) == 'undefined') {
return false;
}
// console.log(parseInt(this.attr("x")));
if (parseInt(this.attr("x")) > 1200) {
if ($.inArray(this.data("key"), ["Journalists", "Corporates", "Vaishnavi", "Politicians", "Issues", "Mention of,"]) != -1) {
return false;
} else {
return true;
}
}
return true;
}