Mercurial > hg > rc1
comparison plugins/calendar/print.js @ 3:f6fe4b6ae66a
calendar plugin nearly as distributed
author | Charlie Root |
---|---|
date | Sat, 13 Jan 2018 08:56:12 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c828b0fd4a6e | 3:f6fe4b6ae66a |
---|---|
1 /** | |
2 * Print view for the Calendar plugin | |
3 * | |
4 * @author Thomas Bruederli <bruederli@kolabsys.com> | |
5 * | |
6 * @licstart The following is the entire license notice for the | |
7 * JavaScript code in this file. | |
8 * | |
9 * Copyright (C) 2011, Kolab Systems AG <contact@kolabsys.com> | |
10 * | |
11 * This program is free software: you can redistribute it and/or modify | |
12 * it under the terms of the GNU Affero General Public License as | |
13 * published by the Free Software Foundation, either version 3 of the | |
14 * License, or (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU Affero General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU Affero General Public License | |
22 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
23 * | |
24 * @licend The above is the entire license notice | |
25 * for the JavaScript code in this file. | |
26 */ | |
27 | |
28 | |
29 /* calendar plugin printing code */ | |
30 window.rcmail && rcmail.addEventListener('init', function(evt) { | |
31 | |
32 // quote html entities | |
33 var Q = function(str) | |
34 { | |
35 return String(str).replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
36 }; | |
37 | |
38 var rc_loading; | |
39 var showdesc = true; | |
40 var settings = $.extend(rcmail.env.calendar_settings, rcmail.env.libcal_settings); | |
41 | |
42 // create list of event sources AKA calendars | |
43 var src, event_sources = []; | |
44 var add_url = (rcmail.env.search ? '&q='+escape(rcmail.env.search) : ''); | |
45 for (var id in rcmail.env.calendars) { | |
46 if (!rcmail.env.calendars[id].active) | |
47 continue; | |
48 | |
49 source = $.extend({ | |
50 url: "./?_task=calendar&_action=load_events&source=" + escape(id) + add_url, | |
51 className: 'fc-event-cal-'+id, | |
52 id: id | |
53 }, rcmail.env.calendars[id]); | |
54 | |
55 event_sources.push(source); | |
56 } | |
57 | |
58 var viewdate = new Date(); | |
59 if (rcmail.env.date) | |
60 viewdate.setTime(rcmail.env.date * 1000); | |
61 | |
62 // initalize the fullCalendar plugin | |
63 var fc = $('#calendar').fullCalendar({ | |
64 header: { | |
65 left: '', | |
66 center: 'title', | |
67 right: 'agendaDay,agendaWeek,month,table' | |
68 }, | |
69 aspectRatio: 0.85, | |
70 ignoreTimezone: true, // will treat the given date strings as in local (browser's) timezone | |
71 date: viewdate.getDate(), | |
72 month: viewdate.getMonth(), | |
73 year: viewdate.getFullYear(), | |
74 defaultView: rcmail.env.view, | |
75 eventSources: event_sources, | |
76 monthNames : settings['months'], | |
77 monthNamesShort : settings['months_short'], | |
78 dayNames : settings['days'], | |
79 dayNamesShort : settings['days_short'], | |
80 firstDay : settings['first_day'], | |
81 firstHour : settings['first_hour'], | |
82 slotMinutes : 60/settings['timeslots'], | |
83 timeFormat: { | |
84 '': settings['time_format'], | |
85 agenda: settings['time_format'] + '{ - ' + settings['time_format'] + '}', | |
86 list: settings['time_format'] + '{ - ' + settings['time_format'] + '}', | |
87 table: settings['time_format'] + '{ - ' + settings['time_format'] + '}' | |
88 }, | |
89 axisFormat : settings['time_format'], | |
90 columnFormat: { | |
91 month: 'ddd', // Mon | |
92 week: 'ddd ' + settings['date_short'], // Mon 9/7 | |
93 day: 'dddd ' + settings['date_short'], // Monday 9/7 | |
94 list: settings['date_agenda'], | |
95 table: settings['date_agenda'] | |
96 }, | |
97 titleFormat: { | |
98 month: 'MMMM yyyy', | |
99 week: settings['dates_long'], | |
100 day: 'dddd ' + settings['date_long'], | |
101 list: settings['dates_long'], | |
102 table: settings['dates_long'] | |
103 }, | |
104 listSections: rcmail.env.listSections !== undefined ? rcmail.env.listSections : settings['agenda_sections'], | |
105 listRange: rcmail.env.listRange || settings['agenda_range'], | |
106 tableCols: ['handle', 'date', 'time', 'title', 'location'], | |
107 allDayText: rcmail.gettext('all-day', 'calendar'), | |
108 buttonText: { | |
109 day: rcmail.gettext('day', 'calendar'), | |
110 week: rcmail.gettext('week', 'calendar'), | |
111 month: rcmail.gettext('month', 'calendar'), | |
112 table: rcmail.gettext('agenda', 'calendar') | |
113 }, | |
114 listTexts: { | |
115 until: rcmail.gettext('until', 'calendar'), | |
116 past: rcmail.gettext('pastevents', 'calendar'), | |
117 today: rcmail.gettext('today', 'calendar'), | |
118 tomorrow: rcmail.gettext('tomorrow', 'calendar'), | |
119 thisWeek: rcmail.gettext('thisweek', 'calendar'), | |
120 nextWeek: rcmail.gettext('nextweek', 'calendar'), | |
121 thisMonth: rcmail.gettext('thismonth', 'calendar'), | |
122 nextMonth: rcmail.gettext('nextmonth', 'calendar'), | |
123 future: rcmail.gettext('futureevents', 'calendar'), | |
124 week: rcmail.gettext('weekofyear', 'calendar') | |
125 }, | |
126 loading: function(isLoading) { | |
127 rc_loading = rcmail.set_busy(isLoading, 'loading', rc_loading); | |
128 }, | |
129 // event rendering | |
130 eventRender: function(event, element, view) { | |
131 if (view.name != 'month' && view.name != 'table') { | |
132 var cont = element.find('.fc-event-title'); | |
133 if (event.location) { | |
134 cont.after('<div class="fc-event-location">@ ' + Q(event.location) + '</div>'); | |
135 cont = cont.next(); | |
136 } | |
137 if (event.description && showdesc) { | |
138 cont.after('<div class="fc-event-description">' + Q(event.description) + '</div>'); | |
139 } | |
140 /* TODO: create icons black on white | |
141 if (event.recurrence) | |
142 element.find('.fc-event-time').append('<i class="fc-icon-recurring"></i>'); | |
143 if (event.alarms) | |
144 element.find('.fc-event-time').append('<i class="fc-icon-alarms"></i>'); | |
145 */ | |
146 } | |
147 if (view.name == 'table' && event.description && showdesc) { | |
148 var cols = element.children().css('border', 0).length; | |
149 element.after('<tr class="fc-event-row-secondary fc-event"><td colspan="'+cols+'" class="fc-event-description">' + Q(event.description) + '</td></tr>'); | |
150 } | |
151 }, | |
152 viewDisplay: function(view) { | |
153 // remove hard-coded hight and make contents visible | |
154 window.setTimeout(function(){ | |
155 if (view.name == 'table') { | |
156 $('div.fc-list-content').css('overflow', 'visible').height('auto'); | |
157 } | |
158 else { | |
159 $('div.fc-agenda-divider') | |
160 .next().css('overflow', 'visible').height('auto') | |
161 .children('div').css('overflow', 'visible').height('auto'); | |
162 } | |
163 // adjust fixed height if vertical day slots | |
164 var h = $('table.fc-agenda-slots:visible').height() + $('table.fc-agenda-allday:visible').height() + 4; | |
165 if (h) $('table.fc-agenda-days td.fc-widget-content').children('div').height(h); | |
166 }, 20); | |
167 } | |
168 }); | |
169 | |
170 // activate settings form | |
171 $('#propdescription').change(function(){ | |
172 showdesc = this.checked; | |
173 fc.fullCalendar('render'); | |
174 }); | |
175 | |
176 }); |