diff --git a/editor/jgraduate/jquery.jgraduate.min.js b/editor/jgraduate/jquery.jgraduate.min.js new file mode 100644 index 00000000..c149d2df --- /dev/null +++ b/editor/jgraduate/jquery.jgraduate.min.js @@ -0,0 +1 @@ +;var ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console){window.console=new function(){this.log=function(a){};this.dir=function(a){}}}$.jGraduate={Paint:function(b){var a=b||{};this.alpha=a.alpha||100;if(a.copy){this.type=a.copy.type;this.alpha=a.copy.alpha;switch(this.type){case"none":this.solidColor=null;this.linearGradient=null;break;case"solidColor":this.solidColor=a.copy.solidColor;this.linearGradient=null;break;case"linearGradient":this.solidColor=null;this.linearGradient=a.copy.linearGradient.cloneNode(true);break}}else{if(a.linearGradient){this.type="linearGradient";this.solidColor=null;this.linearGradient=a.linearGradient.cloneNode(true)}else{if(a.solidColor){this.type="solidColor";this.solidColor=a.solidColor}else{this.type="none";this.solidColor=null;this.linearGradient=null}}}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint(),window:{pickerTitle:"Drag markers to pick a paint",},images:{clientPath:"images/",},};jQuery.fn.jGraduate=function(b){var a=arguments;return this.each(function(){var l=$(this),m=$.extend(true,{},jQuery.fn.jGraduateDefaults,b),H=l.attr("id"),e="#"+l.attr("id")+" ";if(!e){alert("Container element must have an id attribute to maintain unique id strings for sub-elements.");return}var c=function(){$.isFunction(l.okCallback)&&l.okCallback(l.paint);l.hide()},i=function(){$.isFunction(l.cancelCallback)&&l.cancelCallback();l.hide()};$.extend(true,l,{paint:new $.jGraduate.Paint({copy:m.paint}),okCallback:$.isFunction(a[1])&&a[1]||null,cancelCallback:$.isFunction(a[2])&&a[2]||null,});var F=l.position(),B=null;if(l.paint.type=="none"){l.paint=$.jGraduate.Paint({solidColor:"ffffff"})}l.addClass("jGraduate_Picker");l.html('
');var K=$(e+"> .jGraduate_colPick");var s=$(e+"> .jGraduate_lgPick");s.html('

'+m.window.pickerTitle+'

%
');var N=256,E=0,D=0,j=15/2,w=N-2*E,u=N-2*D;var G=document.getElementById(H+"_jGraduate_GradContainer");var g=G.appendChild(document.createElementNS(ns.svg,"svg"));g.id=H+"_jgraduate_svg";g.setAttribute("width",N);g.setAttribute("height",N);g.setAttribute("xmlns",ns.svg);if(l.paint.type=="linearGradient"){l.paint.linearGradient.id=H+"_jgraduate_grad";l.paint.linearGradient=g.appendChild(document.importNode(l.paint.linearGradient,true))}else{var v=g.appendChild(document.createElementNS(ns.svg,"linearGradient"));v.id=H+"_jgraduate_grad";v.setAttribute("x1","0.0");v.setAttribute("y1","0.0");v.setAttribute("x2","1.0");v.setAttribute("y2","1.0");var o=v.appendChild(document.createElementNS(ns.svg,"stop"));o.setAttribute("offset","0.0");o.setAttribute("stop-color","#ff0000");var t=v.appendChild(document.createElementNS(ns.svg,"stop"));t.setAttribute("offset","1.0");t.setAttribute("stop-color","#ffff00");l.paint.linearGradient=v}var z=l.paint.alpha;$("#"+H+"_jGraduate_OpacityInput").val(z);var r=parseInt(255*(z/100))-4.5;$("#"+H+"_jGraduate_AlphaArrows").css({"margin-left":r});$("#"+H+"_jgraduate_rect").attr("fill-opacity",z/100);var q=parseFloat(l.paint.linearGradient.getAttribute("x1")||0);var Q=parseFloat(l.paint.linearGradient.getAttribute("y1")||0);var p=parseFloat(l.paint.linearGradient.getAttribute("x2")||1);var P=parseFloat(l.paint.linearGradient.getAttribute("y2")||0);var C=document.createElementNS(ns.svg,"rect");C.id=H+"_jgraduate_rect";C.setAttribute("x",E);C.setAttribute("y",D);C.setAttribute("width",u);C.setAttribute("height",u);C.setAttribute("fill","url(#"+H+"_jgraduate_grad)");C.setAttribute("fill-opacity","1.0");C=g.appendChild(C);var k=document.createElementNS(ns.svg,"image");k.id=H+"_stop1";k.setAttribute("class","stop");k.setAttributeNS(ns.xlink,"href",m.images.clientPath+"mappoint.gif");k.setAttributeNS(ns.xlink,"title","Begin Stop");k.appendChild(document.createElementNS(ns.svg,"title")).appendChild(document.createTextNode("Begin Stop"));k.setAttribute("width",18);k.setAttribute("height",18);k.setAttribute("x",E+w*q-j);k.setAttribute("y",D+u*Q-j);k.setAttribute("cursor","move");k=g.appendChild(k);var M=document.createElementNS(ns.svg,"image");M.id=H+"_stop2";M.setAttribute("class","stop");M.setAttributeNS(ns.xlink,"href",m.images.clientPath+"mappoint.gif");M.setAttributeNS(ns.xlink,"title","End Stop");M.appendChild(document.createElementNS(ns.svg,"title")).appendChild(document.createTextNode("End Stop"));M.setAttribute("width",18);M.setAttribute("height",18);M.setAttribute("x",E+w*p-j);M.setAttribute("y",D+u*P-j);M.setAttribute("cursor","move");M=g.appendChild(M);$("#"+H+"_jGraduate_Ok").bind("click",function(){l.paint.type="linearGradient";l.paint.solidColor=null;c()});$("#"+H+"_jGraduate_Cancel").bind("click",function(R){i()});var q=l.paint.linearGradient.getAttribute("x1");if(!q){q="0.0"}x1Input=$("#"+H+"_jGraduate_x1");x1Input.val(q);x1Input.change(function(){if(isNaN(parseFloat(this.value))||this.value<0||this.value>1){this.value=0}l.paint.linearGradient.setAttribute("x1",this.value);k.setAttribute("x",E+w*this.value-j)});var Q=l.paint.linearGradient.getAttribute("y1");if(!Q){Q="0.0"}y1Input=$("#"+H+"_jGraduate_y1");y1Input.val(Q);y1Input.change(function(){if(isNaN(parseFloat(this.value))||this.value<0||this.value>1){this.value=0}l.paint.linearGradient.setAttribute("y1",this.value);k.setAttribute("y",D+u*this.value-j)});var p=l.paint.linearGradient.getAttribute("x2");if(!p){p="1.0"}x2Input=$("#"+H+"_jGraduate_x2");x2Input.val(p);x2Input.change(function(){if(isNaN(parseFloat(this.value))||this.value<0||this.value>1){this.value=1}l.paint.linearGradient.setAttribute("x2",this.value);M.setAttribute("x",E+w*this.value-j)});var P=l.paint.linearGradient.getAttribute("y2");if(!P){P="0.0"}y2Input=$("#"+H+"_jGraduate_y2");y2Input.val(P);y2Input.change(function(){if(isNaN(parseFloat(this.value))||this.value<0||this.value>1){this.value=0}l.paint.linearGradient.setAttribute("y2",this.value);M.setAttribute("y",D+u*this.value-j)});var A=l.paint.linearGradient.getElementsByTagNameNS(ns.svg,"stop");var I=A.length;if(I<2){while(I<2){l.paint.linearGradient.appendChild(document.createElementNS(ns.svg,"stop"));++I}A=l.paint.linearGradient.getElementsByTagNameNS(ns.svg,"stop")}var n=function(T,V){var U=V.offset();var S=(T.pageX-U.left-parseInt(V.css("border-left-width")));if(S>255){S=255}if(S<0){S=0}var R=S-4.5;S/=255;$("#"+H+"_jGraduate_AlphaArrows").css({"margin-left":R});$("#"+H+"_jgraduate_rect").attr("fill-opacity",S);S=parseInt(S*100);$("#"+H+"_jGraduate_OpacityInput").val(S);l.paint.alpha=S};var O=false;$(".jGraduate_Opacity").mousedown(function(R){n(R,$(this));O=true;R.preventDefault()});$(".jGraduate_Opacity").mousemove(function(R){if(O){n(R,$(this));R.preventDefault()}});$(".jGraduate_Opacity").mouseup(function(R){n(R,$(this));O=false;R.preventDefault()});var L=null;var h=-1,f=-1;$(".stop, #color_picker_jGraduate_GradContainer image").mousedown(function(R){L=this;h=R.clientX;f=R.clientY;R.preventDefault()});$("#"+H+"_jgraduate_svg").mousemove(function(T){if(null!=L){var V=T.clientX-h;var S=T.clientY-f;h+=V;f+=S;var R=parseFloat(L.getAttribute("x"))+V;var X=parseFloat(L.getAttribute("y"))+S;if(RE+w-j){R=E+w-j}if(X>D+u-j){X=D+u-j}L.setAttribute("x",R);L.setAttribute("y",X);var W=(R-E+j)/w;var U=(X-D+j)/u;if(L.id==(H+"_stop1")){x1Input.val(W);y1Input.val(U);l.paint.linearGradient.setAttribute("x1",W);l.paint.linearGradient.setAttribute("y1",U)}else{x2Input.val(W);y2Input.val(U);l.paint.linearGradient.setAttribute("x2",W);l.paint.linearGradient.setAttribute("y2",U)}T.preventDefault()}});$("#"+H+"_jgraduate_svg").mouseup(function(R){L=null});var J=A[0].getAttribute("stop-color");if(!J){J="#000"}beginColorBox=$("#"+H+"_jGraduate_colorBoxBegin");beginColorBox.css({"background-color":J});var x=A[0].getAttribute("stop-opacity");if(!x){x="1.0"}$("#"+H+"jGraduate_beginOpacity").html((x*100)+"%");var d=A[A.length-1].getAttribute("stop-color");if(!d){d="#000"}endColorBox=$("#"+H+"_jGraduate_colorBoxEnd");endColorBox.css({"background-color":d});var y=A[A.length-1].getAttribute("stop-opacity");if(!y){y="1.0"}$("#"+H+"jGraduate_endOpacity").html((y*100)+"%");$("#"+H+"_jGraduate_colorBoxBegin").click(function(){$("div.jGraduate_LightBox").show();var R=$(this);B=new $.jPicker.Color({hex:J.substr(1),a:(parseFloat(x)*100)});$("#"+H+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:m.images.clientPath},color:{active:B,alphaSupport:true}},function(S){J="#"+this.settings.color.active.hex;x=this.settings.color.active.a/100;R.css("background",J);$("#"+H+"_jGraduate_beginOpacity").html(parseInt(x*100)+"%");A[0].setAttribute("stop-color",J);A[0].setAttribute("stop-opacity",x);$("div.jGraduate_LightBox").hide();$("#"+H+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+H+"_jGraduate_stopPicker").hide()})});$("#"+H+"_jGraduate_colorBoxEnd").click(function(){$("div.jGraduate_LightBox").show();var R=$(this);B=new $.jPicker.Color({hex:d.substr(1),a:(parseFloat(y)*100)});$("#"+H+"_jGraduate_stopPicker").css({left:100,top:15}).jPicker({window:{title:"Pick the end color and opacity for the gradient"},images:{clientPath:m.images.clientPath},color:{active:B,alphaSupport:true}},function(S){d="#"+this.settings.color.active.hex;y=this.settings.color.active.a/100;R.css("background",d);$("#"+H+"_jGraduate_endOpacity").html(parseInt(y*100)+"%");A[1].setAttribute("stop-color",d);A[1].setAttribute("stop-opacity",y);$("div.jGraduate_LightBox").hide();$("#"+H+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+H+"_jGraduate_stopPicker").hide()})});K.jPicker({window:{title:m.window.pickerTitle},images:{clientPath:m.images.clientPath},color:{active:new $.jPicker.Color({hex:l.paint.solidColor,a:l.paint.alpha}),alphaSupport:true}},function(R){l.paint.type="solidColor";l.paint.alpha=R.a;l.paint.solidColor=R.hex;l.paint.linearGradient=null;c()},null,function(){i()});$(e+" .jGraduate_tab_color").click(function(){$(e+" .jGraduate_tab_lingrad").removeClass("jGraduate_tab_current");$(e+" .jGraduate_tab_color").addClass("jGraduate_tab_current");s.hide();K.show()});$(e+" .jGraduate_tab_lingrad").click(function(){$(e+" .jGraduate_tab_color").removeClass("jGraduate_tab_current");$(e+" .jGraduate_tab_lingrad").addClass("jGraduate_tab_current");K.hide();s.show()});if(l.paint.type=="linearGradient"){s.show();K.hide();$(e+" .jGraduate_tab_color").removeClass("jGraduate_tab_current");$(e+" .jGraduate_tab_lingrad").addClass("jGraduate_tab_current")}else{K.show();s.hide();$(e+" .jGraduate_tab_color").addClass("jGraduate_tab_current");$(e+" .jGraduate_tab_lingrad").removeClass("jGraduate_tab_current")}l.show()})}; \ No newline at end of file diff --git a/editor/jpicker/css/jPicker-1.0.9.css b/editor/jpicker/css/jPicker-1.0.9.css deleted file mode 100755 index c4af17a4..00000000 --- a/editor/jpicker/css/jPicker-1.0.9.css +++ /dev/null @@ -1,227 +0,0 @@ -.jPicker_Picker { - display: inline-block; - height: 24px; /* change this value if using a different sized color picker icon */ - position: relative; /* make this element an absolute positioning container */ - text-align: left; /* make the zero width children position to the left of container */ - width: 25px; /* change this value if using a different sized color picker icon */ -} -.jPicker_Color { - display: block; - height: 100%; - left: 0px; - position: absolute; - top: 0px; - width: 100%; -} -.jPicker_Icon { - background-repeat: no-repeat; - cursor: pointer; - display: block; - height: 100%; - left: 0px; - position: absolute; - top: 0px; - width: 100%; -} -.jPicker_Container { - display: none; - z-index: 10; /* make sure container draws above color picker icon in Firefox/Safari/Chrome/Opera/etc. - - IE calculates z-index so this won't work - we will hide all color picker icons placed after the selected one in code when shown in IE */ -} -.jPicker_table { - background-color: #efefef; - border: 1px outset #666; - font-family: Arial, Helvetica, Sans-Serif; - font-size: 12px; - height: 330px; - margin: 0px; - padding: 5px; - width: 550px; -} -.jPicker_table td { - margin: 0px; - padding: 0px; - vertical-align: top; -} -.jPicker_MoveBar { - background-color: #dddddd; - border: 1px outset #aaa; - cursor: move; - height: 12px; -} -.jPicker_Title { - font-size: 11px !important; - font-weight: bold; - margin: -2px 0px 0px 0px; - padding: 0px; - text-align: center; - width: 100%; -} -.jPicker_ColorMap { - border: 2px inset #eee; - cursor: crosshair; - height: 260px; /* IE 6 incorrectly draws border inside the width and height instead of outside - We will fix this to 256px later */ - margin: 0px 5px 0px 5px; - overflow: hidden; /* hide the overdraw of the Color Map icon when at edge of viewing box */ - padding: 0px; - position: relative; /* make this element an absolute positioning container */ - width: 260px; /* IE 6 incorrectly draws border inside the width and height instead of outside - We will fix this to 256px later */ -} -div[class="jPicker_ColorMap"] { - height: 256px; /* correct to 256px for browsers that support the "[class="xxx"]" selector (IE7+,Firefox,Safari,Chrome,Opera,etc.) */ - width: 256px; /* correct to 256px for browsers that support the "[class="xxx"]" selector (IE7+,Firefox,Safari,Chrome,Opera,etc.) */ -} -.jPicker_ColorMap_l1, .jPicker_ColorMap_l2, .jPicker_ColorMap_l3, .jPicker_ColorBar_l1, .jPicker_ColorBar_l2, .jPicker_ColorBar_l3, .jPicker_ColorBar_l4, .jPicker_ColorBar_l5, .jPicker_AlphaBar_l1, .jPicker_AlphaBar_l2 { - background-repeat: no-repeat; - display: block; - height: 100%; - left: 0px; - position: absolute; - top: 0px; - width: 100%; -} -.jPicker_ColorMap_l1 { - background-color: #000000; - background-image: none; -} -.jPicker_ColorMap_l2 { - background-color: transparent; -} -.jPicker_ColorMap_l3 { - background-repeat: repeat; -} -.jPicker_ColorMap_Arrow { - display: block; - position: absolute; -} -.jPicker_ColorBar { - border: 2px inset #eee; - cursor: n-resize; - height: 260px; /* IE 6 incorrectly draws border inside the width and height instead of outside - We will fix this to 256px later */ - margin: 12px 10px 0px 5px; - padding: 0px; - position: relative; - width: 24px; /* IE 6 incorrectly draws border inside the width and height instead of outside - We will fix this to 20px later */ -} -div[class="jPicker_ColorBar"] { - height: 256px; /* correct to 256px for browsers that support the "[class="xxx"]" selector (IE7+,Firefox,Safari,Chrome,Opera,etc.) */ - width: 20px; /* correct to 20px for browsers that support the "[class="xxx"]" selector (IE7+,Firefox,Safari,Chrome,Opera,etc.) */ -} -.jPicker_ColorBar_l1, .jPicker_ColorBar_l2, .jPicker_ColorBar_l3 { - background-color: transparent; - background-image: none; - background-repeat: repeat-x; -} -.jPicker_ColorBar_l4 { - background-color: transparent; - background-repeat: repeat-x; -} -.jPicker_ColorBar_l5 { - background-color: transparent; - background-repeat: repeat; -} -.jPicker_ColorBar_Arrow { - display: block; - left: -10px; /* (arrow width / 2) - (element width / 2) - position arrows' center in elements' center */ - position: absolute; -} -.jPicker_AlphaBar { - border: 2px inset #eee; - cursor: e-resize; - display: none; - height: 24px; /* IE 6 incorrectly draws border inside the width and height instead of outside - We will fix this to 20px later */ - margin: 10px 5px 4px 5px; - padding: 0px; - position: relative; - width: 260px; /* IE 6 incorrectly draws border inside the width and height instead of outside - We will fix this to 256px later */ -} -div[class="jPicker_AlphaBar"] { - height: 20px; /* correct to 20px for browsers that support the "[class="xxx"]" selector (IE7+,Firefox,Safari,Chrome,Opera,etc.) */ - width: 256px; /* correct to 256px for browsers that support the "[class="xxx"]" selector (IE7+,Firefox,Safari,Chrome,Opera,etc.) */ -} -.jPicker_AlphaBar_Arrow { - display: block; - top: -10px; /* (arrow height / 2) - (element height / 2) - position arrows' center in elements' center */ - position: absolute; -} -.jPicker_EnableAlpha { - text-align: left; -} -.jPicker_Preview { - font-size: x-small; - text-align: center; -} -.jPicker_Preview div { - border: 2px inset #eee; - height: 62px; - margin: 0px auto; - padding: 0px; - width: 62px; -} -.jPicker_Preview div span { - border: 1px solid #000; - display: block; - height: 30px; - margin: 0px auto; - padding: 0px; - width: 60px; -} -.jPicker_Preview div span.jPicker_Active { - border-bottom-width: 0px; -} -.jPicker_Preview div span.jPicker_Current { - border-top-width: 0px; - cursor: pointer; -} -.jPicker_OkCancel { - text-align: center; - width: 120px; -} -.jPicker_OkCancel input { - width: 100px; -} -.jPicker_OkCancel input.jPicker_Ok { - margin: 12px 0px 5px 0px; -} -.jPicker_Spacer { - height: 10px; -} -.jPicker_HueText, .jPicker_SaturationText, .jPicker_BrightnessText, .jPicker_RedText, .jPicker_GreenText, .jPicker_BlueText, .jPicker_AlphaText { - background-color: #fff; - border: 1px inset #aaa; - margin: 0px 0px 0px 5px; - width: 30px; -} -.jPicker_EnterHex { - text-align: right; -} -.jPicker_HexText { - background-color: #fff; - border: 1px inset #aaa; - margin: 0px 19px 0px 5px; - width: 50px; -} -td.jPicker_OpacityCol { - padding-top: 12px; - text-indent: -8px; -} -td.jPicker_OpacityCol * { - display: none; -} -td.jPicker_HexCol { - text-align: left; -} -.jPicker_Grid { - text-align: center; -} -.jPicker_QuickColor { - border: 1px inset #aaa; - cursor: pointer; - display: block; - float: left; - height: 12px; - line-height: 12px; - margin: 2px 3px 1px 3px; - padding: 0px; - width: 12px; -} \ No newline at end of file diff --git a/editor/jpicker/images/Bars.png b/editor/jpicker/images/Bars.png deleted file mode 100644 index 4c1608e3..00000000 Binary files a/editor/jpicker/images/Bars.png and /dev/null differ diff --git a/editor/jpicker/images/Maps.png b/editor/jpicker/images/Maps.png deleted file mode 100644 index 498cf3be..00000000 Binary files a/editor/jpicker/images/Maps.png and /dev/null differ diff --git a/editor/jpicker/images/bar-opacity.png b/editor/jpicker/images/bar-opacity.png deleted file mode 100644 index e42ad081..00000000 Binary files a/editor/jpicker/images/bar-opacity.png and /dev/null differ diff --git a/editor/jpicker/images/map-opacity.png b/editor/jpicker/images/map-opacity.png deleted file mode 100644 index 6756cee6..00000000 Binary files a/editor/jpicker/images/map-opacity.png and /dev/null differ diff --git a/editor/jpicker/images/mappoint.gif b/editor/jpicker/images/mappoint.gif deleted file mode 100644 index f5f85574..00000000 Binary files a/editor/jpicker/images/mappoint.gif and /dev/null differ diff --git a/editor/jpicker/images/picker.gif b/editor/jpicker/images/picker.gif deleted file mode 100644 index 374d8910..00000000 Binary files a/editor/jpicker/images/picker.gif and /dev/null differ diff --git a/editor/jpicker/images/preview-opacity.png b/editor/jpicker/images/preview-opacity.png deleted file mode 100644 index 0dd9a2f8..00000000 Binary files a/editor/jpicker/images/preview-opacity.png and /dev/null differ diff --git a/editor/jpicker/images/rangearrows.gif b/editor/jpicker/images/rangearrows.gif deleted file mode 100644 index 218872cc..00000000 Binary files a/editor/jpicker/images/rangearrows.gif and /dev/null differ diff --git a/editor/jpicker/images/rangearrows2.gif b/editor/jpicker/images/rangearrows2.gif deleted file mode 100644 index fdeb54a1..00000000 Binary files a/editor/jpicker/images/rangearrows2.gif and /dev/null differ diff --git a/editor/jpicker/jpicker-1.0.9.js b/editor/jpicker/jpicker-1.0.9.js deleted file mode 100755 index 7d00ec4a..00000000 --- a/editor/jpicker/jpicker-1.0.9.js +++ /dev/null @@ -1,1675 +0,0 @@ -/* - * jPicker 1.0.9 - * - * jQuery Plugin for Photoshop style color picker - * - * Copyright (c) 2009 Christopher T. Tillman - * Digital Magic Productions, Inc. (http://www.digitalmagicpro.com/) - * MIT style license, FREE to use, alter, copy, sell, and especially ENHANCE - * - * Painstakingly ported from John Dyers' excellent work on his own color picker based on the Prototype framework. - * - * John Dyers' website: (http://johndyer.name) - * Color Picker page: (http://johndyer.name/post/2007/09/PhotoShop-like-JavaScript-Color-Picker.aspx) - * - * Change Log - * ______________ - * 1.0.9 - * Added optional title variable for each jPicker window. - * - * 1.0.8 - * Moved all images into a few sprites - now using backgroundPosition to change color maps and bars instead of changing the image - this should be faster to download and run. - * - * 1.0.7 - * RENAMED CSS FILE TO INCLUDE VERSION NUMBER!!! YOU MUST USE THIS VERSIONED CSS FILE!!! There will be no need to do your own CSS version number increments from now on. - * Added opacity feedback to color preview boxes. - * Removed reliance on "id" value of containing object. Subobjects are now found by class and container instead of id's. This drastically reduces injected code. - * Removed (jQuery).jPicker.getListElementById(id) function since "id" is no longer incorporated or required. - * - * 1.0.6 - * Corrected picker bugs introduced with 1.0.5. - * Removed alpha slider bar until activated - default behavior for alpha is now OFF. - * Corrected Color constructor bug not allowing values of 0 for initial value (it was evaluating false and missing the init code - Thanks Pavol). - * Removed title tags (tooltips) from color maps and bars - They get in the way in some browsers (e.g. IE - dragging marker does NOT prevent or hide the tooltip). - * THERE WERE CSS FILE CHANGES WITH THIS UPDATE!!! IF YOU USE NEVER-EXPIRE HEADERS, YOU WILL NEED TO INCREMENT YOUR CSS FILE VERSION NUMBER!!! - * - * 1.0.5 - * Added opacity support to picker and color/callback methods. New property "a" (alpha - range from 0-100) in all color objects now - defaults to 100% opaque. (Thank you Pavol) - * Added title attributes to input elements - gives short tooltip directions on what button or field does. - * Commit callback used to fire on control initialization (twice actually) - This has been corrected, it does not fire on initialization. - * THERE WERE CSS FILE CHANGES WITH THIS UPDATE!!! IF YOU USE NEVER-EXPIRE HEADERS, YOU WILL NEED TO INCREMENT YOUR CSS FILE VERSION NUMBER!!! - * - * 1.0.4 - * Added ability for smaller picker icon with expandable window on any DOM element (not just input). - * "draggable" property renamed to "expandable" and its scope increased to create small picker icon or large static picker. - * - * 1.0.3 - * Added cancelCallback function for registering an external function when user clicks cancel button. (Thank you Jeff and Pavol) - * - * 1.0.2 - * Random bug fixes - speed concerns. - * - * 1.0.1 - * Corrected closure based memeory leak - there may be others? - * - * 1.0.0 - * First Release. - * - */ -(function($, version) -{ - var Slider = // encapsulate slider functionality for the ColorMap and ColorBar - could be useful to use a jQuery UI draggable for this with certain extensions - function(bar, options) - { - var $this = this, // private properties, methods, and events - keep these variables and classes invisible to outside code - arrow = $('img', bar), // the arrow image image to drag - barMouseDown = // bind the mousedown to the bar not the arrow for quick snapping to the clicked location - function(e) - { - setValuesFromMousePosition(e); - // Bind mousemove and mouseup event to the document so it responds when dragged of of the bar - we will unbind these when on mouseup to save processing - $(document).bind('mousemove', docMouseMove).bind('mouseup', docMouseUp); - e.stopPropagation(); - e.preventDefault(); // don't try to select anything or drag the image to the desktop - return false; - }, - docMouseMove = // set the values as the mouse moves - function(e) - { - setValuesFromMousePosition(e); - e.stopPropagation(); - e.preventDefault(); - return false; - }, - docMouseUp = // unbind the document events - they aren't needed when not dragging - function(e) - { - $(document).unbind('mouseup', docMouseUp).unbind('mousemove', docMouseMove); - e.stopPropagation(); - e.preventDefault(); - return false; - }, - setValuesFromMousePosition = // calculate mouse position and set value within the current range - function(e) - { - var offset = bar.offset(), // lets not calculate this more than once - x = e.pageX - offset.left - parseInt(bar.css('border-left-width')), - y = e.pageY - offset.top - parseInt(bar.css('border-top-width')), - barW = bar.w, // local copies for YUI compressor - barH = bar.h, - newX, - newY; - // keep the arrow within the bounds of the bar - if (x < 0) x = 0; - else if (x > barW) x = barW; - if (y < 0) y = 0; - else if (y > barH) y = barH; - // we will use Math.floor for ALL conversion to pixel lengths - parseInt takes a string as input so it boxes the number into a string THEN converts it - // number.toFixed(0) spends time processing rounding which when dealing with imprecise pixels is unnecessary - newX = Math.floor(x / barW * $this.mxX); - newY = Math.floor(y / barH * $this.mxY); - $this.x = newX; - $this.y = newY; - // if x or y have no range, set it to 1D dragging - if ($this.mxX == $this.mnX) x = 0; - if ($this.mxY == $this.mnY) y = 0; - // set the arrow position - $this.setArrowPosition(x, y); - // check if this.valuesChanged is a function and execute it if it is - $.isFunction($this.valuesChanged) && $this.valuesChanged($this); - }; - $.extend(true, $this, // public properties, methods, and event - these we need to access from other controls - { - settings: options, // we'll set map and arrow dimensions and image sources - x: 0, // this is the calculated x value based on the x range and mouse position - y: 0, // this is the calculated y value based on the y range and mouse position - mnX: 0, // set the min x value - mxX: 0, // set the max x value - mnY: 100, // set the min y value - mxY: 100, // set the max y value - valuesChanged: $.isFunction(arguments[2]) && arguments[2] || null, // pass this argument or assign the variable to register for callbacks - setPositioningVariables: - function(e) - { - var map = $this.settings.map; // local copy for YUI compressor - bar.w = map && map.width || bar.width(); - bar.h = map && map.height || bar.height(); - $this.MinX = 0; - $this.MinY = 0; - $this.MaxX = bar.w; - $this.MaxY = bar.h; - }, - setArrowPositionFromValues: - function(e) - { - $this.setPositioningVariables(); - var arrowOffsetX = 0, - arrowOffsetY = 0, - // local copies for YUI compressor - mnX = $this.mnX, - mxX = $this.mxX, - mnY = $this.mnY, - mxY = $this.mxY, - x = $this.x, - y = $this.y; - if (mnX != mxX) // range is greater than zero - { - // constrain to bounds - if (x == mnX) arrowOffsetX = 0; - else if (x == mxX) arrowOffsetX = bar.w; - else // set arrow x position - { - if (mnX < 1) mxX += Math.abs(mnX) + 1; - if (x < 1) x += 1; - arrowOffsetX = x / mxX * bar.w; - if (parseInt(arrowOffsetX) == (mxX - 1)) arrowOffsetX = mxX; - else arrowOffsetX = parseInt(arrowOffsetX); - if (mnX < 1) arrowOffsetX -= Math.abs(mnX) - 1; - } - } - if (mnY != mxY) // range is greater than zero - { - // constrain to bounds - if (y == mnY) arrowOffsetY = 0; - else if (y == mxY) arrowOffsetY = bar.h; - else // set arrow y position - { - if (mnY < 1) mxY += Math.abs(mnY) + 1; - if (y < 1) y += 1; - arrowOffsetY = y / mxY * bar.h; - if (parseInt(arrowOffsetY) == (mxY - 1)) arrowOffsetY = mxY; - else arrowOffsetY = parseInt(arrowOffsetY); - if (mnY < 1) arrowOffsetY -= Math.abs(mnY) - 1; - } - } - // set the arrow position based on these offsets - $this.setArrowPosition(arrowOffsetX, arrowOffsetY); - }, - setArrowPosition: - function(offsetX, offsetY) - { - var barW = bar.w, // local copies for YUI compressor - barH = bar.h, - arrowW = arrow.w, - arrowH = arrow.h; - // constrain arrow to bar x - if (offsetX < 0) offsetX = 0; - else if (offsetX > barW) offsetX = barW; - // constrain arrow to bar y - if (offsetY < 0) offsetY = 0; - else if (offsetY > barH) offsetY = barH; - // if arrow width is greater than bar width, center arrow and prevent horizontal dragging - if (arrowW > barW) offsetX = (barW >> 1) - (arrowW >> 1); // number >> 1 - superfast bitwise divide by two and truncate (move bits over one bit discarding lowest) - else offsetX -= arrowW >> 1; - // if arrow height is greater than bar height, center arrow and prevent vertical dragging - if (arrowH > barH) offsetY = (barH >> 1) - (arrowH >> 1); - else offsetY -= arrowH >> 1; - // set the elements offsets - arrow.css({ left: offsetX + 'px', top: offsetY + 'px' }); - }, - destroy: - function() - { - // unbind all possible events and null objects - $(document).unbind('mouseup', docMouseUp).unbind('mousemove', docMouseMove); - bar.unbind('mousedown', barMouseDown); - bar = null; - arrow = null; - $this.valuesChanged = null; - } - }); - // initialize this control - arrow.src = $this.settings.arrow && $this.settings.arrow.image; - arrow.w = $this.settings.arrow && $this.settings.arrow.width || arrow.width(); - arrow.h = $this.settings.arrow && $this.settings.arrow.height || arrow.height(); - $this.setPositioningVariables(); - // bind mousedown event - bar.bind('mousedown', barMouseDown); - $this.setArrowPositionFromValues(); - // first callback to set initial values - $.isFunction($this.valuesChanged) && $this.valuesChanged($this); - }, - ColorValuePicker = // controls for all the input elements for the typing in color values - function(picker) - { - var $this = this, // private properties and methods - hsvKeyUp = // hue, saturation, or brightness input box key up - validate value and set color - function(e) - { - if (e.target.value == '') return; - validateHsv(e); - $this.setValuesFromHsv(); - $.isFunction($this.valuesChanged) && $this.valuesChanged($this); - }, - rgbKeyUp = // red, green, or blue input box key up - validate and set color - function(e) - { - if (e.target.value == '') return; - validateRgb(e); - $this.setValuesFromRgb(); - $.isFunction($this.valuesChanged) && $this.valuesChanged($this); - }, - alphaKeyUp = // alpha input box blur - validate and set color - function(e) - { - if (e.target.value == '') return; - validateAlpha(e); - color.a = e.target.value; - $.isFunction($this.valuesChanged) && $this.valuesChanged($this); - }, - hsvBlur = // hue, saturation, or brightness input box blur - reset to original if value empty - function(e) - { - if (e.target.value == '') $this.setValuesFromRgb(); - }, - rgbBlur = // red, green, or blue input box blur - reset to original value if empty - function(e) - { - if (e.target.value == '') $this.setValuesFromHsv(); - }, - alphaBlur = // alpha input box blur - reset to 100 if empty - function(e) - { - if (e.target.value == '') fields.alpha.val(100); - }, - hexKeyUp = // hex input box key up - validate and set color - function(e) - { - if (e.target.value == '') return; - validateHex(e); - $this.setValuesFromHex(); - $.isFunction($this.valuesChanged) && $this.valuesChanged($this); - }, - hexBlur = // hex input box blur - reset to original value if empty - function(e) - { - if (e.target.value == '') $this.setValuesFromHsv(); - }, - validateRgb = // validate rgb values - function(e) - { - if (!validateKey(e)) return e; - fields.red.val(setValueInRange(fields.red.val(), 0, 255)); - fields.green.val(setValueInRange(fields.green.val(), 0, 255)); - fields.blue.val(setValueInRange(fields.blue.val(), 0, 255)); - }, - validateAlpha = // validate alpha value - function(e) - { - if (!validateKey(e)) return e; - fields.alpha.val(setValueInRange(fields.alpha.val(), 0, 100)); - }, - validateHsv = // validate hsv values - function(e) - { - if (!validateKey(e)) return e; - fields.hue.val(setValueInRange(fields.hue.val(), 0, 360)); - fields.saturation.val(setValueInRange(fields.saturation.val(), 0, 100)); - fields.value.val(setValueInRange(fields.value.val(), 0, 100)); - }, - validateHex = // validate hex value - function(e) - { - if (!validateKey(e)) return e; - fields.hex.val(fields.hex.val().replace(/[^a-fA-F0-9]/g, '0').toLowerCase().substring(0, 6)); - }, - validateKey = // validate key - function(e) - { - switch(e.keyCode) - { - case 9: - case 16: - case 29: - case 37: - case 38: - case 40: - return false; - case 'c'.charCodeAt(): - case 'v'.charCodeAt(): - if (e.ctrlKey) return false; - } - return true; - }, - setValueInRange = // constrain value within range - function(value, min, max) - { - if (value == '' || isNaN(value)) return min; - value = parseInt(value); - if (value > max) return max; - if (value < min) return min; - return value; - }; - $.extend(true, $this, // public properties and methods - { - color: new Color(), - fields: - { - hue: $('.jPicker_HueText', picker), - saturation: $('.jPicker_SaturationText', picker), - value: $('.jPicker_BrightnessText', picker), - red: $('.jPicker_RedText', picker), - green: $('.jPicker_GreenText', picker), - blue: $('.jPicker_BlueText', picker), - hex: $('.jPicker_HexText', picker), - alpha: $('.jPicker_AlphaText', picker) - }, - valuesChanged: $.isFunction(arguments[1]) && arguments[1] || null, - bindedHexKeyUp: // binded input element key up - function(e) - { - hexKeyUp(e); - }, - setValuesFromRgb: // set values when rgb changes - function() - { - color.fromRgb(fields.red.val(), fields.green.val(), fields.blue.val()); - fields.hex.val(color.hex); - fields.hue.val(color.h); - fields.saturation.val(color.s); - fields.value.val(color.v); - }, - setValuesFromHsv: // set values when hsv changes - function() - { - color.fromHsv(fields.hue.val(), fields.saturation.val(), fields.value.val()); - fields.hex.val(color.hex); - fields.red.val(color.r); - fields.green.val(color.g); - fields.blue.val(color.b); - }, - setValuesFromHex: // set values when hex changes - function() - { - color.fromHex(fields.hex.val()); - fields.red.val(color.r); - fields.green.val(color.g); - fields.blue.val(color.b); - fields.hue.val(color.h); - fields.saturation.val(color.s); - fields.value.val(color.v); - }, - setAlphaFromValue: // set alpha value when bar changes - function() - { - color.a=fields.alpha.val(); - }, - destroy: - function() - { - // unbind all events and null objects - fields.hue.add(fields.saturation).add(fields.value).unbind('keyup', events.hsvKeyUp).unbind('blur', hsvBlur); - fields.red.add(fields.green).add(fields.blue).unbind('keyup', events.rgbKeyUp).unbind('blur', rgbBlur); - fields.alpha.unbind('keyup', alphaKeyUp).unbind('blur', alphaBlur); - fields.hex.unbind('keyup', hexKeyUp); - fields = null; - color = null; - $this.valuesChanged = null; - } - }); - var fields = $this.fields, color = $this.color; // local copies for YUI compressor - fields.hue.add(fields.saturation).add(fields.value).bind('keyup', hsvKeyUp).bind('blur', hsvBlur); - fields.red.add(fields.green).add(fields.blue).bind('keyup', rgbKeyUp).bind('blur', rgbBlur); - fields.alpha.bind('keyup', alphaKeyUp).bind('blur', alphaBlur); - fields.hex.bind('keyup', hexKeyUp).bind('blur', hexBlur); - if (fields.hex.val() != '') - { - color.fromHex(fields.hex.val()); - $this.setValuesFromHex(); - } - }; - $.jPicker = - { - List: [], // array holding references to each active instance of the control - Color: // color object - we will be able to assign by any color space type or retrieve any color space info - // we want this public so we can optionally assign new color objects to initial values using inputs other than a string hex value (also supported) - function(init) - { - var $this = this; - $.extend(true, $this, // public properties and methods - { - r: 0, // Red - g: 0, // Green - b: 0, // Blue - h: 0, // Hue - s: 0, // Saturation - v: 0, // Brightness - a: 100, // Alpha - hex: '', // Hex - fromRgb: - function(r, g, b) - { - var $this = this; - $this.r = r; - $this.g = g; - $this.b = b; - var newHsv = ColorMethods.rgbToHsv($this); - $this.h = newHsv.h; - $this.s = newHsv.s; - $this.v = newHsv.v; - $this.hex = ColorMethods.rgbToHex($this); - }, - fromHsv: - function(h, s, v) - { - var $this = this; - $this.h = h; - $this.s = s; - $this.v = v; - var newRgb = ColorMethods.hsvToRgb($this); - $this.r = newRgb.r; - $this.g = newRgb.g; - $this.b = newRgb.b; - $this.hex = ColorMethods.rgbToHex(newRgb); - }, - fromHex: - function(hex) - { - var $this = this; - $this.hex = hex; - var newRgb = ColorMethods.hexToRgb(hex); - $this.r = newRgb.r; - $this.g = newRgb.g; - $this.b = newRgb.b; - var newHsv = ColorMethods.rgbToHsv(newRgb); - $this.h = newHsv.h; - $this.s = newHsv.s; - $this.v = newHsv.v; - $this.hex = ColorMethods.rgbToHex(newRgb); - } - }); - if (init) - { - if (init.hex) $this.fromHex(init.hex); - else if (!isNaN(init.r)) $this.fromRgb(init.r, init.g, init.b); - else if (!isNaN(init.h)) $this.fromHsv(init.h, init.s, init.v); - if (!isNaN(init.a)) $this.a = init.a; - } - }, - ColorMethods: // color conversion methods - make public to give use to external scripts - { - hexToRgb: - function(hex) - { - hex = this.validateHex(hex); - var r = '00', g = '00', b = '00'; - if (hex.length == 6) - { - r = hex.substring(0, 2); - g = hex.substring(2, 4); - b = hex.substring(4, 6); - } - else - { - if (hex.length > 4) - { - r = hex.substring(4, hex.length); - hex = hex.substring(0, 4); - } - if (hex.length > 2) - { - g = hex.substring(2, hex.length); - hex = hex.substring(0, 2); - } - if (hex.length > 0) b = hex.substring(0, hex.length); - } - return { r: this.hexToInt(r), g: this.hexToInt(g), b: this.hexToInt(b) }; - }, - validateHex: - function(hex) - { - hex = hex.toLowerCase().replace(/[^a-f0-9]/g, '0'); - if (hex.length > 6) hex = hex.substring(0, 6); - return hex; - }, - rgbToHex: - function(rgb) - { - return this.intToHex(rgb.r) + this.intToHex(rgb.g) + this.intToHex(rgb.b); - }, - intToHex: - function(dec) - { - var result = parseInt(dec).toString(16); - if (result.length == 1) result = ('0' + result); - return result.toLowerCase(); - }, - hexToInt: - function(hex) - { - return parseInt(hex, 16); - }, - rgbToHsv: - function(rgb) - { - var r = rgb.r / 255, g = rgb.g / 255, b = rgb.b / 255, hsv = { h: 0, s: 0, v: 0 }, min = 0, max = 0, delta; - if (r >= g && r >= b) - { - max = r; - min = g > b ? b : g; - } - else if (g >= b && g >= r) - { - max = g; - min = r > b ? b : r; - } - else - { - max = b; - min = g > r ? r : g; - } - hsv.v = max; - hsv.s = max ? (max - min) / max : 0; - if (!hsv.s) hsv.h = 0; - else - { - delta = max - min; - if (r == max) hsv.h = (g - b) / delta; - else if (g == max) hsv.h = 2 + (b - r) / delta; - else hsv.h = 4 + (r - g) / delta; - hsv.h = parseInt(hsv.h * 60); - if (hsv.h < 0) hsv.h += 360; - } - hsv.s = parseInt(hsv.s * 100); - hsv.v = parseInt(hsv.v * 100); - return hsv; - }, - hsvToRgb: - function(hsv) - { - var rgb = { r: 0, g: 0, b: 0 }, h = hsv.h, s = hsv.s, v = hsv.v; - if (s == 0) - { - if (v == 0) rgb.r = rgb.g = rgb.b = 0; - else rgb.r = rgb.g = rgb.b = parseInt(v * 255 / 100); - } - else - { - if (h == 360) h = 0; - h /= 60; - s = s / 100; - v = v / 100; - var i = parseInt(h), - f = h - i, - p = v * (1 - s), - q = v * (1 - (s * f)), - t = v * (1 - (s * (1 - f))); - switch (i) - { - case 0: - rgb.r = v; - rgb.g = t; - rgb.b = p; - break; - case 1: - rgb.r = q; - rgb.g = v; - rgb.b = p; - break; - case 2: - rgb.r = p; - rgb.g = v; - rgb.b = t; - break; - case 3: - rgb.r = p; - rgb.g = q; - rgb.b = v; - break; - case 4: - rgb.r = t; - rgb.g = p; - rgb.b = v; - break; - case 5: - rgb.r = v; - rgb.g = p; - rgb.b = q; - break; - } - rgb.r = parseInt(rgb.r * 255); - rgb.g = parseInt(rgb.g * 255); - rgb.b = parseInt(rgb.b * 255); - } - return rgb; - } - } - }; - var Color = $.jPicker.Color, List = $.jPicker.List, ColorMethods = $.jPicker.ColorMethods; // local copies for YUI compressor - $.fn.jPicker = - function(options) - { - var $arguments = arguments; - return this.each( - function() - { - var $this = $(this), $settings = $.extend(true, {}, $.fn.jPicker.defaults, options); // local copies for YUI compressor - if ($this.get(0).nodeName.toLowerCase() == 'input') // Add color picker icon if binding to an input element and bind the events to the input - { - $.extend(true, $settings, - { - window: - { - bindToInput: true, - expandable: true, - input: $this - } - }); - if (ColorMethods.validateHex($this.val())) - { - $settings.color.active = new Color({ hex: $this.val(), a: $settings.color.active.a }); - $settings.color.current = new Color({ hex: $this.val(), a: $settings.color.active.a }); - } - } - if ($settings.window.expandable) - $this.after('   '); - else $settings.window.liveUpdate = false; // Basic control binding for inline use - You will need to override the liveCallback or commitCallback function to retrieve results - var isLessThanIE7 = parseFloat(navigator.appVersion.split('MSIE')[1]) < 7 && document.body.filters, // needed to run the AlphaImageLoader function for IE6 - colorMapL1 = null, // different layers of colorMap and colorBar - colorMapL2 = null, - colorMapL3 = null, - colorBarL1 = null, - colorBarL2 = null, - colorBarL3 = null, - colorBarL4 = null, - colorBarL5 = null, - enableAlpha = null, - alphaCheckbox = null, - alphaBarDiv = null, - alphaBarL1 = null, - alphaBarL2 = null, - container = null, - hue = null, // radio buttons - saturation = null, - value = null, - red = null, - green = null, - blue = null, - colorMap = null, // color maps - colorBar = null, - alphaBar = null, - colorPicker = null, - elementStartX = null, // Used to record the starting css positions for dragging the control - elementStartY = null, - pageStartX = null, // Used to record the mousedown coordinates for dragging the control - pageStartY = null, - activeColor = null, // color boxes above the radio buttons - currentColor = null, - currentActiveBG = null, - okButton = null, - cancelButton = null, - grid = null, // preset colors grid - colorBox = null, // colorBox for popup button - colorIcon = null, // colorIcon popup icon - moveBar = null, // drag bar - setColorMode = // set color mode and update visuals for the new color mode - function(colorMode) - { - color.active = colorPicker.color; - var active = color.active, // local copies for YUI compressor - clientPath = images.clientPath, - resetImage = - function(img) - { - setAlpha(img, 100); - img.css({ backgroundColor: '', backgroundPosition: '0px 0px', filter: '' }); - }; - resetImage(colorMapL1); // reset images - resetImage(colorMapL2); - resetImage(colorBarL1); - resetImage(colorBarL2); - resetImage(colorBarL3); - resetImage(colorBarL4); - hue.add(saturation).add(value).add(red).add(green).add(blue).removeAttr('checked'); - switch (colorMode) - { - case 'h': - hue.attr('checked', true); - colorMapL1.css({ backgroundColor: '#' + active.hex }); - colorMapL2.css({ backgroundColor: 'transparent' }); - setImgLoc(colorMapL2, -256); - setAlpha(colorMapL2, 100); - setImgLoc(colorBarL4, -256); - colorMap.mxX = 100; - colorMap.mxY = 100; - colorBar.mxY = 360; - break; - case 's': - saturation.attr('checked', true); - setImgLoc(colorMapL1, -512); - setImgLoc(colorMapL2, -768); - setAlpha(colorMapL2, 0); - setBG(colorBarL3, active.hex); - setImgLoc(colorBarL4, -512); - colorMap.mxX = 360; - colorMap.mxY = 100; - colorBar.mxY = 100; - break; - case 'v': - value.attr('checked', true); - setBG(colorMapL1, '000'); - setImgLoc(colorMapL2, -1024); - colorBarL3.css({ backgroundColor: '#' + active.hex }); - setImgLoc(colorBarL4, -768); - colorMap.mxX = 360; - colorMap.mxY = 100; - colorBar.mxY = 100; - break; - case 'r': - red.attr('checked', true); - setImgLoc(colorMapL2, -1536); - setImgLoc(colorMapL1, -1280); - setImgLoc(colorBarL4, -1024); - setImgLoc(colorBarL3, -1280); - setImgLoc(colorBarL2, -1536); - setImgLoc(colorBarL1, -1792); - break; - case 'g': - green.attr('checked', true); - setImgLoc(colorMapL2, -2048); - setImgLoc(colorMapL1, -1792); - setImgLoc(colorBarL4, -2048); - setImgLoc(colorBarL3, -2304); - setImgLoc(colorBarL2, -2560); - setImgLoc(colorBarL1, -2816); - break; - case 'b': - blue.attr('checked', true); - setImgLoc(colorMapL2, -2560); - setImgLoc(colorMapL1, -2304); - setImgLoc(colorBarL4, -3072); - setImgLoc(colorBarL3, -3328); - setImgLoc(colorBarL2, -3584); - setImgLoc(colorBarL1, -3840); - break; - default: - throw ('Invalid Mode'); - break; - } - switch (colorMode) - { - case 'h': - case 's': - case 'v': - colorMap.mnX = 1; - colorMap.mnY = 1; - colorBar.mnY = 1; - break; - case 'r': - case 'g': - case 'b': - colorMap.mnX = 0; - colorMap.mnY = 0; - colorBar.mnY = 0; - colorMap.mxX = 255; - colorMap.mxY = 255; - colorBar.mxY = 255; - break; - } - color.mode = colorMode; - positionMapAndBarArrows(); - updateMapVisuals(); - updateBarVisuals(); - if (window.expandable && window.liveUpdate) - { - colorBox.css({ backgroundColor: '#' + active.hex }); - if (window.bindToInput) - window.input.val(active.hex).css( - { - backgroundColor: '#' + active.hex, - color: active.v > 75 ? '#000000' : '#ffffff' - }); - } - $.isFunction($this.liveCallback) && $this.liveCallback(active); - }, - textValuesChanged = // Update color when user changes text values - function() - { - positionMapAndBarArrows(); - updateVisuals(); - color.active = colorPicker.color; - var active = color.active; // local copy for YUI compressor - if (window.expandable && window.liveUpdate) - { - colorBox.css({ backgroundColor: '#' + active.hex }); - if (window.bindToInput) - window.input.val(colorPicker.fields.hex.val()).css( - { - backgroundColor: '#' + active.hex, - color: active.v > 75 ? '#000000' : '#ffffff' - }); - } - $.isFunction($this.liveCallback) && $this.liveCallback(active); - }, - mapValueChanged = // user has dragged the ColorMap pointer - function() - { - if (!colorPicker || !colorMap || !colorBar || !alphaBar) return; - color.active = colorPicker.color; - var fields = colorPicker.fields, // local copies for YUI compressor - active = color.active; - switch (color.mode) - { - case 'h': - fields.saturation.val(colorMap.x); - fields.value.val(100 - colorMap.y); - break; - case 's': - fields.hue.val(colorMap.x); - fields.value.val(100 - colorMap.y); - break; - case 'v': - fields.hue.val(colorMap.x); - fields.saturation.val(100 - colorMap.y); - break; - case 'r': - fields.blue.val(colorMap.x); - fields.green.val(255 - colorMap.y); - break; - case 'g': - fields.blue.val(colorMap.x); - fields.red.val(255 - colorMap.y); - break; - case 'b': - fields.red.val(colorMap.x); - fields.green.val(255 - colorMap.y); - break; - } - switch (color.mode) - { - case 'h': - case 's': - case 'v': - colorPicker.setValuesFromHsv(); - break; - case 'r': - case 'g': - case 'b': - colorPicker.setValuesFromRgb(); - break; - } - updateVisuals(); - if (window.expandable && window.liveUpdate) - { - colorBox.css({ backgroundColor: '#' + active.hex }); - if (window.bindToInput) - window.input.val(active.hex).css( - { - backgroundColor: '#' + active.hex, - color: active.v > 75 ? '#000000' : '#ffffff' - }); - } - $.isFunction($this.liveCallback) && $this.liveCallback(active); - }, - colorBarValueChanged = // user has dragged the ColorBar slider - function() - { - if (!colorPicker || !colorMap || !colorBar || !alphaBar) return; - color.active = colorPicker.color; - var fields = colorPicker.fields, // local copies for YUI compressor - active = color.active; - switch (color.mode) - { - case 'h': - fields.hue.val(360 - colorBar.y); - break; - case 's': - fields.saturation.val(100 - colorBar.y); - break; - case 'v': - fields.value.val(100 - colorBar.y); - break; - case 'r': - fields.red.val(255 - colorBar.y); - break; - case 'g': - fields.green.val(255 - colorBar.y); - break; - case 'b': - fields.blue.val(255 - colorBar.y); - break; - } - switch (color.mode) - { - case 'h': - case 's': - case 'v': - colorPicker.setValuesFromHsv(); - break; - case 'r': - case 'g': - case 'b': - colorPicker.setValuesFromRgb(); - break; - } - updateVisuals(); - if (window.expandable && window.liveUpdate) - { - colorBox.css({ backgroundColor: '#' + active.hex }); - if (window.bindToInput) - window.input.val(active.hex).css( - { - backgroundColor: '#' + active.hex, - color: active.v > 75 ? '#000000' : '#ffffff' - }); - } - $.isFunction($this.liveCallback) && $this.liveCallback(active); - }, - alphaBarValueChanged = - function() - { - if (!colorPicker || !colorMap || !colorBar || !alphaBar) return; - color.active = colorPicker.color; - var fields = colorPicker.fields, // local copies for YUI compressor - active = color.active; - fields.alpha.val(alphaBar.x); - colorPicker.setAlphaFromValue(); - updateVisuals(); - $.isFunction($this.liveCallback) && $this.liveCallback(color.active); - }, - positionMapAndBarArrows = // position map and bar arrows to match current color - function() - { - color.active = colorPicker.color; - var sliderValue = 0, - active = color.active; // local copy for YUI compressor - switch ($this.settings.color.mode) - { - case 'h': - sliderValue = 360 - active.h; - break; - case 's': - sliderValue = 100 - active.s; - break; - case 'v': - sliderValue = 100 - active.v; - break; - case 'r': - sliderValue = 255 - active.r; - break; - case 'g': - sliderValue = 255 - active.g; - break; - case 'b': - sliderValue = 255 - active.b; - break; - } - colorBar.y = sliderValue; - alphaBar.x = active.a; - colorBar.setArrowPositionFromValues(); - alphaBar.setArrowPositionFromValues(); - var mapX = 0, mapY = 0; - switch ($this.settings.color.mode) - { - case 'h': - mapX = active.s; - mapY = 100 - active.v; - break; - case 's': - mapX = active.h; - mapY = 100 - active.v; - break; - case 'v': - mapX = active.h; - mapY = 100 - active.s; - break; - case 'r': - mapX = active.b; - mapY = 256 - active.g; - break; - case 'g': - mapX = active.b; - mapY = 256 - active.r; - break; - case 'b': - mapX = active.r; - mapY = 256 - active.g; - break; - } - colorMap.x = mapX; - colorMap.y = mapY; - colorMap.setArrowPositionFromValues(); - }, - updateVisuals = - function() - { - updatePreview(); - updateMapVisuals(); - updateBarVisuals(); - updateAlphaVisuals(); - }, - updatePreview = - function() - { - try - { - activeColor.css({ backgroundColor: '#' + colorPicker.color.hex }); - setAlpha(activeColor, colorPicker.color.a); - } - catch (e) { } - }, - updateMapVisuals = - function() - { - if (!color || !colorPicker) return; - color.active = colorPicker.color; - var active = color.active; // local copy for YUI compressor - switch (color.mode) - { - case 'h': - setBG(colorMapL1, new Color({ h: active.h, s: 100, v: 100 }).hex); - break; - case 's': - setAlpha(colorMapL2, 100 - active.s); - break; - case 'v': - setAlpha(colorMapL2, active.v); - break; - case 'r': - setAlpha(colorMapL2, active.r / 256 * 100); - break; - case 'g': - setAlpha(colorMapL2, active.g / 256 * 100); - break; - case 'b': - setAlpha(colorMapL2, active.b / 256 * 100); - break; - } - setAlpha(colorMapL3, 100 - active.a); - }, - updateBarVisuals = - function() - { - if (!color || !colorPicker) return; - color.active = colorPicker.color; - var active = color.active, // local copy for YUI compressor - mode = color.mode, - fields = colorPicker.fields; - switch (mode) - { - case 'h': - break; - case 's': - var saturatedColor = new Color({ h: active.h, s: 100, v: active.v }); - setBG(colorBarL3, saturatedColor.hex); - break; - case 'v': - var valueColor = new Color({ h: active.h, s: active.s, v: 100 }); - setBG(colorBarL3, valueColor.hex); - break; - case 'r': - case 'g': - case 'b': - var hValue = 0, vValue = 0; - if (mode == 'r') - { - hValue = fields.blue.val(); - vValue = fields.green.val(); - } - else if (mode == 'g') - { - hValue = fields.blue.val(); - vValue = fields.red.val(); - } - else if (mode == 'b') - { - hValue = fields.red.val(); - vValue = fields.green.val(); - } - var horzPer = hValue / 256 * 100, vertPer = vValue / 256 * 100, horzPerRev = (256 - hValue) / 256 * 100, vertPerRev = (256 - vValue) / 256 * 100; - setAlpha(colorBarL4, vertPer > horzPerRev ? horzPerRev : vertPer); - setAlpha(colorBarL3, vertPer > horzPer ? horzPer : vertPer); - setAlpha(colorBarL2, vertPerRev > horzPer ? horzPer : vertPerRev); - setAlpha(colorBarL1, vertPerRev > horzPerRev ? horzPerRev : vertPerRev); - break; - } - setAlpha(colorBarL5, 100 - active.a); - }, - updateAlphaVisuals = - function() - { - setBG(alphaBarL1, colorPicker.color.hex); - }, - setBG = - function(el, c) - { - try - { - el.css({ backgroundColor: '#' + c }); - } - catch (e) { } - }, - setImg = - function(img, src) - { - if (src.indexOf('png') && this.isLessThanIE7) - { - img.attr('pngSrc', src); - img.css({ backgroundImage: 'none', filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\')' }); - } - else img.css({ backgroundImage: 'url(' + src + ')' }); - }, - setImgLoc = - function(img, y) - { - img.css({ backgroundPosition: '0px ' + y + 'px' }); - }, - setAlpha = - function(obj, alpha) - { - if (alpha < 100) - { - if (this.isLessThanIE7) - { - var src = obj.attr('pngSrc'); - if (src != null && src.indexOf('map-hue') == -1) - obj.css({ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\') progid:DXImageTransform.Microsoft.Alpha(opacity=' + alpha + ')' }); - } - else obj.css({ opacity: alpha / 100 }); - } - else if (alpha == 100) // IE7 still will not combine 8-bit PNG translucency AND element opacity without drawing errors - // Even opacity:1.0 (or filter:Alpha(opacity=100)) causes issues, so remove it if opaque - { - if (this.isLessThanIE7) - { - var src = obj.attr('pngSrc'); - if (src != null && src.indexOf('map-hue') == -1) obj.css({ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\')' }); - } - else obj.css({ opacity: '' }); - } - }, - revertColor = // revert color to original color when opened - function() - { - colorPicker.fields.hex.val(color.current.hex); - colorPicker.fields.alpha.val(color.current.a); - colorPicker.setValuesFromHex(); - colorPicker.setAlphaFromValue(); - $.isFunction(colorPicker.valuesChanged) && colorPicker.valuesChanged(colorPicker); - }, - radioClicked = - function(e) - { - setColorMode(e.target.value); - }, - currentClicked = - function() - { - revertColor(); - }, - cancelClicked = - function() - { - revertColor(); - window.expandable && $this.hide(); - $.isFunction($this.cancelCallback) && $this.cancelCallback(); - }, - commitColor = // commit the color changes - function() - { - var active = color.active; // local copies for YUI compressor - color.current = new Color({ hex: active.hex }); - color.current.a = active.a; - currentColor.css({ backgroundColor: '#' + active.hex }); - setAlpha(currentColor, colorPicker.color.a); - if (window.expandable) - { - colorBox.css({ backgroundColor: '#' + active.hex }); - if (window.bindToInput) - window.input.val(active.hex).css( - { - backgroundColor: '#' + active.hex, - color: active.v > 75 ? '#000000' : '#ffffff' - }); - } - $.isFunction($this.commitCallback) && $this.commitCallback(active); - }, - okClicked = - function() - { - commitColor(); - window.expandable && $this.hide(); - }, - colorIconClicked = - function() - { - $this.show(); - }, - moveBarMouseDown = - function(e) - { - var element = window.element, // local copies for YUI compressor - page = window.page; - elementStartX = parseInt(container.css('left')); - elementStartY = parseInt(container.css('top')); - pageStartX = e.pageX; - pageStartY = e.pageY; - // bind events to document to move window - we will unbind these on mouseup - $(document).bind('mousemove', documentMouseMove).bind('mouseup', documentMouseUp); - e.stopPropagation(); - e.preventDefault(); // prevent attempted dragging of the column - return false; - }, - documentMouseMove = - function(e) - { - container.css({ left: elementStartX - (pageStartX - e.pageX) + 'px', top: elementStartY - (pageStartY - e.pageY) + 'px' }); - e.stopPropagation(); - e.preventDefault(); - return false; - }, - documentMouseUp = - function(e) - { - $(document).unbind('mousemove', documentMouseMove).unbind('mouseup', documentMouseUp); - e.stopPropagation(); - e.preventDefault(); - return false; - }, - bindedHexKeyUp = - function(e) - { - colorPicker.fields.hex.val($this.settings.window.input.val()); - colorPicker.bindedHexKeyUp(e); - }, - quickPickClicked = - function(e) - { - colorPicker.fields.hex.val(color.quickList[e.data.i].hex); - colorPicker.fields.alpha.val(color.quickList[e.data.i].a); - colorPicker.setValuesFromHex(); - colorPicker.setAlphaFromValue(); - $.isFunction(colorPicker.valuesChanged) && colorPicker.valuesChanged(colorPicker); - }; - $.extend(true, $this, // public properties, methods, and callbacks - { - id: $this.attr('id'), - settings: $settings, - color: null, - icon: null, - commitCallback: $.isFunction($arguments[1]) && $arguments[1] || null, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks "OK" - liveCallback: $.isFunction($arguments[2]) && $arguments[2] || null, // liveCallback function can be overridden to return the selected color to a method you specify in live mode (continuous update) - cancelCallback: $.isFunction($arguments[3]) && $arguments[3] || null, // cancelCallback function can be overridden to a method you specify when the user clicks "Cancel" - show: - function() - { - if (document.all) // In IE, due to calculated z-index values, we need to hide all color picker icons that appear later in the source code than this one - { - var foundthis = false; - for (i = 0; i < List.length; i++) - { - if (foundthis) List[i].color.add(List[i].icon).css({ display: 'none' }); - if (List[i].id == $this.id) foundthis = true; - } - } - color.current = new Color({ hex: color.active.hex, a: color.active.a }); - currentColor.css({ backgroundColor: '#' + color.active.hex }); - setAlpha(currentColor, color.active.a); - container.css({ display: 'block' }); - colorMap.setPositioningVariables(); - colorBar.setPositioningVariables(); - positionMapAndBarArrows(); - }, - hide: - function() - { - if (document.all) // In IE, show the previously hidden color picker icons again - { - var foundthis = false; - for (i = 0; i < List.length; i++) - { - if (foundthis) List[i].color.add(List[i].icon).css({ display: 'block' }); - if (List[i].id == $this.id) foundthis = true; - } - } - container.css({ display: 'none' }); - }, - destroy: // destroys this control entirely, removing all events and objects, and removing itself from the List - function() - { - if (window.expandable) colorIcon = $('.jPicker_Icon', container).unbind('click', colorIconClicked); - if (window.bindToInput) window.input.unbind('keyup', bindedHexKeyUp).unbind('change', bindedHexKeyUp); - hue.add(saturation).add(value).add(red).add(green).add(blue).unbind('click', radioClicked); - currentColor.unbind('click', currentClicked); - cancelButton.unbind('click', cancelClicked); - okButton.unbind('click', okClicked); - if (window.expandable) moveBar.unbind('mousedown', moveBarMouseDown); - $('.jPicker_QuickColor', container).unbind('click', quickPickClicked); - hue = null; - saturation = null; - value = null; - red = null; - green = null; - blue = null; - colorMapL1 = null; - colorMapL2 = null; - colorMapL3 = null; - colorBarL1 = null; - colorBarL2 = null; - colorBarL3 = null; - colorBarL4 = null; - colorBarL5 = null; - enableAlpha = null; - alphaCheckbox = null; - alphaBarDiv = null; - alphaBarL1 = null; - alphaBarL2 = null; - currentActiveBG = null; - activeColor = null; - currentColor = null; - okButton = null; - cancelButton = null; - grid = null; - $this.color = null; - $this.icon = null; - colorMap.destroy(); - colorMap = null; - colorBar.destroy(); - colorBar = null; - alphaBar.destroy(); - alphaBar = null; - colorPicker.destroy(); - colorPicker = null; - $this.commitCallback = null; - $this.cancelCallback = null; - $this.liveCallback = null; - container.html(''); - for (i = 0; i < List.length; i++) if (List[i].id == $this.id) List.splice(i, 1); - } - }); - var images = $this.settings.images, // local copies for YUI compressor - window = $this.settings.window, - color = $this.settings.color; - container = window.expandable ? $('.jPicker_Container', $this.next()) : $this; - if (window.expandable) - container.css( // positions must be set and display set to absolute before source code injection or IE will size the container to fit the window - { - left: window.position.x == 'left' ? '-526px' : window.position.x == 'center' ? '-259px' : window.position.x == 'right' ? '0px' : window.position.x == 'screenCenter' ? - (($(document).width() >> 1) - 259) - $this.next().offset().left + 'px' : window.position.x, - position: 'absolute', - top: window.position.y == 'top' ? '-340px' : window.position.y == 'center' ? '-153px' : window.position.y == 'bottom' ? '25px' : window.position.y - }); - // if default colors are hex strings, change them to color objects - if ((typeof (color.active)).toString().toLowerCase() == 'string') color.active = new Color({ hex: color.active.substring(1) }); - // inject html source code - we are using a single table for this control - I know tables are considered bad, but it takes care of equal height columns and - // this control really is tabular data, so I believe it is the right move - if (!color.alphaSupport) color.active.a = 100; - container.html('' + (window.expandable ? '' : '') + '
 

' + (window.title || 'Drag Markers To Pick A Color') + '

   
     
new
  
current

 
°
%
%
 
  
% 
'); - // initialize the objects to the source code just injected - hue = $('.jPicker_HueRadio', container); - saturation = $('.jPicker_SaturationRadio', container); - value = $('.jPicker_BrightnessRadio', container); - red = $('.jPicker_RedRadio', container); - green = $('.jPicker_GreenRadio', container); - blue = $('.jPicker_BlueRadio', container); - colorMapL1 = $('.jPicker_ColorMap_l1', container); - colorMapL2 = $('.jPicker_ColorMap_l2', container); - colorMapL3 = $('.jPicker_ColorMap_l3', container); - colorBarL1 = $('.jPicker_ColorBar_l1', container); - colorBarL2 = $('.jPicker_ColorBar_l2', container); - colorBarL3 = $('.jPicker_ColorBar_l3', container); - colorBarL4 = $('.jPicker_ColorBar_l4', container); - colorBarL5 = $('.jPicker_ColorBar_l5', container); - alphaBarL1 = $('.jPicker_AlphaBar_l1', container); - alphaBarL2 = $('.jPicker_AlphaBar_l2', container); - enableAlpha = $('.jPicker_EnableAlpha', container); - alphaCheckbox = $('.jPicker_AlphaCheckbox', container); - alphaBarDiv = $('.jPicker_AlphaBar', container); - currentActiveBG = $('.jPicker_NewCurrent', container); - activeColor = $('.jPicker_Active', container).css({ backgroundColor: '#' + color.active.hex }); - currentColor = $('.jPicker_Current', container).css({ backgroundColor: '#' + color.active.hex }); - okButton = $('.jPicker_Ok', container); - cancelButton = $('.jPicker_Cancel', container); - grid = $('.jPicker_Grid', container); - $this.color = $('.Picker_Color'); - $this.icon = $('.jPicker_Icon'); - // create color pickers and maps - colorPicker = new ColorValuePicker(container, textValuesChanged); - colorMap = new Slider($('.jPicker_ColorMap', container), - { - map: - { - width: images.colorMap.width, - height: images.colorMap.height - }, - arrow: - { - image: images.clientPath + images.colorMap.arrow.file, - width: images.colorMap.arrow.width, - height: images.colorMap.arrow.height - } - }, - mapValueChanged); - colorBar = new Slider($('.jPicker_ColorBar', container), - { - map: - { - width: images.colorBar.width, - height: images.colorBar.height - }, - arrow: - { - image: images.clientPath + images.colorBar.arrow.file, - width: images.colorBar.arrow.width, - height: images.colorBar.arrow.height - } - }, - colorBarValueChanged); - alphaBar = new Slider($('.jPicker_AlphaBar', container), - { - map: - { - width: images.alphaBar.width, - height: images.alphaBar.height - }, - arrow: - { - image: images.clientPath + images.alphaBar.arrow.file, - width: images.alphaBar.arrow.width, - height: images.alphaBar.arrow.height - } - }, - alphaBarValueChanged); - alphaBar.mnX = 0; - alphaBar.mxX = 100; - setImg(colorMapL1, images.clientPath + 'Maps.png'); - setImg(colorMapL2, images.clientPath + 'Maps.png'); - setImg(colorMapL3, images.clientPath + 'map-opacity.png'); - setImg(colorBarL1, images.clientPath + 'Bars.png'); - setImg(colorBarL2, images.clientPath + 'Bars.png'); - setImg(colorBarL3, images.clientPath + 'Bars.png'); - setImg(colorBarL4, images.clientPath + 'Bars.png'); - setImg(colorBarL5, images.clientPath + 'bar-opacity.png'); - setImg(alphaBarL2, images.clientPath + 'Maps.png'); - setImgLoc(alphaBarL2, -2816); - setImg(currentActiveBG, images.clientPath + 'preview-opacity.png'); - currentActiveBG.css({ backgroundPosition: '1px 1px' }); - if (color.alphaSupport) - { - enableAlpha.hide(); - alphaBarDiv.show(); - $('td.jPicker_OpacityCol *', container).show(); - } - else - alphaCheckbox.bind('click', - function() - { - enableAlpha.hide(); - alphaBarDiv.show(); - $('td.jPicker_OpacityCol *', container).show(); - }); - // bind to input - if (window.expandable) - { - colorBox = $('.jPicker_Color', $this.next()).css({ backgroundColor: '#' + color.active.hex }); - colorIcon = $('.jPicker_Icon', $this.next()).css( - { - backgroundImage: 'url(' + images.clientPath + images.picker.file + ')' - }).bind('click', colorIconClicked); - if (window.bindToInput) window.input.bind('keyup', bindedHexKeyUp).bind('change', bindedHexKeyUp); - } - hue.add(saturation).add(value).add(red).add(green).add(blue).bind('click', radioClicked); - currentColor.bind('click', currentClicked); - cancelButton.bind('click', cancelClicked); - okButton.bind('click', okClicked); - if (window.expandable) moveBar = $('.jPicker_MoveBar', container).bind('mousedown', moveBarMouseDown); - // initialize quick list - if (color.quickList && color.quickList.length > 0) - { - grid.html(''); - for (i = 0; i < color.quickList.length; i++) - { - /* if default colors are hex strings, change them to color objects */ - if ((typeof (color.quickList[i])).toString().toLowerCase() == 'string') color.quickList[i] = new Color({ hex: color.quickList[i].substring(1) }); - grid.append(' '); - $('.jPicker_QuickColor', container).eq(i).css({ backgroundColor: '#' + color.quickList[i].hex }).bind('click', { i: i }, quickPickClicked); - } - } - setColorMode(color.mode); - colorPicker.fields.hex.val(colorBar.hex); - colorPicker.setValuesFromHex(); - colorPicker.setAlphaFromValue(); - positionMapAndBarArrows(); - updateVisuals(); - if (!window.expandable) $this.show(); - List.push($this); - }); - }; - $.fn.jPicker.defaults = /* jPicker defaults - you can change anything in this section (such as the clientPath to your images) without fear of breaking the program */ - { - window: - { - title: null, /* any title for the jPicker window itself - displays "Drag Markers To Pick A Color" if left null */ - position: - { - x: 'screenCenter', /* acceptable values "left", "center", "right", "screenCenter", or relative px value */ - y: 'top' /* acceptable values "top", "bottom", "center", or relative px value */ - }, - expandable: false, /* default to large static picker - set to true to make an expandable picker (small icon with popup) - set automatically when binded to input element */ - liveUpdate: true /* set false if you want the user to have to click "OK" before the binded input box updates values */ - }, - color: - { - mode: 'h', /* acceptabled values "h" (hue), "s" (saturation), "v" (brightness), "r" (red), "g" (green), "b" (blue) */ - active: new Color({ hex: 'ffc000' }), /* acceptable values are any declared $.jPicker.Color object or string HEX value (e.g. #ffc000) INCLUDING the "#" prefix */ - alphaSupport: false, /* change to true to enable alpha editing support (without this, alpha will always be 100) */ - quickList: /* the quick pick color list */ - [ - new Color({ h: 360, s: 33, v: 100 }), /* acceptable values are any declared $.jPicker.Color object or string HEX value (e.g. #ffc000) INCLUDING the "#" prefix */ - new Color({ h: 360, s: 66, v: 100 }), - new Color({ h: 360, s: 100, v: 100 }), - new Color({ h: 360, s: 100, v: 75 }), - new Color({ h: 360, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 100 }), - new Color({ h: 30, s: 33, v: 100 }), - new Color({ h: 30, s: 66, v: 100 }), - new Color({ h: 30, s: 100, v: 100 }), - new Color({ h: 30, s: 100, v: 75 }), - new Color({ h: 30, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 90 }), - new Color({ h: 60, s: 33, v: 100 }), - new Color({ h: 60, s: 66, v: 100 }), - new Color({ h: 60, s: 100, v: 100 }), - new Color({ h: 60, s: 100, v: 75 }), - new Color({ h: 60, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 80 }), - new Color({ h: 90, s: 33, v: 100 }), - new Color({ h: 90, s: 66, v: 100 }), - new Color({ h: 90, s: 100, v: 100 }), - new Color({ h: 90, s: 100, v: 75 }), - new Color({ h: 90, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 70 }), - new Color({ h: 120, s: 33, v: 100 }), - new Color({ h: 120, s: 66, v: 100 }), - new Color({ h: 120, s: 100, v: 100 }), - new Color({ h: 120, s: 100, v: 75 }), - new Color({ h: 120, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 60 }), - new Color({ h: 150, s: 33, v: 100 }), - new Color({ h: 150, s: 66, v: 100 }), - new Color({ h: 150, s: 100, v: 100 }), - new Color({ h: 150, s: 100, v: 75 }), - new Color({ h: 150, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 50 }), - new Color({ h: 180, s: 33, v: 100 }), - new Color({ h: 180, s: 66, v: 100 }), - new Color({ h: 180, s: 100, v: 100 }), - new Color({ h: 180, s: 100, v: 75 }), - new Color({ h: 180, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 40 }), - new Color({ h: 210, s: 33, v: 100 }), - new Color({ h: 210, s: 66, v: 100 }), - new Color({ h: 210, s: 100, v: 100 }), - new Color({ h: 210, s: 100, v: 75 }), - new Color({ h: 210, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 30 }), - new Color({ h: 240, s: 33, v: 100 }), - new Color({ h: 240, s: 66, v: 100 }), - new Color({ h: 240, s: 100, v: 100 }), - new Color({ h: 240, s: 100, v: 75 }), - new Color({ h: 240, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 20 }), - new Color({ h: 270, s: 33, v: 100 }), - new Color({ h: 270, s: 66, v: 100 }), - new Color({ h: 270, s: 100, v: 100 }), - new Color({ h: 270, s: 100, v: 75 }), - new Color({ h: 270, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 10 }), - new Color({ h: 300, s: 33, v: 100 }), - new Color({ h: 300, s: 66, v: 100 }), - new Color({ h: 300, s: 100, v: 100 }), - new Color({ h: 300, s: 100, v: 75 }), - new Color({ h: 300, s: 100, v: 50 }), - new Color({ h: 180, s: 0, v: 0 }), - new Color({ h: 330, s: 33, v: 100 }), - new Color({ h: 330, s: 66, v: 100 }), - new Color({ h: 330, s: 100, v: 100 }), - new Color({ h: 330, s: 100, v: 75 }), - new Color({ h: 330, s: 100, v: 50 }) - ] - }, - images: - { - clientPath: '/jPicker/images/', /* Path to image files */ - colorMap: - { - width: 256, - height: 256, - arrow: - { - file: 'mappoint.gif', /* ColorMap arrow icon */ - width: 15, - height: 15 - } - }, - colorBar: - { - width: 20, - height: 256, - arrow: - { - file: 'rangearrows.gif', /* ColorBar arrow icon */ - width: 40, - height: 9 - } - }, - alphaBar: - { - width: 256, - height: 20, - arrow: - { - file: 'rangearrows2.gif', /* AlphaBar arrow icon */ - width: 9, - height: 40 - } - }, - picker: - { - file: 'picker.gif', /* Color Picker icon */ - width: 25, - height: 24 - } - } - }; -})(jQuery, '1.0.9'); diff --git a/editor/jpicker/jpicker-1.0.9.min.js b/editor/jpicker/jpicker-1.0.9.min.js deleted file mode 100755 index 2627c1d1..00000000 --- a/editor/jpicker/jpicker-1.0.9.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(e,a){var d=function(n,k){var p=this,o=e("img",n),l=function(q){h(q);e(document).bind("mousemove",m).bind("mouseup",j);q.stopPropagation();q.preventDefault();return false;},m=function(q){h(q);q.stopPropagation();q.preventDefault();return false;},j=function(q){e(document).unbind("mouseup",j).unbind("mousemove",m);q.stopPropagation();q.preventDefault();return false;},h=function(u){var w=n.offset(),q=u.pageX-w.left-parseInt(n.css("border-left-width")),z=u.pageY-w.top-parseInt(n.css("border-top-width")),t=n.w,r=n.h,v,s;if(q<0){q=0;}else{if(q>t){q=t;}}if(z<0){z=0;}else{if(z>r){z=r;}}v=Math.floor(q/t*p.mxX);s=Math.floor(z/r*p.mxY);p.x=v;p.y=s;if(p.mxX==p.mnX){q=0;}if(p.mxY==p.mnY){z=0;}p.setArrowPosition(q,z);e.isFunction(p.valuesChanged)&&p.valuesChanged(p);};e.extend(true,p,{settings:k,x:0,y:0,mnX:0,mxX:0,mnY:100,mxY:100,valuesChanged:e.isFunction(arguments[2])&&arguments[2]||null,setPositioningVariables:function(r){var q=p.settings.map;n.w=q&&q.width||n.width();n.h=q&&q.height||n.height();p.MinX=0;p.MinY=0;p.MaxX=n.w;p.MaxY=n.h;},setArrowPositionFromValues:function(t){p.setPositioningVariables();var w=0,v=0,u=p.mnX,r=p.mxX,s=p.mnY,q=p.mxY,A=p.x,z=p.y;if(u!=r){if(A==u){w=0;}else{if(A==r){w=n.w;}else{if(u<1){r+=Math.abs(u)+1;}if(A<1){A+=1;}w=A/r*n.w;if(parseInt(w)==(r-1)){w=r;}else{w=parseInt(w);}if(u<1){w-=Math.abs(u)-1;}}}}if(s!=q){if(z==s){v=0;}else{if(z==q){v=n.h;}else{if(s<1){q+=Math.abs(s)+1;}if(z<1){z+=1;}v=z/q*n.h;if(parseInt(v)==(q-1)){v=q;}else{v=parseInt(v);}if(s<1){v-=Math.abs(s)-1;}}}}p.setArrowPosition(w,v);},setArrowPosition:function(q,v){var u=n.w,s=n.h,t=o.w,r=o.h;if(q<0){q=0;}else{if(q>u){q=u;}}if(v<0){v=0;}else{if(v>s){v=s;}}if(t>u){q=(u>>1)-(t>>1);}else{q-=t>>1;}if(r>s){v=(s>>1)-(r>>1);}else{v-=r>>1;}o.css({left:q+"px",top:v+"px"});},destroy:function(){e(document).unbind("mouseup",j).unbind("mousemove",m);n.unbind("mousedown",l);n=null;o=null;p.valuesChanged=null;}});o.src=p.settings.arrow&&p.settings.arrow.image;o.w=p.settings.arrow&&p.settings.arrow.width||o.width();o.h=p.settings.arrow&&p.settings.arrow.height||o.height();p.setPositioningVariables();n.bind("mousedown",l);p.setArrowPositionFromValues();e.isFunction(p.valuesChanged)&&p.valuesChanged(p);},b=function(n){var m=this,y=function(A){if(A.target.value==""){return;}t(A);m.setValuesFromHsv();e.isFunction(m.valuesChanged)&&m.valuesChanged(m);},s=function(A){if(A.target.value==""){return;}q(A);m.setValuesFromRgb();e.isFunction(m.valuesChanged)&&m.valuesChanged(m);},r=function(A){if(A.target.value==""){return;}l(A);w.a=A.target.value;e.isFunction(m.valuesChanged)&&m.valuesChanged(m);},v=function(A){if(A.target.value==""){m.setValuesFromRgb();}},k=function(A){if(A.target.value==""){m.setValuesFromHsv();}},o=function(A){if(A.target.value==""){u.alpha.val(100);}},z=function(A){if(A.target.value==""){return;}x(A);m.setValuesFromHex();e.isFunction(m.valuesChanged)&&m.valuesChanged(m);},j=function(A){if(A.target.value==""){m.setValuesFromHsv();}},q=function(A){if(!p(A)){return A;}u.red.val(h(u.red.val(),0,255));u.green.val(h(u.green.val(),0,255));u.blue.val(h(u.blue.val(),0,255));},l=function(A){if(!p(A)){return A;}u.alpha.val(h(u.alpha.val(),0,100));},t=function(A){if(!p(A)){return A;}u.hue.val(h(u.hue.val(),0,360));u.saturation.val(h(u.saturation.val(),0,100));u.value.val(h(u.value.val(),0,100));},x=function(A){if(!p(A)){return A;}u.hex.val(u.hex.val().replace(/[^a-fA-F0-9]/g,"0").toLowerCase().substring(0,6));},p=function(A){switch(A.keyCode){case 9:case 16:case 29:case 37:case 38:case 40:return false;case"c".charCodeAt():case"v".charCodeAt():if(A.ctrlKey){return false;}}return true;},h=function(C,B,A){if(C==""||isNaN(C)){return B;}C=parseInt(C);if(C>A){return A;}if(C4){k=l.substring(4,l.length);l=l.substring(0,4);}if(l.length>2){j=l.substring(2,l.length);l=l.substring(0,2);}if(l.length>0){h=l.substring(0,l.length);}}return{r:this.hexToInt(k),g:this.hexToInt(j),b:this.hexToInt(h)};},validateHex:function(h){h=h.toLowerCase().replace(/[^a-f0-9]/g,"0");if(h.length>6){h=h.substring(0,6);}return h;},rgbToHex:function(h){return this.intToHex(h.r)+this.intToHex(h.g)+this.intToHex(h.b);},intToHex:function(j){var h=parseInt(j).toString(16);if(h.length==1){h=("0"+h);}return h.toLowerCase();},hexToInt:function(h){return parseInt(h,16);},rgbToHsv:function(l){var o=l.r/255,n=l.g/255,j=l.b/255,k={h:0,s:0,v:0},m=0,h=0,p;if(o>=n&&o>=j){h=o;m=n>j?j:n;}else{if(n>=j&&n>=o){h=n;m=o>j?j:o;}else{h=j;m=n>o?o:n;}}k.v=h;k.s=h?(h-m)/h:0;if(!k.s){k.h=0;}else{p=h-m;if(o==h){k.h=(n-j)/p;}else{if(n==h){k.h=2+(j-o)/p;}else{k.h=4+(o-n)/p;}}k.h=parseInt(k.h*60);if(k.h<0){k.h+=360;}}k.s=parseInt(k.s*100);k.v=parseInt(k.v*100);return k;},hsvToRgb:function(n){var r={r:0,g:0,b:0},m=n.h,x=n.s,u=n.v;if(x==0){if(u==0){r.r=r.g=r.b=0;}else{r.r=r.g=r.b=parseInt(u*255/100);}}else{if(m==360){m=0;}m/=60;x=x/100;u=u/100;var l=parseInt(m),o=m-l,k=u*(1-x),j=u*(1-(x*o)),w=u*(1-(x*(1-o)));switch(l){case 0:r.r=u;r.g=w;r.b=k;break;case 1:r.r=j;r.g=u;r.b=k;break;case 2:r.r=k;r.g=u;r.b=w;break;case 3:r.r=k;r.g=j;r.b=u;break;case 4:r.r=w;r.g=k;r.b=u;break;case 5:r.r=u;r.g=k;r.b=j;break;}r.r=parseInt(r.r*255);r.g=parseInt(r.g*255);r.b=parseInt(r.b*255);}return r;}}};var f=e.jPicker.Color,c=e.jPicker.List,g=e.jPicker.ColorMethods;e.fn.jPicker=function(j){var h=arguments;return this.each(function(){var w=e(this),y=e.extend(true,{},e.fn.jPicker.defaults,j);if(w.get(0).nodeName.toLowerCase()=="input"){e.extend(true,y,{window:{bindToInput:true,expandable:true,input:w}});if(g.validateHex(w.val())){y.color.active=new f({hex:w.val(),a:y.color.active.a});y.color.current=new f({hex:w.val(),a:y.color.active.a});}}if(y.window.expandable){w.after('   ');}else{y.window.liveUpdate=false;}var W=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,ax=null,aw=null,av=null,U=null,T=null,S=null,R=null,Q=null,aC=null,V=null,au=null,J=null,I=null,X=null,ac=null,az=null,ak=null,am=null,ao=null,K=null,G=null,aa=null,L=null,ay=null,P=null,O=null,at=null,aq=null,A=null,l=null,M=null,ap=null,ad=null,ai=null,n=null,C=null,u=null,an=function(aE){N.active=ay.color;var aF=N.active,aG=p.clientPath,aD=function(aH){ae(aH,100);aH.css({backgroundColor:"",backgroundPosition:"0px 0px",filter:""});};aD(ax);aD(aw);aD(U);aD(T);aD(S);aD(R);ac.add(az).add(ak).add(am).add(ao).add(K).removeAttr("checked");switch(aE){case"h":ac.attr("checked",true);ax.css({backgroundColor:"#"+aF.hex});aw.css({backgroundColor:"transparent"});x(aw,-256);ae(aw,100);x(R,-256);G.mxX=100;G.mxY=100;aa.mxY=360;break;case"s":az.attr("checked",true);x(ax,-512);x(aw,-768);ae(aw,0);z(S,aF.hex);x(R,-512);G.mxX=360;G.mxY=100;aa.mxY=100;break;case"v":ak.attr("checked",true);z(ax,"000");x(aw,-1024);S.css({backgroundColor:"#"+aF.hex});x(R,-768);G.mxX=360;G.mxY=100;aa.mxY=100;break;case"r":am.attr("checked",true);x(aw,-1536);x(ax,-1280);x(R,-1024);x(S,-1280);x(T,-1536);x(U,-1792);break;case"g":ao.attr("checked",true);x(aw,-2048);x(ax,-1792);x(R,-2048);x(S,-2304);x(T,-2560);x(U,-2816);break;case"b":K.attr("checked",true);x(aw,-2560);x(ax,-2304);x(R,-3072);x(S,-3328);x(T,-3584);x(U,-3840);break;default:throw ("Invalid Mode");break;}switch(aE){case"h":case"s":case"v":G.mnX=1;G.mnY=1;aa.mnY=1;break;case"r":case"g":case"b":G.mnX=0;G.mnY=0;aa.mnY=0;G.mxX=255;G.mxY=255;aa.mxY=255;break;}N.mode=aE;v();ar();ab();if(aj.expandable&&aj.liveUpdate){n.css({backgroundColor:"#"+aF.hex});if(aj.bindToInput){aj.input.val(aF.hex).css({backgroundColor:"#"+aF.hex,color:aF.v>75?"#000000":"#ffffff"});}}e.isFunction(w.liveCallback)&&w.liveCallback(aF);},m=function(){v();ah();N.active=ay.color;var aD=N.active;if(aj.expandable&&aj.liveUpdate){n.css({backgroundColor:"#"+aD.hex});if(aj.bindToInput){aj.input.val(ay.fields.hex.val()).css({backgroundColor:"#"+aD.hex,color:aD.v>75?"#000000":"#ffffff"});}}e.isFunction(w.liveCallback)&&w.liveCallback(aD);},B=function(){if(!ay||!G||!aa||!L){return;}N.active=ay.color;var aD=ay.fields,aE=N.active;switch(N.mode){case"h":aD.saturation.val(G.x);aD.value.val(100-G.y);break;case"s":aD.hue.val(G.x);aD.value.val(100-G.y);break;case"v":aD.hue.val(G.x);aD.saturation.val(100-G.y);break;case"r":aD.blue.val(G.x);aD.green.val(255-G.y);break;case"g":aD.blue.val(G.x);aD.red.val(255-G.y);break;case"b":aD.red.val(G.x);aD.green.val(255-G.y);break;}switch(N.mode){case"h":case"s":case"v":ay.setValuesFromHsv();break;case"r":case"g":case"b":ay.setValuesFromRgb();break;}ah();if(aj.expandable&&aj.liveUpdate){n.css({backgroundColor:"#"+aE.hex});if(aj.bindToInput){aj.input.val(aE.hex).css({backgroundColor:"#"+aE.hex,color:aE.v>75?"#000000":"#ffffff"});}}e.isFunction(w.liveCallback)&&w.liveCallback(aE);},al=function(){if(!ay||!G||!aa||!L){return;}N.active=ay.color;var aD=ay.fields,aE=N.active;switch(N.mode){case"h":aD.hue.val(360-aa.y);break;case"s":aD.saturation.val(100-aa.y);break;case"v":aD.value.val(100-aa.y);break;case"r":aD.red.val(255-aa.y);break;case"g":aD.green.val(255-aa.y);break;case"b":aD.blue.val(255-aa.y);break;}switch(N.mode){case"h":case"s":case"v":ay.setValuesFromHsv();break;case"r":case"g":case"b":ay.setValuesFromRgb();break;}ah();if(aj.expandable&&aj.liveUpdate){n.css({backgroundColor:"#"+aE.hex});if(aj.bindToInput){aj.input.val(aE.hex).css({backgroundColor:"#"+aE.hex,color:aE.v>75?"#000000":"#ffffff"});}}e.isFunction(w.liveCallback)&&w.liveCallback(aE);},s=function(){if(!ay||!G||!aa||!L){return;}N.active=ay.color;var aD=ay.fields,aE=N.active;aD.alpha.val(L.x);ay.setAlphaFromValue();ah();e.isFunction(w.liveCallback)&&w.liveCallback(N.active);},v=function(){N.active=ay.color;var aG=0,aF=N.active;switch(w.settings.color.mode){case"h":aG=360-aF.h;break;case"s":aG=100-aF.s;break;case"v":aG=100-aF.v;break;case"r":aG=255-aF.r;break;case"g":aG=255-aF.g;break;case"b":aG=255-aF.b;break;}aa.y=aG;L.x=aF.a;aa.setArrowPositionFromValues();L.setArrowPositionFromValues();var aE=0,aD=0;switch(w.settings.color.mode){case"h":aE=aF.s;aD=100-aF.v;break;case"s":aE=aF.h;aD=100-aF.v;break;case"v":aE=aF.h;aD=100-aF.s;break;case"r":aE=aF.b;aD=256-aF.g;break;case"g":aE=aF.b;aD=256-aF.r;break;case"b":aE=aF.r;aD=256-aF.g;break;}G.x=aE;G.y=aD;G.setArrowPositionFromValues();},ah=function(){aB();ar();ab();aA();},aB=function(){try{A.css({backgroundColor:"#"+ay.color.hex});ae(A,ay.color.a);}catch(aD){}},ar=function(){if(!N||!ay){return;}N.active=ay.color;var aD=N.active;switch(N.mode){case"h":z(ax,new f({h:aD.h,s:100,v:100}).hex);break;case"s":ae(aw,100-aD.s);break;case"v":ae(aw,aD.v);break;case"r":ae(aw,aD.r/256*100);break;case"g":ae(aw,aD.g/256*100);break;case"b":ae(aw,aD.b/256*100);break;}ae(av,100-aD.a);},ab=function(){if(!N||!ay){return;}N.active=ay.color;var aH=N.active,aK=N.mode,aM=ay.fields;switch(aK){case"h":break;case"s":var aI=new f({h:aH.h,s:100,v:aH.v});z(S,aI.hex);break;case"v":var aL=new f({h:aH.h,s:aH.s,v:100});z(S,aL.hex);break;case"r":case"g":case"b":var aJ=0,aN=0;if(aK=="r"){aJ=aM.blue.val();aN=aM.green.val();}else{if(aK=="g"){aJ=aM.blue.val();aN=aM.red.val();}else{if(aK=="b"){aJ=aM.red.val();aN=aM.green.val();}}}var aD=aJ/256*100,aG=aN/256*100,aF=(256-aJ)/256*100,aE=(256-aN)/256*100;ae(R,aG>aF?aF:aG);ae(S,aG>aD?aD:aG);ae(T,aE>aD?aD:aE);ae(U,aE>aF?aF:aE);break;}ae(Q,100-aH.a);},aA=function(){z(J,ay.color.hex);},z=function(aD,aF){try{aD.css({backgroundColor:"#"+aF});}catch(aE){}},t=function(aD,aE){if(aE.indexOf("png")&&this.isLessThanIE7){aD.attr("pngSrc",aE);aD.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+aE+"')"});}else{aD.css({backgroundImage:"url("+aE+")"});}},x=function(aD,aE){aD.css({backgroundPosition:"0px "+aE+"px"});},ae=function(aE,aD){if(aD<100){if(this.isLessThanIE7){var aF=aE.attr("pngSrc");if(aF!=null&&aF.indexOf("map-hue")==-1){aE.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+aF+"') progid:DXImageTransform.Microsoft.Alpha(opacity="+aD+")"});}}else{aE.css({opacity:aD/100});}}else{if(aD==100){if(this.isLessThanIE7){var aF=aE.attr("pngSrc");if(aF!=null&&aF.indexOf("map-hue")==-1){aE.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+aF+"')"});}}else{aE.css({opacity:""});}}}},E=function(){ay.fields.hex.val(N.current.hex);ay.fields.alpha.val(N.current.a);ay.setValuesFromHex();ay.setAlphaFromValue();e.isFunction(ay.valuesChanged)&&ay.valuesChanged(ay);},D=function(aD){an(aD.target.value);},af=function(){E();},r=function(){E();aj.expandable&&w.hide();e.isFunction(w.cancelCallback)&&w.cancelCallback();},Z=function(){var aD=N.active;N.current=new f({hex:aD.hex});N.current.a=aD.a;l.css({backgroundColor:"#"+aD.hex});ae(l,ay.color.a);if(aj.expandable){n.css({backgroundColor:"#"+aD.hex});if(aj.bindToInput){aj.input.val(aD.hex).css({backgroundColor:"#"+aD.hex,color:aD.v>75?"#000000":"#ffffff"});}}e.isFunction(w.commitCallback)&&w.commitCallback(aD);},o=function(){Z();aj.expandable&&w.hide();},ag=function(){w.show();},Y=function(aF){var aD=aj.element,aE=aj.page;P=parseInt(X.css("left"));O=parseInt(X.css("top"));at=aF.pageX;aq=aF.pageY;e(document).bind("mousemove",k).bind("mouseup",q);aF.stopPropagation();aF.preventDefault();return false;},k=function(aD){X.css({left:P-(at-aD.pageX)+"px",top:O-(aq-aD.pageY)+"px"});aD.stopPropagation();aD.preventDefault();return false;},q=function(aD){e(document).unbind("mousemove",k).unbind("mouseup",q);aD.stopPropagation();aD.preventDefault();return false;},F=function(aD){ay.fields.hex.val(w.settings.window.input.val());ay.bindedHexKeyUp(aD);},H=function(aD){ay.fields.hex.val(N.quickList[aD.data.i].hex);ay.fields.alpha.val(N.quickList[aD.data.i].a);ay.setValuesFromHex();ay.setAlphaFromValue();e.isFunction(ay.valuesChanged)&&ay.valuesChanged(ay);};e.extend(true,w,{id:w.attr("id"),settings:y,color:null,icon:null,commitCallback:e.isFunction(h[1])&&h[1]||null,liveCallback:e.isFunction(h[2])&&h[2]||null,cancelCallback:e.isFunction(h[3])&&h[3]||null,show:function(){if(document.all){var aD=false;for(i=0;i>1)-259)-w.next().offset().left+"px":aj.position.x,position:"absolute",top:aj.position.y=="top"?"-340px":aj.position.y=="center"?"-153px":aj.position.y=="bottom"?"25px":aj.position.y});}if((typeof(N.active)).toString().toLowerCase()=="string"){N.active=new f({hex:N.active.substring(1)});}if(!N.alphaSupport){N.active.a=100;}X.html(''+(aj.expandable?'':"")+'
 

'+(aj.title||"Drag Markers To Pick A Color")+'

   
     
new
  
current

 
°
%
%
 
  
% 
');ac=e(".jPicker_HueRadio",X);az=e(".jPicker_SaturationRadio",X);ak=e(".jPicker_BrightnessRadio",X);am=e(".jPicker_RedRadio",X);ao=e(".jPicker_GreenRadio",X);K=e(".jPicker_BlueRadio",X);ax=e(".jPicker_ColorMap_l1",X);aw=e(".jPicker_ColorMap_l2",X);av=e(".jPicker_ColorMap_l3",X);U=e(".jPicker_ColorBar_l1",X);T=e(".jPicker_ColorBar_l2",X);S=e(".jPicker_ColorBar_l3",X);R=e(".jPicker_ColorBar_l4",X);Q=e(".jPicker_ColorBar_l5",X);J=e(".jPicker_AlphaBar_l1",X);I=e(".jPicker_AlphaBar_l2",X);aC=e(".jPicker_EnableAlpha",X);V=e(".jPicker_AlphaCheckbox",X);au=e(".jPicker_AlphaBar",X);M=e(".jPicker_NewCurrent",X);A=e(".jPicker_Active",X).css({backgroundColor:"#"+N.active.hex});l=e(".jPicker_Current",X).css({backgroundColor:"#"+N.active.hex});ap=e(".jPicker_Ok",X);ad=e(".jPicker_Cancel",X);ai=e(".jPicker_Grid",X);w.color=e(".Picker_Color");w.icon=e(".jPicker_Icon");ay=new b(X,m);G=new d(e(".jPicker_ColorMap",X),{map:{width:p.colorMap.width,height:p.colorMap.height},arrow:{image:p.clientPath+p.colorMap.arrow.file,width:p.colorMap.arrow.width,height:p.colorMap.arrow.height}},B);aa=new d(e(".jPicker_ColorBar",X),{map:{width:p.colorBar.width,height:p.colorBar.height},arrow:{image:p.clientPath+p.colorBar.arrow.file,width:p.colorBar.arrow.width,height:p.colorBar.arrow.height}},al);L=new d(e(".jPicker_AlphaBar",X),{map:{width:p.alphaBar.width,height:p.alphaBar.height},arrow:{image:p.clientPath+p.alphaBar.arrow.file,width:p.alphaBar.arrow.width,height:p.alphaBar.arrow.height}},s);L.mnX=0;L.mxX=100;t(ax,p.clientPath+"Maps.png");t(aw,p.clientPath+"Maps.png");t(av,p.clientPath+"map-opacity.png");t(U,p.clientPath+"Bars.png");t(T,p.clientPath+"Bars.png");t(S,p.clientPath+"Bars.png");t(R,p.clientPath+"Bars.png");t(Q,p.clientPath+"bar-opacity.png");t(I,p.clientPath+"Maps.png");x(I,-2816);t(M,p.clientPath+"preview-opacity.png");M.css({backgroundPosition:"1px 1px"});if(N.alphaSupport){aC.hide();au.show();e("td.jPicker_OpacityCol *",X).show();}else{V.bind("click",function(){aC.hide();au.show();e("td.jPicker_OpacityCol *",X).show();});}if(aj.expandable){n=e(".jPicker_Color",w.next()).css({backgroundColor:"#"+N.active.hex});C=e(".jPicker_Icon",w.next()).css({backgroundImage:"url("+p.clientPath+p.picker.file+")"}).bind("click",ag);if(aj.bindToInput){aj.input.bind("keyup",F).bind("change",F);}}ac.add(az).add(ak).add(am).add(ao).add(K).bind("click",D);l.bind("click",af);ad.bind("click",r);ap.bind("click",o);if(aj.expandable){u=e(".jPicker_MoveBar",X).bind("mousedown",Y);}if(N.quickList&&N.quickList.length>0){ai.html("");for(i=0;i ');e(".jPicker_QuickColor",X).eq(i).css({backgroundColor:"#"+N.quickList[i].hex}).bind("click",{i:i},H);}}an(N.mode);ay.fields.hex.val(aa.hex);ay.setValuesFromHex();ay.setAlphaFromValue();v();ah();if(!aj.expandable){w.show();}c.push(w);});};e.fn.jPicker.defaults={window:{title:null,position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true},color:{mode:"h",active:new f({hex:"ffc000"}),alphaSupport:false,quickList:[new f({h:360,s:33,v:100}),new f({h:360,s:66,v:100}),new f({h:360,s:100,v:100}),new f({h:360,s:100,v:75}),new f({h:360,s:100,v:50}),new f({h:180,s:0,v:100}),new f({h:30,s:33,v:100}),new f({h:30,s:66,v:100}),new f({h:30,s:100,v:100}),new f({h:30,s:100,v:75}),new f({h:30,s:100,v:50}),new f({h:180,s:0,v:90}),new f({h:60,s:33,v:100}),new f({h:60,s:66,v:100}),new f({h:60,s:100,v:100}),new f({h:60,s:100,v:75}),new f({h:60,s:100,v:50}),new f({h:180,s:0,v:80}),new f({h:90,s:33,v:100}),new f({h:90,s:66,v:100}),new f({h:90,s:100,v:100}),new f({h:90,s:100,v:75}),new f({h:90,s:100,v:50}),new f({h:180,s:0,v:70}),new f({h:120,s:33,v:100}),new f({h:120,s:66,v:100}),new f({h:120,s:100,v:100}),new f({h:120,s:100,v:75}),new f({h:120,s:100,v:50}),new f({h:180,s:0,v:60}),new f({h:150,s:33,v:100}),new f({h:150,s:66,v:100}),new f({h:150,s:100,v:100}),new f({h:150,s:100,v:75}),new f({h:150,s:100,v:50}),new f({h:180,s:0,v:50}),new f({h:180,s:33,v:100}),new f({h:180,s:66,v:100}),new f({h:180,s:100,v:100}),new f({h:180,s:100,v:75}),new f({h:180,s:100,v:50}),new f({h:180,s:0,v:40}),new f({h:210,s:33,v:100}),new f({h:210,s:66,v:100}),new f({h:210,s:100,v:100}),new f({h:210,s:100,v:75}),new f({h:210,s:100,v:50}),new f({h:180,s:0,v:30}),new f({h:240,s:33,v:100}),new f({h:240,s:66,v:100}),new f({h:240,s:100,v:100}),new f({h:240,s:100,v:75}),new f({h:240,s:100,v:50}),new f({h:180,s:0,v:20}),new f({h:270,s:33,v:100}),new f({h:270,s:66,v:100}),new f({h:270,s:100,v:100}),new f({h:270,s:100,v:75}),new f({h:270,s:100,v:50}),new f({h:180,s:0,v:10}),new f({h:300,s:33,v:100}),new f({h:300,s:66,v:100}),new f({h:300,s:100,v:100}),new f({h:300,s:100,v:75}),new f({h:300,s:100,v:50}),new f({h:180,s:0,v:0}),new f({h:330,s:33,v:100}),new f({h:330,s:66,v:100}),new f({h:330,s:100,v:100}),new f({h:330,s:100,v:75}),new f({h:330,s:100,v:50})]},images:{clientPath:"/jPicker/images/",colorMap:{width:256,height:256,arrow:{file:"mappoint.gif",width:15,height:15}},colorBar:{width:20,height:256,arrow:{file:"rangearrows.gif",width:40,height:9}},alphaBar:{width:256,height:20,arrow:{file:"rangearrows2.gif",width:9,height:40}},picker:{file:"picker.gif",width:25,height:24}}};})(jQuery,"1.0.9"); \ No newline at end of file diff --git a/editor/spinbtn/JQuerySpinBtn.min.js b/editor/spinbtn/JQuerySpinBtn.min.js new file mode 100644 index 00000000..dd6c76cd --- /dev/null +++ b/editor/spinbtn/JQuerySpinBtn.min.js @@ -0,0 +1 @@ +$.fn.SpinButton=function(a){return this.each(function(){this.repeating=false;this.spinCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&a.step?Number(a.step):1,page:a&&a.page?Number(a.page):10,upClass:a&&a.upClass?a.upClass:"up",downClass:a&&a.downClass?a.downClass:"down",reset:a&&a.reset?a.reset:this.value,delay:a&&a.delay?Number(a.delay):500,interval:a&&a.interval?Number(a.interval):100,_btn_width:20,_btn_height:12,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null,};this.adjustValue=function(d){var c=(isNaN(this.value)?this.spinCfg.reset:Number(this.value))+Number(d);if(this.spinCfg.min!==null){c=Math.max(c,this.spinCfg.min)}if(this.spinCfg.max!==null){c=Math.min(c,this.spinCfg.max)}this.value=c;if($.isFunction(this.spinCfg.callback)){this.spinCfg.callback(this)}};$(this).addClass(a&&a.spinClass?a.spinClass:"spin-button").mousemove(function(g){var c=g.pageX||g.x;var h=g.pageY||g.y;var d=g.target||g.srcElement;var f=(c>b(d,"offsetLeft")+d.offsetWidth-this.spinCfg._btn_width)?((h=120){this.adjustValue(this.spinCfg.step)}else{if(c.wheelDelta<=-120){this.adjustValue(-this.spinCfg.step)}}c.preventDefault()}).change(function(c){this.adjustValue(0)});if(this.addEventListener){this.addEventListener("DOMMouseScroll",function(c){if(c.detail>0){this.adjustValue(-this.spinCfg.step)}else{if(c.detail<0){this.adjustValue(this.spinCfg.step)}}c.preventDefault()},false)}});function b(e,g){var f=e[g],d=document.body;while((e=e.offsetParent)&&(e!=d)){if(!$.browser.msie||(e.currentStyle.position!="relative")){f+=e[g]}}return f}}; \ No newline at end of file diff --git a/editor/svg-editor.html b/editor/svg-editor.html index c5dd12a4..43f44493 100644 --- a/editor/svg-editor.html +++ b/editor/svg-editor.html @@ -7,19 +7,18 @@ - - + - - - - - - - - + + + + + + + + SVG-edit demo diff --git a/editor/svg-editor.min.js b/editor/svg-editor.min.js new file mode 100644 index 00000000..6c0b0194 --- /dev/null +++ b/editor/svg-editor.min.js @@ -0,0 +1 @@ +if(!window.console){window.console=new function(){this.log=function(a){};this.dir=function(a){}}}function svg_edit_setup(){var I=["#000000","#202020","#404040","#606060","#808080","#a0a0a0","#c0c0c0","#e0e0e0","#ffffff","#800000","#ff0000","#808000","#ffff00","#008000","#00ff00","#008080","#00ffff","#000080","#0000ff","#800080","#ff00ff","#2b0000","#550000","#800000","#aa0000","#d40000","#ff0000","#ff2a2a","#ff5555","#ff8080","#ffaaaa","#ffd5d5","#280b0b","#501616","#782121","#a02c2c","#c83737","#d35f5f","#de8787","#e9afaf","#f4d7d7","#241c1c","#483737","#6c5353","#916f6f","#ac9393","#c8b7b7","#e3dbdb","#2b1100","#552200","#803300","#aa4400","#d45500","#ff6600","#ff7f2a","#ff9955","#ffb380","#ffccaa","#ffe6d5","#28170b","#502d16","#784421","#a05a2c","#c87137","#d38d5f","#deaa87","#e9c6af","#f4e3d7","#241f1c","#483e37","#6c5d53","#917c6f","#ac9d93","#c8beb7","#e3dedb","#2b2200","#554400","#806600","#aa8800","#d4aa00","#ffcc00","#ffd42a","#ffdd55","#ffe680","#ffeeaa","#fff6d5","#28220b","#504416","#786721","#a0892c","#c8ab37","#d3bc5f","#decd87","#e9ddaf","#f4eed7","#24221c","#484537","#6c6753","#918a6f","#aca793","#c8c4b7","#e3e2db","#222b00","#445500","#668000","#88aa00","#aad400","#ccff00","#d4ff2a","#ddff55","#e5ff80","#eeffaa","#f6ffd5","#22280b","#445016","#677821","#89a02c","#abc837","#bcd35f","#cdde87","#dde9af","#eef4d7","#22241c","#454837","#676c53","#8a916f","#a7ac93","#c4c8b7","#e2e3db","#112b00","#225500","#338000","#44aa00","#55d400","#66ff00","#7fff2a","#99ff55","#b3ff80","#ccffaa","#e5ffd5","#17280b","#2d5016","#447821","#5aa02c","#71c837","#8dd35f","#aade87","#c6e9af","#e3f4d7","#1f241c","#3e4837","#5d6c53","#7c916f","#9dac93","#bec8b7","#dee3db","#002b00","#005500","#008000","#00aa00","#00d400","#00ff00","#2aff2a","#55ff55","#80ff80","#aaffaa","#d5ffd5","#0b280b","#165016","#217821","#2ca02c","#37c837","#5fd35f","#87de87","#afe9af","#d7f4d7","#1c241c","#374837","#536c53","#6f916f","#93ac93","#b7c8b7","#dbe3db","#002b11","#005522","#008033","#00aa44","#00d455","#00ff66","#2aff80","#55ff99","#80ffb3","#aaffcc","#d5ffe6","#0b2817","#16502d","#217844","#2ca05a","#37c871","#5fd38d","#87deaa","#afe9c6","#d7f4e3","#1c241f","#37483e","#536c5d","#6f917c","#93ac9d","#b7c8be","#dbe3de","#002b22","#005544","#008066","#00aa88","#00d4aa","#00ffcc","#2affd5","#55ffdd","#80ffe6","#aaffee","#d5fff6","#0b2822","#165044","#217867","#2ca089","#37c8ab","#5fd3bc","#87decd","#afe9dd","#d7f4ee","#1c2422","#374845","#536c67","#6f918a","#93aca7","#b7c8c4","#dbe3e2","#00222b","#004455","#006680","#0088aa","#00aad4","#00ccff","#2ad4ff","#55ddff","#80e5ff","#aaeeff","#d5f6ff","#0b2228","#164450","#216778","#2c89a0","#37abc8","#5fbcd3","#87cdde","#afdde9","#d7eef4","#1c2224","#374548","#53676c","#6f8a91","#93a7ac","#b7c4c8","#dbe2e3","#00112b","#002255","#003380","#0044aa","#0055d4","#0066ff","#2a7fff","#5599ff","#80b3ff","#aaccff","#d5e5ff","#0b1728","#162d50","#214478","#2c5aa0","#3771c8","#5f8dd3","#87aade","#afc6e9","#d7e3f4","#1c1f24","#373e48","#535d6c","#6f7c91","#939dac","#b7bec8","#dbdee3","#00002b","#000055","#000080","#0000aa","#0000d4","#0000ff","#2a2aff","#5555ff","#8080ff","#aaaaff","#d5d5ff","#0b0b28","#161650","#212178","#2c2ca0","#3737c8","#5f5fd3","#8787de","#afafe9","#d7d7f4","#1c1c24","#373748","#53536c","#6f6f91","#9393ac","#b7b7c8","#dbdbe3","#11002b","#220055","#330080","#4400aa","#5500d4","#6600ff","#7f2aff","#9955ff","#b380ff","#ccaaff","#e5d5ff","#170b28","#2d1650","#442178","#5a2ca0","#7137c8","#8d5fd3","#aa87de","#c6afe9","#e3d7f4","#1f1c24","#3e3748","#5d536c","#7c6f91","#9d93ac","#beb7c8","#dedbe3","#22002b","#440055","#660080","#8800aa","#aa00d4","#cc00ff","#d42aff","#dd55ff","#e580ff","#eeaaff","#f6d5ff","#220b28","#441650","#672178","#892ca0","#ab37c8","#bc5fd3","#cd87de","#ddafe9","#eed7f4","#221c24","#453748","#67536c","#8a6f91","#a793ac","#c4b7c8","#e2dbe3","#2b0022","#550044","#800066","#aa0088","#d400aa","#ff00cc","#ff2ad4","#ff55dd","#ff80e5","#ffaaee","#ffd5f6","#280b22","#501644","#782167","#a02c89","#c837ab","#d35fbc","#de87cd","#e9afdd","#f4d7ee","#241c22","#483745","#6c5367","#916f8a","#ac93a7","#c8b7c4","#e3dbe2","#2b0011","#550022","#800033","#aa0044","#d40055","#ff0066","#ff2a7f","#ff5599","#ff80b2","#ffaacc","#ffd5e5","#280b17","#50162d","#782144","#a02c5a","#c83771","#d35f8d","#de87aa","#e9afc6","#f4d7e3","#241c1f","#48373e","#6c535d","#916f7c","#ac939d","#c8b7be","#e3dbde"];var O=false;var y="";var T=new SvgCanvas(document.getElementById("svgcanvas"));var L=function(){$(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");$("#tool_select").addClass("tool_button_current");$("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all} #svgcanvas svg{cursor:default}");T.setMode("select")};var z=1250;var ap=false;var al=null;var Z=false;var R=false;var P=["x","y","x1","x2","y1","y2","cx","cy","width","height","r","rx","ry","width","height","radius"];var C=["em","ex","px","cm","mm","in","pt","pc","%"];var g=new $.jGraduate.Paint({solidColor:"FF0000"});var E=new $.jGraduate.Paint({solidColor:"000000"});var at=function(ay,i){ay.open("data:image/svg+xml;base64,"+Utils.encode64(i))};var ad=function(ay,i){al=(i.length==1||i[1]==null?i[0]:null);Z=(i.length>=2&&i[1]!=null);if(al!=null){if(T.getMode()!="multiselect"){L()}u()}Y()};var ah=function(aB,ay){for(var az=0;az0){$("#tool_undo").removeClass("tool_button_disabled")}else{$("#tool_undo").addClass("tool_button_disabled")}if(T.getRedoStackSize()>0){$("#tool_redo").removeClass("tool_button_disabled")}else{$("#tool_redo").addClass("tool_button_disabled")}T.addedNew=false};$("#text").focus(function(){ap=true});$("#text").blur(function(){ap=false});T.bind("selected",ad);T.bind("changed",ah);T.bind("saved",at);var au='
';$.each(I,function(ay,az){au+='
'});$("#palette").append(au);var ai=$("#tools_rect_show").position();$("#tools_rect").css({left:ai.left+4,top:ai.top+70});ai=$("#tools_ellipse_show").position();$("#tools_ellipse").css({left:ai.left+4,top:ai.top+70});var an=function(i){T.setRectRadius(i.value)};var am=function(i){var ay=i.value;if(ay==0&&al&&$.inArray(al.nodeName,["line","polyline"])!=-1){ay=i.value=1}T.setStrokeWidth(ay)};var q=function(i){T.setRotationAngle(i.value)};$("#stroke_style").change(function(){T.setStrokeStyle(this.options[this.selectedIndex].value)});$("select").change(function(){$(this).blur()});$("#group_opacity").change(function(){T.setOpacity(this.options[this.selectedIndex].value)});$("#font_size").change(function(){T.setFontSize(this.options[this.selectedIndex].value)});$("#font_family").change(function(){T.setFontFamily(this.options[this.selectedIndex].value)});$("#text").keyup(function(){T.setTextContent(this.value)});$(".attr_changer").change(function(){var i=this.getAttribute("alt");var az=this.value;var ay=false;if($.inArray(i,P)!=-1){if(!isNaN(az)){ay=true}else{}}else{ay=true}if(!ay){alert("Invalid value given for"+$(this).attr("title").replace("Change","")+".");this.value=al.getAttribute(i);return false}T.changeSelectedAttribute(i,az)});$("#palette").mouseover(function(){var i=$('');$(this).append(i);i.focus().remove()});$(".palette_item").click(function(i){var aA=(i.shiftKey?"stroke":"fill");var aC=(i.shiftKey?"#stroke_":"#fill_");var az=$(this).attr("data-rgb");var ay=document.getElementById("gradbox_"+aA).parentNode.firstChild;var aB=null;if(az=="transparent"||az=="initial"){az="none";$(aC+"opacity").html("N/A");aB=new $.jGraduate.Paint()}else{aB=new $.jGraduate.Paint({alpha:100,solidColor:az.substr(1)})}ay.setAttribute("fill",az);if(i.shiftKey){E=aB;if(T.getStrokeColor()!=az){T.setStrokeColor(az)}if(az!="none"&&T.getStrokeOpacity()!=1){T.setStrokeOpacity(1);$("#stroke_opacity").html("100 %")}}else{g=aB;if(T.getFillColor()!=az){T.setFillColor(az)}if(az!="none"&&T.getFillOpacity()!=1){T.setFillOpacity(1);$("#fill_opacity").html("100 %")}}w()});var F=function(ay,i){if($(ay).hasClass("tool_button_disabled")){return false}var i=i||"normal";$(".tools_flyout").fadeOut(i);$("#styleoverrides").text("");$(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");$(ay).addClass("tool_button_current");T.clearSelection();return true};var G=function(){if(F("#tool_select")){T.setMode("select");$("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}};var av=function(){if(F("#tool_path")){T.setMode("path")}};var U=function(){if(F("#tool_line")){T.setMode("line")}};var l=function(){if(F("#tools_rect_show",z)){z="normal";T.setMode("square")}$("#tools_rect_show").attr("src","images/square.png")};var S=function(){if(F("#tools_rect_show")){T.setMode("rect")}$("#tools_rect_show").attr("src","images/rect.png")};var o=function(){if(F("#tools_rect_show")){T.setMode("fhrect")}$("#tools_rect_show").attr("src","images/freehand-square.png")};var a=function(){if(F("#tools_ellipse_show",z)){z="normal";T.setMode("circle")}$("#tools_ellipse_show").attr("src","images/circle.png")};var D=function(){if(F("#tools_ellipse_show")){T.setMode("ellipse")}$("#tools_ellipse_show").attr("src","images/ellipse.png")};var N=function(){if(F("#tools_ellipse_show")){T.setMode("fhellipse")}$("#tools_ellipse_show").attr("src","images/freehand-circle.png")};var r=function(){F("#tool_text");T.setMode("text")};var ab=function(){F("#tool_poly");T.setMode("poly")};var c=function(){if(al!=null||Z){T.deleteSelectedElements()}};var f=function(){if(al!=null){T.moveToTopSelectedElement()}};var B=function(){if(al!=null){T.moveToBottomSelectedElement()}};var m=function(ay,i){if(al!=null||Z){T.moveSelectedElements(ay,i)}};var aj=function(){T.cycleElement(1)};var Q=function(){T.cycleElement(0)};var d=function(i){if(al==null||Z){return}var az=5;if(!i){az*=-1}var ay=$("#angle").val()*1+az;T.setRotationAngle(ay)};var X=function(){if(confirm("Do you want to clear the drawing?\nThis will also erase your undo history!")){T.clear();Y()}};var M=function(){T.setBold(!T.getBold());Y()};var W=function(){T.setItalic(!T.getItalic());Y()};var aa=function(){T.save()};var ak=function(){T.open()};var s=function(){if(T.getUndoStackSize()>0){T.undo()}};var K=function(){if(T.getRedoStackSize()>0){T.redo()}};var A=function(){T.cloneSelectedElements()};var e=function(){T.alignSelectedElements("l",$("#align_relative_to option:selected").val())};var ae=function(){T.alignSelectedElements("c",$("#align_relative_to option:selected").val())};var j=function(){T.alignSelectedElements("r",$("#align_relative_to option:selected").val())};var H=function(){T.alignSelectedElements("t",$("#align_relative_to option:selected").val())};var ac=function(){T.alignSelectedElements("m",$("#align_relative_to option:selected").val())};var v=function(){T.alignSelectedElements("b",$("#align_relative_to option:selected").val())};var k=function(){if(R){return}R=true;var i=T.getSvgString();$("#svg_source_textarea").val(i);$("#svg_source_editor").fadeIn();h();$("#svg_source_textarea").focus()};var h=function(){var i=$("#svg_source_container").height()-80;$("#svg_source_textarea").css("height",i)};var ao=function(){if(!R){return}if(!T.setSvgString($("#svg_source_textarea").val())){if(!confirm("There were parsing errors in your SVG source.\nRevert back to original SVG source?")){return false}}T.clearSelection();ar()};var V=function(){if(!R){return}var i=T.getSvgString();if(i!=$("#svg_source_textarea").val()){if(!confirm("Ignore changes made to SVG source?")){return false}}ar()};var ar=function(){$("#svg_source_editor").hide();R=false;$("#svg_source_textarea").blur()};$(window).resize(function(i){if(!R){return}h()});$("#tool_select").click(G);$("#tool_path").click(av);$("#tool_line").click(U);$("#tool_square").mouseup(l);$("#tool_rect").mouseup(S);$("#tool_fhrect").mouseup(o);$("#tool_circle").mouseup(a);$("#tool_ellipse").mouseup(D);$("#tool_fhellipse").mouseup(N);$("#tool_text").click(r);$("#tool_poly").click(ab);$("#tool_clear").click(X);$("#tool_save").click(aa);$("#tool_open").click(ak);$("#tool_source").click(k);$("#tool_source_cancel,#svg_source_overlay").click(V);$("#tool_source_save").click(ao);$("#tool_delete").click(c);$("#tool_delete_multi").click(c);$("#tool_move_top").click(f);$("#tool_move_bottom").click(B);$("#tool_undo").click(s);$("#tool_redo").click(K);$("#tool_clone").click(A);$("#tool_clone_multi").click(A);$("#tool_alignleft").click(e);$("#tool_aligncenter").click(ae);$("#tool_alignright").click(j);$("#tool_aligntop").click(H);$("#tool_alignmiddle").click(ac);$("#tool_alignbottom").click(v);$("#tools_rect_show").click(l);$("#tools_ellipse_show").click(a);$("#tool_bold").mousedown(M);$("#tool_italic").mousedown(W);function ag(){var az=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"];var i="";var ay="tool_button_current";$.each(az,function(aA,aB){i+="#tool_"+aB+(aA==az.length-1?",":"")});$(i).mousedown(function(){$(this).addClass(ay)}).bind("mousedown mouseout",function(){$(this).removeClass(ay)});$("#tool_undo, #tool_redo").mousedown(function(){if(!$(this).hasClass("tool_button_disabled")){$(this).addClass(ay)}}).bind("mousedown mouseout",function(){$(this).removeClass(ay)})}ag();if(O){var x=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];var J=x.length;while(J--){var b=document.getElementById(x[J]);var n=b.title;var aq=n.indexOf("Ctrl+");b.title=[n.substr(0,aq),"Cmd+",n.substr(aq+5)].join("")}}function t(){var i=[["1",G],["2",av],["3",U],["Shift+4",l],["4",S],["Shift+5",a],["5",D],["6",r],["7",ab],[y+"N",function(ay){X();ay.preventDefault()}],[y+"S",function(ay){R?ao():aa();ay.preventDefault()}],[y+"O",function(ay){ak();ay.preventDefault()}],["del",function(ay){c();ay.preventDefault()}],["backspace",function(ay){c();ay.preventDefault()}],["shift+up",f],["shift+down",B],["shift+left",function(){d(0)}],["shift+right",function(){d(1)}],["shift+O",Q],["shift+P",aj],["up",function(ay){m(0,-1);ay.preventDefault()}],["down",function(ay){m(0,1);ay.preventDefault()}],["left",function(ay){m(-1,0);ay.preventDefault()}],["right",function(ay){m(1,0);ay.preventDefault()}],[y+"z",function(ay){s();ay.preventDefault()}],[y+"y",function(ay){K();ay.preventDefault()}],[y+"u",function(ay){k();ay.preventDefault()}],[y+"c",function(ay){A();ay.preventDefault()}],["esc",V,false]];$.each(i,function(az,aA){var ay=!(aA.length>2&&!aA[2]);$(document).bind("keydown",{combi:aA[0],disableInInput:ay},aA[1])});$(".attr_changer").bind("keydown",{combi:"return",disableInInput:false},function(ay){$(this).change();ay.preventDefault()})}t();var af=function(az){var ay=az.attr("id")=="stroke_color"?"stroke":"fill";var i=(ay=="stroke"?$("#stroke_opacity"):$("#fill_opacity"));var aC=(ay=="stroke"?E:g);var aB=(ay=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity");var aA=false;if(aC.type=="none"){aC=new $.jGraduate.Paint({solidColor:"ffffff"});aA=true}var aD=az.position();$("#color_picker").css({left:aD.left-140,bottom:124-aD.top}).jGraduate({paint:aC,window:{pickerTitle:aB},images:{clientPath:"jgraduate/images/"},},function(aI){aC=new $.jGraduate.Paint(aI);var aG=document.getElementById("gradbox_"+ay);var aH=aG.parentNode;var aF=aH.firstChild;if(aC.type=="linearGradient"){aH.removeChild(aG);var aE=aH.appendChild(document.importNode(aC.linearGradient,true));aE.id="gradbox_"+ay;aF.setAttribute("fill","url(#gradbox_"+ay+")")}else{aF.setAttribute("fill","#"+aC.solidColor)}i.html(aC.alpha+" %");if(ay=="stroke"){T.setStrokePaint(aC,true)}else{T.setFillPaint(aC,true)}u();$("#color_picker").hide()},function(aE){$("#color_picker").hide()})};var w=function(){var i=(T.getFillColor()=="none");var ay=(T.getStrokeColor()=="none");var aB=["#tool_path","#tool_line"];var aA=["#tools_rect_show","#tools_ellipse_show","#tool_text"];if(ay){for(aq in aB){var az=aB[aq];if($(az).hasClass("tool_button_current")){G()}$(az).removeClass("tool_button").addClass("tool_button_disabled")}}else{for(aq in aB){var az=aB[aq];$(az).removeClass("tool_button_disabled").addClass("tool_button")}}if(ay&&i){for(aq in aA){var az=aA[aq];if($(az).hasClass("tool_button_current")){G()}$(az).removeClass("tool_button").addClass("tool_button_disabled")}}else{for(aq in aA){var az=aA[aq];$(az).removeClass("tool_button_disabled").addClass("tool_button")}}};var p=new DOMParser().parseFromString(' ',"text/xml");var ax=p.getElementById("gradbox_");ax.id="gradbox_fill";$("#fill_color").append(document.importNode(p.documentElement,true));ax.id="gradbox_stroke";$(p.documentElement.firstChild).attr("fill","#000000");$("#stroke_color").append(document.importNode(p.documentElement,true));$("#fill_color").click(function(){af($(this));w()});$("#stroke_color").click(function(){af($(this));w()});$("#tools_rect_show").mousedown(function(i){$("#tools_rect").show();i.preventDefault()});$("#tools_rect").mouseleave(function(){$("#tools_rect").fadeOut()});$("#tool_move_top").mousedown(function(i){$("#tools_stacking").show();i.preventDefault()});$("#tools_ellipse_show").mousedown(function(i){$("#tools_ellipse").show();i.preventDefault()});$("#tools_ellipse").mouseleave(function(){$("#tools_ellipse").fadeOut()});$(".tool_flyout_button").mouseover(function(){$(this).addClass("tool_flyout_button_current")}).mouseout(function(){$(this).removeClass("tool_flyout_button_current")});function aw(i,aA){var ay=i+"x"+aA;var az=false;$("#resolution option").each(function(){if($(this).text()==ay){$("#resolution").val(i+"x"+aA);az=true}});if(!az){$("#resolution").val("Custom")}$("#svgcanvas").css({width:i,height:aA})}$("#resolution").change(function(){if(this.value=="Custom"){var aA=prompt("Please enter custom size (i.e. 400x300)","");var ay=aA.match(/(\d+)[x \/,](\d+)/);if(!ay){alert("Invalid size. Please format it as WIDTHxHEIGHT (like 400x300)");return false}else{var i=ay[1],aB=ay[2];if(i=="0"||aB=="0"){alert("Invalid size. Width or height may not be 0.");return false}}}else{if(this.value=="Fit to content"){var i="",aB=""}else{var az=this.value.split("x");var i=parseInt(az[0]),aB=parseInt(az[1])}}T.setResolution(i,aB)});$("#rect_rx").SpinButton({min:0,max:1000,step:1,callback:an});$("#stroke_width").SpinButton({min:0,max:99,step:1,callback:am});$("#angle").SpinButton({min:-180,max:180,step:5,callback:q});T.setCustomHandlers=function(i){if(i.open){$("#tool_open").show();T.bind("opened",i.open)}if(i.save){T.bind("saved",i.save)}};return T}$(function(){svgCanvas=svg_edit_setup()}); \ No newline at end of file diff --git a/editor/svgcanvas.min.js b/editor/svgcanvas.min.js new file mode 100644 index 00000000..10ea7ffb --- /dev/null +++ b/editor/svgcanvas.min.js @@ -0,0 +1 @@ +if(!window.console){window.console=new function(){this.log=function(a){};this.dir=function(a){}}}var svgWhiteList={circle:["cx","cy","fill","fill-opacity","id","opacity","r","stroke","stroke-dasharray","stroke-opacity","stroke-width","transform"],defs:[],ellipse:["cx","cy","fill","fill-opacity","id","opacity","rx","ry","stroke","stroke-dasharray","stroke-opacity","stroke-width","transform"],line:["fill","fill-opacity","id","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-opacity","stroke-width","transform","x1","x2","y1","y2"],linearGradient:["id","gradientTransform","gradientUnits","spreadMethod","x1","x2","y1","y2"],path:["d","fill","fill-opacity","id","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-opacity","stroke-width","transform"],polygon:["id","fill","fill-opacity","id","opacity","points","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-opacity","stroke-width","transform"],polyline:["id","fill","fill-opacity","opacity","points","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-opacity","stroke-width","transform"],radialGradient:["id","cx","cy","fx","fy","gradientTransform","gradientUnits","r","spreadMethod"],rect:["fill","fill-opacity","height","id","opacity","rx","ry","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-opacity","stroke-width","transform","width","x","y"],stop:["id","offset","stop-color","stop-opacity"],svg:["id","height","transform","width","xmlns"],text:["fill","fill-opacity","font-family","font-size","font-style","font-weight","id","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-opacity","stroke-width","transform","text-anchor","x","y"],};function SvgCanvas(an){function V(at,c,au){this.elem=at;this.text=au?("Change "+at.tagName+" "+au):("Change "+at.tagName);this.newValues={};this.oldValues=c;for(attr in c){if(attr=="#text"){this.newValues[attr]=at.textContent}else{this.newValues[attr]=at.getAttribute(attr)}}this.apply=function(){for(attr in this.newValues){if(this.newValues[attr]){if(attr=="#text"){this.elem.textContent=this.newValues[attr]}else{this.elem.setAttribute(attr,this.newValues[attr])}}else{if(attr!="#text"){this.elem.textContent=""}else{this.elem.removeAttribute(attr)}}}if(attr!="transform"){var ay=n.getRotationAngle(at);if(ay){var ax=at.getBBox();var av=parseInt(ax.x+ax.width/2),az=parseInt(ax.y+ax.height/2);var aw=["rotate(",ay," ",av,",",az,")"].join("");if(aw!=at.getAttribute("transform")){at.setAttribute("transform",aw)}}}return true};this.unapply=function(){for(attr in this.oldValues){if(this.oldValues[attr]){if(attr=="#text"){this.elem.textContent=this.oldValues[attr]}else{this.elem.setAttribute(attr,this.oldValues[attr])}}else{if(attr=="#text"){this.elem.textContent=""}else{this.elem.removeAttribute(attr)}}}if(attr!="transform"){var ay=n.getRotationAngle(at);if(ay){var ax=at.getBBox();var av=parseInt(ax.x+ax.width/2),az=parseInt(ax.y+ax.height/2);var aw=["rotate(",ay," ",av,",",az,")"].join("");if(aw!=at.getAttribute("transform")){at.setAttribute("transform",aw)}}}return true};this.elements=function(){return[this.elem]}}function aq(c,at){this.elem=c;this.text=at||("Create "+c.tagName);this.parent=c.parentNode;this.apply=function(){this.elem=this.parent.insertBefore(this.elem,this.elem.nextSibling)};this.unapply=function(){this.parent=this.elem.parentNode;this.elem=this.elem.parentNode.removeChild(this.elem)};this.elements=function(){return[this.elem]}}function aa(at,c,au){this.elem=at;this.text=au||("Delete "+at.tagName);this.parent=c;this.apply=function(){this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem)};this.unapply=function(){this.elem=this.parent.insertBefore(this.elem,this.elem.nextSibling)};this.elements=function(){return[this.elem]}}function K(at,au,c,av){this.elem=at;this.text=av?("Move "+at.tagName+" to "+av):("Move "+at.tagName+"top/bottom");this.oldNextSibling=au;this.oldParent=c;this.newNextSibling=at.nextSibling;this.newParent=at.parentNode;this.apply=function(){this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling)};this.unapply=function(){this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling)};this.elements=function(){return[this.elem]}}function H(c){this.text=c||"Batch Command";this.stack=[];this.apply=function(){var at=this.stack.length;for(var au=0;au=0;at--){this.stack[at].unapply()}};this.elements=function(){var at=[];var aw=this.stack.length;while(aw--){var av=this.stack[aw].elements();var au=av.length;while(au--){if(at.indexOf(av[au])==-1){at.push(av[au])}}}return at};this.addSubCommand=function(at){this.stack.push(at)};this.isEmpty=function(){return this.stack.length==0}}function R(at,c){this.id=at;this.selectedElement=c;this.locked=true;this.reset=function(au){this.locked=true;this.selectedElement=au;this.resize();N.update();this.selectorGroup.setAttribute("display","inline")};this.selectorGroup=g({element:"g",attr:{id:("selectorGroup"+this.id)}});this.selectorRect=this.selectorGroup.appendChild(g({element:"rect",attr:{id:("selectedBox"+this.id),fill:"none",stroke:"blue","stroke-width":"1","stroke-dasharray":"5,5",width:1,height:1,style:"pointer-events:none"}}));this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.rotateGripConnector=this.selectorGroup.appendChild(g({element:"line",attr:{id:("selectorGrip_rotate_connector_"+this.id),stroke:"blue","stroke-width":"1",}}));this.rotateGrip=this.selectorGroup.appendChild(g({element:"circle",attr:{id:("selectorGrip_rotate_"+this.id),fill:"lime",r:4,stroke:"blue","stroke-width":2}}));for(dir in this.selectorGrips){this.selectorGrips[dir]=this.selectorGroup.appendChild(g({element:"rect",attr:{id:("selectorGrip_"+dir+"_"+this.id),fill:"blue",width:6,height:6,style:("cursor:"+dir+"-resize"),"stroke-width":2,"pointer-events":"all",display:"none"}}));$("#"+this.selectorGrips[dir].id).mousedown(function(){aj="resize";af=this.id.substr(13,this.id.indexOf("_",13)-13)});$("#selectorGrip_rotate_"+at).mousedown(function(){aj="rotate"})}this.showGrips=function(au){var av=au?"inline":"none";this.rotateGrip.setAttribute("display",av);this.rotateGripConnector.setAttribute("display",av);var aw=this.selectedElement;if(aw&&aw.tagName=="text"){av="none"}for(dir in this.selectorGrips){this.selectorGrips[dir].setAttribute("display",av)}if(aw){this.updateGripCursors(n.getRotationAngle(aw))}};this.updateGripCursors=function(ax){var aw=[];var au=Math.round(ax/45);if(au<0){au+=8}for(dir in this.selectorGrips){aw.push(dir)}while(au>0){aw.push(aw.shift());au--}var av=0;for(dir in this.selectorGrips){this.selectorGrips[dir].setAttribute("style",("cursor:"+aw[av]+"-resize"));av++}};this.resize=function(aD){var au=this.selectorRect;var ax=this.selectorGrips;var aG=this.selectedElement;var aF=parseInt(aG.getAttribute("stroke-width"));var ay=1;if(!isNaN(aF)){ay+=aF/2}if(aG.tagName=="text"){ay+=2}var aE=n.getBBox(this.selectedElement);var av=aD||aE;var aH=av.x-ay,aC=av.y-ay,aA=av.width+(ay<<1),aI=av.height+(ay<<1);var aL=G.suspendRedraw(100);S(au,{x:aH,y:aC,width:aA,height:aI});var az={nw:[aH-3,aC-3],ne:[aH+aA-3,aC-3],sw:[aH-3,aC+aI-3],se:[aH+aA-3,aC+aI-3],n:[aH+aA/2-3,aC-3],w:[aH-3,aC+aI/2-3],e:[aH+aA-3,aC+aI/2-3],s:[aH+aA/2-3,aC+aI-3]};$.each(az,function(aM,aN){S(ax[aM],{x:aN[0],y:aN[1]})});S(this.rotateGripConnector,{x1:aH+aA/2,y1:aC-20,x2:aH+aA/2,y2:aC});S(this.rotateGrip,{cx:aH+aA/2,cy:aC-20});this.selectorGroup.setAttribute("transform","");this.selectorGroup.removeAttribute("transform");var aK=this.selectedElement;var aB=aK.getAttribute("transform");var aJ=n.getRotationAngle(aK);if(aJ){var aw=parseInt(aE.x+aE.width/2);cy=parseInt(aE.y+aE.height/2);this.selectorGroup.setAttribute("transform","rotate("+aJ+" "+aw+","+cy+")")}G.unsuspendRedraw(aL)};this.reset(c)}function ap(){this.selectorParentGroup=null;this.rubberBandBox=null;this.selectors=[];this.selectorMap={};var c=this;this.initGroup=function(){c.selectorParentGroup=g({element:"g",attr:{id:"selectorParentGroup"}});c.selectorMap={};c.selectors=[];c.rubberBandBox=null};this.requestSelector=function(au){if(au==null){return null}var av=this.selectors.length;if(typeof(this.selectorMap[au.id])=="object"){this.selectorMap[au.id].locked=true;return this.selectorMap[au.id]}for(var at=0;at0){r=r.splice(0,ae)}r.push(c);ae=r.length};var ao=function(){if(D.getid){return b("getid",ad)}return q+ad};var U=function(){var c=ao();while(E.getElementById(c)){ad++;c=ao()}return c};var b=function(at,c){if(D[at]){return D[at](this,c)}};var ac=function(aw){if(aw.nodeType==3){aw.nodeValue=aw.nodeValue.replace(/^\s+|\s+$/g,"")}if(aw.nodeType!=1){return}var ax=aw.ownerDocument;var av=aw.parentNode;if(!ax||!av){return}var ay=svgWhiteList[aw.nodeName];if(ay!=undefined){var au=aw.attributes.length;while(au--){var at=aw.attributes.item(au).nodeName;if(ay.indexOf(at)==-1){aw.removeAttribute(at)}}au=aw.childNodes.length;while(au--){ac(aw.childNodes.item(au))}}else{var c=[];while(aw.hasChildNodes()){c.push(av.insertBefore(aw.firstChild,aw))}av.removeChild(aw);var au=c.length;while(au--){ac(c[au])}}};var Q=function(){var au=G.getElementsByTagNameNS(al,"defs");if(!au||!au.length){return}var aB=G.getElementsByTagNameNS(al,"*");var aw=[];$.each(aB,function(aC,aD){var aF=aD.getAttribute("fill");if(aF&&aF.indexOf("url(#")==0){aw.push(aF)}var aE=aD.getAttribute("stroke");if(aE&&aE.indexOf("url(#")==0){aw.push(aE)}});var ay=G.getElementsByTagNameNS(al,"linearGradient");var az=[];var av=ay.length;while(av--){var aA=ay[av];var c=aA.getAttribute("id");var ax="url(#"+c+")";if($.inArray(ax,aw)==-1){aA.parentNode.removeChild(aA)}}var av=au.length;while(av--){var at=au[av];if(!at.getElementsByTagNameNS(al,"*").length){at.parentNode.removeChild(at)}}};var p=function(au,at){var av=new Array();if(au){var aB=au.attributes;var ay;var aw;var az=au.childNodes;for(aw=0;aw=0;aw--){ay=aB.item(aw);if(ay.nodeValue!=""){if(window.opera&&ay.nodeName=="opacity"&&/^\d+,\d+$/.test(ay.nodeValue)){ay.nodeValue=ay.nodeValue.replace(",",".")}av.push(" ");av.push(ay.nodeName);av.push('="');av.push(ay.nodeValue);av.push('"')}}if(au.hasChildNodes()){av.push(">");at++;var ax=false;for(aw=0;aw");break}}at--;if(!ax){av.push("\n");for(aw=0;aw")}else{av.push("/>")}}return av.join("")};var ab=function(){var av=(af=="none"?"position":"size");var c=new H(av);var at=d.length;while(at--){var au=ak(at);if(au){c.addSubCommand(au)}}if(!c.isEmpty()){I(c);b("changed",d)}};var J=[0,"z","m","m","l","l","c","c","q","q","a","a","l","l","l","l","s","s","t","t"];var ak=function(ba){var aQ=d[ba];if(aQ==null){return null}var aD=P[ba];var aA=n.getBBox(aQ);if(aA.x==aD.x&&aA.y==aD.y&&aA.width==aD.width&&aA.height==aD.height){return null}var a4=function(bf,bg){return{x:parseInt(((bf-aA.x)/aA.width)*aD.width+aD.x),y:parseInt(((bg-aA.y)/aA.height)*aD.height+aD.y)}};var aG=function(bf){return parseInt(bf*aD.width/aA.width)};var aP=function(bf){return parseInt(bf*aD.height/aA.height)};var aN={};var aH=n.getRotationAngle(aQ);var aX=document.getElementById("polypointgrip_container");if(aH){var ay=parseInt(aA.x+aA.width/2),ax=parseInt(aA.y+aA.height/2);var aM=null,aK=null;var at=false;var aY=aQ.transform.baseVal;var a1=aY.numberOfItems;while(a1--){var a6=aY.getItem(a1);if(a6.type==3){at=true;break}}if(at){var a7=aH*Math.PI/180;var av=aD.x-ay,au=aD.y-ax,a2=Math.sqrt(av*av+au*au),aJ=Math.atan2(au,av)+a7;var aw=a2*Math.cos(aJ)+ay,az=a2*Math.sin(aJ)+ax;av+=aD.width;au+=aD.height;a2=Math.sqrt(av*av+au*au);aJ=Math.atan2(au,av)+a7;var a5=a2*Math.cos(aJ)+ay,c=a2*Math.sin(aJ)+ax;aM=parseInt(aw+(a5-aw)/2);aK=parseInt(az+(c-az)/2);aD.x=parseInt(aM-aD.width/2),aD.y=parseInt(aK-aD.height/2)}else{var a9=aD.x-aA.x,a8=aD.y-aA.y;aM=ay+a9;aK=ax+a8}var bb=["rotate(",aH," ",aM,",",aK,")"].join("");aQ.setAttribute("transform",bb);if(aX){aX.setAttribute("transform",bb)}}else{aQ.setAttribute("transform","");aQ.removeAttribute("transform");if(aX){aX.setAttribute("transform","");aX.removeAttribute("transform")}}switch(aQ.tagName){case"polygon":case"polyline":aN.points=aQ.getAttribute("points");var aL=aQ.points;var aI=aL.numberOfItems;var a3="";for(var ba=0;ba0&&(B-ag)>0){aB=g({element:"ellipse",attr:{cx:(ai+C)/2,cy:(ag+B)/2,rx:(C-ai)/2,ry:(B-ag)/2,id:ao(),fill:e.fill,stroke:e.stroke,"stroke-width":e.stroke_width,"stroke-dasharray":e.stroke_style,opacity:e.opacity,"stroke-opacity":e.stroke_opacity,"fill-opacity":e.fill_opacity}});b("changed",[aB]);au=true}break;case"fhrect":if((C-ai)>0&&(B-ag)>0){aB=g({element:"rect",attr:{x:ai,y:ag,width:(C-ai),height:(B-ag),id:ao(),fill:e.fill,stroke:e.stroke,"stroke-width":e.stroke_width,"stroke-dasharray":e.stroke_style,opacity:e.opacity,"stroke-opacity":e.stroke_opacity,"fill-opacity":e.fill_opacity}});b("changed",[aB]);au=true}break;case"text":au=true;n.clearSelection();break;case"poly":aB=null;ar=true;var aH=document.getElementById("poly_stretch_line");if(!aH){aH=document.createElementNS(al,"line");S(aH,{id:"poly_stretch_line",stroke:"blue","stroke-width":"0.5"});aH=document.getElementById("selectorParentGroup").appendChild(aH)}aH.setAttribute("display","inline");if(z.length==0){z.push(aR);z.push(aQ);am="M"+aR+","+aQ+" ";g({element:"path",attr:{d:am,id:U(),fill:e.fill,"fill-opacity":e.fill_opacity,stroke:e.stroke,"stroke-width":e.stroke_width,"stroke-dasharray":e.stroke_style,"stroke-opacity":e.stroke_opacity,opacity:e.opacity/2}});S(aH,{x1:aR,y1:aQ,x2:aR,y2:aQ});f(aR,aQ,0)}else{var a0=z.length;var aL=6;var aA=false;while(a0){a0-=2;var az=z[a0],ay=z[a0+1];if(aR>=(az-aL)&&aR<=(az+aL)&&aQ>=(ay-aL)&&aQ<=(ay+aL)){aA=true;break}}var aM=E.getElementById(ao());if(aA){if(a0==0&&z.length>=6){aM.setAttribute("d",am+"z")}ah();aB=aM;z=[];ar=false}else{var aF=z.length;var aX=z[aF-2],aW=z[aF-1];z.push(aR);z.push(aQ);am+="l"+parseInt(aR-aX)+","+parseInt(aQ-aW)+" ";aM.setAttribute("d",am);S(aH,{x1:aR,y1:aQ,x2:aR,y2:aQ});f(aR,aQ,(z.length/2-1))}au=true}break;case"polyedit":au=true;aB=null;if(w!=-1){w=-1;var at=new H("Edit Poly");var a4={};a4.d=s;var aE=n.getRotationAngle(v)*Math.PI/180;if(aE){var ax=n.getBBox(v);var a2=P[0];var aV=parseInt(a2.x+a2.width/2),aU=parseInt(a2.y+a2.height/2),c=parseInt(ax.x+ax.width/2),a5=parseInt(ax.y+ax.height/2);var aw=c-aV,av=a5-aU;var aT=Math.sqrt(aw*aw+av*av);var aG=Math.atan2(av,aw)+aE;c=parseInt(aT*Math.cos(aG)+aV);a5=parseInt(aT*Math.sin(aG)+aU);var a0=z.length;while(a0){a0-=2;aw=z[a0]-aV;av=z[a0+1]-aU;aT=Math.sqrt(aw*aw+av*av);aG=Math.atan2(av,aw)+aE;z[a0]=aw=aT*Math.cos(aG)+aV;z[a0+1]=av=aT*Math.sin(aG)+aU;aw-=c;av-=a5;aT=Math.sqrt(aw*aw+av*av);aG=Math.atan2(av,aw)-aE;z[a0]=parseInt(aT*Math.cos(aG)+c);z[a0+1]=parseInt(aT*Math.sin(aG)+a5)}var aD=v.getAttribute("d");var a3=(aD[aD.length-1]=="z"||aD[aD.length-1]=="Z");var aF=z.length/2;var aC=new Array(aF+1);var aO=z[0],aN=z[1];aC[0]=["M",aO,",",aN].join("");S(document.getElementById("polypointgrip_0"),{cx:aO,cy:aN},100);for(var aZ=1;aZ0){var at=E.getElementById(ao());at.parentNode.removeChild(at);n.clearPoly();n.clearSelection();ar=false}else{if(aj=="polyedit"){n.clearPoly()}}l=(d[0]&&d[0].nodeName=="text")?A:e;aj=c};this.getStrokeColor=function(){return l.stroke};this.setStrokeColor=function(at,c){e.stroke=at;l.stroke_paint={type:"solidColor"};if(!c){this.changeSelectedAttribute("stroke",at)}else{this.changeSelectedAttributeNoUndo("stroke",at)}};this.getFillColor=function(){return l.fill};this.setFillColor=function(aw,at){l.fill=aw;l.fill_paint={type:"solidColor"};var c=[];var au=d.length;while(au--){var av=d[au];if(av&&av.tagName!="polyline"&&av.tagName!="line"){c.push(av)}}if(c.length>0){if(!at){this.changeSelectedAttribute("fill",aw,c)}else{this.changeSelectedAttributeNoUndo("fill",aw,c)}}};var y=function(){var c=G.getElementsByTagNameNS(al,"defs");if(c.length>0){c=c[0]}else{c=G.insertBefore(E.createElementNS(al,"defs"),G.firstChild.nextSibling)}return c};var L=function(){$.each(["stroke","fill"],function(au,av){if(!l[av+"_paint"]||l[av+"_paint"].type=="solidColor"){return}var ax=n[av+"Grad"];var aw=t(ax);var c=y();if(!aw){ax=c.appendChild(E.importNode(ax,true));ax.id=U()}else{ax=aw}var at=av=="fill"?"Fill":"Stroke";n["set"+at+"Color"]("url(#"+ax.id+")")})};var t=function(ax){var au=y();var ay=au.getElementsByTagNameNS(al,"linearGradient");var av=ay.length;while(av--){var az=ay.item(av);if(ax.getAttribute("x1")!=az.getAttribute("x1")||ax.getAttribute("y1")!=az.getAttribute("y1")||ax.getAttribute("x2")!=az.getAttribute("x2")||ax.getAttribute("y2")!=az.getAttribute("y2")){continue}var aA=ax.getElementsByTagNameNS(al,"stop");var aB=az.getElementsByTagNameNS(al,"stop");if(aA.length!=aB.length){continue}var at=aA.length;while(at--){var aw=aA.item(at);var c=aB.item(at);if(aw.getAttribute("offset")!=c.getAttribute("offset")||aw.getAttribute("stop-opacity")!=c.getAttribute("stop-opacity")||aw.getAttribute("stop-color")!=c.getAttribute("stop-color")){break}}if(at==-1){return az}}return null};this.setStrokePaint=function(at,c){var at=new $.jGraduate.Paint(at);this.setStrokeOpacity(at.alpha/100);l.stroke_paint=at;if(at.type=="solidColor"){this.setStrokeColor("#"+at.solidColor)}else{if(at.type=="linearGradient"){n.strokeGrad=at.linearGradient;if(c){L()}}else{}}};this.setFillPaint=function(at,c){var at=new $.jGraduate.Paint(at);this.setFillOpacity(at.alpha/100,true);l.fill_paint=at;if(at.type=="solidColor"){this.setFillColor("#"+at.solidColor)}else{if(at.type=="linearGradient"){n.fillGrad=at.linearGradient;if(c){L()}}else{}}};this.getStrokeWidth=function(){return l.stroke_width};this.setStrokeWidth=function(c){if(c==0&&$.inArray(aj,["line","path"])==-1){n.setStrokeWidth(1)}l.stroke_width=c;this.changeSelectedAttribute("stroke-width",c)};this.getStrokeStyle=function(){return e.stroke_style};this.setStrokeStyle=function(c){e.stroke_style=c;this.changeSelectedAttribute("stroke-dasharray",c)};this.getOpacity=function(){return e.opacity};this.setOpacity=function(c){e.opacity=c;this.changeSelectedAttribute("opacity",c)};this.getFillOpacity=function(){return e.fill_opacity};this.setFillOpacity=function(at,c){e.fill_opacity=at;if(!c){this.changeSelectedAttribute("fill-opacity",at)}else{this.changeSelectedAttributeNoUndo("fill-opacity",at)}};this.getStrokeOpacity=function(){return e.stroke_opacity};this.setStrokeOpacity=function(at,c){e.stroke_opacity=at;if(!c){this.changeSelectedAttribute("stroke-opacity",at)}else{this.changeSelectedAttributeNoUndo("stroke-opacity",at)}};this.getBBox=function(au){var at=au||d[0];if(au.nodeName=="text"&&at.textContent==""){at.textContent="a";var c=at.getBBox();at.textContent=""}else{var c=at.getBBox()}return c};this.getRotationAngle=function(aw){var av=aw||d[0];var ax=av.transform.baseVal;var au=ax.numberOfItems;var at=false;while(au--){var c=ax.getItem(au);if(c.type==4){return c.angle}}return 0};this.setRotationAngle=function(ay,at){var av=d[0];var ax=av.getBBox();var c=parseInt(ax.x+ax.width/2),az=parseInt(ax.y+ax.height/2);var au="rotate("+ay+" "+c+","+az+")";if(at){this.changeSelectedAttributeNoUndo("transform",au,d)}else{this.changeSelectedAttribute("transform",au,d)}var aw=document.getElementById("polypointgrip_container");if(av.nodeName=="path"&&aw){aw.setAttribute("transform",au)}N.requestSelector(d[0]).updateGripCursors(ay)};this.each=function(c){$(G).children().each(c)};this.bind=function(at,au){var c=D[at];D[at]=au;return c};this.setIdPrefix=function(c){q=c};this.getBold=function(){var c=d[0];if(c!=null&&c.tagName=="text"&&d[1]==null){return(c.getAttribute("font-weight")=="bold")}return false};this.setBold=function(c){var at=d[0];if(at!=null&&at.tagName=="text"&&d[1]==null){this.changeSelectedAttribute("font-weight",c?"bold":"normal")}};this.getItalic=function(){var c=d[0];if(c!=null&&c.tagName=="text"&&d[1]==null){return(c.getAttribute("font-style")=="italic")}return false};this.setItalic=function(c){var at=d[0];if(at!=null&&at.tagName=="text"&&d[1]==null){this.changeSelectedAttribute("font-style",c?"italic":"normal")}};this.getFontFamily=function(){return A.font_family};this.setFontFamily=function(c){A.font_family=c;this.changeSelectedAttribute("font-family",c)};this.getFontSize=function(){return A.font_size};this.setFontSize=function(c){A.font_size=c;this.changeSelectedAttribute("font-size",c)};this.getText=function(){var c=d[0];if(c==null){return""}return c.textContent};this.setTextContent=function(c){this.changeSelectedAttribute("#text",c)};this.setRectRadius=function(au){var c=d[0];if(c!=null&&c.tagName=="rect"){var at=c.getAttribute("rx");if(at!=au){c.setAttribute("rx",au);c.setAttribute("ry",au);I(new V(c,{rx:at,ry:at},"Radius"));b("changed",[c])}}};this.quickClone=function(c){if(navigator.userAgent.indexOf("Gecko/")==-1){return c}var at=c.cloneNode(true);c.parentNode.insertBefore(at,c);c.parentNode.removeChild(c);n.clearSelection();n.addToSelection([at],true);return at};var m=-1;var F=[];this.beginUndoableChange=function(av,at){var ay=++m;var au=at.length;var c=new Array(au),ax=new Array(au);while(au--){var aw=at[au];if(aw==null){continue}ax[au]=aw;c[au]=aw.getAttribute(av)}F[ay]={attrName:av,oldValues:c,elements:ax}};this.changeSelectedAttributeNoUndo=function(aB,at,c){var aA=G.suspendRedraw(1000);var c=c||d;var az=c.length;while(az--){var au=c[az];if(au==null){continue}var aC=aB=="#text"?au.textContent:au.getAttribute(aB);if(aC==null){aC=""}if(aC!=at){if(aB=="#text"){au.textContent=at;au=n.quickClone(au)}else{au.setAttribute(aB,at)}P[az]=this.getBBox(au);if(au.nodeName=="text"){if((at+"").indexOf("url")==0||$.inArray(aB,["font-size","font-family","x","y"])!=-1){au=n.quickClone(au)}}setTimeout(function(){N.requestSelector(au).resize(P[az])},0);var aw=n.getRotationAngle(au);if(aw&&aB!="transform"){var ax=parseInt(P[az].x+P[az].width/2),av=parseInt(P[az].y+P[az].height/2);var ay=["rotate(",aw," ",ax,",",av,")"].join("");if(ay!=au.getAttribute("transform")){au.setAttribute("transform",ay)}}}}G.unsuspendRedraw(aA);b("changed",c)};this.finishUndoableChange=function(){var ax=m--;var ay=F[ax];var au=ay.elements.length;var at=ay.attrName;var c=new H("Change "+at);while(au--){var aw=ay.elements[au];if(aw==null){continue}var av={};av[at]=ay.oldValues[au];if(av[at]!=aw.getAttribute(at)){c.addSubCommand(new V(aw,av,at))}}F[ax]=null;return c};this.changeSelectedAttribute=function(c,aw,au){var au=au||d;n.beginUndoableChange(c,au);var av=au.length;n.changeSelectedAttributeNoUndo(c,aw,au);var at=n.finishUndoableChange();if(!at.isEmpty()){I(at)}};$(W).mouseup(k);$(W).mousedown(o);$(W).mousemove(u);this.deleteSelectedElements=function(){var au=new H("Delete Elements");var at=d.length;var c=[];for(var aw=0;aw=aw.length){c=0}else{if(c<0){c=aw.length-1}}av=aw[c];break}}}n.clearSelection();n.addToSelection([av],true);b("selected",d)};var X=function(){r=[];ae=0};this.getUndoStackSize=function(){return ae};this.getRedoStackSize=function(){return r.length-ae};this.getNextUndoCommandText=function(){if(ae>0){return r[ae-1].text}return""};this.getNextRedoCommandText=function(){if(ae0){this.clearSelection();ah();var c=r[--ae];c.unapply();b("changed",c.elements())}};this.redo=function(){if(ae0){this.clearSelection();var c=r[ae++];c.apply();b("changed",c.elements())}};this.cloneSelectedElements=function(){var at=new H("Clone Elements");var c=d.length;for(var au=0;auaK){aK=aD}if(aC>aH){aH=aC}}aA[aQ].x=aL;aA[aQ].y=aI;aA[aQ].width=aK-aL;aA[aQ].height=aH-aI}switch(aE){case"smallest":if((ax=="l"||ax=="c"||ax=="r")&&(aJ==Number.MIN_VALUE||aJ>aA[aQ].width)||(ax=="t"||ax=="m"||ax=="b")&&(aP==Number.MIN_VALUE||aP>aA[aQ].height)){az=aA[aQ].x;aw=aA[aQ].y;ay=aA[aQ].x+aA[aQ].width;av=aA[aQ].y+aA[aQ].height;aJ=aA[aQ].width;aP=aA[aQ].height}break;case"largest":if((ax=="l"||ax=="c"||ax=="r")&&(aJ==Number.MIN_VALUE||aJay){ay=aA[aQ].x+aA[aQ].width}if(aA[aQ].y+aA[aQ].height>av){av=aA[aQ].y+aA[aQ].height}break}}if(aE=="page"){az=0;aw=0;ay=G.getAttribute("width");av=G.getAttribute("height")}var aG=new Array(aR);var aF=new Array(aR);for(var aQ=0;aQ>2;h=((l&3)<<4)|(j>>4);f=((j&15)<<2)|(g>>6);e=g&63;if(isNaN(j)){f=e=64}else{if(isNaN(g)){e=64}}b[a++]=this._keyStr.charAt(k);b[a++]=this._keyStr.charAt(h);b[a++]=this._keyStr.charAt(f);b[a++]=this._keyStr.charAt(e)}while(cb.x&&a.y<(b.y+b.height)&&(a.y+a.height)>b.y},text2xml:function(b){var a;try{var d=($.browser.msie)?new ActiveXObject("Microsoft.XMLDOM"):new DOMParser();d.async=false}catch(c){throw new Error("XML Parser could not be instantiated")}try{if($.browser.msie){a=(d.loadXML(b))?d:false}else{a=d.parseFromString(b,"text/xml")}}catch(c){throw new Error("Error parsing XML string")}return a}}; \ No newline at end of file