annotate resources/datetime/UX_DateTimePicker.js @ 478:a07cf685606c

Added dependency to colum layout.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 21 Jan 2014 15:08:08 +0100
parents 4d8819844c48
children
rev   line source
273
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
1 Ext.define('Ext.ux.DateTimePicker', {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
2 extend: 'Ext.picker.Date',
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
3 alias: 'widget.datetimepicker',
470
4d8819844c48 Fixed circular requirement.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 273
diff changeset
4 todayText: "Now",
4d8819844c48 Fixed circular requirement.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 273
diff changeset
5 timeLabel: 'Time',
273
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 requires: ['Ext.ux.form.TimePickerField'],
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
7
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
8 initComponent: function() {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 // keep time part for value
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 var value = this.value || new Date();
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 this.callParent();
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 this.value = value;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 },
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 onRender: function(container, position) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 if(!this.timefield) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 this.timefield = Ext.create('Ext.ux.form.TimePickerField', {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17 fieldLabel: this.timeLabel,
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
18 labelWidth: 40,
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
19 value: Ext.Date.format(this.value, 'H:i:s')
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
20 });
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
21 }
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
22 this.timefield.ownerCt = this;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
23 this.timefield.on('change', this.timeChange, this);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 this.callParent(arguments);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
25
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
26 var table = Ext.get(Ext.DomQuery.selectNode('table', this.el.dom));
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 var tfEl = Ext.core.DomHelper.insertAfter(table, {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28 tag: 'div',
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
29 style: 'border:0px;',
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 children: [{
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 tag: 'div',
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
32 cls: 'x-datepicker-footer ux-timefield'
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
33 }]
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
34 }, true);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
35 this.timefield.render(this.el.child('div div.ux-timefield'));
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
36
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
37 var p = this.getEl().parent('div.x-layer');
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
38 if(p) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
39 p.setStyle("height", p.getHeight() + 31);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
40 }
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 },
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
42 // listener 时间域修改, timefield change
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
43 timeChange: function(tf, time, rawtime) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
44 // if(!this.todayKeyListener) { // before render
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
45 this.value = this.fillDateTime(this.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
46 // } else {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
47 // this.setValue(this.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
48 // }
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
49 },
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
50 // @private
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
51 fillDateTime: function(value) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
52 if(this.timefield) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 var rawtime = this.timefield.getRawValue();
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
54 value.setHours(rawtime.h);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
55 value.setMinutes(rawtime.m);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 value.setSeconds(rawtime.s);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57 }
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
58 return value;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 },
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 // @private
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 changeTimeFiledValue: function(value) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
62 this.timefield.un('change', this.timeChange, this);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
63 this.timefield.setValue(this.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
64 this.timefield.on('change', this.timeChange, this);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
65 },
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
66
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
67 /* TODO 时间值与输入框绑定, 考虑: 创建this.timeValue 将日期和时间分开保存. */
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
68 // overwrite
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
69 setValue: function(value) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
70 this.value = value;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
71 this.changeTimeFiledValue(value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
72 return this.update(this.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
73 },
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
74 // overwrite
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
75 getValue: function() {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
76 return this.fillDateTime(this.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
77 },
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
78
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
79 // overwrite : fill time before setValue
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
80 handleDateClick: function(e, t) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
81 var me = this,
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
82 handler = me.handler;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
83
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
84 e.stopEvent();
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
85 if(!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
86 me.doCancelFocus = me.focusOnSelect === false;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
87 me.setValue(this.fillDateTime(new Date(t.dateValue))); // overwrite: fill time before setValue
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
88 delete me.doCancelFocus;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
89 me.fireEvent('select', me, me.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
90 if(handler) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
91 handler.call(me.scope || me, me, me.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
92 }
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
93 me.onSelect();
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
94 }
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
95 },
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
96
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
97 // overwrite : fill time before setValue
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
98 selectToday: function() {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
99 var me = this,
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
100 btn = me.todayBtn,
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
101 handler = me.handler;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
102
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
103 if(btn && !btn.disabled) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
104 // me.setValue(Ext.Date.clearTime(new Date())); //src
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
105 me.setValue(new Date());// overwrite: fill time before setValue
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
106 me.fireEvent('select', me, me.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
107 if(handler) {
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
108 handler.call(me.scope || me, me, me.value);
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
109 }
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
110 me.onSelect();
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
111 }
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
112 return me;
a282da79cfaa Added datetimepicker from
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
113 }
470
4d8819844c48 Fixed circular requirement.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 273
diff changeset
114 });

http://lada.wald.intevation.org