NaviMode.js 34 KB

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