Main.js 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. MWF.xApplication.ForumSection = MWF.xApplication.ForumSection || {};
  3. MWF.require("MWF.widget.O2Identity", null,false);
  4. MWF.xDesktop.requireApp("Forum", "Common", null, false);
  5. //MWF.xDesktop.requireApp("Forum", "Actions.RestActions", null, false);
  6. MWF.xDesktop.requireApp("Forum", "lp."+MWF.language, null, false);
  7. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  8. MWF.xDesktop.requireApp("Forum", "Access", null, false);
  9. MWF.xDesktop.requireApp("Forum", "TopNode", null, false);
  10. MWF.xApplication.ForumSection.options = {
  11. multitask: true,
  12. executable: true
  13. };
  14. MWF.xApplication.ForumSection.Main = new Class({
  15. Extends: MWF.xApplication.Common.Main,
  16. Implements: [Options, Events],
  17. options: {
  18. "style": "default",
  19. "name": "ForumSection",
  20. "icon": "icon.png",
  21. "width": "1230",
  22. "height": "700",
  23. "isResize": true,
  24. "isMax": true,
  25. "title": MWF.xApplication.ForumSection.LP.title,
  26. "hasTop" : true,
  27. "naviMode" : false,
  28. "hasBreadCrumb" : true,
  29. "autoWidth" : false,
  30. "sectionId" : ""
  31. },
  32. onQueryLoad: function(){
  33. this.lp = MWF.xApplication.Forum.LP;
  34. },
  35. onQueryClose : function(){
  36. this.clearContent();
  37. },
  38. loadApplication: function(callback){
  39. this.userName = layout.desktop.session.user.distinguishedName;
  40. this.restActions = MWF.Actions.get("x_bbs_assemble_control"); //new MWF.xApplication.Forum.Actions.RestActions();
  41. this.path = "../x_component_ForumSection/$Main/"+this.options.style+"/";
  42. this.createNode();
  43. this.loadApplicationContent();
  44. },
  45. loadController: function(callback){
  46. this.access = new MWF.xApplication.Forum.Access( this.restActions, this.lp );
  47. if(callback)callback();
  48. },
  49. createNode: function(){
  50. this.content.setStyle("overflow", "hidden");
  51. this.node = new Element("div", {
  52. "styles": this.css.node
  53. }).inject(this.content);
  54. },
  55. clearContent: function(){
  56. this.node.empty();
  57. },
  58. loadApplicationContent: function(){
  59. if( !this.options.sectionId && this.status && this.status.sectionId ){
  60. this.options.sectionId = this.status.sectionId;
  61. }
  62. this.loadController(function(){
  63. this.access.login( function () {
  64. this.loadApplicationLayout();
  65. }.bind(this))
  66. }.bind(this))
  67. },
  68. reloadAllParents : function(){
  69. var aid = "Forum";
  70. if (this.desktop.apps[aid] && this.desktop.apps[aid].reload){
  71. this.desktop.apps[aid].reload();
  72. }
  73. aid = "ForumCategory"+this.sectionData.forumId;
  74. if (this.desktop.apps[aid] && this.desktop.apps[aid].reload){
  75. this.desktop.apps[aid].reload();
  76. }
  77. },
  78. reload : function(){
  79. this.status = {
  80. sectionId : this.options.sectionId,
  81. viewPageNum : this.explorer.view.getCurrentPageNum(),
  82. noteHidden : this.noteNodeHidden
  83. };
  84. this.clearContent();
  85. this.contentContainerNode = new Element("div.contentContainerNode", {
  86. "styles": this.options.autoWidth ? this.css.contentContainerNode_inContainer : this.css.contentContainerNode
  87. }).inject(this.node);
  88. this.createTopNode();
  89. this.createMiddleNode();
  90. },
  91. loadApplicationLayout : function(){
  92. this.contentContainerNode = new Element("div.contentContainerNode", {
  93. "styles": this.options.autoWidth ? this.css.contentContainerNode_inContainer : this.css.contentContainerNode
  94. }).inject(this.node);
  95. if( this.options.sectionId ){
  96. this.restActions.listSectionPermission( this.options.sectionId, function( permission ){
  97. this.sectionPermission = permission.data;
  98. this.isAdmin = this.sectionPermission.subjectManageAble;
  99. this.restActions.getSection( this.options.sectionId, function( json ){
  100. this.sectionData = json.data;
  101. //this.access.hasSectionAdminAuthority( this.sectionData, function( flag ){
  102. //this.isAdmin = flag;
  103. var tail = (this.inBrowser && layout.desktop.session.user.name !== "anonymous") ? (MWFForum.getSystemConfigValue( MWFForum.BBS_TITLE_TAIL ) || "") : "";
  104. this.setTitle( this.sectionData.sectionName + tail );
  105. this.createTopNode();
  106. this.createMiddleNode();
  107. //}.bind(this) );
  108. }.bind(this) )
  109. }.bind(this) )
  110. }else{
  111. this.close()
  112. }
  113. },
  114. loadTopObject : function(naviMode){
  115. if( this.options.hasTop ){
  116. var node = this.topObject = new MWF.xApplication.Forum.TopNode(this.contentContainerNode, this, this, {
  117. type: this.options.style,
  118. naviModeEnable : true,
  119. naviMode : naviMode
  120. });
  121. node.load();
  122. }
  123. },
  124. createTopNode: function(){
  125. this.loadTopObject( false );
  126. if( this.options.hasBreadCrumb ){
  127. var topNode = this.topNode = new Element("div.topNode", {
  128. "styles": this.options.autoWidth ? this.css.topNode_inContainer : this.css.topNode
  129. }).inject(this.contentContainerNode);
  130. //topNode.setStyle("border-bottom","1px solid "+forumColor);
  131. var topTitleMiddleNode = this.breadCrumbNode = new Element("div.topTitleMiddleNode", {
  132. "styles": this.css.topTitleMiddleNode
  133. }).inject(topNode);
  134. //topTitleMiddleNode.setStyle( "background-color" , forumColor )
  135. var topItemTitleNode = new Element("div.topItemTitleNode", {
  136. "styles": this.css.topItemTitleNode,
  137. "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
  138. }).inject(topTitleMiddleNode);
  139. topItemTitleNode.addEvent("click", function(){
  140. if( this.options.naviMode && this.forumNavi ){
  141. this.forumNavi.goto( MWFForum.NaviType.main )
  142. }else{
  143. var appId = "Forum";
  144. if (this.desktop.apps[appId]){
  145. this.desktop.apps[appId].setCurrent();
  146. }else {
  147. this.desktop.openApplication(null, "Forum", { "appId": appId });
  148. }
  149. this.close();
  150. }
  151. }.bind(this));
  152. var topItemSepNode = new Element("div.topItemSepNode", {
  153. "styles": this.css.topItemSepNode,
  154. "text" : ">"
  155. }).inject(topTitleMiddleNode);
  156. var topItemTitleNode = new Element("div.topItemTitleNode", {
  157. "styles": this.css.topItemTitleNode,
  158. "text": this.sectionData.forumName
  159. }).inject(topTitleMiddleNode);
  160. topItemTitleNode.addEvent("click", function(){
  161. if( this.obj.options.naviMode && this.obj.forumNavi ){
  162. this.obj.forumNavi.goto( MWFForum.NaviType.category, this.forumId )
  163. }else{
  164. var appId = "ForumCategory"+this.forumId;
  165. if (this.obj.desktop.apps[appId]){
  166. this.obj.desktop.apps[appId].setCurrent();
  167. }else {
  168. this.obj.desktop.openApplication(null, "ForumCategory", { "categoryId" : this.forumId ,"appId": appId });
  169. }
  170. if( !this.obj.inBrowser ){
  171. this.obj.close();
  172. }
  173. }
  174. }.bind({ obj: this, forumId : this.sectionData.forumId }));
  175. topItemSepNode = new Element("div.topItemSepNode", {
  176. "styles": this.css.topItemSepNode,
  177. "text" : ">"
  178. }).inject(topTitleMiddleNode);
  179. topItemTitleNode = new Element("div.topItemTitleNode", {
  180. "styles": this.css.topItemTitleLastNode,
  181. "text": this.sectionData.sectionName
  182. }).inject(topTitleMiddleNode);
  183. }
  184. if( this.sectionData.sectionNotice ){
  185. var topRightNode = new Element("div", {
  186. "styles": this.css.topRightNode
  187. }).inject(topNode);
  188. topRightNode.addEvents({
  189. "click" :function(){
  190. if( !this.noteNodeHidden ){
  191. this.noteNode.setStyle("display","none");
  192. this.topRightIconNode.setStyles(this.css.topRightIconDownNode);
  193. this.noteNodeHidden = true;
  194. }else{
  195. this.noteNode.setStyle("display","");
  196. this.topRightIconNode.setStyles(this.css.topRightIconNode);
  197. this.noteNodeHidden = false;
  198. }
  199. }.bind(this)
  200. });
  201. var topRightIconNode = this.topRightIconNode = new Element("div", {
  202. "styles": this.css.topRightIconNode
  203. }).inject(topRightNode);
  204. if( this.status && this.status.noteHidden ){
  205. this.topRightIconNode.setStyles(this.css.topRightIconDownNode);
  206. this.noteNodeHidden = true;
  207. }
  208. }
  209. },
  210. createMiddleNode: function(){
  211. this.middleNode = new Element("div.middleNode", {
  212. "styles": this.options.autoWidth ? this.css.middleNode_inContainer : this.css.middleNode
  213. }).inject(this.contentContainerNode);
  214. this.createSectionNode();
  215. this.createNoteNode();
  216. this._createMiddleNode();
  217. if( !this.options.naviMode ){
  218. this.addEvent("resize", function () {
  219. this.setContentSize();
  220. }.bind(this));
  221. this.setContentSize();
  222. }
  223. //MWF.require("MWF.widget.ScrollBar", function () {
  224. // new MWF.widget.ScrollBar(this.contentContainerNode, {
  225. // "indent": false,
  226. // "style": "xApp_TaskList",
  227. // "where": "before",
  228. // "distance": 30,
  229. // "friction": 4,
  230. // "axis": {"x": false, "y": true},
  231. // "onScroll": function (y) {
  232. // }
  233. // });
  234. //}.bind(this));
  235. },
  236. openNavi: function () {
  237. MWF.xDesktop.requireApp("Forum", "NaviMode", null, false);
  238. this.clearContent();
  239. this.contentContainerNode = new Element("div.contentContainerNode", {
  240. "styles": this.css.contentContainerNode
  241. }).inject(this.node);
  242. this.loadTopObject( true );
  243. this.middleNode = new Element("div.middleNode", {
  244. "styles": this.css.middleNode
  245. }).inject(this.contentContainerNode);
  246. this.contentNode = new Element("div.contentNode", {
  247. "styles": this.css.contentNode
  248. }).inject(this.middleNode);
  249. this.navi = new MWF.xApplication.Forum.NaviMode(this, this.contentNode, {
  250. type : MWFForum.NaviType.section,
  251. id : this.sectionData.id
  252. });
  253. this.navi.load();
  254. },
  255. closeNavi : function(){
  256. if( this.navi )this.navi.close();
  257. },
  258. colorRgba : function( color, opacity ){ /*16进制颜色转为RGB格式*/
  259. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  260. var sColor = color.toLowerCase();
  261. if(sColor && reg.test(sColor)){
  262. if(sColor.length === 4){
  263. var sColorNew = "#";
  264. for(var i=1; i<4; i+=1){
  265. sColorNew += sColor.slice(i,i+1).concat(sColor.slice(i,i+1));
  266. }
  267. sColor = sColorNew;
  268. }
  269. //处理六位的颜色值
  270. var sColorChange = [];
  271. for(var i=1; i<7; i+=2){
  272. sColorChange.push(parseInt("0x"+sColor.slice(i,i+2)));
  273. }
  274. return "rgba(" + sColorChange.join(",") + "," + opacity + ")";
  275. }else{
  276. return sColor;
  277. }
  278. },
  279. createSectionNode: function(){
  280. var forumColor = MWF.xApplication.Forum.ForumSetting[this.sectionData.forumId].forumColor;
  281. var sectionNode = new Element("div.sectionNode", {
  282. "styles": this.options.autoWidth ? this.css.sectionNode_inContainer : this.css.sectionNode
  283. }).inject(this.middleNode);
  284. sectionNode.setStyle("background-color", this.colorRgba( forumColor, "0.05" ));
  285. var sectionLeftNode = new Element("div.sectionLeftNode", {
  286. "styles": this.css.sectionLeftNode
  287. }).inject(sectionNode);
  288. var sectionLeftIconNode = new Element("div.sectionLeftIconNode", {
  289. "styles": this.css.sectionLeftIconNode
  290. }).inject(sectionLeftNode);
  291. var sectionLeftIcon = new Element("img", {
  292. "styles": this.css.sectionLeftIcon,
  293. "src" : this.sectionData.icon ? ('data:image/png;base64,'+ this.sectionData.icon) : "../x_component_Forum/$Setting/default/sectionIcon/forum_icon.png"
  294. }).inject(sectionLeftIconNode);
  295. var sectionLeftContent = new Element("div.sectionLeftContent", {
  296. "styles": this.css.sectionLeftContent
  297. }).inject(sectionLeftNode);
  298. var sectionTopDiv = new Element("div.sectionTopDiv", {
  299. "styles": this.css.sectionTopDiv
  300. }).inject(sectionLeftContent);
  301. var sectionTopInfor= new Element("div.sectionTopInfor", {
  302. "styles": this.css.sectionTopInfor,
  303. "text" : this.lp.subject + ":" + this.sectionData.subjectTotal + "," + this.lp.replyCount + ":" + this.sectionData.replyTotal
  304. }).inject(sectionTopDiv);
  305. var sectionLeftDiv = new Element("div.sectionLeftDiv", {
  306. "styles": this.css.sectionLeftDiv
  307. }).inject(sectionLeftContent);
  308. var sectionLeftMemo = new Element("div.sectionLeftMemo", {
  309. "styles": this.css.sectionLeftMemo,
  310. "text" : this.sectionData.sectionDescription
  311. }).inject(sectionLeftDiv);
  312. sectionTopDiv = new Element("div.sectionTopDiv", {
  313. "styles": this.css.sectionTopDiv
  314. }).inject(sectionLeftContent);
  315. sectionTopInfor= new Element("div.sectionTopInfor", {
  316. "styles": this.css.sectionTopInfor,
  317. "text" : this.lp.moderatorNames + ":"
  318. }).inject(sectionTopDiv);
  319. sectionTopInfor= new Element("div.sectionTopInfor", {
  320. "styles": this.css.sectionTopInfor
  321. }).inject(sectionTopDiv);
  322. this.createPersonNode( sectionTopInfor, this.sectionData.moderatorNames );
  323. },
  324. createNoteNode : function(){
  325. if( !this.sectionData.sectionNotice || this.sectionData.sectionNotice.trim() =="" ){
  326. return;
  327. }
  328. var noteNode = this.noteNode = new Element("div.noteNode", {
  329. "styles": this.css.noteNode
  330. }).inject(this.middleNode);
  331. var noteTopNode = new Element("div.noteTopNode", {
  332. "styles": this.css.noteTopNode
  333. }).inject(noteNode);
  334. var noteTopContent = new Element("div.noteTopContent", {
  335. "styles": this.css.noteTopContent
  336. }).inject(noteTopNode);
  337. var noteIcon = new Element("div.noteIcon", {
  338. "styles": this.css.noteIcon
  339. }).inject(noteTopContent);
  340. var noteTopText = new Element("div.noteTopText", {
  341. "styles": this.css.noteTopText,
  342. "text" : this.lp.sectionNotice
  343. }).inject(noteTopContent);
  344. var noteContent = new Element("div.noteContent", {
  345. "styles": this.css.noteContent,
  346. "html" : this.sectionData.sectionNotice
  347. }).inject(noteNode);
  348. if( this.status && this.status.noteHidden ){
  349. noteNode.setStyle("display" , "none");
  350. }
  351. },
  352. _createMiddleNode : function(){
  353. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.middleNode);
  354. if( this.contentDiv )this.contentDiv.empty();
  355. if( this.explorer ){
  356. this.explorer.destroy();
  357. delete this.explorer;
  358. }
  359. this.explorer = new MWF.xApplication.ForumSection.Explorer(this.contentDiv, this, this,{
  360. style:this.options.style,
  361. viewPageNum : ( this.status && this.status.viewPageNum ) ? this.status.viewPageNum : 1
  362. });
  363. this.explorer.load();
  364. },
  365. setContentSize: function () {
  366. //var topSize = this.topNode ? this.topNode.getSize() : {"x": 0, "y": 0};
  367. var topSize = {"x": 0, "y": 0};
  368. var nodeSize = this.content.getSize();
  369. var pt = this.contentContainerNode.getStyle("padding-top").toFloat();
  370. var pb = this.contentContainerNode.getStyle("padding-bottom").toFloat();
  371. var height = nodeSize.y - topSize.y - pt - pb;
  372. this.contentContainerNode.setStyle("height", "" + height + "px");
  373. },
  374. // openLoginForm : function(){
  375. // //MWF.xDesktop.requireApp("Forum", "Login", null, false);
  376. // //var login = new MWF.xApplication.Forum.Login(this, {
  377. // // onPostOk : function(){
  378. // // window.location.reload();
  379. // // }
  380. // //});
  381. // //login.openLoginForm();
  382. // MWF.require("MWF.xDesktop.Authentication", null, false);
  383. // var authentication = new MWF.xDesktop.Authentication({
  384. // style : "application",
  385. // onPostOk : function(){
  386. // window.location.reload();
  387. // }
  388. // },this);
  389. // authentication.openLoginForm({
  390. // hasMask : true
  391. // });
  392. // },
  393. // openSignUpForm : function(){
  394. // //MWF.xDesktop.requireApp("Forum", "Login", null, false);
  395. // //var login = new MWF.xApplication.Forum.Login(this, {});
  396. // //login.openSignUpForm();
  397. // MWF.require("MWF.xDesktop.Authentication", null, false);
  398. // var authentication = new MWF.xDesktop.Authentication( {
  399. // style : "application",
  400. // onPostOk : function(){
  401. // }
  402. // }, this);
  403. // authentication.openSignUpForm({
  404. // hasMask : true
  405. // });
  406. // },
  407. openLoginForm : function(){
  408. MWF.require("MWF.xDesktop.Authentication", null, false);
  409. var authentication = new MWF.xDesktop.Authentication({
  410. "style" : "flat",
  411. "popupStyle_password": "o2platformSignupFlat",
  412. onPostOk : function(){
  413. window.location.reload();
  414. }
  415. },this);
  416. authentication.popupOptions = {
  417. "draggable": true,
  418. "closeAction": true,
  419. "hasMask": true,
  420. "relativeToApp": true,
  421. "width": "420",
  422. "height": "640"
  423. };
  424. // authentication.loadLogin(this.app.content);
  425. authentication.openLoginForm();
  426. },
  427. openSignUpForm : function(){
  428. MWF.require("MWF.xDesktop.Authentication", null, false);
  429. var authentication = new MWF.xDesktop.Authentication( {
  430. style : "flat",
  431. "popupStyle_password": "o2platformSignupFlat",
  432. onPostOk : function(){
  433. }
  434. }, this);
  435. authentication.popupOptions = {
  436. "draggable": true,
  437. "closeAction": true,
  438. "hasMask": true,
  439. "relativeToApp": true,
  440. "width": "420",
  441. "height": "640"
  442. };
  443. authentication.openSignUpForm();
  444. },
  445. recordStatus: function(){
  446. return {
  447. sectionId : this.options.sectionId,
  448. viewPageNum : this.explorer.view.getCurrentPageNum(),
  449. noteHidden : this.noteNodeHidden
  450. };
  451. },
  452. openPerson : function( userName, data ){
  453. if( !userName || userName == "" ){
  454. }else{
  455. MWFForum.openPersonCenter( userName, data );
  456. }
  457. },
  458. createPersonNode : function( container, personName ){
  459. var persons = typeOf( personName ) === "string" ? personName.split(",") : personName;
  460. persons.each( function(userName, i){
  461. if( !userName )return;
  462. Promise.resolve( MWFForum.getDisplayName( userName ) ).then(function (name) {
  463. var span = new Element("span", {
  464. "text" : name.split("@")[0],
  465. "styles" : this.css.person
  466. }).inject(container);
  467. span.addEvents( {
  468. mouseover : function(){ this.node.setStyles( this.obj.css.person_over )}.bind( {node:span, obj:this} ),
  469. mouseout : function(){ this.node.setStyles( this.obj.css.person )}.bind( {node:span, obj:this} ),
  470. click : function(){ this.obj.openPerson( this.userName ) }.bind( {userName:userName, obj:this} )
  471. });
  472. if( i != persons.length - 1 ){
  473. new Element("span", {
  474. "text" : "、"
  475. }).inject(container);
  476. }
  477. }.bind(this))
  478. }.bind(this))
  479. },
  480. destroy : function(){
  481. this.clearContent();
  482. },
  483. clearContent: function () {
  484. if (this.explorer)this.explorer.destroy();
  485. if(this.setContentSizeFun)this.removeEvent("resize", this.setContentSizeFun );
  486. if(this.scrollBar && this.scrollBar.scrollVAreaNode)this.scrollBar.scrollVAreaNode.destroy();
  487. if( this.scrollBar )delete this.scrollBar;
  488. if (this.contentContainerNode) {
  489. this.contentContainerNode.destroy();
  490. //this.middleNode.destroy();
  491. //this.contentNode.destroy();
  492. }
  493. }
  494. });
  495. MWF.xApplication.ForumSection.Explorer = new Class({
  496. Extends: MWF.widget.Common,
  497. Implements: [Options, Events],
  498. options: {
  499. "style": "default",
  500. "viewPageNum" : 1
  501. },
  502. initialize: function (container, app, parent, options) {
  503. this.setOptions( options );
  504. this.container = container;
  505. this.parent = parent;
  506. this.app = app;
  507. this.css = this.parent.css;
  508. this.lp = this.app.lp;
  509. },
  510. load: function () {
  511. this.container.empty();
  512. this.loadToolbar();
  513. this.viewContainerTop = Element("div",{
  514. "styles" : this.css.viewContainerTop
  515. }).inject(this.container);
  516. this.viewContainer = Element("div",{
  517. "styles" : this.css.viewContainer
  518. }).inject(this.container);
  519. this.viewContainerPrime = Element("div",{
  520. "styles" : this.css.viewContainer
  521. }).inject(this.container);
  522. this.viewContainerType = Element("div",{
  523. "styles" : this.css.viewContainer
  524. }).inject(this.container);
  525. this.loadToolbar();
  526. //this.loadTopView();
  527. this.loadView();
  528. },
  529. destroy : function(){
  530. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  531. this.view.destroy();
  532. if( this.view.refreshInterval ){
  533. clearInterval( this.view.refreshInterval );
  534. }
  535. },
  536. loadToolbar: function(){
  537. var toolbar = new Element("div",{
  538. styles : this.css.toolbar
  539. }).inject(this.container);
  540. if( this.toolbarTop ){
  541. this.toolbarBottom = toolbar;
  542. }else{
  543. this.toolbarTop = toolbar;
  544. }
  545. //if( this.parent.access.isSubjectPublisher( this.parent.sectionData ) ){
  546. if( this.app.sectionPermission.subjectPublishAble && !MWFForum.isSubjectMuted()){
  547. var createActionNode = new Element("div",{
  548. styles : this.css.toolbarActionNode,
  549. text: this.lp.createSubject
  550. }).inject(toolbar);
  551. createActionNode.addEvents(
  552. {
  553. "mouseover": function () {
  554. this.node.setStyles(this.obj.css.toolbarActionNode_over);
  555. }.bind({obj: this, node: createActionNode}),
  556. "mouseout": function () {
  557. this.node.setStyles(this.obj.css.toolbarActionNode);
  558. }.bind({obj: this, node: createActionNode}),
  559. "click": function () {
  560. if( this.app.access.isAnonymousDynamic() ){
  561. this.app.openLoginForm(
  562. function(){ this.createSubject(); }.bind(this)
  563. );
  564. }else{
  565. this.createSubject();
  566. }
  567. }.bind(this)
  568. }
  569. )
  570. }
  571. var fileterNode = new Element("div",{
  572. styles : this.css.fileterNode
  573. }).inject(toolbar);
  574. var pagingBar = new Element("div",{
  575. styles : this.css.fileterNode
  576. }).inject(toolbar);
  577. if( this.pagingBarTop ){
  578. this.pagingBarBottom = pagingBar;
  579. }else{
  580. this.pagingBarTop = pagingBar;
  581. }
  582. },
  583. loadView : function(){
  584. this.view = new MWF.xApplication.ForumSection.View( this.viewContainer, this.app, this, {
  585. templateUrl : this.parent.path+"listItem.json",
  586. pagingEnable : true,
  587. onPostCreateViewBody : function(){
  588. this.app.fireEvent("postCreateViewBody");
  589. }.bind(this),
  590. pagingPar : {
  591. hasReturn : !this.app.naviMode,
  592. currentPage : this.options.viewPageNum,
  593. countPerPage : 30,
  594. onPostLoad : function( pagingBar ){
  595. if(pagingBar.nextPageNode){
  596. pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
  597. }
  598. }.bind(this),
  599. onPageReturn : function( pagingBar ){
  600. var appId = "Forum";
  601. if (this.app.desktop.apps[appId]){
  602. this.app.desktop.apps[appId].setCurrent();
  603. }else {
  604. this.app.desktop.openApplication(null, "Forum", { "appId": appId });
  605. }
  606. this.app.close();
  607. }.bind(this)
  608. }
  609. } );
  610. this.view.filterData = { sectionId : this.app.sectionData.id , withTopSubject : true };
  611. this.view.pagingContainerTop = this.pagingBarTop;
  612. this.view.pagingContainerBottom = this.pagingBarBottom;
  613. this.view.load();
  614. },
  615. reloadView : function() {
  616. if( this.viewPrime )this.viewPrime.destroy();
  617. if( this.viewType )this.viewType.destroy();
  618. this.viewContainer.setStyle("display","");
  619. this.viewContainerTop.setStyle("display","");
  620. this.viewContainerPrime.setStyle("display","none");
  621. this.viewContainerType.setStyle("display","none");
  622. //this.loadTopView();
  623. this.loadView();
  624. },
  625. loadPrimeView : function(){
  626. if( this.view )this.view.destroy();
  627. if( this.viewTop )this.viewTop.destroy();
  628. if( this.viewType )this.viewType.destroy();
  629. this.viewContainer.setStyle("display","none");
  630. this.viewContainerTop.setStyle("display","none");
  631. this.viewContainerPrime.setStyle("display","");
  632. this.viewContainerType.setStyle("display","none");
  633. this.viewPrime = new MWF.xApplication.ForumSection.PrimeView( this.viewContainerPrime, this.app, this, {
  634. templateUrl : this.parent.path+"listItemPrime.json",
  635. pagingEnable : true,
  636. pagingPar : {
  637. hasReturn : !this.app.naviMode,
  638. currentPage : 1,
  639. countPerPage : 30,
  640. onPostLoad : function( pagingBar ){
  641. if(pagingBar.nextPageNode){
  642. pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
  643. }
  644. }.bind(this),
  645. onPageReturn : function( pagingBar ){
  646. var appId = "Forum";
  647. if (this.app.desktop.apps[appId]){
  648. this.app.desktop.apps[appId].setCurrent();
  649. }else {
  650. this.app.desktop.openApplication(null, "Forum", { "appId": appId });
  651. }
  652. this.app.close();
  653. }.bind(this)
  654. }
  655. } );
  656. this.viewPrime.filterData = { sectionId : this.app.sectionData.id };
  657. this.viewPrime.pagingContainerTop = this.pagingBarTop;
  658. this.viewPrime.pagingContainerBottom = this.pagingBarBottom;
  659. this.viewPrime.load();
  660. },
  661. loadTypeView : function(){
  662. debugger;
  663. if( this.view )this.view.destroy();
  664. if( this.viewTop )this.viewTop.destroy();
  665. if( this.viewPrime )this.viewPrime.destroy();
  666. this.viewContainer.setStyle("display","none");
  667. this.viewContainerTop.setStyle("display","none");
  668. this.viewContainerType.setStyle("display","");
  669. this.viewContainerPrime.setStyle("display","none");
  670. this.viewType = new MWF.xApplication.ForumSection.TypeView( this.viewContainerType, this.app, this, {
  671. templateUrl : this.parent.path+"listItemType.json",
  672. pagingEnable : true,
  673. pagingPar : {
  674. hasReturn : !this.app.naviMode,
  675. currentPage : 1,
  676. countPerPage : 30,
  677. onPostLoad : function( pagingBar ){
  678. if(pagingBar.nextPageNode){
  679. pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
  680. }
  681. }.bind(this),
  682. onPageReturn : function( pagingBar ){
  683. var appId = "Forum";
  684. if (this.app.desktop.apps[appId]){
  685. this.app.desktop.apps[appId].setCurrent();
  686. }else {
  687. this.app.desktop.openApplication(null, "Forum", { "appId": appId });
  688. }
  689. this.app.close();
  690. }.bind(this)
  691. }
  692. } );
  693. this.viewType.filterData = { sectionId : this.app.sectionData.id ,sectionName:this.app.sectionData.sectionName,subjectType:"",withTopSubject:true};
  694. this.viewType.pagingContainerTop = this.pagingBarTop;
  695. this.viewType.pagingContainerBottom = this.pagingBarBottom;
  696. this.viewType.load();
  697. this.loadSelectType();
  698. },
  699. reloadTypeView : function(typeName){
  700. debugger;
  701. if( this.view )this.view.destroy();
  702. if( this.viewTop )this.viewTop.destroy();
  703. if( this.viewPrime )this.viewPrime.destroy();
  704. if( this.viewType )this.viewType.destroy();
  705. this.viewContainer.setStyle("display","none");
  706. this.viewContainerTop.setStyle("display","none");
  707. this.viewContainerType.setStyle("display","");
  708. this.viewContainerPrime.setStyle("display","none");
  709. this.viewType = new MWF.xApplication.ForumSection.TypeView( this.viewContainerType, this.app, this, {
  710. templateUrl : this.parent.path+"listItemType.json",
  711. pagingEnable : true,
  712. pagingPar : {
  713. hasReturn : !this.app.naviMode,
  714. currentPage : 1,
  715. countPerPage : 30,
  716. onPostLoad : function( pagingBar ){
  717. if(pagingBar.nextPageNode){
  718. pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
  719. }
  720. }.bind(this),
  721. onPageReturn : function( pagingBar ){
  722. var appId = "Forum";
  723. if (this.app.desktop.apps[appId]){
  724. this.app.desktop.apps[appId].setCurrent();
  725. }else {
  726. this.app.desktop.openApplication(null, "Forum", { "appId": appId });
  727. }
  728. this.app.close();
  729. }.bind(this)
  730. }
  731. } );
  732. debugger;
  733. this.viewType.filterData = { sectionId : this.app.sectionData.id ,sectionName:this.app.sectionData.sectionName,subjectType:typeName,withTopSubject:true};
  734. this.viewType.pagingContainerTop = this.pagingBarTop;
  735. this.viewType.pagingContainerBottom = this.pagingBarBottom;
  736. this.viewType.load();
  737. this.loadSelectType();
  738. },
  739. loadSelectType : function(){
  740. var _self = this;
  741. debugger;
  742. var selectNode = this.viewType.node.getElements("[lable='select']")[0];
  743. var select = new Element("select",{
  744. "name" : "type"
  745. }).inject(selectNode);
  746. var subjectTypeName = "";
  747. if((this.viewType.filterData.subjectType) && this.viewType.filterData.subjectType!="请选择主题类别"){
  748. subjectTypeName = this.viewType.filterData.subjectType;
  749. }
  750. var selectNotice = this.lp.selectSubjectType;
  751. var optiondefault = new Element("option",{
  752. "value" : selectNotice,
  753. "text" : selectNotice
  754. }).inject(select);
  755. var subjectTypeList = (this.app.sectionData.subjectType || "").split("|"); //this.app.sectionData.subjectTypeList;
  756. subjectTypeList.each( function(subjectType, i){
  757. if( !subjectType )return;
  758. if(subjectTypeName!="" && subjectTypeName==subjectType){
  759. var option = new Element("option",{
  760. "value" : subjectType,
  761. "text" : subjectType,
  762. "selected":true
  763. }).inject(select);
  764. }else{
  765. var option = new Element("option",{
  766. "value" : subjectType,
  767. "text" : subjectType
  768. }).inject(select);
  769. }
  770. }.bind(this));
  771. select.addEvent("change", function(){
  772. debugger;
  773. _self.reloadTypeView(this.value);
  774. });
  775. },
  776. resizeWindow: function(){
  777. var size = this.app.content.getSize();
  778. this.viewContainer.setStyles({"height":(size.y-121)+"px"});
  779. },
  780. createSubject: function(){
  781. var _self = this;
  782. var appId = "ForumDocument"+this.app.sectionData.id;
  783. if (_self.app.desktop.apps[appId]){
  784. _self.app.desktop.apps[appId].setCurrent();
  785. }else {
  786. this.app.desktop.openApplication(null, "ForumDocument", {
  787. "sectionId": this.app.sectionData.id,
  788. "appId": appId,
  789. "isNew" : true,
  790. "isEdited" : true,
  791. "onPostPublish" : function(){
  792. //this.view.reload();
  793. }.bind(this)
  794. });
  795. }
  796. }
  797. });
  798. MWF.xApplication.ForumSection.TopView = new Class({
  799. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  800. _createDocument: function(data, index){
  801. return new MWF.xApplication.ForumSection.TopDocument(this.viewNode, data, this.explorer, this, null, index);
  802. },
  803. _getCurrentPageData: function(callback, count){
  804. if (!count)count = 30;
  805. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  806. var filter = this.filterData || {};
  807. //page, count, filterData, success,failure, async
  808. if( !this.page ){
  809. this.page = 1;
  810. }else{
  811. this.page ++;
  812. }
  813. this.actions.listTopSubject( this.app.sectionData.id, function (json) {
  814. if( !json.data )json.data = [];
  815. if (callback)callback(json);
  816. }.bind(this))
  817. },
  818. _removeDocument: function(documentData, all){
  819. this.actions.deleteSubject(documentData.id, function(json){
  820. this.reload();
  821. this.app.reloadAllParents();
  822. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  823. }.bind(this));
  824. },
  825. _create: function(){
  826. },
  827. _openDocument: function( documentData,index ){
  828. var appId = "ForumDocument"+documentData.id;
  829. if (this.app.desktop.apps[appId]){
  830. this.app.desktop.apps[appId].setCurrent();
  831. }else {
  832. this.app.desktop.openApplication(null, "ForumDocument", {
  833. "sectionId" : documentData.sectionId,
  834. "id" : documentData.id,
  835. "appId": appId,
  836. "isEdited" : false,
  837. "isNew" : false,
  838. "index" : index
  839. });
  840. }
  841. },
  842. _queryCreateViewNode: function(){
  843. },
  844. _postCreateViewNode: function( viewNode ){
  845. },
  846. _queryCreateViewHead:function(){
  847. },
  848. _postCreateViewHead: function( headNode ){
  849. /*var primeNode = headNode.getElements("[lable='prime']")[0];
  850. primeNode.addEvent( "click", function(){
  851. this.explorer.loadPrimeView();
  852. }.bind(this));
  853. var typeNode = headNode.getElements("[lable='sType']")[0];
  854. typeNode.addEvent( "click", function(){
  855. this.explorer.loadTypeView();
  856. }.bind(this));*/
  857. }
  858. });
  859. MWF.xApplication.ForumSection.TopDocument = new Class({
  860. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  861. _queryCreateDocumentNode:function( itemData ){
  862. },
  863. _postCreateDocumentNode: function( itemNode, itemData ){
  864. },
  865. open: function (e) {
  866. this.view._openDocument(this.data, this.index);
  867. },
  868. edit : function(){
  869. var appId = "ForumDocument"+this.data.id;
  870. if (this.app.desktop.apps[appId]){
  871. this.app.desktop.apps[appId].setCurrent();
  872. }else {
  873. this.app.desktop.openApplication(null, "ForumDocument", {
  874. "sectionId" : this.data.sectionId,
  875. "id" : this.data.id,
  876. "appId": appId,
  877. "isEdited" : true,
  878. "isNew" : false,
  879. "index" : this.index
  880. });
  881. }
  882. }
  883. });
  884. MWF.xApplication.ForumSection.View = new Class({
  885. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  886. refreshNewSubject : function(){
  887. if (this.refreshTr)this.refreshTr.destroy();
  888. if( this.refreshInterval ){
  889. clearInterval( this.refreshInterval );
  890. }
  891. this.refreshInterval = setInterval( function(){
  892. this.actions.listSubjectFilterPage( 1, 1, this.filterData || {}, function(json){
  893. if( !json.count )json.count=0;
  894. var count = this.laterRefreshCount || this.dataCount;
  895. if( json.count > count ) {
  896. this.laterRefreshCount = json.count;
  897. this.createRefreshTr( json.count );
  898. }
  899. }.bind(this))
  900. }.bind(this), 10 * 60 * 1000 )
  901. },
  902. createRefreshTr : function( newCount ){
  903. if (this.refreshTr)this.refreshTr.destroy();
  904. var refreshTr = this.refreshTr = new Element( "tr.refreshTrNode" , {
  905. styles : this.css.refreshTrNode
  906. }).inject( this.headNode, "after" );
  907. var td = this.refreshTd = new Element( "td.refreshTdNode", {
  908. width : "60%",
  909. styles : this.css.refreshTdNode
  910. }).inject( refreshTr );
  911. var refreshNode = new Element("div" , {
  912. styles : this.css.refreshNode,
  913. text : this.lp.newSubjectPublishedText.replace( "{count}", newCount - this.dataCount )
  914. }).inject(td);
  915. refreshNode.addEvent("click", function(){
  916. this.gotoPage(1)
  917. }.bind(this));
  918. var td = new Element( "td.refreshTdNode", {
  919. styles : this.css.refreshTdNode,
  920. width : "12%"
  921. }).inject( refreshTr );
  922. var td = new Element( "td.refreshTdNode", {
  923. styles : this.css.refreshTdNode,
  924. width : "7%"
  925. }).inject( refreshTr );
  926. var td = new Element( "td.refreshTdNode", {
  927. styles : this.css.refreshTdNode,
  928. width : "7%"
  929. }).inject( refreshTr );
  930. var td = new Element( "td.refreshTdNode", {
  931. styles : this.css.refreshTdNode,
  932. width : "14%"
  933. }).inject( refreshTr )
  934. },
  935. _createDocument: function(data, index){
  936. return new MWF.xApplication.ForumSection.Document(this.viewNode, data, this.explorer, this, null, index);
  937. },
  938. _getCurrentPageData: function(callback, count, pageNum){
  939. this.clearBody();
  940. if(!count)count=30;
  941. if(!pageNum)pageNum = 1;
  942. //if( pageNum == 1 ){
  943. // this.explorer.viewContainerTop.setStyle("display","block");
  944. // this.headNode.setStyle("display","none");
  945. //}else{
  946. // this.explorer.viewContainerTop.setStyle("display","none");
  947. // this.headNode.setStyle("display","");
  948. //}
  949. if( this.topSepTr )this.topSepTr.destroy();
  950. var filter = this.filterData || {};
  951. //filter.withTopSubject = false;
  952. this.actions.listSubjectFilterPage( pageNum, count, filter, function(json){
  953. if( !json.data )json.data = [];
  954. if( !json.count )json.count=0;
  955. this.refreshNewSubject();
  956. if( callback )callback(json);
  957. }.bind(this))
  958. },
  959. _removeDocument: function(documentData, all){
  960. this.actions.deleteSubject(documentData.id, function(json){
  961. this.reload();
  962. this.app.reloadAllParents();
  963. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  964. }.bind(this));
  965. },
  966. _create: function(){
  967. },
  968. _openDocument: function( documentData,index ){
  969. var appId = "ForumDocument"+documentData.id;
  970. if (this.app.desktop.apps[appId]){
  971. this.app.desktop.apps[appId].setCurrent();
  972. }else {
  973. this.app.desktop.openApplication(null, "ForumDocument", {
  974. "sectionId" : documentData.sectionId,
  975. "id" : documentData.id,
  976. "appId": appId,
  977. "isEdited" : false,
  978. "isNew" : false,
  979. "index" : index
  980. });
  981. }
  982. },
  983. _queryCreateViewNode: function(){
  984. },
  985. _postCreateViewNode: function( viewNode ){
  986. },
  987. _queryCreateViewHead:function(){
  988. },
  989. _postCreateViewHead: function( headNode ){
  990. var primeNode = headNode.getElements("[lable='prime']")[0];
  991. primeNode.addEvent( "click", function(){
  992. this.explorer.loadPrimeView();
  993. }.bind(this));
  994. var typeNode = headNode.getElements("[lable='sType']")[0];
  995. typeNode.addEvent( "click", function(){
  996. debugger;
  997. this.explorer.loadTypeView();
  998. }.bind(this));
  999. }
  1000. });
  1001. MWF.xApplication.ForumSection.Document = new Class({
  1002. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1003. _queryCreateDocumentNode:function( itemData ){
  1004. },
  1005. _postCreateDocumentNode: function( itemNode, itemData ){
  1006. //置顶帖和一般帖之间添加分割线
  1007. if( this.index != 1 && !itemData.isTopSubject ){
  1008. var prev = this.view.items[this.index-1];
  1009. if( prev && prev.data.isTopSubject ){
  1010. var tr = this.view.topSepTr = new Element( "tr" , {styles: this.css.documentNode_empty } ).inject( itemNode, "before" );
  1011. new Element( "td", {colspan:5}).inject( tr )
  1012. }
  1013. }
  1014. },
  1015. open: function (e) {
  1016. this.view._openDocument(this.data, this.index);
  1017. },
  1018. edit : function(){
  1019. var appId = "ForumDocument"+this.data.id;
  1020. if (this.app.desktop.apps[appId]){
  1021. this.app.desktop.apps[appId].setCurrent();
  1022. }else {
  1023. this.app.desktop.openApplication(null, "ForumDocument", {
  1024. "sectionId" : this.data.sectionId,
  1025. "id" : this.data.id,
  1026. "appId": appId,
  1027. "isEdited" : true,
  1028. "isNew" : false,
  1029. "index" : this.index
  1030. });
  1031. }
  1032. }
  1033. });
  1034. MWF.xApplication.ForumSection.PrimeView = new Class({
  1035. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1036. _createDocument: function(data, index){
  1037. return new MWF.xApplication.ForumSection.TypeDocument(this.viewNode, data, this.explorer, this, null, index);
  1038. },
  1039. _getCurrentPageData: function(callback, count, pageNum){
  1040. this.clearBody();
  1041. if(!count)count=30;
  1042. if(!pageNum)pageNum = 1;
  1043. var filter = this.filterData || {};
  1044. this.actions.listCreamSubjectFilterPage( pageNum, count, filter, function(json){
  1045. if( !json.data )json.data = [];
  1046. if( !json.count )json.count=0;
  1047. if( callback )callback(json);
  1048. }.bind(this))
  1049. },
  1050. _removeDocument: function(documentData, all){
  1051. this.actions.deleteSubject(documentData.id, function(json){
  1052. this.reload();
  1053. this.app.reloadAllParents();
  1054. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  1055. }.bind(this));
  1056. },
  1057. _create: function(){
  1058. },
  1059. _openDocument: function( documentData,index ){
  1060. var appId = "ForumDocument"+documentData.id;
  1061. if (this.app.desktop.apps[appId]){
  1062. this.app.desktop.apps[appId].setCurrent();
  1063. }else {
  1064. this.app.desktop.openApplication(null, "ForumDocument", {
  1065. "sectionId" : documentData.sectionId,
  1066. "id" : documentData.id,
  1067. "appId": appId,
  1068. "isEdited" : false,
  1069. "isNew" : false,
  1070. "index" : index
  1071. });
  1072. }
  1073. },
  1074. _queryCreateViewNode: function(){
  1075. },
  1076. _postCreateViewNode: function( viewNode ){
  1077. },
  1078. _queryCreateViewHead:function(){
  1079. },
  1080. _postCreateViewHead: function( headNode ){
  1081. var allSubjectNode = headNode.getElements("[lable='allSubject']")[0];
  1082. allSubjectNode.addEvent( "click", function(){
  1083. this.explorer.reloadView();
  1084. }.bind(this));
  1085. debugger;
  1086. var typeNode = headNode.getElements("[lable='sType']")[0];
  1087. typeNode.addEvent( "click", function(){
  1088. this.explorer.loadTypeView();
  1089. }.bind(this));
  1090. }
  1091. });
  1092. MWF.xApplication.ForumSection.TypeView = new Class({
  1093. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1094. _createDocument: function(data, index){
  1095. debugger;
  1096. return new MWF.xApplication.ForumSection.TypeDocument(this.viewNode, data, this.explorer, this, null, index);
  1097. },
  1098. _getCurrentPageData: function(callback, count, pageNum){
  1099. this.clearBody();
  1100. if(!count)count=30;
  1101. if(!pageNum)pageNum = 1;
  1102. var filter = this.filterData || {};
  1103. debugger;
  1104. if(this.filterData.subjectType!="" && this.filterData.subjectType!=this.app.lp.selectSubjectType){
  1105. this.actions.listSubjectWithSubjectTypeForPage( pageNum, count, filter, function(json){
  1106. if( !json.data )json.data = [];
  1107. if( !json.count )json.count=0;
  1108. if( callback )callback(json);
  1109. }.bind(this))
  1110. }else{
  1111. this.actions.listSubjectFilterPage( pageNum, count, filter, function(json){
  1112. if( !json.data )json.data = [];
  1113. if( !json.count )json.count=0;
  1114. if( callback )callback(json);
  1115. }.bind(this))
  1116. }
  1117. },
  1118. _removeDocument: function(documentData, all){
  1119. this.actions.deleteSubject(documentData.id, function(json){
  1120. this.reload();
  1121. this.app.reloadAllParents();
  1122. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  1123. }.bind(this));
  1124. },
  1125. _create: function(){
  1126. },
  1127. _openDocument: function( documentData,index ){
  1128. var appId = "ForumDocument"+documentData.id;
  1129. if (this.app.desktop.apps[appId]){
  1130. this.app.desktop.apps[appId].setCurrent();
  1131. }else {
  1132. this.app.desktop.openApplication(null, "ForumDocument", {
  1133. "sectionId" : documentData.sectionId,
  1134. "id" : documentData.id,
  1135. "appId": appId,
  1136. "isEdited" : false,
  1137. "isNew" : false,
  1138. "index" : index
  1139. });
  1140. }
  1141. },
  1142. _queryCreateViewNode: function(){
  1143. },
  1144. _postCreateViewNode: function( viewNode ){
  1145. },
  1146. _queryCreateViewHead:function(){
  1147. },
  1148. _postCreateViewHead: function( headNode ){
  1149. var allSubjectNode = headNode.getElements("[lable='allSubject']")[0];
  1150. allSubjectNode.addEvent( "click", function(){
  1151. this.explorer.reloadView();
  1152. }.bind(this));
  1153. var primeNode = headNode.getElements("[lable='prime']")[0];
  1154. primeNode.addEvent( "click", function(){
  1155. this.explorer.loadPrimeView();
  1156. }.bind(this));
  1157. }
  1158. });
  1159. MWF.xApplication.ForumSection.PrimeDocument = new Class({
  1160. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1161. _queryCreateDocumentNode:function( itemData ){
  1162. },
  1163. _postCreateDocumentNode: function( itemNode, itemData ){
  1164. },
  1165. open: function (e) {
  1166. this.view._openDocument(this.data, this.index);
  1167. },
  1168. edit : function(){
  1169. var appId = "ForumDocument"+this.data.id;
  1170. if (this.app.desktop.apps[appId]){
  1171. this.app.desktop.apps[appId].setCurrent();
  1172. }else {
  1173. this.app.desktop.openApplication(null, "ForumDocument", {
  1174. "sectionId" : this.data.sectionId,
  1175. "id" : this.data.id,
  1176. "appId": appId,
  1177. "isEdited" : true,
  1178. "isNew" : false,
  1179. "index" : this.index
  1180. });
  1181. }
  1182. }
  1183. });
  1184. MWF.xApplication.ForumSection.TypeDocument = new Class({
  1185. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1186. _queryCreateDocumentNode:function( itemData ){
  1187. },
  1188. _postCreateDocumentNode: function( itemNode, itemData ){
  1189. },
  1190. open: function (e) {
  1191. this.view._openDocument(this.data, this.index);
  1192. },
  1193. edit : function(){
  1194. var appId = "ForumDocument"+this.data.id;
  1195. if (this.app.desktop.apps[appId]){
  1196. this.app.desktop.apps[appId].setCurrent();
  1197. }else {
  1198. this.app.desktop.openApplication(null, "ForumDocument", {
  1199. "sectionId" : this.data.sectionId,
  1200. "id" : this.data.id,
  1201. "appId": appId,
  1202. "isEdited" : true,
  1203. "isNew" : false,
  1204. "index" : this.index
  1205. });
  1206. }
  1207. }
  1208. });