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() { $(this).click(function() {
console.log($(this).attr("id")); // console.log($(this).attr("id"));
}); });
$(this).mouseover(function() { $(this).mouseover(function() {
console.log($(this).attr("id")); // console.log($(this).attr("id"));
}); });
}); });
@ -46,23 +46,32 @@ $(function() {
if (R.hasOwnProperty(key)) { if (R.hasOwnProperty(key)) {
thisData = R[key]; thisData = R[key];
var $this = $(this); var $this = $(this);
if (key == 'Journalists') {
J = $this;
}
// $this.data("r", thisData); // $this.data("r", thisData);
$this.data("key", key); $this.data("key", key);
$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.addClass(thisData.type);
$this.tooltip({ // console.log($this.data("key"));
'delay': 0, // console.log($this.hasTooltip());
'showURL': false, if ($this.hasTooltip()) {
'bodyHandler': function() { $this.tooltip({
var html = "<div class='ttWrapper'>"; 'delay': 0,
html += "<div class='tooltipName'>" + $(this).data("name") + "</div>"; 'showURL': false,
html += "<div class='padmaPosters'>" + getPostersHTML(PADMA[$(this).data("key")]) + "</div>"; 'bodyHandler': function() {
html += "</div>"; var html = "<div class='ttWrapper'>";
return html; 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); $texts.push($this);
var highlightShadow = '2px 2px 1px #666'; var highlightShadow = '2px 2px 1px #666';
@ -78,6 +87,7 @@ $(function() {
$this.mouseover(function(e) { $this.mouseover(function(e) {
var typ = $(this).data("type"); var typ = $(this).data("type");
if (typ === "") { return }
for (var i=0; i<$texts.length;i++) { for (var i=0; i<$texts.length;i++) {
var $t = $texts[i]; var $t = $texts[i];
if ($t.data("type") == typ) { if ($t.data("type") == typ) {
@ -90,6 +100,7 @@ $(function() {
$this.mouseout(function(e) { $this.mouseout(function(e) {
var typ = $(this).data("type"); var typ = $(this).data("type");
if (typ === '') { return; }
for (var i=0; i<$texts.length;i++) { for (var i=0; i<$texts.length;i++) {
var $t = $texts[i]; var $t = $texts[i];
if ($t.data("type") == typ) { if ($t.data("type") == typ) {
@ -121,3 +132,19 @@ function getPostersHTML(padma_ids) {
} }
return html; 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;
}