lib/har/viewer/scripts/tabs/pageTimeline.js in har-0.0.9 vs lib/har/viewer/scripts/tabs/pageTimeline.js in har-0.1.0

- old
+ new

@@ -1,10 +2 @@ -require.def("tabs/pageTimeline",["domplate/domplate","core/lib","core/trace","i18n!nls/pageTimeline","preview/harModel"],function(i,c,k,f,j){with(i){var g=function(){this.listeners=[];this.element=null;this.maxElapsedTime=-1;this.lastSelectedBar=null};g.prototype=domplate({graphCols:FOR("page","$input|getPages",TD({"class":"pageTimelineCol"},DIV({"class":"pageBar",_input:"$input",_page:"$page",title:f.pageBarTooltip,style:"height: $page|getHeight\\px",onmousemove:"$onMouseMove",onclick:"$onClick"}))), -pageGraph:TABLE({"class":"pageTimelineTable",cellpadding:0,cellspacing:0},TBODY(TR({"class":"pageTimelineRow"},TAG("$graphCols",{input:"$input"})))),tag:DIV({"class":"pageTimelineBody",style:"height: auto; display: none"},TABLE({style:"margin: 7px;",cellpadding:0,cellspacing:0},TBODY(TR(TD(TAG("$pageGraph",{input:"$input"}))),TR(TD({"class":"pageDescContainer",colspan:2}))))),getHeight:function(a){var b=1;a=a.pageTimings.onLoad;if(a>0&&this.maxElapsedTime>0)b=Math.round(a/this.maxElapsedTime*100); -return Math.max(1,b)},onClick:function(a){var b=$.event.fix(a||window.event);a=b.target;if(c.hasClass(a,"pageBar")){var d=c.isControlClick(b);b=c.isShiftClick(b);var e=c.getAncestorByClass(a,"pageTimelineRow");!d&&!b&&h.unselectAll(e,a);h.toggle(a);this.selectionChanged()}},onMouseMove:function(a){a=$.event.fix(a||window.event).target;if(c.hasClass(a,"pageBar"))if(this.highlightedPage!=a.page){this.highlightedPage=a.page;var b=c.getElementByClass(this.element,"pageDescContainer");g.Desc.render(b, -a)}},getPages:function(a){return a.log.pages?a.log.pages:[]},getPageBar:function(a){if(this.element)for(var b=c.getElementByClass(this.element,"pageTimelineTable").firstChild.firstChild.firstChild;b;){if(b.firstChild.page==a)return b.firstChild;b=b.nextSibling}},recalcLayout:function(){for(var a=this.maxElapsedTime=0,b=c.getElementsByClass(this.element,"pageBar"),d=0;d<b.length;d++){var e=b[d].page.pageTimings.onLoad;if(e>0&&this.maxElapsedTime<e)this.maxElapsedTime=e}if(a!=this.maxElapsedTime)for(d= -0;d<b.length;d++)b[d].style.height=this.getHeight(b[d].page)+"px"},updateDesc:function(){if(this.isVisible())if(!this.highlightedPage){var a=c.getElementByClass(this.element,"pageBar");a&&c.fireEvent(a,"mousemove")}},addListener:function(a){this.listeners.push(a)},removeListener:function(a){remove(this.listeners,a)},selectionChanged:function(){var a=this.getSelection();c.dispatch(this.listeners,"onSelectionChange",[a])},removeSelection:function(){if(this.element){var a=c.getElementByClass(this.element, -"pageTimelineRow");h.unselectAll(a);this.selectionChanged()}},getSelection:function(){if(!this.isVisible())return[];var a=c.getElementByClass(this.element,"pageTimelineRow");return h.getSelection(a)},show:function(a){if(!this.isVisible()){if(!a||$.browser.msie)this.element.style.display="block";else $(this.element).slideDown();c.setClass(this.element,"opened");this.updateDesc()}},hide:function(a){if(this.isVisible()){if(!a||$.browser.msie)this.element.style.display="none";else $(this.element).slideUp(); -c.removeClass(this.element,"opened");this.removeSelection()}},isVisible:function(){return c.hasClass(this.element,"opened")},toggle:function(a){this.isVisible()?this.hide(a):this.show(a)},render:function(a){this.element=this.tag.replace({input:{log:{pages:[]}}},a,this);this.recalcLayout();return this.element},append:function(a){if(this.element){var b=c.getElementByClass(this.element,"pageTimelineRow");this.graphCols.insertCols({input:a},b,this);this.recalcLayout();this.updateDesc()}}});g.Desc=domplate({tag:DIV({"class":"pageDescBox"}, -DIV({"class":"connector"}),DIV({"class":"desc"},SPAN({"class":"summary"},"$object|getSummary"),SPAN({"class":"time"},"$object.page|getTime"),SPAN({"class":"title"},"$object.page|getTitle"),PRE({"class":"comment"},"$object.page|getComment"))),getSummary:function(a){var b="",d=a.page.pageTimings.onLoad;if(d>0)b+=f.pageLoad+": "+c.formatTime(d)+", ";a=j.getPageEntries(a.input,a.page).length;b+=a+" "+(a==1?f.request:f.requests);return b},getTime:function(a){a=c.parseISO8601(a.startedDateTime);return(new Date(a)).toLocaleString()}, -getTitle:function(a){return a.title},getComment:function(a){return a.comment?a.comment:""},render:function(a,b){a=this.tag.replace({object:{input:b.input,page:b.page}},a);c.$(a,"connector").style.marginLeft=b.parentNode.offsetLeft+"px";return a}});var h={isSelected:function(a){return c.hasClass(a,"selected")},toggle:function(a){c.toggleClass(a,"selected")},select:function(a){this.isSelected(a)||c.setClass(a,"selected")},unselect:function(a){this.isSelected(a)&&c.removeClass(a,"selected")},getSelection:function(a){var b= -[];a=c.getElementsByClass(a,"pageBar");for(var d=0;d<a.length;d++){var e=a[d];this.isSelected(e)&&b.push(e.page)}return b},unselectAll:function(a,b){a=c.getElementsByClass(a,"pageBar");for(var d=0;d<a.length;d++)b!=a[d]&&this.unselect(a[d])}};return g}}); +require.def("tabs/pageTimeline",["domplate/domplate","core/lib","core/trace","i18n!nls/pageTimeline","preview/harModel"],function(Domplate,Lib,Trace,Strings,HarModel){with(Domplate){function Timeline(){this.listeners=[],this.element=null,this.maxElapsedTime=-1,this.lastSelectedBar=null}Timeline.prototype=domplate({graphCols:FOR("page","$input|getPages",TD({"class":"pageTimelineCol"},DIV({"class":"pageBar",_input:"$input",_page:"$page",title:Strings.pageBarTooltip,style:"height: $page|getHeight\\px",onmousemove:"$onMouseMove",onclick:"$onClick"}))),pageGraph:TABLE({"class":"pageTimelineTable",cellpadding:0,cellspacing:0},TBODY(TR({"class":"pageTimelineRow"},TAG("$graphCols",{input:"$input"})))),tag:DIV({"class":"pageTimelineBody",style:"height: auto; display: none"},TABLE({style:"margin: 7px;",cellpadding:0,cellspacing:0},TBODY(TR(TD(TAG("$pageGraph",{input:"$input"}))),TR(TD({"class":"pageDescContainer",colspan:2}))))),getHeight:function(a){var b=1,c=a.pageTimings.onLoad;c>0&&this.maxElapsedTime>0&&(b=Math.round(c/this.maxElapsedTime*100));return Math.max(1,b)},onClick:function(a){var b=Lib.fixEvent(a),c=b.target;if(Lib.hasClass(c,"pageBar")){var d=Lib.isControlClick(b),e=Lib.isShiftClick(b),f=Lib.getAncestorByClass(c,"pageTimelineRow");!d&&!e&&Selection.unselectAll(f,c),Selection.toggle(c),this.selectionChanged()}},onMouseMove:function(a){var b=Lib.fixEvent(a),c=b.target;if(Lib.hasClass(c,"pageBar")){if(this.highlightedPage==c.page)return;this.highlightedPage=c.page;var d=Lib.getElementByClass(this.element,"pageDescContainer");Timeline.Desc.render(d,c)}},getPages:function(a){return a.log.pages?a.log.pages:[]},getPageBar:function(a){if(this.element){var b=Lib.getElementByClass(this.element,"pageTimelineTable"),c=b.firstChild.firstChild.firstChild;while(c){if(c.firstChild.page==a)return c.firstChild;c=c.nextSibling}}},recalcLayout:function(){this.maxElapsedTime=0;var a=this.maxElapsedTime,b=Lib.getElementsByClass(this.element,"pageBar");for(var c=0;c<b.length;c++){var d=b[c].page,e=d.pageTimings.onLoad;e>0&&this.maxElapsedTime<e&&(this.maxElapsedTime=e)}if(a!=this.maxElapsedTime)for(var c=0;c<b.length;c++)b[c].style.height=this.getHeight(b[c].page)+"px"},updateDesc:function(){if(this.isVisible())if(!this.highlightedPage){var a=Lib.getElementByClass(this.element,"pageBar");a&&Lib.fireEvent(a,"mousemove")}},addListener:function(a){this.listeners.push(a)},removeListener:function(a){remove(this.listeners,a)},selectionChanged:function(){var a=this.getSelection();Lib.dispatch(this.listeners,"onSelectionChange",[a])},removeSelection:function(){if(this.element){var a=Lib.getElementByClass(this.element,"pageTimelineRow");Selection.unselectAll(a),this.selectionChanged()}},getSelection:function(){if(!this.isVisible())return[];var a=Lib.getElementByClass(this.element,"pageTimelineRow");return Selection.getSelection(a)},show:function(a){this.isVisible()||(!a||$.browser.msie?this.element.style.display="block":$(this.element).slideDown(),Lib.setClass(this.element,"opened"),this.updateDesc())},hide:function(a){this.isVisible()&&(!a||$.browser.msie?this.element.style.display="none":$(this.element).slideUp(),Lib.removeClass(this.element,"opened"),this.removeSelection())},isVisible:function(){return Lib.hasClass(this.element,"opened")},toggle:function(a){this.isVisible()?this.hide(a):this.show(a)},render:function(a){this.element=this.tag.replace({input:{log:{pages:[]}}},a,this),this.recalcLayout();return this.element},append:function(a,b){if(this.element){var c=Lib.getElementByClass(this.element,"pageTimelineRow");this.graphCols.insertCols({input:a},c,this),this.recalcLayout(),this.updateDesc()}}}),Timeline.Desc=domplate({tag:DIV({"class":"pageDescBox"},DIV({"class":"connector"}),DIV({"class":"desc"},SPAN({"class":"summary"},"$object|getSummary"),SPAN({"class":"time"},"$object.page|getTime"),SPAN({"class":"title"},"$object.page|getTitle"),PRE({"class":"comment"},"$object.page|getComment"))),getSummary:function(a){var b="",c=a.page.pageTimings.onLoad;c>0&&(b+=Strings.pageLoad+": "+Lib.formatTime(c)+", ");var d=HarModel.getPageEntries(a.input,a.page),e=d.length;b+=e+" "+(e==1?Strings.request:Strings.requests);return b},getTime:function(a){var b=Lib.parseISO8601(a.startedDateTime),c=new Date(b);return c.toLocaleString()},getTitle:function(a){return a.title},getComment:function(a){return a.comment?a.comment:""},render:function(a,b){var c={input:b.input,page:b.page},d=this.tag.replace({object:c},a),e=Lib.$(d,"connector");e.style.marginLeft=b.parentNode.offsetLeft+"px";return d}});var Selection={isSelected:function(a){return Lib.hasClass(a,"selected")},toggle:function(a){Lib.toggleClass(a,"selected")},select:function(a){this.isSelected(a)||Lib.setClass(a,"selected")},unselect:function(a){this.isSelected(a)&&Lib.removeClass(a,"selected")},getSelection:function(a){var b=[],c=Lib.getElementsByClass(a,"pageBar");for(var d=0;d<c.length;d++){var e=c[d];this.isSelected(e)&&b.push(e.page)}return b},unselectAll:function(a,b){var c=Lib.getElementsByClass(a,"pageBar");for(var d=0;d<c.length;d++)b!=c[d]&&this.unselect(c[d])}};return Timeline}}) \ No newline at end of file