netzke-basepack 0.3.10 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. data/CHANGELOG +10 -0
  2. data/Manifest +12 -16
  3. data/Rakefile +1 -1
  4. data/TODO +3 -1
  5. data/autotest/discover.rb +3 -0
  6. data/javascripts/basepack.js +680 -52
  7. data/lib/app/models/netzke_hash_record.rb +180 -0
  8. data/lib/app/models/netzke_layout_item.rb +11 -0
  9. data/lib/netzke/ar_ext.rb +57 -34
  10. data/lib/netzke/border_layout_panel.rb +0 -1
  11. data/lib/netzke/db_fields.rb +4 -0
  12. data/lib/netzke/field_model.rb +131 -0
  13. data/lib/netzke/fields_configurator.rb +13 -5
  14. data/lib/netzke/fields_configurator_old.rb +62 -0
  15. data/lib/netzke/form_panel.rb +18 -24
  16. data/lib/netzke/form_panel_extras/interface.rb +20 -13
  17. data/lib/netzke/form_panel_extras/js_builder.rb +4 -1
  18. data/lib/netzke/grid_panel.rb +37 -40
  19. data/lib/netzke/grid_panel_extras/interface.rb +22 -18
  20. data/lib/netzke/grid_panel_extras/js_builder.rb +42 -13
  21. data/lib/netzke/property_editor_extras/helper_model.rb +2 -1
  22. data/lib/netzke/tab_panel.rb +15 -11
  23. data/netzke-basepack.gemspec +10 -10
  24. data/test/{accordion_panel_test.rb → unit/accordion_panel_test.rb} +0 -0
  25. data/test/{ar_ext_test.rb → unit/ar_ext_test.rb} +3 -9
  26. data/test/{grid_panel_test.rb → unit/grid_panel_test.rb} +0 -5
  27. data/test/{netzke_basepack_test.rb → unit/netzke_basepack_test.rb} +0 -0
  28. data/test/unit/netzke_hash_record_test.rb +52 -0
  29. data/test/unit/netzke_layout_item_test.rb +28 -0
  30. data/test/{tab_panel_test.rb → unit/tab_panel_test.rb} +0 -0
  31. metadata +30 -30
  32. data/generators/netzke_basepack/USAGE +0 -8
  33. data/generators/netzke_basepack/netzke_basepack_generator.rb +0 -8
  34. data/generators/netzke_form_panel/netzke_form_panel_generator.rb +0 -7
  35. data/generators/netzke_form_panel/templates/create_netzke_form_panel_fields.rb +0 -21
  36. data/generators/netzke_grid_panel/netzke_grid_panel_generator.rb +0 -7
  37. data/generators/netzke_grid_panel/templates/create_netzke_grid_panel_columns.rb +0 -24
  38. data/lib/app/models/netzke_form_panel_field.rb +0 -51
  39. data/lib/app/models/netzke_grid_panel_column.rb +0 -56
  40. data/lib/netzke/form_panel_extras/javascripts/xdatetime.js +0 -634
  41. data/test/app_root/db/migrate/20090102223811_create_netzke_grid_panel_columns.rb +0 -23
  42. data/test/border_layout_panel_test.rb +0 -25
@@ -1,8 +0,0 @@
1
- Description:
2
- Explain the generator
3
-
4
- Example:
5
- ./script/generate netzke-basepack Thing
6
-
7
- This will create:
8
- what/will/it/create
@@ -1,8 +0,0 @@
1
- class NetzkeBasepackGenerator < Rails::Generator::NamedBase
2
- def manifest
3
- record do |m|
4
- # m.directory "lib"
5
- # m.template 'README', "README"
6
- end
7
- end
8
- end
@@ -1,7 +0,0 @@
1
- class NetzkeFormPanelGenerator < Rails::Generator::Base
2
- def manifest
3
- record do |m|
4
- m.migration_template 'create_netzke_form_panel_fields.rb', "db/migrate", {:migration_file_name => "create_netzke_form_panel_fields"}
5
- end
6
- end
7
- end
@@ -1,21 +0,0 @@
1
- class CreateNetzkeFormPanelFields < ActiveRecord::Migration
2
- def self.up
3
- create_table :netzke_form_panel_fields do |t|
4
- t.string :name
5
- t.string :field_label
6
- t.boolean :hidden
7
- t.boolean :disabled
8
- t.string :xtype
9
- t.string :ext_config, :limit => 1024
10
-
11
- t.integer :position
12
- t.integer :layout_id
13
-
14
- t.timestamps
15
- end
16
- end
17
-
18
- def self.down
19
- drop_table :netzke_form_panel_fields
20
- end
21
- end
@@ -1,7 +0,0 @@
1
- class NetzkeGridPanelGenerator < Rails::Generator::Base
2
- def manifest
3
- record do |m|
4
- m.migration_template 'create_netzke_grid_panel_columns.rb', "db/migrate", {:migration_file_name => "create_netzke_grid_panel_columns"}
5
- end
6
- end
7
- end
@@ -1,24 +0,0 @@
1
- class CreateNetzkeGridPanelColumns < ActiveRecord::Migration
2
- def self.up
3
- create_table :netzke_grid_panel_columns do |t|
4
- t.string :name
5
- t.string :label
6
- t.boolean :read_only
7
- t.boolean :hidden
8
- t.integer :width
9
- t.string :editor, :limit => 32
10
- t.string :renderer, :limit => 32
11
- t.string :xtype, :limit => 32
12
- t.string :ext_config, :limit => 1024
13
-
14
- t.integer :position
15
- t.integer :layout_id
16
-
17
- t.timestamps
18
- end
19
- end
20
-
21
- def self.down
22
- drop_table :netzke_grid_panel_columns
23
- end
24
- end
@@ -1,51 +0,0 @@
1
- class NetzkeFormPanelField < ActiveRecord::Base
2
- belongs_to :layout, :class_name => "NetzkeLayout"
3
-
4
- acts_as_list :scope => :layout
5
-
6
- validate :valid_ext_config
7
-
8
- expose_columns :id,
9
- :name,
10
- :field_label,
11
- :hidden,
12
- {:name => :disabled, :renderer => "checkbox"},
13
- :xtype,
14
- :ext_config
15
-
16
-
17
- def self.create_layout_for_widget(widget)
18
- layout = NetzkeLayout.create_with_user(:widget_name => widget.id_name, :items_class => self.name)
19
-
20
- columns = widget.default_db_fields
21
-
22
- for c in columns
23
- config_for_create = c.merge(:layout_id => layout.id).stringify_values!
24
- new_field = self.new
25
- ext_config = {}
26
- for k in config_for_create.keys
27
- if new_field.respond_to?("#{k}=")
28
- new_field.send("#{k}=", config_for_create[k])
29
- else
30
- ext_config[k] = config_for_create[k]
31
- end
32
- end
33
- new_field.ext_config = ext_config.to_js
34
- new_field.save!
35
- end
36
-
37
- layout
38
- end
39
-
40
- private
41
-
42
- def valid_ext_config
43
- begin
44
- ActiveSupport::JSON.decode(ext_config)
45
- rescue
46
- errors.add(:ext_config, "is not valid JSON")
47
- end
48
- end
49
-
50
-
51
- end
@@ -1,56 +0,0 @@
1
- require 'netzke/ar_ext'
2
-
3
- class NetzkeGridPanelColumn < ActiveRecord::Base
4
- belongs_to :layout, :class_name => "NetzkeLayout"
5
-
6
- acts_as_list :scope => :layout
7
-
8
- validate :valid_ext_config
9
-
10
- expose_columns :id,
11
- :name,
12
- :label,
13
- {:name => :read_only, :label => "R/O"},
14
- :hidden,
15
- {:name => :width, :width => 50},
16
- {:name => :editor, :editor => :combo_box},
17
- {:name => :renderer, :editor => :combo_box},
18
- :ext_config
19
-
20
- def self.create_layout_for_widget(widget)
21
- layout = NetzkeLayout.create_with_user(:widget_name => widget.id_name, :items_class => self.name)
22
- columns = widget.default_db_fields
23
-
24
- for c in columns
25
- config_for_create = c.merge(:layout_id => layout.id).stringify_values!
26
- new_field = self.new
27
- ext_config = {}
28
- for k in config_for_create.keys
29
- if new_field.respond_to?("#{k}=")
30
- new_field.send("#{k}=", config_for_create[k])
31
- else
32
- ext_config[k] = config_for_create[k]
33
- end
34
- end
35
-
36
- new_field.ext_config = ext_config.to_js
37
- new_field.save!
38
-
39
- # config_for_create = c.merge(:layout_id => layout.id).stringify_values!
40
- # create(config_for_create)
41
- end
42
-
43
- layout
44
- end
45
-
46
- private
47
-
48
- def valid_ext_config
49
- begin
50
- ActiveSupport::JSON.decode(ext_config)
51
- rescue
52
- errors.add(:ext_config, "is not valid JSON")
53
- end
54
- end
55
-
56
- end
@@ -1,634 +0,0 @@
1
- /*global Ext */
2
- /**
3
- * @class Ext.ux.form.DateTime
4
- * @extends Ext.form.Field
5
- *
6
- * DateTime field, combination of DateField and TimeField
7
- *
8
- * @author Ing. Jozef Sak�lo�
9
- * @copyright (c) 2008, Ing. Jozef Sak�lo�
10
- * @version 2.0
11
- * @revision $Id: Ext.ux.form.DateTime.js 513 2009-01-29 19:59:22Z jozo $
12
- *
13
- * @license Ext.ux.form.DateTime is licensed under the terms of
14
- * the Open Source LGPL 3.0 license. Commercial use is permitted to the extent
15
- * that the code/component(s) do NOT become part of another Open Source or Commercially
16
- * licensed development library or toolkit without explicit permission.
17
- *
18
- * <p>License details: <a href="http://www.gnu.org/licenses/lgpl.html"
19
- * target="_blank">http://www.gnu.org/licenses/lgpl.html</a></p>
20
- *
21
- * @forum 22661
22
- */
23
-
24
- Ext.ns('Ext.ux.form');
25
-
26
- /**
27
- * @constructor
28
- * Creates new DateTime
29
- * @param {Object} config The config object
30
- */
31
- Ext.ux.form.DateTime = Ext.extend(Ext.form.Field, {
32
- /**
33
- * @cfg {String/Object} defaultAutoCreate DomHelper element spec
34
- * Let superclass to create hidden field instead of textbox. Hidden will be submittend to server
35
- */
36
- defaultAutoCreate:{tag:'input', type:'hidden'}
37
- /**
38
- * @cfg {Number} timeWidth Width of time field in pixels (defaults to 100)
39
- */
40
- ,timeWidth:80
41
- /**
42
- * @cfg {String} dtSeparator Date - Time separator. Used to split date and time (defaults to ' ' (space))
43
- */
44
- ,dtSeparator:' '
45
- /**
46
- * @cfg {String} hiddenFormat Format of datetime used to store value in hidden field
47
- * and submitted to server (defaults to 'Y-m-d H:i:s' that is mysql format)
48
- */
49
- ,hiddenFormat:'Y-m-d H:i:s'
50
- /**
51
- * @cfg {Boolean} otherToNow Set other field to now() if not explicly filled in (defaults to true)
52
- */
53
- ,otherToNow:true
54
- /**
55
- * @cfg {Boolean} emptyToNow Set field value to now on attempt to set empty value.
56
- * If it is true then setValue() sets value of field to current date and time (defaults to false)
57
- */
58
- /**
59
- * @cfg {String} timePosition Where the time field should be rendered. 'right' is suitable for forms
60
- * and 'below' is suitable if the field is used as the grid editor (defaults to 'right')
61
- */
62
- ,timePosition:'right' // valid values:'below', 'right'
63
- /**
64
- * @cfg {String} dateFormat Format of DateField. Can be localized. (defaults to 'm/y/d')
65
- */
66
- ,dateFormat:'m/d/y'
67
- /**
68
- * @cfg {String} timeFormat Format of TimeField. Can be localized. (defaults to 'g:i A')
69
- */
70
- ,timeFormat:'g:i A'
71
- /**
72
- * @cfg {Object} dateConfig Config for DateField constructor.
73
- */
74
- /**
75
- * @cfg {Object} timeConfig Config for TimeField constructor.
76
- */
77
-
78
- // {{{
79
- /**
80
- * @private
81
- * creates DateField and TimeField and installs the necessary event handlers
82
- */
83
- ,initComponent:function() {
84
- // call parent initComponent
85
- Ext.ux.form.DateTime.superclass.initComponent.call(this);
86
-
87
- // create DateField
88
- var dateConfig = Ext.apply({}, {
89
- id:this.id + '-date'
90
- ,format:this.dateFormat || Ext.form.DateField.prototype.format
91
- ,width:this.timeWidth
92
- ,selectOnFocus:this.selectOnFocus
93
- ,listeners:{
94
- blur:{scope:this, fn:this.onBlur}
95
- ,focus:{scope:this, fn:this.onFocus}
96
- }
97
- }, this.dateConfig);
98
- this.df = new Ext.form.DateField(dateConfig);
99
- this.df.ownerCt = this;
100
- delete(this.dateFormat);
101
-
102
-
103
- // create TimeField
104
- var timeConfig = Ext.apply({}, {
105
- id:this.id + '-time'
106
- ,format:this.timeFormat || Ext.form.TimeField.prototype.format
107
- ,width:this.timeWidth
108
- ,selectOnFocus:this.selectOnFocus
109
- ,listeners:{
110
- blur:{scope:this, fn:this.onBlur}
111
- ,focus:{scope:this, fn:this.onFocus}
112
- }
113
- }, this.timeConfig);
114
- this.tf = new Ext.form.TimeField(timeConfig);
115
- this.tf.ownerCt = this;
116
- delete(this.timeFormat);
117
-
118
- // relay events
119
- this.relayEvents(this.df, ['focus', 'specialkey', 'invalid', 'valid']);
120
- this.relayEvents(this.tf, ['focus', 'specialkey', 'invalid', 'valid']);
121
-
122
- } // eo function initComponent
123
- // }}}
124
- // {{{
125
- /**
126
- * @private
127
- * Renders underlying DateField and TimeField and provides a workaround for side error icon bug
128
- */
129
- ,onRender:function(ct, position) {
130
- // don't run more than once
131
- if(this.isRendered) {
132
- return;
133
- }
134
-
135
- // render underlying hidden field
136
- Ext.ux.form.DateTime.superclass.onRender.call(this, ct, position);
137
-
138
- // render DateField and TimeField
139
- // create bounding table
140
- var t;
141
- if('below' === this.timePosition || 'bellow' === this.timePosition) {
142
- t = Ext.DomHelper.append(ct, {tag:'table',style:'border-collapse:collapse',children:[
143
- {tag:'tr',children:[{tag:'td', style:'padding-bottom:1px', cls:'ux-datetime-date'}]}
144
- ,{tag:'tr',children:[{tag:'td', cls:'ux-datetime-time'}]}
145
- ]}, true);
146
- }
147
- else {
148
- t = Ext.DomHelper.append(ct, {tag:'table',style:'border-collapse:collapse',children:[
149
- {tag:'tr',children:[
150
- {tag:'td',style:'padding-right:4px', cls:'ux-datetime-date'},{tag:'td', cls:'ux-datetime-time'}
151
- ]}
152
- ]}, true);
153
- }
154
-
155
- this.tableEl = t;
156
- // this.wrap = t.wrap({cls:'x-form-field-wrap'});
157
- this.wrap = t.wrap();
158
- this.wrap.on("mousedown", this.onMouseDown, this, {delay:10});
159
-
160
- // render DateField & TimeField
161
- this.df.render(t.child('td.ux-datetime-date'));
162
- this.tf.render(t.child('td.ux-datetime-time'));
163
-
164
- // workaround for IE trigger misalignment bug
165
- if(Ext.isIE && Ext.isStrict) {
166
- t.select('input').applyStyles({top:0});
167
- }
168
-
169
- this.on('specialkey', this.onSpecialKey, this);
170
- this.df.el.swallowEvent(['keydown', 'keypress']);
171
- this.tf.el.swallowEvent(['keydown', 'keypress']);
172
-
173
- // create icon for side invalid errorIcon
174
- if('side' === this.msgTarget) {
175
- var elp = this.el.findParent('.x-form-element', 10, true);
176
- this.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});
177
-
178
- this.df.errorIcon = this.errorIcon;
179
- this.tf.errorIcon = this.errorIcon;
180
- }
181
-
182
- // setup name for submit
183
- this.el.dom.name = this.hiddenName || this.name || this.id;
184
-
185
- // prevent helper fields from being submitted
186
- this.df.el.dom.removeAttribute("name");
187
- this.tf.el.dom.removeAttribute("name");
188
-
189
- // we're rendered flag
190
- this.isRendered = true;
191
-
192
- // update hidden field
193
- this.updateHidden();
194
-
195
- } // eo function onRender
196
- // }}}
197
- // {{{
198
- /**
199
- * @private
200
- */
201
- ,adjustSize:Ext.BoxComponent.prototype.adjustSize
202
- // }}}
203
- // {{{
204
- /**
205
- * @private
206
- */
207
- ,alignErrorIcon:function() {
208
- this.errorIcon.alignTo(this.tableEl, 'tl-tr', [2, 0]);
209
- }
210
- // }}}
211
- // {{{
212
- /**
213
- * @private initializes internal dateValue
214
- */
215
- ,initDateValue:function() {
216
- this.dateValue = this.otherToNow ? new Date() : new Date(1970, 0, 1, 0, 0, 0);
217
- }
218
- // }}}
219
- // {{{
220
- /**
221
- * Calls clearInvalid on the DateField and TimeField
222
- */
223
- ,clearInvalid:function(){
224
- this.df.clearInvalid();
225
- this.tf.clearInvalid();
226
- } // eo function clearInvalid
227
- // }}}
228
- // {{{
229
- /**
230
- * @private
231
- * called from Component::destroy.
232
- * Destroys all elements and removes all listeners we've created.
233
- */
234
- ,beforeDestroy:function() {
235
- if(this.isRendered) {
236
- // this.removeAllListeners();
237
- this.wrap.removeAllListeners();
238
- this.wrap.remove();
239
- this.tableEl.remove();
240
- this.df.destroy();
241
- this.tf.destroy();
242
- }
243
- } // eo function beforeDestroy
244
- // }}}
245
- // {{{
246
- /**
247
- * Disable this component.
248
- * @return {Ext.Component} this
249
- */
250
- ,disable:function() {
251
- if(this.isRendered) {
252
- this.df.disabled = this.disabled;
253
- this.df.onDisable();
254
- this.tf.onDisable();
255
- }
256
- this.disabled = true;
257
- this.df.disabled = true;
258
- this.tf.disabled = true;
259
- this.fireEvent("disable", this);
260
- return this;
261
- } // eo function disable
262
- // }}}
263
- // {{{
264
- /**
265
- * Enable this component.
266
- * @return {Ext.Component} this
267
- */
268
- ,enable:function() {
269
- if(this.rendered){
270
- this.df.onEnable();
271
- this.tf.onEnable();
272
- }
273
- this.disabled = false;
274
- this.df.disabled = false;
275
- this.tf.disabled = false;
276
- this.fireEvent("enable", this);
277
- return this;
278
- } // eo function enable
279
- // }}}
280
- // {{{
281
- /**
282
- * @private Focus date filed
283
- */
284
- ,focus:function() {
285
- this.df.focus();
286
- } // eo function focus
287
- // }}}
288
- // {{{
289
- /**
290
- * @private
291
- */
292
- ,getPositionEl:function() {
293
- return this.wrap;
294
- }
295
- // }}}
296
- // {{{
297
- /**
298
- * @private
299
- */
300
- ,getResizeEl:function() {
301
- return this.wrap;
302
- }
303
- // }}}
304
- // {{{
305
- /**
306
- * @return {Date/String} Returns value of this field
307
- */
308
- ,getValue:function() {
309
- // create new instance of date
310
- return this.dateValue ? new Date(this.dateValue) : '';
311
- } // eo function getValue
312
- // }}}
313
- // {{{
314
- /**
315
- * @return {Boolean} true = valid, false = invalid
316
- * @private Calls isValid methods of underlying DateField and TimeField and returns the result
317
- */
318
- ,isValid:function() {
319
- return this.df.isValid() && this.tf.isValid();
320
- } // eo function isValid
321
- // }}}
322
- // {{{
323
- /**
324
- * Returns true if this component is visible
325
- * @return {boolean}
326
- */
327
- ,isVisible : function(){
328
- return this.df.rendered && this.df.getActionEl().isVisible();
329
- } // eo function isVisible
330
- // }}}
331
- // {{{
332
- /**
333
- * @private Handles blur event
334
- */
335
- ,onBlur:function(f) {
336
- // called by both DateField and TimeField blur events
337
-
338
- // revert focus to previous field if clicked in between
339
- if(this.wrapClick) {
340
- f.focus();
341
- this.wrapClick = false;
342
- }
343
-
344
- // update underlying value
345
- if(f === this.df) {
346
- this.updateDate();
347
- }
348
- else {
349
- this.updateTime();
350
- }
351
- this.updateHidden();
352
-
353
- // fire events later
354
- (function() {
355
- if(!this.df.hasFocus && !this.tf.hasFocus) {
356
- var v = this.getValue();
357
- if(String(v) !== String(this.startValue)) {
358
- this.fireEvent("change", this, v, this.startValue);
359
- }
360
- this.hasFocus = false;
361
- this.fireEvent('blur', this);
362
- }
363
- }).defer(100, this);
364
-
365
- } // eo function onBlur
366
- // }}}
367
- // {{{
368
- /**
369
- * @private Handles focus event
370
- */
371
- ,onFocus:function() {
372
- if(!this.hasFocus){
373
- this.hasFocus = true;
374
- this.startValue = this.getValue();
375
- this.fireEvent("focus", this);
376
- }
377
- }
378
- // }}}
379
- // {{{
380
- /**
381
- * @private Just to prevent blur event when clicked in the middle of fields
382
- */
383
- ,onMouseDown:function(e) {
384
- if(!this.disabled) {
385
- this.wrapClick = 'td' === e.target.nodeName.toLowerCase();
386
- }
387
- }
388
- // }}}
389
- // {{{
390
- /**
391
- * @private
392
- * Handles Tab and Shift-Tab events
393
- */
394
- ,onSpecialKey:function(t, e) {
395
- var key = e.getKey();
396
- if(key === e.TAB) {
397
- if(t === this.df && !e.shiftKey) {
398
- e.stopEvent();
399
- this.tf.focus();
400
- }
401
- if(t === this.tf && e.shiftKey) {
402
- e.stopEvent();
403
- this.df.focus();
404
- }
405
- }
406
- // otherwise it misbehaves in editor grid
407
- if(key === e.ENTER) {
408
- this.updateValue();
409
- }
410
-
411
- } // eo function onSpecialKey
412
- // }}}
413
- // {{{
414
- /**
415
- * @private Sets the value of DateField
416
- */
417
- ,setDate:function(date) {
418
- this.df.setValue(date);
419
- } // eo function setDate
420
- // }}}
421
- // {{{
422
- /**
423
- * @private Sets the value of TimeField
424
- */
425
- ,setTime:function(date) {
426
- this.tf.setValue(date);
427
- } // eo function setTime
428
- // }}}
429
- // {{{
430
- /**
431
- * @private
432
- * Sets correct sizes of underlying DateField and TimeField
433
- * With workarounds for IE bugs
434
- */
435
- ,setSize:function(w, h) {
436
- if(!w) {
437
- return;
438
- }
439
- if('below' === this.timePosition) {
440
- this.df.setSize(w, h);
441
- this.tf.setSize(w, h);
442
- if(Ext.isIE) {
443
- this.df.el.up('td').setWidth(w);
444
- this.tf.el.up('td').setWidth(w);
445
- }
446
- }
447
- else {
448
- this.df.setSize(w - this.timeWidth - 4, h);
449
- this.tf.setSize(this.timeWidth, h);
450
-
451
- if(Ext.isIE) {
452
- this.df.el.up('td').setWidth(w - this.timeWidth - 4);
453
- this.tf.el.up('td').setWidth(this.timeWidth);
454
- }
455
- }
456
- } // eo function setSize
457
- // }}}
458
- // {{{
459
- /**
460
- * @param {Mixed} val Value to set
461
- * Sets the value of this field
462
- */
463
- ,setValue:function(val) {
464
- if(!val && true === this.emptyToNow) {
465
- this.setValue(new Date());
466
- return;
467
- }
468
- else if(!val) {
469
- this.setDate('');
470
- this.setTime('');
471
- this.updateValue();
472
- return;
473
- }
474
- if ('number' === typeof val) {
475
- val = new Date(val);
476
- }
477
- else if('string' === typeof val && this.hiddenFormat) {
478
- val = Date.parseDate(val, this.hiddenFormat)
479
- }
480
- val = val ? val : new Date(1970, 0 ,1, 0, 0, 0);
481
- var da, time;
482
- if(val instanceof Date) {
483
- this.setDate(val);
484
- this.setTime(val);
485
- this.dateValue = new Date(val);
486
- }
487
- else {
488
- da = val.split(this.dtSeparator);
489
- this.setDate(da[0]);
490
- if(da[1]) {
491
- if(da[2]) {
492
- // add am/pm part back to time
493
- da[1] += da[2];
494
- }
495
- this.setTime(da[1]);
496
- }
497
- }
498
- this.updateValue();
499
- } // eo function setValue
500
- // }}}
501
- // {{{
502
- /**
503
- * Hide or show this component by boolean
504
- * @return {Ext.Component} this
505
- */
506
- ,setVisible: function(visible){
507
- if(visible) {
508
- this.df.show();
509
- this.tf.show();
510
- }else{
511
- this.df.hide();
512
- this.tf.hide();
513
- }
514
- return this;
515
- } // eo function setVisible
516
- // }}}
517
- //{{{
518
- ,show:function() {
519
- return this.setVisible(true);
520
- } // eo function show
521
- //}}}
522
- //{{{
523
- ,hide:function() {
524
- return this.setVisible(false);
525
- } // eo function hide
526
- //}}}
527
- // {{{
528
- /**
529
- * @private Updates the date part
530
- */
531
- ,updateDate:function() {
532
-
533
- var d = this.df.getValue();
534
- if(d) {
535
- if(!(this.dateValue instanceof Date)) {
536
- this.initDateValue();
537
- if(!this.tf.getValue()) {
538
- this.setTime(this.dateValue);
539
- }
540
- }
541
- this.dateValue.setMonth(0); // because of leap years
542
- this.dateValue.setFullYear(d.getFullYear());
543
- this.dateValue.setMonth(d.getMonth(), d.getDate());
544
- // this.dateValue.setDate(d.getDate());
545
- }
546
- else {
547
- this.dateValue = '';
548
- this.setTime('');
549
- }
550
- } // eo function updateDate
551
- // }}}
552
- // {{{
553
- /**
554
- * @private
555
- * Updates the time part
556
- */
557
- ,updateTime:function() {
558
- var t = this.tf.getValue();
559
- if(t && !(t instanceof Date)) {
560
- t = Date.parseDate(t, this.tf.format);
561
- }
562
- if(t && !this.df.getValue()) {
563
- this.initDateValue();
564
- this.setDate(this.dateValue);
565
- }
566
- if(this.dateValue instanceof Date) {
567
- if(t) {
568
- this.dateValue.setHours(t.getHours());
569
- this.dateValue.setMinutes(t.getMinutes());
570
- this.dateValue.setSeconds(t.getSeconds());
571
- }
572
- else {
573
- this.dateValue.setHours(0);
574
- this.dateValue.setMinutes(0);
575
- this.dateValue.setSeconds(0);
576
- }
577
- }
578
- } // eo function updateTime
579
- // }}}
580
- // {{{
581
- /**
582
- * @private Updates the underlying hidden field value
583
- */
584
- ,updateHidden:function() {
585
- if(this.isRendered) {
586
- var value = this.dateValue instanceof Date ? this.dateValue.format(this.hiddenFormat) : '';
587
- this.el.dom.value = value;
588
- }
589
- }
590
- // }}}
591
- // {{{
592
- /**
593
- * @private Updates all of Date, Time and Hidden
594
- */
595
- ,updateValue:function() {
596
-
597
- this.updateDate();
598
- this.updateTime();
599
- this.updateHidden();
600
-
601
- return;
602
- } // eo function updateValue
603
- // }}}
604
- // {{{
605
- /**
606
- * @return {Boolean} true = valid, false = invalid
607
- * calls validate methods of DateField and TimeField
608
- */
609
- ,validate:function() {
610
- return this.df.validate() && this.tf.validate();
611
- } // eo function validate
612
- // }}}
613
- // {{{
614
- /**
615
- * Returns renderer suitable to render this field
616
- * @param {Object} Column model config
617
- */
618
- ,renderer: function(field) {
619
- var format = field.editor.dateFormat || Ext.ux.form.DateTime.prototype.dateFormat;
620
- format += ' ' + (field.editor.timeFormat || Ext.ux.form.DateTime.prototype.timeFormat);
621
- var renderer = function(val) {
622
- var retval = Ext.util.Format.date(val, format);
623
- return retval;
624
- };
625
- return renderer;
626
- } // eo function renderer
627
- // }}}
628
-
629
- }); // eo extend
630
-
631
- // register xtype
632
- Ext.reg('xdatetime', Ext.ux.form.DateTime);
633
-
634
- // eof