r58427 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58426‎ | r58427 | r58428 >
Date:13:26, 2 November 2009
Author:catrope
Status:deferred
Tags:
Comment:
EditToolbar: (bug 21016) Tabbing to a button and pressing Enter doesn't work in replace dialog
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -1138,7 +1138,7 @@
11391139 $j(this).data( 'articlePathRegex', new RegExp(
11401140 '^' + RegExp.escape( wgServer + wgArticlePath )
11411141 .replace( /\\\$1/g, '(.*)' ) + '$'
1142 - ) );
 1142+ ) );
11431143 // Pre-fill the text fields based on the current selection
11441144 var selection = $j(this).data( 'context' ).$textarea.getSelection();
11451145 $j( '#edittoolbar-link-int-target' ).focus();
@@ -1516,8 +1516,8 @@
15171517 $j(this).data( 'offset', 0 );
15181518 $j( '#edittoolbar-replace-search' ).focus();
15191519 $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch, #edittoolbar-replace-invalidregex' ).hide();
1520 - if ( !( $j(this).data( 'dialogkeypressset' ) ) ) {
1521 - $j(this).data( 'dialogkeypressset', true );
 1520+ if ( !( $j(this).data( 'onetimeonlystuff' ) ) ) {
 1521+ $j(this).data( 'onetimeonlystuff', true );
15221522 // Execute the action associated with the first button
15231523 // when the user presses Enter
15241524 $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
@@ -1527,6 +1527,11 @@
15281528 e.preventDefault();
15291529 }
15301530 });
 1531+ // Make tabbing to a button and pressing
 1532+ // Enter do what people expect
 1533+ $j(this).closest( '.ui-dialog' ).find( 'button' ).focus( function() {
 1534+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', this );
 1535+ });
15311536 }
15321537 var dialog = $j(this).closest( '.ui-dialog' );
15331538 $j(this).data( 'context' ).$textarea.bind( 'keypress.srdialog', function( e ) {
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.min.js
@@ -151,5 +151,5 @@
152152 matches=text.match(regex);if(!matches)
153153 $j('#edittoolbar-replace-nomatch').show();else if(mode=='replaceAll'){var start=text.lastIndexOf(matches[matches.length-1]);var end=start+replaceStr.length;var replaced=text.replace(regex,replaceStr);var corr=replaced.length-text.length-replaceStr.length+matches[matches.length-1].length;$textarea.val(replaced).change().focus().setSelection(start+corr,end+corr).scrollToCaretPosition();$j('#edittoolbar-replace-success').text(gM('edittoolbar-tool-replace-success',matches.length)).show();$j(this).data('offset',0);}else{var start=text.indexOf(matches[0],$j(this).data('offset'));if(start==-1)
154154 start=text.indexOf(matches[0]);var end=start+matches[0].length;var newEnd=start+replaceStr.length;$textarea.focus().setSelection(start,end);if(mode=='replace'){$textarea.encapsulateSelection('',replaceStr,'',false,true).setSelection(start,newEnd);}
155 -$textarea.scrollToCaretPosition();$j(this).data('offset',mode=='replace'?newEnd:end);}});},dialog:{buttons:{'edittoolbar-tool-replace-button-findnext':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'find');},'edittoolbar-tool-replace-button-replacenext':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'replace');},'edittoolbar-tool-replace-button-replaceall':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'replaceAll');},'edittoolbar-tool-replace-close':function(){$j(this).dialog('close');}},open:function(){$j(this).data('offset',0);$j('#edittoolbar-replace-search').focus();$j('#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch, #edittoolbar-replace-invalidregex').hide();if(!($j(this).data('dialogkeypressset'))){$j(this).data('dialogkeypressset',true);$j(this).closest('.ui-dialog').keypress(function(e){if((e.keyCode||e.which)==13){var button=$j(this).data('dialogaction')||$j(this).find('button:first');button.click();e.preventDefault();}});}
 155+$textarea.scrollToCaretPosition();$j(this).data('offset',mode=='replace'?newEnd:end);}});},dialog:{buttons:{'edittoolbar-tool-replace-button-findnext':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'find');},'edittoolbar-tool-replace-button-replacenext':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'replace');},'edittoolbar-tool-replace-button-replaceall':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'replaceAll');},'edittoolbar-tool-replace-close':function(){$j(this).dialog('close');}},open:function(){$j(this).data('offset',0);$j('#edittoolbar-replace-search').focus();$j('#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch, #edittoolbar-replace-invalidregex').hide();if(!($j(this).data('onetimeonlystuff'))){$j(this).data('onetimeonlystuff',true);$j(this).closest('.ui-dialog').keypress(function(e){if((e.keyCode||e.which)==13){var button=$j(this).data('dialogaction')||$j(this).find('button:first');button.click();e.preventDefault();}});$j(this).closest('.ui-dialog').find('button').focus(function(){$j(this).closest('.ui-dialog').data('dialogaction',this);});}
156156 var dialog=$j(this).closest('.ui-dialog');$j(this).data('context').$textarea.bind('keypress.srdialog',function(e){if((e.keyCode||e.which)==13){var button=dialog.data('dialogaction')||dialog.find('button:first');button.click();e.preventDefault();}});},close:function(){$j(this).data('context').$textarea.unbind('keypress.srdialog').focus();$j(this).closest('.ui-dialog').data('dialogaction',false);}}}}});}});
\ No newline at end of file
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 = 70;
 23+$wgEditToolbarStyleVersion = 71;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r59204wmf-deployment: Merging usability changes from trunk...catrope18:53, 18 November 2009
r61474UsabilityInitiative: (bug 21016) Fix behavior of Enter key in search&replace ...catrope20:23, 24 January 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r57425* EditToolbar: (bug 21015) Make table and link dialogs also work nicely with ...catrope14:22, 6 October 2009

Status & tagging log