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.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
21 function createConsole(){
23 var scriptPanel = new Ext.debug.ScriptsPanel();
24 var logView = new Ext.debug.LogPanel();
25 var tree = new Ext.debug.DomTree();
26 var compInspector = new Ext.debug.ComponentInspector();
27 var compInfoPanel = new Ext.debug.ComponentInfoPanel();
28 var storeInspector = new Ext.debug.StoreInspector();
29 var objInspector = new Ext.debug.ObjectInspector();
31 var tabs = new Ext.TabPanel({
34 tabPosition: 'bottom',
36 title: 'Debug Console',
38 items: [logView, scriptPanel]
40 title: 'HTML Inspector',
44 title: 'Component Inspector',
46 items: [compInspector,compInfoPanel]
48 title: 'Object Inspector',
54 items: [storeInspector]
59 id: 'x-debug-browser',
63 style: 'position:absolute;left:0;bottom:0;z-index:101',
73 Ext.EventManager.removeResizeListener(handleResize);
80 cp.render(Ext.getBody());
82 cp.resizer = new Ext.Resizable(cp.el, {
87 resizeElement : function(){
88 var box = this.proxy.getBox();
90 cp.setHeight(box.height);
95 // function handleResize(){
96 // cp.setWidth(Ext.getBody().getViewSize().width);
98 // Ext.EventManager.onWindowResize(handleResize);
102 function handleResize(){
103 var b = Ext.getBody();
104 var size = b.getViewSize();
105 if(size.height < b.dom.scrollHeight) {
108 cp.setWidth(size.width);
110 Ext.EventManager.onWindowResize(handleResize);
120 cp.logView.log.apply(cp.logView, arguments);
123 logf : function(format, arg1, arg2, etc){
124 Ext.log(String.format.apply(String, arguments));
128 if(typeof o == 'string' || typeof o == 'number' || typeof o == 'undefined' || Ext.isDate(o)){
132 }else if(typeof o != "object"){
133 Ext.log('Unknown return type');
134 }else if(Ext.isArray(o)){
135 Ext.log('['+o.join(',')+']');
139 var to = typeof o[key];
140 if(to != "function" && to != "object"){
141 b.push(String.format(" {0}: {1},\n", key, o[key]));
146 s = s.substr(0, s.length-2);
154 time : function(name){
155 name = name || "def";
156 Ext._timers[name] = new Date().getTime();
159 timeEnd : function(name, printResults){
160 var t = new Date().getTime();
161 name = name || "def";
162 var v = String.format("{0} ms", t-Ext._timers[name]);
163 Ext._timers[name] = new Date().getTime();
164 if(printResults !== false){
165 Ext.log('Timer ' + (name == "def" ? v : name + ": " + v));
174 Ext.debug.ScriptsPanel = Ext.extend(Ext.Panel, {
175 id:'x-debug-scripts',
182 style:'border-width:0 0 0 1px;',
184 initComponent : function(){
186 this.scriptField = new Ext.form.TextArea({
188 style:'border-width:0;'
191 this.trapBox = new Ext.form.Checkbox({
193 boxLabel: 'Trap Errors',
197 this.toolbar = new Ext.Toolbar([{
200 handler: this.evalScript
211 this.items = [this.toolbar, this.scriptField];
213 Ext.debug.ScriptsPanel.superclass.initComponent.call(this);
216 evalScript : function(){
217 var s = this.scriptField.getValue();
218 if(this.trapBox.getValue()){
221 Ext.dump(rt === undefined? '(no return)' : rt);
223 Ext.log(e.message || e.descript);
227 Ext.dump(rt === undefined? '(no return)' : rt);
232 this.scriptField.setValue('');
233 this.scriptField.focus();
238 Ext.debug.LogPanel = Ext.extend(Ext.Panel, {
242 style:'border-width:0 1px 0 0',
245 var markup = [ '<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
246 Ext.util.Format.htmlEncode(Array.prototype.join.call(arguments, ', ')).replace(/\n/g, '<br/>').replace(/\s/g, ' '),
250 this.body.insertHtml('beforeend', markup);
251 bd.scrollTop = bd.scrollHeight;
255 this.body.update('');
256 this.body.dom.scrollTop = 0;
260 Ext.debug.DomTree = Ext.extend(Ext.tree.TreePanel, {
270 initComponent : function(){
273 Ext.debug.DomTree.superclass.initComponent.call(this);
275 // tree related stuff
276 var styles = false, hnode;
277 var nonSpace = /^\s*$/;
278 var html = Ext.util.Format.htmlEncode;
279 var ellipsis = Ext.util.Format.ellipsis;
280 var styleRe = /\s?([a-z\-]*)\:([^;]*)(?:[;\s\n\r]*)/gi;
282 function findNode(n){
283 if(!n || n.nodeType != 1 || n == document.body || n == document){
287 while((p = p.parentNode) && p.nodeType == 1 && p.tagName.toUpperCase() != 'HTML'){
291 for(var i = 0, len = pn.length; i < len; i++){
293 cn = cn.findChild('htmlNode', pn[i]);
294 if(!cn){ // in this dialog?
299 var a = cn.ui.anchor;
300 this.getTreeEl().dom.scrollTop = Math.max(0 ,a.offsetTop-10);
301 //treeEl.dom.scrollLeft = Math.max(0 ,a.offsetLeft-10); no likey
306 function nodeTitle(n){
310 }else if(n.className){
311 s += '.'+n.className;
317 function onNodeSelect(t, n, last){
319 if(last && last.unframe){
331 reload.setDisabled(n.leaf);
332 var dom = n.htmlNode;
333 stylePanel.setTitle(nodeTitle(dom));
334 if(styles && !showAll.pressed){
335 var s = dom.style ? dom.style.cssText : '';
338 while ((m = styleRe.exec(s)) != null){
339 props[m[1].toLowerCase()] = m[2];
343 var cl = Ext.debug.cssList;
344 var s = dom.style, fly = Ext.fly(dom);
346 for(var i = 0, len = cl.length; i<len; i++){
348 var v = s[st] || fly.getStyle(st);
349 if(v != undefined && v !== null && v !== ''){
357 if((isNaN(a+10)) && v != undefined && v !== null && v !== '' && !(Ext.isGecko && a[0] == a[0].toUpperCase())){
369 stylesGrid.setSource(props);
370 stylesGrid.treeNode = n;
371 stylesGrid.view.fitColumns();
375 this.loader = new Ext.tree.TreeLoader();
376 this.loader.load = function(n, cb){
377 var isBody = n.htmlNode == document.body;
378 var cn = n.htmlNode.childNodes;
379 for(var i = 0, c; c = cn[i]; i++){
380 if(isBody && c.id == 'x-debug-browser'){
384 n.appendChild(new Ext.debug.HtmlNode(c));
385 }else if(c.nodeType == 3 && !nonSpace.test(c.nodeValue)){
386 n.appendChild(new Ext.tree.TreeNode({
387 text:'<em>' + ellipsis(html(String(c.nodeValue)), 35) + '</em>',
395 //tree.getSelectionModel().on('selectionchange', onNodeSelect, null, {buffer:250});
397 this.root = this.setRootNode(new Ext.tree.TreeNode('Ext'));
399 hnode = this.root.appendChild(new Ext.debug.HtmlNode(
400 document.getElementsByTagName('html')[0]
406 Ext.debug.ComponentNodeUI = Ext.extend(Ext.tree.TreeNodeUI,{
407 onOver : function(e){
408 Ext.debug.ComponentNodeUI.superclass.onOver.call(this);
409 var cmp = this.node.attributes.component;
410 if (cmp.el && cmp.el.mask && cmp.id !='x-debug-browser') {
411 try { // Oddly bombs on some elements in IE, gets any we care about though
418 Ext.debug.ComponentNodeUI.superclass.onOut.call(this);
419 var cmp = this.node.attributes.component;
420 if (cmp.el && cmp.el.unmask && cmp.id !='x-debug-browser') {
428 Ext.debug.ComponentInspector = Ext.extend(Ext.tree.TreePanel, {
438 initComponent : function(){
439 this.loader = new Ext.tree.TreeLoader();
440 this.bbar = new Ext.Toolbar([{
442 handler: this.refresh,
445 Ext.debug.ComponentInspector.superclass.initComponent.call(this);
447 this.root = this.setRootNode(new Ext.tree.TreeNode({
448 text: 'Ext Components',
449 component: Ext.ComponentMgr.all,
452 this.parseRootNode();
454 this.on('click', this.onClick, this);
457 createNode: function(n,c) {
458 var leaf = (c.items && c.items.length > 0);
459 return n.appendChild(new Ext.tree.TreeNode({
460 text: c.id + (c.getXType() ? ' [ ' + c.getXType() + ' ]': '' ),
462 uiProvider:Ext.debug.ComponentNodeUI,
467 parseChildItems: function(n) {
468 var cn = n.attributes.component.items;
470 for (var i = 0;i < cn.length; i++) {
472 if (c.id != this.id && c.id != this.bottomToolbar.id) {
473 var newNode = this.createNode(n,c);
475 this.parseChildItems(newNode)
482 parseRootNode: function() {
484 var cn = n.attributes.component.items;
485 for (var i = 0,c;c = cn[i];i++) {
486 if (c.id != this.id && c.id != this.bottomToolbar.id) {
488 var newNode = this.createNode(n,c);
490 this.parseChildItems(newNode);
497 onClick: function(node, e) {
498 var oi = Ext.getCmp('x-debug-objinspector');
499 oi.refreshNodes(node.attributes.component);
503 refresh: function() {
504 while (this.root.firstChild) {
505 this.root.removeChild(this.root.firstChild);
507 this.parseRootNode();
508 var ci = Ext.getCmp('x-debug-compinfo');
510 ci.message('refreshed component tree - '+Ext.ComponentMgr.all.length)
515 Ext.debug.ComponentInfoPanel = Ext.extend(Ext.Panel,{
516 id:'x-debug-compinfo',
524 style:'border-width:0 0 0 1px;',
526 initComponent: function() {
527 this.watchBox = new Ext.form.Checkbox({
528 id: 'x-debug-watchcomp',
529 boxLabel: 'Watch ComponentMgr',
531 check: function(cb, val) {
533 Ext.ComponentMgr.all.on('add', this.onAdd, this);
534 Ext.ComponentMgr.all.on('remove', this.onRemove, this);
536 Ext.ComponentMgr.all.un('add', this.onAdd, this);
537 Ext.ComponentMgr.all.un('remove', this.onRemove, this);
544 this.tbar = new Ext.Toolbar([{
550 Ext.debug.ComponentInfoPanel.superclass.initComponent.call(this);
553 onAdd: function(i, o, key) {
554 var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
557 this.insertMarkup(markup);
560 onRemove: function(o, key) {
561 var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
564 this.insertMarkup(markup);
567 message: function(msg) {
568 var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
571 this.insertMarkup(markup);
573 insertMarkup: function(markup) {
574 this.body.insertHtml('beforeend', markup);
575 this.body.scrollTo('top', 100000);
578 this.body.update('');
579 this.body.dom.scrollTop = 0;
583 Ext.debug.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
584 focus: Ext.emptyFn, // prevent odd scrolling behavior
586 renderElements : function(n, a, targetNode, bulkRender){
587 this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
589 var t = n.getOwnerTree();
590 var cols = t.columns;
591 var bw = t.borderWidth;
595 '<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ', a.cls,'">',
596 '<div class="x-tree-col" style="width:',c.width-bw,'px;">',
597 '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
598 '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow"/>',
599 '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on"/>',
600 '<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',
601 a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
602 '<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
604 for(var i = 1, len = cols.length; i < len; i++){
607 buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
608 '<div class="x-tree-col-text">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
612 '<div class="x-clear"></div></div>',
613 '<ul class="x-tree-node-ct" style="display:none;"></ul>',
616 if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
617 this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
618 n.nextSibling.ui.getEl(), buf.join(""));
620 this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
623 this.elNode = this.wrap.childNodes[0];
624 this.ctNode = this.wrap.childNodes[1];
625 var cs = this.elNode.firstChild.childNodes;
626 this.indentNode = cs[0];
628 this.iconNode = cs[2];
630 this.textNode = cs[3].firstChild;
634 Ext.debug.ObjectInspector = Ext.extend(Ext.tree.TreePanel, {
635 id: 'x-debug-objinspector',
645 borderWidth: Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
648 initComponent : function(){
649 this.showFunc = false;
650 this.toggleFunc = function() {
651 this.showFunc = !this.showFunc;
652 this.refreshNodes(this.currentObject);
654 this.bbar = new Ext.Toolbar([{
655 text: 'Show Functions',
658 handler: this.toggleFunc,
664 loader: new Ext.tree.TreeLoader(),
676 Ext.debug.ObjectInspector.superclass.initComponent.call(this);
678 this.root = this.setRootNode(new Ext.tree.TreeNode({
683 if (this.currentObject) {
688 refreshNodes: function(newObj) {
689 this.currentObject = newObj;
690 var node = this.root;
691 while(node.firstChild){
692 node.removeChild(node.firstChild);
697 parseNodes: function() {
698 for (var o in this.currentObject) {
699 if (!this.showFunc) {
700 if (Ext.isFunction(this.currentObject[o])) {
708 createNode: function(o) {
709 return this.root.appendChild(new Ext.tree.TreeNode({
711 value: this.currentObject[o],
712 uiProvider:Ext.debug.ColumnNodeUI,
713 iconCls: 'x-debug-node',
718 onRender : function(){
719 Ext.debug.ObjectInspector.superclass.onRender.apply(this, arguments);
720 this.headers = this.header.createChild({cls:'x-tree-headers'});
722 var cols = this.columns, c;
725 for(var i = 0, len = cols.length; i < len; i++){
727 totalWidth += c.width;
728 this.headers.createChild({
729 cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
731 cls:'x-tree-hd-text',
734 style:'width:'+(c.width-this.borderWidth)+'px;'
737 this.headers.createChild({cls:'x-clear'});
738 // prevent floats from wrapping when clipped
739 this.headers.setWidth(totalWidth);
740 this.innerCt.setWidth(totalWidth);
745 Ext.debug.StoreInspector = Ext.extend(Ext.tree.TreePanel, {
755 initComponent: function() {
756 this.bbar = new Ext.Toolbar([{
758 handler: this.refresh,
761 Ext.debug.StoreInspector.superclass.initComponent.call(this);
763 this.root = this.setRootNode(new Ext.tree.TreeNode({
767 this.on('click', this.onClick, this);
772 parseStores: function() {
773 var cn = Ext.StoreMgr.items;
774 for (var i = 0,c;c = cn[i];i++) {
775 this.root.appendChild({
776 text: c.storeId + ' - ' + c.totalLength + ' records',
783 onClick: function(node, e) {
784 var oi = Ext.getCmp('x-debug-objinspector');
785 oi.refreshNodes(node.attributes.component);
789 refresh: function() {
790 while (this.root.firstChild) {
791 this.root.removeChild(this.root.firstChild);
797 // highly unusual class declaration
798 Ext.debug.HtmlNode = function(){
799 var html = Ext.util.Format.htmlEncode;
800 var ellipsis = Ext.util.Format.ellipsis;
801 var nonSpace = /^\s*$/;
805 {n: 'className', v: 'class'},
806 {n: 'name', v: 'name'},
807 {n: 'type', v: 'type'},
808 {n: 'src', v: 'src'},
809 {n: 'href', v: 'href'}
812 function hasChild(n){
813 for(var i = 0, c; c = n.childNodes[i]; i++){
821 function renderNode(n, leaf){
822 var tag = n.tagName.toLowerCase();
823 var s = '<' + tag;
824 for(var i = 0, len = attrs.length; i < len; i++){
827 if(v && !nonSpace.test(v)){
828 s += ' ' + a.v + '="<i>' + html(v) +'</i>"';
831 var style = n.style ? n.style.cssText : '';
833 s += ' style="<i>' + html(style.toLowerCase()) +'</i>"';
835 if(leaf && n.childNodes.length > 0){
836 s+='><em>' + ellipsis(html(String(n.innerHTML)), 35) + '</em></'+tag+'>';
845 var HtmlNode = function(n){
846 var leaf = !hasChild(n);
848 this.tagName = n.tagName.toLowerCase();
850 text : renderNode(n, leaf),
854 HtmlNode.superclass.constructor.call(this, attr);
855 this.attributes.htmlNode = n; // for searching
857 this.on('expand', this.onExpand, this);
858 this.on('collapse', this.onCollapse, this);
863 Ext.extend(HtmlNode, Ext.tree.AsyncTreeNode, {
864 cls: 'x-tree-noicon',
865 preventHScroll: true,
866 refresh : function(highlight){
867 var leaf = !hasChild(this.htmlNode);
868 this.setText(renderNode(this.htmlNode, leaf));
870 Ext.fly(this.ui.textNode).highlight();
874 onExpand : function(){
875 if(!this.closeNode && this.parentNode){
876 this.closeNode = this.parentNode.insertBefore(new Ext.tree.TreeNode({
877 text:'</' + this.tagName + '>',
879 }), this.nextSibling);
880 }else if(this.closeNode){
881 this.closeNode.ui.show();
885 onCollapse : function(){
887 this.closeNode.ui.hide();
891 render : function(bulkRender){
892 HtmlNode.superclass.render.call(this, bulkRender);
895 highlightNode : function(){
896 //Ext.fly(this.htmlNode).highlight();
899 highlight : function(){
900 //Ext.fly(this.ui.textNode).highlight();
904 this.htmlNode.style.border = '1px solid #0000ff';
905 //this.highlightNode();
908 unframe : function(){
909 //Ext.fly(this.htmlNode).removeClass('x-debug-frame');
910 this.htmlNode.style.border = '';