MWF.xApplication.query.QueryExplorer.Importer = new Class({ Extends: MWF.widget.Common, Implements: [Options, Events], options: { "style": "default" }, initialize: function(app, e, options){ this.setOptions(options); this.app = app; this.container = this.app.content; this.actions = this.app.restActions; this.event = e; this.path = "../x_component_query_QueryExplorer/$Importer/"; this.cssPath = "../x_component_query_QueryExplorer/$Importer/"+this.options.style+"/css.wcss"; this._loadCss(); }, load: function(){ this.container.mask({ "destroyOnHide": true, "style": { "background-color": "#666", "opacity": 0.6 } }); this.node = new Element("div", {"styles": this.css.content}); this.titleNode = new Element("div", {"styles": this.css.titleNode, "text": this.app.lp.application.import}).inject(this.node); this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node); this.buttonAreaNode = new Element("div", {"styles": this.css.buttonAreaNode}).inject(this.node); this.cancelButton = new Element("div", {"styles": this.css.button, "text": this.app.lp.application.export_cancel}).inject(this.buttonAreaNode); this.okButton = new Element("div", {"styles": this.css.okButton, "text": this.app.lp.application.export_ok}).inject(this.buttonAreaNode); this.loadContent(); this.setEvent(); this.node.inject(this.container); this.node.position({ relativeTo: this.container, position: 'center', edge: 'center' }); }, loadContent: function(){ this.textarea = new Element("textarea", {"styles": this.css.textarea}).inject(this.contentNode); }, setEvent: function(){ this.cancelButton.addEvent("click", function(e){ this.close(); }.bind(this)); this.okButton.addEvent("click", function(e){ this.importApplication(); }.bind(this)); }, close: function(){ this.container.unmask(); this.node.destroy(); this.cancelButton = null; this.okButton = null; this.buttonAreaNode = null; this.contentNode = null; this.titleNode = null; this.node = null; this.fireEvent("close"); }, importApplication: function(){ var str = this.textarea.get("value"); if (str){ this.applicationJson = JSON.decode(str); var name = this.applicationJson.application.name; this.actions.listApplicationSummary("", function(json){ var flag = "create"; var overApplication = null; if (json.data){ for (var i=0; i