3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 <div id="cls-Ext.calendar.EventEditForm"></div>/**
16 * @class Ext.calendar.EventEditForm
17 * @extends Ext.form.FormPanel
18 * <p>A custom form used for detailed editing of events.</p>
19 * <p>This is pretty much a standard form that is simply pre-configured for the options needed by the
20 * calendar components. It is also configured to automatically bind records of type {@link Ext.calendar.EventRecord}
21 * to and from the form.</p>
22 * <p>This form also provides custom events specific to the calendar so that other calendar components can be easily
23 * notified when an event has been edited via this component.</p>
24 * <p>The default configs are as follows:</p><pre><code>
27 titleTextAdd: 'Add Event',
28 titleTextEdit: 'Edit Event',
29 bodyStyle: 'background:transparent;padding:20px 20px 10px;',
31 buttonAlign: 'center',
33 cls: 'ext-evt-edit-form',
36 * @param {Object} config The config object
38 Ext.calendar.EventEditForm = Ext.extend(Ext.form.FormPanel, {
41 titleTextAdd: 'Add Event',
42 titleTextEdit: 'Edit Event',
43 bodyStyle: 'background:transparent;padding:20px 20px 10px;',
45 buttonAlign: 'center',
47 // to allow for the notes field to autogrow
48 cls: 'ext-evt-edit-form',
50 // private properties:
55 initComponent: function() {
58 <div id="event-Ext.calendar.EventEditForm-eventadd"></div>/**
60 * Fires after a new event is added
61 * @param {Ext.calendar.EventEditForm} this
62 * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was added
65 <div id="event-Ext.calendar.EventEditForm-eventupdate"></div>/**
67 * Fires after an existing event is updated
68 * @param {Ext.calendar.EventEditForm} this
69 * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was updated
72 <div id="event-Ext.calendar.EventEditForm-eventdelete"></div>/**
74 * Fires after an event is deleted
75 * @param {Ext.calendar.EventEditForm} this
76 * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was deleted
79 <div id="event-Ext.calendar.EventEditForm-eventcancel"></div>/**
81 * Fires after an event add/edit operation is canceled by the user and no store update took place
82 * @param {Ext.calendar.EventEditForm} this
83 * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was canceled
88 this.titleField = new Ext.form.TextField({
90 name: Ext.calendar.EventMappings.Title.name,
93 this.dateRangeField = new Ext.calendar.DateRangeField({
97 this.reminderField = new Ext.calendar.ReminderField({
100 this.notesField = new Ext.form.TextArea({
102 name: Ext.calendar.EventMappings.Notes.name,
107 this.locationField = new Ext.form.TextField({
108 fieldLabel: 'Location',
109 name: Ext.calendar.EventMappings.Location.name,
112 this.urlField = new Ext.form.TextField({
113 fieldLabel: 'Web Link',
114 name: Ext.calendar.EventMappings.Url.name,
118 var leftFields = [this.titleField, this.dateRangeField, this.reminderField],
119 rightFields = [this.notesField, this.locationField, this.urlField];
121 if (this.calendarStore) {
122 this.calendarField = new Ext.calendar.CalendarPicker({
123 store: this.calendarStore,
124 name: Ext.calendar.EventMappings.CalendarId.name
126 leftFields.splice(2, 0, this.calendarField);
153 handler: this.onDelete
158 handler: this.onCancel
161 Ext.calendar.EventEditForm.superclass.initComponent.call(this);
165 loadRecord: function(rec) {
166 this.form.loadRecord.apply(this.form, arguments);
167 this.activeRecord = rec;
168 this.dateRangeField.setValue(rec.data);
169 if (this.calendarStore) {
170 this.form.setValues({
171 'calendar': rec.data[Ext.calendar.EventMappings.CalendarId.name]
174 this.isAdd = !!rec.data[Ext.calendar.EventMappings.IsNew.name];
177 this.setTitle(this.titleTextAdd);
178 Ext.select('.ext-del-btn').setDisplayed(false);
181 this.setTitle(this.titleTextEdit);
182 Ext.select('.ext-del-btn').setDisplayed(true);
184 this.titleField.focus();
188 updateRecord: function() {
189 var dates = this.dateRangeField.getValue();
191 this.form.updateRecord(this.activeRecord);
192 this.activeRecord.set(Ext.calendar.EventMappings.StartDate.name, dates[0]);
193 this.activeRecord.set(Ext.calendar.EventMappings.EndDate.name, dates[1]);
194 this.activeRecord.set(Ext.calendar.EventMappings.IsAllDay.name, dates[2]);
198 onCancel: function() {
200 this.fireEvent('eventcancel', this, this.activeRecord);
204 cleanup: function(hide) {
205 if (this.activeRecord && this.activeRecord.dirty) {
206 this.activeRecord.reject();
208 delete this.activeRecord;
210 if (this.form.isDirty()) {
217 if (!this.form.isValid()) {
222 if (!this.activeRecord.dirty) {
227 this.fireEvent(this.isAdd ? 'eventadd': 'eventupdate', this, this.activeRecord);
231 onDelete: function() {
232 this.fireEvent('eventdelete', this, this.activeRecord);
236 Ext.reg('eventeditform', Ext.calendar.EventEditForm);