<commit_before>/**
 * Menu
 */
Garnish.Menu = Garnish.Base.extend({

	settings: null,

	$container: null,
	$options: null,
	$anchor: null,

	menuId: null,

	_windowWidth: null,
	_windowHeight: null,
	_windowScrollLeft: null,
	_windowScrollTop: null,

	_anchorOffset: null,
	_anchorWidth: null,
	_anchorHeight: null,
	_anchorOffsetRight: null,
	_anchorOffsetBottom: null,

	_menuWidth: null,
	_menuHeight: null,

	/**
	 * Constructor
	 */
	init: function(container, settings)
	{
		this.setSettings(settings, Garnish.Menu.defaults);

		this.$container = $(container);

		this.$options = $();
		this.addOptions(this.$container.find('a'));

		// Menu List
		this.menuId = 'menu' + this._namespace;
		this.$menuList = $('ul', this.$container);
		this.$menuList.attr({
			'role': 'listbox',
			'id': this.menuId,
			'aria-hidden': 'true'
		});

		// Deprecated
		if (this.settings.attachToElement)
		{
			this.settings.anchor = this.settings.attachToElement;
			Garnish.log('The \'attachToElement\' setting is deprecated. Use \'anchor\' instead.');
		}

		if (this.settings.anchor)
		{
			this.$anchor = $(this.settings.anchor);
		}

		// Prevent clicking on the container from hiding the menu
		this.addListener(this.$container, 'mousedown', function(ev)
		{
			ev.stopPropagation();
		});
	},

	addOptions: function($options)
	{
		this.$options = this.$options.add($options);<commit_msg>Fixed a bug where mouse-down on a menu option would hide the menu before the click could be registered<commit_after>/**
 * Menu
 */
Garnish.Menu = Garnish.Base.extend({

	settings: null,

	$container: null,
	$options: null,
	$anchor: null,

	menuId: null,

	_windowWidth: null,
	_windowHeight: null,
	_windowScrollLeft: null,
	_windowScrollTop: null,

	_anchorOffset: null,
	_anchorWidth: null,
	_anchorHeight: null,
	_anchorOffsetRight: null,
	_anchorOffsetBottom: null,

	_menuWidth: null,
	_menuHeight: null,

	/**
	 * Constructor
	 */
	init: function(container, settings)
	{
		this.setSettings(settings, Garnish.Menu.defaults);

		this.$container = $(container);

		this.$options = $();
		this.addOptions(this.$container.find('a'));

		// Menu List
		this.menuId = 'menu' + this._namespace;
		this.$menuList = $('ul', this.$container);
		this.$menuList.attr({
			'role': 'listbox',
			'id': this.menuId,
			'aria-hidden': 'true'
		});

		// Deprecated
		if (this.settings.attachToElement)
		{
			this.settings.anchor = this.settings.attachToElement;
			Garnish.log('The \'attachToElement\' setting is deprecated. Use \'anchor\' instead.');
		}

		if (this.settings.anchor)
		{
			this.$anchor = $(this.settings.anchor);
		}

		// Prevent clicking on the container from hiding the menu
		this.addListener(this.$container, 'mousedown', function(ev)
		{
			ev.stopPropagation();

			// Prevent this from causing the menu button to blur
			ev.preventDefault();
		});
	},

	addOptions: function($options)
	{
		this.$options = this.$options.add($options);
{'fraction_non_alphanumeric': 0.1529291553133515, 'fraction_numerical': 0.0, 'mean_word_length': 3.886855241264559, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2535104', 'n_tokens_mistral': 1095, 'n_tokens_neox': 975, 'n_words': 217}