iColor-min.js
3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
本代码由素材家园收集并编辑整理;
尊重他人劳动成果;
转载请保留素材家园链接 - www.sucaijiayuan.com
*/
(function(a) {
a(function() {
a(document).bind("click", function() {
if ($iColor.is(":visible")) {
$iColor.fadeOut("fast")[0].tar = null
}
});
$iColor = a(
'<div id="iColorPicker"><table class="pickerTable"><thead></thead><tbody><tr><td colspan="16" id="colorPreview"></td></tr></tbody></table></div>')
.css( {
"display" : "none",
"position" : "absolute"
}).appendTo(a("body")).each(
function() {
var b = [], c = "", d = [ "f00", "ff0", "0f0",
"0ff", "00f", "f0f", "fff", "ebebeb",
"e1e1e1", "d7d7d7", "ccc", "c2c2c2",
"b7b7b7", "acacac", "a0a0a0", "959595",
"ee1d24", "fff100", "00a650", "00aeef",
"2f3192", "ed008c", "898989", "7d7d7d",
"707070", "626262", "555", "464646",
"363636", "262626", "111", "000", "f7977a",
"fbad82", "fdc68c", "fff799", "c6df9c",
"a4d49d", "81ca9d", "7bcdc9", "6ccff7",
"7ca6d8", "8293ca", "8881be", "a286bd",
"bc8cbf", "f49bc1", "f5999d", "f16c4d",
"f68e54", "fbaf5a", "fff467", "acd372",
"7dc473", "39b778", "16bcb4", "00bff3",
"438ccb", "5573b7", "5e5ca7", "855fa8",
"a763a9", "ef6ea8", "f16d7e", "ee1d24",
"f16522", "f7941d", "fff100", "8fc63d",
"37b44a", "00a650", "00a99e", "00aeef",
"0072bc", "0054a5", "2f3192", "652c91",
"91278f", "ed008c", "ee105a", "9d0a0f",
"a1410d", "a36209", "aba000", "588528",
"197b30", "007236", "00736a", "0076a4",
"004a80", "003370", "1d1363", "450e61",
"62055f", "9e005c", "9d0039", "790000",
"7b3000", "7c4900", "827a00", "3e6617",
"045f20", "005824", "005951", "005b7e",
"003562", "002056", "0c004b", "30004a",
"4b0048", "7a0045", "7a0026" ];
a.each(d, function(f, e) {
c += '<td style="background:#' + e + '" hx="'
+ e + '"></td>';
if (f % 16 == 15) {
b.push("<tr>" + c + "</tr>");
c = ""
}
});
a(this).find("thead").html(b.join(""))
}).bind(
{
"mouseover" : function(b) {
var c = a(b.target).attr("hx");
c != undefined
&& a("#colorPreview").css("background",
"#" + c).attr("hx", c)
},
"click" : function(b) {
var c = this.tar, d = a(b.target).attr("hx");
if (!d) {
b.stopPropagation();
return false
}
c.set.call(a(c).attr("hx", d), d)
},
"coord" : function(c) {
var b = a.extend( {
"x" : 0,
"y" : 0
}, c.num || null);
a(this).fadeIn("fast").css( {
"top" : c.posix.y + b.y,
"left" : c.posix.x + b.x
})
}
})
});
a.fn.iColor = function(b, d) {
var c = a.extend( {
"x" : 0,
"y" : 0,
"type" : "click",
"open" : function() {
},
"set" : function(f) {
var e = "#" + f;
this[!this.attr("type") ? "html" : "val"](e).css("background",
e)
}
}, b);
return this.each(function() {
var f = a(this), e = f.attr("hx");
this.set = d || (a.isFunction(b) ? b : c.set);
if (e) {
e = a.trim(e);
if (e[0] == "#") {
e = e.substring(1)
}
!this.set && console.log(this);
e.length
&& this.set
.call(f, e + [ "", "00", "0" ][e.length % 3])
}
})[c.type](function(h) {
var g = h.target, f = $iColor[0].tar || null;
if (f == g && g.show) {
return
}
g.show = true;
h.stopPropagation();
c.open.call(a(g), h);
$iColor.trigger( {
"type" : "coord",
"num" : d,
"posix" : {
"x" : h.pageX,
"y" : h.pageY
}
})[0].tar = g
})
}
})(jQuery);