/*! * Ext JS Library 3.3.1 * Copyright(c) 2006-2010 Sencha Inc. * licensing@sencha.com * http://www.sencha.com/license */ /** * @class Ext.calendar.DateRangeField * @extends Ext.form.Field *
A combination field that includes start and end dates and times, as well as an optional all-day checkbox.
* @constructor * @param {Object} config The config object */ Ext.calendar.DateRangeField = Ext.extend(Ext.form.Field, { /** * @cfg {String} toText * The text to display in between the date/time fields (defaults to 'to') */ toText: 'a', /** * @cfg {String} toText * The text to display as the label for the all day checkbox (defaults to 'All day') */ allDayText: 'Todo el día', // private onRender: function(ct, position) { if (!this.el) { this.startDate = new Ext.form.DateField({ id: this.id + '-start-date', format: 'j/n/Y', width: 100, listeners: { 'change': { fn: function() { this.checkDates('date', 'start'); }, scope: this } } }); this.startTime = new Ext.form.TimeField({ id: this.id + '-start-time', hidden: this.showTimes === false, labelWidth: 0, hideLabel: true, minValue: '7:00 AM', maxValue: '23:00 PM', width: 90, listeners: { 'select': { fn: function() { this.checkDates('time', 'start'); }, scope: this } } }); this.endTime = new Ext.form.TimeField({ id: this.id + '-end-time', hidden: this.showTimes === false, labelWidth: 0, hideLabel: true, minValue: '7:00 AM', maxValue: '23:00 PM', width: 90, listeners: { 'select': { fn: function() { this.checkDates('time', 'end'); }, scope: this } } }); this.endDate = new Ext.form.DateField({ id: this.id + '-end-date', format: 'j/n/Y', hideLabel: true, width: 100, listeners: { 'change': { fn: function() { this.checkDates('date', 'end'); }, scope: this } } }); this.allDay = new Ext.form.Checkbox({ id: this.id + '-allday', hidden: this.showTimes === false || this.showAllDay === false, boxLabel: this.allDayText, handler: function(chk, checked) { this.startTime.setVisible(!checked); this.endTime.setVisible(!checked); }, scope: this }); this.toLabel = new Ext.form.Label({ xtype: 'label', id: this.id + '-to-label', text: this.toText }); this.fieldCt = new Ext.Container({ autoEl: { id: this.id }, //make sure the container el has the field's id cls: 'ext-dt-range', renderTo: ct, layout: 'table', layoutConfig: { columns: 6 }, defaults: { hideParent: true }, items: [ this.startDate, this.startTime, this.toLabel, this.endTime, this.endDate, this.allDay ] }); this.fieldCt.ownerCt = this; this.el = this.fieldCt.getEl(); this.items = new Ext.util.MixedCollection(); this.items.addAll([this.startDate, this.endDate, this.toLabel, this.startTime, this.endTime, this.allDay]); } Ext.calendar.DateRangeField.superclass.onRender.call(this, ct, position); }, // private checkDates: function(type, startend) { var startField = Ext.getCmp(this.id + '-start-' + type), endField = Ext.getCmp(this.id + '-end-' + type), startValue = this.getDT('start'), endValue = this.getDT('end'); if (startValue > endValue) { if (startend == 'start') { endField.setValue(startValue); } else { startField.setValue(endValue); this.checkDates(type, 'start'); } } if (type == 'date') { this.checkDates('time', startend); } }, /** * Returns an array containing the following values in order:DateTime : DateTime : Boolean : Array : DateTime : Object :