Mercurial > lada > lada-client
annotate app/view/widget/base/DateTimePicker.js @ 1080:15d7b7a9e177
Override getValue for Netzbetreiber Combobox to allways return the correct
value.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 13 Apr 2016 16:10:25 +0200 |
parents | 777bf66dbb11 |
children |
rev | line source |
---|---|
892
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
2 * Software engineering by Intevation GmbH |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
3 * |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
7 */ |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
8 |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
9 /** |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
10 * This Widget extends a DateTimePicker in order to create a |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
11 * something like a DateTimePicker |
777bf66dbb11
even more jsduck... for widgets this time
Dustin Demuth <dustin@intevation.de>
parents:
667
diff
changeset
|
12 */ |
649
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 Ext.define('Lada.view.widget.base.DateTimePicker', { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 extend: 'Ext.picker.Date', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 alias: 'widget.datetimepicker', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 requires: [ |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 'Ext.picker.Date', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 'Ext.form.field.Number' |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 ], |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 todayText: 'Jetzt', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 renderTpl: [ |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 '<div id="{id}-innerEl" role="grid">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 '<div role="presentation" class="{baseCls}-header">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 // 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
|
27 '<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
|
28 '<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
|
29 // 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
|
30 '<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
|
31 '</div>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 '<table id="{id}-eventEl" class="{baseCls}-inner" cellspacing="0" role="grid">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 '<thead role="presentation"><tr role="row">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 '<tpl for="dayNames">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 '<th role="columnheader" class="{parent.baseCls}-column-header" title="{.}">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 '<div class="{parent.baseCls}-column-header-inner">{.:this.firstInitial}</div>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 '</th>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 '</tpl>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 '</tr></thead>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 '<tbody role="presentation"><tr role="row">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 '<tpl for="days">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 '{#:this.isEndOfWeek}', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 '<td role="gridcell" id="{[Ext.id()]}">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 // 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
|
45 '<a role="presentation" hidefocus="on" class="{parent.baseCls}-date" href="#"></a>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 '</td>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 '</tpl>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 '</tr></tbody>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 '</table>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 '<div id="{id}-timeEl" role="presentation" class="{baseCls}-footer">', |
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><col width="70"><col width="40"><col width="40"></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}-timeLabelEl" role="presentation">{%this.renderTimeLabel(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}-timeHourEl" role="presentation">{%this.renderTimeHour(values, out)%}</div>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 '</td><td>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 '<div id="{id}-timeMinuteEl" role="presentation">{%this.renderTimeMinute(values, out)%}</div>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 '</td>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 '</tr>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 '</table>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 '<table cellspacing="0">', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 '<colgroup width="75"></colgroup>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 '<tr>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 '<td>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 '<div id="{id}-footerNowEl" role="presentation">{%this.renderTodayBtn(values, out)%}</div>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 '</td><td>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 '<div id="{id}-footerAcceptEl" role="presentation">{%this.renderAcceptBtn(values, out)%}</div>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 '</td>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 '</tr>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 '</table>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 '</div>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 '</div>', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 firstInitial: function(value) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 return Ext.picker.Date.prototype.getDayInitial(value); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 }, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 isEndOfWeek: function(value) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 // convert from 1 based index to 0 based |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 // by decrementing value once. |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 value--; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 var end = value % 7 === 0 && value !== 0; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 return end ? '</tr><tr role="row">' : ''; |
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 renderTodayBtn: function(values, out) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 Ext.DomHelper.generateMarkup(values.$comp.todayBtn.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 renderMonthBtn: function(values, out) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 Ext.DomHelper.generateMarkup(values.$comp.monthBtn.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 renderTimeLabel: function(values, out) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 Ext.DomHelper.generateMarkup(values.$comp.timeLabel.getRenderTree(), out); |
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 renderTimeHour: function(values, out) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 Ext.DomHelper.generateMarkup(values.$comp.hourField.getRenderTree(), out); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 }, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 renderTimeMinute: function(values, out) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 Ext.DomHelper.generateMarkup(values.$comp.minuteField.getRenderTree(), out); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 }, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 renderAcceptBtn: function(values, out) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 Ext.DomHelper.generateMarkup(values.$comp.acceptBtn.getRenderTree(), out); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 ], |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 beforeRender: function () { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 var me = this; |
667
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
109 me.hourField = new Ext.form.field.Number({ |
649
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 ownerCt: me, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 ownerLayout: me.getComponentLayout(), |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 value: 0, |
667
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
113 valueToRaw: function (value) { |
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
114 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
|
115 }, |
655
195a253e9842
Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents:
651
diff
changeset
|
116 maxValue: 23, |
667
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
117 maxLength: 2, |
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
118 enforceMaxLength: true, |
651
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
119 onSpinUp: function() { |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
120 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
|
121 if (value === 23) { |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
122 return; |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
123 } |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
124 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
|
125 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
|
126 }, |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
127 onSpinDown: function() { |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
128 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
|
129 if (value === 0) { |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
130 return; |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
131 } |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
132 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
|
133 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
|
134 }, |
649
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 listeners: { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 change: me.changeTimeValue, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 scope: me |
667
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
138 }, |
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
139 checkChangeEvents: ['change'] |
649
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 }); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 |
667
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
142 me.minuteField = new Ext.form.field.Number({ |
649
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 ownerCt: me, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 ownerLayout: me.getComponentLayout(), |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 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
|
146 maxValue: 59, |
667
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
147 valueToRaw: function (value) { |
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
148 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
|
149 }, |
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
150 maxLength: 2, |
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
151 enforceMaxLength: true, |
651
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
152 onSpinUp: function() { |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
153 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
|
154 if (value === 59) { |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
155 return; |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
156 } |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
157 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
|
158 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
|
159 }, |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
160 onSpinDown: function() { |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
161 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
|
162 if (value === 0) { |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
163 return; |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
164 } |
f4fef1d3a2ce
Changed numberfield to spinner in datepicker to allow leading zeros.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
649
diff
changeset
|
165 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
|
166 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
|
167 }, |
649
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 listeners: { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 change: me.changeTimeValue, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 scope: me |
667
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
171 }, |
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
172 checkChangeEvents: ['change'] |
649
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 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 me.timeLabel = new Ext.form.Label({ |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 ownerCt: me, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 ownerLayout: me.getComponentLayout(), |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 text: 'Zeit' |
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 me.acceptBtn = new Ext.button.Button({ |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 ownerCt: me, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 ownerLayout: me.getComponentLayout(), |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 text: 'Ãœbernehmen', |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 handler: me.acceptDate, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 scope: me |
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 me.callParent(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 }, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 finishRenderChildren: function() { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 var me = this; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 me.callParent(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 me.timeLabel.finishRender(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 me.hourField.finishRender(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 me.minuteField.finishRender(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 me.acceptBtn.finishRender(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 }, |
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 showTimePicker: function() { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 var me = this; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 var el = me.el; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 Ext.defer(function() { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 var xPos = el.getX(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
204 var yPos = el.getY() + el.getHeight(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 me.timePicker.setHeight(30); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 me.timePicker.setWidth(el.getWidth()); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 me.timePicker.setPosition(xPos, yPos); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 me.timePicker.show(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 },1); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
210 }, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
211 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
212 beforeDestroy: function() { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
213 var me = this; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 if (me.rendered) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
215 Ext.destroy( |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
216 me.minuteField, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
217 me.hourField |
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 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
220 me.callParent(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
221 }, |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
222 |
655
195a253e9842
Fixed bug in datetimepicker: Allways insert leading zero; do not allow values
Raimund Renkert <raimund.renkert@intevation.de>
parents:
651
diff
changeset
|
223 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
|
224 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
|
225 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
|
226 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
|
227 } |
667
c34e65346572
Changes to the Datetimepicker's events, InputValidation and Sanity Checks
Dustin Demuth <dustin@intevation.de>
parents:
655
diff
changeset
|
228 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
|
229 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
|
230 } |
649
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 setValue: function(value) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
234 value.setSeconds(0); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
235 this.value = new Date(value); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
236 return this.update(this.value); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
237 }, |
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 selectToday: function() { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
240 var me = this; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
241 var btn = me.todayBtn; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
242 var handler = me.handler; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
243 var auxDate = new Date(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
244 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
245 if (btn && !btn.disabled) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
246 me.pickerField.setValue(new Date(auxDate.setSeconds(0))); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
247 me.setValue(new Date(auxDate.setSeconds(0))); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
248 if (handler) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
249 handler.call(me.scope || me, me, me.value); |
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 me.onSelect(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
252 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
253 return me; |
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 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
256 acceptDate: function() { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
257 var me = this; |
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 currentDate = me.value; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
261 currentDate.setHours(hourSet); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
262 currentDate.setMinutes(minuteSet); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
263 me.setValue(currentDate); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
264 me.fireEvent('select', me, currentDate); |
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 handleDateClick: function(e, t) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
268 var me = this; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
269 var handler = me.handler; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
270 var hourSet = me.hourField.getValue(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
271 var minuteSet = me.minuteField.getValue(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
272 var auxDate = new Date(t.dateValue); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
273 e.stopEvent(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
274 if (!me.disabled && |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
275 t.dateValue && |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
276 !Ext.fly(t.parentNode).hasCls(me.disabledCellCls) |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
277 ) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
278 me.doCancelFocus = me.focusOnSelect === false; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
279 auxDate.setHours(hourSet, minuteSet, 0); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
280 me.setValue(new Date(auxDate)); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
281 delete me.doCancelFocus; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
282 if (handler) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
283 handler.call(me.scope || me, me, me.value); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
284 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
285 // event handling is turned off on hide |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
286 // when we are using the picker in a field |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
287 // therefore onSelect comes AFTER the select |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
288 // event. |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
289 me.onSelect(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
290 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
291 }, |
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 selectedUpdate: function(date) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
294 var me = this; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
295 var dateOnly = Ext.Date.clearTime(date, true); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
296 var t = dateOnly.getTime(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
297 var currentDate = (me.pickerField && me.pickerField.getValue()) || new Date(); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
298 var cells = me.cells; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
299 var cls = me.selectedCls; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
300 var cellItems = cells.elements; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
301 var c; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
302 var cLen = cellItems.length; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
303 var cell; |
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 cells.removeCls(cls); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
306 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
307 for (c = 0; c < cLen; c++) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
308 cell = Ext.fly(cellItems[c]); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
309 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
310 if (cell.dom.firstChild.dateValue == t) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
311 me.fireEvent('highlightitem', me, cell); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
312 cell.addCls(cls); |
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 if (me.isVisible() && !me.doCancelFocus) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
315 Ext.fly(cell.dom.firstChild).focus(50); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
316 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
317 |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
318 break; |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
319 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
320 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
321 if (currentDate) { |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
322 me.hourField.setValue(currentDate.getHours()); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
323 me.minuteField.setValue(currentDate.getMinutes()); |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
324 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
325 } |
1f51b6020f8c
Added new DateTimeFields.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
326 }); |