Index: popups.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/popups/popups.js,v retrieving revision 1.9.2.23 diff -u -r1.9.2.23 popups.js --- popups.js 27 Feb 2009 01:08:33 -0000 1.9.2.23 +++ popups.js 27 Feb 2009 20:11:30 -0000 @@ -147,10 +147,13 @@ var top = (windowHeight / 2) - (popupHeight / 2) + Drupal.popups.scrollTop(); $popups.css('top', top).css('left', left); // Position the popups to be visible. - - this.refocus(); // TODO: capture the focus when it leaves the dialog. - Drupal.popups.removeLoading(); // Remove the loading img. - + + // Focus on the first input element in the popup window. + this.refocus(); + + // Remove the loading image. + Drupal.popups.removeLoading(); + return false; }; @@ -243,14 +246,18 @@ }; /** - * Set the focus on the popups to the first visible form element, or the first button, or the close link. + * Set the focus on the popups to the first enabled visible form element, or the close link. */ Drupal.popups.refocus = function() { - $focus = $('#popups input:visible:eq(0)'); - if (!isset(focus)) { - $focus = $('#popups-close'); // Doesn't seem to work. + // Select the first visable enabled input element. + var focus = $('#popups input:visible:enabled:first'); + if (focus.length > 0) { + focus.focus(); + } + else { + // Select the close link. + $('#popups-close a').focus(); } - $focus.focus(); }; /****************************************************************************