Main.js 23 KB

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