/
index.html
312 lines (275 loc) · 10.1 KB
/
index.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>jQuery Colorpicker</title>
<!-- jQuery/jQueryUI (hosted) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
<style>
body {
font-family: 'Segoe UI', Verdana, Arial, Helvetica, sans-serif;
font-size: 62.5%;
}
</style>
<script src="jquery.colorpicker.js"></script>
<link href="jquery.colorpicker.css" rel="stylesheet" type="text/css"/>
<script src="i18n/jquery.ui.colorpicker-nl.js"></script>
<script src="swatches/jquery.ui.colorpicker-pantone.js"></script>
<script src="parts/jquery.ui.colorpicker-rgbslider.js"></script>
<script src="parts/jquery.ui.colorpicker-memory.js"></script>
<script>
$(function() {
$('#tabs').tabs();
});
</script>
</head>
<body>
<h1>jQuery ColorPicker</h1>
<div id="tabs">
<ul>
<li><a href="#tab-input">Basic <input></a></li>
<li><a href="#tab-element">Basic element</a></li>
<li><a href="#tab-full">All features</a></li>
<li><a href="#tab-i18n">Localization</a></li>
<li><a href="#tab-websafe">Websafe colors</a></li>
<li><a href="#tab-alt">Alternative display field</a></li>
<li><a href="#tab-events">Events</a></li>
<li><a href="#tab-input-format">Input formatting</a></li>
<li><a href="#tab-format">Output formatting</a></li>
<li><a href="#tab-format-list">Output format list</a></li>
<li><a href="#tab-dialog">In a dialog</a></li>
<li><a href="#tab-modal">Modal</a></li>
<li><a href="#tab-no-inline">Any element to popup</a></li>
<li><a href="#tab-layout">Custom layout</a></li>
<li><a href="#tab-pantone">Custom swatches</a></li>
<li><a href="#tab-hidden-input">Hidden input</a></li>
<li><a href="#tab-plugins">Plugins</a></li>
</ul>
<div id="tab-input">
<h2>Basic <input> example, without any options</h2>
<input type="text" class="cp-basic" value="fe9810"/>
</div>
<div id="tab-element">
<h2>Basic element (<span>> example, without any options</h2>
<span class="cp-basic" style="display: inline-block; vertical-align: top;"></span>
</div>
<div id="tab-full">
<h2>Fully-featured example</h2>
<input type="text" class="cp-full" value="186aa7"/>
</div>
<div id="tab-i18n">
<h2>Localized to Dutch (nl)</h2>
<input type="text" class="cp-i18n" value="ccea73"/>
</div>
<div id="tab-websafe">
<h2>Limit to websafe colors</h2>
<input type="text" class="cp-websafe" value="0fa7c2"/>
</div>
<div id="tab-alt">
<h2>Alternative field class</h2>
<input type="text" class="cp-alt" value="b762ae"/>
<span class="cp-alt-target" style="display: inline-block; border: thin solid black; padding: .5em 4em;">
<div style=" background-color: white; border: thin solid black; padding: .25em 2em; font-size: 1.25em; font-weight: bold;">Background-color on outside, text color here</div>
</span>
</div>
<div id="tab-events">
<h2>Events</h2>
<input type="text" class="cp-events" value="92b64a"/>
<div class="cp-events-log" style="vertical-align: top; display: inline-block; border: thin solid black; height: 10em; overflow-y: scroll; width: 50em;"></div>
</div>
<div id="tab-format">
<h2>Output formatting HSLA</h2>
<input type="text" class="cp-format" value="918237"/>
<span class="cp-format-output"></span>
</div>
<div id="tab-format-list">
<h2>Output format list</h2>
You can specify a list of output formats, the first perfect match for the color is output.<br/>
<input type="text" class="cp-name" value="a92fb4"/>
<span class="cp-name-output"></span>
</div>
<div id="tab-dialog">
<h2>Dialog with Colorpicker popup (demonstrates z-index)</h2>
<button id="cp-dialog-open">Open dialog</button>
<div id="cp-dialog-modal" title="Basic modal dialog">
Basic <input> example, without any options: <input type="text" class="cp-basic" value="fe9810"/>
<br/>
Basic element example, without any options: <span class="cp-basic" style="display: inline-block; vertical-align: top;"></span>
</div>
</div>
<div id="tab-modal">
<h2>Modal (and showCancelButton, closeOnEscape, showCloseButton)</h2>
<input type="text" class="cp-modal" value="9ba73f"/>
</div>
<div id="tab-input-format">
<h2>Input formatting</h2>
Demonstrates the ability to parse common color formats as input.<br/>
<input type="text" class="cp-input" value="rgb(123,42,87)"/>
</div>
<div id="tab-no-inline">
<h2>Popup from any element (<em>)</h2>
Just click on this <em>Emphasized</em> word to show the colorpicker.
</div>
<div id="tab-layout">
<h2>Custom layout</h2>
It's easy to arrange a new layout for the dialog. Especially handy when used in a sidebar.<br/>
<input type="text" class="cp-layout" value="92b7a5"/>
</div>
<div id="tab-pantone">
<h2>Custom swatches</h2>
Use the Pantone PMS colors as swatches<br/>
<input type="text" class="cp-pantone" value="242"/>
<span class="cp-pantone-output"></span>
</div>
<div id="tab-hidden-input">
<h2>Hidden input</h2>
Uses a hidden input and buttons to pop open the colorpicker<br/>
<input type="hidden" class="cp-hidden-input" value="#abc123"/>
<button id="cp-hidden-input-open">Open</button>
</div>
<div id="tab-plugins">
<h2>Plugins</h2>
Demonstrates how to extend the set of parts with plugins.<br/>
<ol>
<li>RGB Slider - Individual RGB sliders</li>
<li>Memory - store and retrieve colors with cookies</li>
</ol>
<input type="text" class="cp-plugins" value="#18b7af"/>
</div>
</div>
<script>
$( function() {
$('.cp-basic').colorpicker();
$('.cp-full').colorpicker({
parts: 'full',
showOn: 'both',
buttonColorize: true,
showNoneButton: true,
alpha: true
});
$('.cp-i18n').colorpicker({
regional: 'nl',
showNoneButton: true,
alpha: true
});
$('.cp-websafe').colorpicker({
limit: 'websafe'
});
$('.cp-alt').colorpicker({
altField: '.cp-alt-target',
altProperties: 'background-color,color',
altAlpha: true,
alpha: true
});
{ // event log
var count = 0;
function addToEventLog(label, message) {
var line = '<div>#'+(++count)+' '+label+': '+message+'</div>';
var log = $('.cp-events-log');
log.append(line).scrollTop(log[0].scrollHeight);
}
$('.cp-events').colorpicker({
init: function(event, color) {
addToEventLog('Init', color.formatted);
},
select: function(event, color) {
addToEventLog('Select', color.formatted);
},
close: function(event, color) {
addToEventLog('Close', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
}
});
}
$('.cp-format').colorpicker({
colorFormat: 'HSLA',
alpha: true,
init: function(event, color) {
$('.cp-format-output').text(color.formatted);
},
select: function(event, color) {
$('.cp-format-output').text(color.formatted);
}
});
$('.cp-name').colorpicker({
parts: 'full',
colorFormat: ['EXACT', '#HEX3', 'RGB', 'RGBA'],
init: function(event, color) {
$('.cp-name-output').text(color.formatted);
},
select: function(event, color) {
$('.cp-name-output').text(color.formatted);
}
});
var dialogModal = $('#cp-dialog-modal').dialog({
autoOpen: false,
minWidth: 500,
modal: true,
buttons: { 'Close': function() {
$(this).dialog('close');
}
}
});
$('#cp-dialog-open').click(function() {
dialogModal.dialog('open');
});
$('.cp-modal').colorpicker({
parts: 'draggable',
showCloseButton: false,
modal: true,
showCancelButton: false,
closeOnEscape: false
});
$('.cp-input').colorpicker({
colorFormat: ['RGBA']
});
$('em').colorpicker({
inline: false
});
$('.cp-layout').colorpicker({
parts: ['header', 'map', 'bar', 'hex', 'hsv', 'rgb', 'alpha', 'preview', 'swatches', 'footer'],
alpha: true,
layout: {
hex: [0, 0, 2, 1],
preview: [2, 0, 1, 1],
map: [0, 1, 3, 1], // Left, Top, Width, Height (in table cells).
bar: [0, 2, 1, 4],
swatches: [2, 2, 1, 4],
rgb: [1, 2, 1, 1],
hsv: [1, 3, 1, 1],
alpha: [1, 4, 1, 1],
lab: [0, 5, 1, 1],
cmyk: [1, 5, 1, 2]
}
});
$('.cp-pantone').colorpicker({
parts: 'full',
swatches: 'pantone',
colorFormat: 'NAME',
swatchesWidth: 173,
limit: 'name',
init: function(event, color) {
$('.cp-pantone-output').text(color.formatted);
},
select: function(event, color) {
$('.cp-pantone-output').text(color.formatted);
}
});
var dialogHidden = $('.cp-hidden-input').colorpicker();
$('#cp-hidden-input-open').click(function(e) {
e.stopPropagation();
dialogHidden.colorpicker('open');
});
$('.cp-plugins').colorpicker({
parts: ['header', 'preview', 'hex', 'rgbslider', 'memory', 'footer'],
layout: {
preview: [0, 0, 1, 1],
hex: [1, 0, 1, 1],
rgbslider: [0, 1, 2, 1],
memory: [0, 2, 2, 1]
}
});
});
</script>
</body>
</html>