r57425 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57424‎ | r57425 | r57426 >
Date:14:22, 6 October 2009
Author:catrope
Status:ok (Comments)
Tags:
Comment:
* EditToolbar: (bug 21015) Make table and link dialogs also work nicely with the Enter key in Opera
* (bug 21016) In the S&R dialog, remember what the last clicked button was and trigger that one on Enter instead of always triggering Find Next
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -1067,6 +1067,7 @@
10681068 $j(this)
10691069 .find( 'button:first' )
10701070 .click();
 1071+ e.preventDefault();
10711072 }
10721073 });
10731074 }
@@ -1093,15 +1094,6 @@
10941095 $j(this).find( '[rel]' ).each( function() {
10951096 $j(this).text( gM( $j(this).attr( 'rel' ) ) );
10961097 });
1097 - // Execute the action associated with the first button
1098 - // when the user presses Enter
1099 - $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
1100 - if ( ( e.keyCode || e.which ) == 13 ) {
1101 - $j(this)
1102 - .find( 'button:first' )
1103 - .click();
1104 - }
1105 - });
11061098 $j( '#edittoolbar-table-dimensions-rows' ).val( 2 );
11071099 $j( '#edittoolbar-table-dimensions-columns' ).val( 2 );
11081100 },
@@ -1171,6 +1163,7 @@
11721164 $j(this)
11731165 .find( 'button:first' )
11741166 .click();
 1167+ e.preventDefault();
11751168 }
11761169 });
11771170 }
@@ -1203,15 +1196,6 @@
12041197 $j(this).find( '[rel]' ).each( function() {
12051198 $j(this).text( gM( $j(this).attr( 'rel' ) ) );
12061199 });
1207 - // Execute the action associated with the first button
1208 - // when the user presses Enter
1209 - $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
1210 - if ( ( e.keyCode || e.which ) == 13 ) {
1211 - $j(this)
1212 - .find( 'button:first' )
1213 - .click();
1214 - }
1215 - });
12161200
12171201 // TODO: Find a cleaner way to share this function
12181202 $j(this).data( 'replaceCallback', function( mode ) {
@@ -1286,13 +1270,16 @@
12871271 },
12881272 dialog: {
12891273 buttons: {
1290 - 'edittoolbar-tool-replace-button-findnext': function() {
 1274+ 'edittoolbar-tool-replace-button-findnext': function( e ) {
 1275+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', e.target );
12911276 $j(this).data( 'replaceCallback' ).call( this, 'find' );
12921277 },
1293 - 'edittoolbar-tool-replace-button-replacenext': function() {
 1278+ 'edittoolbar-tool-replace-button-replacenext': function( e ) {
 1279+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', e.target );
12941280 $j(this).data( 'replaceCallback' ).call( this, 'replace' );
12951281 },
1296 - 'edittoolbar-tool-replace-button-replaceall': function() {
 1282+ 'edittoolbar-tool-replace-button-replaceall': function( e ) {
 1283+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', e.target );
12971284 $j(this).data( 'replaceCallback' ).call( this, 'replaceAll' );
12981285 },
12991286 'edittoolbar-tool-replace-close': function() {
@@ -1300,6 +1287,7 @@
13011288 $j(this).data( 'context' ).$textarea
13021289 .unbind( 'keypress.srdialog' )
13031290 .focus();
 1291+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', false );
13041292 }
13051293 },
13061294 open: function() {
@@ -1312,7 +1300,8 @@
13131301 // when the user presses Enter
13141302 $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
13151303 if ( ( e.keyCode || e.which ) == 13 ) {
1316 - $j(this).find( 'button:first' ).click();
 1304+ var button = $j(this).data( 'dialogaction' ) || $j(this).find( 'button:first' );
 1305+ button.click();
13171306 e.preventDefault();
13181307 }
13191308 });
@@ -1320,7 +1309,8 @@
13211310 var dialog = $j(this).closest( '.ui-dialog' );
13221311 $j(this).data( 'context' ).$textarea.bind( 'keypress.srdialog', function( e ) {
13231312 if ( ( e.keyCode || e.which ) == 13 ) {
1324 - dialog.find( 'button:first' ).click();
 1313+ var button = dialog.data( 'dialogaction' ) || dialog.find( 'button:first' );
 1314+ button.click();
13251315 e.preventDefault();
13261316 }
13271317 });
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 = 52;
 23+$wgEditToolbarStyleVersion = 53;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r58427EditToolbar: (bug 21016) Tabbing to a button and pressing Enter doesn't work ...catrope13:26, 2 November 2009
r58993usability: Merge r57425 from trunk to acaifixcatrope00:26, 13 November 2009
r61474UsabilityInitiative: (bug 21016) Fix behavior of Enter key in search&replace ...catrope20:23, 24 January 2010

Comments

#Comment by Shuhari (talk | contribs)   18:55, 18 November 2009

This revision was reviewed by Werdna at 6:44pm UTC on November 18th before production deployment.

Status & tagging log