Label.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xApplication.process.Xform.Label = MWF.APPLabel = new Class({
  3. Implements: [Events],
  4. Extends: MWF.APP$Module,
  5. _loadUserInterface: function(){
  6. if (this.json.valueType == "text"){
  7. this.node.set("text", this.json.text || "");
  8. }
  9. if (this.json.valueType == "script"){
  10. var code = (this.json.script) ? this.json.script.code : "";
  11. if (code){
  12. this.node.set("text", this.form.Macro.exec(code, this) || "");
  13. }
  14. }
  15. if (this.json.prefixIcon || this.json.suffixIcon){
  16. var text = this.node.get("text");
  17. this.node.empty();
  18. var tNode = new Element("div", {"styles": {
  19. "margin-left": (this.json.prefixIcon) ? "20px" : "0px",
  20. "margin-right": (this.json.suffixIcon) ? "20px" : "0px",
  21. "height": "100%"
  22. }, "text": text}).inject(this.node);
  23. if (this.json.prefixIcon){
  24. var node = new Element("div", {"styles": {
  25. "float": "left",
  26. "width": "20px",
  27. "height": ""+this.node.getSize().y+"px",
  28. "background": "url("+this.json.prefixIcon+") center center no-repeat"
  29. }}).inject(tNode, "before");
  30. }
  31. if (this.json.suffixIcon){
  32. var node = new Element("div", {"styles": {
  33. "float": "right",
  34. "width": "20px",
  35. "height": ""+this.node.getSize().y+"px",
  36. "background": "url("+this.json.suffixIcon+") center center no-repeat"
  37. }}).inject(tNode, "before");
  38. }
  39. }
  40. },
  41. setText: function(text){
  42. this.node.set("text", text);
  43. }
  44. });