Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
— | — | @@ -240,7 +240,11 @@ |
241 | 241 | |
242 | 242 | global $wgRequest; |
243 | 243 | if ( $this->methodApplies( 'talkpage_new_thread' ) ) { |
| 244 | + $params = array( 'class' => 'lqt-new-thread lqt-edit-form', |
| 245 | + 'style' => 'display: none;'); |
| 246 | + $this->output->addHTML( Xml::openElement( 'div', $params ) ); |
244 | 247 | $this->showNewThreadForm(); |
| 248 | + $this->output->addHTML( Xml::closeElement( 'div' ) ); |
245 | 249 | } else { |
246 | 250 | $this->showTalkpageViewOptions( $article ); |
247 | 251 | $newThreadLink = $this->talkpageLink( $this->title, |
— | — | @@ -250,6 +254,9 @@ |
251 | 255 | array( 'known' ) ); |
252 | 256 | |
253 | 257 | $this->output->addHTML( Xml::tags( 'strong', null, $newThreadLink ) ); |
| 258 | + |
| 259 | + $this->output->addHTML( Xml::tags( 'div', |
| 260 | + array( 'class' => 'lqt-new-thread lqt-edit-form' ), '' ) ); |
254 | 261 | } |
255 | 262 | |
256 | 263 | $this->showSearchBox(); |
Index: trunk/extensions/LiquidThreads/lqt.js |
— | — | @@ -1,82 +1,48 @@ |
2 | 2 | var liquidThreads = { |
3 | 3 | 'handleReplyLink' : function(e) { |
4 | | - var link; |
5 | | - if (!e) e = window.event; |
6 | | - if (e.target) link = e.target; |
7 | | - else if (e.srcElement) link = e.srcElement; |
8 | | - if (link.nodeType == 3) // defeat Safari bug |
9 | | - link = link.parentNode; |
10 | | - link = link.parentNode; // Get the enclosing li. |
| 4 | + e.preventDefault(); |
11 | 5 | |
12 | 6 | var prefixLength = "lqt-reply-id-".length; |
13 | | - var thread_id = link.id.substring( prefixLength ); |
14 | | - var container = document.getElementById( 'lqt_thread_id_'+thread_id ); |
15 | | - var footer_cmds = getElementsByClassName( container, '*', 'lqt-thread-toolbar' )[0]; |
| 7 | + var replyLI = $j(this).closest('.lqt-command-reply')[0]; |
| 8 | + var thread_id = replyLI.id.substring( prefixLength ); |
| 9 | + var container = $j( '#lqt_thread_id_'+thread_id ); |
16 | 10 | var query = '&lqt_method=reply&lqt_operand='+thread_id; |
17 | 11 | |
18 | | - liquidThreads.injectEditForm( query, container, footer_cmds.nextSibling, e.preload ); |
19 | | - |
20 | | - if (e.preventDefault) |
21 | | - e.preventDefault(); |
| 12 | + var replyDiv = $j(container).find('.lqt-reply-form')[0]; |
22 | 13 | |
| 14 | + liquidThreads.injectEditForm( query, replyDiv, e.preload ); |
| 15 | + |
23 | 16 | return false; |
24 | 17 | }, |
25 | 18 | |
26 | 19 | 'handleNewLink' : function(e) { |
27 | | - var link; |
28 | | - if (!e) e = window.event; |
29 | | - if (e.target) link = e.target; |
30 | | - else if (e.srcElement) link = e.srcElement; |
31 | | - if (link.nodeType == 3) // defeat Safari bug |
32 | | - link = link.parentNode; |
33 | | - |
| 20 | + e.preventDefault(); |
| 21 | + |
34 | 22 | var query = '&lqt_method=talkpage_new_thread'; |
35 | | - var container = document.getElementById( 'bodyContent' ); |
36 | 23 | |
37 | | - liquidThreads.injectEditForm( query, container, link.parentNode.nextSibling ); |
| 24 | + var container = $j('.lqt-new-thread' ); |
38 | 25 | |
39 | | - if (e.preventDefault) |
40 | | - e.preventDefault(); |
| 26 | + liquidThreads.injectEditForm( query, container ); |
41 | 27 | |
42 | 28 | return false; |
43 | 29 | }, |
44 | 30 | |
45 | | - 'injectEditForm' : function(query, container, before, preload) { |
46 | | - var x = sajax_init_object(); |
47 | | - var url = wgServer+wgScript+'?title='+encodeURIComponent(wgPageName)+ |
48 | | - query+'&lqt_inline=1' |
49 | | - x.open( 'get', url, true ); |
50 | | - |
51 | | - x.onreadystatechange = |
52 | | - function() { |
53 | | - if (x.readyState != 4) |
54 | | - return; |
| 31 | + 'injectEditForm' : function(query, container, preload) { |
| 32 | + var url = wgServer+wgScript+'?lqt_inline=1&title='+encodeURIComponent(wgPageName)+ |
| 33 | + query |
55 | 34 | |
56 | | - if ( liquidThreads.currentEditForm ) { |
57 | | - var f = liquidThreads.currentEditForm; |
58 | | - f.parentNode.removeChild( f ); |
59 | | - } |
60 | | - |
61 | | - var result = x.responseText; |
62 | | - var replyDiv = document.createElement( 'div' ); |
63 | | - replyDiv.className = 'lqt_ajax_reply_form' |
64 | | - replyDiv.innerHTML = result; |
65 | | - |
66 | | - if (before) { |
67 | | - container.insertBefore( replyDiv, before ); |
68 | | - } else { |
69 | | - container.appendChild( replyDiv ); |
70 | | - } |
71 | | - |
72 | | - liquidThreads.currentEditForm = replyDiv; |
73 | | - |
74 | | - if (preload) { |
75 | | - var textbox = document.getElementById( 'wpTextbox1' ); |
76 | | - textbox.value = preload; |
77 | | - } |
78 | | - }; |
| 35 | + $j('.lqt-reply-form').not(container).slideUp('slow'); |
| 36 | + $j('.lqt-reply-form').not(container).empty(); |
79 | 37 | |
80 | | - x.send( null ); |
| 38 | + $j(container).load(wgServer+wgScript, 'title='+encodeURIComponent(wgPageName)+ |
| 39 | + query+'&lqt_inline=1', |
| 40 | + function() { |
| 41 | + if (preload) { |
| 42 | + $j("textarea", container)[0].value = preload; |
| 43 | + } |
| 44 | + |
| 45 | + $j(container).slideDown('slow'); |
| 46 | + } ); |
81 | 47 | }, |
82 | 48 | |
83 | 49 | //From http://clipmarks.com/clipmark/CEFC94CB-94D6-4495-A7AA-791B7355E284/ |
— | — | @@ -137,17 +103,8 @@ |
138 | 104 | }, |
139 | 105 | |
140 | 106 | 'doQuote' : function(e) { |
141 | | - if (!e) e = window.event; |
142 | 107 | e.preventDefault(); |
143 | 108 | |
144 | | - var button; |
145 | | - if (e.target) button = e.target; |
146 | | - else if (e.srcElement) button = e.srcElement; |
147 | | - if (button.nodeType == 3) // defeat Safari bug |
148 | | - button = button.parentNode; |
149 | | - |
150 | | - var thread = button; |
151 | | - |
152 | 109 | // Get the post node |
153 | 110 | // Keep walking up until we hit the thread node. |
154 | 111 | while (thread.id.substr(0,13) != 'lqt_thread_id') { |
— | — | @@ -185,54 +142,48 @@ |
186 | 143 | }, |
187 | 144 | |
188 | 145 | 'showQuoteButtons' : function() { |
189 | | - var elems = getElementsByClassName( document, 'div', 'lqt-thread-header-rhs' ); |
| 146 | + var elems = $j('div.lqt-thread-header-rhs'); |
190 | 147 | |
191 | | - var length = elems.length; |
192 | | - for( var i = 0; i<length; ++i ) { |
193 | | - var quoteButton = document.createElement( 'span' ); |
| 148 | + elems.each( function(i) { |
| 149 | + var quoteButton = $j('<span></span>' ); |
194 | 150 | quoteButton.className = 'lqt-header-quote'; |
195 | 151 | |
196 | | - var text = wgLqtMessages['lqt-quote']; |
197 | | - var textNode = document.createTextNode( text ); |
| 152 | + var link = $j('<a href="#"></a>'); |
| 153 | + link.append( wgLqtMessages['lqt-quote'] ); |
| 154 | + quoteButton.append( link ); |
198 | 155 | |
199 | | - var link = document.createElement( 'a' ); |
200 | | - link.href='#'; |
201 | | - link.appendChild( textNode ); |
202 | | - quoteButton.appendChild( link ); |
| 156 | + quoteButton.click( liquidThreads.doQuote ); |
203 | 157 | |
204 | | - addHandler( quoteButton, 'click', liquidThreads.doQuote ); |
205 | | - |
206 | | - elems[i].insertBefore( quoteButton, elems[i].firstChild ); |
207 | | - elems[i].insertBefore( document.createTextNode( '|' ), quoteButton.nextSibling ); |
208 | | - } |
| 158 | + this.prepend( '|' ); |
| 159 | + this.prepend( quoteButton ); |
| 160 | + } ); |
209 | 161 | } |
210 | 162 | } |
211 | 163 | |
212 | | -addOnloadHook( function() { |
| 164 | +js2AddOnloadHook( function() { |
213 | 165 | // Find all the reply links |
214 | | - var threadContainers = getElementsByClassName( document, 'div', 'lqt_thread' ); |
| 166 | + var threadContainers = $j('div.lqt_thread'); |
215 | 167 | var prefixLength = "lqt_thread_id_".length; |
216 | 168 | |
217 | | - for( var i = 0; i < threadContainers.length; ++i ) { |
218 | | - var container = threadContainers[i]; |
219 | | - var replyLI = getElementsByClassName( container, '*', 'lqt-command-reply' )[0]; |
220 | | - var threadId = container.id.substring( prefixLength ); |
| 169 | + threadContainers.each( function(i) { |
| 170 | + var replyLI = $j(this).find( '.lqt-command-reply' ); |
| 171 | + var threadId = this.id.substring( prefixLength ); |
221 | 172 | |
222 | 173 | if (!replyLI) { |
223 | | - continue; |
| 174 | + return; |
224 | 175 | } |
225 | 176 | |
226 | | - replyLI.id = "lqt-reply-id-"+threadId; |
227 | | - var replyLink = replyLI.firstChild; |
| 177 | + replyLI[0].id = "lqt-reply-id-"+threadId; |
| 178 | + var replyLink = replyLI.find('a'); |
228 | 179 | |
229 | | - addHandler( replyLink, 'click', liquidThreads.handleReplyLink ); |
230 | | - } |
| 180 | + replyLink.click( liquidThreads.handleReplyLink ); |
| 181 | + } ); |
231 | 182 | |
232 | 183 | // Update the new thread link |
233 | | - var newThreadLink = getElementsByClassName( document, 'a', 'lqt_start_discussion' )[0]; |
| 184 | + var newThreadLink = $j('a.lqt_start_discussion'); |
234 | 185 | |
235 | 186 | if (newThreadLink) { |
236 | | - addHandler( newThreadLink, 'click', liquidThreads.handleNewLink ); |
| 187 | + newThreadLink.click( liquidThreads.handleNewLink ); |
237 | 188 | } |
238 | 189 | |
239 | 190 | // Show quote buttons |
Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -851,6 +851,11 @@ |
852 | 852 | $this->output->addHTML( $html ); |
853 | 853 | $this->showReplyForm( $thread ); |
854 | 854 | $html = $this->unindent( $thread ); |
| 855 | + } else { |
| 856 | + $html .= Xml::tags( 'div', |
| 857 | + array( 'class' => 'lqt-reply-form lqt-edit-form', |
| 858 | + 'style' => 'display: none;' ), |
| 859 | + '' ); |
855 | 860 | } |
856 | 861 | |
857 | 862 | $this->output->addHTML( $html ); |