r71504 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71503‎ | r71504 | r71505 >
Date:19:24, 23 August 2010
Author:adam
Status:deferred (Comments)
Tags:
Comment:
LQT - adding collapsing, and some css improvements
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)
  • /trunk/extensions/LiquidThreads/jquery/jquery.thread_collapse.css (added) (history)
  • /trunk/extensions/LiquidThreads/jquery/jquery.thread_collapse.js (added) (history)
  • /trunk/extensions/LiquidThreads/lqt.css (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/jquery/jquery.thread_collapse.js
@@ -0,0 +1,107 @@
 2+( function( $ ) {
 3+
 4+ $.fn.thread_collapse = function( $$options ) {
 5+ // return if the function is called on an empty jquery object
 6+ if( !this.length ) return this;
 7+ //merge options into the defaults
 8+ var $settings = $.extend( {}, $.thread_collapse.defaults, $$options );
 9+ // run the initialization on each jquery object
 10+ this.each( function() {
 11+ $thread = $( this );
 12+ // add collapse controls to this thread
 13+ $.thread_collapse.fn.init( $thread );
 14+ // add collapse controls recursivly to the child threads
 15+ $thread.find( '.lqt_thread' ).each( function() {
 16+ $.thread_collapse.fn.init( this );
 17+ } );
 18+ } );
 19+ return this;
 20+ };
 21+
 22+ $.thread_collapse = {
 23+ 'fn' : {
 24+ 'init': function( thread ) {
 25+ return $( thread )
 26+ .bind( 'collapse.thread_collapse', $.thread_collapse.fn.toggleCollapse )
 27+ .children( '.lqt-post-wrapper' )
 28+ .prepend( $( $.thread_collapse.templates.collapseControl )
 29+ .find( 'a' )
 30+ .bind( 'click.thread_collapse', $.thread_collapse.fn.toggleCollapse )
 31+ .end() );
 32+ },
 33+ 'getPreview': function( thread, depth ) {
 34+ var $out = $( '<ul />' )
 35+ .addClass( 'thread-collapse-preview' )
 36+ .addClass( 'thread-collapse-preview-depth-' + depth )
 37+ .append( $( '<li />' )
 38+ .append( thread.find( '.lqt-post-wrapper:first .lqt-thread-signature' ).clone() )
 39+ );
 40+ thread.find( '.lqt-thread-replies' ).children( '.lqt_thread' ).each( function() {
 41+ $out.append( $.thread_collapse.fn.getPreview( $( this ), depth + 1 ) );
 42+ } );
 43+ return $out;
 44+ },
 45+ 'toggleCollapse': function() {
 46+ var $thread = $( this ).closest( '.lqt_thread' );
 47+ if( $thread.is( '.collapsed_thread' ) ) {
 48+ // expand!
 49+ $thread
 50+ .removeClass( 'collapsed_thread' )
 51+ .children()
 52+ .show()
 53+ .parent()
 54+ .children( '.thread-collapsed-preview' )
 55+ .hide();
 56+ } else {
 57+ // collapse!
 58+ // if the thread preview already exists, don't bother recreating it
 59+ if( $thread.children( '.thread-collapsed-preview' ).size() > 0 ) {
 60+ $thread
 61+ .addClass( 'collapsed_thread' )
 62+ .children()
 63+ .hide()
 64+ .end()
 65+ .children( '.thread-collapsed-preview' )
 66+ .show();
 67+ } else {
 68+ // counter for the number of replies
 69+ var numReplies = $thread.find( '.lqt_thread' ).size() + 1;
 70+ // create the thread preview we'll use in the collapsed state
 71+ var $preview = $( '<div class="thread-collapsed-preview"></div>' )
 72+ .addClass( 'lqt-post-wrapper' )
 73+ .append( $( $.thread_collapse.templates.collapseControl )
 74+ .find( 'a' )
 75+ .text( 'Expand' )
 76+ .addClass( 'thread-control-collapsed' )
 77+ .bind( 'click.thread_collapse', $.thread_collapse.fn.toggleCollapse )
 78+ .end() )
 79+ .append( $( '<span />' )
 80+ .addClass( 'thread-collapsed-num-replies' )
 81+ .text( 'Show ' + numReplies + ' more replies' ) )
 82+ .append( $.thread_collapse.fn.getPreview( $thread, 0 ) );
 83+ // hide the other elements of the thread, and append the collapsed preview
 84+ $thread
 85+ .children()
 86+ .hide()
 87+ .end()
 88+ .addClass( 'collapsed_thread' )
 89+ .append( $preview );
 90+ }
 91+ }
 92+ return false;
 93+ }
 94+ },
 95+ templates: {
 96+ 'collapseControl': '<span class="thread-collapse-control"> \
 97+ <a href="#">Collapse</a> \
 98+ </span>'
 99+ },
 100+ defaults: {
 101+
 102+ }
 103+ };
 104+ // FIXME - this should be moved out of here
 105+ $( document ).ready( function () {
 106+ $( '.lqt-thread-topmost' ).thread_collapse();
 107+ } ); //document ready
 108+} )( jQuery );
\ No newline at end of file
Property changes on: trunk/extensions/LiquidThreads/jquery/jquery.thread_collapse.js
___________________________________________________________________
Added: svn:eol-style
1109 + native
Index: trunk/extensions/LiquidThreads/jquery/jquery.thread_collapse.css
@@ -0,0 +1,11 @@
 2+.thread-collapse-control a {
 3+ display: block;
 4+ outline: none;
 5+ width: 17px;
 6+ height: 17px;
 7+ background: url( ../images/thread_collapse_control_expanded.gif ) 0 0 no-repeat;
 8+ text-indent: -9999px;
 9+}
 10+.thread-collapse-control a.thread-control-collapsed {
 11+ background: url( ../images/thread_collapse_control_collapsed.gif ) 0 0 no-repeat;
 12+}
\ No newline at end of file
Property changes on: trunk/extensions/LiquidThreads/jquery/jquery.thread_collapse.css
___________________________________________________________________
Added: svn:eol-style
113 + native
Index: trunk/extensions/LiquidThreads/lqt.css
@@ -317,9 +317,11 @@
318318 padding: 0.5em 1em;
319319 padding-bottom: 1em;
320320 padding-right: 1em;
321 - overflow: auto;
 321+ overflow: hidden;
322322 border: 0.2em solid silver;
 323+ background: #e8e8e8;
323324 border-top: none;
 325+ position: relative;
324326 }
325327
326328 .lqt-thread-topmost > .lqt-post-wrapper {
@@ -335,9 +337,9 @@
336338 }
337339
338340 .lqt-thread-toolbar {
339 - right: 1.5em;
 341+ right: 0;
 342+ bottom: 0;
340343 position: absolute;
341 - clear: both;
342344 }
343345
344346 .lqt-post-sep {
@@ -352,7 +354,7 @@
353355 margin-top: 8px;
354356 padding: 0;
355357 }
356 -.lqt-thread-toolbar .lqt-command > a {
 358+.lqt-thread-toolbar .lqt-command a {
357359 display: block;
358360 }
359361
@@ -363,7 +365,7 @@
364366 background-position: left center !important;
365367 }
366368
367 -.lqt-thread-toolbar-commands > li.lqt-command {
 369+.lqt-thread-toolbar-commands li.lqt-command {
368370 margin-left: 0.5em;
369371 margin-right: 0.5em;
370372 line-height: 2em;
@@ -386,10 +388,8 @@
387389 list-style: none;
388390 padding: 0;
389391 margin: 0;
390 - line-height: 1em;
391 - height: 1em;
392392 }
393 -.lqt-thread-toolbar-commands > .lqt-command,
 393+.lqt-thread-toolbar-commands .lqt-command,
394394 .lqt-thread-toolbar-menu {
395395 float: left;
396396 }
@@ -432,7 +432,7 @@
433433 }
434434
435435 .lqt-newmessages-left {
436 - width: 10em ;
 436+ width: 10em;
437437 }
438438
439439 .lqt-thread-link-url,
@@ -493,7 +493,9 @@
494494 margin-right: 20px;
495495 }
496496 /* Float Clearing - If you confused, http://www.positioniseverything.net/easyclearing.html */
497 -.lqt_thread_heading:after
 497+.lqt_thread_heading:after,
 498+.lqt-thread-toolbar-commands:after,
 499+.lqt-post-wrapper:after
498500 {
499501 content: ".";
500502 display: block;
@@ -502,13 +504,19 @@
503505 visibility: hidden;
504506 }
505507
506 -.lqt_thread_heading
 508+.lqt_thread_heading,
 509+.lqt-thread-toolbar-commands,
 510+.lqt-post-wrapper
507511 {display: inline-block;}
508512
509513 /* Hides from IE-mac */
510 -* html .lqt_thread_heading
 514+* html .lqt_thread_heading,
 515+* html .lqt-thread-toolbar-commands,
 516+* html .lqt-post-wrapper
511517 {height: 1%;}
512518
513 -.lqt_thread_heading
 519+.lqt_thread_heading,
 520+.lqt-thread-toolbar-commands,
 521+.lqt-post-wrapper
514522 {display: block;}
515523 /* End hide from IE-mac */
Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -1201,11 +1201,13 @@
12021202 }
12031203
12041204 $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery-ui-1.7.2.css" );
1205 -
12061205 $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/jquery.autogrow.js" );
12071206
12081207 $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/lqt.js" );
12091208 $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/js/lqt.toolbar.js" );
 1209+ $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/jquery.thread_collapse.js" );
 1210+ $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery.thread_collapse.css" );
 1211+
12101212 $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/lqt.css?{$wgStyleVersion}" );
12111213
12121214 self::$stylesAndScriptsDone = true;
@@ -1316,7 +1318,6 @@
13171319 $html .= implode( ' ', $headerParts );
13181320
13191321 $html = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-commands' ), $html );
1320 - $html .= Xml::tags( 'div', array( 'style' => 'clear: both; height: 0;' ), '&#160;' );
13211322
13221323 $html = Xml::tags( 'div', array( 'class' => 'lqt-thread-toolbar' ), $html ) .
13231324 $menuHTML;
@@ -1421,9 +1422,6 @@
14221423 $html .= $this->showPostBody( $post, $oldid );
14231424 }
14241425 $html .= Xml::closeElement( 'div' );
1425 - $html .= Xml::tags( 'div', array( 'style' => 'clear: both; height: 0' ),
1426 - '&#160;' );
1427 -
14281426 wfRunHooks( 'LiquidThreadsShowPostThreadBody',
14291427 array( $thread, $this->request, &$html ) );
14301428
@@ -1752,7 +1750,6 @@
17531751 }
17541752
17551753 $div = Xml::openElement( 'div', array( 'class' => $repliesClass ) );
1756 - $sep = Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), '&#160;' );
17571754
17581755 $subthreadCount = count( $thread->subthreads() );
17591756 $i = 0;
@@ -1785,7 +1782,7 @@
17861783 if ( $showCount == 1 ) {
17871784 // There's a post sep before each reply group to
17881785 // separate from the parent thread.
1789 - $this->output->addHTML( $sep . $div );
 1786+ $this->output->addHTML( $div );
17901787 }
17911788
17921789 $this->showThread( $st, $i, $subthreadCount, $cascadeOptions );

Follow-up revisions

RevisionCommit summaryAuthorDate
r71579Followup to r71504 - adding forgotten image filesadam20:19, 24 August 2010
r71588Followup to r71504 - fixing the More menuadam21:21, 24 August 2010

Comments

#Comment by Nikerabbit (talk | contribs)   20:10, 24 August 2010

Failed to load resource: the server responded with a status of 404 (Not Found)

w/extensions/LiquidThreads/images/thread_collapse_control_expanded.gif

Also the "more" links are broken (excep the last one on the page?).

#Comment by Nikerabbit (talk | contribs)   06:33, 25 August 2010

Both issues fixed in follow-ups.

Status & tagging log