All files / dist js-year-calendar.js

88.06% Statements 693/787
71.5% Branches 429/600
90.24% Functions 111/123
88.79% Lines 665/749

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 20126x 6x   6x 6x                     6x     6x   6x   64x   414x   6x   972x                                         6x                     6x         6x                                   6x                                                                                                                                                                                         64x   64x   64x   64x   64x   64x   64x   64x   64x   64x   64x   64x   64x   64x   64x   64x   64x   64x 3x 61x 60x   1x     63x   63x   63x   63x     6x     63x 11x     63x                                                 63x 60x   60x           63x 11x     63x 1x     63x 1x     63x 1x     63x 1x     63x 1x     63x 1x     63x 1x           7x 7x   7x   2x     5x   5x 3x   2x                   69x 34x 32x                     129x     129x 177x     129x 127x     129x 7x   122x   122x   122x     122x 122x 122x 122x 122x 36x 36x 8x       122x               205x 205x 205x 205x 205x   205x 4x     205x 205x 205x 205x 205x 205x 205x 205x   205x 6x     205x 205x 205x 205x 205x   205x 4x     205x 205x 205x 205x 205x 205x 205x 205x 205x   205x 7x     205x 205x 205x 205x 205x   205x 9x     205x 205x 205x   205x 7x     205x 205x 205x 205x 205x 205x         122x 122x   122x   1464x 1464x 1464x   1464x       1464x 1464x 1464x     1464x 1464x 1464x 1464x 1464x 1464x 1464x 1464x 1464x   1464x 36x 36x 36x 36x     1464x 1464x   1464x 10248x 10248x 10248x   10248x 84x     10248x 10248x 10248x     1464x 1464x     1464x 1464x   1464x 4310x     1464x 7582x   7582x 186x 186x   186x 186x 186x 186x     7582x 53074x 53074x   53074x 434x     53074x 4310x 48764x 4129x   44635x 2032x     44635x 44635x 44635x 44635x   44635x 732x       53074x 53074x     7582x     1464x 1464x     122x         7x 7x 7x 7x 7x   7x             7x 7x   7x 21x 21x 21x     7x     7x 7x         122x   122x 25x 300x 300x 300x   300x 300x   300x 456x 263x       300x 178x 5452x 5452x 5452x   5452x 5452x 8053x 272x       5452x 265x                       265x   265x   222x   222x 218x 4x 4x         222x 222x   222x 228x 6x     228x     222x     222x     43x 43x   43x 4x   4x                         4x 1x   39x 4x   4x                         4x 1x       43x                         122x   122x   120x 480x 4x 4x       120x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x         120x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x             122x 122x   42603x 2x   2x   2x               42603x 5x 2x   2x 2x       5x   5x               42603x 2196x 4x 4x   4x 4x 4x   4x       2196x 4x 4x   4x 1x   1x 1x   1x 4x 1x     3x 3x                             1x     4x 4x   4x 4x               42603x 7x 3x   3x             42603x 2x   2x               122x   6x 1x 1x   1x   1x 1x   1x                     122x 59x 59x     122x 29x       29x 29x 29x   29x   29x   29x   29x     29x     29x 348x 228x 1140x   228x               9x   9x 45x   9x 5x   9x 5x     9x 8x 8x 8x 96x   96x 9x 277x   277x 67x   67x 8x     67x 8x                     1x 1x   1x 1x 1x 1x     1x               2x   2x   2x 1x   1x       1x 1x 1x     2x   2x   2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x   1x     2x 1x   1x 1x 1x 1x   1x           1x       1x                 1x 1x 1x           2x 2x   2x 3x       3x 3x 3x 3x 3x 3x 3x 3x   3x                 3x   3x 1x 1x 1x 1x   1x     3x     2x 2x                                                           299x 299x 299x 299x         214x   214x 214x           214x   214x 319x     214x 214x         44890x 1661x     43229x 1098x 2301x 365x         42864x 1841x 2938x 7x         42857x         63322x 1554x 3256x 518x         62804x                       188x 188x   188x   188x   188x                     24x                       30x   30x 30x 54x 21x         30x                           6x   6x 6x   6x       6x 5x 1x     1x                   9x                     80x   80x   80x 79x   79x 32x     79x 78x     79x         79x 6x   6x 6x   6x   6x     73x 73x                       3x                           2x   2x 2x   2x 2x                     3x                           2x   2x 2x   2x 2x                     4x                           3x 3x   3x 3x                   3x                     2x                 3x                           2x 2x   2x 2x                   3x                           2x 2x   2x 2x                   3x                           3x 3x   3x 3x                   3x                           2x 2x   2x 2x                   3x                           2x 2x   2x 2x                   3x                           2x 2x   2x 2x                   3x                           2x 2x   2x 2x                   3x                           2x 2x   2x 2x                   3x                           2x 2x   2x 2x                   3x                           3x 3x   3x 3x                   3x                           2x 2x   2x 2x                   3x                           2x 2x   2x 2x                   3x                           2x 2x   2x 2x                   3x                           3x   3x 2x   2x 2x                     5x                           3x   3x 3x   3x 1x   1x 1x   1x   1x     2x   2x   2x 2x                     4x                           2x 2x   2x 2x                   3x                     2x                             1x   1x   1x 1x         6x     6x   6x                       6x   6x 6x 6x 1x 1x        
(function (global, factory) {
  Iif (typeof define === "function" && define.amd) {
    define(["exports"], factory);
  } else Eif (typeof exports !== "undefined") {
    factory(exports);
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports);
    global.jsYearCalendar = mod.exports;
  }
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
  "use strict";
 
  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports["default"] = void 0;
 
  function _typeof(obj) { "@babel/helpers - typeof"; Eif (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
 
  function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
 
  function _createClass(Constructor, protoProps, staticProps) { Eif (protoProps) _defineProperties(Constructor.prototype, protoProps); Iif (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
 
  function _defineProperty(obj, key, value) { Iif (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
 
  /* =========================================================
   * JS year calendar v1.0.0
   * Repo: https://github.com/year-calendar/js-year-calendar
   * =========================================================
   * Created by Paul David-Sivelle
   *
   * 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.
   * ========================================================= */
  // NodeList forEach() polyfill
  Iif (typeof NodeList !== "undefined" && !NodeList.prototype.forEach) {
    NodeList.prototype.forEach = function (callback, thisArg) {
      thisArg = thisArg || window;
 
      for (var i = 0; i < this.length; i++) {
        callback.call(thisArg, this[i], i, this);
      }
    };
  } // Element closest() polyfill
 
 
  Iif (typeof Element !== "undefined" && !Element.prototype.matches) {
    var prototype = Element.prototype;
    Element.prototype.matches = prototype.msMatchesSelector || prototype.webkitMatchesSelector;
  }
 
  Iif (typeof Element !== "undefined" && !Element.prototype.closest) {
    Element.prototype.closest = function (s) {
      var el = this;
      if (!document.documentElement.contains(el)) return null;
 
      do {
        if (el.matches(s)) return el;
        el = el.parentElement || el.parentNode;
      } while (el !== null && el.nodeType == 1);
 
      return null;
    };
  }
  /**
   * Calendar instance.
   */
 
 
  var Calendar = /*#__PURE__*/function () {
    /**
     * Fired when a day is clicked.
     * @event
     * @example
     * ```
     * 
     * document.querySelector('.calendar').addEventListener('clickDay', function(e) {
     *   console.log("Click on day: " + e.date + " (" + e.events.length + " events)");
     * })
     * ```
     */
 
    /**
     * Fired when a day is right clicked.
     * @event
     * @example
     * ```
     * 
     * document.querySelector('.calendar').addEventListener('clickDay', function(e) {
     *   console.log("Right click on day: " + e.date + " (" + e.events.length + " events)");
     * })
     * ```
     */
 
    /**
     * Fired when the mouse enter in a day.
     * @event
     * @example
     * ```
     * 
     * document.querySelector('.calendar').addEventListener('mouseOnDay', function(e) {
     *   console.log("Mouse enter in a day: " + e.date + " (" + e.events.length + " events)");
     * })
     * ```
     */
 
    /**
     * Fired when the mouse leave a day.
     * @event
     * @example
     * ```
     * 
     * document.querySelector('.calendar').addEventListener('mouseOutDay', function(e) {
     *   console.log("Mouse leave a day: " + e.date + " (" + e.events.length + " events)");
     * })
     * ```
     */
 
    /**
     * Fired when the calendar rendering is ended.
     * @event
     * @example
     * ```
     * 
     * document.querySelector('.calendar').addEventListener('renderEnd', function(e) {
     *   console.log("Render end for year: " + e.currentYear);
     * })
     * ```
     */
 
    /**
     * Fired when a date range is selected.
     * 
     * Don't forget to enable the `enableRangeSelection` option to be able to use the range selection functionality.
     * @event
     * @example
     * ```
     * 
     * document.querySelector('.calendar').addEventListener('selectRange', function(e) {
     *   console.log("Select the range: " + e.startDate + " - " + e.endDate);
     * })
     * ```
     */
 
    /**
     * Triggered after the changing the current year.
     * @event
     * @example
     * ```
     * 
     * document.querySelector('.calendar').addEventListener('yearChanged', function(e) {
     *   console.log("New year selected: " + e.currentYear);
     * })
     * ```
     */
 
    /**
     * Create a new calendar.
     * @param element The element (or the selector to an element) in which the calendar should be created.
     * @param options [Optional] The options used to customize the calendar
     */
    function Calendar(element) {
      var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
 
      _classCallCheck(this, Calendar);
 
      _defineProperty(this, "element", void 0);
 
      _defineProperty(this, "options", void 0);
 
      _defineProperty(this, "_dataSource", void 0);
 
      _defineProperty(this, "_mouseDown", void 0);
 
      _defineProperty(this, "_rangeStart", void 0);
 
      _defineProperty(this, "_rangeEnd", void 0);
 
      _defineProperty(this, "_responsiveInterval", void 0);
 
      _defineProperty(this, "_nbCols", void 0);
 
      _defineProperty(this, "clickDay", void 0);
 
      _defineProperty(this, "dayContextMenu", void 0);
 
      _defineProperty(this, "mouseOnDay", void 0);
 
      _defineProperty(this, "mouseOutDay", void 0);
 
      _defineProperty(this, "renderEnd", void 0);
 
      _defineProperty(this, "selectRange", void 0);
 
      _defineProperty(this, "yearChanged", void 0);
 
      if (element instanceof HTMLElement) {
        this.element = element;
      } else if (typeof element === "string") {
        this.element = document.querySelector(element);
      } else {
        throw new Error("The element parameter should be a DOM node or a selector");
      }
 
      this.element.classList.add('calendar');
 
      this._initializeEvents(options);
 
      this._initializeOptions(options);
 
      this.setYear(this.options.startYear);
    }
 
    _createClass(Calendar, [{
      key: "_initializeOptions",
      value: function _initializeOptions(opt) {
        if (opt == null) {
          opt = {};
        }
 
        this.options = {
          startYear: !isNaN(parseInt(opt.startYear)) ? parseInt(opt.startYear) : new Date().getFullYear(),
          minDate: opt.minDate instanceof Date ? opt.minDate : null,
          maxDate: opt.maxDate instanceof Date ? opt.maxDate : null,
          language: opt.language != null && Calendar.locales[opt.language] != null ? opt.language : 'en',
          allowOverlap: opt.allowOverlap != null ? opt.allowOverlap : true,
          displayWeekNumber: opt.displayWeekNumber != null ? opt.displayWeekNumber : false,
          displayDisabledDataSource: opt.displayDisabledDataSource != null ? opt.displayDisabledDataSource : false,
          displayHeader: opt.displayHeader != null ? opt.displayHeader : true,
          alwaysHalfDay: opt.alwaysHalfDay != null ? opt.alwaysHalfDay : false,
          enableRangeSelection: opt.enableRangeSelection != null ? opt.enableRangeSelection : false,
          disabledDays: opt.disabledDays instanceof Array ? opt.disabledDays : [],
          disabledWeekDays: opt.disabledWeekDays instanceof Array ? opt.disabledWeekDays : [],
          hiddenWeekDays: opt.hiddenWeekDays instanceof Array ? opt.hiddenWeekDays : [],
          roundRangeLimits: opt.roundRangeLimits != null ? opt.roundRangeLimits : false,
          dataSource: opt.dataSource instanceof Array || typeof opt.dataSource === "function" ? opt.dataSource : [],
          style: opt.style == 'background' || opt.style == 'border' || opt.style == 'custom' ? opt.style : 'border',
          enableContextMenu: opt.enableContextMenu != null ? opt.enableContextMenu : false,
          contextMenuItems: opt.contextMenuItems instanceof Array ? opt.contextMenuItems : [],
          customDayRenderer: typeof opt.customDayRenderer === "function" ? opt.customDayRenderer : null,
          customDataSourceRenderer: typeof opt.customDataSourceRenderer === "function" ? opt.customDataSourceRenderer : null,
          weekStart: !isNaN(parseInt(opt.weekStart)) ? parseInt(opt.weekStart) : null,
          loadingTemplate: typeof opt.loadingTemplate === "string" || opt.loadingTemplate instanceof HTMLElement ? opt.loadingTemplate : null
        };
 
        if (this.options.dataSource instanceof Array) {
          this._dataSource = this.options.dataSource;
 
          this._initializeDatasourceColors();
        }
      }
    }, {
      key: "_initializeEvents",
      value: function _initializeEvents(opt) {
        if (opt == null) {
          opt = [];
        }
 
        if (opt.yearChanged) {
          this.element.addEventListener('yearChanged', opt.yearChanged);
        }
 
        if (opt.renderEnd) {
          this.element.addEventListener('renderEnd', opt.renderEnd);
        }
 
        if (opt.clickDay) {
          this.element.addEventListener('clickDay', opt.clickDay);
        }
 
        if (opt.dayContextMenu) {
          this.element.addEventListener('dayContextMenu', opt.dayContextMenu);
        }
 
        if (opt.selectRange) {
          this.element.addEventListener('selectRange', opt.selectRange);
        }
 
        if (opt.mouseOnDay) {
          this.element.addEventListener('mouseOnDay', opt.mouseOnDay);
        }
 
        if (opt.mouseOutDay) {
          this.element.addEventListener('mouseOutDay', opt.mouseOutDay);
        }
      }
    }, {
      key: "_fetchDataSource",
      value: function _fetchDataSource(callback) {
        Eif (typeof this.options.dataSource === "function") {
          var getDataSource = this.options.dataSource;
 
          if (getDataSource.length == 2) {
            // 2 parameters, means callback method
            getDataSource(this.options.startYear, callback);
          } else {
            // 1 parameter, means synchronous or promise method
            var result = getDataSource(this.options.startYear);
 
            if (result instanceof Array) {
              callback(result);
            } else {
              result.then(callback);
            }
          }
        } else {
          callback(this.options.dataSource);
        }
      }
    }, {
      key: "_initializeDatasourceColors",
      value: function _initializeDatasourceColors() {
        for (var i = 0; i < this._dataSource.length; i++) {
          if (this._dataSource[i].color == null) {
            this._dataSource[i].color = Calendar.colors[i % Calendar.colors.length];
          }
        }
      }
      /**
          * Renders the calendar.
          */
 
    }, {
      key: "render",
      value: function render() {
        var isLoading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
 
        // Clear the calendar (faster method)
        while (this.element.firstChild) {
          this.element.removeChild(this.element.firstChild);
        }
 
        if (this.options.displayHeader) {
          this._renderHeader();
        }
 
        if (isLoading) {
          this._renderLoading();
        } else {
          this._renderBody();
 
          this._renderDataSource();
 
          this._applyEvents(); // Fade animation
 
 
          var months = this.element.querySelector('.months-container');
          months.style.opacity = '0';
          months.style.display = 'block';
          months.style.transition = 'opacity 0.5s';
          setTimeout(function () {
            months.style.opacity = '1';
            setTimeout(function () {
              return months.style.transition = '';
            }, 500);
          }, 0);
 
          this._triggerEvent('renderEnd', {
            currentYear: this.options.startYear
          });
        }
      }
    }, {
      key: "_renderHeader",
      value: function _renderHeader() {
        var header = document.createElement('div');
        header.classList.add('calendar-header');
        var headerTable = document.createElement('table');
        var prevDiv = document.createElement('th');
        prevDiv.classList.add('prev');
 
        if (this.options.minDate != null && this.options.minDate > new Date(this.options.startYear - 1, 11, 31)) {
          prevDiv.classList.add('disabled');
        }
 
        var prevIcon = document.createElement('span');
        prevIcon.innerHTML = "&lsaquo;";
        prevDiv.appendChild(prevIcon);
        headerTable.appendChild(prevDiv);
        var prev2YearDiv = document.createElement('th');
        prev2YearDiv.classList.add('year-title');
        prev2YearDiv.classList.add('year-neighbor2');
        prev2YearDiv.textContent = (this.options.startYear - 2).toString();
 
        if (this.options.minDate != null && this.options.minDate > new Date(this.options.startYear - 2, 11, 31)) {
          prev2YearDiv.classList.add('disabled');
        }
 
        headerTable.appendChild(prev2YearDiv);
        var prevYearDiv = document.createElement('th');
        prevYearDiv.classList.add('year-title');
        prevYearDiv.classList.add('year-neighbor');
        prevYearDiv.textContent = (this.options.startYear - 1).toString();
 
        if (this.options.minDate != null && this.options.minDate > new Date(this.options.startYear - 1, 11, 31)) {
          prevYearDiv.classList.add('disabled');
        }
 
        headerTable.appendChild(prevYearDiv);
        var yearDiv = document.createElement('th');
        yearDiv.classList.add('year-title');
        yearDiv.textContent = this.options.startYear.toString();
        headerTable.appendChild(yearDiv);
        var nextYearDiv = document.createElement('th');
        nextYearDiv.classList.add('year-title');
        nextYearDiv.classList.add('year-neighbor');
        nextYearDiv.textContent = (this.options.startYear + 1).toString();
 
        if (this.options.maxDate != null && this.options.maxDate < new Date(this.options.startYear + 1, 0, 1)) {
          nextYearDiv.classList.add('disabled');
        }
 
        headerTable.appendChild(nextYearDiv);
        var next2YearDiv = document.createElement('th');
        next2YearDiv.classList.add('year-title');
        next2YearDiv.classList.add('year-neighbor2');
        next2YearDiv.textContent = (this.options.startYear + 2).toString();
 
        if (this.options.maxDate != null && this.options.maxDate < new Date(this.options.startYear + 2, 0, 1)) {
          next2YearDiv.classList.add('disabled');
        }
 
        headerTable.appendChild(next2YearDiv);
        var nextDiv = document.createElement('th');
        nextDiv.classList.add('next');
 
        if (this.options.maxDate != null && this.options.maxDate < new Date(this.options.startYear + 1, 0, 1)) {
          nextDiv.classList.add('disabled');
        }
 
        var nextIcon = document.createElement('span');
        nextIcon.innerHTML = "&rsaquo;";
        nextDiv.appendChild(nextIcon);
        headerTable.appendChild(nextDiv);
        header.appendChild(headerTable);
        this.element.appendChild(header);
      }
    }, {
      key: "_renderBody",
      value: function _renderBody() {
        var monthsDiv = document.createElement('div');
        monthsDiv.classList.add('months-container');
 
        for (var m = 0; m < 12; m++) {
          /* Container */
          var monthDiv = document.createElement('div');
          monthDiv.classList.add('month-container');
          monthDiv.dataset.monthId = m.toString();
 
          Iif (this._nbCols) {
            monthDiv.classList.add("month-".concat(this._nbCols));
          }
 
          var firstDate = new Date(this.options.startYear, m, 1);
          var table = document.createElement('table');
          table.classList.add('month');
          /* Month header */
 
          var thead = document.createElement('thead');
          var titleRow = document.createElement('tr');
          var titleCell = document.createElement('th');
          titleCell.classList.add('month-title');
          titleCell.setAttribute('colspan', this.options.displayWeekNumber ? '8' : '7');
          titleCell.textContent = Calendar.locales[this.options.language].months[m];
          titleRow.appendChild(titleCell);
          thead.appendChild(titleRow);
          var headerRow = document.createElement('tr');
 
          if (this.options.displayWeekNumber) {
            var weekNumberCell = document.createElement('th');
            weekNumberCell.classList.add('week-number');
            weekNumberCell.textContent = Calendar.locales[this.options.language].weekShort;
            headerRow.appendChild(weekNumberCell);
          }
 
          var weekStart = this.options.weekStart ? this.options.weekStart : Calendar.locales[this.options.language].weekStart;
          var d = weekStart;
 
          do {
            var headerCell = document.createElement('th');
            headerCell.classList.add('day-header');
            headerCell.textContent = Calendar.locales[this.options.language].daysMin[d];
 
            if (this._isHidden(d)) {
              headerCell.classList.add('hidden');
            }
 
            headerRow.appendChild(headerCell);
            d++;
            if (d >= 7) d = 0;
          } while (d != weekStart);
 
          thead.appendChild(headerRow);
          table.appendChild(thead);
          /* Days */
 
          var currentDate = new Date(firstDate.getTime());
          var lastDate = new Date(this.options.startYear, m + 1, 0);
 
          while (currentDate.getDay() != weekStart) {
            currentDate.setDate(currentDate.getDate() - 1);
          }
 
          while (currentDate <= lastDate) {
            var row = document.createElement('tr');
 
            if (this.options.displayWeekNumber) {
              var weekNumberCell = document.createElement('td');
              var currentThursday = new Date(currentDate.getTime()); // Week number is computed based on the thursday
 
              currentThursday.setDate(currentThursday.getDate() - weekStart + 4);
              weekNumberCell.classList.add('week-number');
              weekNumberCell.textContent = this.getWeekNumber(currentThursday).toString();
              row.appendChild(weekNumberCell);
            }
 
            do {
              var cell = document.createElement('td');
              cell.classList.add('day');
 
              if (this._isHidden(currentDate.getDay())) {
                cell.classList.add('hidden');
              }
 
              if (currentDate < firstDate) {
                cell.classList.add('old');
              } else if (currentDate > lastDate) {
                cell.classList.add('new');
              } else {
                if (this._isDisabled(currentDate)) {
                  cell.classList.add('disabled');
                }
 
                var cellContent = document.createElement('div');
                cellContent.classList.add('day-content');
                cellContent.textContent = currentDate.getDate().toString();
                cell.appendChild(cellContent);
 
                if (this.options.customDayRenderer) {
                  this.options.customDayRenderer(cellContent, currentDate);
                }
              }
 
              row.appendChild(cell);
              currentDate.setDate(currentDate.getDate() + 1);
            } while (currentDate.getDay() != weekStart);
 
            table.appendChild(row);
          }
 
          monthDiv.appendChild(table);
          monthsDiv.appendChild(monthDiv);
        }
 
        this.element.appendChild(monthsDiv);
      }
    }, {
      key: "_renderLoading",
      value: function _renderLoading() {
        var container = document.createElement('div');
        container.classList.add('calendar-loading-container');
        container.style.minHeight = this._nbCols * 200 + 'px';
        var loading = document.createElement('div');
        loading.classList.add('calendar-loading');
 
        Iif (this.options.loadingTemplate) {
          if (typeof this.options.loadingTemplate === "string") {
            loading.innerHTML = this.options.loadingTemplate;
          } else if (this.options.loadingTemplate instanceof HTMLElement) {
            loading.appendChild(this.options.loadingTemplate);
          }
        } else {
          var spinner = document.createElement('div');
          spinner.classList.add('calendar-spinner');
 
          for (var i = 1; i <= 3; i++) {
            var bounce = document.createElement('div');
            bounce.classList.add("bounce".concat(i));
            spinner.appendChild(bounce);
          }
 
          loading.appendChild(spinner);
        }
 
        container.appendChild(loading);
        this.element.appendChild(container);
      }
    }, {
      key: "_renderDataSource",
      value: function _renderDataSource() {
        var _this = this;
 
        if (this._dataSource != null && this._dataSource.length > 0) {
          this.element.querySelectorAll('.month-container').forEach(function (month) {
            var monthId = parseInt(month.dataset.monthId);
            var firstDate = new Date(_this.options.startYear, monthId, 1);
            var lastDate = new Date(_this.options.startYear, monthId + 1, 1);
 
            Eif ((_this.options.minDate == null || lastDate > _this.options.minDate) && (_this.options.maxDate == null || firstDate <= _this.options.maxDate)) {
              var monthData = [];
 
              for (var i = 0; i < _this._dataSource.length; i++) {
                if (!(_this._dataSource[i].startDate >= lastDate) || _this._dataSource[i].endDate < firstDate) {
                  monthData.push(_this._dataSource[i]);
                }
              }
 
              if (monthData.length > 0) {
                month.querySelectorAll('.day-content').forEach(function (day) {
                  var currentDate = new Date(_this.options.startYear, monthId, parseInt(day.textContent));
                  var nextDate = new Date(_this.options.startYear, monthId, currentDate.getDate() + 1);
                  var dayData = [];
 
                  Eif ((_this.options.minDate == null || currentDate >= _this.options.minDate) && (_this.options.maxDate == null || currentDate <= _this.options.maxDate)) {
                    for (var i = 0; i < monthData.length; i++) {
                      if (monthData[i].startDate < nextDate && monthData[i].endDate >= currentDate) {
                        dayData.push(monthData[i]);
                      }
                    }
 
                    if (dayData.length > 0 && (_this.options.displayDisabledDataSource || !_this._isDisabled(currentDate))) {
                      _this._renderDataSourceDay(day, currentDate, dayData);
                    }
                  }
                });
              }
            }
          });
        }
      }
    }, {
      key: "_renderDataSourceDay",
      value: function _renderDataSourceDay(elt, currentDate, events) {
        var parent = elt.parentElement;
 
        switch (this.options.style) {
          case 'border':
            var weight = 0;
 
            if (events.length == 1) {
              weight = 4;
            } else Eif (events.length <= 3) {
              weight = 2;
            } else {
              parent.style.boxShadow = 'inset 0 -4px 0 0 black';
            }
 
            Eif (weight > 0) {
              var boxShadow = '';
 
              for (var i = 0; i < events.length; i++) {
                if (boxShadow != '') {
                  boxShadow += ",";
                }
 
                boxShadow += "inset 0 -".concat((i + 1) * weight, "px 0 0 ").concat(events[i].color);
              }
 
              parent.style.boxShadow = boxShadow;
            }
 
            break;
 
          case 'background':
            parent.style.backgroundColor = events[events.length - 1].color;
            var currentTime = currentDate.getTime();
 
            if (events[events.length - 1].startDate.getTime() == currentTime) {
              parent.classList.add('day-start');
 
              Iif (events[events.length - 1].startHalfDay || this.options.alwaysHalfDay) {
                parent.classList.add('day-half'); // Find color for other half
 
                var otherColor = 'transparent';
 
                for (var i = events.length - 2; i >= 0; i--) {
                  if (events[i].startDate.getTime() != currentTime || !events[i].startHalfDay && !this.options.alwaysHalfDay) {
                    otherColor = events[i].color;
                    break;
                  }
                }
 
                parent.style.background = "linear-gradient(-45deg, ".concat(events[events.length - 1].color, ", ").concat(events[events.length - 1].color, " 49%, ").concat(otherColor, " 51%, ").concat(otherColor, ")");
              } else if (this.options.roundRangeLimits) {
                parent.classList.add('round-left');
              }
            } else if (events[events.length - 1].endDate.getTime() == currentTime) {
              parent.classList.add('day-end');
 
              Iif (events[events.length - 1].endHalfDay || this.options.alwaysHalfDay) {
                parent.classList.add('day-half'); // Find color for other half
 
                var otherColor = 'transparent';
 
                for (var i = events.length - 2; i >= 0; i--) {
                  if (events[i].endDate.getTime() != currentTime || !events[i].endHalfDay && !this.options.alwaysHalfDay) {
                    otherColor = events[i].color;
                    break;
                  }
                }
 
                parent.style.background = "linear-gradient(135deg, ".concat(events[events.length - 1].color, ", ").concat(events[events.length - 1].color, " 49%, ").concat(otherColor, " 51%, ").concat(otherColor, ")");
              } else if (this.options.roundRangeLimits) {
                parent.classList.add('round-right');
              }
            }
 
            break;
 
          case 'custom':
            if (this.options.customDataSourceRenderer) {
              this.options.customDataSourceRenderer.call(this, elt, currentDate, events);
            }
 
            break;
        }
      }
    }, {
      key: "_applyEvents",
      value: function _applyEvents() {
        var _this2 = this;
 
        if (this.options.displayHeader) {
          /* Header buttons */
          this.element.querySelectorAll('.year-neighbor, .year-neighbor2').forEach(function (element) {
            element.addEventListener('click', function (e) {
              Eif (!e.currentTarget.classList.contains('disabled')) {
                _this2.setYear(parseInt(e.currentTarget.textContent));
              }
            });
          });
          this.element.querySelector('.calendar-header .prev').addEventListener('click', function (e) {
            Eif (!e.currentTarget.classList.contains('disabled')) {
              var months = _this2.element.querySelector('.months-container');
 
              months.style.transition = 'margin-left 0.1s';
              months.style.marginLeft = '100%';
              setTimeout(function () {
                months.style.visibility = 'hidden';
                months.style.transition = '';
                months.style.marginLeft = '0';
                setTimeout(function () {
                  _this2.setYear(_this2.options.startYear - 1);
                }, 50);
              }, 100);
            }
          });
          this.element.querySelector('.calendar-header .next').addEventListener('click', function (e) {
            Eif (!e.currentTarget.classList.contains('disabled')) {
              var months = _this2.element.querySelector('.months-container');
 
              months.style.transition = 'margin-left 0.1s';
              months.style.marginLeft = '-100%';
              setTimeout(function () {
                months.style.visibility = 'hidden';
                months.style.transition = '';
                months.style.marginLeft = '0';
                setTimeout(function () {
                  _this2.setYear(_this2.options.startYear + 1);
                }, 50);
              }, 100);
            }
          });
        }
 
        var cells = this.element.querySelectorAll('.day:not(.old):not(.new):not(.disabled)');
        cells.forEach(function (cell) {
          /* Click on date */
          cell.addEventListener('click', function (e) {
            e.stopPropagation();
 
            var date = _this2._getDate(e.currentTarget);
 
            _this2._triggerEvent('clickDay', {
              element: e.currentTarget,
              date: date,
              events: _this2.getEvents(date)
            });
          });
          /* Click right on date */
 
          cell.addEventListener('contextmenu', function (e) {
            if (_this2.options.enableContextMenu) {
              e.preventDefault();
 
              Eif (_this2.options.contextMenuItems.length > 0) {
                _this2._openContextMenu(e.currentTarget);
              }
            }
 
            var date = _this2._getDate(e.currentTarget);
 
            _this2._triggerEvent('dayContextMenu', {
              element: e.currentTarget,
              date: date,
              events: _this2.getEvents(date)
            });
          });
          /* Range selection */
 
          if (_this2.options.enableRangeSelection) {
            cell.addEventListener('mousedown', function (e) {
              Eif (e.which == 1) {
                var currentDate = _this2._getDate(e.currentTarget);
 
                Eif (_this2.options.allowOverlap || _this2.isThereFreeSlot(currentDate)) {
                  _this2._mouseDown = true;
                  _this2._rangeStart = _this2._rangeEnd = currentDate;
 
                  _this2._refreshRange();
                }
              }
            });
            cell.addEventListener('mouseenter', function (e) {
              Eif (_this2._mouseDown) {
                var currentDate = _this2._getDate(e.currentTarget);
 
                if (!_this2.options.allowOverlap) {
                  var newDate = new Date(_this2._rangeStart.getTime());
 
                  Eif (newDate < currentDate) {
                    var nextDate = new Date(newDate.getFullYear(), newDate.getMonth(), newDate.getDate() + 1);
 
                    while (newDate < currentDate) {
                      if (!_this2.isThereFreeSlot(nextDate, false)) {
                        break;
                      }
 
                      newDate.setDate(newDate.getDate() + 1);
                      nextDate.setDate(nextDate.getDate() + 1);
                    }
                  } else {
                    var nextDate = new Date(newDate.getFullYear(), newDate.getMonth(), newDate.getDate() - 1);
 
                    while (newDate > currentDate) {
                      if (!_this2.isThereFreeSlot(nextDate, true)) {
                        break;
                      }
 
                      newDate.setDate(newDate.getDate() - 1);
                      nextDate.setDate(nextDate.getDate() - 1);
                    }
                  }
 
                  currentDate = newDate;
                }
 
                var oldValue = _this2._rangeEnd;
                _this2._rangeEnd = currentDate;
 
                Eif (oldValue.getTime() != _this2._rangeEnd.getTime()) {
                  _this2._refreshRange();
                }
              }
            });
          }
          /* Hover date */
 
 
          cell.addEventListener('mouseenter', function (e) {
            if (!_this2._mouseDown) {
              var date = _this2._getDate(e.currentTarget);
 
              _this2._triggerEvent('mouseOnDay', {
                element: e.currentTarget,
                date: date,
                events: _this2.getEvents(date)
              });
            }
          });
          cell.addEventListener('mouseleave', function (e) {
            var date = _this2._getDate(e.currentTarget);
 
            _this2._triggerEvent('mouseOutDay', {
              element: e.currentTarget,
              date: date,
              events: _this2.getEvents(date)
            });
          });
        });
 
        if (this.options.enableRangeSelection) {
          // Release range selection
          window.addEventListener('mouseup', function (e) {
            Eif (_this2._mouseDown) {
              _this2._mouseDown = false;
 
              _this2._refreshRange();
 
              var minDate = _this2._rangeStart < _this2._rangeEnd ? _this2._rangeStart : _this2._rangeEnd;
              var maxDate = _this2._rangeEnd > _this2._rangeStart ? _this2._rangeEnd : _this2._rangeStart;
 
              _this2._triggerEvent('selectRange', {
                startDate: minDate,
                endDate: maxDate,
                events: _this2.getEventsOnRange(minDate, new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate() + 1))
              });
            }
          });
        }
        /* Responsive management */
 
 
        if (this._responsiveInterval) {
          clearInterval(this._responsiveInterval);
          this._responsiveInterval = null;
        }
 
        this._responsiveInterval = setInterval(function () {
          Iif (_this2.element.querySelector('.month') == null) {
            return;
          }
 
          var calendarSize = _this2.element.offsetWidth;
          var monthSize = _this2.element.querySelector('.month').offsetWidth + 10;
          _this2._nbCols = null;
 
          Iif (monthSize * 6 < calendarSize) {
            _this2._nbCols = 2;
          } else Iif (monthSize * 4 < calendarSize) {
            _this2._nbCols = 3;
          } else Iif (monthSize * 3 < calendarSize) {
            _this2._nbCols = 4;
          } else Iif (monthSize * 2 < calendarSize) {
            _this2._nbCols = 6;
          } else {
            _this2._nbCols = 12;
          }
 
          _this2.element.querySelectorAll('.month-container').forEach(function (month) {
            if (!month.classList.contains("month-".concat(_this2._nbCols))) {
              ['month-2', 'month-3', 'month-4', 'month-6', 'month-12'].forEach(function (className) {
                month.classList.remove(className);
              });
              month.classList.add("month-".concat(_this2._nbCols));
            }
          });
        }, 300);
      }
    }, {
      key: "_refreshRange",
      value: function _refreshRange() {
        var _this3 = this;
 
        this.element.querySelectorAll('td.day.range').forEach(function (day) {
          return day.classList.remove('range');
        });
        this.element.querySelectorAll('td.day.range-start').forEach(function (day) {
          return day.classList.remove('range-start');
        });
        this.element.querySelectorAll('td.day.range-end').forEach(function (day) {
          return day.classList.remove('range-end');
        });
 
        if (this._mouseDown) {
          var minDate = this._rangeStart < this._rangeEnd ? this._rangeStart : this._rangeEnd;
          var maxDate = this._rangeEnd > this._rangeStart ? this._rangeEnd : this._rangeStart;
          this.element.querySelectorAll('.month-container').forEach(function (month) {
            var monthId = parseInt(month.dataset.monthId);
 
            if (minDate.getMonth() <= monthId && maxDate.getMonth() >= monthId) {
              month.querySelectorAll('td.day:not(.old):not(.new)').forEach(function (day) {
                var date = _this3._getDate(day);
 
                if (date >= minDate && date <= maxDate) {
                  day.classList.add('range');
 
                  if (date.getTime() == minDate.getTime()) {
                    day.classList.add('range-start');
                  }
 
                  if (date.getTime() == maxDate.getTime()) {
                    day.classList.add('range-end');
                  }
                }
              });
            }
          });
        }
      }
    }, {
      key: "_getElementPosition",
      value: function _getElementPosition(element) {
        var top = 0,
            left = 0;
 
        do {
          top += element.offsetTop || 0;
          left += element.offsetLeft || 0;
          element = element.offsetParent;
        } while (element);
 
        return {
          top: top,
          left: left
        };
      }
    }, {
      key: "_openContextMenu",
      value: function _openContextMenu(elt) {
        var _this4 = this;
 
        var contextMenu = document.querySelector('.calendar-context-menu');
 
        if (contextMenu !== null) {
          contextMenu.style.display = 'none'; // Clear the context menu (faster method)
 
          while (contextMenu.firstChild) {
            contextMenu.removeChild(contextMenu.firstChild);
          }
        } else {
          contextMenu = document.createElement('div');
          contextMenu.classList.add('calendar-context-menu');
          document.body.appendChild(contextMenu);
        }
 
        var date = this._getDate(elt);
 
        var events = this.getEvents(date);
 
        for (var i = 0; i < events.length; i++) {
          var eventItem = document.createElement('div');
          eventItem.classList.add('item');
          eventItem.style.paddingLeft = '4px';
          eventItem.style.boxShadow = "inset 4px 0 0 0 ".concat(events[i].color);
          var eventItemContent = document.createElement('div');
          eventItemContent.classList.add('content');
          var text = document.createElement('span');
          text.classList.add('text');
          text.textContent = events[i].name;
          eventItemContent.appendChild(text);
          var icon = document.createElement('span');
          icon.classList.add('arrow');
          icon.innerHTML = "&rsaquo;";
          eventItemContent.appendChild(icon);
          eventItem.appendChild(eventItemContent);
 
          this._renderContextMenuItems(eventItem, this.options.contextMenuItems, events[i]);
 
          contextMenu.appendChild(eventItem);
        }
 
        if (contextMenu.children.length > 0) {
          var position = this._getElementPosition(elt);
 
          contextMenu.style.left = position.left + 25 + 'px';
          contextMenu.style.right = '';
          contextMenu.style.top = position.top + 25 + 'px';
          contextMenu.style.display = 'block';
 
          Iif (contextMenu.getBoundingClientRect().right > document.body.offsetWidth) {
            contextMenu.style.left = '';
            contextMenu.style.right = '0';
          } // Launch the position check once the whole context menu tree will be rendered
 
 
          setTimeout(function () {
            return _this4._checkContextMenuItemsPosition();
          }, 0);
 
          var closeContextMenu = function closeContextMenu(event) {
            if (event.type !== 'click' || !contextMenu.contains(event.target)) {
              contextMenu.style.display = 'none';
              window.removeEventListener('click', closeContextMenu);
              window.removeEventListener('resize', closeContextMenu);
              window.removeEventListener('scroll', closeContextMenu);
            }
          };
 
          window.addEventListener('click', closeContextMenu);
          window.addEventListener('resize', closeContextMenu);
          window.addEventListener('scroll', closeContextMenu);
        }
      }
    }, {
      key: "_renderContextMenuItems",
      value: function _renderContextMenuItems(parent, items, evt) {
        var subMenu = document.createElement('div');
        subMenu.classList.add('submenu');
 
        for (var i = 0; i < items.length; i++) {
          Iif (items[i].visible === false || typeof items[i].visible === "function" && !items[i].visible(evt)) {
            continue;
          }
 
          var menuItem = document.createElement('div');
          menuItem.classList.add('item');
          var menuItemContent = document.createElement('div');
          menuItemContent.classList.add('content');
          var text = document.createElement('span');
          text.classList.add('text');
          text.textContent = items[i].text;
          menuItemContent.appendChild(text);
 
          Iif (items[i].click) {
            (function (index) {
              menuItemContent.addEventListener('click', function () {
                document.querySelector('.calendar-context-menu').style.display = 'none';
                items[index].click(evt);
              });
            })(i);
          }
 
          menuItem.appendChild(menuItemContent);
 
          if (items[i].items && items[i].items.length > 0) {
            var icon = document.createElement('span');
            icon.classList.add('arrow');
            icon.innerHTML = "&rsaquo;";
            menuItemContent.appendChild(icon);
 
            this._renderContextMenuItems(menuItem, items[i].items, evt);
          }
 
          subMenu.appendChild(menuItem);
        }
 
        Eif (subMenu.children.length > 0) {
          parent.appendChild(subMenu);
        }
      }
    }, {
      key: "_checkContextMenuItemsPosition",
      value: function _checkContextMenuItemsPosition() {
        var menus = document.querySelectorAll('.calendar-context-menu .submenu');
        menus.forEach(function (menu) {
          var htmlMenu = menu;
          htmlMenu.style.display = 'block';
          htmlMenu.style.visibility = 'hidden';
        });
        menus.forEach(function (menu) {
          var htmlMenu = menu;
 
          if (htmlMenu.getBoundingClientRect().right > document.body.offsetWidth) {
            htmlMenu.classList.add('open-left');
          } else {
            htmlMenu.classList.remove('open-left');
          }
        });
        menus.forEach(function (menu) {
          var htmlMenu = menu;
          htmlMenu.style.display = '';
          htmlMenu.style.visibility = '';
        });
      }
    }, {
      key: "_getDate",
      value: function _getDate(elt) {
        var day = elt.querySelector('.day-content').textContent;
        var month = elt.closest('.month-container').dataset.monthId;
        var year = this.options.startYear;
        return new Date(year, month, day);
      }
    }, {
      key: "_triggerEvent",
      value: function _triggerEvent(eventName, parameters) {
        var event = null;
 
        Eif (typeof Event === "function") {
          event = new Event(eventName);
        } else {
          event = document.createEvent('Event');
          event.initEvent(eventName, false, false);
        }
 
        event.calendar = this;
 
        for (var i in parameters) {
          event[i] = parameters[i];
        }
 
        this.element.dispatchEvent(event);
        return event;
      }
    }, {
      key: "_isDisabled",
      value: function _isDisabled(date) {
        if (this.options.minDate != null && date < this.options.minDate || this.options.maxDate != null && date > this.options.maxDate) {
          return true;
        }
 
        if (this.options.disabledWeekDays.length > 0) {
          for (var d = 0; d < this.options.disabledWeekDays.length; d++) {
            if (date.getDay() == this.options.disabledWeekDays[d]) {
              return true;
            }
          }
        }
 
        if (this.options.disabledDays.length > 0) {
          for (var d = 0; d < this.options.disabledDays.length; d++) {
            if (date.getTime() == this.options.disabledDays[d].getTime()) {
              return true;
            }
          }
        }
 
        return false;
      }
    }, {
      key: "_isHidden",
      value: function _isHidden(day) {
        if (this.options.hiddenWeekDays.length > 0) {
          for (var d = 0; d < this.options.hiddenWeekDays.length; d++) {
            if (day == this.options.hiddenWeekDays[d]) {
              return true;
            }
          }
        }
 
        return false;
      }
      /**
          * Gets the week number for a specified date.
          *
          * @param date The specified date.
          */
 
    }, {
      key: "getWeekNumber",
      value: function getWeekNumber(date) {
        // Algorithm from https://weeknumber.net/how-to/javascript
        var workingDate = new Date(date.getTime());
        workingDate.setHours(0, 0, 0, 0); // Thursday in current week decides the year.
 
        workingDate.setDate(workingDate.getDate() + 3 - (workingDate.getDay() + 6) % 7); // January 4 is always in week 1.
 
        var week1 = new Date(workingDate.getFullYear(), 0, 4); // Adjust to Thursday in week 1 and count number of weeks from date to week1.
 
        return 1 + Math.round(((workingDate.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
      }
      /**
          * Gets the data source elements for a specified day.
          *
          * @param date The specified day.
          */
 
    }, {
      key: "getEvents",
      value: function getEvents(date) {
        return this.getEventsOnRange(date, new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1));
      }
      /**
          * Gets the data source elements for a specified range of days.
          *
          * @param startDate The beginning of the day range (inclusive).
       * @param endDate The end of the day range (non inclusive).
          */
 
    }, {
      key: "getEventsOnRange",
      value: function getEventsOnRange(startDate, endDate) {
        var events = [];
 
        Eif (this._dataSource && startDate && endDate) {
          for (var i = 0; i < this._dataSource.length; i++) {
            if (this._dataSource[i].startDate < endDate && this._dataSource[i].endDate >= startDate) {
              events.push(this._dataSource[i]);
            }
          }
        }
 
        return events;
      }
      /**
          * Check if there is no event on the first part, last part or on the whole specified day.
          *
          * @param date The specified day.
          * @param after Whether to check for a free slot on the first part (if `false`) or the last part (if `true`) of the day. If `null`, this will check on the whole day.
       * 
       * Usefull only if using the `alwaysHalfDay` option of the calendar, or the `startHalfDay` or `endHalfDay` option of the datasource.
          */
 
    }, {
      key: "isThereFreeSlot",
      value: function isThereFreeSlot(date) {
        var _this5 = this;
 
        var after = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
        var events = this.getEvents(date);
 
        Iif (after === true) {
          return !events.some(function (evt) {
            return !_this5.options.alwaysHalfDay && !evt.endHalfDay || evt.endDate > date;
          });
        } else if (after === false) {
          return !events.some(function (evt) {
            return !_this5.options.alwaysHalfDay && !evt.startHalfDay || evt.startDate < date;
          });
        } else {
          return this.isThereFreeSlot(date, false) || this.isThereFreeSlot(date, true);
        }
      }
      /**
          * Gets the year displayed on the calendar.
          */
 
    }, {
      key: "getYear",
      value: function getYear() {
        return this.options.startYear;
      }
      /**
          * Sets the year displayed on the calendar.
          *
          * @param year The year to displayed on the calendar.
          */
 
    }, {
      key: "setYear",
      value: function setYear(year) {
        var _this6 = this;
 
        var parsedYear = parseInt(year);
 
        if (!isNaN(parsedYear)) {
          this.options.startYear = parsedYear; // Clear the calendar (faster method)
 
          while (this.element.firstChild) {
            this.element.removeChild(this.element.firstChild);
          }
 
          if (this.options.displayHeader) {
            this._renderHeader();
          }
 
          var eventResult = this._triggerEvent('yearChanged', {
            currentYear: this.options.startYear,
            preventRendering: false
          });
 
          if (typeof this.options.dataSource === "function") {
            this.render(true);
 
            this._fetchDataSource(function (dataSource) {
              _this6._dataSource = dataSource;
 
              _this6._initializeDatasourceColors();
 
              _this6.render(false);
            });
          } else {
            Eif (!eventResult.preventRendering) {
              this.render();
            }
          }
        }
      }
      /**
          * Gets the minimum date of the calendar.
          */
 
    }, {
      key: "getMinDate",
      value: function getMinDate() {
        return this.options.minDate;
      }
      /**
          * Sets the minimum date of the calendar.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param minDate The minimum date to set.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setMinDate",
      value: function setMinDate(date) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
 
        Eif (date instanceof Date || date === null) {
          this.options.minDate = date;
 
          Eif (!preventRendering) {
            this.render();
          }
        }
      }
      /**
          * Gets the maximum date of the calendar.
          */
 
    }, {
      key: "getMaxDate",
      value: function getMaxDate() {
        return this.options.maxDate;
      }
      /**
          * Sets the maximum date of the calendar. 
       * 
       * This method causes a refresh of the calendar.
          *
          * @param maxDate The maximum date to set.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setMaxDate",
      value: function setMaxDate(date) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
 
        Eif (date instanceof Date || date === null) {
          this.options.maxDate = date;
 
          Eif (!preventRendering) {
            this.render();
          }
        }
      }
      /**
          * Gets the current style used for displaying data source.
          */
 
    }, {
      key: "getStyle",
      value: function getStyle() {
        return this.options.style;
      }
      /**
          * Sets the style to use for displaying data source. 
       * 
       * This method causes a refresh of the calendar.
          *
          * @param style The style to use for displaying data source ("background", "border" or "custom").
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setStyle",
      value: function setStyle(style) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.style = style == 'background' || style == 'border' || style == 'custom' ? style : 'border';
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets a value indicating whether the user can select a range which overlapping an other element present in the datasource.
          */
 
    }, {
      key: "getAllowOverlap",
      value: function getAllowOverlap() {
        return this.options.allowOverlap;
      }
      /**
          * Sets a value indicating whether the user can select a range which overlapping an other element present in the datasource.
          *
          * @param allowOverlap Indicates whether the user can select a range which overlapping an other element present in the datasource.
          */
 
    }, {
      key: "setAllowOverlap",
      value: function setAllowOverlap(allowOverlap) {
        this.options.allowOverlap = allowOverlap;
      }
      /**
          * Gets a value indicating whether the weeks number are displayed.
          */
 
    }, {
      key: "getDisplayWeekNumber",
      value: function getDisplayWeekNumber() {
        return this.options.displayWeekNumber;
      }
      /**
          * Sets a value indicating whether the weeks number are displayed.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param  displayWeekNumber Indicates whether the weeks number are displayed.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setDisplayWeekNumber",
      value: function setDisplayWeekNumber(displayWeekNumber) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.displayWeekNumber = displayWeekNumber;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets a value indicating whether the calendar header is displayed.
          */
 
    }, {
      key: "getDisplayHeader",
      value: function getDisplayHeader() {
        return this.options.displayHeader;
      }
      /**
          * Sets a value indicating whether the calendar header is displayed.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param displayHeader Indicates whether the calendar header is displayed.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setDisplayHeader",
      value: function setDisplayHeader(displayHeader) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.displayHeader = displayHeader;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets a value indicating whether the data source must be rendered on disabled days.
          */
 
    }, {
      key: "getDisplayDisabledDataSource",
      value: function getDisplayDisabledDataSource() {
        return this.options.displayDisabledDataSource;
      }
      /**
          * Sets a value indicating whether the data source must be rendered on disabled days.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param displayDisabledDataSource Indicates whether the data source must be rendered on disabled days.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setDisplayDisabledDataSource",
      value: function setDisplayDisabledDataSource(displayDisabledDataSource) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.displayDisabledDataSource = displayDisabledDataSource;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets a value indicating whether the beginning and the end of each range should be displayed as half selected day.
          */
 
    }, {
      key: "getAlwaysHalfDay",
      value: function getAlwaysHalfDay() {
        return this.options.alwaysHalfDay;
      }
      /**
          * Sets a value indicating whether the beginning and the end of each range should be displayed as half selected day.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param alwaysHalfDay Indicates whether the beginning and the end of each range should be displayed as half selected day.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setAlwaysHalfDay",
      value: function setAlwaysHalfDay(alwaysHalfDay) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.alwaysHalfDay = alwaysHalfDay;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets a value indicating whether the user can make range selection.
          */
 
    }, {
      key: "getEnableRangeSelection",
      value: function getEnableRangeSelection() {
        return this.options.enableRangeSelection;
      }
      /**
          * Sets a value indicating whether the user can make range selection.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param enableRangeSelection Indicates whether the user can make range selection.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setEnableRangeSelection",
      value: function setEnableRangeSelection(enableRangeSelection) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.enableRangeSelection = enableRangeSelection;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets the disabled days.
          */
 
    }, {
      key: "getDisabledDays",
      value: function getDisabledDays() {
        return this.options.disabledDays;
      }
      /**
          * Sets the disabled days.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param disableDays The disabled days to set.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setDisabledDays",
      value: function setDisabledDays(disabledDays) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.disabledDays = disabledDays instanceof Array ? disabledDays : [];
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets the disabled days of the week.
          */
 
    }, {
      key: "getDisabledWeekDays",
      value: function getDisabledWeekDays() {
        return this.options.disabledWeekDays;
      }
      /**
          * Sets the disabled days of the week.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param disabledWeekDays The disabled days of the week to set.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setDisabledWeekDays",
      value: function setDisabledWeekDays(disabledWeekDays) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.disabledWeekDays = disabledWeekDays instanceof Array ? disabledWeekDays : [];
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets the hidden days of the week.
          */
 
    }, {
      key: "getHiddenWeekDays",
      value: function getHiddenWeekDays() {
        return this.options.hiddenWeekDays;
      }
      /**
          * Sets the hidden days of the week.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param hiddenWeekDays The hidden days of the week to set.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setHiddenWeekDays",
      value: function setHiddenWeekDays(hiddenWeekDays) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.hiddenWeekDays = hiddenWeekDays instanceof Array ? hiddenWeekDays : [];
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets a value indicating whether the beginning and the end of each range should be displayed as rounded cells.
          */
 
    }, {
      key: "getRoundRangeLimits",
      value: function getRoundRangeLimits() {
        return this.options.roundRangeLimits;
      }
      /**
          * Sets a value indicating whether the beginning and the end of each range should be displayed as rounded cells.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param roundRangeLimits Indicates whether the beginning and the end of each range should be displayed as rounded cells. 
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setRoundRangeLimits",
      value: function setRoundRangeLimits(roundRangeLimits) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.roundRangeLimits = roundRangeLimits;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets a value indicating whether the default context menu must be displayed when right clicking on a day.
          */
 
    }, {
      key: "getEnableContextMenu",
      value: function getEnableContextMenu() {
        return this.options.enableContextMenu;
      }
      /**
          * Sets a value indicating whether the default context menu must be displayed when right clicking on a day. 
          * 
       * This method causes a refresh of the calendar.
          * 
          * @param enableContextMenu Indicates whether the default context menu must be displayed when right clicking on a day.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setEnableContextMenu",
      value: function setEnableContextMenu(enableContextMenu) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.enableContextMenu = enableContextMenu;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets the context menu items.
          */
 
    }, {
      key: "getContextMenuItems",
      value: function getContextMenuItems() {
        return this.options.contextMenuItems;
      }
      /**
          * Sets new context menu items.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param contextMenuItems The new context menu items.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setContextMenuItems",
      value: function setContextMenuItems(contextMenuItems) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.contextMenuItems = contextMenuItems instanceof Array ? contextMenuItems : [];
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets the custom day renderer.
          */
 
    }, {
      key: "getCustomDayRenderer",
      value: function getCustomDayRenderer() {
        return this.options.customDayRenderer;
      }
      /**
          * Sets the custom day renderer.
       * 
       * This method causes a refresh of the calendar.
       *
       * @param handler The function used to render the days. This function is called during render for each day.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setCustomDayRenderer",
      value: function setCustomDayRenderer(customDayRenderer) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.customDayRenderer = typeof customDayRenderer === "function" ? customDayRenderer : null;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets the custom data source renderer.
          */
 
    }, {
      key: "getCustomDataSourceRenderer",
      value: function getCustomDataSourceRenderer() {
        return this.options.customDataSourceRenderer;
      }
      /**
          * Sets the custom data source renderer. Works only with the style set to "custom".
       * 
       * This method causes a refresh of the calendar.
       *
       * @param handler The function used to render the data source. This function is called during render for each day containing at least one event.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setCustomDataSourceRenderer",
      value: function setCustomDataSourceRenderer(customDataSourceRenderer) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.customDataSourceRenderer = typeof customDataSourceRenderer === "function" ? customDataSourceRenderer : null;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets the language used for calendar rendering.
          */
 
    }, {
      key: "getLanguage",
      value: function getLanguage() {
        return this.options.language;
      }
      /**
          * Sets the language used for calendar rendering.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param language The language to use for calendar redering.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setLanguage",
      value: function setLanguage(language) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
 
        if (language != null && Calendar.locales[language] != null) {
          this.options.language = language;
 
          Eif (!preventRendering) {
            this.render();
          }
        }
      }
      /**
          * Gets the current data source.
          */
 
    }, {
      key: "getDataSource",
      value: function getDataSource() {
        return this.options.dataSource;
      }
      /**
          * Sets a new data source.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param dataSource The new data source.
       * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setDataSource",
      value: function setDataSource(dataSource) {
        var _this7 = this;
 
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.dataSource = dataSource instanceof Array || typeof dataSource === "function" ? dataSource : [];
 
        if (typeof this.options.dataSource === "function") {
          this.render(true);
 
          this._fetchDataSource(function (dataSource) {
            _this7._dataSource = dataSource;
 
            _this7._initializeDatasourceColors();
 
            _this7.render(false);
          });
        } else {
          this._dataSource = this.options.dataSource;
 
          this._initializeDatasourceColors();
 
          Eif (!preventRendering) {
            this.render();
          }
        }
      }
      /**
          * Gets the starting day of the week.
          */
 
    }, {
      key: "getWeekStart",
      value: function getWeekStart() {
        return this.options.weekStart ? this.options.weekStart : Calendar.locales[this.options.language].weekStart;
      }
      /**
          * Sets the starting day of the week.
       * 
       * This method causes a refresh of the calendar.
          *
          * @param weekStart The starting day of the week. This option overrides the parameter define in the language file.
          * @param preventRedering Indicates whether the rendering should be prevented after the property update.
          */
 
    }, {
      key: "setWeekStart",
      value: function setWeekStart(weekStart) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        this.options.weekStart = !isNaN(parseInt(weekStart)) ? parseInt(weekStart) : null;
 
        Eif (!preventRendering) {
          this.render();
        }
      }
      /**
          * Gets the loading template.
          */
 
    }, {
      key: "getLoadingTemplate",
      value: function getLoadingTemplate() {
        return this.options.loadingTemplate;
      }
      /**
          * Sets the loading template.
          *
          * @param loadingTemplate The loading template.
          */
 
    }, {
      key: "setLoadingTemplate",
      value: function setLoadingTemplate(loadingTemplate) {
        this.options.loadingTemplate = typeof loadingTemplate === "string" || loadingTemplate instanceof HTMLElement ? loadingTemplate : null;
      }
      /**
       * 
          * Add a new element to the data source.
       * 
       * This method causes a refresh of the calendar.
          * 
          * @param element The element to add.
       * @param preventRendering Indicates whether the calendar shouldn't be refreshed once the event added.
          */
 
    }, {
      key: "addEvent",
      value: function addEvent(evt) {
        var preventRendering = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
 
        this._dataSource.push(evt);
 
        Eif (!preventRendering) {
          this.render();
        }
      }
    }]);
 
    return Calendar;
  }();
 
  _exports["default"] = Calendar;
 
  _defineProperty(Calendar, "locales", {
    en: {
      days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
      daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
      daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
      months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
      monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
      weekShort: 'W',
      weekStart: 0
    }
  });
 
  _defineProperty(Calendar, "colors", ['#2C8FC9', '#9CB703', '#F5BB00', '#FF4A32', '#B56CE2', '#45A597']);
 
  Eif ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") {
    window.Calendar = Calendar;
    document.addEventListener("DOMContentLoaded", function () {
      document.querySelectorAll('[data-provide="calendar"]').forEach(function (element) {
        return new Calendar(element);
      });
    });
  }
});