r53054 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53053‎ | r53054 | r53055 >
Date:14:55, 10 July 2009
Author:werdna
Status:deferred
Tags:
Comment:
* Fix LQT output to include only post content in the div.lqt_post
* Fix quoting. If nothing's selected, quote the whole post.
* Trim quote before quoting, sometimes you can get lots of random newlines.
* Fix JS warning for internal call to handleReplyLink by conditionally calling preventDefault.
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/LqtView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/LqtView.php
@@ -724,7 +724,7 @@
725725
726726 $html = Xml::tags( 'div', array( 'class' => 'lqt-thread-header' ), $html );
727727
728 - $this->output->addHTML( $html );
 728+ return $html;
729729 }
730730
731731 function showThreadFooter( $thread ) {
@@ -790,7 +790,7 @@
791791 $post = $thread->root();
792792
793793 $divClass = $this->postDivClass( $thread );
794 - $html = Xml::openElement( 'div', array( 'class' => $divClass ) );
 794+ $html = '';
795795
796796 // This is a bit of a hack to have individual histories work.
797797 // We can grab oldid either from lqt_oldid (which is a thread rev),
@@ -806,23 +806,27 @@
807807
808808 // If we're editing the thread, show the editing form.
809809 if ( $this->methodAppliesToThread( 'edit', $thread ) ) {
 810+ $html = Xml::openElement( 'div', array( 'class' => $divClass ) );
810811 $this->output->addHTML( $html );
811812 $html = '';
812813
813814 // No way am I refactoring EditForm to send its output as HTML.
814815 // so I'm just flushing the HTML and displaying it as-is.
815816 $this->showPostEditingForm( $thread );
 817+ $html .= Xml::closeElement( 'div' );
816818 } else {
817819 $html .= $this->showThreadHeader( $thread );
818820 $html .= $this->getReplyContext( $thread );
 821+ $html .= Xml::openElement( 'div', array( 'class' => $divClass ) );
819822 $html .= $this->showPostBody( $post, $oldid );
 823+ $html .= Xml::closeElement( 'div' );
820824 $html .= $this->showThreadFooter( $thread );
821825 }
822826
823827 // wish I didn't have to use this open/closeElement cruft.
824 - $html .= Xml::closeElement( 'div' );
825828
826829
 830+
827831 // If we're replying to this thread, show the reply form after it.
828832 if ( $this->methodAppliesToThread( 'reply', $thread ) ) {
829833 // As with above, flush HTML to avoid refactoring EditPage.
Index: trunk/extensions/LiquidThreads/lqt.js
@@ -16,7 +16,8 @@
1717
1818 liquidThreads.injectEditForm( query, container, footer_cmds.nextSibling, e.preload );
1919
20 - e.preventDefault();
 20+ if (e.preventDefault)
 21+ e.preventDefault();
2122
2223 return false;
2324 },
@@ -34,7 +35,9 @@
3536
3637 liquidThreads.injectEditForm( query, container, link.parentNode.nextSibling );
3738
38 - e.preventDefault();
 39+ if (e.preventDefault)
 40+ e.preventDefault();
 41+
3942 return false;
4043 },
4144
@@ -97,6 +100,7 @@
98101 },
99102
100103 'transformQuote' : function(quote) {
 104+ quote = quote.trim();
101105 var lines = quote.split("\n");
102106 var newQuote = '';
103107
@@ -126,24 +130,39 @@
127131 var button;
128132 if (e.target) button = e.target;
129133 else if (e.srcElement) button = e.srcElement;
 134+ if (button.nodeType == 3) // defeat Safari bug
 135+ button = button.parentNode;
130136
 137+ var thread = button;
 138+
 139+ // Get the post node
 140+ // Keep walking up until we hit the thread node.
 141+ while (thread.id.substr(0,13) != 'lqt_thread_id') {
 142+ thread = thread.parentNode;
 143+ }
 144+ var post = getElementsByClassName( thread, 'div', 'lqt_post' )[0];
 145+
131146 var text = liquidThreads.getSelection();
 147+
 148+ if (text.length == 0) {
 149+ // Quote the whole post
 150+ if (post.innerText) {
 151+ text = post.innerText;
 152+ } else if (post.textContent) {
 153+ text = post.textContent;
 154+ }
 155+ }
 156+
132157 text = liquidThreads.transformQuote( text );
133158 // TODO auto-generate context info and link.
134159
135160 var textbox = document.getElementById( 'wpTextbox1' );
136161 if (textbox) {
137162 liquidThreads.insertAtCursor( textbox, text );
 163+ textbox.focus();
138164 } else {
139165 // Open the reply window
140 - var elem = button;
141 -
142 - // Keep walking up until we hit the thread node.
143 - while (elem.id.substr(0,13) != 'lqt_thread_id') {
144 - elem = elem.parentNode;
145 - }
146 - var post = getElementsByClassName( elem, 'div', 'lqt_post' )[0];
147 - var replyLI = getElementsByClassName( post, 'li', 'lqt-command-reply' )[0];
 166+ var replyLI = getElementsByClassName( thread, 'li', 'lqt-command-reply' )[0];
148167 var replyLink = replyLI.getElementsByTagName( 'a' )[0];
149168
150169 liquidThreads.handleReplyLink( { 'target':replyLink, 'preload':text } );

Status & tagging log