12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289 |
- MWF.xApplication.Forum = MWF.xApplication.Forum || {};
- MWF.xApplication.ForumSection = MWF.xApplication.ForumSection || {};
- MWF.require("MWF.widget.O2Identity", null,false);
- MWF.xDesktop.requireApp("Forum", "Common", null, false);
- //MWF.xDesktop.requireApp("Forum", "Actions.RestActions", null, false);
- MWF.xDesktop.requireApp("Forum", "lp."+MWF.language, null, false);
- MWF.xDesktop.requireApp("Template", "Explorer", null, false);
- MWF.xDesktop.requireApp("Forum", "Access", null, false);
- MWF.xDesktop.requireApp("Forum", "TopNode", null, false);
- MWF.xApplication.ForumSection.options = {
- multitask: true,
- executable: true
- };
- MWF.xApplication.ForumSection.Main = new Class({
- Extends: MWF.xApplication.Common.Main,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "name": "ForumSection",
- "icon": "icon.png",
- "width": "1230",
- "height": "700",
- "isResize": true,
- "isMax": true,
- "title": MWF.xApplication.ForumSection.LP.title,
- "hasTop" : true,
- "naviMode" : false,
- "hasBreadCrumb" : true,
- "autoWidth" : false,
- "sectionId" : ""
- },
- onQueryLoad: function(){
- this.lp = MWF.xApplication.Forum.LP;
- },
- onQueryClose : function(){
- this.clearContent();
- },
- loadApplication: function(callback){
- this.userName = layout.desktop.session.user.distinguishedName;
- this.restActions = MWF.Actions.get("x_bbs_assemble_control"); //new MWF.xApplication.Forum.Actions.RestActions();
- this.path = "../x_component_ForumSection/$Main/"+this.options.style+"/";
- this.createNode();
- this.loadApplicationContent();
- },
- loadController: function(callback){
- this.access = new MWF.xApplication.Forum.Access( this.restActions, this.lp );
- if(callback)callback();
- },
- createNode: function(){
- this.content.setStyle("overflow", "hidden");
- this.node = new Element("div", {
- "styles": this.css.node
- }).inject(this.content);
- },
- clearContent: function(){
- this.node.empty();
- },
- loadApplicationContent: function(){
- if( !this.options.sectionId && this.status && this.status.sectionId ){
- this.options.sectionId = this.status.sectionId;
- }
- this.loadController(function(){
- this.access.login( function () {
- this.loadApplicationLayout();
- }.bind(this))
- }.bind(this))
- },
- reloadAllParents : function(){
- var aid = "Forum";
- if (this.desktop.apps[aid] && this.desktop.apps[aid].reload){
- this.desktop.apps[aid].reload();
- }
- aid = "ForumCategory"+this.sectionData.forumId;
- if (this.desktop.apps[aid] && this.desktop.apps[aid].reload){
- this.desktop.apps[aid].reload();
- }
- },
- reload : function(){
- this.status = {
- sectionId : this.options.sectionId,
- viewPageNum : this.explorer.view.getCurrentPageNum(),
- noteHidden : this.noteNodeHidden
- };
- this.clearContent();
- this.contentContainerNode = new Element("div.contentContainerNode", {
- "styles": this.options.autoWidth ? this.css.contentContainerNode_inContainer : this.css.contentContainerNode
- }).inject(this.node);
- this.createTopNode();
- this.createMiddleNode();
- },
- loadApplicationLayout : function(){
- this.contentContainerNode = new Element("div.contentContainerNode", {
- "styles": this.options.autoWidth ? this.css.contentContainerNode_inContainer : this.css.contentContainerNode
- }).inject(this.node);
- if( this.options.sectionId ){
- this.restActions.listSectionPermission( this.options.sectionId, function( permission ){
- this.sectionPermission = permission.data;
- this.isAdmin = this.sectionPermission.subjectManageAble;
- this.restActions.getSection( this.options.sectionId, function( json ){
- this.sectionData = json.data;
- //this.access.hasSectionAdminAuthority( this.sectionData, function( flag ){
- //this.isAdmin = flag;
- var tail = (this.inBrowser && layout.desktop.session.user.name !== "anonymous") ? (MWFForum.getSystemConfigValue( MWFForum.BBS_TITLE_TAIL ) || "") : "";
- this.setTitle( this.sectionData.sectionName + tail );
- this.createTopNode();
- this.createMiddleNode();
- //}.bind(this) );
- }.bind(this) )
- }.bind(this) )
- }else{
- this.close()
- }
- },
- loadTopObject : function(naviMode){
- if( this.options.hasTop ){
- var node = this.topObject = new MWF.xApplication.Forum.TopNode(this.contentContainerNode, this, this, {
- type: this.options.style,
- naviModeEnable : true,
- naviMode : naviMode
- });
- node.load();
- }
- },
- createTopNode: function(){
- this.loadTopObject( false );
- if( this.options.hasBreadCrumb ){
- var topNode = this.topNode = new Element("div.topNode", {
- "styles": this.options.autoWidth ? this.css.topNode_inContainer : this.css.topNode
- }).inject(this.contentContainerNode);
- //topNode.setStyle("border-bottom","1px solid "+forumColor);
- var topTitleMiddleNode = this.breadCrumbNode = new Element("div.topTitleMiddleNode", {
- "styles": this.css.topTitleMiddleNode
- }).inject(topNode);
- //topTitleMiddleNode.setStyle( "background-color" , forumColor )
- var topItemTitleNode = new Element("div.topItemTitleNode", {
- "styles": this.css.topItemTitleNode,
- "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
- }).inject(topTitleMiddleNode);
- topItemTitleNode.addEvent("click", function(){
- if( this.options.naviMode && this.forumNavi ){
- this.forumNavi.goto( MWFForum.NaviType.main )
- }else{
- var appId = "Forum";
- if (this.desktop.apps[appId]){
- this.desktop.apps[appId].setCurrent();
- }else {
- this.desktop.openApplication(null, "Forum", { "appId": appId });
- }
- this.close();
- }
- }.bind(this));
- var topItemSepNode = new Element("div.topItemSepNode", {
- "styles": this.css.topItemSepNode,
- "text" : ">"
- }).inject(topTitleMiddleNode);
- var topItemTitleNode = new Element("div.topItemTitleNode", {
- "styles": this.css.topItemTitleNode,
- "text": this.sectionData.forumName
- }).inject(topTitleMiddleNode);
- topItemTitleNode.addEvent("click", function(){
- if( this.obj.options.naviMode && this.obj.forumNavi ){
- this.obj.forumNavi.goto( MWFForum.NaviType.category, this.forumId )
- }else{
- var appId = "ForumCategory"+this.forumId;
- if (this.obj.desktop.apps[appId]){
- this.obj.desktop.apps[appId].setCurrent();
- }else {
- this.obj.desktop.openApplication(null, "ForumCategory", { "categoryId" : this.forumId ,"appId": appId });
- }
- if( !this.obj.inBrowser ){
- this.obj.close();
- }
- }
- }.bind({ obj: this, forumId : this.sectionData.forumId }));
- topItemSepNode = new Element("div.topItemSepNode", {
- "styles": this.css.topItemSepNode,
- "text" : ">"
- }).inject(topTitleMiddleNode);
- topItemTitleNode = new Element("div.topItemTitleNode", {
- "styles": this.css.topItemTitleLastNode,
- "text": this.sectionData.sectionName
- }).inject(topTitleMiddleNode);
- }
- if( this.sectionData.sectionNotice ){
- var topRightNode = new Element("div", {
- "styles": this.css.topRightNode
- }).inject(topNode);
- topRightNode.addEvents({
- "click" :function(){
- if( !this.noteNodeHidden ){
- this.noteNode.setStyle("display","none");
- this.topRightIconNode.setStyles(this.css.topRightIconDownNode);
- this.noteNodeHidden = true;
- }else{
- this.noteNode.setStyle("display","");
- this.topRightIconNode.setStyles(this.css.topRightIconNode);
- this.noteNodeHidden = false;
- }
- }.bind(this)
- });
- var topRightIconNode = this.topRightIconNode = new Element("div", {
- "styles": this.css.topRightIconNode
- }).inject(topRightNode);
- if( this.status && this.status.noteHidden ){
- this.topRightIconNode.setStyles(this.css.topRightIconDownNode);
- this.noteNodeHidden = true;
- }
- }
- },
- createMiddleNode: function(){
- this.middleNode = new Element("div.middleNode", {
- "styles": this.options.autoWidth ? this.css.middleNode_inContainer : this.css.middleNode
- }).inject(this.contentContainerNode);
- this.createSectionNode();
- this.createNoteNode();
- this._createMiddleNode();
- if( !this.options.naviMode ){
- this.addEvent("resize", function () {
- this.setContentSize();
- }.bind(this));
- this.setContentSize();
- }
- //MWF.require("MWF.widget.ScrollBar", function () {
- // new MWF.widget.ScrollBar(this.contentContainerNode, {
- // "indent": false,
- // "style": "xApp_TaskList",
- // "where": "before",
- // "distance": 30,
- // "friction": 4,
- // "axis": {"x": false, "y": true},
- // "onScroll": function (y) {
- // }
- // });
- //}.bind(this));
- },
- openNavi: function () {
- MWF.xDesktop.requireApp("Forum", "NaviMode", null, false);
- this.clearContent();
- this.contentContainerNode = new Element("div.contentContainerNode", {
- "styles": this.css.contentContainerNode
- }).inject(this.node);
- this.loadTopObject( true );
- this.middleNode = new Element("div.middleNode", {
- "styles": this.css.middleNode
- }).inject(this.contentContainerNode);
- this.contentNode = new Element("div.contentNode", {
- "styles": this.css.contentNode
- }).inject(this.middleNode);
- this.navi = new MWF.xApplication.Forum.NaviMode(this, this.contentNode, {
- type : MWFForum.NaviType.section,
- id : this.sectionData.id
- });
- this.navi.load();
- },
- closeNavi : function(){
- if( this.navi )this.navi.close();
- },
- colorRgba : function( color, opacity ){ /*16进制颜色转为RGB格式*/
- var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
- var sColor = color.toLowerCase();
- if(sColor && reg.test(sColor)){
- if(sColor.length === 4){
- var sColorNew = "#";
- for(var i=1; i<4; i+=1){
- sColorNew += sColor.slice(i,i+1).concat(sColor.slice(i,i+1));
- }
- sColor = sColorNew;
- }
- //处理六位的颜色值
- var sColorChange = [];
- for(var i=1; i<7; i+=2){
- sColorChange.push(parseInt("0x"+sColor.slice(i,i+2)));
- }
- return "rgba(" + sColorChange.join(",") + "," + opacity + ")";
- }else{
- return sColor;
- }
- },
- createSectionNode: function(){
- var forumColor = MWF.xApplication.Forum.ForumSetting[this.sectionData.forumId].forumColor;
- var sectionNode = new Element("div.sectionNode", {
- "styles": this.options.autoWidth ? this.css.sectionNode_inContainer : this.css.sectionNode
- }).inject(this.middleNode);
- sectionNode.setStyle("background-color", this.colorRgba( forumColor, "0.05" ));
- var sectionLeftNode = new Element("div.sectionLeftNode", {
- "styles": this.css.sectionLeftNode
- }).inject(sectionNode);
- var sectionLeftIconNode = new Element("div.sectionLeftIconNode", {
- "styles": this.css.sectionLeftIconNode
- }).inject(sectionLeftNode);
- var sectionLeftIcon = new Element("img", {
- "styles": this.css.sectionLeftIcon,
- "src" : this.sectionData.icon ? ('data:image/png;base64,'+ this.sectionData.icon) : "../x_component_Forum/$Setting/default/sectionIcon/forum_icon.png"
- }).inject(sectionLeftIconNode);
- var sectionLeftContent = new Element("div.sectionLeftContent", {
- "styles": this.css.sectionLeftContent
- }).inject(sectionLeftNode);
- var sectionTopDiv = new Element("div.sectionTopDiv", {
- "styles": this.css.sectionTopDiv
- }).inject(sectionLeftContent);
- var sectionTopInfor= new Element("div.sectionTopInfor", {
- "styles": this.css.sectionTopInfor,
- "text" : this.lp.subject + ":" + this.sectionData.subjectTotal + "," + this.lp.replyCount + ":" + this.sectionData.replyTotal
- }).inject(sectionTopDiv);
- var sectionLeftDiv = new Element("div.sectionLeftDiv", {
- "styles": this.css.sectionLeftDiv
- }).inject(sectionLeftContent);
- var sectionLeftMemo = new Element("div.sectionLeftMemo", {
- "styles": this.css.sectionLeftMemo,
- "text" : this.sectionData.sectionDescription
- }).inject(sectionLeftDiv);
- sectionTopDiv = new Element("div.sectionTopDiv", {
- "styles": this.css.sectionTopDiv
- }).inject(sectionLeftContent);
- sectionTopInfor= new Element("div.sectionTopInfor", {
- "styles": this.css.sectionTopInfor,
- "text" : this.lp.moderatorNames + ":"
- }).inject(sectionTopDiv);
- sectionTopInfor= new Element("div.sectionTopInfor", {
- "styles": this.css.sectionTopInfor
- }).inject(sectionTopDiv);
- this.createPersonNode( sectionTopInfor, this.sectionData.moderatorNames );
- },
- createNoteNode : function(){
- if( !this.sectionData.sectionNotice || this.sectionData.sectionNotice.trim() =="" ){
- return;
- }
- var noteNode = this.noteNode = new Element("div.noteNode", {
- "styles": this.css.noteNode
- }).inject(this.middleNode);
- var noteTopNode = new Element("div.noteTopNode", {
- "styles": this.css.noteTopNode
- }).inject(noteNode);
- var noteTopContent = new Element("div.noteTopContent", {
- "styles": this.css.noteTopContent
- }).inject(noteTopNode);
- var noteIcon = new Element("div.noteIcon", {
- "styles": this.css.noteIcon
- }).inject(noteTopContent);
- var noteTopText = new Element("div.noteTopText", {
- "styles": this.css.noteTopText,
- "text" : this.lp.sectionNotice
- }).inject(noteTopContent);
- var noteContent = new Element("div.noteContent", {
- "styles": this.css.noteContent,
- "html" : this.sectionData.sectionNotice
- }).inject(noteNode);
- if( this.status && this.status.noteHidden ){
- noteNode.setStyle("display" , "none");
- }
- },
- _createMiddleNode : function(){
- this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.middleNode);
- if( this.contentDiv )this.contentDiv.empty();
- if( this.explorer ){
- this.explorer.destroy();
- delete this.explorer;
- }
- this.explorer = new MWF.xApplication.ForumSection.Explorer(this.contentDiv, this, this,{
- style:this.options.style,
- viewPageNum : ( this.status && this.status.viewPageNum ) ? this.status.viewPageNum : 1
- });
- this.explorer.load();
- },
- setContentSize: function () {
- //var topSize = this.topNode ? this.topNode.getSize() : {"x": 0, "y": 0};
- var topSize = {"x": 0, "y": 0};
- var nodeSize = this.content.getSize();
- var pt = this.contentContainerNode.getStyle("padding-top").toFloat();
- var pb = this.contentContainerNode.getStyle("padding-bottom").toFloat();
- var height = nodeSize.y - topSize.y - pt - pb;
- this.contentContainerNode.setStyle("height", "" + height + "px");
- },
- // openLoginForm : function(){
- // //MWF.xDesktop.requireApp("Forum", "Login", null, false);
- // //var login = new MWF.xApplication.Forum.Login(this, {
- // // onPostOk : function(){
- // // window.location.reload();
- // // }
- // //});
- // //login.openLoginForm();
- // MWF.require("MWF.xDesktop.Authentication", null, false);
- // var authentication = new MWF.xDesktop.Authentication({
- // style : "application",
- // onPostOk : function(){
- // window.location.reload();
- // }
- // },this);
- // authentication.openLoginForm({
- // hasMask : true
- // });
- // },
- // openSignUpForm : function(){
- // //MWF.xDesktop.requireApp("Forum", "Login", null, false);
- // //var login = new MWF.xApplication.Forum.Login(this, {});
- // //login.openSignUpForm();
- // MWF.require("MWF.xDesktop.Authentication", null, false);
- // var authentication = new MWF.xDesktop.Authentication( {
- // style : "application",
- // onPostOk : function(){
- // }
- // }, this);
- // authentication.openSignUpForm({
- // hasMask : true
- // });
- // },
- openLoginForm : function(){
- MWF.require("MWF.xDesktop.Authentication", null, false);
- var authentication = new MWF.xDesktop.Authentication({
- "style" : "flat",
- "popupStyle_password": "o2platformSignupFlat",
- onPostOk : function(){
- window.location.reload();
- }
- },this);
- authentication.popupOptions = {
- "draggable": true,
- "closeAction": true,
- "hasMask": true,
- "relativeToApp": true,
- "width": "420",
- "height": "640"
- };
- // authentication.loadLogin(this.app.content);
- authentication.openLoginForm();
- },
- openSignUpForm : function(){
- MWF.require("MWF.xDesktop.Authentication", null, false);
- var authentication = new MWF.xDesktop.Authentication( {
- style : "flat",
- "popupStyle_password": "o2platformSignupFlat",
- onPostOk : function(){
- }
- }, this);
- authentication.popupOptions = {
- "draggable": true,
- "closeAction": true,
- "hasMask": true,
- "relativeToApp": true,
- "width": "420",
- "height": "640"
- };
- authentication.openSignUpForm();
- },
- recordStatus: function(){
- return {
- sectionId : this.options.sectionId,
- viewPageNum : this.explorer.view.getCurrentPageNum(),
- noteHidden : this.noteNodeHidden
- };
- },
- openPerson : function( userName, data ){
- if( !userName || userName == "" ){
- }else{
- MWFForum.openPersonCenter( userName, data );
- }
- },
- createPersonNode : function( container, personName ){
- var persons = typeOf( personName ) === "string" ? personName.split(",") : personName;
- persons.each( function(userName, i){
- if( !userName )return;
- Promise.resolve( MWFForum.getDisplayName( userName ) ).then(function (name) {
- var span = new Element("span", {
- "text" : name.split("@")[0],
- "styles" : this.css.person
- }).inject(container);
- span.addEvents( {
- mouseover : function(){ this.node.setStyles( this.obj.css.person_over )}.bind( {node:span, obj:this} ),
- mouseout : function(){ this.node.setStyles( this.obj.css.person )}.bind( {node:span, obj:this} ),
- click : function(){ this.obj.openPerson( this.userName ) }.bind( {userName:userName, obj:this} )
- });
- if( i != persons.length - 1 ){
- new Element("span", {
- "text" : "、"
- }).inject(container);
- }
- }.bind(this))
- }.bind(this))
- },
- destroy : function(){
- this.clearContent();
- },
- clearContent: function () {
- if (this.explorer)this.explorer.destroy();
- if(this.setContentSizeFun)this.removeEvent("resize", this.setContentSizeFun );
- if(this.scrollBar && this.scrollBar.scrollVAreaNode)this.scrollBar.scrollVAreaNode.destroy();
- if( this.scrollBar )delete this.scrollBar;
- if (this.contentContainerNode) {
- this.contentContainerNode.destroy();
- //this.middleNode.destroy();
- //this.contentNode.destroy();
- }
- }
- });
- MWF.xApplication.ForumSection.Explorer = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "viewPageNum" : 1
- },
- initialize: function (container, app, parent, options) {
- this.setOptions( options );
- this.container = container;
- this.parent = parent;
- this.app = app;
- this.css = this.parent.css;
- this.lp = this.app.lp;
- },
- load: function () {
- this.container.empty();
- this.loadToolbar();
- this.viewContainerTop = Element("div",{
- "styles" : this.css.viewContainerTop
- }).inject(this.container);
- this.viewContainer = Element("div",{
- "styles" : this.css.viewContainer
- }).inject(this.container);
- this.viewContainerPrime = Element("div",{
- "styles" : this.css.viewContainer
- }).inject(this.container);
- this.viewContainerType = Element("div",{
- "styles" : this.css.viewContainer
- }).inject(this.container);
- this.loadToolbar();
- //this.loadTopView();
- this.loadView();
- },
- destroy : function(){
- if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
- this.view.destroy();
- if( this.view.refreshInterval ){
- clearInterval( this.view.refreshInterval );
- }
- },
- loadToolbar: function(){
- var toolbar = new Element("div",{
- styles : this.css.toolbar
- }).inject(this.container);
- if( this.toolbarTop ){
- this.toolbarBottom = toolbar;
- }else{
- this.toolbarTop = toolbar;
- }
- //if( this.parent.access.isSubjectPublisher( this.parent.sectionData ) ){
- if( this.app.sectionPermission.subjectPublishAble && !MWFForum.isSubjectMuted()){
- var createActionNode = new Element("div",{
- styles : this.css.toolbarActionNode,
- text: this.lp.createSubject
- }).inject(toolbar);
- createActionNode.addEvents(
- {
- "mouseover": function () {
- this.node.setStyles(this.obj.css.toolbarActionNode_over);
- }.bind({obj: this, node: createActionNode}),
- "mouseout": function () {
- this.node.setStyles(this.obj.css.toolbarActionNode);
- }.bind({obj: this, node: createActionNode}),
- "click": function () {
- if( this.app.access.isAnonymousDynamic() ){
- this.app.openLoginForm(
- function(){ this.createSubject(); }.bind(this)
- );
- }else{
- this.createSubject();
- }
- }.bind(this)
- }
- )
- }
- var fileterNode = new Element("div",{
- styles : this.css.fileterNode
- }).inject(toolbar);
- var pagingBar = new Element("div",{
- styles : this.css.fileterNode
- }).inject(toolbar);
- if( this.pagingBarTop ){
- this.pagingBarBottom = pagingBar;
- }else{
- this.pagingBarTop = pagingBar;
- }
- },
- loadView : function(){
- this.view = new MWF.xApplication.ForumSection.View( this.viewContainer, this.app, this, {
- templateUrl : this.parent.path+"listItem.json",
- pagingEnable : true,
- onPostCreateViewBody : function(){
- this.app.fireEvent("postCreateViewBody");
- }.bind(this),
- pagingPar : {
- hasReturn : !this.app.naviMode,
- currentPage : this.options.viewPageNum,
- countPerPage : 30,
- onPostLoad : function( pagingBar ){
- if(pagingBar.nextPageNode){
- pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
- }
- }.bind(this),
- onPageReturn : function( pagingBar ){
- var appId = "Forum";
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "Forum", { "appId": appId });
- }
- this.app.close();
- }.bind(this)
- }
- } );
- this.view.filterData = { sectionId : this.app.sectionData.id , withTopSubject : true };
- this.view.pagingContainerTop = this.pagingBarTop;
- this.view.pagingContainerBottom = this.pagingBarBottom;
- this.view.load();
- },
- reloadView : function() {
- if( this.viewPrime )this.viewPrime.destroy();
- if( this.viewType )this.viewType.destroy();
- this.viewContainer.setStyle("display","");
- this.viewContainerTop.setStyle("display","");
- this.viewContainerPrime.setStyle("display","none");
- this.viewContainerType.setStyle("display","none");
- //this.loadTopView();
- this.loadView();
- },
- loadPrimeView : function(){
- if( this.view )this.view.destroy();
- if( this.viewTop )this.viewTop.destroy();
- if( this.viewType )this.viewType.destroy();
- this.viewContainer.setStyle("display","none");
- this.viewContainerTop.setStyle("display","none");
- this.viewContainerPrime.setStyle("display","");
- this.viewContainerType.setStyle("display","none");
- this.viewPrime = new MWF.xApplication.ForumSection.PrimeView( this.viewContainerPrime, this.app, this, {
- templateUrl : this.parent.path+"listItemPrime.json",
- pagingEnable : true,
- pagingPar : {
- hasReturn : !this.app.naviMode,
- currentPage : 1,
- countPerPage : 30,
- onPostLoad : function( pagingBar ){
- if(pagingBar.nextPageNode){
- pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
- }
- }.bind(this),
- onPageReturn : function( pagingBar ){
- var appId = "Forum";
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "Forum", { "appId": appId });
- }
- this.app.close();
- }.bind(this)
- }
- } );
- this.viewPrime.filterData = { sectionId : this.app.sectionData.id };
- this.viewPrime.pagingContainerTop = this.pagingBarTop;
- this.viewPrime.pagingContainerBottom = this.pagingBarBottom;
- this.viewPrime.load();
- },
- loadTypeView : function(){
- debugger;
- if( this.view )this.view.destroy();
- if( this.viewTop )this.viewTop.destroy();
- if( this.viewPrime )this.viewPrime.destroy();
- this.viewContainer.setStyle("display","none");
- this.viewContainerTop.setStyle("display","none");
- this.viewContainerType.setStyle("display","");
- this.viewContainerPrime.setStyle("display","none");
- this.viewType = new MWF.xApplication.ForumSection.TypeView( this.viewContainerType, this.app, this, {
- templateUrl : this.parent.path+"listItemType.json",
- pagingEnable : true,
- pagingPar : {
- hasReturn : !this.app.naviMode,
- currentPage : 1,
- countPerPage : 30,
- onPostLoad : function( pagingBar ){
- if(pagingBar.nextPageNode){
- pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
- }
- }.bind(this),
- onPageReturn : function( pagingBar ){
- var appId = "Forum";
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "Forum", { "appId": appId });
- }
- this.app.close();
- }.bind(this)
- }
- } );
- this.viewType.filterData = { sectionId : this.app.sectionData.id ,sectionName:this.app.sectionData.sectionName,subjectType:"",withTopSubject:true};
- this.viewType.pagingContainerTop = this.pagingBarTop;
- this.viewType.pagingContainerBottom = this.pagingBarBottom;
- this.viewType.load();
- this.loadSelectType();
- },
- reloadTypeView : function(typeName){
- debugger;
- if( this.view )this.view.destroy();
- if( this.viewTop )this.viewTop.destroy();
- if( this.viewPrime )this.viewPrime.destroy();
- if( this.viewType )this.viewType.destroy();
- this.viewContainer.setStyle("display","none");
- this.viewContainerTop.setStyle("display","none");
- this.viewContainerType.setStyle("display","");
- this.viewContainerPrime.setStyle("display","none");
- this.viewType = new MWF.xApplication.ForumSection.TypeView( this.viewContainerType, this.app, this, {
- templateUrl : this.parent.path+"listItemType.json",
- pagingEnable : true,
- pagingPar : {
- hasReturn : !this.app.naviMode,
- currentPage : 1,
- countPerPage : 30,
- onPostLoad : function( pagingBar ){
- if(pagingBar.nextPageNode){
- pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
- }
- }.bind(this),
- onPageReturn : function( pagingBar ){
- var appId = "Forum";
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "Forum", { "appId": appId });
- }
- this.app.close();
- }.bind(this)
- }
- } );
- debugger;
- this.viewType.filterData = { sectionId : this.app.sectionData.id ,sectionName:this.app.sectionData.sectionName,subjectType:typeName,withTopSubject:true};
- this.viewType.pagingContainerTop = this.pagingBarTop;
- this.viewType.pagingContainerBottom = this.pagingBarBottom;
- this.viewType.load();
- this.loadSelectType();
- },
- loadSelectType : function(){
- var _self = this;
- debugger;
- var selectNode = this.viewType.node.getElements("[lable='select']")[0];
- var select = new Element("select",{
- "name" : "type"
- }).inject(selectNode);
- var subjectTypeName = "";
- if((this.viewType.filterData.subjectType) && this.viewType.filterData.subjectType!="请选择主题类别"){
- subjectTypeName = this.viewType.filterData.subjectType;
- }
- var selectNotice = this.lp.selectSubjectType;
- var optiondefault = new Element("option",{
- "value" : selectNotice,
- "text" : selectNotice
- }).inject(select);
- var subjectTypeList = (this.app.sectionData.subjectType || "").split("|"); //this.app.sectionData.subjectTypeList;
- subjectTypeList.each( function(subjectType, i){
- if( !subjectType )return;
- if(subjectTypeName!="" && subjectTypeName==subjectType){
- var option = new Element("option",{
- "value" : subjectType,
- "text" : subjectType,
- "selected":true
- }).inject(select);
- }else{
- var option = new Element("option",{
- "value" : subjectType,
- "text" : subjectType
- }).inject(select);
- }
- }.bind(this));
- select.addEvent("change", function(){
- debugger;
- _self.reloadTypeView(this.value);
- });
- },
- resizeWindow: function(){
- var size = this.app.content.getSize();
- this.viewContainer.setStyles({"height":(size.y-121)+"px"});
- },
- createSubject: function(){
- var _self = this;
- var appId = "ForumDocument"+this.app.sectionData.id;
- if (_self.app.desktop.apps[appId]){
- _self.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId": this.app.sectionData.id,
- "appId": appId,
- "isNew" : true,
- "isEdited" : true,
- "onPostPublish" : function(){
- //this.view.reload();
- }.bind(this)
- });
- }
- }
- });
- MWF.xApplication.ForumSection.TopView = new Class({
- Extends: MWF.xApplication.Template.Explorer.ComplexView,
- _createDocument: function(data, index){
- return new MWF.xApplication.ForumSection.TopDocument(this.viewNode, data, this.explorer, this, null, index);
- },
- _getCurrentPageData: function(callback, count){
- if (!count)count = 30;
- //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
- var filter = this.filterData || {};
- //page, count, filterData, success,failure, async
- if( !this.page ){
- this.page = 1;
- }else{
- this.page ++;
- }
- this.actions.listTopSubject( this.app.sectionData.id, function (json) {
- if( !json.data )json.data = [];
- if (callback)callback(json);
- }.bind(this))
- },
- _removeDocument: function(documentData, all){
- this.actions.deleteSubject(documentData.id, function(json){
- this.reload();
- this.app.reloadAllParents();
- this.app.notice(this.app.lp.deleteDocumentOK, "success");
- }.bind(this));
- },
- _create: function(){
- },
- _openDocument: function( documentData,index ){
- var appId = "ForumDocument"+documentData.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId" : documentData.sectionId,
- "id" : documentData.id,
- "appId": appId,
- "isEdited" : false,
- "isNew" : false,
- "index" : index
- });
- }
- },
- _queryCreateViewNode: function(){
- },
- _postCreateViewNode: function( viewNode ){
- },
- _queryCreateViewHead:function(){
- },
- _postCreateViewHead: function( headNode ){
- /*var primeNode = headNode.getElements("[lable='prime']")[0];
- primeNode.addEvent( "click", function(){
- this.explorer.loadPrimeView();
- }.bind(this));
- var typeNode = headNode.getElements("[lable='sType']")[0];
- typeNode.addEvent( "click", function(){
- this.explorer.loadTypeView();
- }.bind(this));*/
- }
- });
- MWF.xApplication.ForumSection.TopDocument = new Class({
- Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
- _queryCreateDocumentNode:function( itemData ){
- },
- _postCreateDocumentNode: function( itemNode, itemData ){
- },
- open: function (e) {
- this.view._openDocument(this.data, this.index);
- },
- edit : function(){
- var appId = "ForumDocument"+this.data.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId" : this.data.sectionId,
- "id" : this.data.id,
- "appId": appId,
- "isEdited" : true,
- "isNew" : false,
- "index" : this.index
- });
- }
- }
- });
- MWF.xApplication.ForumSection.View = new Class({
- Extends: MWF.xApplication.Template.Explorer.ComplexView,
- refreshNewSubject : function(){
- if (this.refreshTr)this.refreshTr.destroy();
- if( this.refreshInterval ){
- clearInterval( this.refreshInterval );
- }
- this.refreshInterval = setInterval( function(){
- this.actions.listSubjectFilterPage( 1, 1, this.filterData || {}, function(json){
- if( !json.count )json.count=0;
- var count = this.laterRefreshCount || this.dataCount;
- if( json.count > count ) {
- this.laterRefreshCount = json.count;
- this.createRefreshTr( json.count );
- }
- }.bind(this))
- }.bind(this), 10 * 60 * 1000 )
- },
- createRefreshTr : function( newCount ){
- if (this.refreshTr)this.refreshTr.destroy();
- var refreshTr = this.refreshTr = new Element( "tr.refreshTrNode" , {
- styles : this.css.refreshTrNode
- }).inject( this.headNode, "after" );
- var td = this.refreshTd = new Element( "td.refreshTdNode", {
- width : "60%",
- styles : this.css.refreshTdNode
- }).inject( refreshTr );
- var refreshNode = new Element("div" , {
- styles : this.css.refreshNode,
- text : this.lp.newSubjectPublishedText.replace( "{count}", newCount - this.dataCount )
- }).inject(td);
- refreshNode.addEvent("click", function(){
- this.gotoPage(1)
- }.bind(this));
- var td = new Element( "td.refreshTdNode", {
- styles : this.css.refreshTdNode,
- width : "12%"
- }).inject( refreshTr );
- var td = new Element( "td.refreshTdNode", {
- styles : this.css.refreshTdNode,
- width : "7%"
- }).inject( refreshTr );
- var td = new Element( "td.refreshTdNode", {
- styles : this.css.refreshTdNode,
- width : "7%"
- }).inject( refreshTr );
- var td = new Element( "td.refreshTdNode", {
- styles : this.css.refreshTdNode,
- width : "14%"
- }).inject( refreshTr )
- },
- _createDocument: function(data, index){
- return new MWF.xApplication.ForumSection.Document(this.viewNode, data, this.explorer, this, null, index);
- },
- _getCurrentPageData: function(callback, count, pageNum){
- this.clearBody();
- if(!count)count=30;
- if(!pageNum)pageNum = 1;
- //if( pageNum == 1 ){
- // this.explorer.viewContainerTop.setStyle("display","block");
- // this.headNode.setStyle("display","none");
- //}else{
- // this.explorer.viewContainerTop.setStyle("display","none");
- // this.headNode.setStyle("display","");
- //}
- if( this.topSepTr )this.topSepTr.destroy();
- var filter = this.filterData || {};
- //filter.withTopSubject = false;
- this.actions.listSubjectFilterPage( pageNum, count, filter, function(json){
- if( !json.data )json.data = [];
- if( !json.count )json.count=0;
- this.refreshNewSubject();
- if( callback )callback(json);
- }.bind(this))
- },
- _removeDocument: function(documentData, all){
- this.actions.deleteSubject(documentData.id, function(json){
- this.reload();
- this.app.reloadAllParents();
- this.app.notice(this.app.lp.deleteDocumentOK, "success");
- }.bind(this));
- },
- _create: function(){
- },
- _openDocument: function( documentData,index ){
- var appId = "ForumDocument"+documentData.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId" : documentData.sectionId,
- "id" : documentData.id,
- "appId": appId,
- "isEdited" : false,
- "isNew" : false,
- "index" : index
- });
- }
- },
- _queryCreateViewNode: function(){
- },
- _postCreateViewNode: function( viewNode ){
- },
- _queryCreateViewHead:function(){
- },
- _postCreateViewHead: function( headNode ){
- var primeNode = headNode.getElements("[lable='prime']")[0];
- primeNode.addEvent( "click", function(){
- this.explorer.loadPrimeView();
- }.bind(this));
- var typeNode = headNode.getElements("[lable='sType']")[0];
- typeNode.addEvent( "click", function(){
- debugger;
- this.explorer.loadTypeView();
- }.bind(this));
- }
- });
- MWF.xApplication.ForumSection.Document = new Class({
- Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
- _queryCreateDocumentNode:function( itemData ){
- },
- _postCreateDocumentNode: function( itemNode, itemData ){
- //置顶帖和一般帖之间添加分割线
- if( this.index != 1 && !itemData.isTopSubject ){
- var prev = this.view.items[this.index-1];
- if( prev && prev.data.isTopSubject ){
- var tr = this.view.topSepTr = new Element( "tr" , {styles: this.css.documentNode_empty } ).inject( itemNode, "before" );
- new Element( "td", {colspan:5}).inject( tr )
- }
- }
- },
- open: function (e) {
- this.view._openDocument(this.data, this.index);
- },
- edit : function(){
- var appId = "ForumDocument"+this.data.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId" : this.data.sectionId,
- "id" : this.data.id,
- "appId": appId,
- "isEdited" : true,
- "isNew" : false,
- "index" : this.index
- });
- }
- }
- });
- MWF.xApplication.ForumSection.PrimeView = new Class({
- Extends: MWF.xApplication.Template.Explorer.ComplexView,
- _createDocument: function(data, index){
- return new MWF.xApplication.ForumSection.TypeDocument(this.viewNode, data, this.explorer, this, null, index);
- },
- _getCurrentPageData: function(callback, count, pageNum){
- this.clearBody();
- if(!count)count=30;
- if(!pageNum)pageNum = 1;
- var filter = this.filterData || {};
- this.actions.listCreamSubjectFilterPage( pageNum, count, filter, function(json){
- if( !json.data )json.data = [];
- if( !json.count )json.count=0;
- if( callback )callback(json);
- }.bind(this))
- },
- _removeDocument: function(documentData, all){
- this.actions.deleteSubject(documentData.id, function(json){
- this.reload();
- this.app.reloadAllParents();
- this.app.notice(this.app.lp.deleteDocumentOK, "success");
- }.bind(this));
- },
- _create: function(){
- },
- _openDocument: function( documentData,index ){
- var appId = "ForumDocument"+documentData.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId" : documentData.sectionId,
- "id" : documentData.id,
- "appId": appId,
- "isEdited" : false,
- "isNew" : false,
- "index" : index
- });
- }
- },
- _queryCreateViewNode: function(){
- },
- _postCreateViewNode: function( viewNode ){
- },
- _queryCreateViewHead:function(){
- },
- _postCreateViewHead: function( headNode ){
- var allSubjectNode = headNode.getElements("[lable='allSubject']")[0];
- allSubjectNode.addEvent( "click", function(){
- this.explorer.reloadView();
- }.bind(this));
- debugger;
- var typeNode = headNode.getElements("[lable='sType']")[0];
- typeNode.addEvent( "click", function(){
- this.explorer.loadTypeView();
- }.bind(this));
- }
- });
- MWF.xApplication.ForumSection.TypeView = new Class({
- Extends: MWF.xApplication.Template.Explorer.ComplexView,
- _createDocument: function(data, index){
- debugger;
- return new MWF.xApplication.ForumSection.TypeDocument(this.viewNode, data, this.explorer, this, null, index);
- },
- _getCurrentPageData: function(callback, count, pageNum){
- this.clearBody();
- if(!count)count=30;
- if(!pageNum)pageNum = 1;
- var filter = this.filterData || {};
- debugger;
- if(this.filterData.subjectType!="" && this.filterData.subjectType!=this.app.lp.selectSubjectType){
- this.actions.listSubjectWithSubjectTypeForPage( pageNum, count, filter, function(json){
- if( !json.data )json.data = [];
- if( !json.count )json.count=0;
- if( callback )callback(json);
- }.bind(this))
- }else{
- this.actions.listSubjectFilterPage( pageNum, count, filter, function(json){
- if( !json.data )json.data = [];
- if( !json.count )json.count=0;
- if( callback )callback(json);
- }.bind(this))
- }
- },
- _removeDocument: function(documentData, all){
- this.actions.deleteSubject(documentData.id, function(json){
- this.reload();
- this.app.reloadAllParents();
- this.app.notice(this.app.lp.deleteDocumentOK, "success");
- }.bind(this));
- },
- _create: function(){
- },
- _openDocument: function( documentData,index ){
- var appId = "ForumDocument"+documentData.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId" : documentData.sectionId,
- "id" : documentData.id,
- "appId": appId,
- "isEdited" : false,
- "isNew" : false,
- "index" : index
- });
- }
- },
- _queryCreateViewNode: function(){
- },
- _postCreateViewNode: function( viewNode ){
- },
- _queryCreateViewHead:function(){
- },
- _postCreateViewHead: function( headNode ){
- var allSubjectNode = headNode.getElements("[lable='allSubject']")[0];
- allSubjectNode.addEvent( "click", function(){
- this.explorer.reloadView();
- }.bind(this));
- var primeNode = headNode.getElements("[lable='prime']")[0];
- primeNode.addEvent( "click", function(){
- this.explorer.loadPrimeView();
- }.bind(this));
- }
- });
- MWF.xApplication.ForumSection.PrimeDocument = new Class({
- Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
- _queryCreateDocumentNode:function( itemData ){
- },
- _postCreateDocumentNode: function( itemNode, itemData ){
- },
- open: function (e) {
- this.view._openDocument(this.data, this.index);
- },
- edit : function(){
- var appId = "ForumDocument"+this.data.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId" : this.data.sectionId,
- "id" : this.data.id,
- "appId": appId,
- "isEdited" : true,
- "isNew" : false,
- "index" : this.index
- });
- }
- }
- });
- MWF.xApplication.ForumSection.TypeDocument = new Class({
- Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
- _queryCreateDocumentNode:function( itemData ){
- },
- _postCreateDocumentNode: function( itemNode, itemData ){
- },
- open: function (e) {
- this.view._openDocument(this.data, this.index);
- },
- edit : function(){
- var appId = "ForumDocument"+this.data.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "sectionId" : this.data.sectionId,
- "id" : this.data.id,
- "appId": appId,
- "isEdited" : true,
- "isNew" : false,
- "index" : this.index
- });
- }
- }
- });
|