r61474 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61473‎ | r61474 | r61475 >
Date:20:23, 24 January 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: (bug 21016) Fix behavior of Enter key in search&replace dialog, make Esc work
Modified paths:
  • /trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js
@@ -1921,18 +1921,24 @@
19221922 });
19231923 }
19241924 var dialog = $j(this).closest( '.ui-dialog' );
1925 - $j(this).data( 'context' ).$textarea.bind( 'keypress.srdialog', function( e ) {
1926 - if ( ( e.keyCode || e.which ) == 13 ) {
1927 - var button = dialog.data( 'dialogaction' ) || dialog.find( 'button:first' );
1928 - button.click();
1929 - e.preventDefault();
1930 - }
1931 - });
 1925+ var that = this;
 1926+ $j( $j(this).data( 'context' ).$iframe[0].contentWindow.document )
 1927+ .bind( 'keypress.srdialog', function( e ) {
 1928+ if ( ( e.keyCode || e.which ) == 13 ) {
 1929+ // Enter
 1930+ var button = dialog.data( 'dialogaction' ) || dialog.find( 'button:first' );
 1931+ button.click();
 1932+ e.preventDefault();
 1933+ } else if ( ( e.keyCode || e.which ) == 27 ) {
 1934+ // Escape
 1935+ $j(that).dialog( 'close' );
 1936+ }
 1937+ });
19321938 },
19331939 close: function() {
1934 - $j(this).data( 'context' ).$textarea
1935 - .unbind( 'keypress.srdialog' )
1936 - .focus();
 1940+ $j( $j(this).data( 'context' ).$iframe[0].contentWindow.document )
 1941+ .unbind( 'keypress.srdialog' );
 1942+ $j(this).data( 'context' ).$iframe[0].contentWindow.focus();
19371943 $j(this).closest( '.ui-dialog' ).data( 'dialogaction', false );
19381944 }
19391945 }
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js
@@ -169,5 +169,5 @@
170170 s=s.substr(index+match[i].length);var start=index+offset;var end=start+match[i].length;var newEnd=start+replaceStr.length;$textarea.textSelection('setSelection',{'start':start,'end':end}).textSelection('encapsulateSelection',{'peri':replaceStr,'replace':true}).textSelection('setSelection',{'start':start,'end':newEnd});offset=newEnd;}
171171 $j('#wikieditor-toolbar-replace-success').text(gM('wikieditor-toolbar-tool-replace-success',match.length)).show();$j(this).data('offset',0);}else{var start=match.index+offset;var end=start+match[0].length;var newEnd=start+replaceStr.length;$textarea.textSelection('setSelection',{'start':start,'end':end});if(mode=='replace'){$textarea.textSelection('encapsulateSelection',{'peri':replaceStr,'replace':true}).textSelection('setSelection',{'start':start,'end':newEnd});}
172172 $textarea.textSelection('scrollToCaretPosition');$j(this).data('offset',mode=='replace'?newEnd:end);}});},dialog:{width:500,buttons:{'wikieditor-toolbar-tool-replace-button-findnext':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'find');},'wikieditor-toolbar-tool-replace-button-replacenext':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'replace');},'wikieditor-toolbar-tool-replace-button-replaceall':function(e){$j(this).closest('.ui-dialog').data('dialogaction',e.target);$j(this).data('replaceCallback').call(this,'replaceAll');},'wikieditor-toolbar-tool-replace-close':function(){$j(this).dialog('close');}},open:function(){$j(this).data('offset',0);$j('#wikieditor-toolbar-replace-search').focus();$j('#wikieditor-toolbar-replace-nomatch, #wikieditor-toolbar-replace-success, #wikieditor-toolbar-replace-emptysearch, #wikieditor-toolbar-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);});}
173 -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);}}}}});}});mw.loadDone('wikiEditor.config.toolbar');mw.addMessages({"wikieditor-template-editor-preference":"Enable form-based editing of wiki templates"});mw.ready(function(){if(!wgWikiEditorEnabledModules.templateEditor){return true;}
 173+var dialog=$j(this).closest('.ui-dialog');var that=this;$j($j(this).data('context').$iframe[0].contentWindow.document).bind('keypress.srdialog',function(e){if((e.keyCode||e.which)==13){var button=dialog.data('dialogaction')||dialog.find('button:first');button.click();e.preventDefault();}else if((e.keyCode||e.which)==27){$j(that).dialog('close');}});},close:function(){$j($j(this).data('context').$iframe[0].contentWindow.document).unbind('keypress.srdialog');$j(this).data('context').$iframe[0].contentWindow.focus();$j(this).closest('.ui-dialog').data('dialogaction',false);}}}}});}});mw.loadDone('wikiEditor.config.toolbar');mw.addMessages({"wikieditor-template-editor-preference":"Enable form-based editing of wiki templates"});mw.ready(function(){if(!wgWikiEditorEnabledModules.templateEditor){return true;}
174174 if($j.fn.wikiEditor){$j('textarea#wpTextbox1').wikiEditor('addModule','templateEditor');}});mw.loadDone('wikiEditor.config.templateEditor');
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js
@@ -1840,18 +1840,24 @@
18411841 });
18421842 }
18431843 var dialog = $j(this).closest( '.ui-dialog' );
1844 - $j(this).data( 'context' ).$textarea.bind( 'keypress.srdialog', function( e ) {
1845 - if ( ( e.keyCode || e.which ) == 13 ) {
1846 - var button = dialog.data( 'dialogaction' ) || dialog.find( 'button:first' );
1847 - button.click();
1848 - e.preventDefault();
1849 - }
1850 - });
 1844+ var that = this;
 1845+ $j( $j(this).data( 'context' ).$iframe[0].contentWindow.document )
 1846+ .bind( 'keypress.srdialog', function( e ) {
 1847+ if ( ( e.keyCode || e.which ) == 13 ) {
 1848+ // Enter
 1849+ var button = dialog.data( 'dialogaction' ) || dialog.find( 'button:first' );
 1850+ button.click();
 1851+ e.preventDefault();
 1852+ } else if ( ( e.keyCode || e.which ) == 27 ) {
 1853+ // Escape
 1854+ $j(that).dialog( 'close' );
 1855+ }
 1856+ });
18511857 },
18521858 close: function() {
1853 - $j(this).data( 'context' ).$textarea
1854 - .unbind( 'keypress.srdialog' )
1855 - .focus();
 1859+ $j( $j(this).data( 'context' ).$iframe[0].contentWindow.document )
 1860+ .unbind( 'keypress.srdialog' );
 1861+ $j(this).data( 'context' ).$iframe[0].contentWindow.focus();
18561862 $j(this).closest( '.ui-dialog' ).data( 'dialogaction', false );
18571863 }
18581864 }

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
r58427EditToolbar: (bug 21016) Tabbing to a button and pressing Enter doesn't work ...catrope13:26, 2 November 2009

Status & tagging log