r64439 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64438‎ | r64439 | r64440 >
Date:15:15, 31 March 2010
Author:adam
Status:ok
Tags:
Comment:
Altering scrollToPosition() in the textSelection plugin so that it doesn't clear the current selection in IE
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' => 9 ),
75 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 28 ),
 75+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 29 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 179 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 52 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 54 ),
@@ -82,10 +82,10 @@
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 370 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 371 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 370 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 371 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
@@ -312,7 +312,9 @@
313313 * cover that case, we'll force it to act by moving one
314314 * character back and forth.
315315 */
316 - var range = document.selection.createRange();
 316+ var range = document.body.createTextRange();
 317+ // store the current selection so we can reselect it later
 318+ var savedRange = document.selection.createRange();
317319 var pos = $(this).textSelection( 'getCaretPosition' );
318320 var oldScrollTop = this.scrollTop;
319321 range.moveToElementText( this );
@@ -326,6 +328,7 @@
327329 range.select();
328330 }
329331 }
 332+ savedRange.select();
330333 $(this).trigger( 'scrollToPosition' );
331334 } );
332335 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6479,7 +6479,9 @@
64806480 * cover that case, we'll force it to act by moving one
64816481 * character back and forth.
64826482 */
6483 - var range = document.selection.createRange();
 6483+ var range = document.body.createTextRange();
 6484+ // store the current selection so we can reselect it later
 6485+ var savedRange = document.selection.createRange();
64846486 var pos = $(this).textSelection( 'getCaretPosition' );
64856487 var oldScrollTop = this.scrollTop;
64866488 range.moveToElementText( this );
@@ -6493,6 +6495,7 @@
64946496 range.select();
64956497 }
64966498 }
 6499+ savedRange.select();
64976500 $(this).trigger( 'scrollToPosition' );
64986501 } );
64996502 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -437,9 +437,9 @@
438438 if(nextSpace>lineLength&&caret<=lineLength){charInLine=caret-lastSpaceInLine;row++;}
439439 return($.os.name=='mac'?13:($.os.name=='linux'?15:16))*row;}
440440 return this.each(function(){if($(this).is(':hidden')){}else if(this.selectionStart||this.selectionStart=='0'){var scroll=getCaretScrollPosition(this);if(options.force||scroll<$(this).scrollTop()||scroll>$(this).scrollTop()+$(this).height())
441 -$(this).scrollTop(scroll);}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var pos=$(this).textSelection('getCaretPosition');var oldScrollTop=this.scrollTop;range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();if(this.scrollTop!=oldScrollTop)
 441+$(this).scrollTop(scroll);}else if(document.selection&&document.selection.createRange){var range=document.body.createTextRange();var savedRange=document.selection.createRange();var pos=$(this).textSelection('getCaretPosition');var oldScrollTop=this.scrollTop;range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();if(this.scrollTop!=oldScrollTop)
442442 this.scrollTop+=range.offsetTop;else if(options.force){range.move('character',-1);range.select();}}
443 -$(this).trigger('scrollToPosition');});}};switch(command){case'encapsulateSelection':options=$.extend({'pre':'','peri':'','post':'','ownline':false,'replace':false},options);break;case'getCaretPosition':options=$.extend({'startAndEnd':false},options);break;case'setSelection':options=$.extend({'start':undefined,'end':undefined,'startContainer':undefined,'endContainer':undefined},options);if(options.end===undefined)
 443+savedRange.select();$(this).trigger('scrollToPosition');});}};switch(command){case'encapsulateSelection':options=$.extend({'pre':'','peri':'','post':'','ownline':false,'replace':false},options);break;case'getCaretPosition':options=$.extend({'startAndEnd':false},options);break;case'setSelection':options=$.extend({'start':undefined,'end':undefined,'startContainer':undefined,'endContainer':undefined},options);if(options.end===undefined)
444444 options.end=options.start;if(options.endContainer==undefined)
445445 options.endContainer=options.startContainer;break;case'scrollToCaretPosition':options=$.extend({'force':false},options);break;}
446446 var context=$(this).data('wikiEditor-context');var hasIframe=context!==undefined&&context.$iframe!==undefined;var needSave=false;if(hasIframe&&context.savedSelection!==null){context.fn.restoreSelection();needSave=true;}

Follow-up revisions

RevisionCommit summaryAuthorDate
r64441Followup to r64439. Fixing a bug that was causing an error in anything that w...adam15:45, 31 March 2010

Status & tagging log