{"size": 1098, "ext": "js", "max_stars_repo_path": "client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.js", "max_stars_repo_name": "mariansollmann/CM", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.js", "max_issues_repo_name": "mariansollmann/CM", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.js", "max_forks_repo_name": "mariansollmann/CM", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.875, "max_line_length": 85, "alphanum_fraction": 0.6247723133}
/*
 * Author: CM
 */
(function($) {

	$.clickDecorators.confirmed = {
		before: function(event) {
			var $this = $(this);

			var activateButton = function() {
				$this.addClass('confirmClick');

				var deactivateButton = function() {
					$this.removeClass('confirmClick');
					$this.removeData('clickConfirmed.deactivate');
					clearTimeout(deactivateTimeout);
					$(document).off('click.clickConfirmed', documentClickHandler);
				};

				$this.data('clickConfirmed.deactivate', deactivateButton);

				var deactivateTimeout = setTimeout(function() {
					deactivateButton();
				}, 3000);

				var documentClickHandler = function(e) {
					if (!$this.length || e.target !== $this[0] && !$.contains($this[0], e.target)) {
						deactivateButton();
					}
				};

				setTimeout(function() {
					$(document).on('click.clickConfirmed', documentClickHandler);
				}, 0);
			};

			if ($this.hasClass('confirmClick')) {
				$this.data('clickConfirmed.deactivate')();
			} else {
				activateButton();
				event.preventDefault();
				event.stopImmediatePropagation();
			}
		}
	};

})(jQuery);
