lib/har/viewer/scripts/domplate/tabView.js in har-0.0.9 vs lib/har/viewer/scripts/domplate/tabView.js in har-0.1.0
- old
+ new
@@ -1,6 +2 @@
-require.def("domplate/tabView",["domplate/domplate","core/lib","core/trace"],function(e,c,h){with(e){var f=domplate({tag:TABLE({"class":"tabView",cellpadding:0,cellspacing:0,_repObject:"$tabView"},TBODY(TR({"class":"tabViewRow"},TD({"class":"tabViewCol",valign:"top"},TAG("$tabList",{tabView:"$tabView"}))))),tabList:DIV({"class":"tabViewBody",onclick:"$onClickTab"},DIV({"class":"$tabView.id\\Bar tabBar"}),DIV({"class":"$tabView.id\\Bodies tabBodies"})),tabHeaderTag:A({"class":"$tab.id\\Tab tab",view:"$tab.id",
-_repObject:"$tab"},"$tab.label"),tabBodyTag:DIV({"class":"tab$tab.id\\Body tabBody",_repObject:"$tab"}),hideTab:function(){return false},onClickTab:function(a){a=$.event.fix(a||window.event);this.getTabView(a.target).onClickTab(a)},getTabView:function(a){return c.getAncestorByClass(a,"tabView").repObject}});e=function(a){this.id=a;this.tabs=[];this.listeners=[]};e.prototype={appendTab:function(a){this.tabs.push(a);a.tabView=this;return a},getTab:function(a){return(a=c.getElementByClass(this.element,
-a+"Tab"))?a.repObject:null},selectTabByName:function(a){(a=c.getElementByClass(this.element,a+"Tab"))&&this.selectTab(a)},addListener:function(a){this.listeners.push(a)},removeListener:function(a){c.remove(this.listeners,a)},onClickTab:function(a){(a=c.getAncestorByClass(a.target,"tab"))&&this.selectTab(a)},selectTab:function(a){if(c.hasClass(a,"tab"))if(!c.hasClass(a,"selected")){var d=a.getAttribute("view");if(d){var b=c.getAncestorByClass(a,"tabViewBody");if(b.selectedTab){b.selectedTab.removeAttribute("selected");
-b.selectedBody.removeAttribute("selected");c.removeClass(b.selectedTab,"selected");c.removeClass(b.selectedBody,"selected")}var g=c.getElementByClass(b,"tab"+d+"Body");g||h.error("TabView.selectTab; Missing tab body",a);b.selectedTab=a;b.selectedBody=g;b.selectedTab.setAttribute("selected","true");b.selectedBody.setAttribute("selected","true");c.setClass(b.selectedBody,"selected");c.setClass(b.selectedTab,"selected");this.updateTabBody(b,d)}}},updateTabBody:function(a){a=a.selectedTab.repObject;if(!a._body._updated){a._body._updated=
-true;a.bodyTag&&a.bodyTag.replace({tab:a},a._body);a&&a.onUpdateBody&&a.onUpdateBody(this,a._body);for(var d=0;d<this.listeners.length;d++){var b=this.listeners[d];b.onUpdateBody&&b.onUpdateBody(this,a._body)}}},render:function(a){this.element=f.tag.replace({tabView:this},a,f);c.setClass(this.element,this.id);for(var d in this.tabs){var b=this.tabs[d],g=b.tabHeaderTag?b.tabHeaderTag:f.tabHeaderTag,i=b.tabBodyTag?b.tabBodyTag:f.tabBodyTag;try{b._header=g.append({tab:b},c.$(a,"tabBar"));b._body=i.append({tab:b},
-c.$(a,"tabBodies"))}catch(j){h.exception("TabView.appendTab; Exception ",j)}}return this.element}};e.Tab=function(){};e.Tab.prototype={invalidate:function(){this._updated=false},select:function(){this.tabView.selectTabByName(this.id)}};return e}});
+require.def("domplate/tabView",["domplate/domplate","core/lib","core/trace"],function(Domplate,Lib,Trace){with(Domplate){var TabViewTempl=domplate({tag:TABLE({"class":"tabView",cellpadding:0,cellspacing:0,_repObject:"$tabView"},TBODY(TR({"class":"tabViewRow"},TD({"class":"tabViewCol",valign:"top"},TAG("$tabList",{tabView:"$tabView"}))))),tabList:DIV({"class":"tabViewBody",onclick:"$onClickTab"},DIV({"class":"$tabView.id\\Bar tabBar"}),DIV({"class":"$tabView.id\\Bodies tabBodies"})),tabHeaderTag:A({"class":"$tab.id\\Tab tab",view:"$tab.id",_repObject:"$tab"},"$tab.label"),tabBodyTag:DIV({"class":"tab$tab.id\\Body tabBody",_repObject:"$tab"}),hideTab:function(a){return!1},onClickTab:function(a){var b=Lib.fixEvent(a),c=this.getTabView(b.target);c.onClickTab(b)},getTabView:function(a){var b=Lib.getAncestorByClass(a,"tabView");return b.repObject}});function TabView(a){this.id=a,this.tabs=[],this.listeners=[],this.tabBarVisibility=!0}TabView.prototype={appendTab:function(a){this.tabs.push(a),a.tabView=this;return a},removeTab:function(a){for(var b in this.tabs){var c=this.tabs[b];if(c.id==a){this.tabs.splice(b,1);break}}},getTab:function(a){for(var b in this.tabs){var c=this.tabs[b];if(c.id==a)return c}},selectTabByName:function(a){var b=Lib.getElementByClass(this.element,a+"Tab");b&&this.selectTab(b)},showTabBar:function(a){this.element?a?this.element.removeAttribute("hideTabBar"):this.element.setAttribute("hideTabBar","true"):this.tabBarVisibility=a},addListener:function(a){this.listeners.push(a)},removeListener:function(a){Lib.remove(this.listeners,a)},onClickTab:function(a){var b=Lib.getAncestorByClass(a.target,"tab");b&&this.selectTab(b)},selectTab:function(a){if(Lib.hasClass(a,"tab")){if(Lib.hasClass(a,"selected")&&a._updated)return;var b=a.getAttribute("view");if(!b)return;var c=Lib.getAncestorByClass(a,"tabViewBody");c.selectedTab&&(c.selectedTab.removeAttribute("selected"),c.selectedBody.removeAttribute("selected"),Lib.removeClass(c.selectedTab,"selected"),Lib.removeClass(c.selectedBody,"selected"));var d=Lib.getElementByClass(c,"tab"+b+"Body");d||Trace.error("TabView.selectTab; Missing tab body",a),c.selectedTab=a,c.selectedBody=d,c.selectedTab.setAttribute("selected","true"),c.selectedBody.setAttribute("selected","true"),Lib.setClass(c.selectedBody,"selected"),Lib.setClass(c.selectedTab,"selected"),this.updateTabBody(c,b)}},updateTabBody:function(a,b){var c=a.selectedTab.repObject;if(!c._body._updated){c._body._updated=!0,c.bodyTag&&c.bodyTag.replace({tab:c},c._body),c&&c.onUpdateBody&&c.onUpdateBody(this,c._body);for(var d=0;d<this.listeners.length;d++){var e=this.listeners[d];e.onUpdateBody&&e.onUpdateBody(this,c._body)}}},render:function(a){this.element=TabViewTempl.tag.replace({tabView:this},a,TabViewTempl),Lib.setClass(this.element,this.id),this.showTabBar(this.tabBarVisibility);for(var b in this.tabs){var c=this.tabs[b],d=c.tabHeaderTag?c.tabHeaderTag:TabViewTempl.tabHeaderTag,e=c.tabBodyTag?c.tabBodyTag:TabViewTempl.tabBodyTag;try{c._header=d.append({tab:c},Lib.$(a,"tabBar")),c._body=e.append({tab:c},Lib.$(a,"tabBodies"))}catch(f){Trace.exception("TabView.appendTab; Exception ",f)}}return this.element}},TabView.Tab=function(){},TabView.Tab.prototype={invalidate:function(){this._updated=!1},select:function(){this.tabView.selectTabByName(this.id)}};return TabView}})
\ No newline at end of file