<commit_before>/* =========================================================
	Modifications made by https://github.com/Toodledo/ADE

	1) Added comments so I could better understand the code
	2) Better handling for case where no date is preset
	3) Allows canceling of the calendar without setting a date
	4) Enabled full text parsing of unrecognized dates via an external date.js library.
		So you can type "next week" and it should work
	5) Got rid of date formatting and allowed caller to take care of this
	6) Method for destroying the calendar DOM object
	7) Remove unnecessary changeDate events
 * ========================================================= */


/* =========================================================
 * bootstrap-datepicker.js
 * http://www.eyecon.ro/bootstrap-datepicker
 * =========================================================
 * Copyright 2012 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ========================================================= */

!function($) {

	//Initialization
	var Datepicker = function(element, options) {
		this.element = $(element);
		this.picker = $(DPGlobal.template)
							.appendTo('body')
							.on({
								click: $.proxy(this.click, this),
								mousedown: $.proxy(this.mousedown, this)
							});
		this.isInput = this.element.is('input');
		this.component = this.element.is('.date') ? this.element.find('.add-on') : false;

		if (this.isInput) {
			this.element.on({
				focus: $.proxy(this.show, this),
				blur: $.proxy(this.hide, this),
				keyup: $.proxy(this.update, this)
			});
		} else {
			if (this.component) {
				this.component.on('click', $.proxy(this.show, this));
			} else {
				this.element.on('click', $.proxy(this.show, this));
			}
		}
		this.minViewMode = options.minViewMode || this.element.data('date-minviewmode') || 0;
		if (typeof this.minViewMode === 'string') {
			switch (this.minViewMode) {
				case 'months':
					this.minViewMode = 1;
					break;
				case 'years':
					this.minViewMode = 2;
					break;
				default:
					this.minViewMode = 0;
					break;
			}
		}
		this.viewMode = options.viewMode || this.element.data('date-viewmode') || 0;
		if (typeof this.viewMode === 'string') {
			switch (this.viewMode) {
				case 'months':
					this.viewMode = 1;
					break;
				case 'years':
					this.viewMode = 2;
					break;
				default:
					this.viewMode = 0;
					break;
			}
		}
		this.startViewMode = this.viewMode;
		this.weekStart = options.weekStart || this.element.data('date-weekstart') || 0;
		this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
		this.fillDow();
		this.fillMonths();
		this.update();
		this.showMode();
	};

	Datepicker.prototype = {
		constructor: Datepicker,

		show: function(e) {
			this.picker.show();
			this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
			this.place();
			$(window).on('resize', $.proxy(this.place, this));
			if (e) {
				e.stopPropagation();
				e.preventDefault();
			}
			if (!this.isInput) {
				$(document).on('mousedown', $.proxy(this.hide, this));
			}
			this.element.trigger({
				type: 'show',
				date: this.date
			});
		},

		hide: function() {
			this.picker.hide();
			$(window).off('resize', this.place);
			this.viewMode = this.startViewMode;
			this.showMode();
			if (!this.isInput) {
				$(document).off('mousedown', this.hide);
			}
			this.set();
			this.element.trigger({
				type: 'hide',
				date: this.date
			});
		},

		remove: function() {
			this.picker.remove();
		},

		//value is set by clicking, on hide, or external setting
		set: function() {
			this.element.trigger({
				type: 'changeDate',
				date: this.date ? this.date.getTime() : null
			});
			return;
		},

		//a public function to programatically update the selected date
		setValue: function(newDate) {
			if (!newDate) {
				this.date = null;
			} else if (typeof newDate === 'string') {
				this.date = DPGlobal.parseDate(newDate);
			} else {
				this.date = new Date(newDate * 1000);
			}
			this.set();

			if (newDate && this.date) {
				this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
			} else {
				this.viewDate = null;
			}
			this.fill();
		},

		//place the popup in the proper place on the screen
		place: function() {
			var offset = this.component ? this.component.offset() : this.element.offset();
			this.picker.css({
				top: offset.top + this.height,
				left: offset.left
			});

			//flip up top if off bottom of page
			var windowH = $(window).height();
			var scroll = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
			var pickerHeight = this.picker[0].offsetTop + this.picker[0].offsetHeight;

			if (pickerHeight - scroll > windowH) {
				this.picker.css({
					top: offset.top - this.picker[0].offsetHeight - 5,
					left: offset.left
				}).addClass("flipped");
			}
		},
<commit_msg>Issue #53: small fix<commit_after>/* =========================================================
	Modifications made by https://github.com/Toodledo/ADE

	1) Added comments so I could better understand the code
	2) Better handling for case where no date is preset
	3) Allows canceling of the calendar without setting a date
	4) Enabled full text parsing of unrecognized dates via an external date.js library.
		So you can type "next week" and it should work
	5) Got rid of date formatting and allowed caller to take care of this
	6) Method for destroying the calendar DOM object
	7) Remove unnecessary changeDate events
 * ========================================================= */


/* =========================================================
 * bootstrap-datepicker.js
 * http://www.eyecon.ro/bootstrap-datepicker
 * =========================================================
 * Copyright 2012 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ========================================================= */

!function($) {

	//Initialization
	var Datepicker = function(element, options) {
		this.element = $(element);
		this.picker = $(DPGlobal.template)
							.appendTo('body')
							.on({
								click: $.proxy(this.click, this),
								mousedown: $.proxy(this.mousedown, this)
							});
		this.isInput = this.element.is('input');
		this.component = this.element.is('.date') ? this.element.find('.add-on') : false;

		if (this.isInput) {
			this.element.on({
				focus: $.proxy(this.show, this),
				blur: $.proxy(this.hide, this),
				keyup: $.proxy(this.update, this)
			});
		} else {
			if (this.component) {
				this.component.on('click', $.proxy(this.show, this));
			} else {
				this.element.on('click', $.proxy(this.show, this));
			}
		}
		this.minViewMode = options.minViewMode || this.element.data('date-minviewmode') || 0;
		if (typeof this.minViewMode === 'string') {
			switch (this.minViewMode) {
				case 'months':
					this.minViewMode = 1;
					break;
				case 'years':
					this.minViewMode = 2;
					break;
				default:
					this.minViewMode = 0;
					break;
			}
		}
		this.viewMode = options.viewMode || this.element.data('date-viewmode') || 0;
		if (typeof this.viewMode === 'string') {
			switch (this.viewMode) {
				case 'months':
					this.viewMode = 1;
					break;
				case 'years':
					this.viewMode = 2;
					break;
				default:
					this.viewMode = 0;
					break;
			}
		}
		this.startViewMode = this.viewMode;
		this.weekStart = options.weekStart || this.element.data('date-weekstart') || 0;
		this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
		this.fillDow();
		this.fillMonths();
		this.update();
		this.showMode();
	};

	Datepicker.prototype = {
		constructor: Datepicker,

		show: function(e) {
			this.picker.show();
			this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
			this.place();
			$(window).on('resize', $.proxy(this.place, this));
			if (e) {
				e.stopPropagation();
				e.preventDefault();
			}
			if (!this.isInput) {
				$(document).on('mousedown', $.proxy(this.hide, this));
			}
			this.element.trigger({
				type: 'show',
				date: this.date
			});
		},

		hide: function() {
			this.picker.hide();
			$(window).off('resize', this.place);
			this.viewMode = this.startViewMode;
			this.showMode();
			if (!this.isInput) {
				$(document).off('mousedown', this.hide);
			}
			this.set();
			this.element.trigger({
				type: 'hide',
				date: this.date
			});
		},

		remove: function() {
			this.picker.remove();
		},

		//value is set by clicking, on hide, or external setting
		set: function() {
			this.element.trigger({
				type: 'changeDate',
				date: this.date ? this.date.getTime() : null
			});
			return;
		},

		//a public function to programatically update the selected date
		setValue: function(newDate) {
			if (!newDate) {
				this.date = null;
			} else if (typeof newDate === 'string') {
				this.date = DPGlobal.parseDate(newDate);
			} else {
				this.date = new Date(newDate * 1000);
			}
			this.set();

			if (newDate && this.date) {
				this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
			} else {
				this.viewDate = null;
			}
			this.fill();
		},

		//place the popup in the proper place on the screen
		place: function() {
			var offset = this.component ? this.component.offset() : this.element.offset();
			this.picker.css({
				top: offset.top + this.height,
				left: offset.left
			});

			//flip up top if off bottom of page
			var windowH = $(window).height();
			var scroll = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
			var pickerHeight = this.picker[0].offsetTop + this.picker[0].offsetHeight;

			if (pickerHeight - scroll > windowH) {
				this.picker.css({
					top: offset.top - this.picker[0].offsetHeight - 5,
					left: offset.left
				}).addClass("flipped");
			} else {
        this.picker.removeClass("flipped");
      }
		},

{'fraction_non_alphanumeric': 0.191047235444892, 'fraction_numerical': 0.007506407909190773, 'mean_word_length': 3.2116422513492675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '3375271', 'n_tokens_mistral': 4088, 'n_tokens_neox': 3321, 'n_words': 897}