wp-gpx-maps/mColorPicker_min.js

12 lines
9.9 KiB
JavaScript
Raw Normal View History

2020-05-10 14:06:09 +00:00
/*
mColorPicker
Version: 1.0 r39
Copyright (c) 2010 Meta100 LLC.
http://www.meta100.com/
Licensed under the MIT license
http://www.opensource.org/licenses/mit-license.php
*/
(function($){var b,f,h,l,j=$(document),i=$("<div>"),k=$("<div>"),n=$("<div>"),o=$("<input>"),p=/^rgb[a]?\((\d+),\s*(\d+),\s*(\d+)(,\s*(\d+\.\d+)*)?\)/,q=/([a-f0-9])([a-f0-9])([a-f0-9])/,r=/#[a-f0-9]{3}/,s=/#[a-f0-9]{6}/;$.fn.mColorPicker=function(a){var c=$.fn.mColorPicker.getCookie("swatches");b=$.extend($.fn.mColorPicker.defaults,a);$.fn.mColorPicker.defaults.swatches.concat(b.swatches).slice(-10);f.enhancedSwatches&&c&&(b.swatches=c.split("||").concat(b.swatches).slice(0,10)||b.swatches);$("div#mColorPicker").length||$.fn.mColorPicker.drawPicker();$("#css_disabled_color_picker").length||$("head").prepend('<meta data-remove-me="true"/><style id="css_disabled_color_picker" type="text/css">.mColorPicker[disabled] + span, .mColorPicker[disabled="disabled"] + span, .mColorPicker[disabled="true"] + span {filter:alpha(opacity=50);-moz-opacity:0.5;-webkit-opacity:0.5;-khtml-opacity: 0.5;opacity: 0.5;cursor:default;}</style>');$("meta[data-remove-me=true]").remove();this.each($.fn.mColorPicker.drawPickerTriggers);return this};$.fn.mColorPicker.init={replace:"[type=color]",index:0,enhancedSwatches:!0,allowTransparency:!0,slogan:"Meta100 - Designing Fun",showLogo:!0};$.fn.mColorPicker.defaults={currentId:!1,currentInput:!1,currentColor:!1,changeColor:!1,color:!1,imageFolder:"http://meta100.github.com/mColorPicker/images/",swatches:"#ffffff,#ffff00,#00ff00,#00ffff,#0000ff,#ff00ff,#ff0000,#4c2b11,#3b3b3b,#000000".split(",")};$.fn.mColorPicker.start=function(){$('input[data-mcolorpicker!="true"]').filter(function(){return"[type=color]"==f.replace?"color"==this.getAttribute("type"):$(this).is(f.replace)}).mColorPicker()};$.fn.mColorPicker.events=function(){$("#mColorPickerBg").live("click",$.fn.mColorPicker.closePicker);$(".mColorPicker").live("keyup",function(){try{$(this).css({"background-color":$(this).val()}).css({color:$.fn.mColorPicker.textColor($(this).css("background-color"))}).trigger("change")}catch(a){}});$(".mColorPickerTrigger").live("click",$.fn.mColorPicker.colorShow);$(".mColor, .mPastColor").live("mousemove",function(a){if(!b.changeColor)return!1;var c=$(this),g=c.offset(),d=b.currentInput,d=d.attr("data-hex")||d.attr("hex");b.color=c.css("background-color");c.hasClass("mPastColor")?b.color=$.fn.mColorPicker.setColor(b.color,d):c.hasClass("mColorTransparent")?b.color="transparent":c.hasClass("mPastColor")||(b.color=$.fn.mColorPicker.whichColor(a.pageX-g.left,a.pageY-g.top,d));b.currentInput.mSetInputColor(b.color)}).live("click",$.fn.mColorPicker.colorPicked);$("#mColorPickerInput").live("keyup",function(a){try{b.color=$(this).val(),b.currentInput.mSetInputColor(b.color),13==a.which&&$.fn.mColorPicker.colorPicked()}catch(c){}}).live("blur",function(){b.currentInput.mSetInputColor(b.color)});$("#mColorPickerWrapper").live("mouseleave",function(){if(!b.changeColor)return!1;var a=b.currentInput;b.currentInput.mSetInputColor($.fn.mColorPicker.setColor(b.currentColor,a.attr("data-hex")||a.attr("hex")))})};$.fn.mColorPicker.drawPickerTriggers=function(){var a=$(this),c=a.attr("id")||"color_"+f.index++,g="hidden"==a.attr("text")||"hidden"==a.attr("data-text")?!0:!1,d=$.fn.mColorPicker.setColor(a.val(),a.attr("data-hex")||a.attr("hex")),e=a.width(),h=a.height(),i=a.css("float"),j=$("<span>"),m=$("<span>"),k="";j.attr({id:"color_work_area","class":"mColorPickerInput"}).appendTo(l);m.attr({id:"mcp_"+c,"class":"mColorPickerTrigger"}).css({display:"inline-block",cursor:"pointer"}).insertAfter(a);$("<img>").attr({src:b.imageFolder+"color.png"}).css({border:0,margin:"0 0 0 3px","vertical-align":"text-bottom"}).appendTo(m);j.append(a);k=j.html().replace(/type=[^a-z ]*color[^a-z //>]*/gi,'type="'+(g?"hidden":"text")+'"');j.html("").remove();a=$(k).attr("id",c).addClass("mColorPicker").val(d).insertBefore(m);g&&m.css({border:"1px solid black","float":i,width:e,height:h}).addClass(a.attr("class")).html("&nbsp;");a.mSetInputColor(d);return a};$.fn.mColorPicker.drawPicker=function(){var a=$("<div>"),c=$("<a>"),g=$("<div>"),d=$("<div>");k.attr({id:"mColorPickerBg"}).css({display:"none",background:"black",opacity:0.01,position:"absolute