src/js/widgets/tooltipWidget.js
author hamidouk
Mon, 05 Dec 2011 15:53:30 +0100
branchcap-demo
changeset 409 aa08a47b3dbb
parent 336 8da13562cfea
permissions -rw-r--r--
truncate the text if it's too long.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     1
/* this widget displays a small tooltip */
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     2
IriSP.TooltipWidget = function(Popcorn, config, Serializer) {
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     3
  IriSP.Widget.call(this, Popcorn, config, Serializer);
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     4
};
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     5
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     6
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     7
IriSP.TooltipWidget.prototype = new IriSP.Widget();
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     8
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     9
IriSP.TooltipWidget.prototype.draw = function() {
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    10
  var templ = Mustache.to_html(IriSP.tooltipWidget_template);
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    11
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    12
  this.selector.append(templ);
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    13
  this.hide();
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    14
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    15
};
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    16
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    17
IriSP.TooltipWidget.prototype.clear = function() {
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    18
	this.selector.find(".tiptext").text("");
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    19
};
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    20
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    21
IriSP.TooltipWidget.prototype.show = function(text, color, x, y) {
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    22
  if (this.selector.find(".tiptext").text() == text)
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    23
    return;
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    24
409
aa08a47b3dbb truncate the text if it's too long.
hamidouk
parents: 336
diff changeset
    25
  if(text.length > 120)
aa08a47b3dbb truncate the text if it's too long.
hamidouk
parents: 336
diff changeset
    26
    text = text.slice(0,119) + "...";
aa08a47b3dbb truncate the text if it's too long.
hamidouk
parents: 336
diff changeset
    27
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    28
  this.selector.find(".tipcolor").css("background-color", color);
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    29
	this.selector.find(".tiptext").text(text);
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    30
  this.selector.find(".tip").css("left", x).css("top", y);
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    31
};
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    32
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    33
IriSP.TooltipWidget.prototype.hide = function() {
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    34
  this.clear();
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    35
  this.selector.find(".tip").css("left", -10000).css("top", -100000);
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    36
};