r53770 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53769‎ | r53770 | r53771 >
Date:22:37, 25 July 2009
Author:catrope
Status:deferred
Tags:
Comment:
NavigableTOC: Make textarea scrolling work more reliably in IE. This can be done because IE is kind enough to scroll the section to the bottom, so it's easy to scroll it to the top. Still gotta find something similar that works for other browsers.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/Resources/jquery.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Resources/jquery.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Resources/jquery.scrolltextarea.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -13,7 +13,7 @@
1414 private static $messages = array();
1515 private static $styles = array();
1616 private static $scripts = array(
17 - array( 'src' => 'Resources/jquery.combined.js', 'version' => 1 ),
 17+ array( 'src' => 'Resources/jquery.combined.js', 'version' => 2 ),
1818 );
1919 private static $doOutput = false;
2020
Index: trunk/extensions/UsabilityInitiative/Resources/jquery.scrolltextarea.js
@@ -150,22 +150,37 @@
151151 }
152152
153153 return this.each(function() {
154 - // Put the cursor at the desired position
155 - this.focus();
 154+ $(this).focus();
156155 if ( this.selectionStart || this.selectionStart == '0' ) { // Mozilla
157156 this.selectionStart = this.selectionEnd = pos;
 157+ $(this).scrollTop( getCaretPosition( this ) );
158158 } else if ( document.selection && document.selection.createRange ) { // IE/Opera
159 - var range = document.selection.createRange();
 159+ // IE automatically scrolls the section
 160+ // to the bottom of the page, except
 161+ // if it's already in view and the
 162+ // cursor position hasn't changed, in
 163+ // which case it does nothing. In that
 164+ // case we'll force it to act by moving
 165+ // one character back and forth
 166+ range = document.selection.createRange();
 167+ oldPos = $(this).bytePos();
 168+ goBack = false;
 169+ if ( oldPos == pos ) {
 170+ pos++;
 171+ goBack = true;
 172+ }
160173 range.moveToElementText( this );
161174 range.collapse();
162 - //range.moveStart( 'character', pos );
163175 range.move( 'character', pos );
164 - //alert(range.text);
165176 range.select();
 177+ this.scrollTop += range.offsetTop;
 178+ if ( goBack ) {
 179+ range.move( 'character', -1 );
 180+ range.select();
 181+ }
166182 }
167 - $(this).scrollTop( getCaretPosition( this ) );
168183 $(this).trigger( 'scrollToPosition' );
169184 });
170185 }
171 - });
 186+ });
172187 })(jQuery);
Index: trunk/extensions/UsabilityInitiative/Resources/jquery.combined.js
@@ -4783,24 +4783,39 @@
47844784 }
47854785
47864786 return this.each(function() {
4787 - // Put the cursor at the desired position
4788 - this.focus();
 4787+ $(this).focus();
47894788 if ( this.selectionStart || this.selectionStart == '0' ) { // Mozilla
47904789 this.selectionStart = this.selectionEnd = pos;
 4790+ $(this).scrollTop( getCaretPosition( this ) );
47914791 } else if ( document.selection && document.selection.createRange ) { // IE/Opera
4792 - var range = document.selection.createRange();
 4792+ // IE automatically scrolls the section
 4793+ // to the bottom of the page, except
 4794+ // if it's already in view and the
 4795+ // cursor position hasn't changed, in
 4796+ // which case it does nothing. In that
 4797+ // case we'll force it to act by moving
 4798+ // one character back and forth
 4799+ range = document.selection.createRange();
 4800+ oldPos = $(this).bytePos();
 4801+ goBack = false;
 4802+ if ( oldPos == pos ) {
 4803+ pos++;
 4804+ goBack = true;
 4805+ }
47934806 range.moveToElementText( this );
47944807 range.collapse();
4795 - //range.moveStart( 'character', pos );
47964808 range.move( 'character', pos );
4797 - //alert(range.text);
47984809 range.select();
 4810+ this.scrollTop += range.offsetTop;
 4811+ if ( goBack ) {
 4812+ range.move( 'character', -1 );
 4813+ range.select();
 4814+ }
47994815 }
4800 - $(this).scrollTop( getCaretPosition( this ) );
48014816 $(this).trigger( 'scrollToPosition' );
48024817 });
48034818 }
4804 - });
 4819+ });
48054820 })(jQuery);
48064821 /*
48074822 * Ported from skins/common/edit.js by Trevor Parscal
Index: trunk/extensions/UsabilityInitiative/Resources/jquery.combined.min.js
@@ -461,8 +461,9 @@
462462 var nextSpace=0;for(j=caret;j<caret+lineLength;j++){if(text.charAt(j)==" "||text.charAt(j)=="\n"||caret==text.length){nextSpace=j;break;}}
463463 if(nextSpace>lineLength&&caret<=lineLength){charInLine=caret-lastSpaceInLine;row++;}
464464 return($.os.name=='mac'?13:($.os.name=='linux'?15:16))*row;}
465 -return this.each(function(){this.focus();if(this.selectionStart||this.selectionStart=='0'){this.selectionStart=this.selectionEnd=pos;}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();range.moveToElementText(this);range.collapse();range.move('character',pos);range.select();}
466 -$(this).scrollTop(getCaretPosition(this));$(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.fn.extend({encapsulateSelection:function(pre,peri,post){var e=this.jquery?this[0]:this;var selText;var isSample=false;if(document.selection&&document.selection.createRange){if(document.documentElement&&document.documentElement.scrollTop)
 465+return this.each(function(){$(this).focus();if(this.selectionStart||this.selectionStart=='0'){this.selectionStart=this.selectionEnd=pos;$(this).scrollTop(getCaretPosition(this));}else if(document.selection&&document.selection.createRange){range=document.selection.createRange();oldPos=$(this).bytePos();goBack=false;if(oldPos==pos){pos++;goBack=true;}
 466+range.moveToElementText(this);range.collapse();range.move('character',pos);range.select();this.scrollTop+=range.offsetTop;if(goBack){range.move('character',-1);range.select();}}
 467+$(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.fn.extend({encapsulateSelection:function(pre,peri,post){var e=this.jquery?this[0]:this;var selText;var isSample=false;if(document.selection&&document.selection.createRange){if(document.documentElement&&document.documentElement.scrollTop)
467468 var winScroll=document.documentElement.scrollTop
468469 else if(document.body)
469470 var winScroll=document.body.scrollTop;e.focus();var range=document.selection.createRange();selText=range.text;checkSelectedText();range.text=pre+selText+post;if(isSample&&range.moveStart){if(window.opera)

Status & tagging log