1 <& /util/import_javascript.mas, classes => [ "calendar.moment_min", "calendar.fullcalendar_min", "jquery.dataTables", "calendar.fullcalendar_gcal_min", "calendar.bootstrap_datepicker_min" ] &>
3 <& /util/import_css.mas, paths => ['/css/datepicker.css'] &>
13 .datepicker{z-index:1151 !important;}
16 <div class="modal fade" id="calendar_modal" name="calendar_modal" tabindex="-1" role="dialog" aria-labelledby="calendarDialog">
17 <div class="modal-dialog modal-lg" role="document">
18 <div class="modal-content">
19 <div class="modal-header">
20 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
21 <h4 class="modal-title" id="calendarDialog">Your Calendar</h4>
23 <div class="modal-body">
24 <div class="container-fluid">
25 <div id='calendar' style="background:#f9f9f9; padding:2px; width:100%">
29 <div class="well well-sm">
31 <p><b>Having trouble viewing events on the calendar?</b> <br/>Are you associated with the breeding program you are interested in viewing?</p>
32 <a class="btn btn-primary" id="calendar_bp_user_roles_show" href="/breeders/manage_roles/">Calendar Permissions</a>
37 <div class="modal-footer">
38 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
46 <div class="modal fade" id="day_dialog" name="day_dialog" tabindex="-1" role="dialog" aria-labelledby="addEventDialog">
47 <div class="modal-dialog" role="document">
48 <div class="modal-content">
49 <div class="modal-header">
50 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
51 <h4 class="modal-title" id="addEventDialog">Add New Event</h4>
53 <div class="modal-body">
54 <div class="container-fluid">
55 <form class="form-horizontal" role="form" name="day_dialog_add_event_form" id="day_dialog_add_event_form">
56 <div class="form-group">
57 <label class="col-sm-2 control-label">Project: </label>
58 <div class="col-sm-10">
59 <select class="form-control" name="event_project_select" id="event_project_select"></select>
62 <div class="form-group">
63 <label class="col-sm-2 control-label">Event Type: </label>
64 <div class="col-sm-10">
65 <select class="form-control" name="event_type_select" id="event_type_select" ></select>
68 <div class="form-group">
69 <label class="col-sm-2 control-label">Start: </label>
70 <div class="col-sm-10">
71 <div class="input-group date">
72 <input type="text" class="form-control datepicker" name="event_start" id="event_start">
73 <div class="input-group-addon">
74 <span class="glyphicon glyphicon-th"></span>
79 <div class="form-group">
80 <label class="col-sm-2 control-label">End: </label>
81 <div class="col-sm-10">
82 <div class="input-group date">
83 <input type="text" class="form-control datepicker" name="event_end" id="event_end" placeholder="Leave Blank if Not Applicable">
84 <div class="input-group-addon">
85 <span class="glyphicon glyphicon-th"></span>
90 <div class="form-group">
91 <label class="col-sm-2 control-label">Description: </label>
92 <div class="col-sm-10">
93 <input class="form-control" name="event_description" id="event_description" type="text" >
96 <div class="form-group">
97 <label class="col-sm-2 control-label">Web URL: </label>
98 <div class="col-sm-10">
99 <div class="input-group">
100 <span class="input-group-addon" id="basic-addon2">http://www.</span>
101 <input type="text" name="event_url" id="event_url" class="form-control" placeholder="example.com" aria-describedby="basic-addon2" />
108 <div class="modal-footer">
109 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
110 <button type="button" class="btn btn-primary" name="add_event_submit" id="add_event_submit">Add Event</button>
116 <div class="modal fade" id="event_dialog" name="event_dialog" tabindex="-1" role="dialog" aria-labelledby="eventDialog">
117 <div class="modal-dialog" role="document">
118 <div class="modal-content">
119 <div class="modal-header">
120 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
121 <h4 class="modal-title" id="eventDialog">Event Info</h4>
123 <div class="modal-body">
124 <div class="container-fluid">
125 <table class="table table-hover">
134 <td>Project Name: </td>
135 <td id="event_info_title"></td>
138 <td>Start Date: </td>
139 <td id="event_info_start_display"></td>
140 <input id="event_info_start" type="hidden" />
144 <td id="event_info_end_display"></td>
145 <input id="event_info_end" type="hidden" />
148 <td>Event Type: </td>
149 <td id="event_info_property"></td>
150 <input id="event_info_cvterm_id" type="hidden" />
153 <td>Event Description: </td>
154 <td id="event_info_description"></td>
157 <td>Event Web URL: </td>
158 <td id="event_info_url"></td>
159 <input id="event_info_url_raw" type="hidden" />
165 <div class="modal-footer">
166 <form name="event_dialog_more_info_form" id="event_dialog_more_info_form">
167 <input type="hidden" name="event_project_id" id="event_project_id" />
168 <input type="hidden" name="event_project_title" id="event_project_title" />
170 <form name="event_dialog_delete_event_form" id="event_dialog_delete_event_form">
171 <input type="hidden" name="event_projectprop_id" id="event_projectprop_id" />
173 <button type="button" class="btn btn-primary" name="event_edit_display" id="event_edit_display">Edit Event</button>
174 <button type="button" class="btn btn-danger" name="delete_event_submit" id="delete_event_submit">Delete Event</button>
175 <button type="button" class="btn btn-info" name="export_event_display" id="export_event_display">Export Event</button>
176 <button type="button" class="btn btn-default" data-dismiss="modal" id="event_dialog_dismiss">Close</button>
183 <div class="modal fade" id="edit_event_dialog" name="edit_event_dialog" tabindex="-1" role="dialog" aria-labelledby="editEventDialog">
184 <div class="modal-dialog" role="document">
185 <div class="modal-content">
186 <div class="modal-header">
187 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
188 <h4 class="modal-title" id="editEventDialog">Edit Event</h4>
190 <div class="modal-body">
191 <div class="container-fluid">
192 <form class="form-horizontal" role="form" name="edit_event_form" id="edit_event_form">
193 <div class="form-group">
194 <label class="col-sm-2 control-label">Project: </label>
195 <div class="col-sm-10">
196 <select class="form-control" name="edit_event_project_select" id="edit_event_project_select"></select>
199 <div class="form-group">
200 <label class="col-sm-2 control-label">Event Type: </label>
201 <div class="col-sm-10">
202 <select class="form-control" name="edit_event_type_select" id="edit_event_type_select" ></select>
205 <div class="form-group">
206 <label class="col-sm-2 control-label">Start: </label>
207 <div class="col-sm-10">
208 <div class="input-group date">
209 <input type="text" class="form-control datepicker" name="edit_event_start" id="edit_event_start">
210 <div class="input-group-addon">
211 <span class="glyphicon glyphicon-th"></span>
216 <div class="form-group">
217 <label class="col-sm-2 control-label">End: </label>
218 <div class="col-sm-10">
219 <div class="input-group date">
220 <input type="text" class="form-control datepicker" name="edit_event_end" id="edit_event_end" placeholder="Leave Blank if Not Applicable">
221 <div class="input-group-addon">
222 <span class="glyphicon glyphicon-th"></span>
227 <div class="form-group">
228 <label class="col-sm-2 control-label">Description: </label>
229 <div class="col-sm-10">
230 <input class="form-control" name="edit_event_description" id="edit_event_description" type="text" >
233 <div class="form-group">
234 <label class="col-sm-2 control-label">Web URL: </label>
235 <div class="col-sm-10">
236 <input type="hidden" id="edit_event_projectprop_id" name="edit_event_projectprop_id" />
237 <input type="text" name="edit_event_url" id="edit_event_url" class="form-control" placeholder="example.com">
243 <div class="modal-footer">
244 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
245 <button type="button" class="btn btn-primary" name="edit_event_submit" id="edit_event_submit">Save</button>
255 jQuery(document).ready(function() {
257 jQuery(document).on('click', "button[name='personal_calendar_link']", function() {
258 jQuery("#calendar_modal").modal("show");
261 //If a date is given in the url, using the query parameter currentDate=<timestamp>
262 var captured = /currentDate=([^&]+)/.exec(window.location.href);
263 var result = captured ? captured[1] : Date.now();
264 var valid = (new Date(result)).getTime() > 0;
265 if (valid && captured) {
266 jQuery('#calendar').fullCalendar('gotoDate', result);
267 jQuery("#calendar_modal").modal("show");
270 jQuery('#calendar_modal').on('shown.bs.modal', function () {
271 jQuery("#calendar").fullCalendar('render');
274 jQuery('.datepicker').datepicker({
275 format: 'yyyy-mm-dd',
280 // url: '/ajax/calendar/populate/personal/month',
281 // error: function() {window.location.replace('/solpeople/login.pl');},
282 // className: 'bg-info',
283 // textColor: '#000',
284 // borderColor: '#FFF',
287 url: '/ajax/calendar/populate/personal/agendaWeek',
288 error: function() {window.location.replace('/user/login');},
289 className: 'bg-info',
294 // googleCalendarId: 'mtm2tg9p10nvqttdjas4v0n0sg@group.calendar.google.com',
295 // className: 'bg-success',
296 // textColor: '#000',
297 // borderColor: '#FFF',
300 // googleCalendarId: 'en.usa#holiday@group.v.calendar.google.com',
301 // className: 'bg-danger',
302 // textColor: '#000',
303 // borderColor: '#FFF',
308 jQuery('#calendar').fullCalendar({
314 center: 'month,agendaWeek',
315 right: 'prevYear,prev,today,next,nextYear'
319 titleFormat: 'MMM YYYY'
322 titleFormat: 'MMM D YYYY'
325 eventSources: [fcSources.month_view, fcSources.agendaWeek_view, fcSources.gcal_cassbase, fcSources.gcal_holidays],
326 defaultView: 'month',
327 googleCalendarApiKey: 'AIzaSyDHH6NGHEYJcYRcxr5mHBWKcqNlKyu-L-Q',
328 eventRender: function(event, element, view) {
330 element.find('.fc-title').html(event.title + ": " + event.property );
333 dayClick: function(date, jsEvent, view) {
335 url: "/ajax/calendar/dayclick/personal",
338 success: function(data) {
339 jQuery("input#event_start").val(date.format());
340 var options = jQuery("#event_project_select");
342 jQuery.each(data.project_list, function () {
343 options.append(jQuery("<option />").val(this.project_id).text(this.project_name));
345 var options = jQuery("#event_type_select");
347 jQuery.each(data.projectprop_list, function () {
348 options.append(jQuery("<option />").val(this.cvterm_id).text(this.cvterm_name));
353 alert("Error preparing Day dialog!");
356 jQuery('#day_dialog').modal('show');
357 // jQuery(this).css('background-color', '#A9F5F2');
359 eventClick: function(event) {
361 window.open(event.url);
364 jQuery("#event_info_title").html("<a href='" + event.project_url + "'>" + event.title + "</a>");
365 jQuery("#event_info_start_display").html(event.start_display);
366 jQuery("#event_info_end_display").html(event.end_display);
367 jQuery("input#event_info_start").val(event.start_drag);
368 jQuery("input#event_info_end").val(event.end_drag);
369 jQuery("input#event_info_cvterm_id").val(event.cvterm_id);
370 jQuery("#event_info_property").html("<a href='" + event.cvterm_url + "'>" + event.property + "</a>");
371 jQuery("#event_info_description").html(event.event_description);
372 jQuery("input#event_info_url_raw").val(event.event_url);
373 jQuery("#event_info_url").html("<a href='" + event.event_url + "'>" + event.event_url + "</a>");
374 jQuery("input#event_project_title").val(event.title);
375 jQuery("input#event_project_id").val(event.project_id);
376 jQuery("input#event_projectprop_id").val(event.projectprop_id);
377 jQuery('#event_dialog').modal('show');
381 eventMouseover: function(event, jsEvent) {
383 jQuery(this).popover({html:true, title:event.title, placement:'right', container:'body', content: 'Location: ' + event.location + '<br/>Description: ' + event.description,}).popover('show');
386 jQuery(this).popover({html:true, title:event.title, placement:'right', container:'body', content: 'Start: ' + event.start_display + '<br/>End: ' + event.end_display + '<br/>Type: ' + event.property + '<br/>Description: ' + event.event_description + '<br/>URL: ' + event.event_url,}).popover('show');
390 eventMouseout: function(event) {
391 jQuery(this).popover("hide");
394 eventDrop: function(event, delta, revertFunc, jsEvent, ui, view) {
395 if (!confirm("Are you sure about this change?")) {
400 url: "/ajax/calendar/drag_or_resize",
405 start_drag: event.start_drag,
406 end_drag: event.end_drag,
407 description: event.event_description,
408 url: event.event_url,
409 projectprop_id: event.projectprop_id,
410 delta: delta.asSeconds(),
412 allday: +event.allDay,
415 success: function(data) {
416 if (data.status ==3) {
417 alert("You do not have the permissions to edit this event.");
418 } else if (data.error ==1) {
419 alert("The was a problem editing this event.");
420 } else if (data.success == 1) {
421 event.start = data.start;
422 event.start_drag = data.start_drag;
423 event.start_display = data.start_display;
424 event.end = data.end;
425 event.end_drag = data.end_drag;
426 event.end_display = data.end_display;
428 jQuery('#calendar').fullCalendar('updateEvent', event);
433 alert("Error! Did Not Update Event! E.001");
437 eventResize: function(event, delta, revertFunc, jsEvent, ui, view) {
438 if (!confirm("Are you sure about this change?")) {
443 url: "/ajax/calendar/drag_or_resize",
448 start_drag: event.start_drag,
449 end_drag: event.end_drag,
450 description: event.event_description,
451 url: event.event_url,
452 projectprop_id: event.projectprop_id,
453 delta: delta.asSeconds(),
455 allday: +event.allDay,
458 success: function(data) {
459 if (data.status ==3) {
460 alert("You do not have the permissions to edit this event.");
461 } else if (data.error ==1) {
462 alert("The was a problem editing this event.");
463 } else if (data.success == 1) {
464 event.start = data.start;
465 event.start_drag = data.start_drag;
466 event.start_display = data.start_display;
467 event.end = data.end;
468 event.end_drag = data.end_drag;
469 event.end_display = data.end_display;
471 jQuery('#calendar').fullCalendar('updateEvent', event);
476 alert("Error! Did Not Update Event! E.001");
482 jQuery('button#add_event_submit').click( function(event) {
483 event.preventDefault();
485 url: "/ajax/calendar/add_event",
488 data: jQuery('form#day_dialog_add_event_form').serialize(),
489 success: function(data) {
490 if(data.status == 1){
491 alert("Event Successfully Added!");
492 jQuery('#day_dialog').modal('hide');
493 jQuery('#calendar').fullCalendar('refetchEvents');
494 }else if(data.status == 2){
495 alert("Error! Event Not Added! E.002");
496 }else if(data.status == 3){
497 alert("You do not have the permissions to add an event.");
501 alert("Error! Event Not Added! E.001");
506 jQuery('button#delete_event_submit').click( function(event) {
507 event.preventDefault();
508 jQuery('button#export_event_display').popover('hide');
509 if (!confirm("Are you sure you want to delete this event?")) {
513 url: "/ajax/calendar/delete_event",
516 data: jQuery('form#event_dialog_delete_event_form').serialize(),
517 success: function(data) {
518 jQuery('#event_dialog').modal('hide');
519 jQuery('#calendar').fullCalendar( 'refetchEvents' );
521 alert("You do not have the permissions to delete an event.");
522 } else if (data.status==0){
523 alert("The event was not deleted!");
527 alert("Did Not Delete Event! E.001");
532 jQuery('button#event_edit_display').click( function(event) {
533 event.preventDefault();
535 url: "/ajax/calendar/dayclick/personal",
538 success: function(data) {
539 var options = jQuery("#edit_event_project_select");
541 jQuery.each(data.project_list, function () {
542 options.append(jQuery("<option />").val(this.project_id).text(this.project_name));
544 options.val(jQuery("input#event_project_id").val());
545 var options = jQuery("#edit_event_type_select");
547 jQuery.each(data.projectprop_list, function () {
548 options.append(jQuery("<option />").val(this.cvterm_id).text(this.cvterm_name));
550 options.val(jQuery("input#event_info_cvterm_id").val());
554 alert("Error Preparing Edit Event Dialog!");
558 jQuery("#edit_event_projectprop_id").val(jQuery("#event_projectprop_id").val());
559 jQuery("#edit_event_start").val(jQuery("#event_info_start").val());
560 jQuery("#edit_event_end").val(jQuery("#event_info_end").val());
561 jQuery("#edit_event_description").val(jQuery("#event_info_description").html());
562 jQuery("#edit_event_url").val(jQuery("#event_info_url_raw").val());
563 jQuery("#edit_event_dialog").modal("show");
566 jQuery('button#edit_event_submit').click( function(event) {
567 event.preventDefault();
568 if (!confirm("Are you sure you want to save this edit?")) {
572 url: "/ajax/calendar/edit_event",
575 data: jQuery('form#edit_event_form').serialize(),
576 success: function(data) {
577 if (data.status == 1) {
578 jQuery('#event_dialog').modal('hide');
579 jQuery('#edit_event_dialog').modal('hide');
580 jQuery('#calendar').fullCalendar( 'refetchEvents' );
581 } else if (data.status == 0) {
582 alert("Event Already Existed! Your Edit Was Not Saved!");
583 } else if (data.status == 3) {
584 alert("You do not have the permissions to edit thie event.");
588 alert("Did Not Save Edit! E.001");
593 jQuery('button#export_event_display').click( function() {
594 jQuery(this).popover({html:true, title:"Export Event", placement:'right', container:'body', content: "Google Calendar: <a href='http://www.google.com/calendar' target='_blank' >Export</a>"}).popover('toggle');
597 jQuery('#event_dialog').on('hide.bs.modal', function (e) {
598 jQuery('button#export_event_display').popover('hide');