# j-MonthlyCalendar

> Month and day names are taken from MONTHS and DAYS properties defined in jComponent library.

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

- supports only monthly view

__Configuration__:

- `parent {String}` a jQuery selector for obtaining of fixed height (default `auto`)
- `firstday {Number}` first day in the calendar `0 = Sunday`, default `0`
- `noborder {Boolean}` disables border (default: `false`)
- `selectable {Boolean}` enables selecting of days (default: `true`)
- `morebutton {String}` a Tangular template for __More button__ (default: `+{{ count }} more`)
- `select {String}` a path to `Function(item_event, el, e)`, be careful: `item_event` can be `null`
- `create {String}` a path to `Function({ beg: Date, end: Date }, beg_element, end_element)`
- `dblclick {String}` a path to `Function(item_event, el, e)`
- `dblclickdate {String}` a path to `Function(date, el, e)`
- `contextmenu {String}` a path to `Function(item_event, el, e)`
- `rebind {String}` a path to `Function({ dates: Array, date: Date })` is executed when the calendar is rebinded
- `topoffset {Boolean}` subtracts `offset.top` from `height` (default: `false`)
- `topposition {Boolean}` subtracts `position.top` from `height` (default: `false`)
- `margin {Number}` top/bottom margin together (default: `0`)
- `marginxs {Number}` top/bottom margin together for `xs` screen width
- `marginsm {Number}` top/bottom margin together for `sm` screen width
- `marginmd {Number}` top/bottom margin together for `md` screen width
- `marginlg {Number}` top/bottom margin together for `lg` screen width
- __NEW__: `keepselected {Boolean}` keeps selected (hovered) days (default: `false`)
- __NEW__: `hover {String}` a path to `Function({ beg: Date, end: Date }, beg_element, end_element)` (same like `create`, but it's called on `component.hover()` and `component.unhover()` methods)
- __NEW__: `scalewidth {Boolean}` scales the height according to the width of the parent element

__Methods__:

- `component.addevents(events)` adds events
	- `events` means Array of object below:
	- `[{ id: String, beg: Date, end: Date, html: String, icon: String, color: String, background: Boolean }]`
- `component.addevent(event)` adds an event
	- can't be combined with `addevents` method
	- can be executed multiple times
	- event object: `{ id: String, html: String, icon: String, color: String, background: Boolean }`
- __NEW__: `component.addbadge(date, [color])` adds a badge
- __NEW__: `component.hover(beg, end)`
- __NEW__: `component.unhover()`
- `component.clear()` removes all events and badges

__Localization__:

Month and day names are taken from `MONTHS` and `DAYS` properties defined in jComponent library.

Use it with `<ui-component name="monthlycalendar">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<style>
	body{margin:0;padding:0;overflow:hidden;}
</style>

<ui-component name="monthlycalendar" path="common.date" config="parent:auto;noborder:1;firstday:1"></ui-component>

<script>
	var common = { date: NOW };

	(function() {
		var events = [];
		events.push({ id: 'a', beg: NOW.add('-10 days'), end: NOW.add('2 days'), html: 'Big event', color: 'orange' });
		events.push({ id: 'b', beg: NOW, html: 'Current', icon: 'ti ti-car', color: 'blue' });
		SETTER(true, 'monthlycalendar/addevents', events);
	})();

</script>
```
