src/js/widgets/tooltipWidget.js
author veltr
Mon, 19 Mar 2012 18:46:17 +0100
branchpopcorn-port
changeset 834 573c7ca752e0
parent 830 18ca612e9ff0
child 874 38b65761a7d5
permissions -rw-r--r--
Adapted Stackgraph for Cinecast
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);
827
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    14
  // position the widget absolutely relative to document. --- NOOOO !!!!
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    15
  this.selector.css({
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    16
      "position": "absolute",
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    17
      "top": 0,
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    18
      "left": 0
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    19
  });
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    20
  this.selector.parent().css({
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    21
      "position": "relative"
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    22
  });
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    23
  this.selector.append(templ);
830
18ca612e9ff0 Lots of changes
veltr
parents: 828
diff changeset
    24
  var _this = this;
18ca612e9ff0 Lots of changes
veltr
parents: 828
diff changeset
    25
  this.selector.mouseover(function() {
18ca612e9ff0 Lots of changes
veltr
parents: 828
diff changeset
    26
      _this.hide();
18ca612e9ff0 Lots of changes
veltr
parents: 828
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.hide();
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    29
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    30
};
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    31
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    32
IriSP.TooltipWidget.prototype.clear = function() {
685
973d9a495d11 allow display of html content in tooltip.
hamidouk
parents: 646
diff changeset
    33
	this.selector.find(".tiptext").html("");
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
diff changeset
    34
};
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 289
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
IriSP.TooltipWidget.prototype.show = function(text, color, x, y) {
478
1422ba0fc333 fixed annoying tooltip flicker bug.
hamidouk
parents: 477
diff changeset
    37
579
179b32df9caa fixed a tooltip display bug.
hamidouk
parents: 550
diff changeset
    38
  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
    39
    return;
579
179b32df9caa fixed a tooltip display bug.
hamidouk
parents: 550
diff changeset
    40
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    41
  this.selector.find(".tipcolor").css("background-color", color);
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 474
diff changeset
    42
  this._displayedText = text;
827
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    43
  this.selector.find(".tiptext").html(text);
646
2b8b2a94ee92 limit where the widget can position itself.
hamidouk
parents: 579
diff changeset
    44
  
827
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    45
  var _tip = this.selector.find(".tip");
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    46
  _tip.show();
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    47
  _tip.css({
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    48
      "left": Math.floor(x - _tip.outerWidth() / 2)+"px",
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    49
      "top": Math.floor(y - _tip.outerHeight())+"px"
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 685
diff changeset
    50
  });
474
c1998d5d552e fixed a couple show-stoppers.
hamidouk
parents: 336
diff changeset
    51
  this._shown = true;
289
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    52
};
c0e399fbf3fb due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents: 231
diff changeset
    53
478
1422ba0fc333 fixed annoying tooltip flicker bug.
hamidouk
parents: 477
diff changeset
    54
IriSP.TooltipWidget.prototype.hide = function() {                                                   
1422ba0fc333 fixed annoying tooltip flicker bug.
hamidouk
parents: 477
diff changeset
    55
  this.selector.find(".tip").hide();
1422ba0fc333 fixed annoying tooltip flicker bug.
hamidouk
parents: 477
diff changeset
    56
  this._shown = false;  
487
4c006b1dcc66 temporary fix for demo player.
hamidouk
parents: 480
diff changeset
    57
};