Index: trunk/extensions/LiquidThreads/lqt.js |
— | — | @@ -657,20 +657,34 @@ |
658 | 658 | |
659 | 659 | // Update thread-level menu, if appropriate |
660 | 660 | if ( $j(threadWrapper).hasClass( 'lqt-thread-topmost' ) ) { |
| 661 | + // To perform better, check the 3 elements before the top-level thread container before |
| 662 | + // scanning the whole document |
| 663 | + var menu = undefined; |
661 | 664 | var threadLevelCommandSelector = '#lqt-threadlevel-commands-'+threadId; |
| 665 | + var traverseElement = $j(threadWrapper); |
662 | 666 | |
663 | | - var menu = $j(threadLevelCommandSelector); |
| 667 | + for( i=0;i<3 && typeof menu == 'undefined';++i ) { |
| 668 | + traverseElement = traverseElement.prev(); |
| 669 | + if ( traverseElement.is(threadLevelCommandSelector) ) { |
| 670 | + menu = traverseElement |
| 671 | + } |
| 672 | + } |
| 673 | + |
| 674 | + if ( typeof menu == 'undefined' ) { |
| 675 | + menu = $j(threadLevelCommandSelector); |
| 676 | + } |
| 677 | + |
664 | 678 | liquidThreads.setupThreadMenu( menu, threadId ); |
665 | 679 | } |
666 | 680 | |
667 | 681 | // Check for a "show replies" button |
668 | | - $j('a.lqt-show-replies').click( liquidThreads.showReplies ); |
| 682 | + $j(threadContainer).find('a.lqt-show-replies').click( liquidThreads.showReplies ); |
669 | 683 | |
670 | 684 | // "Show more posts" link |
671 | | - $j('a.lqt-show-more-posts').click( liquidThreads.showMore ); |
| 685 | + $j(threadContainer).find('a.lqt-show-more-posts').click( liquidThreads.showMore ); |
672 | 686 | |
673 | 687 | // Handler for "Link to this" button |
674 | | - $j('.lqt-command-link').click( liquidThreads.showLinkWindow ); |
| 688 | + $j(threadContainer).find('.lqt-command-link').click( liquidThreads.showLinkWindow ); |
675 | 689 | }, |
676 | 690 | |
677 | 691 | 'showReplies' : function(e) { |