<commit_before>(function (Q, $, window, document, undefined) {


/**
 * Q Tools
 * @module Q-tools
 */

/**
 * This plugin Makes a contextual menu from given options and handles its showing / hiding.
 * @class Q contextual
 * @constructor
 * @param {Object} [options] options an object that can include:
 * @param {Array} [options.elements] elements is an array of LI elements to add
 * @param {String} [options.className=''] className is a CSS class name for additional styling. Optional
 * @param {Q.Event|function|String} [options.defaultHandler=null] defaultHandler is a Q.Event, or function which is called when a specific handler for selected item is not defined.
 *   So you can use just one handler for whole contextual or provide separate handlers for each item.
 * @param {Object} [options.size=null] size is an object with values for override default contextual size.
 * @param {Number} [options.size.width] width
 * @param {Number} [options.size.height] height
 */
Q.Tool.jQuery('Q/contextual', function _Q_contextual() {

	var $this = $(this);
	var state = $this.state('Q/contextual');

	// the first time when any contextual is added we need to preload its graphics,
	if ($('.Q_contextual_arrows_preloaded').length == 0) {
		$('<div class="Q_contextual_arrows_preloaded Q_contextual">' +
			'<div class="Q_contextual_top_arrow"></div>' +
			'<div class="Q_contextual_bottom_arrow"></div>' +
		'</div>').appendTo(document.body);
	}
	if (state.defaultHandler
	&& Q.typeOf(state.defaultHandler) != 'Q.Event'
	&& typeof(state.defaultHandler) != 'function'
	&& typeof(state.defaultHandler) != 'string') {
		console.warn("Default handler must be a valid Q.Event object, function or function string name.");
	}
	
	if ($this.hasClass('Q_selected')) {
		$this.removeClass('Q_selected');
		state.restoreSelected = true;
	}

	var contextual = $('<div class="Q_contextual" />');
	if (state.className) {
		contextual.addClass(state.className);
	}
	var listingWrapper = $('<div class="Q_listing_wrapper" />');
	if (state.defaultHandler) {
		if (typeof(state.defaultHandler) == 'string') {
			contextual.attr('data-handler', state.defaultHandler);
		} else {
			contextual.data('defaultHandler', state.defaultHandler);
		}
	}
	var listing = $('<ul class="Q_listing" />');
	if (state.elements) {<commit_msg>Updated Q/contextual plugin. Added options "hideDelay", "fadeTime", "doubleBlink". For "doubleBlink" set "hideDelay" 300ms and toggle class Q_contextual_pulsate in clicked menu item.<commit_after>(function (Q, $, window, document, undefined) {


/**
 * Q Tools
 * @module Q-tools
 */

/**
 * This plugin Makes a contextual menu from given options and handles its showing / hiding.
 * @class Q contextual
 * @constructor
 * @param {Object} [options] options an object that can include:
 * @param {Array} [options.elements] elements is an array of LI elements to add
 * @param {String} [options.className=''] className is a CSS class name for additional styling. Optional
 * @param {Integer} [options.hideDelay] Amount of milliseconds before hide contextual.
 * @param {Integer} [options.fadeTime] Amount of milliseconds to fade out.
 * @param {Boolean} [options.doubleBlink] If true use selected menu item double blinked (like iOS style) before console closed.
 * @param {Q.Event|function|String} [options.defaultHandler=null] defaultHandler is a Q.Event, or function which is called when a specific handler for selected item is not defined.
 *   So you can use just one handler for whole contextual or provide separate handlers for each item.
 * @param {Object} [options.size=null] size is an object with values for override default contextual size.
 * @param {Number} [options.size.width] width
 * @param {Number} [options.size.height] height
 */
Q.Tool.jQuery('Q/contextual', function _Q_contextual() {

	var $this = $(this);
	var state = $this.state('Q/contextual');

	// the first time when any contextual is added we need to preload its graphics,
	if ($('.Q_contextual_arrows_preloaded').length == 0) {
		$('<div class="Q_contextual_arrows_preloaded Q_contextual">' +
			'<div class="Q_contextual_top_arrow"></div>' +
			'<div class="Q_contextual_bottom_arrow"></div>' +
		'</div>').appendTo(document.body);
	}
	if (state.defaultHandler
	&& Q.typeOf(state.defaultHandler) != 'Q.Event'
	&& typeof(state.defaultHandler) != 'function'
	&& typeof(state.defaultHandler) != 'string') {
		console.warn("Default handler must be a valid Q.Event object, function or function string name.");
	}
	
	if ($this.hasClass('Q_selected')) {
		$this.removeClass('Q_selected');
		state.restoreSelected = true;
	}

	var contextual = $('<div class="Q_contextual" />');
	if (state.className) {
		contextual.addClass(state.className);
	}
	if (state.fadeTime) {
		contextual.data("fadeTime", state.fadeTime);
	}
	if (state.hideDelay) {
		contextual.data("hideDelay", state.hideDelay);
	} else if (state.doubleBlink) {
		var hideDelay = 300;
		contextual.data("hideDelay", hideDelay);
		contextual.on(Q.Pointer.fastclick, "li", function () {
			var $this = $(this);
			$this.addClass("Q_contextual_pulsate").on("animationend", function () {
				$this.removeClass("Q_contextual_pulsate");
			});
		});
	}
	var listingWrapper = $('<div class="Q_listing_wrapper" />');
	if (state.defaultHandler) {
		if (typeof(state.defaultHandler) == 'string') {
			contextual.attr('data-handler', state.defaultHandler);
		} else {
			contextual.data('defaultHandler', state.defaultHandler);
		}
	}
	var listing = $('<ul class="Q_listing" />');
	if (state.elements) {
{'fraction_non_alphanumeric': 0.14350262063979757, 'fraction_numerical': 0.001445870233146575, 'mean_word_length': 4.782654127481714, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '121465', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1664, 'n_words': 498}