InforContent.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. MWF.xApplication.Homepage.InforContent = new Class({
  2. Extends: MWF.xApplication.Homepage.TaskContent,
  3. Implements: [Options, Events],
  4. options: {
  5. "view": "inforContent.html"
  6. },
  7. load: function(){
  8. this.tabs = {};
  9. this.container.loadHtml(this.viewPath, {"bind": {"lp": this.app.lp}, "module": this}, function(){
  10. this.initSize();
  11. this.loadInfor(function(){
  12. this.fireEvent("load");
  13. }.bind(this));
  14. // this.loadTask(function(){
  15. // this.fireEvent("load");
  16. // }.bind(this));
  17. //
  18. // //是否需要定时自动刷新 @todo
  19. // this.startProcessAction.addEvent("click", this.startProcess.bind(this));
  20. //this.moreInforAction.addEvent("click", this.moreInfor.bind(this));
  21. }.bind(this));
  22. },
  23. openInfor: function(e){
  24. layout.openApplication(e, "cms.Index");
  25. },
  26. setContentSize: function(){
  27. var total = this.container.getSize().y;
  28. var titleHeight = this.taskTitleNode.getSize().y+this.taskTitleNode.getEdgeHeight();
  29. var thisHeight = this.contentNode.getEdgeHeight();
  30. var contentHeight = total-titleHeight-thisHeight;
  31. this.contentNode.setStyle("height", ""+contentHeight+"px");
  32. this.contentHeight = contentHeight;
  33. //this.pageSize = (this.options.itemHeight/this.contentHeight).toInt();
  34. if (this.noItemNode){
  35. var m;
  36. if (this.currentTab && this.currentTab.itemsContainer){
  37. m = (this.currentTab.itemsContainer.getSize().y- this.noItemNode.getSize().y)/2;
  38. }else{
  39. m = (this.contentHeight- this.noItemNode.getSize().y)/2;
  40. }
  41. this.noItemNode.setStyle("margin-top", ""+m+"px");
  42. }
  43. if (this.currentTab){
  44. if (this.currentTab.hotpicDocAreaNode){
  45. var pageHeight = this.currentTab.hotpicPageAreaNode.getSize().y+this.currentTab.hotpicPageAreaNode.getEdgeHeight();
  46. var height = this.contentHeight-pageHeight;
  47. this.currentTab.hotpicDocAreaNode.setStyle("height", ""+height+"px");
  48. }
  49. if (this.currentTab.itemsContainer){
  50. var itemPageHeight = this.pageAreaNode.getSize().y+this.pageAreaNode.getEdgeHeight();
  51. var itemHeight = this.contentHeight-itemPageHeight;
  52. this.currentTab.itemsContainer.setStyle("height", ""+itemHeight+"px");
  53. }
  54. }
  55. },
  56. loadInfor: function(callback){
  57. this.loadInforApps();
  58. this.loadAllInfor(callback);
  59. },
  60. loadInforApps: function(){
  61. o2.Actions.load("x_cms_assemble_control").AppInfoAction.listWhatICanView_Article(function(json){
  62. if (json.data) json.data.each(function(app){
  63. var tabNode = new Element("div.o2_homepage_title_tab", {"text": app.appName}).inject(this.tabAreaNode);
  64. tabNode.store("app", app.id);
  65. tabNode.addEvents({
  66. "mouseover": function(e){ this.tabover(e.event); }.bind(this),
  67. "mouseout": function(e){ this.tabout(e.event); }.bind(this),
  68. "click": function(e){
  69. var id = e.target.retrieve("app");
  70. this.loadList(id, (e.target || e.currentTarget));
  71. }.bind(this),
  72. });
  73. }.bind(this));
  74. }.bind(this));
  75. },
  76. loadList: function(id, tabNode){
  77. if (!this.isLoading) {
  78. if (!this.tabs[id]){
  79. this.tabs[id] = new MWF.xApplication.Homepage.InforContent.Infor(this, tabNode, id);
  80. }else{
  81. this.tabs[id].load();
  82. }
  83. this.currentTab = this.tabs[id];
  84. }
  85. },
  86. loadAllInfor: function(callback){
  87. if (!this.isLoading) {
  88. if (!this.allInforContentTab){
  89. this.allInforContentTab = new MWF.xApplication.Homepage.InforContent.AllInfor(this, this.allInforTab, {
  90. "onLoad": function(){ if (callback) callback(); }
  91. });
  92. }else{
  93. this.allInforContentTab.load();
  94. }
  95. this.currentTab = this.allInforContentTab;
  96. }
  97. }
  98. });
  99. MWF.xApplication.Homepage.InforContent.AllInfor = new Class({
  100. Extends: MWF.xApplication.Homepage.TaskContent.Task,
  101. Implements: [Options, Events],
  102. options: {
  103. "type": "allInfor",
  104. "switchTime": 5000
  105. },
  106. initialize: function(content, tab, options){
  107. this.setOptions(options);
  108. this.content = content;
  109. this.app = this.content.app;
  110. this.container = this.content.contentNode;
  111. this.tab = tab;
  112. this.load();
  113. },
  114. //this.container = this.content.itemContentNode;
  115. load: function(){
  116. this.container.empty();
  117. this.content.isLoading = true;
  118. if (this.content.currentTab) this.content.currentTab.hideTab();
  119. this.loadItemsNode(function(){
  120. this.beginLoadContent();
  121. this.showTab();
  122. this.initSize();
  123. this.initItemCount(this.page);
  124. this.loadItemsRes();
  125. }.bind(this));
  126. },
  127. reload: function(){
  128. this.load();
  129. // if (!this.content.isLoading){
  130. // this.initSize();
  131. // this.beginLoadContent();
  132. // this.showTab();
  133. // this.initItemCount(this.page);
  134. // this.loadItemsRes();
  135. // }
  136. },
  137. reloadPic: function(){
  138. this.hotpicDocArea.empty();
  139. this.hotpicPageContent.empty();
  140. this.loadItemsRes_pic();
  141. },
  142. reloadItem: function(){
  143. this.beginItemLoadContent();
  144. this.initItemCount(this.page);
  145. this.loadItemsRes_item();
  146. },
  147. initItemCount: function(count){
  148. this.page = count || 1;
  149. this.pageSize = (this.itemContentArea.getSize().y/this.options.itemHeight).toInt();
  150. },
  151. loadItemsNode: function(callback){
  152. var url = this.app.path+this.app.options.style+"/allInfor.html";
  153. this.container.loadHtml(url, {"module": this}, callback.bind(this));
  154. },
  155. initSize: function(){
  156. this.resizeFun = this.resize.bind(this);
  157. this.resize();
  158. this.app.addEvent("resize", this.resizeFun);
  159. },
  160. resize: function(){
  161. var mHeight = this.hotpicDocArea.getEdgeHeight();
  162. var pageHeight = this.hotpicPageArea.getSize().y+this.hotpicPageArea.getEdgeHeight();
  163. var h = this.content.contentHeight - mHeight - pageHeight;
  164. this.hotpicDocArea.setStyle("height", ""+h+"px");
  165. mHeight = this.itemContentArea.getEdgeHeight();
  166. pageHeight = this.itemPageArea.getSize().y+this.itemPageArea.getEdgeHeight();
  167. h = this.content.contentHeight - mHeight - pageHeight;
  168. this.itemContentArea.setStyle("height", ""+h+"px");
  169. if (this.hotpics && this.hotpics.length) this.hotpics.each(function(picNode){
  170. this.resizePicNode(picNode);
  171. }.bind(this));
  172. if (this.noHotpicNode){
  173. var m = (this.hotpicDocArea.getSize().y- this.noHotpicNode.getSize().y)/2;
  174. this.noHotpicNode.setStyle("margin-top", ""+m+"px");
  175. }
  176. if (this.noItemNode){
  177. var m = (this.itemContentArea.getSize().y- this.noItemNode.getSize().y)/2;
  178. this.noItemNode.setStyle("margin-top", ""+m+"px");
  179. }
  180. },
  181. destroy: function(){
  182. this.container.empty();
  183. if (this.switchId) window.clearInterval(this.switchId);
  184. this.switchId = null;
  185. if (this.resizeFun) this.app.removeEvent("resize", this.resizeFun);
  186. o2.release(this);
  187. },
  188. hideTab: function(){
  189. this.container.empty();
  190. if (this.switchId) window.clearInterval(this.switchId);
  191. this.switchId = null;
  192. if (this.resizeFun) this.app.removeEvent("resize", this.resizeFun);
  193. this.content.currentTab = null;
  194. this.tab.removeClass("mainColor_color").removeClass("mainColor_border").removeClass("o2_homepage_title_tab_current").removeClass("o2_homepage_title_tab_over");
  195. // if (this.destroy) this.destroy();
  196. // o2.release(this);
  197. },
  198. beginLoadContent: function(){
  199. this.beginPicLoadContent();
  200. this.beginItemLoadContent();
  201. this.noItemNode = null;
  202. this.hotpics = [];
  203. this.content.isLoading = true;
  204. },
  205. beginPicLoadContent: function(){
  206. this.picLoading = true;
  207. this.hotpicDocArea.empty();
  208. this.hotpicDocArea.addClass("o2_homepage_area_content_loading").addClass("icon_loading");
  209. this.hotpicPageContent.empty();
  210. },
  211. beginItemLoadContent: function(){
  212. this.itemLoading = true;
  213. this.itemContentArea.empty();
  214. this.itemContentArea.addClass("o2_homepage_area_content_loading").addClass("icon_loading");
  215. this.itemPageArea.empty();
  216. },
  217. endLoadContent: function(){
  218. this.endPicLoadContent();
  219. this.endItemLoadContent();
  220. this.content.isLoading = false;
  221. },
  222. endPicLoadContent: function(){
  223. if (this.noHotpicNode){
  224. this.noHotpicNode.destroy();
  225. this.noHotpicNode = null;
  226. }
  227. this.hotpicDocArea.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  228. this.picLoading = false;
  229. if (!this.itemLoading && !this.picLoading){
  230. this.content.isLoading = false;
  231. this.fireEvent("load");
  232. }
  233. },
  234. endItemLoadContent: function(){
  235. if (this.noItemNode){
  236. this.noItemNode.destroy();
  237. this.noItemNode = null;
  238. }
  239. this.itemContentArea.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  240. this.itemLoading = false;
  241. if (!this.itemLoading && !this.picLoading){
  242. this.content.isLoading = false;
  243. this.fireEvent("load");
  244. }
  245. },
  246. loadItemsRes: function(){
  247. //this.loadHotpic();
  248. this.loadItemsRes_pic();
  249. this.loadItemsRes_item();
  250. },
  251. loadItemsRes_pic:function(){
  252. this.hotpicCount = 6;
  253. o2.Actions.load("x_hotpic_assemble_control").HotPictureInfoAction.listForPage(1, this.hotpicCount, {}, function(json){
  254. this.hotpicCount = json.data.length;
  255. if (this.hotpicCount) {
  256. var url = this.app.path+this.app.options.style+"/hotpic.html";
  257. o2.loadHtml(url, function(loaded){
  258. this.endPicLoadContent();
  259. var html = loaded[0].data;
  260. json.data.each(function(doc){
  261. this.loadHotpic(doc, html);
  262. }.bind(this));
  263. this.loadPicPage();
  264. }.bind(this));
  265. }else{
  266. this.endPicLoadContent();
  267. this.noHotpicNode = new Element("div.o2_homepage_hotpic_area_content_empty_node", {"text": this.app.lp.noHotpic}).inject(this.hotpicDocArea);
  268. var m = (this.hotpicDocArea.getSize().y- this.noHotpicNode.getSize().y)/2;
  269. this.noHotpicNode.setStyle("margin-top", ""+m+"px");
  270. }
  271. }.bind(this));
  272. },
  273. loadItemsRes_item:function(){
  274. o2.Actions.load("x_cms_assemble_control").DocumentAction.query_listWithFilterPaging(this.page, this.pageSize, {
  275. "orderField": "publishTime",
  276. "orderType": "DESC",
  277. "readFlag": "UNREAD"
  278. }, function(json){
  279. this.itemCount = json.count;
  280. if (json.data && json.data.length){
  281. this.loadItems(json.data);
  282. this.checkLoadPage();
  283. }else{
  284. this.endItemLoadContent();
  285. this.noItemNode = new Element("div.o2_homepage_hotpic_area_content_empty_node", {"text": this.app.lp.noInforItem}).inject(this.itemContentArea);
  286. var m = (this.itemContentArea.getSize().y- this.noItemNode.getSize().y)/2;
  287. this.noItemNode.setStyle("margin-top", ""+m+"px");
  288. }
  289. }.bind(this));
  290. },
  291. checkLoadPage: function(){
  292. if (this.itemCount){
  293. this.getPageCount();
  294. this.loadPage(this.itemPageArea);
  295. }
  296. },
  297. getPageCount:function(){
  298. var n = this.itemCount/this.pageSize;
  299. var nInt = n.toInt();
  300. this.pages = (nInt===n) ? nInt : nInt+1;
  301. },
  302. loadItems: function(data){
  303. var table = new Element("table", { "width": "100%", "border": 0, "cellpadding": 0, "cellspacing": 0 }).inject(this.itemContentArea);
  304. data.each(function(d, i){
  305. this.loadItem(table, d, i);
  306. }.bind(this));
  307. this.endItemLoadContent();
  308. },
  309. loadItem: function(table, d, i){
  310. var row = this.loadItemRow(table, d, i);
  311. var _self = this;
  312. row.store("data", d);
  313. row.addEvents({
  314. "mouseover": function(){
  315. this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
  316. this.getElement("div").addClass("mainColor_bg").addClass("o2_homepage_task_item_number_over");
  317. var topNode = this.getElement(".o2_homepage_task_item_top");
  318. if(topNode)topNode.addClass("mainColor_bg").addClass("o2_homepage_task_item_top_over");
  319. },
  320. "mouseout": function(){
  321. this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
  322. this.getElement("div").removeClass("mainColor_bg").removeClass("o2_homepage_task_item_number_over");
  323. var topNode = this.getElement(".o2_homepage_task_item_top");
  324. if(topNode)topNode.removeClass("mainColor_bg").removeClass("o2_homepage_task_item_top_over");
  325. },
  326. "click": function(e){
  327. var d = this.retrieve("data");
  328. if (d) {
  329. _self.open(e, d);
  330. }
  331. }
  332. })
  333. },
  334. loadItemRow: function(table, d, i){
  335. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  336. var idx = (this.page-1)*this.pageSize+i+1;
  337. var idxShow = (idx>99) ? "···" : idx;
  338. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  339. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  340. var subject = o2.txt(d.title || this.app.lp.noSubject);
  341. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  342. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  343. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_top");
  344. if( d.isTop ){
  345. new Element("div.o2_homepage_task_item_top").inject(cell); //.addClass("mainColor_bg");
  346. }
  347. var time = (d.publishTime || d.createTime).substr(0,10);
  348. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  349. new Element("div.o2_homepage_task_item_time", {"text": time, "title":this.app.lp.publishTime + ": " + time}).inject(cell);
  350. return row;
  351. },
  352. resizePicNode: function(picNode){
  353. var size = this.hotpicDocArea.getSize();
  354. var imgHeight = size.x/2;
  355. picNode.getFirst().setStyle("height", ""+imgHeight+"px");
  356. },
  357. loadHotpic: function(doc, html, i){
  358. var picNode = new Element("div.o2_homepage_infor_hotpicNode").inject(this.hotpicDocArea, "top");
  359. var bind = {
  360. "title": doc.title,
  361. "summary": doc.summary || doc.title,
  362. "createTime": doc.createTime.toString().substr(0, 10),
  363. "url": MWF.xDesktop.getImageSrc(doc.picId)
  364. }
  365. picNode.set("html", html.bindJson(bind));
  366. picNode.store("data", doc);
  367. var _self = this;
  368. picNode.addEvent("click", function(e){
  369. var d = this.retrieve("data");
  370. _self.open(e, d);
  371. });
  372. if (!this.hotpics) this.hotpics = [];
  373. this.resizePicNode(picNode);
  374. this.hotpics.push(picNode);
  375. },
  376. loadPicPage: function(){
  377. if (this.hotpics && this.hotpics.length){
  378. this.hotpics.each(function(picNode, i){
  379. var pageNode = new Element("div.o2_homepage_infor_hotpicArea_page_item").inject(this.hotpicPageContent);
  380. pageNode.store("picNode", picNode);
  381. pageNode.addEvent("click", function(e){
  382. this.showPic(e.target);
  383. this.beginSwitchPic();
  384. }.bind(this));
  385. if (i==0) this.showPic(pageNode);
  386. }.bind(this));
  387. this.beginSwitchPic();
  388. }else{
  389. this.endPicLoadContent();
  390. this.noHotpicNode = new Element("div.o2_homepage_hotpic_area_content_empty_node", {"text": this.app.lp.noHotpic}).inject(this.hotpicDocArea);
  391. var m = (this.hotpicDocArea.getSize().y- this.noHotpicNode.getSize().y)/2;
  392. this.noHotpicNode.setStyle("margin-top", ""+m+"px");
  393. }
  394. },
  395. beginSwitchPic: function(){
  396. if (this.switchId) window.clearInterval(this.switchId);
  397. this.switchId = window.setInterval(function(){
  398. var currentPageNode = this.hotpicPageContent.getElement(".o2_homepage_infor_hotpicArea_page_item_current");
  399. var nextPageNode = null;
  400. if (!currentPageNode){
  401. nextPageNode = this.hotpicPageContent.getFirst();
  402. }else{
  403. nextPageNode = currentPageNode.getNext();
  404. if (!nextPageNode) nextPageNode = this.hotpicPageContent.getFirst();
  405. }
  406. if (nextPageNode) this.showPic(nextPageNode);
  407. }.bind(this), this.options.switchTime)
  408. },
  409. showPic: function(pageNode){
  410. var picNode = pageNode.retrieve("picNode");
  411. if (picNode){
  412. if (this.currentPageNode) this.hidePic(this.currentPageNode);
  413. picNode.fade("in");
  414. picNode.addClass("o2_homepage_infor_hotpicNode_current");
  415. pageNode.addClass("o2_homepage_infor_hotpicArea_page_item_current");
  416. this.currentPageNode = pageNode;
  417. }
  418. },
  419. hidePic: function(pageNode){
  420. var picNode = pageNode.retrieve("picNode");
  421. if (picNode){
  422. picNode.fade("out");
  423. picNode.removeClass("o2_homepage_infor_hotpicNode_current");
  424. pageNode.removeClass("o2_homepage_infor_hotpicArea_page_item_current");
  425. this.currentPageNode = null;
  426. }
  427. },
  428. open: function(e, data){
  429. var id = data.infoId || data.id;
  430. // var options = {"documentId": id, "docTitle": d.title, "appId": "cms.Document"+id};
  431. // layout.openApplication(e, "cms.Document", options);
  432. if( data.application == "BBS" ){
  433. var appId = "ForumDocument"+data.infoId;
  434. if (this.app.desktop.apps[appId]){
  435. this.app.desktop.apps[appId].setCurrent();
  436. }else {
  437. layout.openApplication(null, "ForumDocument", {
  438. "id" : id,
  439. "appId": appId,
  440. // "docTitle": data.title,
  441. "isEdited" : false,
  442. "isNew" : false
  443. });
  444. }
  445. }else{
  446. var appId = "cms.Document"+ (data.infoId || data.id);
  447. if (this.app.desktop.apps[appId]){
  448. this.app.desktop.apps[appId].setCurrent();
  449. }else {
  450. layout.openApplication(null, "cms.Document", {
  451. "documentId" : id,
  452. // "docTitle": data.title,
  453. "appId": appId,
  454. "readonly" : true
  455. });
  456. }
  457. }
  458. },
  459. prevPage: function(){
  460. if (this.page>1){
  461. this.page--;
  462. //this.loadPageNumber();
  463. this.reloadItem();
  464. }
  465. },
  466. nextPage: function(){
  467. if (this.page<this.pages){
  468. this.page++;
  469. //this.loadPageNumber();
  470. this.reloadItem();
  471. }
  472. },
  473. gotoPage: function(i){
  474. this.page = i.toInt();
  475. //this.loadPageNumber();
  476. this.reloadItem();
  477. },
  478. reversePage: function(){
  479. var range = this.getCurrentPageRange();
  480. var endNumber = range.beginNumber-1;
  481. var beginNumber = endNumber-(this.options.showPages-1);
  482. if (beginNumber<1) beginNumber = 1;
  483. this.page = beginNumber+((this.options.showPages/2).toInt());
  484. this.reloadItem();
  485. },
  486. forwardPage: function(){
  487. var range = this.getCurrentPageRange();
  488. var beginNumber = range.endNumber+1;
  489. var endNumber = beginNumber+(this.options.showPages-1);
  490. if (beginNumber>=this.pages) endNumber = this.pages;
  491. this.page = endNumber-((this.options.showPages/2).toInt());
  492. this.reloadItem();
  493. }
  494. });
  495. MWF.xApplication.Homepage.InforContent.Infor = new Class({
  496. Extends: MWF.xApplication.Homepage.TaskContent.Task,
  497. Implements: [Options, Events],
  498. options: {
  499. "type": "infor",
  500. },
  501. initialize: function(content, tab, id, options){
  502. this.setOptions(options);
  503. this.content = content;
  504. this.app = this.content.app;
  505. this.container = this.content.contentNode;
  506. this.tab = tab;
  507. this.id = id;
  508. this.load();
  509. },
  510. load: function(){
  511. this.container = this.content.contentNode;
  512. this.container.empty();
  513. this.beginLoadContent();
  514. this.showTab();
  515. this.initItemCount();
  516. this.loadItemsRes();
  517. },
  518. reload: function(){
  519. if (!this.content.isLoading) {
  520. this.container = this.content.contentNode;
  521. this.container.empty();
  522. this.beginLoadContent();
  523. this.showTab();
  524. this.initItemCount(this.page);
  525. this.loadItemsRes();
  526. }
  527. },
  528. showTab: function(){
  529. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  530. this.itemsContainer = new Element("div.o2_homepage_task_area_content").inject(this.container);
  531. var pageAreaNode = new Element("div.o2_homepage_infor_area_action").inject(this.container);
  532. this.container = this.itemsContainer;
  533. this.content.pageAreaNode = pageAreaNode;
  534. this.container.addClass("o2_homepage_area_content_loading").addClass("icon_loading");
  535. var itemPageHeight = pageAreaNode.getSize().y+pageAreaNode.getEdgeHeight();
  536. var itemHeight = this.content.contentHeight-itemPageHeight;
  537. this.container.setStyle("height", ""+itemHeight+"px");
  538. this.content.currentTab = this;
  539. this.tab.addClass("mainColor_color").addClass("mainColor_border").addClass("o2_homepage_title_tab_current").removeClass("o2_homepage_title_tab_over");
  540. },
  541. loadItemsRes: function(){
  542. o2.Actions.load("x_cms_assemble_control").DocumentAction.query_listWithFilterPaging(this.page, this.pageSize, {
  543. "orderField": "publishTime",
  544. "orderType": "DESC",
  545. "readFlag": "UNREAD",
  546. "appIdList": [this.id]
  547. }, function(json){
  548. this.itemCount = json.count;
  549. if (json.data && json.data.length){
  550. this.loadItems(json.data);
  551. this.checkLoadPage();
  552. }else{
  553. this.emptyLoadContent();
  554. }
  555. }.bind(this));
  556. },
  557. emptyLoadContent: function(){
  558. this.container.empty();
  559. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  560. this.content.pageAreaNode.empty();
  561. //this.itemContentNode.addClass("o2_homepage_task_area_content_empty").addClass("icon_notask");
  562. this.content.noItemNode = new Element("div.o2_homepage_hotpic_area_content_empty_node", {"text": this.app.lp.noInforItem}).inject(this.container);
  563. var m = (this.container.getSize().y- this.content.noItemNode.getSize().y)/2;
  564. this.content.noItemNode.setStyle("margin-top", ""+m+"px");
  565. this.content.isLoading = false;
  566. },
  567. loadItem: function(table, d, i){
  568. var row = this.loadItemRow(table, d, i);
  569. var _self = this;
  570. row.store("data", d);
  571. row.addEvents({
  572. "mouseover": function(){
  573. this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
  574. this.getElement("div").addClass("mainColor_bg").addClass("o2_homepage_task_item_number_over");
  575. var topNode = this.getElement(".o2_homepage_task_item_top");
  576. if(topNode)topNode.addClass("mainColor_bg").addClass("o2_homepage_task_item_top_over");
  577. },
  578. "mouseout": function(){
  579. this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
  580. this.getElement("div").removeClass("mainColor_bg").removeClass("o2_homepage_task_item_number_over");
  581. var topNode = this.getElement(".o2_homepage_task_item_top");
  582. if(topNode)topNode.removeClass("mainColor_bg").removeClass("o2_homepage_task_item_top_over");
  583. },
  584. "click": function(e){
  585. var d = this.retrieve("data");
  586. if (d) {
  587. _self.open(e, d);
  588. }
  589. }
  590. })
  591. },
  592. loadItemRow: function(table, d, i){
  593. var row = table.insertRow(-1).addClass("o2_homepage_task_item_row");
  594. var idx = (this.page-1)*this.pageSize+i+1;
  595. var idxShow = (idx>99) ? "···" : idx;
  596. var cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_number");
  597. var numberNode = new Element("div.o2_homepage_task_item_number", {"text": idxShow, "title":idx}).inject(cell);
  598. //var subject = "<span>["+d.processName+"]</span> "+(d.title || this.app.lp.noSubject);
  599. var subject = o2.txt(d.title || this.app.lp.noSubject);
  600. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_subject");
  601. new Element("div.o2_homepage_task_item_subject", {"html": subject, "title":subject}).inject(cell);
  602. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_top");
  603. if( d.isTop ){
  604. new Element("div.o2_homepage_task_item_top").setStyles({"margin-right":"10px"}).inject(cell); //.addClass("mainColor_bg");
  605. }
  606. var creatorPerson = o2.name.cn(d.creatorPerson)
  607. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_creator");
  608. new Element("div.o2_homepage_task_item_creator", {"text": creatorPerson, "title": this.app.lp.publishPerson+": "+creatorPerson}).inject(cell);
  609. var time = (d.publishTime || d.createTime).substr(0,10);
  610. cell = row.insertCell(-1).addClass("o2_homepage_task_item_cell_time");
  611. new Element("div.o2_homepage_task_item_time", {"text": time, "title": this.app.lp.publishTime+": "+time}).inject(cell);
  612. return row;
  613. },
  614. checkLoadPage: function(){
  615. if (this.itemCount){
  616. this.getPageCount();
  617. this.loadPage(this.itemPageArea);
  618. }
  619. },
  620. getPageCount:function(){
  621. var n = this.itemCount/this.pageSize;
  622. var nInt = n.toInt();
  623. this.pages = (nInt===n) ? nInt : nInt+1;
  624. },
  625. open: function(e, d){
  626. var id = d.infoId || d.id;
  627. var options = {"documentId": id, "docTitle": d.title, "appId": "cms.Document"+id};
  628. layout.openApplication(e, "cms.Document", options);
  629. },
  630. });