Main.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. MWF.require("MWF.widget.MaskNode", null, false);
  2. MWF.xApplication.O2Bug.options.multitask = false;
  3. MWF.xApplication.O2Bug.Main = new Class({
  4. Extends: MWF.xApplication.Common.Main,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "name": "O2Bug",
  9. "icon": "icon.png",
  10. "width": "1200",
  11. "height": "700",
  12. "isResize": true,
  13. "isMax": true,
  14. "title": MWF.xApplication.O2Bug.LP.title
  15. },
  16. onQueryLoad: function(){
  17. this.lp = MWF.xApplication.O2Bug.LP;
  18. },
  19. loadApplication: function(callback){
  20. this.loadTitle();
  21. this.loadFilter();
  22. },
  23. loadTitle: function(){
  24. this.loadTitleBar();
  25. this.loadTitleUserNode();
  26. this.loadCreateActionNode();
  27. this.loadTitleTextNode();
  28. this.loadSearchNode();
  29. },
  30. loadTitleBar: function(){
  31. this.titleBar = new Element("div", {
  32. "styles": this.css.titleBar
  33. }).inject(this.content);
  34. },
  35. loadTitleUserNode: function(){
  36. this.titleUserNode = new Element("div", {
  37. "styles": this.css.titleUserNode
  38. }).inject(this.titleBar);
  39. this.titleUserIconNode = new Element("div", {
  40. "styles": this.css.titleUserIconNode
  41. }).inject(this.titleUserNode);
  42. this.titleUserTextNode = new Element("div", {
  43. "styles": this.css.titleUserTextNode,
  44. "text": this.desktop.session.user.name
  45. }).inject(this.titleUserNode);
  46. },
  47. loadCreateActionNode: function() {
  48. this.createAction = new Element("div", {
  49. "styles": this.css.createAction
  50. }).inject(this.titleBar);
  51. this.createAction.addEvents({
  52. "click": function(e){
  53. this.createBug();
  54. }.bind(this)
  55. });
  56. },
  57. loadTitleTextNode: function(){
  58. this.titleTextNode = new Element("div", {
  59. "styles": this.css.titleTextNode,
  60. "text": this.lp.title
  61. }).inject(this.titleBar);
  62. },
  63. loadSearchNode: function(){
  64. this.searchBarAreaNode = new Element("div", {
  65. "styles": this.css.searchBarAreaNode
  66. }).inject(this.titleBar);
  67. this.searchBarNode = new Element("div", {
  68. "styles": this.css.searchBarNode
  69. }).inject(this.searchBarAreaNode);
  70. this.searchBarActionNode = new Element("div", {
  71. "styles": this.css.searchBarActionNode
  72. }).inject(this.searchBarNode);
  73. this.searchBarInputBoxNode = new Element("div", {
  74. "styles": this.css.searchBarInputBoxNode
  75. }).inject(this.searchBarNode);
  76. this.searchBarInputNode = new Element("input", {
  77. "type": "text",
  78. "value": this.lp.searchKey,
  79. "styles": this.css.searchBarInputNode
  80. }).inject(this.searchBarInputBoxNode);
  81. var _self = this;
  82. this.searchBarActionNode.addEvent("click", function(){
  83. this.searchTask();
  84. }.bind(this));
  85. this.searchBarInputNode.addEvents({
  86. "focus": function(){
  87. if (this.value==_self.lp.searchKey) this.set("value", "");
  88. },
  89. "blur": function(){if (!this.value) this.set("value", _self.lp.searchKey);},
  90. "keydown": function(e){
  91. if (e.code==13){
  92. this.searchTask();
  93. e.preventDefault();
  94. }
  95. }.bind(this),
  96. "selectstart": function(e){
  97. e.preventDefault();
  98. }
  99. });
  100. },
  101. loadFilter: function(){
  102. this.filterBar = new Element("div", {"styles": this.css.filterBar}).inject(this.content);
  103. this.filterTitleNode = new Element("div", {"styles": this.css.filterTitleNode}).inject(this.filterBar);
  104. this.filterTitleNode.set("text", this.lp.filter);
  105. this.filterContentNode = new Element("div", {"styles": this.css.filterContentNode}).inject(this.filterBar);
  106. var html = this.lp.bugType+": <select id='sel_bugType'></select><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>"+
  107. this.lp.creator+": <select id='sel_creator'></select><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>"+
  108. this.lp.targetUser+": <select id='sel_targetUser'></select><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>"+
  109. this.lp.status+": <select id='sel_status'></select><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
  110. this.filterContentNode.set("html", html);
  111. this.filterBugTypeNode = this.filterContentNode.getElementById("sel_bugType");
  112. this.filterCreatorNode = this.filterContentNode.getElementById("sel_targetUser");
  113. this.filterTargetUserNode = this.filterContentNode.getElementById("sel_targetUser");
  114. this.filterStatusNode = this.filterContentNode.getElementById("sel_status");
  115. Object.each(this.lp.bugTypeList, function(v, k){new Element("option", {"value": k,"text": v}).inject(this.filterBugTypeNode)}.bind(this));
  116. Object.each(this.lp.statusList, function(v, k){new Element("option", {"value": k,"text": v}).inject(this.filterStatusNode)}.bind(this));
  117. },
  118. createBug: function(){
  119. this.note = new MWF.xApplication.O2Bug.Note(null, this.createAction, this);
  120. }
  121. });
  122. MWF.xApplication.O2Bug.Note = new Class({
  123. initialize: function(data, node, app){
  124. this.data = data;
  125. this.startNode = node;
  126. this.app = app;
  127. this.css = this.app.css;
  128. this.container = this.app.content;
  129. this.isNew = ((this.data) && (this.data.id)) ? true : false;
  130. this.load();
  131. },
  132. load: function(){
  133. if (!this.data) this.createNewData();
  134. this.mask = new MWF.widget.MaskNode(this.container, {"loading": false});
  135. this.mask.load();
  136. this.createNode();
  137. this.show();
  138. //this.loadContent();
  139. },
  140. createNewData: function(){
  141. this.data = {}
  142. },
  143. createNode: function(){
  144. var size = this.startNode.getSize();
  145. this.node = new Element("div", {
  146. "styles": this.css.bugNoteNode
  147. }).inject(this.container);
  148. this.node.setStyles({
  149. "width": ""+size.x+"px",
  150. "height": ""+size.y+"px"
  151. });
  152. this.node.position({
  153. relativeTo: this.startNode,
  154. position: 'topLeft',
  155. edge: 'topLeft'
  156. });
  157. },
  158. show: function(){
  159. var o = this.getNodeCoordinates();
  160. var fx = new Fx.Morph(this.node, {
  161. "duration": "500",
  162. "transition": Fx.Transitions.Expo.easeOut
  163. });
  164. fx.start({
  165. "opacity": 1,
  166. "width": ""+ o.width+"px",
  167. "height": ""+ o.height+"px",
  168. "left": ""+ o.left+"px",
  169. "top": ""+ o.top+"px"
  170. }).chain(function(){
  171. this.setNodeSizeFun = this.setNodeSize.bind(this);
  172. this.app.addEvent("resize", this.setNodeSizeFun);
  173. }.bind(this));
  174. },
  175. setNodeSize: function(){
  176. var o = this.getNodeCoordinates();
  177. this.node.setStyles({
  178. "width": ""+ o.width+"px",
  179. "height": ""+ o.height+"px",
  180. "left": ""+ o.left+"px",
  181. "top": ""+ o.top+"px"
  182. });
  183. },
  184. getNodeCoordinates: function(){
  185. var size = this.container.getSize();
  186. var w = size.x*0.8;
  187. if (w<800) w = 800;
  188. var h = size.y*0.8;
  189. if (h<300) h = 300;
  190. var position = this.container.getPosition(this.container.getOffsetParent());
  191. var l = size.x/2-w/2;
  192. if (l<0) l=0;
  193. l = position.x+l;
  194. var t = size.y/2-h/2;
  195. if (t<0) t=0;
  196. t = position.y+t;
  197. return {
  198. "width": w,
  199. "height": h,
  200. "left": l,
  201. "top": t
  202. }
  203. },
  204. });