src/js/widgets/tooltipWidget.js
author hamidouk
Tue, 15 Nov 2011 10:52:43 +0100
branchrequire-js
changeset 241 e321b1140949
parent 238 6008172a0592
permissions -rw-r--r--
WIP - converting the source to require.js

/* this widget displays a small tooltip */
define(["IriSP", "widgets", "util"], function() {
  IriSP.TooltipWidget = function(Popcorn, config, Serializer) {
    IriSP.Widget.call(this, Popcorn, config, Serializer);  
  };


  IriSP.TooltipWidget.prototype = new IriSP.Widget();

  IriSP.TooltipWidget.prototype.draw = function() {
    var templ = Mustache.to_html(IriSP.tooltipWidget_template);
      
    this.selector.append(templ);
    this.hide();
    
  };

  IriSP.TooltipWidget.prototype.show = function(text, color, x, y) {
    if (this.selector.find(".tiptext").text() == text)
      return;
      
    this.selector.find(".tipcolor").css("background-color", color);  
    this.selector.find(".tiptext").text(text);  
    this.selector.find(".tip").css("left", x).css("top", y);
  };

  IriSP.TooltipWidget.prototype.hide = function() {
    this.selector.find(".tip").css("left", -10000).css("top", -100000);
  };
});