src/js/widgets/tooltipWidget.js
author hamidouk
Mon, 19 Dec 2011 10:53:34 +0100
branchpopcorn-port
changeset 477 1e51d638e7ea
parent 474 c1998d5d552e
child 478 1422ba0fc333
permissions -rw-r--r--
fixes in a rush.
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);
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
  this.selector.append(templ);
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    16
  this.hide();
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    17
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
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    20
IriSP.TooltipWidget.prototype.clear = function() {
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    21
	this.selector.find(".tiptext").text("");
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    22
};
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    23
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    24
IriSP.TooltipWidget.prototype.show = function(text, color, x, y) {
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    25
  if (this._shown === true || this._displayedText == text)
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    26
    return;
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    27
    
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    28
  // cancel the timeout for the previously displayed element.
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    29
  if (this._hideTimeout != -1) {
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    30
    window.clearTimeout(this._hideTimeout);
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    31
    this._hideTimeout = -1;
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    32
    console.log(text === this._displayedText);
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    33
  }
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    34
  debugger;
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    35
  
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    36
  this.selector.find(".tipcolor").css("background-color", color);
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    37
  this._displayedText = text;
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    38
	this.selector.find(".tiptext").text(text);
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    39
  //this.selector.find(".tip").css("left", x).css("top", y);  
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    40
  this.selector.find(".tip").css("left", x).css("top", "-160px");
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    41
  this.selector.find(".tip").show();
474
c1998d5d552e fixed a couple show-stoppers.
hamidouk
parents: 336
diff changeset
    42
  this._shown = true;
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    43
};
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    44
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    45
IriSP.TooltipWidget.prototype.hide = function() {  
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    46
  this._hideTimeout = window.setTimeout(IriSP.wrap(this, function() {                                                  
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    47
                                                  this.selector.find(".tip").hide();
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    48
                                                  this._shown = false; }), 1000);
474
c1998d5d552e fixed a couple show-stoppers.
hamidouk
parents: 336
diff changeset
    49
  
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    50
};