Index: trunk/extensions/LiquidThreads/lqt.css |
— | — | @@ -488,3 +488,11 @@ |
489 | 489 | .mw-lqt-newmessages-left { |
490 | 490 | width: 10em ; |
491 | 491 | } |
| 492 | + |
| 493 | +.lqt-command-working { |
| 494 | + padding: 10px !important; |
| 495 | + margin-right: 0.6em; |
| 496 | + background-image: url(../../skins/common/images/spinner.gif); |
| 497 | + background-position: middle middle; |
| 498 | + background-repeat: no-repeat; |
| 499 | +} |
Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -672,7 +672,7 @@ |
673 | 673 | wfLoadExtensionMessages( 'LiquidThreads' ); |
674 | 674 | |
675 | 675 | $messages = array( 'lqt-quote-intro', 'lqt-quote', 'lqt-ajax-updated', |
676 | | - 'lqt-ajax-update-link' ); |
| 676 | + 'lqt-ajax-update-link', 'watch', 'unwatch' ); |
677 | 677 | $data = array(); |
678 | 678 | |
679 | 679 | foreach( $messages as $msg ) { |
— | — | @@ -911,8 +911,10 @@ |
912 | 912 | $commands_html = ""; |
913 | 913 | } else { |
914 | 914 | $lis = $this->listItemsForCommands( $this->topLevelThreadCommands( $thread ) ); |
| 915 | + $id = 'lqt-threadlevel-commands-'.$thread->id(); |
915 | 916 | $commands_html = Xml::tags( 'ul', |
916 | | - array( 'class' => 'lqt_threadlevel_commands' ), |
| 917 | + array( 'class' => 'lqt_threadlevel_commands', |
| 918 | + 'id' => $id ), |
917 | 919 | $lis ); |
918 | 920 | } |
919 | 921 | |
— | — | @@ -1067,7 +1069,13 @@ |
1068 | 1070 | wfTimestamp( TS_MW, $thread->modified() ), |
1069 | 1071 | array( 'id' => 'lqt-thread-modified-'.$thread->id(), |
1070 | 1072 | 'class' => 'lqt-thread-modified' ) ); |
1071 | | - } |
| 1073 | + } |
| 1074 | + |
| 1075 | + // Add the thread's title |
| 1076 | + $html .= Xml::hidden( 'lqt-thread-title-'.$thread->id(), |
| 1077 | + $thread->title()->getPrefixedText(), |
| 1078 | + array( 'id' => 'lqt-thread-title-'.$thread->id(), |
| 1079 | + 'class' => 'lqt-thread-title-metadata' ) ); |
1072 | 1080 | |
1073 | 1081 | // Flush output to display thread |
1074 | 1082 | $this->output->addHTML( $html ); |
Index: trunk/extensions/LiquidThreads/lqt.js |
— | — | @@ -485,6 +485,44 @@ |
486 | 486 | }, 'json' ); |
487 | 487 | |
488 | 488 | $j(this).remove(); |
| 489 | + }, |
| 490 | + |
| 491 | + 'asyncWatch' : function(e) { |
| 492 | + var button = $j(this); |
| 493 | + var tlcOffset = "lqt-threadlevel-commands-".length; |
| 494 | + |
| 495 | + // Find the title of the thread |
| 496 | + var threadLevelCommands = button.closest('.lqt_threadlevel_commands'); |
| 497 | + var threadID = threadLevelCommands.attr('id').substring( tlcOffset ); |
| 498 | + var title = $j('#lqt-thread-title-'+threadID).val(); |
| 499 | + |
| 500 | + // Check if we're watching or unwatching. |
| 501 | + var action = ''; |
| 502 | + if ( button.hasClass( 'lqt-command-watch' ) ) { |
| 503 | + button.removeClass( 'lqt-command-watch' ); |
| 504 | + action = 'watch'; |
| 505 | + } else if ( button.hasClass( 'lqt-command-unwatch' ) ) { |
| 506 | + button.removeClass( 'lqt-command-unwatch' ); |
| 507 | + action = 'unwatch'; |
| 508 | + } |
| 509 | + |
| 510 | + // Replace the watch link with a spinner |
| 511 | + button.empty().addClass( 'lqt-command-working' ); |
| 512 | + |
| 513 | + // Do the AJAX call. |
| 514 | + var apiParams = { 'action' : 'watch', 'title' : title, 'format' : 'json' }; |
| 515 | + |
| 516 | + if (action == 'unwatch') { |
| 517 | + apiParams.unwatch = 'yes'; |
| 518 | + } |
| 519 | + |
| 520 | + $j.get( wgScriptPath+'/api'+wgScriptExtension, apiParams, |
| 521 | + function( data ) { |
| 522 | + threadLevelCommands.load( window.location.href+' '+ |
| 523 | + '#'+threadLevelCommands.attr('id')+' > *' ); |
| 524 | + }, 'json' ); |
| 525 | + |
| 526 | + e.preventDefault(); |
489 | 527 | } |
490 | 528 | } |
491 | 529 | |
— | — | @@ -529,6 +567,10 @@ |
530 | 568 | liquidThreads.setupThread( this ); |
531 | 569 | } ); |
532 | 570 | |
| 571 | + // Live bind for unwatch/watch stuff. |
| 572 | + $j('.lqt-command-watch').live( 'click', liquidThreads.asyncWatch ); |
| 573 | + $j('.lqt-command-unwatch').live( 'click', liquidThreads.asyncWatch ); |
| 574 | + |
533 | 575 | // Set up periodic update checking |
534 | 576 | setInterval( liquidThreads.checkForUpdates, 60000 ); |
535 | 577 | } ); |