Person.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. MWF.xDesktop.requireApp("Setting", "servers.DataServers", null, false);
  2. MWF.xApplication.Setting.resource = MWF.xApplication.Setting.resource || {};
  3. MWF.xApplication.Setting.resource.Person = 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.personContent;
  10. this.css = this.explorer.app.css;
  11. this.load();
  12. },
  13. load: function(){
  14. this.app.actions.getResPerson(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'>defaultPassword</td><td><input value='"+(this.json.defaultPassword || "")+"'/></td></tr>" +
  37. "<tr><td>defaultIconMale</td><td><textarea>"+(this.json.defaultIconMale || "")+"</textarea></td></tr>" +
  38. "<tr><td>defaultIconFemale</td><td><textarea>"+(this.json.defaultIconFemale || "")+"</textarea></td></tr>" +
  39. "<tr><td>defaultIcon</td><td><textarea>"+(this.json.defaultIcon || "")+"</textarea></td></tr>" +
  40. "</table>";
  41. this.inforNode.set("html", html);
  42. var tds = this.inforNode.getElements("td");
  43. var inputs = this.inforNode.getElements("input");
  44. var textareas = this.inforNode.getElements("textarea");
  45. tds.setStyles(this.css.applicationServerDocumentTdNode);
  46. inputs.setStyles(this.css.applicationServerDocumentInputNode);
  47. textareas.setStyles(this.css.applicationServerDocumentTextareasNode);
  48. },
  49. saveDocument: function(){
  50. var inputs = this.inforNode.getElements("input");
  51. var textareas = this.inforNode.getElements("textarea");
  52. this.json.defaultPassword = inputs[0].get("value");
  53. this.json.defaultIconMale = textareas[0].get("value");
  54. this.json.defaultIconFemale = textareas[1].get("value");
  55. this.json.defaultIcon = textareas[2].get("value");
  56. this.app.actions.updateResPerson(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. });