MWF.xApplication.ScriptEditor.ScriptArea = new Class({ initialize: function(editor){ this.editor = editor; this.node = this.editor.scriptAreaNode; this.css = this.editor.css; this.statementNodes = []; this.statements = []; this.links = []; this.mortises = []; this.beginStatements = []; this.currentLink = null; this.load(); }, load: function(){ this.titleNode = new Element("div", {"styles": this.css.scriptAreaTitleNode}).inject(this.node); this.blockArea = new Element("div", {"styles": this.css.scriptAreaBlockNode}).inject(this.node); this.scriptArea = new Element("div", {"styles": this.css.scriptAreaScriptNode}).inject(this.node); this.blockAreaContent = new Element("div").inject(this.blockArea); this.loadTitleNode(); this.setAreaSizeFun = this.setAreaSize.bind(this); this.editor.app.addEvent("resize", this.setAreaSizeFun); this.setAreaSize(); }, setAreaSize: function(){ var size = this.node.getSize(); var titleSize = this.titleNode.getSize(); var y = size.y-titleSize.y; this.blockArea.setStyle("height", ""+y+"px"); this.scriptArea.setStyle("height", ""+y+"px"); this.beginStatements.each(function(statement){ var p = statement.node.getPosition(this.blockArea); var size = statement.node.getSize(); var h = p.y+size.y; this.blockAreaContent.setStyle("height", ""+h+"px"); }.bind(this)); }, loadTitleNode: function(){ this.blockTabNode = new Element("div", {"styles": this.css.scriptAreaTitleBlockNode}).inject(this.titleNode); this.scriptTabNode = new Element("div", {"styles": this.css.scriptAreaTitleScriptNode}).inject(this.titleNode); this.blockTabNode.set("text", this.editor.app.lp.block); this.scriptTabNode.set("text", this.editor.app.lp.script); this.blockTabNode.setStyles(this.css.titleActionNode_current); this.blockTabNode.addEvent("click", function(){ this.blockTabNode.setStyles(this.css.titleActionNode_current); this.blockArea.setStyle("display", "block"); this.scriptTabNode.setStyles(this.css.scriptAreaTitleScriptNode); this.scriptArea.setStyle("display", "none"); }.bind(this)); this.scriptTabNode.addEvent("click", function(){ this.blockTabNode.setStyles(this.css.scriptAreaTitleBlockNode); this.blockArea.setStyle("display", "none"); this.scriptTabNode.setStyles(this.css.titleActionNode_current); this.scriptArea.setStyle("display", "block"); }.bind(this)); }, createStatement: function(node, block){ this.statementNodes.push(node); var classPath = ("statement."+block.data.class).split("."); var clazz = MWF.xApplication.ScriptEditor; classPath.each(function(p){ if (clazz){clazz = clazz[p];} }.bind(this)); if (!clazz) clazz = this.createClazz(block); if (clazz){ var statement = new clazz(node, block, this); return statement; } return null; }, createClazz: function(block){ var clazz = MWF.xApplication.ScriptEditor; var classPath = ("statement."+block.data.class).split("."); classPath.each(function(p, i){ if (i===(classPath.length-1)){ clazz[p] = new Class({ Extends: MWF.xApplication.ScriptEditor.statement.$Statement[block.data.extend] }); clazz = clazz[p]; }else{ clazz = clazz[p]; if (!clazz) clazz = {}; } }.bind(this)); return clazz; }, buildStatement: function(statement){ statement.load(); this.statements.push(statement); return statement; }, // checkDownLinks: function(checkLink, p, max){ // this.downLinks.each(function(link){ // var v = Math.abs(link.position.x-p.x)+Math.abs(link.position.y-p.y); // if (checkLink.distance===null){ // if (v