r56001 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56000‎ | r56001 | r56002 >
Date:22:39, 7 September 2009
Author:werdna
Status:deferred
Tags:
Comment:
Make LiquidThreads toolbar track the scroll position if it's scrolled out of view.
Modified paths:
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/lqt.js
@@ -1,5 +1,6 @@
22 var liquidThreads = {
33 currentReplyThread : null,
 4+ currentToolbar : null,
45
56 'handleReplyLink' : function(e) {
67 if (e.preventDefault)
@@ -207,8 +208,14 @@
208209 post.hover(
209210 function() {
210211 toolbar.fadeIn(100);
211 - } /*over*/,
 212+ liquidThreads.currentToolbar = toolbar;
 213+ } /* over */,
212214 function() {
 215+ if ( liquidThreads.currentToolbar &&
 216+ liquidThreads.currentToolbar.is(toolbar) ) {
 217+ liquidThreads.currentToolbar = null;
 218+ }
 219+
213220 toolbar.fadeOut(20);
214221 }/*out */ );
215222
@@ -304,6 +311,28 @@
305312 // Move menus into their proper location
306313 $j('div.lqt-post-wrapper').each( liquidThreads.setupMenus );
307314
 315+ // Add scrolling handler
 316+ $j(document).scroll( function() {
 317+ var toolbar = liquidThreads.currentToolbar;
 318+ if ( !toolbar ) { return; }
 319+
 320+ var post = toolbar.closest('.lqt_thread');
 321+ var scrollTop = $j(document).scrollTop();
 322+ var toolbarTop = toolbar.offset().top;
 323+ var postTop = post.offset().top;
 324+
 325+ if ( scrollTop > toolbarTop ) {
 326+ toolbar.css( 'top', scrollTop );
 327+ } else if ( toolbar.css('top') && scrollTop < toolbarTop ) {
 328+ // Move back either to the start of the post, or to the scroll point
 329+ if ( scrollTop > postTop ) {
 330+ toolbar.css( 'top', scrollTop );
 331+ } else {
 332+ toolbar.css( 'top', 'auto' );
 333+ }
 334+ }
 335+ } );
 336+
308337 // Show quote buttons
309338 liquidThreads.showQuoteButtons();
310339

Status & tagging log