FileContent.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. MWF.xApplication.Homepage.FileContent = new Class({
  2. Extends: MWF.xApplication.Homepage.TaskContent,
  3. Implements: [Options, Events],
  4. options: {
  5. "view": "fileContent.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.loadMyFile(function(){
  12. this.fireEvent("load");
  13. }.bind(this));
  14. // //是否需要定时自动刷新 @todo
  15. // this.startProcessAction.addEvent("click", this.startProcess.bind(this));
  16. //this.moreInforAction.addEvent("click", this.moreInfor.bind(this));
  17. }.bind(this));
  18. },
  19. openFile: function(e){
  20. //应用市场中的云文件,门户id为95135369-ab35-47ba-a9ce-845f26ff9efb
  21. o2.Actions.load("x_portal_assemble_surface").PortalAction.get("95135369-ab35-47ba-a9ce-845f26ff9efb", function () {
  22. layout.openApplication(e, "portal.Portal", {
  23. portalId : "95135369-ab35-47ba-a9ce-845f26ff9efb"
  24. });
  25. }, function(){
  26. layout.openApplication(e, "File");
  27. })
  28. },
  29. setContentSize: function(){
  30. var total = this.container.getSize().y;
  31. var titleHeight = this.taskTitleNode.getSize().y+this.taskTitleNode.getEdgeHeight();
  32. var bottomHeight = this.pageAreaNode.getSize().y+this.pageAreaNode.getEdgeHeight();
  33. var thisHeight = this.itemContentNode.getEdgeHeight();
  34. var contentHeight = total-titleHeight-bottomHeight-thisHeight;
  35. this.itemContentNode.setStyle("height", ""+contentHeight+"px");
  36. this.contentHeight = contentHeight;
  37. //this.pageSize = (this.options.itemHeight/this.contentHeight).toInt();
  38. if (this.noItemNode){
  39. var m = (this.contentHeight- this.noItemNode.getSize().y)/2;
  40. this.noItemNode.setStyle("margin-top", ""+m+"px");
  41. }
  42. },
  43. loadMyFile: function(callback){
  44. this.loadFile(null, callback);
  45. },
  46. loadFile: function(e, callback){
  47. if (!this.isLoading) {
  48. if (!this.fileContentTab){
  49. this.fileContentTab = new MWF.xApplication.Homepage.FileContent.File(this, this.fileTab, {
  50. "onLoad": function(){ if (callback) callback(); }
  51. });
  52. }else{
  53. this.fileContentTab.load();
  54. }
  55. this.currentTab = this.fileContentTab;
  56. }
  57. }
  58. });
  59. MWF.xApplication.Homepage.FileContent.File = new Class({
  60. Extends: MWF.xApplication.Homepage.TaskContent.Task,
  61. Implements: [Options, Events],
  62. options: {
  63. "itemHeight": 50,
  64. "type": "file"
  65. },
  66. getIconJson: function(callback){
  67. if (!this.iconJson){
  68. o2.JSON.get("../x_component_File/$Main/icon.json", function(iconJson){
  69. this.iconJson = iconJson;
  70. if (callback) callback();
  71. }.bind(this));
  72. }else{
  73. if (callback) callback();
  74. }
  75. },
  76. loadItemsRes: function(){
  77. var items = [];
  78. o2.Actions.load("x_file_assemble_control").Attachment2Action.listTop(function(json2){
  79. o2.Actions.load("x_file_assemble_control").AttachmentAction.listTop(function(json){
  80. if( json2.data && json2.data.length ){
  81. json2.data.map(function (d) {
  82. d.version = "v2"
  83. });
  84. items = items.concat( json2.data );
  85. }
  86. if( json.data && json.data.length ){
  87. json.data.map(function (d) {
  88. d.version = "v1"
  89. });
  90. items = items.concat( json.data );
  91. }
  92. if (items.length){
  93. items.sort( function (a, b) {
  94. return Date.parse( b.lastUpdateTime ) - Date.parse( a.lastUpdateTime )
  95. });
  96. this.getIconJson(function(){
  97. this.loadItems(items);
  98. }.bind(this));
  99. }else{
  100. this.emptyLoadContent();
  101. }
  102. this.fireEvent("load");
  103. }.bind(this));
  104. }.bind(this));
  105. // o2.Actions.load("x_file_assemble_control").AttachmentAction.listTop(function(json){
  106. // if (json.data && json.data.length){
  107. // this.getIconJson(function(){
  108. // this.loadItems(json.data);
  109. // }.bind(this));
  110. // }else{
  111. // this.emptyLoadContent();
  112. // }
  113. // this.fireEvent("load");
  114. // }.bind(this));
  115. },
  116. emptyLoadContent: function(){
  117. this.container.empty();
  118. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  119. this.content.pageAreaNode.empty();
  120. //this.itemContentNode.addClass("o2_homepage_task_area_content_empty").addClass("icon_notask");
  121. this.content.noItemNode = new Element("div.o2_homepage_file_area_content_empty_node", {"text": this.app.lp.noFile}).inject(this.container);
  122. this.content.noItemNode.addEvent("click", function(e){
  123. // layout.openApplication(e, "File");
  124. this.content.openFile(e);
  125. }.bind(this));
  126. var m = (this.content.contentHeight- this.content.noItemNode.getSize().y)/2;
  127. this.content.noItemNode.setStyle("margin-top", ""+m+"px");
  128. this.content.isLoading = false;
  129. },
  130. loadItems: function(data){
  131. for (var i=0; i<Math.min(data.length, this.pageSize); i++){
  132. var d = data[i];
  133. this.loadItem(d, i);
  134. }
  135. this.endLoadContent();
  136. },
  137. loadItemRow: function(d){
  138. var row = new Element("div.o2_homepage_file_item_node").inject(this.container);
  139. var iconArea = new Element("div.o2_homepage_file_item_icon").inject(row);
  140. var actionArea = new Element("div.o2_homepage_file_item_action", {"title": this.app.lp.download}).inject(row);
  141. var titleArea = new Element("div.o2_homepage_file_item_title", {"text": d.name, "title": d.name}).inject(row);
  142. var imgName = this.iconJson[d.extension.toLowerCase()];
  143. if (!imgName) imgName = this.iconJson["unknow"];
  144. iconArea.setStyle("background-image", "url(../x_component_File/$Main/default/file/"+imgName+")");
  145. return row;
  146. },
  147. loadItem: function(d, i){
  148. var row = this.loadItemRow(d, i);
  149. var _self = this;
  150. row.store("data", d);
  151. row.addEvents({
  152. "mouseover": function(){
  153. this.addClass("mainColor_color").addClass("o2_homepage_task_item_row_over");
  154. },
  155. "mouseout": function(){
  156. this.removeClass("mainColor_color").removeClass("o2_homepage_task_item_row_over");
  157. }
  158. });
  159. row.getLast().addEvent("click", function(e){
  160. var d = this.getParent().retrieve("data");
  161. _self.openAttachment(d);
  162. });
  163. row.getLast().getPrevious().addEvent("click", function(e){
  164. var d = this.getParent().retrieve("data");
  165. _self.downloadAttachment(d);
  166. });
  167. },
  168. openAttachment: function(d){
  169. if( d.version === "v2" ){
  170. o2.Actions.get("x_file_assemble_control").getFileDownloadUrl2(d.id, function(url){
  171. window.open(o2.filterUrl(url));
  172. });
  173. }else{
  174. o2.Actions.get("x_file_assemble_control").getFileDownloadUrl(d.id, function(url){
  175. window.open(o2.filterUrl(url));
  176. });
  177. }
  178. },
  179. downloadAttachment: function(d){
  180. if( d.version === "v2" ) {
  181. o2.Actions.get("x_file_assemble_control").getFileUrl2(d.id, function (url) {
  182. window.open(o2.filterUrl(url));
  183. });
  184. }else{
  185. o2.Actions.get("x_file_assemble_control").getFileUrl(d.id, function (url) {
  186. window.open(o2.filterUrl(url));
  187. });
  188. }
  189. },
  190. open: function(e, d){
  191. layout.openApplication(e, "Meeting");
  192. }
  193. });
  194. // MWF.xApplication.Homepage.MeetingContent.Meeting = new Class({
  195. // Extends: MWF.xApplication.Homepage.MeetingContent.MeetingInvited,
  196. // Implements: [Options, Events],
  197. // options: {
  198. // "itemHeight": 80,
  199. // "type": "meetingInvited",
  200. // "month": 1
  201. // },
  202. // loadItemsRes: function(){
  203. // o2.Actions.load("x_meeting_assemble_control").MeetingAction.listComingMonth(this.options.month, function(json){
  204. // if (json.data && json.data.length){
  205. // this.loadItems(json.data);
  206. // }else{
  207. // this.emptyLoadContent();
  208. // }
  209. // this.fireEvent("load");
  210. // }.bind(this));
  211. // },
  212. // loadItemRow: function(d){
  213. // var row = new Element("div.o2_homepage_meeting_item_node").inject(this.container);
  214. //
  215. // var actionArea = new Element("div.o2_homepage_meeting_item_action").inject(row);
  216. // var inforArea = new Element("div.o2_homepage_meeting_item_infor").inject(row);
  217. //
  218. // var titleNode = new Element("div.o2_homepage_meeting_item_title", {"text": d.subject, "title": d.subject}).inject(inforArea);
  219. //
  220. // var timeNode = new Element("div.o2_homepage_meeting_item_time").inject(inforArea);
  221. // var start = (new Date()).parse(d.startTime);
  222. // var completed = (new Date()).parse(d.completedTime);
  223. // var startStr = start.format("%Y-%m-%d %H:%M");
  224. // var completedStr = start.format("%H:%M");
  225. // timeNode.set("html", this.app.lp.meetingTime+": <span style='color: #999999'>"+startStr+" - "+completedStr+"<span>");
  226. //
  227. // var locationNode = new Element("div.o2_homepage_meeting_item_location").inject(inforArea);
  228. // locationNode.set("html", this.app.lp.meetingLocation+": <span style='color: #999999'>"+d.woRoom.name+"<span>");
  229. //
  230. //
  231. // return row;
  232. // },
  233. // });