Main.js 23 KB

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