<commit_before>/**
 * @class  UIFactory.DatePicker
 * @author  <NAME> <<EMAIL>>
 *
 * Show a DatePicker dialog for iOS + Android.
 *
 * ### Arguments
 *
 * #### `callback(value: Date) (Function)`
 *
 * The callback to invoke when user clicks Done.
 *
 * #### `cancel() (Function)`
 *
 * The callback to invoke when user clicks Cancel.
 *
 * #### `autoClose (Boolean)`
 *
 * If `true`, close the window when users clicks Done.
 * Otherwise, use `.close()`. in your callback.
 *
 */

module.exports = function(args) {
	args = args || {};

	var $this = Ti.UI.createWindow({
		backgroundColor: 'transparent'
	});

	var $view = Ti.UI.createView({
		height: 216+50,
		bottom: 0,
		transform: Ti.UI.create2DMatrix().translate(0, 216+50)
	});

	/*
	Build picker
	*/

	$this.$picker = Ti.UI.createPicker(_.extend({
		type: Ti.UI.PICKER_TYPE_DATE,
		minDate: new Date(1990,1,1),
		maxDate: new Date(2020,1,1),
		value: new Date(),
		bottom: 0,
		height: 216
	}, _.pick(args, 'minDate', 'maxDate', 'value')));
	$view.add($this.$picker);


	/*
	Build toolbar
	*/

	var $doneBtn = Ti.UI.createButton({
		title: L('Done'),
		style: Ti.UI.iPhone.SystemButtonStyle.DONE
	});
	$doneBtn.addEventListener('click', function() {
		if (args.autoClose === true) $this.close();
		if (_.isFunction(args.callback)) args.callback($this.$picker.value);
	});

	var $cancelBtn = Ti.UI.createButton({
		systemButton: Ti.UI.iPhone.SystemButton.CANCEL
	});
	$cancelBtn.addEventListener('click', function(e){
		$this.close();
		if (_.isFunction(args.cancel)) args.cancel();
	});

	$view.add(Ti.UI.iOS.createToolbar({
		items: [
			$cancelBtn,
			Ti.UI.createButton({ systemButton:Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE }),
			$doneBtn
		],
		bottom: 216,
		borderTop: true,
		borderBottom: false
	}));


	/*
	Override open/close
	*/

	$this.add($view);
	$this.addEventListener('open', function(e){
		$view.animate({
			transform: Ti.UI.create2DMatrix()
		});
	});

	return $this;
};
<commit_msg>Datepicker fixes for current value<commit_after>/**
 * @class  UIFactory.DatePicker
 * @author  <NAME> <<EMAIL>>
 *
 * Show a DatePicker dialog for iOS + Android.
 *
 * ### Arguments
 *
 * #### `callback(value: Date) (Function)`
 *
 * The callback to invoke when user clicks Done.
 *
 * #### `cancel() (Function)`
 *
 * The callback to invoke when user clicks Cancel.
 *
 * #### `autoClose (Boolean)`
 *
 * If `true`, close the window when users clicks Done.
 * Otherwise, use `.close()`. in your callback.
 *
 */

module.exports = function(args) {
	args = args || {};

	var $this = Ti.UI.createWindow({
		backgroundColor: 'transparent'
	});

	var $view = Ti.UI.createView({
		height: 216+50,
		bottom: 0,
		transform: Ti.UI.create2DMatrix().translate(0, 216+50)
	});

	/*
	Build picker
	*/

	$this.$picker = Ti.UI.createPicker(_.extend({
		type: Ti.UI.PICKER_TYPE_DATE,
		minDate: new Date(1990,1,1),
		maxDate: new Date(2020,1,1),
		bottom: 0,
		useSpinner: true,
		height: 216
	}, _.pick(args, 'minDate', 'maxDate', 'value')));

	$this.$picker.addEventListener('change', function(e){
		$this.value = e.value;
	});
	$view.add($this.$picker);

	/*
	Build toolbar
	*/

	var $doneBtn = Ti.UI.createButton({
		title: L('Done'),
		style: Ti.UI.iPhone.SystemButtonStyle.DONE
	});
	$doneBtn.addEventListener('click', function() {
		if (args.autoClose === true) $this.close();
		if (_.isFunction(args.callback)) args.callback($this.value);
	});

	var $cancelBtn = Ti.UI.createButton({
		systemButton: Ti.UI.iPhone.SystemButton.CANCEL
	});
	$cancelBtn.addEventListener('click', function(e){
		$this.close();
		if (_.isFunction(args.cancel)) args.cancel();
	});

	$view.add(Ti.UI.iOS.createToolbar({
		items: [
			$cancelBtn,
			Ti.UI.createButton({ systemButton:Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE }),
			$doneBtn
		],
		bottom: 216,
		borderTop: true,
		borderBottom: false
	}));


	/*
	Override open/close
	*/

	$this.add($view);
	$this.addEventListener('open', function(e){
		$view.animate({
			transform: Ti.UI.create2DMatrix()
		});
	});

	return $this;
};

{'fraction_non_alphanumeric': 0.1881680338056177, 'fraction_numerical': 0.01640566741237882, 'mean_word_length': 3.854041013268999, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5968158', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1451, 'n_words': 299}