1 | /*! |
---|
2 | * Ext JS Library 3.4.0 |
---|
3 | * Copyright(c) 2006-2011 Sencha Inc. |
---|
4 | * licensing@sencha.com |
---|
5 | * http://www.sencha.com/license |
---|
6 | */ |
---|
7 | Ext.ns('Ext.debug'); |
---|
8 | Ext.debug.Assistant = function(){ |
---|
9 | var enabled = true; |
---|
10 | |
---|
11 | return { |
---|
12 | enable: function(){ |
---|
13 | enabled = true; |
---|
14 | }, |
---|
15 | |
---|
16 | disable: function(){ |
---|
17 | enabled = false; |
---|
18 | }, |
---|
19 | |
---|
20 | init : function(classes){ |
---|
21 | var klass, |
---|
22 | intercept = false, |
---|
23 | fn, |
---|
24 | method; |
---|
25 | Ext.each(classes, function(cls){ |
---|
26 | if(this.namespaceExists(cls.name)){ |
---|
27 | klass = this.getClass(cls.name); |
---|
28 | method = cls.instance ? this.addInstanceCheck : this.addPrototypeCheck; |
---|
29 | Ext.each(cls.checks, function(check){ |
---|
30 | intercept = check.intercept == true; |
---|
31 | fn = method.call(this, klass, check.name, check.fn, check.intercept == true); |
---|
32 | if(check.after){ |
---|
33 | check.after(fn); |
---|
34 | } |
---|
35 | }, this); |
---|
36 | } |
---|
37 | }, this); |
---|
38 | }, |
---|
39 | |
---|
40 | namespaceExists: function(name){ |
---|
41 | var parent = window, |
---|
42 | exists = true; |
---|
43 | |
---|
44 | Ext.each(name.split('.'), function(n){ |
---|
45 | if(!Ext.isDefined(parent[n])){ |
---|
46 | exists = false; |
---|
47 | return false; |
---|
48 | } |
---|
49 | parent = parent[n]; |
---|
50 | }); |
---|
51 | return exists; |
---|
52 | }, |
---|
53 | |
---|
54 | getClass : function(name){ |
---|
55 | var parent = window; |
---|
56 | Ext.each(name.split('.'), function(n){ |
---|
57 | parent = parent[n]; |
---|
58 | }); |
---|
59 | return parent; |
---|
60 | }, |
---|
61 | |
---|
62 | warn: function(){ |
---|
63 | if(enabled && window.console){ |
---|
64 | console.warn.apply(console, arguments); |
---|
65 | } |
---|
66 | }, |
---|
67 | |
---|
68 | error: function(){ |
---|
69 | if(enabled && window.console){ |
---|
70 | console.error.apply(console, arguments); |
---|
71 | } |
---|
72 | }, |
---|
73 | |
---|
74 | addPrototypeCheck : function(cls, method, fn, intercept){ |
---|
75 | return (cls.prototype[method] = cls.prototype[method][intercept ? 'createInterceptor' : 'createSequence'](fn)); |
---|
76 | }, |
---|
77 | |
---|
78 | addInstanceCheck : function(cls, method, fn, intercept){ |
---|
79 | return (cls[method] = cls[method][intercept ? 'createInterceptor' : 'createSequence'](fn)); |
---|
80 | } |
---|
81 | }; |
---|
82 | }(); |
---|
83 | |
---|
84 | (function(){ |
---|
85 | var A = Ext.debug.Assistant, |
---|
86 | cls = []; |
---|
87 | |
---|
88 | cls.push({ |
---|
89 | name: 'Ext.util.Observable', |
---|
90 | checks: [{ |
---|
91 | name: 'addListener', |
---|
92 | intercept: true, |
---|
93 | fn: function(eventName, fn){ |
---|
94 | if(typeof eventName == 'object'){ |
---|
95 | var ev, o; |
---|
96 | for(ev in eventName){ |
---|
97 | if(!this.filterOptRe.test(ev)){ |
---|
98 | o = eventName[ev]; |
---|
99 | o = o && o.fn ? o.fn : o; |
---|
100 | if(!Ext.isFunction(o)){ |
---|
101 | A.error('Non function passed to event listener', this, ev); |
---|
102 | return false; |
---|
103 | } |
---|
104 | } |
---|
105 | } |
---|
106 | }else{ |
---|
107 | if(!Ext.isFunction(fn)){ |
---|
108 | A.error('Non function passed to event listener', this, eventName); |
---|
109 | } |
---|
110 | } |
---|
111 | }, |
---|
112 | after: function(method){ |
---|
113 | Ext.util.Observable.prototype.on = method; |
---|
114 | } |
---|
115 | }] |
---|
116 | }); |
---|
117 | |
---|
118 | cls.push({ |
---|
119 | name: 'Ext.Component', |
---|
120 | checks: [{ |
---|
121 | name: 'render', |
---|
122 | intercept: true, |
---|
123 | fn: function(container, position){ |
---|
124 | if(!container && !this.el){ |
---|
125 | A.error('Unable to render to container', this, container); |
---|
126 | } |
---|
127 | |
---|
128 | if(this.contentEl){ |
---|
129 | var el = Ext.getDom(this.contentEl); |
---|
130 | if(!el){ |
---|
131 | A.error('Specified contentEl does not exist', this, this.contentEl); |
---|
132 | return false; |
---|
133 | } |
---|
134 | } |
---|
135 | } |
---|
136 | }] |
---|
137 | }); |
---|
138 | |
---|
139 | cls.push({ |
---|
140 | name: 'Ext.Container', |
---|
141 | checks: [{ |
---|
142 | name: 'onBeforeAdd', |
---|
143 | intercept: true, |
---|
144 | fn: function(c){ |
---|
145 | if(c.isDestroyed){ |
---|
146 | A.warn('Adding destroyed component to container', c, this); |
---|
147 | } |
---|
148 | if(c.renderTo){ |
---|
149 | A.warn('Using renderTo while adding an item to a Container. You should use the add() method or put the item in the items configuration', c, this); |
---|
150 | } |
---|
151 | if(c.applyTo){ |
---|
152 | A.warn('Using applyTo while adding an item to a Container. You should use the add() method or put the item in the items configuration', c, this); |
---|
153 | } |
---|
154 | |
---|
155 | var type = this.layout.type; |
---|
156 | if(type == 'container' || type == 'auto'){ |
---|
157 | A.warn('A non sizing layout is being used in a container that has child components. This means the child components will not be sized.', this); |
---|
158 | } |
---|
159 | } |
---|
160 | },{ |
---|
161 | name: 'lookupComponent', |
---|
162 | intercept: true, |
---|
163 | fn: function(c){ |
---|
164 | var valid = true; |
---|
165 | if(Ext.isEmpty(c)){ |
---|
166 | valid = false; |
---|
167 | } |
---|
168 | if(Ext.isString(c)){ |
---|
169 | c = Ext.ComponentMgr.get(comp); |
---|
170 | valid = !Ext.isEmpty(c); |
---|
171 | } |
---|
172 | if(!valid){ |
---|
173 | A.error('Adding invalid component to container', this, c); |
---|
174 | return false; |
---|
175 | } |
---|
176 | } |
---|
177 | }] |
---|
178 | }); |
---|
179 | |
---|
180 | cls.push({ |
---|
181 | name: 'Ext.DataView', |
---|
182 | checks: [{ |
---|
183 | name: 'initComponent', |
---|
184 | fn: function(){ |
---|
185 | if(!this.itemSelector){ |
---|
186 | A.error('No itemSelector specified', this); |
---|
187 | } |
---|
188 | } |
---|
189 | },{ |
---|
190 | name: 'afterRender', |
---|
191 | fn: function(){ |
---|
192 | if(!this.store){ |
---|
193 | A.error('No store attached to DataView', this); |
---|
194 | } |
---|
195 | } |
---|
196 | }] |
---|
197 | }); |
---|
198 | |
---|
199 | cls.push({ |
---|
200 | name: 'Ext.Window', |
---|
201 | checks: [{ |
---|
202 | name: 'show', |
---|
203 | intercept: true, |
---|
204 | fn: function(){ |
---|
205 | if(this.isDestroyed){ |
---|
206 | A.error('Trying to show a destroyed window. If you want to reuse the window, look at the closeAction configuration.', this); |
---|
207 | return false; |
---|
208 | } |
---|
209 | } |
---|
210 | }] |
---|
211 | }); |
---|
212 | |
---|
213 | cls.push({ |
---|
214 | name: 'Ext.grid.GridPanel', |
---|
215 | checks: [{ |
---|
216 | name: 'initComponent', |
---|
217 | fn: function(){ |
---|
218 | if(!this.colModel){ |
---|
219 | A.error('No column model specified for grid', this); |
---|
220 | } |
---|
221 | if(!this.store){ |
---|
222 | A.error('No store specified for grid', this); |
---|
223 | } |
---|
224 | } |
---|
225 | }] |
---|
226 | }); |
---|
227 | |
---|
228 | cls.push({ |
---|
229 | name: 'Ext.grid.GridView', |
---|
230 | checks: [{ |
---|
231 | name: 'autoExpand', |
---|
232 | intercept: true, |
---|
233 | fn: function(){ |
---|
234 | var g = this.grid, |
---|
235 | cm = this.cm; |
---|
236 | if(!this.userResized && g.autoExpandColumn){ |
---|
237 | var tw = cm.getTotalWidth(false), |
---|
238 | aw = this.grid.getGridEl().getWidth(true) - this.getScrollOffset(); |
---|
239 | if(tw != aw){ |
---|
240 | var ci = cm.getIndexById(g.autoExpandColumn); |
---|
241 | if(ci == -1){ |
---|
242 | A.error('The autoExpandColumn does not exist in the column model', g, g.autoExpandColumn); |
---|
243 | return false; |
---|
244 | } |
---|
245 | } |
---|
246 | } |
---|
247 | } |
---|
248 | }] |
---|
249 | }); |
---|
250 | |
---|
251 | cls.push({ |
---|
252 | name: 'Ext.chart.Chart', |
---|
253 | checks: [{ |
---|
254 | name: 'initComponent', |
---|
255 | fn: function(){ |
---|
256 | if(!this.store){ |
---|
257 | A.error('No store specified for chart', this); |
---|
258 | } |
---|
259 | } |
---|
260 | }] |
---|
261 | }); |
---|
262 | |
---|
263 | cls.push({ |
---|
264 | name: 'Ext.tree.TreePanel', |
---|
265 | checks: [{ |
---|
266 | name: 'afterRender', |
---|
267 | intercept: true, |
---|
268 | fn: function(){ |
---|
269 | if(!this.root){ |
---|
270 | A.error('No root node specified for tree', this); |
---|
271 | return false; |
---|
272 | } |
---|
273 | } |
---|
274 | }] |
---|
275 | }); |
---|
276 | |
---|
277 | cls.push({ |
---|
278 | name: 'Ext', |
---|
279 | instance: true, |
---|
280 | checks: [{ |
---|
281 | name: 'extend', |
---|
282 | intercept: true, |
---|
283 | fn: function(){ |
---|
284 | if(arguments.length == 2 && !arguments[0]){ |
---|
285 | A.error('Invalid base class passed to extend', arguments[0]); |
---|
286 | return false; |
---|
287 | } |
---|
288 | if(arguments.length == 3){ |
---|
289 | if(!arguments[0]){ |
---|
290 | A.error('Invalid class to extend', arguments[0]); |
---|
291 | return false; |
---|
292 | }else if(!arguments[1]){ |
---|
293 | A.error('Invalid base class passed to extend', arguments[1]); |
---|
294 | return false; |
---|
295 | } |
---|
296 | } |
---|
297 | } |
---|
298 | },{ |
---|
299 | name: 'override', |
---|
300 | intercept: true, |
---|
301 | fn: function(c){ |
---|
302 | if(!c){ |
---|
303 | A.error('Invalid class passed to override', c); |
---|
304 | return false; |
---|
305 | } |
---|
306 | } |
---|
307 | }] |
---|
308 | }); |
---|
309 | |
---|
310 | cls.push({ |
---|
311 | name: 'Ext.ComponentMgr', |
---|
312 | instance: true, |
---|
313 | checks: [{ |
---|
314 | name: 'register', |
---|
315 | intercept: true, |
---|
316 | fn: function(c){ |
---|
317 | if(this.all.indexOfKey(c.id) > -1){ |
---|
318 | A.warn('A component with this id already exists', c, c.id); |
---|
319 | } |
---|
320 | } |
---|
321 | },{ |
---|
322 | name: 'create', |
---|
323 | intercept: true, |
---|
324 | fn: function(config, defaultType){ |
---|
325 | var types = Ext.ComponentMgr.types; |
---|
326 | if(!config.render){ |
---|
327 | if(config.xtype){ |
---|
328 | if(!types[config.xtype]){ |
---|
329 | A.error('Unknown xtype specified', config, config.xtype); |
---|
330 | return false; |
---|
331 | } |
---|
332 | }else{ |
---|
333 | if(!types[defaultType]){ |
---|
334 | A.error('Unknown defaultType specified', config, defaultType); |
---|
335 | return false; |
---|
336 | } |
---|
337 | } |
---|
338 | } |
---|
339 | } |
---|
340 | }] |
---|
341 | }); |
---|
342 | |
---|
343 | cls.push({ |
---|
344 | name: 'Ext.layout.FitLayout', |
---|
345 | checks: [{ |
---|
346 | name: 'onLayout', |
---|
347 | intercept: true, |
---|
348 | fn: function(){ |
---|
349 | var ct = this.container; |
---|
350 | if(ct.items.getCount() > 1){ |
---|
351 | A.warn('More than 1 item in the container. A fit layout will only display a single item.', ct); |
---|
352 | } |
---|
353 | } |
---|
354 | }] |
---|
355 | }); |
---|
356 | |
---|
357 | if(Ext.BLANK_IMAGE_URL == 'http:/' + '/www.extjs.com/s.gif'){ |
---|
358 | A.warn('You should set the Ext.BLANK_IMAGE_URL to reference a local copy.'); |
---|
359 | } |
---|
360 | |
---|
361 | A.init(cls); |
---|
362 | |
---|
363 | |
---|
364 | })(); |
---|