r62287 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62286‎ | r62287 | r62288 >
Date:02:33, 11 February 2010
Author:werdna
Status:deferred
Tags:
Comment:
LiquidThreads JS:
* Remove quoting functions.
* Re-introduce live preview, this time working reliably, lazy-initialised.
Modified paths:
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/lqt.js
@@ -188,6 +188,16 @@
189189
190190 },
191191
 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+
192202 //From http://clipmarks.com/clipmark/CEFC94CB-94D6-4495-A7AA-791B7355E284/
193203 'insertAtCursor' : function(myField, myValue) {
194204 //IE support
@@ -208,30 +218,6 @@
209219 }
210220 },
211221
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 -
236222 'getSelection' : function() {
237223 if (window.getSelection) {
238224 return window.getSelection().toString();
@@ -244,40 +230,6 @@
245231 }
246232 },
247233
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 -
282234 'cancelEdit' : function( e ) {
283235 if ( typeof e != 'undefined' && typeof e.preventDefault == 'function' ) {
284236 e.preventDefault();
@@ -1618,6 +1570,7 @@
16191571 // Save handlers
16201572 $j('#wpSave').live( 'click', liquidThreads.handleAJAXSave );
16211573 $j('#wpTextbox1').live( 'keyup', liquidThreads.onTextboxKeyUp );
 1574+ $j('#wpPreview').live('click', liquidThreads.doLivePreview );
16221575
16231576 // Hide menus when a click happens outside them
16241577 $j(document).click( liquidThreads.handleDocumentClick );

Status & tagging log