Index: trunk/extensions/Lingo/libs/Lingo.js |
— | — | @@ -1,15 +1,22 @@ |
2 | 2 | jQuery(function ($){ |
3 | 3 | |
4 | 4 | $(".tooltip") |
5 | | - .mouseenter(function(){ |
| 5 | + .mouseenter(function( event ){ |
6 | 6 | |
| 7 | + event.stopImmediatePropagation(); |
| 8 | + |
7 | 9 | var tip = $(this); |
8 | 10 | var wrapper = tip.find(".tooltip_tipwrapper"); |
9 | 11 | var tipdef = wrapper.find(".tooltip_tip"); |
10 | 12 | |
11 | | - var maxAvailableWidth = window.innerWidth - 15; // -15 for scrollbar |
| 13 | + if ( wrapper.css("display") == "block" ) { |
| 14 | + return; |
| 15 | + } |
| 16 | + |
| 17 | + var termLineHeight = tip.outerHeight() + 5; |
| 18 | + var maxAvailableWidth = $(window).width(); |
12 | 19 | var maxAvailableHeightAbove = tip.offset().top - $(window).scrollTop() - 5; |
13 | | - var maxAvailableHeightBelow = window.innerHeight - (tip.offset().top - $(window).scrollTop()) - tip.outerHeight() - 5 - 15; // -15 for scrollbar |
| 20 | + var maxAvailableHeightBelow = $(window).height() - (tip.offset().top - $(window).scrollTop()) - termLineHeight; |
14 | 21 | |
15 | 22 | var maxWidthWithoutBreak = maxAvailableWidth / 3; |
16 | 23 | |
— | — | @@ -40,6 +47,8 @@ |
41 | 48 | maxAvailableHeightBelow -= borderWidth; |
42 | 49 | maxWidthWithoutBreak -= borderWidth; |
43 | 50 | |
| 51 | + var maxAvailableWidthRight = maxAvailableWidth - (tip.offset().left - $(window).scrollLeft() ); |
| 52 | + |
44 | 53 | tipdef.width( maxAvailableWidth ); |
45 | 54 | |
46 | 55 | // height if constrained to the window width, i.e. |
— | — | @@ -77,11 +86,11 @@ |
78 | 87 | // done with it |
79 | 88 | wrapper.css({ |
80 | 89 | 'width': maxAvailableWidth + 'px', |
81 | | - 'padding-left': '10px', |
82 | | - 'left': '0px', |
| 90 | + 'padding-left': '0px', |
| 91 | + 'left': (maxAvailableWidthRight - maxAvailableWidth) +'px', |
83 | 92 | 'top': '0px', |
84 | 93 | 'padding-bottom': '0px', |
85 | | - 'padding-top' : (tip.outerHeight() + 5 ) +'px' |
| 94 | + 'padding-top' : termLineHeight +'px' |
86 | 95 | }); |
87 | 96 | |
88 | 97 | } else { |
— | — | @@ -109,8 +118,6 @@ |
110 | 119 | |
111 | 120 | wrapper.height(tipdef.height()); |
112 | 121 | |
113 | | - var maxAvailableWidthRight = window.innerWidth - (tip.offset().left - $(window).scrollLeft() ) - borderWidth; |
114 | | - |
115 | 122 | if ( maxAvailableWidthRight - 10 >= width ) { |
116 | 123 | // will not bump into right window border |
117 | 124 | wrapper.css({ |
— | — | @@ -121,8 +128,7 @@ |
122 | 129 | |
123 | 130 | } else { |
124 | 131 | // will bump into right window border |
125 | | - var left = maxAvailableWidthRight - width - borderWidth; |
126 | | - wrapper.width(width); |
| 132 | + var left = maxAvailableWidthRight - width; |
127 | 133 | wrapper.css({ |
128 | 134 | 'width': width + 'px', |
129 | 135 | 'padding-left': '0px', |
— | — | @@ -133,7 +139,7 @@ |
134 | 140 | if ( placeAbove ) { |
135 | 141 | wrapper.css({ |
136 | 142 | 'top': ( - tipdef.outerHeight() - 5) + 'px', |
137 | | - 'padding-bottom': (tip.outerHeight() + 5 ) +'px', |
| 143 | + 'padding-bottom': termLineHeight +'px', |
138 | 144 | 'padding-top' : '0px' |
139 | 145 | }); |
140 | 146 | |
— | — | @@ -142,7 +148,7 @@ |
143 | 149 | // 'position': 'absolute', |
144 | 150 | 'top': '0px', |
145 | 151 | 'padding-bottom': '0px', |
146 | | - 'padding-top' : (tip.outerHeight() + 5 ) +'px' |
| 152 | + 'padding-top' : termLineHeight +'px' |
147 | 153 | }); |
148 | 154 | } |
149 | 155 | |
— | — | @@ -164,13 +170,20 @@ |
165 | 171 | .fadeIn(200); |
166 | 172 | }) |
167 | 173 | |
168 | | - .mouseleave(function(){ |
169 | | - $(".tooltip_tipwrapper", this).fadeOut(200); |
| 174 | + .mouseleave( function( event ){ |
| 175 | + event.stopImmediatePropagation(); |
| 176 | + |
| 177 | + $(this).find(".tooltip_tipwrapper").fadeOut(200); |
170 | 178 | }) |
171 | | - |
| 179 | + |
| 180 | + .find(".tooltip_tipwrapper") |
| 181 | + .css( "display", "none" ) |
| 182 | + |
172 | 183 | .find(".tooltip_tip") |
173 | | - .mouseleave(function(){ |
174 | | - $(this).parent().parent().mouseleave(); |
| 184 | + .mouseleave( function( event ){ |
| 185 | + event.stopImmediatePropagation(); |
| 186 | + |
| 187 | + $(this).parent().fadeOut(200); |
175 | 188 | }) |
176 | 189 | |
177 | 190 | }); |
\ No newline at end of file |