# j-DatePicker

> Il componente deve essere chiamato manualmente o funziona automaticamente con il componente j-Input.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: it
Content-SHA256: a28d81c8570fb252a913c58ae4378ef1bd04eacae1b486f0221ef6549b4d275a
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- è un clone migliorato di `j-Calendar`
- Sviluppo - Modo oscuro
- supporta i gesti __touch (swipe)__ e la dimensione completa fissa sul cellulare

__Configurazione__:

- `firstday {Number}` il primo giorno della settimana (default: `DEF.firstdayofweek`)
- `today {String}` un'etichetta per il pulsante `Set today`
- `clear {String}` un'etichetta per il pulsante `Clear`
- `days {String}` giorni, ad esempio `SU,MO,TU,WE,TH,FR,SA` (default)
- `months {String}` mesi, ad esempio `January,February,...` (default)

Il componente deve essere chiamato manualmente o funziona automaticamente con il componente `j-Input`.

- __importante__ aggiungere il componente del calendario sotto l'elemento `<body>`

## Utilizzo

```javascript
var opt = {};
opt.element = YOUR_ELEMENT;
opt.value = new Date();
// or opt.value = 'path.to.date'; --> then "opt.callback" is disabled
// opt.align {String}      : align "left" (default), "center" or "right"
// opt.position {String}   : position "top" (default) or "bottom"
// NEW: opt.clock {Boolean} : enables time (default: false)
// NEW: opt.ampm {Boolean} : enables AM/PM (default: false)

opt.clear = false; // Removes "clear" button from datepicker. If this property is not specified as "false" - "clear" button will be shown

opt.callback = function(newdate) {
	console.log('date has been changed');
};
// IMPORTANT - opt.callback() can receive "null" value as a parameter, so this check should be taken into consideration when callback function is being created.

// opt.offsetX {Number} "x" offset
// opt.offsetY {Number} "y" offset
// opt.close {Function} optional, this function can determine closing of DatePicker

// NEW and OPTIONAL
// It's callend when the DatePicker changes year/month
opt.badges = function(date, append) {
	// Appends small and red badges to the current view/month
	append([date1, date2, date3]);
};

SETTER('datepicker/show', opt);
```

Utilizzare con `<ui-component name="datepicker">`Quando il componente non è ancora caricato, jComponent Scarica il codice in prima utilizzazione dall'indirizzo `DEF.fallback` (Il Componentator La storia di Peter Širka.Fonte: il Componentator Ristorante dei componenti, licenza MIT.

```html example.html
<a href="#datepicker">SHOW DATEPICKER: <b><ui-bind path="form.date" config="html:value?value.format('dd.MM.yyyy'):DEF.empty"></ui-bind></b></a>
<ui-component name="datepicker" config="today:Set today;firstday:0"></ui-component>

<script>
	var form = {};
	form.date = new Date();

	$('a[href="#datepicker"]').on('click', function(e) {
		var opt = {};
		opt.value = 'form.date';
		opt.element = this;

		// Append badges
		opt.badges = function(date, append) {
			setTimeout(function() {
				append([date.add('-5 days'), date.add('-2 days'), date.add('3 days'), date.add('8 days')])
			}, 1000);
		};

		SETTER('datepicker/show', opt);
	});
</script>
```
