Collect.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. MWF.xDesktop.requireApp("Setting", "servers.DataServers", null, false);
  2. MWF.xApplication.Setting.resource = MWF.xApplication.Setting.resource || {};
  3. MWF.xApplication.Setting.resource.Collect = new Class({
  4. Extends: MWF.xApplication.Setting.servers.DataServer.Document,
  5. Implements: [Events],
  6. initialize: function(explorer){
  7. this.explorer = explorer;
  8. this.app = this.explorer.app;
  9. this.container = this.explorer.collectContent;
  10. this.css = this.explorer.app.css;
  11. this.load();
  12. },
  13. load: function(){
  14. this.app.actions.getResCollect(function(json){
  15. this.json = json.data;
  16. this.node = new Element("div", {"styles": this.css.centerServerDocumentNode}).inject(this.container);
  17. this.createForm();
  18. }.bind(this));
  19. },
  20. createActions: function(){
  21. this.actionNode = new Element("div", {"styles": this.css.applicationServerDocumentActionNode}).inject(this.node);
  22. this.saveAction = new Element("div", {"styles": this.css.applicationServerDocumentSaveNode}).inject(this.actionNode);
  23. //this.closeAction = new Element("div", {"styles": this.css.applicationServerDocumentCloseNode}).inject(this.actionNode);
  24. this.saveAction.addEvents({
  25. "mouseover": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_over);}.bind(this),
  26. "mouseout": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode);}.bind(this),
  27. "mousedown": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_down);}.bind(this),
  28. "mouseup": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_over);}.bind(this),
  29. "click": function(e){this.saveDocument();}.bind(this)
  30. });
  31. },
  32. createBaseInfo: function(){
  33. this.inforAreaNode = new Element("div", {"styles": this.css.applicationServerDocumentInforAreaNode}).inject(this.node);
  34. this.inforNode = new Element("div", {"styles": this.css.dataServerDocumentInforNode}).inject(this.inforAreaNode);
  35. var html = "<table cellSpacing='8px' width='90%' align='center'>" +
  36. "<tr><td width='120px'>enable</td><td><select>" +
  37. "<option value='true' "+((this.json.enable) ? "selected" : "")+">true</option>" +
  38. "<option value='false' "+((!this.json.enable) ? "selected" : "")+">false</option>" +
  39. "</select></td></tr>" +
  40. "<tr><td>name</td><td><input value='"+(this.json.name || "")+"'/></td></tr>" +
  41. "<tr><td>password</td><td><input value='"+(this.json.password || "")+"'/></td></tr>" +
  42. "</table>";
  43. this.inforNode.set("html", html);
  44. var tds = this.inforNode.getElements("td");
  45. var inputs = this.inforNode.getElements("input");
  46. tds.setStyles(this.css.applicationServerDocumentTdNode);
  47. inputs.setStyles(this.css.applicationServerDocumentInputNode);
  48. },
  49. saveDocument: function(){
  50. var inputs = this.inforNode.getElements("input");
  51. this.json.name = inputs[0].get("value");
  52. this.json.password = inputs[1].get("value");
  53. var select = this.inforNode.getElement("select");
  54. var str = select.options[select.selectedIndex].value;
  55. this.json.enable = (str=="true") ? true : false;
  56. this.app.actions.updateResCollect(this.json, function(){
  57. this.app.notice(this.app.lp.centerSaveInfor, "success");
  58. }.bind(this));
  59. },
  60. destroy: function(){
  61. if (this.node) this.node.destroy();
  62. MWF.release(this);
  63. },
  64. });