r66334 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66333‎ | r66334 | r66335 >
Date:11:24, 13 May 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: (bug 23501) IE inserts bold markers in the wrong place when the selection is preceded by more than one newline. Stupidest cause ever.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -71,7 +71,7 @@
7272 array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 4 ),
7373 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 14 ),
75 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 32 ),
 75+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 33 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 187 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 62 ),
@@ -83,10 +83,10 @@
8484 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ),
8585 ),
8686 'combined' => array(
87 - array( 'src' => 'js/plugins.combined.js', 'version' => 395 ),
 87+ array( 'src' => 'js/plugins.combined.js', 'version' => 396 ),
8888 ),
8989 'minified' => array(
90 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 395 ),
 90+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 396 ),
9191 ),
9292 ),
9393 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
@@ -138,7 +138,7 @@
139139 var caretPos = 0, endPos = 0;
140140 if ( $.browser.msie ) {
141141 // IE Support
142 - var postFinished = false;
 142+ var preFinished = false;
143143 var periFinished = false;
144144 var postFinished = false;
145145 var preText, rawPreText, periText;
@@ -167,15 +167,15 @@
168168 * not changed then we know that IE has trimmed a \r\n from the end.
169169 */
170170 do {
171 - if ( !postFinished ) {
 171+ if ( !preFinished ) {
172172 if ( preRange.compareEndPoints( "StartToEnd", preRange ) == 0 ) {
173 - postFinished = true;
 173+ preFinished = true;
174174 } else {
175175 preRange.moveEnd( "character", -1 )
176176 if ( preRange.text == preText ) {
177177 rawPreText += "\r\n";
178178 } else {
179 - postFinished = true;
 179+ preFinished = true;
180180 }
181181 }
182182 }
@@ -203,7 +203,7 @@
204204 }
205205 }
206206 }
207 - } while ( ( !postFinished || !periFinished || !postFinished ) );
 207+ } while ( ( !preFinished || !periFinished || !postFinished ) );
208208 caretPos = rawPreText.replace( /\r\n/g, "\n" ).length;
209209 endPos = caretPos + rawPeriText.replace( /\r\n/g, "\n" ).length;
210210 } else if ( e.selectionStart || e.selectionStart == '0' ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6342,7 +6342,7 @@
63436343 var caretPos = 0, endPos = 0;
63446344 if ( $.browser.msie ) {
63456345 // IE Support
6346 - var postFinished = false;
 6346+ var preFinished = false;
63476347 var periFinished = false;
63486348 var postFinished = false;
63496349 var preText, rawPreText, periText;
@@ -6371,15 +6371,15 @@
63726372 * not changed then we know that IE has trimmed a \r\n from the end.
63736373 */
63746374 do {
6375 - if ( !postFinished ) {
 6375+ if ( !preFinished ) {
63766376 if ( preRange.compareEndPoints( "StartToEnd", preRange ) == 0 ) {
6377 - postFinished = true;
 6377+ preFinished = true;
63786378 } else {
63796379 preRange.moveEnd( "character", -1 )
63806380 if ( preRange.text == preText ) {
63816381 rawPreText += "\r\n";
63826382 } else {
6383 - postFinished = true;
 6383+ preFinished = true;
63846384 }
63856385 }
63866386 }
@@ -6407,7 +6407,7 @@
64086408 }
64096409 }
64106410 }
6411 - } while ( ( !postFinished || !periFinished || !postFinished ) );
 6411+ } while ( ( !preFinished || !periFinished || !postFinished ) );
64126412 caretPos = rawPreText.replace( /\r\n/g, "\n" ).length;
64136413 endPos = caretPos + rawPeriText.replace( /\r\n/g, "\n" ).length;
64146414 } else if ( e.selectionStart || e.selectionStart == '0' ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -422,12 +422,12 @@
423423 var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){options.post+="\n";}}
424424 checkSelectedText();range.text=options.pre+selText+options.post;if(isSample&&range.moveStart){range.moveStart('character',-options.post.length-selText.length);range.moveEnd('character',-options.post.length);}
425425 range.select();this.scrollTop=scrollTop;}
426 -$(this).trigger('encapsulateSelection',[options.pre,options.peri,options.post,options.ownline,options.replace]);});},getCaretPosition:function(options){function getCaret(e){var caretPos=0,endPos=0;if($.browser.msie){var postFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!postFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){postFinished=true;}else{preRange.moveEnd("character",-1)
427 -if(preRange.text==preText){rawPreText+="\r\n";}else{postFinished=true;}}}
 426+$(this).trigger('encapsulateSelection',[options.pre,options.peri,options.post,options.ownline,options.replace]);});},getCaretPosition:function(options){function getCaret(e){var caretPos=0,endPos=0;if($.browser.msie){var preFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!preFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){preFinished=true;}else{preRange.moveEnd("character",-1)
 427+if(preRange.text==preText){rawPreText+="\r\n";}else{preFinished=true;}}}
428428 if(!periFinished){if(periRange.compareEndPoints("StartToEnd",periRange)==0){periFinished=true;}else{periRange.moveEnd("character",-1)
429429 if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}}
430430 if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1)
431 -if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));caretPos=rawPreText.replace(/\r\n/g,"\n").length;endPos=caretPos+rawPeriText.replace(/\r\n/g,"\n").length;}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;endPos=e.selectionEnd;}
 431+if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!preFinished||!periFinished||!postFinished));caretPos=rawPreText.replace(/\r\n/g,"\n").length;endPos=caretPos+rawPeriText.replace(/\r\n/g,"\n").length;}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;endPos=e.selectionEnd;}
432432 return options.startAndEnd?[caretPos,endPos]:caretPos;}
433433 return getCaret(this.get(0));},setSelection:function(options){return this.each(function(){if($(this).is(':hidden')){}else if(this.selectionStart||this.selectionStart=='0'){if(options.start>this.selectionEnd){this.selectionEnd=options.end;this.selectionStart=options.start;}else{this.selectionStart=options.start;this.selectionEnd=options.end;}}else if(document.body.createTextRange){var selection=document.body.createTextRange();selection.moveToElementText(this);var length=this.value.length;var newLines=this.value.match(/\n/g);if(newLines)length=length-newLines.length;selection.moveStart('character',options.start);selection.moveEnd('character',-length+options.end);selection.select();}});},scrollToCaretPosition:function(options){function getLineLength(e){return Math.floor(e.scrollWidth/($.os.name=='linux'?7:8));}
434434 function getCaretScrollPosition(e){var text=e.value.replace(/\r/g,"");var caret=$(e).textSelection('getCaretPosition');var lineLength=getLineLength(e);var row=0;var charInLine=0;var lastSpaceInLine=0;for(i=0;i<caret;i++){charInLine++;if(text.charAt(i)==" "){lastSpaceInLine=charInLine;}else if(text.charAt(i)=="\n"){lastSpaceInLine=0;charInLine=0;row++;}

Status & tagging log