Index: trunk/extensions/LiquidThreads/classes/LqtView.php |
— | — | @@ -724,7 +724,7 @@ |
725 | 725 | |
726 | 726 | $html = Xml::tags( 'div', array( 'class' => 'lqt-thread-header' ), $html ); |
727 | 727 | |
728 | | - $this->output->addHTML( $html ); |
| 728 | + return $html; |
729 | 729 | } |
730 | 730 | |
731 | 731 | function showThreadFooter( $thread ) { |
— | — | @@ -790,7 +790,7 @@ |
791 | 791 | $post = $thread->root(); |
792 | 792 | |
793 | 793 | $divClass = $this->postDivClass( $thread ); |
794 | | - $html = Xml::openElement( 'div', array( 'class' => $divClass ) ); |
| 794 | + $html = ''; |
795 | 795 | |
796 | 796 | // This is a bit of a hack to have individual histories work. |
797 | 797 | // We can grab oldid either from lqt_oldid (which is a thread rev), |
— | — | @@ -806,23 +806,27 @@ |
807 | 807 | |
808 | 808 | // If we're editing the thread, show the editing form. |
809 | 809 | if ( $this->methodAppliesToThread( 'edit', $thread ) ) { |
| 810 | + $html = Xml::openElement( 'div', array( 'class' => $divClass ) ); |
810 | 811 | $this->output->addHTML( $html ); |
811 | 812 | $html = ''; |
812 | 813 | |
813 | 814 | // No way am I refactoring EditForm to send its output as HTML. |
814 | 815 | // so I'm just flushing the HTML and displaying it as-is. |
815 | 816 | $this->showPostEditingForm( $thread ); |
| 817 | + $html .= Xml::closeElement( 'div' ); |
816 | 818 | } else { |
817 | 819 | $html .= $this->showThreadHeader( $thread ); |
818 | 820 | $html .= $this->getReplyContext( $thread ); |
| 821 | + $html .= Xml::openElement( 'div', array( 'class' => $divClass ) ); |
819 | 822 | $html .= $this->showPostBody( $post, $oldid ); |
| 823 | + $html .= Xml::closeElement( 'div' ); |
820 | 824 | $html .= $this->showThreadFooter( $thread ); |
821 | 825 | } |
822 | 826 | |
823 | 827 | // wish I didn't have to use this open/closeElement cruft. |
824 | | - $html .= Xml::closeElement( 'div' ); |
825 | 828 | |
826 | 829 | |
| 830 | + |
827 | 831 | // If we're replying to this thread, show the reply form after it. |
828 | 832 | if ( $this->methodAppliesToThread( 'reply', $thread ) ) { |
829 | 833 | // As with above, flush HTML to avoid refactoring EditPage. |
Index: trunk/extensions/LiquidThreads/lqt.js |
— | — | @@ -16,7 +16,8 @@ |
17 | 17 | |
18 | 18 | liquidThreads.injectEditForm( query, container, footer_cmds.nextSibling, e.preload ); |
19 | 19 | |
20 | | - e.preventDefault(); |
| 20 | + if (e.preventDefault) |
| 21 | + e.preventDefault(); |
21 | 22 | |
22 | 23 | return false; |
23 | 24 | }, |
— | — | @@ -34,7 +35,9 @@ |
35 | 36 | |
36 | 37 | liquidThreads.injectEditForm( query, container, link.parentNode.nextSibling ); |
37 | 38 | |
38 | | - e.preventDefault(); |
| 39 | + if (e.preventDefault) |
| 40 | + e.preventDefault(); |
| 41 | + |
39 | 42 | return false; |
40 | 43 | }, |
41 | 44 | |
— | — | @@ -97,6 +100,7 @@ |
98 | 101 | }, |
99 | 102 | |
100 | 103 | 'transformQuote' : function(quote) { |
| 104 | + quote = quote.trim(); |
101 | 105 | var lines = quote.split("\n"); |
102 | 106 | var newQuote = ''; |
103 | 107 | |
— | — | @@ -126,24 +130,39 @@ |
127 | 131 | var button; |
128 | 132 | if (e.target) button = e.target; |
129 | 133 | else if (e.srcElement) button = e.srcElement; |
| 134 | + if (button.nodeType == 3) // defeat Safari bug |
| 135 | + button = button.parentNode; |
130 | 136 | |
| 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 | + |
131 | 146 | 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 | + |
132 | 157 | text = liquidThreads.transformQuote( text ); |
133 | 158 | // TODO auto-generate context info and link. |
134 | 159 | |
135 | 160 | var textbox = document.getElementById( 'wpTextbox1' ); |
136 | 161 | if (textbox) { |
137 | 162 | liquidThreads.insertAtCursor( textbox, text ); |
| 163 | + textbox.focus(); |
138 | 164 | } else { |
139 | 165 | // 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]; |
148 | 167 | var replyLink = replyLI.getElementsByTagName( 'a' )[0]; |
149 | 168 | |
150 | 169 | liquidThreads.handleReplyLink( { 'target':replyLink, 'preload':text } ); |