Main.js 23 KB

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