This repository was archived by the owner on Sep 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathext_bug_fixes.js
More file actions
256 lines (233 loc) · 8.53 KB
/
ext_bug_fixes.js
File metadata and controls
256 lines (233 loc) · 8.53 KB
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/*globals Ext, console */
/*jslint glovar: true, undef: true, browser: true */
/* This code fixes a bug on Radios */
Ext.override(Ext.form.BasicForm, {
setValues : function(values) {
if(values instanceof Array){
for(var i = 0, len = values.length; i < len; i++){
var v = values[i];
var f = this.findField(v.id);
if(f){
if ( f.getEl().dom.type == 'radio' ) {
var group = this.el.dom.elements[f.getName()];
for (var i2=0; i < group.length; i2++ ) {
if(group[i2].__ext_field) {
group[i2].__ext_field.setValue(group[i2].value == v);
if(this.trackResetOnLoad){
group[i2].__ext_field.originalValue = group[i2].__ext_field.getValue();
}
}
}
}
else
{
f.setValue(v.value);
if(this.trackResetOnLoad){
f.originalValue = f.getValue();
}
}
}
}
}else{
var field, id;
for(id in values){
if(typeof values[id] != 'function' && (field = this.findField(id))){
if( field.getEl().dom.type == 'radio' ) {
var group2 = this.el.dom.elements[field.getName()];
for (var i3=0; i3 < group2.length; i3++ ) {
if(group2[i3].__ext_field) {
group2[i3].__ext_field.setValue(group2[i3].value == values[id]);
if(this.trackResetOnLoad){
group2[i3].__ext_field.originalValue = group2[i3].__ext_field.getValue();
}
}
}
}
else
{
field.setValue(values[id]);
if(this.trackResetOnLoad){
field.originalValue = field.getValue();
}
}
}
}
}
return this;
}
});
Ext.override(Ext.form.Radio, {
onRender : function(ct, position) {
Ext.form.Radio.superclass.onRender.call(this, ct, position);
this.el.dom.__ext_field = this;
},
setValue : function(v) {
if(v === true || v === 'true' || v == '1' || v === false || v === 'false' || v == '0') {
// Select all radios of this group
var radios = this.el.up('form').select('input[type=radio]');
this.checked = (v === true || v === 'true' || v == '1');
if(this.el && this.el.dom) {
this.el.dom.checked = this.checked;
}
// When a radio il checked, all other radios with the same name are unchecked automatically by
// the browser, so the DOM part is done. Now we must set checked = false on the Ext object
// and fire the "check" (false) event with the correct parameters
// This cycles over all the radios...
for(var i = 0; i < radios.elements.length; i++) {
if(radios.elements[i].__ext_field && radios.elements[i].__ext_field != this && radios.elements[i].name == this.el.dom.name && radios.elements[i].__ext_field.el.dom.checked === false)
{
radios.elements[i].__ext_field.checked = false;
radios.elements[i].__ext_field.fireEvent("check", radios.elements[i].__ext_field, false);
}
}
// Lastly, we must fire the "check" (true) event on the selected radio
this.fireEvent("check", this, this.checked);
}
}
});
//Ext.form.Field.onBlur calls beforeBlur too
Ext.override(Ext.form.TriggerField, {
triggerBlur : function(){
this.mimicing = false;
Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur);
if(this.monitorTab){
this.el.un("keydown", this.checkTab, this);
}
Ext.form.TriggerField.superclass.onBlur.call(this);
},
beforeBlur : function() {
Ext.form.TriggerField.superclass.beforeBlur.call(this);
this.wrap.removeClass('x-trigger-wrap-focus');
}
});
Ext.override(Ext.DataView, {
// The default implementation is always giving me errors
// about updating elements that don't exist
onUpdate: function(ds, record) {
this.refresh();
}
});
Ext.override(Ext.data.GroupingStore, {
applySort : function(){
Ext.data.GroupingStore.superclass.applySort.call(this);
if(!this.groupOnSort && !this.remoteGroup){
var gs = this.getGroupState();
if(gs && (!this.sortInfo || gs != this.sortInfo.field)){
this.sortData(this.groupField);
}
}
}
});
Ext.override(Ext.tree.TreeNodeUI, {
collapse: function() {
this.updateExpandIcon();
// There is a bug where the code below
// is called when not rendered. Line 22946
if(this.rendered) {
this.ctNode.style.display = "none";
}
}
});
// The removeMask feature is busted by default
Ext.override(Ext.LoadMask, {
onLoad: function() {
this.el.unmask();
if(this.removeMask) {
this.disabled = true;
this.destroy();
}
}
});
Ext.override(Ext.PagingToolbar, {
onLoad : function(store, r, o){
if(!this.rendered){
this.dsLoaded = [store, r, o];
return;
}
// Fixed just this line. caused UI problems if start wasn't in the params
this.cursor = o.params ? (o.params[this.paramNames.start] || 0) : 0;
var d = this.getPageData(), ap = d.activePage, ps = d.pages;
this.afterTextEl.el.innerHTML = String.format(this.afterPageText, d.pages);
this.field.dom.value = ap;
this.first.setDisabled(ap == 1);
this.prev.setDisabled(ap == 1);
this.next.setDisabled(ap == ps);
this.last.setDisabled(ap == ps);
this.loading.enable();
this.updateInfo();
}
});
Ext.override(Ext.form.ComboBox, {
clearValue : function(){
if(this.hiddenField){
this.hiddenField.value = '';
}
//By default if you call clearValue, then getValue, it
//will return the previous value
this.value = null;
this.setRawValue('');
this.lastSelectionText = '';
this.applyEmptyText();
},
onDisable: function(){
// this.disabled isn't set until AFTER this method is called,
// so the default implementation is just wacked
Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);
if(this.hiddenField){
this.hiddenField.disabled = true;
}
},
onEnable: function() {
// This is entirely missing
Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);
if(this.hiddenField) {
this.hiddenField.disabled = false;
}
}
});
Ext.override(Ext.data.Store, {
onMetaChange: function(meta, rtype, o) {
this.recordType = rtype;
this.fields = rtype.prototype.fields;
delete this.snapshot;
if(meta.sortInfo) {
// Only change the sortInfo if it is provided, this
// allows the server to choose not to affect the any
// sort applied by the user
this.sortInfo = meta.sortInfo;
}
this.modified = [];
this.fireEvent('metachange', this, this.reader.meta);
},
insert: function(index, records) {
records = [].concat(records);
for(var i = 0, len = records.length; i < len; i++){
this.data.insert(index, records[i]);
records[i].join(this);
}
if(this.snapshot){ //This was missing
this.snapshot.addAll(records);
}
this.fireEvent("add", this, records, index);
}
});
Ext.override(Ext.Container, {
remove : function(comp, autoDestroy){
var c = this.getComponent(comp);
if(c && this.fireEvent('beforeremove', this, c) !== false){
this.items.remove(c);
delete c.ownerCt;
if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){
c.destroy();
} else {
// By default, if you don't destroy the component it gets removed but the markup is left in place and unhidden cause render issues with other components.
c.hide();
}
if(this.layout && this.layout.activeItem == c){
delete this.layout.activeItem;
}
this.fireEvent('remove', this, c);
}
return c;
}
});