Ext.ns("feyaSoft.openSource");feyaSoft.openSource.DetailPanel=function(config){this.config=config;this.myPageSize=5;this.backBtn=new Ext.Button({iconCls:"app_back",text:"Go back to topic list",handler:this.onBackFn,scope:this});this.replyBtn=new Ext.Button({iconCls:"editItem",text:"Reply",handler:this.onReplyFn,scope:this});this.dataStore=new Ext.data.JsonStore({url:"openSourceForum/list?type="+config.type,remoteSort:true,fields:[]});this.dataStore.setDefaultSort("createTime","ASC");this.pageBar=new Ext.PagingToolbar({pageSize:this.myPageSize,store:this.dataStore,displayInfo:true,displayMsg:"Displaying items {0} - {1} of {2}",emptyMsg:"not result to display"});this.tpl=new Ext.XTemplate('<tpl for="."><div class="x-thread-detail"><div class="x-thread-inner"><div class="x-thread-header"><table width="100%"><tbody><tr><td><div class="x-thread-header-info"><b>&nbsp;#{index}</b>&nbsp;&nbsp;{[values.updateTime.format("Y-m-d H:i:s")]}</div></td><td class="x-thread-header-tool"><tpl if="this.hasRight(userRole) == true"><img class="x-thread-header-tool-edit" src="'+Ext.BLANK_IMAGE_URL+'"></img><img class="x-thread-header-tool-delete" src="'+Ext.BLANK_IMAGE_URL+'"></img></tpl></td></tr></tbody></table></div><div class="x-thread-body"><div class="x-thread-body-inner"><div class="x-thread-author"><b>{author}</b></div><div class="x-thread-subject"><div class="x-thread-subject-inner"><b>{subject}</b></div></div><div class="x-thread-desc">{description}</div><tpl if="this.hasAttach(uploadFileLoc) == true"><div class="x-thread-attach"><img class="function-file-download" src="images/icons/attach.png" style="cursor:pointer"></img><a class="x-thread-attach-link" href="#">Download attached file <b>{uploadFileName}</b></a></div></tpl><div class="x-thread-footer"><input class="x-thread-footer-quote" type="button" value="Quote" /></div></div></div></div></div></tpl><div class="x-clear"></div>',{hasRight:function(userRole){if(userRole!="reader"){return true}return false},hasAttach:function(uploadFileLoc){if(uploadFileLoc&&""!=uploadFileLoc){return true}return false}});this.dataView=new Ext.DataView({store:this.dataStore,tpl:this.tpl,itemSelector:"div.x-thread-detail",singleSelect:true});feyaSoft.openSource.DetailPanel.superclass.constructor.call(this,{border:false,tbar:[this.backBtn,"-",this.replyBtn],autoScroll:true,items:[this.dataView],bbar:this.pageBar});this.dataView.on("click",this.onDataViewClickFn,this)};Ext.extend(feyaSoft.openSource.DetailPanel,Ext.Panel,{loadTopic:function(topic){this.topic=topic;this.dataStore.baseParams={parentId:topic.data.id};this.dataStore.removeAll();this.pageBar.doLoad(0)},onBackFn:function(){var layout=this.ownerCt.getLayout();layout.setActiveItem(0);layout.activeItem.reload()},onReplyFn:function(){Ext.Ajax.request({url:"userWholeAccess/isUserLogin",success:function(result,request){var jsonData=Ext.decode(result.responseText);if(jsonData.success=="true"){new feyaSoft.openSource.myCalendar.CreateEditForum({myOwner:this,type:this.config.type,parentId:this.topic.data.id,replySub:this.topic.data.subject})}else{new feyaSoft.openSource.Login()}},failure:function(result,request){new feyaSoft.openSource.Login()},scope:this})},reload:function(){this.pageBar.doLoad(this.pageBar.cursor)},onDataViewClickFn:function(dv,index,node,e){var tgEl=Ext.get(e.getTarget());if(tgEl){var rd=this.dataStore.getAt(index);var pid=this.topic.data.id;if(pid==rd.data.id){pid=0}if(tgEl.hasClass("x-thread-header-tool-edit")){new feyaSoft.openSource.myCalendar.CreateEditForum({myOwner:this,type:this.config.type,parentId:pid,record:rd})}else{if(tgEl.hasClass("x-thread-header-tool-delete")){var id=rd.data.id;Ext.Msg.show({title:"Confirm",msg:"Do you really want to delete this item?",width:350,buttons:Ext.MessageBox.OKCANCEL,scope:this,fn:function(btn){if(btn=="ok"){Ext.Ajax.request({url:"openSourceForum/cancel",params:{id:id},success:function(response,options){var backObj=Ext.decode(response.responseText);if(backObj.success=="false"){Ext.Msg.show({title:"Error",msg:backObj.errorInfo,buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR})}else{this.reload();Ext.Message.msgStay("Confirm",backObj.info,2000)}},failure:function(response,options){Ext.MessageBox.alert("Error","Internet error!")},scope:this})}}})}else{if(tgEl.hasClass("x-thread-footer-quote")){var author=rd.data.author;var desc=rd.data.description;new feyaSoft.openSource.myCalendar.CreateEditForum({myOwner:this,type:this.config.type,parentId:this.topic.data.id,replySub:this.topic.data.subject,quote:'<br><div style="padding:10px 20px 10px 20px;"><b style="font-size:14px;">Quote:</b><div style="border:1px solid silver;padding:5px;background:rgb(239,239,239);"><b style="font-size:12px;">Originally Posted by '+author+"</b><br><br>"+desc+"</div></div><br><br>"})}else{if(tgEl.hasClass("x-thread-attach-link")){var url="openSourceForum/download?id="+rd.data.id;window.open(url,"Download")}}}}}}});