Main.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. MWF.xApplication.ForumPerson = MWF.xApplication.ForumPerson || {};
  3. MWF.require("MWF.widget.O2Identity", null,false);
  4. //MWF.xDesktop.requireApp("Forum", "Actions.RestActions", null, false);
  5. MWF.xDesktop.requireApp("Forum", "Common", 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.ForumPerson.options = {
  11. multitask: true,
  12. executable: true
  13. };
  14. MWF.xApplication.ForumPerson.Main = new Class({
  15. Extends: MWF.xApplication.Common.Main,
  16. Implements: [Options, Events],
  17. options: {
  18. "style": "default",
  19. "name": "ForumPerson",
  20. "icon": "icon.png",
  21. "width": "1230",
  22. "height": "700",
  23. "isResize": false,
  24. "isMax": true,
  25. "title": MWF.xApplication.ForumPerson.LP.title,
  26. "personName" : "",
  27. "p": ""
  28. },
  29. onQueryLoad: function(){
  30. this.lp = MWF.xApplication.Forum.LP;
  31. },
  32. loadApplication: function(callback){
  33. this.userName = layout.desktop.session.user.distinguishedName;
  34. this.restActions = MWF.Actions.get("x_bbs_assemble_control"); //new MWF.xApplication.Forum.Actions.RestActions();
  35. this.path = "../x_component_ForumPerson/$Main/"+this.options.style+"/";
  36. this.createNode();
  37. this.loadApplicationContent();
  38. },
  39. loadController: function(callback){
  40. this.access = new MWF.xApplication.Forum.Access( this.restActions, this.lp );
  41. if(callback)callback();
  42. },
  43. createNode: function(){
  44. this.content.setStyle("overflow", "hidden");
  45. this.node = new Element("div", {
  46. "styles": this.css.node
  47. }).inject(this.content);
  48. },
  49. clearContent: function(){
  50. this.node.empty();
  51. },
  52. loadApplicationContent: function(){
  53. if( !this.options.personName && this.status && this.status.personName ){
  54. this.options.personName = this.status.personName;
  55. }
  56. if( !this.options.p && this.status && this.status.p ){
  57. this.options.p = this.status.p;
  58. }
  59. this.loadController(function(){
  60. this.access.login( function () {
  61. this.getUserData( this.options.personName || this.options.p, function( json ){
  62. this.personData = json.data;
  63. this.options.personName = this.personData.distinguishedName;
  64. this.isCurrentUser = this.userName == this.options.personName;
  65. var name = MWFForum.isUseNickName() ? this.personData.nickName : this.options.personName;
  66. this.personNameAbbreviate = (name || this.options.personName).split('@')[0];
  67. var tail = (this.inBrowser && layout.desktop.session.user.name !== "anonymous") ? (MWFForum.getSystemConfigValue( MWFForum.BBS_TITLE_TAIL ) || "") : "";
  68. this.setTitle( this.personNameAbbreviate + tail );
  69. this.loadApplicationLayout();
  70. }.bind(this) )
  71. }.bind(this))
  72. }.bind(this))
  73. },
  74. getUserData : function( name, callback ){
  75. if( this.access.isAnonymous() ){
  76. var url = MWF.Actions.get("x_organization_assemble_personal").getIcon(name);
  77. if( callback )callback( { data : {
  78. icon : url,
  79. genderType : "m",
  80. signature : ""
  81. } } );
  82. //MWF.Actions.get("x_organization_assemble_control").getPersonIcon(name, function(url){
  83. // if( callback )callback( { data : {
  84. // icon : url,
  85. // genderType : "m",
  86. // signature : ""
  87. // } } );
  88. //})
  89. }else{
  90. MWF.Actions.get("x_organization_assemble_control").getPerson( function( json ){
  91. if( !json.data.signature )json.data.signature="";
  92. var url = MWF.Actions.get("x_organization_assemble_personal").getIcon(name);
  93. if( url ){
  94. if( json.data ){
  95. json.data.icon = url;
  96. if( callback )callback( json );
  97. }
  98. }else{
  99. if( json.data ){
  100. json.data.icon = "../x_component_ForumDocument/$Main/"+this.options.style+"/icon/noavatar_big.gif";
  101. if( callback )callback( json );
  102. }
  103. }
  104. //MWF.Actions.get("x_organization_assemble_control").getPersonIcon(name, function(url){
  105. // if( json.data ){
  106. // json.data.icon = url;
  107. // if( callback )callback( json );
  108. // }
  109. //}.bind(this), function(){
  110. // if( json.data ){
  111. // json.data.icon = "../x_component_ForumDocument/$Main/"+this.options.style+"/icon/noavatar_big.gif";
  112. // if( callback )callback( json );
  113. // }
  114. //});
  115. //if( callback )callback( json );
  116. }.bind(this), null, name, true )
  117. }
  118. },
  119. loadApplicationLayout : function(){
  120. this.contentContainerNode = new Element("div.contentContainerNode", {
  121. "styles": this.css.contentContainerNode
  122. }).inject(this.node);
  123. this.createTopNode();
  124. this.createMiddleNode();
  125. },
  126. reloadAllParents : function( sectionId ){
  127. this.restActions.getSection( sectionId, function( json ){
  128. var aid = "Forum";
  129. if (this.desktop.apps[aid] && this.desktop.apps[aid].reload ){
  130. this.desktop.apps[aid].reload();
  131. }
  132. aid = "ForumCategory"+json.data.forumId;
  133. if (this.desktop.apps[aid] && this.desktop.apps[aid].reload){
  134. this.desktop.apps[aid].reload();
  135. }
  136. aid = "ForumSection"+sectionId;
  137. if (this.desktop.apps[aid] && this.desktop.apps[aid].reload){
  138. this.desktop.apps[aid].reload();
  139. }
  140. }.bind(this) )
  141. },
  142. createTopNode: function(){
  143. var node = new MWF.xApplication.Forum.TopNode(this.contentContainerNode, this, this, {
  144. type: this.options.style,
  145. logoutEnable : false
  146. });
  147. node.load();
  148. var forumColor = this.lp.defaultForumColor;
  149. var topNode = this.topNode = new Element("div.topNode", {
  150. "styles": this.css.topNode
  151. }).inject(this.contentContainerNode);
  152. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  153. "styles": this.css.topTitleMiddleNode
  154. }).inject(topNode);
  155. var topItemTitleNode = new Element("div.topItemTitleNode", {
  156. "styles": this.css.topItemTitleNode,
  157. "text": this.lp.title
  158. }).inject(topTitleMiddleNode);
  159. topItemTitleNode.addEvent("click", function(){
  160. var appId = "Forum";
  161. if (this.desktop.apps[appId]){
  162. this.desktop.apps[appId].setCurrent();
  163. }else {
  164. this.desktop.openApplication(null, "Forum", { "appId": appId });
  165. }
  166. if( !this.inBrowser ){
  167. this.close();
  168. }
  169. //this.close();
  170. }.bind(this));
  171. var topItemSepNode = new Element("div.topItemSepNode", {
  172. "styles": this.css.topItemSepNode,
  173. "text" : ">"
  174. }).inject(topTitleMiddleNode);
  175. var topItemTitleNode = new Element("div.topItemTitleNode", {
  176. "styles": this.css.topItemTitleLastNode,
  177. "text": this.lp.personCenter + ":"+ this.personNameAbbreviate
  178. }).inject(topTitleMiddleNode);
  179. },
  180. createMiddleNode: function(){
  181. this.middleNode = new Element("div.middleNode", {
  182. "styles": this.css.middleNode
  183. }).inject(this.contentContainerNode);
  184. this.createPersonNode();
  185. this._createMiddleNode();
  186. this.addEvent("resize", function () {
  187. this.setContentSize();
  188. }.bind(this));
  189. this.setContentSize();
  190. //MWF.require("MWF.widget.ScrollBar", function () {
  191. // new MWF.widget.ScrollBar(this.contentContainerNode, {
  192. // "indent": false,
  193. // "style": "xApp_TaskList",
  194. // "where": "before",
  195. // "distance": 30,
  196. // "friction": 4,
  197. // "axis": {"x": false, "y": true},
  198. // "onScroll": function (y) {
  199. // }
  200. // });
  201. //}.bind(this));
  202. },
  203. createPersonNode: function(){
  204. var personNode = new Element("div.personNode", {
  205. "styles": this.css.personNode
  206. }).inject(this.middleNode);
  207. this.restActions.getUserInfor( {"userName":this.options.personName}, function( json ){
  208. var userInfor = this.userInfor = json.data;
  209. var personLeftNode = new Element("div.personLeftNode", {
  210. "styles": this.css.personLeftNode
  211. }).inject(personNode);
  212. var personLeftIconNode = new Element("div.personLeftIconNode", {
  213. "styles": this.css.personLeftIconNode
  214. }).inject(personLeftNode);
  215. var personLeftIcon = new Element("img", {
  216. "styles": this.css.personLeftIcon,
  217. "src" : this.personData.icon
  218. }).inject(personLeftIconNode);
  219. var personLeftContent = new Element("div.personLeftContent", {
  220. "styles": this.css.personLeftContent
  221. }).inject(personLeftNode);
  222. var personTopDiv = new Element("div.personTopDiv", {
  223. "styles": this.css.personTopDiv
  224. }).inject(personLeftContent);
  225. var personTopInfor= new Element("div.personTopInfor", {
  226. "styles": this.css.personTopInfor,
  227. "text" : this.personNameAbbreviate
  228. }).inject(personTopDiv);
  229. if( !this.access.isAnonymous() ){
  230. if( this.isCurrentUser ){
  231. var actionNode = new Element("input", {
  232. "type" : "button",
  233. "styles": this.css.personSettingAction,
  234. "value" : this.lp.changePersonSetting
  235. }).inject(personTopDiv);
  236. actionNode.addEvent("click", function(){
  237. var appId = "Profile";
  238. if (this.desktop.apps[appId]){
  239. this.desktop.apps[appId].setCurrent();
  240. }else {
  241. this.desktop.openApplication(null, "Profile", {
  242. });
  243. }
  244. }.bind(this))
  245. }else{
  246. // var actionNode = new Element("input", {
  247. // "type" : "button",
  248. // "styles": this.css.personSettingAction,
  249. // "value" : this.lp.sendMessage
  250. // }).inject(personTopDiv);
  251. // actionNode.addEvent("click", function(e){
  252. // if (layout.desktop.widgets["IMIMWidget"]) {
  253. // var IM = layout.desktop.widgets["IMIMWidget"];
  254. // var name = this.options.personName;
  255. // IM.getOwner(function(){
  256. // this.openChat(e, {
  257. // from : name
  258. // });
  259. // }.bind(IM));
  260. // }
  261. // }.bind(this))
  262. }
  263. }
  264. var personLeftDiv = new Element("div.personLeftDiv", {
  265. "styles": this.css.personLeftDiv,
  266. "text" : this.lp.subject + ":" + userInfor.subjectCount + "," + this.lp.replyCount + ":" + userInfor.replyCount + "," + //this.lp.accessed + ":" + userInfor.popularity + "," +
  267. this.lp.prime + ":" + userInfor.creamCount + "," + this.lp.todaySubject + ":" + userInfor.subjectCountToday + "," + this.lp.todayReply + ":" + userInfor.replyCountToday
  268. }).inject(personLeftContent);
  269. //var personLeftMemo = new Element("div.personLeftMemo", {
  270. // "styles": this.css.personLeftMemo,
  271. // "text" : this.personData.personDescription
  272. //}).inject(personLeftDiv)
  273. var personLeftDiv = new Element("div.personLeftDiv", {
  274. "styles": this.css.personLeftDiv,
  275. "text" : this.lp.signature + ":" + this.personData.signature
  276. //"text" : this.lp.mail + ":" + this.personData.mail + "," + this.lp.mobile + ":" + this.personData.mobile + "," + "QQ" + ":" + this.personData.qq + "," + this.lp.weixin + ":" + this.personData.weixin
  277. }).inject(personLeftContent)
  278. }.bind(this))
  279. },
  280. _createMiddleNode : function(){
  281. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.middleNode);
  282. if( this.contentDiv )this.contentDiv.empty();
  283. if( this.explorer ){
  284. this.explorer.destroy();
  285. delete this.explorer;
  286. }
  287. this.explorer = new MWF.xApplication.ForumPerson.Explorer(this.contentDiv, this, this,{
  288. style:this.options.style,
  289. type : ( this.status && this.status.type ) ? this.status.type : "subject",
  290. viewPageNum : ( this.status && this.status.viewPageNum ) ? this.status.viewPageNum : 1
  291. });
  292. this.explorer.load();
  293. },
  294. openPerson : function( userName, data ){
  295. if( !userName || userName == "" ){
  296. }else{
  297. MWFForum.openPersonCenter( userName, data );
  298. }
  299. },
  300. setContentSize: function () {
  301. //var topSize = this.topNode ? this.topNode.getSize() : {"x": 0, "y": 0};
  302. var topSize = {"x": 0, "y": 0};
  303. var nodeSize = this.node.getSize();
  304. var pt = this.contentContainerNode.getStyle("padding-top").toFloat();
  305. var pb = this.contentContainerNode.getStyle("padding-bottom").toFloat();
  306. var height = nodeSize.y - topSize.y - pt - pb;
  307. this.contentContainerNode.setStyle("height", "" + height + "px");
  308. },
  309. recordStatus: function(){
  310. debugger;
  311. if( this.options.p ){
  312. if( this.explorer && this.explorer.options ){
  313. return {
  314. type : this.explorer.options.type,
  315. p : this.options.p,
  316. viewPageNum : this.explorer.view.getCurrentPageNum()
  317. };
  318. }else{
  319. return {
  320. p : this.options.p
  321. }
  322. }
  323. }else{
  324. if( this.explorer && this.explorer.options ) {
  325. return {
  326. type: this.explorer.options.type,
  327. personName: this.options.personName,
  328. viewPageNum: this.explorer.view.getCurrentPageNum()
  329. };
  330. }else{
  331. return {
  332. personName: this.options.personName
  333. };
  334. }
  335. }
  336. }
  337. });
  338. MWF.xApplication.ForumPerson.Explorer = new Class({
  339. Extends: MWF.widget.Common,
  340. Implements: [Options, Events],
  341. options: {
  342. "style": "default",
  343. "type" : "subject",
  344. "viewPageNum" : 1
  345. },
  346. initialize: function (container, app, parent, options) {
  347. this.setOptions( options );
  348. this.container = container;
  349. this.parent = parent;
  350. this.app = app;
  351. this.css = this.parent.css;
  352. this.lp = this.app.lp;
  353. },
  354. load: function () {
  355. this.container.empty();
  356. this.loadToolbar();
  357. this.viewContainer = Element("div",{
  358. "styles" : this.css.viewContainer
  359. }).inject(this.container);
  360. this.loadToolbar();
  361. if( this.options.type == "subject" ){
  362. this.loadSubjectView();
  363. }else{
  364. this.loadReplyView();
  365. }
  366. },
  367. destroy : function(){
  368. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  369. this.view.destroy();
  370. },
  371. loadToolbar: function(){
  372. var toolbar = new Element("div",{
  373. styles : this.css.toolbar
  374. }).inject(this.container);
  375. if( !this.toolbarTop ){
  376. if( this.app.isCurrentUser ){
  377. this.toolbarLeft = new Element("div.toolbarLeft",{
  378. "styles" : this.css.toolbarLeft
  379. }).inject( toolbar );
  380. this.mySubjectNode = new Element("div.toolbarLeftItem",{
  381. "styles" : this.css.toolbarLeftItem,
  382. "text" : this.lp.mySubject
  383. }).inject( this.toolbarLeft );
  384. this.mySubjectNode.addEvents({
  385. "mouseover" : function(){
  386. if(this.currentNaviNode!=this.mySubjectNode)this.mySubjectNode.setStyles( this.css.toolbarLeftItem_over );
  387. }.bind(this),
  388. "mouseout" : function(){
  389. if(this.currentNaviNode!=this.mySubjectNode)this.mySubjectNode.setStyles( this.css.toolbarLeftItem );
  390. }.bind(this),
  391. "click" : function(){
  392. this.options.type = "subject";
  393. if(this.currentNaviNode)this.currentNaviNode.setStyles( this.css.toolbarLeftItem );
  394. this.currentNaviNode = this.mySubjectNode;
  395. this.mySubjectNode.setStyles( this.css.toolbarLeftItem_current );
  396. this.loadSubjectView();
  397. }.bind(this)
  398. });
  399. this.myReplyNode = new Element("div.toolbarLeftItem",{
  400. "styles" : this.css.toolbarLeftItem,
  401. "text" : this.lp.myReply
  402. }).inject( this.toolbarLeft );
  403. this.myReplyNode.addEvents({
  404. "mouseover" : function(){
  405. if(this.currentNaviNode!=this.myReplyNode)this.myReplyNode.setStyles( this.css.toolbarLeftItem_over );
  406. }.bind(this),
  407. "mouseout" : function(){
  408. if(this.currentNaviNode!=this.myReplyNode)this.myReplyNode.setStyles( this.css.toolbarLeftItem );
  409. }.bind(this),
  410. "click" : function(){
  411. this.options.type = "reply";
  412. if(this.currentNaviNode)this.currentNaviNode.setStyles( this.css.toolbarLeftItem );
  413. this.currentNaviNode = this.myReplyNode;
  414. this.myReplyNode.setStyles( this.css.toolbarLeftItem_current );
  415. this.loadReplyView();
  416. }.bind(this)
  417. });
  418. if( this.options.type == "reply"){
  419. this.myReplyNode.setStyles( this.css.toolbarLeftItem_current );
  420. this.currentNaviNode = this.myReplyNode;
  421. }else{
  422. this.mySubjectNode.setStyles( this.css.toolbarLeftItem_current );
  423. this.currentNaviNode = this.mySubjectNode;
  424. }
  425. }else{
  426. this.toolbarLeft = new Element("div.toolbarLeft",{
  427. "styles" : this.css.toolbarLeft
  428. }).inject( toolbar );
  429. this.mySubjectNode = new Element("div.toolbarLeftItem",{
  430. "styles" : this.css.toolbarLeftItem,
  431. "text" : ( this.app.personData.genderType || "" ).toLowerCase() == "f" ? this.lp.herSubject : this.lp.hisSubject
  432. }).inject( this.toolbarLeft );
  433. this.mySubjectNode.setStyles( this.css.toolbarLeftItem_current );
  434. this.mySubjectNode.setStyle("cursor","default");
  435. }
  436. }
  437. if( this.toolbarTop ){
  438. this.toolbarBottom = toolbar;
  439. }else{
  440. this.toolbarTop = toolbar;
  441. }
  442. var pagingBar = new Element("div",{
  443. styles : this.css.fileterNode
  444. }).inject(toolbar);
  445. if( this.pagingBarTop ){
  446. this.pagingBarBottom = pagingBar;
  447. }else{
  448. this.pagingBarTop = pagingBar;
  449. }
  450. },
  451. loadSubjectView : function(){
  452. if( this.view )this.view.destroy();
  453. this.view = new MWF.xApplication.ForumPerson.SubjectView( this.viewContainer, this.app, this, {
  454. templateUrl : this.parent.path+"listItem.json",
  455. pagingEnable : true,
  456. pagingPar : {
  457. //currentPage : this.options.viewPageNum,
  458. countPerPage : 30,
  459. onPostLoad : function( pagingBar ){
  460. if(pagingBar.nextPageNode){
  461. pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
  462. }
  463. }.bind(this),
  464. onPageReturn : function( pagingBar ){
  465. var appId = "Forum";
  466. if (this.app.desktop.apps[appId]){
  467. this.app.desktop.apps[appId].setCurrent();
  468. }else {
  469. this.app.desktop.openApplication(null, "Forum", { "appId": appId });
  470. }
  471. this.app.close();
  472. }.bind(this)
  473. }
  474. } );
  475. this.view.filterData = { creatorName : this.app.options.personName };
  476. this.view.pagingContainerTop = this.pagingBarTop;
  477. this.view.pagingContainerBottom = this.pagingBarBottom;
  478. this.view.load();
  479. },
  480. loadReplyView : function(){
  481. if( this.view )this.view.destroy();
  482. this.view = new MWF.xApplication.ForumPerson.ReplyView( this.viewContainer, this.app, this, {
  483. templateUrl : this.parent.path+"listItemReply.json",
  484. pagingEnable : true,
  485. pagingPar : {
  486. //currentPage : this.options.viewPageNum,
  487. countPerPage : 30,
  488. onPostLoad : function( pagingBar ){
  489. if(pagingBar.nextPageNode){
  490. pagingBar.nextPageNode.inject( this.toolbarBottom, "before" );
  491. }
  492. }.bind(this),
  493. onPageReturn : function( pagingBar ){
  494. var appId = "Forum";
  495. if (this.app.desktop.apps[appId]){
  496. this.app.desktop.apps[appId].setCurrent();
  497. }else {
  498. this.app.desktop.openApplication(null, "Forum", { "appId": appId });
  499. }
  500. this.app.close();
  501. }.bind(this)
  502. }
  503. } );
  504. this.view.filterData = { creatorName : this.app.options.personName };
  505. this.view.pagingContainerTop = this.pagingBarTop;
  506. this.view.pagingContainerBottom = this.pagingBarBottom;
  507. this.view.load();
  508. },
  509. resizeWindow: function(){
  510. var size = this.app.content.getSize();
  511. this.viewContainer.setStyles({"height":(size.y-121)+"px"});
  512. }
  513. });
  514. MWF.xApplication.ForumPerson.SubjectView = new Class({
  515. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  516. _createDocument: function(data, index){
  517. return new MWF.xApplication.ForumPerson.SubjectDocument(this.viewNode, data, this.explorer, this, null, index);
  518. },
  519. _getCurrentPageData: function(callback, count, pageNum){
  520. this.clearBody();
  521. if(!count)count=30;
  522. if(!pageNum)pageNum = 1;
  523. var filter = this.filterData || {};
  524. if( this.app.isCurrentUser ){
  525. this.actions.listMySubjectPage( pageNum, count, filter, function(json){
  526. if( !json.data )json.data = [];
  527. if( !json.count )json.count=0;
  528. if( callback )callback(json);
  529. }.bind(this))
  530. }else{
  531. this.actions.listUserSubjectPage( pageNum, count, filter, function(json){
  532. if( !json.data )json.data = [];
  533. if( !json.count )json.count=0;
  534. json.data = json.data.filter(function(d){
  535. return !d.anonymousSubject;
  536. })
  537. if( callback )callback(json);
  538. }.bind(this))
  539. }
  540. },
  541. _removeDocument: function(documentData, all){
  542. this.actions.deleteSubject(documentData.id, function(json){
  543. this.reload();
  544. this.app.reloadAllParents( documentData.sectionId );
  545. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  546. }.bind(this));
  547. },
  548. _create: function(){
  549. },
  550. _openDocument: function( documentData,index ){
  551. var appId = "ForumDocument"+documentData.id;
  552. if (this.app.desktop.apps[appId]){
  553. this.app.desktop.apps[appId].setCurrent();
  554. }else {
  555. this.app.desktop.openApplication(null, "ForumDocument", {
  556. "sectionId" : documentData.sectionId,
  557. "id" : documentData.id,
  558. "appId": appId,
  559. "isEdited" : false,
  560. "isNew" : false,
  561. "index" : index
  562. });
  563. }
  564. },
  565. _queryCreateViewNode: function(){
  566. },
  567. _postCreateViewNode: function( viewNode ){
  568. },
  569. _queryCreateViewHead:function(){
  570. },
  571. _postCreateViewHead: function( headNode ){
  572. }
  573. });
  574. MWF.xApplication.ForumPerson.SubjectDocument = new Class({
  575. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  576. _queryCreateDocumentNode:function( itemData ){
  577. },
  578. _postCreateDocumentNode: function( itemNode, itemData ){
  579. },
  580. open: function (e) {
  581. this.view._openDocument(this.data, this.index);
  582. },
  583. edit : function(){
  584. var appId = "ForumDocument"+this.data.id;
  585. if (this.app.desktop.apps[appId]){
  586. this.app.desktop.apps[appId].setCurrent();
  587. }else {
  588. this.app.desktop.openApplication(null, "ForumDocument", {
  589. "sectionId" : this.data.sectionId,
  590. "id" : this.data.id,
  591. "appId": appId,
  592. "isEdited" : true,
  593. "isNew" : false,
  594. "index" : this.index
  595. });
  596. }
  597. },
  598. openSection : function( ev ){
  599. var data = this.data;
  600. var appId = "ForumSection"+ data.sectionId;
  601. if (this.app.desktop.apps[appId]){
  602. this.app.desktop.apps[appId].setCurrent();
  603. }else {
  604. this.app.desktop.openApplication(ev, "ForumSection", {
  605. "sectionId": data.sectionId,
  606. "appId": appId
  607. });
  608. }
  609. ev.stopPropagation();
  610. },
  611. isAdmin: function(){
  612. return this.app.access.isAdmin();
  613. }
  614. });
  615. MWF.xApplication.ForumPerson.ReplyView = new Class({
  616. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  617. _createDocument: function(data, index){
  618. return new MWF.xApplication.ForumPerson.ReplyDocument(this.viewNode, data, this.explorer, this, null, index);
  619. },
  620. _getCurrentPageData: function(callback, count, pageNum){
  621. this.clearBody();
  622. if(!count)count=30;
  623. if(!pageNum)pageNum = 1;
  624. var filter = this.filterData || {};
  625. this.actions.listMyReplyPage( pageNum, count, filter, function(json){
  626. if( !json.data )json.data = [];
  627. if( !json.count )json.count=0;
  628. if( callback )callback(json);
  629. }.bind(this))
  630. },
  631. _removeDocument: function(documentData, all){
  632. this.actions.deleteReply(documentData.id, function(json){
  633. this.reload();
  634. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  635. }.bind(this));
  636. },
  637. _create: function(){
  638. },
  639. _openDocument: function( documentData,index ){
  640. var appId = "ForumDocument"+documentData.id;
  641. if (this.app.desktop.apps[appId]){
  642. this.app.desktop.apps[appId].setCurrent();
  643. }else {
  644. this.app.desktop.openApplication(null, "ForumDocument", {
  645. "sectionId" : documentData.sectionId,
  646. "id" : documentData.subjectId,
  647. "replyIndex" : documentData.orderNumber,
  648. "appId": appId,
  649. "isEdited" : false,
  650. "isNew" : false,
  651. "index" : index
  652. });
  653. }
  654. },
  655. _queryCreateViewNode: function(){
  656. },
  657. _postCreateViewNode: function( viewNode ){
  658. },
  659. _queryCreateViewHead:function(){
  660. },
  661. _postCreateViewHead: function( headNode ){
  662. }
  663. });
  664. MWF.xApplication.ForumPerson.ReplyDocument = new Class({
  665. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  666. _queryCreateDocumentNode:function( itemData ){
  667. },
  668. _postCreateDocumentNode: function( itemNode, itemData ){
  669. },
  670. open: function (e) {
  671. this.view._openDocument(this.data, this.index);
  672. },
  673. edit : function(){
  674. var appId = "ForumDocument"+this.data.id;
  675. if (this.app.desktop.apps[appId]){
  676. this.app.desktop.apps[appId].setCurrent();
  677. }else {
  678. this.app.desktop.openApplication(null, "ForumDocument", {
  679. "sectionId" : this.data.sectionId,
  680. "id" : this.data.id,
  681. "appId": appId,
  682. "isEdited" : true,
  683. "isNew" : false,
  684. "index" : this.index
  685. });
  686. }
  687. },
  688. openSection : function( ev ){
  689. var data = this.data;
  690. var appId = "ForumSection"+ data.sectionId;
  691. if (this.app.desktop.apps[appId]){
  692. this.app.desktop.apps[appId].setCurrent();
  693. }else {
  694. this.app.desktop.openApplication(ev, "ForumSection", {
  695. "sectionId": data.sectionId,
  696. "appId": appId
  697. });
  698. }
  699. ev.stopPropagation();
  700. },
  701. isAdmin: function(){
  702. return this.app.access.isAdmin();
  703. },
  704. htmlToString : function( html ){
  705. html = html.replace( /<img[^>]+>/g," ["+this.app.lp.picture+"] ");
  706. return html.replace(/<[^>]+>/g,"");
  707. }
  708. });