SettingModuleResource.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. MWF.xApplication.Setting.ResourceModuleDocument = new Class({
  2. Extends: MWF.xApplication.Setting.Document,
  3. load: function(){
  4. this.node = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  5. this.titleName = new Element("div", {"styles": this.explorer.css.explorerContentTitleNode}).inject(this.node);
  6. this.titleName.set("text", this.lp.ui_moduleSetting_resource);
  7. this.uploadTitleNode = new Element("div",{"styles":this.css.explorerContentItemTitleNode}).inject(this.contentAreaNode);
  8. this.uploadTitleNode.set("text",this.lp.resource_upload);
  9. this.uploadFileNode = new Element("input",{"type":"file","styles":this.css.explorerContentInputInforNode}).inject(this.contentAreaNode);
  10. this.isReplaceTitleNode = new Element("div",{"styles":this.css.explorerContentItemTitleNode}).inject(this.contentAreaNode);
  11. this.isReplaceTitleNode.set("text",this.lp.resource_replace);
  12. this.isReplaceDescNode = new Element("div",{"styles":this.css.explorerContentInputInforNode}).inject(this.contentAreaNode);
  13. this.isReplaceDescNode.set("text",this.lp.resource_replaceDesc);
  14. this.isReplaceNode = new Element("div",{"styles":this.css.explorerContentInputInforNode}).inject(this.contentAreaNode);
  15. this.isReplaceSelectNode = new Element("select").inject(this.isReplaceNode);
  16. new Element("option",{"value":false,"text":this.lp.resource_replace_yes}).inject(this.isReplaceSelectNode);
  17. new Element("option",{"value":true,"text":this.lp.resource_replace_no}).inject(this.isReplaceSelectNode);
  18. this.filePathTitleNode = new Element("div",{"styles":this.css.explorerContentItemTitleNode}).inject(this.contentAreaNode);
  19. this.filePathTitleNode.set("text",this.lp.resource_filePath);
  20. this.filePathDescNode = new Element("div",{"styles":this.css.explorerContentInputInforNode}).inject(this.contentAreaNode);
  21. this.filePathDescNode.set("text",this.lp.resource_filePathDesc);
  22. this.filePathNode = new Element("div",{"styles":this.css.explorerContentInputInforNode}).inject(this.contentAreaNode);
  23. this.filePathInputNode = new Element("input", {"styles": {"width": "500px"}}).inject(this.filePathNode);
  24. this.submitNode = new Element("div",{"styles":this.css.explorerContentInputInforNode}).inject(this.contentAreaNode);
  25. this.submitBtnNode = new Element("button",{"styles":this.css.explorerContentButtonNode,"text":this.lp.ok}).inject(this.submitNode);
  26. this.submitNode.setStyle("margin-top","40px");
  27. this.submitBtnNode.addEvent("click",function () {
  28. var files = this.uploadFileNode.files;
  29. if (files.length) {
  30. var file = files[0];
  31. var asNew = this.isReplaceSelectNode.get("value")
  32. var formData = new FormData();
  33. formData.append("file", file);
  34. formData.append("fileName", file.name);
  35. formData.append("filePath", this.filePathInputNode.get("value"));
  36. o2.Actions.load("x_program_center").ModuleAction.dispatchResource(asNew, formData, null, function (json){
  37. this.app.notice(this.lp.resource_success, "success", this.appContentNode);
  38. }.bind(this),false);
  39. }
  40. }.bind(this))
  41. }
  42. });