Main.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. MWF.xApplication.cms = MWF.xApplication.cms || {};
  2. MWF.CMSE = MWF.xApplication.cms.Index = MWF.xApplication.cms.Index ||{};
  3. MWF.require("MWF.widget.O2Identity", null,false);
  4. //MWF.xDesktop.requireApp("cms.Index", "Actions.RestActions", null, false);
  5. MWF.xApplication.cms.Index.options = {
  6. multitask: false,
  7. executable: true
  8. };
  9. MWF.xApplication.cms.Index.Main = new Class({
  10. Extends: MWF.xApplication.Common.Main,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "name": "cms.Index",
  15. "icon": "icon.png",
  16. "width": "1220",
  17. "height": "680",
  18. "isResize": true,
  19. "isMax": true,
  20. "title": MWF.CMSE.LP.title
  21. },
  22. onQueryLoad: function(){
  23. this.lp = MWF.xApplication.cms.Index.LP;
  24. },
  25. loadApplication: function(callback){
  26. this.columns = [];
  27. this.restActions = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.Index.Actions.RestActions();
  28. this.createNode();
  29. this.loadApplicationContent();
  30. },
  31. reload : function(){
  32. this.scrollNode.destroy();
  33. this.loadContent();
  34. this.setCurrentAppType( this.currentAppType, this.currentAppTypeNode );
  35. },
  36. createNode: function(){
  37. this.content.setStyle("overflow", "hidden");
  38. this.node = new Element("div", {
  39. "styles": this.css.container
  40. }).inject(this.content);
  41. },
  42. loadApplicationContent: function(){
  43. this.loadTitle();
  44. this.loadContent();
  45. this.setCurrentAppType( "all", this.allTypeNode );
  46. },
  47. loadTitle : function(){
  48. this.loadTitleBar();
  49. this.loadAllTypeNode();
  50. this.loadCreateDocumentActionNode();
  51. this.loadSearchNode();
  52. this.loadAppType();
  53. },
  54. loadTitleBar: function(){
  55. this.titleBarContainer = new Element("div", {
  56. "styles": this.css.titleBarContainer
  57. }).inject(this.node);
  58. this.titleBar = new Element("div", {
  59. "styles": this.css.titleBar
  60. }).inject(this.titleBarContainer);
  61. },
  62. loadAllTypeNode : function(){
  63. this.allTypeNode = new Element("div.columnTop_All",{
  64. "styles" : this.css.columnTop_All,
  65. "text" : "全部栏目"
  66. }).inject( this.titleBar );
  67. this.allTypeNode.addEvents({
  68. "mouseover" : function(){
  69. if( this.currentAppTypeNode !== this.allTypeNode )this.allTypeNode.setStyles( this.css.columnTop_All_over );
  70. }.bind(this),
  71. "mouseout" : function(){
  72. if( this.currentAppTypeNode !== this.allTypeNode )this.allTypeNode.setStyles( this.css.columnTop_All );
  73. }.bind(this),
  74. "click": function () {
  75. this.setCurrentAppType( "all", this.allTypeNode );
  76. }.bind(this)
  77. });
  78. },
  79. loadCreateDocumentActionNode: function() {
  80. this.createDocumentAction = new Element("div", {
  81. "styles": this.css.createDocumentAction,
  82. "text" : this.lp.start
  83. }).inject(this.titleBar);
  84. this.createDocumentAction.addEvents({
  85. "click": function(e){
  86. MWF.xDesktop.requireApp("cms.Index", "Newer", function(){
  87. this.creater = new MWF.xApplication.cms.Index.Newer(null,null,this,this);
  88. this.creater.load();
  89. }.bind(this));
  90. }.bind(this),
  91. "mouseover" : function(e){
  92. this.createDocumentAction.setStyles( this.css.createDocumentAction_over );
  93. this.createDocumentAction.addClass( "o2_cms_index_createDocument_over" );
  94. }.bind(this),
  95. "mouseout" : function(e){
  96. this.createDocumentAction.setStyles( this.css.createDocumentAction );
  97. this.createDocumentAction.removeClass( "o2_cms_index_createDocument_over" );
  98. }.bind(this)
  99. });
  100. },
  101. //loadTitleTextNode: function(){
  102. // this.titleTextNode = new Element("div", {
  103. // "styles": this.css.titleTextNode,
  104. // "text": this.lp.title
  105. // }).inject(this.titleBar);
  106. //},
  107. loadSearchNode: function(){
  108. this.searchBarAreaNode = new Element("div", {
  109. "styles": this.css.searchBarAreaNode
  110. }).inject(this.titleBar);
  111. this.searchBarNode = new Element("div", {
  112. "styles": this.css.searchBarNode
  113. }).inject(this.searchBarAreaNode);
  114. this.searchBarActionNode = new Element("div", {
  115. "styles": this.css.searchBarActionNode,
  116. "title" : "搜索"
  117. }).inject(this.searchBarNode);
  118. this.searchBarResetActionNode = new Element("div", {
  119. "styles": this.css.searchBarResetActionNode,
  120. "title" : "重置"
  121. }).inject(this.searchBarNode);
  122. this.searchBarResetActionNode.setStyle("display","none");
  123. this.searchBarInputBoxNode = new Element("div", {
  124. "styles": this.css.searchBarInputBoxNode
  125. }).inject(this.searchBarNode);
  126. this.searchBarInputNode = new Element("input", {
  127. "type": "text",
  128. "value": this.lp.searchKey,
  129. "styles": this.css.searchBarInputNode
  130. }).inject(this.searchBarInputBoxNode);
  131. var _self = this;
  132. this.searchBarActionNode.addEvent("click", function(){
  133. this.search();
  134. }.bind(this));
  135. this.searchBarResetActionNode.addEvent("click", function(){
  136. this.reset();
  137. }.bind(this));
  138. this.searchBarInputNode.addEvents({
  139. "focus": function(){
  140. if (this.value==_self.lp.searchKey) this.set("value", "");
  141. },
  142. "blur": function(){if (!this.value) this.set("value", _self.lp.searchKey);},
  143. "keydown": function(e){
  144. if (e.code==13){
  145. this.search();
  146. e.preventDefault();
  147. }
  148. }.bind(this),
  149. "selectstart": function(e){
  150. e.preventDefault();
  151. }
  152. });
  153. },
  154. loadAppType : function(){
  155. var _self = this;
  156. this.typeListContainer = new Element("div.columnTop_category", {
  157. "styles": this.css.columnTop_category
  158. }).inject(this.titleBar);
  159. this.restActions.listAllAppType( function( json ){
  160. (json.data || []).each( function( typeObject ){
  161. new Element( "div.columnTop_category", {
  162. "styles" : this.css.columnTop_categoryItem,
  163. "text" : typeObject.appType + "(" + typeObject.count + ")",
  164. "events" : {
  165. "mouseover" : function( ev ){
  166. if( this.currentAppTypeNode !== ev.target )ev.target.setStyles( this.css.columnTop_categoryItem_over );
  167. }.bind(this),
  168. "mouseout" : function( ev ){
  169. if( this.currentAppTypeNode !== ev.target )ev.target.setStyles( this.css.columnTop_categoryItem );
  170. }.bind(this),
  171. "click": function ( ev ) {
  172. _self.setCurrentAppType( this, ev.target );
  173. }.bind( typeObject.appType )
  174. }
  175. }).inject( this.typeListContainer )
  176. }.bind(this))
  177. if (this.typeListContainer.getScrollSize().y> Math.round(this.typeListContainer.getSize().y) && !this.columnTypeExpandNode ) this.createTypeExpandButton();
  178. }.bind(this))
  179. },
  180. createTypeExpandButton : function(){
  181. this.columnTypeExpandNode = new Element("div.columnTop_categoryExpandButton",{
  182. "styles" : this.css.columnTop_categoryExpandButton
  183. }).inject( this.typeListContainer, "before" );
  184. this.columnTypeExpandNode.addEvent("click", this.expandOrCollapseCategory.bind(this));
  185. },
  186. expandOrCollapseCategory : function(e){
  187. if (!this.categoryMorph) this.categoryMorph = new Fx.Morph(this.typeListContainer, {"duration": 100});
  188. if( !this.expand ){
  189. this.typeListContainer.setStyle( "width", this.typeListContainer.getSize().x + "px" );
  190. this.typeListContainer.setStyles( this.css.columnTop_category_more );
  191. this.categoryMorph.start({"height": ""+this.typeListContainer.getScrollSize().y+"px"});
  192. this.expandOrCollapseCategoryFun = this.expandOrCollapseCategory.bind(this);
  193. this.content.addEvent("click", this.expandOrCollapseCategoryFun);
  194. this.expand = true;
  195. }else{
  196. this.typeListContainer.setStyle( "width", "auto" );
  197. this.typeListContainer.setStyles( this.css.columnTop_category );
  198. this.categoryMorph.start({"height": ""+this.titleBar.getSize().y+"px"});
  199. if (this.expandOrCollapseCategoryFun) this.content.removeEvent("click", this.expandOrCollapseCategoryFun);
  200. this.expand = false;
  201. }
  202. e.stopPropagation();
  203. },
  204. setCurrentAppType : function( appType, target ){
  205. if( this.currentAppType ){
  206. if( this.currentAppType === "all" ){
  207. this.currentAppTypeNode.setStyles( this.css.columnTop_All );
  208. this.currentAppTypeNode.removeClass("o2_cms_index_all_current");
  209. }else{
  210. this.currentAppTypeNode.setStyles( this.css.columnTop_categoryItem );
  211. this.currentAppTypeNode.removeClass("o2_cms_index_categoryItem_current");
  212. }
  213. }
  214. if( appType === "all" ){
  215. target.setStyles( this.css.columnTop_All_current );
  216. target.addClass("o2_cms_index_all_current");
  217. }else{
  218. target.setStyles( this.css.columnTop_categoryItem_current );
  219. target.addClass("o2_cms_index_categoryItem_current");
  220. }
  221. this.currentAppType = appType;
  222. this.currentAppTypeNode = target;
  223. this.createColumnNodes();
  224. },
  225. //loadRefreshNode : function(){
  226. // this.refreshAreaNode = new Element("div", {
  227. // "styles": this.css.refreshAreaNode
  228. // }).inject(this.titleBar);
  229. //
  230. // this.refreshActionNode = new Element("div", {
  231. // "styles": this.css.refreshActionNode,
  232. // "title" : this.lp.refresh
  233. // }).inject(this.refreshAreaNode);
  234. // this.refreshActionNode.addEvent("click", function(){
  235. // this.reload();
  236. // }.bind(this));
  237. //},
  238. loadContent: function(callback){
  239. //this.container = new Element("div", {
  240. // "styles": this.css.container
  241. //}).inject(this.node);
  242. this.scrollNode = new Element("div", {
  243. "styles": this.css.scrollNode
  244. }).inject(this.node);
  245. this.contentWarpNode = new Element("div", {
  246. "styles": this.css.node
  247. }).inject(this.scrollNode);
  248. this.contentContainerNode = new Element("div",{
  249. "styles" : this.css.contentContainerNode
  250. }).inject(this.contentWarpNode);
  251. this.contentNode = new Element("div", {
  252. "styles": this.css.contentNode
  253. }).inject(this.contentContainerNode);
  254. //this.createColumnNodes();
  255. //MWF.require("MWF.widget.ScrollBar", function(){
  256. // new MWF.widget.ScrollBar(this.contentContainerNode, {
  257. // "indent": false,"style":"xApp_TaskList", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  258. // "onScroll": function(y){
  259. // //var scrollSize = _self.elementContentNode.getScrollSize();
  260. // //var clientSize = _self.elementContentNode.getSize();
  261. // //var scrollHeight = scrollSize.y-clientSize.y;
  262. // //if (y+200>scrollHeight) {
  263. // // if (!_self.view.isItemsLoaded) _self.view.loadElementList();
  264. // //}
  265. // }
  266. // });
  267. //}.bind(this));
  268. //
  269. this.setContentSize();
  270. this.addEvent("resize", function(){
  271. this.setContentSize();
  272. }.bind(this));
  273. },
  274. createColumnNodes: function(){
  275. this.contentNode.empty();
  276. if( this.currentAppType === "all" ){
  277. this.restActions.listColumn( function(json){
  278. this._createColumnNodes( json )
  279. }.bind(this));
  280. }else{
  281. this.restActions.listWhatICanViewWithAppType(this.currentAppType, function(json){
  282. this._createColumnNodes( json )
  283. }.bind(this));
  284. }
  285. },
  286. _createColumnNodes : function( json ){
  287. if( typeOf(json.data)!="array" )return;
  288. var tmpArray = json.data;
  289. tmpArray.sort(function( a, b ){
  290. return parseFloat(a.appInfoSeq) - parseFloat(b.appInfoSeq)
  291. });
  292. json.data = tmpArray;
  293. var i = 0;
  294. json.data.each(function(column){
  295. var column = new MWF.xApplication.cms.Index.Column(this, column, {"index" : i++ });
  296. column.load();
  297. this.columns.push(column);
  298. }.bind(this));
  299. },
  300. search : function( key ){
  301. if(!key)key = this.searchBarInputNode.get("value");
  302. if(key==this.lp.searchKey)key="";
  303. if( key!="" ){
  304. this.searchBarResetActionNode.setStyle("display","block");
  305. this.searchBarActionNode.setStyle("display","none");
  306. }
  307. this.columns.each(function( column ){
  308. column.search( key );
  309. }.bind(this))
  310. },
  311. reset : function(){
  312. this.searchBarInputNode.set("value",this.lp.searchKey);
  313. this.searchBarResetActionNode.setStyle("display","none");
  314. this.searchBarActionNode.setStyle("display","block");
  315. this.columns.each(function( column ){
  316. column.loadList();
  317. }.bind(this))
  318. },
  319. clearContent: function(){
  320. //if (this.indexContent){
  321. // if (this.index) delete this.index;
  322. // this.indexContent.destroy();
  323. // this.indexContent = null;
  324. //}
  325. },
  326. openManager : function(){
  327. var appId = "cms.Column";
  328. if (this.desktop.apps[appId]){
  329. this.desktop.apps[appId].setCurrent();
  330. }else {
  331. this.desktop.openApplication(null, "cms.Column", {
  332. "appId": appId,
  333. "onQueryLoad": function(){
  334. }
  335. });
  336. }
  337. },
  338. recordStatus: function(){
  339. //if (this.menu.currentNavi){
  340. // var naviType = this.menu.currentNavi.retrieve("type");
  341. // var naviData = this.menu.currentNavi.retrieve("naviData");
  342. // return {
  343. // "navi" :{ "type": naviType, "id": naviData.id, "columnId":naviData.appId},
  344. // "view" : this.index.currentViewData.id ? this.index.currentViewData.id : "default"
  345. // };
  346. //}
  347. },
  348. setContentSize: function(){
  349. //var titlebarSize = this.titleBar ? this.titleBar.getSize() : {"x":0,"y":0};
  350. //var nodeSize = this.node.getSize();
  351. //var pt = this.contentContainerNode.getStyle("padding-top").toFloat();
  352. //var pb = this.contentContainerNode.getStyle("padding-bottom").toFloat();
  353. //
  354. //var height = nodeSize.y-pt-pb-titlebarSize.y;
  355. //this.contentContainerNode.setStyle("height", ""+height+"px");
  356. var nodeSize = this.content.getSize();
  357. var titlebarSize = this.titleBarContainer ? this.titleBarContainer.getSize() : {"x":0,"y":0};
  358. this.scrollNode.setStyle("height", ""+(nodeSize.y-titlebarSize.y)+"px");
  359. if (this.contentWarpNode){
  360. var count = (nodeSize.x/550).toInt();
  361. var x = 550 * count;
  362. var m = (nodeSize.x-x)/2-10;
  363. this.contentWarpNode.setStyles({
  364. "width": ""+x+"px",
  365. "margin-left": ""+m+"px"
  366. });
  367. //this.titleBar.setStyles({
  368. // "margin-left": ""+(m+10)+"px",
  369. // "margin-right": ""+(m+10)+"px"
  370. //});
  371. if( this.typeListContainer ){
  372. if ( this.typeListContainer.getScrollSize().y> Math.round(this.typeListContainer.getSize().y)) {
  373. if( !this.columnTypeExpandNode ){
  374. this.createTypeExpandButton();
  375. }else{
  376. this.columnTypeExpandNode.setStyle("display","")
  377. }
  378. }else{
  379. if(this.columnTypeExpandNode)this.columnTypeExpandNode.setStyle("display","none");
  380. }
  381. }
  382. }
  383. }
  384. });
  385. MWF.xApplication.cms.Index.Column = new Class({
  386. Implements: [Options, Events],
  387. options: {
  388. "where": "bottom",
  389. "index" : 0
  390. },
  391. initialize: function (app, data, options) {
  392. this.setOptions(options);
  393. this.app = app;
  394. this.container = this.app.contentNode;
  395. this.data = data;
  396. this.isNew = false;
  397. this.defaultColumnIcon = "../x_component_cms_Index/$Main/"+this.app.options.style+"/icon/column.png";
  398. },
  399. load : function(){
  400. this.loadNode();
  401. this.loadTop();
  402. this.loadCategory();
  403. this.loadList();
  404. },
  405. loadNode : function(){
  406. this.node = new Element("div.columnItem", {
  407. "styles": this.app.css.columnItemNode
  408. }).inject(this.container,this.options.where);
  409. //if( this.options.index % 2 == 1 ){
  410. // this.node.setStyles({
  411. // "margin-left" : "0px",
  412. // "margin-right" : "0px"
  413. // })
  414. //}else{
  415. // this.node.setStyles({
  416. // "margin-left" : "0px",
  417. // "margin-right" : "10px"
  418. // })
  419. //}
  420. var leftNode = this.leftNode = new Element("div.columnItemLeftNode", {
  421. "styles": this.app.css.columnItemLeftNode
  422. }).inject(this.node);
  423. var rightNode = this.rightNode = new Element("div.columnItemRightNode", {
  424. "styles": this.app.css.columnItemRightNode
  425. }).inject(this.node);
  426. this.categoryContainer = new Element("div.categoryContainer",{
  427. "styles" : this.app.css.categoryContainer
  428. }).inject(this.rightNode);
  429. this.categoryList = new Element("div.categoryList",{
  430. "styles" : this.app.css.categoryList
  431. }).inject(this.categoryContainer);
  432. this.documentList = new Element("div",{
  433. "styles" : this.app.css.documentList
  434. }).inject(this.rightNode);
  435. },
  436. loadTop: function () {
  437. this.data.name = this.data.appName;
  438. var columnName = this.data.appName;
  439. var alias = this.data.appAlias;
  440. var memo = this.data.description;
  441. var order = this.data.appInfoSeq;
  442. var creator =this.data.creatorUid;
  443. var createTime = this.data.createTime;
  444. var leftNode = this.leftNode;
  445. //var iconNode = this.iconNode = new Element("div",{
  446. // "styles" : this.app.css.columnItemIconNode
  447. //}).inject(topNode);
  448. //
  449. //if (this.data.appIcon){
  450. // this.iconNode.setStyle("background-image", "url(data:image/png;base64,"+this.data.appIcon+")");
  451. //}else{
  452. // this.iconNode.setStyle("background-image", "url("+this.defaultColumnIcon+")")
  453. //}
  454. var iconAreaNode = this.iconAreaNode = new Element("div",{
  455. "styles" : this.app.css.columnItemIconAreaNode
  456. }).inject(leftNode);
  457. //var mod = this.options.index % this.backgroundColors.length;
  458. //this.color = this.backgroundColors[mod];
  459. //iconAreaNode.setStyle("background-color",this.color);
  460. var iconNode = this.iconNode = new Element("img",{
  461. "styles" : this.app.css.columnItemIconNode
  462. }).inject(iconAreaNode);
  463. if (this.data.appIcon){
  464. this.iconNode.set("src", "data:image/png;base64,"+this.data.appIcon+"");
  465. }else{
  466. this.iconNode.set("src", this.defaultColumnIcon)
  467. }
  468. iconNode.makeLnk({
  469. "par": this._getLnkPar()
  470. });
  471. var textNode = new Element("div",{
  472. "styles" : this.app.css.columnItemTextNode
  473. }).inject(leftNode);
  474. var titleNode = new Element("div",{
  475. "styles" : this.app.css.columnItemTitleNode,
  476. "text" : columnName,
  477. "title": (alias) ? columnName+" ("+alias+") " : columnName
  478. }).inject(textNode);
  479. var description = ( memo && memo!="") ? memo : this.app.lp.noDescription;
  480. var descriptionNode = new Element("div",{
  481. "styles" : this.app.css.columnItemDescriptionNode,
  482. "text" : description,
  483. "title" : description
  484. }).inject(textNode);
  485. var _self = this;
  486. leftNode.addEvents({
  487. //"mouseover": function(){if (!_self.selected) this.setStyles(_self.app.css.columnItemNode_over);},
  488. //"mouseout": function(){if (!_self.selected) this.setStyles(_self.app.css.columnItemNode);},
  489. "click": function(e){_self.clickColumnNode(_self,this,e)}
  490. });
  491. },
  492. _getLnkPar: function(){
  493. var lnkIcon = this.defaultColumnIcon;
  494. if (this.data.appIcon) lnkIcon = "data:image/png;base64,"+this.data.appIcon;
  495. var appId = "cms.Module"+this.data.id;
  496. return {
  497. "icon": lnkIcon,
  498. "title": this.data.appName,
  499. "par": "cms.Module#{\"columnId\": \""+this.data.id+"\", \"appId\": \""+appId+"\"}"
  500. };
  501. },
  502. clickColumnNode : function(_self, el, e ){
  503. this.openModule("all",e);
  504. },
  505. clickMoreLink : function(e){
  506. var key = this.app.searchBarInputNode.get("value");
  507. if(key==this.app.lp.searchKey)key="";
  508. this.openModule("all",e, key);
  509. },
  510. openModule : function( categoryId , e , searchKey, isCategory ){
  511. var appId = "cms.Module"+this.data.id;
  512. if (this.app.desktop.apps[appId]){
  513. if( searchKey ){
  514. this.app.desktop.apps[appId].close();
  515. }else{
  516. this.app.desktop.apps[appId].setCurrent();
  517. return;
  518. }
  519. }
  520. this.app.desktop.openApplication(e, "cms.Module", {
  521. "columnData": this.data,
  522. "appId": appId,
  523. "categoryId": categoryId,
  524. //"viewId" : "default",
  525. "isCategory" : isCategory || false,
  526. "searchKey" : searchKey
  527. });
  528. },
  529. loadCategory : function(){
  530. var _self = this;
  531. if( typeOf(this.data.wrapOutCategoryList) != "array" )return;
  532. var tmpArray = this.data.wrapOutCategoryList;
  533. tmpArray.sort(function( a, b ){
  534. return parseFloat(a.categorySeq) - parseFloat(b.categorySeq)
  535. });
  536. this.data.wrapOutCategoryList = tmpArray;
  537. this.data.wrapOutCategoryList.each(function(category){
  538. var categoryNode = new Element("div.categoryItem",{
  539. "text" : category.categoryName,
  540. "styles" : this.app.css.categoryItem
  541. }).addClass("o2_cms_index_categoryItem_text").inject( this.categoryList, "top" );
  542. categoryNode.store("category",category);
  543. categoryNode.addEvents({
  544. "mouseover" : function(){
  545. this.setStyles(_self.app.css.categoryItem_over);
  546. this.addClass("o2_cms_index_categoryItem_text_over");
  547. },
  548. "mouseout" : function(){
  549. this.setStyles(_self.app.css.categoryItem);
  550. this.removeClass("o2_cms_index_categoryItem_text_over");
  551. },
  552. "click" : function(e){
  553. _self.openModule( this.retrieve("category").id , e , "", true)
  554. }
  555. })
  556. }.bind(this));
  557. if( this.categoryList.getScrollSize().y > this.categoryContainer.getSize().y ){
  558. this.categoryArrowNode = new Element("div.categoryArrowNode",{
  559. "styles" : this.app.css.categoryArrowNode
  560. }).inject( this.categoryContainer );
  561. this.categoryArrowNode.addEvents({
  562. "mouseover" : function(){
  563. this.categoryArrowNode.setStyles( this.categoryArrow != "down" ? this.app.css.categoryArrowNode_over : this.app.css.categoryArrowNode_down_over);
  564. }.bind(this),
  565. "mouseout" : function(){
  566. this.categoryArrowNode.setStyles( this.categoryArrow != "down" ? this.app.css.categoryArrowNode : this.app.css.categoryArrowNode_down);
  567. }.bind(this),
  568. "click" : function( e ){
  569. if( this.categoryArrow != "down" ){
  570. this.openCategoryList( e );
  571. }else{
  572. this.closeCategoryList( e )
  573. }
  574. }.bind(this)
  575. });
  576. }
  577. },
  578. openCategoryList : function( e ){
  579. this.categoryArrow = "down";
  580. this.categoryArrowNode.setStyles(this.app.css.categoryArrowNode_down_over );
  581. this.categoryList.setStyles(this.app.css.categoryList_all);
  582. window.closeCategoryList = this.closeCategoryList.bind(this);
  583. this.app.content.addEvent("click", window.closeCategoryList );
  584. e.stopPropagation();
  585. },
  586. closeCategoryList : function( e ){
  587. this.categoryArrow = "up";
  588. this.categoryArrowNode.setStyles(this.app.css.categoryArrowNode );
  589. this.categoryList.setStyles(this.app.css.categoryList);
  590. this.app.content.removeEvent("click" , window.closeCategoryList );
  591. e.stopPropagation();
  592. },
  593. destroy: function(){
  594. this.node.destroy();
  595. MWF.release(this);
  596. delete this;
  597. },
  598. search : function(key){
  599. if( !key || key==""){
  600. this.loadList();
  601. return;
  602. }
  603. if(this.documentList)this.documentList.empty();
  604. if(this.moreArea)this.moreArea.destroy();
  605. var filter = {
  606. "title": key,
  607. "appIdList": [this.data.id],
  608. "statusList": ["published"]
  609. };
  610. this.getDocumentData(function(json){
  611. //json.count //栏目下文档总数
  612. //json.size //当前条数
  613. if( json.count > json.size ){
  614. this.loadMoreItem( json.count, json.size )
  615. }
  616. json.data.each(function(data){
  617. this.listDocument(data);
  618. }.bind(this))
  619. }.bind(this), null, filter );
  620. },
  621. loadList: function(){
  622. if(this.documentList)this.documentList.empty();
  623. if(this.moreArea)this.moreArea.destroy();
  624. this.getDocumentData(function(json){
  625. //json.count //栏目下文档总数
  626. //json.size //当前条数
  627. //if( json.count > json.size ){
  628. // this.loadMoreItem( json.count, json.size )
  629. //}
  630. json.data.each(function(data){
  631. this.listDocument(data);
  632. }.bind(this))
  633. }.bind(this));
  634. },
  635. listDocument:function(data){
  636. var _self = this;
  637. var documentItem = new Element("div",{
  638. "text" : data.title,
  639. "title" : data.title,
  640. "styles" : this.app.css.documentItem
  641. }).inject(this.documentList);
  642. documentItem.store("documentId",data.id);
  643. documentItem.addEvents({
  644. "mouseover" : function(){
  645. this.setStyles(_self.app.css.documentItem_over);
  646. this.addClass("mainColor_color");
  647. },
  648. "mouseout" : function(){
  649. this.setStyles(_self.app.css.documentItem);
  650. this.removeClass("mainColor_color");
  651. },
  652. "click" : function(){
  653. var documentId = this.retrieve("documentId");
  654. var appId = "cms.Document"+documentId;
  655. if (_self.app.desktop.apps[appId]){
  656. _self.app.desktop.apps[appId].setCurrent();
  657. }else {
  658. var options = {
  659. "documentId": documentId,
  660. "appId": appId,
  661. "readonly": true
  662. };
  663. _self.app.desktop.openApplication(null, "cms.Document", options);
  664. }
  665. }
  666. })
  667. },
  668. getDocumentData: function(callback, count, filter){
  669. if(!count)count=6;
  670. var id = "(0)";
  671. if(!filter){
  672. filter = {
  673. "appIdList": [this.data.id],
  674. "statusList": ["published"]
  675. }
  676. }
  677. this.app.restActions.listDocumentFilterNext(id, count, filter, function(json){
  678. if (callback) callback(json);
  679. });
  680. },
  681. loadMoreItem: function(total, size){
  682. var _self = this;
  683. this.moreArea = new Element("div",{
  684. "styles" : this.app.css.moreArea
  685. }).inject(this.rightNode);
  686. this.moreLinkText = new Element("div",{
  687. "styles" : this.app.css.moreLinkText,
  688. "text" : "更多("+(total-size)+")"
  689. }).inject(this.moreArea);
  690. this.moreLinkImage = new Element("div",{
  691. "styles" : this.app.css.moreLinkImage
  692. }).inject(this.moreArea);
  693. this.moreArea.addEvents({
  694. "mouseover" : function(){
  695. this.moreLinkText.setStyles(_self.app.css.moreLinkText_over);
  696. this.moreLinkImage.setStyles(_self.app.css.moreLinkImage_over)
  697. }.bind(this),
  698. "mouseout" : function(){
  699. this.moreLinkText.setStyles(_self.app.css.moreLinkText);
  700. this.moreLinkImage.setStyles(_self.app.css.moreLinkImage)
  701. }.bind(this),
  702. "click" : function(e){_self.clickMoreLink( e )}
  703. });
  704. //this.moreArea.setStyle("background-color",this.color)
  705. }
  706. });