<commit_before>/*!
	Modaal - accessible modals - v0.2.10
	by Humaan, for all humans.
	http://humaan.com
 */
/**
	Modaal jQuery Plugin : Accessible Modals
	
	==== General Options ===
	type (string) 							: 	ajax, inline, image, iframe, confirm. Defaults to 'inline'
	animation (string) 						: 	Fade, expand, down, up. Defaults to 'fade'
	after_callback_delay (integer)			: 	Specify a delay value for the after open callbacks. This is necessary because with the bundled animations
												have a set duration in the bundled CSS. Specify a delay of the same amount as the animation duration in so
												more accurately fire the after open/close callbacks. Defaults 350, does not apply if animation is 'none', 
												after open callbacks are dispatched immediately

	is_locked (boolean)						: 	Set this to true to disable closing the modal via keypress or clicking the background. Beware that if 
												type != 'confirm' there will be no interface to dismiss the modal if is_locked = true, you'd have to
												programmatically arrange to dismiss the modal. Confirm modals are always locked regardless of this option
												Defaults to false
	hide_close (boolean)					:	Set this to true to hide the close modal button. Key press and overlay click will still close the modal.
												This method is best used when you want to put a custom close button inside the modal container space.

	background (string)						: 	Background overlay style. Defaults to '#000'
	overlay_opacity (float) 				: 	Background overlay transparency. Defaults to 0.8
	overlay_close (boolean)					:	Set this to false if you want to disable click to close on overlay background.
	
	accessible_title (string)				: 	Accessible title. Default 'Dialog Window'
	start_open (boolean)					:	Set this to true to launch the Modaal window immediately on page open
	fullscreen (boolean)					:	Set this to true to make the modaal fill the entire screen, false will default to own width/height attributes.
	custom_class (string)					:	Fill in this string with a custom class that will be applied to the outer most modal wrapper.
	
	width (integer)							: 	Desired width of the modal. Required for iframe type. Defaults to undefined //TODO
	height (integer)						: 	Desired height of the modal. Required for iframe type. Defaults to undefined //TODO
	

	=== Events ===
	before_open (function) 					: 	Callback function executed before modal is opened
	after_open (function)					: 	Callback function executed after modal is opened
	before_close (function)					: 	Callback function executed before modal is closed
	after_close (function)					: 	Callback function executed after modal is closed
	source (function(element, src))			: 	Callback function executed on the default source, it is intended to transform the
												source (href in an AJAX modal or iframe). The function passes in the triggering element
												as well as the default source depending of the modal type. The default output of the
												function is an untransformed default source.


	=== Confirm Options & Events ===
	confirm_button_text (string)			: 	Text on the confirm button. Defaults to 'Confirm'
	confirm_cancel_button_text (string)		: 	Text on the confirm modal cancel button. Defaults to 'Cancel'
	confirm_title (string)					: 	Title for confirm modal. Default 'Confirm Title'
	confirm_content (string)				: 	HTML content for confirm message
	confirm_callback (function)				: 	Callback function for when the confirm button is pressed as opposed to cancel

	
	=== Gallery Options & Events ===
	gallery_active_class (string)			: 	Active class applied to the currently active image or image slide in a gallery 'gallery_active_item'
	before_image_change (function)			: 	Callback function executed before the image slide changes in a gallery modal. Default function( current_item, incoming_item )
	after_image_change (function)			: 	Callback function executed after the image slide changes in a gallery modal. Default function ( current_item )
	

	=== AJAX Options & Events ===
	loading_content (string)				: 	HTML content for loading message. Default 'Loading &hellip;'
	loading_class (string)					: 	Class name to be applied while content is loaded via AJAX. Default 'is_loading'
	ajax_error_class (string)				:	Class name to be applied when content has failed to load. Default is 'modaal-error'
	ajax_success (function)		 			:   Callback for when AJAX content is loaded in
	
	
	=== SOCIAL CONTENT ===
	instagram_id (string)					:	Unique photo ID for an Instagram photo.

*/
( function( $ ) {

	var dom = $('body');
	var modaal_close = '<button type="button" class="modaal-close" id="modaal-close" aria-label="Close (Press escape to close)"><span>Close</span></button>';
	var modaal_loading_spinner = '<div class="modaal-loading-spinner"><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div></div>'
	
	var Modaal = {
		init : function(options, elem) {
			var self = this;
			
			self.$elem = $(elem);
			self.options = $.extend({}, $.fn.modaal.options, self.$elem.data(), options);
			self.xhr = null;
			
			// set up the scope
			self.scope = {
				is_open: false,
				id: 'modaal_' + ( new Date().getTime() ) + ( Math.random().toString(16).substring(2) )
			};
			
			// add scope attribute to trigger element
			self.$elem.attr('data-modaal-scope', self.scope.id);
			
			// private options
			self.private_options = {
				active_class: 'is_active'
			};
			
			self.lastFocus = null;
			
			// if is_locked
			if ( self.options.is_locked || self.options.type == 'confirm' || self.options.hide_close ) {
				self.scope.close_btn = '';
			} else {
				self.scope.close_btn = modaal_close;
			}
			
			// reset animation_speed
			if (self.options.animation === 'none' ){
				self.options.animation_speed = 0;
				self.options.after_callback_delay = 0;
			}
			
			// On click to open modal
			$(elem).on('click.Modaal', function(e) {
				e.preventDefault();

				var source;
				
				// Save last active state before modal
				self.lastFocus = document.activeElement;
				
				// CB: before_open
				self.options.before_open.call(self, e);
				
				switch (self.options.type) {
					case 'inline':
						self.create_basic();
						break;
						
					case 'ajax':
						source = self.options.source( self.$elem, self.$elem.attr('href') );
						self.fetch_ajax( source );
						break;
						
					case 'confirm':
						self.options.is_locked = true;
						self.create_confirm();
						break;
						
					case 'image':
						self.create_image();
						break;
						
					case 'iframe':
						source = self.options.source( self.$elem, self.$elem.attr('href') );
						self.create_iframe( source );
						break;
						
					case 'video':
						self.create_video(self.$elem.attr('href'));
						break;
						
					case 'instagram':
						self.create_instagram();
						break;
				}
				
				// call events to be watched (click, tab, keyup, keydown etc.)
				self.watch_events();
				
			});
			
			
			// Check for start_open
			if (self.options.start_open === true ){
				$(elem).click();
			}
		},

		// Watching Modal
		// ----------------------------------------------------------------
		watch_events : function() {
			var self = this;
			
			dom.off('click.Modaal keyup.Modaal keydown.Modaal');

			// Body keydown
			dom.bind('keydown.Modaal', function(e) {
				var key = e.keyCode;
				var target = e.target;

				// look for tab change and reset focus to modal window
				// done in keydown so the check fires repeatedly when you hold the tab key down
				if (key == 9 && self.scope.is_open) {
					if (!$.contains(document.getElementById(self.scope.id), target) ) {
						$('#' + self.scope.id).find('*[tabindex="0"]').focus();
					}
				}
			});

			// Body keyup
			dom.bind('keyup.Modaal', function(e) {
				var key = e.keyCode;
				var target = e.target;

				if ( !self.options.is_locked ){
					// On escape key press close modal
					if (key == 27 && self.scope.is_open ) {
						if ( $(document.activeElement).is('input') ) {
							return false;
						}
						
						self.modaal_close();
						return;
					}
				}

				// is gallery open and images length is > 1
				if ( self.options.type == 'image' ) {
					// arrow left for back
					if (key == 37 && self.scope.is_open && (!$('#' + self.scope.id + ' .modaal-gallery-prev').hasClass('is_hidden')) ) {
						self.gallery_update('prev');
					}
					// arrow right for next
					if (key == 39 && self.scope.is_open && (!$('#' + self.scope.id + ' .modaal-gallery-next').hasClass('is_hidden')) ) {
						self.gallery_update('next');
					}
					return;
				}<commit_msg>Replaced calls to bind with on, as bind is deprecated and just a wrapper these days. Issue #16<commit_after>/*!
	Modaal - accessible modals - v0.2.10
	by Humaan, for all humans.
	http://humaan.com
 */
/**
	Modaal jQuery Plugin : Accessible Modals
	
	==== General Options ===
	type (string) 							: 	ajax, inline, image, iframe, confirm. Defaults to 'inline'
	animation (string) 						: 	Fade, expand, down, up. Defaults to 'fade'
	after_callback_delay (integer)			: 	Specify a delay value for the after open callbacks. This is necessary because with the bundled animations
												have a set duration in the bundled CSS. Specify a delay of the same amount as the animation duration in so
												more accurately fire the after open/close callbacks. Defaults 350, does not apply if animation is 'none', 
												after open callbacks are dispatched immediately

	is_locked (boolean)						: 	Set this to true to disable closing the modal via keypress or clicking the background. Beware that if 
												type != 'confirm' there will be no interface to dismiss the modal if is_locked = true, you'd have to
												programmatically arrange to dismiss the modal. Confirm modals are always locked regardless of this option
												Defaults to false
	hide_close (boolean)					:	Set this to true to hide the close modal button. Key press and overlay click will still close the modal.
												This method is best used when you want to put a custom close button inside the modal container space.

	background (string)						: 	Background overlay style. Defaults to '#000'
	overlay_opacity (float) 				: 	Background overlay transparency. Defaults to 0.8
	overlay_close (boolean)					:	Set this to false if you want to disable click to close on overlay background.
	
	accessible_title (string)				: 	Accessible title. Default 'Dialog Window'
	start_open (boolean)					:	Set this to true to launch the Modaal window immediately on page open
	fullscreen (boolean)					:	Set this to true to make the modaal fill the entire screen, false will default to own width/height attributes.
	custom_class (string)					:	Fill in this string with a custom class that will be applied to the outer most modal wrapper.
	
	width (integer)							: 	Desired width of the modal. Required for iframe type. Defaults to undefined //TODO
	height (integer)						: 	Desired height of the modal. Required for iframe type. Defaults to undefined //TODO
	

	=== Events ===
	before_open (function) 					: 	Callback function executed before modal is opened
	after_open (function)					: 	Callback function executed after modal is opened
	before_close (function)					: 	Callback function executed before modal is closed
	after_close (function)					: 	Callback function executed after modal is closed
	source (function(element, src))			: 	Callback function executed on the default source, it is intended to transform the
												source (href in an AJAX modal or iframe). The function passes in the triggering element
												as well as the default source depending of the modal type. The default output of the
												function is an untransformed default source.


	=== Confirm Options & Events ===
	confirm_button_text (string)			: 	Text on the confirm button. Defaults to 'Confirm'
	confirm_cancel_button_text (string)		: 	Text on the confirm modal cancel button. Defaults to 'Cancel'
	confirm_title (string)					: 	Title for confirm modal. Default 'Confirm Title'
	confirm_content (string)				: 	HTML content for confirm message
	confirm_callback (function)				: 	Callback function for when the confirm button is pressed as opposed to cancel

	
	=== Gallery Options & Events ===
	gallery_active_class (string)			: 	Active class applied to the currently active image or image slide in a gallery 'gallery_active_item'
	before_image_change (function)			: 	Callback function executed before the image slide changes in a gallery modal. Default function( current_item, incoming_item )
	after_image_change (function)			: 	Callback function executed after the image slide changes in a gallery modal. Default function ( current_item )
	

	=== AJAX Options & Events ===
	loading_content (string)				: 	HTML content for loading message. Default 'Loading &hellip;'
	loading_class (string)					: 	Class name to be applied while content is loaded via AJAX. Default 'is_loading'
	ajax_error_class (string)				:	Class name to be applied when content has failed to load. Default is 'modaal-error'
	ajax_success (function)		 			:   Callback for when AJAX content is loaded in
	
	
	=== SOCIAL CONTENT ===
	instagram_id (string)					:	Unique photo ID for an Instagram photo.

*/
( function( $ ) {

	var dom = $('body');
	var modaal_close = '<button type="button" class="modaal-close" id="modaal-close" aria-label="Close (Press escape to close)"><span>Close</span></button>';
	var modaal_loading_spinner = '<div class="modaal-loading-spinner"><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div></div>'
	
	var Modaal = {
		init : function(options, elem) {
			var self = this;
			
			self.$elem = $(elem);
			self.options = $.extend({}, $.fn.modaal.options, self.$elem.data(), options);
			self.xhr = null;
			
			// set up the scope
			self.scope = {
				is_open: false,
				id: 'modaal_' + ( new Date().getTime() ) + ( Math.random().toString(16).substring(2) )
			};
			
			// add scope attribute to trigger element
			self.$elem.attr('data-modaal-scope', self.scope.id);
			
			// private options
			self.private_options = {
				active_class: 'is_active'
			};
			
			self.lastFocus = null;
			
			// if is_locked
			if ( self.options.is_locked || self.options.type == 'confirm' || self.options.hide_close ) {
				self.scope.close_btn = '';
			} else {
				self.scope.close_btn = modaal_close;
			}
			
			// reset animation_speed
			if (self.options.animation === 'none' ){
				self.options.animation_speed = 0;
				self.options.after_callback_delay = 0;
			}
			
			// On click to open modal
			$(elem).on('click.Modaal', function(e) {
				e.preventDefault();

				var source;
				
				// Save last active state before modal
				self.lastFocus = document.activeElement;
				
				// CB: before_open
				self.options.before_open.call(self, e);
				
				switch (self.options.type) {
					case 'inline':
						self.create_basic();
						break;
						
					case 'ajax':
						source = self.options.source( self.$elem, self.$elem.attr('href') );
						self.fetch_ajax( source );
						break;
						
					case 'confirm':
						self.options.is_locked = true;
						self.create_confirm();
						break;
						
					case 'image':
						self.create_image();
						break;
						
					case 'iframe':
						source = self.options.source( self.$elem, self.$elem.attr('href') );
						self.create_iframe( source );
						break;
						
					case 'video':
						self.create_video(self.$elem.attr('href'));
						break;
						
					case 'instagram':
						self.create_instagram();
						break;
				}
				
				// call events to be watched (click, tab, keyup, keydown etc.)
				self.watch_events();
				
			});
			
			
			// Check for start_open
			if (self.options.start_open === true ){
				$(elem).click();
			}
		},

		// Watching Modal
		// ----------------------------------------------------------------
		watch_events : function() {
			var self = this;
			
			dom.off('click.Modaal keyup.Modaal keydown.Modaal');

			// Body keydown
			dom.on('keydown.Modaal', function(e) {
				var key = e.keyCode;
				var target = e.target;

				// look for tab change and reset focus to modal window
				// done in keydown so the check fires repeatedly when you hold the tab key down
				if (key == 9 && self.scope.is_open) {
					if (!$.contains(document.getElementById(self.scope.id), target) ) {
						$('#' + self.scope.id).find('*[tabindex="0"]').focus();
					}
				}
			});

			// Body keyup
			dom.on('keyup.Modaal', function(e) {
				var key = e.keyCode;
				var target = e.target;

				if ( !self.options.is_locked ){
					// On escape key press close modal
					if (key == 27 && self.scope.is_open ) {
						if ( $(document.activeElement).is('input') ) {
							return false;
						}
						
						self.modaal_close();
						return;
					}
				}

				// is gallery open and images length is > 1
				if ( self.options.type == 'image' ) {
					// arrow left for back
					if (key == 37 && self.scope.is_open && (!$('#' + self.scope.id + ' .modaal-gallery-prev').hasClass('is_hidden')) ) {
						self.gallery_update('prev');
					}
					// arrow right for next
					if (key == 39 && self.scope.is_open && (!$('#' + self.scope.id + ' .modaal-gallery-next').hasClass('is_hidden')) ) {
						self.gallery_update('next');
					}
					return;
				}
{'fraction_non_alphanumeric': 0.11743610178174987, 'fraction_numerical': 0.0030739454659304377, 'mean_word_length': 2.783760499676933, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 81, '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': '3582048', 'n_tokens_mistral': 6531, 'n_tokens_neox': 5130, 'n_words': 1751}