forked from vanderlee/colorpicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
479 lines (434 loc) · 14.4 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- 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 src="parsers/jquery.ui.colorpicker-cmyk-parser.js"></script>
<script src="parsers/jquery.ui.colorpicker-cmyk-percentage-parser.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>
<li><a href="#tab-buttonImageOnly">buttonImageOnly</a></li>
<li><a href="#tab-revert">Revert</a></li>
<li><a href="#tab-okonenter">Close on enter</a></li>
</ul>
<div id="tab-input">
<h2>Basic <input> example, without any options</h2>
<input type="text" class="cp-basic" value="fe9810"/>
<script>
$(function() {
});
</script>
</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>
<script>
$(function() {
$('.cp-basic').colorpicker();
});
</script>
</div>
<div id="tab-full">
<h2>Fully-featured example</h2>
<input type="text" class="cp-full" value="186aa7"/>
<script>
$(function() {
$('.cp-full').colorpicker({
parts: 'full',
showOn: 'both',
buttonColorize: true,
showNoneButton: true,
alpha: true,
colorFormat: 'RGBA'
});
});
</script>
</div>
<div id="tab-i18n">
<h2>Localized to Dutch (nl)</h2>
<input type="text" class="cp-i18n" value="ccea73"/>
<script>
$(function() {
$('.cp-i18n').colorpicker({
regional: 'nl',
showNoneButton: true,
alpha: true
});
});
</script>
</div>
<div id="tab-websafe">
<h2>Limit to websafe colors</h2>
<input type="text" class="cp-websafe" value="0fa7c2"/>
<script>
$(function() {
$('.cp-websafe').colorpicker({
limit: 'websafe'
});
});
</script>
</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>
<script>
$(function() {
$('.cp-alt').colorpicker({
altField: '.cp-alt-target',
altProperties: 'background-color,color',
altAlpha: true,
alpha: true
});
});
</script>
</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>
<script>
$(function() {
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);
},
ok: function(event, color) {
addToEventLog('Ok', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
},
open: function(event, color) {
addToEventLog('Open', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
},
cancel: function(event, color) {
addToEventLog('Cancel', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
}
});
});
</script>
</div>
<div id="tab-format">
<h2>Output formatting HSLA</h2>
<input type="text" class="cp-format" value="918237"/>
<span class="cp-format-output"></span>
<script>
$(function() {
$('.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);
}
});
});
</script>
</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>
<script>
$(function() {
$('.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);
}
});
});
</script>
</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-onclick" value="fe9810"/>
<br/>
Basic element example, without any options: <span class="cp-onclick" style="display: inline-block; vertical-align: top;"></span>
</div>
<script>
$(function() {
var dialogModal = $('#cp-dialog-modal').dialog({
autoOpen: false,
minWidth: 500,
modal: true,
buttons: { 'Close': function() {
$(this).dialog('close');
}
}
});
$('.cp-onclick').colorpicker({
showOn: 'click',
inlineFrame: false
});
$('#cp-dialog-open').click(function() {
dialogModal.dialog('open');
});
});
</script>
</div>
<div id="tab-modal">
<h2>Modal (and showCancelButton, closeOnEscape, showCloseButton)</h2>
<input type="text" class="cp-modal" value="9ba73f"/>
<script>
$(function() {
$('.cp-modal').colorpicker({
parts: 'draggable',
showCloseButton: false,
modal: true,
showCancelButton: false,
closeOnEscape: false
});
});
</script>
</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)"/>
<script>
$(function() {
$('.cp-input').colorpicker({
colorFormat: ['RGBA']
});
});
</script>
</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.
<script>
$(function() {
$('em').colorpicker({
inline: false
});
});
</script>
</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"/>
<script>
$(function() {
$('.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]
}
});
});
</script>
</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>
<script>
$(function() {
$('.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);
}
});
});
</script>
</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>
<script>
$(function() {
var dialogHidden = $('.cp-hidden-input').colorpicker();
$('#cp-hidden-input-open').click(function(e) {
e.stopPropagation();
dialogHidden.colorpicker('open');
});
});
</script>
</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"/>
<script>
$(function() {
$('.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>
</div>
<div id="tab-buttonImageOnly">
<h2>Only a button image</h2>
<input type="text" class="cp-buttonImageOnly" value="#18b7af"/>
<script>
$(function() {
$('.cp-buttonImageOnly').colorpicker({
showOn: 'both',
buttonImageOnly: true
});
});
</script>
</div>
<div id="tab-revert">
<h2>Revert color on non-button exit.</h2>
<p>Reverts the color on escape, clickOnOutside or close window
using the [X] button.</p>
<p>Open the Colorpicker, change color and click outside window,
press ESC key or click the [X] button in the header. The dialog
should now close and the previous color restored in the
input.</p>
<input type="text" class="cp-revert" value=""/>
<script>
$(function() {
$('.cp-revert').colorpicker({
revert: true,
parts: 'full',
showNoneButton: true
});
});
</script>
</div>
<div id="tab-okonenter">
<h2>Close OK on enter</h2>
Close the popup by pressing the enter key, keeping the selected color.
<input type="text" class="cp-okonenter" value="a83b19"/>
<script>
$(function() {
$('.cp-okonenter').colorpicker({
okOnEnter: true
});
});
</script>
</div>
</div>
<h2>A feature-packed colorpicker for jQuery and jQueryUI.</h2>
<ul>
<li>jQueryUI (themeroller-based) look & feel</li>
<li>Familiar interface layout</li>
<li>Highly configurable
<ul>
<li>Control parts</li>
<li>Layout</li>
<li>Input/output formats</li>
<li>Swatches</li>
<li>Many more…</li>
</ul>
</li>
<li>Accurate color model</li>
<li>Supports localization
<ul>
<li>English</li>
<li>Dutch</li>
<li>French</li>
<li>Brazilian Portuguese</li>
<li>easily translateable…</li>
</ul>
</li>
<li>Smart window alignment</li>
<li>Complete API with events and methods</li>
<li>Easily extendable with plugins
<ul>
<li>RGB-Sliders</li>
<li>Cookie memory</li>
</ul>
</li>
<li>Documented</li>
<li>Now with QUnit tests (<a href="test/">click here</a>)</li>
</ul>
</body>
</html>