EventsEditor.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. MWF.xApplication.cms.FormDesigner.widget = MWF.xApplication.cms.FormDesigner.widget || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", null, false);
  3. MWF.xApplication.cms.FormDesigner.widget.EventsEditor = new Class({
  4. Extends: MWF.xApplication.process.FormDesigner.widget.EventsEditor,
  5. load: function(data){
  6. this.data = data;
  7. Object.each(data, function(obj, key){
  8. var item = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor.Item(this);
  9. item.load(key, obj);
  10. this.items.push(item);
  11. }.bind(this));
  12. },
  13. addEvent: function(){
  14. var item = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor.Item(this);
  15. item.load("", "");
  16. }
  17. });
  18. MWF.xApplication.cms.FormDesigner.widget.EventsEditor.Item = new Class({
  19. Extends: MWF.xApplication.process.FormDesigner.widget.EventsEditor.Item,
  20. editCode: function(){
  21. if (this.editor.currentEditItem){
  22. if (this.editor.currentEditItem!=this) this.editor.currentEditItem.editCodeComplete();
  23. }
  24. if (this.editor.currentEditItem!=this){
  25. if (!this.codeEditor){
  26. this.codeEditor = new MWF.widget.ScriptArea(this.codeNode, {
  27. "style": "event",
  28. "title": "on"+this.event+" (S)",
  29. "maxObj": this.editor.options.maxObj,
  30. "onChange": function(){
  31. var json = this.codeEditor.toJson();
  32. this.data.code = json.code;
  33. this.data.html = json.html;
  34. this.checkIcon();
  35. }.bind(this),
  36. "onSave": function(){
  37. var json = this.codeEditor.toJson();
  38. this.data.code = json.code;
  39. this.data.html = json.html;
  40. this.editor.app.saveForm();
  41. }.bind(this),
  42. "helpStyle" : "cms"
  43. });
  44. this.codeEditor.load(this.data);
  45. }
  46. if (!this.morph){
  47. this.morph = new Fx.Morph(this.codeNode, {duration: 200});
  48. }
  49. this.codeNode.setStyle("display", "block");
  50. this.morph.start({"height": [0,300]}).chain(function(){
  51. this.codeEditor.resizeContentNodeSize();
  52. this.codeEditor.focus();
  53. // this.fireEvent("postShow");
  54. }.bind(this));
  55. this.editor.currentEditItem = this;
  56. }else{
  57. this.editCodeComplete();
  58. }
  59. }
  60. });