PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/calendar/templates/month_detailed.mustache

http://github.com/moodle/moodle
Mustache | 186 lines | 147 code | 6 blank | 33 comment | 2 complexity | 2937a029175c886dcdd2062871e4c860 MD5 | raw file
Possible License(s): MIT, AGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause
  1. {{!
  2. This file is part of Moodle - http://moodle.org/
  3. Moodle is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. Moodle is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  13. }}
  14. {{!
  15. @template calendar/month_detailed
  16. Calendar month view.
  17. The purpose of this template is to render the month view.
  18. Classes required for JS:
  19. * none
  20. Data attributes required for JS:
  21. * none
  22. Example context (json):
  23. {
  24. }
  25. }}
  26. <div{{!
  27. }} class="calendarwrapper"{{!
  28. }}{{#courseid}} data-courseid="{{courseid}}"{{/courseid}}{{!
  29. }}{{#categoryid}} data-categoryid="{{categoryid}}"{{/categoryid}}{{!
  30. }} data-context-id="{{defaulteventcontext}}"{{!
  31. }} data-month="{{date.mon}}"{{!
  32. }} data-year="{{date.year}}"{{!
  33. }} data-view="month"{{!
  34. }}>
  35. {{> core_calendar/month_navigation }}
  36. {{> core/overlay_loading}}
  37. <table id="month-detailed-{{uniqid}}" class="calendarmonth calendartable mb-0">
  38. <thead>
  39. <tr>
  40. {{# daynames }}
  41. <th class="header text-xs-center" aria-label="{{fullname}}">
  42. {{shortname}}
  43. </th>
  44. {{/ daynames }}
  45. </tr>
  46. </thead>
  47. <tbody>
  48. {{#weeks}}
  49. <tr data-region="month-view-week">
  50. {{#prepadding}}
  51. <td class="dayblank">&nbsp;</td>
  52. {{/prepadding}}
  53. {{#days}}
  54. <td class="day text-sm-center text-md-left{{!
  55. }}{{#istoday}} today{{/istoday}}{{!
  56. }}{{#isweekend}} weekend{{/isweekend}}{{!
  57. }}{{#durationevents.0}} duration{{/durationevents.0}}{{!
  58. }}{{#durationevents}} duration_{{.}}{{/durationevents}}{{!
  59. }}{{#defaulteventcontext}} clickable{{/defaulteventcontext}}{{!
  60. }}"
  61. data-day-timestamp="{{timestamp}}"
  62. data-drop-zone="month-view-day"
  63. data-region="day"
  64. data-new-event-timestamp="{{neweventtimestamp}}">
  65. <div class="d-none d-md-block hidden-phone text-xs-center">
  66. {{#hasevents}}
  67. <a data-action="view-day-link" href="#" class="day" aria-label="{{viewdaylinktitle}}"
  68. data-year="{{date.year}}" data-month="{{date.mon}}" data-day="{{mday}}"
  69. data-courseid="{{courseid}}" data-categoryid="{{categoryid}}"
  70. data-timestamp="{{timestamp}}">{{mday}}</a>
  71. {{/hasevents}}
  72. {{^hasevents}}
  73. {{mday}}
  74. {{/hasevents}}
  75. {{#hasevents}}
  76. <div data-region="day-content">
  77. <ul>
  78. {{#events}}
  79. {{#underway}}
  80. <li class="events-underway">[{{{name}}}]</li>
  81. {{/underway}}
  82. {{^underway}}
  83. <li data-region="event-item"
  84. data-eventtype-{{normalisedeventtype}}="1"
  85. {{#draggable}}
  86. draggable="true"
  87. data-drag-type="move"
  88. {{#mindaytimestamp}}
  89. data-min-day-timestamp="{{.}}"
  90. {{/mindaytimestamp}}
  91. {{#mindayerror}}
  92. data-min-day-error="{{.}}"
  93. {{/mindayerror}}
  94. {{#maxdaytimestamp}}
  95. data-max-day-timestamp="{{.}}"
  96. {{/maxdaytimestamp}}
  97. {{#maxdayerror}}
  98. data-max-day-error="{{.}}"
  99. {{/maxdayerror}}
  100. {{/draggable}}>
  101. <a data-action="view-event" data-event-id="{{id}}" href="{{url}}" title="{{name}}">
  102. <span class="badge badge-circle calendar_event_{{normalisedeventtype}}">
  103. &nbsp;
  104. </span>
  105. {{> core_calendar/event_icon}}
  106. <span class="eventname">{{{name}}}</span>
  107. </a>
  108. </li>
  109. {{/underway}}
  110. {{/events}}
  111. </ul>
  112. </div>
  113. {{/hasevents}}
  114. </div>
  115. <div class="d-md-none hidden-desktop hidden-tablet">
  116. {{#hasevents}}
  117. <a data-action="view-day-link" href="#" class="day" aria-label="{{viewdaylinktitle}}"
  118. data-year="{{date.year}}" data-month="{{date.mon}}" data-day="{{mday}}"
  119. data-courseid="{{courseid}}" data-categoryid="{{categoryid}}"
  120. data-timestamp="{{timestamp}}">{{mday}}</a>
  121. {{/hasevents}}
  122. {{^hasevents}}
  123. {{mday}}
  124. {{/hasevents}}
  125. </div>
  126. </td>
  127. {{/days}}
  128. {{#postpadding}}
  129. <td class="dayblank">&nbsp;</td>
  130. {{/postpadding}}
  131. </tr>
  132. {{/weeks}}
  133. </tbody>
  134. </table>
  135. </div>
  136. {{#js}}
  137. require([
  138. 'jquery',
  139. 'core_calendar/month_view_drag_drop',
  140. 'core_calendar/selectors',
  141. 'core_calendar/events',
  142. ], function(
  143. $,
  144. DragDrop,
  145. CalendarSelectors,
  146. CalendarEvents
  147. ) {
  148. var root = $('#month-detailed-{{uniqid}}');
  149. DragDrop.init(root);
  150. $('body').on(CalendarEvents.filterChanged, function(e, data) {
  151. M.util.js_pending("month-detailed-{{uniqid}}-filterChanged");
  152. // A filter value has been changed.
  153. // Find all matching cells in the popover data, and hide them.
  154. var target = $("#month-detailed-{{uniqid}}").find(CalendarSelectors.eventType[data.type]);
  155. var transitionPromise = $.Deferred();
  156. if (data.hidden) {
  157. transitionPromise.then(function() {
  158. return target.slideUp('fast').promise();
  159. });
  160. } else {
  161. transitionPromise.then(function() {
  162. return target.slideDown('fast').promise();
  163. });
  164. }
  165. transitionPromise.then(function() {
  166. M.util.js_complete("month-detailed-{{uniqid}}-filterChanged");
  167. return;
  168. });
  169. transitionPromise.resolve();
  170. });
  171. });
  172. {{/js}}