FileContent.js 9.9 KB

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