Mercurial > laserkard
view awesome_js/robert.js @ 48:b2a11435a89b laserkard
[svn r49] implemented resizing text :)
author | rlm |
---|---|
date | Sun, 31 Jan 2010 20:26:16 -0500 |
parents | 4431dc7d4bb5 |
children | 5eb11cf654de |
line wrap: on
line source
2 descHash = new Object();4 prevVal = "";8 descHash.classic_acrylic_clear =9 "<h1>The Classic LaserKard.</h1>Balanced and Complete. The original LaserKard. For those that wish to leave no stone unturned. It's all there.";11 descHash.big_acrylic_clear =12 "<h1>The Bold Kard.</h1>Austere and Iconic. For those that wish to leave an impression with the power of their name accompanied only by their main method of contact. Bold, period.";14 descHash.basic_acrylic_clear =15 "<h1>The Arrow Kard.</h1>Precise and Straightforward. For those that seek to make a statement while being clear and concise. Straight as an arrow.";17 descHash.lines_acrylic_clear =18 "<h1>The Direct Kard.</h1>Thorough and Distinct. For those that aim to demonstrate their professionalism with style. Push the envelope. Be Direct.";25 function pokedex(target)26 {29 var description = eval ("descHash." + target);31 document.getElementById('pokedex').innerHTML = description;33 }37 function stabForm(ID)38 {39 var JSONtext = document.getElementById('formValues').innerHTML;40 var hash = new Object();41 hash = eval('(' + JSONtext + ')');43 propertyValue = document.getElementById(ID).value;44 propertyName = ID;45 propertyValue = escape(propertyValue);47 eval("hash."+propertyName+"='"+propertyValue+"'");49 var JSONtext = document.getElementById('formValues').innerHTML = JSON.stringify(hash);50 }54 function getPosition(style, field)55 {57 var cardType = eval ("laserkard." + style);60 if ( eval("typeof cardType." + field + " != 'undefined'")) //shouldn't ever really matter61 {62 values = eval("cardType." + field);64 if (typeof values.posx != 'undefined'){posx = values.posx;}65 if (typeof values.posy != 'undefined'){posy = values.posy;}66 if (typeof values.center != 'undefined'){center = values.center;}67 if (typeof values.font != 'undefined'){font = values.font;}68 if (typeof values.face != 'undefined'){face = values.face;}69 if (typeof values.width != 'undefined'){width = values.width;}70 if (typeof values.weirdFlip != 'undefined'){weirdFlip = values.weirdFlip;}71 if (typeof values.resize != 'undefined'){resize = values.resize;}72 }75 }80 function smallRedraw(style,field)81 {85 var JSONtext = document.getElementById('formValues').innerHTML;86 var hash = new Object();87 hash = eval('(' + JSONtext + ')');89 var content = eval("hash."+field);91 content = unescape(content);93 if (prevVal == content){return;}95 posx = 10;96 posy = 10;97 center = 0;98 font = 10;99 face = 700;100 weirdFlip = 0;101 resize = 1;102 width = 450;104 getPosition(style, field);109 target = "d_" + field;112 var whatev = eval("typeof " + target + " != 'undefined'")114 if (whatev){eval ("{" + target + ".remove();}");}116 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );119 var sizzle = eval(target+".getBBox().width;");121 document.getElementById('output').innerHTML = sizzle;124 if (resize == 1)126 {131 //base case132 if ((sizzle) > width)133 {135 mul = .9;138 mul = (width/sizzle);141 font = font * mul;143 //eval( target + ".scale(mul,mul)" );145 eval ( target + ".remove();");146 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );149 }153 }157 var sizzle = eval(target+".getBBox().width;");159 document.getElementById('output').innerHTML = sizzle;161 eval ( target +".attr('stroke', '#fefefe');");162 //eval ( target +".attr('stroke', '#fbafcd');");164 eval ( target +".attr('fill', 'none');");169 if (center == 1)170 {171 eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);");172 }175 if (weirdFlip == 1)176 {177 eval("var c = "+target+".getBBox().width;");178 eval(target+ ".translate((317 - c)/2,0);");179 eval(target+".translate(0, -490);");180 eval(target+".rotate(90,0,0);");181 }185 prevVal = content;189 }191 function clearAll()192 {193 if(typeof d_Name != 'undefined' ){d_Name.remove();}194 if(typeof d_Company != 'undefined' ){d_Company.remove();}195 if(typeof d_Email != 'undefined' ){d_Email.remove();}196 if(typeof d_Occupation != 'undefined' ){d_Occupation.remove();}197 if(typeof d_Phone != 'undefined' ){d_Phone.remove();}198 if(typeof d_Website != 'undefined' ){d_Website.remove();}200 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}201 }203 function redraw(style)204 {209 if (style == "bold")210 {212 clearAll();213 smallRedraw("bold","Name");214 smallRedraw("bold","Email");218 }221 if (style == "arrow")222 {224 clearAll();226 smallRedraw("arrow","Name");227 smallRedraw("arrow","Email");228 smallRedraw("arrow","Occupation");229 smallRedraw("arrow","Company");232 d_lineArt = raphe.path("M 2 272 L 258 272");233 d_lineArt.attr('stroke', '#fefefe');235 }238 if (style == "classic")239 {241 clearAll();243 smallRedraw("classic","Name");244 smallRedraw("classic","Email");245 smallRedraw("classic","Occupation");246 smallRedraw("classic","Company");247 smallRedraw("classic","Phone");248 smallRedraw("classic","Website");249 }252 if (style == "direct")253 {255 clearAll();257 smallRedraw("direct","Name");258 smallRedraw("direct","Email");259 smallRedraw("direct","Occupation");260 smallRedraw("direct","Company");261 smallRedraw("direct","Phone");262 smallRedraw("direct","Website");264 d_lineArt = raphe.path("M 350 165 L 512 165 M 350 173 L 512 173 M 350 181 L 512 181 M 350 189 L 512 189 M 350 197 L 512 197 M 350 213 L 512 213 M 350 205 L 512 205 M 350 221 L 512 221");265 d_lineArt.attr('stroke', '#fefefe');269 }275 }