From 3db76d41990ef71266f749ab01af11897f655c8f Mon Sep 17 00:00:00 2001 From: chanlee Date: Thu, 4 Feb 2016 16:00:27 +0900 Subject: [PATCH 1/2] multi-line text box size to 200 --- dist/entry.js | 15 ++------------- dist/entry.min.js | 6 +++--- src/object.js | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/dist/entry.js b/dist/entry.js index 4184ae5069..2081d076b7 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -7235,20 +7235,9 @@ Entry.EntryObject.prototype.initEntity = function(a) { b.height = c.height; } else { if ("textBox" == this.objectType) { - if (b.regX = 25, b.regY = 12, b.scaleX = b.scaleY = 1.5, b.width = 50, b.height = 24, b.text = a.name, a.options) { + if (b.regX = 25, b.regY = 12, b.scaleX = b.scaleY = 1.5, b.width = 50, b.height = 24, b.text = a.text, a.options) { if (a = a.options, c = "", a.bold && (c += "bold "), a.italic && (c += "italic "), b.underline = a.underline, b.strike = a.strike, b.font = c + "20px " + a.font.family, b.colour = a.colour, b.bgColor = a.background, b.lineBreak = a.lineBreak) { - a = b.text.split("\n"); - if (1 < a.length) { - for (var c = a[0].length, d = 1, e = a.length;d < e;d++) { - a[d].length > c && (c = a[d].length); - } - b.width = 25 * c; - b.height = 24 * a.length; - } else { - b.width = 25 * b.text.length; - } - b.regX = b.width / 2; - b.regY = b.height / 2; + b.width = 256, b.height = .5625 * b.width, b.regX = b.width / 2, b.regY = b.height / 2; } } else { b.underline = !1, b.strike = !1, b.font = "20px Nanum Gothic", b.colour = "#000000", b.bgColor = "#ffffff"; diff --git a/dist/entry.min.js b/dist/entry.min.js index e866ac39a0..be7ba1e6de 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -679,9 +679,9 @@ d=Entry.createElement("div"),d.addClass("rotationMethodWrapper"),a.appendChild(d a=Entry.createElement("div"),a.addClass("entryObjectRotateModeWorkspace"),a.addClass("entryObjectRotateModeBWorkspace"),a.object=this,this.rotateModeBView_=a,d.appendChild(a),a.bindOnClick(function(a){Entry.engine.isState("run")||this.object.setRotateMethod("vertical")}),a=Entry.createElement("div"),a.addClass("entryObjectRotateModeWorkspace"),a.addClass("entryObjectRotateModeCWorkspace"),a.object=this,this.rotateModeCView_=a,d.appendChild(a),a.bindOnClick(function(a){Entry.engine.isState("run")|| this.object.setRotateMethod("none")}),this.updateThumbnailView(),this.updateCoordinateView(),this.updateRotateMethodView(),this.updateInputViews(),this.view_};Entry.EntryObject.prototype.setName=function(a){Entry.assert("string"==typeof a,"object name must be string");this.name=a;this.nameView_.value=a};Entry.EntryObject.prototype.setText=function(a){Entry.assert("string"==typeof a,"object text must be string");this.text=a};Entry.EntryObject.prototype.setScript=function(a){this.script=a}; Entry.EntryObject.prototype.getScriptText=function(a){a=Blockly.Xml.domToText(this.script);a=a.replace(/\sxmlns=\"(.*?)\"/,"");a=a.replace(/\sclass=\"(.*?)\"/g,"");a=a.replace(/\sid=\"(.*?)\"/g,"");return a=a.replace(/\sinline=\"(.*?)\"/g,"")}; -Entry.EntryObject.prototype.initEntity=function(a){var b={};b.x=b.y=0;b.rotation=0;b.direction=90;if("sprite"==this.objectType){var c=a.sprite.pictures[0].dimension;b.regX=c.width/2;b.regY=c.height/2;b.scaleX=b.scaleY="background"==a.sprite.category.main?Math.max(270/c.height,480/c.width):"new"==a.sprite.category.main?1:200/(c.width+c.height);b.width=c.width;b.height=c.height}else if("textBox"==this.objectType)if(b.regX=25,b.regY=12,b.scaleX=b.scaleY=1.5,b.width=50,b.height=24,b.text=a.name,a.options){if(a= -a.options,c="",a.bold&&(c+="bold "),a.italic&&(c+="italic "),b.underline=a.underline,b.strike=a.strike,b.font=c+"20px "+a.font.family,b.colour=a.colour,b.bgColor=a.background,b.lineBreak=a.lineBreak){a=b.text.split("\n");if(1c&&(c=a[d].length);b.width=25*c;b.height=24*a.length}else b.width=25*b.text.length;b.regX=b.width/2;b.regY=b.height/2}}else b.underline=!1,b.strike=!1,b.font="20px Nanum Gothic",b.colour="#000000",b.bgColor="#ffffff"; -return b};Entry.EntryObject.prototype.updateThumbnailView=function(){if("sprite"==this.objectType)if(this.entity.picture.fileurl)this.thumbnailView_.style.backgroundImage='url("'+this.entity.picture.fileurl+'")';else{var a=this.entity.picture.filename;this.thumbnailView_.style.backgroundImage='url("/uploads/'+a.substring(0,2)+"/"+a.substring(2,4)+"/thumb/"+a+'.png")'}else"textBox"==this.objectType&&(this.thumbnailView_.style.backgroundImage="url("+(Entry.mediaFilePath+"/text_icon.png")+")")}; +Entry.EntryObject.prototype.initEntity=function(a){var b={};b.x=b.y=0;b.rotation=0;b.direction=90;if("sprite"==this.objectType){var c=a.sprite.pictures[0].dimension;b.regX=c.width/2;b.regY=c.height/2;b.scaleX=b.scaleY="background"==a.sprite.category.main?Math.max(270/c.height,480/c.width):"new"==a.sprite.category.main?1:200/(c.width+c.height);b.width=c.width;b.height=c.height}else if("textBox"==this.objectType)if(b.regX=25,b.regY=12,b.scaleX=b.scaleY=1.5,b.width=50,b.height=24,b.text=a.text,a.options){if(a= +a.options,c="",a.bold&&(c+="bold "),a.italic&&(c+="italic "),b.underline=a.underline,b.strike=a.strike,b.font=c+"20px "+a.font.family,b.colour=a.colour,b.bgColor=a.background,b.lineBreak=a.lineBreak)b.width=256,b.height=.5625*b.width,b.regX=b.width/2,b.regY=b.height/2}else b.underline=!1,b.strike=!1,b.font="20px Nanum Gothic",b.colour="#000000",b.bgColor="#ffffff";return b}; +Entry.EntryObject.prototype.updateThumbnailView=function(){if("sprite"==this.objectType)if(this.entity.picture.fileurl)this.thumbnailView_.style.backgroundImage='url("'+this.entity.picture.fileurl+'")';else{var a=this.entity.picture.filename;this.thumbnailView_.style.backgroundImage='url("/uploads/'+a.substring(0,2)+"/"+a.substring(2,4)+"/thumb/"+a+'.png")'}else"textBox"==this.objectType&&(this.thumbnailView_.style.backgroundImage="url("+(Entry.mediaFilePath+"/text_icon.png")+")")}; Entry.EntryObject.prototype.updateCoordinateView=function(a){if((this.isSelected()||a)&&this.coordinateView_&&this.coordinateView_.xInput_&&this.coordinateView_.yInput_){a=this.coordinateView_.xInput_.value;var b=this.coordinateView_.yInput_.value,c=this.coordinateView_.sizeInput_.value,d=this.entity.getX().toFixed(1),e=this.entity.getY().toFixed(1),f=this.entity.getSize().toFixed(1);a!=d&&(this.coordinateView_.xInput_.value=d);b!=e&&(this.coordinateView_.yInput_.value=e);c!=f&&(this.coordinateView_.sizeInput_.value= f)}};Entry.EntryObject.prototype.updateRotationView=function(a){if(this.isSelected()&&this.view_||a)a="","free"==this.getRotateMethod()?(this.rotateSpan_.removeClass("entryRemove"),this.rotateInput_.removeClass("entryRemove"),a+=this.entity.getRotation().toFixed(1),this.rotateInput_.value=a+"\u02da"):(this.rotateSpan_.addClass("entryRemove"),this.rotateInput_.addClass("entryRemove")),a=""+this.entity.getDirection().toFixed(1),a+="\u02da",this.directionInput_.value=a}; Entry.EntryObject.prototype.select=function(a){console.log(this)};Entry.EntryObject.prototype.addPicture=function(a,b){Entry.stateManager&&Entry.stateManager.addCommand("add sprite",this,this.removePicture,a.id);b||0===b?(this.pictures.splice(b,0,a),Entry.playground.injectPicture(this)):this.pictures.push(a);return new Entry.State(this,this.removePicture,a.id)}; diff --git a/src/object.js b/src/object.js index a0641585fc..2f6ebe02e8 100644 --- a/src/object.js +++ b/src/object.js @@ -851,7 +851,7 @@ Entry.EntryObject.prototype.initEntity = function(model) { json.scaleX = json.scaleY = 1.5; json.width = 50; json.height = 24; - json.text = model.name; + json.text = model.text; if (model.options) { var options = model.options; var fontStyle = ''; @@ -867,19 +867,28 @@ Entry.EntryObject.prototype.initEntity = function(model) { json.bgColor = options.background; json.lineBreak = options.lineBreak; if (options.lineBreak) { + /* var lines = json.text.split('\n'); if (lines.length > 1) { var maxLen = lines[0].length; + var maxHeight = lines.length; for(var i=1,len=lines.length;i maxLen) { maxLen = lines[i].length; } } - json.width = 25 * maxLen; - json.height = 24 * lines.length; + if (maxLen > 20) maxLen= 20; + if (maxHeight > 3) maxHeight = 3; + + json.width = 20 * maxLen; + json.height = 35 * maxHeight; } else { - json.width = 25 * json.text.length; + json.width = 20 * json.text.length; + json.height = 35; } + */ + json.width = 256; + json.height = json.width * 0.5625; json.regX = json.width / 2; json.regY = json.height / 2; } From 487c654e7c6a1ee46af6cc66f4a8a665059a725b Mon Sep 17 00:00:00 2001 From: chanlee Date: Thu, 4 Feb 2016 16:01:32 +0900 Subject: [PATCH 2/2] remove comments --- src/object.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/object.js b/src/object.js index 2f6ebe02e8..957e20c846 100644 --- a/src/object.js +++ b/src/object.js @@ -867,26 +867,6 @@ Entry.EntryObject.prototype.initEntity = function(model) { json.bgColor = options.background; json.lineBreak = options.lineBreak; if (options.lineBreak) { - /* - var lines = json.text.split('\n'); - if (lines.length > 1) { - var maxLen = lines[0].length; - var maxHeight = lines.length; - for(var i=1,len=lines.length;i maxLen) { - maxLen = lines[i].length; - } - } - if (maxLen > 20) maxLen= 20; - if (maxHeight > 3) maxHeight = 3; - - json.width = 20 * maxLen; - json.height = 35 * maxHeight; - } else { - json.width = 20 * json.text.length; - json.height = 35; - } - */ json.width = 256; json.height = json.width * 0.5625; json.regX = json.width / 2;