Main.js 25 KB

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