annotate resources/datetime/UX_DateTimePicker.js @ 357:94884cd8f8c0

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

http://lada.wald.intevation.org