SourceText.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xApplication.process.Xform.SourceText = MWF.APPSourceText = new Class({
  3. Extends: MWF.APP$Module,
  4. _loadUserInterface: function(){
  5. this._loadJsonData();
  6. },
  7. _getSource: function(){
  8. var parent = this.node.getParent();
  9. while(parent && (parent.get("MWFtype")!="source" && parent.get("MWFtype")!="subSource" && parent.get("MWFtype")!="subSourceItem")) parent = parent.getParent();
  10. return (parent) ? parent.retrieve("module") : null;
  11. },
  12. _loadJsonData: function(){
  13. this.node.set("text", "");
  14. this.source = this._getSource();
  15. if (this.source){
  16. if (this.source.data){
  17. COMMON.AjaxModule.load("JSONTemplate", function(){
  18. this.template = new Template();
  19. this.text = this.template.substitute("{"+this.json.jsonPath+"}", this.source.data);
  20. if (this.json.jsonText){
  21. if (this.json.jsonText.code){
  22. this.text = this.form.Macro.exec(this.json.jsonText.code, this);
  23. if( typeOf(this.text) === "string" )this.node.set("text", this.text);
  24. }else{
  25. this.node.set("text", this.text);
  26. }
  27. }else{
  28. this.node.set("text", this.text);
  29. }
  30. }.bind(this));
  31. }
  32. }
  33. }
  34. });