annotate app/view/widget/base/DateTimePicker.js @ 650:67963fcb7739

Removed old DateTimeField and replaced them with the new one.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 18 Mar 2015 13:55:14 +0100
parents 1f51b6020f8c
children f4fef1d3a2ce
rev   line source
649
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 Ext.define('Lada.view.widget.base.DateTimePicker', {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 extend: 'Ext.picker.Date',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 alias: 'widget.datetimepicker',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 requires: [
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 'Ext.picker.Date',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 'Ext.form.field.Number'
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 ],
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 todayText: 'Jetzt',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 renderTpl: [
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 '<div id="{id}-innerEl" role="grid">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 '<div role="presentation" class="{baseCls}-header">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 // the href attribute is required for the :hover selector to work in IE6/7/quirks
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 '<a id="{id}-prevEl" class="{baseCls}-prev {baseCls}-arrow" href="#" role="button" title="{prevText}" hidefocus="on" ></a>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 '<div class="{baseCls}-month" id="{id}-middleBtnEl">{%this.renderMonthBtn(values, out)%}</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 // the href attribute is required for the :hover selector to work in IE6/7/quirks
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 '<a id="{id}-nextEl" class="{baseCls}-next {baseCls}-arrow" href="#" role="button" title="{nextText}" hidefocus="on" ></a>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 '</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 '<table id="{id}-eventEl" class="{baseCls}-inner" cellspacing="0" role="grid">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 '<thead role="presentation"><tr role="row">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 '<tpl for="dayNames">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 '<th role="columnheader" class="{parent.baseCls}-column-header" title="{.}">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 '<div class="{parent.baseCls}-column-header-inner">{.:this.firstInitial}</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 '</th>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 '</tpl>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 '</tr></thead>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 '<tbody role="presentation"><tr role="row">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 '<tpl for="days">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 '{#:this.isEndOfWeek}',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 '<td role="gridcell" id="{[Ext.id()]}">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 // the href attribute is required for the :hover selector to work in IE6/7/quirks
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 '<a role="presentation" hidefocus="on" class="{parent.baseCls}-date" href="#"></a>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 '</td>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 '</tpl>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 '</tr></tbody>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 '</table>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 '<div id="{id}-timeEl" role="presentation" class="{baseCls}-footer">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 '<table cellspacing="0">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 '<colgroup><col width="70"><col width="40"><col width="40"></colgroup>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 '<tr>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 '<td>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 '<div id="{id}-timeLabelEl" role="presentation">{%this.renderTimeLabel(values, out)%}</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 '</td><td>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 '<div id="{id}-timeHourEl" role="presentation">{%this.renderTimeHour(values, out)%}</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 '</td><td>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 '<div id="{id}-timeMinuteEl" role="presentation">{%this.renderTimeMinute(values, out)%}</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 '</td>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 '</tr>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 '</table>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 '<table cellspacing="0">',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 '<colgroup width="75"></colgroup>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 '<tr>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 '<td>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 '<div id="{id}-footerNowEl" role="presentation">{%this.renderTodayBtn(values, out)%}</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 '</td><td>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 '<div id="{id}-footerAcceptEl" role="presentation">{%this.renderAcceptBtn(values, out)%}</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 '</td>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 '</tr>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 '</table>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 '</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 '</div>',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 firstInitial: function(value) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 return Ext.picker.Date.prototype.getDayInitial(value);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 isEndOfWeek: function(value) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 // convert from 1 based index to 0 based
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 // by decrementing value once.
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 value--;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 var end = value % 7 === 0 && value !== 0;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 return end ? '</tr><tr role="row">' : '';
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 renderTodayBtn: function(values, out) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 Ext.DomHelper.generateMarkup(values.$comp.todayBtn.getRenderTree(), out);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 renderMonthBtn: function(values, out) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 Ext.DomHelper.generateMarkup(values.$comp.monthBtn.getRenderTree(), out);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 renderTimeLabel: function(values, out) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 Ext.DomHelper.generateMarkup(values.$comp.timeLabel.getRenderTree(), out);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 renderTimeHour: function(values, out) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 Ext.DomHelper.generateMarkup(values.$comp.hourField.getRenderTree(), out);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 renderTimeMinute: function(values, out) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 Ext.DomHelper.generateMarkup(values.$comp.minuteField.getRenderTree(), out);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 renderAcceptBtn: function(values, out) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 Ext.DomHelper.generateMarkup(values.$comp.acceptBtn.getRenderTree(), out);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 ],
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 beforeRender: function () {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 me.hourField = new Ext.form.field.Number({
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 ownerCt: me,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 ownerLayout: me.getComponentLayout(),
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 value: 0,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 increment: 1,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 minValue: 0,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 maxValue: 23,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 listeners: {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 change: me.changeTimeValue,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 scope: me
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 });
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 me.minuteField = new Ext.form.field.Number({
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 ownerCt: me,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 ownerLayout: me.getComponentLayout(),
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 value: 0,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 increment: 1,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 minValue: 0,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 maxValue: 59,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 listeners: {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 change: me.changeTimeValue,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 scope: me
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 });
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 me.timeLabel = new Ext.form.Label({
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 ownerCt: me,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 ownerLayout: me.getComponentLayout(),
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 text: 'Zeit'
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 });
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 me.acceptBtn = new Ext.button.Button({
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 ownerCt: me,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 ownerLayout: me.getComponentLayout(),
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 text: 'Ãœbernehmen',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 handler: me.acceptDate,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 scope: me
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 });
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 me.callParent();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 finishRenderChildren: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 me.callParent();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 me.timeLabel.finishRender();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 me.hourField.finishRender();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 me.minuteField.finishRender();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 me.acceptBtn.finishRender();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 showTimePicker: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 var el = me.el;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 Ext.defer(function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 var xPos = el.getX();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 var yPos = el.getY() + el.getHeight();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 me.timePicker.setHeight(30);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 me.timePicker.setWidth(el.getWidth());
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
155 me.timePicker.setPosition(xPos, yPos);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 me.timePicker.show();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 },1);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 beforeDestroy: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162 if (me.rendered) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 Ext.destroy(
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 me.minuteField,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 me.hourField
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 );
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 me.callParent();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171 changeTimeValue: function (field, nValue, oValue) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
173
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174 setValue: function(value) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 value.setSeconds(0);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176 this.value = new Date(value);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 return this.update(this.value);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
179
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180 selectToday: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
181 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
182 var btn = me.todayBtn;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
183 var handler = me.handler;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
184 var auxDate = new Date();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
185
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
186 if (btn && !btn.disabled) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
187 me.pickerField.setValue(new Date(auxDate.setSeconds(0)));
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
188 me.setValue(new Date(auxDate.setSeconds(0)));
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
189 if (handler) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 handler.call(me.scope || me, me, me.value);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
191 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
192 me.onSelect();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
193 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
194 return me;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
195 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
196
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
197 acceptDate: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199 var hourSet = me.hourField.getValue();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
200 var minuteSet = me.minuteField.getValue();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
201 var currentDate = me.value;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
202 currentDate.setHours(hourSet);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
203 currentDate.setMinutes(minuteSet);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
204 me.setValue(currentDate);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
205 me.fireEvent('select', me, currentDate);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
207
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
208 handleDateClick: function(e, t) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
209 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
210 var handler = me.handler;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
211 var hourSet = me.hourField.getValue();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
212 var minuteSet = me.minuteField.getValue();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
213 var auxDate = new Date(t.dateValue);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
214 e.stopEvent();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
215 if (!me.disabled &&
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
216 t.dateValue &&
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
217 !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
218 ) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
219 me.doCancelFocus = me.focusOnSelect === false;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
220 auxDate.setHours(hourSet, minuteSet, 0);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 me.setValue(new Date(auxDate));
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222 delete me.doCancelFocus;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
223 if (handler) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 handler.call(me.scope || me, me, me.value);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226 // event handling is turned off on hide
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 // when we are using the picker in a field
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228 // therefore onSelect comes AFTER the select
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 // event.
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
230 me.onSelect();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
232 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
233
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234 selectedUpdate: function(date) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
235 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 var dateOnly = Ext.Date.clearTime(date, true);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237 var t = dateOnly.getTime();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
238 var currentDate = (me.pickerField && me.pickerField.getValue()) || new Date();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
239 var cells = me.cells;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 var cls = me.selectedCls;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241 var cellItems = cells.elements;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
242 var c;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
243 var cLen = cellItems.length;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
244 var cell;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
245
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
246 cells.removeCls(cls);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
247
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 for (c = 0; c < cLen; c++) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
249 cell = Ext.fly(cellItems[c]);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
250
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
251 if (cell.dom.firstChild.dateValue == t) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
252 me.fireEvent('highlightitem', me, cell);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
253 cell.addCls(cls);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
254
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
255 if (me.isVisible() && !me.doCancelFocus) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
256 Ext.fly(cell.dom.firstChild).focus(50);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
258
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
259 break;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
260 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
261 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
262 if (currentDate) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
263 me.hourField.setValue(currentDate.getHours());
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264 me.minuteField.setValue(currentDate.getMinutes());
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
265 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
266 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 });

http://lada.wald.intevation.org