r57387 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57386‎ | r57387 | r57388 >
Date:15:24, 5 October 2009
Author:catrope
Status:ok
Tags:
Comment:
* EditToolbar: (bug 20994) Pressing Enter while a search result is selected replaces the search result with a newline in Opera
* Fix annoying selection bug caused by Opera's refusal (at least in 9.0, didn't test 9.6 or 10) to set selectionStart past the current selectionEnd; set them in the right order so this doesn't happen
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)
  • /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
@@ -63,7 +63,7 @@
6464 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
6565 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
6666 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 4 ),
67 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 14 ),
 67+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 15 ),
6868 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 9 ),
6969 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ),
7070 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 4 ),
@@ -73,10 +73,10 @@
7474 array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2y' ),
7575 ),
7676 'combined' => array(
77 - array( 'src' => 'js/plugins.combined.js', 'version' => 38 ),
 77+ array( 'src' => 'js/plugins.combined.js', 'version' => 39 ),
7878 ),
7979 'minified' => array(
80 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 38 ),
 80+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 39 ),
8181 ),
8282 ),
8383 );
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -1310,14 +1310,18 @@
13111311 // Execute the action associated with the first button
13121312 // when the user presses Enter
13131313 $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
1314 - if ( ( e.keyCode || e.which ) == 13 )
 1314+ if ( ( e.keyCode || e.which ) == 13 ) {
13151315 $j(this).find( 'button:first' ).click();
 1316+ e.preventDefault();
 1317+ }
13161318 });
13171319 }
13181320 var dialog = $j(this).closest( '.ui-dialog' );
13191321 $j(this).data( 'context' ).$textarea.bind( 'keypress.srdialog', function( e ) {
1320 - if ( ( e.keyCode || e.which ) == 13 )
 1322+ if ( ( e.keyCode || e.which ) == 13 ) {
13211323 dialog.find( 'button:first' ).click();
 1324+ e.preventDefault();
 1325+ }
13221326 });
13231327 }
13241328 }
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php
@@ -19,7 +19,7 @@
2020 /* Configuration */
2121
2222 // Bump the version number every time you change any of the .css/.js files
23 -$wgEditToolbarStyleVersion = 49;
 23+$wgEditToolbarStyleVersion = 50;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
@@ -203,8 +203,16 @@
204204 end = start;
205205 return this.each( function() {
206206 if ( this.selectionStart || this.selectionStart == '0' ) {
207 - this.selectionStart = start;
208 - this.selectionEnd = end;
 207+ // Opera 9.0 doesn't allow setting selectionStart past
 208+ // selectionEnd; any attempts to do that will be ignored
 209+ // Make sure to set them in the right order
 210+ if ( start > this.selectionEnd ) {
 211+ this.selectionEnd = end;
 212+ this.selectionStart = start;
 213+ } else {
 214+ this.selectionStart = start;
 215+ this.selectionEnd = end;
 216+ }
209217 } else if ( document.body.createTextRange ) {
210218 var selection = document.body.createTextRange();
211219 selection.moveToElementText( this );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -1027,8 +1027,16 @@
10281028 end = start;
10291029 return this.each( function() {
10301030 if ( this.selectionStart || this.selectionStart == '0' ) {
1031 - this.selectionStart = start;
1032 - this.selectionEnd = end;
 1031+ // Opera 9.0 doesn't allow setting selectionStart past
 1032+ // selectionEnd; any attempts to do that will be ignored
 1033+ // Make sure to set them in the right order
 1034+ if ( start > this.selectionEnd ) {
 1035+ this.selectionEnd = end;
 1036+ this.selectionStart = start;
 1037+ } else {
 1038+ this.selectionStart = start;
 1039+ this.selectionEnd = end;
 1040+ }
10331041 } else if ( document.body.createTextRange ) {
10341042 var selection = document.body.createTextRange();
10351043 selection.moveToElementText( this );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -69,7 +69,7 @@
7070 if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));caretPos=rawPreText.replace(/\r\n/g,"\n").length;}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;}
7171 return caretPos;}
7272 return getCaret(this.get(0));},setSelection:function(start,end){if(typeof end=='undefined')
73 -end=start;return this.each(function(){if(this.selectionStart||this.selectionStart=='0'){this.selectionStart=start;this.selectionEnd=end;}else if(document.body.createTextRange){var selection=document.body.createTextRange();selection.moveToElementText(this);var length=selection.text.length;selection.moveStart('character',start);selection.moveEnd('character',-length+end);selection.select();}});},scrollToCaretPosition:function(force){function getLineLength(e){return Math.floor(e.scrollWidth/($.os.name=='linux'?7:8));}
 73+end=start;return this.each(function(){if(this.selectionStart||this.selectionStart=='0'){if(start>this.selectionEnd){this.selectionEnd=end;this.selectionStart=start;}else{this.selectionStart=start;this.selectionEnd=end;}}else if(document.body.createTextRange){var selection=document.body.createTextRange();selection.moveToElementText(this);var length=selection.text.length;selection.moveStart('character',start);selection.moveEnd('character',-length+end);selection.select();}});},scrollToCaretPosition:function(force){function getLineLength(e){return Math.floor(e.scrollWidth/($.os.name=='linux'?7:8));}
7474 function getCaretScrollPosition(e){var text=e.value.replace(/\r/g,"");var caret=$(e).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++;}
7575 if(charInLine>lineLength){if(lastSpaceInLine>0){charInLine=charInLine-lastSpaceInLine;lastSpaceInLine=0;row++;}}}
7676 var nextSpace=0;for(j=caret;j<caret+lineLength;j++){if(text.charAt(j)==" "||text.charAt(j)=="\n"||caret==text.length){nextSpace=j;break;}}

Follow-up revisions

RevisionCommit summaryAuthorDate
r57719wmf-deployment: Merge babaco fixes from trunk...catrope20:20, 14 October 2009

Status & tagging log