month.tpl 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. <style>
  2. .fc-day-grid-event > .fc-content {
  3. white-space: normal;
  4. }
  5. </style>
  6. <script>
  7. function checkLength( o, n, min, max ) {
  8. if ( o.val().length > max || o.val().length < min ) {
  9. o.addClass( "ui-state-error" );
  10. /*updateTips( "Length of " + n + " must be between " +
  11. min + " and " + max + "." );*/
  12. return false;
  13. } else {
  14. return true;
  15. }
  16. }
  17. function clean_user_select() {
  18. //Cleans the selected attr
  19. $("#users_to_send").val('').trigger("chosen:updated");
  20. /*$('#users_to_send')
  21. .find('option')
  22. .removeAttr('selected')
  23. .end();*/
  24. }
  25. var region_value = '{{ region_value }}';
  26. $(document).ready(function() {
  27. var cookieData = Cookies.getJSON('agenda_cookies');
  28. var defaultView = (cookieData && cookieData.view) || '{{ default_view }}';
  29. var defaultStartDate = (cookieData && cookieData.start) || moment.now();
  30. // Reset button.
  31. $("button[type=reset]").click(function() {
  32. $("#session_id").find('option').removeAttr("selected");
  33. });
  34. $("#dialog-form").dialog({
  35. autoOpen : false,
  36. modal : false,
  37. width : 580,
  38. height : 480,
  39. zIndex : 20000 // added because of qtip2
  40. });
  41. $("#simple-dialog-form").dialog({
  42. autoOpen : false,
  43. modal : false,
  44. width : 580,
  45. height : 480,
  46. zIndex : 20000 // added because of qtip2
  47. });
  48. var title = $("#title"),
  49. content = $("#content"),
  50. allFields = $([]).add( title ).add( content ), tips = $(".validateTips");
  51. $("#select_form_id_search").change(function() {
  52. var temp ="&user_id="+$("#select_form_id_search").val();
  53. var position =String(window.location).indexOf("&user");
  54. var url = String(window.location).substring(0,position)+temp;
  55. if (position > 0) {
  56. window.location.replace(url);
  57. } else {
  58. url = String(window.location)+temp;
  59. window.location.replace(url);
  60. }
  61. });
  62. var CustomListViewGrid = ListViewGrid.extend({
  63. fgSegHtml: function(seg) {
  64. var view = this.view;
  65. var classes = [ 'fc-list-item' ].concat(this.getSegCustomClasses(seg));
  66. var bgColor = this.getSegBackgroundColor(seg);
  67. var event = seg.event;
  68. var url = event.url;
  69. var timeHtml;
  70. if (event.allDay) {
  71. timeHtml = view.getAllDayHtml();
  72. }
  73. else if (view.isMultiDayEvent(event)) { // if the event appears to span more than one day
  74. if (seg.isStart || seg.isEnd) { // outer segment that probably lasts part of the day
  75. timeHtml = htmlEscape(this.getEventTimeText(seg));
  76. }
  77. else { // inner segment that lasts the whole day
  78. timeHtml = view.getAllDayHtml();
  79. }
  80. }
  81. else {
  82. // Display the normal time text for the *event's* times
  83. timeHtml = htmlEscape(this.getEventTimeText(event));
  84. }
  85. if (url) {
  86. classes.push('fc-has-url');
  87. }
  88. return '<tr class="' + classes.join(' ') + '">' +
  89. (this.displayEventTime ?
  90. '<td class="fc-list-item-time ' + view.widgetContentClass + '">' +
  91. (timeHtml || '') +
  92. '</td>' :
  93. '') +
  94. '<td class="fc-list-item-marker ' + view.widgetContentClass + '">' +
  95. '<span class="fc-event-dot"' +
  96. (bgColor ?
  97. ' style="background-color:' + bgColor + '"' :
  98. '') +
  99. '></span>' +
  100. '</td>' +
  101. '<td class="fc-list-item-title ' + view.widgetContentClass + '">' +
  102. '<a' + (url ? ' href="' + htmlEscape(url) + '"' : '') + '>' +
  103. htmlEscape(seg.event.title || '') + (seg.event.description || '')
  104. '</a>' +
  105. '</td>' +
  106. '</tr>';
  107. },
  108. // render the event segments in the view
  109. renderSegList: function(allSegs) {
  110. var segsByDay = this.groupSegsByDay(allSegs); // sparse array
  111. var dayIndex;
  112. var daySegs;
  113. var i;
  114. var tableEl = $('<table class="fc-list-table"><tbody/></table>');
  115. var tbodyEl = tableEl.find('tbody');
  116. var eventList = new Array;
  117. for (dayIndex = 0; dayIndex < segsByDay.length; dayIndex++) {
  118. daySegs = segsByDay[dayIndex];
  119. if (daySegs) { // sparse array, so might be undefined
  120. this.sortEventSegs(daySegs);
  121. for (i = 0; i < daySegs.length; i++) {
  122. var event = daySegs[i].event;
  123. if (jQuery.inArray(event.id, eventList) !== -1) {
  124. continue;
  125. }
  126. eventList.push(event.id);
  127. // append a day header
  128. tbodyEl.append(this.dayHeaderHtml(
  129. this.view.start.clone().add(dayIndex, 'days'),
  130. event
  131. ));
  132. tbodyEl.append(daySegs[i].el); // append event row
  133. }
  134. }
  135. }
  136. this.el.empty().append(tableEl);
  137. },
  138. // generates the HTML for the day headers that live amongst the event rows
  139. dayHeaderHtml: function(dayDate, event) {
  140. var view = this.view;
  141. var mainFormat = 'LL';
  142. var altFormat = 'dddd';
  143. var checkIfSame = true;
  144. if (event.end) {
  145. checkIfSame = event.end.format(mainFormat) == dayDate.format(mainFormat);
  146. }
  147. return '<tr class="fc-list-heading" data-date="' + dayDate.format('YYYY-MM-DD') + '">' +
  148. '<td class="' + view.widgetHeaderClass + '" colspan="3">' +
  149. (mainFormat ?
  150. view.buildGotoAnchorHtml(
  151. dayDate,
  152. { 'class': 'fc-list-heading-main' },
  153. htmlEscape(dayDate.format(mainFormat)) // inner HTML
  154. ) :
  155. '') +
  156. ((checkIfSame == false && mainFormat) ?
  157. view.buildGotoAnchorHtml(
  158. dayDate,
  159. { 'class': 'fc-list-heading-main' },
  160. '&nbsp;-&nbsp; ' + htmlEscape(event.end.format(mainFormat)) // inner HTML
  161. ) :
  162. '') +
  163. (altFormat ?
  164. view.buildGotoAnchorHtml(
  165. dayDate,
  166. { 'class': 'fc-list-heading-alt' },
  167. htmlEscape(dayDate.format(altFormat)) // inner HTML
  168. ) :
  169. '') +
  170. '</td>' +
  171. '</tr>';
  172. },
  173. });
  174. var FC = $.fullCalendar; // a reference to FullCalendar's root namespace
  175. var View = ListView; // the class that all views must inherit from
  176. var CustomView; // our subclass
  177. CustomView = View.extend({ // make a subclass of View
  178. initialize: function() {
  179. this.grid = new CustomListViewGrid(this);
  180. this.scroller = new Scroller({
  181. overflowX: 'hidden',
  182. overflowY: 'auto'
  183. });
  184. }
  185. });
  186. FC.views.CustomView = CustomView; // register our class with the view system
  187. var height = '';
  188. if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
  189. height = 'auto';
  190. }
  191. var calendar = $('#calendar').fullCalendar({
  192. height: height,
  193. header: {
  194. left: 'today,prev,next',
  195. center: 'title',
  196. right: 'month,agendaWeek,agendaDay,CustomView'
  197. },
  198. views: {
  199. CustomView: { // name of view
  200. type: 'list',
  201. buttonText: '{{ 'AgendaList' | get_lang | escape('js') }}',
  202. duration: { month: 1 },
  203. defaults: {
  204. 'listDayAltFormat': 'dddd' // day-of-week is nice-to-have
  205. }
  206. },
  207. month: {
  208. 'displayEventEnd' : true
  209. }
  210. },
  211. locale: region_value,
  212. {% if use_google_calendar == 1 %}
  213. eventSources: [
  214. // if you want to add more just add URL in this array
  215. '{{ google_calendar_url }}',
  216. {
  217. className: 'gcal-event' // an option!
  218. }
  219. ],
  220. {% endif %}
  221. defaultView: defaultView,
  222. defaultDate: defaultStartDate,
  223. firstHour: 8,
  224. firstDay: 1,
  225. selectable : true,
  226. selectHelper: true,
  227. viewDisplay: function(view) {
  228. /* When changing the view update the qtips */
  229. /*var api = $('.qtip').qtip('api'); // Access the API of the first tooltip on the page
  230. if (api) {
  231. api.destroy();
  232. //api.render();
  233. }*/
  234. },
  235. viewRender: function(view, element) {
  236. var data = {
  237. 'view': view.name,
  238. 'start': view.intervalStart.format("YYYY-MM-DD")
  239. };
  240. Cookies.set('agenda_cookies', data, 1); // Expires 1 day
  241. },
  242. // Add event
  243. select: function(start, end, jsEvent, view) {
  244. var diffDays = moment(end).diff(start, 'days');
  245. var allDay = true;
  246. if (end.hasTime()) {
  247. allDay = false;
  248. }
  249. $('#visible_to_input').show();
  250. $('#add_as_announcement_div').show();
  251. $('#visible_to_read_only').hide();
  252. // Cleans the selected attr
  253. clean_user_select();
  254. // Sets the 1st item selected by default
  255. $('#users_to_send option').eq(0).attr('selected', 'selected');
  256. // Update chz-select
  257. //$("#users_to_send").trigger("chosen:updated");
  258. if ({{ can_add_events }} == 1) {
  259. var startEn = start.clone().locale('en'),
  260. endEn = end.clone().locale('en');
  261. var url = '{{ web_agenda_ajax_url }}&a=add_event&start='+startEn.format("YYYY-MM-DD HH:mm:00")+'&end='+endEn.format("YYYY-MM-DD HH:mm:00")+'&all_day='+allDay+'&view='+view.name;
  262. var start_date_value = start.format('{{ js_format_date }}');
  263. $('#start_date').html(start_date_value);
  264. if (diffDays > 1) {
  265. $('#start_date').html('');
  266. var end_date_value = '';
  267. if (end) {
  268. var clone = end.clone();
  269. end_date_value = clone.subtract(1, 'days').format('{{ js_format_date }}');
  270. }
  271. $('#end_date').html(start_date_value + " - " + end_date_value);
  272. } else if (diffDays == 0) {
  273. var start_date_value = start.format('ll');
  274. var startTime = start.format('LT');
  275. var endTime = end.format('LT');
  276. $('#start_date').html('');
  277. $('#end_date').html(start_date_value + " (" + startTime + " - " + endTime+") ");
  278. } else {
  279. $('#end_date').html('');
  280. }
  281. $('#color_calendar')
  282. .html('{{ type_label | escape('js')}}')
  283. .removeClass('group_event')
  284. .addClass('label_tag')
  285. .addClass('{{ type_event_class | escape('js') }}')
  286. .css('background-color', '{{ type_event_color }}');
  287. //It shows the CKEDITOR while Adding an Event
  288. $('#cke_content').show();
  289. //It Fixing a minor bug with textarea ckeditor.remplace
  290. $('#content').css('display','none');
  291. //Reset the CKEditor content that persist in memory
  292. CKEDITOR.instances['content'].setData('');
  293. allFields.removeClass("ui-state-error");
  294. $("#dialog-form").dialog("open");
  295. $("#dialog-form").dialog({
  296. buttons: {
  297. '{{ "Add" | get_lang }}' : function() {
  298. var bValid = true;
  299. bValid = bValid && checkLength(title, "title", 1, 255);
  300. //Update the CKEditor Instance to the remplaced textarea, ready to be serializable
  301. for ( instance in CKEDITOR.instances ) {
  302. CKEDITOR.instances[instance].updateElement();
  303. }
  304. var params = $("#add_event_form").serialize();
  305. $.ajax({
  306. url: url+'&'+params,
  307. success:function(data) {
  308. var user = $('#users_to_send').val();
  309. if (user) {
  310. if (user.length > 1) {
  311. user = 0;
  312. } else {
  313. user = user[0];
  314. }
  315. var user_length = String(user).length;
  316. if (String(user).substring(0,1) == 'G') {
  317. var user_id = String(user).substring(6,user_length);
  318. var user_id = "G:"+user_id;
  319. } else {
  320. var user_id = String(user).substring(5,user_length);
  321. }
  322. var temp = "&user_id="+user_id;
  323. var position = String(window.location).indexOf("&user");
  324. var url = String(window.location).substring(0, position)+temp;
  325. /*if (position > 0) {
  326. window.location.replace(url);
  327. } else {
  328. url = String(window.location)+temp;
  329. window.location.replace(url);
  330. }*/
  331. }
  332. $("#title").val('');
  333. $("#content").val('');
  334. $("#comment").val('');
  335. calendar.fullCalendar('refetchEvents');
  336. calendar.fullCalendar('rerenderEvents');
  337. $("#dialog-form").dialog('close');
  338. }
  339. });
  340. }
  341. },
  342. close: function() {
  343. $("#title").val('');
  344. $("#content").val('');
  345. $("#comment").val('');
  346. }
  347. });
  348. calendar.fullCalendar('unselect');
  349. //Reload events
  350. calendar.fullCalendar("refetchEvents");
  351. calendar.fullCalendar("rerenderEvents");
  352. }
  353. },
  354. eventRender: function(event, element) {
  355. if (event.attachment) {
  356. /*element.qtip({
  357. hide: {
  358. delay: 2000
  359. },
  360. content: event.attachment,
  361. position: { at:'top right' , my:'bottom right'}
  362. }).removeData('qtip'); // this is an special hack to add multiple qtip in the same target
  363. */
  364. }
  365. var onHoverInfo = '';
  366. {% if on_hover_info.description %}
  367. if (event.description) {
  368. onHoverInfo = event.description;
  369. }
  370. {% endif %}
  371. {% if on_hover_info.comment %}
  372. if (event.comment) {
  373. onHoverInfo = onHoverInfo + event.comment;
  374. }
  375. {% endif %}
  376. if (onHoverInfo) {
  377. element.qtip({
  378. content: onHoverInfo,
  379. position: {
  380. at: 'top center',
  381. my: 'bottom center',
  382. viewport: $(window)
  383. }
  384. });
  385. }
  386. },
  387. eventClick: function(calEvent, jsEvent, view) {
  388. var start = calEvent.start;
  389. var end = calEvent.end;
  390. var diffDays = moment(end).diff(start, 'days');
  391. var endDateMinusOne = '';
  392. // If event is not editable then just return the qtip
  393. if (!calEvent.editable) {
  394. var onHoverInfo = '';
  395. {% if calEvent.description %}
  396. if (calEvent.description) {
  397. onHoverInfo = calEvent.description;
  398. }
  399. {% endif %}
  400. {% if on_hover_info.comment %}
  401. if (calEvent.comment) {
  402. onHoverInfo = onHoverInfo + calEvent.comment;
  403. }
  404. {% endif %}
  405. if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
  406. $(this).qtip({
  407. overwrite: false,
  408. show: {ready: true},
  409. content: onHoverInfo,
  410. position: {
  411. at: 'top center',
  412. my: 'bottom center',
  413. viewport: $(window)
  414. }
  415. });
  416. return;
  417. }
  418. }
  419. if (end) {
  420. var clone = end.clone();
  421. endDateMinusOne = clone.subtract(1, 'days').format('{{ js_format_date }}');
  422. }
  423. var startDateToString = start.format("{{ js_format_date }}");
  424. // Edit event.
  425. if (calEvent.editable) {
  426. $('#visible_to_input').hide();
  427. $('#add_as_announcement_div').hide();
  428. {% if type != 'admin' %}
  429. $('#visible_to_read_only').show();
  430. $("#visible_to_read_only_users").html(calEvent.sent_to);
  431. {% endif %}
  432. $('#color_calendar').html('{{ type_label | escape('js') }}');
  433. $('#color_calendar').addClass('label_tag');
  434. $('#color_calendar').removeClass('course_event');
  435. $('#color_calendar').removeClass('personal_event');
  436. $('#color_calendar').removeClass('group_event');
  437. $('#color_calendar').addClass(calEvent.type+'_event');
  438. // It hides the CKEDITOR while clicking an existing Event
  439. $('#cke_content').hide();
  440. $('#start_date').html(startDateToString);
  441. if (diffDays > 1) {
  442. $('#end_date').html(' - ' + endDateMinusOne);
  443. } else if (diffDays == 0) {
  444. var start_date_value = start.format('ll');
  445. var startTime = start.format('LT');
  446. var endTime = end.format('LT');
  447. $('#start_date').html('');
  448. $('#end_date').html(start_date_value + " (" + startTime + " - " + endTime+") ");
  449. } else {
  450. $('#end_date').html('');
  451. }
  452. if ($("#title").parent().find('#title_edit').length == 0) {
  453. $("#title").parent().append('<div id="title_edit"></div>');
  454. }
  455. $("#title_edit").html(calEvent.title);
  456. if ($("#content").parent().find('#content_edit').length == 0) {
  457. $("#content").parent().append('<div id="content_edit"></div>');
  458. }
  459. $("#content_edit").html(calEvent.description);
  460. if ($("#comment").parent().find('#comment_edit').length == 0) {
  461. $("#comment").parent().append('<div id="comment_edit"></div>');
  462. }
  463. if (calEvent.course_name) {
  464. $("#calendar_course_info").html(
  465. '<div class="form-group"><label class="col-sm-2 control-label">{{ 'Course' | get_lang }}</label>' +
  466. '<div class="class="col-sm-8">' + calEvent.course_name+"</div></div>"
  467. );
  468. } else {
  469. $("#calendar_course_info").html('');
  470. }
  471. if (calEvent.session_name) {
  472. $("#calendar_session_info").html(
  473. '<div class="form-group"><label class="col-sm-2 control-label">{{ 'Session' | get_lang }}</label>'+
  474. '<div class="class="col-sm-8">' + calEvent.session_name+"</div></div>"
  475. );
  476. } else {
  477. $("#calendar_session_info").html('');
  478. }
  479. $("#comment_edit").html(calEvent.comment);
  480. $("#title_edit").show();
  481. $("#content_edit").show();
  482. $("#comment_edit").show();
  483. $("#title").hide();
  484. $("#content").hide();
  485. $("#comment").hide();
  486. allFields.removeClass( "ui-state-error" );
  487. $("#dialog-form").dialog("open");
  488. var url = '{{ web_agenda_ajax_url }}&a=edit_event&id='+calEvent.id+'&view='+view.name;
  489. var delete_url = '{{ web_agenda_ajax_url }}&a=delete_event&id='+calEvent.id;
  490. $("#dialog-form").dialog({
  491. buttons: {
  492. '{{ "ExportiCalConfidential"|get_lang }}' : function() {
  493. url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
  494. window.location.href = url;
  495. },
  496. '{{ "ExportiCalPrivate"|get_lang }}': function() {
  497. url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
  498. window.location.href = url;
  499. },
  500. '{{ "ExportiCalPublic"|get_lang }}': function() {
  501. url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
  502. window.location.href = url;
  503. },
  504. {% if type == 'not_available' %}
  505. '{{ "Edit" | get_lang }}' : function() {
  506. var bValid = true;
  507. bValid = bValid && checkLength( title, "title", 1, 255 );
  508. var params = $("#add_event_form").serialize();
  509. $.ajax({
  510. url: url+'&'+params,
  511. success:function() {
  512. calEvent.title = $("#title").val();
  513. calEvent.start = calEvent.start;
  514. calEvent.end = calEvent.end;
  515. calEvent.allDay = calEvent.allDay;
  516. calEvent.description = $("#content").val();
  517. calendar.fullCalendar('updateEvent',
  518. calEvent,
  519. true // make the event "stick"
  520. );
  521. $("#dialog-form").dialog("close");
  522. }
  523. });
  524. },
  525. {% endif %}
  526. '{{ "Edit"|get_lang }}' : function() {
  527. url = "{{ _p.web_main }}calendar/agenda.php?action=edit&type=fromjs&id="+calEvent.id+'&course_id='+calEvent.course_id+"";
  528. window.location.href = url;
  529. $("#dialog-form").dialog( "close" );
  530. },
  531. '{{ "Delete"|get_lang }}': function() {
  532. if (calEvent.parent_event_id || calEvent.has_children != '') {
  533. var newDiv = $('<div>');
  534. newDiv.dialog({
  535. modal: true,
  536. title: "{{ 'DeleteThisItem' | get_lang }}",
  537. buttons: []
  538. });
  539. var buttons = newDiv.dialog("option", "buttons");
  540. if (calEvent.has_children == '0') {
  541. buttons.push({
  542. text: '{{ "DeleteThisItem" | get_lang }}',
  543. click: function() {
  544. $.ajax({
  545. url: delete_url,
  546. success:function() {
  547. calendar.fullCalendar('removeEvents',
  548. calEvent
  549. );
  550. calendar.fullCalendar("refetchEvents");
  551. calendar.fullCalendar("rerenderEvents");
  552. $("#dialog-form").dialog("close");
  553. newDiv.dialog( "destroy" );
  554. }
  555. });
  556. }
  557. });
  558. newDiv.dialog("option", "buttons", buttons);
  559. }
  560. var buttons = newDiv.dialog("option", "buttons");
  561. buttons.push({
  562. text: '{{ "DeleteAllItems" | get_lang }}',
  563. click: function() {
  564. $.ajax({
  565. url: delete_url+'&delete_all_events=1',
  566. success:function() {
  567. calendar.fullCalendar('removeEvents',
  568. calEvent
  569. );
  570. calendar.fullCalendar('refetchEvents');
  571. calendar.fullCalendar('rerenderEvents');
  572. $("#dialog-form").dialog('close');
  573. newDiv.dialog( "destroy" );
  574. }
  575. });
  576. }
  577. });
  578. newDiv.dialog("option", "buttons", buttons);
  579. return true;
  580. }
  581. $.ajax({
  582. url: delete_url,
  583. success:function() {
  584. calendar.fullCalendar('removeEvents',
  585. calEvent
  586. );
  587. calendar.fullCalendar('refetchEvents');
  588. calendar.fullCalendar('rerenderEvents');
  589. $("#dialog-form").dialog('close');
  590. }
  591. });
  592. }
  593. },
  594. close: function() {
  595. $("#title_edit").hide();
  596. $("#content_edit").hide();
  597. $("#comment_edit").hide();
  598. $("#title").show();
  599. $("#content").show();
  600. $("#comment").show();
  601. $("#title_edit").html('');
  602. $("#content_edit").html('');
  603. $("#comment_edit").html('');
  604. $("#title").val('');
  605. $("#content").val('');
  606. $("#comment").val('');
  607. }
  608. });
  609. } else {
  610. // Simple form
  611. $('#simple_start_date').html(startDateToString);
  612. if (diffDays > 1) {
  613. $('#simple_end_date').html(' - ' + endDateMinusOne);
  614. } else if (diffDays == 0) {
  615. var start_date_value = start.format('ll');
  616. var startTime = start.format('LT');
  617. var endTime = end.format('LT');
  618. $('#simple_start_date').html('');
  619. $('#simple_end_date').html(start_date_value + " (" + startTime + " - " + endTime+") ");
  620. } else {
  621. $('#simple_end_date').html('');
  622. }
  623. if (calEvent.course_name) {
  624. $("#calendar_course_info_simple").html(
  625. '<div class="form-group"><label class="col-sm-3 control-label">{{ 'Course' | get_lang }}</label>' +
  626. '<div class="col-sm-9">' + calEvent.course_name+"</div></div>"
  627. );
  628. } else {
  629. $("#calendar_course_info_simple").html('');
  630. }
  631. if (calEvent.session_name) {
  632. $("#calendar_session_info").html(
  633. '<div class="form-group"><label class="col-sm-3 control-label">{{ 'Session' | get_lang }}</label>' +
  634. '<div class="col-sm-9">' + calEvent.session_name+"</div></div>"
  635. );
  636. } else {
  637. $("#calendar_session_info").html('');
  638. }
  639. $("#simple_title").html(calEvent.title);
  640. $("#simple_content").html(calEvent.description);
  641. $("#simple_comment").html(calEvent.comment);
  642. $("#simple-dialog-form").dialog("open");
  643. $("#simple-dialog-form").dialog({
  644. buttons: {
  645. '{{"ExportiCalConfidential"|get_lang}}' : function() {
  646. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
  647. window.location.href = url;
  648. },
  649. '{{"ExportiCalPrivate"|get_lang}}': function() {
  650. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
  651. window.location.href = url;
  652. },
  653. '{{"ExportiCalPublic"|get_lang}}': function() {
  654. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
  655. window.location.href = url;
  656. }
  657. }
  658. });
  659. }
  660. },
  661. editable: true,
  662. events: "{{web_agenda_ajax_url}}&a=get_events",
  663. eventDrop: function(event, delta, revert_func) {
  664. var allDay = 0;
  665. if (event.allDay == true) {
  666. allDay = 1;
  667. }
  668. $.ajax({
  669. url: '{{ web_agenda_ajax_url }}',
  670. data: {
  671. a: 'move_event',
  672. id: event.id,
  673. all_day: allDay,
  674. minute_delta: delta.asMinutes()
  675. }
  676. });
  677. },
  678. eventResize: function(event, delta, revert_func) {
  679. $.ajax({
  680. url: '{{ web_agenda_ajax_url }}',
  681. data: {
  682. a: 'resize_event',
  683. id: event.id,
  684. minute_delta: delta.asMinutes()
  685. }
  686. });
  687. },
  688. axisFormat: 'H(:mm)', // pm-am format -> h(:mm)a
  689. timeFormat: 'H:mm', // pm-am format -> h:mm
  690. loading: function(bool) {
  691. if (bool) $('#loading').show();
  692. else $('#loading').hide();
  693. }
  694. });
  695. });
  696. </script>
  697. {{ actions_div }}
  698. {{ toolbar }}
  699. <div id="simple-dialog-form" style="display:none;">
  700. <div style="width:500px">
  701. <form name="form-simple" class="form-horizontal">
  702. <span id="calendar_course_info_simple"></span>
  703. <span id="calendar_session_info"></span>
  704. <div class="form-group">
  705. <label class="col-sm-3 control-label">
  706. <b>{{ "Date" |get_lang}}</b>
  707. </label>
  708. <div class="col-sm-9">
  709. <span id="simple_start_date"></span>
  710. <span id="simple_end_date"></span>
  711. </div>
  712. </div>
  713. <div class="form-group">
  714. <label class="col-sm-3 control-label">
  715. <b>{{ "Title" |get_lang}}</b>
  716. </label>
  717. <div class="col-sm-9">
  718. <div id="simple_title"></div>
  719. </div>
  720. </div>
  721. <div class="form-group">
  722. <label class="col-sm-3 control-label">
  723. <b>{{ "Description" |get_lang}}</b>
  724. </label>
  725. <div class="col-sm-9">
  726. <div id="simple_content"></div>
  727. </div>
  728. </div>
  729. <div class="form-group">
  730. <label class="col-sm-3 control-label">
  731. <b>{{ "Comment" |get_lang}}</b>
  732. </label>
  733. <div class="col-sm-9">
  734. <div id="simple_comment"></div>
  735. </div>
  736. </div>
  737. </form>
  738. </div>
  739. </div>
  740. <div id="dialog-form" style="display:none;">
  741. <div class="dialog-form-content">
  742. {{ form_add }}
  743. </div>
  744. </div>
  745. {% if legend_list %}
  746. {% for color, text in legend_list %}
  747. <span style="background-color: {{ color }}" class="label label-default">&nbsp;</span> {{ text }} &nbsp;&nbsp;
  748. {% endfor %}
  749. <br /><br />
  750. {% endif %}
  751. <div id="loading" style="margin-left:150px;position:absolute;display:none">
  752. {{ "Loading" | get_lang }}...
  753. </div>
  754. <div id="calendar"></div>