1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
* Ext JS Library 3.3.1
* Copyright(c) 2006-2010 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
<div id="cls-Ext.calendar.EventEditForm"></div>/**
* @class Ext.calendar.EventEditForm
* @extends Ext.form.FormPanel
* <p>A custom form used for detailed editing of events.</p>
* <p>This is pretty much a standard form that is simply pre-configured for the options needed by the
* calendar components. It is also configured to automatically bind records of type {@link Ext.calendar.EventRecord}
* to and from the form.</p>
* <p>This form also provides custom events specific to the calendar so that other calendar components can be easily
* notified when an event has been edited via this component.</p>
* <p>The default configs are as follows:</p><pre><code>
labelWidth: 65,
title: 'Event Form',
titleTextAdd: 'Add Event',
titleTextEdit: 'Edit Event',
bodyStyle: 'background:transparent;padding:20px 20px 10px;',
border: false,
buttonAlign: 'center',
autoHeight: true,
cls: 'ext-evt-edit-form',
</code></pre>
* @constructor
* @param {Object} config The config object
*/
Ext.calendar.EventEditForm = Ext.extend(Ext.form.FormPanel, {
labelWidth: 65,
title: 'Event Form',
titleTextAdd: 'Add Event',
titleTextEdit: 'Edit Event',
bodyStyle: 'background:transparent;padding:20px 20px 10px;',
border: false,
buttonAlign: 'center',
autoHeight: true,
// to allow for the notes field to autogrow
cls: 'ext-evt-edit-form',
// private properties:
newId: 10000,
layout: 'column',
// private
initComponent: function() {
this.addEvents({
<div id="event-Ext.calendar.EventEditForm-eventadd"></div>/**
* @event eventadd
* Fires after a new event is added
* @param {Ext.calendar.EventEditForm} this
* @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was added
*/
eventadd: true,
<div id="event-Ext.calendar.EventEditForm-eventupdate"></div>/**
* @event eventupdate
* Fires after an existing event is updated
* @param {Ext.calendar.EventEditForm} this
* @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was updated
*/
eventupdate: true,
<div id="event-Ext.calendar.EventEditForm-eventdelete"></div>/**
* @event eventdelete
* Fires after an event is deleted
* @param {Ext.calendar.EventEditForm} this
* @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was deleted
*/
eventdelete: true,
<div id="event-Ext.calendar.EventEditForm-eventcancel"></div>/**
* @event eventcancel
* Fires after an event add/edit operation is canceled by the user and no store update took place
* @param {Ext.calendar.EventEditForm} this
* @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was canceled
*/
eventcancel: true
});
this.titleField = new Ext.form.TextField({
fieldLabel: 'Title',
name: Ext.calendar.EventMappings.Title.name,
anchor: '90%'
});
this.dateRangeField = new Ext.calendar.DateRangeField({
fieldLabel: 'When',
anchor: '90%'
});
this.reminderField = new Ext.calendar.ReminderField({
name: 'Reminder'
});
this.notesField = new Ext.form.TextArea({
fieldLabel: 'Notes',
name: Ext.calendar.EventMappings.Notes.name,
grow: true,
growMax: 150,
anchor: '100%'
});
this.locationField = new Ext.form.TextField({
fieldLabel: 'Location',
name: Ext.calendar.EventMappings.Location.name,
anchor: '100%'
});
this.urlField = new Ext.form.TextField({
fieldLabel: 'Web Link',
name: Ext.calendar.EventMappings.Url.name,
anchor: '100%'
});
var leftFields = [this.titleField, this.dateRangeField, this.reminderField],
rightFields = [this.notesField, this.locationField, this.urlField];
if (this.calendarStore) {
this.calendarField = new Ext.calendar.CalendarPicker({
store: this.calendarStore,
name: Ext.calendar.EventMappings.CalendarId.name
});
leftFields.splice(2, 0, this.calendarField);
};
this.items = [{
id: 'left-col',
columnWidth: 0.65,
layout: 'form',
border: false,
items: leftFields
},
{
id: 'right-col',
columnWidth: 0.35,
layout: 'form',
border: false,
items: rightFields
}];
this.fbar = [{
text: 'Save',
scope: this,
handler: this.onSave
},
{
cls: 'ext-del-btn',
text: 'Delete',
scope: this,
handler: this.onDelete
},
{
text: 'Cancel',
scope: this,
handler: this.onCancel
}];
Ext.calendar.EventEditForm.superclass.initComponent.call(this);
},
// inherited docs
loadRecord: function(rec) {
this.form.loadRecord.apply(this.form, arguments);
this.activeRecord = rec;
this.dateRangeField.setValue(rec.data);
if (this.calendarStore) {
this.form.setValues({
'calendar': rec.data[Ext.calendar.EventMappings.CalendarId.name]
});
}
this.isAdd = !!rec.data[Ext.calendar.EventMappings.IsNew.name];
if (this.isAdd) {
rec.markDirty();
this.setTitle(this.titleTextAdd);
Ext.select('.ext-del-btn').setDisplayed(false);
}
else {
this.setTitle(this.titleTextEdit);
Ext.select('.ext-del-btn').setDisplayed(true);
}
this.titleField.focus();
},
// inherited docs
updateRecord: function() {
var dates = this.dateRangeField.getValue();
this.form.updateRecord(this.activeRecord);
this.activeRecord.set(Ext.calendar.EventMappings.StartDate.name, dates[0]);
this.activeRecord.set(Ext.calendar.EventMappings.EndDate.name, dates[1]);
this.activeRecord.set(Ext.calendar.EventMappings.IsAllDay.name, dates[2]);
},
// private
onCancel: function() {
this.cleanup(true);
this.fireEvent('eventcancel', this, this.activeRecord);
},
// private
cleanup: function(hide) {
if (this.activeRecord && this.activeRecord.dirty) {
this.activeRecord.reject();
}
delete this.activeRecord;
if (this.form.isDirty()) {
this.form.reset();
}
},
// private
onSave: function() {
if (!this.form.isValid()) {
return;
}
this.updateRecord();
if (!this.activeRecord.dirty) {
this.onCancel();
return;
}
this.fireEvent(this.isAdd ? 'eventadd': 'eventupdate', this, this.activeRecord);
},
// private
onDelete: function() {
this.fireEvent('eventdelete', this, this.activeRecord);
}
});
Ext.reg('eventeditform', Ext.calendar.EventEditForm);
</pre>
</body>
</html>
|