src/js/widgets/tooltipWidget.js
author hamidouk
Fri, 13 Jan 2012 15:45:42 +0100
branchpopcorn-port
changeset 629 b13bcfd2f9b1
parent 579 179b32df9caa
child 646 2b8b2a94ee92
permissions -rw-r--r--
DRYied the code.
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);
474
c1998d5d552e fixed a couple show-stoppers.
hamidouk
parents: 336
diff changeset
     4
  this._shown = false;
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
     5
  this._displayedText = "";
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
     6
  this._hideTimeout = -1;
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
     7
};
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
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    10
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
    11
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    12
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
    13
  var templ = Mustache.to_html(IriSP.tooltipWidget_template);
550
ae0f2ec05ed7 fixed long-standing tooltip positioning bug.
hamidouk
parents: 489
diff changeset
    14
  // position the widget absolutely relative to document.
ae0f2ec05ed7 fixed long-standing tooltip positioning bug.
hamidouk
parents: 489
diff changeset
    15
  this.selector.css("position", "static");
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    16
  this.selector.append(templ);
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    17
  this.hide();
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    18
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    19
};
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    20
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    21
IriSP.TooltipWidget.prototype.clear = function() {
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    22
	this.selector.find(".tiptext").text("");
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    23
};
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    24
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    25
IriSP.TooltipWidget.prototype.show = function(text, color, x, y) {
478
1422ba0fc333 fixed annoying tooltip flicker bug.
hamidouk
parents: 477
diff changeset
    26
579
179b32df9caa fixed a tooltip display bug.
hamidouk
parents: 550
diff changeset
    27
  if (this._displayedText == text && this._shown)
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    28
    return;
579
179b32df9caa fixed a tooltip display bug.
hamidouk
parents: 550
diff changeset
    29
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    30
  this.selector.find(".tipcolor").css("background-color", color);
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    31
  this._displayedText = text;
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    32
	this.selector.find(".tiptext").text(text);
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    33
  //this.selector.find(".tip").css("left", x).css("top", y);  
489
0b84128f609b fixes forgotten debug line.
hamidouk
parents: 487
diff changeset
    34
  this.selector.find(".tip").css("left", x).css("top", y);
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    35
  this.selector.find(".tip").show();
474
c1998d5d552e fixed a couple show-stoppers.
hamidouk
parents: 336
diff changeset
    36
  this._shown = true;
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    37
};
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    38
478
1422ba0fc333 fixed annoying tooltip flicker bug.
hamidouk
parents: 477
diff changeset
    39
IriSP.TooltipWidget.prototype.hide = function() {                                                   
1422ba0fc333 fixed annoying tooltip flicker bug.
hamidouk
parents: 477
diff changeset
    40
  this.selector.find(".tip").hide();
1422ba0fc333 fixed annoying tooltip flicker bug.
hamidouk
parents: 477
diff changeset
    41
  this._shown = false;  
487
4c006b1dcc66 temporary fix for demo player.
hamidouk
parents: 480
diff changeset
    42
};