r89841 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89840‎ | r89841 | r89842 >
Date:19:05, 10 June 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
minor fixes for tooltip positioning and event handling
Modified paths:
  • /trunk/extensions/Lingo/libs/Lingo.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Lingo/libs/Lingo.js
@@ -1,15 +1,22 @@
22 jQuery(function ($){
33
44 $(".tooltip")
5 - .mouseenter(function(){
 5+ .mouseenter(function( event ){
66
 7+ event.stopImmediatePropagation();
 8+
79 var tip = $(this);
810 var wrapper = tip.find(".tooltip_tipwrapper");
911 var tipdef = wrapper.find(".tooltip_tip");
1012
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();
1219 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;
1421
1522 var maxWidthWithoutBreak = maxAvailableWidth / 3;
1623
@@ -40,6 +47,8 @@
4148 maxAvailableHeightBelow -= borderWidth;
4249 maxWidthWithoutBreak -= borderWidth;
4350
 51+ var maxAvailableWidthRight = maxAvailableWidth - (tip.offset().left - $(window).scrollLeft() );
 52+
4453 tipdef.width( maxAvailableWidth );
4554
4655 // height if constrained to the window width, i.e.
@@ -77,11 +86,11 @@
7887 // done with it
7988 wrapper.css({
8089 'width': maxAvailableWidth + 'px',
81 - 'padding-left': '10px',
82 - 'left': '0px',
 90+ 'padding-left': '0px',
 91+ 'left': (maxAvailableWidthRight - maxAvailableWidth) +'px',
8392 'top': '0px',
8493 'padding-bottom': '0px',
85 - 'padding-top' : (tip.outerHeight() + 5 ) +'px'
 94+ 'padding-top' : termLineHeight +'px'
8695 });
8796
8897 } else {
@@ -109,8 +118,6 @@
110119
111120 wrapper.height(tipdef.height());
112121
113 - var maxAvailableWidthRight = window.innerWidth - (tip.offset().left - $(window).scrollLeft() ) - borderWidth;
114 -
115122 if ( maxAvailableWidthRight - 10 >= width ) {
116123 // will not bump into right window border
117124 wrapper.css({
@@ -121,8 +128,7 @@
122129
123130 } else {
124131 // will bump into right window border
125 - var left = maxAvailableWidthRight - width - borderWidth;
126 - wrapper.width(width);
 132+ var left = maxAvailableWidthRight - width;
127133 wrapper.css({
128134 'width': width + 'px',
129135 'padding-left': '0px',
@@ -133,7 +139,7 @@
134140 if ( placeAbove ) {
135141 wrapper.css({
136142 'top': ( - tipdef.outerHeight() - 5) + 'px',
137 - 'padding-bottom': (tip.outerHeight() + 5 ) +'px',
 143+ 'padding-bottom': termLineHeight +'px',
138144 'padding-top' : '0px'
139145 });
140146
@@ -142,7 +148,7 @@
143149 // 'position': 'absolute',
144150 'top': '0px',
145151 'padding-bottom': '0px',
146 - 'padding-top' : (tip.outerHeight() + 5 ) +'px'
 152+ 'padding-top' : termLineHeight +'px'
147153 });
148154 }
149155
@@ -164,13 +170,20 @@
165171 .fadeIn(200);
166172 })
167173
168 - .mouseleave(function(){
169 - $(".tooltip_tipwrapper", this).fadeOut(200);
 174+ .mouseleave( function( event ){
 175+ event.stopImmediatePropagation();
 176+
 177+ $(this).find(".tooltip_tipwrapper").fadeOut(200);
170178 })
171 -
 179+
 180+ .find(".tooltip_tipwrapper")
 181+ .css( "display", "none" )
 182+
172183 .find(".tooltip_tip")
173 - .mouseleave(function(){
174 - $(this).parent().parent().mouseleave();
 184+ .mouseleave( function( event ){
 185+ event.stopImmediatePropagation();
 186+
 187+ $(this).parent().fadeOut(200);
175188 })
176189
177190 });
\ No newline at end of file

Status & tagging log