gradient inversion code now accepts shorthand hex
parent
7897117f63
commit
11c9f22521
|
@ -382,13 +382,16 @@ jQuery.fn.jGraduate =
|
|||
case 'inverse':
|
||||
// Invert current color for second stop
|
||||
var inverted = '';
|
||||
|
||||
if (color.length === 3) {
|
||||
color = color.split("").map(function(d){return d + "" + d}).join("");
|
||||
}
|
||||
for(var i = 0; i < 6; i += 2) {
|
||||
var ch = color.substr(i, 2);
|
||||
var inv = (255 - parseInt(color.substr(i, 2), 16)).toString(16);
|
||||
if(inv.length < 2) inv = 0 + inv;
|
||||
inverted += inv;
|
||||
}
|
||||
console.log(inverted)
|
||||
mkStop(1, '#' + inverted, 1);
|
||||
break;
|
||||
|
||||
|
@ -460,16 +463,6 @@ jQuery.fn.jGraduate =
|
|||
|
||||
var coords = $(idref + ' .grad_coord');
|
||||
|
||||
// $(container).hover(function() {
|
||||
// coords.animate({
|
||||
// opacity: 1
|
||||
// }, 500);
|
||||
// }, function() {
|
||||
// coords.animate({
|
||||
// opacity: .2
|
||||
// }, 500);
|
||||
// });
|
||||
|
||||
$.each(['x1', 'y1', 'x2', 'y2', 'cx', 'cy', 'fx', 'fy'], function(i, attr) {
|
||||
var attrval = curGradient.getAttribute(attr);
|
||||
|
||||
|
@ -514,8 +507,6 @@ jQuery.fn.jGraduate =
|
|||
}).change();
|
||||
});
|
||||
|
||||
|
||||
|
||||
function mkStop(n, color, opac, sel, stop_elem) {
|
||||
var stop = stop_elem || mkElem('stop',{'stop-color':color,'stop-opacity':opac,offset:n}, curGradient);
|
||||
if(stop_elem) {
|
||||
|
|
|
@ -105,25 +105,25 @@ v+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click
|
|||
v+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+v+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+v+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+v+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+B.images.clientPath+
|
||||
'rangearrows2.gif"></div><label><input type="text" id="'+v+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba </label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+v+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+v+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+v+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
|
||||
v+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+v+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var Z=256,qa=Z-0,aa=Z-0,Y,ga,Ba,ja={};$(".jGraduate_SliderBar").width(145);var da=$("#"+v+"_jGraduate_GradContainer")[0],U=a("svg",{id:v+"_jgraduate_svg",width:Z,height:Z,xmlns:o.svg},da);Y=Y||w.paint.type;var X=ga=w.paint[Y],na=w.paint.alpha,oa=Y==="solidColor";switch(Y){case "solidColor":case "linearGradient":if(!oa){ga.id=v+"_lg_jgraduate_grad";X=
|
||||
ga=U.appendChild(ga)}a("radialGradient",{id:v+"_rg_jgraduate_grad"},U);if(Y==="linearGradient")break;case "radialGradient":if(!oa){ga.id=v+"_rg_jgraduate_grad";X=ga=U.appendChild(ga)}a("linearGradient",{id:v+"_lg_jgraduate_grad"},U)}if(oa){X=ga=$("#"+v+"_lg_jgraduate_grad")[0];I=w.paint[Y];s(0,"#"+I,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+I,1);break;case "inverse":ma="";for(var la=0;la<6;la+=2){I.substr(la,2);var ya=(255-parseInt(I.substr(la,2),16)).toString(16);
|
||||
if(ya.length<2)ya=0+ya;ma+=ya}s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+I,"opac"in B.newstop?B.newstop.opac:1)}I=parseFloat(X.getAttribute("x1")||0);ma=parseFloat(X.getAttribute("y1")||0);la=parseFloat(X.getAttribute("x2")||1);ya=parseFloat(X.getAttribute("y2")||0);var za=parseFloat(X.getAttribute("cx")||0.5),Ja=parseFloat(X.getAttribute("cy")||0.5),Ia=parseFloat(X.getAttribute("fx")||za),Fa=parseFloat(X.getAttribute("fy")||
|
||||
Ja);Ba=a("rect",{id:v+"_jgraduate_rect",x:0,y:0,width:qa,height:aa,fill:"url(#"+v+"_jgraduate_grad)","fill-opacity":na/100},U);var Ma=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*Z,left:I*Z}).data("coord","start").appendTo(da),Da=Ma.clone().text(2).css({top:ya*Z,left:la*Z}).attr("title","End stop").data("coord","end").appendTo(da),wa=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ja*Z,left:za*
|
||||
Z}).data("coord","center").appendTo(da),ra=wa.clone().text("F").css({top:Fa*Z,left:Ia*Z,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);ra[0].id=v+"_jGraduate_focusCoord";$(N+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ia,ba){var ka=ga.getAttribute(ba),M=isNaN(ba[1]);ka||(ka=M?"0.5":ba==="x2"?"1.0":"0.0");ja[ba]=$("#"+v+"_jGraduate_"+ba).val(ka).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
|
||||
1)this.value=1;if(!(ba[0]==="f"&&!eb))if(M&&Y==="radialGradient"||!M&&Y==="linearGradient")ga.setAttribute(ba,this.value);var P=M?ba[0]==="c"?wa:ra:ba[1]==="1"?Ma:Da,ea=ba.indexOf("x")>=0?"left":"top";P.css(ea,this.value*Z)}).change()});var va,kb,vb=$("#"+v+"_jGraduate_StopSlider"),cb,Ta,Va,Ga=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Ta),ta,$a=1,Ka=1,Sa=0,Ha=za,db=Ja;Ta=a("svg",{width:"100%",height:45},vb[0]);da=a("pattern",{width:16,
|
||||
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Ta);a("image",{width:16,height:16},da).setAttributeNS(o.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Ta).on("click touchstart",function(ia){ta=vb.offset();if(ia.target.tagName!=="path"){var ba=ia.pageX-ta.left-8;ba=ba<10?10:ba>Z+10?Z+10:ba;s(ba/Z,0,0,true);ia.stopPropagation()}});$(Ta).mouseover(function(){Ta.appendChild(Ga)});kb=a("g",{},Ta);a("line",{x1:10,y1:15,x2:Z+10,y2:15,"stroke-width":2,stroke:"#000"},Ta);var lb=
|
||||
L.find(".jGraduate_spreadMethod").change(function(){ga.setAttribute("spreadMethod",$(this).val())}),Ua=null,Xa=function(ia){var ba=ia.pageX-hb.left,ka=ia.pageY-hb.top;ba=ba<0?0:ba>Z?Z:ba;ka=ka<0?0:ka>Z?Z:ka;Ua.css("left",ba).css("top",ka);ba=ba/qa;ka=ka/aa;var M=Ua.data("coord"),P=ga;switch(M){case "start":ja.x1.val(ba);ja.y1.val(ka);P.setAttribute("x1",ba);P.setAttribute("y1",ka);break;case "end":ja.x2.val(ba);ja.y2.val(ka);P.setAttribute("x2",ba);P.setAttribute("y2",ka);break;case "center":ja.cx.val(ba);
|
||||
ja.cy.val(ka);P.setAttribute("cx",ba);P.setAttribute("cy",ka);Ha=ba;db=ka;d();break;case "focus":ja.fx.val(ba);ja.fy.val(ka);P.setAttribute("fx",ba);P.setAttribute("fy",ka);d()}ia.preventDefault()},wb=function(){Ua=null;S.unbind("mousemove",Xa).unbind("mouseup",wb)};va=ga.getElementsByTagNameNS(o.svg,"stop");if(sa<2){for(;sa<2;){ga.appendChild(document.createElementNS(o.svg,"stop"));++sa}va=ga.getElementsByTagNameNS(o.svg,"stop")}var sa=va.length;for(la=0;la<sa;la++)s(0,0,0,0,va[la]);lb.val(ga.getAttribute("spreadMethod")||
|
||||
"pad");var hb,eb=false;Ba.setAttribute("fill-opacity",na/100);$("#"+v+" div.grad_coord").mousedown(function(ia){ia.preventDefault();Ua=$(this);Ua.offset();hb=Ua.parent().offset();S.mousemove(Xa).mouseup(wb)});$("#"+v+"_jGraduate_Ok").bind("click touchstart",function(){w.paint.type=Y;w.paint[Y]=ga.cloneNode(true);w.paint.solidColor=null;Q()});$("#"+v+"_jGraduate_Cancel").bind("click touchstart",function(){K()});if(Y==="radialGradient")if(eb)ra.show();else{ra.hide();ja.fx.val("");ja.fy.val("")}$("#"+
|
||||
v+"_jGraduate_match_ctr")[0].checked=!eb;var sb,ib;$("#"+v+"_jGraduate_match_ctr").change(function(){eb=!this.checked;ra.toggle(eb);ja.fx.val("");ja.fy.val("");var ia=ga;if(eb){var ba=sb||0.5,ka=ib||0.5;ia.setAttribute("fx",ba);ia.setAttribute("fy",ka);ja.fx.val(ba);ja.fy.val(ka)}else{sb=ia.getAttribute("fx");ib=ia.getAttribute("fy");ia.removeAttribute("fx");ia.removeAttribute("fy")}});va=ga.getElementsByTagNameNS(o.svg,"stop");sa=va.length;if(sa<2){for(;sa<2;){ga.appendChild(document.createElementNS(o.svg,
|
||||
"stop"));++sa}va=ga.getElementsByTagNameNS(o.svg,"stop")}var ab;na=L=0;if(Y==="radialGradient"){U=ga.gradientTransform.baseVal;if(U.numberOfItems===2){sa=U.getItem(0);U=U.getItem(1);if(sa.type===2&&U.type===3){sa=U.matrix;if(sa.a!==1)L=Math.round(-(1-sa.a)*100);else if(sa.d!==1)L=Math.round((1-sa.d)*100)}}else if(U.numberOfItems===3){da=U.getItem(0);sa=U.getItem(1);U=U.getItem(2);if(da.type===4&&sa.type===2&&U.type===3){na=Math.round(da.angle);sa=U.matrix;if(sa.a!==1)L=Math.round(-(1-sa.a)*100);else if(sa.d!==
|
||||
1)L=Math.round((1-sa.d)*100)}}}L={radius:{handle:"#"+v+"_jGraduate_RadiusArrows",input:"#"+v+"_jGraduate_RadiusInput",val:(ga.getAttribute("r")||0.5)*100},opacity:{handle:"#"+v+"_jGraduate_OpacArrows",input:"#"+v+"_jGraduate_OpacInput",val:w.paint.alpha||100},ellip:{handle:"#"+v+"_jGraduate_EllipArrows",input:"#"+v+"_jGraduate_EllipInput",val:L},angle:{handle:"#"+v+"_jGraduate_AngleArrows",input:"#"+v+"_jGraduate_AngleInput",val:na}};$.each(L,function(ia,ba){var ka=$(ba.handle);ka.mousedown(function(M){var P=
|
||||
ka.parent();ab={type:ia,elem:ka,input:$(ba.input),parent:P,offset:P.offset()};S.mousemove(ob).mouseup(pb);M.preventDefault()});$(ba.input).val(ba.val).change(function(){var M=+this.value,P=0,ea=Y==="radialGradient";switch(ia){case "radius":ea&&ga.setAttribute("r",M/100);P=Math.pow(M/100,0.4)/2*145;break;case "opacity":w.paint.alpha=M;Ba.setAttribute("fill-opacity",M/100);P=M*1.45;break;case "ellip":$a=Ka=1;if(M===0){P=72.5;break}if(M>99.5)M=99.5;if(M>0)Ka=1-M/100;else $a=-(M/100)-1;P=145*((M+100)/
|
||||
2)/100;ea&&d();break;case "angle":Sa=M;P=Sa/180;P+=0.5;P*=145;ea&&d()}if(P>145)P=145;else if(P<0)P=0;ka.css({"margin-left":P-5})}).change()});var ob=function(ia){var ba=ia.pageX-ab.offset.left-parseInt(ab.parent.css("border-left-width"));if(ba>145)ba=145;if(ba<=0)ba=0;var ka=ba-5;ba/=145;switch(ab.type){case "radius":ba=Math.pow(ba*2,2.5);if(ba>0.98&&ba<1.02)ba=1;if(ba<=0.01)ba=0.01;ga.setAttribute("r",ba);break;case "opacity":w.paint.alpha=parseInt(ba*100);Ba.setAttribute("fill-opacity",ba);break;
|
||||
case "ellip":Ka=$a=1;if(ba<0.5){ba/=0.5;$a=ba<=0?0.01:ba}else if(ba>0.5){ba/=0.5;ba=2-ba;Ka=ba<=0?0.01:ba}d();ba-=1;if(Ka===ba+1)ba=Math.abs(ba);break;case "angle":ba-=0.5;Sa=ba*=180;d();ba/=100}ab.elem.css({"margin-left":ka});ba=Math.round(ba*100);ab.input.val(ba);ia.preventDefault()},pb=function(){S.unbind("mousemove",ob).unbind("mouseup",pb);ab=null};for(L=(w.paint.alpha*255/100).toString(16);L.length<2;)L="0"+L;L=L.split(".")[0];I=w.paint.solidColor=="none"?"":w.paint.solidColor+L;oa||(I=va[0].getAttribute("stop-color"));
|
||||
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});R.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:I,alphaSupport:true}},function(ia){w.paint.type="solidColor";w.paint.alpha=ia.val("ahex")?Math.round(ia.val("a")/255*100):100;w.paint.solidColor=ia.val("hex")?ia.val("hex"):"none";w.paint.radialGradient=null;Q()},null,function(){K()});var fb=$(N+" .jGraduate_tabs li");fb.on("click touchstart",function(){fb.removeClass("jGraduate_tab_current");
|
||||
$(this).addClass("jGraduate_tab_current");$(N+" > div").hide();var ia=$(this).attr("data-type");$(N+" .jGraduate_gradPick").show();if(ia==="rg"||ia==="lg"){$(".jGraduate_"+ia+"_field").show();$(".jGraduate_"+(ia==="lg"?"rg":"lg")+"_field").hide();$("#"+v+"_jgraduate_rect")[0].setAttribute("fill","url(#"+v+"_"+ia+"_jgraduate_grad)");Y=ia==="lg"?"linearGradient":"radialGradient";$("#"+v+"_jGraduate_OpacInput").val(w.paint.alpha).change();var ba=$("#"+v+"_"+ia+"_jgraduate_grad")[0];if(ga!==ba){var ka=
|
||||
$(ga).find("stop");$(ba).empty().append(ka);ga=ba;ba=lb.val();ga.setAttribute("spreadMethod",ba)}eb=ia==="rg"&&ga.getAttribute("fx")!=null&&!(za==Ia&&Ja==Fa);$("#"+v+"_jGraduate_focusCoord").toggle(eb);if(eb)$("#"+v+"_jGraduate_match_ctr")[0].checked=false}else{$(N+" .jGraduate_gradPick").hide();$(N+" .jGraduate_colPick").show()}});$(N+" > div").hide();fb.removeClass("jGraduate_tab_current");var tb;switch(w.paint.type){case "linearGradient":tb=$(N+" .jGraduate_tab_lingrad");break;case "radialGradient":tb=
|
||||
$(N+" .jGraduate_tab_radgrad");break;default:tb=$(N+" .jGraduate_tab_color")}w.show();setTimeout(function(){tb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),o=$(document);$.extend($.fn,{contextMenu:function(e,b){if(e.menu==undefined)return false;if(e.inSpeed==undefined)e.inSpeed=150;if(e.outSpeed==undefined)e.outSpeed=75;if(e.inSpeed==0)e.inSpeed=-1;if(e.outSpeed==0)e.outSpeed=-1;$(this).each(function(){var l=$(this),s=$(l).offset(),c=$("#"+e.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(p){var w=$(this);w.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
|
||||
ga=U.appendChild(ga)}a("radialGradient",{id:v+"_rg_jgraduate_grad"},U);if(Y==="linearGradient")break;case "radialGradient":if(!oa){ga.id=v+"_rg_jgraduate_grad";X=ga=U.appendChild(ga)}a("linearGradient",{id:v+"_lg_jgraduate_grad",x1:0,y1:0,x2:1,y2:0},U)}if(oa){X=ga=$("#"+v+"_lg_jgraduate_grad")[0];I=w.paint[Y];s(0,"#"+I,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+I,1);break;case "inverse":ma="";if(I.length===3)I=I.split("").map(function(ia){return ia+""+ia}).join("");
|
||||
for(var la=0;la<6;la+=2){I.substr(la,2);var ya=(255-parseInt(I.substr(la,2),16)).toString(16);if(ya.length<2)ya=0+ya;ma+=ya}console.log(ma);s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+I,"opac"in B.newstop?B.newstop.opac:1)}I=parseFloat(X.getAttribute("x1")||0);ma=parseFloat(X.getAttribute("y1")||0);la=parseFloat(X.getAttribute("x2")||1);ya=parseFloat(X.getAttribute("y2")||0);var za=parseFloat(X.getAttribute("cx")||
|
||||
0.5),Ja=parseFloat(X.getAttribute("cy")||0.5),Ia=parseFloat(X.getAttribute("fx")||za),Fa=parseFloat(X.getAttribute("fy")||Ja);Ba=a("rect",{id:v+"_jgraduate_rect",x:0,y:0,width:qa,height:aa,fill:"url(#"+v+"_jgraduate_grad)","fill-opacity":na/100},U);var Ma=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*Z,left:I*Z}).data("coord","start").appendTo(da),Da=Ma.clone().text(2).css({top:ya*Z,left:la*Z}).attr("title","End stop").data("coord","end").appendTo(da),
|
||||
wa=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ja*Z,left:za*Z}).data("coord","center").appendTo(da),ra=wa.clone().text("F").css({top:Fa*Z,left:Ia*Z,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);ra[0].id=v+"_jGraduate_focusCoord";$(N+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ia,ba){var ka=ga.getAttribute(ba),M=isNaN(ba[1]);ka||(ka=M?"0.5":ba==="x2"?"1.0":"0.0");ja[ba]=$("#"+v+"_jGraduate_"+
|
||||
ba).val(ka).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>1)this.value=1;if(!(ba[0]==="f"&&!eb))if(M&&Y==="radialGradient"||!M&&Y==="linearGradient")ga.setAttribute(ba,this.value);var P=M?ba[0]==="c"?wa:ra:ba[1]==="1"?Ma:Da,ea=ba.indexOf("x")>=0?"left":"top";P.css(ea,this.value*Z)}).change()});var va,kb,vb=$("#"+v+"_jGraduate_StopSlider"),cb,Ta,Va,Ga=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},
|
||||
Ta),ta,$a=1,Ka=1,Sa=0,Ha=za,db=Ja;Ta=a("svg",{width:"100%",height:45},vb[0]);da=a("pattern",{width:16,height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Ta);a("image",{width:16,height:16},da).setAttributeNS(o.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Ta).on("click touchstart",function(ia){ta=vb.offset();if(ia.target.tagName!=="path"){var ba=ia.pageX-ta.left-8;ba=ba<10?10:ba>Z+10?Z+10:ba;s(ba/Z,0,0,true);ia.stopPropagation()}});$(Ta).mouseover(function(){Ta.appendChild(Ga)});
|
||||
kb=a("g",{},Ta);a("line",{x1:10,y1:15,x2:Z+10,y2:15,"stroke-width":2,stroke:"#000"},Ta);var lb=L.find(".jGraduate_spreadMethod").change(function(){ga.setAttribute("spreadMethod",$(this).val())}),Ua=null,Xa=function(ia){var ba=ia.pageX-hb.left,ka=ia.pageY-hb.top;ba=ba<0?0:ba>Z?Z:ba;ka=ka<0?0:ka>Z?Z:ka;Ua.css("left",ba).css("top",ka);ba=ba/qa;ka=ka/aa;var M=Ua.data("coord"),P=ga;switch(M){case "start":ja.x1.val(ba);ja.y1.val(ka);P.setAttribute("x1",ba);P.setAttribute("y1",ka);break;case "end":ja.x2.val(ba);
|
||||
ja.y2.val(ka);P.setAttribute("x2",ba);P.setAttribute("y2",ka);break;case "center":ja.cx.val(ba);ja.cy.val(ka);P.setAttribute("cx",ba);P.setAttribute("cy",ka);Ha=ba;db=ka;d();break;case "focus":ja.fx.val(ba);ja.fy.val(ka);P.setAttribute("fx",ba);P.setAttribute("fy",ka);d()}ia.preventDefault()},wb=function(){Ua=null;S.unbind("mousemove",Xa).unbind("mouseup",wb)};va=ga.getElementsByTagNameNS(o.svg,"stop");if(sa<2){for(;sa<2;){ga.appendChild(document.createElementNS(o.svg,"stop"));++sa}va=ga.getElementsByTagNameNS(o.svg,
|
||||
"stop")}var sa=va.length;for(la=0;la<sa;la++)s(0,0,0,0,va[la]);lb.val(ga.getAttribute("spreadMethod")||"pad");var hb,eb=false;Ba.setAttribute("fill-opacity",na/100);$("#"+v+" div.grad_coord").mousedown(function(ia){ia.preventDefault();Ua=$(this);Ua.offset();hb=Ua.parent().offset();S.mousemove(Xa).mouseup(wb)});$("#"+v+"_jGraduate_Ok").bind("click touchstart",function(){w.paint.type=Y;w.paint[Y]=ga.cloneNode(true);w.paint.solidColor=null;Q()});$("#"+v+"_jGraduate_Cancel").bind("click touchstart",function(){K()});
|
||||
if(Y==="radialGradient")if(eb)ra.show();else{ra.hide();ja.fx.val("");ja.fy.val("")}$("#"+v+"_jGraduate_match_ctr")[0].checked=!eb;var sb,ib;$("#"+v+"_jGraduate_match_ctr").change(function(){eb=!this.checked;ra.toggle(eb);ja.fx.val("");ja.fy.val("");var ia=ga;if(eb){var ba=sb||0.5,ka=ib||0.5;ia.setAttribute("fx",ba);ia.setAttribute("fy",ka);ja.fx.val(ba);ja.fy.val(ka)}else{sb=ia.getAttribute("fx");ib=ia.getAttribute("fy");ia.removeAttribute("fx");ia.removeAttribute("fy")}});va=ga.getElementsByTagNameNS(o.svg,
|
||||
"stop");sa=va.length;if(sa<2){for(;sa<2;){ga.appendChild(document.createElementNS(o.svg,"stop"));++sa}va=ga.getElementsByTagNameNS(o.svg,"stop")}var ab;na=L=0;if(Y==="radialGradient"){U=ga.gradientTransform.baseVal;if(U.numberOfItems===2){sa=U.getItem(0);U=U.getItem(1);if(sa.type===2&&U.type===3){sa=U.matrix;if(sa.a!==1)L=Math.round(-(1-sa.a)*100);else if(sa.d!==1)L=Math.round((1-sa.d)*100)}}else if(U.numberOfItems===3){da=U.getItem(0);sa=U.getItem(1);U=U.getItem(2);if(da.type===4&&sa.type===2&&U.type===
|
||||
3){na=Math.round(da.angle);sa=U.matrix;if(sa.a!==1)L=Math.round(-(1-sa.a)*100);else if(sa.d!==1)L=Math.round((1-sa.d)*100)}}}L={radius:{handle:"#"+v+"_jGraduate_RadiusArrows",input:"#"+v+"_jGraduate_RadiusInput",val:(ga.getAttribute("r")||0.5)*100},opacity:{handle:"#"+v+"_jGraduate_OpacArrows",input:"#"+v+"_jGraduate_OpacInput",val:w.paint.alpha||100},ellip:{handle:"#"+v+"_jGraduate_EllipArrows",input:"#"+v+"_jGraduate_EllipInput",val:L},angle:{handle:"#"+v+"_jGraduate_AngleArrows",input:"#"+v+"_jGraduate_AngleInput",
|
||||
val:na}};$.each(L,function(ia,ba){var ka=$(ba.handle);ka.mousedown(function(M){var P=ka.parent();ab={type:ia,elem:ka,input:$(ba.input),parent:P,offset:P.offset()};S.mousemove(ob).mouseup(pb);M.preventDefault()});$(ba.input).val(ba.val).change(function(){var M=+this.value,P=0,ea=Y==="radialGradient";switch(ia){case "radius":ea&&ga.setAttribute("r",M/100);P=Math.pow(M/100,0.4)/2*145;break;case "opacity":w.paint.alpha=M;Ba.setAttribute("fill-opacity",M/100);P=M*1.45;break;case "ellip":$a=Ka=1;if(M===
|
||||
0){P=72.5;break}if(M>99.5)M=99.5;if(M>0)Ka=1-M/100;else $a=-(M/100)-1;P=145*((M+100)/2)/100;ea&&d();break;case "angle":Sa=M;P=Sa/180;P+=0.5;P*=145;ea&&d()}if(P>145)P=145;else if(P<0)P=0;ka.css({"margin-left":P-5})}).change()});var ob=function(ia){var ba=ia.pageX-ab.offset.left-parseInt(ab.parent.css("border-left-width"));if(ba>145)ba=145;if(ba<=0)ba=0;var ka=ba-5;ba/=145;switch(ab.type){case "radius":ba=Math.pow(ba*2,2.5);if(ba>0.98&&ba<1.02)ba=1;if(ba<=0.01)ba=0.01;ga.setAttribute("r",ba);break;
|
||||
case "opacity":w.paint.alpha=parseInt(ba*100);Ba.setAttribute("fill-opacity",ba);break;case "ellip":Ka=$a=1;if(ba<0.5){ba/=0.5;$a=ba<=0?0.01:ba}else if(ba>0.5){ba/=0.5;ba=2-ba;Ka=ba<=0?0.01:ba}d();ba-=1;if(Ka===ba+1)ba=Math.abs(ba);break;case "angle":ba-=0.5;Sa=ba*=180;d();ba/=100}ab.elem.css({"margin-left":ka});ba=Math.round(ba*100);ab.input.val(ba);ia.preventDefault()},pb=function(){S.unbind("mousemove",ob).unbind("mouseup",pb);ab=null};for(L=(w.paint.alpha*255/100).toString(16);L.length<2;)L="0"+
|
||||
L;L=L.split(".")[0];I=w.paint.solidColor=="none"?"":w.paint.solidColor+L;oa||(I=va[0].getAttribute("stop-color"));$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});R.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:I,alphaSupport:true}},function(ia){w.paint.type="solidColor";w.paint.alpha=ia.val("ahex")?Math.round(ia.val("a")/255*100):100;w.paint.solidColor=ia.val("hex")?ia.val("hex"):"none";w.paint.radialGradient=
|
||||
null;Q()},null,function(){K()});var fb=$(N+" .jGraduate_tabs li");fb.on("click touchstart",function(){fb.removeClass("jGraduate_tab_current");$(this).addClass("jGraduate_tab_current");$(N+" > div").hide();var ia=$(this).attr("data-type");$(N+" .jGraduate_gradPick").show();if(ia==="rg"||ia==="lg"){$(".jGraduate_"+ia+"_field").show();$(".jGraduate_"+(ia==="lg"?"rg":"lg")+"_field").hide();$("#"+v+"_jgraduate_rect")[0].setAttribute("fill","url(#"+v+"_"+ia+"_jgraduate_grad)");Y=ia==="lg"?"linearGradient":
|
||||
"radialGradient";$("#"+v+"_jGraduate_OpacInput").val(w.paint.alpha).change();var ba=$("#"+v+"_"+ia+"_jgraduate_grad")[0];if(ga!==ba){var ka=$(ga).find("stop");$(ba).empty().append(ka);ga=ba;ba=lb.val();ga.setAttribute("spreadMethod",ba)}eb=ia==="rg"&&ga.getAttribute("fx")!=null&&!(za==Ia&&Ja==Fa);$("#"+v+"_jGraduate_focusCoord").toggle(eb);if(eb)$("#"+v+"_jGraduate_match_ctr")[0].checked=false}else{$(N+" .jGraduate_gradPick").hide();$(N+" .jGraduate_colPick").show()}});$(N+" > div").hide();fb.removeClass("jGraduate_tab_current");
|
||||
var tb;switch(w.paint.type){case "linearGradient":tb=$(N+" .jGraduate_tab_lingrad");break;case "radialGradient":tb=$(N+" .jGraduate_tab_radgrad");break;default:tb=$(N+" .jGraduate_tab_color")}w.show();setTimeout(function(){tb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),o=$(document);$.extend($.fn,{contextMenu:function(e,b){if(e.menu==undefined)return false;if(e.inSpeed==undefined)e.inSpeed=150;if(e.outSpeed==undefined)e.outSpeed=75;if(e.inSpeed==0)e.inSpeed=-1;if(e.outSpeed==0)e.outSpeed=-1;$(this).each(function(){var l=$(this),s=$(l).offset(),c=$("#"+e.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(p){var w=$(this);w.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
|
||||
e.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||g(p,d,w)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var p=$(this);p.unbind("mouseup");g(d,d,p)});var g=function(d,p,w){if(typeof p=="undefined")p=d;d.stopPropagation();if(l.hasClass("disabled")||p.altKey)return false;var B=d.pageX,v=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;v=d.originalEvent.touches[0].pageY}d=a.width()-c.width();p=a.height()-c.height();if(B>d-15)B=d-15;
|
||||
if(v>p-30)v=p-30;if(svgedit.browser.isTouch())v-=c.height()/2;o.unbind("click");c.css({top:v,left:B}).fadeIn(e.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});o.keypress(function(N){switch(N.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover");
|
||||
break;case 40:if(c.find("LI.hover").length==0)c.find("LI:first").addClass("hover");else{c.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:first").addClass("hover")}break;case 13:c.find("LI.hover A").trigger("click");break;case 27:o.trigger("click")}});c.find("A").unbind("mouseup");c.find("LI:not(.disabled) A").mouseup(function(){o.unbind("click").unbind("keypress");$(".contextMenu").hide();b&&b($(this).attr("href").substr(1),
|
||||
|
|
|
@ -28,18 +28,6 @@
|
|||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
src: url('font-files/oswald-bold-webfont.woff') format('woff');
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
src: url('font-files/oswald-light-webfont.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Shadows Into Light';
|
||||
src: url('font-files/shadowsintolight-webfont.woff') format('woff');
|
||||
|
|
|
@ -326,7 +326,7 @@
|
|||
<option value="Georgia, Times, 'Times New Roman', serif">Georgia</option>
|
||||
<option value="Helvetica, Arial, sans-serif" selected="selected">Helvetica</option>
|
||||
<option value="Junction, sans-serif">Junction</option>
|
||||
<option value="Junction, sans-serif">Junction</option>
|
||||
<option value="'League Gothic', sans-serif">League Gothic</option>
|
||||
<option value="Oswald, sans-serif">Oswald</option>
|
||||
<option value="'Palatino Linotype', 'Book Antiqua', Palatino, serif">Palatino</option>
|
||||
<option value="'Trebuchet MS', Gadget, sans-serif">Trebuchet</option>
|
||||
|
|
|
@ -358,7 +358,11 @@ jQuery.fn.jGraduate =
|
|||
grad = curGradient = svg.appendChild(curGradient);//.cloneNode(true));
|
||||
}
|
||||
mkElem('linearGradient', {
|
||||
id: id + '_lg_jgraduate_grad'
|
||||
id: id + '_lg_jgraduate_grad',
|
||||
x1: 0,
|
||||
y1: 0,
|
||||
x2: 1,
|
||||
y2: 0
|
||||
}, svg);
|
||||
}
|
||||
|
||||
|
@ -378,13 +382,16 @@ jQuery.fn.jGraduate =
|
|||
case 'inverse':
|
||||
// Invert current color for second stop
|
||||
var inverted = '';
|
||||
|
||||
if (color.length === 3) {
|
||||
color = color.split("").map(function(d){return d + "" + d}).join("");
|
||||
}
|
||||
for(var i = 0; i < 6; i += 2) {
|
||||
var ch = color.substr(i, 2);
|
||||
var inv = (255 - parseInt(color.substr(i, 2), 16)).toString(16);
|
||||
if(inv.length < 2) inv = 0 + inv;
|
||||
inverted += inv;
|
||||
}
|
||||
console.log(inverted)
|
||||
mkStop(1, '#' + inverted, 1);
|
||||
break;
|
||||
|
||||
|
@ -456,16 +463,6 @@ jQuery.fn.jGraduate =
|
|||
|
||||
var coords = $(idref + ' .grad_coord');
|
||||
|
||||
// $(container).hover(function() {
|
||||
// coords.animate({
|
||||
// opacity: 1
|
||||
// }, 500);
|
||||
// }, function() {
|
||||
// coords.animate({
|
||||
// opacity: .2
|
||||
// }, 500);
|
||||
// });
|
||||
|
||||
$.each(['x1', 'y1', 'x2', 'y2', 'cx', 'cy', 'fx', 'fy'], function(i, attr) {
|
||||
var attrval = curGradient.getAttribute(attr);
|
||||
|
||||
|
@ -510,8 +507,6 @@ jQuery.fn.jGraduate =
|
|||
}).change();
|
||||
});
|
||||
|
||||
|
||||
|
||||
function mkStop(n, color, opac, sel, stop_elem) {
|
||||
var stop = stop_elem || mkElem('stop',{'stop-color':color,'stop-opacity':opac,offset:n}, curGradient);
|
||||
if(stop_elem) {
|
||||
|
|
|
@ -105,25 +105,25 @@ v+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click
|
|||
v+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+v+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+v+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+v+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+B.images.clientPath+
|
||||
'rangearrows2.gif"></div><label><input type="text" id="'+v+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba </label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+v+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+v+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+v+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
|
||||
v+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+v+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var Z=256,qa=Z-0,aa=Z-0,Y,ga,Ba,ja={};$(".jGraduate_SliderBar").width(145);var da=$("#"+v+"_jGraduate_GradContainer")[0],U=a("svg",{id:v+"_jgraduate_svg",width:Z,height:Z,xmlns:o.svg},da);Y=Y||w.paint.type;var X=ga=w.paint[Y],na=w.paint.alpha,oa=Y==="solidColor";switch(Y){case "solidColor":case "linearGradient":if(!oa){ga.id=v+"_lg_jgraduate_grad";X=
|
||||
ga=U.appendChild(ga)}a("radialGradient",{id:v+"_rg_jgraduate_grad"},U);if(Y==="linearGradient")break;case "radialGradient":if(!oa){ga.id=v+"_rg_jgraduate_grad";X=ga=U.appendChild(ga)}a("linearGradient",{id:v+"_lg_jgraduate_grad"},U)}if(oa){X=ga=$("#"+v+"_lg_jgraduate_grad")[0];I=w.paint[Y];s(0,"#"+I,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+I,1);break;case "inverse":ma="";for(var la=0;la<6;la+=2){I.substr(la,2);var ya=(255-parseInt(I.substr(la,2),16)).toString(16);
|
||||
if(ya.length<2)ya=0+ya;ma+=ya}s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+I,"opac"in B.newstop?B.newstop.opac:1)}I=parseFloat(X.getAttribute("x1")||0);ma=parseFloat(X.getAttribute("y1")||0);la=parseFloat(X.getAttribute("x2")||1);ya=parseFloat(X.getAttribute("y2")||0);var za=parseFloat(X.getAttribute("cx")||0.5),Ja=parseFloat(X.getAttribute("cy")||0.5),Ia=parseFloat(X.getAttribute("fx")||za),Fa=parseFloat(X.getAttribute("fy")||
|
||||
Ja);Ba=a("rect",{id:v+"_jgraduate_rect",x:0,y:0,width:qa,height:aa,fill:"url(#"+v+"_jgraduate_grad)","fill-opacity":na/100},U);var Ma=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*Z,left:I*Z}).data("coord","start").appendTo(da),Da=Ma.clone().text(2).css({top:ya*Z,left:la*Z}).attr("title","End stop").data("coord","end").appendTo(da),wa=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ja*Z,left:za*
|
||||
Z}).data("coord","center").appendTo(da),ra=wa.clone().text("F").css({top:Fa*Z,left:Ia*Z,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);ra[0].id=v+"_jGraduate_focusCoord";$(N+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ia,ba){var ka=ga.getAttribute(ba),M=isNaN(ba[1]);ka||(ka=M?"0.5":ba==="x2"?"1.0":"0.0");ja[ba]=$("#"+v+"_jGraduate_"+ba).val(ka).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
|
||||
1)this.value=1;if(!(ba[0]==="f"&&!eb))if(M&&Y==="radialGradient"||!M&&Y==="linearGradient")ga.setAttribute(ba,this.value);var P=M?ba[0]==="c"?wa:ra:ba[1]==="1"?Ma:Da,ea=ba.indexOf("x")>=0?"left":"top";P.css(ea,this.value*Z)}).change()});var va,kb,vb=$("#"+v+"_jGraduate_StopSlider"),cb,Ta,Va,Ga=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Ta),ta,$a=1,Ka=1,Sa=0,Ha=za,db=Ja;Ta=a("svg",{width:"100%",height:45},vb[0]);da=a("pattern",{width:16,
|
||||
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Ta);a("image",{width:16,height:16},da).setAttributeNS(o.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Ta).on("click touchstart",function(ia){ta=vb.offset();if(ia.target.tagName!=="path"){var ba=ia.pageX-ta.left-8;ba=ba<10?10:ba>Z+10?Z+10:ba;s(ba/Z,0,0,true);ia.stopPropagation()}});$(Ta).mouseover(function(){Ta.appendChild(Ga)});kb=a("g",{},Ta);a("line",{x1:10,y1:15,x2:Z+10,y2:15,"stroke-width":2,stroke:"#000"},Ta);var lb=
|
||||
L.find(".jGraduate_spreadMethod").change(function(){ga.setAttribute("spreadMethod",$(this).val())}),Ua=null,Xa=function(ia){var ba=ia.pageX-hb.left,ka=ia.pageY-hb.top;ba=ba<0?0:ba>Z?Z:ba;ka=ka<0?0:ka>Z?Z:ka;Ua.css("left",ba).css("top",ka);ba=ba/qa;ka=ka/aa;var M=Ua.data("coord"),P=ga;switch(M){case "start":ja.x1.val(ba);ja.y1.val(ka);P.setAttribute("x1",ba);P.setAttribute("y1",ka);break;case "end":ja.x2.val(ba);ja.y2.val(ka);P.setAttribute("x2",ba);P.setAttribute("y2",ka);break;case "center":ja.cx.val(ba);
|
||||
ja.cy.val(ka);P.setAttribute("cx",ba);P.setAttribute("cy",ka);Ha=ba;db=ka;d();break;case "focus":ja.fx.val(ba);ja.fy.val(ka);P.setAttribute("fx",ba);P.setAttribute("fy",ka);d()}ia.preventDefault()},wb=function(){Ua=null;S.unbind("mousemove",Xa).unbind("mouseup",wb)};va=ga.getElementsByTagNameNS(o.svg,"stop");if(sa<2){for(;sa<2;){ga.appendChild(document.createElementNS(o.svg,"stop"));++sa}va=ga.getElementsByTagNameNS(o.svg,"stop")}var sa=va.length;for(la=0;la<sa;la++)s(0,0,0,0,va[la]);lb.val(ga.getAttribute("spreadMethod")||
|
||||
"pad");var hb,eb=false;Ba.setAttribute("fill-opacity",na/100);$("#"+v+" div.grad_coord").mousedown(function(ia){ia.preventDefault();Ua=$(this);Ua.offset();hb=Ua.parent().offset();S.mousemove(Xa).mouseup(wb)});$("#"+v+"_jGraduate_Ok").bind("click touchstart",function(){w.paint.type=Y;w.paint[Y]=ga.cloneNode(true);w.paint.solidColor=null;Q()});$("#"+v+"_jGraduate_Cancel").bind("click touchstart",function(){K()});if(Y==="radialGradient")if(eb)ra.show();else{ra.hide();ja.fx.val("");ja.fy.val("")}$("#"+
|
||||
v+"_jGraduate_match_ctr")[0].checked=!eb;var sb,ib;$("#"+v+"_jGraduate_match_ctr").change(function(){eb=!this.checked;ra.toggle(eb);ja.fx.val("");ja.fy.val("");var ia=ga;if(eb){var ba=sb||0.5,ka=ib||0.5;ia.setAttribute("fx",ba);ia.setAttribute("fy",ka);ja.fx.val(ba);ja.fy.val(ka)}else{sb=ia.getAttribute("fx");ib=ia.getAttribute("fy");ia.removeAttribute("fx");ia.removeAttribute("fy")}});va=ga.getElementsByTagNameNS(o.svg,"stop");sa=va.length;if(sa<2){for(;sa<2;){ga.appendChild(document.createElementNS(o.svg,
|
||||
"stop"));++sa}va=ga.getElementsByTagNameNS(o.svg,"stop")}var ab;na=L=0;if(Y==="radialGradient"){U=ga.gradientTransform.baseVal;if(U.numberOfItems===2){sa=U.getItem(0);U=U.getItem(1);if(sa.type===2&&U.type===3){sa=U.matrix;if(sa.a!==1)L=Math.round(-(1-sa.a)*100);else if(sa.d!==1)L=Math.round((1-sa.d)*100)}}else if(U.numberOfItems===3){da=U.getItem(0);sa=U.getItem(1);U=U.getItem(2);if(da.type===4&&sa.type===2&&U.type===3){na=Math.round(da.angle);sa=U.matrix;if(sa.a!==1)L=Math.round(-(1-sa.a)*100);else if(sa.d!==
|
||||
1)L=Math.round((1-sa.d)*100)}}}L={radius:{handle:"#"+v+"_jGraduate_RadiusArrows",input:"#"+v+"_jGraduate_RadiusInput",val:(ga.getAttribute("r")||0.5)*100},opacity:{handle:"#"+v+"_jGraduate_OpacArrows",input:"#"+v+"_jGraduate_OpacInput",val:w.paint.alpha||100},ellip:{handle:"#"+v+"_jGraduate_EllipArrows",input:"#"+v+"_jGraduate_EllipInput",val:L},angle:{handle:"#"+v+"_jGraduate_AngleArrows",input:"#"+v+"_jGraduate_AngleInput",val:na}};$.each(L,function(ia,ba){var ka=$(ba.handle);ka.mousedown(function(M){var P=
|
||||
ka.parent();ab={type:ia,elem:ka,input:$(ba.input),parent:P,offset:P.offset()};S.mousemove(ob).mouseup(pb);M.preventDefault()});$(ba.input).val(ba.val).change(function(){var M=+this.value,P=0,ea=Y==="radialGradient";switch(ia){case "radius":ea&&ga.setAttribute("r",M/100);P=Math.pow(M/100,0.4)/2*145;break;case "opacity":w.paint.alpha=M;Ba.setAttribute("fill-opacity",M/100);P=M*1.45;break;case "ellip":$a=Ka=1;if(M===0){P=72.5;break}if(M>99.5)M=99.5;if(M>0)Ka=1-M/100;else $a=-(M/100)-1;P=145*((M+100)/
|
||||
2)/100;ea&&d();break;case "angle":Sa=M;P=Sa/180;P+=0.5;P*=145;ea&&d()}if(P>145)P=145;else if(P<0)P=0;ka.css({"margin-left":P-5})}).change()});var ob=function(ia){var ba=ia.pageX-ab.offset.left-parseInt(ab.parent.css("border-left-width"));if(ba>145)ba=145;if(ba<=0)ba=0;var ka=ba-5;ba/=145;switch(ab.type){case "radius":ba=Math.pow(ba*2,2.5);if(ba>0.98&&ba<1.02)ba=1;if(ba<=0.01)ba=0.01;ga.setAttribute("r",ba);break;case "opacity":w.paint.alpha=parseInt(ba*100);Ba.setAttribute("fill-opacity",ba);break;
|
||||
case "ellip":Ka=$a=1;if(ba<0.5){ba/=0.5;$a=ba<=0?0.01:ba}else if(ba>0.5){ba/=0.5;ba=2-ba;Ka=ba<=0?0.01:ba}d();ba-=1;if(Ka===ba+1)ba=Math.abs(ba);break;case "angle":ba-=0.5;Sa=ba*=180;d();ba/=100}ab.elem.css({"margin-left":ka});ba=Math.round(ba*100);ab.input.val(ba);ia.preventDefault()},pb=function(){S.unbind("mousemove",ob).unbind("mouseup",pb);ab=null};for(L=(w.paint.alpha*255/100).toString(16);L.length<2;)L="0"+L;L=L.split(".")[0];I=w.paint.solidColor=="none"?"":w.paint.solidColor+L;oa||(I=va[0].getAttribute("stop-color"));
|
||||
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});R.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:I,alphaSupport:true}},function(ia){w.paint.type="solidColor";w.paint.alpha=ia.val("ahex")?Math.round(ia.val("a")/255*100):100;w.paint.solidColor=ia.val("hex")?ia.val("hex"):"none";w.paint.radialGradient=null;Q()},null,function(){K()});var fb=$(N+" .jGraduate_tabs li");fb.on("click touchstart",function(){fb.removeClass("jGraduate_tab_current");
|
||||
$(this).addClass("jGraduate_tab_current");$(N+" > div").hide();var ia=$(this).attr("data-type");$(N+" .jGraduate_gradPick").show();if(ia==="rg"||ia==="lg"){$(".jGraduate_"+ia+"_field").show();$(".jGraduate_"+(ia==="lg"?"rg":"lg")+"_field").hide();$("#"+v+"_jgraduate_rect")[0].setAttribute("fill","url(#"+v+"_"+ia+"_jgraduate_grad)");Y=ia==="lg"?"linearGradient":"radialGradient";$("#"+v+"_jGraduate_OpacInput").val(w.paint.alpha).change();var ba=$("#"+v+"_"+ia+"_jgraduate_grad")[0];if(ga!==ba){var ka=
|
||||
$(ga).find("stop");$(ba).empty().append(ka);ga=ba;ba=lb.val();ga.setAttribute("spreadMethod",ba)}eb=ia==="rg"&&ga.getAttribute("fx")!=null&&!(za==Ia&&Ja==Fa);$("#"+v+"_jGraduate_focusCoord").toggle(eb);if(eb)$("#"+v+"_jGraduate_match_ctr")[0].checked=false}else{$(N+" .jGraduate_gradPick").hide();$(N+" .jGraduate_colPick").show()}});$(N+" > div").hide();fb.removeClass("jGraduate_tab_current");var tb;switch(w.paint.type){case "linearGradient":tb=$(N+" .jGraduate_tab_lingrad");break;case "radialGradient":tb=
|
||||
$(N+" .jGraduate_tab_radgrad");break;default:tb=$(N+" .jGraduate_tab_color")}w.show();setTimeout(function(){tb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),o=$(document);$.extend($.fn,{contextMenu:function(e,b){if(e.menu==undefined)return false;if(e.inSpeed==undefined)e.inSpeed=150;if(e.outSpeed==undefined)e.outSpeed=75;if(e.inSpeed==0)e.inSpeed=-1;if(e.outSpeed==0)e.outSpeed=-1;$(this).each(function(){var l=$(this),s=$(l).offset(),c=$("#"+e.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(p){var w=$(this);w.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
|
||||
ga=U.appendChild(ga)}a("radialGradient",{id:v+"_rg_jgraduate_grad"},U);if(Y==="linearGradient")break;case "radialGradient":if(!oa){ga.id=v+"_rg_jgraduate_grad";X=ga=U.appendChild(ga)}a("linearGradient",{id:v+"_lg_jgraduate_grad",x1:0,y1:0,x2:1,y2:0},U)}if(oa){X=ga=$("#"+v+"_lg_jgraduate_grad")[0];I=w.paint[Y];s(0,"#"+I,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+I,1);break;case "inverse":ma="";if(I.length===3)I=I.split("").map(function(ia){return ia+""+ia}).join("");
|
||||
for(var la=0;la<6;la+=2){I.substr(la,2);var ya=(255-parseInt(I.substr(la,2),16)).toString(16);if(ya.length<2)ya=0+ya;ma+=ya}console.log(ma);s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+I,"opac"in B.newstop?B.newstop.opac:1)}I=parseFloat(X.getAttribute("x1")||0);ma=parseFloat(X.getAttribute("y1")||0);la=parseFloat(X.getAttribute("x2")||1);ya=parseFloat(X.getAttribute("y2")||0);var za=parseFloat(X.getAttribute("cx")||
|
||||
0.5),Ja=parseFloat(X.getAttribute("cy")||0.5),Ia=parseFloat(X.getAttribute("fx")||za),Fa=parseFloat(X.getAttribute("fy")||Ja);Ba=a("rect",{id:v+"_jgraduate_rect",x:0,y:0,width:qa,height:aa,fill:"url(#"+v+"_jgraduate_grad)","fill-opacity":na/100},U);var Ma=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*Z,left:I*Z}).data("coord","start").appendTo(da),Da=Ma.clone().text(2).css({top:ya*Z,left:la*Z}).attr("title","End stop").data("coord","end").appendTo(da),
|
||||
wa=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ja*Z,left:za*Z}).data("coord","center").appendTo(da),ra=wa.clone().text("F").css({top:Fa*Z,left:Ia*Z,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);ra[0].id=v+"_jGraduate_focusCoord";$(N+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ia,ba){var ka=ga.getAttribute(ba),M=isNaN(ba[1]);ka||(ka=M?"0.5":ba==="x2"?"1.0":"0.0");ja[ba]=$("#"+v+"_jGraduate_"+
|
||||
ba).val(ka).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>1)this.value=1;if(!(ba[0]==="f"&&!eb))if(M&&Y==="radialGradient"||!M&&Y==="linearGradient")ga.setAttribute(ba,this.value);var P=M?ba[0]==="c"?wa:ra:ba[1]==="1"?Ma:Da,ea=ba.indexOf("x")>=0?"left":"top";P.css(ea,this.value*Z)}).change()});var va,kb,vb=$("#"+v+"_jGraduate_StopSlider"),cb,Ta,Va,Ga=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},
|
||||
Ta),ta,$a=1,Ka=1,Sa=0,Ha=za,db=Ja;Ta=a("svg",{width:"100%",height:45},vb[0]);da=a("pattern",{width:16,height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Ta);a("image",{width:16,height:16},da).setAttributeNS(o.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Ta).on("click touchstart",function(ia){ta=vb.offset();if(ia.target.tagName!=="path"){var ba=ia.pageX-ta.left-8;ba=ba<10?10:ba>Z+10?Z+10:ba;s(ba/Z,0,0,true);ia.stopPropagation()}});$(Ta).mouseover(function(){Ta.appendChild(Ga)});
|
||||
kb=a("g",{},Ta);a("line",{x1:10,y1:15,x2:Z+10,y2:15,"stroke-width":2,stroke:"#000"},Ta);var lb=L.find(".jGraduate_spreadMethod").change(function(){ga.setAttribute("spreadMethod",$(this).val())}),Ua=null,Xa=function(ia){var ba=ia.pageX-hb.left,ka=ia.pageY-hb.top;ba=ba<0?0:ba>Z?Z:ba;ka=ka<0?0:ka>Z?Z:ka;Ua.css("left",ba).css("top",ka);ba=ba/qa;ka=ka/aa;var M=Ua.data("coord"),P=ga;switch(M){case "start":ja.x1.val(ba);ja.y1.val(ka);P.setAttribute("x1",ba);P.setAttribute("y1",ka);break;case "end":ja.x2.val(ba);
|
||||
ja.y2.val(ka);P.setAttribute("x2",ba);P.setAttribute("y2",ka);break;case "center":ja.cx.val(ba);ja.cy.val(ka);P.setAttribute("cx",ba);P.setAttribute("cy",ka);Ha=ba;db=ka;d();break;case "focus":ja.fx.val(ba);ja.fy.val(ka);P.setAttribute("fx",ba);P.setAttribute("fy",ka);d()}ia.preventDefault()},wb=function(){Ua=null;S.unbind("mousemove",Xa).unbind("mouseup",wb)};va=ga.getElementsByTagNameNS(o.svg,"stop");if(sa<2){for(;sa<2;){ga.appendChild(document.createElementNS(o.svg,"stop"));++sa}va=ga.getElementsByTagNameNS(o.svg,
|
||||
"stop")}var sa=va.length;for(la=0;la<sa;la++)s(0,0,0,0,va[la]);lb.val(ga.getAttribute("spreadMethod")||"pad");var hb,eb=false;Ba.setAttribute("fill-opacity",na/100);$("#"+v+" div.grad_coord").mousedown(function(ia){ia.preventDefault();Ua=$(this);Ua.offset();hb=Ua.parent().offset();S.mousemove(Xa).mouseup(wb)});$("#"+v+"_jGraduate_Ok").bind("click touchstart",function(){w.paint.type=Y;w.paint[Y]=ga.cloneNode(true);w.paint.solidColor=null;Q()});$("#"+v+"_jGraduate_Cancel").bind("click touchstart",function(){K()});
|
||||
if(Y==="radialGradient")if(eb)ra.show();else{ra.hide();ja.fx.val("");ja.fy.val("")}$("#"+v+"_jGraduate_match_ctr")[0].checked=!eb;var sb,ib;$("#"+v+"_jGraduate_match_ctr").change(function(){eb=!this.checked;ra.toggle(eb);ja.fx.val("");ja.fy.val("");var ia=ga;if(eb){var ba=sb||0.5,ka=ib||0.5;ia.setAttribute("fx",ba);ia.setAttribute("fy",ka);ja.fx.val(ba);ja.fy.val(ka)}else{sb=ia.getAttribute("fx");ib=ia.getAttribute("fy");ia.removeAttribute("fx");ia.removeAttribute("fy")}});va=ga.getElementsByTagNameNS(o.svg,
|
||||
"stop");sa=va.length;if(sa<2){for(;sa<2;){ga.appendChild(document.createElementNS(o.svg,"stop"));++sa}va=ga.getElementsByTagNameNS(o.svg,"stop")}var ab;na=L=0;if(Y==="radialGradient"){U=ga.gradientTransform.baseVal;if(U.numberOfItems===2){sa=U.getItem(0);U=U.getItem(1);if(sa.type===2&&U.type===3){sa=U.matrix;if(sa.a!==1)L=Math.round(-(1-sa.a)*100);else if(sa.d!==1)L=Math.round((1-sa.d)*100)}}else if(U.numberOfItems===3){da=U.getItem(0);sa=U.getItem(1);U=U.getItem(2);if(da.type===4&&sa.type===2&&U.type===
|
||||
3){na=Math.round(da.angle);sa=U.matrix;if(sa.a!==1)L=Math.round(-(1-sa.a)*100);else if(sa.d!==1)L=Math.round((1-sa.d)*100)}}}L={radius:{handle:"#"+v+"_jGraduate_RadiusArrows",input:"#"+v+"_jGraduate_RadiusInput",val:(ga.getAttribute("r")||0.5)*100},opacity:{handle:"#"+v+"_jGraduate_OpacArrows",input:"#"+v+"_jGraduate_OpacInput",val:w.paint.alpha||100},ellip:{handle:"#"+v+"_jGraduate_EllipArrows",input:"#"+v+"_jGraduate_EllipInput",val:L},angle:{handle:"#"+v+"_jGraduate_AngleArrows",input:"#"+v+"_jGraduate_AngleInput",
|
||||
val:na}};$.each(L,function(ia,ba){var ka=$(ba.handle);ka.mousedown(function(M){var P=ka.parent();ab={type:ia,elem:ka,input:$(ba.input),parent:P,offset:P.offset()};S.mousemove(ob).mouseup(pb);M.preventDefault()});$(ba.input).val(ba.val).change(function(){var M=+this.value,P=0,ea=Y==="radialGradient";switch(ia){case "radius":ea&&ga.setAttribute("r",M/100);P=Math.pow(M/100,0.4)/2*145;break;case "opacity":w.paint.alpha=M;Ba.setAttribute("fill-opacity",M/100);P=M*1.45;break;case "ellip":$a=Ka=1;if(M===
|
||||
0){P=72.5;break}if(M>99.5)M=99.5;if(M>0)Ka=1-M/100;else $a=-(M/100)-1;P=145*((M+100)/2)/100;ea&&d();break;case "angle":Sa=M;P=Sa/180;P+=0.5;P*=145;ea&&d()}if(P>145)P=145;else if(P<0)P=0;ka.css({"margin-left":P-5})}).change()});var ob=function(ia){var ba=ia.pageX-ab.offset.left-parseInt(ab.parent.css("border-left-width"));if(ba>145)ba=145;if(ba<=0)ba=0;var ka=ba-5;ba/=145;switch(ab.type){case "radius":ba=Math.pow(ba*2,2.5);if(ba>0.98&&ba<1.02)ba=1;if(ba<=0.01)ba=0.01;ga.setAttribute("r",ba);break;
|
||||
case "opacity":w.paint.alpha=parseInt(ba*100);Ba.setAttribute("fill-opacity",ba);break;case "ellip":Ka=$a=1;if(ba<0.5){ba/=0.5;$a=ba<=0?0.01:ba}else if(ba>0.5){ba/=0.5;ba=2-ba;Ka=ba<=0?0.01:ba}d();ba-=1;if(Ka===ba+1)ba=Math.abs(ba);break;case "angle":ba-=0.5;Sa=ba*=180;d();ba/=100}ab.elem.css({"margin-left":ka});ba=Math.round(ba*100);ab.input.val(ba);ia.preventDefault()},pb=function(){S.unbind("mousemove",ob).unbind("mouseup",pb);ab=null};for(L=(w.paint.alpha*255/100).toString(16);L.length<2;)L="0"+
|
||||
L;L=L.split(".")[0];I=w.paint.solidColor=="none"?"":w.paint.solidColor+L;oa||(I=va[0].getAttribute("stop-color"));$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});R.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:I,alphaSupport:true}},function(ia){w.paint.type="solidColor";w.paint.alpha=ia.val("ahex")?Math.round(ia.val("a")/255*100):100;w.paint.solidColor=ia.val("hex")?ia.val("hex"):"none";w.paint.radialGradient=
|
||||
null;Q()},null,function(){K()});var fb=$(N+" .jGraduate_tabs li");fb.on("click touchstart",function(){fb.removeClass("jGraduate_tab_current");$(this).addClass("jGraduate_tab_current");$(N+" > div").hide();var ia=$(this).attr("data-type");$(N+" .jGraduate_gradPick").show();if(ia==="rg"||ia==="lg"){$(".jGraduate_"+ia+"_field").show();$(".jGraduate_"+(ia==="lg"?"rg":"lg")+"_field").hide();$("#"+v+"_jgraduate_rect")[0].setAttribute("fill","url(#"+v+"_"+ia+"_jgraduate_grad)");Y=ia==="lg"?"linearGradient":
|
||||
"radialGradient";$("#"+v+"_jGraduate_OpacInput").val(w.paint.alpha).change();var ba=$("#"+v+"_"+ia+"_jgraduate_grad")[0];if(ga!==ba){var ka=$(ga).find("stop");$(ba).empty().append(ka);ga=ba;ba=lb.val();ga.setAttribute("spreadMethod",ba)}eb=ia==="rg"&&ga.getAttribute("fx")!=null&&!(za==Ia&&Ja==Fa);$("#"+v+"_jGraduate_focusCoord").toggle(eb);if(eb)$("#"+v+"_jGraduate_match_ctr")[0].checked=false}else{$(N+" .jGraduate_gradPick").hide();$(N+" .jGraduate_colPick").show()}});$(N+" > div").hide();fb.removeClass("jGraduate_tab_current");
|
||||
var tb;switch(w.paint.type){case "linearGradient":tb=$(N+" .jGraduate_tab_lingrad");break;case "radialGradient":tb=$(N+" .jGraduate_tab_radgrad");break;default:tb=$(N+" .jGraduate_tab_color")}w.show();setTimeout(function(){tb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),o=$(document);$.extend($.fn,{contextMenu:function(e,b){if(e.menu==undefined)return false;if(e.inSpeed==undefined)e.inSpeed=150;if(e.outSpeed==undefined)e.outSpeed=75;if(e.inSpeed==0)e.inSpeed=-1;if(e.outSpeed==0)e.outSpeed=-1;$(this).each(function(){var l=$(this),s=$(l).offset(),c=$("#"+e.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(p){var w=$(this);w.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
|
||||
e.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||g(p,d,w)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var p=$(this);p.unbind("mouseup");g(d,d,p)});var g=function(d,p,w){if(typeof p=="undefined")p=d;d.stopPropagation();if(l.hasClass("disabled")||p.altKey)return false;var B=d.pageX,v=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;v=d.originalEvent.touches[0].pageY}d=a.width()-c.width();p=a.height()-c.height();if(B>d-15)B=d-15;
|
||||
if(v>p-30)v=p-30;if(svgedit.browser.isTouch())v-=c.height()/2;o.unbind("click");c.css({top:v,left:B}).fadeIn(e.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});o.keypress(function(N){switch(N.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover");
|
||||
break;case 40:if(c.find("LI.hover").length==0)c.find("LI:first").addClass("hover");else{c.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:first").addClass("hover")}break;case 13:c.find("LI.hover A").trigger("click");break;case 27:o.trigger("click")}});c.find("A").unbind("mouseup");c.find("LI:not(.disabled) A").mouseup(function(){o.unbind("click").unbind("keypress");$(".contextMenu").hide();b&&b($(this).attr("href").substr(1),
|
||||
|
|
Loading…
Reference in New Issue