month.tpl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. {% extends "jquery_mobile/layout/layout_1_col.tpl" %}
  2. {% block content %}
  3. <script>
  4. function checkLength( o, n, min, max ) {
  5. if ( o.val().length > max || o.val().length < min ) {
  6. o.addClass( "ui-state-error" );
  7. updateTips( "Length of " + n + " must be between " +
  8. min + " and " + max + "." );
  9. return false;
  10. } else {
  11. return true;
  12. }
  13. }
  14. function clean_user_select() {
  15. //Cleans the selected attr
  16. $('#users_to_send_id')
  17. .find('option')
  18. .removeAttr('selected')
  19. .end();
  20. }
  21. var region_value = '{{ region_value }}';
  22. $(document).ready(function() {
  23. /*$("body").delegate(".datetime", "focusin", function(){
  24. $(this).datepicker({
  25. stepMinute: 10,
  26. dateFormat: 'dd/mm/yy',
  27. timeFormat: 'hh:mm:ss'
  28. });
  29. });*/
  30. var date = new Date();
  31. var d = date.getDate();
  32. var m = date.getMonth()+1;
  33. var y = date.getFullYear();
  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. $('#users_to_send_id').bind('change', function() {
  52. var selected_counts = $("#users_to_send_id option:selected").size();
  53. //alert(selected_counts);
  54. /* if (selected_counts >= 1 && $("#users_to_send_id option[value='everyone']").attr('selected') == 'selected') {
  55. clean_user_select();
  56. $('#users_to_send_id option').eq(0).attr('selected', 'selected');
  57. //deleting the everyone
  58. $("#users_to_send_id").trigger("liszt:updated");
  59. deleted_items = true;
  60. }*/
  61. $("#users_to_send_id").trigger("liszt:updated");
  62. /*
  63. if (selected_counts >= 1) {
  64. $('#users_to_send_id option').eq(0).removeAttr('selected');
  65. }
  66. */
  67. //clean_user_select();
  68. //$("#users_to_send_id").trigger("liszt:updated");
  69. //alert($("#users_to_send_id option[value='everyone']").attr('selected'));
  70. if ($("#users_to_send_id option[value='everyone']").attr('selected') == 'selected') {
  71. //clean_user_select();
  72. //$('#users_to_send_id option').eq(0).attr('selected', 'selected');
  73. //$("#users_to_send_id").trigger("liszt:updated");
  74. }
  75. });
  76. $.datepicker.setDefaults( $.datepicker.regional[region_value] );
  77. var calendar = $('#calendar').fullCalendar({
  78. header: {
  79. left: 'today prev,next',
  80. center: 'title',
  81. right: 'month,agendaWeek,agendaDay'
  82. },
  83. {% if use_google_calendar == 1 %}
  84. eventSources: [
  85. '{{ google_calendar_url }}', //if you want to add more just add URL in this array
  86. {
  87. className: 'gcal-event' // an option!
  88. }
  89. ],
  90. {% endif %}
  91. buttonText: {{ button_text }},
  92. monthNames: {{ month_names }},
  93. monthNamesShort:{{ month_names_short }},
  94. dayNames: {{ day_names }},
  95. dayNamesShort: {{ day_names_short }},
  96. firstHour: 8,
  97. firstDay: 1,
  98. selectable : true,
  99. selectHelper: true,
  100. viewDisplay: function(view) {
  101. /* When changing the view update the qtips */
  102. var api = $('.qtip').qtip('api'); // Access the API of the first tooltip on the page
  103. if (api) {
  104. api.destroy();
  105. //api.render();
  106. }
  107. },
  108. //add event
  109. select: function(start, end, allDay, jsEvent, view) {
  110. //Removing UTC stuff
  111. var start_date = $.datepicker.formatDate("yy-mm-dd", start) + " " + start.toTimeString().substr(0, 8);
  112. var end_date = $.datepicker.formatDate("yy-mm-dd", end) + " " + end.toTimeString().substr(0, 8);
  113. $('#visible_to_input').show();
  114. $('#add_as_announcement_div').show();
  115. $('#visible_to_read_only').hide();
  116. //Cleans the selected attr
  117. clean_user_select();
  118. //Sets the 1st item selected by jquery_mobile
  119. //$('#users_to_send_id option').eq(0).attr('selected', 'selected');
  120. //Update chz-select
  121. $("#users_to_send_id").trigger("liszt:updated");
  122. if ({{ can_add_events }} == 1) {
  123. var url = '{{ web_agenda_ajax_url }}&a=add_event&start='+start_date+'&end='+end_date+'&all_day='+allDay+'&view='+view.name;
  124. var start_date_value = $.datepicker.formatDate('{{ js_format_date }}', start);
  125. var end_date_value = $.datepicker.formatDate('{{ js_format_date }}', end);
  126. $('#start_date').html(start_date_value + " " + start.toTimeString().substr(0, 8));
  127. if (view.name != 'month') {
  128. $('#start_date').html(start_date_value + " " + start.toTimeString().substr(0, 8));
  129. if (start.toDateString() == end.toDateString()) {
  130. $('#end_date').html(' - '+end.toTimeString().substr(0, 8));
  131. } else {
  132. $('#end_date').html(' - '+start_date_value+" " + end.toTimeString().substr(0, 8));
  133. }
  134. } else {
  135. $('#start_date').html(start_date_value);
  136. $('#end_date').html(' ');
  137. }
  138. $('#color_calendar').html('{{ type_label }}');
  139. $('#color_calendar').removeClass('group_event');
  140. $('#color_calendar').addClass('label_tag');
  141. $('#color_calendar').addClass('{{ type_event_class }}');
  142. allFields.removeClass( "ui-state-error" );
  143. $("#dialog-form").dialog("open");
  144. $("#dialog-form").dialog({
  145. buttons: {
  146. '{{ "Add"|get_lang}}' : function() {
  147. var bValid = true;
  148. bValid = bValid && checkLength( title, "title", 1, 255 );
  149. //bValid = bValid && checkLength( content, "content", 1, 255 );
  150. var params = $("#add_event_form").serialize();
  151. $.ajax({
  152. url: url+'&'+params,
  153. success:function(data) {
  154. calendar.fullCalendar("refetchEvents");
  155. calendar.fullCalendar("rerenderEvents");
  156. $("#dialog-form").dialog("close");
  157. }
  158. });
  159. }
  160. },
  161. close: function() {
  162. $("#title").attr('value', '');
  163. $("#content").attr('value', '');
  164. }
  165. });
  166. //Don't follow the link
  167. return false;
  168. calendar.fullCalendar('unselect');
  169. //Reload events
  170. calendar.fullCalendar("refetchEvents");
  171. calendar.fullCalendar("rerenderEvents");
  172. }
  173. },
  174. eventRender: function(event, element) {
  175. if (event.attachment) {
  176. element.qtip({
  177. hide: {
  178. delay: 2000
  179. },
  180. content: event.attachment,
  181. position: { at:'top right' , my:'bottom right'},
  182. }).removeData('qtip'); // this is an special hack to add multiple qtip in the same target
  183. }
  184. if (event.description) {
  185. element.qtip({
  186. hide: {
  187. delay: 2000
  188. },
  189. content: event.description,
  190. position: { at:'top left' , my:'bottom left'}
  191. });
  192. }
  193. },
  194. eventClick: function(calEvent, jsEvent, view) {
  195. //var start_date = Math.round(calEvent.start.getTime() / 1000);
  196. var start_date = $.datepicker.formatDate("yy-mm-dd", calEvent.start) + " " + calEvent.start.toTimeString().substr(0, 8);
  197. if (calEvent.allDay == 1) {
  198. var end_date = '';
  199. } else {
  200. var end_date = '';
  201. if (calEvent.end && calEvent.end != '') {
  202. //var end_date = Math.round(calEvent.end.getTime() / 1000);
  203. var end_date = $.datepicker.formatDate("yy-mm-dd", calEvent.end) + " " + calEvent.end.toTimeString().substr(0, 8);
  204. }
  205. }
  206. //edit event
  207. if (calEvent.editable) {
  208. $('#visible_to_input').hide();
  209. $('#add_as_announcement_div').hide();
  210. {% if type != 'admin' %}
  211. $('#visible_to_read_only').show();
  212. $("#visible_to_read_only_users").html(calEvent.sent_to);
  213. {% endif %}
  214. $('#color_calendar').html('{{type_label}}');
  215. $('#color_calendar').addClass('label_tag');
  216. $('#color_calendar').removeClass('course_event');
  217. $('#color_calendar').removeClass('personal_event');
  218. $('#color_calendar').removeClass('group_event');
  219. $('#color_calendar').addClass(calEvent.type+'_event');
  220. my_start_month = calEvent.start.getMonth() +1;
  221. $('#start_date').html(calEvent.start.getDate() +"/"+ my_start_month +"/"+calEvent.start.getFullYear());
  222. if (end_date != '') {
  223. my_end_month = calEvent.end.getMonth() +1;
  224. $('#end_date').html(' '+calEvent.end.getDate() +"/"+ my_end_month +"/"+calEvent.end.getFullYear());
  225. }
  226. /*$("#title").attr('value', calEvent.title);
  227. $("#content").attr('value', calEvent.description);*/
  228. $("#title_edit").html(calEvent.title);
  229. $("#content_edit").html(calEvent.description);
  230. $("#title_edit").show();
  231. $("#content_edit").show();
  232. $("#title").attr('value', calEvent.title);
  233. $("#content").attr('value', calEvent.description);
  234. allFields.removeClass( "ui-state-error" );
  235. $("#dialog-form").dialog("open");
  236. var url = '{{web_agenda_ajax_url}}&a=edit_event&id='+calEvent.id+'&start='+start_date+'&end='+end_date+'&all_day='+calEvent.allDay+'&view='+view.name;
  237. var delete_url = '{{web_agenda_ajax_url}}&a=delete_event&id='+calEvent.id;
  238. $("#dialog-form").dialog({
  239. buttons: {
  240. '{{ "ExportiCalConfidential"|get_lang }}' : function() {
  241. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
  242. window.location.href = url;
  243. },
  244. '{{ "ExportiCalPrivate"|get_lang }}': function() {
  245. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
  246. window.location.href = url;
  247. },
  248. '{{ "ExportiCalPublic"|get_lang }}': function() {
  249. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
  250. window.location.href = url;
  251. },
  252. {% if type == 'not_available' %}
  253. '{{ "Edit"|get_lang }}' : function() {
  254. var bValid = true;
  255. bValid = bValid && checkLength( title, "title", 1, 255 );
  256. var params = $("#add_event_form").serialize();
  257. $.ajax({
  258. url: url+'&'+params,
  259. success:function() {
  260. calEvent.title = $("#title").val();
  261. calEvent.start = calEvent.start;
  262. calEvent.end = calEvent.end;
  263. calEvent.allDay = calEvent.allDay;
  264. calEvent.description = $("#content").val();
  265. calendar.fullCalendar('updateEvent',
  266. calEvent,
  267. true // make the event "stick"
  268. );
  269. $("#dialog-form").dialog("close");
  270. }
  271. });
  272. },
  273. {% endif %}
  274. '{{ "Edit"|get_lang }}' : function() {
  275. url = "agenda.php?action=edit&type=fromjs&id=" + calEvent.id+'&course_id='+calEvent.course_id+"";
  276. window.location.href = url;
  277. $("#dialog-form").dialog( "close" );
  278. },
  279. '{{ "Delete"|get_lang }}': function() {
  280. $.ajax({
  281. url: delete_url,
  282. success:function() {
  283. calendar.fullCalendar('removeEvents',
  284. calEvent
  285. );
  286. calendar.fullCalendar("refetchEvents");
  287. calendar.fullCalendar("rerenderEvents");
  288. $("#dialog-form").dialog( "close" );
  289. }
  290. });
  291. }
  292. },
  293. close: function() {
  294. $("#title").attr('value', '');
  295. $("#content").attr('value', '');
  296. $("#title").show();
  297. $("#content").show();
  298. $("#title_edit").html('');
  299. $("#content_edit").html('');
  300. $("#title").attr('value', '');
  301. $("#content").attr('value', '');
  302. }
  303. });
  304. } else { //simple form
  305. my_start_month = calEvent.start.getMonth() +1;
  306. $('#simple_start_date').html(calEvent.start.getDate() +"/"+ my_start_month +"/"+calEvent.start.getFullYear());
  307. if (end_date != '') {
  308. my_end_month = calEvent.end.getMonth() +1;
  309. $('#simple_start_date').html(calEvent.start.getDate() +"/"+ my_start_month +"/"+calEvent.start.getFullYear() +" - "+calEvent.start.toLocaleTimeString());
  310. $('#simple_end_date').html(' '+calEvent.end.getDate() +"/"+ my_end_month +"/"+calEvent.end.getFullYear() +" - "+calEvent.end.toLocaleTimeString());
  311. }
  312. $("#simple_title").html(calEvent.title);
  313. $("#simple_content").html(calEvent.description);
  314. $("#simple-dialog-form").dialog("open");
  315. $("#simple-dialog-form").dialog({
  316. buttons: {
  317. '{{"ExportiCalConfidential"|get_lang}}' : function() {
  318. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
  319. window.location.href = url;
  320. },
  321. '{{"ExportiCalPrivate"|get_lang}}': function() {
  322. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
  323. window.location.href = url;
  324. },
  325. '{{"ExportiCalPublic"|get_lang}}': function() {
  326. url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
  327. window.location.href = url;
  328. }
  329. }
  330. });
  331. }
  332. },
  333. editable: true,
  334. events: "{{web_agenda_ajax_url}}&a=get_events",
  335. eventDrop: function(event, day_delta, minute_delta, all_day, revert_func) {
  336. $.ajax({
  337. url: '{{web_agenda_ajax_url}}',
  338. data: {
  339. a:'move_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta
  340. }
  341. });
  342. },
  343. eventResize: function(event, day_delta, minute_delta, revert_func) {
  344. $.ajax({
  345. url: '{{web_agenda_ajax_url}}',
  346. data: {
  347. a:'resize_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta
  348. }
  349. });
  350. },
  351. axisFormat: 'HH(:mm)',
  352. timeFormat: 'HH:mm{ - HH:mm}',
  353. loading: function(bool) {
  354. if (bool) $('#loading').show();
  355. else $('#loading').hide();
  356. }
  357. });
  358. });
  359. </script>
  360. <div id="simple-dialog-form" style="display:none;">
  361. <div style="width:500px">
  362. <form name="form-simple" class="form-vertical" >
  363. <div class="control-group">
  364. <label class="control-label"><b>{{"Date"|get_lang}}</b></label>
  365. <div class="controls">
  366. <span id="simple_start_date"></span><span id="simple_end_date"></span>
  367. </div>
  368. </div>
  369. <div class="control-group">
  370. <label class="control-label"><b>{{"Title"|get_lang}}</b></label>
  371. <div class="controls">
  372. <div id="simple_title"></div>
  373. </div>
  374. </div>
  375. <div class="control-group">
  376. <label class="control-label"><b>{{"Description"|get_lang}}</b></label>
  377. <div class="controls">
  378. <div id="simple_content"></div>
  379. </div>
  380. </div>
  381. </form>
  382. </div>
  383. </div>
  384. <div id="dialog-form" style="display:none;">
  385. <div style="width:500px">
  386. <form class="form-horizontal" id="add_event_form" name="form">
  387. {% if visible_to is not null %}
  388. <div id="visible_to_input" class="control-group">
  389. <label class="control-label">{{ "To"|get_lang }}</label>
  390. <div class="controls">
  391. {{visible_to}}
  392. </div>
  393. </div>
  394. {% endif %}
  395. <div id="visible_to_read_only" class="control-group" style="display:none">
  396. <label class="control-label">{{ "To"|get_lang }}</label>
  397. <div class="controls">
  398. <div id="visible_to_read_only_users"></div>
  399. </div>
  400. </div>
  401. <div class="control-group">
  402. <label class="control-label">{{ "Agenda"|get_lang }}</label>
  403. <div class="controls">
  404. <div id="color_calendar"></div>
  405. </div>
  406. </div>
  407. <div class="control-group">
  408. <label class="control-label" for="end_date">{{"Date"|get_lang}}</label>
  409. <div class="controls">
  410. <span id="start_date"></span><span id="end_date"></span>
  411. </div>
  412. </div>
  413. <div class="control-group">
  414. <label class="control-label" for="title">{{ "Title"|get_lang }}</label>
  415. <div class="controls">
  416. <input type="text" name="title" id="title" size="40" />
  417. <span id="title_edit"></span>
  418. </div>
  419. </div>
  420. <div class="control-group">
  421. <label class="control-label" for="content">{{ "Description"|get_lang }}</label>
  422. <div class="controls">
  423. <textarea name="content" id="content" class="span3" rows="5"></textarea>
  424. <span id="content_edit"></span>
  425. </div>
  426. </div>
  427. {% if type == 'course' %}
  428. <div id="add_as_announcement_div">
  429. <div class="control-group">
  430. <label></label>
  431. <div class="controls">
  432. <label class="checkbox inline" for="add_as_annonuncement">
  433. {{ "AddAsAnnouncement"|get_lang }} ({{ "SendEmail" | get_lang }})
  434. <input type="checkbox" name="add_as_annonuncement" id="add_as_annonuncement" />
  435. </label>
  436. </div>
  437. </div>
  438. </div>
  439. {% endif %}
  440. </form>
  441. </div>
  442. </div>
  443. <div id="loading" style="margin-left:150px;position:absolute;display:none">{{"Loading"|get_lang}}...</div>
  444. <div id="calendar"></div>
  445. {% endblock %}