| author | veltr |
| Tue, 01 Oct 2013 15:41:46 +0200 | |
| changeset 1013 | 392ddcd212d7 |
| parent 987 | 7b65bf78873a |
| child 1021 | 7253d4d06f0d |
| permissions | -rw-r--r-- |
|
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 */ |
| 957 | 2 |
IriSP.Widgets.Tooltip = function(player, config) { |
3 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
4 |
}; |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
5 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
6 |
IriSP.Widgets.Tooltip.prototype = new IriSP.Widgets.Widget(); |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
7 |
|
| 986 | 8 |
IriSP.Widgets.Tooltip.prototype.defaults = { |
9 |
|
|
10 |
}; |
|
11 |
||
12 |
IriSP.Widgets.Tooltip.prototype.template = |
|
13 |
'<div class="Ldt-Tooltip"><div class="Ldt-Tooltip-Main"><div class="Ldt-Tooltip-Corner-NW"></div>' |
|
14 |
+ '<div class="Ldt-Tooltip-Border-Top"></div><div class="Ldt-Tooltip-Corner-NE"></div>' |
|
15 |
+ '<div class="Ldt-Tooltip-Border-Left"></div><div class="Ldt-Tooltip-Border-Right"></div>' |
|
16 |
+ '<div class="Ldt-Tooltip-Corner-SW"></div><div class="Ldt-Tooltip-Border-SW"></div>' |
|
17 |
+ '<div class="Ldt-Tooltip-Tip"></div><div class="Ldt-Tooltip-Border-SE"></div>' |
|
18 |
+ '<div class="Ldt-Tooltip-Corner-SE"></div><div class="Ldt-Tooltip-Inner">' |
|
19 |
+ '<div class="Ldt-Tooltip-Color"></div><p class="Ldt-Tooltip-Text"></p></div></div></div>'; |
|
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
20 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
21 |
IriSP.Widgets.Tooltip.prototype.draw = function() { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
22 |
_this = this; |
| 986 | 23 |
this.renderTemplate(); |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
24 |
this.$.parent().css({ |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
25 |
"position" : "relative" |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
26 |
}); |
| 986 | 27 |
this.$tooltip = this.$.find(".Ldt-Tooltip"); |
28 |
this.$tip = this.$.find(".Ldt-Tooltip-Tip"); |
|
29 |
this.$sw = this.$.find(".Ldt-Tooltip-Border-SW"); |
|
30 |
this.$se = this.$.find(".Ldt-Tooltip-Border-SE"); |
|
31 |
this.__halfWidth = Math.floor(this.$.find(".Ldt-Tooltip-Main").width()/2); |
|
32 |
this.__borderWidth = this.$.find(".Ldt-Tooltip-Border-Left").width(); |
|
33 |
this.__tipDelta = this.__halfWidth - Math.floor(this.$tip.width()/2); |
|
34 |
this.__maxShift = this.__tipDelta - this.__borderWidth; |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
35 |
this.$.mouseover(function() { |
| 986 | 36 |
_this.$tooltip.hide(); |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
37 |
}); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
38 |
this.hide(); |
|
336
8da13562cfea
segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents:
289
diff
changeset
|
39 |
}; |
|
8da13562cfea
segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents:
289
diff
changeset
|
40 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
41 |
IriSP.Widgets.Tooltip.prototype.show = function(x, y, text, color) { |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
42 |
|
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
43 |
if (typeof color !== "undefined") { |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
44 |
this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
45 |
} else { |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
46 |
this.$.find(".Ldt-Tooltip-Color").hide(); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
47 |
} |
| 882 | 48 |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
49 |
this.$.find(".Ldt-Tooltip-Text").html(text); |
| 579 | 50 |
|
| 986 | 51 |
this.$tooltip.show(); |
52 |
|
|
53 |
var shift = 0; |
|
54 |
|
|
55 |
if (typeof this.min_x !== "undefined" && (x - this.__halfWidth < this.min_x)) { |
|
56 |
shift = Math.max(x - this.__halfWidth - this.min_x, - this.__maxShift); |
|
57 |
} |
|
58 |
|
|
| 987 | 59 |
if (typeof this.max_x !== "undefined" && (+x + this.__halfWidth > this.max_x)) { |
60 |
shift = Math.min(+ x + this.__halfWidth - this.max_x, this.__maxShift); |
|
| 986 | 61 |
} |
62 |
|
|
63 |
this.$tooltip.css({ |
|
64 |
"left" : (x - shift) + "px", |
|
65 |
"top" : y + "px" |
|
66 |
}); |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
67 |
this.$tip.css({ |
| 986 | 68 |
"left": (this.__tipDelta + shift) + "px" |
69 |
}); |
|
70 |
this.$sw.css({ |
|
71 |
"width": (this.__tipDelta + shift - this.__borderWidth) + "px" |
|
72 |
}); |
|
73 |
this.$se.css({ |
|
74 |
"width": (this.__tipDelta - shift - this.__borderWidth) + "px" |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
75 |
}); |
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
76 |
}; |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
77 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
78 |
IriSP.Widgets.Tooltip.prototype.hide = function() { |
| 986 | 79 |
this.$tooltip.hide(); |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
80 |
}; |