Upgrade to ExtJS 3.3.0 - Released 10/06/2010
[extjs.git] / docs / source / error-checking.html
diff --git a/docs/source/error-checking.html b/docs/source/error-checking.html
new file mode 100644 (file)
index 0000000..a7fbfeb
--- /dev/null
@@ -0,0 +1,374 @@
+<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.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+Ext.ns('Ext.debug');\r
+Ext.debug.Assistant = function(){\r
+    var enabled = true;\r
+        \r
+    return {\r
+        enable: function(){\r
+            enabled = true;\r
+        },\r
+        \r
+        disable: function(){\r
+            enabled = false;\r
+        },\r
+        \r
+        init : function(classes){\r
+            var klass,\r
+                intercept = false,\r
+                fn,\r
+                method;\r
+            Ext.each(classes, function(cls){\r
+                if(this.namespaceExists(cls.name)){\r
+                    klass = this.getClass(cls.name);\r
+                    method = cls.instance ? this.addInstanceCheck : this.addPrototypeCheck;\r
+                    Ext.each(cls.checks, function(check){\r
+                        intercept = check.intercept == true;\r
+                        fn = method.call(this, klass, check.name, check.fn, check.intercept == true);\r
+                        if(check.after){\r
+                            check.after(fn);\r
+                        }\r
+                    }, this);\r
+                }\r
+            }, this);  \r
+        },\r
+        \r
+        namespaceExists: function(name){\r
+            var parent = window,\r
+                exists = true;\r
+                \r
+            Ext.each(name.split('.'), function(n){\r
+                if(!Ext.isDefined(parent[n])){\r
+                    exists = false;\r
+                    return false;\r
+                }\r
+                parent = parent[n];\r
+            });\r
+            return exists;\r
+        },\r
+        \r
+        getClass : function(name){\r
+            var parent = window;\r
+            Ext.each(name.split('.'), function(n){\r
+                parent = parent[n];\r
+            });  \r
+            return parent;\r
+        },\r
+        \r
+        warn: function(){\r
+            if(enabled && window.console){\r
+                console.warn.apply(console, arguments);\r
+            }\r
+        },\r
+        \r
+        error: function(){\r
+            if(enabled && window.console){\r
+                console.error.apply(console, arguments);\r
+            }\r
+        },\r
+        \r
+        addPrototypeCheck : function(cls, method, fn, intercept){\r
+            return (cls.prototype[method] = cls.prototype[method][intercept ? 'createInterceptor' : 'createSequence'](fn));\r
+        },\r
+        \r
+        addInstanceCheck : function(cls, method, fn, intercept){\r
+            return (cls[method] = cls[method][intercept ? 'createInterceptor' : 'createSequence'](fn));\r
+        }\r
+    };\r
+}();\r
+\r
+(function(){\r
+    var A = Ext.debug.Assistant,\r
+        cls = [];\r
+        \r
+    cls.push({\r
+        name: 'Ext.util.Observable',\r
+        checks: [{\r
+            name: 'addListener',\r
+            intercept: true,\r
+            fn: function(eventName, fn){\r
+                if(typeof eventName == 'object'){\r
+                    var ev, o;\r
+                    for(ev in eventName){\r
+                        if(!this.filterOptRe.test(ev)){\r
+                            o = eventName[ev];\r
+                            o = o && o.fn ? o.fn : o;\r
+                            if(!Ext.isFunction(o)){\r
+                                A.error('Non function passed to event listener', this, ev);\r
+                                return false;\r
+                            }\r
+                        }\r
+                    }\r
+                }else{\r
+                    if(!Ext.isFunction(fn)){\r
+                        A.error('Non function passed to event listener', this, eventName);\r
+                    }\r
+                }\r
+            },\r
+            after: function(method){\r
+                Ext.util.Observable.prototype.on = method;\r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.Component',\r
+        checks: [{\r
+            name: 'render',\r
+            intercept: true,\r
+            fn: function(container, position){\r
+                if(!container && !this.el){\r
+                    A.error('Unable to render to container', this, container);\r
+                }\r
+            \r
+                if(this.contentEl){\r
+                    var el = Ext.getDom(this.contentEl);\r
+                    if(!el){\r
+                        A.error('Specified contentEl does not exist', this, this.contentEl);\r
+                        return false;\r
+                    }\r
+                }\r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.Container',\r
+        checks: [{\r
+            name: 'onBeforeAdd',\r
+            intercept: true,\r
+            fn: function(c){\r
+                if(c.isDestroyed){\r
+                    A.warn('Adding destroyed component to container', c, this);\r
+                }\r
+                if(c.renderTo){\r
+                    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);\r
+                }\r
+                if(c.applyTo){\r
+                    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);\r
+                }\r
+                \r
+                var type = this.layout.type;\r
+                if(type == 'container' || type == 'auto'){\r
+                    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);\r
+                }\r
+            }\r
+        },{\r
+            name: 'lookupComponent',\r
+            intercept: true,\r
+            fn: function(c){\r
+                var valid = true;\r
+                if(Ext.isEmpty(c)){\r
+                    valid = false;\r
+                }\r
+                if(Ext.isString(c)){\r
+                    c = Ext.ComponentMgr.get(comp);\r
+                    valid = !Ext.isEmpty(c);\r
+                }\r
+                if(!valid){\r
+                    A.error('Adding invalid component to container', this, c);\r
+                    return false;\r
+                }\r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.DataView',\r
+        checks: [{\r
+            name: 'initComponent',\r
+            fn: function(){\r
+                if(!this.itemSelector){\r
+                    A.error('No itemSelector specified', this);\r
+                }\r
+            }\r
+        },{\r
+            name: 'afterRender',\r
+            fn: function(){\r
+                if(!this.store){\r
+                    A.error('No store attached to DataView', this);\r
+                } \r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.Window',\r
+        checks: [{\r
+            name: 'show',\r
+            intercept: true,\r
+            fn: function(){\r
+                if(this.isDestroyed){\r
+                    A.error('Trying to show a destroyed window. If you want to reuse the window, look at the closeAction configuration.', this);\r
+                    return false;\r
+                } \r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.grid.GridPanel',\r
+        checks: [{\r
+            name: 'initComponent',\r
+            fn: function(){\r
+                if(!this.colModel){\r
+                    A.error('No column model specified for grid', this);\r
+                }\r
+                if(!this.store){\r
+                    A.error('No store specified for grid', this);\r
+                }\r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.grid.GridView',\r
+        checks: [{\r
+            name: 'autoExpand',\r
+            intercept: true,\r
+            fn: function(){\r
+                var g = this.grid, \r
+                cm = this.cm;\r
+                if(!this.userResized && g.autoExpandColumn){\r
+                    var tw = cm.getTotalWidth(false), \r
+                        aw = this.grid.getGridEl().getWidth(true) - this.getScrollOffset();\r
+                    if(tw != aw){\r
+                        var ci = cm.getIndexById(g.autoExpandColumn);\r
+                        if(ci == -1){\r
+                            A.error('The autoExpandColumn does not exist in the column model', g, g.autoExpandColumn);\r
+                            return false;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.chart.Chart',\r
+        checks: [{\r
+            name: 'initComponent',\r
+            fn: function(){\r
+                if(!this.store){\r
+                    A.error('No store specified for chart', this);\r
+                }\r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.tree.TreePanel',\r
+        checks: [{\r
+            name: 'afterRender',\r
+            intercept: true,\r
+            fn: function(){\r
+                if(!this.root){\r
+                    A.error('No root node specified for tree', this);\r
+                    return false;\r
+                }\r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext',\r
+        instance: true,\r
+        checks: [{\r
+            name: 'extend',\r
+            intercept: true,\r
+            fn: function(){\r
+                if(arguments.length == 2 && !arguments[0]){\r
+                    A.error('Invalid base class passed to extend', arguments[0]);\r
+                    return false;\r
+                }    \r
+                if(arguments.length == 3){\r
+                    if(!arguments[0]){\r
+                        A.error('Invalid class to extend', arguments[0]);\r
+                        return false;    \r
+                    }else if(!arguments[1]){\r
+                        A.error('Invalid base class passed to extend', arguments[1]);\r
+                        return false;\r
+                    }\r
+                }\r
+            }\r
+        },{\r
+            name: 'override',\r
+            intercept: true,\r
+            fn: function(c){\r
+                if(!c){\r
+                    A.error('Invalid class passed to override', c);\r
+                    return false;\r
+                }\r
+            }\r
+        }]    \r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.ComponentMgr',\r
+        instance: true,\r
+        checks: [{\r
+            name: 'register',\r
+            intercept: true,\r
+            fn: function(c){\r
+                if(this.all.indexOfKey(c.id) > -1){\r
+                    A.warn('A component with this id already exists', c, c.id);\r
+                }\r
+            }\r
+        },{\r
+            name: 'create',\r
+            intercept: true,\r
+            fn: function(config, defaultType){\r
+                var types = Ext.ComponentMgr.types;\r
+                if(!config.render){\r
+                    if(config.xtype){\r
+                        if(!types[config.xtype]){\r
+                            A.error('Unknown xtype specified', config, config.xtype);\r
+                            return false;\r
+                        }\r
+                    }else{\r
+                        if(!types[defaultType]){\r
+                            A.error('Unknown defaultType specified', config, defaultType);\r
+                            return false;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }]\r
+    });\r
+    \r
+    cls.push({\r
+        name: 'Ext.layout.FitLayout',\r
+        checks: [{\r
+            name: 'onLayout',\r
+            intercept: true,\r
+            fn: function(){\r
+                var ct = this.container;\r
+                if(ct.items.getCount() > 1){\r
+                    A.warn('More than 1 item in the container. A fit layout will only display a single item.', ct);\r
+                }\r
+            }\r
+        }]\r
+    });\r
+    \r
+    if(Ext.BLANK_IMAGE_URL == 'http:/' + '/www.extjs.com/s.gif'){\r
+        A.warn('You should set the Ext.BLANK_IMAGE_URL to reference a local copy.');\r
+    }\r
+    \r
+    A.init(cls);\r
+    \r
+        \r
+})();</pre>    
+</body>
+</html>
\ No newline at end of file