Oy!

Is there a way to set the horizontal scrollbar position in the Popup window to the very top?

At the moment the vertical scrollbar defaults at the center.

I was thinking even something like : $popup.focus( $('popupTitle') );

Any guidance?

Comments

kvvnn’s picture

UPDATE:

It seems that only when I open nodes with comments within a popup window does the vertical scrollbar default in the middle. Otherwise, the scrollbar is positioned at the top.

kvvnn’s picture

Changing this bit of code in popups.js fixed my problem.

/**
* Set the focus on the popups to the first visible, enabled form element, or the close link.
*/
Popups.Popup.prototype.refocus = function() {
// Select the first visible enabled input element.
var $popup = this.$popup();
// kvn ( Tim ) // var $focus = $popup.find(':input:visible:enabled:first');
// kvn ( Tim ) // if (!$focus.length) {
// There is no visible enabled input element, so select the close link.
$focus = $popup.find('.popups-close a'); // kvn ( Tim )
//}
$focus.focus();
};

capellic’s picture

I had the same problem, but I am using version 1.3. I replaced the whole "Drupal.popups.refocus" function with the code in #2 code and it worked. What's interesting is that there is even a comment in the original code, "doesn't seem to work."

From:

/**
 * Set the focus on the popups to the first visible form element, or the first button, 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.
  }
  $focus.focus();
};

To:

/**
 * Set the focus on the popups to the first visible form element, or the first button, or the close link.
 */
Drupal.popups.refocus = function() {
	// Select the first visible enabled input element.
	var $popup = this.$popup();
	// kvn ( Tim ) // var $focus = $popup.find(':input:visible:enabled:first');
	// kvn ( Tim ) // if (!$focus.length) {
	// There is no visible enabled input element, so select the close link.
	$focus = $popup.find('.popups-close a'); // kvn ( Tim )
	//}
	$focus.focus();
};