https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112963

Revision: 112963
Author:   jeroendedauw
Date:     2012-03-03 21:32:12 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
Follow up to r112961; selecting an item with return should not submit dialog

Modified Paths:
--------------
    trunk/extensions/EducationProgram/resources/ep.enlist.js

Modified: trunk/extensions/EducationProgram/resources/ep.enlist.js
===================================================================
--- trunk/extensions/EducationProgram/resources/ep.enlist.js    2012-03-03 
21:08:56 UTC (rev 112962)
+++ trunk/extensions/EducationProgram/resources/ep.enlist.js    2012-03-03 
21:32:12 UTC (rev 112963)
@@ -137,7 +137,8 @@
 
                        this.doAdd = function() {
                                var $add = $( '#ep-' + role + '-add-button' ),
-                               $cancel = $( '#ep-' + role + 
'-add-cancel-button' );
+                               $cancel = $( '#ep-' + role + 
'-add-cancel-button' ),
+                               isCompletionEnter = false;
 
                                $add.button( 'option', 'disabled', true );
                                $add.button( 'option', 'label', ep.msg( 'ep-' + 
role + '-adding' ) );
@@ -244,6 +245,11 @@
                                        },
                                        close: function() {
                                                $( this ).removeClass( 
"ui-corner-top" ).addClass( "ui-corner-all" );
+                                       },
+                                       select: function( event, ui ) {
+                                               if ( ( event.keyCode ? 
event.keyCode : event.which ) === 13 ) {
+                                                       isCompletionEnter = 
true;
+                                               }
                                        }
                                } );
                        }
@@ -260,7 +266,13 @@
                        var enterHandler = function( event ) {
                                if ( event.which == '13' ) {
                                        event.preventDefault();
-                                       _this.doAdd();
+
+                                       if ( isCompletionEnter ) {
+                                               isCompletionEnter = false;
+                                       }
+                                       else {
+                                               _this.doAdd();
+                                       }
                                }
                        };
                        


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to