Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | private static $messages = array(); |
15 | 15 | private static $styles = array(); |
16 | 16 | private static $scripts = array( |
17 | | - array( 'src' => 'Resources/jquery.combined.js', 'version' => 1 ), |
| 17 | + array( 'src' => 'Resources/jquery.combined.js', 'version' => 2 ), |
18 | 18 | ); |
19 | 19 | private static $doOutput = false; |
20 | 20 | |
Index: trunk/extensions/UsabilityInitiative/Resources/jquery.scrolltextarea.js |
— | — | @@ -150,22 +150,37 @@ |
151 | 151 | } |
152 | 152 | |
153 | 153 | return this.each(function() { |
154 | | - // Put the cursor at the desired position |
155 | | - this.focus(); |
| 154 | + $(this).focus(); |
156 | 155 | if ( this.selectionStart || this.selectionStart == '0' ) { // Mozilla |
157 | 156 | this.selectionStart = this.selectionEnd = pos; |
| 157 | + $(this).scrollTop( getCaretPosition( this ) ); |
158 | 158 | } 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 | + } |
160 | 173 | range.moveToElementText( this ); |
161 | 174 | range.collapse(); |
162 | | - //range.moveStart( 'character', pos ); |
163 | 175 | range.move( 'character', pos ); |
164 | | - //alert(range.text); |
165 | 176 | range.select(); |
| 177 | + this.scrollTop += range.offsetTop; |
| 178 | + if ( goBack ) { |
| 179 | + range.move( 'character', -1 ); |
| 180 | + range.select(); |
| 181 | + } |
166 | 182 | } |
167 | | - $(this).scrollTop( getCaretPosition( this ) ); |
168 | 183 | $(this).trigger( 'scrollToPosition' ); |
169 | 184 | }); |
170 | 185 | } |
171 | | - }); |
| 186 | + }); |
172 | 187 | })(jQuery); |
Index: trunk/extensions/UsabilityInitiative/Resources/jquery.combined.js |
— | — | @@ -4783,24 +4783,39 @@ |
4784 | 4784 | } |
4785 | 4785 | |
4786 | 4786 | return this.each(function() { |
4787 | | - // Put the cursor at the desired position |
4788 | | - this.focus(); |
| 4787 | + $(this).focus(); |
4789 | 4788 | if ( this.selectionStart || this.selectionStart == '0' ) { // Mozilla |
4790 | 4789 | this.selectionStart = this.selectionEnd = pos; |
| 4790 | + $(this).scrollTop( getCaretPosition( this ) ); |
4791 | 4791 | } 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 | + } |
4793 | 4806 | range.moveToElementText( this ); |
4794 | 4807 | range.collapse(); |
4795 | | - //range.moveStart( 'character', pos ); |
4796 | 4808 | range.move( 'character', pos ); |
4797 | | - //alert(range.text); |
4798 | 4809 | range.select(); |
| 4810 | + this.scrollTop += range.offsetTop; |
| 4811 | + if ( goBack ) { |
| 4812 | + range.move( 'character', -1 ); |
| 4813 | + range.select(); |
| 4814 | + } |
4799 | 4815 | } |
4800 | | - $(this).scrollTop( getCaretPosition( this ) ); |
4801 | 4816 | $(this).trigger( 'scrollToPosition' ); |
4802 | 4817 | }); |
4803 | 4818 | } |
4804 | | - }); |
| 4819 | + }); |
4805 | 4820 | })(jQuery); |
4806 | 4821 | /* |
4807 | 4822 | * Ported from skins/common/edit.js by Trevor Parscal |
Index: trunk/extensions/UsabilityInitiative/Resources/jquery.combined.min.js |
— | — | @@ -461,8 +461,9 @@ |
462 | 462 | var nextSpace=0;for(j=caret;j<caret+lineLength;j++){if(text.charAt(j)==" "||text.charAt(j)=="\n"||caret==text.length){nextSpace=j;break;}} |
463 | 463 | if(nextSpace>lineLength&&caret<=lineLength){charInLine=caret-lastSpaceInLine;row++;} |
464 | 464 | 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) |
467 | 468 | var winScroll=document.documentElement.scrollTop |
468 | 469 | else if(document.body) |
469 | 470 | 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) |