building correctly

master
Mark MacKay 2012-07-17 20:03:31 -05:00
parent d509b7cb3a
commit 785e79d297
14 changed files with 276 additions and 287 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -73,9 +73,9 @@ $(PACKAGE): $(COMPILED_JS) $(COMPILED_CSS)
# NOTE: WHITESPACE_ONLY and --formatting PRETTY_PRINT is helpful for debugging.
$(COMPILED_CSS):
java -jar $(YUICOMPRESSOR) \
$(CSS_INPUT_FILES) \
-o $(COMPILED_CSS)
cat $(CSS_INPUT_FILES) > editor/temp.css;
java -jar $(YUICOMPRESSOR) editor/temp.css -o $(COMPILED_CSS);
rm editor/temp.css;
$(COMPILED_JS):
java -jar $(CLOSURE) \

BIN
editor/.DS_Store vendored

Binary file not shown.

View File

@ -874,10 +874,14 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
stroke: transparent !important;
}
#tools_top div[id$="_panel"]:not(#canvas_panel) {
.context_panel {
display: none;
}
#canvas_panel {
display: block;
}
#svg_editor #multiselected_panel .selected_tool {
vertical-align: 12px;
}

View File

@ -222,7 +222,7 @@ $(function(){
<div id="tools_top" class="tools_panel">
<div id="canvas_panel">
<div id="canvas_panel" class="context_panel">
<div class="toolset">
<h4>Canvas</h4>
@ -251,7 +251,7 @@ $(function(){
</div>
<div id="rect_panel">
<div id="rect_panel" class="context_panel">
<h4>Rectangle</h4>
<div class="toolset">
<label id="rect_width_tool" title="Change rectangle width">
@ -269,11 +269,11 @@ $(function(){
</label>
</div>
<div id="path_panel">
<div id="path_panel" class="context_panel">
<h4>Path</h4>
</div>
<div id="image_panel">
<div id="image_panel" class="context_panel">
<h4>Image</h4>
<div class="toolset">
<label><span class="icon_label">Width</span>
@ -294,7 +294,7 @@ $(function(){
</div>
</div>
<div id="circle_panel">
<div id="circle_panel" class="context_panel">
<div class="toolset">
<label id="tool_circle_cx"><span class="icon_label">cx:</span>
<input id="circle_cx" class="attr_changer" title="Change circle's cx coordinate" size="3" data-attr="cx" type="number"/>
@ -310,7 +310,7 @@ $(function(){
</div>
</div>
<div id="ellipse_panel">
<div id="ellipse_panel" class="context_panel">
<h4>Ellipse</h4>
<div class="toolset">
<label id="tool_ellipse_cx"><span>X</span>
@ -330,7 +330,7 @@ $(function(){
</div>
</div>
<div id="line_panel">
<div id="line_panel" class="context_panel">
<h4>Line</h4>
<div class="toolset">
<label id="tool_line_x1"><span>Start X</span>
@ -350,7 +350,7 @@ $(function(){
</div>
</div>
<div id="text_panel">
<div id="text_panel" class="context_panel">
<h4>Text</h4>
<div class="toolset" id="tool_font_family">
@ -390,7 +390,7 @@ $(function(){
</div>
<!-- formerly gsvg_panel -->
<div id="container_panel">
<div id="container_panel" class="context_panel">
<!-- Add viewBox field here? -->
@ -401,23 +401,23 @@ $(function(){
</label>
</div>
<div id="use_panel">
<div id="use_panel" class="context_panel">
<div class="push_button" id="tool_unlink_use" title="Break link to reference element (make unique)"></div>
</div>
<div id="g_panel">
<div id="g_panel" class="context_panel">
<h4>Group</h4>
</div>
<!-- For anchor elements -->
<div id="a_panel">
<div id="a_panel" class="context_panel">
<label id="tool_link_url" title="Set link URL (leave empty to remove)">
<span id="linkLabel" class="icon_label"></span>
<input id="link_url" type="text" size="35"/>
</label>
</div>
<div id="path_node_panel">
<div id="path_node_panel" class="context_panel">
<h4>Edit Path</h4>
<div class="tool_sep"></div>
<div class="tool_button push_button_pressed" id="tool_node_link" title="Link Control Points"><input type="checkbox" checked> Linked Control Points</div>
@ -441,7 +441,7 @@ $(function(){
</div>
<!-- Buttons when a single element is selected -->
<div id="selected_panel">
<div id="selected_panel" class="context_panel">
<label id="tool_angle" title="Change rotation angle" class="toolset">
<span class="icon_label">Rotation</span>
@ -532,7 +532,7 @@ $(function(){
</div>
</label>
</div>
<div id="xy_panel" class="toolset">
<div id="xy_panel" class="toolset" class="context_panel">
<h4>Position</h4>
<label>
<span>X:</span> <input id="selected_x" class="attr_changer" title="Change X coordinate" size="3" data-attr="x" type="number"/>
@ -544,7 +544,7 @@ $(function(){
</div>
<!-- Buttons when multiple elements are selected -->
<div id="multiselected_panel">
<div id="multiselected_panel" class="context_panel">
<h4>Multiple Elements</h4>
<!--<div class="tool_sep"></div> -->
<!--<div class="push_button" id="tool_clone_multi" title="Clone Elements [C]"></div> -->

View File

@ -1039,7 +1039,7 @@
// create the panel if it doesn't exist
if(!panel.length)
panel = $('<div>', {id: tool.panel}).appendTo("#tools_top");
panel = $('<div>', {id: tool.panel}).appendTo("#tools_top").hide();
// TODO: Allow support for other types, or adding to existing tool
switch (tool.type) {
@ -1409,7 +1409,7 @@
"stroke": "none",
"id": "canvas_background",
"opacity": 1,
"fill": fill || $.pref('bkgd_color'),
"fill": fill || "#fff",
"style": "pointer-events:none"
}
});
@ -1419,16 +1419,7 @@
// create a new layer background if it doesn't exist
if (!document.getElementById('canvas_background')) createBackground();
else {
var fill = document.getElementById('canvas_background').getAttribute("fill");
}
if($.pref('bkgd_color')) {
setBackground($.pref('bkgd_color'), $.pref('bkgd_url'));
} else if($.pref('bkgd_url')) {
// No color set, only URL
setBackground(defaultPrefs.bkgd_color, $.pref('bkgd_url'));
}
var fill = document.getElementById('canvas_background').getAttribute("fill");
// updates the toolbar (colors, opacity, etc) based on the selected element
// This function also updates the opacity and id elements that are in the context panel
@ -3525,7 +3516,7 @@
var PaintBox = function(container, type) {
var background = document.getElementById("canvas_background");
var cur = {color: "#fff", opacity: 1}
var cur = {color: "fff", opacity: 1}
if (type == "stroke") cur = curConfig['initStroke'];
if (type == "fill") cur = curConfig['initFill'];
if (type == "canvas" && background) {
@ -3538,7 +3529,6 @@
}
}
// set up gradients to be used for the buttons
var svgdocbox = new DOMParser().parseFromString(
'<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\

File diff suppressed because one or more lines are too long

View File

@ -406,116 +406,116 @@ q/2,y:A.y*q+A.height*q/2});f.getMode()=="zoom"&&A.width&&oa();B()}}};a("#cur_con
a(this).mouseup(Ca);Ba.key&&a(document).bind("keydown",Ba.key[0]+" shift+"+Ba.key[0],Ca)});if(va)ja.attr("data-curopt",I[va].sel);else ja.attr("data-curopt")||ja.attr("data-curopt",I[0].sel);var ya,Da=a(X).position();a(A).css({left:Da.left+34,top:Da.top+77});ja.mousedown(function(Ca){a("#tools_shapelib").is(":visible")&&xa(X,false);if(ja.hasClass("disabled"))return false;var Ba=a(A),tb=Da.left+34,Ta=Ba.width()*-1,ia=Ba.data("shown_popop")?200:0;ya=setTimeout(function(){ja.data("isLibrary")?Ba.css("left",
tb).show():Ba.css("left",Ta).show().animate({left:tb},150);Ba.data("shown_popop",true)},ia);Ca.preventDefault()}).mouseup(function(){clearTimeout(ya);var Ca=a(this).attr("data-curopt");if(ja.data("isLibrary")&&a(X.replace("_show","")).is(":visible"))xa(X,true);else xa(X)&&Ca in Ia&&Ia[Ca]()})});Kb()},Ga=function(q,A){return a("<div>",{"class":"tools_flyout",id:q}).appendTo("#svg_editor").append(A)},Cb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show"),A=q.offset();q=q.outerWidth();
a(this).css({left:(A.left+q)*S,top:A.top})})},Kb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show");if(!q.data("isLibrary")){var A=[];a(this).children().each(function(){A.push(this.title)});q[0].title=A.join(" / ")}})},nb,ab=function(q,A,I){var R=null;if(q.indexOf("url(#")===0){q=(q=f.getRefElem(q))?q.cloneNode(true):a("#"+I+"_color defs *")[0];R={alpha:A};R[q.tagName]=q}else R=q.indexOf("#")===0?{alpha:A,solidColor:q.substr(1)}:{alpha:A,solidColor:"none"};return new a.jGraduate.Paint(R)},
Ya=f.getResolution();if(d.baseUnit!=="px"){Ya.w=svgedit.units.convertUnit(Ya.w)+d.baseUnit;Ya.h=svgedit.units.convertUnit(Ya.h)+d.baseUnit}a(".canvas_width").val(Ya.w);a(".canvas_height").val(Ya.h);a("#docprops_button").on("click",function(){H()});var La=function(q){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ya.w+2,height:Ya.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:q||a.pref("bkgd_color"),style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");
f.setCurrentLayerPosition("1")};document.getElementById("canvas_background")?document.getElementById("canvas_background").getAttribute("fill"):La();if(a.pref("bkgd_color"))p(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&p(o.bkgd_color,a.pref("bkgd_url"));var Ea=c.setImageURL=function(q){q||(q=ea);f.setImageURL(q);a("#image_url").val(q);if(q.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{f.embedImage(q,function(A){A?a("#url_notice").hide():a("#url_notice").show();
ea=q});a("#image_url").show();a("#change_image_url").hide()}},qb=function(q){var A=Math.min(Math.max(12+q.value.length*6,50),300);a(q).width(A)},Ja=function(){var q=Z;if(q!=null&&!q.parentNode)q=null;var A=f.getCurrentDrawing().getCurrentLayerName(),I=f.getMode(),R=d.baseUnit!=="px"?d.baseUnit:null,X=I=="pathedit",ja=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #path_panel, #rect_panel, #canvas_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();
a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");!q&&!Aa&&a("#canvas_panel").show();if(q!=null){var va=q.nodeName,ya=f.getRotationAngle(q);a("#angle").val(Math.round(ya));ya=f.getBlur(q);a("#blur").val(ya);a("#blur_slider").slider("option","value",ya);f.addedNew&&va==="image"&&f.getHref(q).indexOf("data:")!==0&&L();if(!X&&I!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(va)>=
0)a("#xy_panel").hide();else{var Da,Ca;if(["g","polyline","path"].indexOf(va)>=0){if(I=f.getStrokedBBox([q])){Da=I.x;Ca=I.y}}else{Da=q.getAttribute("x");Ca=q.getAttribute("y")}if(R){Da=svgedit.units.convertUnit(Da);Ca=svgedit.units.convertUnit(Ca)}a("#selected_x").val(Math.round(Ca)||0);a("#selected_y").val(Math.round(Da)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(va)==-1&&a(".action_path_convert_selected").removeClass("disabled");va==="path"&&a(".action_path_selected").removeClass("disabled")}else{A=
ta.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!ta.canDeleteNodes);fa("#tool_openclose_path",ta.closed_subpath?"open_path":"close_path");if(A){X=a("#seg_type");if(R){A.x=svgedit.units.convertUnit(A.x);A.y=svgedit.units.convertUnit(A.y)}a("#path_node_x").val(Math.round(A.x));a("#path_node_y").val(Math.round(A.y));A.type?X.val(A.type).removeAttr("disabled"):X.val(4).attr("disabled","disabled")}return}R=
{g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]};var Ba=q.tagName;a(q).data("gsvg")&&a("#g_panel").show();Ba=="path"&&a("#path_panel").show();if(R[Ba]){R=R[Ba];a("#"+Ba+"_panel").show();a.each(R,function(tb,Ta){var ia=q.getAttribute(Ta);if(d.baseUnit!=="px"&&q[Ta])ia=svgedit.units.convertUnit(q[Ta].baseVal.value);a("#"+Ba+"_"+Ta).val(Math.round(ia)||0)});if(Ba=="text"){a("#text_panel").css("display",
"inline");f.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");f.getBold()?a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(q.getAttribute("font-family"));a("#font_size").val(q.getAttribute("font-size"));a("#text").val(q.textContent);f.addedNew&&setTimeout(function(){a("#text").focus().select()},
100)}else if(Ba=="image")Ea(f.getHref(q));else if(Ba==="g"||Ba==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");R=f.getTitle();va=a("#g_title")[0];va.value=R;qb(va);Ba=="use"?va.setAttribute("disabled","disabled"):va.removeAttribute("disabled")}}ja[(Ba==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");ja[(Ba==="g"||!Aa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(Aa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");
ja.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else ja.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");ha.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");ha.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");f.addedNew=false;if(q&&!X||Aa){a("#selLayerNames").removeAttr("disabled").val(A);pa.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else a("#selLayerNames").attr("disabled",
"disabled")};a("#text").focus(function(){});a("#text").blur(function(){});f.bind("selected",function(q,A){var I=f.getMode();I==="select"&&oa();I=I=="pathedit";Z=A.length==1||A[1]==null?A[0]:null;Aa=A.length>=2&&A[1]!=null;if(Z!=null)if(!I){if(Z!=null)switch(Z.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var R=null,X=Z.getElementsByTagName("*"),ja=0,va=X.length;ja<va;ja++){var ya=X[ja].getAttribute("stroke-width");if(ja===0)R=ya;else if(R!==ya)R=null}a("#stroke_width").val(R===
null?"":R);la.fill.update(true);la.stroke.update(true);break;default:la.fill.update(true);la.stroke.update(true);a("#stroke_width").val(Z.getAttribute("stroke-width")||1);a("#stroke_style").val(Z.getAttribute("stroke-dasharray")||"none");R=Z.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+R).length!=0&&w(a("#linejoin_"+R)[0]);R=Z.getAttribute("stroke-linecap")||"butt";a("#linecap_"+R).length!=0&&w(a("#linecap_"+R)[0])}if(Z!=null){R=(Z.getAttribute("opacity")||1)*100;a("#group_opacity").val(R);
a("#opac_slider").slider("option","value",R);a("#elem_id").val(Z.id)}}a("#path_node_panel").toggle(I);a("#tools_bottom_2,#tools_bottom_3").toggle(!I);if(I){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");fa("#tool_select","select_node");Aa=false;if(A.length)Z=A[0]}else{if(A[0]){I=f.selectorManager.requestSelector(A[0]);I.reset(A[0]);I.selectorRect.setAttribute("display","inline")}fa("#tool_select",
"select")}Ja();f.runExtensions("selectedChanged",{elems:A,selectedElement:Z,multiselected:Aa})});f.bind("transition",function(q,A){var I=f.getMode(),R=A[0];if(R){Aa=A.length>=2&&A[1]!=null;if(!Aa)switch(I){case "rotate":I=f.getRotationAngle(R);a("#angle").val(Math.round(I));a("#tool_reorient").toggleClass("disabled",I==0)}f.runExtensions("elementTransition",{elems:A})}});f.bind("changed",function(q,A){var I=f.getMode();I==="select"&&oa();for(var R=0;R<A.length;++R){var X=A[R];if(X&&X.tagName==="svg"){Ab();
Rb()}else if(X&&Z&&Z.parentNode==null)Z=X}c.show_save_warning=true;Ja();if(Z&&I==="select"){la.fill.update();la.stroke.update()}f.runExtensions("elementChanged",{elems:A})});f.bind("saved",function(q,A){c.show_save_warning=false;A='<?xml version="1.0"?>\n'+A;var I=navigator.userAgent;if(~I.indexOf("Chrome")&&a.browser.version>=533||~I.indexOf("MSIE"))D(0,true);else{var R=q.open("data:image/svg+xml;base64,"+ca.encode64(A)),X=a.pref("save_notice_done");if(X!=="all"){var ja=e.notification.saveFromBrowser.replace("%s",
"SVG");if(I.indexOf("Gecko/")!==-1)if(A.indexOf("<defs")!==-1){ja+="\n\n"+e.notification.defsFailOnSave;a.pref("save_notice_done","all");X="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");X!=="part"&&R.alert(ja)}}});f.bind("exported",function(q,A){var I=A.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var R=a("#export_canvas")[0];R.width=f.contentW;R.height=f.contentH;canvg(R,A.svg,{renderCallback:function(){var X=R.toDataURL("image/png");
ba.location.href=X;if(a.pref("export_notice_done")!=="all"){X=e.notification.saveFromBrowser.replace("%s","PNG");if(I.length)X+="\n\n"+e.notification.noteTheseIssues+"\n \u2022 "+I.join("\n \u2022 ");a.pref("export_notice_done","all");ba.alert(X)}}})});f.bind("zoomed",Oa);f.bind("contextset",function(q,A){var I="";if(A){var R="";I='<a href="#" data-root="y">'+f.getCurrentDrawing().getCurrentLayerName()+"</a>";a(A).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){R+=" > "+this.id;
I+=this!==A?' > <a href="#">'+this.id+"</a>":" > "+this.id}});Sa=R}else Sa=null;a("#cur_context_panel").toggle(!!A).html(I);W()});f.bind("extension_added",function(q,A){function I(){if(nb){clearTimeout(nb);nb=null}X||(nb=setTimeout(function(){X=true;za(b.iconsize)},50))}var R=false,X=false,ja=true,va=function(){if(A.callback&&!R&&ja){R=true;A.callback()}},ya=[];A.context_tools&&a.each(A.context_tools,function(Ta,ia){var wb=ia.container_id?' id="'+ia.container_id+'"':"",bb=a("#"+ia.panel);bb.length||
(bb=a("<div>",{id:ia.panel}).appendTo("#tools_top"));switch(ia.type){case "tool_button":var Fa='<div class="tool_button">'+ia.id+"</div>",Va=a(Fa).appendTo(bb);ia.events&&a.each(ia.events,function(eb,lb){a(Va).bind(eb,lb)});break;case "select":Fa="<label"+wb+'><select id="'+ia.id+'">';a.each(ia.options,function(eb,lb){Fa+='<option value="'+eb+'"'+(eb==ia.defval?" selected":"")+">"+lb+"</option>"});Fa+="</select></label>";var Ha=a(Fa).appendTo(bb).find("select");a.each(ia.events,function(eb,lb){a(Ha).bind(eb,
lb)});break;case "button-select":Fa='<div id="'+ia.id+'" class="dropdown toolset" title="'+ia.title+'"><div id="cur_'+ia.id+'" class="icon_label"></div><button></button></div>';wb=a('<ul id="'+ia.id+'_opts"></ul>').appendTo("#option_lists");ia.colnum&&wb.addClass("optcols"+ia.colnum);a(Fa).appendTo(bb).children();ya.push({elem:"#"+ia.id,list:"#"+ia.id+"_opts",title:ia.title,callback:ia.events.change,cur:"#cur_"+ia.id});break;case "input":Fa="<label"+wb+'><span id="'+ia.id+'_label">'+ia.label+':</span><input id="'+
ia.id+'" title="'+ia.title+'" size="'+(ia.size||"4")+'" value="'+(ia.defval||"")+'" type="text"/></label>';var kb=a(Fa).appendTo(bb).find("input");ia.spindata&&kb.SpinButton(ia.spindata);ia.events&&a.each(ia.events,function(eb,lb){kb.bind(eb,lb)})}});if(A.buttons){var Da={},Ca={},Ba=A.svgicons,tb={};a.each(A.buttons,function(Ta,ia){for(var wb,bb=ia.id,Fa=Ta;a("#"+bb).length;)bb=ia.id+"_"+ ++Fa;if(Ba){Da[bb]=ia.icon;Fa=ia.svgicon?ia.svgicon:ia.id;if(ia.type=="app_menu")Ca["#"+bb+" > div"]=Fa;else Ca["#"+
bb]=Fa}else wb=ia.type=="menu"?"":a('<img src="'+ia.icon+'">');var Va,Ha;switch(ia.type){case "mode_flyout":case "mode":Va="tool_button";if(ia.cls)Va+=" "+ia.cls;Ha="#tools_left";break;case "context":Va="tool_button";Ha="#"+ia.panel;a(Ha).length||a("<div>",{id:ia.panel}).appendTo("#tools_top");break;case "menu":Va="menu_item tool_button";Ha="#"+(ia.after||ia.panel);break;case "app_menu":Va="";Ha=ia.parent||"#main_menu ul";a(Ha).length||a("<div>",{id:ia.panel}).appendTo("#tools_top")}var kb=a(ia.list||
ia.type=="app_menu"?"<li/>":"<div/>").attr("id",bb).attr("title",ia.title).addClass(Va);if(!ia.includeWith&&!ia.list){if("position"in ia)a(Ha).children().eq(ia.position).before(kb);else ia.type!="menu"||!ia.after?kb.appendTo(Ha):a(Ha).after(kb);if(ia.type=="mode_flyout"){Fa=a(kb);Va=Fa.parent();if(!Fa.parent().hasClass("tools_flyout")){var eb=Fa[0].id.replace("tool_","tools_"),lb=Fa.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Fa.before(lb);Va=Ga(eb,Fa);Va.data("isLibrary",
true);lb.data("isLibrary",true)}Ca["#"+eb+"_show"]=ia.id;bb=tb["#"+Va[0].id]=[{sel:"#"+bb,fn:ia.events.click,icon:ia.id,isDefault:true},Yb]}else if(ia.type=="app_menu"||ia.type=="menu")kb.append(ia.title)}else if(ia.list){kb.addClass("push_button");a("#"+ia.list+"_opts").append(kb);if(ia.isDefault){a("#cur_"+ia.list).append(kb.children().clone());Fa=ia.svgicon?ia.svgicon:ia.id;Ca["#cur_"+ia.list]=Fa}}else if(ia.includeWith){Ha=ia.includeWith;Fa=a(Ha.button);Va=Fa.parent();if(!Fa.parent().hasClass("tools_flyout")){eb=
Fa[0].id.replace("tool_","tools_");lb=Fa.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Fa.before(lb);Va=Ga(eb,Fa)}var Yb=oc.getButtonData(Ha.button);if(Ha.isDefault)Ca["#"+eb+"_show"]=ia.id;bb=tb["#"+Va[0].id]=[{sel:"#"+bb,fn:ia.events.click,icon:ia.id,key:ia.key,isDefault:ia.includeWith?ia.includeWith.isDefault:0},Yb];eb="position"in Ha?Ha.position:"last";Yb=Va.children().length;if(!isNaN(eb)&&eb>=0&&eb<Yb)Va.children().eq(eb).before(kb);else{Va.append(kb);bb.reverse()}}Ba||
kb.append(wb);ia.list||a.each(ia.events,function(Jb,Xb){if(Jb=="click")if(ia.type=="mode"){ia.includeWith?kb.bind(Jb,Xb):kb.bind(Jb,function(){xa(kb)&&Xb()});if(ia.key){a(document).bind("keydown",ia.key,Xb);ia.title&&kb.attr("title",ia.title+" ["+ia.key+"]")}}else kb.bind(Jb,Xb);else kb.bind(Jb,Xb)});Qa(tb)});a.each(ya,function(){sb(this.elem,this.list,this.callback,{seticon:true})});if(Ba)ja=false;a.svgIcons(Ba,{w:27,h:27,id_match:false,no_img:!O,fallback:Da,placement:Ca,callback:function(){b.iconsize&&
b.iconsize!="m"&&I();ja=true;va()}})}va()});f.textActions.setInputElem(a("#text")[0]);var Za='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4",
"#aaffff","#aad4ff"],function(q,A){Za+='<div class="palette_item" style="background-color: '+A+';" data-rgb="'+A+'"></div>'});a("#palette").append(Za);Za="";a.each(["#FFF","#888","#000"],function(){Za+='<div class="color_block" style="background-color:'+this+';"></div>'});a("#bg_blocks").append(Za);var Ma=a("#bg_blocks div");Ma.each(function(){a(this).click(function(){Ma.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))p(a.pref("bkgd_color"),a.pref("bkgd_url"));
else a.pref("bkgd_url")&&p(o.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){b.img_save=a.pref("img_save");a("#image_save_opts input").val([b.img_save])}var ob=function(q){var A=q.value/100;if(A<0.0010)q.value=0.1;else{q=f.getZoom();Oa(window,{width:0,height:0,x:(ra[0].scrollLeft+ra.width()/2)/q,y:(ra[0].scrollTop+ra.height()/2)/q,zoom:A},true)}},xb=function(q,A){if(A==null)A=q.value;a("#group_opacity").val(A);if(!q||!q.handle)a("#opac_slider").slider("option","value",A);f.setOpacity(A/100)},
fb=function(q,A,I){if(A==null)A=q.value;a("#blur").val(A);var R=false;if(!q||!q.handle){a("#blur_slider").slider("option","value",A);R=true}I?f.setBlurNoUndo(A):f.setBlur(A,R)},ib=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){f.setStrokeAttr("stroke-dasharray",a(this).val());ib()});a("#stroke_linejoin").change(function(){f.setStrokeAttr("stroke-linejoin",a(this).val());ib()});a("select").change(function(){a(this).blur()});var Lb=false;a("#selLayerNames").change(function(){var q=
this.options[this.selectedIndex].value,A=e.notification.QmoveElemsToLayer.replace("%s",q),I=function(R){if(R){Lb=true;f.moveSelectedToLayer(q);f.clearSelection();Ab()}};if(q)Lb?I(true):a.confirm(A,I)});a("#font_family").change(function(){f.setFontFamily(this.value)});a("#seg_type").change(function(){f.setSegType(a(this).val())});a("#text").keyup(function(){f.setTextContent(this.value)});a("#image_url").change(function(){Ea(this.value)});a("#link_url").change(function(){this.value.length?f.setLinkURL(this.value):
f.removeHyperlink()});a("#g_title").change(function(){f.setGroupTitle(this.value)});a(".attr_changer").change(function(){var q=this.getAttribute("data-attr"),A=this.value;if(svgedit.units.isValidUnit(q,A,Z))this.blur();else{a.alert(e.notification.invalidAttrValGiven);this.value=Z.getAttribute(q);return false}if(q!=="id")if(isNaN(A))A=f.convertToNum(q,A);else if(d.baseUnit!=="px"){var I=svgedit.units.getTypeMap();if(Z[q]||f.getMode()==="pathedit"||q==="x"||q==="y")A*=I[d.baseUnit]}if(q==="id"){q=Z;
f.clearSelection();q.id=A;f.addToSelection([q],true)}else f.changeSelectedAttribute(q,A);this.blur()});a("#palette").mouseover(function(){var q=a('<input type="hidden">');a(this).append(q);q.focus().remove()});a(".palette_item").mousedown(function(){var q=a("#tool_stroke").hasClass("active"),A=q?"stroke":"fill",I=a(this).attr("data-rgb"),R=null;if(I==="transparent"||I==="initial"||I==="#none"){I="none";R=new a.jGraduate.Paint}else R=new a.jGraduate.Paint({alpha:100,solidColor:I.substr(1)});la[A].setPaint(R);
if(q){f.setColor("stroke",I);I!="none"&&f.getStrokeOpacity()!=1&&f.setPaintOpacity("stroke",1)}else{f.setColor("fill",I);I!="none"&&f.getFillOpacity()!=1&&f.setPaintOpacity("fill",1)}}).bind("contextmenu",function(q){q.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");Ub()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Ub()});var xa=function(q,A){if(a(q).hasClass("disabled"))return false;
if(a(q).parent().hasClass("tools_flyout"))return true;var I=I||"normal";A||a(".tools_flyout").fadeOut(I);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(q).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var q=null,A=null,I=ra[0],R=false,X=false;a("#svgcanvas").bind("mousemove mouseup",function(ja){if(R!==false){I.scrollLeft-=ja.clientX-q;I.scrollTop-=ja.clientY-A;q=ja.clientX;A=ja.clientY;if(ja.type===
"mouseup")R=false;return false}}).mousedown(function(ja){if(ja.button===1||X===true){R=true;q=ja.clientX;A=ja.clientY;return false}});a(window).mouseup(function(){R=false});a(document).bind("keydown","space",function(ja){f.spaceKey=X=true;ja.preventDefault()}).bind("keyup","space",function(ja){ja.preventDefault();f.spaceKey=X=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&ra.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&ra.removeClass("out")})})();var ub=a(".menu"),
rb=function(q){q.target.style.background="#fff";setTimeout(function(){q.target.style.background="#ddd"},50);setTimeout(function(){q.target.style.background="#fff"},150);setTimeout(function(){q.target.style.background="#ddd"},200);setTimeout(function(){q.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").live("click",function(q){rb(q)});a("svg, body").on("mousedown",function(q){top!=self&&!q.isTrigger&&typeof top.exports.setEditorFocus==
"function"&&top.exports.setEditorFocus();if(!a(q.target).hasClass("menu_title"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))rb(q);else{a("#menu_bar").removeClass("active");a("#tools_shapelib").is(":visible")&&!a(q.target).parents("#tools_shapelib_show, #tools_shapelib").length&&a("#tools_shapelib").hide();q.target.nodeName.toLowerCase()!="input"&&a("input").blur()}});var yb=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(q,A,
I,R){if(q.altKey){q.preventDefault();q=f.getZoom()*100;A=yb.length;for(Bb=0;Bb<A;Bb++){I=Math.min(A,Bb+1);if(R>0)zoom=yb[Bb]<=q?yb[I]:zoom;if(R<0)zoom=yb[Bb]<q?yb[Bb]:zoom}zoom&&ob({value:zoom})}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",function(){ub.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,A,I){if(a(q).length!=0){var R=a(q).find("button"),X=a(q).find("ul").attr("id",a(q)[0].id+"-list");
I||a("#option_lists").append(X);var ja=false;I&&a(q).addClass("dropup");X.find("li").bind("mouseup",A);a(window).mouseup(function(){if(!ja){R.removeClass("down");X.hide()}ja=false});R.bind("mousedown",function(){if(R.hasClass("down")){R.removeClass("down");X.hide()}else{R.addClass("down");if(!I){var va=a(q).offset();X.css({top:va.top,left:va.left-110})}X.show();ja=true}}).hover(function(){ja=true}).mouseout(function(){ja=false})}};var sb=function(q,A,I,R){var X=a(q);A=a(A);var ja=false,va=R.dropUp;
va&&a(q).addClass("dropup");A.find("li").bind("mouseup",function(){if(R.seticon){fa("#cur_"+X[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}I.apply(this,arguments)});a(window).mouseup(function(){if(!ja){X.removeClass("down");A.hide();A.css({top:0,left:0})}ja=false});A.height();a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=A.height();ya.left+=8}else ya.top+=a(q).height();a(A).offset(ya);if(X.hasClass("down")){X.removeClass("down");A.hide();
A.css({top:0,left:0})}else{X.addClass("down");A.show();ja=true;return false}}).hover(function(){ja=true}).mouseout(function(){ja=false});R.multiclick&&A.mousedown(function(){ja=true})};c.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});c.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var q=parseInt(a(this).text().split("%")[0]);xb(false,q)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},
stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(q,A){xb(A)}});c.addDropDown("#blur_dropdown",a.noop);var mb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(q,A){mb=false;fb(A);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){mb=true},slide:function(q,A){fb(A,null,mb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),A=q.attr("data-val");A?Oa(window,A):ob({value:parseInt(q.text())})},true);sb("#stroke_linecap","#linecap_opts",
function(){w(this,true)},{dropUp:true});sb("#stroke_linejoin","#linejoin_opts",function(){w(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,"page")})});(function(){var q,A=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=this;U="toolbars";ra.mousedown(A)}).blur(function(){U="canvas";ra.unbind("mousedown",A);f.getMode()==
"textedit"&&a("#text").focus()})})();var Gb=function(){if(xa("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},Hb=function(){xa("#tool_fhpath")&&f.setMode("fhpath")},Mb=function(){xa("#tool_line")&&f.setMode("line")},Nb=function(){xa("#tool_rect")&&f.setMode("rect")},ma=function(){xa("#tool_ellipse")&&f.setMode("ellipse")},Y=function(){xa("#tool_image")&&f.setMode("image")},na=function(){xa("#tool_zoom")&&
f.setMode("zoom")},K=function(){if(xa("#tool_zoom")){E();oa()}},N=function(){xa("#tool_text")&&f.setMode("text")},aa=function(){xa("#tool_path")&&f.setMode("path")},Pa=function(){if(Z!=null||Aa)f.deleteSelectedElements()},Xa=function(){if(Z!=null||Aa){window.event.type==="keydown"&&db(a("#edit_menu"));f.cutSelectedElements()}},hb=function(){if(Z!=null||Aa){window.event.type==="keydown"&&db(a("#edit_menu"));f.copySelectedElements()}},pb=function(){window.event.type==="keydown"&&db(a("#edit_menu"));
var q=f.getZoom(),A=(ra[0].scrollLeft+ra.width()/2)/q-f.contentW;q=(ra[0].scrollTop+ra.height()/2)/q-f.contentH;f.pasteElements("point",A,q)},Db=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveToTopSelectedElement()}},cb=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveToBottomSelectedElement()}},Eb=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected("Up")}},$a=function(){if(Z!=null){window.event.type===
"keydown"&&db(a("#object_menu"));f.moveUpDownSelected("Down")}},Fb=function(q){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected(q)}},Pb=function(){if(Z!=null){f.convertToPath();elems=f.getSelectedElems();f.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");f.setMode("pathedit");ta.toEditMode(elems[0]);f.clearSelection()}},$b=function(){Z!=null&&ta.reorient()},Zb=function(){if(Z!=null||Aa)a.prompt(e.notification.enterNewLinkURL,
"http://",function(q){q&&f.makeHyperlink(q)})},gb=function(q,A){if(Z!=null||Aa){if(d.gridSnapping){var I=f.getZoom()*d.snappingStep;q*=I;A*=I}a("input").blur();f.moveSelectedElements(q,A)}},Ua=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");q?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",false);ta.linkControlPoints(q)},
ic=function(){ta.getNodePoint()&&ta.clonePathNode()},ec=function(){ta.getNodePoint()&&ta.deletePathNode()},cc=function(){var q=a("#tool_add_subpath"),A=!q.hasClass("push_button_pressed");A?q.addClass("push_button_pressed").removeClass("tool_button"):q.removeClass("push_button_pressed").addClass("tool_button");ta.addSubPath(A)},fc=function(){ta.opencloseSubPath()},gc=function(){f.cycleElement(1)},Tb=function(){f.cycleElement(0)},Sb=function(q,A){if(!(Z==null||Aa)){q||(A*=-1);var I=a("#angle").val()*
1+A;f.setRotationAngle(I);Ja()}},mc=function(){var q=d.dimensions;a.confirm(e.notification.QwantToClear,function(A){if(A){oa();f.clear();f.setResolution(q[0],q[1]);Rb(true);E();Ab();Ja();la.fill.prep();la.stroke.prep();f.runExtensions("onNewDocument")}})},Vb=function(){f.setBold(!f.getBold());Ja();return false},vb=function(){f.setItalic(!f.getItalic());Ja();return false},kc=function(){if(!l.pngsave){var q=e.notification.loadingImage;ba=window.open("data:text/html;charset=utf-8,<title>"+q+"</title><h1>"+
q+"</h1>")}window.canvg?f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},jc=function(){f.open()},Wb=function(){},db=function(q){var A=q.prev();A.css("background","#09f");setTimeout(function(){A.css("background","")},200)},dc=function(){if(ha.getUndoStackSize()>0){window.event.type==="keydown"&&db(a("#edit_menu"));ha.undo();Ab()}},g=function(){if(ha.getRedoStackSize()>0){window.event.type==="keydown"&&db(a("#edit_menu"));ha.redo();
Ab()}},h=function(){if(Aa)f.groupSelectedElements();else Z&&f.ungroupSelectedElement()},k=function(){window.event.type==="keydown"&&db(a("#edit_menu"));f.cloneSelectedElements(20,20)},v=function(){var q=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(q,a("#align_relative_to").val())},s=function(){var q=document.querySelector("#tool_stroke rect"),A=document.querySelector("#tool_fill rect"),I=A.getAttribute("fill"),R=q.getAttribute("fill");q=parseFloat(q.getAttribute("stroke-opacity"));
if(isNaN(q))q=100;A=parseFloat(A.getAttribute("fill-opacity"));if(isNaN(A))A=100;R=ab(R,q,"stroke");I=ab(I,A,"fill");la.fill.setPaint(R,true);la.stroke.setPaint(I,true)},E=function(q){var A=f.getResolution();q=q?A.zoom*q:1;a("#zoom").val(q*100);f.setZoom(q);B();Rb(true)},z=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");ra.toggleClass("wireframe");if(!tc){var q=a("#wireframe_rules");
q.length?q.empty():a('<style id="wireframe_rules"></style>').appendTo("head");B()}},t=function(){f.clearSelection();a("#tool_canvas").trigger("click")},C=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},F=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);d.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);d.showRulers=
true}a("#rulers").toggle(!!d.showRulers)},B=function(){if(!tc){var q="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+"px; }";a("#wireframe_rules").text(ra.hasClass("wireframe")?q:"")}},D=function(q,A){if(!Ka){Ka=true;a("#save_output_btns").toggle(!!A);a("#tool_source_back").toggle(!A);var I=sa=f.getSvgString();a("#svg_source_textarea").val(I);a("#svg_source_editor").fadeIn();P();a("#svg_source_textarea").focus()}},H=function(){if(!Ra){Ra=true;a("#image_save_opts input").val([b.img_save]);
var q=f.getResolution();if(d.baseUnit!=="px"){q.w=svgedit.units.convertUnit(q.w)+d.baseUnit;q.h=svgedit.units.convertUnit(q.h)+d.baseUnit}a(".canvas_width").val(q.w);a(".canvas_height").val(q.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},G=function(){if(!Na){Na=true;var q=a("#bg_blocks div"),A=a.pref("bkgd_color"),I=a.pref("bkgd_url");q.each(function(){var R=a(this),X=R.css("background-color")==A;R.toggleClass("cur_background",X);X&&a("#canvas_bg_url").removeClass("cur_background")});
A||q.eq(0).addClass("cur_background");I&&a("#canvas_bg_url").val(I);a("grid_snapping_step").attr("value",d.snappingStep);d.gridSnapping==true?a("#grid_snapping_on").attr("checked","checked"):a("#grid_snapping_on").removeAttr("checked");a("#svg_prefs").show()}},P=function(){var q=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",q)},Q=function(){if(Ka){var q=function(){f.clearSelection();zb();E();Ab();W();la.fill.prep();la.stroke.prep()};f.setSvgString(a("#svg_source_textarea").val())?
q():a.confirm(e.notification.QerrorsRevertToSource,function(A){if(!A)return false;q()});oa()}},W=function(q){q=q||f.getDocumentTitle();q=Wa+(q?": "+q:"");a("title:first").text(q)},ua=function(){var q=a("#canvas_width"),A=q.val(),I=a("#canvas_height"),R=I.val();if(A!="fit"&&!svgedit.units.isValidUnit("width",A)){a.alert(e.notification.invalidAttrValGiven);q.parent().addClass("error");return false}q.parent().removeClass("error");if(R!="fit"&&!svgedit.units.isValidUnit("height",R)){a.alert(e.notification.invalidAttrValGiven);
I.parent().addClass("error");return false}I.parent().removeClass("error");if(!f.setResolution(A,R)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Rb();Qb()},wa=function(){var q=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";p(q,a("#canvas_bg_url").val());q=a("#lang_select").val();q!=b.lang&&c.putLocale(q);za(a("#iconsize").val());d.gridSnapping=a("#grid_snapping_on")[0].checked;d.snappingStep=
a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);d.showRulers&&da();d.baseUnit=a("#base_unit").val();f.setConfig(d);Rb();Ib()},fa=c.setIcon=function(q,A){var I=typeof A==="string"?a.getSvgIcon(A,true):A.clone();I?a(q).find("img").replaceWith(I):console.log("NOTE: Icon image missing: "+A)},ka;ka=function(){var q=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,A=document.getElementsByTagName("script")[0],I;for(I in A.style)if(q.test(I))return I.match(q)[0];
if("WebkitOpacity"in A.style)return"Webkit";if("KhtmlOpacity"in A.style)return"Khtml";return""}();var qa=function(q,A){ka.toLowerCase();var I=["top","left","bottom","right"];q.each(function(){for(var R=a(this),X=R.outerWidth()*(A-1),ja=R.outerHeight()*(A-1),va=0;va<4;va++){var ya=I[va],Da=R.data("orig_margin-"+ya);if(Da==null){Da=parseInt(R.css("margin-"+ya));R.data("orig_margin-"+ya,Da)}Da=Da*A;if(ya==="right")Da+=X;else if(ya==="bottom")Da+=ja;R.css("margin-"+ya,Da)}})},za=c.setIconSize=function(q,
A){if(!(q==b.size&&!A)){var I=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),R=1;R=typeof q=="number"?q:{s:0.75,m:1,l:1.25,xl:1.5}[q];c.tool_scale=S=R;Cb();var X=I.parents(":hidden");X.css("visibility","hidden").show();qa(I,R);X.css("visibility","visible").hide();a.pref("iconsize",q);a("#iconsize").val(q);X={"#tools_top":{left:50,height:72},
"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};I=a("#tool_size_rules");if(I.length)I.empty();else I=a('<style id="tool_size_rules"></style>').appendTo("head");if(q!="m"){var ja="";a.each(X,function(va,ya){va="#svg_editor "+va.replace(/,/g,", #svg_editor");ja+=va+"{";a.each(ya,function(Da,Ca){if(typeof Ca==="number")var Ba=Ca*R+"px";else if(Ca[q]||Ca.all)Ba=Ca[q]||Ca.all;ja+=Da+":"+Ba+";"});ja+="}"});X="-"+ka.toLowerCase()+"-";ja+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+
X+"transform: scale("+R+");} #svg_editor div.toolset .toolset {"+X+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+X+"transform: scale("+1/R+");}";I.text(ja)}Cb()}},jb=function(){a("#dialog_box").hide();if(!Ka&&!Ra&&!Na)Sa&&f.leaveContext();else{if(Ka)sa!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(q){q&&zb()}):zb();else if(Ra)Qb();else Na&&Ib();Ub()}},zb=function(){a("#svg_source_editor").hide();Ka=false;a("#svg_source_textarea").blur()},
Qb=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=0;a("#image_save_opts input").val([b.img_save]);Ra=false},Ib=function(){a("#svg_prefs").hide();Na=false},Ob={width:a(window).width(),height:a(window).height()},Ub=a.noop,ac;svgedit.browser.isIE()&&function(){Ub=function(){if(ra[0].scrollLeft===0&&ra[0].scrollTop===0){ra[0].scrollLeft=ac.left;ra[0].scrollTop=ac.top}};ac={left:ra[0].scrollLeft,top:ra[0].scrollTop};a(window).resize(Ub);
svgEditor.ready(function(){setTimeout(function(){Ub()},500)});ra.scroll(function(){ac={left:ra[0].scrollLeft,top:ra[0].scrollTop}})}();a(window).resize(function(){Ka&&P();a.each(Ob,function(q,A){var I=a(window)[q]();ra[0]["scroll"+(q==="width"?"Left":"Top")]-=(I-A)/2;Ob[q]=I})});(function(){ra.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=ra[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=ra[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});
a("#change_image_url").click(L);(function(){var q=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],A="";a.each(q,function(I,R){A+="#tool_"+R+(I==q.length-1?",":"")});a(A).mousedown(function(){a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")});a("#tool_undo, #tool_redo").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("tool_button_current")}).bind("mousedown mouseout",
function(){a(this).removeClass("tool_button_current")})})();if(V&&!window.opera){V=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(var Bb=V.length;Bb--;){var pc=document.getElementById(V[Bb]);if(pc!=null){var qc=pc.title,uc=qc.indexOf("Ctrl+");pc.title=[qc.substr(0,uc),"Cmd+",qc.substr(uc+5)].join("")}}}var rc=function(q){var A=q[0].id=="stroke_color"?"stroke":"fill",I=q[0].id=="canvas_color";if(I)A="canvas";var R=la[A].paint;q=A=="stroke"?"Pick a Stroke Paint and Opacity":
"Pick a Fill Paint and Opacity";I=I?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(I).jGraduate({paint:R,window:{pickerTitle:q},images:{clientPath:d.jGraduatePath},newstop:"inverse"},function(X){R=new a.jGraduate.Paint(X);la[A].setPaint(R);f.setPaint(A,R);a("#color_picker").hide()},function(){a("#color_picker").hide()})};V=function(q,A){var I=document.getElementById("canvas_background"),
R={color:"#fff",opacity:1};if(A=="stroke")R=d.initStroke;if(A=="fill")R=d.initFill;if(A=="canvas"&&I)if(I=I.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))R={color:("0"+parseInt(I[1],10).toString(16)).slice(-2)+("0"+parseInt(I[2],10).toString(16)).slice(-2)+("0"+parseInt(I[3],10).toString(16)).slice(-2),opacity:1};I=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+R.color+'" opacity="'+R.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',
"text/xml").documentElement;I=a(q)[0].appendChild(document.importNode(I,true));I.setAttribute("width",24.5);this.rect=I.firstChild;this.defs=I.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:R.color});this.type=A;this.setPaint=function(X,ja){this.paint=X;var va="none",ya=X.type,Da=X.alpha/100;switch(ya){case "solidColor":va=X[ya]=="none"||X[ya]=="one"?"none":"#"+X[ya];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);
this.grad=this.defs.appendChild(X[ya]);va="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",va);this.rect.setAttribute("opacity",Da);if(ja){f.setColor(this.type,va,true);f.setPaintOpacity(this.type,Da,true)}if(this.type=="canvas"){(ya=document.getElementById("canvas_background"))?ya.setAttribute("fill",va):La(va);console.log(ya.getAttribute("fill"))}};this.update=function(X){if(Z){var ja=this.type;switch(Z.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var va=
null,ya=Z.getElementsByTagName("*"),Da=0,Ca=ya.length;Da<Ca;Da++){var Ba=ya[Da].getAttribute(ja);if(Da===0)va=Ba;else if(va!==Ba){va=null;break}}if(va===null){ya=null;return}ya=va;va=1;break;default:va=parseFloat(Z.getAttribute(ja+"-opacity"));if(isNaN(va))va=1;ya=ja==="fill"?"black":"none";ya=Z.getAttribute(ja)||ya}if(X){f.setColor(ja,ya,true);f.setPaintOpacity(ja,va,true)}va*=100;this.setPaint(ab(ya,va,ja))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var X=
new a.jGraduate.Paint({copy:this.paint});f.setPaint(A,X)}}};la.fill=new V("#fill_color","fill");la.stroke=new V("#stroke_color","stroke");la.canvas=new V("#canvas_color","canvas");a("#stroke_width").val(d.initStroke.width);a("#group_opacity").val(d.initOpacity*100);V=la.fill.rect.cloneNode(false);V.setAttribute("style","vector-effect:non-scaling-stroke");var tc=V.style.vectorEffect==="non-scaling-stroke";V.removeAttribute("style");V=la.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof V.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(V).remove();setTimeout(function(){f.embedImage("images/placeholder.svg",function(q){if(!q){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);b.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",e.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))rc(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_canvas").click(function(){rc(a("#canvas_color"))});a("#tool_stroke").click(function(){if(a("#tool_stroke").hasClass("active"))rc(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#group_opacityLabel").click(function(){a("#opacity_dropdown button").mousedown();a(window).mouseup()});a("#zoomLabel").click(function(){a("#zoom_dropdown button").mousedown();a(window).mouseup()});a("#tool_move_top").mousedown(function(q){a("#tools_stacking").show();
q.preventDefault()});a(".layer_button").mousedown(function(){a(this).addClass("layer_buttonpressed")}).mouseout(function(){a(this).removeClass("layer_buttonpressed")}).mouseup(function(){a(this).removeClass("layer_buttonpressed")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a("#layer_new").click(function(){var q=f.getCurrentDrawing().getNumLayers();do var A=e.layers.layer+" "+ ++q;while(f.getCurrentDrawing().hasLayer(A));a.prompt(e.notification.enterUniqueLayerName,A,function(I){if(I)if(f.getCurrentDrawing().hasLayer(I))a.alert(e.notification.dupeLayerName);else{f.createLayer(I);Ja();Ab()}})});a("#layer_delete").click(T);a("#layer_up").click(function(){J(-1)});a("#layer_down").click(function(){J(1)});a("#layer_rename").click(function(){a("#layerlist tr.layersel").prevAll();
var q=a("#layerlist tr.layersel td.layername").text();a.prompt(e.notification.enterNewLayerName,"",function(A){if(A)if(q==A||f.getCurrentDrawing().hasLayer(A))a.alert(e.notification.layerHasThatName);else{f.renameCurrentLayer(A);Ab()}})});var bc=-1,lc=false,sc=false,vc=function(q){if(sc)if(bc!=-1){lc=true;q=bc-q.pageX;var A=a("#sidepanels"),I=parseInt(A.css("width"));if(I+q>300)q=300-I;else if(I+q<2)q=2-I;if(q!=0){bc-=q;I=a("#layerpanel");ra.css("right",parseInt(ra.css("right"))+q);A.css("width",
parseInt(A.css("width"))+q);I.css("width",parseInt(I.css("width"))+q);A=a("#ruler_x");A.css("right",parseInt(A.css("right"))+q)}}};a("#sidepanel_handle").mousedown(function(q){bc=q.pageX;a(window).mousemove(vc);sc=false;setTimeout(function(){sc=true},20)}).mouseup(function(){lc||wc();bc=-1;lc=false});a(window).mouseup(function(){bc=-1;lc=false;a("#svg_editor").unbind("mousemove",vc)});var wc=function(q){var A=parseInt(a("#sidepanels").css("width"));q=(A>2||q?2:150)-A;A=a("#sidepanels");var I=a("#layerpanel"),
R=a("#ruler_x");ra.css("right",parseInt(ra.css("right"))+q);A.css("width",parseInt(A.css("width"))+q);I.css("width",parseInt(I.css("width"))+q);R.css("right",parseInt(R.css("right"))+q)},xc=function(q){for(var A=Array(f.getCurrentDrawing().getNumLayers()),I=0;I<A.length;++I)A[I]=f.getCurrentDrawing().getLayerName(I);if(q)for(I=0;I<A.length;++I)A[I]!=q&&f.getCurrentDrawing().setLayerOpacity(A[I],0.5);else for(I=0;I<A.length;++I)f.getCurrentDrawing().setLayerOpacity(A[I],1)},Ab=function(){var q=a("#layerlist tbody"),
A=a("#selLayerNames");q.empty();A.empty();for(var I=f.getCurrentDrawing().getCurrentLayerName(),R=f.getCurrentDrawing().getNumLayers(),X=a.getSvgIcon("eye");R--;){var ja=f.getCurrentDrawing().getLayerName(R),va='<tr class="layer';if(ja==I)va+=" layersel";va+='">';va+=f.getCurrentDrawing().getLayerVisibility(ja)?'<td class="layervis"/><td class="layername" >'+ja+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+ja+"</td></tr>";q.append(va);A.append('<option value="'+ja+'">'+ja+
"</option>")}if(X!==undefined){X.clone();a("td.layervis",q).append(X.clone());a.resizeSvgIcons({"td.layervis .svg_icon":14})}a("#layerlist td.layername").mouseup(function(ya){a("#layerlist tr.layer").removeClass("layersel");a(this.parentNode).addClass("layersel");f.setCurrentLayer(this.textContent);ya.preventDefault()}).mouseover(function(){a(this).css({"font-style":"italic",color:"blue"});xc(this.textContent)}).mouseout(function(){a(this).css({"font-style":"normal",color:"black"});xc()});a("#layerlist td.layervis").click(function(){var ya=
a(this.parentNode).prevAll().length;ya=a("#layerlist tr.layer:eq("+ya+") td.layername").text();var Da=a(this).hasClass("layerinvis");f.setLayerVisibility(ya,Da);Da?a(this).removeClass("layerinvis"):a(this).addClass("layerinvis")});for(A=5-a("#layerlist tr.layer").size();A-- >0;)q.append('<tr><td style="color:white">_</td><td/></tr>')};Ab();a(window).bind("load resize",function(){ra.css("line-height",ra.height()+"px")});a("#resolution").change(function(){var q=a("#canvas_width,#canvas_height");if(this.selectedIndex)if(this.value==
"content")q.val("fit").attr("disabled","disabled");else{var A=this.value.split("x");a("#canvas_width").val(A[0]);a("#canvas_height").val(A[1]);q.removeAttr("disabled")}else a("#canvas_width").val()=="fit"&&q.removeAttr("disabled").val(100)});a("input,select").attr("autocomplete","off");var oc=function(){var q=[{sel:"#tool_select",fn:Gb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Hb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Mb,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Nb,evt:"click",
key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:ma,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:aa,evt:"click",key:["P",true]},{sel:"#tool_text",fn:N,evt:"click",key:["T",true]},{sel:"#tool_image",fn:Y,evt:"mouseup"},{sel:"#tool_zoom",fn:na,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:mc,evt:"mouseup",key:[ga+"N",true]},{sel:"#tool_save",fn:function(){Ka?Q():f.save({images:b.img_save,round_digits:6})},evt:"mouseup",key:[ga+"S",true]},{sel:"#tool_export",fn:kc,evt:"mouseup"},
{sel:"#tool_open",fn:jc,evt:"mouseup"},{sel:"#tool_import",fn:Wb,evt:"mouseup"},{sel:"#tool_source",fn:D,evt:"click",key:[ga+"U",true]},{sel:"#tool_wireframe",fn:z,evt:"click"},{sel:"#tool_rulers",fn:F,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:jb,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Q,evt:"click"},{sel:"#tool_docprops_save",fn:ua,evt:"click"},{sel:"#tool_docprops",fn:H,evt:"mouseup"},{sel:"#tool_prefs_save",
fn:wa,evt:"click"},{sel:"#tool_prefs_option",fn:function(){G();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:Pa,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:$b,evt:"click"},{sel:"#tool_node_link",fn:Ua,evt:"click"},{sel:"#tool_node_clone",fn:ic,evt:"click"},{sel:"#tool_node_delete",fn:ec,evt:"click"},{sel:"#tool_openclose_path",fn:fc,evt:"click"},{sel:"#tool_add_subpath",fn:cc,evt:"click"},{sel:"#tool_move_top",fn:Db,evt:"click",key:ga+"shift+up"},{sel:"#tool_move_bottom",
fn:cb,evt:"click",key:ga+"shift+down"},{sel:"#tool_move_up",fn:Eb,evt:"click",key:[ga+"up",true]},{sel:"#tool_move_down",fn:$a,evt:"click",key:[ga+"down",true]},{sel:"#tool_topath",fn:Pb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:Zb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:k,evt:"click",key:[ga+"D",true]},{sel:"#tool_group",fn:h,evt:"click",key:[ga+"G",true]},{sel:"#tool_ungroup",fn:h,evt:"click",key:ga+"shift+G"},{sel:"#tool_unlink_use",fn:h,evt:"click"},{sel:"[id^=tool_align]",
fn:v,evt:"click"},{sel:"#tool_switch",fn:s,evt:"click",key:["shift+x",true]},{sel:"#tool_undo",fn:dc,evt:"click",key:ga+"z"},{sel:"#tool_redo",fn:g,evt:"click",key:["y",true]},{sel:"#tool_canvas_color_menu",fn:t,evt:"click"},{sel:"#tool_cut",fn:Xa,evt:"click",key:ga+"x"},{sel:"#tool_copy",fn:hb,evt:"click",key:ga+"c"},{sel:"#tool_paste",fn:pb,evt:"click",key:ga+"v"},{sel:"#tool_bold",fn:Vb,evt:"mousedown",key:[ga+"B",true]},{sel:"#tool_italic",fn:vb,evt:"mousedown",key:[ga+"I",true]},{sel:"#copy_save_done",
fn:jb,evt:"click"},{key:"ctrl+left",fn:function(){Sb(0,1)}},{key:"ctrl+right",fn:function(){Sb(1,1)}},{key:"ctrl+shift+left",fn:function(){Sb(0,5)}},{key:"ctrl+shift+right",fn:function(){Sb(1,5)}},{key:"shift+O",fn:Tb},{key:"shift+P",fn:gc},{key:[ga+"+",true],fn:function(){E(2)}},{key:[ga+"-",true],fn:function(){E(0.5)}},{key:["up",true],fn:function(){gb(0,-1)}},{key:["down",true],fn:function(){gb(0,1)}},{key:["left",true],fn:function(){gb(-1,0)}},{key:["right",true],fn:function(){gb(1,0)}},{key:"shift+up",
fn:function(){gb(0,-10)}},{key:"shift+down",fn:function(){gb(0,10)}},{key:"shift+left",fn:function(){gb(-10,0)}},{key:"shift+right",fn:function(){gb(10,0)}},{key:["alt+up",true],fn:function(){f.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){f.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){f.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){f.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){f.cloneSelectedElements(0,-10)}},
{key:["alt+shift+down",true],fn:function(){f.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){f.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){f.cloneSelectedElements(10,0)}},{key:ga+"A",fn:function(){f.selectAllInCurrentLayer()}},{key:ga+"shift+z",fn:g},{key:"esc",fn:C}],A={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var I={};a.each(q,function(R,X){if(X.sel){var ja=a(X.sel);if(ja.length==0)return true;
if(X.evt){if(svgedit.browser.isTouch()&&X.evt==="click")X.evt="mousedown";ja[X.evt](X.fn)}if(X.parent&&a(X.parent+"_show").length!=0){var va=a(X.parent);va.length||(va=Ga(X.parent.substr(1)));va.append(ja);a.isArray(I[X.parent])||(I[X.parent]=[]);I[X.parent].push(X)}}if(X.key){var ya=X.fn,Da=false;if(a.isArray(X.key)){va=X.key[0];if(X.key.length>1)Da=X.key[1]}else va=X.key;va+="";svgedit.browser.isMac&&va.indexOf("+")!=-1&&va.split("+")[0]=="ctrl"&&va.replace("ctrl","cmd");a.each(va.split("/"),function(Ba,
tb){a(document).bind("keydown",tb,function(Ta){ya();Da&&Ta.preventDefault();return false})});if(X.sel&&!X.hidekey&&ja.attr("title")){var Ca=ja.attr("title").split("[")[0]+" ("+va+")";A[va]=X.sel;ja.parents("#main_menu").length||ja.attr("title",Ca)}}});Qa(I);a(".attr_changer, #image_url").bind("keydown","return",function(R){a(this).change();R.preventDefault()});a(window).bind("keydown","tab",function(R){if(U==="canvas"){R.preventDefault();gc()}}).bind("keydown","shift+tab",function(R){if(U==="canvas"){R.preventDefault();
Tb()}});a("#tool_zoom").dblclick(K)},setTitles:function(){a.each(A,function(I,R){var X=a(R).parents("#main_menu").length;a(R).each(function(){var ja=X?a(this).text().split(" [")[0]:this.title.split(" [")[0],va="";a.each(I.split("/"),function(ya,Da){var Ca=Da.split("+"),Ba="";if(Ca.length>1){Ba=Ca[0]+"+";Da=Ca[1]}va+=(ya?"/":"")+Ba+(e["key_"+Da]||Da)});if(X)this.lastChild.textContent=ja+" ["+va+"]";else this.title=ja+" ["+va+"]"})})},getButtonData:function(I){var R;a.each(q,function(X,ja){if(ja.sel===
I)R=ja});return R}}}();oc.setAll();c.ready(function(){var q=d.initTool,A=a("#tools_left, #svg_editor .tools_flyout"),I=A.find("#tool_"+q);q=A.find("#"+q);(I.length?I:q.length?q:a("#tool_select")).click().mouseup();d.wireframe&&a("#tool_wireframe").click();d.showlayers&&wc();a("#rulers").toggle(!!d.showRulers);if(d.showRulers)a("#show_rulers")[0].checked=true;if(d.gridSnapping)a("#grid_snapping_on")[0].checked=true;d.baseUnit&&a("#base_unit").val(d.baseUnit);d.snappingStep&&a("#grid_snapping_step").val(d.snappingStep)});
a("#rect_rx").SpinButton({min:0,max:1E3,step:1,callback:function(q){f.setRectRadius(q.value)}});a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,callback:function(q){var A=q.value;if(A==0&&Z&&["line","polyline"].indexOf(Z.nodeName)>=0)A=q.value=1;f.setStrokeWidth(A)}});a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(q){f.setRotationAngle(q.value);a("#tool_reorient").toggleClass("disabled",q.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(q,
A){var I=q.value-0,R=I+A,X=R>=I;if(A===0)return I;return I>=24?X?Math.round(I*1.1):Math.round(I/1.1):I<=1?X?I*2:I/2:R},callback:function(q){f.setFontSize(q.value)}});a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:xb});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:fb});a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(q,A){var I=q.value-0;if(I===0)return 100;var R=I+A;if(A===0)return I;return I>=100?R:R>=I?I*2:I/2},callback:ob}).val(f.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",
inSpeed:0},function(q){switch(q){case "delete":Pa();break;case "cut":Xa();break;case "copy":hb();break;case "paste":f.pasteElements();break;case "paste_in_place":f.pasteElements("in_place");break;case "group":f.groupSelectedElements();break;case "ungroup":f.ungroupSelectedElement();break;case "move_front":Db();break;case "move_up":Fb("Up");break;case "move_down":Fb("Down");break;case "move_back":cb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(q)&&svgedit.contextmenu.getCustomHandler(q).call()}f.clipBoard.length&&
pa.enableContextMenuItems("#paste,#paste_in_place")});V=function(q){switch(q){case "dupe":M();break;case "delete":T();break;case "merge_down":if(a("#layerlist tr.layersel").index()!=f.getCurrentDrawing().getNumLayers()-1){f.mergeLayer();Ja();Ab()}break;case "merge_all":f.mergeAllLayers();Ja();Ab()}};a("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},V);a("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:true},V);a(".contextMenu li").mousedown(function(q){q.preventDefault()});
a("#cmenu_canvas li").disableContextMenu();pa.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(ha.getUndoStackSize()===0)c.show_save_warning=false;if(!d.no_save_warning&&c.show_save_warning)return e.notification.unsavedChanges};c.openPrep=function(q){a("#main_menu").hide();ha.getUndoStackSize()===0?q(true):a.confirm(e.notification.QwantToOpen,q)};if(window.FileReader){V=a('<input type="file">').change(function(){var q=this;c.openPrep(function(A){if(A){f.clear();if(q.files.length==
1){A=new FileReader;A.onloadend=function(I){n(I.target.result);Rb()};A.readAsText(q.files[0])}}})});a("#tool_open").show().prepend(V);V=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var q=new FileReader;q.onloadend=function(A){f.importSvgString(A.target.result,true);Rb()};q.readAsText(this.files[0])}});a("#tool_import").show().prepend(V)}var Rb=c.updateCanvas=function(q,A){var I=ra.width(),R=ra.height(),X=I,ja=R,va=f.getZoom(),ya=a("#svgcanvas"),Da={x:ra[0].scrollLeft+
X/2,y:ra[0].scrollTop+ja/2},Ca=d.canvas_expansion;I=Math.max(X,f.contentW*va*Ca);R=Math.max(ja,f.contentH*va*Ca);I==X&&R==ja?ra.css("overflow","hidden"):ra.css("overflow","scroll");Ca=ya.height()/2;var Ba=ya.width()/2;ya.width(I).height(R);var tb=R/2,Ta=I/2,ia=f.updateCanvas(I,R),wb=Ta/Ba;I=I/2-X/2;R=R/2-ja/2;if(A){A.x+=ia.x;A.y+=ia.y}else A={x:Ta+(Da.x-Ba)*wb,y:tb+(Da.y-Ca)*wb};if(q)if(f.contentW>ra.width()){ra[0].scrollLeft=ia.x-10;ra[0].scrollTop=ia.y-10}else{ra[0].scrollLeft=I;ra[0].scrollTop=
R}else{ra[0].scrollLeft=A.x-X/2;ra[0].scrollTop=A.y-ja/2}if(d.showRulers){da(ya,va);ra.scroll()}},hc=[];for(Bb=0.1;Bb<1E5;Bb*=10){hc.push(1*Bb);hc.push(2*Bb);hc.push(5*Bb)}Rb(true);try{var yc=function(q){if(window.JSON&&JSON.stringify)return JSON.stringify(q);var A=arguments.callee;if(typeof q=="boolean"||typeof q=="number")return q+"";else if(typeof q=="string")return'"'+q.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
function(X){return"\\u"+("0000"+X.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(q.length){for(var I=0;I<q.length;I++)q[I]=A(q[I]);return"["+q.join(",")+"]"}else{I=[];for(var R in q)I.push(A(R)+":"+A(q[R]));return"{"+I.join(",")+"}"}};window.addEventListener("message",function(q){var A=parseInt(q.data.substr(0,q.data.indexOf(";")));try{q.source.postMessage("SVGe"+A+";"+yc(eval(q.data)),"*")}catch(I){q.source.postMessage("SVGe"+A+";error:"+I.message,"*")}},false)}catch(zc){window.embed_error=
zc}a(function(){window.svgCanvas=f;f.ready=svgEditor.ready});c.setLang=function(q,A){a.pref("lang",q);a("#lang_select").val(q);if(A){var I=a("#layerlist tr.layersel td.layername").text()==e.common.layer+" 1";a.extend(e,A);f.setUiStrings(A);oc.setTitles();if(I){f.renameCurrentLayer(e.common.layer+" 1");Ab()}f.runExtensions("langChanged",q);Kb();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin",
"#linecap_butt":"#cur_linecap"},function(R,X){a(X).attr("title",a(R)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var u=[];c.ready=function(w){m?w():u.push(w)};c.runCallbacks=function(){a.each(u,function(){this()});m=true};c.loadFromString=function(w){c.ready(function(){n(w)})};c.disableUI=function(){};c.loadFromURL=function(w,p){p||(p={});var L=p.cache,T=p.callback;c.ready(function(){a.ajax({url:w,dataType:"text",
cache:!!L,success:function(M){n(M,T)},error:function(M,J,da){M.status!=404&&M.responseText?n(M.responseText,T):a.alert(e.notification.URLloadFail+": \n"+da+"",T)}})})};c.loadFromDataURI=function(w){c.ready(function(){var p=w.substring(26);n(svgedit.utilities.decode64(p))})};c.addExtension=function(){var w=arguments;a(function(){f&&f.addExtension.apply(this,w)})};return c}(jQuery);$(svgEditor.init)})();svgedit=svgedit||{};
Ya=f.getResolution();if(d.baseUnit!=="px"){Ya.w=svgedit.units.convertUnit(Ya.w)+d.baseUnit;Ya.h=svgedit.units.convertUnit(Ya.h)+d.baseUnit}a(".canvas_width").val(Ya.w);a(".canvas_height").val(Ya.h);a("#docprops_button").on("click",function(){H()});var La=function(q){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ya.w+2,height:Ya.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:q||"#fff",style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");
f.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||La();document.getElementById("canvas_background").getAttribute("fill");var Ea=c.setImageURL=function(q){q||(q=ea);f.setImageURL(q);a("#image_url").val(q);if(q.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{f.embedImage(q,function(A){A?a("#url_notice").hide():a("#url_notice").show();ea=q});a("#image_url").show();a("#change_image_url").hide()}},qb=function(q){var A=Math.min(Math.max(12+q.value.length*
6,50),300);a(q).width(A)},Ja=function(){var q=Z;if(q!=null&&!q.parentNode)q=null;var A=f.getCurrentDrawing().getCurrentLayerName(),I=f.getMode(),R=d.baseUnit!=="px"?d.baseUnit:null,X=I=="pathedit",ja=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #path_panel, #rect_panel, #canvas_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item",
"#object_menu").addClass("disabled");!q&&!Aa&&a("#canvas_panel").show();if(q!=null){var va=q.nodeName,ya=f.getRotationAngle(q);a("#angle").val(Math.round(ya));ya=f.getBlur(q);a("#blur").val(ya);a("#blur_slider").slider("option","value",ya);f.addedNew&&va==="image"&&f.getHref(q).indexOf("data:")!==0&&L();if(!X&&I!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(va)>=0)a("#xy_panel").hide();else{var Da,Ca;if(["g","polyline",
"path"].indexOf(va)>=0){if(I=f.getStrokedBBox([q])){Da=I.x;Ca=I.y}}else{Da=q.getAttribute("x");Ca=q.getAttribute("y")}if(R){Da=svgedit.units.convertUnit(Da);Ca=svgedit.units.convertUnit(Ca)}a("#selected_x").val(Math.round(Ca)||0);a("#selected_y").val(Math.round(Da)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(va)==-1&&a(".action_path_convert_selected").removeClass("disabled");va==="path"&&a(".action_path_selected").removeClass("disabled")}else{A=ta.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");
a("#tool_node_delete").toggleClass("disabled",!ta.canDeleteNodes);fa("#tool_openclose_path",ta.closed_subpath?"open_path":"close_path");if(A){X=a("#seg_type");if(R){A.x=svgedit.units.convertUnit(A.x);A.y=svgedit.units.convertUnit(A.y)}a("#path_node_x").val(Math.round(A.x));a("#path_node_y").val(Math.round(A.y));A.type?X.val(A.type).removeAttr("disabled"):X.val(4).attr("disabled","disabled")}return}R={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx",
"cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]};var Ba=q.tagName;a(q).data("gsvg")&&a("#g_panel").show();Ba=="path"&&a("#path_panel").show();if(R[Ba]){R=R[Ba];a("#"+Ba+"_panel").show();a.each(R,function(tb,Ta){var ia=q.getAttribute(Ta);if(d.baseUnit!=="px"&&q[Ta])ia=svgedit.units.convertUnit(q[Ta].baseVal.value);a("#"+Ba+"_"+Ta).val(Math.round(ia)||0)});if(Ba=="text"){a("#text_panel").css("display","inline");f.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):
a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");f.getBold()?a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(q.getAttribute("font-family"));a("#font_size").val(q.getAttribute("font-size"));a("#text").val(q.textContent);f.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(Ba=="image")Ea(f.getHref(q));else if(Ba==="g"||Ba==="use"){a("#container_panel").show();
a(".action_group_selected").removeClass("disabled");R=f.getTitle();va=a("#g_title")[0];va.value=R;qb(va);Ba=="use"?va.setAttribute("disabled","disabled"):va.removeAttribute("disabled")}}ja[(Ba==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");ja[(Ba==="g"||!Aa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(Aa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");ja.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else ja.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");
ha.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");ha.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");f.addedNew=false;if(q&&!X||Aa){a("#selLayerNames").removeAttr("disabled").val(A);pa.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else a("#selLayerNames").attr("disabled","disabled")};a("#text").focus(function(){});a("#text").blur(function(){});f.bind("selected",
function(q,A){var I=f.getMode();I==="select"&&oa();I=I=="pathedit";Z=A.length==1||A[1]==null?A[0]:null;Aa=A.length>=2&&A[1]!=null;if(Z!=null)if(!I){if(Z!=null)switch(Z.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var R=null,X=Z.getElementsByTagName("*"),ja=0,va=X.length;ja<va;ja++){var ya=X[ja].getAttribute("stroke-width");if(ja===0)R=ya;else if(R!==ya)R=null}a("#stroke_width").val(R===null?"":R);la.fill.update(true);la.stroke.update(true);break;default:la.fill.update(true);
la.stroke.update(true);a("#stroke_width").val(Z.getAttribute("stroke-width")||1);a("#stroke_style").val(Z.getAttribute("stroke-dasharray")||"none");R=Z.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+R).length!=0&&w(a("#linejoin_"+R)[0]);R=Z.getAttribute("stroke-linecap")||"butt";a("#linecap_"+R).length!=0&&w(a("#linecap_"+R)[0])}if(Z!=null){R=(Z.getAttribute("opacity")||1)*100;a("#group_opacity").val(R);a("#opac_slider").slider("option","value",R);a("#elem_id").val(Z.id)}}a("#path_node_panel").toggle(I);
a("#tools_bottom_2,#tools_bottom_3").toggle(!I);if(I){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");fa("#tool_select","select_node");Aa=false;if(A.length)Z=A[0]}else{if(A[0]){I=f.selectorManager.requestSelector(A[0]);I.reset(A[0]);I.selectorRect.setAttribute("display","inline")}fa("#tool_select","select")}Ja();f.runExtensions("selectedChanged",{elems:A,selectedElement:Z,multiselected:Aa})});
f.bind("transition",function(q,A){var I=f.getMode(),R=A[0];if(R){Aa=A.length>=2&&A[1]!=null;if(!Aa)switch(I){case "rotate":I=f.getRotationAngle(R);a("#angle").val(Math.round(I));a("#tool_reorient").toggleClass("disabled",I==0)}f.runExtensions("elementTransition",{elems:A})}});f.bind("changed",function(q,A){var I=f.getMode();I==="select"&&oa();for(var R=0;R<A.length;++R){var X=A[R];if(X&&X.tagName==="svg"){Ab();Rb()}else if(X&&Z&&Z.parentNode==null)Z=X}c.show_save_warning=true;Ja();if(Z&&I==="select"){la.fill.update();
la.stroke.update()}f.runExtensions("elementChanged",{elems:A})});f.bind("saved",function(q,A){c.show_save_warning=false;A='<?xml version="1.0"?>\n'+A;var I=navigator.userAgent;if(~I.indexOf("Chrome")&&a.browser.version>=533||~I.indexOf("MSIE"))D(0,true);else{var R=q.open("data:image/svg+xml;base64,"+ca.encode64(A)),X=a.pref("save_notice_done");if(X!=="all"){var ja=e.notification.saveFromBrowser.replace("%s","SVG");if(I.indexOf("Gecko/")!==-1)if(A.indexOf("<defs")!==-1){ja+="\n\n"+e.notification.defsFailOnSave;
a.pref("save_notice_done","all");X="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");X!=="part"&&R.alert(ja)}}});f.bind("exported",function(q,A){var I=A.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var R=a("#export_canvas")[0];R.width=f.contentW;R.height=f.contentH;canvg(R,A.svg,{renderCallback:function(){var X=R.toDataURL("image/png");ba.location.href=X;if(a.pref("export_notice_done")!=="all"){X=e.notification.saveFromBrowser.replace("%s",
"PNG");if(I.length)X+="\n\n"+e.notification.noteTheseIssues+"\n \u2022 "+I.join("\n \u2022 ");a.pref("export_notice_done","all");ba.alert(X)}}})});f.bind("zoomed",Oa);f.bind("contextset",function(q,A){var I="";if(A){var R="";I='<a href="#" data-root="y">'+f.getCurrentDrawing().getCurrentLayerName()+"</a>";a(A).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){R+=" > "+this.id;I+=this!==A?' > <a href="#">'+this.id+"</a>":" > "+this.id}});Sa=R}else Sa=null;a("#cur_context_panel").toggle(!!A).html(I);
W()});f.bind("extension_added",function(q,A){function I(){if(nb){clearTimeout(nb);nb=null}X||(nb=setTimeout(function(){X=true;za(b.iconsize)},50))}var R=false,X=false,ja=true,va=function(){if(A.callback&&!R&&ja){R=true;A.callback()}},ya=[];A.context_tools&&a.each(A.context_tools,function(Ta,ia){var wb=ia.container_id?' id="'+ia.container_id+'"':"",bb=a("#"+ia.panel);bb.length||(bb=a("<div>",{id:ia.panel}).appendTo("#tools_top").hide());switch(ia.type){case "tool_button":var Fa='<div class="tool_button">'+
ia.id+"</div>",Va=a(Fa).appendTo(bb);ia.events&&a.each(ia.events,function(eb,lb){a(Va).bind(eb,lb)});break;case "select":Fa="<label"+wb+'><select id="'+ia.id+'">';a.each(ia.options,function(eb,lb){Fa+='<option value="'+eb+'"'+(eb==ia.defval?" selected":"")+">"+lb+"</option>"});Fa+="</select></label>";var Ha=a(Fa).appendTo(bb).find("select");a.each(ia.events,function(eb,lb){a(Ha).bind(eb,lb)});break;case "button-select":Fa='<div id="'+ia.id+'" class="dropdown toolset" title="'+ia.title+'"><div id="cur_'+
ia.id+'" class="icon_label"></div><button></button></div>';wb=a('<ul id="'+ia.id+'_opts"></ul>').appendTo("#option_lists");ia.colnum&&wb.addClass("optcols"+ia.colnum);a(Fa).appendTo(bb).children();ya.push({elem:"#"+ia.id,list:"#"+ia.id+"_opts",title:ia.title,callback:ia.events.change,cur:"#cur_"+ia.id});break;case "input":Fa="<label"+wb+'><span id="'+ia.id+'_label">'+ia.label+':</span><input id="'+ia.id+'" title="'+ia.title+'" size="'+(ia.size||"4")+'" value="'+(ia.defval||"")+'" type="text"/></label>';
var kb=a(Fa).appendTo(bb).find("input");ia.spindata&&kb.SpinButton(ia.spindata);ia.events&&a.each(ia.events,function(eb,lb){kb.bind(eb,lb)})}});if(A.buttons){var Da={},Ca={},Ba=A.svgicons,tb={};a.each(A.buttons,function(Ta,ia){for(var wb,bb=ia.id,Fa=Ta;a("#"+bb).length;)bb=ia.id+"_"+ ++Fa;if(Ba){Da[bb]=ia.icon;Fa=ia.svgicon?ia.svgicon:ia.id;if(ia.type=="app_menu")Ca["#"+bb+" > div"]=Fa;else Ca["#"+bb]=Fa}else wb=ia.type=="menu"?"":a('<img src="'+ia.icon+'">');var Va,Ha;switch(ia.type){case "mode_flyout":case "mode":Va=
"tool_button";if(ia.cls)Va+=" "+ia.cls;Ha="#tools_left";break;case "context":Va="tool_button";Ha="#"+ia.panel;a(Ha).length||a("<div>",{id:ia.panel}).appendTo("#tools_top");break;case "menu":Va="menu_item tool_button";Ha="#"+(ia.after||ia.panel);break;case "app_menu":Va="";Ha=ia.parent||"#main_menu ul";a(Ha).length||a("<div>",{id:ia.panel}).appendTo("#tools_top")}var kb=a(ia.list||ia.type=="app_menu"?"<li/>":"<div/>").attr("id",bb).attr("title",ia.title).addClass(Va);if(!ia.includeWith&&!ia.list){if("position"in
ia)a(Ha).children().eq(ia.position).before(kb);else ia.type!="menu"||!ia.after?kb.appendTo(Ha):a(Ha).after(kb);if(ia.type=="mode_flyout"){Fa=a(kb);Va=Fa.parent();if(!Fa.parent().hasClass("tools_flyout")){var eb=Fa[0].id.replace("tool_","tools_"),lb=Fa.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Fa.before(lb);Va=Ga(eb,Fa);Va.data("isLibrary",true);lb.data("isLibrary",true)}Ca["#"+eb+"_show"]=ia.id;bb=tb["#"+Va[0].id]=[{sel:"#"+bb,fn:ia.events.click,icon:ia.id,isDefault:true},
Yb]}else if(ia.type=="app_menu"||ia.type=="menu")kb.append(ia.title)}else if(ia.list){kb.addClass("push_button");a("#"+ia.list+"_opts").append(kb);if(ia.isDefault){a("#cur_"+ia.list).append(kb.children().clone());Fa=ia.svgicon?ia.svgicon:ia.id;Ca["#cur_"+ia.list]=Fa}}else if(ia.includeWith){Ha=ia.includeWith;Fa=a(Ha.button);Va=Fa.parent();if(!Fa.parent().hasClass("tools_flyout")){eb=Fa[0].id.replace("tool_","tools_");lb=Fa.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));
Fa.before(lb);Va=Ga(eb,Fa)}var Yb=oc.getButtonData(Ha.button);if(Ha.isDefault)Ca["#"+eb+"_show"]=ia.id;bb=tb["#"+Va[0].id]=[{sel:"#"+bb,fn:ia.events.click,icon:ia.id,key:ia.key,isDefault:ia.includeWith?ia.includeWith.isDefault:0},Yb];eb="position"in Ha?Ha.position:"last";Yb=Va.children().length;if(!isNaN(eb)&&eb>=0&&eb<Yb)Va.children().eq(eb).before(kb);else{Va.append(kb);bb.reverse()}}Ba||kb.append(wb);ia.list||a.each(ia.events,function(Jb,Xb){if(Jb=="click")if(ia.type=="mode"){ia.includeWith?kb.bind(Jb,
Xb):kb.bind(Jb,function(){xa(kb)&&Xb()});if(ia.key){a(document).bind("keydown",ia.key,Xb);ia.title&&kb.attr("title",ia.title+" ["+ia.key+"]")}}else kb.bind(Jb,Xb);else kb.bind(Jb,Xb)});Qa(tb)});a.each(ya,function(){sb(this.elem,this.list,this.callback,{seticon:true})});if(Ba)ja=false;a.svgIcons(Ba,{w:27,h:27,id_match:false,no_img:!O,fallback:Da,placement:Ca,callback:function(){b.iconsize&&b.iconsize!="m"&&I();ja=true;va()}})}va()});f.textActions.setInputElem(a("#text")[0]);var Za='<div class="palette_item" data-rgb="none"></div>';
a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff","#aad4ff"],function(q,A){Za+='<div class="palette_item" style="background-color: '+A+';" data-rgb="'+A+'"></div>'});a("#palette").append(Za);
Za="";a.each(["#FFF","#888","#000"],function(){Za+='<div class="color_block" style="background-color:'+this+';"></div>'});a("#bg_blocks").append(Za);var Ma=a("#bg_blocks div");Ma.each(function(){a(this).click(function(){Ma.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))p(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&p(o.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){b.img_save=a.pref("img_save");a("#image_save_opts input").val([b.img_save])}var ob=
function(q){var A=q.value/100;if(A<0.0010)q.value=0.1;else{q=f.getZoom();Oa(window,{width:0,height:0,x:(ra[0].scrollLeft+ra.width()/2)/q,y:(ra[0].scrollTop+ra.height()/2)/q,zoom:A},true)}},xb=function(q,A){if(A==null)A=q.value;a("#group_opacity").val(A);if(!q||!q.handle)a("#opac_slider").slider("option","value",A);f.setOpacity(A/100)},fb=function(q,A,I){if(A==null)A=q.value;a("#blur").val(A);var R=false;if(!q||!q.handle){a("#blur_slider").slider("option","value",A);R=true}I?f.setBlurNoUndo(A):f.setBlur(A,
R)},ib=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){f.setStrokeAttr("stroke-dasharray",a(this).val());ib()});a("#stroke_linejoin").change(function(){f.setStrokeAttr("stroke-linejoin",a(this).val());ib()});a("select").change(function(){a(this).blur()});var Lb=false;a("#selLayerNames").change(function(){var q=this.options[this.selectedIndex].value,A=e.notification.QmoveElemsToLayer.replace("%s",q),I=function(R){if(R){Lb=true;f.moveSelectedToLayer(q);
f.clearSelection();Ab()}};if(q)Lb?I(true):a.confirm(A,I)});a("#font_family").change(function(){f.setFontFamily(this.value)});a("#seg_type").change(function(){f.setSegType(a(this).val())});a("#text").keyup(function(){f.setTextContent(this.value)});a("#image_url").change(function(){Ea(this.value)});a("#link_url").change(function(){this.value.length?f.setLinkURL(this.value):f.removeHyperlink()});a("#g_title").change(function(){f.setGroupTitle(this.value)});a(".attr_changer").change(function(){var q=
this.getAttribute("data-attr"),A=this.value;if(svgedit.units.isValidUnit(q,A,Z))this.blur();else{a.alert(e.notification.invalidAttrValGiven);this.value=Z.getAttribute(q);return false}if(q!=="id")if(isNaN(A))A=f.convertToNum(q,A);else if(d.baseUnit!=="px"){var I=svgedit.units.getTypeMap();if(Z[q]||f.getMode()==="pathedit"||q==="x"||q==="y")A*=I[d.baseUnit]}if(q==="id"){q=Z;f.clearSelection();q.id=A;f.addToSelection([q],true)}else f.changeSelectedAttribute(q,A);this.blur()});a("#palette").mouseover(function(){var q=
a('<input type="hidden">');a(this).append(q);q.focus().remove()});a(".palette_item").mousedown(function(){var q=a("#tool_stroke").hasClass("active"),A=q?"stroke":"fill",I=a(this).attr("data-rgb"),R=null;if(I==="transparent"||I==="initial"||I==="#none"){I="none";R=new a.jGraduate.Paint}else R=new a.jGraduate.Paint({alpha:100,solidColor:I.substr(1)});la[A].setPaint(R);if(q){f.setColor("stroke",I);I!="none"&&f.getStrokeOpacity()!=1&&f.setPaintOpacity("stroke",1)}else{f.setColor("fill",I);I!="none"&&
f.getFillOpacity()!=1&&f.setPaintOpacity("fill",1)}}).bind("contextmenu",function(q){q.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");Ub()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Ub()});var xa=function(q,A){if(a(q).hasClass("disabled"))return false;if(a(q).parent().hasClass("tools_flyout"))return true;var I=I||"normal";A||a(".tools_flyout").fadeOut(I);a("#styleoverrides").text("");
a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(q).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var q=null,A=null,I=ra[0],R=false,X=false;a("#svgcanvas").bind("mousemove mouseup",function(ja){if(R!==false){I.scrollLeft-=ja.clientX-q;I.scrollTop-=ja.clientY-A;q=ja.clientX;A=ja.clientY;if(ja.type==="mouseup")R=false;return false}}).mousedown(function(ja){if(ja.button===1||X===true){R=true;q=ja.clientX;A=ja.clientY;return false}});
a(window).mouseup(function(){R=false});a(document).bind("keydown","space",function(ja){f.spaceKey=X=true;ja.preventDefault()}).bind("keyup","space",function(ja){ja.preventDefault();f.spaceKey=X=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&ra.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&ra.removeClass("out")})})();var ub=a(".menu"),rb=function(q){q.target.style.background="#fff";setTimeout(function(){q.target.style.background="#ddd"},50);setTimeout(function(){q.target.style.background=
"#fff"},150);setTimeout(function(){q.target.style.background="#ddd"},200);setTimeout(function(){q.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").live("click",function(q){rb(q)});a("svg, body").on("mousedown",function(q){top!=self&&!q.isTrigger&&typeof top.exports.setEditorFocus=="function"&&top.exports.setEditorFocus();if(!a(q.target).hasClass("menu_title"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))rb(q);
else{a("#menu_bar").removeClass("active");a("#tools_shapelib").is(":visible")&&!a(q.target).parents("#tools_shapelib_show, #tools_shapelib").length&&a("#tools_shapelib").hide();q.target.nodeName.toLowerCase()!="input"&&a("input").blur()}});var yb=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(q,A,I,R){if(q.altKey){q.preventDefault();q=f.getZoom()*100;A=yb.length;for(Bb=0;Bb<A;Bb++){I=Math.min(A,Bb+1);if(R>0)zoom=yb[Bb]<=q?yb[I]:zoom;if(R<0)zoom=yb[Bb]<
q?yb[Bb]:zoom}zoom&&ob({value:zoom})}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",function(){ub.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,A,I){if(a(q).length!=0){var R=a(q).find("button"),X=a(q).find("ul").attr("id",a(q)[0].id+"-list");I||a("#option_lists").append(X);var ja=false;I&&a(q).addClass("dropup");X.find("li").bind("mouseup",A);a(window).mouseup(function(){if(!ja){R.removeClass("down");
X.hide()}ja=false});R.bind("mousedown",function(){if(R.hasClass("down")){R.removeClass("down");X.hide()}else{R.addClass("down");if(!I){var va=a(q).offset();X.css({top:va.top,left:va.left-110})}X.show();ja=true}}).hover(function(){ja=true}).mouseout(function(){ja=false})}};var sb=function(q,A,I,R){var X=a(q);A=a(A);var ja=false,va=R.dropUp;va&&a(q).addClass("dropup");A.find("li").bind("mouseup",function(){if(R.seticon){fa("#cur_"+X[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}I.apply(this,
arguments)});a(window).mouseup(function(){if(!ja){X.removeClass("down");A.hide();A.css({top:0,left:0})}ja=false});A.height();a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=A.height();ya.left+=8}else ya.top+=a(q).height();a(A).offset(ya);if(X.hasClass("down")){X.removeClass("down");A.hide();A.css({top:0,left:0})}else{X.addClass("down");A.show();ja=true;return false}}).hover(function(){ja=true}).mouseout(function(){ja=false});R.multiclick&&A.mousedown(function(){ja=true})};c.addDropDown("#font_family_dropdown",
function(){a(this).text();a("#font_family").val(a(this).text()).change()});c.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var q=parseInt(a(this).text().split("%")[0]);xb(false,q)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(q,A){xb(A)}});c.addDropDown("#blur_dropdown",a.noop);var mb=false;a("#blur_slider").slider({max:10,step:0.1,
stop:function(q,A){mb=false;fb(A);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){mb=true},slide:function(q,A){fb(A,null,mb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),A=q.attr("data-val");A?Oa(window,A):ob({value:parseInt(q.text())})},true);sb("#stroke_linecap","#linecap_opts",function(){w(this,true)},{dropUp:true});sb("#stroke_linejoin","#linejoin_opts",function(){w(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",
function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,"page")})});(function(){var q,A=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=this;U="toolbars";ra.mousedown(A)}).blur(function(){U="canvas";ra.unbind("mousedown",A);f.getMode()=="textedit"&&a("#text").focus()})})();var Gb=function(){if(xa("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},
Hb=function(){xa("#tool_fhpath")&&f.setMode("fhpath")},Mb=function(){xa("#tool_line")&&f.setMode("line")},Nb=function(){xa("#tool_rect")&&f.setMode("rect")},ma=function(){xa("#tool_ellipse")&&f.setMode("ellipse")},Y=function(){xa("#tool_image")&&f.setMode("image")},na=function(){xa("#tool_zoom")&&f.setMode("zoom")},K=function(){if(xa("#tool_zoom")){E();oa()}},N=function(){xa("#tool_text")&&f.setMode("text")},aa=function(){xa("#tool_path")&&f.setMode("path")},Pa=function(){if(Z!=null||Aa)f.deleteSelectedElements()},
Xa=function(){if(Z!=null||Aa){window.event.type==="keydown"&&db(a("#edit_menu"));f.cutSelectedElements()}},hb=function(){if(Z!=null||Aa){window.event.type==="keydown"&&db(a("#edit_menu"));f.copySelectedElements()}},pb=function(){window.event.type==="keydown"&&db(a("#edit_menu"));var q=f.getZoom(),A=(ra[0].scrollLeft+ra.width()/2)/q-f.contentW;q=(ra[0].scrollTop+ra.height()/2)/q-f.contentH;f.pasteElements("point",A,q)},Db=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));
f.moveToTopSelectedElement()}},cb=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveToBottomSelectedElement()}},Eb=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected("Up")}},$a=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected("Down")}},Fb=function(q){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected(q)}},Pb=function(){if(Z!=null){f.convertToPath();
elems=f.getSelectedElems();f.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");f.setMode("pathedit");ta.toEditMode(elems[0]);f.clearSelection()}},$b=function(){Z!=null&&ta.reorient()},Zb=function(){if(Z!=null||Aa)a.prompt(e.notification.enterNewLinkURL,"http://",function(q){q&&f.makeHyperlink(q)})},gb=function(q,A){if(Z!=null||Aa){if(d.gridSnapping){var I=f.getZoom()*d.snappingStep;q*=I;A*=I}a("input").blur();f.moveSelectedElements(q,A)}},Ua=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");
q?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",false);ta.linkControlPoints(q)},ic=function(){ta.getNodePoint()&&ta.clonePathNode()},ec=function(){ta.getNodePoint()&&ta.deletePathNode()},cc=function(){var q=a("#tool_add_subpath"),A=!q.hasClass("push_button_pressed");A?q.addClass("push_button_pressed").removeClass("tool_button"):
q.removeClass("push_button_pressed").addClass("tool_button");ta.addSubPath(A)},fc=function(){ta.opencloseSubPath()},gc=function(){f.cycleElement(1)},Tb=function(){f.cycleElement(0)},Sb=function(q,A){if(!(Z==null||Aa)){q||(A*=-1);var I=a("#angle").val()*1+A;f.setRotationAngle(I);Ja()}},mc=function(){var q=d.dimensions;a.confirm(e.notification.QwantToClear,function(A){if(A){oa();f.clear();f.setResolution(q[0],q[1]);Rb(true);E();Ab();Ja();la.fill.prep();la.stroke.prep();f.runExtensions("onNewDocument")}})},
Vb=function(){f.setBold(!f.getBold());Ja();return false},vb=function(){f.setItalic(!f.getItalic());Ja();return false},kc=function(){if(!l.pngsave){var q=e.notification.loadingImage;ba=window.open("data:text/html;charset=utf-8,<title>"+q+"</title><h1>"+q+"</h1>")}window.canvg?f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},jc=function(){f.open()},Wb=function(){},db=function(q){var A=q.prev();A.css("background","#09f");setTimeout(function(){A.css("background",
"")},200)},dc=function(){if(ha.getUndoStackSize()>0){window.event.type==="keydown"&&db(a("#edit_menu"));ha.undo();Ab()}},g=function(){if(ha.getRedoStackSize()>0){window.event.type==="keydown"&&db(a("#edit_menu"));ha.redo();Ab()}},h=function(){if(Aa)f.groupSelectedElements();else Z&&f.ungroupSelectedElement()},k=function(){window.event.type==="keydown"&&db(a("#edit_menu"));f.cloneSelectedElements(20,20)},v=function(){var q=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(q,a("#align_relative_to").val())},
s=function(){var q=document.querySelector("#tool_stroke rect"),A=document.querySelector("#tool_fill rect"),I=A.getAttribute("fill"),R=q.getAttribute("fill");q=parseFloat(q.getAttribute("stroke-opacity"));if(isNaN(q))q=100;A=parseFloat(A.getAttribute("fill-opacity"));if(isNaN(A))A=100;R=ab(R,q,"stroke");I=ab(I,A,"fill");la.fill.setPaint(R,true);la.stroke.setPaint(I,true)},E=function(q){var A=f.getResolution();q=q?A.zoom*q:1;a("#zoom").val(q*100);f.setZoom(q);B();Rb(true)},z=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?
a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");ra.toggleClass("wireframe");if(!tc){var q=a("#wireframe_rules");q.length?q.empty():a('<style id="wireframe_rules"></style>').appendTo("head");B()}},t=function(){f.clearSelection();a("#tool_canvas").trigger("click")},C=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},F=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");
a("#show_rulers").attr("checked",false);d.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);d.showRulers=true}a("#rulers").toggle(!!d.showRulers)},B=function(){if(!tc){var q="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+"px; }";a("#wireframe_rules").text(ra.hasClass("wireframe")?q:"")}},D=function(q,A){if(!Ka){Ka=true;a("#save_output_btns").toggle(!!A);a("#tool_source_back").toggle(!A);var I=sa=f.getSvgString();a("#svg_source_textarea").val(I);
a("#svg_source_editor").fadeIn();P();a("#svg_source_textarea").focus()}},H=function(){if(!Ra){Ra=true;a("#image_save_opts input").val([b.img_save]);var q=f.getResolution();if(d.baseUnit!=="px"){q.w=svgedit.units.convertUnit(q.w)+d.baseUnit;q.h=svgedit.units.convertUnit(q.h)+d.baseUnit}a(".canvas_width").val(q.w);a(".canvas_height").val(q.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},G=function(){if(!Na){Na=true;var q=a("#bg_blocks div"),A=a.pref("bkgd_color"),I=a.pref("bkgd_url");
q.each(function(){var R=a(this),X=R.css("background-color")==A;R.toggleClass("cur_background",X);X&&a("#canvas_bg_url").removeClass("cur_background")});A||q.eq(0).addClass("cur_background");I&&a("#canvas_bg_url").val(I);a("grid_snapping_step").attr("value",d.snappingStep);d.gridSnapping==true?a("#grid_snapping_on").attr("checked","checked"):a("#grid_snapping_on").removeAttr("checked");a("#svg_prefs").show()}},P=function(){var q=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",
q)},Q=function(){if(Ka){var q=function(){f.clearSelection();zb();E();Ab();W();la.fill.prep();la.stroke.prep()};f.setSvgString(a("#svg_source_textarea").val())?q():a.confirm(e.notification.QerrorsRevertToSource,function(A){if(!A)return false;q()});oa()}},W=function(q){q=q||f.getDocumentTitle();q=Wa+(q?": "+q:"");a("title:first").text(q)},ua=function(){var q=a("#canvas_width"),A=q.val(),I=a("#canvas_height"),R=I.val();if(A!="fit"&&!svgedit.units.isValidUnit("width",A)){a.alert(e.notification.invalidAttrValGiven);
q.parent().addClass("error");return false}q.parent().removeClass("error");if(R!="fit"&&!svgedit.units.isValidUnit("height",R)){a.alert(e.notification.invalidAttrValGiven);I.parent().addClass("error");return false}I.parent().removeClass("error");if(!f.setResolution(A,R)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Rb();Qb()},wa=function(){var q=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";
p(q,a("#canvas_bg_url").val());q=a("#lang_select").val();q!=b.lang&&c.putLocale(q);za(a("#iconsize").val());d.gridSnapping=a("#grid_snapping_on")[0].checked;d.snappingStep=a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);d.showRulers&&da();d.baseUnit=a("#base_unit").val();f.setConfig(d);Rb();Ib()},fa=c.setIcon=function(q,A){var I=typeof A==="string"?a.getSvgIcon(A,true):A.clone();I?a(q).find("img").replaceWith(I):console.log("NOTE: Icon image missing: "+
A)},ka;ka=function(){var q=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,A=document.getElementsByTagName("script")[0],I;for(I in A.style)if(q.test(I))return I.match(q)[0];if("WebkitOpacity"in A.style)return"Webkit";if("KhtmlOpacity"in A.style)return"Khtml";return""}();var qa=function(q,A){ka.toLowerCase();var I=["top","left","bottom","right"];q.each(function(){for(var R=a(this),X=R.outerWidth()*(A-1),ja=R.outerHeight()*(A-1),va=0;va<4;va++){var ya=I[va],Da=R.data("orig_margin-"+ya);if(Da==null){Da=parseInt(R.css("margin-"+
ya));R.data("orig_margin-"+ya,Da)}Da=Da*A;if(ya==="right")Da+=X;else if(ya==="bottom")Da+=ja;R.css("margin-"+ya,Da)}})},za=c.setIconSize=function(q,A){if(!(q==b.size&&!A)){var I=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),R=1;R=typeof q=="number"?q:{s:0.75,m:1,l:1.25,xl:1.5}[q];c.tool_scale=S=R;Cb();var X=I.parents(":hidden");X.css("visibility",
"hidden").show();qa(I,R);X.css("visibility","visible").hide();a.pref("iconsize",q);a("#iconsize").val(q);X={"#tools_top":{left:50,height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};I=a("#tool_size_rules");if(I.length)I.empty();else I=a('<style id="tool_size_rules"></style>').appendTo("head");if(q!="m"){var ja="";a.each(X,function(va,ya){va="#svg_editor "+va.replace(/,/g,", #svg_editor");ja+=va+"{";a.each(ya,function(Da,Ca){if(typeof Ca==="number")var Ba=Ca*R+"px";else if(Ca[q]||
Ca.all)Ba=Ca[q]||Ca.all;ja+=Da+":"+Ba+";"});ja+="}"});X="-"+ka.toLowerCase()+"-";ja+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+X+"transform: scale("+R+");} #svg_editor div.toolset .toolset {"+X+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+X+"transform: scale("+1/R+");}";I.text(ja)}Cb()}},jb=function(){a("#dialog_box").hide();
if(!Ka&&!Ra&&!Na)Sa&&f.leaveContext();else{if(Ka)sa!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(q){q&&zb()}):zb();else if(Ra)Qb();else Na&&Ib();Ub()}},zb=function(){a("#svg_source_editor").hide();Ka=false;a("#svg_source_textarea").blur()},Qb=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=0;a("#image_save_opts input").val([b.img_save]);Ra=false},Ib=function(){a("#svg_prefs").hide();
Na=false},Ob={width:a(window).width(),height:a(window).height()},Ub=a.noop,ac;svgedit.browser.isIE()&&function(){Ub=function(){if(ra[0].scrollLeft===0&&ra[0].scrollTop===0){ra[0].scrollLeft=ac.left;ra[0].scrollTop=ac.top}};ac={left:ra[0].scrollLeft,top:ra[0].scrollTop};a(window).resize(Ub);svgEditor.ready(function(){setTimeout(function(){Ub()},500)});ra.scroll(function(){ac={left:ra[0].scrollLeft,top:ra[0].scrollTop}})}();a(window).resize(function(){Ka&&P();a.each(Ob,function(q,A){var I=a(window)[q]();
ra[0]["scroll"+(q==="width"?"Left":"Top")]-=(I-A)/2;Ob[q]=I})});(function(){ra.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=ra[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=ra[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(L);(function(){var q=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],A="";a.each(q,function(I,R){A+="#tool_"+
R+(I==q.length-1?",":"")});a(A).mousedown(function(){a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")});a("#tool_undo, #tool_redo").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")})})();if(V&&!window.opera){V=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(var Bb=V.length;Bb--;){var pc=
document.getElementById(V[Bb]);if(pc!=null){var qc=pc.title,uc=qc.indexOf("Ctrl+");pc.title=[qc.substr(0,uc),"Cmd+",qc.substr(uc+5)].join("")}}}var rc=function(q){var A=q[0].id=="stroke_color"?"stroke":"fill",I=q[0].id=="canvas_color";if(I)A="canvas";var R=la[A].paint;q=A=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";I=I?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(I).jGraduate({paint:R,
window:{pickerTitle:q},images:{clientPath:d.jGraduatePath},newstop:"inverse"},function(X){R=new a.jGraduate.Paint(X);la[A].setPaint(R);f.setPaint(A,R);a("#color_picker").hide()},function(){a("#color_picker").hide()})};V=function(q,A){var I=document.getElementById("canvas_background"),R={color:"fff",opacity:1};if(A=="stroke")R=d.initStroke;if(A=="fill")R=d.initFill;if(A=="canvas"&&I)if(I=I.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))R={color:("0"+parseInt(I[1],10).toString(16)).slice(-2)+
("0"+parseInt(I[2],10).toString(16)).slice(-2)+("0"+parseInt(I[3],10).toString(16)).slice(-2),opacity:1};I=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+R.color+'" opacity="'+R.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;I=a(q)[0].appendChild(document.importNode(I,true));I.setAttribute("width",24.5);this.rect=I.firstChild;this.defs=I.getElementsByTagName("defs")[0];
this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:R.color});this.type=A;this.setPaint=function(X,ja){this.paint=X;var va="none",ya=X.type,Da=X.alpha/100;switch(ya){case "solidColor":va=X[ya]=="none"||X[ya]=="one"?"none":"#"+X[ya];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(X[ya]);va="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",va);this.rect.setAttribute("opacity",Da);if(ja){f.setColor(this.type,
va,true);f.setPaintOpacity(this.type,Da,true)}if(this.type=="canvas"){(ya=document.getElementById("canvas_background"))?ya.setAttribute("fill",va):La(va);console.log(ya.getAttribute("fill"))}};this.update=function(X){if(Z){var ja=this.type;switch(Z.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var va=null,ya=Z.getElementsByTagName("*"),Da=0,Ca=ya.length;Da<Ca;Da++){var Ba=ya[Da].getAttribute(ja);if(Da===0)va=Ba;else if(va!==Ba){va=null;break}}if(va===null){ya=
null;return}ya=va;va=1;break;default:va=parseFloat(Z.getAttribute(ja+"-opacity"));if(isNaN(va))va=1;ya=ja==="fill"?"black":"none";ya=Z.getAttribute(ja)||ya}if(X){f.setColor(ja,ya,true);f.setPaintOpacity(ja,va,true)}va*=100;this.setPaint(ab(ya,va,ja))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var X=new a.jGraduate.Paint({copy:this.paint});f.setPaint(A,X)}}};la.fill=new V("#fill_color","fill");la.stroke=new V("#stroke_color","stroke");la.canvas=new V("#canvas_color",
"canvas");a("#stroke_width").val(d.initStroke.width);a("#group_opacity").val(d.initOpacity*100);V=la.fill.rect.cloneNode(false);V.setAttribute("style","vector-effect:non-scaling-stroke");var tc=V.style.vectorEffect==="non-scaling-stroke";V.removeAttribute("style");V=la.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof V.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(V).remove();setTimeout(function(){f.embedImage("images/placeholder.svg",function(q){if(!q){a("#image_save_opts [value=embed]").attr("disabled",
"disabled");a("#image_save_opts input").val(["ref"]);b.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",e.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))rc(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_canvas").click(function(){rc(a("#canvas_color"))});a("#tool_stroke").click(function(){if(a("#tool_stroke").hasClass("active"))rc(a("#stroke_color"));else{a("#tool_stroke").addClass("active");
a("#tool_fill").removeClass("active")}});a("#group_opacityLabel").click(function(){a("#opacity_dropdown button").mousedown();a(window).mouseup()});a("#zoomLabel").click(function(){a("#zoom_dropdown button").mousedown();a(window).mouseup()});a("#tool_move_top").mousedown(function(q){a("#tools_stacking").show();q.preventDefault()});a(".layer_button").mousedown(function(){a(this).addClass("layer_buttonpressed")}).mouseout(function(){a(this).removeClass("layer_buttonpressed")}).mouseup(function(){a(this).removeClass("layer_buttonpressed")});
a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a("#layer_new").click(function(){var q=f.getCurrentDrawing().getNumLayers();do var A=e.layers.layer+" "+ ++q;while(f.getCurrentDrawing().hasLayer(A));a.prompt(e.notification.enterUniqueLayerName,
A,function(I){if(I)if(f.getCurrentDrawing().hasLayer(I))a.alert(e.notification.dupeLayerName);else{f.createLayer(I);Ja();Ab()}})});a("#layer_delete").click(T);a("#layer_up").click(function(){J(-1)});a("#layer_down").click(function(){J(1)});a("#layer_rename").click(function(){a("#layerlist tr.layersel").prevAll();var q=a("#layerlist tr.layersel td.layername").text();a.prompt(e.notification.enterNewLayerName,"",function(A){if(A)if(q==A||f.getCurrentDrawing().hasLayer(A))a.alert(e.notification.layerHasThatName);
else{f.renameCurrentLayer(A);Ab()}})});var bc=-1,lc=false,sc=false,vc=function(q){if(sc)if(bc!=-1){lc=true;q=bc-q.pageX;var A=a("#sidepanels"),I=parseInt(A.css("width"));if(I+q>300)q=300-I;else if(I+q<2)q=2-I;if(q!=0){bc-=q;I=a("#layerpanel");ra.css("right",parseInt(ra.css("right"))+q);A.css("width",parseInt(A.css("width"))+q);I.css("width",parseInt(I.css("width"))+q);A=a("#ruler_x");A.css("right",parseInt(A.css("right"))+q)}}};a("#sidepanel_handle").mousedown(function(q){bc=q.pageX;a(window).mousemove(vc);
sc=false;setTimeout(function(){sc=true},20)}).mouseup(function(){lc||wc();bc=-1;lc=false});a(window).mouseup(function(){bc=-1;lc=false;a("#svg_editor").unbind("mousemove",vc)});var wc=function(q){var A=parseInt(a("#sidepanels").css("width"));q=(A>2||q?2:150)-A;A=a("#sidepanels");var I=a("#layerpanel"),R=a("#ruler_x");ra.css("right",parseInt(ra.css("right"))+q);A.css("width",parseInt(A.css("width"))+q);I.css("width",parseInt(I.css("width"))+q);R.css("right",parseInt(R.css("right"))+q)},xc=function(q){for(var A=
Array(f.getCurrentDrawing().getNumLayers()),I=0;I<A.length;++I)A[I]=f.getCurrentDrawing().getLayerName(I);if(q)for(I=0;I<A.length;++I)A[I]!=q&&f.getCurrentDrawing().setLayerOpacity(A[I],0.5);else for(I=0;I<A.length;++I)f.getCurrentDrawing().setLayerOpacity(A[I],1)},Ab=function(){var q=a("#layerlist tbody"),A=a("#selLayerNames");q.empty();A.empty();for(var I=f.getCurrentDrawing().getCurrentLayerName(),R=f.getCurrentDrawing().getNumLayers(),X=a.getSvgIcon("eye");R--;){var ja=f.getCurrentDrawing().getLayerName(R),
va='<tr class="layer';if(ja==I)va+=" layersel";va+='">';va+=f.getCurrentDrawing().getLayerVisibility(ja)?'<td class="layervis"/><td class="layername" >'+ja+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+ja+"</td></tr>";q.append(va);A.append('<option value="'+ja+'">'+ja+"</option>")}if(X!==undefined){X.clone();a("td.layervis",q).append(X.clone());a.resizeSvgIcons({"td.layervis .svg_icon":14})}a("#layerlist td.layername").mouseup(function(ya){a("#layerlist tr.layer").removeClass("layersel");
a(this.parentNode).addClass("layersel");f.setCurrentLayer(this.textContent);ya.preventDefault()}).mouseover(function(){a(this).css({"font-style":"italic",color:"blue"});xc(this.textContent)}).mouseout(function(){a(this).css({"font-style":"normal",color:"black"});xc()});a("#layerlist td.layervis").click(function(){var ya=a(this.parentNode).prevAll().length;ya=a("#layerlist tr.layer:eq("+ya+") td.layername").text();var Da=a(this).hasClass("layerinvis");f.setLayerVisibility(ya,Da);Da?a(this).removeClass("layerinvis"):
a(this).addClass("layerinvis")});for(A=5-a("#layerlist tr.layer").size();A-- >0;)q.append('<tr><td style="color:white">_</td><td/></tr>')};Ab();a(window).bind("load resize",function(){ra.css("line-height",ra.height()+"px")});a("#resolution").change(function(){var q=a("#canvas_width,#canvas_height");if(this.selectedIndex)if(this.value=="content")q.val("fit").attr("disabled","disabled");else{var A=this.value.split("x");a("#canvas_width").val(A[0]);a("#canvas_height").val(A[1]);q.removeAttr("disabled")}else a("#canvas_width").val()==
"fit"&&q.removeAttr("disabled").val(100)});a("input,select").attr("autocomplete","off");var oc=function(){var q=[{sel:"#tool_select",fn:Gb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Hb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Mb,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Nb,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:ma,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:aa,evt:"click",key:["P",true]},{sel:"#tool_text",fn:N,evt:"click",key:["T",
true]},{sel:"#tool_image",fn:Y,evt:"mouseup"},{sel:"#tool_zoom",fn:na,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:mc,evt:"mouseup",key:[ga+"N",true]},{sel:"#tool_save",fn:function(){Ka?Q():f.save({images:b.img_save,round_digits:6})},evt:"mouseup",key:[ga+"S",true]},{sel:"#tool_export",fn:kc,evt:"mouseup"},{sel:"#tool_open",fn:jc,evt:"mouseup"},{sel:"#tool_import",fn:Wb,evt:"mouseup"},{sel:"#tool_source",fn:D,evt:"click",key:[ga+"U",true]},{sel:"#tool_wireframe",fn:z,evt:"click"},{sel:"#tool_rulers",
fn:F,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:jb,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Q,evt:"click"},{sel:"#tool_docprops_save",fn:ua,evt:"click"},{sel:"#tool_docprops",fn:H,evt:"mouseup"},{sel:"#tool_prefs_save",fn:wa,evt:"click"},{sel:"#tool_prefs_option",fn:function(){G();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:Pa,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",
fn:$b,evt:"click"},{sel:"#tool_node_link",fn:Ua,evt:"click"},{sel:"#tool_node_clone",fn:ic,evt:"click"},{sel:"#tool_node_delete",fn:ec,evt:"click"},{sel:"#tool_openclose_path",fn:fc,evt:"click"},{sel:"#tool_add_subpath",fn:cc,evt:"click"},{sel:"#tool_move_top",fn:Db,evt:"click",key:ga+"shift+up"},{sel:"#tool_move_bottom",fn:cb,evt:"click",key:ga+"shift+down"},{sel:"#tool_move_up",fn:Eb,evt:"click",key:[ga+"up",true]},{sel:"#tool_move_down",fn:$a,evt:"click",key:[ga+"down",true]},{sel:"#tool_topath",
fn:Pb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:Zb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:k,evt:"click",key:[ga+"D",true]},{sel:"#tool_group",fn:h,evt:"click",key:[ga+"G",true]},{sel:"#tool_ungroup",fn:h,evt:"click",key:ga+"shift+G"},{sel:"#tool_unlink_use",fn:h,evt:"click"},{sel:"[id^=tool_align]",fn:v,evt:"click"},{sel:"#tool_switch",fn:s,evt:"click",key:["shift+x",true]},{sel:"#tool_undo",fn:dc,evt:"click",key:ga+"z"},{sel:"#tool_redo",fn:g,evt:"click",key:["y",
true]},{sel:"#tool_canvas_color_menu",fn:t,evt:"click"},{sel:"#tool_cut",fn:Xa,evt:"click",key:ga+"x"},{sel:"#tool_copy",fn:hb,evt:"click",key:ga+"c"},{sel:"#tool_paste",fn:pb,evt:"click",key:ga+"v"},{sel:"#tool_bold",fn:Vb,evt:"mousedown",key:[ga+"B",true]},{sel:"#tool_italic",fn:vb,evt:"mousedown",key:[ga+"I",true]},{sel:"#copy_save_done",fn:jb,evt:"click"},{key:"ctrl+left",fn:function(){Sb(0,1)}},{key:"ctrl+right",fn:function(){Sb(1,1)}},{key:"ctrl+shift+left",fn:function(){Sb(0,5)}},{key:"ctrl+shift+right",
fn:function(){Sb(1,5)}},{key:"shift+O",fn:Tb},{key:"shift+P",fn:gc},{key:[ga+"+",true],fn:function(){E(2)}},{key:[ga+"-",true],fn:function(){E(0.5)}},{key:["up",true],fn:function(){gb(0,-1)}},{key:["down",true],fn:function(){gb(0,1)}},{key:["left",true],fn:function(){gb(-1,0)}},{key:["right",true],fn:function(){gb(1,0)}},{key:"shift+up",fn:function(){gb(0,-10)}},{key:"shift+down",fn:function(){gb(0,10)}},{key:"shift+left",fn:function(){gb(-10,0)}},{key:"shift+right",fn:function(){gb(10,0)}},{key:["alt+up",
true],fn:function(){f.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){f.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){f.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){f.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){f.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){f.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){f.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",
true],fn:function(){f.cloneSelectedElements(10,0)}},{key:ga+"A",fn:function(){f.selectAllInCurrentLayer()}},{key:ga+"shift+z",fn:g},{key:"esc",fn:C}],A={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var I={};a.each(q,function(R,X){if(X.sel){var ja=a(X.sel);if(ja.length==0)return true;if(X.evt){if(svgedit.browser.isTouch()&&X.evt==="click")X.evt="mousedown";ja[X.evt](X.fn)}if(X.parent&&a(X.parent+"_show").length!=0){var va=a(X.parent);va.length||(va=Ga(X.parent.substr(1)));
va.append(ja);a.isArray(I[X.parent])||(I[X.parent]=[]);I[X.parent].push(X)}}if(X.key){var ya=X.fn,Da=false;if(a.isArray(X.key)){va=X.key[0];if(X.key.length>1)Da=X.key[1]}else va=X.key;va+="";svgedit.browser.isMac&&va.indexOf("+")!=-1&&va.split("+")[0]=="ctrl"&&va.replace("ctrl","cmd");a.each(va.split("/"),function(Ba,tb){a(document).bind("keydown",tb,function(Ta){ya();Da&&Ta.preventDefault();return false})});if(X.sel&&!X.hidekey&&ja.attr("title")){var Ca=ja.attr("title").split("[")[0]+" ("+va+")";
A[va]=X.sel;ja.parents("#main_menu").length||ja.attr("title",Ca)}}});Qa(I);a(".attr_changer, #image_url").bind("keydown","return",function(R){a(this).change();R.preventDefault()});a(window).bind("keydown","tab",function(R){if(U==="canvas"){R.preventDefault();gc()}}).bind("keydown","shift+tab",function(R){if(U==="canvas"){R.preventDefault();Tb()}});a("#tool_zoom").dblclick(K)},setTitles:function(){a.each(A,function(I,R){var X=a(R).parents("#main_menu").length;a(R).each(function(){var ja=X?a(this).text().split(" [")[0]:
this.title.split(" [")[0],va="";a.each(I.split("/"),function(ya,Da){var Ca=Da.split("+"),Ba="";if(Ca.length>1){Ba=Ca[0]+"+";Da=Ca[1]}va+=(ya?"/":"")+Ba+(e["key_"+Da]||Da)});if(X)this.lastChild.textContent=ja+" ["+va+"]";else this.title=ja+" ["+va+"]"})})},getButtonData:function(I){var R;a.each(q,function(X,ja){if(ja.sel===I)R=ja});return R}}}();oc.setAll();c.ready(function(){var q=d.initTool,A=a("#tools_left, #svg_editor .tools_flyout"),I=A.find("#tool_"+q);q=A.find("#"+q);(I.length?I:q.length?q:
a("#tool_select")).click().mouseup();d.wireframe&&a("#tool_wireframe").click();d.showlayers&&wc();a("#rulers").toggle(!!d.showRulers);if(d.showRulers)a("#show_rulers")[0].checked=true;if(d.gridSnapping)a("#grid_snapping_on")[0].checked=true;d.baseUnit&&a("#base_unit").val(d.baseUnit);d.snappingStep&&a("#grid_snapping_step").val(d.snappingStep)});a("#rect_rx").SpinButton({min:0,max:1E3,step:1,callback:function(q){f.setRectRadius(q.value)}});a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,
callback:function(q){var A=q.value;if(A==0&&Z&&["line","polyline"].indexOf(Z.nodeName)>=0)A=q.value=1;f.setStrokeWidth(A)}});a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(q){f.setRotationAngle(q.value);a("#tool_reorient").toggleClass("disabled",q.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(q,A){var I=q.value-0,R=I+A,X=R>=I;if(A===0)return I;return I>=24?X?Math.round(I*1.1):Math.round(I/1.1):I<=1?X?I*2:I/2:R},callback:function(q){f.setFontSize(q.value)}});
a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:xb});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:fb});a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(q,A){var I=q.value-0;if(I===0)return 100;var R=I+A;if(A===0)return I;return I>=100?R:R>=I?I*2:I/2},callback:ob}).val(f.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(q){switch(q){case "delete":Pa();break;case "cut":Xa();break;case "copy":hb();break;case "paste":f.pasteElements();
break;case "paste_in_place":f.pasteElements("in_place");break;case "group":f.groupSelectedElements();break;case "ungroup":f.ungroupSelectedElement();break;case "move_front":Db();break;case "move_up":Fb("Up");break;case "move_down":Fb("Down");break;case "move_back":cb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(q)&&svgedit.contextmenu.getCustomHandler(q).call()}f.clipBoard.length&&pa.enableContextMenuItems("#paste,#paste_in_place")});V=function(q){switch(q){case "dupe":M();
break;case "delete":T();break;case "merge_down":if(a("#layerlist tr.layersel").index()!=f.getCurrentDrawing().getNumLayers()-1){f.mergeLayer();Ja();Ab()}break;case "merge_all":f.mergeAllLayers();Ja();Ab()}};a("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},V);a("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:true},V);a(".contextMenu li").mousedown(function(q){q.preventDefault()});a("#cmenu_canvas li").disableContextMenu();pa.enableContextMenuItems("#delete,#cut,#copy");
window.onbeforeunload=function(){if(ha.getUndoStackSize()===0)c.show_save_warning=false;if(!d.no_save_warning&&c.show_save_warning)return e.notification.unsavedChanges};c.openPrep=function(q){a("#main_menu").hide();ha.getUndoStackSize()===0?q(true):a.confirm(e.notification.QwantToOpen,q)};if(window.FileReader){V=a('<input type="file">').change(function(){var q=this;c.openPrep(function(A){if(A){f.clear();if(q.files.length==1){A=new FileReader;A.onloadend=function(I){n(I.target.result);Rb()};A.readAsText(q.files[0])}}})});
a("#tool_open").show().prepend(V);V=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var q=new FileReader;q.onloadend=function(A){f.importSvgString(A.target.result,true);Rb()};q.readAsText(this.files[0])}});a("#tool_import").show().prepend(V)}var Rb=c.updateCanvas=function(q,A){var I=ra.width(),R=ra.height(),X=I,ja=R,va=f.getZoom(),ya=a("#svgcanvas"),Da={x:ra[0].scrollLeft+X/2,y:ra[0].scrollTop+ja/2},Ca=d.canvas_expansion;I=Math.max(X,f.contentW*va*Ca);R=
Math.max(ja,f.contentH*va*Ca);I==X&&R==ja?ra.css("overflow","hidden"):ra.css("overflow","scroll");Ca=ya.height()/2;var Ba=ya.width()/2;ya.width(I).height(R);var tb=R/2,Ta=I/2,ia=f.updateCanvas(I,R),wb=Ta/Ba;I=I/2-X/2;R=R/2-ja/2;if(A){A.x+=ia.x;A.y+=ia.y}else A={x:Ta+(Da.x-Ba)*wb,y:tb+(Da.y-Ca)*wb};if(q)if(f.contentW>ra.width()){ra[0].scrollLeft=ia.x-10;ra[0].scrollTop=ia.y-10}else{ra[0].scrollLeft=I;ra[0].scrollTop=R}else{ra[0].scrollLeft=A.x-X/2;ra[0].scrollTop=A.y-ja/2}if(d.showRulers){da(ya,va);
ra.scroll()}},hc=[];for(Bb=0.1;Bb<1E5;Bb*=10){hc.push(1*Bb);hc.push(2*Bb);hc.push(5*Bb)}Rb(true);try{var yc=function(q){if(window.JSON&&JSON.stringify)return JSON.stringify(q);var A=arguments.callee;if(typeof q=="boolean"||typeof q=="number")return q+"";else if(typeof q=="string")return'"'+q.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(X){return"\\u"+("0000"+X.charCodeAt(0).toString(16)).slice(-4)})+'"';
else if(q.length){for(var I=0;I<q.length;I++)q[I]=A(q[I]);return"["+q.join(",")+"]"}else{I=[];for(var R in q)I.push(A(R)+":"+A(q[R]));return"{"+I.join(",")+"}"}};window.addEventListener("message",function(q){var A=parseInt(q.data.substr(0,q.data.indexOf(";")));try{q.source.postMessage("SVGe"+A+";"+yc(eval(q.data)),"*")}catch(I){q.source.postMessage("SVGe"+A+";error:"+I.message,"*")}},false)}catch(zc){window.embed_error=zc}a(function(){window.svgCanvas=f;f.ready=svgEditor.ready});c.setLang=function(q,
A){a.pref("lang",q);a("#lang_select").val(q);if(A){var I=a("#layerlist tr.layersel td.layername").text()==e.common.layer+" 1";a.extend(e,A);f.setUiStrings(A);oc.setTitles();if(I){f.renameCurrentLayer(e.common.layer+" 1");Ab()}f.runExtensions("langChanged",q);Kb();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(R,X){a(X).attr("title",a(R)[0].title)});
a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var u=[];c.ready=function(w){m?w():u.push(w)};c.runCallbacks=function(){a.each(u,function(){this()});m=true};c.loadFromString=function(w){c.ready(function(){n(w)})};c.disableUI=function(){};c.loadFromURL=function(w,p){p||(p={});var L=p.cache,T=p.callback;c.ready(function(){a.ajax({url:w,dataType:"text",cache:!!L,success:function(M){n(M,T)},error:function(M,J,da){M.status!=404&&
M.responseText?n(M.responseText,T):a.alert(e.notification.URLloadFail+": \n"+da+"",T)}})})};c.loadFromDataURI=function(w){c.ready(function(){var p=w.substring(26);n(svgedit.utilities.decode64(p))})};c.addExtension=function(){var w=arguments;a(function(){f&&f.addExtension.apply(this,w)})};return c}(jQuery);$(svgEditor.init)})();svgedit=svgedit||{};
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var n=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var f=n.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+n.id+"'>"+n.label+"<span class='shortcut'>"+f+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
{}};svgedit.contextmenu.add=function(n){if(n&&n.id&&n.label&&n.action&&typeof n.action=="function")if(n.id in a.contextMenuExtensions)console.error('Cannot add extension "'+n.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+n.id+", label:"+n.label+"}");a.contextMenuExtensions[n.id]=n}else console.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function")};svgedit.contextmenu.hasCustomHandler=
function(n){return a.contextMenuExtensions[n]&&true};svgedit.contextmenu.getCustomHandler=function(n){return a.contextMenuExtensions[n].action}})();var svgEditor=function(a,n){function f(m,o,b){var d=a("#svg_editor").parent(),e;for(e in o){var l=o[e];l||console.log(e);if(b)e="#"+e;if(d.find(e).length){var u=d.find(e)[0];switch(m){case "content":for(var w=0;w<u.childNodes.length;w++){var p=u.childNodes[w];if(p.nodeType===3&&p.textContent.replace(/\s/g,"")){p.textContent=l;break}}break;case "title":u.title=l}}else console.log("Missing: "+e)}}var c;n.readLang=function(m){var o=n.canvas.runExtensions("addlangData",c,true);a.each(o,function(T,M){if(M.data)m=

View File

@ -874,10 +874,14 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
stroke: transparent !important;
}
#tools_top div[id$="_panel"]:not(#canvas_panel) {
.context_panel {
display: none;
}
#canvas_panel {
display: block;
}
#svg_editor #multiselected_panel .selected_tool {
vertical-align: 12px;
}

View File

@ -222,7 +222,7 @@ $(function(){
<div id="tools_top" class="tools_panel">
<div id="canvas_panel">
<div id="canvas_panel" class="context_panel">
<div class="toolset">
<h4>Canvas</h4>
@ -251,7 +251,7 @@ $(function(){
</div>
<div id="rect_panel">
<div id="rect_panel" class="context_panel">
<h4>Rectangle</h4>
<div class="toolset">
<label id="rect_width_tool" title="Change rectangle width">
@ -269,11 +269,11 @@ $(function(){
</label>
</div>
<div id="path_panel">
<div id="path_panel" class="context_panel">
<h4>Path</h4>
</div>
<div id="image_panel">
<div id="image_panel" class="context_panel">
<h4>Image</h4>
<div class="toolset">
<label><span class="icon_label">Width</span>
@ -294,7 +294,7 @@ $(function(){
</div>
</div>
<div id="circle_panel">
<div id="circle_panel" class="context_panel">
<div class="toolset">
<label id="tool_circle_cx"><span class="icon_label">cx:</span>
<input id="circle_cx" class="attr_changer" title="Change circle's cx coordinate" size="3" data-attr="cx" type="number"/>
@ -310,7 +310,7 @@ $(function(){
</div>
</div>
<div id="ellipse_panel">
<div id="ellipse_panel" class="context_panel">
<h4>Ellipse</h4>
<div class="toolset">
<label id="tool_ellipse_cx"><span>X</span>
@ -330,7 +330,7 @@ $(function(){
</div>
</div>
<div id="line_panel">
<div id="line_panel" class="context_panel">
<h4>Line</h4>
<div class="toolset">
<label id="tool_line_x1"><span>Start X</span>
@ -350,7 +350,7 @@ $(function(){
</div>
</div>
<div id="text_panel">
<div id="text_panel" class="context_panel">
<h4>Text</h4>
<div class="toolset" id="tool_font_family">
@ -390,7 +390,7 @@ $(function(){
</div>
<!-- formerly gsvg_panel -->
<div id="container_panel">
<div id="container_panel" class="context_panel">
<!-- Add viewBox field here? -->
@ -401,23 +401,23 @@ $(function(){
</label>
</div>
<div id="use_panel">
<div id="use_panel" class="context_panel">
<div class="push_button" id="tool_unlink_use" title="Break link to reference element (make unique)"></div>
</div>
<div id="g_panel">
<div id="g_panel" class="context_panel">
<h4>Group</h4>
</div>
<!-- For anchor elements -->
<div id="a_panel">
<div id="a_panel" class="context_panel">
<label id="tool_link_url" title="Set link URL (leave empty to remove)">
<span id="linkLabel" class="icon_label"></span>
<input id="link_url" type="text" size="35"/>
</label>
</div>
<div id="path_node_panel">
<div id="path_node_panel" class="context_panel">
<h4>Edit Path</h4>
<div class="tool_sep"></div>
<div class="tool_button push_button_pressed" id="tool_node_link" title="Link Control Points"><input type="checkbox" checked> Linked Control Points</div>
@ -441,7 +441,7 @@ $(function(){
</div>
<!-- Buttons when a single element is selected -->
<div id="selected_panel">
<div id="selected_panel" class="context_panel">
<label id="tool_angle" title="Change rotation angle" class="toolset">
<span class="icon_label">Rotation</span>
@ -532,7 +532,7 @@ $(function(){
</div>
</label>
</div>
<div id="xy_panel" class="toolset">
<div id="xy_panel" class="toolset" class="context_panel">
<h4>Position</h4>
<label>
<span>X:</span> <input id="selected_x" class="attr_changer" title="Change X coordinate" size="3" data-attr="x" type="number"/>
@ -544,7 +544,7 @@ $(function(){
</div>
<!-- Buttons when multiple elements are selected -->
<div id="multiselected_panel">
<div id="multiselected_panel" class="context_panel">
<h4>Multiple Elements</h4>
<!--<div class="tool_sep"></div> -->
<!--<div class="push_button" id="tool_clone_multi" title="Clone Elements [C]"></div> -->

View File

@ -1039,7 +1039,7 @@
// create the panel if it doesn't exist
if(!panel.length)
panel = $('<div>', {id: tool.panel}).appendTo("#tools_top");
panel = $('<div>', {id: tool.panel}).appendTo("#tools_top").hide();
// TODO: Allow support for other types, or adding to existing tool
switch (tool.type) {
@ -1409,7 +1409,7 @@
"stroke": "none",
"id": "canvas_background",
"opacity": 1,
"fill": fill || $.pref('bkgd_color'),
"fill": fill || "#fff",
"style": "pointer-events:none"
}
});
@ -1419,16 +1419,7 @@
// create a new layer background if it doesn't exist
if (!document.getElementById('canvas_background')) createBackground();
else {
var fill = document.getElementById('canvas_background').getAttribute("fill");
}
if($.pref('bkgd_color')) {
setBackground($.pref('bkgd_color'), $.pref('bkgd_url'));
} else if($.pref('bkgd_url')) {
// No color set, only URL
setBackground(defaultPrefs.bkgd_color, $.pref('bkgd_url'));
}
var fill = document.getElementById('canvas_background').getAttribute("fill");
// updates the toolbar (colors, opacity, etc) based on the selected element
// This function also updates the opacity and id elements that are in the context panel
@ -3525,7 +3516,7 @@
var PaintBox = function(container, type) {
var background = document.getElementById("canvas_background");
var cur = {color: "#fff", opacity: 1}
var cur = {color: "fff", opacity: 1}
if (type == "stroke") cur = curConfig['initStroke'];
if (type == "fill") cur = curConfig['initFill'];
if (type == "canvas" && background) {
@ -3538,7 +3529,6 @@
}
}
// set up gradients to be used for the buttons
var svgdocbox = new DOMParser().parseFromString(
'<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\

File diff suppressed because one or more lines are too long

View File

@ -406,116 +406,116 @@ q/2,y:A.y*q+A.height*q/2});f.getMode()=="zoom"&&A.width&&oa();B()}}};a("#cur_con
a(this).mouseup(Ca);Ba.key&&a(document).bind("keydown",Ba.key[0]+" shift+"+Ba.key[0],Ca)});if(va)ja.attr("data-curopt",I[va].sel);else ja.attr("data-curopt")||ja.attr("data-curopt",I[0].sel);var ya,Da=a(X).position();a(A).css({left:Da.left+34,top:Da.top+77});ja.mousedown(function(Ca){a("#tools_shapelib").is(":visible")&&xa(X,false);if(ja.hasClass("disabled"))return false;var Ba=a(A),tb=Da.left+34,Ta=Ba.width()*-1,ia=Ba.data("shown_popop")?200:0;ya=setTimeout(function(){ja.data("isLibrary")?Ba.css("left",
tb).show():Ba.css("left",Ta).show().animate({left:tb},150);Ba.data("shown_popop",true)},ia);Ca.preventDefault()}).mouseup(function(){clearTimeout(ya);var Ca=a(this).attr("data-curopt");if(ja.data("isLibrary")&&a(X.replace("_show","")).is(":visible"))xa(X,true);else xa(X)&&Ca in Ia&&Ia[Ca]()})});Kb()},Ga=function(q,A){return a("<div>",{"class":"tools_flyout",id:q}).appendTo("#svg_editor").append(A)},Cb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show"),A=q.offset();q=q.outerWidth();
a(this).css({left:(A.left+q)*S,top:A.top})})},Kb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show");if(!q.data("isLibrary")){var A=[];a(this).children().each(function(){A.push(this.title)});q[0].title=A.join(" / ")}})},nb,ab=function(q,A,I){var R=null;if(q.indexOf("url(#")===0){q=(q=f.getRefElem(q))?q.cloneNode(true):a("#"+I+"_color defs *")[0];R={alpha:A};R[q.tagName]=q}else R=q.indexOf("#")===0?{alpha:A,solidColor:q.substr(1)}:{alpha:A,solidColor:"none"};return new a.jGraduate.Paint(R)},
Ya=f.getResolution();if(d.baseUnit!=="px"){Ya.w=svgedit.units.convertUnit(Ya.w)+d.baseUnit;Ya.h=svgedit.units.convertUnit(Ya.h)+d.baseUnit}a(".canvas_width").val(Ya.w);a(".canvas_height").val(Ya.h);a("#docprops_button").on("click",function(){H()});var La=function(q){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ya.w+2,height:Ya.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:q||a.pref("bkgd_color"),style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");
f.setCurrentLayerPosition("1")};document.getElementById("canvas_background")?document.getElementById("canvas_background").getAttribute("fill"):La();if(a.pref("bkgd_color"))p(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&p(o.bkgd_color,a.pref("bkgd_url"));var Ea=c.setImageURL=function(q){q||(q=ea);f.setImageURL(q);a("#image_url").val(q);if(q.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{f.embedImage(q,function(A){A?a("#url_notice").hide():a("#url_notice").show();
ea=q});a("#image_url").show();a("#change_image_url").hide()}},qb=function(q){var A=Math.min(Math.max(12+q.value.length*6,50),300);a(q).width(A)},Ja=function(){var q=Z;if(q!=null&&!q.parentNode)q=null;var A=f.getCurrentDrawing().getCurrentLayerName(),I=f.getMode(),R=d.baseUnit!=="px"?d.baseUnit:null,X=I=="pathedit",ja=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #path_panel, #rect_panel, #canvas_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();
a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");!q&&!Aa&&a("#canvas_panel").show();if(q!=null){var va=q.nodeName,ya=f.getRotationAngle(q);a("#angle").val(Math.round(ya));ya=f.getBlur(q);a("#blur").val(ya);a("#blur_slider").slider("option","value",ya);f.addedNew&&va==="image"&&f.getHref(q).indexOf("data:")!==0&&L();if(!X&&I!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(va)>=
0)a("#xy_panel").hide();else{var Da,Ca;if(["g","polyline","path"].indexOf(va)>=0){if(I=f.getStrokedBBox([q])){Da=I.x;Ca=I.y}}else{Da=q.getAttribute("x");Ca=q.getAttribute("y")}if(R){Da=svgedit.units.convertUnit(Da);Ca=svgedit.units.convertUnit(Ca)}a("#selected_x").val(Math.round(Ca)||0);a("#selected_y").val(Math.round(Da)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(va)==-1&&a(".action_path_convert_selected").removeClass("disabled");va==="path"&&a(".action_path_selected").removeClass("disabled")}else{A=
ta.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!ta.canDeleteNodes);fa("#tool_openclose_path",ta.closed_subpath?"open_path":"close_path");if(A){X=a("#seg_type");if(R){A.x=svgedit.units.convertUnit(A.x);A.y=svgedit.units.convertUnit(A.y)}a("#path_node_x").val(Math.round(A.x));a("#path_node_y").val(Math.round(A.y));A.type?X.val(A.type).removeAttr("disabled"):X.val(4).attr("disabled","disabled")}return}R=
{g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]};var Ba=q.tagName;a(q).data("gsvg")&&a("#g_panel").show();Ba=="path"&&a("#path_panel").show();if(R[Ba]){R=R[Ba];a("#"+Ba+"_panel").show();a.each(R,function(tb,Ta){var ia=q.getAttribute(Ta);if(d.baseUnit!=="px"&&q[Ta])ia=svgedit.units.convertUnit(q[Ta].baseVal.value);a("#"+Ba+"_"+Ta).val(Math.round(ia)||0)});if(Ba=="text"){a("#text_panel").css("display",
"inline");f.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");f.getBold()?a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(q.getAttribute("font-family"));a("#font_size").val(q.getAttribute("font-size"));a("#text").val(q.textContent);f.addedNew&&setTimeout(function(){a("#text").focus().select()},
100)}else if(Ba=="image")Ea(f.getHref(q));else if(Ba==="g"||Ba==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");R=f.getTitle();va=a("#g_title")[0];va.value=R;qb(va);Ba=="use"?va.setAttribute("disabled","disabled"):va.removeAttribute("disabled")}}ja[(Ba==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");ja[(Ba==="g"||!Aa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(Aa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");
ja.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else ja.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");ha.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");ha.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");f.addedNew=false;if(q&&!X||Aa){a("#selLayerNames").removeAttr("disabled").val(A);pa.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else a("#selLayerNames").attr("disabled",
"disabled")};a("#text").focus(function(){});a("#text").blur(function(){});f.bind("selected",function(q,A){var I=f.getMode();I==="select"&&oa();I=I=="pathedit";Z=A.length==1||A[1]==null?A[0]:null;Aa=A.length>=2&&A[1]!=null;if(Z!=null)if(!I){if(Z!=null)switch(Z.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var R=null,X=Z.getElementsByTagName("*"),ja=0,va=X.length;ja<va;ja++){var ya=X[ja].getAttribute("stroke-width");if(ja===0)R=ya;else if(R!==ya)R=null}a("#stroke_width").val(R===
null?"":R);la.fill.update(true);la.stroke.update(true);break;default:la.fill.update(true);la.stroke.update(true);a("#stroke_width").val(Z.getAttribute("stroke-width")||1);a("#stroke_style").val(Z.getAttribute("stroke-dasharray")||"none");R=Z.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+R).length!=0&&w(a("#linejoin_"+R)[0]);R=Z.getAttribute("stroke-linecap")||"butt";a("#linecap_"+R).length!=0&&w(a("#linecap_"+R)[0])}if(Z!=null){R=(Z.getAttribute("opacity")||1)*100;a("#group_opacity").val(R);
a("#opac_slider").slider("option","value",R);a("#elem_id").val(Z.id)}}a("#path_node_panel").toggle(I);a("#tools_bottom_2,#tools_bottom_3").toggle(!I);if(I){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");fa("#tool_select","select_node");Aa=false;if(A.length)Z=A[0]}else{if(A[0]){I=f.selectorManager.requestSelector(A[0]);I.reset(A[0]);I.selectorRect.setAttribute("display","inline")}fa("#tool_select",
"select")}Ja();f.runExtensions("selectedChanged",{elems:A,selectedElement:Z,multiselected:Aa})});f.bind("transition",function(q,A){var I=f.getMode(),R=A[0];if(R){Aa=A.length>=2&&A[1]!=null;if(!Aa)switch(I){case "rotate":I=f.getRotationAngle(R);a("#angle").val(Math.round(I));a("#tool_reorient").toggleClass("disabled",I==0)}f.runExtensions("elementTransition",{elems:A})}});f.bind("changed",function(q,A){var I=f.getMode();I==="select"&&oa();for(var R=0;R<A.length;++R){var X=A[R];if(X&&X.tagName==="svg"){Ab();
Rb()}else if(X&&Z&&Z.parentNode==null)Z=X}c.show_save_warning=true;Ja();if(Z&&I==="select"){la.fill.update();la.stroke.update()}f.runExtensions("elementChanged",{elems:A})});f.bind("saved",function(q,A){c.show_save_warning=false;A='<?xml version="1.0"?>\n'+A;var I=navigator.userAgent;if(~I.indexOf("Chrome")&&a.browser.version>=533||~I.indexOf("MSIE"))D(0,true);else{var R=q.open("data:image/svg+xml;base64,"+ca.encode64(A)),X=a.pref("save_notice_done");if(X!=="all"){var ja=e.notification.saveFromBrowser.replace("%s",
"SVG");if(I.indexOf("Gecko/")!==-1)if(A.indexOf("<defs")!==-1){ja+="\n\n"+e.notification.defsFailOnSave;a.pref("save_notice_done","all");X="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");X!=="part"&&R.alert(ja)}}});f.bind("exported",function(q,A){var I=A.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var R=a("#export_canvas")[0];R.width=f.contentW;R.height=f.contentH;canvg(R,A.svg,{renderCallback:function(){var X=R.toDataURL("image/png");
ba.location.href=X;if(a.pref("export_notice_done")!=="all"){X=e.notification.saveFromBrowser.replace("%s","PNG");if(I.length)X+="\n\n"+e.notification.noteTheseIssues+"\n \u2022 "+I.join("\n \u2022 ");a.pref("export_notice_done","all");ba.alert(X)}}})});f.bind("zoomed",Oa);f.bind("contextset",function(q,A){var I="";if(A){var R="";I='<a href="#" data-root="y">'+f.getCurrentDrawing().getCurrentLayerName()+"</a>";a(A).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){R+=" > "+this.id;
I+=this!==A?' > <a href="#">'+this.id+"</a>":" > "+this.id}});Sa=R}else Sa=null;a("#cur_context_panel").toggle(!!A).html(I);W()});f.bind("extension_added",function(q,A){function I(){if(nb){clearTimeout(nb);nb=null}X||(nb=setTimeout(function(){X=true;za(b.iconsize)},50))}var R=false,X=false,ja=true,va=function(){if(A.callback&&!R&&ja){R=true;A.callback()}},ya=[];A.context_tools&&a.each(A.context_tools,function(Ta,ia){var wb=ia.container_id?' id="'+ia.container_id+'"':"",bb=a("#"+ia.panel);bb.length||
(bb=a("<div>",{id:ia.panel}).appendTo("#tools_top"));switch(ia.type){case "tool_button":var Fa='<div class="tool_button">'+ia.id+"</div>",Va=a(Fa).appendTo(bb);ia.events&&a.each(ia.events,function(eb,lb){a(Va).bind(eb,lb)});break;case "select":Fa="<label"+wb+'><select id="'+ia.id+'">';a.each(ia.options,function(eb,lb){Fa+='<option value="'+eb+'"'+(eb==ia.defval?" selected":"")+">"+lb+"</option>"});Fa+="</select></label>";var Ha=a(Fa).appendTo(bb).find("select");a.each(ia.events,function(eb,lb){a(Ha).bind(eb,
lb)});break;case "button-select":Fa='<div id="'+ia.id+'" class="dropdown toolset" title="'+ia.title+'"><div id="cur_'+ia.id+'" class="icon_label"></div><button></button></div>';wb=a('<ul id="'+ia.id+'_opts"></ul>').appendTo("#option_lists");ia.colnum&&wb.addClass("optcols"+ia.colnum);a(Fa).appendTo(bb).children();ya.push({elem:"#"+ia.id,list:"#"+ia.id+"_opts",title:ia.title,callback:ia.events.change,cur:"#cur_"+ia.id});break;case "input":Fa="<label"+wb+'><span id="'+ia.id+'_label">'+ia.label+':</span><input id="'+
ia.id+'" title="'+ia.title+'" size="'+(ia.size||"4")+'" value="'+(ia.defval||"")+'" type="text"/></label>';var kb=a(Fa).appendTo(bb).find("input");ia.spindata&&kb.SpinButton(ia.spindata);ia.events&&a.each(ia.events,function(eb,lb){kb.bind(eb,lb)})}});if(A.buttons){var Da={},Ca={},Ba=A.svgicons,tb={};a.each(A.buttons,function(Ta,ia){for(var wb,bb=ia.id,Fa=Ta;a("#"+bb).length;)bb=ia.id+"_"+ ++Fa;if(Ba){Da[bb]=ia.icon;Fa=ia.svgicon?ia.svgicon:ia.id;if(ia.type=="app_menu")Ca["#"+bb+" > div"]=Fa;else Ca["#"+
bb]=Fa}else wb=ia.type=="menu"?"":a('<img src="'+ia.icon+'">');var Va,Ha;switch(ia.type){case "mode_flyout":case "mode":Va="tool_button";if(ia.cls)Va+=" "+ia.cls;Ha="#tools_left";break;case "context":Va="tool_button";Ha="#"+ia.panel;a(Ha).length||a("<div>",{id:ia.panel}).appendTo("#tools_top");break;case "menu":Va="menu_item tool_button";Ha="#"+(ia.after||ia.panel);break;case "app_menu":Va="";Ha=ia.parent||"#main_menu ul";a(Ha).length||a("<div>",{id:ia.panel}).appendTo("#tools_top")}var kb=a(ia.list||
ia.type=="app_menu"?"<li/>":"<div/>").attr("id",bb).attr("title",ia.title).addClass(Va);if(!ia.includeWith&&!ia.list){if("position"in ia)a(Ha).children().eq(ia.position).before(kb);else ia.type!="menu"||!ia.after?kb.appendTo(Ha):a(Ha).after(kb);if(ia.type=="mode_flyout"){Fa=a(kb);Va=Fa.parent();if(!Fa.parent().hasClass("tools_flyout")){var eb=Fa[0].id.replace("tool_","tools_"),lb=Fa.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Fa.before(lb);Va=Ga(eb,Fa);Va.data("isLibrary",
true);lb.data("isLibrary",true)}Ca["#"+eb+"_show"]=ia.id;bb=tb["#"+Va[0].id]=[{sel:"#"+bb,fn:ia.events.click,icon:ia.id,isDefault:true},Yb]}else if(ia.type=="app_menu"||ia.type=="menu")kb.append(ia.title)}else if(ia.list){kb.addClass("push_button");a("#"+ia.list+"_opts").append(kb);if(ia.isDefault){a("#cur_"+ia.list).append(kb.children().clone());Fa=ia.svgicon?ia.svgicon:ia.id;Ca["#cur_"+ia.list]=Fa}}else if(ia.includeWith){Ha=ia.includeWith;Fa=a(Ha.button);Va=Fa.parent();if(!Fa.parent().hasClass("tools_flyout")){eb=
Fa[0].id.replace("tool_","tools_");lb=Fa.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Fa.before(lb);Va=Ga(eb,Fa)}var Yb=oc.getButtonData(Ha.button);if(Ha.isDefault)Ca["#"+eb+"_show"]=ia.id;bb=tb["#"+Va[0].id]=[{sel:"#"+bb,fn:ia.events.click,icon:ia.id,key:ia.key,isDefault:ia.includeWith?ia.includeWith.isDefault:0},Yb];eb="position"in Ha?Ha.position:"last";Yb=Va.children().length;if(!isNaN(eb)&&eb>=0&&eb<Yb)Va.children().eq(eb).before(kb);else{Va.append(kb);bb.reverse()}}Ba||
kb.append(wb);ia.list||a.each(ia.events,function(Jb,Xb){if(Jb=="click")if(ia.type=="mode"){ia.includeWith?kb.bind(Jb,Xb):kb.bind(Jb,function(){xa(kb)&&Xb()});if(ia.key){a(document).bind("keydown",ia.key,Xb);ia.title&&kb.attr("title",ia.title+" ["+ia.key+"]")}}else kb.bind(Jb,Xb);else kb.bind(Jb,Xb)});Qa(tb)});a.each(ya,function(){sb(this.elem,this.list,this.callback,{seticon:true})});if(Ba)ja=false;a.svgIcons(Ba,{w:27,h:27,id_match:false,no_img:!O,fallback:Da,placement:Ca,callback:function(){b.iconsize&&
b.iconsize!="m"&&I();ja=true;va()}})}va()});f.textActions.setInputElem(a("#text")[0]);var Za='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4",
"#aaffff","#aad4ff"],function(q,A){Za+='<div class="palette_item" style="background-color: '+A+';" data-rgb="'+A+'"></div>'});a("#palette").append(Za);Za="";a.each(["#FFF","#888","#000"],function(){Za+='<div class="color_block" style="background-color:'+this+';"></div>'});a("#bg_blocks").append(Za);var Ma=a("#bg_blocks div");Ma.each(function(){a(this).click(function(){Ma.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))p(a.pref("bkgd_color"),a.pref("bkgd_url"));
else a.pref("bkgd_url")&&p(o.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){b.img_save=a.pref("img_save");a("#image_save_opts input").val([b.img_save])}var ob=function(q){var A=q.value/100;if(A<0.0010)q.value=0.1;else{q=f.getZoom();Oa(window,{width:0,height:0,x:(ra[0].scrollLeft+ra.width()/2)/q,y:(ra[0].scrollTop+ra.height()/2)/q,zoom:A},true)}},xb=function(q,A){if(A==null)A=q.value;a("#group_opacity").val(A);if(!q||!q.handle)a("#opac_slider").slider("option","value",A);f.setOpacity(A/100)},
fb=function(q,A,I){if(A==null)A=q.value;a("#blur").val(A);var R=false;if(!q||!q.handle){a("#blur_slider").slider("option","value",A);R=true}I?f.setBlurNoUndo(A):f.setBlur(A,R)},ib=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){f.setStrokeAttr("stroke-dasharray",a(this).val());ib()});a("#stroke_linejoin").change(function(){f.setStrokeAttr("stroke-linejoin",a(this).val());ib()});a("select").change(function(){a(this).blur()});var Lb=false;a("#selLayerNames").change(function(){var q=
this.options[this.selectedIndex].value,A=e.notification.QmoveElemsToLayer.replace("%s",q),I=function(R){if(R){Lb=true;f.moveSelectedToLayer(q);f.clearSelection();Ab()}};if(q)Lb?I(true):a.confirm(A,I)});a("#font_family").change(function(){f.setFontFamily(this.value)});a("#seg_type").change(function(){f.setSegType(a(this).val())});a("#text").keyup(function(){f.setTextContent(this.value)});a("#image_url").change(function(){Ea(this.value)});a("#link_url").change(function(){this.value.length?f.setLinkURL(this.value):
f.removeHyperlink()});a("#g_title").change(function(){f.setGroupTitle(this.value)});a(".attr_changer").change(function(){var q=this.getAttribute("data-attr"),A=this.value;if(svgedit.units.isValidUnit(q,A,Z))this.blur();else{a.alert(e.notification.invalidAttrValGiven);this.value=Z.getAttribute(q);return false}if(q!=="id")if(isNaN(A))A=f.convertToNum(q,A);else if(d.baseUnit!=="px"){var I=svgedit.units.getTypeMap();if(Z[q]||f.getMode()==="pathedit"||q==="x"||q==="y")A*=I[d.baseUnit]}if(q==="id"){q=Z;
f.clearSelection();q.id=A;f.addToSelection([q],true)}else f.changeSelectedAttribute(q,A);this.blur()});a("#palette").mouseover(function(){var q=a('<input type="hidden">');a(this).append(q);q.focus().remove()});a(".palette_item").mousedown(function(){var q=a("#tool_stroke").hasClass("active"),A=q?"stroke":"fill",I=a(this).attr("data-rgb"),R=null;if(I==="transparent"||I==="initial"||I==="#none"){I="none";R=new a.jGraduate.Paint}else R=new a.jGraduate.Paint({alpha:100,solidColor:I.substr(1)});la[A].setPaint(R);
if(q){f.setColor("stroke",I);I!="none"&&f.getStrokeOpacity()!=1&&f.setPaintOpacity("stroke",1)}else{f.setColor("fill",I);I!="none"&&f.getFillOpacity()!=1&&f.setPaintOpacity("fill",1)}}).bind("contextmenu",function(q){q.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");Ub()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Ub()});var xa=function(q,A){if(a(q).hasClass("disabled"))return false;
if(a(q).parent().hasClass("tools_flyout"))return true;var I=I||"normal";A||a(".tools_flyout").fadeOut(I);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(q).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var q=null,A=null,I=ra[0],R=false,X=false;a("#svgcanvas").bind("mousemove mouseup",function(ja){if(R!==false){I.scrollLeft-=ja.clientX-q;I.scrollTop-=ja.clientY-A;q=ja.clientX;A=ja.clientY;if(ja.type===
"mouseup")R=false;return false}}).mousedown(function(ja){if(ja.button===1||X===true){R=true;q=ja.clientX;A=ja.clientY;return false}});a(window).mouseup(function(){R=false});a(document).bind("keydown","space",function(ja){f.spaceKey=X=true;ja.preventDefault()}).bind("keyup","space",function(ja){ja.preventDefault();f.spaceKey=X=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&ra.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&ra.removeClass("out")})})();var ub=a(".menu"),
rb=function(q){q.target.style.background="#fff";setTimeout(function(){q.target.style.background="#ddd"},50);setTimeout(function(){q.target.style.background="#fff"},150);setTimeout(function(){q.target.style.background="#ddd"},200);setTimeout(function(){q.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").live("click",function(q){rb(q)});a("svg, body").on("mousedown",function(q){top!=self&&!q.isTrigger&&typeof top.exports.setEditorFocus==
"function"&&top.exports.setEditorFocus();if(!a(q.target).hasClass("menu_title"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))rb(q);else{a("#menu_bar").removeClass("active");a("#tools_shapelib").is(":visible")&&!a(q.target).parents("#tools_shapelib_show, #tools_shapelib").length&&a("#tools_shapelib").hide();q.target.nodeName.toLowerCase()!="input"&&a("input").blur()}});var yb=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(q,A,
I,R){if(q.altKey){q.preventDefault();q=f.getZoom()*100;A=yb.length;for(Bb=0;Bb<A;Bb++){I=Math.min(A,Bb+1);if(R>0)zoom=yb[Bb]<=q?yb[I]:zoom;if(R<0)zoom=yb[Bb]<q?yb[Bb]:zoom}zoom&&ob({value:zoom})}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",function(){ub.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,A,I){if(a(q).length!=0){var R=a(q).find("button"),X=a(q).find("ul").attr("id",a(q)[0].id+"-list");
I||a("#option_lists").append(X);var ja=false;I&&a(q).addClass("dropup");X.find("li").bind("mouseup",A);a(window).mouseup(function(){if(!ja){R.removeClass("down");X.hide()}ja=false});R.bind("mousedown",function(){if(R.hasClass("down")){R.removeClass("down");X.hide()}else{R.addClass("down");if(!I){var va=a(q).offset();X.css({top:va.top,left:va.left-110})}X.show();ja=true}}).hover(function(){ja=true}).mouseout(function(){ja=false})}};var sb=function(q,A,I,R){var X=a(q);A=a(A);var ja=false,va=R.dropUp;
va&&a(q).addClass("dropup");A.find("li").bind("mouseup",function(){if(R.seticon){fa("#cur_"+X[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}I.apply(this,arguments)});a(window).mouseup(function(){if(!ja){X.removeClass("down");A.hide();A.css({top:0,left:0})}ja=false});A.height();a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=A.height();ya.left+=8}else ya.top+=a(q).height();a(A).offset(ya);if(X.hasClass("down")){X.removeClass("down");A.hide();
A.css({top:0,left:0})}else{X.addClass("down");A.show();ja=true;return false}}).hover(function(){ja=true}).mouseout(function(){ja=false});R.multiclick&&A.mousedown(function(){ja=true})};c.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});c.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var q=parseInt(a(this).text().split("%")[0]);xb(false,q)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},
stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(q,A){xb(A)}});c.addDropDown("#blur_dropdown",a.noop);var mb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(q,A){mb=false;fb(A);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){mb=true},slide:function(q,A){fb(A,null,mb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),A=q.attr("data-val");A?Oa(window,A):ob({value:parseInt(q.text())})},true);sb("#stroke_linecap","#linecap_opts",
function(){w(this,true)},{dropUp:true});sb("#stroke_linejoin","#linejoin_opts",function(){w(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,"page")})});(function(){var q,A=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=this;U="toolbars";ra.mousedown(A)}).blur(function(){U="canvas";ra.unbind("mousedown",A);f.getMode()==
"textedit"&&a("#text").focus()})})();var Gb=function(){if(xa("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},Hb=function(){xa("#tool_fhpath")&&f.setMode("fhpath")},Mb=function(){xa("#tool_line")&&f.setMode("line")},Nb=function(){xa("#tool_rect")&&f.setMode("rect")},ma=function(){xa("#tool_ellipse")&&f.setMode("ellipse")},Y=function(){xa("#tool_image")&&f.setMode("image")},na=function(){xa("#tool_zoom")&&
f.setMode("zoom")},K=function(){if(xa("#tool_zoom")){E();oa()}},N=function(){xa("#tool_text")&&f.setMode("text")},aa=function(){xa("#tool_path")&&f.setMode("path")},Pa=function(){if(Z!=null||Aa)f.deleteSelectedElements()},Xa=function(){if(Z!=null||Aa){window.event.type==="keydown"&&db(a("#edit_menu"));f.cutSelectedElements()}},hb=function(){if(Z!=null||Aa){window.event.type==="keydown"&&db(a("#edit_menu"));f.copySelectedElements()}},pb=function(){window.event.type==="keydown"&&db(a("#edit_menu"));
var q=f.getZoom(),A=(ra[0].scrollLeft+ra.width()/2)/q-f.contentW;q=(ra[0].scrollTop+ra.height()/2)/q-f.contentH;f.pasteElements("point",A,q)},Db=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveToTopSelectedElement()}},cb=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveToBottomSelectedElement()}},Eb=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected("Up")}},$a=function(){if(Z!=null){window.event.type===
"keydown"&&db(a("#object_menu"));f.moveUpDownSelected("Down")}},Fb=function(q){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected(q)}},Pb=function(){if(Z!=null){f.convertToPath();elems=f.getSelectedElems();f.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");f.setMode("pathedit");ta.toEditMode(elems[0]);f.clearSelection()}},$b=function(){Z!=null&&ta.reorient()},Zb=function(){if(Z!=null||Aa)a.prompt(e.notification.enterNewLinkURL,
"http://",function(q){q&&f.makeHyperlink(q)})},gb=function(q,A){if(Z!=null||Aa){if(d.gridSnapping){var I=f.getZoom()*d.snappingStep;q*=I;A*=I}a("input").blur();f.moveSelectedElements(q,A)}},Ua=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");q?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",false);ta.linkControlPoints(q)},
ic=function(){ta.getNodePoint()&&ta.clonePathNode()},ec=function(){ta.getNodePoint()&&ta.deletePathNode()},cc=function(){var q=a("#tool_add_subpath"),A=!q.hasClass("push_button_pressed");A?q.addClass("push_button_pressed").removeClass("tool_button"):q.removeClass("push_button_pressed").addClass("tool_button");ta.addSubPath(A)},fc=function(){ta.opencloseSubPath()},gc=function(){f.cycleElement(1)},Tb=function(){f.cycleElement(0)},Sb=function(q,A){if(!(Z==null||Aa)){q||(A*=-1);var I=a("#angle").val()*
1+A;f.setRotationAngle(I);Ja()}},mc=function(){var q=d.dimensions;a.confirm(e.notification.QwantToClear,function(A){if(A){oa();f.clear();f.setResolution(q[0],q[1]);Rb(true);E();Ab();Ja();la.fill.prep();la.stroke.prep();f.runExtensions("onNewDocument")}})},Vb=function(){f.setBold(!f.getBold());Ja();return false},vb=function(){f.setItalic(!f.getItalic());Ja();return false},kc=function(){if(!l.pngsave){var q=e.notification.loadingImage;ba=window.open("data:text/html;charset=utf-8,<title>"+q+"</title><h1>"+
q+"</h1>")}window.canvg?f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},jc=function(){f.open()},Wb=function(){},db=function(q){var A=q.prev();A.css("background","#09f");setTimeout(function(){A.css("background","")},200)},dc=function(){if(ha.getUndoStackSize()>0){window.event.type==="keydown"&&db(a("#edit_menu"));ha.undo();Ab()}},g=function(){if(ha.getRedoStackSize()>0){window.event.type==="keydown"&&db(a("#edit_menu"));ha.redo();
Ab()}},h=function(){if(Aa)f.groupSelectedElements();else Z&&f.ungroupSelectedElement()},k=function(){window.event.type==="keydown"&&db(a("#edit_menu"));f.cloneSelectedElements(20,20)},v=function(){var q=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(q,a("#align_relative_to").val())},s=function(){var q=document.querySelector("#tool_stroke rect"),A=document.querySelector("#tool_fill rect"),I=A.getAttribute("fill"),R=q.getAttribute("fill");q=parseFloat(q.getAttribute("stroke-opacity"));
if(isNaN(q))q=100;A=parseFloat(A.getAttribute("fill-opacity"));if(isNaN(A))A=100;R=ab(R,q,"stroke");I=ab(I,A,"fill");la.fill.setPaint(R,true);la.stroke.setPaint(I,true)},E=function(q){var A=f.getResolution();q=q?A.zoom*q:1;a("#zoom").val(q*100);f.setZoom(q);B();Rb(true)},z=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");ra.toggleClass("wireframe");if(!tc){var q=a("#wireframe_rules");
q.length?q.empty():a('<style id="wireframe_rules"></style>').appendTo("head");B()}},t=function(){f.clearSelection();a("#tool_canvas").trigger("click")},C=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},F=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);d.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);d.showRulers=
true}a("#rulers").toggle(!!d.showRulers)},B=function(){if(!tc){var q="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+"px; }";a("#wireframe_rules").text(ra.hasClass("wireframe")?q:"")}},D=function(q,A){if(!Ka){Ka=true;a("#save_output_btns").toggle(!!A);a("#tool_source_back").toggle(!A);var I=sa=f.getSvgString();a("#svg_source_textarea").val(I);a("#svg_source_editor").fadeIn();P();a("#svg_source_textarea").focus()}},H=function(){if(!Ra){Ra=true;a("#image_save_opts input").val([b.img_save]);
var q=f.getResolution();if(d.baseUnit!=="px"){q.w=svgedit.units.convertUnit(q.w)+d.baseUnit;q.h=svgedit.units.convertUnit(q.h)+d.baseUnit}a(".canvas_width").val(q.w);a(".canvas_height").val(q.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},G=function(){if(!Na){Na=true;var q=a("#bg_blocks div"),A=a.pref("bkgd_color"),I=a.pref("bkgd_url");q.each(function(){var R=a(this),X=R.css("background-color")==A;R.toggleClass("cur_background",X);X&&a("#canvas_bg_url").removeClass("cur_background")});
A||q.eq(0).addClass("cur_background");I&&a("#canvas_bg_url").val(I);a("grid_snapping_step").attr("value",d.snappingStep);d.gridSnapping==true?a("#grid_snapping_on").attr("checked","checked"):a("#grid_snapping_on").removeAttr("checked");a("#svg_prefs").show()}},P=function(){var q=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",q)},Q=function(){if(Ka){var q=function(){f.clearSelection();zb();E();Ab();W();la.fill.prep();la.stroke.prep()};f.setSvgString(a("#svg_source_textarea").val())?
q():a.confirm(e.notification.QerrorsRevertToSource,function(A){if(!A)return false;q()});oa()}},W=function(q){q=q||f.getDocumentTitle();q=Wa+(q?": "+q:"");a("title:first").text(q)},ua=function(){var q=a("#canvas_width"),A=q.val(),I=a("#canvas_height"),R=I.val();if(A!="fit"&&!svgedit.units.isValidUnit("width",A)){a.alert(e.notification.invalidAttrValGiven);q.parent().addClass("error");return false}q.parent().removeClass("error");if(R!="fit"&&!svgedit.units.isValidUnit("height",R)){a.alert(e.notification.invalidAttrValGiven);
I.parent().addClass("error");return false}I.parent().removeClass("error");if(!f.setResolution(A,R)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Rb();Qb()},wa=function(){var q=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";p(q,a("#canvas_bg_url").val());q=a("#lang_select").val();q!=b.lang&&c.putLocale(q);za(a("#iconsize").val());d.gridSnapping=a("#grid_snapping_on")[0].checked;d.snappingStep=
a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);d.showRulers&&da();d.baseUnit=a("#base_unit").val();f.setConfig(d);Rb();Ib()},fa=c.setIcon=function(q,A){var I=typeof A==="string"?a.getSvgIcon(A,true):A.clone();I?a(q).find("img").replaceWith(I):console.log("NOTE: Icon image missing: "+A)},ka;ka=function(){var q=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,A=document.getElementsByTagName("script")[0],I;for(I in A.style)if(q.test(I))return I.match(q)[0];
if("WebkitOpacity"in A.style)return"Webkit";if("KhtmlOpacity"in A.style)return"Khtml";return""}();var qa=function(q,A){ka.toLowerCase();var I=["top","left","bottom","right"];q.each(function(){for(var R=a(this),X=R.outerWidth()*(A-1),ja=R.outerHeight()*(A-1),va=0;va<4;va++){var ya=I[va],Da=R.data("orig_margin-"+ya);if(Da==null){Da=parseInt(R.css("margin-"+ya));R.data("orig_margin-"+ya,Da)}Da=Da*A;if(ya==="right")Da+=X;else if(ya==="bottom")Da+=ja;R.css("margin-"+ya,Da)}})},za=c.setIconSize=function(q,
A){if(!(q==b.size&&!A)){var I=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),R=1;R=typeof q=="number"?q:{s:0.75,m:1,l:1.25,xl:1.5}[q];c.tool_scale=S=R;Cb();var X=I.parents(":hidden");X.css("visibility","hidden").show();qa(I,R);X.css("visibility","visible").hide();a.pref("iconsize",q);a("#iconsize").val(q);X={"#tools_top":{left:50,height:72},
"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};I=a("#tool_size_rules");if(I.length)I.empty();else I=a('<style id="tool_size_rules"></style>').appendTo("head");if(q!="m"){var ja="";a.each(X,function(va,ya){va="#svg_editor "+va.replace(/,/g,", #svg_editor");ja+=va+"{";a.each(ya,function(Da,Ca){if(typeof Ca==="number")var Ba=Ca*R+"px";else if(Ca[q]||Ca.all)Ba=Ca[q]||Ca.all;ja+=Da+":"+Ba+";"});ja+="}"});X="-"+ka.toLowerCase()+"-";ja+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+
X+"transform: scale("+R+");} #svg_editor div.toolset .toolset {"+X+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+X+"transform: scale("+1/R+");}";I.text(ja)}Cb()}},jb=function(){a("#dialog_box").hide();if(!Ka&&!Ra&&!Na)Sa&&f.leaveContext();else{if(Ka)sa!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(q){q&&zb()}):zb();else if(Ra)Qb();else Na&&Ib();Ub()}},zb=function(){a("#svg_source_editor").hide();Ka=false;a("#svg_source_textarea").blur()},
Qb=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=0;a("#image_save_opts input").val([b.img_save]);Ra=false},Ib=function(){a("#svg_prefs").hide();Na=false},Ob={width:a(window).width(),height:a(window).height()},Ub=a.noop,ac;svgedit.browser.isIE()&&function(){Ub=function(){if(ra[0].scrollLeft===0&&ra[0].scrollTop===0){ra[0].scrollLeft=ac.left;ra[0].scrollTop=ac.top}};ac={left:ra[0].scrollLeft,top:ra[0].scrollTop};a(window).resize(Ub);
svgEditor.ready(function(){setTimeout(function(){Ub()},500)});ra.scroll(function(){ac={left:ra[0].scrollLeft,top:ra[0].scrollTop}})}();a(window).resize(function(){Ka&&P();a.each(Ob,function(q,A){var I=a(window)[q]();ra[0]["scroll"+(q==="width"?"Left":"Top")]-=(I-A)/2;Ob[q]=I})});(function(){ra.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=ra[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=ra[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});
a("#change_image_url").click(L);(function(){var q=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],A="";a.each(q,function(I,R){A+="#tool_"+R+(I==q.length-1?",":"")});a(A).mousedown(function(){a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")});a("#tool_undo, #tool_redo").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("tool_button_current")}).bind("mousedown mouseout",
function(){a(this).removeClass("tool_button_current")})})();if(V&&!window.opera){V=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(var Bb=V.length;Bb--;){var pc=document.getElementById(V[Bb]);if(pc!=null){var qc=pc.title,uc=qc.indexOf("Ctrl+");pc.title=[qc.substr(0,uc),"Cmd+",qc.substr(uc+5)].join("")}}}var rc=function(q){var A=q[0].id=="stroke_color"?"stroke":"fill",I=q[0].id=="canvas_color";if(I)A="canvas";var R=la[A].paint;q=A=="stroke"?"Pick a Stroke Paint and Opacity":
"Pick a Fill Paint and Opacity";I=I?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(I).jGraduate({paint:R,window:{pickerTitle:q},images:{clientPath:d.jGraduatePath},newstop:"inverse"},function(X){R=new a.jGraduate.Paint(X);la[A].setPaint(R);f.setPaint(A,R);a("#color_picker").hide()},function(){a("#color_picker").hide()})};V=function(q,A){var I=document.getElementById("canvas_background"),
R={color:"#fff",opacity:1};if(A=="stroke")R=d.initStroke;if(A=="fill")R=d.initFill;if(A=="canvas"&&I)if(I=I.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))R={color:("0"+parseInt(I[1],10).toString(16)).slice(-2)+("0"+parseInt(I[2],10).toString(16)).slice(-2)+("0"+parseInt(I[3],10).toString(16)).slice(-2),opacity:1};I=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+R.color+'" opacity="'+R.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',
"text/xml").documentElement;I=a(q)[0].appendChild(document.importNode(I,true));I.setAttribute("width",24.5);this.rect=I.firstChild;this.defs=I.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:R.color});this.type=A;this.setPaint=function(X,ja){this.paint=X;var va="none",ya=X.type,Da=X.alpha/100;switch(ya){case "solidColor":va=X[ya]=="none"||X[ya]=="one"?"none":"#"+X[ya];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);
this.grad=this.defs.appendChild(X[ya]);va="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",va);this.rect.setAttribute("opacity",Da);if(ja){f.setColor(this.type,va,true);f.setPaintOpacity(this.type,Da,true)}if(this.type=="canvas"){(ya=document.getElementById("canvas_background"))?ya.setAttribute("fill",va):La(va);console.log(ya.getAttribute("fill"))}};this.update=function(X){if(Z){var ja=this.type;switch(Z.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var va=
null,ya=Z.getElementsByTagName("*"),Da=0,Ca=ya.length;Da<Ca;Da++){var Ba=ya[Da].getAttribute(ja);if(Da===0)va=Ba;else if(va!==Ba){va=null;break}}if(va===null){ya=null;return}ya=va;va=1;break;default:va=parseFloat(Z.getAttribute(ja+"-opacity"));if(isNaN(va))va=1;ya=ja==="fill"?"black":"none";ya=Z.getAttribute(ja)||ya}if(X){f.setColor(ja,ya,true);f.setPaintOpacity(ja,va,true)}va*=100;this.setPaint(ab(ya,va,ja))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var X=
new a.jGraduate.Paint({copy:this.paint});f.setPaint(A,X)}}};la.fill=new V("#fill_color","fill");la.stroke=new V("#stroke_color","stroke");la.canvas=new V("#canvas_color","canvas");a("#stroke_width").val(d.initStroke.width);a("#group_opacity").val(d.initOpacity*100);V=la.fill.rect.cloneNode(false);V.setAttribute("style","vector-effect:non-scaling-stroke");var tc=V.style.vectorEffect==="non-scaling-stroke";V.removeAttribute("style");V=la.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof V.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(V).remove();setTimeout(function(){f.embedImage("images/placeholder.svg",function(q){if(!q){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);b.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",e.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))rc(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_canvas").click(function(){rc(a("#canvas_color"))});a("#tool_stroke").click(function(){if(a("#tool_stroke").hasClass("active"))rc(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#group_opacityLabel").click(function(){a("#opacity_dropdown button").mousedown();a(window).mouseup()});a("#zoomLabel").click(function(){a("#zoom_dropdown button").mousedown();a(window).mouseup()});a("#tool_move_top").mousedown(function(q){a("#tools_stacking").show();
q.preventDefault()});a(".layer_button").mousedown(function(){a(this).addClass("layer_buttonpressed")}).mouseout(function(){a(this).removeClass("layer_buttonpressed")}).mouseup(function(){a(this).removeClass("layer_buttonpressed")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a("#layer_new").click(function(){var q=f.getCurrentDrawing().getNumLayers();do var A=e.layers.layer+" "+ ++q;while(f.getCurrentDrawing().hasLayer(A));a.prompt(e.notification.enterUniqueLayerName,A,function(I){if(I)if(f.getCurrentDrawing().hasLayer(I))a.alert(e.notification.dupeLayerName);else{f.createLayer(I);Ja();Ab()}})});a("#layer_delete").click(T);a("#layer_up").click(function(){J(-1)});a("#layer_down").click(function(){J(1)});a("#layer_rename").click(function(){a("#layerlist tr.layersel").prevAll();
var q=a("#layerlist tr.layersel td.layername").text();a.prompt(e.notification.enterNewLayerName,"",function(A){if(A)if(q==A||f.getCurrentDrawing().hasLayer(A))a.alert(e.notification.layerHasThatName);else{f.renameCurrentLayer(A);Ab()}})});var bc=-1,lc=false,sc=false,vc=function(q){if(sc)if(bc!=-1){lc=true;q=bc-q.pageX;var A=a("#sidepanels"),I=parseInt(A.css("width"));if(I+q>300)q=300-I;else if(I+q<2)q=2-I;if(q!=0){bc-=q;I=a("#layerpanel");ra.css("right",parseInt(ra.css("right"))+q);A.css("width",
parseInt(A.css("width"))+q);I.css("width",parseInt(I.css("width"))+q);A=a("#ruler_x");A.css("right",parseInt(A.css("right"))+q)}}};a("#sidepanel_handle").mousedown(function(q){bc=q.pageX;a(window).mousemove(vc);sc=false;setTimeout(function(){sc=true},20)}).mouseup(function(){lc||wc();bc=-1;lc=false});a(window).mouseup(function(){bc=-1;lc=false;a("#svg_editor").unbind("mousemove",vc)});var wc=function(q){var A=parseInt(a("#sidepanels").css("width"));q=(A>2||q?2:150)-A;A=a("#sidepanels");var I=a("#layerpanel"),
R=a("#ruler_x");ra.css("right",parseInt(ra.css("right"))+q);A.css("width",parseInt(A.css("width"))+q);I.css("width",parseInt(I.css("width"))+q);R.css("right",parseInt(R.css("right"))+q)},xc=function(q){for(var A=Array(f.getCurrentDrawing().getNumLayers()),I=0;I<A.length;++I)A[I]=f.getCurrentDrawing().getLayerName(I);if(q)for(I=0;I<A.length;++I)A[I]!=q&&f.getCurrentDrawing().setLayerOpacity(A[I],0.5);else for(I=0;I<A.length;++I)f.getCurrentDrawing().setLayerOpacity(A[I],1)},Ab=function(){var q=a("#layerlist tbody"),
A=a("#selLayerNames");q.empty();A.empty();for(var I=f.getCurrentDrawing().getCurrentLayerName(),R=f.getCurrentDrawing().getNumLayers(),X=a.getSvgIcon("eye");R--;){var ja=f.getCurrentDrawing().getLayerName(R),va='<tr class="layer';if(ja==I)va+=" layersel";va+='">';va+=f.getCurrentDrawing().getLayerVisibility(ja)?'<td class="layervis"/><td class="layername" >'+ja+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+ja+"</td></tr>";q.append(va);A.append('<option value="'+ja+'">'+ja+
"</option>")}if(X!==undefined){X.clone();a("td.layervis",q).append(X.clone());a.resizeSvgIcons({"td.layervis .svg_icon":14})}a("#layerlist td.layername").mouseup(function(ya){a("#layerlist tr.layer").removeClass("layersel");a(this.parentNode).addClass("layersel");f.setCurrentLayer(this.textContent);ya.preventDefault()}).mouseover(function(){a(this).css({"font-style":"italic",color:"blue"});xc(this.textContent)}).mouseout(function(){a(this).css({"font-style":"normal",color:"black"});xc()});a("#layerlist td.layervis").click(function(){var ya=
a(this.parentNode).prevAll().length;ya=a("#layerlist tr.layer:eq("+ya+") td.layername").text();var Da=a(this).hasClass("layerinvis");f.setLayerVisibility(ya,Da);Da?a(this).removeClass("layerinvis"):a(this).addClass("layerinvis")});for(A=5-a("#layerlist tr.layer").size();A-- >0;)q.append('<tr><td style="color:white">_</td><td/></tr>')};Ab();a(window).bind("load resize",function(){ra.css("line-height",ra.height()+"px")});a("#resolution").change(function(){var q=a("#canvas_width,#canvas_height");if(this.selectedIndex)if(this.value==
"content")q.val("fit").attr("disabled","disabled");else{var A=this.value.split("x");a("#canvas_width").val(A[0]);a("#canvas_height").val(A[1]);q.removeAttr("disabled")}else a("#canvas_width").val()=="fit"&&q.removeAttr("disabled").val(100)});a("input,select").attr("autocomplete","off");var oc=function(){var q=[{sel:"#tool_select",fn:Gb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Hb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Mb,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Nb,evt:"click",
key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:ma,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:aa,evt:"click",key:["P",true]},{sel:"#tool_text",fn:N,evt:"click",key:["T",true]},{sel:"#tool_image",fn:Y,evt:"mouseup"},{sel:"#tool_zoom",fn:na,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:mc,evt:"mouseup",key:[ga+"N",true]},{sel:"#tool_save",fn:function(){Ka?Q():f.save({images:b.img_save,round_digits:6})},evt:"mouseup",key:[ga+"S",true]},{sel:"#tool_export",fn:kc,evt:"mouseup"},
{sel:"#tool_open",fn:jc,evt:"mouseup"},{sel:"#tool_import",fn:Wb,evt:"mouseup"},{sel:"#tool_source",fn:D,evt:"click",key:[ga+"U",true]},{sel:"#tool_wireframe",fn:z,evt:"click"},{sel:"#tool_rulers",fn:F,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:jb,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Q,evt:"click"},{sel:"#tool_docprops_save",fn:ua,evt:"click"},{sel:"#tool_docprops",fn:H,evt:"mouseup"},{sel:"#tool_prefs_save",
fn:wa,evt:"click"},{sel:"#tool_prefs_option",fn:function(){G();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:Pa,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:$b,evt:"click"},{sel:"#tool_node_link",fn:Ua,evt:"click"},{sel:"#tool_node_clone",fn:ic,evt:"click"},{sel:"#tool_node_delete",fn:ec,evt:"click"},{sel:"#tool_openclose_path",fn:fc,evt:"click"},{sel:"#tool_add_subpath",fn:cc,evt:"click"},{sel:"#tool_move_top",fn:Db,evt:"click",key:ga+"shift+up"},{sel:"#tool_move_bottom",
fn:cb,evt:"click",key:ga+"shift+down"},{sel:"#tool_move_up",fn:Eb,evt:"click",key:[ga+"up",true]},{sel:"#tool_move_down",fn:$a,evt:"click",key:[ga+"down",true]},{sel:"#tool_topath",fn:Pb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:Zb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:k,evt:"click",key:[ga+"D",true]},{sel:"#tool_group",fn:h,evt:"click",key:[ga+"G",true]},{sel:"#tool_ungroup",fn:h,evt:"click",key:ga+"shift+G"},{sel:"#tool_unlink_use",fn:h,evt:"click"},{sel:"[id^=tool_align]",
fn:v,evt:"click"},{sel:"#tool_switch",fn:s,evt:"click",key:["shift+x",true]},{sel:"#tool_undo",fn:dc,evt:"click",key:ga+"z"},{sel:"#tool_redo",fn:g,evt:"click",key:["y",true]},{sel:"#tool_canvas_color_menu",fn:t,evt:"click"},{sel:"#tool_cut",fn:Xa,evt:"click",key:ga+"x"},{sel:"#tool_copy",fn:hb,evt:"click",key:ga+"c"},{sel:"#tool_paste",fn:pb,evt:"click",key:ga+"v"},{sel:"#tool_bold",fn:Vb,evt:"mousedown",key:[ga+"B",true]},{sel:"#tool_italic",fn:vb,evt:"mousedown",key:[ga+"I",true]},{sel:"#copy_save_done",
fn:jb,evt:"click"},{key:"ctrl+left",fn:function(){Sb(0,1)}},{key:"ctrl+right",fn:function(){Sb(1,1)}},{key:"ctrl+shift+left",fn:function(){Sb(0,5)}},{key:"ctrl+shift+right",fn:function(){Sb(1,5)}},{key:"shift+O",fn:Tb},{key:"shift+P",fn:gc},{key:[ga+"+",true],fn:function(){E(2)}},{key:[ga+"-",true],fn:function(){E(0.5)}},{key:["up",true],fn:function(){gb(0,-1)}},{key:["down",true],fn:function(){gb(0,1)}},{key:["left",true],fn:function(){gb(-1,0)}},{key:["right",true],fn:function(){gb(1,0)}},{key:"shift+up",
fn:function(){gb(0,-10)}},{key:"shift+down",fn:function(){gb(0,10)}},{key:"shift+left",fn:function(){gb(-10,0)}},{key:"shift+right",fn:function(){gb(10,0)}},{key:["alt+up",true],fn:function(){f.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){f.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){f.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){f.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){f.cloneSelectedElements(0,-10)}},
{key:["alt+shift+down",true],fn:function(){f.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){f.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){f.cloneSelectedElements(10,0)}},{key:ga+"A",fn:function(){f.selectAllInCurrentLayer()}},{key:ga+"shift+z",fn:g},{key:"esc",fn:C}],A={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var I={};a.each(q,function(R,X){if(X.sel){var ja=a(X.sel);if(ja.length==0)return true;
if(X.evt){if(svgedit.browser.isTouch()&&X.evt==="click")X.evt="mousedown";ja[X.evt](X.fn)}if(X.parent&&a(X.parent+"_show").length!=0){var va=a(X.parent);va.length||(va=Ga(X.parent.substr(1)));va.append(ja);a.isArray(I[X.parent])||(I[X.parent]=[]);I[X.parent].push(X)}}if(X.key){var ya=X.fn,Da=false;if(a.isArray(X.key)){va=X.key[0];if(X.key.length>1)Da=X.key[1]}else va=X.key;va+="";svgedit.browser.isMac&&va.indexOf("+")!=-1&&va.split("+")[0]=="ctrl"&&va.replace("ctrl","cmd");a.each(va.split("/"),function(Ba,
tb){a(document).bind("keydown",tb,function(Ta){ya();Da&&Ta.preventDefault();return false})});if(X.sel&&!X.hidekey&&ja.attr("title")){var Ca=ja.attr("title").split("[")[0]+" ("+va+")";A[va]=X.sel;ja.parents("#main_menu").length||ja.attr("title",Ca)}}});Qa(I);a(".attr_changer, #image_url").bind("keydown","return",function(R){a(this).change();R.preventDefault()});a(window).bind("keydown","tab",function(R){if(U==="canvas"){R.preventDefault();gc()}}).bind("keydown","shift+tab",function(R){if(U==="canvas"){R.preventDefault();
Tb()}});a("#tool_zoom").dblclick(K)},setTitles:function(){a.each(A,function(I,R){var X=a(R).parents("#main_menu").length;a(R).each(function(){var ja=X?a(this).text().split(" [")[0]:this.title.split(" [")[0],va="";a.each(I.split("/"),function(ya,Da){var Ca=Da.split("+"),Ba="";if(Ca.length>1){Ba=Ca[0]+"+";Da=Ca[1]}va+=(ya?"/":"")+Ba+(e["key_"+Da]||Da)});if(X)this.lastChild.textContent=ja+" ["+va+"]";else this.title=ja+" ["+va+"]"})})},getButtonData:function(I){var R;a.each(q,function(X,ja){if(ja.sel===
I)R=ja});return R}}}();oc.setAll();c.ready(function(){var q=d.initTool,A=a("#tools_left, #svg_editor .tools_flyout"),I=A.find("#tool_"+q);q=A.find("#"+q);(I.length?I:q.length?q:a("#tool_select")).click().mouseup();d.wireframe&&a("#tool_wireframe").click();d.showlayers&&wc();a("#rulers").toggle(!!d.showRulers);if(d.showRulers)a("#show_rulers")[0].checked=true;if(d.gridSnapping)a("#grid_snapping_on")[0].checked=true;d.baseUnit&&a("#base_unit").val(d.baseUnit);d.snappingStep&&a("#grid_snapping_step").val(d.snappingStep)});
a("#rect_rx").SpinButton({min:0,max:1E3,step:1,callback:function(q){f.setRectRadius(q.value)}});a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,callback:function(q){var A=q.value;if(A==0&&Z&&["line","polyline"].indexOf(Z.nodeName)>=0)A=q.value=1;f.setStrokeWidth(A)}});a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(q){f.setRotationAngle(q.value);a("#tool_reorient").toggleClass("disabled",q.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(q,
A){var I=q.value-0,R=I+A,X=R>=I;if(A===0)return I;return I>=24?X?Math.round(I*1.1):Math.round(I/1.1):I<=1?X?I*2:I/2:R},callback:function(q){f.setFontSize(q.value)}});a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:xb});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:fb});a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(q,A){var I=q.value-0;if(I===0)return 100;var R=I+A;if(A===0)return I;return I>=100?R:R>=I?I*2:I/2},callback:ob}).val(f.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",
inSpeed:0},function(q){switch(q){case "delete":Pa();break;case "cut":Xa();break;case "copy":hb();break;case "paste":f.pasteElements();break;case "paste_in_place":f.pasteElements("in_place");break;case "group":f.groupSelectedElements();break;case "ungroup":f.ungroupSelectedElement();break;case "move_front":Db();break;case "move_up":Fb("Up");break;case "move_down":Fb("Down");break;case "move_back":cb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(q)&&svgedit.contextmenu.getCustomHandler(q).call()}f.clipBoard.length&&
pa.enableContextMenuItems("#paste,#paste_in_place")});V=function(q){switch(q){case "dupe":M();break;case "delete":T();break;case "merge_down":if(a("#layerlist tr.layersel").index()!=f.getCurrentDrawing().getNumLayers()-1){f.mergeLayer();Ja();Ab()}break;case "merge_all":f.mergeAllLayers();Ja();Ab()}};a("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},V);a("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:true},V);a(".contextMenu li").mousedown(function(q){q.preventDefault()});
a("#cmenu_canvas li").disableContextMenu();pa.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(ha.getUndoStackSize()===0)c.show_save_warning=false;if(!d.no_save_warning&&c.show_save_warning)return e.notification.unsavedChanges};c.openPrep=function(q){a("#main_menu").hide();ha.getUndoStackSize()===0?q(true):a.confirm(e.notification.QwantToOpen,q)};if(window.FileReader){V=a('<input type="file">').change(function(){var q=this;c.openPrep(function(A){if(A){f.clear();if(q.files.length==
1){A=new FileReader;A.onloadend=function(I){n(I.target.result);Rb()};A.readAsText(q.files[0])}}})});a("#tool_open").show().prepend(V);V=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var q=new FileReader;q.onloadend=function(A){f.importSvgString(A.target.result,true);Rb()};q.readAsText(this.files[0])}});a("#tool_import").show().prepend(V)}var Rb=c.updateCanvas=function(q,A){var I=ra.width(),R=ra.height(),X=I,ja=R,va=f.getZoom(),ya=a("#svgcanvas"),Da={x:ra[0].scrollLeft+
X/2,y:ra[0].scrollTop+ja/2},Ca=d.canvas_expansion;I=Math.max(X,f.contentW*va*Ca);R=Math.max(ja,f.contentH*va*Ca);I==X&&R==ja?ra.css("overflow","hidden"):ra.css("overflow","scroll");Ca=ya.height()/2;var Ba=ya.width()/2;ya.width(I).height(R);var tb=R/2,Ta=I/2,ia=f.updateCanvas(I,R),wb=Ta/Ba;I=I/2-X/2;R=R/2-ja/2;if(A){A.x+=ia.x;A.y+=ia.y}else A={x:Ta+(Da.x-Ba)*wb,y:tb+(Da.y-Ca)*wb};if(q)if(f.contentW>ra.width()){ra[0].scrollLeft=ia.x-10;ra[0].scrollTop=ia.y-10}else{ra[0].scrollLeft=I;ra[0].scrollTop=
R}else{ra[0].scrollLeft=A.x-X/2;ra[0].scrollTop=A.y-ja/2}if(d.showRulers){da(ya,va);ra.scroll()}},hc=[];for(Bb=0.1;Bb<1E5;Bb*=10){hc.push(1*Bb);hc.push(2*Bb);hc.push(5*Bb)}Rb(true);try{var yc=function(q){if(window.JSON&&JSON.stringify)return JSON.stringify(q);var A=arguments.callee;if(typeof q=="boolean"||typeof q=="number")return q+"";else if(typeof q=="string")return'"'+q.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
function(X){return"\\u"+("0000"+X.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(q.length){for(var I=0;I<q.length;I++)q[I]=A(q[I]);return"["+q.join(",")+"]"}else{I=[];for(var R in q)I.push(A(R)+":"+A(q[R]));return"{"+I.join(",")+"}"}};window.addEventListener("message",function(q){var A=parseInt(q.data.substr(0,q.data.indexOf(";")));try{q.source.postMessage("SVGe"+A+";"+yc(eval(q.data)),"*")}catch(I){q.source.postMessage("SVGe"+A+";error:"+I.message,"*")}},false)}catch(zc){window.embed_error=
zc}a(function(){window.svgCanvas=f;f.ready=svgEditor.ready});c.setLang=function(q,A){a.pref("lang",q);a("#lang_select").val(q);if(A){var I=a("#layerlist tr.layersel td.layername").text()==e.common.layer+" 1";a.extend(e,A);f.setUiStrings(A);oc.setTitles();if(I){f.renameCurrentLayer(e.common.layer+" 1");Ab()}f.runExtensions("langChanged",q);Kb();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin",
"#linecap_butt":"#cur_linecap"},function(R,X){a(X).attr("title",a(R)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var u=[];c.ready=function(w){m?w():u.push(w)};c.runCallbacks=function(){a.each(u,function(){this()});m=true};c.loadFromString=function(w){c.ready(function(){n(w)})};c.disableUI=function(){};c.loadFromURL=function(w,p){p||(p={});var L=p.cache,T=p.callback;c.ready(function(){a.ajax({url:w,dataType:"text",
cache:!!L,success:function(M){n(M,T)},error:function(M,J,da){M.status!=404&&M.responseText?n(M.responseText,T):a.alert(e.notification.URLloadFail+": \n"+da+"",T)}})})};c.loadFromDataURI=function(w){c.ready(function(){var p=w.substring(26);n(svgedit.utilities.decode64(p))})};c.addExtension=function(){var w=arguments;a(function(){f&&f.addExtension.apply(this,w)})};return c}(jQuery);$(svgEditor.init)})();svgedit=svgedit||{};
Ya=f.getResolution();if(d.baseUnit!=="px"){Ya.w=svgedit.units.convertUnit(Ya.w)+d.baseUnit;Ya.h=svgedit.units.convertUnit(Ya.h)+d.baseUnit}a(".canvas_width").val(Ya.w);a(".canvas_height").val(Ya.h);a("#docprops_button").on("click",function(){H()});var La=function(q){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ya.w+2,height:Ya.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:q||"#fff",style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");
f.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||La();document.getElementById("canvas_background").getAttribute("fill");var Ea=c.setImageURL=function(q){q||(q=ea);f.setImageURL(q);a("#image_url").val(q);if(q.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{f.embedImage(q,function(A){A?a("#url_notice").hide():a("#url_notice").show();ea=q});a("#image_url").show();a("#change_image_url").hide()}},qb=function(q){var A=Math.min(Math.max(12+q.value.length*
6,50),300);a(q).width(A)},Ja=function(){var q=Z;if(q!=null&&!q.parentNode)q=null;var A=f.getCurrentDrawing().getCurrentLayerName(),I=f.getMode(),R=d.baseUnit!=="px"?d.baseUnit:null,X=I=="pathedit",ja=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #path_panel, #rect_panel, #canvas_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item",
"#object_menu").addClass("disabled");!q&&!Aa&&a("#canvas_panel").show();if(q!=null){var va=q.nodeName,ya=f.getRotationAngle(q);a("#angle").val(Math.round(ya));ya=f.getBlur(q);a("#blur").val(ya);a("#blur_slider").slider("option","value",ya);f.addedNew&&va==="image"&&f.getHref(q).indexOf("data:")!==0&&L();if(!X&&I!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(va)>=0)a("#xy_panel").hide();else{var Da,Ca;if(["g","polyline",
"path"].indexOf(va)>=0){if(I=f.getStrokedBBox([q])){Da=I.x;Ca=I.y}}else{Da=q.getAttribute("x");Ca=q.getAttribute("y")}if(R){Da=svgedit.units.convertUnit(Da);Ca=svgedit.units.convertUnit(Ca)}a("#selected_x").val(Math.round(Ca)||0);a("#selected_y").val(Math.round(Da)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(va)==-1&&a(".action_path_convert_selected").removeClass("disabled");va==="path"&&a(".action_path_selected").removeClass("disabled")}else{A=ta.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");
a("#tool_node_delete").toggleClass("disabled",!ta.canDeleteNodes);fa("#tool_openclose_path",ta.closed_subpath?"open_path":"close_path");if(A){X=a("#seg_type");if(R){A.x=svgedit.units.convertUnit(A.x);A.y=svgedit.units.convertUnit(A.y)}a("#path_node_x").val(Math.round(A.x));a("#path_node_y").val(Math.round(A.y));A.type?X.val(A.type).removeAttr("disabled"):X.val(4).attr("disabled","disabled")}return}R={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx",
"cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]};var Ba=q.tagName;a(q).data("gsvg")&&a("#g_panel").show();Ba=="path"&&a("#path_panel").show();if(R[Ba]){R=R[Ba];a("#"+Ba+"_panel").show();a.each(R,function(tb,Ta){var ia=q.getAttribute(Ta);if(d.baseUnit!=="px"&&q[Ta])ia=svgedit.units.convertUnit(q[Ta].baseVal.value);a("#"+Ba+"_"+Ta).val(Math.round(ia)||0)});if(Ba=="text"){a("#text_panel").css("display","inline");f.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):
a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");f.getBold()?a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(q.getAttribute("font-family"));a("#font_size").val(q.getAttribute("font-size"));a("#text").val(q.textContent);f.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(Ba=="image")Ea(f.getHref(q));else if(Ba==="g"||Ba==="use"){a("#container_panel").show();
a(".action_group_selected").removeClass("disabled");R=f.getTitle();va=a("#g_title")[0];va.value=R;qb(va);Ba=="use"?va.setAttribute("disabled","disabled"):va.removeAttribute("disabled")}}ja[(Ba==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");ja[(Ba==="g"||!Aa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(Aa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");ja.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else ja.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");
ha.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");ha.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");f.addedNew=false;if(q&&!X||Aa){a("#selLayerNames").removeAttr("disabled").val(A);pa.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else a("#selLayerNames").attr("disabled","disabled")};a("#text").focus(function(){});a("#text").blur(function(){});f.bind("selected",
function(q,A){var I=f.getMode();I==="select"&&oa();I=I=="pathedit";Z=A.length==1||A[1]==null?A[0]:null;Aa=A.length>=2&&A[1]!=null;if(Z!=null)if(!I){if(Z!=null)switch(Z.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var R=null,X=Z.getElementsByTagName("*"),ja=0,va=X.length;ja<va;ja++){var ya=X[ja].getAttribute("stroke-width");if(ja===0)R=ya;else if(R!==ya)R=null}a("#stroke_width").val(R===null?"":R);la.fill.update(true);la.stroke.update(true);break;default:la.fill.update(true);
la.stroke.update(true);a("#stroke_width").val(Z.getAttribute("stroke-width")||1);a("#stroke_style").val(Z.getAttribute("stroke-dasharray")||"none");R=Z.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+R).length!=0&&w(a("#linejoin_"+R)[0]);R=Z.getAttribute("stroke-linecap")||"butt";a("#linecap_"+R).length!=0&&w(a("#linecap_"+R)[0])}if(Z!=null){R=(Z.getAttribute("opacity")||1)*100;a("#group_opacity").val(R);a("#opac_slider").slider("option","value",R);a("#elem_id").val(Z.id)}}a("#path_node_panel").toggle(I);
a("#tools_bottom_2,#tools_bottom_3").toggle(!I);if(I){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");fa("#tool_select","select_node");Aa=false;if(A.length)Z=A[0]}else{if(A[0]){I=f.selectorManager.requestSelector(A[0]);I.reset(A[0]);I.selectorRect.setAttribute("display","inline")}fa("#tool_select","select")}Ja();f.runExtensions("selectedChanged",{elems:A,selectedElement:Z,multiselected:Aa})});
f.bind("transition",function(q,A){var I=f.getMode(),R=A[0];if(R){Aa=A.length>=2&&A[1]!=null;if(!Aa)switch(I){case "rotate":I=f.getRotationAngle(R);a("#angle").val(Math.round(I));a("#tool_reorient").toggleClass("disabled",I==0)}f.runExtensions("elementTransition",{elems:A})}});f.bind("changed",function(q,A){var I=f.getMode();I==="select"&&oa();for(var R=0;R<A.length;++R){var X=A[R];if(X&&X.tagName==="svg"){Ab();Rb()}else if(X&&Z&&Z.parentNode==null)Z=X}c.show_save_warning=true;Ja();if(Z&&I==="select"){la.fill.update();
la.stroke.update()}f.runExtensions("elementChanged",{elems:A})});f.bind("saved",function(q,A){c.show_save_warning=false;A='<?xml version="1.0"?>\n'+A;var I=navigator.userAgent;if(~I.indexOf("Chrome")&&a.browser.version>=533||~I.indexOf("MSIE"))D(0,true);else{var R=q.open("data:image/svg+xml;base64,"+ca.encode64(A)),X=a.pref("save_notice_done");if(X!=="all"){var ja=e.notification.saveFromBrowser.replace("%s","SVG");if(I.indexOf("Gecko/")!==-1)if(A.indexOf("<defs")!==-1){ja+="\n\n"+e.notification.defsFailOnSave;
a.pref("save_notice_done","all");X="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");X!=="part"&&R.alert(ja)}}});f.bind("exported",function(q,A){var I=A.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var R=a("#export_canvas")[0];R.width=f.contentW;R.height=f.contentH;canvg(R,A.svg,{renderCallback:function(){var X=R.toDataURL("image/png");ba.location.href=X;if(a.pref("export_notice_done")!=="all"){X=e.notification.saveFromBrowser.replace("%s",
"PNG");if(I.length)X+="\n\n"+e.notification.noteTheseIssues+"\n \u2022 "+I.join("\n \u2022 ");a.pref("export_notice_done","all");ba.alert(X)}}})});f.bind("zoomed",Oa);f.bind("contextset",function(q,A){var I="";if(A){var R="";I='<a href="#" data-root="y">'+f.getCurrentDrawing().getCurrentLayerName()+"</a>";a(A).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){R+=" > "+this.id;I+=this!==A?' > <a href="#">'+this.id+"</a>":" > "+this.id}});Sa=R}else Sa=null;a("#cur_context_panel").toggle(!!A).html(I);
W()});f.bind("extension_added",function(q,A){function I(){if(nb){clearTimeout(nb);nb=null}X||(nb=setTimeout(function(){X=true;za(b.iconsize)},50))}var R=false,X=false,ja=true,va=function(){if(A.callback&&!R&&ja){R=true;A.callback()}},ya=[];A.context_tools&&a.each(A.context_tools,function(Ta,ia){var wb=ia.container_id?' id="'+ia.container_id+'"':"",bb=a("#"+ia.panel);bb.length||(bb=a("<div>",{id:ia.panel}).appendTo("#tools_top").hide());switch(ia.type){case "tool_button":var Fa='<div class="tool_button">'+
ia.id+"</div>",Va=a(Fa).appendTo(bb);ia.events&&a.each(ia.events,function(eb,lb){a(Va).bind(eb,lb)});break;case "select":Fa="<label"+wb+'><select id="'+ia.id+'">';a.each(ia.options,function(eb,lb){Fa+='<option value="'+eb+'"'+(eb==ia.defval?" selected":"")+">"+lb+"</option>"});Fa+="</select></label>";var Ha=a(Fa).appendTo(bb).find("select");a.each(ia.events,function(eb,lb){a(Ha).bind(eb,lb)});break;case "button-select":Fa='<div id="'+ia.id+'" class="dropdown toolset" title="'+ia.title+'"><div id="cur_'+
ia.id+'" class="icon_label"></div><button></button></div>';wb=a('<ul id="'+ia.id+'_opts"></ul>').appendTo("#option_lists");ia.colnum&&wb.addClass("optcols"+ia.colnum);a(Fa).appendTo(bb).children();ya.push({elem:"#"+ia.id,list:"#"+ia.id+"_opts",title:ia.title,callback:ia.events.change,cur:"#cur_"+ia.id});break;case "input":Fa="<label"+wb+'><span id="'+ia.id+'_label">'+ia.label+':</span><input id="'+ia.id+'" title="'+ia.title+'" size="'+(ia.size||"4")+'" value="'+(ia.defval||"")+'" type="text"/></label>';
var kb=a(Fa).appendTo(bb).find("input");ia.spindata&&kb.SpinButton(ia.spindata);ia.events&&a.each(ia.events,function(eb,lb){kb.bind(eb,lb)})}});if(A.buttons){var Da={},Ca={},Ba=A.svgicons,tb={};a.each(A.buttons,function(Ta,ia){for(var wb,bb=ia.id,Fa=Ta;a("#"+bb).length;)bb=ia.id+"_"+ ++Fa;if(Ba){Da[bb]=ia.icon;Fa=ia.svgicon?ia.svgicon:ia.id;if(ia.type=="app_menu")Ca["#"+bb+" > div"]=Fa;else Ca["#"+bb]=Fa}else wb=ia.type=="menu"?"":a('<img src="'+ia.icon+'">');var Va,Ha;switch(ia.type){case "mode_flyout":case "mode":Va=
"tool_button";if(ia.cls)Va+=" "+ia.cls;Ha="#tools_left";break;case "context":Va="tool_button";Ha="#"+ia.panel;a(Ha).length||a("<div>",{id:ia.panel}).appendTo("#tools_top");break;case "menu":Va="menu_item tool_button";Ha="#"+(ia.after||ia.panel);break;case "app_menu":Va="";Ha=ia.parent||"#main_menu ul";a(Ha).length||a("<div>",{id:ia.panel}).appendTo("#tools_top")}var kb=a(ia.list||ia.type=="app_menu"?"<li/>":"<div/>").attr("id",bb).attr("title",ia.title).addClass(Va);if(!ia.includeWith&&!ia.list){if("position"in
ia)a(Ha).children().eq(ia.position).before(kb);else ia.type!="menu"||!ia.after?kb.appendTo(Ha):a(Ha).after(kb);if(ia.type=="mode_flyout"){Fa=a(kb);Va=Fa.parent();if(!Fa.parent().hasClass("tools_flyout")){var eb=Fa[0].id.replace("tool_","tools_"),lb=Fa.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Fa.before(lb);Va=Ga(eb,Fa);Va.data("isLibrary",true);lb.data("isLibrary",true)}Ca["#"+eb+"_show"]=ia.id;bb=tb["#"+Va[0].id]=[{sel:"#"+bb,fn:ia.events.click,icon:ia.id,isDefault:true},
Yb]}else if(ia.type=="app_menu"||ia.type=="menu")kb.append(ia.title)}else if(ia.list){kb.addClass("push_button");a("#"+ia.list+"_opts").append(kb);if(ia.isDefault){a("#cur_"+ia.list).append(kb.children().clone());Fa=ia.svgicon?ia.svgicon:ia.id;Ca["#cur_"+ia.list]=Fa}}else if(ia.includeWith){Ha=ia.includeWith;Fa=a(Ha.button);Va=Fa.parent();if(!Fa.parent().hasClass("tools_flyout")){eb=Fa[0].id.replace("tool_","tools_");lb=Fa.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));
Fa.before(lb);Va=Ga(eb,Fa)}var Yb=oc.getButtonData(Ha.button);if(Ha.isDefault)Ca["#"+eb+"_show"]=ia.id;bb=tb["#"+Va[0].id]=[{sel:"#"+bb,fn:ia.events.click,icon:ia.id,key:ia.key,isDefault:ia.includeWith?ia.includeWith.isDefault:0},Yb];eb="position"in Ha?Ha.position:"last";Yb=Va.children().length;if(!isNaN(eb)&&eb>=0&&eb<Yb)Va.children().eq(eb).before(kb);else{Va.append(kb);bb.reverse()}}Ba||kb.append(wb);ia.list||a.each(ia.events,function(Jb,Xb){if(Jb=="click")if(ia.type=="mode"){ia.includeWith?kb.bind(Jb,
Xb):kb.bind(Jb,function(){xa(kb)&&Xb()});if(ia.key){a(document).bind("keydown",ia.key,Xb);ia.title&&kb.attr("title",ia.title+" ["+ia.key+"]")}}else kb.bind(Jb,Xb);else kb.bind(Jb,Xb)});Qa(tb)});a.each(ya,function(){sb(this.elem,this.list,this.callback,{seticon:true})});if(Ba)ja=false;a.svgIcons(Ba,{w:27,h:27,id_match:false,no_img:!O,fallback:Da,placement:Ca,callback:function(){b.iconsize&&b.iconsize!="m"&&I();ja=true;va()}})}va()});f.textActions.setInputElem(a("#text")[0]);var Za='<div class="palette_item" data-rgb="none"></div>';
a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff","#aad4ff"],function(q,A){Za+='<div class="palette_item" style="background-color: '+A+';" data-rgb="'+A+'"></div>'});a("#palette").append(Za);
Za="";a.each(["#FFF","#888","#000"],function(){Za+='<div class="color_block" style="background-color:'+this+';"></div>'});a("#bg_blocks").append(Za);var Ma=a("#bg_blocks div");Ma.each(function(){a(this).click(function(){Ma.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))p(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&p(o.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){b.img_save=a.pref("img_save");a("#image_save_opts input").val([b.img_save])}var ob=
function(q){var A=q.value/100;if(A<0.0010)q.value=0.1;else{q=f.getZoom();Oa(window,{width:0,height:0,x:(ra[0].scrollLeft+ra.width()/2)/q,y:(ra[0].scrollTop+ra.height()/2)/q,zoom:A},true)}},xb=function(q,A){if(A==null)A=q.value;a("#group_opacity").val(A);if(!q||!q.handle)a("#opac_slider").slider("option","value",A);f.setOpacity(A/100)},fb=function(q,A,I){if(A==null)A=q.value;a("#blur").val(A);var R=false;if(!q||!q.handle){a("#blur_slider").slider("option","value",A);R=true}I?f.setBlurNoUndo(A):f.setBlur(A,
R)},ib=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){f.setStrokeAttr("stroke-dasharray",a(this).val());ib()});a("#stroke_linejoin").change(function(){f.setStrokeAttr("stroke-linejoin",a(this).val());ib()});a("select").change(function(){a(this).blur()});var Lb=false;a("#selLayerNames").change(function(){var q=this.options[this.selectedIndex].value,A=e.notification.QmoveElemsToLayer.replace("%s",q),I=function(R){if(R){Lb=true;f.moveSelectedToLayer(q);
f.clearSelection();Ab()}};if(q)Lb?I(true):a.confirm(A,I)});a("#font_family").change(function(){f.setFontFamily(this.value)});a("#seg_type").change(function(){f.setSegType(a(this).val())});a("#text").keyup(function(){f.setTextContent(this.value)});a("#image_url").change(function(){Ea(this.value)});a("#link_url").change(function(){this.value.length?f.setLinkURL(this.value):f.removeHyperlink()});a("#g_title").change(function(){f.setGroupTitle(this.value)});a(".attr_changer").change(function(){var q=
this.getAttribute("data-attr"),A=this.value;if(svgedit.units.isValidUnit(q,A,Z))this.blur();else{a.alert(e.notification.invalidAttrValGiven);this.value=Z.getAttribute(q);return false}if(q!=="id")if(isNaN(A))A=f.convertToNum(q,A);else if(d.baseUnit!=="px"){var I=svgedit.units.getTypeMap();if(Z[q]||f.getMode()==="pathedit"||q==="x"||q==="y")A*=I[d.baseUnit]}if(q==="id"){q=Z;f.clearSelection();q.id=A;f.addToSelection([q],true)}else f.changeSelectedAttribute(q,A);this.blur()});a("#palette").mouseover(function(){var q=
a('<input type="hidden">');a(this).append(q);q.focus().remove()});a(".palette_item").mousedown(function(){var q=a("#tool_stroke").hasClass("active"),A=q?"stroke":"fill",I=a(this).attr("data-rgb"),R=null;if(I==="transparent"||I==="initial"||I==="#none"){I="none";R=new a.jGraduate.Paint}else R=new a.jGraduate.Paint({alpha:100,solidColor:I.substr(1)});la[A].setPaint(R);if(q){f.setColor("stroke",I);I!="none"&&f.getStrokeOpacity()!=1&&f.setPaintOpacity("stroke",1)}else{f.setColor("fill",I);I!="none"&&
f.getFillOpacity()!=1&&f.setPaintOpacity("fill",1)}}).bind("contextmenu",function(q){q.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");Ub()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Ub()});var xa=function(q,A){if(a(q).hasClass("disabled"))return false;if(a(q).parent().hasClass("tools_flyout"))return true;var I=I||"normal";A||a(".tools_flyout").fadeOut(I);a("#styleoverrides").text("");
a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(q).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var q=null,A=null,I=ra[0],R=false,X=false;a("#svgcanvas").bind("mousemove mouseup",function(ja){if(R!==false){I.scrollLeft-=ja.clientX-q;I.scrollTop-=ja.clientY-A;q=ja.clientX;A=ja.clientY;if(ja.type==="mouseup")R=false;return false}}).mousedown(function(ja){if(ja.button===1||X===true){R=true;q=ja.clientX;A=ja.clientY;return false}});
a(window).mouseup(function(){R=false});a(document).bind("keydown","space",function(ja){f.spaceKey=X=true;ja.preventDefault()}).bind("keyup","space",function(ja){ja.preventDefault();f.spaceKey=X=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&ra.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&ra.removeClass("out")})})();var ub=a(".menu"),rb=function(q){q.target.style.background="#fff";setTimeout(function(){q.target.style.background="#ddd"},50);setTimeout(function(){q.target.style.background=
"#fff"},150);setTimeout(function(){q.target.style.background="#ddd"},200);setTimeout(function(){q.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").live("click",function(q){rb(q)});a("svg, body").on("mousedown",function(q){top!=self&&!q.isTrigger&&typeof top.exports.setEditorFocus=="function"&&top.exports.setEditorFocus();if(!a(q.target).hasClass("menu_title"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))rb(q);
else{a("#menu_bar").removeClass("active");a("#tools_shapelib").is(":visible")&&!a(q.target).parents("#tools_shapelib_show, #tools_shapelib").length&&a("#tools_shapelib").hide();q.target.nodeName.toLowerCase()!="input"&&a("input").blur()}});var yb=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(q,A,I,R){if(q.altKey){q.preventDefault();q=f.getZoom()*100;A=yb.length;for(Bb=0;Bb<A;Bb++){I=Math.min(A,Bb+1);if(R>0)zoom=yb[Bb]<=q?yb[I]:zoom;if(R<0)zoom=yb[Bb]<
q?yb[Bb]:zoom}zoom&&ob({value:zoom})}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",function(){ub.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,A,I){if(a(q).length!=0){var R=a(q).find("button"),X=a(q).find("ul").attr("id",a(q)[0].id+"-list");I||a("#option_lists").append(X);var ja=false;I&&a(q).addClass("dropup");X.find("li").bind("mouseup",A);a(window).mouseup(function(){if(!ja){R.removeClass("down");
X.hide()}ja=false});R.bind("mousedown",function(){if(R.hasClass("down")){R.removeClass("down");X.hide()}else{R.addClass("down");if(!I){var va=a(q).offset();X.css({top:va.top,left:va.left-110})}X.show();ja=true}}).hover(function(){ja=true}).mouseout(function(){ja=false})}};var sb=function(q,A,I,R){var X=a(q);A=a(A);var ja=false,va=R.dropUp;va&&a(q).addClass("dropup");A.find("li").bind("mouseup",function(){if(R.seticon){fa("#cur_"+X[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}I.apply(this,
arguments)});a(window).mouseup(function(){if(!ja){X.removeClass("down");A.hide();A.css({top:0,left:0})}ja=false});A.height();a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=A.height();ya.left+=8}else ya.top+=a(q).height();a(A).offset(ya);if(X.hasClass("down")){X.removeClass("down");A.hide();A.css({top:0,left:0})}else{X.addClass("down");A.show();ja=true;return false}}).hover(function(){ja=true}).mouseout(function(){ja=false});R.multiclick&&A.mousedown(function(){ja=true})};c.addDropDown("#font_family_dropdown",
function(){a(this).text();a("#font_family").val(a(this).text()).change()});c.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var q=parseInt(a(this).text().split("%")[0]);xb(false,q)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(q,A){xb(A)}});c.addDropDown("#blur_dropdown",a.noop);var mb=false;a("#blur_slider").slider({max:10,step:0.1,
stop:function(q,A){mb=false;fb(A);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){mb=true},slide:function(q,A){fb(A,null,mb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),A=q.attr("data-val");A?Oa(window,A):ob({value:parseInt(q.text())})},true);sb("#stroke_linecap","#linecap_opts",function(){w(this,true)},{dropUp:true});sb("#stroke_linejoin","#linejoin_opts",function(){w(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",
function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,"page")})});(function(){var q,A=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=this;U="toolbars";ra.mousedown(A)}).blur(function(){U="canvas";ra.unbind("mousedown",A);f.getMode()=="textedit"&&a("#text").focus()})})();var Gb=function(){if(xa("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},
Hb=function(){xa("#tool_fhpath")&&f.setMode("fhpath")},Mb=function(){xa("#tool_line")&&f.setMode("line")},Nb=function(){xa("#tool_rect")&&f.setMode("rect")},ma=function(){xa("#tool_ellipse")&&f.setMode("ellipse")},Y=function(){xa("#tool_image")&&f.setMode("image")},na=function(){xa("#tool_zoom")&&f.setMode("zoom")},K=function(){if(xa("#tool_zoom")){E();oa()}},N=function(){xa("#tool_text")&&f.setMode("text")},aa=function(){xa("#tool_path")&&f.setMode("path")},Pa=function(){if(Z!=null||Aa)f.deleteSelectedElements()},
Xa=function(){if(Z!=null||Aa){window.event.type==="keydown"&&db(a("#edit_menu"));f.cutSelectedElements()}},hb=function(){if(Z!=null||Aa){window.event.type==="keydown"&&db(a("#edit_menu"));f.copySelectedElements()}},pb=function(){window.event.type==="keydown"&&db(a("#edit_menu"));var q=f.getZoom(),A=(ra[0].scrollLeft+ra.width()/2)/q-f.contentW;q=(ra[0].scrollTop+ra.height()/2)/q-f.contentH;f.pasteElements("point",A,q)},Db=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));
f.moveToTopSelectedElement()}},cb=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveToBottomSelectedElement()}},Eb=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected("Up")}},$a=function(){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected("Down")}},Fb=function(q){if(Z!=null){window.event.type==="keydown"&&db(a("#object_menu"));f.moveUpDownSelected(q)}},Pb=function(){if(Z!=null){f.convertToPath();
elems=f.getSelectedElems();f.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");f.setMode("pathedit");ta.toEditMode(elems[0]);f.clearSelection()}},$b=function(){Z!=null&&ta.reorient()},Zb=function(){if(Z!=null||Aa)a.prompt(e.notification.enterNewLinkURL,"http://",function(q){q&&f.makeHyperlink(q)})},gb=function(q,A){if(Z!=null||Aa){if(d.gridSnapping){var I=f.getZoom()*d.snappingStep;q*=I;A*=I}a("input").blur();f.moveSelectedElements(q,A)}},Ua=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");
q?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",false);ta.linkControlPoints(q)},ic=function(){ta.getNodePoint()&&ta.clonePathNode()},ec=function(){ta.getNodePoint()&&ta.deletePathNode()},cc=function(){var q=a("#tool_add_subpath"),A=!q.hasClass("push_button_pressed");A?q.addClass("push_button_pressed").removeClass("tool_button"):
q.removeClass("push_button_pressed").addClass("tool_button");ta.addSubPath(A)},fc=function(){ta.opencloseSubPath()},gc=function(){f.cycleElement(1)},Tb=function(){f.cycleElement(0)},Sb=function(q,A){if(!(Z==null||Aa)){q||(A*=-1);var I=a("#angle").val()*1+A;f.setRotationAngle(I);Ja()}},mc=function(){var q=d.dimensions;a.confirm(e.notification.QwantToClear,function(A){if(A){oa();f.clear();f.setResolution(q[0],q[1]);Rb(true);E();Ab();Ja();la.fill.prep();la.stroke.prep();f.runExtensions("onNewDocument")}})},
Vb=function(){f.setBold(!f.getBold());Ja();return false},vb=function(){f.setItalic(!f.getItalic());Ja();return false},kc=function(){if(!l.pngsave){var q=e.notification.loadingImage;ba=window.open("data:text/html;charset=utf-8,<title>"+q+"</title><h1>"+q+"</h1>")}window.canvg?f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},jc=function(){f.open()},Wb=function(){},db=function(q){var A=q.prev();A.css("background","#09f");setTimeout(function(){A.css("background",
"")},200)},dc=function(){if(ha.getUndoStackSize()>0){window.event.type==="keydown"&&db(a("#edit_menu"));ha.undo();Ab()}},g=function(){if(ha.getRedoStackSize()>0){window.event.type==="keydown"&&db(a("#edit_menu"));ha.redo();Ab()}},h=function(){if(Aa)f.groupSelectedElements();else Z&&f.ungroupSelectedElement()},k=function(){window.event.type==="keydown"&&db(a("#edit_menu"));f.cloneSelectedElements(20,20)},v=function(){var q=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(q,a("#align_relative_to").val())},
s=function(){var q=document.querySelector("#tool_stroke rect"),A=document.querySelector("#tool_fill rect"),I=A.getAttribute("fill"),R=q.getAttribute("fill");q=parseFloat(q.getAttribute("stroke-opacity"));if(isNaN(q))q=100;A=parseFloat(A.getAttribute("fill-opacity"));if(isNaN(A))A=100;R=ab(R,q,"stroke");I=ab(I,A,"fill");la.fill.setPaint(R,true);la.stroke.setPaint(I,true)},E=function(q){var A=f.getResolution();q=q?A.zoom*q:1;a("#zoom").val(q*100);f.setZoom(q);B();Rb(true)},z=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?
a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");ra.toggleClass("wireframe");if(!tc){var q=a("#wireframe_rules");q.length?q.empty():a('<style id="wireframe_rules"></style>').appendTo("head");B()}},t=function(){f.clearSelection();a("#tool_canvas").trigger("click")},C=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},F=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");
a("#show_rulers").attr("checked",false);d.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);d.showRulers=true}a("#rulers").toggle(!!d.showRulers)},B=function(){if(!tc){var q="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+"px; }";a("#wireframe_rules").text(ra.hasClass("wireframe")?q:"")}},D=function(q,A){if(!Ka){Ka=true;a("#save_output_btns").toggle(!!A);a("#tool_source_back").toggle(!A);var I=sa=f.getSvgString();a("#svg_source_textarea").val(I);
a("#svg_source_editor").fadeIn();P();a("#svg_source_textarea").focus()}},H=function(){if(!Ra){Ra=true;a("#image_save_opts input").val([b.img_save]);var q=f.getResolution();if(d.baseUnit!=="px"){q.w=svgedit.units.convertUnit(q.w)+d.baseUnit;q.h=svgedit.units.convertUnit(q.h)+d.baseUnit}a(".canvas_width").val(q.w);a(".canvas_height").val(q.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},G=function(){if(!Na){Na=true;var q=a("#bg_blocks div"),A=a.pref("bkgd_color"),I=a.pref("bkgd_url");
q.each(function(){var R=a(this),X=R.css("background-color")==A;R.toggleClass("cur_background",X);X&&a("#canvas_bg_url").removeClass("cur_background")});A||q.eq(0).addClass("cur_background");I&&a("#canvas_bg_url").val(I);a("grid_snapping_step").attr("value",d.snappingStep);d.gridSnapping==true?a("#grid_snapping_on").attr("checked","checked"):a("#grid_snapping_on").removeAttr("checked");a("#svg_prefs").show()}},P=function(){var q=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",
q)},Q=function(){if(Ka){var q=function(){f.clearSelection();zb();E();Ab();W();la.fill.prep();la.stroke.prep()};f.setSvgString(a("#svg_source_textarea").val())?q():a.confirm(e.notification.QerrorsRevertToSource,function(A){if(!A)return false;q()});oa()}},W=function(q){q=q||f.getDocumentTitle();q=Wa+(q?": "+q:"");a("title:first").text(q)},ua=function(){var q=a("#canvas_width"),A=q.val(),I=a("#canvas_height"),R=I.val();if(A!="fit"&&!svgedit.units.isValidUnit("width",A)){a.alert(e.notification.invalidAttrValGiven);
q.parent().addClass("error");return false}q.parent().removeClass("error");if(R!="fit"&&!svgedit.units.isValidUnit("height",R)){a.alert(e.notification.invalidAttrValGiven);I.parent().addClass("error");return false}I.parent().removeClass("error");if(!f.setResolution(A,R)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Rb();Qb()},wa=function(){var q=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";
p(q,a("#canvas_bg_url").val());q=a("#lang_select").val();q!=b.lang&&c.putLocale(q);za(a("#iconsize").val());d.gridSnapping=a("#grid_snapping_on")[0].checked;d.snappingStep=a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);d.showRulers&&da();d.baseUnit=a("#base_unit").val();f.setConfig(d);Rb();Ib()},fa=c.setIcon=function(q,A){var I=typeof A==="string"?a.getSvgIcon(A,true):A.clone();I?a(q).find("img").replaceWith(I):console.log("NOTE: Icon image missing: "+
A)},ka;ka=function(){var q=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,A=document.getElementsByTagName("script")[0],I;for(I in A.style)if(q.test(I))return I.match(q)[0];if("WebkitOpacity"in A.style)return"Webkit";if("KhtmlOpacity"in A.style)return"Khtml";return""}();var qa=function(q,A){ka.toLowerCase();var I=["top","left","bottom","right"];q.each(function(){for(var R=a(this),X=R.outerWidth()*(A-1),ja=R.outerHeight()*(A-1),va=0;va<4;va++){var ya=I[va],Da=R.data("orig_margin-"+ya);if(Da==null){Da=parseInt(R.css("margin-"+
ya));R.data("orig_margin-"+ya,Da)}Da=Da*A;if(ya==="right")Da+=X;else if(ya==="bottom")Da+=ja;R.css("margin-"+ya,Da)}})},za=c.setIconSize=function(q,A){if(!(q==b.size&&!A)){var I=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),R=1;R=typeof q=="number"?q:{s:0.75,m:1,l:1.25,xl:1.5}[q];c.tool_scale=S=R;Cb();var X=I.parents(":hidden");X.css("visibility",
"hidden").show();qa(I,R);X.css("visibility","visible").hide();a.pref("iconsize",q);a("#iconsize").val(q);X={"#tools_top":{left:50,height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};I=a("#tool_size_rules");if(I.length)I.empty();else I=a('<style id="tool_size_rules"></style>').appendTo("head");if(q!="m"){var ja="";a.each(X,function(va,ya){va="#svg_editor "+va.replace(/,/g,", #svg_editor");ja+=va+"{";a.each(ya,function(Da,Ca){if(typeof Ca==="number")var Ba=Ca*R+"px";else if(Ca[q]||
Ca.all)Ba=Ca[q]||Ca.all;ja+=Da+":"+Ba+";"});ja+="}"});X="-"+ka.toLowerCase()+"-";ja+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+X+"transform: scale("+R+");} #svg_editor div.toolset .toolset {"+X+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+X+"transform: scale("+1/R+");}";I.text(ja)}Cb()}},jb=function(){a("#dialog_box").hide();
if(!Ka&&!Ra&&!Na)Sa&&f.leaveContext();else{if(Ka)sa!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(q){q&&zb()}):zb();else if(Ra)Qb();else Na&&Ib();Ub()}},zb=function(){a("#svg_source_editor").hide();Ka=false;a("#svg_source_textarea").blur()},Qb=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=0;a("#image_save_opts input").val([b.img_save]);Ra=false},Ib=function(){a("#svg_prefs").hide();
Na=false},Ob={width:a(window).width(),height:a(window).height()},Ub=a.noop,ac;svgedit.browser.isIE()&&function(){Ub=function(){if(ra[0].scrollLeft===0&&ra[0].scrollTop===0){ra[0].scrollLeft=ac.left;ra[0].scrollTop=ac.top}};ac={left:ra[0].scrollLeft,top:ra[0].scrollTop};a(window).resize(Ub);svgEditor.ready(function(){setTimeout(function(){Ub()},500)});ra.scroll(function(){ac={left:ra[0].scrollLeft,top:ra[0].scrollTop}})}();a(window).resize(function(){Ka&&P();a.each(Ob,function(q,A){var I=a(window)[q]();
ra[0]["scroll"+(q==="width"?"Left":"Top")]-=(I-A)/2;Ob[q]=I})});(function(){ra.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=ra[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=ra[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(L);(function(){var q=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],A="";a.each(q,function(I,R){A+="#tool_"+
R+(I==q.length-1?",":"")});a(A).mousedown(function(){a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")});a("#tool_undo, #tool_redo").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")})})();if(V&&!window.opera){V=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(var Bb=V.length;Bb--;){var pc=
document.getElementById(V[Bb]);if(pc!=null){var qc=pc.title,uc=qc.indexOf("Ctrl+");pc.title=[qc.substr(0,uc),"Cmd+",qc.substr(uc+5)].join("")}}}var rc=function(q){var A=q[0].id=="stroke_color"?"stroke":"fill",I=q[0].id=="canvas_color";if(I)A="canvas";var R=la[A].paint;q=A=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";I=I?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(I).jGraduate({paint:R,
window:{pickerTitle:q},images:{clientPath:d.jGraduatePath},newstop:"inverse"},function(X){R=new a.jGraduate.Paint(X);la[A].setPaint(R);f.setPaint(A,R);a("#color_picker").hide()},function(){a("#color_picker").hide()})};V=function(q,A){var I=document.getElementById("canvas_background"),R={color:"fff",opacity:1};if(A=="stroke")R=d.initStroke;if(A=="fill")R=d.initFill;if(A=="canvas"&&I)if(I=I.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))R={color:("0"+parseInt(I[1],10).toString(16)).slice(-2)+
("0"+parseInt(I[2],10).toString(16)).slice(-2)+("0"+parseInt(I[3],10).toString(16)).slice(-2),opacity:1};I=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+R.color+'" opacity="'+R.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;I=a(q)[0].appendChild(document.importNode(I,true));I.setAttribute("width",24.5);this.rect=I.firstChild;this.defs=I.getElementsByTagName("defs")[0];
this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:R.color});this.type=A;this.setPaint=function(X,ja){this.paint=X;var va="none",ya=X.type,Da=X.alpha/100;switch(ya){case "solidColor":va=X[ya]=="none"||X[ya]=="one"?"none":"#"+X[ya];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(X[ya]);va="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",va);this.rect.setAttribute("opacity",Da);if(ja){f.setColor(this.type,
va,true);f.setPaintOpacity(this.type,Da,true)}if(this.type=="canvas"){(ya=document.getElementById("canvas_background"))?ya.setAttribute("fill",va):La(va);console.log(ya.getAttribute("fill"))}};this.update=function(X){if(Z){var ja=this.type;switch(Z.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var va=null,ya=Z.getElementsByTagName("*"),Da=0,Ca=ya.length;Da<Ca;Da++){var Ba=ya[Da].getAttribute(ja);if(Da===0)va=Ba;else if(va!==Ba){va=null;break}}if(va===null){ya=
null;return}ya=va;va=1;break;default:va=parseFloat(Z.getAttribute(ja+"-opacity"));if(isNaN(va))va=1;ya=ja==="fill"?"black":"none";ya=Z.getAttribute(ja)||ya}if(X){f.setColor(ja,ya,true);f.setPaintOpacity(ja,va,true)}va*=100;this.setPaint(ab(ya,va,ja))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var X=new a.jGraduate.Paint({copy:this.paint});f.setPaint(A,X)}}};la.fill=new V("#fill_color","fill");la.stroke=new V("#stroke_color","stroke");la.canvas=new V("#canvas_color",
"canvas");a("#stroke_width").val(d.initStroke.width);a("#group_opacity").val(d.initOpacity*100);V=la.fill.rect.cloneNode(false);V.setAttribute("style","vector-effect:non-scaling-stroke");var tc=V.style.vectorEffect==="non-scaling-stroke";V.removeAttribute("style");V=la.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof V.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(V).remove();setTimeout(function(){f.embedImage("images/placeholder.svg",function(q){if(!q){a("#image_save_opts [value=embed]").attr("disabled",
"disabled");a("#image_save_opts input").val(["ref"]);b.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",e.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))rc(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_canvas").click(function(){rc(a("#canvas_color"))});a("#tool_stroke").click(function(){if(a("#tool_stroke").hasClass("active"))rc(a("#stroke_color"));else{a("#tool_stroke").addClass("active");
a("#tool_fill").removeClass("active")}});a("#group_opacityLabel").click(function(){a("#opacity_dropdown button").mousedown();a(window).mouseup()});a("#zoomLabel").click(function(){a("#zoom_dropdown button").mousedown();a(window).mouseup()});a("#tool_move_top").mousedown(function(q){a("#tools_stacking").show();q.preventDefault()});a(".layer_button").mousedown(function(){a(this).addClass("layer_buttonpressed")}).mouseout(function(){a(this).removeClass("layer_buttonpressed")}).mouseup(function(){a(this).removeClass("layer_buttonpressed")});
a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a("#layer_new").click(function(){var q=f.getCurrentDrawing().getNumLayers();do var A=e.layers.layer+" "+ ++q;while(f.getCurrentDrawing().hasLayer(A));a.prompt(e.notification.enterUniqueLayerName,
A,function(I){if(I)if(f.getCurrentDrawing().hasLayer(I))a.alert(e.notification.dupeLayerName);else{f.createLayer(I);Ja();Ab()}})});a("#layer_delete").click(T);a("#layer_up").click(function(){J(-1)});a("#layer_down").click(function(){J(1)});a("#layer_rename").click(function(){a("#layerlist tr.layersel").prevAll();var q=a("#layerlist tr.layersel td.layername").text();a.prompt(e.notification.enterNewLayerName,"",function(A){if(A)if(q==A||f.getCurrentDrawing().hasLayer(A))a.alert(e.notification.layerHasThatName);
else{f.renameCurrentLayer(A);Ab()}})});var bc=-1,lc=false,sc=false,vc=function(q){if(sc)if(bc!=-1){lc=true;q=bc-q.pageX;var A=a("#sidepanels"),I=parseInt(A.css("width"));if(I+q>300)q=300-I;else if(I+q<2)q=2-I;if(q!=0){bc-=q;I=a("#layerpanel");ra.css("right",parseInt(ra.css("right"))+q);A.css("width",parseInt(A.css("width"))+q);I.css("width",parseInt(I.css("width"))+q);A=a("#ruler_x");A.css("right",parseInt(A.css("right"))+q)}}};a("#sidepanel_handle").mousedown(function(q){bc=q.pageX;a(window).mousemove(vc);
sc=false;setTimeout(function(){sc=true},20)}).mouseup(function(){lc||wc();bc=-1;lc=false});a(window).mouseup(function(){bc=-1;lc=false;a("#svg_editor").unbind("mousemove",vc)});var wc=function(q){var A=parseInt(a("#sidepanels").css("width"));q=(A>2||q?2:150)-A;A=a("#sidepanels");var I=a("#layerpanel"),R=a("#ruler_x");ra.css("right",parseInt(ra.css("right"))+q);A.css("width",parseInt(A.css("width"))+q);I.css("width",parseInt(I.css("width"))+q);R.css("right",parseInt(R.css("right"))+q)},xc=function(q){for(var A=
Array(f.getCurrentDrawing().getNumLayers()),I=0;I<A.length;++I)A[I]=f.getCurrentDrawing().getLayerName(I);if(q)for(I=0;I<A.length;++I)A[I]!=q&&f.getCurrentDrawing().setLayerOpacity(A[I],0.5);else for(I=0;I<A.length;++I)f.getCurrentDrawing().setLayerOpacity(A[I],1)},Ab=function(){var q=a("#layerlist tbody"),A=a("#selLayerNames");q.empty();A.empty();for(var I=f.getCurrentDrawing().getCurrentLayerName(),R=f.getCurrentDrawing().getNumLayers(),X=a.getSvgIcon("eye");R--;){var ja=f.getCurrentDrawing().getLayerName(R),
va='<tr class="layer';if(ja==I)va+=" layersel";va+='">';va+=f.getCurrentDrawing().getLayerVisibility(ja)?'<td class="layervis"/><td class="layername" >'+ja+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+ja+"</td></tr>";q.append(va);A.append('<option value="'+ja+'">'+ja+"</option>")}if(X!==undefined){X.clone();a("td.layervis",q).append(X.clone());a.resizeSvgIcons({"td.layervis .svg_icon":14})}a("#layerlist td.layername").mouseup(function(ya){a("#layerlist tr.layer").removeClass("layersel");
a(this.parentNode).addClass("layersel");f.setCurrentLayer(this.textContent);ya.preventDefault()}).mouseover(function(){a(this).css({"font-style":"italic",color:"blue"});xc(this.textContent)}).mouseout(function(){a(this).css({"font-style":"normal",color:"black"});xc()});a("#layerlist td.layervis").click(function(){var ya=a(this.parentNode).prevAll().length;ya=a("#layerlist tr.layer:eq("+ya+") td.layername").text();var Da=a(this).hasClass("layerinvis");f.setLayerVisibility(ya,Da);Da?a(this).removeClass("layerinvis"):
a(this).addClass("layerinvis")});for(A=5-a("#layerlist tr.layer").size();A-- >0;)q.append('<tr><td style="color:white">_</td><td/></tr>')};Ab();a(window).bind("load resize",function(){ra.css("line-height",ra.height()+"px")});a("#resolution").change(function(){var q=a("#canvas_width,#canvas_height");if(this.selectedIndex)if(this.value=="content")q.val("fit").attr("disabled","disabled");else{var A=this.value.split("x");a("#canvas_width").val(A[0]);a("#canvas_height").val(A[1]);q.removeAttr("disabled")}else a("#canvas_width").val()==
"fit"&&q.removeAttr("disabled").val(100)});a("input,select").attr("autocomplete","off");var oc=function(){var q=[{sel:"#tool_select",fn:Gb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Hb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Mb,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Nb,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:ma,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:aa,evt:"click",key:["P",true]},{sel:"#tool_text",fn:N,evt:"click",key:["T",
true]},{sel:"#tool_image",fn:Y,evt:"mouseup"},{sel:"#tool_zoom",fn:na,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:mc,evt:"mouseup",key:[ga+"N",true]},{sel:"#tool_save",fn:function(){Ka?Q():f.save({images:b.img_save,round_digits:6})},evt:"mouseup",key:[ga+"S",true]},{sel:"#tool_export",fn:kc,evt:"mouseup"},{sel:"#tool_open",fn:jc,evt:"mouseup"},{sel:"#tool_import",fn:Wb,evt:"mouseup"},{sel:"#tool_source",fn:D,evt:"click",key:[ga+"U",true]},{sel:"#tool_wireframe",fn:z,evt:"click"},{sel:"#tool_rulers",
fn:F,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:jb,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Q,evt:"click"},{sel:"#tool_docprops_save",fn:ua,evt:"click"},{sel:"#tool_docprops",fn:H,evt:"mouseup"},{sel:"#tool_prefs_save",fn:wa,evt:"click"},{sel:"#tool_prefs_option",fn:function(){G();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:Pa,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",
fn:$b,evt:"click"},{sel:"#tool_node_link",fn:Ua,evt:"click"},{sel:"#tool_node_clone",fn:ic,evt:"click"},{sel:"#tool_node_delete",fn:ec,evt:"click"},{sel:"#tool_openclose_path",fn:fc,evt:"click"},{sel:"#tool_add_subpath",fn:cc,evt:"click"},{sel:"#tool_move_top",fn:Db,evt:"click",key:ga+"shift+up"},{sel:"#tool_move_bottom",fn:cb,evt:"click",key:ga+"shift+down"},{sel:"#tool_move_up",fn:Eb,evt:"click",key:[ga+"up",true]},{sel:"#tool_move_down",fn:$a,evt:"click",key:[ga+"down",true]},{sel:"#tool_topath",
fn:Pb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:Zb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:k,evt:"click",key:[ga+"D",true]},{sel:"#tool_group",fn:h,evt:"click",key:[ga+"G",true]},{sel:"#tool_ungroup",fn:h,evt:"click",key:ga+"shift+G"},{sel:"#tool_unlink_use",fn:h,evt:"click"},{sel:"[id^=tool_align]",fn:v,evt:"click"},{sel:"#tool_switch",fn:s,evt:"click",key:["shift+x",true]},{sel:"#tool_undo",fn:dc,evt:"click",key:ga+"z"},{sel:"#tool_redo",fn:g,evt:"click",key:["y",
true]},{sel:"#tool_canvas_color_menu",fn:t,evt:"click"},{sel:"#tool_cut",fn:Xa,evt:"click",key:ga+"x"},{sel:"#tool_copy",fn:hb,evt:"click",key:ga+"c"},{sel:"#tool_paste",fn:pb,evt:"click",key:ga+"v"},{sel:"#tool_bold",fn:Vb,evt:"mousedown",key:[ga+"B",true]},{sel:"#tool_italic",fn:vb,evt:"mousedown",key:[ga+"I",true]},{sel:"#copy_save_done",fn:jb,evt:"click"},{key:"ctrl+left",fn:function(){Sb(0,1)}},{key:"ctrl+right",fn:function(){Sb(1,1)}},{key:"ctrl+shift+left",fn:function(){Sb(0,5)}},{key:"ctrl+shift+right",
fn:function(){Sb(1,5)}},{key:"shift+O",fn:Tb},{key:"shift+P",fn:gc},{key:[ga+"+",true],fn:function(){E(2)}},{key:[ga+"-",true],fn:function(){E(0.5)}},{key:["up",true],fn:function(){gb(0,-1)}},{key:["down",true],fn:function(){gb(0,1)}},{key:["left",true],fn:function(){gb(-1,0)}},{key:["right",true],fn:function(){gb(1,0)}},{key:"shift+up",fn:function(){gb(0,-10)}},{key:"shift+down",fn:function(){gb(0,10)}},{key:"shift+left",fn:function(){gb(-10,0)}},{key:"shift+right",fn:function(){gb(10,0)}},{key:["alt+up",
true],fn:function(){f.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){f.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){f.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){f.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){f.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){f.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){f.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",
true],fn:function(){f.cloneSelectedElements(10,0)}},{key:ga+"A",fn:function(){f.selectAllInCurrentLayer()}},{key:ga+"shift+z",fn:g},{key:"esc",fn:C}],A={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var I={};a.each(q,function(R,X){if(X.sel){var ja=a(X.sel);if(ja.length==0)return true;if(X.evt){if(svgedit.browser.isTouch()&&X.evt==="click")X.evt="mousedown";ja[X.evt](X.fn)}if(X.parent&&a(X.parent+"_show").length!=0){var va=a(X.parent);va.length||(va=Ga(X.parent.substr(1)));
va.append(ja);a.isArray(I[X.parent])||(I[X.parent]=[]);I[X.parent].push(X)}}if(X.key){var ya=X.fn,Da=false;if(a.isArray(X.key)){va=X.key[0];if(X.key.length>1)Da=X.key[1]}else va=X.key;va+="";svgedit.browser.isMac&&va.indexOf("+")!=-1&&va.split("+")[0]=="ctrl"&&va.replace("ctrl","cmd");a.each(va.split("/"),function(Ba,tb){a(document).bind("keydown",tb,function(Ta){ya();Da&&Ta.preventDefault();return false})});if(X.sel&&!X.hidekey&&ja.attr("title")){var Ca=ja.attr("title").split("[")[0]+" ("+va+")";
A[va]=X.sel;ja.parents("#main_menu").length||ja.attr("title",Ca)}}});Qa(I);a(".attr_changer, #image_url").bind("keydown","return",function(R){a(this).change();R.preventDefault()});a(window).bind("keydown","tab",function(R){if(U==="canvas"){R.preventDefault();gc()}}).bind("keydown","shift+tab",function(R){if(U==="canvas"){R.preventDefault();Tb()}});a("#tool_zoom").dblclick(K)},setTitles:function(){a.each(A,function(I,R){var X=a(R).parents("#main_menu").length;a(R).each(function(){var ja=X?a(this).text().split(" [")[0]:
this.title.split(" [")[0],va="";a.each(I.split("/"),function(ya,Da){var Ca=Da.split("+"),Ba="";if(Ca.length>1){Ba=Ca[0]+"+";Da=Ca[1]}va+=(ya?"/":"")+Ba+(e["key_"+Da]||Da)});if(X)this.lastChild.textContent=ja+" ["+va+"]";else this.title=ja+" ["+va+"]"})})},getButtonData:function(I){var R;a.each(q,function(X,ja){if(ja.sel===I)R=ja});return R}}}();oc.setAll();c.ready(function(){var q=d.initTool,A=a("#tools_left, #svg_editor .tools_flyout"),I=A.find("#tool_"+q);q=A.find("#"+q);(I.length?I:q.length?q:
a("#tool_select")).click().mouseup();d.wireframe&&a("#tool_wireframe").click();d.showlayers&&wc();a("#rulers").toggle(!!d.showRulers);if(d.showRulers)a("#show_rulers")[0].checked=true;if(d.gridSnapping)a("#grid_snapping_on")[0].checked=true;d.baseUnit&&a("#base_unit").val(d.baseUnit);d.snappingStep&&a("#grid_snapping_step").val(d.snappingStep)});a("#rect_rx").SpinButton({min:0,max:1E3,step:1,callback:function(q){f.setRectRadius(q.value)}});a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,
callback:function(q){var A=q.value;if(A==0&&Z&&["line","polyline"].indexOf(Z.nodeName)>=0)A=q.value=1;f.setStrokeWidth(A)}});a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(q){f.setRotationAngle(q.value);a("#tool_reorient").toggleClass("disabled",q.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(q,A){var I=q.value-0,R=I+A,X=R>=I;if(A===0)return I;return I>=24?X?Math.round(I*1.1):Math.round(I/1.1):I<=1?X?I*2:I/2:R},callback:function(q){f.setFontSize(q.value)}});
a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:xb});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:fb});a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(q,A){var I=q.value-0;if(I===0)return 100;var R=I+A;if(A===0)return I;return I>=100?R:R>=I?I*2:I/2},callback:ob}).val(f.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(q){switch(q){case "delete":Pa();break;case "cut":Xa();break;case "copy":hb();break;case "paste":f.pasteElements();
break;case "paste_in_place":f.pasteElements("in_place");break;case "group":f.groupSelectedElements();break;case "ungroup":f.ungroupSelectedElement();break;case "move_front":Db();break;case "move_up":Fb("Up");break;case "move_down":Fb("Down");break;case "move_back":cb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(q)&&svgedit.contextmenu.getCustomHandler(q).call()}f.clipBoard.length&&pa.enableContextMenuItems("#paste,#paste_in_place")});V=function(q){switch(q){case "dupe":M();
break;case "delete":T();break;case "merge_down":if(a("#layerlist tr.layersel").index()!=f.getCurrentDrawing().getNumLayers()-1){f.mergeLayer();Ja();Ab()}break;case "merge_all":f.mergeAllLayers();Ja();Ab()}};a("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},V);a("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:true},V);a(".contextMenu li").mousedown(function(q){q.preventDefault()});a("#cmenu_canvas li").disableContextMenu();pa.enableContextMenuItems("#delete,#cut,#copy");
window.onbeforeunload=function(){if(ha.getUndoStackSize()===0)c.show_save_warning=false;if(!d.no_save_warning&&c.show_save_warning)return e.notification.unsavedChanges};c.openPrep=function(q){a("#main_menu").hide();ha.getUndoStackSize()===0?q(true):a.confirm(e.notification.QwantToOpen,q)};if(window.FileReader){V=a('<input type="file">').change(function(){var q=this;c.openPrep(function(A){if(A){f.clear();if(q.files.length==1){A=new FileReader;A.onloadend=function(I){n(I.target.result);Rb()};A.readAsText(q.files[0])}}})});
a("#tool_open").show().prepend(V);V=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var q=new FileReader;q.onloadend=function(A){f.importSvgString(A.target.result,true);Rb()};q.readAsText(this.files[0])}});a("#tool_import").show().prepend(V)}var Rb=c.updateCanvas=function(q,A){var I=ra.width(),R=ra.height(),X=I,ja=R,va=f.getZoom(),ya=a("#svgcanvas"),Da={x:ra[0].scrollLeft+X/2,y:ra[0].scrollTop+ja/2},Ca=d.canvas_expansion;I=Math.max(X,f.contentW*va*Ca);R=
Math.max(ja,f.contentH*va*Ca);I==X&&R==ja?ra.css("overflow","hidden"):ra.css("overflow","scroll");Ca=ya.height()/2;var Ba=ya.width()/2;ya.width(I).height(R);var tb=R/2,Ta=I/2,ia=f.updateCanvas(I,R),wb=Ta/Ba;I=I/2-X/2;R=R/2-ja/2;if(A){A.x+=ia.x;A.y+=ia.y}else A={x:Ta+(Da.x-Ba)*wb,y:tb+(Da.y-Ca)*wb};if(q)if(f.contentW>ra.width()){ra[0].scrollLeft=ia.x-10;ra[0].scrollTop=ia.y-10}else{ra[0].scrollLeft=I;ra[0].scrollTop=R}else{ra[0].scrollLeft=A.x-X/2;ra[0].scrollTop=A.y-ja/2}if(d.showRulers){da(ya,va);
ra.scroll()}},hc=[];for(Bb=0.1;Bb<1E5;Bb*=10){hc.push(1*Bb);hc.push(2*Bb);hc.push(5*Bb)}Rb(true);try{var yc=function(q){if(window.JSON&&JSON.stringify)return JSON.stringify(q);var A=arguments.callee;if(typeof q=="boolean"||typeof q=="number")return q+"";else if(typeof q=="string")return'"'+q.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(X){return"\\u"+("0000"+X.charCodeAt(0).toString(16)).slice(-4)})+'"';
else if(q.length){for(var I=0;I<q.length;I++)q[I]=A(q[I]);return"["+q.join(",")+"]"}else{I=[];for(var R in q)I.push(A(R)+":"+A(q[R]));return"{"+I.join(",")+"}"}};window.addEventListener("message",function(q){var A=parseInt(q.data.substr(0,q.data.indexOf(";")));try{q.source.postMessage("SVGe"+A+";"+yc(eval(q.data)),"*")}catch(I){q.source.postMessage("SVGe"+A+";error:"+I.message,"*")}},false)}catch(zc){window.embed_error=zc}a(function(){window.svgCanvas=f;f.ready=svgEditor.ready});c.setLang=function(q,
A){a.pref("lang",q);a("#lang_select").val(q);if(A){var I=a("#layerlist tr.layersel td.layername").text()==e.common.layer+" 1";a.extend(e,A);f.setUiStrings(A);oc.setTitles();if(I){f.renameCurrentLayer(e.common.layer+" 1");Ab()}f.runExtensions("langChanged",q);Kb();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(R,X){a(X).attr("title",a(R)[0].title)});
a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var u=[];c.ready=function(w){m?w():u.push(w)};c.runCallbacks=function(){a.each(u,function(){this()});m=true};c.loadFromString=function(w){c.ready(function(){n(w)})};c.disableUI=function(){};c.loadFromURL=function(w,p){p||(p={});var L=p.cache,T=p.callback;c.ready(function(){a.ajax({url:w,dataType:"text",cache:!!L,success:function(M){n(M,T)},error:function(M,J,da){M.status!=404&&
M.responseText?n(M.responseText,T):a.alert(e.notification.URLloadFail+": \n"+da+"",T)}})})};c.loadFromDataURI=function(w){c.ready(function(){var p=w.substring(26);n(svgedit.utilities.decode64(p))})};c.addExtension=function(){var w=arguments;a(function(){f&&f.addExtension.apply(this,w)})};return c}(jQuery);$(svgEditor.init)})();svgedit=svgedit||{};
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var n=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var f=n.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+n.id+"'>"+n.label+"<span class='shortcut'>"+f+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
{}};svgedit.contextmenu.add=function(n){if(n&&n.id&&n.label&&n.action&&typeof n.action=="function")if(n.id in a.contextMenuExtensions)console.error('Cannot add extension "'+n.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+n.id+", label:"+n.label+"}");a.contextMenuExtensions[n.id]=n}else console.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function")};svgedit.contextmenu.hasCustomHandler=
function(n){return a.contextMenuExtensions[n]&&true};svgedit.contextmenu.getCustomHandler=function(n){return a.contextMenuExtensions[n].action}})();var svgEditor=function(a,n){function f(m,o,b){var d=a("#svg_editor").parent(),e;for(e in o){var l=o[e];l||console.log(e);if(b)e="#"+e;if(d.find(e).length){var u=d.find(e)[0];switch(m){case "content":for(var w=0;w<u.childNodes.length;w++){var p=u.childNodes[w];if(p.nodeType===3&&p.textContent.replace(/\s/g,"")){p.textContent=l;break}}break;case "title":u.title=l}}else console.log("Missing: "+e)}}var c;n.readLang=function(m){var o=n.canvas.runExtensions("addlangData",c,true);a.each(o,function(T,M){if(M.data)m=

File diff suppressed because one or more lines are too long