NaviMode.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  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. }).inject(this.node);
  206. this.node.addEvents({
  207. "mouseover": function(){
  208. if ( !_self.isCurrent ){
  209. this.setStyles(_self.css.categoryNode_over);
  210. _self.setExpendNodeStyle( true );
  211. }
  212. },
  213. "mouseout": function(){
  214. if ( !_self.isCurrent ){
  215. this.setStyles( _self.css.categoryNode );
  216. _self.setExpendNodeStyle();
  217. }
  218. },
  219. click : function(){ _self.setCurrent(this);}
  220. });
  221. this.listNode = new Element("div.sectionListNode",{
  222. "styles" : this.css.sectionListNode
  223. }).inject(this.container);
  224. this.loadListContent();
  225. if( this.isCurrent ){
  226. this.setCurrent();
  227. }
  228. },
  229. setExpendNodeStyle : function( isOver ){
  230. var style;
  231. if( this.hasSub ){
  232. if( this.isExpended ){
  233. if( isOver ){
  234. style = this.css.categoryExpendNode_over;
  235. }else if( this.isCurrent ){
  236. style = this.css.categoryExpendNode_selected;
  237. }else{
  238. style = this.css.categoryExpendNode;
  239. }
  240. }else{
  241. if( isOver ){
  242. style = this.css.categoryCollapseNode_over;
  243. }else if( this.isCurrent ){
  244. style = this.css.categoryCollapseNode_selected;
  245. }else{
  246. style = this.css.categoryCollapseNode;
  247. }
  248. }
  249. }else{
  250. style = this.css.emptyExpendNode;
  251. }
  252. this.expendNode.setStyles( style );
  253. },
  254. triggerExpend : function(){
  255. if( this.hasSub ){
  256. if( this.isExpended ){
  257. this.isExpended = false;
  258. this.listNode.setStyle("display","none")
  259. }else{
  260. this.isExpended = true;
  261. this.listNode.setStyle("display","")
  262. }
  263. this.setExpendNodeStyle();
  264. }
  265. },
  266. setCurrent : function(){
  267. if( this.navi.currentItem ){
  268. this.navi.currentItem.cancelCurrent();
  269. }
  270. this.node.setStyles( this.css.categoryNode_selected );
  271. if( this.hasSub ){
  272. if( this.isExpended ){
  273. this.expendNode.setStyles( this.css.categoryExpendNode_selected );
  274. }else{
  275. this.expendNode.setStyles( this.css.categoryCollapseNode_selected );
  276. }
  277. }
  278. this.isCurrent = true;
  279. this.navi.currentItem = this;
  280. this.navi.setTitle( this.data.forumName );
  281. this.loadView();
  282. },
  283. cancelCurrent : function(){
  284. this.isCurrent = false;
  285. this.node.setStyles( this.css.categoryNode );
  286. if( this.hasSub ){
  287. if( this.isExpended ){
  288. this.expendNode.setStyles( this.css.categoryExpendNode );
  289. }else{
  290. this.expendNode.setStyles( this.css.categoryCollapseNode );
  291. }
  292. }
  293. },
  294. loadView: function( searchkey ){
  295. this.app.openView( this, this.data, this.viewData || this.defaultRevealData, searchkey || "", this );
  296. },
  297. loadListContent : function(){
  298. var d = this.data;
  299. if(d.forumStatus != "停用" ){
  300. MWF.Actions.get("x_bbs_assemble_control").listSection(d.id , function ( json ) {
  301. (json.data || []).each( function( sectiondata ){
  302. var sectionItem = new MWFForum.NaviMode.SectionItem(this.navi, this, this.listNode, sectiondata );
  303. this.sectionItemList.push( sectionItem );
  304. }.bind(this))
  305. }.bind(this));
  306. }
  307. new Element("div", {
  308. "styles": this.css.categorySepartorNode
  309. }).inject( this.listNode );
  310. },
  311. getCategoryId : function(){
  312. return this.data.id;
  313. },
  314. loadView : function(){
  315. if(this.navi.view)this.navi.view.destroy();
  316. this.navi.viewContainer.empty();
  317. MWF.xDesktop.requireApp("ForumCategory", "MainInContainer", null, false);
  318. var container = this.navi.viewContainer;
  319. var scrollNode = this.app.content;
  320. var forumCategory = this.navi.view = new MWF.xApplication.ForumCategory.MainInContainer( this.app.desktop, {
  321. "hasTop" : false,
  322. "hasBreadCrumb" : true,
  323. "categoryId" : this.data.id,
  324. "naviMode" : true,
  325. "autoWidth" : true,
  326. "onPostLoadCategory" : function(){
  327. this.navi.setNodeSize();
  328. this.navi.scrollToTop();
  329. }.bind(this)
  330. }, container, this.app.content , scrollNode );
  331. forumCategory.forumNavi = this.navi;
  332. forumCategory.inBrowser = this.navi.app.inBrowser;
  333. forumCategory.window = this.app.window;
  334. forumCategory.taskitem = this.navi.app.taskitem;
  335. forumCategory.load();
  336. }
  337. });
  338. MWFForum.NaviMode.SectionItem = new Class({
  339. initialize: function ( navi, category, container, data) {
  340. this.type = MWFForum.NaviType.section;
  341. this.navi = navi;
  342. this.category = category;
  343. this.app = navi.app;
  344. this.data = data;
  345. this.container = $(container);
  346. this.css = navi.css;
  347. this.load();
  348. },
  349. load: function(){
  350. this.navi.sectionItemMap[ this.data.id ] = this;
  351. var _self = this;
  352. this.isCurrent = false;
  353. if( this.navi.options.type == MWFForum.NaviType.section && this.navi.options.id == this.data.id ){
  354. this.isCurrent = true;
  355. }
  356. var _self = this;
  357. this.node = new Element("div.sectionNode", {
  358. "styles": this.css.sectionNode,
  359. "text" : this.data.sectionName
  360. }).inject(this.container);
  361. this.node.addEvents({
  362. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.sectionNode_over) },
  363. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.sectionNode ) },
  364. "click": function (el) {
  365. _self.setCurrent();
  366. }
  367. });
  368. if( this.isCurrent ){
  369. this.setCurrent()
  370. }
  371. },
  372. setCurrent : function(){
  373. if( this.navi.currentItem ){
  374. this.navi.currentItem.cancelCurrent();
  375. }
  376. this.node.setStyles( this.css.sectionNode_selected );
  377. this.isCurrent = true;
  378. this.navi.currentItem = this;
  379. this.navi.setTitle( this.data.sectionName );
  380. this.loadView();
  381. },
  382. cancelCurrent : function(){
  383. this.isCurrent = false;
  384. this.node.setStyles( this.css.sectionNode );
  385. },
  386. getCategoryId : function(){
  387. return this.category.data.id;
  388. },
  389. loadView : function(){
  390. if(this.navi.view)this.navi.view.destroy();
  391. this.navi.viewContainer.empty();
  392. MWF.xDesktop.requireApp("ForumSection", "MainInContainer", null, false);
  393. //MWF.xApplication.Forumsection.MainInContainer2 = new Class({
  394. // Extends: MWF.xApplication.ForumSection.MainInContainer,
  395. // loadLayout: function(){
  396. // this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  397. // this.toWeek();
  398. // }
  399. //});
  400. var container = this.navi.viewContainer;
  401. var scrollNode = this.app.content;
  402. var forumSection = this.navi.view = new MWF.xApplication.ForumSection.MainInContainer( this.app.desktop, {
  403. "hasTop" : false,
  404. "hasBreadCrumb" : true,
  405. "sectionId" : this.data.id,
  406. "naviMode" : true,
  407. "autoWidth" : true,
  408. "onPostCreateViewBody" : function(){
  409. this.navi.setNodeSize();
  410. this.navi.scrollToTop();
  411. }.bind(this)
  412. }, container, this.app.content , scrollNode );
  413. forumSection.forumNavi = this.navi;
  414. forumSection.inBrowser = this.navi.app.inBrowser;
  415. forumSection.window = this.navi.app.window;
  416. forumSection.taskitem = this.navi.app.taskitem;
  417. forumSection.load();
  418. }
  419. });
  420. MWFForum.NaviMode.AllItem = new Class({
  421. initialize: function ( navi, container) {
  422. this.type = MWFForum.NaviType.all;
  423. this.navi = navi;
  424. this.app = navi.app;
  425. this.container = $(container);
  426. this.css = navi.css;
  427. this.load();
  428. },
  429. load: function(){
  430. var _self = this;
  431. this.isCurrent = false;
  432. if( this.navi.options.type == MWFForum.NaviType.all ){
  433. this.isCurrent = true;
  434. }
  435. var _self = this;
  436. this.node = new Element("div.allNode", {
  437. "styles": this.css.allNode,
  438. "text" : "全部"
  439. }).inject(this.container);
  440. this.node.addEvents({
  441. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.allNode_over) },
  442. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.allNode ) },
  443. "click": function (el) {
  444. _self.setCurrent();
  445. }
  446. });
  447. if( this.isCurrent ){
  448. this.setCurrent()
  449. }
  450. },
  451. setCurrent : function(){
  452. if( this.navi.currentItem ){
  453. this.navi.currentItem.cancelCurrent();
  454. }
  455. this.node.setStyles( this.css.allNode_selected );
  456. this.isCurrent = true;
  457. this.navi.currentItem = this;
  458. this.navi.setTitle( MWF.xApplication.Forum.LP.allSubject );
  459. this.loadView();
  460. },
  461. cancelCurrent : function(){
  462. this.isCurrent = false;
  463. this.node.setStyles( this.css.allNode );
  464. },
  465. getCategoryId : function(){
  466. return null;
  467. },
  468. loadView : function( ){
  469. if(this.navi.view)this.navi.view.destroy();
  470. this.navi.viewContainer.empty();
  471. this.viewWarp = new Element("div").inject( this.navi.viewContainer );
  472. var topNode = this.topNode = new Element("div.topNode", {
  473. "styles": this.css.topNode
  474. }).inject(this.viewWarp );
  475. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  476. "styles": this.css.topTitleMiddleNode
  477. }).inject(topNode);
  478. var topItemTitleNode = new Element("div.topItemTitleNode", {
  479. "styles": this.css.topItemTitleNode,
  480. "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
  481. }).inject(topTitleMiddleNode);
  482. var topItemSepNode = new Element("div.topItemSepNode", {
  483. "styles": this.css.topItemSepNode,
  484. "text" : ">"
  485. }).inject(topTitleMiddleNode);
  486. topItemTitleNode.addEvent("click", function(){
  487. this.navi.goto( MWFForum.NaviType.main )
  488. }.bind(this));
  489. var topItemTitleNode = new Element("div.topItemTitleNode", {
  490. "styles": this.css.topItemTitleLastNode,
  491. "text": MWF.xApplication.Forum.LP.allSubject
  492. }).inject(topTitleMiddleNode);
  493. var view = this.navi.view = new MWFForum.NaviMode.AllView( this.viewWarp, this.app, this, {
  494. templateUrl : this.navi.path + this.navi.options.style + "/"+"listItem.json",
  495. pagingEnable : true,
  496. pagingPar : {
  497. hasReturn : false,
  498. currentPage : this.navi.options.viewPageNum,
  499. countPerPage : 30
  500. },
  501. onPostCreateViewBody : function(){
  502. this.navi.setNodeSize();
  503. this.navi.scrollToTop();
  504. }.bind(this)
  505. } );
  506. view.pagingContainerTop = this.pagingBarTop;
  507. view.pagingContainerBottom = this.pagingBarBottom;
  508. view.load();
  509. }
  510. });
  511. MWFForum.NaviMode.RecommandItem = new Class({
  512. initialize: function ( navi, container) {
  513. this.type = MWFForum.NaviType.recommand;
  514. this.navi = navi;
  515. this.app = navi.app;
  516. this.container = $(container);
  517. this.css = navi.css;
  518. this.load();
  519. },
  520. load: function(){
  521. var _self = this;
  522. this.isCurrent = false;
  523. if( this.navi.options.type == MWFForum.NaviType.recommand ){
  524. this.isCurrent = true;
  525. }
  526. var _self = this;
  527. this.node = new Element("div.recommandNode", {
  528. "styles": this.css.recommandNode,
  529. "text" : MWF.xApplication.Forum.LP.recommanded
  530. }).inject(this.container);
  531. this.node.addEvents({
  532. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.recommandNode_over) },
  533. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.recommandNode ) },
  534. "click": function (el) {
  535. _self.setCurrent();
  536. }
  537. });
  538. if( this.isCurrent ){
  539. this.setCurrent()
  540. }
  541. },
  542. setCurrent : function(){
  543. if( this.navi.currentItem ){
  544. this.navi.currentItem.cancelCurrent();
  545. }
  546. this.node.setStyles( this.css.recommandNode_selected );
  547. this.isCurrent = true;
  548. this.navi.currentItem = this;
  549. this.navi.setTitle( MWF.xApplication.Forum.LP.recommandedSubject );
  550. this.loadView();
  551. },
  552. cancelCurrent : function(){
  553. this.isCurrent = false;
  554. this.node.setStyles( this.css.recommandNode );
  555. },
  556. getCategoryId : function(){
  557. return null;
  558. },
  559. loadView : function( ){
  560. if(this.navi.view)this.navi.view.destroy();
  561. this.navi.viewContainer.empty();
  562. this.viewWarp = new Element("div").inject( this.navi.viewContainer );
  563. var topNode = this.topNode = new Element("div.topNode", {
  564. "styles": this.css.topNode
  565. }).inject(this.viewWarp );
  566. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  567. "styles": this.css.topTitleMiddleNode
  568. }).inject(topNode);
  569. var topItemTitleNode = new Element("div.topItemTitleNode", {
  570. "styles": this.css.topItemTitleNode,
  571. "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
  572. }).inject(topTitleMiddleNode);
  573. var topItemSepNode = new Element("div.topItemSepNode", {
  574. "styles": this.css.topItemSepNode,
  575. "text" : ">"
  576. }).inject(topTitleMiddleNode);
  577. topItemTitleNode.addEvent("click", function(){
  578. this.navi.goto( MWFForum.NaviType.main )
  579. }.bind(this));
  580. var topItemTitleNode = new Element("div.topItemTitleNode", {
  581. "styles": this.css.topItemTitleLastNode,
  582. "text": MWF.xApplication.Forum.LP.recommandedSubject
  583. }).inject(topTitleMiddleNode);
  584. var view = this.navi.view = new MWFForum.NaviMode.RecommandView( this.viewWarp, this.app, this, {
  585. templateUrl : this.navi.path + this.navi.options.style + "/"+"listItem.json",
  586. pagingEnable : true,
  587. pagingPar : {
  588. hasReturn : false,
  589. currentPage : this.navi.options.viewPageNum,
  590. countPerPage : 30
  591. },
  592. onPostCreateViewBody : function(){
  593. this.navi.setNodeSize();
  594. this.navi.scrollToTop();
  595. }.bind(this)
  596. } );
  597. view.pagingContainerTop = this.pagingBarTop;
  598. view.pagingContainerBottom = this.pagingBarBottom;
  599. view.load();
  600. }
  601. });
  602. MWFForum.NaviMode.CreamItem = new Class({
  603. initialize: function ( navi, container) {
  604. this.type = MWFForum.NaviType.cream;
  605. this.navi = navi;
  606. this.app = navi.app;
  607. this.container = $(container);
  608. this.css = navi.css;
  609. this.load();
  610. },
  611. load: function(){
  612. var _self = this;
  613. this.isCurrent = false;
  614. if( this.navi.options.type == MWFForum.NaviType.cream ){
  615. this.isCurrent = true;
  616. }
  617. var _self = this;
  618. this.node = new Element("div.cream", {
  619. "styles": this.css.recommandNode,
  620. "text" : MWF.xApplication.Forum.LP.prime
  621. }).inject(this.container);
  622. this.node.addEvents({
  623. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.recommandNode_over) },
  624. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.recommandNode ) },
  625. "click": function (el) {
  626. _self.setCurrent();
  627. }
  628. });
  629. if( this.isCurrent ){
  630. this.setCurrent()
  631. }
  632. },
  633. setCurrent : function(){
  634. if( this.navi.currentItem ){
  635. this.navi.currentItem.cancelCurrent();
  636. }
  637. this.node.setStyles( this.css.recommandNode_selected );
  638. this.isCurrent = true;
  639. this.navi.currentItem = this;
  640. this.navi.setTitle( MWF.xApplication.Forum.LP.primeSubject );
  641. this.loadView();
  642. },
  643. cancelCurrent : function(){
  644. this.isCurrent = false;
  645. this.node.setStyles( this.css.recommandNode );
  646. },
  647. getCategoryId : function(){
  648. return null;
  649. },
  650. loadView : function( ){
  651. if(this.navi.view)this.navi.view.destroy();
  652. this.navi.viewContainer.empty();
  653. this.viewWarp = new Element("div").inject( this.navi.viewContainer );
  654. var topNode = this.topNode = new Element("div.topNode", {
  655. "styles": this.css.topNode
  656. }).inject(this.viewWarp );
  657. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  658. "styles": this.css.topTitleMiddleNode
  659. }).inject(topNode);
  660. var topItemTitleNode = new Element("div.topItemTitleNode", {
  661. "styles": this.css.topItemTitleNode,
  662. "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
  663. }).inject(topTitleMiddleNode);
  664. var topItemSepNode = new Element("div.topItemSepNode", {
  665. "styles": this.css.topItemSepNode,
  666. "text" : ">"
  667. }).inject(topTitleMiddleNode);
  668. topItemTitleNode.addEvent("click", function(){
  669. this.navi.goto( MWFForum.NaviType.main )
  670. }.bind(this));
  671. var topItemTitleNode = new Element("div.topItemTitleNode", {
  672. "styles": this.css.topItemTitleLastNode,
  673. "text": MWF.xApplication.Forum.LP.primeSubject
  674. }).inject(topTitleMiddleNode);
  675. var view = this.navi.view = new MWFForum.NaviMode.CreamView( this.viewWarp, this.app, this, {
  676. templateUrl : this.navi.path + this.navi.options.style + "/"+"listItem.json",
  677. pagingEnable : true,
  678. pagingPar : {
  679. hasReturn : false,
  680. currentPage : this.navi.options.viewPageNum,
  681. countPerPage : 30
  682. },
  683. onPostCreateViewBody : function(){
  684. this.navi.setNodeSize();
  685. this.navi.scrollToTop();
  686. }.bind(this)
  687. } );
  688. view.pagingContainerTop = this.pagingBarTop;
  689. view.pagingContainerBottom = this.pagingBarBottom;
  690. view.load();
  691. }
  692. });
  693. MWFForum.NaviMode.AllView = new Class({
  694. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  695. _createDocument: function(data, index){
  696. return new MWFForum.NaviMode.Document(this.viewNode, data, this.explorer, this, null, index);
  697. },
  698. _getCurrentPageData: function(callback, count, pageNum){
  699. this.clearBody();
  700. if(!count)count=30;
  701. if(!pageNum)pageNum = 1;
  702. var filter = this.filterData || {};
  703. //{"withTopSubject":true};
  704. this.actions.listSubjectFilterPage( pageNum, count, filter, function(json){
  705. if( !json.data )json.data = [];
  706. if( !json.count )json.count=0;
  707. if( callback )callback(json);
  708. }.bind(this))
  709. },
  710. _removeDocument: function(documentData, all){
  711. this.actions.deleteSubject(documentData.id, function(json){
  712. this.reload();
  713. this.app.reloadAllParents( documentData.sectionId );
  714. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  715. }.bind(this));
  716. },
  717. _create: function(){
  718. },
  719. _openDocument: function( documentData,index ){
  720. var appId = "ForumDocument"+documentData.id;
  721. if (this.app.desktop.apps[appId]){
  722. this.app.desktop.apps[appId].setCurrent();
  723. }else {
  724. this.app.desktop.openApplication(null, "ForumDocument", {
  725. "sectionId" : documentData.sectionId,
  726. "id" : documentData.id,
  727. "appId": appId,
  728. "isEdited" : false,
  729. "isNew" : false,
  730. "index" : index
  731. });
  732. }
  733. },
  734. _queryCreateViewNode: function(){
  735. },
  736. _postCreateViewNode: function( viewNode ){
  737. },
  738. _queryCreateViewHead:function(){
  739. },
  740. _postCreateViewHead: function( headNode ){
  741. },
  742. isAdmin : function(){
  743. return false;
  744. }
  745. });
  746. MWFForum.NaviMode.RecommandView = new Class({
  747. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  748. _createDocument: function(data, index){
  749. return new MWFForum.NaviMode.Document(this.viewNode, data, this.explorer, this, null, index);
  750. },
  751. _getCurrentPageData: function(callback, count, pageNum){
  752. this.clearBody();
  753. if(!count)count=30;
  754. if(!pageNum)pageNum = 1;
  755. var filter = this.filterData ||
  756. {"subjectId":"","voteOptionId":"","forumId":"","mainSectionId":"","sectionId":"","searchContent":"","creatorName":"","needPicture":"","withTopSubject":true};
  757. this.actions.listRecommendedPage( pageNum, count, filter, function(json){
  758. if( !json.data )json.data = [];
  759. if( !json.count )json.count=0;
  760. if( callback )callback(json);
  761. }.bind(this))
  762. },
  763. _removeDocument: function(documentData, all){
  764. this.actions.deleteSubject(documentData.id, function(json){
  765. this.reload();
  766. this.app.reloadAllParents( documentData.sectionId );
  767. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  768. }.bind(this));
  769. },
  770. _create: function(){
  771. },
  772. _openDocument: function( documentData,index ){
  773. var appId = "ForumDocument"+documentData.id;
  774. if (this.app.desktop.apps[appId]){
  775. this.app.desktop.apps[appId].setCurrent();
  776. }else {
  777. this.app.desktop.openApplication(null, "ForumDocument", {
  778. "sectionId" : documentData.sectionId,
  779. "id" : documentData.id,
  780. "appId": appId,
  781. "isEdited" : false,
  782. "isNew" : false,
  783. "index" : index
  784. });
  785. }
  786. },
  787. _queryCreateViewNode: function(){
  788. },
  789. _postCreateViewNode: function( viewNode ){
  790. },
  791. _queryCreateViewHead:function(){
  792. },
  793. _postCreateViewHead: function( headNode ){
  794. }
  795. });
  796. MWFForum.NaviMode.CreamView = new Class({
  797. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  798. _createDocument: function(data, index){
  799. return new MWFForum.NaviMode.Document(this.viewNode, data, this.explorer, this, null, index);
  800. },
  801. _getCurrentPageData: function(callback, count, pageNum){
  802. this.clearBody();
  803. if(!count)count=30;
  804. if(!pageNum)pageNum = 1;
  805. var filter = this.filterData || {};
  806. this.actions.listCreamSubjectFilterPage( pageNum, count, filter, function(json){
  807. if( !json.data )json.data = [];
  808. if( !json.count )json.count=0;
  809. if( callback )callback(json);
  810. }.bind(this))
  811. },
  812. _removeDocument: function(documentData, all){
  813. this.actions.deleteSubject(documentData.id, function(json){
  814. this.reload();
  815. this.app.reloadAllParents( documentData.sectionId );
  816. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  817. }.bind(this));
  818. },
  819. _create: function(){
  820. },
  821. _openDocument: function( documentData,index ){
  822. var appId = "ForumDocument"+documentData.id;
  823. if (this.app.desktop.apps[appId]){
  824. this.app.desktop.apps[appId].setCurrent();
  825. }else {
  826. this.app.desktop.openApplication(null, "ForumDocument", {
  827. "sectionId" : documentData.sectionId,
  828. "id" : documentData.id,
  829. "appId": appId,
  830. "isEdited" : false,
  831. "isNew" : false,
  832. "index" : index
  833. });
  834. }
  835. },
  836. _queryCreateViewNode: function(){
  837. },
  838. _postCreateViewNode: function( viewNode ){
  839. },
  840. _queryCreateViewHead:function(){
  841. },
  842. _postCreateViewHead: function( headNode ){
  843. }
  844. });
  845. MWFForum.NaviMode.Document = new Class({
  846. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  847. _queryCreateDocumentNode:function( itemData ){
  848. },
  849. _postCreateDocumentNode: function( itemNode, itemData ){
  850. },
  851. open: function (e) {
  852. this.view._openDocument(this.data, this.index);
  853. },
  854. edit : function(){
  855. var appId = "ForumDocument"+this.data.id;
  856. if (this.app.desktop.apps[appId]){
  857. this.app.desktop.apps[appId].setCurrent();
  858. }else {
  859. this.app.desktop.openApplication(null, "ForumDocument", {
  860. "sectionId" : this.data.sectionId,
  861. "id" : this.data.id,
  862. "appId": appId,
  863. "isEdited" : true,
  864. "isNew" : false,
  865. "index" : this.index
  866. });
  867. }
  868. },
  869. openSection : function( ev ){
  870. var data = this.data;
  871. if( this.view.explorer && this.view.explorer.navi ){
  872. this.view.explorer.navi.goto( MWFForum.NaviType.section, data.sectionId );
  873. }else{
  874. var appId = "ForumSection"+ data.sectionId;
  875. if (this.app.desktop.apps[appId]){
  876. this.app.desktop.apps[appId].setCurrent();
  877. }else {
  878. this.app.desktop.openApplication(ev, "ForumSection", {
  879. "sectionId": data.sectionId,
  880. "appId": appId
  881. });
  882. }
  883. }
  884. ev.stopPropagation();
  885. },
  886. isAdmin: function(){
  887. return this.app.access.isAdmin();
  888. }
  889. });