annotate app/view/widget/base/DateTimePicker.js @ 819:00072c3c926e

reload works now.
author Dustin Demuth <dustin@intevation.de>
date Fri, 29 May 2015 09:31:00 +0200
parents c34e65346572
children 777bf66dbb11
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;
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
97 me.hourField = new Ext.form.field.Number({
649
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,
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
101 valueToRaw: function (value) {
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
102 return (value < 10 ? '0' : '') + value; // add leading Zero
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
103 },
655
195a253e9842 Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents: 651
diff changeset
104 maxValue: 23,
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
105 maxLength: 2,
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
106 enforceMaxLength: true,
651
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
107 onSpinUp: function() {
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
108 var value = parseInt(this.getValue());
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
109 if (value === 23) {
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
110 return;
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
111 }
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
112 var newValue = value + 1;
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
113 this.setValue(newValue);
651
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
114 },
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
115 onSpinDown: function() {
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
116 var value = parseInt(this.getValue());
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
117 if (value === 0) {
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
118 return;
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
119 }
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
120 var newValue = value - 1;
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
121 this.setValue(newValue);
651
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
122 },
649
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 listeners: {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 change: me.changeTimeValue,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 scope: me
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
126 },
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
127 checkChangeEvents: ['change']
649
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 });
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
130 me.minuteField = new Ext.form.field.Number({
649
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 ownerCt: me,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 ownerLayout: me.getComponentLayout(),
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 value: 0,
655
195a253e9842 Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents: 651
diff changeset
134 maxValue: 59,
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
135 valueToRaw: function (value) {
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
136 return (value < 10 ? '0' : '') + value; // add leading Zero
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
137 },
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
138 maxLength: 2,
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
139 enforceMaxLength: true,
651
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
140 onSpinUp: function() {
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
141 var value = parseInt(this.getValue());
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
142 if (value === 59) {
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
143 return;
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
144 }
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
145 var newValue = value + 1;
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
146 this.setValue(newValue);
651
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
147 },
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
148 onSpinDown: function() {
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
149 var value = parseInt(this.getValue());
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
150 if (value === 0) {
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
151 return;
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
152 }
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
153 var newValue = value - 1;
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
154 this.setValue(newValue);
651
f4fef1d3a2ce Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 649
diff changeset
155 },
649
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 listeners: {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 change: me.changeTimeValue,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 scope: me
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
159 },
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
160 checkChangeEvents: ['change']
649
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 });
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 me.timeLabel = new Ext.form.Label({
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 ownerCt: me,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 ownerLayout: me.getComponentLayout(),
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 text: 'Zeit'
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.acceptBtn = new Ext.button.Button({
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 ownerCt: me,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170 ownerLayout: me.getComponentLayout(),
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171 text: 'Ãœbernehmen',
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 handler: me.acceptDate,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
173 scope: me
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174 });
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 me.callParent();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 finishRenderChildren: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
179 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180 me.callParent();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
181 me.timeLabel.finishRender();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
182 me.hourField.finishRender();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
183 me.minuteField.finishRender();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
184 me.acceptBtn.finishRender();
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
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
187 showTimePicker: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
188 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
189 var el = me.el;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 Ext.defer(function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
191 var xPos = el.getX();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
192 var yPos = el.getY() + el.getHeight();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
193 me.timePicker.setHeight(30);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
194 me.timePicker.setWidth(el.getWidth());
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
195 me.timePicker.setPosition(xPos, yPos);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
196 me.timePicker.show();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
197 },1);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
200 beforeDestroy: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
201 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
202 if (me.rendered) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
203 Ext.destroy(
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
204 me.minuteField,
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
205 me.hourField
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 me.callParent();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
209 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
210
655
195a253e9842 Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents: 651
diff changeset
211 changeTimeValue: function (field, nValue) {
195a253e9842 Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents: 651
diff changeset
212 var value = parseInt(nValue);
195a253e9842 Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents: 651
diff changeset
213 if (value > field.maxValue) {
195a253e9842 Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents: 651
diff changeset
214 field.setValue(field.maxValue);
195a253e9842 Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents: 651
diff changeset
215 }
667
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
216 if (value == null || value == "" || isNaN(value)) {
c34e65346572 Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents: 655
diff changeset
217 field.setValue('0');
655
195a253e9842 Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents: 651
diff changeset
218 }
649
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
219 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
220
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 setValue: function(value) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222 value.setSeconds(0);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
223 this.value = new Date(value);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 return this.update(this.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
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 selectToday: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 var btn = me.todayBtn;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
230 var handler = me.handler;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 var auxDate = new Date();
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 if (btn && !btn.disabled) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234 me.pickerField.setValue(new Date(auxDate.setSeconds(0)));
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
235 me.setValue(new Date(auxDate.setSeconds(0)));
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 if (handler) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237 handler.call(me.scope || me, me, me.value);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
238 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
239 me.onSelect();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241 return me;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
242 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
243
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
244 acceptDate: function() {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
245 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
246 var hourSet = me.hourField.getValue();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
247 var minuteSet = me.minuteField.getValue();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 var currentDate = me.value;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
249 currentDate.setHours(hourSet);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
250 currentDate.setMinutes(minuteSet);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
251 me.setValue(currentDate);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
252 me.fireEvent('select', me, currentDate);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
253 },
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 handleDateClick: function(e, t) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
256 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 var handler = me.handler;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
258 var hourSet = me.hourField.getValue();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
259 var minuteSet = me.minuteField.getValue();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
260 var auxDate = new Date(t.dateValue);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
261 e.stopEvent();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
262 if (!me.disabled &&
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
263 t.dateValue &&
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264 !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)
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 me.doCancelFocus = me.focusOnSelect === false;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 auxDate.setHours(hourSet, minuteSet, 0);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
268 me.setValue(new Date(auxDate));
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
269 delete me.doCancelFocus;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
270 if (handler) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
271 handler.call(me.scope || me, me, me.value);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
272 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
273 // event handling is turned off on hide
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
274 // when we are using the picker in a field
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
275 // therefore onSelect comes AFTER the select
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
276 // event.
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
277 me.onSelect();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
278 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
279 },
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
280
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
281 selectedUpdate: function(date) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
282 var me = this;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
283 var dateOnly = Ext.Date.clearTime(date, true);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
284 var t = dateOnly.getTime();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
285 var currentDate = (me.pickerField && me.pickerField.getValue()) || new Date();
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
286 var cells = me.cells;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
287 var cls = me.selectedCls;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
288 var cellItems = cells.elements;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
289 var c;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
290 var cLen = cellItems.length;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
291 var cell;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
292
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
293 cells.removeCls(cls);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
294
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
295 for (c = 0; c < cLen; c++) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
296 cell = Ext.fly(cellItems[c]);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
297
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
298 if (cell.dom.firstChild.dateValue == t) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
299 me.fireEvent('highlightitem', me, cell);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
300 cell.addCls(cls);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
301
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
302 if (me.isVisible() && !me.doCancelFocus) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
303 Ext.fly(cell.dom.firstChild).focus(50);
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
304 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
305
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
306 break;
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
307 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
308 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
309 if (currentDate) {
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
310 me.hourField.setValue(currentDate.getHours());
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
311 me.minuteField.setValue(currentDate.getMinutes());
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
312 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
313 }
1f51b6020f8c Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
314 });

http://lada.wald.intevation.org