]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/classic/calendar/src/template/DayBody.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / classic / calendar / src / template / DayBody.js
CommitLineData
6527f429
DM
1/**\r
2 * @class Ext.calendar.template.DayBody\r
3 * @extends Ext.XTemplate\r
4 * <p>This is the template used to render the scrolling body container used in {@link Ext.calendar.DayView DayView} and \r
5 * {@link Ext.calendar.WeekView WeekView}. This template is automatically bound to the underlying event store by the \r
6 * calendar components and expects records of type {@link Ext.calendar.EventRecord}.</p>\r
7 * <p>Note that this template would not normally be used directly. Instead you would use the {@link Ext.calendar.DayViewTemplate}\r
8 * that internally creates an instance of this template along with a {@link Ext.calendar.DayHeaderTemplate}.</p>\r
9 * @constructor\r
10 * @param {Object} config The config object\r
11 */\r
12Ext.define('Ext.calendar.template.DayBody', {\r
13 extend: 'Ext.XTemplate',\r
14 requires: [\r
15 'Ext.calendar.util.Date'\r
16 ],\r
17 \r
18 constructor: function(config){\r
19 \r
20 Ext.apply(this, config);\r
21\r
22 this.callParent([\r
23 '<table class="ext-cal-bg-tbl" cellspacing="0" cellpadding="0">',\r
24 '<tbody>',\r
25 '<tr height="1">',\r
26 '<td class="ext-cal-gutter"></td>',\r
27 '<td colspan="{dayCount}">',\r
28 '<div class="ext-cal-bg-rows">',\r
29 '<div class="ext-cal-bg-rows-inner">',\r
30 '<tpl for="times">',\r
31 '<div class="ext-cal-bg-row">',\r
32 '<div class="ext-cal-bg-row-div ext-row-{[xindex]}"></div>',\r
33 '</div>',\r
34 '</tpl>',\r
35 '</div>',\r
36 '</div>',\r
37 '</td>',\r
38 '</tr>',\r
39 '<tr>',\r
40 '<td class="ext-cal-day-times">',\r
41 '<tpl for="times">',\r
42 '<div class="ext-cal-bg-row">',\r
43 '<div class="ext-cal-day-time-inner">{.}</div>',\r
44 '</div>',\r
45 '</tpl>',\r
46 '</td>',\r
47 '<tpl for="days">',\r
48 '<td class="ext-cal-day-col">',\r
49 '<div class="ext-cal-day-col-inner">',\r
50 '<div id="{[this.id]}-day-col-{.:date("Ymd")}" class="ext-cal-day-col-gutter"></div>',\r
51 '</div>',\r
52 '</td>',\r
53 '</tpl>',\r
54 '</tr>',\r
55 '</tbody>',\r
56 '</table>'\r
57 ]);\r
58 },\r
59\r
60 // private\r
61 applyTemplate : function(o){\r
62 this.today = Ext.calendar.util.Date.today();\r
63 this.dayCount = this.dayCount || 1;\r
64 \r
65 var i = 0,\r
66 days = [],\r
67 dt = Ext.Date.clone(o.viewStart),\r
68 times = [];\r
69 \r
70 for(; i<this.dayCount; i++){\r
71 days[i] = Ext.calendar.util.Date.add(dt, {days: i});\r
72 }\r
73\r
74 // use a fixed DST-safe date so times don't get skipped on DST boundaries\r
75 dt = Ext.Date.clearTime(new Date('5/26/1972'));\r
76 \r
77 for(i=0; i<24; i++){\r
78 times.push(Ext.Date.format(dt, 'ga'));\r
79 dt = Ext.calendar.util.Date.add(dt, {hours: 1});\r
80 }\r
81 \r
82 return this.applyOut({\r
83 days: days,\r
84 dayCount: days.length,\r
85 times: times\r
86 }, []).join('');\r
87 },\r
88 \r
89 apply: function(values) {\r
90 return this.applyTemplate.apply(this, arguments);\r
91 }\r
92});