NaviMode.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. window.MWFForum = window.MWFForum || MWF.xApplication.Forum;
  2. MWFForum.NaviType = {
  3. main : "main",
  4. all : "all",
  5. recommand : "recommand",
  6. cream : "cream",
  7. category : "category",
  8. section : "section"
  9. };
  10. MWF.xApplication.Forum.NaviMode = MWFForum.NaviMode = new Class({
  11. Extends: MWF.widget.Common,
  12. Implements: [Options, Events],
  13. options : {
  14. "style" : "default",
  15. "id" :"" ,
  16. "type" : MWFForum.NaviType.all
  17. },
  18. initialize: function(app, container, options){
  19. this.setOptions(options);
  20. this.path = "../x_component_Forum/$NaviMode/";
  21. this.cssPath = "../x_component_Forum/$NaviMode/"+this.options.style+"/css.wcss";
  22. this._loadCss();
  23. this.app = app;
  24. this.container = $(container);
  25. },
  26. load: function(){
  27. var self = this;
  28. //this.container.setStyles(this.css.contentNode);
  29. this.naviContainer = new Element("div.naviContainer", {
  30. "styles": this.css.naviContainer
  31. }).inject(this.container);
  32. this.naviNode = new Element("div.naviNode", {
  33. "styles": this.css.naviNode
  34. }).inject(this.naviContainer);
  35. this.viewContainer = new Element("div.viewContainer", {
  36. "styles": this.css.viewContainer
  37. }).inject(this.container);
  38. this.allItem = new MWFForum.NaviMode.AllItem( this, this.naviNode );
  39. this.recommandItem = new MWFForum.NaviMode.RecommandItem( this, this.naviNode );
  40. this.creamItem = new MWFForum.NaviMode.CreamItem( this, this.naviNode );
  41. this.categoryItemList = [];
  42. this.categoryItemMap = {};
  43. this.sectionItemMap = {};
  44. MWF.Actions.get("x_bbs_assemble_control").listCategoryAll( function( json ) {
  45. (json.data || []).each(function (d) {
  46. var categoryItem = new MWFForum.NaviMode.CategoryItem(this, this.naviNode,d );
  47. this.categoryItemList.push( categoryItem );
  48. this.categoryItemMap[ d.id ] = categoryItem;
  49. this.fireEvent("postLoad");
  50. }.bind(this))
  51. }.bind(this));
  52. this.setNodeSizeFun = function () {
  53. this.setNodeSize();
  54. }.bind(this);
  55. this.app.addEvent("resize", this.setNodeSizeFun);
  56. this.setNodeSize();
  57. },
  58. close : function(){
  59. this.back();
  60. },
  61. setTitle : function( title ){
  62. var tail = this.app.inBrowser ? (MWFForum.getSystemConfigValue( MWFForum.BBS_TITLE_TAIL ) || "") : "";
  63. this.app.setTitle( title + tail );
  64. },
  65. back : function( type ){
  66. var item = this.currentItem;
  67. if( !type ){
  68. type = item ? item.type : "main";
  69. }
  70. if(this.view)this.view.destroy();
  71. this.app.clearContent();
  72. if(this.app.node)this.app.node.destroy();
  73. switch ( type ){
  74. case MWFForum.NaviType.category :
  75. MWF.xDesktop.requireApp("ForumCategory", "MainInContainer", null, false);
  76. var forumCategory = new MWF.xApplication.ForumCategory.MainInContainer( this.app.desktop, {
  77. "hasTop" : true,
  78. "hasBreadCrumb" : true,
  79. "categoryId" : item.data.id,
  80. "naviMode" : false,
  81. "autoWidth" : false
  82. }, this.app.content, this.app.content , this.app.content );
  83. forumCategory.inBrowser = this.app.inBrowser;
  84. forumCategory.window = this.app.window;
  85. forumCategory.taskitem = this.app.taskitem;
  86. forumCategory.load();
  87. this.setTitle( item.data.forumName );
  88. this.destroy();
  89. break;
  90. case MWFForum.NaviType.section :
  91. MWF.xDesktop.requireApp("ForumSection", "MainInContainer", null, false);
  92. var forumSection = new MWF.xApplication.ForumSection.MainInContainer( this.app.desktop, {
  93. "hasTop" : true,
  94. "hasBreadCrumb" : true,
  95. "sectionId" : item.data.id,
  96. "naviMode" : false,
  97. "autoWidth" : false
  98. }, this.app.content, this.app.content , this.app.content );
  99. forumSection.inBrowser = this.app.inBrowser;
  100. forumSection.window = this.app.window;
  101. forumSection.taskitem = this.app.taskitem;
  102. forumSection.load();
  103. this.setTitle( item.data.sectionName );
  104. this.destroy();
  105. break;
  106. default :
  107. MWF.xDesktop.requireApp("Forum", "MainInContainer", null, false);
  108. var forum = new MWF.xApplication.Forum.MainInContainer( this.app.desktop, {
  109. "hasTop" : true,
  110. "hasBreadCrumb" : true,
  111. "naviMode" : false,
  112. "autoWidth" : false
  113. }, this.app.content, this.app.content , this.app.content );
  114. forum.inBrowser = this.app.inBrowser;
  115. forum.window = this.app.window;
  116. forum.taskitem = this.app.taskitem;
  117. forum.load();
  118. this.setTitle( MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title );
  119. this.destroy();
  120. break
  121. }
  122. },
  123. goto : function( type, id ){
  124. switch ( type ) {
  125. case MWFForum.NaviType.main :
  126. this.back( MWFForum.NaviType.main );
  127. break;
  128. case MWFForum.NaviType.all :
  129. this.allItem.setCurrent();
  130. break;
  131. case MWFForum.NaviType.recommand :
  132. this.recommandItem.setCurrent();
  133. break;
  134. case MWFForum.NaviType.cream :
  135. this.creamItem.setCurrent();
  136. break;
  137. case MWFForum.NaviType.category :
  138. var category = this.categoryItemMap[id];
  139. if(category)category.setCurrent();
  140. break;
  141. case MWFForum.NaviType.section :
  142. var section = this.sectionItemMap[id];
  143. if(section)section.setCurrent();
  144. break;
  145. default :
  146. break;
  147. }
  148. },
  149. scrollToTop : function(){
  150. this.app.contentContainerNode.scrollTo(0, 0);
  151. },
  152. setNodeSize : function(){
  153. var appSize = this.app.node.getSize();
  154. var topSize = this.app.topObject ? this.app.topObject.topContainerNode.getSize() : {x:0, y:0};
  155. var pt = this.app.contentContainerNode.getStyle("padding-top").toFloat();
  156. var pb = this.app.contentContainerNode.getStyle("padding-bottom").toFloat();
  157. var height = appSize.y - pt - pb;
  158. this.app.contentContainerNode.setStyle("height", "" + height + "px");
  159. var initY = appSize.y - topSize.y - 20;
  160. var naviSize = this.naviNode.getSize();
  161. var viewNode = this.viewContainer.getFirst();
  162. var viewSize = viewNode ? viewNode.getSize() : {x:0, y:0} ;
  163. //alert( "initY=" + initY +" , naviSize =" + naviSize.y + ", viewSize =" + viewSize.y );
  164. this.naviContainer.setStyle( "min-height" , Math.max( initY, naviSize.y, viewSize.y ) );
  165. this.viewContainer.setStyle( "min-height" , Math.max( initY, naviSize.y, viewSize.y ) );
  166. },
  167. destroy : function(){
  168. if(this.setNodeSizeFun)this.app.removeEvent("resize", this.setNodeSizeFun);
  169. if(this.naviNode)this.naviNode.destroy();
  170. }
  171. });
  172. MWFForum.NaviMode.CategoryItem = new Class({
  173. initialize: function ( navi, container, data ) {
  174. this.type = MWFForum.NaviType.category;
  175. this.navi = navi;
  176. this.app = navi.app;
  177. this.data = data;
  178. this.container = $(container);
  179. this.css = navi.css;
  180. this.load();
  181. },
  182. load: function () {
  183. var _self = this;
  184. this.isCurrent = false;
  185. this.isExpended = true;
  186. this.hasSub = true;
  187. this.sectionItemList = [];
  188. if( this.navi.options.id == this.data.id && this.navi.options.type == MWFForum.NaviType.category ){
  189. this.isCurrent = true;
  190. }
  191. this.node = new Element("div.categoryNode", {
  192. "styles": this.css.categoryNode
  193. }).inject(this.container);
  194. this.expendNode = new Element("div.categoryExpendNode").inject(this.node);
  195. this.setExpendNodeStyle();
  196. if( this.hasSub ){
  197. this.expendNode.addEvent( "click" , function(ev){
  198. this.triggerExpend();
  199. ev.stopPropagation();
  200. }.bind(this));
  201. }
  202. this.textNode = new Element("div.categoryTextNode",{
  203. "styles": this.css.categoryTextNode,
  204. "text": this.data.forumName,
  205. "title": this.data.forumName
  206. }).inject(this.node);
  207. this.node.addEvents({
  208. "mouseover": function(){
  209. if ( !_self.isCurrent ){
  210. this.setStyles(_self.css.categoryNode_over);
  211. _self.setExpendNodeStyle( true );
  212. }
  213. },
  214. "mouseout": function(){
  215. if ( !_self.isCurrent ){
  216. this.setStyles( _self.css.categoryNode );
  217. _self.setExpendNodeStyle();
  218. }
  219. },
  220. click : function(){ _self.setCurrent(this);}
  221. });
  222. this.listNode = new Element("div.sectionListNode",{
  223. "styles" : this.css.sectionListNode
  224. }).inject(this.container);
  225. this.loadListContent();
  226. if( this.isCurrent ){
  227. this.setCurrent();
  228. }
  229. },
  230. setExpendNodeStyle : function( isOver ){
  231. var style;
  232. if( this.hasSub ){
  233. if( this.isExpended ){
  234. if( isOver ){
  235. style = this.css.categoryExpendNode_over;
  236. }else if( this.isCurrent ){
  237. style = this.css.categoryExpendNode_selected;
  238. }else{
  239. style = this.css.categoryExpendNode;
  240. }
  241. }else{
  242. if( isOver ){
  243. style = this.css.categoryCollapseNode_over;
  244. }else if( this.isCurrent ){
  245. style = this.css.categoryCollapseNode_selected;
  246. }else{
  247. style = this.css.categoryCollapseNode;
  248. }
  249. }
  250. }else{
  251. style = this.css.emptyExpendNode;
  252. }
  253. this.expendNode.setStyles( style );
  254. },
  255. triggerExpend : function(){
  256. if( this.hasSub ){
  257. if( this.isExpended ){
  258. this.isExpended = false;
  259. this.listNode.setStyle("display","none")
  260. }else{
  261. this.isExpended = true;
  262. this.listNode.setStyle("display","")
  263. }
  264. this.setExpendNodeStyle();
  265. }
  266. },
  267. setCurrent : function(){
  268. if( this.navi.currentItem ){
  269. this.navi.currentItem.cancelCurrent();
  270. }
  271. this.node.setStyles( this.css.categoryNode_selected );
  272. if( this.hasSub ){
  273. if( this.isExpended ){
  274. this.expendNode.setStyles( this.css.categoryExpendNode_selected );
  275. }else{
  276. this.expendNode.setStyles( this.css.categoryCollapseNode_selected );
  277. }
  278. }
  279. this.isCurrent = true;
  280. this.navi.currentItem = this;
  281. this.navi.setTitle( this.data.forumName );
  282. this.loadView();
  283. },
  284. cancelCurrent : function(){
  285. this.isCurrent = false;
  286. this.node.setStyles( this.css.categoryNode );
  287. if( this.hasSub ){
  288. if( this.isExpended ){
  289. this.expendNode.setStyles( this.css.categoryExpendNode );
  290. }else{
  291. this.expendNode.setStyles( this.css.categoryCollapseNode );
  292. }
  293. }
  294. },
  295. loadView: function( searchkey ){
  296. this.app.openView( this, this.data, this.viewData || this.defaultRevealData, searchkey || "", this );
  297. },
  298. loadListContent : function(){
  299. var d = this.data;
  300. if(d.forumStatus != MWF.xApplication.Forum.LP.disable ){
  301. MWF.Actions.get("x_bbs_assemble_control").listSection(d.id , function ( json ) {
  302. (json.data || []).each( function( sectiondata ){
  303. var sectionItem = new MWFForum.NaviMode.SectionItem(this.navi, this, this.listNode, sectiondata );
  304. this.sectionItemList.push( sectionItem );
  305. }.bind(this))
  306. }.bind(this));
  307. }
  308. new Element("div", {
  309. "styles": this.css.categorySepartorNode
  310. }).inject( this.listNode );
  311. },
  312. getCategoryId : function(){
  313. return this.data.id;
  314. },
  315. loadView : function(){
  316. if(this.navi.view)this.navi.view.destroy();
  317. this.navi.viewContainer.empty();
  318. MWF.xDesktop.requireApp("ForumCategory", "MainInContainer", null, false);
  319. var container = this.navi.viewContainer;
  320. var scrollNode = this.app.content;
  321. var forumCategory = this.navi.view = new MWF.xApplication.ForumCategory.MainInContainer( this.app.desktop, {
  322. "hasTop" : false,
  323. "hasBreadCrumb" : true,
  324. "categoryId" : this.data.id,
  325. "naviMode" : true,
  326. "autoWidth" : true,
  327. "onPostLoadCategory" : function(){
  328. this.navi.setNodeSize();
  329. this.navi.scrollToTop();
  330. }.bind(this)
  331. }, container, this.app.content , scrollNode );
  332. forumCategory.forumNavi = this.navi;
  333. forumCategory.inBrowser = this.navi.app.inBrowser;
  334. forumCategory.window = this.app.window;
  335. forumCategory.taskitem = this.navi.app.taskitem;
  336. forumCategory.load();
  337. }
  338. });
  339. MWFForum.NaviMode.SectionItem = new Class({
  340. initialize: function ( navi, category, container, data) {
  341. this.type = MWFForum.NaviType.section;
  342. this.navi = navi;
  343. this.category = category;
  344. this.app = navi.app;
  345. this.data = data;
  346. this.container = $(container);
  347. this.css = navi.css;
  348. this.load();
  349. },
  350. load: function(){
  351. this.navi.sectionItemMap[ this.data.id ] = this;
  352. var _self = this;
  353. this.isCurrent = false;
  354. if( this.navi.options.type == MWFForum.NaviType.section && this.navi.options.id == this.data.id ){
  355. this.isCurrent = true;
  356. }
  357. var _self = this;
  358. this.node = new Element("div.sectionNode", {
  359. "styles": this.css.sectionNode,
  360. "text" : this.data.sectionName
  361. }).inject(this.container);
  362. this.node.addEvents({
  363. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.sectionNode_over) },
  364. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.sectionNode ) },
  365. "click": function (el) {
  366. _self.setCurrent();
  367. }
  368. });
  369. if( this.isCurrent ){
  370. this.setCurrent()
  371. }
  372. },
  373. setCurrent : function(){
  374. if( this.navi.currentItem ){
  375. this.navi.currentItem.cancelCurrent();
  376. }
  377. this.node.setStyles( this.css.sectionNode_selected );
  378. this.isCurrent = true;
  379. this.navi.currentItem = this;
  380. this.navi.setTitle( this.data.sectionName );
  381. this.loadView();
  382. },
  383. cancelCurrent : function(){
  384. this.isCurrent = false;
  385. this.node.setStyles( this.css.sectionNode );
  386. },
  387. getCategoryId : function(){
  388. return this.category.data.id;
  389. },
  390. loadView : function(){
  391. if(this.navi.view)this.navi.view.destroy();
  392. this.navi.viewContainer.empty();
  393. MWF.xDesktop.requireApp("ForumSection", "MainInContainer", null, false);
  394. //MWF.xApplication.Forumsection.MainInContainer2 = new Class({
  395. // Extends: MWF.xApplication.ForumSection.MainInContainer,
  396. // loadLayout: function(){
  397. // this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  398. // this.toWeek();
  399. // }
  400. //});
  401. var container = this.navi.viewContainer;
  402. var scrollNode = this.app.content;
  403. var forumSection = this.navi.view = new MWF.xApplication.ForumSection.MainInContainer( this.app.desktop, {
  404. "hasTop" : false,
  405. "hasBreadCrumb" : true,
  406. "sectionId" : this.data.id,
  407. "naviMode" : true,
  408. "autoWidth" : true,
  409. "onPostCreateViewBody" : function(){
  410. this.navi.setNodeSize();
  411. this.navi.scrollToTop();
  412. }.bind(this)
  413. }, container, this.app.content , scrollNode );
  414. forumSection.forumNavi = this.navi;
  415. forumSection.inBrowser = this.navi.app.inBrowser;
  416. forumSection.window = this.navi.app.window;
  417. forumSection.taskitem = this.navi.app.taskitem;
  418. forumSection.load();
  419. }
  420. });
  421. MWFForum.NaviMode.AllItem = new Class({
  422. initialize: function ( navi, container) {
  423. this.type = MWFForum.NaviType.all;
  424. this.navi = navi;
  425. this.app = navi.app;
  426. this.container = $(container);
  427. this.css = navi.css;
  428. this.load();
  429. },
  430. load: function(){
  431. var _self = this;
  432. this.isCurrent = false;
  433. if( this.navi.options.type == MWFForum.NaviType.all ){
  434. this.isCurrent = true;
  435. }
  436. var _self = this;
  437. this.node = new Element("div.allNode", {
  438. "styles": this.css.allNode,
  439. "text" : MWF.xApplication.Forum.LP.all1
  440. }).inject(this.container);
  441. this.node.addEvents({
  442. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.allNode_over) },
  443. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.allNode ) },
  444. "click": function (el) {
  445. _self.setCurrent();
  446. }
  447. });
  448. if( this.isCurrent ){
  449. this.setCurrent()
  450. }
  451. },
  452. setCurrent : function(){
  453. if( this.navi.currentItem ){
  454. this.navi.currentItem.cancelCurrent();
  455. }
  456. this.node.setStyles( this.css.allNode_selected );
  457. this.isCurrent = true;
  458. this.navi.currentItem = this;
  459. this.navi.setTitle( MWF.xApplication.Forum.LP.allSubject );
  460. this.loadView();
  461. },
  462. cancelCurrent : function(){
  463. this.isCurrent = false;
  464. this.node.setStyles( this.css.allNode );
  465. },
  466. getCategoryId : function(){
  467. return null;
  468. },
  469. loadView : function( ){
  470. if(this.navi.view)this.navi.view.destroy();
  471. this.navi.viewContainer.empty();
  472. this.viewWarp = new Element("div").inject( this.navi.viewContainer );
  473. var topNode = this.topNode = new Element("div.topNode", {
  474. "styles": this.css.topNode
  475. }).inject(this.viewWarp );
  476. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  477. "styles": this.css.topTitleMiddleNode
  478. }).inject(topNode);
  479. var topItemTitleNode = new Element("div.topItemTitleNode", {
  480. "styles": this.css.topItemTitleNode,
  481. "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
  482. }).inject(topTitleMiddleNode);
  483. var topItemSepNode = new Element("div.topItemSepNode", {
  484. "styles": this.css.topItemSepNode,
  485. "text" : ">"
  486. }).inject(topTitleMiddleNode);
  487. topItemTitleNode.addEvent("click", function(){
  488. this.navi.goto( MWFForum.NaviType.main )
  489. }.bind(this));
  490. var topItemTitleNode = new Element("div.topItemTitleNode", {
  491. "styles": this.css.topItemTitleLastNode,
  492. "text": MWF.xApplication.Forum.LP.allSubject
  493. }).inject(topTitleMiddleNode);
  494. var view = this.navi.view = new MWFForum.NaviMode.AllView( this.viewWarp, this.app, this, {
  495. templateUrl : this.navi.path + this.navi.options.style + "/"+"listItem.json",
  496. pagingEnable : true,
  497. pagingPar : {
  498. hasReturn : false,
  499. currentPage : this.navi.options.viewPageNum,
  500. countPerPage : 30
  501. },
  502. onPostCreateViewBody : function(){
  503. this.navi.setNodeSize();
  504. this.navi.scrollToTop();
  505. }.bind(this)
  506. } );
  507. view.pagingContainerTop = this.pagingBarTop;
  508. view.pagingContainerBottom = this.pagingBarBottom;
  509. view.load();
  510. }
  511. });
  512. MWFForum.NaviMode.RecommandItem = new Class({
  513. initialize: function ( navi, container) {
  514. this.type = MWFForum.NaviType.recommand;
  515. this.navi = navi;
  516. this.app = navi.app;
  517. this.container = $(container);
  518. this.css = navi.css;
  519. this.load();
  520. },
  521. load: function(){
  522. var _self = this;
  523. this.isCurrent = false;
  524. if( this.navi.options.type == MWFForum.NaviType.recommand ){
  525. this.isCurrent = true;
  526. }
  527. var _self = this;
  528. this.node = new Element("div.recommandNode", {
  529. "styles": this.css.recommandNode,
  530. "text" : MWF.xApplication.Forum.LP.recommanded
  531. }).inject(this.container);
  532. this.node.addEvents({
  533. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.recommandNode_over) },
  534. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.recommandNode ) },
  535. "click": function (el) {
  536. _self.setCurrent();
  537. }
  538. });
  539. if( this.isCurrent ){
  540. this.setCurrent()
  541. }
  542. },
  543. setCurrent : function(){
  544. if( this.navi.currentItem ){
  545. this.navi.currentItem.cancelCurrent();
  546. }
  547. this.node.setStyles( this.css.recommandNode_selected );
  548. this.isCurrent = true;
  549. this.navi.currentItem = this;
  550. this.navi.setTitle( MWF.xApplication.Forum.LP.recommandedSubject );
  551. this.loadView();
  552. },
  553. cancelCurrent : function(){
  554. this.isCurrent = false;
  555. this.node.setStyles( this.css.recommandNode );
  556. },
  557. getCategoryId : function(){
  558. return null;
  559. },
  560. loadView : function( ){
  561. if(this.navi.view)this.navi.view.destroy();
  562. this.navi.viewContainer.empty();
  563. this.viewWarp = new Element("div").inject( this.navi.viewContainer );
  564. var topNode = this.topNode = new Element("div.topNode", {
  565. "styles": this.css.topNode
  566. }).inject(this.viewWarp );
  567. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  568. "styles": this.css.topTitleMiddleNode
  569. }).inject(topNode);
  570. var topItemTitleNode = new Element("div.topItemTitleNode", {
  571. "styles": this.css.topItemTitleNode,
  572. "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
  573. }).inject(topTitleMiddleNode);
  574. var topItemSepNode = new Element("div.topItemSepNode", {
  575. "styles": this.css.topItemSepNode,
  576. "text" : ">"
  577. }).inject(topTitleMiddleNode);
  578. topItemTitleNode.addEvent("click", function(){
  579. this.navi.goto( MWFForum.NaviType.main )
  580. }.bind(this));
  581. var topItemTitleNode = new Element("div.topItemTitleNode", {
  582. "styles": this.css.topItemTitleLastNode,
  583. "text": MWF.xApplication.Forum.LP.recommandedSubject
  584. }).inject(topTitleMiddleNode);
  585. var view = this.navi.view = new MWFForum.NaviMode.RecommandView( this.viewWarp, this.app, this, {
  586. templateUrl : this.navi.path + this.navi.options.style + "/"+"listItem.json",
  587. pagingEnable : true,
  588. pagingPar : {
  589. hasReturn : false,
  590. currentPage : this.navi.options.viewPageNum,
  591. countPerPage : 30
  592. },
  593. onPostCreateViewBody : function(){
  594. this.navi.setNodeSize();
  595. this.navi.scrollToTop();
  596. }.bind(this)
  597. } );
  598. view.pagingContainerTop = this.pagingBarTop;
  599. view.pagingContainerBottom = this.pagingBarBottom;
  600. view.load();
  601. }
  602. });
  603. MWFForum.NaviMode.CreamItem = new Class({
  604. initialize: function ( navi, container) {
  605. this.type = MWFForum.NaviType.cream;
  606. this.navi = navi;
  607. this.app = navi.app;
  608. this.container = $(container);
  609. this.css = navi.css;
  610. this.load();
  611. },
  612. load: function(){
  613. var _self = this;
  614. this.isCurrent = false;
  615. if( this.navi.options.type == MWFForum.NaviType.cream ){
  616. this.isCurrent = true;
  617. }
  618. var _self = this;
  619. this.node = new Element("div.cream", {
  620. "styles": this.css.recommandNode,
  621. "text" : MWF.xApplication.Forum.LP.prime
  622. }).inject(this.container);
  623. this.node.addEvents({
  624. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.recommandNode_over) },
  625. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.recommandNode ) },
  626. "click": function (el) {
  627. _self.setCurrent();
  628. }
  629. });
  630. if( this.isCurrent ){
  631. this.setCurrent()
  632. }
  633. },
  634. setCurrent : function(){
  635. if( this.navi.currentItem ){
  636. this.navi.currentItem.cancelCurrent();
  637. }
  638. this.node.setStyles( this.css.recommandNode_selected );
  639. this.isCurrent = true;
  640. this.navi.currentItem = this;
  641. this.navi.setTitle( MWF.xApplication.Forum.LP.primeSubject );
  642. this.loadView();
  643. },
  644. cancelCurrent : function(){
  645. this.isCurrent = false;
  646. this.node.setStyles( this.css.recommandNode );
  647. },
  648. getCategoryId : function(){
  649. return null;
  650. },
  651. loadView : function( ){
  652. if(this.navi.view)this.navi.view.destroy();
  653. this.navi.viewContainer.empty();
  654. this.viewWarp = new Element("div").inject( this.navi.viewContainer );
  655. var topNode = this.topNode = new Element("div.topNode", {
  656. "styles": this.css.topNode
  657. }).inject(this.viewWarp );
  658. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  659. "styles": this.css.topTitleMiddleNode
  660. }).inject(topNode);
  661. var topItemTitleNode = new Element("div.topItemTitleNode", {
  662. "styles": this.css.topItemTitleNode,
  663. "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
  664. }).inject(topTitleMiddleNode);
  665. var topItemSepNode = new Element("div.topItemSepNode", {
  666. "styles": this.css.topItemSepNode,
  667. "text" : ">"
  668. }).inject(topTitleMiddleNode);
  669. topItemTitleNode.addEvent("click", function(){
  670. this.navi.goto( MWFForum.NaviType.main )
  671. }.bind(this));
  672. var topItemTitleNode = new Element("div.topItemTitleNode", {
  673. "styles": this.css.topItemTitleLastNode,
  674. "text": MWF.xApplication.Forum.LP.primeSubject
  675. }).inject(topTitleMiddleNode);
  676. var view = this.navi.view = new MWFForum.NaviMode.CreamView( this.viewWarp, this.app, this, {
  677. templateUrl : this.navi.path + this.navi.options.style + "/"+"listItem.json",
  678. pagingEnable : true,
  679. pagingPar : {
  680. hasReturn : false,
  681. currentPage : this.navi.options.viewPageNum,
  682. countPerPage : 30
  683. },
  684. onPostCreateViewBody : function(){
  685. this.navi.setNodeSize();
  686. this.navi.scrollToTop();
  687. }.bind(this)
  688. } );
  689. view.pagingContainerTop = this.pagingBarTop;
  690. view.pagingContainerBottom = this.pagingBarBottom;
  691. view.load();
  692. }
  693. });
  694. MWFForum.NaviMode.AllView = new Class({
  695. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  696. _createDocument: function(data, index){
  697. return new MWFForum.NaviMode.Document(this.viewNode, data, this.explorer, this, null, index);
  698. },
  699. _getCurrentPageData: function(callback, count, pageNum){
  700. this.clearBody();
  701. if(!count)count=30;
  702. if(!pageNum)pageNum = 1;
  703. var filter = this.filterData || {};
  704. //{"withTopSubject":true};
  705. this.actions.listSubjectFilterPage( pageNum, count, filter, function(json){
  706. if( !json.data )json.data = [];
  707. if( !json.count )json.count=0;
  708. if( callback )callback(json);
  709. }.bind(this))
  710. },
  711. _removeDocument: function(documentData, all){
  712. this.actions.deleteSubject(documentData.id, function(json){
  713. this.reload();
  714. this.app.reloadAllParents( documentData.sectionId );
  715. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  716. }.bind(this));
  717. },
  718. _create: function(){
  719. },
  720. _openDocument: function( documentData,index ){
  721. var appId = "ForumDocument"+documentData.id;
  722. if (this.app.desktop.apps[appId]){
  723. this.app.desktop.apps[appId].setCurrent();
  724. }else {
  725. this.app.desktop.openApplication(null, "ForumDocument", {
  726. "sectionId" : documentData.sectionId,
  727. "id" : documentData.id,
  728. "appId": appId,
  729. "isEdited" : false,
  730. "isNew" : false,
  731. "index" : index
  732. });
  733. }
  734. },
  735. _queryCreateViewNode: function(){
  736. },
  737. _postCreateViewNode: function( viewNode ){
  738. },
  739. _queryCreateViewHead:function(){
  740. },
  741. _postCreateViewHead: function( headNode ){
  742. },
  743. isAdmin : function(){
  744. return false;
  745. }
  746. });
  747. MWFForum.NaviMode.RecommandView = new Class({
  748. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  749. _createDocument: function(data, index){
  750. return new MWFForum.NaviMode.Document(this.viewNode, data, this.explorer, this, null, index);
  751. },
  752. _getCurrentPageData: function(callback, count, pageNum){
  753. this.clearBody();
  754. if(!count)count=30;
  755. if(!pageNum)pageNum = 1;
  756. var filter = this.filterData ||
  757. {"subjectId":"","voteOptionId":"","forumId":"","mainSectionId":"","sectionId":"","searchContent":"","creatorName":"","needPicture":"","withTopSubject":true};
  758. this.actions.listRecommendedPage( pageNum, count, filter, function(json){
  759. if( !json.data )json.data = [];
  760. if( !json.count )json.count=0;
  761. if( callback )callback(json);
  762. }.bind(this))
  763. },
  764. _removeDocument: function(documentData, all){
  765. this.actions.deleteSubject(documentData.id, function(json){
  766. this.reload();
  767. this.app.reloadAllParents( documentData.sectionId );
  768. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  769. }.bind(this));
  770. },
  771. _create: function(){
  772. },
  773. _openDocument: function( documentData,index ){
  774. var appId = "ForumDocument"+documentData.id;
  775. if (this.app.desktop.apps[appId]){
  776. this.app.desktop.apps[appId].setCurrent();
  777. }else {
  778. this.app.desktop.openApplication(null, "ForumDocument", {
  779. "sectionId" : documentData.sectionId,
  780. "id" : documentData.id,
  781. "appId": appId,
  782. "isEdited" : false,
  783. "isNew" : false,
  784. "index" : index
  785. });
  786. }
  787. },
  788. _queryCreateViewNode: function(){
  789. },
  790. _postCreateViewNode: function( viewNode ){
  791. },
  792. _queryCreateViewHead:function(){
  793. },
  794. _postCreateViewHead: function( headNode ){
  795. }
  796. });
  797. MWFForum.NaviMode.CreamView = new Class({
  798. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  799. _createDocument: function(data, index){
  800. return new MWFForum.NaviMode.Document(this.viewNode, data, this.explorer, this, null, index);
  801. },
  802. _getCurrentPageData: function(callback, count, pageNum){
  803. this.clearBody();
  804. if(!count)count=30;
  805. if(!pageNum)pageNum = 1;
  806. var filter = this.filterData || {};
  807. this.actions.listCreamSubjectFilterPage( pageNum, count, filter, function(json){
  808. if( !json.data )json.data = [];
  809. if( !json.count )json.count=0;
  810. if( callback )callback(json);
  811. }.bind(this))
  812. },
  813. _removeDocument: function(documentData, all){
  814. this.actions.deleteSubject(documentData.id, function(json){
  815. this.reload();
  816. this.app.reloadAllParents( documentData.sectionId );
  817. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  818. }.bind(this));
  819. },
  820. _create: function(){
  821. },
  822. _openDocument: function( documentData,index ){
  823. var appId = "ForumDocument"+documentData.id;
  824. if (this.app.desktop.apps[appId]){
  825. this.app.desktop.apps[appId].setCurrent();
  826. }else {
  827. this.app.desktop.openApplication(null, "ForumDocument", {
  828. "sectionId" : documentData.sectionId,
  829. "id" : documentData.id,
  830. "appId": appId,
  831. "isEdited" : false,
  832. "isNew" : false,
  833. "index" : index
  834. });
  835. }
  836. },
  837. _queryCreateViewNode: function(){
  838. },
  839. _postCreateViewNode: function( viewNode ){
  840. },
  841. _queryCreateViewHead:function(){
  842. },
  843. _postCreateViewHead: function( headNode ){
  844. }
  845. });
  846. MWFForum.NaviMode.Document = new Class({
  847. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  848. _queryCreateDocumentNode:function( itemData ){
  849. },
  850. _postCreateDocumentNode: function( itemNode, itemData ){
  851. },
  852. open: function (e) {
  853. this.view._openDocument(this.data, this.index);
  854. },
  855. edit : function(){
  856. var appId = "ForumDocument"+this.data.id;
  857. if (this.app.desktop.apps[appId]){
  858. this.app.desktop.apps[appId].setCurrent();
  859. }else {
  860. this.app.desktop.openApplication(null, "ForumDocument", {
  861. "sectionId" : this.data.sectionId,
  862. "id" : this.data.id,
  863. "appId": appId,
  864. "isEdited" : true,
  865. "isNew" : false,
  866. "index" : this.index
  867. });
  868. }
  869. },
  870. openSection : function( ev ){
  871. var data = this.data;
  872. if( this.view.explorer && this.view.explorer.navi ){
  873. this.view.explorer.navi.goto( MWFForum.NaviType.section, data.sectionId );
  874. }else{
  875. var appId = "ForumSection"+ data.sectionId;
  876. if (this.app.desktop.apps[appId]){
  877. this.app.desktop.apps[appId].setCurrent();
  878. }else {
  879. this.app.desktop.openApplication(ev, "ForumSection", {
  880. "sectionId": data.sectionId,
  881. "appId": appId
  882. });
  883. }
  884. }
  885. ev.stopPropagation();
  886. },
  887. isAdmin: function(){
  888. return this.app.access.isAdmin();
  889. }
  890. });