1 line
21 KiB
JavaScript
1 line
21 KiB
JavaScript
if(!window.console){window.console=new function(){this.log=function(a){};this.dir=function(a){}}}function svg_edit_setup(){var I=["#000000","#202020","#404040","#606060","#808080","#a0a0a0","#c0c0c0","#e0e0e0","#ffffff","#800000","#ff0000","#808000","#ffff00","#008000","#00ff00","#008080","#00ffff","#000080","#0000ff","#800080","#ff00ff","#2b0000","#550000","#800000","#aa0000","#d40000","#ff0000","#ff2a2a","#ff5555","#ff8080","#ffaaaa","#ffd5d5","#280b0b","#501616","#782121","#a02c2c","#c83737","#d35f5f","#de8787","#e9afaf","#f4d7d7","#241c1c","#483737","#6c5353","#916f6f","#ac9393","#c8b7b7","#e3dbdb","#2b1100","#552200","#803300","#aa4400","#d45500","#ff6600","#ff7f2a","#ff9955","#ffb380","#ffccaa","#ffe6d5","#28170b","#502d16","#784421","#a05a2c","#c87137","#d38d5f","#deaa87","#e9c6af","#f4e3d7","#241f1c","#483e37","#6c5d53","#917c6f","#ac9d93","#c8beb7","#e3dedb","#2b2200","#554400","#806600","#aa8800","#d4aa00","#ffcc00","#ffd42a","#ffdd55","#ffe680","#ffeeaa","#fff6d5","#28220b","#504416","#786721","#a0892c","#c8ab37","#d3bc5f","#decd87","#e9ddaf","#f4eed7","#24221c","#484537","#6c6753","#918a6f","#aca793","#c8c4b7","#e3e2db","#222b00","#445500","#668000","#88aa00","#aad400","#ccff00","#d4ff2a","#ddff55","#e5ff80","#eeffaa","#f6ffd5","#22280b","#445016","#677821","#89a02c","#abc837","#bcd35f","#cdde87","#dde9af","#eef4d7","#22241c","#454837","#676c53","#8a916f","#a7ac93","#c4c8b7","#e2e3db","#112b00","#225500","#338000","#44aa00","#55d400","#66ff00","#7fff2a","#99ff55","#b3ff80","#ccffaa","#e5ffd5","#17280b","#2d5016","#447821","#5aa02c","#71c837","#8dd35f","#aade87","#c6e9af","#e3f4d7","#1f241c","#3e4837","#5d6c53","#7c916f","#9dac93","#bec8b7","#dee3db","#002b00","#005500","#008000","#00aa00","#00d400","#00ff00","#2aff2a","#55ff55","#80ff80","#aaffaa","#d5ffd5","#0b280b","#165016","#217821","#2ca02c","#37c837","#5fd35f","#87de87","#afe9af","#d7f4d7","#1c241c","#374837","#536c53","#6f916f","#93ac93","#b7c8b7","#dbe3db","#002b11","#005522","#008033","#00aa44","#00d455","#00ff66","#2aff80","#55ff99","#80ffb3","#aaffcc","#d5ffe6","#0b2817","#16502d","#217844","#2ca05a","#37c871","#5fd38d","#87deaa","#afe9c6","#d7f4e3","#1c241f","#37483e","#536c5d","#6f917c","#93ac9d","#b7c8be","#dbe3de","#002b22","#005544","#008066","#00aa88","#00d4aa","#00ffcc","#2affd5","#55ffdd","#80ffe6","#aaffee","#d5fff6","#0b2822","#165044","#217867","#2ca089","#37c8ab","#5fd3bc","#87decd","#afe9dd","#d7f4ee","#1c2422","#374845","#536c67","#6f918a","#93aca7","#b7c8c4","#dbe3e2","#00222b","#004455","#006680","#0088aa","#00aad4","#00ccff","#2ad4ff","#55ddff","#80e5ff","#aaeeff","#d5f6ff","#0b2228","#164450","#216778","#2c89a0","#37abc8","#5fbcd3","#87cdde","#afdde9","#d7eef4","#1c2224","#374548","#53676c","#6f8a91","#93a7ac","#b7c4c8","#dbe2e3","#00112b","#002255","#003380","#0044aa","#0055d4","#0066ff","#2a7fff","#5599ff","#80b3ff","#aaccff","#d5e5ff","#0b1728","#162d50","#214478","#2c5aa0","#3771c8","#5f8dd3","#87aade","#afc6e9","#d7e3f4","#1c1f24","#373e48","#535d6c","#6f7c91","#939dac","#b7bec8","#dbdee3","#00002b","#000055","#000080","#0000aa","#0000d4","#0000ff","#2a2aff","#5555ff","#8080ff","#aaaaff","#d5d5ff","#0b0b28","#161650","#212178","#2c2ca0","#3737c8","#5f5fd3","#8787de","#afafe9","#d7d7f4","#1c1c24","#373748","#53536c","#6f6f91","#9393ac","#b7b7c8","#dbdbe3","#11002b","#220055","#330080","#4400aa","#5500d4","#6600ff","#7f2aff","#9955ff","#b380ff","#ccaaff","#e5d5ff","#170b28","#2d1650","#442178","#5a2ca0","#7137c8","#8d5fd3","#aa87de","#c6afe9","#e3d7f4","#1f1c24","#3e3748","#5d536c","#7c6f91","#9d93ac","#beb7c8","#dedbe3","#22002b","#440055","#660080","#8800aa","#aa00d4","#cc00ff","#d42aff","#dd55ff","#e580ff","#eeaaff","#f6d5ff","#220b28","#441650","#672178","#892ca0","#ab37c8","#bc5fd3","#cd87de","#ddafe9","#eed7f4","#221c24","#453748","#67536c","#8a6f91","#a793ac","#c4b7c8","#e2dbe3","#2b0022","#550044","#800066","#aa0088","#d400aa","#ff00cc","#ff2ad4","#ff55dd","#ff80e5","#ffaaee","#ffd5f6","#280b22","#501644","#782167","#a02c89","#c837ab","#d35fbc","#de87cd","#e9afdd","#f4d7ee","#241c22","#483745","#6c5367","#916f8a","#ac93a7","#c8b7c4","#e3dbe2","#2b0011","#550022","#800033","#aa0044","#d40055","#ff0066","#ff2a7f","#ff5599","#ff80b2","#ffaacc","#ffd5e5","#280b17","#50162d","#782144","#a02c5a","#c83771","#d35f8d","#de87aa","#e9afc6","#f4d7e3","#241c1f","#48373e","#6c535d","#916f7c","#ac939d","#c8b7be","#e3dbde"];var O=false;var y="";var T=new SvgCanvas(document.getElementById("svgcanvas"));var L=function(){$(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");$("#tool_select").addClass("tool_button_current");$("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all} #svgcanvas svg{cursor:default}");T.setMode("select")};var z=1250;var ap=false;var al=null;var Z=false;var R=false;var P=["x","y","x1","x2","y1","y2","cx","cy","width","height","r","rx","ry","width","height","radius"];var C=["em","ex","px","cm","mm","in","pt","pc","%"];var g=new $.jGraduate.Paint({solidColor:"FF0000"});var E=new $.jGraduate.Paint({solidColor:"000000"});var at=function(ay,i){ay.open("data:image/svg+xml;base64,"+Utils.encode64(i))};var ad=function(ay,i){al=(i.length==1||i[1]==null?i[0]:null);Z=(i.length>=2&&i[1]!=null);if(al!=null){if(T.getMode()!="multiselect"){L()}u()}Y()};var ah=function(aB,ay){for(var az=0;az<ay.length;++az){var aA=ay[az];if(aA&&aA.tagName=="svg"){aw(parseInt(aA.getAttribute("width")),parseInt(aA.getAttribute("height")))}}Y()};var u=function(){if(al!=null){var i=parseFloat(al.getAttribute("fill-opacity"));if(isNaN(i)){i=1}var az=parseFloat(al.getAttribute("stroke-opacity"));if(isNaN(az)){az=1}var aB=al.getAttribute("fill")||"none";T.setFillColor(aB,true);T.setFillOpacity(i,true);var aA=al.getAttribute("stroke")||"none";T.setStrokeColor(aA,true);T.setStrokeOpacity(az,true);i*=100;az*=100;var ay=function(aC,aE){var aD=null;if(aC.substr(0,5)=="url(#"){aD={alpha:aE,linearGradient:document.getElementById(aC.substr(5,aC.length-6))}}else{if(aC.substr(0,1)=="#"){aD={alpha:aE,solidColor:aC.substr(1)}}}return new $.jGraduate.Paint(aD)};g=ay(aB,i);E=ay(aA,az);i=i+" %";az=az+" %";if(aB=="none"){i="N/A"}document.getElementById("gradbox_fill").parentNode.firstChild.setAttribute("fill",aB);if(aA==null||aA==""||aA=="none"){aA="none";az="N/A"}document.getElementById("gradbox_stroke").parentNode.firstChild.setAttribute("fill",aA);$("#fill_opacity").html(i);$("#stroke_opacity").html(az);$("#group_opacity").val(((al.getAttribute("opacity")||1)*100)+" %");$("#stroke_width").val(al.getAttribute("stroke-width")||1);$("#stroke_style").val(al.getAttribute("stroke-dasharray")||"none")}w()};var Y=function(){var az=al;if(T.getMode()=="rotate"&&az!=null){$("#angle").val(T.getRotationAngle(az));return}$("#selected_panel, #multiselected_panel, #rect_panel, #circle_panel, #ellipse_panel, #line_panel, #text_panel").hide();if(az!=null){$("#angle").val(T.getRotationAngle(az));$("#selected_panel").show();var i={rect:["radius","x","y","width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"]};var ay=az.tagName;if(i[ay]){var aA=i[ay];$("#"+ay+"_panel").show();$.each(aA,function(aB,aC){$("#"+ay+"_"+aC).val(az.getAttribute(aC)||0)});if(ay=="text"){$("#text_panel").css("display","inline");if(T.getItalic()){$("#tool_italic").addClass("tool_button_current")}else{$("#tool_italic").removeClass("tool_button_current")}if(T.getBold()){$("#tool_bold").addClass("tool_button_current")}else{$("#tool_bold").removeClass("tool_button_current")}$("#font_family").val(az.getAttribute("font-family"));$("#font_size").val(az.getAttribute("font-size"));$("#text").val(az.textContent);if(T.addedNew){$("#text").focus().select()}}}}else{if(Z){$("#multiselected_panel").show()}}if(T.getUndoStackSize()>0){$("#tool_undo").removeClass("tool_button_disabled")}else{$("#tool_undo").addClass("tool_button_disabled")}if(T.getRedoStackSize()>0){$("#tool_redo").removeClass("tool_button_disabled")}else{$("#tool_redo").addClass("tool_button_disabled")}T.addedNew=false};$("#text").focus(function(){ap=true});$("#text").blur(function(){ap=false});T.bind("selected",ad);T.bind("changed",ah);T.bind("saved",at);var au='<div class="palette_item" style="background-image: url(\'images/none.png\');" data-rgb="none"></div>';$.each(I,function(ay,az){au+='<div class="palette_item" style="background-color: '+az+';" data-rgb="'+az+'"></div>'});$("#palette").append(au);var ai=$("#tools_rect_show").position();$("#tools_rect").css({left:ai.left+4,top:ai.top+70});ai=$("#tools_ellipse_show").position();$("#tools_ellipse").css({left:ai.left+4,top:ai.top+70});var an=function(i){T.setRectRadius(i.value)};var am=function(i){var ay=i.value;if(ay==0&&al&&$.inArray(al.nodeName,["line","polyline"])!=-1){ay=i.value=1}T.setStrokeWidth(ay)};var q=function(i){T.setRotationAngle(i.value)};$("#stroke_style").change(function(){T.setStrokeStyle(this.options[this.selectedIndex].value)});$("select").change(function(){$(this).blur()});$("#group_opacity").change(function(){T.setOpacity(this.options[this.selectedIndex].value)});$("#font_size").change(function(){T.setFontSize(this.options[this.selectedIndex].value)});$("#font_family").change(function(){T.setFontFamily(this.options[this.selectedIndex].value)});$("#text").keyup(function(){T.setTextContent(this.value)});$(".attr_changer").change(function(){var i=this.getAttribute("alt");var az=this.value;var ay=false;if($.inArray(i,P)!=-1){if(!isNaN(az)){ay=true}else{}}else{ay=true}if(!ay){alert("Invalid value given for"+$(this).attr("title").replace("Change","")+".");this.value=al.getAttribute(i);return false}T.changeSelectedAttribute(i,az)});$("#palette").mouseover(function(){var i=$('<input type="hidden">');$(this).append(i);i.focus().remove()});$(".palette_item").click(function(i){var aA=(i.shiftKey?"stroke":"fill");var aC=(i.shiftKey?"#stroke_":"#fill_");var az=$(this).attr("data-rgb");var ay=document.getElementById("gradbox_"+aA).parentNode.firstChild;var aB=null;if(az=="transparent"||az=="initial"){az="none";$(aC+"opacity").html("N/A");aB=new $.jGraduate.Paint()}else{aB=new $.jGraduate.Paint({alpha:100,solidColor:az.substr(1)})}ay.setAttribute("fill",az);if(i.shiftKey){E=aB;if(T.getStrokeColor()!=az){T.setStrokeColor(az)}if(az!="none"&&T.getStrokeOpacity()!=1){T.setStrokeOpacity(1);$("#stroke_opacity").html("100 %")}}else{g=aB;if(T.getFillColor()!=az){T.setFillColor(az)}if(az!="none"&&T.getFillOpacity()!=1){T.setFillOpacity(1);$("#fill_opacity").html("100 %")}}w()});var F=function(ay,i){if($(ay).hasClass("tool_button_disabled")){return false}var i=i||"normal";$(".tools_flyout").fadeOut(i);$("#styleoverrides").text("");$(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");$(ay).addClass("tool_button_current");T.clearSelection();return true};var G=function(){if(F("#tool_select")){T.setMode("select");$("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}};var av=function(){if(F("#tool_path")){T.setMode("path")}};var U=function(){if(F("#tool_line")){T.setMode("line")}};var l=function(){if(F("#tools_rect_show",z)){z="normal";T.setMode("square")}$("#tools_rect_show").attr("src","images/square.png")};var S=function(){if(F("#tools_rect_show")){T.setMode("rect")}$("#tools_rect_show").attr("src","images/rect.png")};var o=function(){if(F("#tools_rect_show")){T.setMode("fhrect")}$("#tools_rect_show").attr("src","images/freehand-square.png")};var a=function(){if(F("#tools_ellipse_show",z)){z="normal";T.setMode("circle")}$("#tools_ellipse_show").attr("src","images/circle.png")};var D=function(){if(F("#tools_ellipse_show")){T.setMode("ellipse")}$("#tools_ellipse_show").attr("src","images/ellipse.png")};var N=function(){if(F("#tools_ellipse_show")){T.setMode("fhellipse")}$("#tools_ellipse_show").attr("src","images/freehand-circle.png")};var r=function(){F("#tool_text");T.setMode("text")};var ab=function(){F("#tool_poly");T.setMode("poly")};var c=function(){if(al!=null||Z){T.deleteSelectedElements()}};var f=function(){if(al!=null){T.moveToTopSelectedElement()}};var B=function(){if(al!=null){T.moveToBottomSelectedElement()}};var m=function(ay,i){if(al!=null||Z){T.moveSelectedElements(ay,i)}};var aj=function(){T.cycleElement(1)};var Q=function(){T.cycleElement(0)};var d=function(i){if(al==null||Z){return}var az=5;if(!i){az*=-1}var ay=$("#angle").val()*1+az;T.setRotationAngle(ay)};var X=function(){if(confirm("Do you want to clear the drawing?\nThis will also erase your undo history!")){T.clear();Y()}};var M=function(){T.setBold(!T.getBold());Y()};var W=function(){T.setItalic(!T.getItalic());Y()};var aa=function(){T.save()};var ak=function(){T.open()};var s=function(){if(T.getUndoStackSize()>0){T.undo()}};var K=function(){if(T.getRedoStackSize()>0){T.redo()}};var A=function(){T.cloneSelectedElements()};var e=function(){T.alignSelectedElements("l",$("#align_relative_to option:selected").val())};var ae=function(){T.alignSelectedElements("c",$("#align_relative_to option:selected").val())};var j=function(){T.alignSelectedElements("r",$("#align_relative_to option:selected").val())};var H=function(){T.alignSelectedElements("t",$("#align_relative_to option:selected").val())};var ac=function(){T.alignSelectedElements("m",$("#align_relative_to option:selected").val())};var v=function(){T.alignSelectedElements("b",$("#align_relative_to option:selected").val())};var k=function(){if(R){return}R=true;var i=T.getSvgString();$("#svg_source_textarea").val(i);$("#svg_source_editor").fadeIn();h();$("#svg_source_textarea").focus()};var h=function(){var i=$("#svg_source_container").height()-80;$("#svg_source_textarea").css("height",i)};var ao=function(){if(!R){return}if(!T.setSvgString($("#svg_source_textarea").val())){if(!confirm("There were parsing errors in your SVG source.\nRevert back to original SVG source?")){return false}}T.clearSelection();ar()};var V=function(){if(!R){return}var i=T.getSvgString();if(i!=$("#svg_source_textarea").val()){if(!confirm("Ignore changes made to SVG source?")){return false}}ar()};var ar=function(){$("#svg_source_editor").hide();R=false;$("#svg_source_textarea").blur()};$(window).resize(function(i){if(!R){return}h()});$("#tool_select").click(G);$("#tool_path").click(av);$("#tool_line").click(U);$("#tool_square").mouseup(l);$("#tool_rect").mouseup(S);$("#tool_fhrect").mouseup(o);$("#tool_circle").mouseup(a);$("#tool_ellipse").mouseup(D);$("#tool_fhellipse").mouseup(N);$("#tool_text").click(r);$("#tool_poly").click(ab);$("#tool_clear").click(X);$("#tool_save").click(aa);$("#tool_open").click(ak);$("#tool_source").click(k);$("#tool_source_cancel,#svg_source_overlay").click(V);$("#tool_source_save").click(ao);$("#tool_delete").click(c);$("#tool_delete_multi").click(c);$("#tool_move_top").click(f);$("#tool_move_bottom").click(B);$("#tool_undo").click(s);$("#tool_redo").click(K);$("#tool_clone").click(A);$("#tool_clone_multi").click(A);$("#tool_alignleft").click(e);$("#tool_aligncenter").click(ae);$("#tool_alignright").click(j);$("#tool_aligntop").click(H);$("#tool_alignmiddle").click(ac);$("#tool_alignbottom").click(v);$("#tools_rect_show").click(l);$("#tools_ellipse_show").click(a);$("#tool_bold").mousedown(M);$("#tool_italic").mousedown(W);function ag(){var az=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"];var i="";var ay="tool_button_current";$.each(az,function(aA,aB){i+="#tool_"+aB+(aA==az.length-1?",":"")});$(i).mousedown(function(){$(this).addClass(ay)}).bind("mousedown mouseout",function(){$(this).removeClass(ay)});$("#tool_undo, #tool_redo").mousedown(function(){if(!$(this).hasClass("tool_button_disabled")){$(this).addClass(ay)}}).bind("mousedown mouseout",function(){$(this).removeClass(ay)})}ag();if(O){var x=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];var J=x.length;while(J--){var b=document.getElementById(x[J]);var n=b.title;var aq=n.indexOf("Ctrl+");b.title=[n.substr(0,aq),"Cmd+",n.substr(aq+5)].join("")}}function t(){var i=[["1",G],["2",av],["3",U],["Shift+4",l],["4",S],["Shift+5",a],["5",D],["6",r],["7",ab],[y+"N",function(ay){X();ay.preventDefault()}],[y+"S",function(ay){R?ao():aa();ay.preventDefault()}],[y+"O",function(ay){ak();ay.preventDefault()}],["del",function(ay){c();ay.preventDefault()}],["backspace",function(ay){c();ay.preventDefault()}],["shift+up",f],["shift+down",B],["shift+left",function(){d(0)}],["shift+right",function(){d(1)}],["shift+O",Q],["shift+P",aj],["up",function(ay){m(0,-1);ay.preventDefault()}],["down",function(ay){m(0,1);ay.preventDefault()}],["left",function(ay){m(-1,0);ay.preventDefault()}],["right",function(ay){m(1,0);ay.preventDefault()}],[y+"z",function(ay){s();ay.preventDefault()}],[y+"y",function(ay){K();ay.preventDefault()}],[y+"u",function(ay){k();ay.preventDefault()}],[y+"c",function(ay){A();ay.preventDefault()}],["esc",V,false]];$.each(i,function(az,aA){var ay=!(aA.length>2&&!aA[2]);$(document).bind("keydown",{combi:aA[0],disableInInput:ay},aA[1])});$(".attr_changer").bind("keydown",{combi:"return",disableInInput:false},function(ay){$(this).change();ay.preventDefault()})}t();var af=function(az){var ay=az.attr("id")=="stroke_color"?"stroke":"fill";var i=(ay=="stroke"?$("#stroke_opacity"):$("#fill_opacity"));var aC=(ay=="stroke"?E:g);var aB=(ay=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity");var aA=false;if(aC.type=="none"){aC=new $.jGraduate.Paint({solidColor:"ffffff"});aA=true}var aD=az.position();$("#color_picker").css({left:aD.left-140,bottom:124-aD.top}).jGraduate({paint:aC,window:{pickerTitle:aB},images:{clientPath:"jgraduate/images/"},},function(aI){aC=new $.jGraduate.Paint(aI);var aG=document.getElementById("gradbox_"+ay);var aH=aG.parentNode;var aF=aH.firstChild;if(aC.type=="linearGradient"){aH.removeChild(aG);var aE=aH.appendChild(document.importNode(aC.linearGradient,true));aE.id="gradbox_"+ay;aF.setAttribute("fill","url(#gradbox_"+ay+")")}else{aF.setAttribute("fill","#"+aC.solidColor)}i.html(aC.alpha+" %");if(ay=="stroke"){T.setStrokePaint(aC,true)}else{T.setFillPaint(aC,true)}u();$("#color_picker").hide()},function(aE){$("#color_picker").hide()})};var w=function(){var i=(T.getFillColor()=="none");var ay=(T.getStrokeColor()=="none");var aB=["#tool_path","#tool_line"];var aA=["#tools_rect_show","#tools_ellipse_show","#tool_text"];if(ay){for(aq in aB){var az=aB[aq];if($(az).hasClass("tool_button_current")){G()}$(az).removeClass("tool_button").addClass("tool_button_disabled")}}else{for(aq in aB){var az=aB[aq];$(az).removeClass("tool_button_disabled").addClass("tool_button")}}if(ay&&i){for(aq in aA){var az=aA[aq];if($(az).hasClass("tool_button_current")){G()}$(az).removeClass("tool_button").addClass("tool_button_disabled")}}else{for(aq in aA){var az=aA[aq];$(az).removeClass("tool_button_disabled").addClass("tool_button")}}};var p=new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" fill="#FF0000"/> <linearGradient id="gradbox_"> <stop stop-color="#000" offset="0.0"/> <stop stop-color="#FF0000" offset="1.0"/> </linearGradient></svg>',"text/xml");var ax=p.getElementById("gradbox_");ax.id="gradbox_fill";$("#fill_color").append(document.importNode(p.documentElement,true));ax.id="gradbox_stroke";$(p.documentElement.firstChild).attr("fill","#000000");$("#stroke_color").append(document.importNode(p.documentElement,true));$("#fill_color").click(function(){af($(this));w()});$("#stroke_color").click(function(){af($(this));w()});$("#tools_rect_show").mousedown(function(i){$("#tools_rect").show();i.preventDefault()});$("#tools_rect").mouseleave(function(){$("#tools_rect").fadeOut()});$("#tool_move_top").mousedown(function(i){$("#tools_stacking").show();i.preventDefault()});$("#tools_ellipse_show").mousedown(function(i){$("#tools_ellipse").show();i.preventDefault()});$("#tools_ellipse").mouseleave(function(){$("#tools_ellipse").fadeOut()});$(".tool_flyout_button").mouseover(function(){$(this).addClass("tool_flyout_button_current")}).mouseout(function(){$(this).removeClass("tool_flyout_button_current")});function aw(i,aA){var ay=i+"x"+aA;var az=false;$("#resolution option").each(function(){if($(this).text()==ay){$("#resolution").val(i+"x"+aA);az=true}});if(!az){$("#resolution").val("Custom")}$("#svgcanvas").css({width:i,height:aA})}$("#resolution").change(function(){if(this.value=="Custom"){var aA=prompt("Please enter custom size (i.e. 400x300)","");var ay=aA.match(/(\d+)[x \/,](\d+)/);if(!ay){alert("Invalid size. Please format it as WIDTHxHEIGHT (like 400x300)");return false}else{var i=ay[1],aB=ay[2];if(i=="0"||aB=="0"){alert("Invalid size. Width or height may not be 0.");return false}}}else{if(this.value=="Fit to content"){var i="",aB=""}else{var az=this.value.split("x");var i=parseInt(az[0]),aB=parseInt(az[1])}}T.setResolution(i,aB)});$("#rect_rx").SpinButton({min:0,max:1000,step:1,callback:an});$("#stroke_width").SpinButton({min:0,max:99,step:1,callback:am});$("#angle").SpinButton({min:-180,max:180,step:5,callback:q});T.setCustomHandlers=function(i){if(i.open){$("#tool_open").show();T.bind("opened",i.open)}if(i.save){T.bind("saved",i.save)}};return T}$(function(){svgCanvas=svg_edit_setup()}); |