lib/har/viewer/scripts/tabs/pageTimeline.js in har-0.1.0 vs lib/har/viewer/scripts/tabs/pageTimeline.js in har-0.1.1
- old
+ new
@@ -1,2 +1,4 @@
-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}})
+/* See license.txt for terms of usage */
+
+define("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(e){var t=1,n=e.pageTimings.onLoad;return n>0&&this.maxElapsedTime>0&&(t=Math.round(n/this.maxElapsedTime*100)),Math.max(1,t)},onClick:function(e){var t=Lib.fixEvent(e),n=t.target;if(!Lib.hasClass(n,"pageBar"))return;var r=Lib.isControlClick(t),i=Lib.isShiftClick(t),s=Lib.getAncestorByClass(n,"pageTimelineRow");!r&&!i&&Selection.unselectAll(s,n),Selection.toggle(n),this.selectionChanged()},onMouseMove:function(e){var t=Lib.fixEvent(e),n=t.target;if(!Lib.hasClass(n,"pageBar"))return;if(this.highlightedPage==n.page)return;this.highlightedPage=n.page;var r=Lib.getElementByClass(this.element,"pageDescContainer");Timeline.Desc.render(r,n)},getPages:function(e){return e.log.pages?e.log.pages:[]},getPageBar:function(e){if(!this.element)return;var t=Lib.getElementByClass(this.element,"pageTimelineTable"),n=t.firstChild.firstChild.firstChild;while(n){if(n.firstChild.page==e)return n.firstChild;n=n.nextSibling}},recalcLayout:function(){this.maxElapsedTime=0;var e=this.maxElapsedTime,t=Lib.getElementsByClass(this.element,"pageBar");for(var n=0;n<t.length;n++){var r=t[n].page,i=r.pageTimings.onLoad;i>0&&this.maxElapsedTime<i&&(this.maxElapsedTime=i)}if(e!=this.maxElapsedTime)for(var n=0;n<t.length;n++)t[n].style.height=this.getHeight(t[n].page)+"px"},updateDesc:function(){if(!this.isVisible())return;if(!this.highlightedPage){var e=Lib.getElementByClass(this.element,"pageBar");e&&Lib.fireEvent(e,"mousemove")}},addListener:function(e){this.listeners.push(e)},removeListener:function(e){remove(this.listeners,e)},selectionChanged:function(){var e=this.getSelection();Lib.dispatch(this.listeners,"onSelectionChange",[e])},removeSelection:function(){if(!this.element)return;var e=Lib.getElementByClass(this.element,"pageTimelineRow");Selection.unselectAll(e),this.selectionChanged()},getSelection:function(){if(!this.isVisible())return[];var e=Lib.getElementByClass(this.element,"pageTimelineRow");return Selection.getSelection(e)},show:function(e){if(this.isVisible())return;e?$(this.element).slideDown():this.element.style.display="block",Lib.setClass(this.element,"opened"),this.updateDesc()},hide:function(e){if(!this.isVisible())return;e?$(this.element).slideUp():this.element.style.display="none",Lib.removeClass(this.element,"opened"),this.removeSelection()},isVisible:function(){return Lib.hasClass(this.element,"opened")},toggle:function(e){this.isVisible()?this.hide(e):this.show(e)},render:function(e){return this.element=this.tag.replace({input:{log:{pages:[]}}},e,this),this.recalcLayout(),this.element},append:function(e,t){if(!this.element)return;var n=Lib.getElementByClass(this.element,"pageTimelineRow");this.graphCols.insertCols({input:e},n,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(e){var t="",n=e.page.pageTimings.onLoad;n>0&&(t+=Strings.pageLoad+": "+Lib.formatTime(n)+", ");var r=HarModel.getPageEntries(e.input,e.page),i=r.length;return t+=i+" "+(i==1?Strings.request:Strings.requests),t},getTime:function(e){var t=Lib.parseISO8601(e.startedDateTime),n=new Date(t);return n.toLocaleString()},getTitle:function(e){return e.title},getComment:function(e){return e.comment?e.comment:""},render:function(e,t){var n={input:t.input,page:t.page},r=this.tag.replace({object:n},e),i=Lib.$(r,"connector");return i.style.marginLeft=t.parentNode.offsetLeft+"px",r}});var Selection={isSelected:function(e){return Lib.hasClass(e,"selected")},toggle:function(e){Lib.toggleClass(e,"selected")},select:function(e){this.isSelected(e)||Lib.setClass(e,"selected")},unselect:function(e){this.isSelected(e)&&Lib.removeClass(e,"selected")},getSelection:function(e){var t=[],n=Lib.getElementsByClass(e,"pageBar");for(var r=0;r<n.length;r++){var i=n[r];this.isSelected(i)&&t.push(i.page)}return t},unselectAll:function(e,t){var n=Lib.getElementsByClass(e,"pageBar");for(var r=0;r<n.length;r++)t!=n[r]&&this.unselect(n[r])}};return Timeline}});
\ No newline at end of file