lib/har/viewer/scripts/preview/pageList.js in har-0.0.9 vs lib/har/viewer/scripts/preview/pageList.js in har-0.1.0

- old
+ new

@@ -1,4 +2 @@ -require.def("preview/pageList",["domplate/domplate","core/lib","core/trace","preview/requestList"],function(d,c,h,f){with(d){d=function(a){this.input=a};d.prototype=domplate({tableTag:TABLE({"class":"pageTable",cellpadding:0,cellspacing:0,onclick:"$onClick",_repObject:"$input"},TBODY(TAG("$rowTag",{groups:"$input.log.pages"}))),rowTag:FOR("group","$groups",TR({"class":"pageRow",_repObject:"$group"},TD({"class":"groupName pageCol"},SPAN({"class":"pageName"},"$group|getPageTitle")))),bodyTag:TR({"class":"pageInfoRow", -style:"height:auto;"},TD({"class":"pageInfoCol"})),getPageTitle:function(a){return c.cropString(a.title,100)},getPageID:function(a){return"["+a.id+"]"},onClick:function(a){var b=$.event.fix(a||window.event);if(c.isLeftClick(a))if(b=c.getAncestorByClass(b.target,"pageRow")){this.toggleRow(b);c.cancelEvent(a)}},toggleRow:function(a,b){if(!(c.hasClass(a,"opened")&&b)){c.toggleClass(a,"opened");if(c.hasClass(a,"opened")){b=this.bodyTag.insertRows({},a)[0];(new f(this.input)).render(b.firstChild,a.repObject)}else{b= -a.nextSibling;a.parentNode.removeChild(b)}}},expandAll:function(a){for(a=a.firstChild.firstChild;a;){hasClass(a,"pageRow")&&this.toggleRow(a,true);a=a.nextSibling}},getPageRow:function(a){for(var b=c.getElementsByClass(this.element.parentNode,"pageRow"),e=0;e<b.length;e++){var g=b[e];if(g.repObject==a)return g}},togglePage:function(a){this.toggleRow(this.getPageRow(a))},expandPage:function(a){this.toggleRow(this.getPageRow(a),true)},collapsePage:function(a){a=this.getPageRow(a);c.hasClass(a,"opened")&& -this.toggleRow(a)},append:function(a){(new f(this.input)).render(a,null);var b=this.input.log.pages;if(b&&b.length){a=this.tableTag.append({input:this.input},a,this);a.firstChild.childNodes.length==1&&a.parentNode.childNodes.length==1&&this.toggleRow(a.firstChild.firstChild)}},render:function(a){this.append(a)}});return d}}); +require.def("preview/pageList",["domplate/domplate","core/lib","core/trace","core/cookies","preview/requestList","i18n!nls/pageList","domplate/popupMenu"],function(Domplate,Lib,Trace,Cookies,RequestList,Strings,Menu){with(Domplate){function PageList(a){this.input=a,this.listeners=[]}PageList.prototype=domplate({tableTag:TABLE({"class":"pageTable",cellpadding:0,cellspacing:0,onclick:"$onClick",_repObject:"$input"},TBODY(TAG("$rowTag",{groups:"$input.log.pages"}))),rowTag:FOR("group","$groups",TR({"class":"pageRow",_repObject:"$group"},TD({"class":"groupName pageCol",width:"1%"},SPAN({"class":"pageName"},"$group|getPageTitle")),TD({"class":"netOptionsCol netCol",width:"15px"},DIV({"class":"netOptionsLabel netLabel",onclick:"$onOpenOptions"})))),bodyTag:TR({"class":"pageInfoRow",style:"height:auto;"},TD({"class":"pageInfoCol",colspan:2})),getPageTitle:function(a){return Lib.cropString(a.title,100)},getPageID:function(a){return"["+a.id+"]"},onClick:function(a){var b=Lib.fixEvent(a);if(Lib.isLeftClick(a)){var c=Lib.getAncestorByClass(b.target,"pageRow");c&&(this.toggleRow(c),Lib.cancelEvent(a))}},toggleRow:function(a,b){var c=Lib.hasClass(a,"opened");if(!c||!b){Lib.toggleClass(a,"opened");if(Lib.hasClass(a,"opened")){var d=this.bodyTag.insertRows({},a)[0],e=this.createRequestList(),f=PageList.prototype.pageTimings;for(var g=0;g<f.length;g++)e.addPageTiming(f[g]);e.render(d.firstChild,a.repObject)}else{var d=a.nextSibling;a.parentNode.removeChild(d)}}},expandAll:function(a){var b=a.firstChild.firstChild;while(b)Lib.hasClass(b,"pageRow")&&this.toggleRow(b,!0),b=b.nextSibling},getPageRow:function(a){var b=this.element.parentNode,c=Lib.getElementsByClass(b,"pageRow");for(var d=0;d<c.length;d++){var e=c[d];if(e.repObject==a)return e}},togglePage:function(a){var b=this.getPageRow(a);this.toggleRow(b)},expandPage:function(a){var b=this.getPageRow(a);this.toggleRow(b,!0)},collapsePage:function(a){var b=this.getPageRow(a);Lib.hasClass(b,"opened")&&this.toggleRow(b)},onOpenOptions:function(a){var b=Lib.fixEvent(a);Lib.cancelEvent(a);if(Lib.isLeftClick(a)){var c=b.target,d=Lib.getAncestorByClass(c,"pageRow"),e=this.getMenuItems(d.repObject),f=new Menu({id:"requestContextMenu",items:e});f.showPopup(c)}},getMenuItems:function(a){var b=RequestList.getVisibleColumns().join(),c,d=0,e=[];for(var f=0;f<RequestList.columns.length;f++){var g=RequestList.columns[f],h=b.indexOf(g)>-1;e.push({label:Strings["column.label."+g],type:"checkbox",checked:h,command:Lib.bindFixed(this.onToggleColumn,this,g)}),h&&(c=f,d++)}d==1&&(e[c].disabled=!0),e.push("-"),e.push({label:Strings["action.label.Reset"],command:Lib.bindFixed(this.updateColumns,this)});return e},onToggleColumn:function(a){var b=RequestList.getVisibleColumns();Lib.remove(b,a)||b.push(a),this.updateColumns(b)},updateColumns:function(a){a||(a=RequestList.defaultColumns),RequestList.setVisibleColumns(a)},createRequestList:function(){var a=new RequestList(this.input);a.listeners=this.listeners;return a},append:function(a){var b=this.createRequestList();b.render(a,null);var c=this.input.log.pages;if(c&&c.length){var d=this.tableTag.append({input:this.input},a,this),e=Lib.getElementsByClass(d,"pageRow"),f=Lib.getElementsByClass(a,"pageTable");e.length==1&&f.length==1&&this.toggleRow(e[0]);var g=Lib.getURLParameter("expand");g&&this.expandAll(d)}},render:function(a){this.append(a)},addListener:function(a){this.listeners.push(a)},removeListener:function(a){Lib.remove(this.listeners,a)}}),PageList.prototype.pageTimings=[];return PageList}}) \ No newline at end of file