r69760 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69759‎ | r69760 | r69761 >
Date:22:09, 22 July 2010
Author:adam
Status:deferred
Tags:
Comment:
Liquid Threads: fix for bug 24475 along with a few enhancements
Modified paths:
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/lqt.js
@@ -177,6 +177,8 @@
178178 }
179179 // Add wikiEditor toolbar
180180 $j( '#wpTextbox1' ).wikiEditor( 'addModule', { 'toolbar': liquidThreads.toolbar.config, 'dialogs': liquidThreads.toolbar.dialogs } );
 181+ // cleanup unnecessary things from the old toolbar
 182+ $j( '#editpage-specialchars' ).remove();
181183 } else {
182184 // Add old toolbar
183185 mwSetupToolbar()
@@ -591,7 +593,14 @@
592594
593595 'setupThread' : function(threadContainer) {
594596 var prefixLength = "lqt_thread_id_".length;
595 -
 597+ // add the interruption class if it needs it
 598+ $parentWrapper = $j( threadContainer )
 599+ .closest( '.lqt-thread-wrapper' ).parent().closest( '.lqt-thread-wrapper' );
 600+ if( $parentWrapper.next( '.lqt-thread-wrapper' ).length > 0 ) {
 601+ $parentWrapper
 602+ .find( '.lqt-thread-replies' )
 603+ .addClass( 'lqt-thread-replies-interruption' );
 604+ }
596605 // Update reply links
597606 var threadWrapper = $j(threadContainer).closest('.lqt_thread')[0]
598607 var threadId = threadWrapper.id.substring( prefixLength );
@@ -860,35 +869,12 @@
861870 editform.prepend(spinner);
862871
863872 var replyCallback = function( data ) {
864 - // Grab topmost thread, reload it.
865 - var topmostThread = editform.closest('.lqt-thread-topmost');
866 - var post = topmostThread.find('.lqt-post-wrapper');
867 -// var threadID = post.data('thread-id'); Unused, but useful
868 - var newPostID = data.threadaction.thread['thread-id'];
869 -
870 - // Load data from JSON
871 - var html = data.threadaction.thread['html']
872 - var newContent = $j(html);
873 -
874 - // Clear old post.
875 - topmostThread.empty();
876 -
877 - // Replace post content
878 - var newThread = newContent.filter('div.lqt_thread')[0];
879 - var newThreadContent = $j(newThread).contents();
880 - topmostThread.append( newThreadContent );
881 - topmostThread.removeClass( 'lqt-thread-no-subthreads' );
882 - topmostThread.addClass( 'lqt-thread-with-subthreads' );
883 -
884 - // Set up thread.
885 - topmostThread.find('.lqt-post-wrapper').each( function() {
886 - liquidThreads.setupThread( $j(this) );
887 - } );
888 -
889 - // Scroll to the new post.
890 - var newPost = $j('#lqt_thread_id_'+newPostID);
891 - var targetOffset = $j(newPost).offset().top;
892 - $j('html,body').animate({scrollTop: targetOffset}, 'slow');
 873+ $parent = $j( '#lqt_thread_id_' + data.threadaction.thread['parent-id'] );
 874+ $html = $j( data.threadaction.thread['html'] );
 875+ $newThread = $html.find( '#lqt_thread_id_' + data.threadaction.thread['thread-id'] ).parent();
 876+ $parent.find( '.lqt-thread-replies:first' ).append( $newThread );
 877+ liquidThreads.setupThread( $newThread.find( '.lqt-post-wrapper' ) );
 878+ $j( 'html,body' ).animate({scrollTop: $newThread.offset().top}, 'slow');
893879 };
894880
895881 var newCallback = function( data ) {

Status & tagging log