OfdView.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.OfdView = MWF.FCOfdView = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/OfdView/ofdView.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/OfdView/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/OfdView/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "ofdview";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "ofdview",
  24. "id": this.json.id,
  25. "styles": this.css.moduleNodeMove,
  26. "events": {
  27. "selectstart": function(){
  28. return false;
  29. }
  30. }
  31. }).inject(this.form.container);
  32. },
  33. _createNode: function(){
  34. this.node = this.moveNode.clone(true, true);
  35. this.node.setStyles(this.css.moduleNode);
  36. this.node.set("id", this.json.id);
  37. this.node.addEvent("selectstart", function(){
  38. return false;
  39. });
  40. this.iconNode = new Element("div", {
  41. "styles": this.css.iconNode
  42. }).inject(this.node);
  43. var icon = new Element("div", {
  44. "styles": this.css.iconNodeIcon
  45. }).inject(this.iconNode);
  46. var text = new Element("div", {
  47. "styles": this.css.iconNodeText,
  48. "text": "OfdView"
  49. }).inject(this.iconNode);
  50. this.setIcon();
  51. },
  52. _loadNodeStyles: function(){
  53. this.iconNode = this.node.getElement("div").setStyles(this.css.iconNode);
  54. this.iconNode.getFirst("div").setStyles(this.css.iconNodeIcon);
  55. this.iconNode.getLast("div").setStyles(this.css.iconNodeText);
  56. },
  57. setIconNode: function(img, txt, color, width){
  58. if (this.iconNode){
  59. this.iconNode.setStyle("width", width);
  60. var icon = this.iconNode.getFirst();
  61. var text = this.iconNode.getLast();
  62. icon.setStyle("background-image", "url("+this.path+this.options.style+"/icon/"+img+".png)");
  63. text.set("text", txt);
  64. text.setStyles({
  65. "color": color,
  66. "width": width-48
  67. });
  68. }
  69. },
  70. setIcon: function(){
  71. this.setIconNode("ofd", "OFD View", "#2b5797", 240);
  72. }
  73. });