Label.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. var value = this.form.Macro.exec(code, this);
  13. this._setNodeText(value);
  14. //this.node.set("text", this.form.Macro.exec(code, this) || "");
  15. }
  16. }
  17. if (this.json.prefixIcon || this.json.suffixIcon){
  18. var text = this.node.get("text");
  19. this.node.empty();
  20. var tNode = new Element("div", {"styles": {
  21. "margin-left": (this.json.prefixIcon) ? "20px" : "0px",
  22. "margin-right": (this.json.suffixIcon) ? "20px" : "0px",
  23. "height": "100%"
  24. }, "text": text}).inject(this.node);
  25. if (this.json.prefixIcon){
  26. var node = new Element("div", {"styles": {
  27. "float": "left",
  28. "width": "20px",
  29. "height": ""+this.node.getSize().y+"px",
  30. "background": "url("+this.json.prefixIcon+") center center no-repeat"
  31. }}).inject(tNode, "before");
  32. }
  33. if (this.json.suffixIcon){
  34. var node = new Element("div", {"styles": {
  35. "float": "right",
  36. "width": "20px",
  37. "height": ""+this.node.getSize().y+"px",
  38. "background": "url("+this.json.suffixIcon+") center center no-repeat"
  39. }}).inject(tNode, "before");
  40. }
  41. }
  42. },
  43. _setNodeText: function(value){
  44. if (value && value.isAG){
  45. value.addResolve(function(v){
  46. this._setNodeText(v);
  47. }.bind(this));
  48. }else{
  49. this.node.set("text", value || "");
  50. }
  51. },
  52. setText: function(text){
  53. this.node.set("text", text);
  54. }
  55. });