roundcubemail-plugins-kolab/plugins/calendar/print.js
Aleksander Machniak cbd1c1ae47 Upgrade to fullCalendar 3.9.0
Squashed commit of the following:

commit cd7c726b57
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Tue Jan 22 13:52:35 2019 +0000

    Remove leftover code

    Agenda sections and fisheye view.

commit 8b2203adfc
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Tue Jan 22 12:23:11 2019 +0000

    Fix duplicated requests on using Next/Prev buttons in Agenda view

commit 2dff079625
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Tue Jan 22 11:34:16 2019 +0000

    Increase font-size for .fc-event

commit 9bb48ec3fa
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Fri Jan 18 12:10:33 2019 +0000

    Fix re-fetching updated event in quickview mode

commit 841815f5b1
Merge: ffe9c0c7 315079c8
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Fri Jan 18 11:43:19 2019 +0000

    Merge branch 'master' into dev/fullcalendar-upgrade

commit ffe9c0c7f7
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Fri Jan 18 11:41:59 2019 +0000

    Fix events re-rendering after "Print descriptions" option change

commit bc48cd6639
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Fri Jan 18 11:30:38 2019 +0000

    Fix event color on hover in print mode

commit 0776636fd6
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Fri Jan 18 10:07:41 2019 +0000

    Fix including eye.svg

commit 7cc525e4e9
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Fri Jan 18 09:50:34 2019 +0000

    Elastic support for new fullCalendar

commit 3efc8d0389
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Thu Jan 17 07:47:59 2019 +0000

    Remove now indicator on calendar print

commit a1d018875b
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Wed Jan 16 13:40:11 2019 +0100

    Calendar agenda view and printing

    Note that agenda's smart sections feature is not implemented (yet)
    as it does not exist in fullCalendar (it was a Kolab's customization).

commit ea873a9589
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Tue Jan 15 12:18:21 2019 +0100

    Calendar Agenda and searching fixes

commit fb0c3436a3
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Fri Jan 11 13:59:29 2019 +0100

    Varius calendar fixes and cleanups

commit d45f3439b9
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Wed Jan 9 13:22:24 2019 +0100

    Fix various Larry skin regressions after fullCalendar upgrade

commit 3373fff6b3
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Wed Jan 9 10:51:16 2019 +0100

    Fix .fc-today style

commit 5718fd40e3
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Wed Jan 9 10:31:22 2019 +0100

    Fix various date calculation issues after fullCalendar upgrade

    - allDay flag must be boolean
    - allDay event's end date must be exclusive

commit d08e8a8a3b
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Tue Jan 8 11:39:10 2019 +0100

    Fix date/time format issies and inconsistencies, remove confusing config

commit b0196c7ff1
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Mon Jan 7 15:46:51 2019 +0000

    Fox some small issues after fullCalendar update

commit c7b561f19d
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Mon Jan 7 13:22:57 2019 +0000

    Fix handling 'source' argument in load_events request

commit 59fc3c8168
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Mon Jan 7 12:26:04 2019 +0000

    Fix including moment.js

commit eb85d762c7
Author: Aleksander Machniak <machniak@kolabsys.com>
Date:   Fri Jan 4 16:12:33 2019 +0000

    Upgrade to fullcalendar 3.9.0 - Part I

    Just started, still many issues, no printing, no elastic, no agenda view
2019-01-30 15:30:11 +01:00

214 lines
6.9 KiB
JavaScript

/**
* Print view for the Calendar plugin
*
* @author Thomas Bruederli <bruederli@kolabsys.com>
*
* @licstart The following is the entire license notice for the
* JavaScript code in this file.
*
* Copyright (C) 2011-2018, Kolab Systems AG <contact@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @licend The above is the entire license notice
* for the JavaScript code in this file.
*/
/* calendar plugin printing code */
window.rcmail && rcmail.addEventListener('init', function(evt) {
// quote html entities
var Q = function(str)
{
return String(str).replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
};
var rc_loading;
var showdesc = true;
var desc_elements = {};
var settings = $.extend(rcmail.env.calendar_settings, rcmail.env.libcal_settings);
// create list of event sources AKA calendars
var id, src, event_sources = [];
var add_url = '&mode=print' + (rcmail.env.search ? '&q='+escape(rcmail.env.search) : '');
for (id in rcmail.env.calendars) {
if (!rcmail.env.calendars[id].active)
continue;
source = $.extend({
url: "./?_task=calendar&_action=load_events&source=" + escape(id) + add_url,
className: 'fc-event-cal-'+id,
id: id
}, rcmail.env.calendars[id]);
source.color = '#' + source.color.replace(/^#/, '');
if (source.color == '#ffffff')
source.color = '#ccc';
event_sources.push(source);
}
var viewdate = new Date();
if (rcmail.env.date)
viewdate.setTime(rcmail.env.date * 1000);
// initalize the fullCalendar plugin
var fc = $('#calendar').fullCalendar({
header: {
left: '',
center: 'title',
right: 'agendaDay,agendaWeek,month,list'
},
theme: false,
aspectRatio: 0.85,
selectable: false,
editable: false,
timezone: false, // will treat the given date strings as in local (browser's) timezone
monthNames: settings.months,
monthNamesShort: settings.months_short,
dayNames: settings.days,
dayNamesShort: settings.days_short,
weekNumbers: settings.show_weekno > 0,
weekNumberTitle: rcmail.gettext('weekshort', 'calendar') + ' ',
firstDay: settings.first_day,
firstHour: settings.first_hour,
slotDuration: {minutes: 60/settings.timeslots},
businessHours: {
start: settings.work_start + ':00',
end: settings.work_end + ':00'
},
views: {
list: {
titleFormat: settings.dates_long,
listDayFormat: settings.date_long,
visibleRange: function(currentDate) {
return {
start: currentDate.clone(),
end: currentDate.clone().add(settings.agenda_range, 'days')
}
}
},
month: {
columnFormat: 'ddd', // Mon
titleFormat: 'MMMM YYYY',
eventLimit: 10
},
week: {
columnFormat: 'ddd ' + settings.date_short, // Mon 9/7
titleFormat: settings.dates_long
},
day: {
columnFormat: 'dddd ' + settings.date_short, // Monday 9/7
titleFormat: 'dddd ' + settings.date_long
}
},
timeFormat: settings.time_format,
slotLabelFormat: settings.time_format,
allDayText: rcmail.gettext('all-day', 'calendar'),
defaultDate: viewdate,
defaultView: rcmail.env.view,
eventSources: event_sources,
buttonText: {
today: settings['today'],
day: rcmail.gettext('day', 'calendar'),
week: rcmail.gettext('week', 'calendar'),
month: rcmail.gettext('month', 'calendar'),
list: rcmail.gettext('agenda', 'calendar')
},
buttonIcons: {
prev: 'left-single-arrow',
next: 'right-single-arrow'
},
eventLimitText: function(num) {
return rcmail.gettext('andnmore', 'calendar').replace('$nr', num);
},
loading: function(isLoading) {
rc_loading = rcmail.set_busy(isLoading, 'loading', rc_loading);
},
// event rendering
eventRender: function(event, element, view) {
if (view.name == 'list') {
var loc = $('<td>').attr('class', 'fc-event-location');
if (event.location)
loc.text(event.location);
element.find('.fc-list-item-title').after(loc);
// we can't add HTML elements after the curent element,
// so we store it for later. One description per event
if (event.description && showdesc && !desc_elements[event.uid])
desc_elements[event.uid] = {element: element[0], description: event.description};
}
else if (view.name != 'month') {
var cont = element.find('div.fc-title');
if (event.location) {
cont.after('<div class="fc-event-location">@&nbsp;' + Q(event.location) + '</div>');
cont = cont.next();
}
if (event.description && showdesc) {
cont.after('<div class="fc-event-description">' + Q(event.description) + '</div>');
}
}
},
eventAfterAllRender: function(view) {
if (view.name == 'list') {
// Fix colspan of headers after we added Location column
fc.find('tr.fc-list-heading > td').attr('colspan', 4);
$.each(desc_elements, function() {
$(this.element).after('<tr class="fc-event-row-secondary fc-list-item"><td colspan="2"></td><td colspan="2" class="fc-event-description">' + Q(this.description) + '</td></tr>');
});
}
},
viewRender: function(view) {
desc_elements = {};
}
});
// activate settings form
$('#propdescription').change(function() {
showdesc = this.checked;
desc_elements = {};
fc.fullCalendar('rerenderEvents');
});
var selector = $('#calendar').data('view-selector');
if (selector) {
selector = $('#' + selector);
$('.fc-right button').each(function() {
var cl = 'btn btn-secondary', btn = $(this);
if (btn.is('.fc-state-active')) {
cl += ' active';
}
$('<button>').attr({'class': cl, type: 'button'})
.text(btn.text())
.appendTo(selector)
.on('click', function() {
selector.children('.active').removeClass('active');
$(this).addClass('active');
btn.click();
});
});
};
// Update layout after initialization
// In devel mode we have to wait until all styles are applied by less
if (rcmail.env.devel_mode && window.less) {
less.pageLoadFinished.then(function() { $(window).resize(); });
}
});