defaultcalendar.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Call this from the developer console and you can control both instances
  2. var calendars = {};
  3. $(function() {
  4. // console.info(
  5. // 'Welcome to the CLNDR demo. Click around on the calendars and' +
  6. // 'the console will log different events that fire.');
  7. // Assuming you've got the appropriate language files,
  8. // clndr will respect whatever moment's language is set to.
  9. // moment.locale('ru');
  10. // Here's some magic to make sure the dates are happening this month.
  11. var thisMonth = moment().format('YYYY-MM');
  12. // Events to load into calendar
  13. var eventArray = [
  14. {
  15. title: 'Multi-Day Event',
  16. endDate: thisMonth + '-14',
  17. startDate: thisMonth + '-10'
  18. }, {
  19. endDate: thisMonth + '-23',
  20. startDate: thisMonth + '-21',
  21. title: 'Another Multi-Day Event'
  22. }, {
  23. date: thisMonth + '-27',
  24. title: 'Single Day Event'
  25. }
  26. ];
  27. // The order of the click handlers is predictable. Direct click action
  28. // callbacks come first: click, nextMonth, previousMonth, nextYear,
  29. // previousYear, nextInterval, previousInterval, or today. Then
  30. // onMonthChange (if the month changed), inIntervalChange if the interval
  31. // has changed, and finally onYearChange (if the year changed).
  32. calendars.clndr1 = $('.cal1').clndr({
  33. events: eventArray,
  34. clickEvents: {
  35. click: function (target) {
  36. console.log('Cal-1 clicked: ', target);
  37. },
  38. today: function () {
  39. console.log('Cal-1 today');
  40. },
  41. nextMonth: function () {
  42. console.log('Cal-1 next month');
  43. },
  44. previousMonth: function () {
  45. console.log('Cal-1 previous month');
  46. },
  47. onMonthChange: function () {
  48. console.log('Cal-1 month changed');
  49. },
  50. nextYear: function () {
  51. console.log('Cal-1 next year');
  52. },
  53. previousYear: function () {
  54. console.log('Cal-1 previous year');
  55. },
  56. onYearChange: function () {
  57. console.log('Cal-1 year changed');
  58. },
  59. nextInterval: function () {
  60. console.log('Cal-1 next interval');
  61. },
  62. previousInterval: function () {
  63. console.log('Cal-1 previous interval');
  64. },
  65. onIntervalChange: function () {
  66. console.log('Cal-1 interval changed');
  67. }
  68. },
  69. multiDayEvents: {
  70. singleDay: 'date',
  71. endDate: 'endDate',
  72. startDate: 'startDate'
  73. },
  74. showAdjacentMonths: true,
  75. adjacentDaysChangeMonth: false
  76. });
  77. });