Mobile.min.js 9.0 KB

1
  1. MWF.xApplication.Forum=MWF.xApplication.Forum||{};MWF.xApplication.ForumDocument=MWF.xApplication.ForumDocument||{};MWF.xDesktop.requireApp("Forum","Common",null,false);MWF.xDesktop.requireApp("Template","Explorer",null,false);MWF.xApplication.ForumDocument.Mobile=new Class({Implements:[Options,Events],options:{id:"",sectionId:"",viewPageNum:1,replyIndex:null,isNew:false,isEdited:false},initialize:function(e,t,i,n,s,o){this.setOptions(o);this.app=t;this.node=$(e);this.actions=i;this.lp=n;this.css=s;this.path="/x_component_ForumDocument/$Mobile/default/"},load:function(){this.actions.login({},function(e){this.actions.listSubjectPermission(this.options.id,function(e){this.permission=e.data;this.actions.getSubjectView(this.options.id,function(e){this.data=e.data.currentSubject;this.options.sectionId=this.data.sectionId;this.createMiddleNode()}.bind(this))}.bind(this))}.bind(this))},createMiddleNode:function(){this.middleNode=new Element("div.middleNode",{styles:this.css.middleNode}).inject(this.node);this.subjectConainer=new Element("div.subjectConainer",{styles:this.css.subjectConainer}).inject(this.middleNode);if(this.data.typeCategory==this.lp.question){this.satisfiedReplyViewConainer=new Element("div.satisfiedReplyViewConainer",{styles:this.css.replyViewConainer}).inject(this.middleNode)}this.replyViewConainer=new Element("div.replyViewConainer",{styles:this.css.replyViewConainer}).inject(this.middleNode);this.createSubject();if(this.data.typeCategory==this.lp.question){if(this.data.acceptReplyId){this.createSatisfiedReplyView()}}this.createReplyView()},createSubject:function(){this.subjectView=new MWF.xApplication.ForumDocument.Mobile.SubjectView(this.subjectConainer,this.app,this,{templateUrl:this.path+"listItemSubject.json",scrollEnable:false});this.subjectView.data=this.data;this.subjectView.load()},showReply:function(e){this.replyView.showReply(e)},createReplyView:function(){var e=new Element("div.itemReplyTitleArea",{styles:this.css.itemReplyTitleArea}).inject(this.replyViewConainer);new Element("div.itemReplyTitle",{styles:this.css.itemReplyTitle,text:this.lp.allReply+"("+this.data.replyTotal+")"}).inject(e);this.replyView=new MWF.xApplication.ForumDocument.Mobile.ReplyView(this.replyViewConainer,this.app,this,{templateUrl:this.path+"listItemReply.json",scrollEnable:false,pagingEnable:true,documentKeyWord:"orderNumber",pagingPar:{currentPage:this.options.viewPageNum||1,countPerPage:10,hasPrevPage:true,hasTruningBar:false,onPostLoad:function(){if(this.replyView.getCurrentPageNum()==1){if(this.replyView.paging&&this.replyView.paging.nextPageNode)this.replyView.paging.nextPageNode.setStyle("width","99%")}else if(this.replyView.getCurrentPageNum()==this.replyView.getPageSize()){if(this.replyView.paging&&this.replyView.paging.prevPageNode)this.replyView.paging.prevPageNode.setStyle("width","99%")}else{if(this.replyView.paging&&this.replyView.paging.prevPageNode)this.replyView.paging.prevPageNode.setStyle("width","49%");if(this.replyView.paging&&this.replyView.paging.nextPageNode)this.replyView.paging.nextPageNode.setStyle("width","49%")}}.bind(this)}});this.replyView.data=this.data;this.replyView.filterData={subjectId:this.data.id};this.replyView.load()},createSatisfiedReplyView:function(){var e=new Element("div.itemReplyTitleArea",{styles:this.css.itemReplyTitleArea}).inject(this.satisfiedReplyViewConainer);new Element("div.itemReplyTitle",{styles:this.css.itemReplyTitle_accepted,text:this.lp.satisfiedAnswer}).inject(e);this.satisfiedReplyView=new MWF.xApplication.ForumDocument.Mobile.SatisfiedReplyView(this.satisfiedReplyViewConainer,this,this,{templateUrl:this.path+"listItemSatisfied.json",scrollEnable:false});this.satisfiedReplyView.data=this.data;this.satisfiedReplyView.load()},getUserIcon:function(e){var t="";var i=MWF.Actions.get("x_organization_assemble_personal").getIcon(e);if(i){t=i}else{t="/x_component_ForumDocument/$Main/default/icon/noavatar_big.gif"}return t}});MWF.xApplication.ForumDocument.Mobile.SubjectView=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexView,_createDocument:function(e,t){e.index=t;return new MWF.xApplication.ForumDocument.Mobile.SubjectDocument(this.viewNode,e,this.explorer,this,null,e.index)},getUserData:function(e,t){MWF.Actions.get("x_organization_assemble_control").getPerson(function(e){if(t)t(e)}.bind(this),null,e,true)},_getCurrentPageData:function(e,t){var i={type:"success",count:1,size:1,data:[this.data]};if(e)e(i)},_removeDocument:function(e,t){this.actions.deleteSection(e.id,function(e){this.reload();this.app.notice(this.app.lp.deleteDocumentOK,"success")}.bind(this))},_create:function(){},_queryCreateViewNode:function(){},_postCreateViewNode:function(e){},_queryCreateViewHead:function(){},_postCreateViewHead:function(e){}});MWF.xApplication.ForumDocument.Mobile.SubjectDocument=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexDocument,mouseoverSubject:function(e,t){},mouseoutSubject:function(e,t){},_queryCreateDocumentNode:function(e){},_postCreateDocumentNode:function(e,t){var i=e.getElements("[item='content']")[0];i.getElements("img").each(function(e){e.setStyles({height:"auto","max-width":"100%"})}.bind(this));if(this.data.typeCategory==this.lp.vote){var n=e.getElement("[item='vote']");MWF.xDesktop.requireApp("ForumDocument","Vote",function(){this.vote=new MWF.xApplication.ForumDocument.Vote(n,this.app,{isNew:false,isEdited:false},this.data);this.vote.load()}.bind(this),true)}},createReply:function(e,t){var i=new MWF.xApplication.ForumDocument.ReplyForm(this,{},{toMain:true,onPostOk:function(e){this.app.postCreateReply(e)}.bind(this)});i.mainData=this.data;i.create()}});MWF.xApplication.ForumDocument.Mobile.ReplyView=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexView,showReply:function(e){this.actions.getReply(e,function(e){new MWF.xApplication.ForumDocument.Mobile.ReplyDocument(this.viewNode,e.data,this.explorer,this,null,null)}.bind(this))},_createDocument:function(e,t){e.index=t;return new MWF.xApplication.ForumDocument.Mobile.ReplyDocument(this.viewNode,e,this.explorer,this,null,e.index)},_getCurrentPageData:function(t,e,i){this.clearBody();if(!e)e=10;if(!i)i=1;if(i==1){this.explorer.subjectConainer.setStyle("display","block");if(this.explorer.satisfiedReplyViewConainer)this.explorer.satisfiedReplyViewConainer.setStyle("display","block")}else{this.explorer.subjectConainer.setStyle("display","none");if(this.explorer.satisfiedReplyViewConainer)this.explorer.satisfiedReplyViewConainer.setStyle("display","none")}var n=this.filterData||{};this.actions.listReplyFilterPage(i,e,n,function(e){if(!e.data)e.data=[];if(!e.count)e.count=0;if(t)t(e)}.bind(this))},_removeDocument:function(e,t){this.actions.deleteReply(e.id,function(){this.reload();this.app.notice(this.lp.deleteReplySuccess,"ok")}.bind(this))},_create:function(){},_queryCreateViewNode:function(){},_postCreateViewNode:function(e){},_queryCreateViewHead:function(){},_postCreateViewHead:function(e){}});MWF.xApplication.ForumDocument.Mobile.ReplyDocument=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexDocument,mouseoverSubject:function(e,t){},mouseoutSubject:function(e,t){},getUserData:function(e,t){MWF.Actions.get("x_organization_assemble_control").getPerson(function(e){if(t)t(e)}.bind(this),null,e,true)},_queryCreateDocumentNode:function(e){},_postCreateDocumentNode:function(e,t){var i=e.getElements("[item='content']")[0];i.getElements("img").each(function(e){e.setStyles({height:"auto","max-width":"100%"})}.bind(this));if(t.parentId&&t.parentId!=""){var a=e.getElements("[item='quoteContent']")[0];this.actions.getReply(t.parentId,function(e){var t=this.parentData=e.data;var i=new Element("div",{styles:this.css.itemQuote}).inject(a);var n=i.set("html",t.content).get("text");i.empty();t.contentText=n;var s=new Element("div",{styles:this.css.quoteArea}).inject(i);var o=new Element("div",{styles:this.css.quoteInfor,text:this.lp.replyTo+" "+t.orderNumber+this.lp.floor+" "+t.creatorName.split("@")[0]+" "+t.createTime}).inject(s);new Element("div",{styles:this.css.quoteText,text:n.length>100?n.substr(0,100)+"...":n}).inject(s)}.bind(this),function(e){new Element("div",{styles:this.css.replyBeinngDelete,text:this.lp.quoteReplyBeingDeleted}).inject(a)}.bind(this))}},createReply:function(e,t){var i=navigator.userAgent.toLowerCase();if(/iphone|ipad|ipod/.test(i)){window.webkit.messageHandlers.ReplyAction.postMessage({body:this.data.id})}else if(/android/.test(i)){window.o2bbs.reply(this.data.id)}}});MWF.xApplication.ForumDocument.Mobile.SatisfiedReplyView=new Class({Extends:MWF.xApplication.ForumDocument.Mobile.ReplyView,_createDocument:function(e,t){e.index=t;return new MWF.xApplication.ForumDocument.Mobile.SatisfiedReplyDocument(this.viewNode,e,this.explorer,this,null,e.index)},_getCurrentPageData:function(t,e,i){this.clearBody();if(!e)e=1;if(!i)i=1;var n=this.filterData||{};this.actions.getAcceptedReply(this.data.acceptReplyId,function(e){if(!e.data){e.data=[]}else if(typeOf(e.data)=="object"){e.data=[e.data];e.count=1}if(!e.count)e.count=0;if(t)t(e)}.bind(this))}});MWF.xApplication.ForumDocument.Mobile.SatisfiedReplyDocument=new Class({Extends:MWF.xApplication.ForumDocument.Mobile.ReplyDocument});