lib/har/viewer/scripts/tabs/previewTab.js in har-0.1.0 vs lib/har/viewer/scripts/tabs/previewTab.js in har-0.1.1

- old
+ new

@@ -1,2 +1,4 @@ -require.def("tabs/previewTab",["domplate/domplate","domplate/tabView","core/lib","i18n!nls/previewTab","domplate/toolbar","tabs/pageTimeline","tabs/pageStats","preview/pageList","core/cookies","preview/validationError","downloadify/js/swfobject","downloadify/src/downloadify"],function(Domplate,TabView,Lib,Strings,Toolbar,Timeline,Stats,PageList,Cookies,ValidationError){with(Domplate){function PreviewTab(a){this.model=a,this.toolbar=new Toolbar,this.timeline=new Timeline,this.stats=new Stats(a,this.timeline),this.toolbar.addButtons(this.getToolbarButtons()),ValidationError.addListener(this)}PreviewTab.prototype=Lib.extend(TabView.Tab.prototype,{id:"Preview",label:Strings.previewTabLabel,tabBodyTag:DIV({"class":"tab$tab.id\\Body tabBody",_repObject:"$tab"},DIV({"class":"previewToolbar"}),DIV({"class":"previewTimeline"}),DIV({"class":"previewStats"}),DIV({"class":"previewList"})),onUpdateBody:function(a,b){this.toolbar.render(Lib.$(b,"previewToolbar")),this.stats.render(Lib.$(b,"previewStats")),this.timeline.render(Lib.$(b,"previewTimeline"));var c=this.model.input;c&&Cookies.getCookie("timeline")=="true"&&this.onTimeline(!1),c&&Cookies.getCookie("stats")=="true"&&this.onStats(!1),this.updateDownloadifyButton()},updateDownloadifyButton:function(){var a=this.model;$(".harDownloadButton").downloadify({filename:function(){return"netData.har"},data:function(){return a?a.toJSON():""},onComplete:function(){},onCancel:function(){},onError:function(){alert(Strings.downloadError)},swf:"scripts/downloadify/media/downloadify.swf",downloadImage:"css/images/download-sprites.png",width:16,height:16,transparent:!0,append:!1})},getToolbarButtons:function(){var a=[{id:"showTimeline",label:Strings.showTimelineButton,tooltiptext:Strings.showTimelineTooltip,command:Lib.bindFixed(this.onTimeline,this,!0)},{id:"showStats",label:Strings.showStatsButton,tooltiptext:Strings.showStatsTooltip,command:Lib.bindFixed(this.onStats,this,!0)},{id:"clear",label:Strings.clearButton,tooltiptext:Strings.clearTooltip,command:Lib.bindFixed(this.onClear,this)}];$.browser.mozilla&&a.push({id:"download",tooltiptext:Strings.downloadTooltip,className:"harDownloadButton"});return a},onTimeline:function(a){var b=this.toolbar.getButton("showTimeline");if(b){this.timeline.toggle(a);var c=this.timeline.isVisible();b.label=Strings[c?"hideTimelineButton":"showTimelineButton"],this.toolbar.render(),this.updateDownloadifyButton(),Cookies.setCookie("timeline",c)}},onStats:function(a){var b=this.toolbar.getButton("showStats");if(b){this.stats.toggle(a);var c=this.stats.isVisible();b.label=Strings[c?"hideStatsButton":"showStatsButton"],this.toolbar.render(),this.updateDownloadifyButton(),Cookies.setCookie("stats",c)}},onClear:function(){var a=document.location.href,b=a.indexOf("?");document.location=a.substr(0,b)},showStats:function(a){Cookies.setCookie("stats",a)},showTimeline:function(a){Cookies.setCookie("timeline",a)},append:function(a){var b=new PageList(a);b.append(Lib.$(this._body,"previewList")),this.timeline.append(a),b.addListener(this)},appendError:function(a){ValidationError.appendError(a,Lib.$(this._body,"previewList"))},addPageTiming:function(a){PageList.prototype.pageTimings.push(a)},getMenuItems:function(a,b,c){c&&(a.push("-"),a.push({label:Strings.menuShowHARSource,command:Lib.bind(this.showHARSource,this,b,c)}))},showHARSource:function(a,b,c){var d=this.tabView.getTab("DOM");d&&(d.select("DOM"),d.highlightFile(b,c))}});return PreviewTab}}) +/* See license.txt for terms of usage */ + +define("tabs/previewTab",["domplate/domplate","domplate/tabView","core/lib","i18n!nls/previewTab","domplate/toolbar","tabs/pageTimeline","tabs/harStats","preview/pageList","core/cookies","preview/validationError","downloadify/js/swfobject","downloadify/src/downloadify"],function(Domplate,TabView,Lib,Strings,Toolbar,Timeline,Stats,PageList,Cookies,ValidationError){with(Domplate){function PreviewTab(e){this.model=e,this.toolbar=new Toolbar,this.timeline=new Timeline,this.stats=new Stats(e,this.timeline),this.toolbar.addButtons(this.getToolbarButtons()),ValidationError.addListener(this)}return PreviewTab.prototype=Lib.extend(TabView.Tab.prototype,{id:"Preview",label:Strings.previewTabLabel,tabBodyTag:DIV({"class":"tab$tab.id\\Body tabBody",_repObject:"$tab"},DIV({"class":"previewToolbar"}),DIV({"class":"previewTimeline"}),DIV({"class":"previewStats"}),DIV({"class":"previewList"})),onUpdateBody:function(e,t){this.toolbar.render(Lib.$(t,"previewToolbar")),this.stats.render(Lib.$(t,"previewStats")),this.timeline.render(Lib.$(t,"previewTimeline"));var n=this.model.input;n&&Cookies.getCookie("timeline")=="true"&&this.onTimeline(!1),n&&Cookies.getCookie("stats")=="true"&&this.onStats(!1),this.updateDownloadifyButton()},updateDownloadifyButton:function(){var e=this.model;$(".harDownloadButton").downloadify({filename:function(){return"netData.har"},data:function(){return e?e.toJSON():""},onComplete:function(){},onCancel:function(){},onError:function(){alert(Strings.downloadError)},swf:"scripts/downloadify/media/downloadify.swf",downloadImage:"css/images/download-sprites.png",width:16,height:16,transparent:!0,append:!1})},getToolbarButtons:function(){var e=[{id:"showTimeline",label:Strings.showTimelineButton,tooltiptext:Strings.showTimelineTooltip,command:Lib.bindFixed(this.onTimeline,this,!0)},{id:"showStats",label:Strings.showStatsButton,tooltiptext:Strings.showStatsTooltip,command:Lib.bindFixed(this.onStats,this,!0)},{id:"clear",label:Strings.clearButton,tooltiptext:Strings.clearTooltip,command:Lib.bindFixed(this.onClear,this)}];return e.push({id:"download",tooltiptext:Strings.downloadTooltip,className:"harDownloadButton"}),e},onTimeline:function(e){var t=this.toolbar.getButton("showTimeline");if(!t)return;this.timeline.toggle(e);var n=this.timeline.isVisible();t.label=Strings[n?"hideTimelineButton":"showTimelineButton"],this.toolbar.render(),this.updateDownloadifyButton(),Cookies.setCookie("timeline",n)},onStats:function(e){var t=this.toolbar.getButton("showStats");if(!t)return;this.stats.toggle(e);var n=this.stats.isVisible();t.label=Strings[n?"hideStatsButton":"showStatsButton"],this.toolbar.render(),this.updateDownloadifyButton(),Cookies.setCookie("stats",n)},onClear:function(){var e=document.location.href,t=e.indexOf("?");document.location=e.substr(0,t)},showStats:function(e){Cookies.setCookie("stats",e)},showTimeline:function(e){Cookies.setCookie("timeline",e)},append:function(e){var t=new PageList(e);t.append(Lib.$(this._body,"previewList")),this.timeline.append(e),t.addListener(this)},appendError:function(e){ValidationError.appendError(e,Lib.$(this._body,"previewList"))},addPageTiming:function(e){PageList.prototype.pageTimings.push(e)},getMenuItems:function(e,t,n){if(!n)return;e.push("-"),e.push({label:Strings.menuShowHARSource,command:Lib.bind(this.showHARSource,this,t,n)})},showHARSource:function(e,t,n){var r=this.tabView.getTab("DOM");if(!r)return;r.select("DOM"),r.highlightFile(t,n)}}),PreviewTab}}); \ No newline at end of file