1/** 2 * Author: æéª¨è 3 * Git: https://gitee.com/colorpicker/jquery_palette 4 * Modified: ä¿®æ¹æ¯ææ¸ é¤åä¼ å ¥ä¸ 5 */ 6(function (c, f, h, k) { 7 var g = function (a, b) { 8 this.eve = a; 9 this.defaults = {width: 230, height: 400, color: "#1926dc", recommend: !1, title: "\u6700\u8fd1\u4f7f\u7528"}; 10 this.options = c.extend({}, this.defaults, b); 11 }; 12 g.prototype = { 13 init: function () { 14 this.getPosition(); 15 this.initDefaultColor(); 16 this.latelyColor(); 17 this.createHtml(); 18 this.on() 19 }, createHtml: function () { 20 var a = this.options, b = a.bg.r + "," + a.bg.g + "," + a.bg.b, d = ""; 21 c.each(a.lately, function (a, b) { 22 if (9 < a) return !1; 23 d += '\x3cdiv style\x3d"width: 20px;height: 20px;margin:5px 11px;float: left;box-shadow: 0 0 5px #ccc;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg\x3d\x3d)"\x3e\x3cdiv style\x3d"width: 100%px;height: 100%;background: rgba(' + b + ');" class\x3d"colorpicker-lately" data-color\x3d"' + b + '"\x3e\x3c/div\x3e\x3c/div\x3e' 24 }); 25 a = ['\x3cdiv style\x3d"position: fixed;top: 0;left: 0;right: 0;bottom: 0;z-index: 9999;" id\x3d"colorpicker-screen"\x3e', '\x3cdiv style\x3d"width: ' + a.width + "px;height: " + a.height + "px;background: #fff;position: absolute;top: " + a.positionTop + "px;left: " + a.positionLeft + 'px;box-shadow: 0 0 10px #ddd;z-index:99999;" id\x3d"colorpicker-color-picker"\x3e', '\x3cdiv style\x3d"width:100%;height: 150px;background: rgb(' + b + ');position: absolute;overflow: hidden;" id\x3d"color-block"\x3e', '\x3cdiv style\x3d"width:100%;height:100%;background: linear-gradient(to right, #fff, rgba(255,255,255,0));position: absolute;"\x3e\x3cdiv style\x3d"width: 100%;height: 100%;background: linear-gradient(to top, #000, rgba(0,0,0,0));position: absolute;"\x3e', '\x3cdiv style\x3d"width: 12px;height: 12px;border-radius: 6px;box-shadow: inset 0 0 0 1px #fff;position: absolute;top: ' + a.ident.top + "px;left: " + a.ident.left + 'px; z-index:1;" id\x3d"block-ident"\x3e\x3c/div\x3e', '\x3cdiv style\x3d"width:100%;height:100%;position:absolute;top:0;left:0;right:0;bottom:0;z-index:2;" id\x3d"colorpicker-palette"\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv style\x3d"width: 100%;height:100px;position: absolute;top: 150px;padding: 10px 20px;box-sizing: border-box;"\x3e\x3cdiv style\x3d"width:16px;height:16px;border-radius: 8px;background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg\x3d\x3d);box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); float: left;margin-top: 5px;"\x3e', '\x3cdiv style\x3d"width:16px;height:16px;border-radius: 8px;background: rgba(' + a.color.r + "," + a.color.g + "," + a.color.b + ');" id\x3d"final-color"\x3e\x3c/div\x3e', '\x3c/div\x3e\x3cdiv style\x3d"width:160px;height: 10px;background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);float: right;position:relative;margin-bottom: 10px;"\x3e', '\x3cdiv style\x3d"width:10px;height: 10px;background-color: #fff;border-radius: 5px;box-shadow: 0 0 2px #ccc;position: absolute;left:' + (a.colorSlider - 5) + 'px; z-index:1;" id\x3d"colorpicker-slider-btn"\x3e\x3c/div\x3e', '\x3cdiv style\x3d"width:100%;height:100%;position: absolute;left:0;top:0;right:0;bottom:0;z-index:2;" id\x3d"colorpicker-slider"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv style\x3d"width:160px;height: 10px;float: right;background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg\x3d\x3d);position: relative;"\x3e', '\x3cdiv style\x3d"width: 100%;height: 10px;background:linear-gradient(to right, rgba(' + b + ", 0) 0%, rgba(" + b + ', 1) 100%);position: relative;" id\x3d"colorpicker-alpha-block"\x3e', '\x3cdiv style\x3d"width:10px;height: 10px;background-color: #fff;border-radius: 5px;box-shadow: 0 0 2px #ccc;position: absolute;right:-5px;z-index:1;" id\x3d"colorpicker-alpha-btn"\x3e\x3c/div\x3e\x3cdiv style\x3d"width:100%;height:100%;position: absolute;
25left:0;top:0;right:0;bottom:0;z-index:2;" id\x3d"colorpicker-alpha"\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv style\x3d"width: 100%;height:45px;clear: both;padding-top: 10px;"\x3e\x3cdiv style\x3d"width: 153px;height: 100%;float: left;"\x3e\x3cdiv style\x3d"width:100%;height:100%; " id\x3d"colorpicker-rgba"\x3e', '\x3cinput type\x3d"text" name\x3d"colorpicker-r" style\x3d"width: 33px;height:20px;padding:0;border: 1px solid #ccc;border-radius: 5px;margin-right: 4px;text-align:center;color:#333" value\x3d"' + a.color.r + '"\x3e', '\x3cinput type\x3d"text" name\x3d"colorpicker-g" style\x3d"width: 33px;height:20px;padding:0;border: 1px solid #ccc;border-radius: 5px;margin-right: 4px;text-align:center;color:#333" value\x3d"' + a.color.g + '"\x3e', '\x3cinput type\x3d"text" name\x3d"colorpicker-b" style\x3d"width: 33px;height:20px;padding:0;border: 1px solid #ccc;border-radius: 5px;margin-right: 4px;text-align:center;color:#333" value\x3d"' + a.color.b + '"\x3e', '\x3cinput type\x3d"text" name\x3d"colorpicker-a" style\x3d"width: 33px;height:20px;padding:0;border: 1px solid #ccc;border-radius: 5px;text-align:center;color:#333" value\x3d"' + a.color.a + '"\x3e', '\x3cp style\x3d"color:#666;letter-spacing: 29px;text-indent: 13px;line-height: 25px;margin:0;"\x3eRGBA\x3c/p\x3e\x3c/div\x3e\x3cdiv style\x3d"width:100%;height:100%;float: left; display: none;" id\x3d"colorpicker-rex"\x3e', '\x3cinput type\x3d"text" name\x3d"colorpicker-hex" style\x3d"width:100%;height:20px;border: 1px solid #ccc;border-radius: 5px;text-align:center;color:#333" value\x3d"#' + a.hex + '" \x3e', '\x3cp style\x3d"color:#666;text-align:center;letter-spacing: 8px;text-indent: 13px;line-height: 25px;margin:0;"\x3eHEX\x3c/p\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv style\x3d"width:35px;height: 100%;float: right;cursor: pointer;padding-top: 8px;text-align: right;" id\x3d"colorpicker-tab"\x3e\x3csvg style\x3d"width:85%;" viewBox\x3d"0 0 24 24" data-reactid\x3d".0.0.q.0.0.0.0.0.1.1.1.0.0" \x3e\x3cpath fill\x3d"#333" d\x3d"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z" data-reactid\x3d".0.0.q.0.0.0.0.0.1.1.1.0.0.0"\x3e\x3c/path\x3e\x3c/svg\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv style\x3d"width:100%;height: 100px;position: absolute;bottom: 50px;padding:10px;box-sizing: border-box;"\x3e', '\x3cp style\x3d"color:#666;text-indent: 10px;margin:0;"\x3e' + a.title + "\x3c/p\x3e", '\x3cdiv style\x3d"height: 70px;width:100%;padding: 5px 0;box-sizing: border-box;"\x3e', d, '\x3c/div\x3e\x3c/div\x3e\x3cdiv style\x3d"width:100%;height: 50px;text-align: center;position: absolute;bottom: 0;line-height: 50px;"\x3e\x3cbutton style\x3d"line-height:18px;border: 1px solid #333;background: #333;padding: 5px 30px;border-radius: 4px;color: #fff;cursor: pointer;font-size:12px;" id\x3d"colorpicker-ok"\x3e\u786e\u5b9a\x3c/button\x3e \x3cbutton style\x3d"line-height:18px;border: 1px solid #333;background: #fff;padding: 5px 30px;border-radius: 4px;color: #333;cursor: pointer;font-size:12px;" id\x3d"colorpicker-clear"\x3e\u6e05\u9664\x3c/button\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e'].join(""); 26 c("body").append(a) 27 }, initDefaultColor: function () { 28 var color = typeof this.options.color == 'function' ? this.options.color.apply(this) : this.options.color; 29 var a = color.split(","); 30 if (1 == a.length) { 31 var b = this.hexToRgb(a[0]); 32 b.a = 1; 33 var d = this.rgbToHex(b), e = this.rgbToHsb(b) 34 } else 3 == a.length ? (b = a[0], d = a[1], e = a[2], a = 1) : 4 == a.length ? (b = a[0], d = a[1], e = a[2], a = a[3]) : (b = 42, d = 0, e = 255, a = 1), b = {r: 255 < parseInt(b) ? 255 : parseInt(b), g: 255 < parseInt(d) ? 255 : parseInt(d), b: 255 < parseInt(e) ? 255 : parseInt(e), a: parseFloat(.9 < parseFloat(a).toFixed(1) ? 1 : parseFloat(a).toFixed(1))}, d = this.rgbToHex(b), e = this.rgbToHsb(b); 35 a = this.hsbToRgb({h: e.h, s: 100, b: 100}); 36 this.set({color: b, hex: d, hsb: e, bg: a, ident: {top: 150 - e.b / 100 * 150 - 6, left: e.s / 100 * 230 - 6}, colorSlider: parseInt(e.h / 360 * 160)}) 37 }, latelyColor: function () { 38 if (this.options.recommend) { 39 var a = this.options.recommend.split("|"); 40 this.options.lately = a; 41 this.options.title = "\u63a8\u8350\u8272" 42 } else if (f.localStorage) { 43 var a = f.localStorage, b = a.getItem("colorpicker-lately"); 44 b ? b = b.split("-") : (b = "0,0,51,1 0,51,102,1 0,102,153,1 0,153,204,1 0,204,255,1 102,0,51,1 102,51,102,1 102,102,153,1 102,204,204,1 102,255,255,1".split(" "), a.setItem("colorpicker-lately", b.join("-"))); 45 this.options.lately = b 46 } 47 }, rgbToHsb: function (a) { 48 var b = {h: 0, s: 0, b: 0}, d = Math.min(a.r, a.g, a.b), e = Math.max(a.r, a.g, a.b), c = e - d; 49 b.b = e; 50 b.s = 0 != e ? 255 * c / e : 0; 51 b.h = 0 != b.s ? a.r == e ? (a.g - a.b) / c : a.g == e ? 2 + (a.b - a.r) / c : 4 + (a.r - a.g) / c : -1; 52 e == d && (b.h = 0); 53 b.h *= 60; 54 0 > b.h && (b.h += 360); 55 b.s *= 100 / 255; 56 b.b *= 100 / 255; 57 return b = {h: Math.round(b.h), s: Math.round(b.s), b: Math.round(b.b)} 58 }, hexToRgb: function (a) { 59 a = -1 < a.indexOf("#") ? a.substring(1) : a; 60 3 == a.length && (a = a.split(""), a = a[0] + a[0] + a[1] + a[1] + a[2] + a[2]); 61 a = parseInt(a, 16); 62 return {r: a >> 16, g: (a & 65280) >> 8, b: a & 255} 63 }, rgbToHex: function (a) { 64 var b = [a.r.toString(16), a.g.toString(16), a.b.toString(16)]; 65 c.each(b, function (a, e) { 66 1 == e.length && (b[a] = "0" + e) 67 }); 68 return b.join("") 69 }, hsbToRgb: function (a) { 70 var b, d, e; 71 b = a.h; 72 var c = 255 * a.s / 100; 73 a = 255 * a.b / 100; 74 if (0 == c) b = d = e = a; else { 75 var c = (255 - c) * a / 255, f = b % 60 * (a - c) / 60; 76 360 == b && (b = 0); 77 60 > b ? (b = a, e = c, d = c + f) : 120 > b ? (d = a, e = c, b = a - f) : 180 > b ? (d = a, b = c, e = c + f) : 240 > b ? (e = a, b = c, d = a - f) : 300 > b ? (e = a, d = c, b = c + f) : 360 > b ? (b = a, d = c, e = a - f) : e = d = b = 0 78 } 79 return {r: Math.round(b), g: Math.round(d), b: Math.round(e)} 80 }, hsbToHex: function (a) { 81 a = this.hsbToRgb(a); 82 var b = [a.r.toString(16), a.g.toString(16), a.b.toString(16)]; 83 c.each(b, function (a, c) { 84 1 == c.length && (b[a] = "0" + c) 85 }); 86 return b.join("") 87 }, getPosition: function () { 88 var a = this.options, b = c(f).width(), d = c(f).height(), e = this.eve.getBoundingClientRect(); 89 b - e.right > a.width ? this.set({positionLeft: e.right + 5}) : this.set({positionLeft: e.left - a.width - 5}); 90 d - e.bottom > a.height || a.height > e.top ? this.set({positionTop: (a.height + e.top > d ? 5 : e.top)}) : this.set({positionTop: e.bottom - a.height}) 91 }, doploy: function () { 92 var a = this.options; 93 c("#colorpicker-slider-btn").css("left", a.colorSlider - 5); 94 var b = this.hsbToHex({h: a.colorSlider / 160 * 360, s: 100, b: 100}), d = this.hexToRgb(b), e = {h: a.colorSlider / 160 * 360, s: 100, s: a.hsb.s, b: a.hsb.b}, b = this.hsbToHex(e), f = this.hexToRgb(b); 95 f.a = a.color.a; 96 this.set({bg: d, color: f, hex: b, hsb: e}); 97 this.setInputColor() 98 }, setInputColor: function () { 99 var a = this.options, b = a.color.r + "," + a.color.g + "," + a.color.b; 100 c("#final-color").css("background", "rgba(" + b + "," + a.color.a + ")"); 101 var d = a.bg.r + "," + a.bg.g + "," + a.bg.b; 102 c("#color-block").css("background", "rgb(" + d + ")"); 103 c("#colorpicker-alpha-block").css("background", "linear-gradient(to right, rgba(" + b + ", 0) 0%, rgba(" + b + ", 1) 100%)"); 104 c.each(a.color, function (a, b) { 105 c("input[name\x3d'colorpicker-" + a + "']").val(b) 106 }); 107 c("input[name\x3d'colorpicker-hex']").val("#" + a.hex); 108 this.callFun() 109 }, inputSetColor: function () { 110 var a = this.options.hsb, b = this.hsbToRgb({h: 0 == a.h ? 250 : a.h, s: 100, b: 100}), d = 150 - a.b / 100 * 150 - 6, e = a.s / 100 * 230 - 6, a = parseInt(a.h / 360 * 160), f = this.options.color; 111 this.set({bg: b, ident: {top: d, left: e}, colorSlider: a}); 112 c("#color-block").css("background", "rgb(" + b.r + "," + b.g + "," + b.b + ")"); 113 c("#block-ident").css({top: d, left: e}); 114 c("#colorpicker-slider-btn").css("left", a - 5); 115 c("#final-color").css("background", "rgb(" + f.r + "," + f.g + "," + f.b + "," + f.a + ")"); 116 c("#colorpicker-alpha-block").css("background", "linear-gradient(to right, rgba(0,17,255, 0) 0%, rgba(" + b.r + "," + b.g + "," + b.b + ", 1) 100%)"); 117 c("#colorpicker-alpha-btn").css("left", parseInt(160 * f.a) - 5); 118 this.callFun() 119 }, palette: function () { 120 var a = this.options; 121 c("#block-ident").css(a.ident); 122 var b = 0 > a.ident.top ? 0 : a.ident.top, d = 0 > a.ident.left ? 0 : a.ident.left, a = {s: ((230 < d ? 230 : d) + 6) / 230 * 100, b: 100 - ((150 < b ? 150 : b) + 6) / 150 * 100, h: a.hsb.h}, b = this.hsbToHex(a), d = this.hexToRgb(b); 123 this.options.hex = b; 124 this.options.hsb = a; 125 this.options.color.r = d.r; 126 this.options.color.g = d.g; 127 this.options.color.b = d.b; 128 this.setInputColor() 129 }, callFun: function () { 130 var a = this.options, b = a.color; 131 this.callBack(this.eve, {hex: a.hex, rgba: b.r + "," + b.g + "," + b.b + "," + b.a, rgb: b.r + "," + b.g + "," + b.b}) 132 }, callFunClear: function () { 133 var a = this.options, b = a.color; 134 this.callClear(this.eve, {hex: a.hex, rgba: b.r + "," + b.g + "," + b.b + "," + b.a, rgb: b.r + "," + b.g + "," + b.b}) 135 }, set: function (a) { 136 this.options = c.extend({}, this.options, a); 137 return this 138 }, on: function () { 139 var a = this; 140 c("#colorpicker-screen").off().on("mousedown", function () { 141 c(this).remove(); 142 return !1 143 }); 144 c("#colorpicker-color-picker").off().on("mousedown", function (a) { 145 a.stopPropagation() 146 }); 147 c("#colorpicker-tab").off().on("click", function () { 148 c("#colorpicker-rgba").is(":hidden") ? (c("#colorpicker-rgba").show(), c("#colorpicker-rex").hide()) : (c("#colorpicker-rgba").hide(), c("#colorpicker-rex").show()) 149 }); 150 c("#colorpicker-palette").off().on("mousedown", function (b) { 151 b = b || f.event; 152 f.colorpickerpalette = !0; 153 a.set({ident: {top: b.offsetY - 6, left: b.offsetX - 6}}); 154 a.palette() 155 }).on("mousemove", function (b) { 156 b = b || f.event; 157 f.colorpickerpalette && (a.set({ident: {top: b.offsetY - 6, left: b.offsetX - 6}}), a.palette()) 158 }).on("mouseup", function () { 159 f.colorpickerpalette = !1 160 }).on("mouseleave", function () { 161 f.colorpickerpalette = !1 162 }); 163 c("#colorpicker-slider").off().on("mousedown", function (b) { 164 b = b || f.event; 165 f.colorpickerslider = !0; 166 a.set({colorSlider: b.offsetX}); 167 a.doploy() 168 }).on("mousemove", function (b) { 169 b = b || f.event; 170 f.colorpickerslider && (a.set({colorSlider: 0 > b.offsetX ? 0 : b.offsetX}), a.doploy()) 171 }).on("mouseup", function () { 172 f.colorpickerslider = !1 173 }).on("mouseleave", function () { 174 f.colorpickerslider = !1 175 }); 176 c("#colorpicker-alpha").off().on("mousedown", function (b) { 177 b = b || f.event; 178 f.colorpickeralpha = !0; 179 c("#colorpicker-alpha-btn").css("left", b.offsetX - 6); 180 a.options.color.a = parseFloat((b.offsetX / 160).toFixed(1)); 181 a.setInputColor() 182 }).on("mousemove", function (b) { 183 b = b || f.event; 184 f.colorpickeralpha && (c("#colorpicker-alpha-btn").css("left", b.offsetX - 6), a.options.color.a = parseFloat(((0 > b.offsetX ? 0 : b.offsetX) / 160).toFixed(1)), a.setInputColor()) 185 }).on("mouseup", function () { 186 f.colorpickeralpha = !1 187 }).on("mouseleave", function () { 188 f.colorpickeralpha = !1 189 }); 190 c('input[name\x3d"colorpicker-r"],input[name\x3d"colorpicker-g"],input[name\x3d"colorpicker-b"],input[name\x3d"colorpicker-a"]').on("keyup", function () { 191 var b = c(this).attr("name").split("-"); 192 if ("a" == b[1]) { 193 var d = parseFloat(c(this).val()) || 1, d = parseFloat(d.toFixed(1)); 194 if (1 < d || 0 > d) c(this).val(1), d = 1 195 } else d = parseInt(c(this).val()) || 0, 0 > d ? (c(this).val(0), d = 0) : 255 < d && (c(this).val(255), d = 255); 196 a.options.color[b[1]] = d; 197 b = a.rgbToHex(a.options.color); 198 c('input[name\x3d"colorpicker-hex"]').val("#" + b); 199 a.options.hex = b; 200 b = a.rgbToHsb(a.options.color); 201 a.options.hsb = b; 202 a.inputSetColor() 203 }); 204 c('input[name\x3d"colorpicker-hex"]').on("keyup", function () { 205 var b = c(this).val().replace("#", ""); 206 if (3 == b.length || 6 == b.length) b = a.hexToRgb(b), b.a = 1, a.set({color: b, hex: a.rgbToHex(b), hsb: a.rgbToHsb(b)}), c.each(b, function (a, b) { 207 c('input[name\x3d"colorpicker-' + a + '"]').val(b) 208 }), a.inputSetColor() 209 }); 210 c(".colorpicker-lately").on("click", function () {
211 var b = c(this).data("color"), d = b.split(","), e = {r: parseInt(d[0]), g: parseInt(d[1]), b: parseInt(d[2])}, b = e; 212 b.a = d["3"] || 1; 213 d = a.rgbToHex(e); 214 a.callBack(a.eve, {hex: d, rgba: b.r + "," + b.g + "," + b.b + "," + b.a, rgb: b.r + "," + b.g + "," + b.b}); 215 c("#colorpicker-screen").remove() 216 }); 217 c("#colorpicker-ok").on("click", function () { 218 a.callFun(); 219 var b = a.options.color; 220 if (f.localStorage) { 221 var d = f.localStorage, e = d.getItem("colorpicker-lately"), e = e.split("-"); 222 e.shift(); 223 e.push(b.r + "," + b.g + "," + b.b + "," + b.a); 224 d.setItem("colorpicker-lately", e.join("-")) 225 } 226 c("#colorpicker-screen").remove() 227 }); 228 c("#colorpicker-clear").on("click", function () { 229 a.callFunClear(); 230 c("#colorpicker-screen").remove() 231 }) 232 } 233 }; 234 c.fn.extend({ 235 colorpicker: function (a, b, s) { 236 this.each(function (d, e) { 237 c(this).off().on("click", function () { 238 var c = new g(this, a); 239 c.init(); 240 c.callBack = b; 241 c.callClear = s; 242 }); 243 return this 244 }) 245 } 246 }) 247})(jQuery, window, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.