
werdna at svn
Nov 20, 2009, 9:30 AM
Post #1 of 1
(88 views)
Permalink
|
|
SVN: [59292] trunk/extensions/LiquidThreads
|
|
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59292 Revision: 59292 Author: werdna Date: 2009-11-20 17:30:08 +0000 (Fri, 20 Nov 2009) Log Message: ----------- LiquidThreads: instead of deleting a thread altogether when marking it as read, replace it with a note that it was marked as read, giving an option to bring it back. Modified Paths: -------------- trunk/extensions/LiquidThreads/classes/View.php trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php trunk/extensions/LiquidThreads/lqt.css trunk/extensions/LiquidThreads/newmessages.js trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php Modified: trunk/extensions/LiquidThreads/classes/View.php =================================================================== --- trunk/extensions/LiquidThreads/classes/View.php 2009-11-20 17:04:35 UTC (rev 59291) +++ trunk/extensions/LiquidThreads/classes/View.php 2009-11-20 17:30:08 UTC (rev 59292) @@ -826,6 +826,8 @@ 'lqt-thread-link-title', 'lqt-thread-link-copy', 'lqt-sign-not-necessary', + 'lqt-marked-as-read-placeholder', + 'lqt-email-undo', ); $data = array(); Modified: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php =================================================================== --- trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php 2009-11-20 17:04:35 UTC (rev 59291) +++ trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php 2009-11-20 17:30:08 UTC (rev 59292) @@ -247,6 +247,7 @@ 'lqt-thread-link-copy' => 'Copy to clipboard', 'lqt-sign-not-necessary' => 'It is not necessary to sign your post with four tildes. The signature is shown automatically.', + 'lqt-marked-as-read-placeholder' => 'The thread $1 was marked as read.', // Feeds 'lqt-feed-title-all' => '{{SITENAME}} — New posts', Modified: trunk/extensions/LiquidThreads/lqt.css =================================================================== --- trunk/extensions/LiquidThreads/lqt.css 2009-11-20 17:04:35 UTC (rev 59291) +++ trunk/extensions/LiquidThreads/lqt.css 2009-11-20 17:30:08 UTC (rev 59292) @@ -461,7 +461,7 @@ width: 100%; } -.mw-lqt-newmessages-left { +.lqt-newmessages-left { width: 10em ; } Modified: trunk/extensions/LiquidThreads/newmessages.js =================================================================== --- trunk/extensions/LiquidThreads/newmessages.js 2009-11-20 17:04:35 UTC (rev 59291) +++ trunk/extensions/LiquidThreads/newmessages.js 2009-11-20 17:30:08 UTC (rev 59292) @@ -1,3 +1,61 @@ +liquidThreads.markReadDone = +{ + 'one' : function(reply,button,operand) { + var row = $j(button).closest('tr'); + var right_col = row.find('td.lqt-newmessages-right'); + $j(button).closest('td').empty(); + + var msg = wgLqtMessages['lqt-marked-as-read-placeholder']; + var undoMsg = wgLqtMessages['lqt-email-undo']; + // We have to split the message to the part before the + // $1 and the part after the $1 + var placeholderIndex = msg.indexOf( '$1' ); + var elem = $j('<span class="lqt-read-placeholder"/>'); + + if (placeholderIndex >= 0) { + var beforeMsg = msg.substr(0,placeholderIndex); + var afterMsg = msg.substr(placeholderIndex+2); + + var beforeText = $j(document.createTextNode(beforeMsg)); + elem.append(beforeText); + + // Produce the link + var titleSel = '.lqt-thread-topmost > .lqt-thread-title-metadata'; + var subject = right_col.find('h3').text(); + var title = right_col.find(titleSel).val(); + var url = wgArticlePath.replace( '$1', title ); + var link = $j('<a/>').attr('href', url).text(subject); + elem.append(link); + + var afterText = $j(document.createTextNode(afterMsg+' ')); + elem.append(afterText); + } else { + elem.text(msg); + } + + // Add the "undo" link. + var undoURL = wgArticlePath.replace( '$1', wgPageName ); + alert( undoURL ); + var query = 'lqt_method=mark_as_unread&lqt_operand='+operand; + if ( undoURL.indexOf('?') == -1 ) { + query = '?'+query; + } else { + query = '&'+query; + } + undoURL += query; + + var undoLink = $j('<a/>').attr('href', undoURL).text(undoMsg); + elem.append( undoLink ); + + right_col.empty().append(elem); + }, + + 'all' : function(reply) { + var tables = $j('table.lqt-new-messages'); + tables.fadeOut( 'slow', + function() { tables.remove(); } ); + } +}; liquidThreads.doMarkRead = function(e) { @@ -29,21 +87,6 @@ var spinner = $j('<div class="mw-ajax-loader"/>'); $j(button).before( spinner ); - var doneCallback = - function(reply) { - if ( type == 'one' ) { - var row = button.closest('tr'); - row.fadeOut( 'slow', - function() { row.remove(); } ); - } else { - var tables = $j('table.lqt-new-messages'); - tables.fadeOut( 'slow', - function() { tables.remove(); } ); - } - - spinner.remove(); - } - $j.get( wgScriptPath+'/api'+wgScriptExtension, getTokenParams, function( data ) { var token = data.query.pages[-1].edittoken; @@ -59,9 +102,12 @@ $j.post( wgScriptPath+'/api'+wgScriptExtension, markReadParameters, - doneCallback, 'json' ); + function(e) { + liquidThreads.markReadDone[type](e,button,operand); + spinner.remove(); + }, 'json' ); }, 'json' ); - } + }; // Setup $j( function() { Modified: trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php =================================================================== --- trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php 2009-11-20 17:04:35 UTC (rev 59291) +++ trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php 2009-11-20 17:30:08 UTC (rev 59292) @@ -54,8 +54,8 @@ 'title' => wfMsg( 'lqt-email-info-undo' ) ) ); $html = Xml::tags( 'form', - array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ), - $html ); + array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ), + $html ); return $html; } @@ -81,15 +81,10 @@ global $wgOut, $wgScriptPath; $wgOut->addScriptFile( "{$wgScriptPath}/extensions/LiquidThreads/newmessages.js" ); } + + $this->user->setNewtalk( false ); - if ( $this->request->wasPosted() ) { - // If they just viewed this page, maybe they still want that notice. - // But if they took the time to dismiss even one message, they - // probably don't anymore. - $this->user->setNewtalk( false ); - } - - if ( $this->request->wasPosted() && $this->methodApplies( 'mark_as_unread' ) ) { + if ( $this->methodApplies( 'mark_as_unread' ) ) { $ids = explode( ',', $this->request->getVal( 'lqt_operand', '' ) ); if ( $ids !== false ) { @@ -99,7 +94,7 @@ } $this->output->redirect( $this->title->getFullURL() ); } - } elseif ( $this->request->wasPosted() && $this->methodApplies( 'mark_as_read' ) ) { + } elseif ( $this->methodApplies( 'mark_as_read' ) ) { $ids = explode( ',', $this->request->getVal( 'lqt_operand' ) ); if ( $ids !== false ) { foreach ( $ids as $id ) { @@ -188,9 +183,9 @@ $leftColumn = Xml::tags( 'p', null, $read_button ) . Xml::tags( 'p', null, $contextLink ) . $talkpageInfo; - $leftColumn = Xml::tags( 'td', array( 'class' => 'mw-lqt-newmessages-left' ), + $leftColumn = Xml::tags( 'td', array( 'class' => 'lqt-newmessages-left' ), $leftColumn ); - $html = "<tr>$leftColumn<td>"; + $html = "<tr>$leftColumn<td class='lqt-newmessages-right'>"; $this->output->addHTML( $html ); $mustShowThreads = $this->targets[$t->id()]; _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|