src/widgets/Polemic.js
changeset 986 f9d51dd4a3fe
parent 983 97fef7a4b189
child 987 7b65bf78873a
--- a/src/widgets/Polemic.js	Fri Nov 30 10:49:26 2012 +0100
+++ b/src/widgets/Polemic.js	Wed Dec 19 19:02:52 2012 +0100
@@ -135,12 +135,14 @@
                     _annotation.trigger("click");
                 });
                 _annotation.on("select", function() {
-                    _this.tooltip.show(
-                        Math.floor(_elx + (_this.element_width - 1) / 2),
-                        _ely,
-                        _annotation.title,
-                        _col
-                    );
+                    if (_this.tooltip) {
+                        _this.tooltip.show(
+                            Math.floor(_elx + (_this.element_width - 1) / 2),
+                            _ely,
+                            _annotation.title,
+                            _col
+                        );
+                    }
                     _this.$tweets.each(function() {
                         var _e = IriSP.jQuery(this);
                         _e.css(
@@ -150,7 +152,9 @@
                     });
                 });
                 _annotation.on("unselect", function() {
-                    _this.tooltip.hide();
+                    if (_this.tooltip) {
+                        _this.tooltip.hide();
+                    }
                     _this.$tweets.css("opacity",1);
                 });
                 _annotation.on("found", function() {
@@ -270,10 +274,14 @@
                     var _color = _i ? _this.polemics[_i - 1].color : _this.defaultcolor;
                     _html += '<div class="Ldt-Tooltip-Color" style="background: ' + _color + '"></div><p>' + _nums[_i] + _this.l10n._annotations + '</p>'
                 }
-                _this.tooltip.show(_el.attr("pos-x"), _el.attr("pos-y"), _html);
+                if (_this.tooltip) {
+                    _this.tooltip.show(_el.attr("pos-x"), _el.attr("pos-y"), _html);
+                }
             })
             .mouseout(function() {
-                _this.tooltip.hide();
+                if (_this.tooltip) {
+                    _this.tooltip.hide();
+                }
             })
             
     }
@@ -289,7 +297,15 @@
     
     this.$.append('<div class="Ldt-Polemic-Tooltip"></div>');
     
-    this.insertSubwidget(this.$.find(".Ldt-Polemic-Tooltip"), { type: "Tooltip" }, "tooltip");
+    this.insertSubwidget(
+        this.$.find(".Ldt-Polemic-Tooltip"),
+        {
+            type: "Tooltip",
+            min_x: 0,
+            max_x: this.width
+        },
+        "tooltip"
+    );
 }
 
 IriSP.Widgets.Polemic.prototype.onTimeupdate = function(_time) {