@@ -21,58 +21,52 @@ class Tooltip {
2121
2222 dom.Element tooltipElem;
2323
24- Tooltip (dom.Element this .element, dom.Node this .node,
25- Scope this .scope) {
26-
27- element.onMouseEnter.listen ((event) {
28- _createTemplate ();
29- });
30-
31- element.onMouseLeave.listen ((event) {
32- _destroyTemplate ();
33- });
24+ Tooltip (this .element, this .node, this .scope) {
25+ element
26+ ..onMouseEnter.listen ((_) => _createTemplate ())
27+ ..onMouseLeave.listen ((_) => _destroyTemplate ());
3428 }
3529
3630 _createTemplate () {
3731 assert (displayModel != null );
3832
3933 tooltipElem = new dom.DivElement ();
4034
41- dom.ImageElement imgElem = new dom.ImageElement ();
42- imgElem. width = displayModel.imgWidth;
43- imgElem .src = displayModel.imgUrl;
35+ dom.ImageElement imgElem = new dom.ImageElement ()
36+ .. width = displayModel.imgWidth
37+ . .src = displayModel.imgUrl;
4438 tooltipElem.append (imgElem);
4539
4640 if (displayModel.text != null ) {
47- dom.DivElement textSpan = new dom.DivElement ();
48- textSpan. appendText (displayModel.text);
49- textSpan. style.color = "white" ;
50- textSpan. style.fontSize = "smaller" ;
51- textSpan .style.paddingBottom = "5px" ;
41+ dom.DivElement textSpan = new dom.DivElement ()
42+ .. appendText (displayModel.text)
43+ .. style.color = "white"
44+ .. style.fontSize = "smaller"
45+ . .style.paddingBottom = "5px" ;
5246
5347 tooltipElem.append (textSpan);
5448 }
5549
56- tooltipElem.style.padding = "5px" ;
57- tooltipElem.style.paddingBottom = "0px" ;
58- tooltipElem.style.backgroundColor = "black" ;
59- tooltipElem.style.borderRadius = "5px" ;
60- tooltipElem.style.width = "${displayModel .imgWidth .toString ()}px" ;
50+ tooltipElem.style
51+ ..padding = "5px"
52+ ..paddingBottom = "0px"
53+ ..backgroundColor = "black"
54+ ..borderRadius = "5px"
55+ ..width = "${displayModel .imgWidth .toString ()}px" ;
6156
6257 // find the coordinates of the parent DOM element
6358 Rectangle bounds = element.getBoundingClientRect ();
6459 int left = (bounds.left + dom.window.pageXOffset).toInt ();
6560 int top = (bounds.top + dom.window.pageYOffset).toInt ();
66- int width = ( bounds.width) .toInt ();
67- int height = ( bounds.height) .toInt ();
61+ int width = bounds.width.toInt ();
62+ int height = bounds.height.toInt ();
6863
6964 // position the tooltip.
7065 // Figure out where the containing element sits in the window.
71- int tooltipLeft = left + width + 10 ;
72- int tooltipTop = top - height;
73- tooltipElem.style.position = "absolute" ;
74- tooltipElem.style.top = "${tooltipTop }px" ;
75- tooltipElem.style.left = "${tooltipLeft }px" ;
66+ tooltipElem.style
67+ ..position = "absolute"
68+ ..top = "${top - height }px"
69+ ..left = "${left + width + 10 }px" ;
7670
7771 // Add the tooltip to the document body. We add it here because
7872 // we need to position it absolutely, without reference to its
@@ -90,6 +84,5 @@ class TooltipModel {
9084 String text;
9185 int imgWidth;
9286
93- TooltipModel (String this .imgUrl, String this .text,
94- int this .imgWidth);
87+ TooltipModel (this .imgUrl, this .text, this .imgWidth);
9588}
0 commit comments