Ext.define("CitrixDashMenuModel",{extend:"Ext.data.Model",fields:[{name:"name"},{name:"caption"},{name:"lcaption"},{name:"children"},{name:"iconCls"},{name:"id"},{name:"isParent"}]});Ext.create("Ext.data.Store",{id:"citrixdashmenu_model_id",model:"CitrixDashMenuModel",autoLoad:true,data:requestParams.views});
var citrixDashMenuTpl=new Ext.XTemplate('<div class="sidebarmenu">',"<ul>",'<tpl for=".">','<li class="x-item <tpl if="children"><tpl if="id != \'seeMore\'">has-sub</tpl> submenuitems</tpl>" id={id}>','<a href="javascript:void(0)" id="{id}-link"><img id="{id}-images"  style="vertical-align:middle;" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="{iconCls}" /><span>{lcaption}</span></a>','<tpl if="children">','<ul class="<tpl if="id == \'seeMore\'">seeMoreMenu </tpl>submenu">','<tpl for="children">','<li  class="x-item x-item-child" index={#} id={id}>','<a href="javascript:void(0)" id="{id}-link"><img id="{id}-images" style="vertical-align:middle;" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="{iconCls}" /> <span>{lcaption}</span></a>',"</li>","</tpl>","</ul>","</tpl>","</li>","</tpl>","</ul>","</div>");
Ext.define("citrixDashboard.view.CitrixDashMenu",{extend:"Ext.view.View",ui:"sidebar",alias:"widget.citrixdashmenu",id:"dashmenu_model_id",store:Ext.data.StoreManager.lookup("citrixdashmenu_model_id"),tpl:citrixDashMenuTpl,trackOver:false,multiSelect:true,scroll:true,autoScroll:true,itemSelector:".x-item",emptyText:"",listeners:{itemclick:function(d,h,p,i,a,k){var f=h.data,l="";
selected=d.getSelectionModel().getSelection(),m=this,f=h.data,visibleSubmenu=$("li ul.submenu:visible"),submenu=$(p).find("ul.submenu"),seeMoreID=$("li.x-item-selected #seeMore-link").is(":visible");thatSubMenu=$(""+m.itemSelector+".x-item-selected").find(".submenu");if(!Ext.isEmpty(h.get("children"))){var g=Ext.fly(p).getAttribute("index"),n=h.get("children");
if(!Ext.isEmpty(n[g-1])){f=n[g-1];l=g-1;var b=$(p).parent().closest("li"+m.itemSelector+".x-item-selected").find(".submenu").is(":visible");var c=$("li"+m.itemSelector+"").find("#seeMore-link").is(":visible");$(this).siblings().find("ul").hide();if(!b){thatSubMenu.slideUp({easing:"swing"});$(""+m.itemSelector+".x-item-selected").removeClass("x-selected");
}else{}requestParams.activeView=f.id;setSession(requestParams.activeView);var m=this,o=citrixDashboard.app.getController("Main").getMain().getComponent("citrix_ground").getComponent("cardID");if(!Ext.isEmpty(o)){o.stopAnimation();o.animate({duration:500,to:{"opacity":0},listeners:{afteranimate:function(){citrixDashboard.app.getController("Main").addPage(f.caption);
}},scope:citrixDashboard.app.getController("Main").getMain()});}}else{$(p).addClass("currentSel").siblings().removeClass("currentSel");if(!submenu.is(":visible")){var c=$(this.getNode(h)).find("#seeMore-link").is(":visible");if(c){$("li"+m.itemSelector+"").find("#seeMore-link").hide();}else{$("li"+m.itemSelector+"").find("#seeMore-link").show();
}if(submenu.length>=1){try{a.preventDefault();}catch(j){}submenu.slideToggle("fast",function(){$(p).addClass("x-selected");});}return false;}else{return false;}}}else{f=h.data;if(visibleSubmenu.length>=1){try{a.preventDefault();}catch(j){}if(!$("#seeMore-link").is(":empty")){$(""+m.itemSelector+"").find("#seeMore-link").show();
}if($(""+m.itemSelector+"").hasClass("x-selected")){$(""+m.itemSelector+"").removeClass("x-selected");}visibleSubmenu.slideUp({speed:"fast",easing:"swing"});}requestParams.activeView=f.id;setSession(requestParams.activeView);var o=citrixDashboard.app.getController("Main").getMain().getComponent("citrix_ground").getComponent("cardID");
if(!Ext.isEmpty(o)){o.stopAnimation();o.animate({duration:500,to:{"opacity":0},listeners:{afteranimate:function(){citrixDashboard.app.getController("Main").addPage(f.caption);}},scope:citrixDashboard.app.getController("Main").getMain()});}}},viewready:function(a){var g=a.store.snapshot||a.store.data;
var e=requestParams.views;var c=null;var b=null;for(var d=0;d<e.length;d++){if(Ext.isEmpty(e[d].children)){if(requestParams.activeView==e[d].id){c=d;}}else{var f=e[d].children;for(var h=0;h<f.length;h++){if(requestParams.activeView==f[h].id){b=h;c=d;}}}}a.onLoadSelectItem(c,g.items[c],b);a.toggleMenu();
citrixDashboard.app.getController("Main").addPage(requestParams.activeView);}},toggleMenu:function(){var a=this;$("#"+this.id).hover(function(){$(this).addClass("sidebarmenu-open");if($(""+a.itemSelector+"").hasClass("x-item-selected")){$(""+a.itemSelector+".x-item-selected").find(".submenu").slideToggle("fast",function(){});
if(!$("#seeMore-link").is(":empty")){$(""+a.itemSelector+".x-item-selected").find("#seeMore-link").hide();}}$(this).stop().animate({width:251,},300,"linear",function(){});},function(){$(this).removeClass("sidebarmenu-open");if($(""+a.itemSelector+"").hasClass("x-item-selected")){$(""+a.itemSelector+"").find(".submenu").slideUp("fast",function(){});
}if(!$("#seeMore-link").is(":empty")){$("#seeMore-link").show();}if($(""+a.itemSelector+"").hasClass("x-selected")){$(""+a.itemSelector+"").removeClass("x-selected");}$(this).stop().animate({width:51},300,"linear",function(){});});},onItemSelect:function(a){var c=this._selectedNode;var b=this;if(c){Ext.select("li.x-item").removeCls(b.selectedItemCls);
Ext.select("li.x-item.x-item-selected").removeCls(b.selectedItemCls);Ext.fly(b.getNode(a)).addCls(b.selectedItemCls);Ext.fly(c).addCls(this.selectedItemCls);if(c.getAttribute("id")!=this.getNode(a).getAttribute("id")){if($(b.getNode(a)).hasClass("submenuitems")){Ext.fly(c).addCls("x-item-selected");}else{Ext.fly(c).removeCls("x-item-selected");
Ext.fly(b.getNode(a)).addCls("x-item-selected");}}}else{Ext.select("li.x-item").removeCls(b.selectedItemCls);Ext.select("li.x-item.x-item-selected").removeCls(b.selectedItemCls);Ext.fly(b.getNode(a)).addCls(b.selectedItemCls);}},onLoadSelectItem:function(b,c,d){var e=c;if(e){this.getSelectionModel().select(b);
Ext.fly(this.getNode(c)).addCls(this.selectedItemCls);Ext.fly(e).addCls(this.selectedItemCls);if(!Ext.isEmpty(e.data.children)){var a=e.data.children[d];Ext.get(a.id).addCls(this.selectedItemCls);}$(".x-item").css({"marginLeft":"300px"});$(".x-item").each(function(f){$(this).delay(100*f).animate({marginLeft:"0"},500);
});}},onItemDeselect:function(a){var b=this._deselectedNode;Ext.select("li.x-item.x-item-selected").removeCls(this.selectedItemCls);Ext.select("li.x-item").removeCls(this.overItemCls);if(b){Ext.fly(this.getNode(a)).removeCls(this.selectedItemCls);Ext.fly(b).removeCls(this.selectedItemCls);}else{var b=this.getNode(a);
Ext.fly(this.getNode(a)).removeCls(this.selectedItemCls);}},onTriggerSelect:function(e){var c=e,a=this;if(!Ext.isEmpty(e)){var b=a.store.snapshot||a.store.data;var d=b.items;d.forEach(function(h,g,i){var f=h.data.id;if(!Ext.isEmpty(h.data.children)){h.data.children.forEach(function(k,l){var j=k.id;if(e==j){a.onItemSelect(h);
}});}else{if(e==f){a.onItemSelect(h);}}});}},processItemEvent:function(a,c,b,d){if(d.type=="mousedown"&&d.button==0){this._deselectedNode=this._selectedNode;this._selectedNode=c;}},updateIndexes:function(f,e){var d=this.all.elements,a=this.store.getRange(),c,b;f=f||0;e=e||((e===0)?0:(d.length-1));for(c=f,b=f-1;
c<=e;c++){if(!Ext.fly(d[c]).is(".x-item-child")){b++;}d[c].viewIndex=c;d[c].viewRecordId=a[b].internalId;if(!d[c].boundView){d[c].boundView=this.id;}}}});