3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
16 * This is an internal helper class for the calendar views and should not be overridden.
17 * It is responsible for the base event rendering logic underlying all of the calendar views.
19 Ext.calendar.WeekEventRenderer = function() {
21 var getEventRow = function(id, week, index) {
23 //skip row with date #'s
25 wkRow = Ext.get(id + '-wk-' + week);
27 var table = wkRow.child('.ext-cal-evt-tbl', true);
28 evtRow = table.tBodies[0].childNodes[index + indexOffset];
30 evtRow = Ext.DomHelper.append(table.tBodies[0], '<tr></tr>');
33 return Ext.get(evtRow);
40 dt = o.viewStart.clone(),
42 max = o.maxEventsPerDay != undefined ? o.maxEventsPerDay: 999,
43 weekCount = o.weekCount < 1 ? 6: o.weekCount,
44 dayCount = o.weekCount == 1 ? o.dayCount: 7,
47 for (; w < weekCount; w++) {
48 if (!grid[w] || grid[w].length == 0) {
49 // no events or span cells for the entire week
51 row = getEventRow(o.id, w, 0);
55 id: o.id + '-empty-0-day-' + dt.format('Ymd'),
59 cellCfg.colspan = dayCount;
61 Ext.DomHelper.append(row, cellCfg);
63 dt = dt.add(Date.DAY, 7);
68 startOfWeek = dt.clone(),
69 endOfWeek = startOfWeek.add(Date.DAY, dayCount).add(Date.MILLI, -1);
71 for (; d < dayCount; d++) {
73 var ev = emptyCells = skipped = 0,
78 for (; ev < ct; ev++) {
83 if (emptyCells > 0 && ev - emptyCells < max) {
84 row = getEventRow(o.id, w, ev - emptyCells);
88 id: o.id + '-empty-' + ct + '-day-' + dt.format('Ymd')
90 if (emptyCells > 1 && max - ev > emptyCells) {
91 cellCfg.rowspan = Math.min(emptyCells, max - ev);
93 Ext.DomHelper.append(row, cellCfg);
103 if (!evt.isSpan || evt.isSpanStart) {
104 //skip non-starting span cells
105 var item = evt.data || evt.event.data;
107 item._renderAsAllDay = item[Ext.calendar.EventMappings.IsAllDay.name] || evt.isSpanStart;
108 item.spanLeft = item[Ext.calendar.EventMappings.StartDate.name].getTime() < startOfWeek.getTime();
109 item.spanRight = item[Ext.calendar.EventMappings.EndDate.name].getTime() > endOfWeek.getTime();
110 item.spanCls = (item.spanLeft ? (item.spanRight ? 'ext-cal-ev-spanboth':
111 'ext-cal-ev-spanleft') : (item.spanRight ? 'ext-cal-ev-spanright': ''));
113 row = getEventRow(o.id, w, ev);
117 cn: eventTpl.apply(o.templateDataFn(item))
119 var diff = Ext.calendar.Date.diffDays(dt, item[Ext.calendar.EventMappings.EndDate.name]) + 1,
120 cspan = Math.min(diff, dayCount - d);
123 cellCfg.colspan = cspan;
125 Ext.DomHelper.append(row, cellCfg);
129 row = getEventRow(o.id, w, max);
130 Ext.DomHelper.append(row, {
132 cls: 'ext-cal-ev-more',
133 id: 'ext-cal-ev-more-' + dt.format('Ymd'),
136 html: '+' + skipped + ' more...'
140 if (ct < o.evtMaxCount[w]) {
141 row = getEventRow(o.id, w, ct);
146 id: o.id + '-empty-' + (ct + 1) + '-day-' + dt.format('Ymd')
148 var rowspan = o.evtMaxCount[w] - ct;
150 cellCfg.rowspan = rowspan;
152 Ext.DomHelper.append(row, cellCfg);
156 row = getEventRow(o.id, w, 0);
161 id: o.id + '-empty-day-' + dt.format('Ymd')
163 if (o.evtMaxCount[w] > 1) {
164 cellCfg.rowSpan = o.evtMaxCount[w];
166 Ext.DomHelper.append(row, cellCfg);
169 dt = dt.add(Date.DAY, 1);