| author | cavaliet |
| Thu, 02 Jan 2014 16:40:25 +0100 | |
| branch | new-model |
| changeset 1019 | 3ab36f402b0c |
| parent 922 | 096c06aea8b5 |
| child 1020 | 198c2b79f5e1 |
| 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 */ |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
2 |
IriSP.Widgets.Tooltip = function(player, config) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
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 |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
8 |
IriSP.Widgets.Tooltip.prototype.defaults = { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
9 |
|
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
10 |
}; |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
11 |
|
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
12 |
IriSP.Widgets.Tooltip.prototype.template = |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
13 |
'<div class="Ldt-Tooltip"><div class="Ldt-Tooltip-Main"><div class="Ldt-Tooltip-Corner-NW"></div>' |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
14 |
+ '<div class="Ldt-Tooltip-Border-Top"></div><div class="Ldt-Tooltip-Corner-NE"></div>' |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
15 |
+ '<div class="Ldt-Tooltip-Border-Left"></div><div class="Ldt-Tooltip-Border-Right"></div>' |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
16 |
+ '<div class="Ldt-Tooltip-Corner-SW"></div><div class="Ldt-Tooltip-Border-SW"></div>' |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
17 |
+ '<div class="Ldt-Tooltip-Tip"></div><div class="Ldt-Tooltip-Border-SE"></div>' |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
18 |
+ '<div class="Ldt-Tooltip-Corner-SE"></div><div class="Ldt-Tooltip-Inner">' |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
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; |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
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 |
}); |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
27 |
this.$tooltip = this.$.find(".Ldt-Tooltip"); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
28 |
this.$tip = this.$.find(".Ldt-Tooltip-Tip"); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
29 |
this.$sw = this.$.find(".Ldt-Tooltip-Border-SW"); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
30 |
this.$se = this.$.find(".Ldt-Tooltip-Border-SE"); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
31 |
this.__halfWidth = Math.floor(( this.$.find(".Ldt-Tooltip-Main").width() || 192)/2); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
32 |
this.__borderWidth = this.$.find(".Ldt-Tooltip-Border-Left").width(); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
33 |
this.__tipDelta = this.__halfWidth - Math.floor(this.$tip.width()/2); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
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() { |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
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") { |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
44 |
// one color or array of colors |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
45 |
if (typeof color === "string") { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
46 |
this.$.find(".Ldt-Tooltip-Color").html(""); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
47 |
this.$.find(".Ldt-Tooltip-Color").show().css("background-color", color); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
48 |
this.$.find(".Ldt-Tooltip-Color").show().css("height", ""); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
49 |
} |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
50 |
else{ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
51 |
var d = this.$.find(".Ldt-Tooltip-Color"); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
52 |
d.html(""); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
53 |
d.show(); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
54 |
for(var i=0; i<color.length; i++){ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
55 |
d.append('<div style="float: left; height: 10px; width: 10px; background-color: ' + color[i] + '">') |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
56 |
} |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
57 |
this.$.find(".Ldt-Tooltip-Color").css("height", (color.length * 10) + "px"); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
58 |
} |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
59 |
} else { |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
60 |
this.$.find(".Ldt-Tooltip-Color").hide(); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
61 |
} |
| 882 | 62 |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
63 |
this.$.find(".Ldt-Tooltip-Text").html(text); |
| 579 | 64 |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
65 |
this.$tooltip.show(); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
66 |
|
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
67 |
var shift = 0; |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
68 |
|
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
69 |
if (typeof this.min_x !== "undefined" && (x - this.__halfWidth < this.min_x)) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
70 |
shift = Math.max(x - this.__halfWidth - this.min_x, - this.__maxShift); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
71 |
} |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
72 |
|
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
73 |
if (typeof this.max_x !== "undefined" && (+x + this.__halfWidth > this.max_x)) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
74 |
shift = Math.min(+ x + this.__halfWidth - this.max_x, this.__maxShift); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
75 |
} |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
76 |
|
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
77 |
this.$tooltip.css({ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
78 |
"left" : (x - shift) + "px", |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
79 |
"top" : y + "px" |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
80 |
}); |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
81 |
this.$tip.css({ |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
82 |
"left": (this.__tipDelta + shift) + "px" |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
83 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
84 |
this.$sw.css({ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
85 |
"width": (this.__tipDelta + shift - this.__borderWidth) + "px" |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
86 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
87 |
this.$se.css({ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
88 |
"width": (this.__tipDelta - shift - this.__borderWidth) + "px" |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
89 |
}); |
|
289
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
90 |
}; |
|
c0e399fbf3fb
due to a np++ crash, some files where created in with windows line endings.
hamidouk
parents:
231
diff
changeset
|
91 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
92 |
IriSP.Widgets.Tooltip.prototype.hide = function() { |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
922
diff
changeset
|
93 |
this.$tooltip.hide(); |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
830
diff
changeset
|
94 |
}; |