Main.js 25 KB

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