Main.js 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. MWF.require("MWF.widget.Identity", null, false);
  3. MWF.xDesktop.requireApp("Forum", "Actions.RestActions", null, false);
  4. MWF.xDesktop.requireApp("Forum", "Access", null, false);
  5. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  6. MWF.xApplication.Forum.options = {
  7. multitask: false,
  8. executable: true
  9. }
  10. MWF.xApplication.Forum.Main = new Class({
  11. Extends: MWF.xApplication.Common.Main,
  12. Implements: [Options, Events],
  13. options: {
  14. "style": "default",
  15. "name": "Forum",
  16. "icon": "icon.png",
  17. "width": "1210",
  18. "height": "700",
  19. "isResize": false,
  20. "isMax": true,
  21. "title": MWF.xApplication.Forum.LP.title
  22. },
  23. onQueryLoad: function () {
  24. this.lp = MWF.xApplication.Forum.LP;
  25. },
  26. loadApplication: function (callback) {
  27. this.userName = layout.desktop.session.user.name;
  28. this.restActions = new MWF.xApplication.Forum.Actions.RestActions();
  29. this.path = "/x_component_Forum/$Main/" + this.options.style + "/";
  30. this.createNode();
  31. this.loadApplicationContent();
  32. },
  33. loadController: function (callback) {
  34. this.access = new MWF.xApplication.Forum.Access( this.restActions, this.lp );
  35. if (callback)callback();
  36. },
  37. reload : function(){
  38. this.clearContent();
  39. if( this.explorer ){
  40. this.openSetting( this.explorer.currentNaviItem.retrieve("index") )
  41. }else{
  42. this.loadApplicationLayout();
  43. }
  44. },
  45. isAdmin : function(){
  46. return this.access.isAdmin();
  47. },
  48. createNode: function () {
  49. this.content.setStyle("overflow", "hidden");
  50. this.node = new Element("div", {
  51. "styles": this.css.node
  52. }).inject(this.content);
  53. },
  54. loadApplicationContent: function () {
  55. this.loadController(function () {
  56. this.access.login( function(){
  57. if( this.status && this.status.setting ){
  58. this.openSetting( this.status.index )
  59. }else{
  60. this.loadApplicationLayout();
  61. }
  62. }.bind(this))
  63. }.bind(this))
  64. },
  65. loaNavi: function (callback) {
  66. this.naviNode = new Element("div.naviNode", {
  67. "styles": this.css.naviNode
  68. }).inject(this.node);
  69. var curNavi = {"id": ""}
  70. if (this.status) {
  71. curNavi.id = this.status.id
  72. }
  73. this.navi = new MWF.xApplication.Forum.Navi(this, this.naviNode, curNavi);
  74. },
  75. loadApplicationLayout: function () {
  76. this.contentContainerNode = new Element("div.contentContainerNode", {
  77. "styles": this.css.contentContainerNode
  78. }).inject(this.node);
  79. this.createTopNode();
  80. this.createContainerNode();
  81. },
  82. createTopNode: function () {
  83. this.topContainerNode = new Element("div.topContainerNode", {
  84. "styles": this.css.topContainerNode
  85. }).inject(this.contentContainerNode);
  86. this.topNode = new Element("div.topNode", {
  87. "styles": this.css.topNode
  88. }).inject(this.topContainerNode);
  89. this.topMainPageNode = new Element("div.topMainPageNode",{
  90. "styles" : { "cursor" : "pointer" }
  91. }).inject(this.topNode)
  92. this.topMainPageNode.addEvent("click", function(){
  93. this.openMainPage();
  94. }.bind(this))
  95. this.searchDiv = new Element("div.searchDiv",{
  96. "styles" : this.css.searchDiv
  97. }).inject(this.topNode)
  98. this.searchInput = new Element("input.searchInput",{
  99. "styles" : this.css.searchInput,
  100. "value" : this.lp.searchKey,
  101. "title" : this.lp.searchTitle
  102. }).inject(this.searchDiv)
  103. var _self = this;
  104. this.searchInput.addEvents({
  105. "focus": function(){
  106. if (this.value==_self.lp.searchKey) this.set("value", "");
  107. },
  108. "blur": function(){if (!this.value) this.set("value", _self.lp.searchKey);},
  109. "keydown": function(e){
  110. if (e.code==13){
  111. this.search();
  112. e.preventDefault();
  113. }
  114. }.bind(this)
  115. });
  116. this.searchAction = new Element("div.searchAction",{
  117. "styles" : this.css.searchAction
  118. }).inject(this.searchDiv);
  119. this.searchAction.addEvents({
  120. "click": function(){ this.search(); }.bind(this),
  121. "mouseover": function(e){
  122. this.searchAction.setStyles( this.css.searchAction_over2 );
  123. e.stopPropagation();
  124. }.bind(this),
  125. "mouseout": function(){ this.searchAction.setStyles( this.css.searchAction ) }.bind(this)
  126. });
  127. this.searchDiv.addEvents( {
  128. "mouseover" : function(){
  129. this.searchInput.setStyles( this.css.searchInput_over )
  130. this.searchAction.setStyles( this.css.searchAction_over )
  131. }.bind(this),
  132. "mouseout" : function(){
  133. this.searchInput.setStyles( this.css.searchInput )
  134. this.searchAction.setStyles( this.css.searchAction )
  135. }.bind(this)
  136. } )
  137. //this.getSystemSetting( "BBS_LOGO_NAME", function( data ){
  138. this.restActions.getBBSName( function( json ){
  139. var data = json.data;
  140. if( data.configValue && data.configValue!="" && data.configValue!="企业论坛" ){
  141. this.topTextNode = new Element("div.topTextNode", {
  142. "styles": this.css.topTextNode,
  143. "text": data.configValue
  144. }).inject(this.topMainPageNode)
  145. }else{
  146. this.topIconNode = new Element("div", {
  147. "styles": this.css.topIconNode
  148. }).inject(this.topMainPageNode)
  149. }
  150. }.bind(this), null, false );
  151. //}.bind(this), false )
  152. this.topContentNode = new Element("div", {
  153. "styles": this.css.topContentNode
  154. }).inject(this.topNode);
  155. if( this.access.isAnonymous() ){
  156. if( this.access.signUpMode != "disable" ){
  157. this.signupNode = new Element("div", {
  158. "styles": this.css.signupNode
  159. }).inject(this.topContentNode);
  160. this.signupIconNode = new Element("div", {
  161. "styles": this.css.signupIconNode
  162. }).inject(this.signupNode);
  163. this.signupTextNode = new Element("div", {
  164. "styles": this.css.signupTextNode,
  165. "text": this.lp.signup
  166. }).inject(this.signupNode);
  167. this.signupNode.addEvent("click", function(){ this.openSignUpForm( ) }.bind(this))
  168. }
  169. this.loginNode = new Element("div", {
  170. "styles": this.css.loginNode
  171. }).inject(this.topContentNode);
  172. this.loginIconNode = new Element("div", {
  173. "styles": this.css.loginIconNode
  174. }).inject(this.loginNode);
  175. this.loginTextNode = new Element("div", {
  176. "styles": this.css.loginTextNode,
  177. "text": this.lp.login
  178. }).inject(this.loginNode);
  179. this.loginNode.addEvent("click", function(){ this.openLoginForm( ) }.bind(this))
  180. }else{
  181. if( this.inBrowser ){
  182. this.logoutNode = new Element("div", {
  183. "styles": this.css.logoutNode
  184. }).inject(this.topContentNode);
  185. this.logoutIconNode = new Element("div", {
  186. "styles": this.css.logoutIconNode
  187. }).inject(this.logoutNode);
  188. this.logoutTextNode = new Element("div", {
  189. "styles": this.css.logoutTextNode,
  190. "text": this.lp.logout
  191. }).inject(this.logoutNode);
  192. this.logoutNode.addEvent("click", function(){ this.logout( ) }.bind(this))
  193. }
  194. this.settingNode = new Element("div", {
  195. "styles": this.css.settingNode
  196. }).inject(this.topContentNode);
  197. this.settingIconNode = new Element("div", {
  198. "styles": this.css.settingIconNode
  199. }).inject(this.settingNode);
  200. this.settingTextNode = new Element("div", {
  201. "styles": this.css.settingTextNode,
  202. "text": this.lp.setting
  203. }).inject(this.settingNode);
  204. this.settingNode.addEvent("click", function(){ this.openSetting( ) }.bind(this));
  205. this.personNode = new Element("div", {
  206. "styles": this.css.personNode
  207. }).inject(this.topContentNode);
  208. this.personIconNode = new Element("div", {
  209. "styles": this.css.personIconNode
  210. }).inject(this.personNode);
  211. this.personTextNode = new Element("div", {
  212. "styles": this.css.personTextNode,
  213. "text": this.lp.personCenter
  214. }).inject(this.personNode);
  215. this.personNode.addEvent("click", function(){ this.openPerson(this.userName ) }.bind(this))
  216. }
  217. this._createTopContent();
  218. },
  219. _createTopContent: function () {
  220. },
  221. getSystemSetting : function( code, callback, async ){
  222. this.restActions.getSystemSettingByCode( {configCode : code }, function(json) {
  223. if (callback)callback(json.data);
  224. }.bind(this), null, async )
  225. },
  226. search : function(){
  227. var val = this.searchInput.get("value");
  228. if( val == "" || val == this.lp.searchKey ){
  229. this.notice( this.lp.noSearchContentNotice, "error" );
  230. return;
  231. }
  232. var appId = "ForumSearch";
  233. if (this.desktop.apps[appId] && !this.inBrowser){
  234. this.desktop.apps[appId].close();
  235. }
  236. this.desktop.openApplication(null, "ForumSearch", {
  237. "appId": appId,
  238. "searchContent" : val
  239. });
  240. },
  241. createContainerNode: function () {
  242. this.createContent();
  243. },
  244. createContent: function () {
  245. this.middleNode = new Element("div.middleNode", {
  246. "styles": this.css.middleNode
  247. }).inject(this.contentContainerNode);
  248. this.setContentSizeFun = this.setContentSize.bind(this);
  249. this.addEvent("resize", this.setContentSizeFun );
  250. this.setContentSize();
  251. //MWF.require("MWF.widget.ScrollBar", function () {
  252. // this.scrollBar = new MWF.widget.ScrollBar(this.contentContainerNode, {
  253. // "indent": false,
  254. // "style": "xApp_TaskList",
  255. // "where": "before",
  256. // "distance": 30,
  257. // "friction": 4,
  258. // "axis": {"x": false, "y": true},
  259. // "onScroll": function (y) {
  260. // }
  261. // });
  262. //}.bind(this));
  263. this.contentNode = new Element("div.contentNode", {
  264. "styles": this.css.contentNode
  265. }).inject(this.middleNode);
  266. this.createRecommand();
  267. this.restActions.listCategoryAll(function (json) {
  268. if( !json.data )json.data = [];
  269. json.data.each(function (d) {
  270. if(d.forumStatus != this.lp.invalid ){
  271. this._createCategory(d);
  272. }
  273. }.bind(this))
  274. }.bind(this))
  275. },
  276. setContentSize: function () {
  277. //var topSize = this.topNode ? this.topNode.getSize() : {"x": 0, "y": 0};
  278. var topSize = {"x": 0, "y": 0};
  279. var nodeSize = this.node.getSize();
  280. var pt = this.contentContainerNode.getStyle("padding-top").toFloat();
  281. var pb = this.contentContainerNode.getStyle("padding-bottom").toFloat();
  282. var height = nodeSize.y - topSize.y - pt - pb;
  283. this.contentContainerNode.setStyle("height", "" + height + "px");
  284. },
  285. createRecommand: function () {
  286. var recommandNode = new Element("div.recommandNode", {
  287. "styles": this.css.recommandNode
  288. }).inject(this.contentNode);
  289. var recommandTopNode = new Element("div.recommandTopNode", {
  290. "styles": this.css.recommandTopNode
  291. }).inject(recommandNode);
  292. recommandTopNode.setStyle( "border-bottom" , "1px solid "+this.lp.defaultForumColor );
  293. var recommandTopTitleNode = new Element("div.recommandTopTitleNode", {
  294. "styles": this.css.recommandTopTitleNode,
  295. "text": this.lp.recommandSubject
  296. }).inject(recommandTopNode);
  297. recommandTopTitleNode.setStyle( "background-color" , this.lp.defaultForumColor );
  298. //categoryTopTitleNode.addEvents({
  299. // click : function(el){ this.obj.openCategory( this.data ) }.bind({ obj : this, data : d })
  300. //})
  301. //var categoryTopRightNode = new Element("div.categoryTopRightNode", {
  302. // "styles": this.css.categoryTopRightNode,
  303. // "text": this.lp.recommandSubject
  304. //}).inject(categoryTopNode);
  305. var view = new MWF.xApplication.Forum.Main.RecommandView(recommandNode, this, this, {
  306. templateUrl: this.path + "listItemRecommand.json"
  307. }, {
  308. lp: this.lp
  309. })
  310. view.load();
  311. },
  312. _createCategory: function (d) {
  313. var categoryNode = new Element("div.categoryNode", {
  314. "styles": this.css.categoryNode
  315. }).inject(this.contentNode);
  316. var categoryTopNode = new Element("div.categoryTopNode", {
  317. "styles": this.css.categoryTopNode
  318. }).inject(categoryNode);
  319. categoryTopNode.setStyle( "border-bottom" , "1px solid "+ d.forumColor || this.lp.defaultForumColor );
  320. var categoryTopTitleNode = new Element("div.categoryTopTitleNode", {
  321. "styles": this.css.categoryTopTitleNode,
  322. "text": d.forumName
  323. }).inject(categoryTopNode);
  324. categoryTopTitleNode.addEvents({
  325. click : function(el){ this.obj.openCategory( this.data ) }.bind({ obj : this, data : d })
  326. })
  327. categoryTopTitleNode.setStyle( "background-color" , d.forumColor || this.lp.defaultForumColor );
  328. var categoryTopRightNode = new Element("div.categoryTopRightNode", {
  329. "styles": this.css.categoryTopRightNode2
  330. }).inject(categoryTopNode);
  331. this.createPersonNode(categoryTopRightNode,d.forumManagerName );
  332. new Element("div.categoryTopRightNode", {
  333. "styles": this.css.categoryTopRightNode,
  334. "text": this.lp.categoryManager + ":" //+ d.forumManagerName
  335. }).inject(categoryTopNode);
  336. if (d.indexListStyle == "经典") {
  337. var view = new MWF.xApplication.Forum.Main.ListView(categoryNode, this, this, {
  338. templateUrl: this.path + "listItemList.json",
  339. categoryId: d.id
  340. }, {
  341. lp: this.lp
  342. })
  343. view.load();
  344. } else if (d.indexListStyle == "图片矩形") {
  345. var view = new MWF.xApplication.Forum.Main.ImageView(categoryNode, this, this, {
  346. templateUrl: this.path + "listItemImage.json",
  347. categoryId: d.id
  348. }, {
  349. lp: this.lp
  350. })
  351. view.load();
  352. } else {
  353. var view = new MWF.xApplication.Forum.Main.TileView(categoryNode, this, this, {
  354. templateUrl: this.path + "listItemTile.json",
  355. categoryId: d.id
  356. }, {
  357. lp: this.lp
  358. })
  359. view.load();
  360. }
  361. },
  362. clearContent: function () {
  363. if (this.explorer)this.explorer.destroy();
  364. this.explorer = null;
  365. if(this.setContentSizeFun)this.removeEvent("resize", this.setContentSizeFun );
  366. if(this.scrollBar && this.scrollBar.scrollVAreaNode)this.scrollBar.scrollVAreaNode.destroy();
  367. if( this.scrollBar )delete this.scrollBar;
  368. if (this.contentContainerNode) {
  369. this.contentContainerNode.destroy();
  370. //this.middleNode.destroy();
  371. //this.contentNode.destroy();
  372. }
  373. },
  374. openMainPage : function(){
  375. this.clearContent();
  376. //this.createCategory();
  377. this.loadApplicationLayout();
  378. },
  379. openCategory : function( d ){
  380. var appId = "ForumCategory"+ d.id;
  381. if (this.desktop.apps[appId]){
  382. this.desktop.apps[appId].setCurrent();
  383. }else {
  384. this.desktop.openApplication(null, "ForumCategory", {
  385. "categoryId": d.id,
  386. "appId": appId
  387. });
  388. }
  389. },
  390. openLoginForm : function(){
  391. //MWF.xDesktop.requireApp("Forum", "Login", null, false);
  392. //var login = new MWF.xApplication.Forum.Login(this, {
  393. // onPostOk : function(){
  394. // window.location.reload();
  395. // }
  396. //});
  397. //login.openLoginForm();
  398. MWF.require("MWF.xDesktop.Authentication", null, false);
  399. var authentication = new MWF.xDesktop.Authentication({
  400. style : "application",
  401. onPostOk : function(){
  402. window.location.reload();
  403. }
  404. },this);
  405. authentication.openLoginForm();
  406. },
  407. openSignUpForm : function(){
  408. //MWF.xDesktop.requireApp("Forum", "Login", null, false);
  409. //var login = new MWF.xApplication.Forum.Login(this, {});
  410. //login.openSignUpForm();
  411. MWF.require("MWF.xDesktop.Authentication", null, false);
  412. var authentication = new MWF.xDesktop.Authentication( {
  413. style : "application",
  414. onPostOk : function(){
  415. }
  416. }, this);
  417. authentication.openSignUpForm();
  418. },
  419. openSetting: function ( index ) {
  420. MWF.xDesktop.requireApp("Forum", "Setting", null, false);
  421. this.clearContent();
  422. this.contentContainerNode = new Element("div.contentContainerNode", {
  423. "styles": this.css.contentContainerNode
  424. }).inject(this.node);
  425. this.createTopNode();
  426. this.middleNode = new Element("div.middleNode", {
  427. "styles": this.css.middleNode
  428. }).inject(this.contentContainerNode);
  429. this.contentNode = new Element("div.contentNode", {
  430. "styles": this.css.contentNode
  431. }).inject(this.middleNode);
  432. this.explorer = new MWF.xApplication.Forum.Setting(this.contentNode, this, this.restActions, {"isAdmin": this.isAdmin() , "index" : (index || 0) });
  433. this.explorer.load();
  434. },
  435. recordStatus: function () {
  436. var status = {};
  437. if( this.explorer ){
  438. status = {
  439. setting : true,
  440. index : this.explorer.currentNaviItem.retrieve("index")
  441. };
  442. }
  443. return status;
  444. },
  445. openPerson : function( userName ){
  446. var appId = "ForumPerson"+userName;
  447. if (this.desktop.apps[appId]){
  448. this.desktop.apps[appId].setCurrent();
  449. }else {
  450. this.desktop.openApplication(null, "ForumPerson", {
  451. "personName" : userName,
  452. "appId": appId
  453. });
  454. }
  455. },
  456. createPersonNode : function( container, personName ){
  457. var persons = personName.split(",");
  458. persons.each( function(userName, i){
  459. var span = new Element("span", {
  460. "text" : userName,
  461. "styles" : this.css.person
  462. }).inject(container);
  463. span.addEvents( {
  464. mouseover : function(){ this.node.setStyles( this.obj.css.person_over )}.bind( {node:span, obj:this} ),
  465. mouseout : function(){ this.node.setStyles( this.obj.css.person )}.bind( {node:span, obj:this} ),
  466. click : function(){ this.obj.openPerson( this.userName ) }.bind( {userName:userName, obj:this} )
  467. })
  468. if( i != persons.length - 1 ){
  469. new Element("span", {
  470. "text" : ",",
  471. }).inject(container);
  472. }
  473. }.bind(this))
  474. },
  475. logout: function(){
  476. this.restActions.logout( function(){
  477. layout.desktop.session.user.name = "anonymous";
  478. this.clearContent();
  479. this.loadApplicationContent();
  480. this.openLoginForm();
  481. }.bind(this))
  482. }
  483. });
  484. MWF.xApplication.Forum.Main.RecommandView = new Class({
  485. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  486. _createDocument: function (data, index) {
  487. return new MWF.xApplication.Forum.Main.RecommandDocument(this.viewNode, data, this.explorer, this, null, index);
  488. },
  489. _getCurrentPageData: function (callback, count) {
  490. if (!count)count = 12;
  491. this.actions.listRecommendedSubject(count, function (json) {
  492. if( !json.data )json.data = [];
  493. if (callback)callback(json);
  494. }.bind(this))
  495. },
  496. _removeDocument: function (documentData, all) {
  497. //this.actions.deleteSchedule(documentData.id, function(json){
  498. // this.reload();
  499. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  500. //}.bind(this));
  501. },
  502. _create: function () {
  503. },
  504. _openDocument: function (documentData) {
  505. },
  506. _queryCreateViewNode: function () {
  507. },
  508. _postCreateViewNode: function (viewNode) {
  509. },
  510. _queryCreateViewHead: function () {
  511. },
  512. _postCreateViewHead: function (headNode) {
  513. }
  514. })
  515. MWF.xApplication.Forum.Main.RecommandDocument = new Class({
  516. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  517. mouseoverDocument: function () {
  518. //this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode_over"]);
  519. //this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode_over"]);
  520. //this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode_over"]);
  521. },
  522. mouseoutDocument: function () {
  523. //this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode"]);
  524. //this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode"]);
  525. //this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode"]);
  526. },
  527. _queryCreateDocumentNode: function (itemData) {
  528. },
  529. _postCreateDocumentNode: function (itemNode, itemData) {
  530. },
  531. open: function( ){
  532. var data = this.data;
  533. var appId = "ForumDocument"+data.id;
  534. if (this.app.desktop.apps[appId]){
  535. this.app.desktop.apps[appId].setCurrent();
  536. }else {
  537. this.app.desktop.openApplication(null, "ForumDocument", {
  538. "sectionId" : data.sectionId,
  539. "id" : data.id,
  540. "appId": appId,
  541. "isEdited" : false,
  542. "isNew" : false
  543. });
  544. }
  545. },
  546. openSection : function( el ){
  547. var data = this.data;
  548. var appId = "ForumSection"+ data.sectionId;
  549. if (this.app.desktop.apps[appId]){
  550. this.app.desktop.apps[appId].setCurrent();
  551. }else {
  552. this.app.desktop.openApplication(el, "ForumSection", {
  553. "sectionId": data.sectionId,
  554. "appId": appId
  555. });
  556. }
  557. }
  558. })
  559. MWF.xApplication.Forum.Main.TileView = new Class({
  560. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  561. _createDocument: function (data, index) {
  562. if( this.explorer.access.isSectionViewer( data ) ){
  563. return new MWF.xApplication.Forum.Main.TileDocument(this.viewNode, data, this.explorer, this, null, index);
  564. }
  565. },
  566. _getCurrentPageData: function (callback, count) {
  567. if (!count)count = 20;
  568. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  569. var filter = this.filterData || {};
  570. this.actions.listSection(this.options.categoryId, function (json) {
  571. if( !json.data )json.data = [];
  572. if (callback)callback(json);
  573. }.bind(this))
  574. },
  575. _removeDocument: function (documentData, all) {
  576. //this.actions.deleteSchedule(documentData.id, function(json){
  577. // this.reload();
  578. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  579. //}.bind(this));
  580. },
  581. _create: function () {
  582. },
  583. _openDocument: function (documentData) {
  584. },
  585. _queryCreateViewNode: function () {
  586. },
  587. _postCreateViewNode: function (viewNode) {
  588. },
  589. _queryCreateViewHead: function () {
  590. },
  591. _postCreateViewHead: function (headNode) {
  592. }
  593. })
  594. MWF.xApplication.Forum.Main.TileDocument = new Class({
  595. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  596. mouseoverDocument: function () {
  597. //this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode_over"]);
  598. //this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode_over"]);
  599. //this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode_over"]);
  600. },
  601. mouseoutDocument: function () {
  602. //this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode"]);
  603. //this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode"]);
  604. //this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode"]);
  605. },
  606. _queryCreateDocumentNode: function (itemData) {
  607. },
  608. _postCreateDocumentNode: function (itemNode, itemData) {
  609. if( (this.index + 1) % 4 == 0 ){
  610. itemNode.setStyle("margin-right" , "0px" );
  611. }
  612. var personNode = itemNode.getElements("[item='moderatorNames']")[0];
  613. this.app.createPersonNode( personNode, itemData.moderatorNames )
  614. var listNode = itemNode.getElements("[styles='documentItemListNode']")[0];
  615. if (listNode) {
  616. this._getListData(function (json) {
  617. json.data.each(function (d,i) {
  618. var div = new Element("div", {
  619. "styles": this.css.documentItemListItemNode,
  620. "text": d.title,
  621. "title": d.title
  622. }).inject(listNode)
  623. div.addEvents({
  624. "mouseover": function () {
  625. this.node.setStyles(this.obj.css.documentItemListItemNode_over)
  626. }.bind({node: div, obj: this}),
  627. "mouseout": function () {
  628. this.node.setStyles(this.obj.css.documentItemListItemNode)
  629. }.bind({node: div, obj: this}),
  630. "click" : function(){
  631. var appId = "ForumDocument"+this.da.id;
  632. if (this.obj.app.desktop.apps[appId]){
  633. this.obj.app.desktop.apps[appId].setCurrent();
  634. }else {
  635. this.obj.app.desktop.openApplication(null, "ForumDocument", {
  636. "sectionId" : this.da.sectionId,
  637. "id" : this.da.id,
  638. "appId": appId,
  639. "isEdited" : false,
  640. "isNew" : false,
  641. "index" : i
  642. });
  643. }
  644. }.bind({da: d, obj: this})
  645. })
  646. }.bind(this))
  647. }.bind(this), 6)
  648. }
  649. },
  650. _getListData: function (callback, count) {
  651. if (!count)count = 6;
  652. var filterData = {
  653. "sectionId": this.data.id
  654. }
  655. this.actions.listSubjectFilterPage(1, count, filterData, function (json) {
  656. if (!json.data)json.data = [];
  657. if (callback)callback(json);
  658. }.bind(this))
  659. },
  660. openSection : function( el ){
  661. var appId = "ForumSection"+ this.data.id;
  662. if (this.app.desktop.apps[appId]){
  663. this.app.desktop.apps[appId].setCurrent();
  664. }else {
  665. this.app.desktop.openApplication(el, "ForumSection", {
  666. "sectionId": this.data.id,
  667. "appId": appId
  668. });
  669. }
  670. }
  671. })
  672. MWF.xApplication.Forum.Main.ListView = new Class({
  673. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  674. _createDocument: function (data, index) {
  675. if( this.explorer.access.isSectionViewer( data ) ){
  676. return new MWF.xApplication.Forum.Main.ListDocument(this.viewNode, data, this.explorer, this, null, index);
  677. }
  678. },
  679. _getCurrentPageData: function (callback, count) {
  680. if (!count)count = 20;
  681. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  682. var filter = this.filterData || {};
  683. this.actions.listSection(this.options.categoryId, function (json) {
  684. if( !json.data )json.data = [];
  685. if (callback)callback(json);
  686. }.bind(this))
  687. },
  688. _removeDocument: function (documentData, all) {
  689. //this.actions.deleteSchedule(documentData.id, function(json){
  690. // this.reload();
  691. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  692. //}.bind(this));
  693. },
  694. _create: function () {
  695. },
  696. _openDocument: function (documentData) {
  697. },
  698. _queryCreateViewNode: function () {
  699. },
  700. _postCreateViewNode: function (viewNode) {
  701. },
  702. _queryCreateViewHead: function () {
  703. },
  704. _postCreateViewHead: function (headNode) {
  705. }
  706. })
  707. MWF.xApplication.Forum.Main.ListDocument = new Class({
  708. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  709. mouseoverDocument: function () {
  710. //this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode_over"]);
  711. //this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode_over"]);
  712. //this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode_over"]);
  713. },
  714. mouseoutDocument: function () {
  715. //this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode"]);
  716. //this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode"]);
  717. //this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode"]);
  718. },
  719. _queryCreateDocumentNode: function (itemData) {
  720. },
  721. _postCreateDocumentNode: function (itemNode, itemData) {
  722. var personNode = itemNode.getElements("[item='moderatorNames']")[0];
  723. this.app.createPersonNode( personNode, itemData.moderatorNames )
  724. var listNode = itemNode.getElements("[styles='documentItemListNode_list']")[0];
  725. var replyListNode = itemNode.getElements("[styles='documentItemReplyListNode_list']")[0];
  726. if (listNode) {
  727. this._getListData(function (json) {
  728. json.data.each(function (d,i) {
  729. var div = new Element("div", {
  730. "styles": this.css.documentItemListItemNode_list,
  731. "text": d.title,
  732. "title": d.title
  733. }).inject(listNode)
  734. div.addEvents({
  735. "mouseover": function () {
  736. this.node.setStyles(this.obj.css.documentItemListItemNode_list_over)
  737. }.bind({node: div, obj: this}),
  738. "mouseout": function () {
  739. this.node.setStyles(this.obj.css.documentItemListItemNode_list)
  740. }.bind({node: div, obj: this}),
  741. "click" : function(){
  742. var appId = "ForumDocument"+this.da.id;
  743. if (this.obj.app.desktop.apps[appId]){
  744. this.obj.app.desktop.apps[appId].setCurrent();
  745. }else {
  746. this.obj.app.desktop.openApplication(null, "ForumDocument", {
  747. "sectionId" : this.da.sectionId,
  748. "id" : this.da.id,
  749. "appId": appId,
  750. "isEdited" : false,
  751. "isNew" : false,
  752. "index" : i
  753. });
  754. }
  755. }.bind({da: d, obj: this})
  756. })
  757. var replyNode = new Element("div", {
  758. "styles": this.css.documentItemReplyListItemNode_list
  759. }).inject(replyListNode)
  760. var div = new Element("div", {
  761. "styles": this.css.documentItemReplyTimeNode_list,
  762. "text": getDateDiff(d.createTime),
  763. "title": d.createTime
  764. }).inject(replyNode)
  765. var div = new Element("div", {
  766. "styles": this.css.documentItemReplyPersonNode_list,
  767. "text": d.creatorName
  768. }).inject(replyNode)
  769. div.addEvents({
  770. "mouseover": function () {
  771. this.node.setStyles(this.obj.css.documentItemReplyPersonNode_list_over)
  772. }.bind({node: div, obj: this}),
  773. "mouseout": function () {
  774. this.node.setStyles(this.obj.css.documentItemReplyPersonNode_list)
  775. }.bind({node: div, obj: this}),
  776. "click" : function(){
  777. this.obj.app.openPerson( this.userName );
  778. }.bind( {userName : d.creatorName, obj:this} )
  779. })
  780. }.bind(this))
  781. }.bind(this), 6)
  782. }
  783. },
  784. _getListData: function (callback, count) {
  785. if (!count)count = 6;
  786. var filterData = {
  787. "sectionId": this.data.id
  788. }
  789. this.actions.listSubjectFilterPage(1, count, filterData, function (json) {
  790. if (!json.data)json.data = [];
  791. if (callback)callback(json);
  792. }.bind(this))
  793. },
  794. removeCenterWork: function (itemData) {
  795. //if(isAdmin){
  796. // return true;
  797. //}
  798. return false;
  799. },
  800. openSection : function( el ){
  801. var appId = "ForumSection"+ this.data.id;
  802. if (this.app.desktop.apps[appId]){
  803. this.app.desktop.apps[appId].setCurrent();
  804. }else {
  805. this.app.desktop.openApplication(el, "ForumSection", {
  806. "sectionId": this.data.id,
  807. "appId": appId
  808. });
  809. }
  810. }
  811. })
  812. MWF.xApplication.Forum.Main.ImageView = new Class({
  813. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  814. _createDocument: function (data, index) {
  815. if( this.explorer.access.isSectionViewer( data ) ){
  816. return new MWF.xApplication.Forum.Main.ImageDocument(this.viewNode, data, this.explorer, this, null, index);
  817. }
  818. },
  819. _getCurrentPageData: function (callback, count) {
  820. if (!count)count = 20;
  821. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  822. var filter = this.filterData || {};
  823. this.actions.listSection(this.options.categoryId, function (json) {
  824. if( !json.data )json.data = [];
  825. if (callback)callback(json);
  826. }.bind(this))
  827. },
  828. _removeDocument: function (documentData, all) {
  829. //this.actions.deleteSchedule(documentData.id, function(json){
  830. // this.reload();
  831. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  832. //}.bind(this));
  833. },
  834. _create: function () {
  835. },
  836. _openDocument: function (documentData) {
  837. },
  838. _queryCreateViewNode: function () {
  839. },
  840. _postCreateViewNode: function (viewNode) {
  841. },
  842. _queryCreateViewHead: function () {
  843. },
  844. _postCreateViewHead: function (headNode) {
  845. }
  846. })
  847. MWF.xApplication.Forum.Main.ImageDocument = new Class({
  848. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  849. mouseoverDocument: function () {
  850. //this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode_over"]);
  851. //this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode_over"]);
  852. //this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode_over"]);
  853. },
  854. mouseoutDocument: function () {
  855. //this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode"]);
  856. //this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode"]);
  857. //this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode"]);
  858. },
  859. _queryCreateDocumentNode: function (itemData) {
  860. },
  861. _postCreateDocumentNode: function (itemNode, itemData) {
  862. var personNode = itemNode.getElements("[item='moderatorNames']")[0];
  863. this.app.createPersonNode( personNode, itemData.moderatorNames )
  864. var _self = this;
  865. if( (this.index + 1) % 2 == 0 ){
  866. itemNode.setStyle("margin-right" , "0px" );
  867. }
  868. var imageNode = itemNode.getElements("[styles='documentItemLeftImage']")[0];
  869. var filterData = {
  870. "sectionId": this.data.id,
  871. "needPicture" : true
  872. }
  873. this.actions.listSubjectFilterPage(1, 1, filterData, function( json ){
  874. if( json.data ){
  875. var d = json.data[0];
  876. this.node.set("title", d.title);
  877. this.node.set("src", d.pictureBase64 );
  878. this.node.addEvents({
  879. "click": function () {
  880. var appId = "ForumDocument" + this.da.id;
  881. if (_self.app.desktop.apps[appId]) {
  882. _self.app.desktop.apps[appId].setCurrent();
  883. } else {
  884. _self.app.desktop.openApplication(null, "ForumDocument", {
  885. "sectionId": this.da.sectionId,
  886. "id": this.da.id,
  887. "appId": appId,
  888. "isEdited": false,
  889. "isNew": false
  890. });
  891. }
  892. }.bind({da: d})
  893. })
  894. }
  895. }.bind({ node : imageNode }))
  896. var listNode = itemNode.getElements("[styles='documentItemListNode']")[0];
  897. if (listNode) {
  898. this._getListData(function (json) {
  899. json.data.each(function (d,i) {
  900. var div = new Element("div", {
  901. "styles": this.css.documentItemListItemNode,
  902. "text": d.title,
  903. "title": d.title
  904. }).inject(listNode)
  905. div.addEvents({
  906. "mouseover": function () {
  907. this.node.setStyles(this.obj.css.documentItemListItemNode_over)
  908. }.bind({node: div, obj: this}),
  909. "mouseout": function () {
  910. this.node.setStyles(this.obj.css.documentItemListItemNode)
  911. }.bind({node: div, obj: this}),
  912. "click" : function(){
  913. var appId = "ForumDocument"+this.da.id;
  914. if (this.obj.app.desktop.apps[appId]){
  915. this.obj.app.desktop.apps[appId].setCurrent();
  916. }else {
  917. this.obj.app.desktop.openApplication(null, "ForumDocument", {
  918. "sectionId" : this.da.sectionId,
  919. "id" : this.da.id,
  920. "appId": appId,
  921. "isEdited" : false,
  922. "isNew" : false,
  923. "index" : i
  924. });
  925. }
  926. }.bind({da: d, obj: this})
  927. })
  928. }.bind(this))
  929. }.bind(this), 6)
  930. }
  931. },
  932. _getListData: function (callback, count) {
  933. if (!count)count = 6;
  934. var filterData = {
  935. "sectionId": this.data.id
  936. }
  937. this.actions.listSubjectFilterPage(1, count, filterData, function (json) {
  938. if (!json.data)json.data = [];
  939. if (callback)callback(json);
  940. }.bind(this))
  941. },
  942. removeCenterWork: function (itemData) {
  943. //if(isAdmin){
  944. // return true;
  945. //}
  946. return false;
  947. },
  948. openSection : function( el ){
  949. var appId = "ForumSection"+ this.data.id;
  950. if (this.app.desktop.apps[appId]){
  951. this.app.desktop.apps[appId].setCurrent();
  952. }else {
  953. this.app.desktop.openApplication(el, "ForumSection", {
  954. "sectionId": this.data.id,
  955. "appId": appId
  956. });
  957. }
  958. }
  959. })
  960. var getDateDiff = function (publishTime) {
  961. var dateTimeStamp = Date.parse(publishTime.replace(/-/gi, "/"));
  962. var minute = 1000 * 60;
  963. var hour = minute * 60
  964. var day = hour * 24;
  965. var halfamonth = day * 15;
  966. var month = day * 30;
  967. var year = month * 12;
  968. var now = new Date().getTime();
  969. var diffValue = now - dateTimeStamp;
  970. if (diffValue < 0) {
  971. //若日期不符则弹出窗口告之
  972. //alert("结束日期不能小于开始日期!");
  973. }
  974. var yesterday = new Date().decrement('day', 1);
  975. var beforYesterday = new Date().decrement('day', 2);
  976. var yearC = diffValue / year;
  977. var monthC = diffValue / month;
  978. var weekC = diffValue / (7 * day);
  979. var dayC = diffValue / day;
  980. var hourC = diffValue / hour;
  981. var minC = diffValue / minute;
  982. if (yesterday.getFullYear() == dateTimeStamp.getFullYear() && yesterday.getMonth() == dateTimeStamp.getMonth() && yesterday.getDate() == dateTimeStamp.getDate()) {
  983. result = "昨天 " + dateTimeStamp.getHours() + ":" + dateTimeStamp.getMinutes();
  984. } else if (beforYesterday.getFullYear() == dateTimeStamp.getFullYear() && beforYesterday.getMonth() == dateTimeStamp.getMonth() && beforYesterday.getDate() == dateTimeStamp.getDate()) {
  985. result = "前天 " + dateTimeStamp.getHours() + ":" + dateTimeStamp.getMinutes();
  986. } else if (yearC > 1) {
  987. result = dateTimeStamp.getFullYear() + "年" + (dateTimeStamp.getMonth() + 1) + "月" + dateTimeStamp.getDate() + "日";
  988. } else if (monthC >= 1) {
  989. //result= parseInt(monthC) + "个月前";
  990. // s.getFullYear()+"年";
  991. result = (dateTimeStamp.getMonth() + 1) + "月" + dateTimeStamp.getDate() + "日";
  992. } else if (weekC >= 1) {
  993. result = parseInt(weekC) + "周前";
  994. } else if (dayC >= 1) {
  995. result = parseInt(dayC) + "天前";
  996. } else if (hourC >= 1) {
  997. result = parseInt(hourC) + "小时前";
  998. } else if (minC >= 1) {
  999. result = parseInt(minC) + "分钟前";
  1000. } else
  1001. result = "刚刚发表";
  1002. return result;
  1003. };