r61393 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61392‎ | r61393 | r61394 >
Date:20:55, 22 January 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: (bug 22202) Link and table dialogs insert text when pressing Enter on Cancel button
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)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php
@@ -35,7 +35,7 @@
3636 array(
3737 'src' => 'Modules/Toolbar/Toolbar.js',
3838 'class' => 'wikiEditor.config.toolbar',
39 - 'version' => 24
 39+ 'version' => 25
4040 ),
4141 array(
4242 'src' => 'Modules/TemplateEditor/TemplateEditor.js',
@@ -44,10 +44,10 @@
4545 ),
4646 ),
4747 'combined' => array(
48 - array( 'src' => 'WikiEditor.combined.js', 'version' => 26 ),
 48+ array( 'src' => 'WikiEditor.combined.js', 'version' => 27 ),
4949 ),
5050 'minified' => array(
51 - array( 'src' => 'WikiEditor.combined.min.js', 'version' => 26 ),
 51+ array( 'src' => 'WikiEditor.combined.min.js', 'version' => 27 ),
5252 ),
5353 );
5454 static $messages = array(
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js
@@ -1526,12 +1526,17 @@
15271527 // when the user presses Enter
15281528 $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
15291529 if ( ( e.keyCode || e.which ) == 13 ) {
1530 - $j(this)
1531 - .find( 'button:first' )
1532 - .click();
 1530+ var button = $j(this).data( 'dialogaction' ) || $j(this).find( 'button:first' );
 1531+ button.click();
15331532 e.preventDefault();
15341533 }
15351534 });
 1535+
 1536+ // Make tabbing to a button and pressing
 1537+ // Enter do what people expect
 1538+ $j(this).closest( '.ui-dialog' ).find( 'button' ).focus( function() {
 1539+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', this );
 1540+ });
15361541 }
15371542 }
15381543 }
@@ -1730,12 +1735,17 @@
17311736 // when the user presses Enter
17321737 $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
17331738 if ( ( e.keyCode || e.which ) == 13 ) {
1734 - $j(this)
1735 - .find( 'button:first' )
1736 - .click();
 1739+ var button = $j(this).data( 'dialogaction' ) || $j(this).find( 'button:first' );
 1740+ button.click();
17371741 e.preventDefault();
17381742 }
17391743 });
 1744+
 1745+ // Make tabbing to a button and pressing
 1746+ // Enter do what people expect
 1747+ $j(this).closest( '.ui-dialog' ).find( 'button' ).focus( function() {
 1748+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', this );
 1749+ });
17401750 }
17411751 }
17421752 }
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js
@@ -72,7 +72,7 @@
7373 $j('#wikieditor-toolbar-link-int-target').val(target).change();if(typeof type!='undefined')
7474 $j('#wikieditor-toolbar-link-'+type).attr('checked','checked');}
7575 $j('#wikieditor-toolbar-link-int-text').data('untouched',$j('#wikieditor-toolbar-link-int-text').val()==$j('#wikieditor-toolbar-link-int-target').val());$j('#wikieditor-toolbar-link-int-target').suggestions();$j('#wikieditor-toolbar-link-int-text, #wikiedit-toolbar-link-int-target').each(function(){if($j(this).val()=='')
76 -$j(this).parent().find('label').show();});if(!($j(this).data('dialogkeypressset'))){$j(this).data('dialogkeypressset',true);$j(this).closest('.ui-dialog').keypress(function(e){if((e.keyCode||e.which)==13){$j(this).find('button:first').click();e.preventDefault();}});}}}},'insert-table':{titleMsg:'wikieditor-toolbar-tool-table-title',id:'wikieditor-toolbar-table-dialog',html:'\
 76+$j(this).parent().find('label').show();});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();}});$j(this).closest('.ui-dialog').find('button').focus(function(){$j(this).closest('.ui-dialog').data('dialogaction',this);});}}}},'insert-table':{titleMsg:'wikieditor-toolbar-tool-table-title',id:'wikieditor-toolbar-table-dialog',html:'\
7777 <fieldset><div class="wikieditor-toolbar-table-form">\
7878 <div class="wikieditor-toolbar-field-wrapper">\
7979 <input type="checkbox" id="wikieditor-toolbar-table-dimensions-header" checked />\
@@ -140,7 +140,7 @@
141141 classes.push('sortable');var classStr=classes.length>0?' class="'+classes.join(' ')+'"':'';$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:'{|'+classStr+"\n",peri:table,post:'|}',ownline:true}},$j(this));$j('#wikieditor-toolbar-table-dimensions-rows').val(4);$j('#wikieditor-toolbar-table-dimensions-columns').val(3);if(!$j('#wikieditor-toolbar-table-dimensions-header').is(':checked'))
142142 $j('#wikieditor-toolbar-table-dimensions-header').click();if(!$j('#wikieditor-toolbar-table-wikitable').is(':checked'))
143143 $j('#wikieditor-toolbar-table-wikitable').click();if($j('#wikieditor-toolbar-table-sortable').is(':checked'))
144 -$j('#wikieditor-toolbar-table-sortable').click();$j(this).dialog('close');},'wikieditor-toolbar-tool-table-cancel':function(){$j(this).dialog('close');}},open:function(){$j('#wikieditor-toolbar-table-dimensions-rows').focus();if(!($j(this).data('dialogkeypressset'))){$j(this).data('dialogkeypressset',true);$j(this).closest('.ui-dialog').keypress(function(e){if((e.keyCode||e.which)==13){$j(this).find('button:first').click();e.preventDefault();}});}}}},'search-and-replace':{titleMsg:'wikieditor-toolbar-tool-replace-title',id:'wikieditor-toolbar-replace-dialog',html:'\
 144+$j('#wikieditor-toolbar-table-sortable').click();$j(this).dialog('close');},'wikieditor-toolbar-tool-table-cancel':function(){$j(this).dialog('close');}},open:function(){$j('#wikieditor-toolbar-table-dimensions-rows').focus();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();}});$j(this).closest('.ui-dialog').find('button').focus(function(){$j(this).closest('.ui-dialog').data('dialogaction',this);});}}}},'search-and-replace':{titleMsg:'wikieditor-toolbar-tool-replace-title',id:'wikieditor-toolbar-replace-dialog',html:'\
145145 <div id="wikieditor-toolbar-replace-message">\
146146 <div id="wikieditor-toolbar-replace-nomatch" rel="wikieditor-toolbar-tool-replace-nomatch"></div>\
147147 <div id="wikieditor-toolbar-replace-success"></div>\
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js
@@ -1445,12 +1445,17 @@
14461446 // when the user presses Enter
14471447 $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
14481448 if ( ( e.keyCode || e.which ) == 13 ) {
1449 - $j(this)
1450 - .find( 'button:first' )
1451 - .click();
 1449+ var button = $j(this).data( 'dialogaction' ) || $j(this).find( 'button:first' );
 1450+ button.click();
14521451 e.preventDefault();
14531452 }
14541453 });
 1454+
 1455+ // Make tabbing to a button and pressing
 1456+ // Enter do what people expect
 1457+ $j(this).closest( '.ui-dialog' ).find( 'button' ).focus( function() {
 1458+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', this );
 1459+ });
14551460 }
14561461 }
14571462 }
@@ -1649,12 +1654,17 @@
16501655 // when the user presses Enter
16511656 $j(this).closest( '.ui-dialog' ).keypress( function( e ) {
16521657 if ( ( e.keyCode || e.which ) == 13 ) {
1653 - $j(this)
1654 - .find( 'button:first' )
1655 - .click();
 1658+ var button = $j(this).data( 'dialogaction' ) || $j(this).find( 'button:first' );
 1659+ button.click();
16561660 e.preventDefault();
16571661 }
16581662 });
 1663+
 1664+ // Make tabbing to a button and pressing
 1665+ // Enter do what people expect
 1666+ $j(this).closest( '.ui-dialog' ).find( 'button' ).focus( function() {
 1667+ $j(this).closest( '.ui-dialog' ).data( 'dialogaction', this );
 1668+ });
16591669 }
16601670 }
16611671 }
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -586,23 +586,29 @@
587587 if ( typeof selector == 'undefined' ) {
588588 selector = '*';
589589 }
 590+
 591+ // Start at the selection's start and traverse the DOM backwards
 592+ // This is done by traversing an element's children first, then the element itself, then its parent
590593 var e;
591594 if ( context.$iframe[0].contentWindow.getSelection ) {
592595 // Firefox and Opera
593596 var selection = context.$iframe[0].contentWindow.getSelection();
594597 // On load, webkit seems to not have a valid selection
595598 if ( selection.baseNode !== null ) {
596 - // Start at the selection's start and traverse the DOM backwards
597 - // This is done by traversing an element's children first, then the element itself, then its parent
598599 e = selection.getRangeAt( 0 ).startContainer;
599600 } else {
600601 return $( [] );
601602 }
602603 } else if ( context.$iframe[0].contentWindow.document.selection ) {
603604 // IE
604 - // TODO
605 - return $( [] );
 605+ // range.startContainer or similar functionality is not available in IE, so we have to
 606+ // traverse the DOM to find out which element the selection starts in
 607+ var range = context.$iframe[0].contentWindow.document.selection.createRange(),
 608+ preRange = context.$iframe[0].contentWindow.document.body.createTextRange();
 609+ preRange.setEndPoint( "EndToStart", range );
 610+ // TODO finish
606611 }
 612+
607613 if ( e.nodeName != '#text' ) {
608614 // The selection is not in a textnode, but between two non-text nodes
609615 // (usually inside the <body> between two <br>s). Go to the rightmost

Follow-up revisions

RevisionCommit summaryAuthorDate
r61399Partial revert of r61393: committed unrelated work in progresscatrope21:57, 22 January 2010

Status & tagging log