123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", null, false);
- MWF.xApplication.process.FormDesigner.widget.ParameterEditor = new Class({
- Implements: [Options, Events],
- Extends: MWF.xApplication.process.FormDesigner.widget.EventsEditor,
- options: {
- "style": "default",
- "maxObj": document.body
- },
- load: function(data, module, path){
- this.data = data || {};
- this.module = module;
- this.scriptPath = path;
- //if (!Object.getLength(this.data)){
- this.addNewItemAction = new Element("div", {"styles": this.css.addNewItemAction, "text": "+"}).inject(this.node);
- this.addNewItemAction.addEvent("click", function(){
- this.addEventItem();
- this.addNewItemAction.setStyle("display", "none");
- }.bind(this));
- //}
- Object.each(data, function(obj, key){
- var item = new MWF.xApplication.process.FormDesigner.widget.ParameterEditor.Item(this);
- item.load(key, obj);
- this.items.push(item);
- }.bind(this));
- },
- deleteItem: function(item){
- var oldValue = item.oldData;
- this.items.erase(item);
- var data;
- if (this.data[item.event]){
- data = Object.clone( this.data[item.event] );
- this.data[item.event].code = "";
- this.data[item.event].html = "";
- delete this.data[item.event];
- }
- item.deleteScriptDesignerItem();
- this.fireEvent("change", [item.event, null, data, item.event+" [delete]"]);
- if (item.container){
- item.container.destroy();
- }
- if (!Object.getLength(this.data)){
- if (this.addNewItemAction) this.addNewItemAction.setStyle("display", "block");
- }
- },
- addItem: function(item){
- this.data[item.event] = item.data;
- this.fireEvent("change", [item.event, Object.clone(item.data)]);
- this.items.push(item);
- },
- addEventItem: function(){
- var item = new MWF.xApplication.process.FormDesigner.widget.ParameterEditor.Item(this);
- item.load("", "");
- }
- });
- MWF.xApplication.process.FormDesigner.widget.ParameterEditor.Item = new Class({
- Extends: MWF.xApplication.process.FormDesigner.widget.EventsEditor.Item,
- createContainerTitle: function(){
- this.container = new Element("div", {
- "styles": this.editor.css.itemContainer
- }).inject(this.editor.eventsContainer);
- this.titleContainer = new Element("div", {
- "styles": this.editor.css.itemTitleContainer
- }).inject(this.container);
- this.iconNode = new Element("div", {
- "styles": this.editor.css.parIconNode
- }).inject(this.titleContainer);
- this.actionNode = new Element("div", {
- "styles": this.editor.css.actionNode
- }).inject(this.titleContainer);
- this.textNode = new Element("div", {
- "styles": this.editor.css.textNode,
- "text": this.event
- }).inject(this.titleContainer);
- },
- editCode: function(){
- if (this.editor.currentEditItem){
- if (this.editor.currentEditItem!=this) this.editor.currentEditItem.editCodeComplete();
- }
- if (this.editor.currentEditItem!=this){
- if (!this.codeEditor){
- this.codeEditor = new MWF.widget.ScriptArea(this.codeNode, {
- "style": "event",
- "isbind": false,
- "title": this.event+" (S)",
- "maxObj": this.editor.options.maxObj,
- "onChange": function(){
- var json = this.codeEditor.toJson();
- this.data.code = json.code;
- this.data.html = json.html;
- this.editor.fireEvent("change", [this.event, Object.clone(this.data), this.oldData]);
- this.checkIcon();
- }.bind(this),
- "onSave": function(){
- var json = this.codeEditor.toJson();
- this.data.code = json.code;
- this.data.html = json.html;
- this.checkIcon();
- this.editor.fireEvent("change", [this.event, Object.clone(this.data), this.oldData]);
- this.editor.app.savePage();
- }.bind(this)
- });
- this.codeEditor.load(this.data);
- }
-
- if (!this.morph){
- this.morph = new Fx.Morph(this.codeNode, {duration: 200});
- }
- this.codeNode.setStyle("display", "block");
- this.morph.start({"height": [0,300]}).chain(function(){
- this.codeEditor.resizeContentNodeSize();
- this.codeEditor.focus();
- // this.fireEvent("postShow");
- }.bind(this));
- this.editor.currentEditItem = this;
- }else{
- this.editCodeComplete();
- }
- },
- bindScriptDesigner: function(){
- var form = this.editor.app.form || this.editor.app.page;
- if (form.scriptDesigner) form.scriptDesigner.addScriptItem(this.data, "code", this.editor.module, this.editor.scriptPath, this.event);
- },
- deleteScriptDesignerItem: function(){
- var form = this.editor.app.form || this.editor.app.page;
- if (form.scriptDesigner){
- form.scriptDesigner.deleteScriptItem(this.editor.module, this.editor.scriptPath, this.event);
- }
- },
- checkIcon: function(){
- if (this.data.code){
- this.iconNode.setStyle("background", "url("+this.editor.path+this.editor.options.style+"/icon/codePar.png) center center no-repeat");
- }else{
- this.iconNode.setStyle("background", "url("+this.editor.path+this.editor.options.style+"/icon/codePar_empty.png) center center no-repeat");
- }
- }
- });
|