-
Notifications
You must be signed in to change notification settings - Fork 72
/
jscolor-examples.html
162 lines (94 loc) · 3.84 KB
/
jscolor-examples.html
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="en">
<head>
<title>jscolor Examples</title>
<style>
body { padding: 30px 60px 30px; }
h2, footer { margin: 200px 0 20px; }
footer h2 { margin: 30px 0 15px; }
</style>
</head>
<body>
<h1>Examples of <a href="https://jscolor.com/" target="_blank">jscolor</a> usage</h1>
<script src="jscolor.js"></script>
<script>
// Here we can adjust defaults for all color pickers on page:
jscolor.presets.default = {
palette: [
'#000000', '#7d7d7d', '#870014', '#ec1c23', '#ff7e26', '#fef100', '#22b14b', '#00a1e7', '#3f47cc', '#a349a4',
'#ffffff', '#c3c3c3', '#b87957', '#feaec9', '#ffc80d', '#eee3af', '#b5e61d', '#99d9ea', '#7092be', '#c8bfe7',
],
//paletteCols: 12,
//hideOnPaletteClick: true,
//width: 271,
//height: 151,
//position: 'right',
//previewPosition: 'right',
//backgroundColor: 'rgba(51,51,51,1)', controlBorderColor: 'rgba(153,153,153,1)', buttonColor: 'rgba(240,240,240,1)',
}
</script>
<h2>Example 1 - HEX</h2>
Color: <input value="3399FF" data-jscolor="{}">
<h2>Example 2 - HEX with Alpha</h2>
Color: <input value="3399FF80" data-jscolor="{}">
<h2>Example 3 - RGBA</h2>
Color: <input value="rgba(51,153,255,0.5)" data-jscolor="{}">
<h2>Example 4 - Button</h2>
Color: <button data-jscolor="{valueElement:'#val4', alphaElement:'#alp4'}"></button>
Value: <input id="val4" value="#3399FF80">
Alpha: <input id="alp4">
<h2>Example 5 - Events: onChange and onInput</h2>
<p>
You can specify onChange/onInput event handler using jscolor's options:
<button data-jscolor="{
onChange: 'update(this, \'#pr1\')',
onInput: 'update(this, \'#pr2\')',
alpha:0.7, value:'CCFFAA'}"></button>
</p>
<em id="pr1" style="display:inline-block; padding:1em;">change event</em>
<em id="pr2" style="display:inline-block; padding:1em;">input event</em>
<p>
For text INPUTS, you can keep with classic HTML attributes:
<input onChange="update(this.jscolor, '#pr3')" onInput="update(this.jscolor, '#pr4')" value="CCFFAA" data-jscolor="{alpha:0.7}">
</p>
<em id="pr3" style="display:inline-block; padding:1em;">change event</em>
<em id="pr4" style="display:inline-block; padding:1em;">input event</em>
<script>
function update(picker, selector) {
document.querySelector(selector).style.background = picker.toBackground()
}
// triggers 'onInput' and 'onChange' on all color pickers when they are ready
jscolor.trigger('input change');
</script>
<h2>Example 6 - Presets</h2>
<p>
Small dark preset:
<input value="FFA000" data-jscolor="{preset:'small dark', position:'right'}">
</p>
<p>
Large preset:
<input value="rgba(255,160,0,0.5)" data-jscolor="{preset:'large', position:'right'}">
</p>
<h2>Example 7 - Customized picker</h2>
<input value="rgba(255,160,0,1.0)" data-jscolor="{
position: 'right', width: 181, height: 121,
palette: '#fff #fcd #fdc #ffc #dfc #dff #cdf #dcf #ccc', paletteCols: 9, paletteHeight: 25,
padding: 10, sliderSize: 25, borderRadius: 5,
borderWidth: 0, controlBorderWidth: 1, pointerBorderWidth: 2,
borderColor: '#000', controlBorderColor: '#AAA', backgroundColor: '#F3F3F3', shadowColor: 'rgba(0,0,0,.4)',
closeButton: true, closeText: 'OK', buttonColor: '#333',
}">
<footer>
<h2>Links</h2>
<ul>
<li><a href="https://jscolor.com/examples/" target="_blank">More examples</a></li>
<li><a href="https://jscolor.com/docs/" target="_blank">Documentation</a></li>
</ul>
<h2>License</h2>
<ul>
<li><a href="http://www.gnu.org/licenses/gpl-3.0.txt" target="_blank">GNU GPL v3</a> for open source use</li>
<li><a href="https://jscolor.com/download/#licenses" target="_blank">Commercial license</a> for commercial use</li>
</ul>
</footer>
</body>
</html>