src/js/widgets/tooltipWidget.js
author hamidouk
Mon, 14 Nov 2011 17:19:26 +0100
branchrequire-js
changeset 238 6008172a0592
parent 231 accc7358d8b5
permissions -rw-r--r--
converted all the source files to use the require.js syntax.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
172
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     1
/* this widget displays a small tooltip */
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
     2
define(["IriSP", "widgets", "util"], function() {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
     3
  IriSP.TooltipWidget = function(Popcorn, config, Serializer) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
     4
    IriSP.Widget.call(this, Popcorn, config, Serializer);  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
     5
  };
172
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     6
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     7
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
     8
  IriSP.TooltipWidget.prototype = new IriSP.Widget();
172
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
     9
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    10
  IriSP.TooltipWidget.prototype.draw = function() {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    11
    var templ = Mustache.to_html(IriSP.tooltipWidget_template);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    12
      
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    13
    this.selector.append(templ);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    14
    this.hide();
231
accc7358d8b5 fixed a position bug.
hamidouk
parents: 177
diff changeset
    15
    
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    16
  };
172
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    17
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    18
  IriSP.TooltipWidget.prototype.show = function(text, color, x, y) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    19
    if (this.selector.find(".tiptext").text() == text)
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    20
      return;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    21
      
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    22
    this.selector.find(".tipcolor").css("background-color", color);  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    23
    this.selector.find(".tiptext").text(text);  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    24
    this.selector.find(".tip").css("left", x).css("top", y);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    25
  };
172
3ffa0e0c8803 added a "tooltip" widget. Made some changes to the css corresponding to this
hamidouk
parents:
diff changeset
    26
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    27
  IriSP.TooltipWidget.prototype.hide = function() {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    28
    this.selector.find(".tip").css("left", -10000).css("top", -100000);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    29
  };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    30
});