var jsonData;Ext.define("egindex.view.SwitchUserProfileCombo",{extend:"Ext.form.field.Picker",alias:"widget.switchuserprofilecombo",ui:"eg-new-combo inputUserswitchIcon",editable:false,margin:0,padding:0,id:"enabledUserContainer",initComponent:function(){this.callParent();},listeners:{focus:function(a,c,b){}},value:"",applyValues:function(){var b=this,a=b.picker,c=a.getForm().getValues();
if(b.boundSelection[0]["selection"]!=-1&&b.boundSelection[0]["selection"]!="egenterprise"){b.setValue(b.boundSelection[0]["selection"]);Ext.getCmp("UserSubmitBtn").enable();}else{b.setValue(jsonData["RootNodeText"]);Ext.getCmp("UserSubmitBtn").disable();}b.fireEvent("blur");b.collapse();},boundSelection:[],collapseIf:Ext.Function.createInterceptor(Ext.form.field.Picker.prototype.collapseIf,function(c){var a=Ext.get(c.target).up(".x-boundlist"),b;
b=a&&Ext.getCmp(a.id);if(Ext.isEmpty(b)){if(b&&this.picker.down("#"+b.pickerField.id)){return false;}}}),onCollapse:function(){var a=this;$(".for_switch").each(function(b){Ext.fly(this).show();});a.addCls("x-hidden");Ext.get("switchUser").removeCls("selected_navigation");Ext.getCmp("iconsContainer").doComponentLayout();
},mimicBlur:Ext.Function.createInterceptor(Ext.form.field.Picker.prototype.collapseIf,function(c){var a=Ext.get(c.target).up(".x-boundlist"),b;b=a&&Ext.getCmp(a.id);if(Ext.isEmpty(b)){if(b&&this.picker.down("#"+b.pickerField.id)){return false;}}}),createPicker:function(){var a=this,b=Ext.String.format;
return Ext.create("Ext.form.Panel",{pickerField:a,ui:"pickerui",ownerCt:a.ownerCt,renderTo:document.body,floating:true,bodyPadding:0,items:[{xtype:"hiddenfield",id:"hiddenUserId",name:"hiddenUserId"},{xype:"container",cls:"multisearchlist",width:410,items:[{xtype:"trigger",name:"searchbox",id:"searchbox",trigger1Cls:"x-form-clear-trigger",trigger2Cls:"x-form-search-trigger",cls:"whitedropdown_search",emptyText:searchLbl,width:277,onTrigger1Click:function(){this.reset();
},onTrigger2Click:function(){egTitleSearch();},listeners:{change:function(c){egTitleSearch();},specialkey:function(d,c){if(c.getKey()==c.ENTER){egTitleSearch();}}},getTriggerMarkup:function(){var g=this,e=0,k=(g.readOnly||g.hideTrigger),c,h=g.triggerBaseCls,j=[],f=Ext.dom.Element.unselectableCls,d="width:"+g.triggerWidth-20+"px;"+(k?"display:none;":""),l=g.extraTriggerCls+" "+Ext.baseCSSPrefix+"trigger-cell "+f;
if(!g.trigger1Cls){g.trigger1Cls=g.triggerCls;}for(e=0;(c=g["trigger"+(e+1)+"Cls"])||e<1;e++){if(e==0){j.push({tag:"td",role:"presentation",valign:"top",cls:l,id:"MyTrigger_"+g.id+"_"+e,style:d+"display:none;",cn:{cls:[Ext.baseCSSPrefix+"trigger-index-"+e,h,c].join(" "),role:"presentation"}});}else{j.push({tag:"td",role:"presentation",valign:"top",cls:l,id:"MyTrigger_"+g.id+"_"+e,style:d,cn:{cls:[Ext.baseCSSPrefix+"trigger-index-"+e,h,c].join(" "),role:"presentation"}});
}}j[0].cn.cls+=" "+h+"-first";return Ext.DomHelper.markup(j);},disabled:false}]},{xtype:"treepanel",id:"boundlist",height:200,name:"preselect",bodyStyle:{"border":"0px solid transparent !important"},ui:"newTreePanel defaultTree",emptyText:'<table width="100%"><tr><td align="center" valign="middle"><div class="iconInformation" style="margin:25% auto 0% auto"></div>No users found</td></tr></table>',listeners:{itemclick:function(i,c,g,d,h,f){a.boundSelection.length=0;
a.boundSelection.push({"selection":c.data.id});if(c.data.id!=-1&&c.data.id!="egenterprise"){a.setValue(a.boundSelection[0]["selection"]);Ext.getCmp("UserSubmitBtn").enable();}else{a.setValue(jsonData["RootNodeText"]);Ext.getCmp("UserSubmitBtn").disable();}}},clearFilter:function(){var c=this.getView();
if(this.getRootNode()){this.getRootNode().cascadeBy(function(e,g){var f=g.getNodeByRecord(this);if(f){Ext.get(f).setDisplayed("table-row");}},null,[this,c]);var d=Ext.getElementById("noDataFound");if(d){d.style.display="none";}}},filterBy:function(h,g){this.clearFilter();var c=this.getView(),e=this,f=[];
if(this.getRootNode()){this.getRootNode().cascadeBy(function(j,k){var i=this;if(i&&i.data[g]&&i.data[g].toString().toLowerCase().indexOf(h.toLowerCase())>-1){e.expandPath(i.getPath());while(i.parentNode){f.push(i.id);i=i.parentNode;}}},null,[e,c]);this.getRootNode().cascadeBy(function(i,k){var j=k.getNodeByRecord(this);
if(j&&!Ext.Array.contains(f,this.id)&&this.data.id!=-1){Ext.get(j).setDisplayed("none");}},null,[e,c]);if(Ext.isEmpty(f)){this.getRootNode().cascadeBy(function(i,k){var j=k.getNodeByRecord(this);if(this.data.id==-1){Ext.get(j).setDisplayed("none");}},null,[e,c]);var d=Ext.getElementById("noDataFound");
if(d==null||d===undefined){Ext.DomHelper.append(Ext.get(c.id),{tag:"div",style:{"width":"100%","textAlign":"center","display":"table"},cls:"new-div-cls",id:"noDataFound",html:LoadSearchAlert});}else{d.style.display="table";}}}},useArrows:false,autoShow:true,autoScroll:true,store:Ext.create("Ext.data.TreeStore",{sorters:[{property:"text",direction:"ASC"}]}),rootVisible:true}],dockedItems:[{xtype:"toolbar",dock:"bottom",ui:"footer",padding:"7 0 7 0",items:["->",{xtype:"button",name:"submit",cls:"button20",text:switchLbl,id:"UserSubmitBtn",},"->"]}],listeners:{afterrender:function(c,d){switchUserTabClick(c,d,a);
},show:function(c,d){switchUserTabClick(c,d,a);}}});}});function switchUserTabClick(b,d,c){var e;b.getEl().on("mouseleave",function(){e=setTimeout(function(){c.onCollapse();c.fireEvent("blur");c.collapse();},2000);});b.getEl().on("mouseenter",function(){clearTimeout(e);});var a=new Ext.LoadMask(b,{msg:"Loading .."});
a.show();Ext.Ajax.request({url:"/final/scripts/EgIndexApp/data/EgSwitchUsersJson.jsp",method:"post",scope:this,timeout:120000,success:function(g){a.hide();var i=g.responseText;jsonData=Ext.decode(i);if(Ext.isObject(Ext.getCmp("boundlist"))){var f=jsonData["exportDataArr"];var j=Ext.getCmp("boundlist");
if(!Ext.isEmpty(f)){var h={text:jsonData["RootNodeText"],id:"-1",name:"-1",expanded:true,children:jsonData["exportDataArr"]};j.getStore().setRootNode(h);c.setValue(jsonData["RootNodeText"]);Ext.getCmp("hiddenUserId").setValue(jsonData["currentUser"]);}else{j.getStore().removeAll();}if(c.getValue()===jsonData["RootNodeText"]||c.getValue()==="egenterprise"){Ext.getCmp("UserSubmitBtn").disable();
}else{if(!Ext.isEmpty(f)){Ext.getCmp("UserSubmitBtn").enable();}else{Ext.getCmp("UserSubmitBtn").disable();}}}},failure:function(f){}});}function egTitleSearch(){var e=Ext.getCmp("boundlist");var b=Ext.getCmp("searchbox").getValue();var d="MyTrigger_searchbox_0";var c="MyTrigger_searchbox_1";if(b==""||b.length==0){Ext.get(d).setStyle("display","none");
Ext.get(c).setStyle("display","block");}else{Ext.get(c).setStyle("display","none");Ext.get(d).setStyle("display","block");}if(b==null||b==""){Ext.getCmp("boundlist").filterBy(b,"text");var a=Ext.getElementById("noDataFound");if(a){a.style.display="none";}Ext.getCmp("enabledUserContainer").setValue(jsonData["RootNodeText"]);
}else{Ext.getCmp("boundlist").filterBy(b,"text");Ext.getCmp("enabledUserContainer").setValue(jsonData["RootNodeText"]);}Ext.getCmp("UserSubmitBtn").disable();}