Index: branches/liquidthreads/skins/monobook/main.css |
— | — | @@ -40,6 +40,10 @@ |
41 | 41 | top:-3.2em; |
42 | 42 | } |
43 | 43 | |
| 44 | +.lqt_hidden { |
| 45 | + display: none; |
| 46 | +} |
| 47 | + |
44 | 48 | h1.firstHeading { |
45 | 49 | padding-right: 4.5em; |
46 | 50 | } |
— | — | @@ -110,8 +114,8 @@ |
111 | 115 | font-size: smaller; |
112 | 116 | color: #777; |
113 | 117 | |
114 | | - padding-left: 0.3em; /* for post colors */ |
115 | | - border-left: 0.3em solid; |
| 118 | +// padding-left: 0.3em; /* for post colors */ |
| 119 | +// border-left: 0.3em solid; |
116 | 120 | } |
117 | 121 | |
118 | 122 | .lqt_post_color_1 { border-left-color: #cd9800; } |
Index: branches/liquidthreads/skins/common/lqt.js |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +// http://onlinetools.org/articles/unobtrusivejavascript/chapter4.html |
| 3 | +function lqt_add_event(obj, evType, fn){ |
| 4 | + if (obj.addEventListener){ |
| 5 | + obj.addEventListener(evType, fn, false); |
| 6 | + return true; |
| 7 | + } else if (obj.attachEvent){ |
| 8 | + var r = obj.attachEvent("on"+evType, fn); |
| 9 | + return r; |
| 10 | + } else { |
| 11 | + return false; |
| 12 | + } |
| 13 | +} |
| 14 | + |
| 15 | +function lqt_on_load() { |
| 16 | + /* Hide the Go button on the archive widget, because we will |
| 17 | + automatically go when a selection is made. */ |
| 18 | + document.getElementById('lqt_archive_go_button').className = "lqt_hidden"; |
| 19 | + |
| 20 | + var dropdown = document.getElementById('lqt_archive_month'); |
| 21 | + lqt_add_event(dropdown, 'change', function(){ |
| 22 | + document.getElementById('lqt_archive_browser_form').submit(); |
| 23 | + }); |
| 24 | +} |
| 25 | + |
| 26 | +addOnloadHook(lqt_on_load); |
\ No newline at end of file |
Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -246,14 +246,12 @@ |
247 | 247 | $p = new Parser(); $sig = $p->getUserSig( $thread->rootPost()->originalAuthor() ); |
248 | 248 | $this->output->addWikitext( $sig, false ); |
249 | 249 | $this->output->addHTML( wfCloseElement( 'li' ) ); |
250 | | - |
251 | | - global $wgContLang; |
252 | | - $this->output->addHTML( |
253 | | - wfOpenElement( 'li' ) . |
254 | | - $wgContLang->timeanddate( $thread->touched() ) . |
255 | | - wfCloseElement( 'li' ) |
256 | | - ); |
257 | 250 | |
| 251 | + $this->output->addHTML( wfOpenElement( 'li' ) ); |
| 252 | + $d = new Date($thread->touched()); |
| 253 | + $this->output->addHTML( $d->lastMonth()->text() ); |
| 254 | + $this->output->addHTML( wfCloseElement( 'li' ) ); |
| 255 | + |
258 | 256 | $commands = array( 'Edit' => $this->lqtTalkpageUrl( $this->title, 'lqt_edit_post', $thread ), |
259 | 257 | 'Reply' => $this->lqtTalkpageUrl( $this->title, 'lqt_reply_to', $thread ), |
260 | 258 | 'Permalink' => $this->permalinkUrl( $thread ) ); |
— | — | @@ -349,6 +347,8 @@ |
350 | 348 | } |
351 | 349 | |
352 | 350 | function showArchive($month) { |
| 351 | + // TODO having a subtitle screws up our relative positioning on the widget. |
| 352 | +// $this->output->setSubtitle("Archived threads from {$this->formattedMonth($month)}."); |
353 | 353 | $threads = Thread::threadsOfArticleInMonth( $this->article, $month ); |
354 | 354 | foreach($threads as $t) { |
355 | 355 | $this->showThread($t); |
— | — | @@ -369,30 +369,55 @@ |
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
| 373 | + function formattedMonth($yyyymm) { |
| 374 | + global $wgLang; // TODO global. |
| 375 | + return $wgLang->getMonthName( substr($yyyymm, 4, 2) ).' '.substr($yyyymm, 0, 4); |
| 376 | + } |
| 377 | + |
373 | 378 | function showArchiveWidget($month) { |
374 | 379 | global $wgLang; // TODO global. |
375 | 380 | |
376 | | - $options = Thread::monthsWhereArticleHasThreads($this->article); |
377 | | - array_unshift($options, 'Last 30 days' ); # prepend. |
| 381 | + $sel = $this->request->getVal('lqt_archive_month', 'recent'); |
378 | 382 | |
| 383 | + $months = Thread::monthsWhereArticleHasThreads($this->article); |
| 384 | + |
| 385 | + $options = array( 'Last 30 days' => 'recent' ); |
| 386 | + foreach($months as $m) { |
| 387 | + $options[$this->formattedMonth($m)] = $m; |
| 388 | + } |
| 389 | + |
379 | 390 | $this->openDiv('lqt_archive_widget'); |
380 | | - $this->output->addHTML('<form><select>'); |
381 | | - foreach( $options as $o ) { |
382 | | - $this->output->addHTML("<option>$o</option>"); |
| 391 | + $this->output->addHTML(<<<HTML |
| 392 | + <form id="lqt_archive_browser_form"><select name="lqt_archive_month" id="lqt_archive_month"> |
| 393 | +HTML |
| 394 | +); |
| 395 | + foreach( $options as $label => $value ) { |
| 396 | + $selected = $sel == $value ? 'selected="true"' : ''; |
| 397 | + $this->output->addHTML("<option value=\"$value\" $selected>$label"); |
383 | 398 | } |
384 | | - $this->output->addHTML('</select></form>'); |
| 399 | + $this->output->addHTML(<<<HTML |
| 400 | + </select><input type="submit" id="lqt_archive_go_button" value="Go"></form> |
| 401 | +HTML |
| 402 | + ); |
385 | 403 | $this->closeDiv(); |
386 | 404 | } |
387 | 405 | |
| 406 | + function addJSandCSS() { |
| 407 | + global $wgJsMimeType, $wgStylePath; // TODO globals. |
| 408 | + $s = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/lqt.js\"><!-- lqt js --></script>\n"; |
| 409 | + $this->output->addScript($s); |
| 410 | + } |
| 411 | + |
388 | 412 | function show() { |
389 | 413 | global $wgHooks; |
390 | 414 | $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs'); |
391 | 415 | |
392 | 416 | $this->output->setPageTitle( "Talk:" . $this->title->getText() ); |
| 417 | + $this->addJSandCSS(); |
393 | 418 | |
394 | 419 | $month = $this->request->getVal('lqt_archive_month'); |
395 | 420 | $this->showArchiveWidget($month); |
396 | | - if ( $month ) { |
| 421 | + if ( $month && $month != 'recent' ) { |
397 | 422 | $this->showArchive($month); |
398 | 423 | } else { |
399 | 424 | $this->showLatest(); |