Main.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. MWF.xDesktop.requireApp("TeamWork", "Common", null, false);
  2. MWF.xApplication.TeamWork.options = {
  3. multitask: false,
  4. executable: true
  5. };
  6. MWF.xApplication.TeamWork.Main = new Class({
  7. Extends: MWF.xApplication.Common.Main,
  8. Implements: [Options, Events],
  9. options: {
  10. "style": "default",
  11. "name": "TeamWork",
  12. "icon": "appicon.png",
  13. // "width": "1270",
  14. // "height": "700",
  15. // "isResize": false,
  16. // "isMax": true,
  17. "title": MWF.xApplication.TeamWork.LP.title
  18. },
  19. onQueryLoad: function(){
  20. this.lp = MWF.xApplication.TeamWork.LP;
  21. },
  22. loadApplication: function(callback){
  23. this.user = layout.desktop.session.user.name;
  24. this.distinguishedName = layout.desktop.session.user.distinguishedName;
  25. this.userGender = layout.desktop.session.user.genderType;
  26. this.department="";
  27. this.restActions = MWF.Actions.get("x_teamwork_assemble_control");
  28. this.orgActions = MWF.Actions.get("x_organization_assemble_express");
  29. MWF.xDesktop.requireApp("TeamWork", "ProjectList", function(){
  30. this.pl = new MWF.xApplication.TeamWork.ProjectList(this.content,this,this.restActions,{
  31. });
  32. this.pl.load();
  33. }.bind(this))
  34. },
  35. showTips:function(target,data,opt){
  36. var opt = Object.merge( {nodeStyles:this.css.tips.nodeStyles}, opt );
  37. // if(this.stTimer){
  38. // clearTimeout(this.stTimer);
  39. // }
  40. // this.stTimer = window.setTimeout(function(){
  41. // var tt = new MWF.xApplication.TeamWork.Common.Tips(this.content, target, this.app, data, opt);
  42. // tt.load();
  43. // }.bind(this),100)
  44. var tt = new MWF.xApplication.TeamWork.Common.Tips(this.content, target, this.app, data, opt);
  45. tt.load();
  46. },
  47. selectCalendar : function( target, container, options, callback ){
  48. var type = options.type;
  49. var calendarOptions = {
  50. "style" : "xform",
  51. "isTime": type == "time" || type.toLowerCase() == "datetime",
  52. "timeOnly": type == "time",
  53. "target": container,
  54. "onComplate" : function( dateString ,date ){
  55. var json={
  56. "action":"ok",
  57. "dateString":dateString,
  58. "date":date
  59. };
  60. if( callback )callback( json );
  61. }.bind(this),
  62. "onClear":function(){
  63. var json={
  64. "action":"clear"
  65. };
  66. if(callback) callback(json);
  67. //if(this.calendar) delete this.calendar;
  68. }.bind(this),
  69. "onHide":function(){ //alert("hidden");
  70. //this.calendar.container.destroy();
  71. // this.calendar.visible = false;
  72. //delete this.calendar;
  73. //if(this.calendar) delete this.calendar;
  74. }.bind(this)
  75. };
  76. if( options.calendarOptions ){
  77. calendarOptions = Object.merge( calendarOptions, options.calendarOptions )
  78. }
  79. MWF.require("MWF.widget.Calendar", function(){
  80. //if(this.calendar) delete this.calendar;
  81. //else {
  82. this.calendar = new MWF.widget.Calendar( target, calendarOptions);
  83. this.calendar.show();
  84. //}
  85. }.bind(this));
  86. },
  87. setScrollBar: function(node, view, style, offset, callback){
  88. if (!style) style = "default";
  89. if (!offset){
  90. offset = {
  91. "V": {"x": 0, "y": 0},
  92. "H": {"x": 0, "y": 0}
  93. };
  94. }
  95. MWF.require("MWF.widget.ScrollBar", function(){
  96. if(this.scrollbar && this.scrollbar.scrollVAreaNode){
  97. this.scrollbar.scrollVAreaNode.destroy();
  98. delete this.scrollbar;
  99. }
  100. this.scrollbar = new MWF.widget.ScrollBar(node, {
  101. "style": style,
  102. "offset": offset,
  103. "where": "before",
  104. "indent": false,
  105. "distance": 100,
  106. "friction": 4,
  107. "onScroll": function (y) {
  108. var scrollSize = node.getScrollSize();
  109. var clientSize = node.getSize();
  110. var scrollHeight = scrollSize.y - clientSize.y;
  111. if (y + 200 > scrollHeight && view && view.loadElementList) {
  112. if (! view.isItemsLoaded) view.loadElementList()
  113. }
  114. }.bind(this)
  115. });
  116. if (callback) callback();
  117. }.bind(this));
  118. return false;
  119. },
  120. setLoading:function(container){
  121. var _height = container.getHeight();
  122. var _width = container.getWidth();
  123. var loading = new Element("img",{styles:this.css.loading,"src":"http://dev.o2oa.net/x_component_TeamWork/$Main/default/icon/loading.gif"}).inject(container);
  124. loading.setStyles({
  125. "margin-left":(_width-loading.getWidth())/2+"px"
  126. })
  127. },
  128. showErrorMessage:function(xhr,text,error){
  129. var errorText = error;
  130. var errorMessage;
  131. if (xhr) errorMessage = xhr.responseText;
  132. if(errorMessage!=""){
  133. var e = JSON.parse(errorMessage);
  134. if(e.message){
  135. this.notice( e.message,"error");
  136. }else{
  137. this.notice( errorText,"error");
  138. }
  139. }else{
  140. this.notice(errorText,"error");
  141. }
  142. }
  143. });