Main.js 23 KB

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