lib/har/viewer/scripts/domplate/domTree.js in har-0.0.9 vs lib/har/viewer/scripts/domplate/domTree.js in har-0.1.0
- old
+ new
@@ -1,5 +2 @@
-require.def("domplate/domTree",["domplate/domplate","core/lib"],function(g,e){with(g){g=function(a){this.input=a};g.prototype=domplate({tag:TABLE({"class":"domTable",cellpadding:0,cellspacing:0,onclick:"$onClick"},TBODY(FOR("member","$object|memberIterator",TAG("$member|getRowTag",{member:"$member"})))),rowTag:TR({"class":"memberRow $member.open $member.type\\Row $member|hasChildren",$hasChildren:"$member|hasChildren",_repObject:"$member",level:"$member.level"},TD({"class":"memberLabelCell",style:"padding-left: $member.indent\\px"},
-SPAN({"class":"memberLabel $member.type\\Label"},"$member.name")),TD({"class":"memberValueCell"},TAG("$member.tag",{object:"$member.value"}))),valueTag:SPAN({"class":"objectTitle"},"$object|getTitle"),loop:FOR("member","$members",TAG("$member|getRowTag",{member:"$member"})),hasChildren:function(a){return a.hasChildren?"hasChildren":""},memberIterator:function(a){return this.getMembers(a)},getRowTag:function(){return this.rowTag},getTitle:function(a){if(jQuery.isArray(a))return"Array";a=h(a);var b=
-/\[object (.*?)\]/.exec(a);return b?b[1]:a},onClick:function(a){a=$.event.fix(a||window.event);if(e.isLeftClick(a)){var b=e.getAncestorByClass(a.target,"memberRow");e.getAncestorByClass(a.target,"memberLabel")&&e.hasClass(b,"hasChildren")&&this.toggleRow(b)}},toggleRow:function(a){var b=parseInt(a.getAttribute("level"));if(e.hasClass(a,"opened")){e.removeClass(a,"opened");for(var c=a.parentNode,d=a.nextSibling;d;d=a.nextSibling){if(parseInt(d.getAttribute("level"))<=b)break;c.removeChild(d)}}else{e.setClass(a,
-"opened");if(c=a.repObject)(b=this.getMembers(c.value,b+1))&&this.loop.insertRows({members:b},a)}},getMembers:function(a,b){b||(b=0);var c=[];for(var d in a){var f=a[d];typeof f!="function"&&c.push(this.createMember("dom",d,f,b))}return c},createMember:function(a,b,c,d){var f=typeof c;f=this.hasProperties(c)&&f=="object";return{name:b,value:c,type:a,rowClass:"memberRow-"+a,open:"",level:d,indent:d*16,hasChildren:f,tag:this.valueTag}},hasProperties:function(a){for(var b in a)return true;return false},
-append:function(a){a=this.tag.append({object:this.input},a);a.firstChild.firstChild&&this.toggleRow(a.firstChild.firstChild)}});var h=function(a){try{return a.toString()}catch(b){return""}};return g}});
+require.def("domplate/domTree",["domplate/domplate","core/lib","core/trace"],function(Domplate,Lib,Trace){with(Domplate){function DomTree(a){this.input=a}DomTree.prototype=domplate({tag:TABLE({"class":"domTable",cellpadding:0,cellspacing:0,onclick:"$onClick"},TBODY(FOR("member","$object|memberIterator",TAG("$member|getRowTag",{member:"$member"})))),rowTag:TR({"class":"memberRow $member.open $member.type\\Row $member|hasChildren",$hasChildren:"$member|hasChildren",_repObject:"$member",level:"$member.level"},TD({"class":"memberLabelCell",style:"padding-left: $member.indent\\px"},SPAN({"class":"memberLabel $member.type\\Label"},"$member.name")),TD({"class":"memberValueCell"},TAG("$member.tag",{object:"$member|getValue"}))),loop:FOR("member","$members",TAG("$member|getRowTag",{member:"$member"})),hasChildren:function(a){return a.hasChildren?"hasChildren":""},memberIterator:function(a){return this.getMembers(a)},getValue:function(a){return a.value},getRowTag:function(a){return this.rowTag},onClick:function(a){var b=Lib.fixEvent(a);if(Lib.isLeftClick(b)){var c=Lib.getAncestorByClass(b.target,"memberRow"),d=Lib.getAncestorByClass(b.target,"memberLabel");d&&Lib.hasClass(c,"hasChildren")&&this.toggleRow(c)}},toggleRow:function(a,b){if(a){var c=parseInt(a.getAttribute("level"));if(b&&Lib.hasClass(a,"opened"))return;if(Lib.hasClass(a,"opened")){Lib.removeClass(a,"opened");var d=a.parentNode;for(var e=a.nextSibling;e;e=a.nextSibling){if(parseInt(e.getAttribute("level"))<=c)break;d.removeChild(e)}}else{Lib.setClass(a,"opened");var f=a.repObject;if(f){if(!f.hasChildren)return;var g=this.getMembers(f.value,c+1);g&&this.loop.insertRows({members:g},a)}}}},getMembers:function(a,b){b||(b=0);var c=[];for(var d in a){var e=a[d];typeof e!="function"&&c.push(this.createMember("dom",d,e,b))}return c},createMember:function(a,b,c,d){var e=typeof c,f=this.hasProperties(c)&&e=="object",g=DomTree.Reps.getRep(c);return{name:b,value:c,type:a,rowClass:"memberRow-"+a,open:"",level:d,indent:d*16,hasChildren:f,tag:g.tag}},hasProperties:function(a){if(typeof a=="string")return!1;try{for(var b in a)return!0}catch(c){}return!1},append:function(a){this.element=this.tag.append({object:this.input},a),this.element.repObject=this;var b=Lib.isArray(this.input)&&this.input.length>2,c=this.element.firstChild.firstChild;c&&!b&&this.toggleRow(c)},expandRow:function(a){var b=this.getRow(a);this.toggleRow(b,!0);return b},getRow:function(a){if(this.element){var b=Lib.getElementsByClass(this.element,"memberRow");for(var c=0;c<b.length;c++){var d=b[c];if(d.repObject.value==a)return d}return null}}});function safeToString(a){try{return a.toString()}catch(b){return""}}var OBJECTBOX=DIV({"class":"objectBox objectBox-$className"});DomTree.Reps={reps:[],registerRep:function(){this.reps.push.apply(this.reps,arguments)},getRep:function(a){var b=typeof a;b=="object"&&a instanceof String&&(b="string");for(var c=0;c<this.reps.length;++c){var d=this.reps[c];try{if(d.supportsObject(a,b))return d}catch(e){Trace.exception("domTree.getRep; ",e)}}return DomTree.Rep}},DomTree.Rep=domplate({tag:OBJECTBOX("$object|getTitle"),className:"object",getTitle:function(a){var b=safeToString(a),c=/\[object (.*?)\]/,d=c.exec(b);return d?d[1]:b},getTooltip:function(a){return null},supportsObject:function(a,b){return!1}}),DomTree.Reps.Null=domplate(DomTree.Rep,{tag:OBJECTBOX("null"),className:"null",supportsObject:function(a,b){return a==null}}),DomTree.Reps.Number=domplate(DomTree.Rep,{tag:OBJECTBOX("$object"),className:"number",supportsObject:function(a,b){return b=="boolean"||b=="number"}}),DomTree.Reps.String=domplate(DomTree.Rep,{tag:OBJECTBOX("$object"),className:"string",supportsObject:function(a,b){return b=="string"}}),DomTree.Reps.Arr=domplate(DomTree.Rep,{tag:OBJECTBOX("$object|getTitle"),className:"array",supportsObject:function(a,b){return Lib.isArray(a)},getTitle:function(a){return"Array ["+a.length+"]"}}),DomTree.Reps.Tree=domplate(DomTree.Rep,{tag:OBJECTBOX(TAG("$object|getTag",{object:"$object|getRoot"})),className:"tree",getTag:function(a){return Tree.tag},getRoot:function(a){return[a]},supportsObject:function(a,b){return b=="object"}});var Tree=domplate(DomTree.prototype,{createMember:function(a,b,c,d){var e=DomTree.prototype.createMember(a,b,c,d);d==0&&(e.name="",e.type="tableCell");return e}});DomTree.Reps.registerRep(DomTree.Reps.Null,DomTree.Reps.Number,DomTree.Reps.String,DomTree.Reps.Arr);return DomTree}})
\ No newline at end of file