r63512 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63511‎ | r63512 | r63513 >
Date:21:44, 9 March 2010
Author:pdhanda
Status:ok
Tags:
Comment:
Response to r63455. wrap with <p> only for content that is changed. Also fixed cursor position on paste.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -379,18 +379,17 @@
380380 if ( context.oldDelayedHTML != newHTML ) {
381381 context.oldDelayedHTML = newHTML;
382382 event.data.scope = 'realchange';
383 - }
384 -
385 - //surround by <p> if it does not already have it
386 - var t = context.fn.getOffset();
387 - if ( t.node.parentNode.nodeName.toLowerCase() == 'body' ) {
 383+
 384+ //surround by <p> if it does not already have it
388385 var cursorPos = context.fn.getCaretPosition();
389 - $( t.node ).wrap( "<p></p>" );
390 - context.fn.purgeOffsets();
391 - context.fn.setSelection( { start: cursorPos[0], end: cursorPos[1] } );
392 - }
393 -
394 -
 386+ var t = context.fn.getOffset(cursorPos[0]);
 387+ if ( t.node.parentNode.nodeName.toLowerCase() == 'body' ) {
 388+ $( t.node ).wrap( "<p></p>" );
 389+ context.fn.purgeOffsets();
 390+ context.fn.setSelection( { start: cursorPos[0], end: cursorPos[1] } );
 391+ }
 392+ }
 393+
395394 context.fn.updateHistory( event.data.scope == 'realchange' );
396395 return true;
397396 },
@@ -489,7 +488,7 @@
490489
491490 // Restore cursor position
492491 context.fn.purgeOffsets();
493 - var restoreTo = cursorPos[0] + context.fn.getContents().length - oldLength;
 492+ var restoreTo = cursorPos[1] + context.fn.getContents().length - oldLength;
494493 context.fn.setSelection( { start: restoreTo, end: restoreTo } );
495494 }, 0 );
496495 return true;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r63455This should fix the some toc highlighting issues. Also bug 22642pdhanda03:26, 9 March 2010

Status & tagging log