Index: trunk/extensions/LiquidThreads/lqt.js |
— | — | @@ -188,6 +188,16 @@ |
189 | 189 | |
190 | 190 | }, |
191 | 191 | |
| 192 | + 'doLivePreview' : function( e ) { |
| 193 | + e.preventDefault(); |
| 194 | + if ( typeof doLivePreview == 'function' ) { |
| 195 | + doLivePreview(e); |
| 196 | + } else { |
| 197 | + $j.getScript( stylepath+'/common/preview.js', |
| 198 | + function() { doLivePreview(e); }); |
| 199 | + } |
| 200 | + }, |
| 201 | + |
192 | 202 | //From http://clipmarks.com/clipmark/CEFC94CB-94D6-4495-A7AA-791B7355E284/ |
193 | 203 | 'insertAtCursor' : function(myField, myValue) { |
194 | 204 | //IE support |
— | — | @@ -208,30 +218,6 @@ |
209 | 219 | } |
210 | 220 | }, |
211 | 221 | |
212 | | - 'transformQuote' : function(quote) { |
213 | | - quote = quote.trim(); |
214 | | - var lines = quote.split("\n"); |
215 | | - var newQuote = ''; |
216 | | - |
217 | | - for( var i = 0; i<lines.length; ++i ) { |
218 | | - if (lines[i].length) { |
219 | | - newQuote += liquidThreads.quoteLine(lines[i])+"\n"; |
220 | | - } |
221 | | - } |
222 | | - |
223 | | - return newQuote; |
224 | | - }, |
225 | | - |
226 | | - 'quoteLine' : function(line) { |
227 | | - var versionParts = wgVersion.split('.'); |
228 | | - |
229 | | - if (versionParts[0] <= 1 && versionParts[1] < 16) { |
230 | | - return '<blockquote>'+line+'</blockquote>'; |
231 | | - } |
232 | | - |
233 | | - return '> '+line; |
234 | | - }, |
235 | | - |
236 | 222 | 'getSelection' : function() { |
237 | 223 | if (window.getSelection) { |
238 | 224 | return window.getSelection().toString(); |
— | — | @@ -244,40 +230,6 @@ |
245 | 231 | } |
246 | 232 | }, |
247 | 233 | |
248 | | - 'doQuote' : function(e) { |
249 | | - if (e.preventDefault) |
250 | | - e.preventDefault(); |
251 | | - |
252 | | - // Get the post node |
253 | | - // Keep walking up until we hit the thread node. |
254 | | - var thread = $j(this).closest('.lqt_thread'); |
255 | | - var post = $j(thread.find('.lqt_post')[0]); |
256 | | - |
257 | | - var text = liquidThreads.getSelection(); |
258 | | - |
259 | | - if (text.length == 0) { |
260 | | - // Quote the whole post |
261 | | - text = post.text(); |
262 | | - } |
263 | | - |
264 | | - text = liquidThreads.transformQuote( text ); |
265 | | - // TODO auto-generate context info and link. |
266 | | - |
267 | | - var textbox = document.getElementById( 'wpTextbox1' ); |
268 | | - if (textbox) { |
269 | | - liquidThreads.insertAtCursor( textbox, text ); |
270 | | - textbox.focus(); |
271 | | - } else { |
272 | | - // Open the reply window |
273 | | - var replyLI = thread.find('.lqt-command-reply')[0]; |
274 | | - var replyLink = $j(replyLI).find('a')[0]; |
275 | | - |
276 | | - liquidThreads.handleReplyLink( { 'target':replyLink, 'preload':text } ); |
277 | | - } |
278 | | - |
279 | | - return false; |
280 | | - }, |
281 | | - |
282 | 234 | 'cancelEdit' : function( e ) { |
283 | 235 | if ( typeof e != 'undefined' && typeof e.preventDefault == 'function' ) { |
284 | 236 | e.preventDefault(); |
— | — | @@ -1618,6 +1570,7 @@ |
1619 | 1571 | // Save handlers |
1620 | 1572 | $j('#wpSave').live( 'click', liquidThreads.handleAJAXSave ); |
1621 | 1573 | $j('#wpTextbox1').live( 'keyup', liquidThreads.onTextboxKeyUp ); |
| 1574 | + $j('#wpPreview').live('click', liquidThreads.doLivePreview ); |
1622 | 1575 | |
1623 | 1576 | // Hide menus when a click happens outside them |
1624 | 1577 | $j(document).click( liquidThreads.handleDocumentClick ); |