forked from claviska/jquery-minicolors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
149 lines (114 loc) · 4.39 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery miniColors</title>
<style type="text/css">
BODY {
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
line-height: 1.5;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.miniColors.js"></script>
<link type="text/css" rel="stylesheet" href="jquery.miniColors.css" />
<script type="text/javascript">
$(document).ready( function() {
//
// Enabling miniColors
//
$(".color-picker").miniColors({
letterCase: 'uppercase',
change: function(hex, rgb) {
logData(hex, rgb);
}
});
//
// Only for the demo
//
function logData(hex, rgb) {
$("#console").prepend('HEX: ' + hex + ' (RGB: ' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')<br />');
}
$("#disable").click( function() {
$("#console").prepend('disable<br />');
$(".color-picker").miniColors('disabled', true);
$("#disable").prop('disabled', true);
$("#enable").prop('disabled', false);
});
$("#enable").click( function() {
$("#console").prepend('enable<br />');
$(".color-picker").miniColors('disabled', false);
$("#disable").prop('disabled', false);
$("#enable").prop('disabled', true);
});
$("#makeReadonly").click( function() {
$("#console").prepend('readonly = true<br />');
$(".color-picker").miniColors('readonly', true);
$("#unmakeReadonly").prop('disabled', false);
$("#makeReadonly").prop('disabled', true);
});
$("#unmakeReadonly").click( function() {
$("#console").prepend('readonly = false<br />');
$(".color-picker").miniColors('readonly', false);
$("#unmakeReadonly").prop('disabled', true);
$("#makeReadonly").prop('disabled', false);
});
$("#destroy").click( function() {
$("#console").prepend('destroy<br />');
$(".color-picker").miniColors('destroy');
$("INPUT[type=button]:not(#create)").prop('disabled', true);
$("#destroy").prop('disabled', true);
$("#create").prop('disabled', false);
});
$("#create").click( function() {
$("#console").prepend('create<br />');
$(".color-picker").miniColors({
letterCase: 'uppercase',
change: function(hex, rgb) {
logData(hex, rgb);
}
});
$("#makeReadonly, #disable, #destroy, #randomize").prop('disabled', false);
$("#destroy").prop('disabled', false);
$("#create").prop('disabled', true);
});
$("#randomize").click( function() {
$(".color-picker").miniColors('value', '#' + Math.floor(Math.random() * 16777215).toString(16));
});
});
</script>
</head>
<body>
<h1>jQuery miniColors</h1>
<p>
A miniature color selector for input elements.
</p>
<div id="console" style="width: 500px; float: right; color: #FFF; background: #000; font: 12px monospace; padding: 1em; margin: 1em 0; height: 350px; overflow: auto;"></div>
<p>
Default<br /><input type="text" name="color1" class="color-picker" size="6" autocomplete="on" maxlength="10" />
</p>
<p>
Black theme (set class="black" on the input element)<br />
<input type="text" name="color2" class="color-picker black" size="6" />
</p>
<p>
Preset value (set value attribute on the input element)<br />
<input type="text" name="color3" class="color-picker" size="6" value="#abCdeF" />
</p>
<p>
Attached to a hidden input<br />
<input type="hidden" name="color4" class="color-picker" size="6" />
</p>
<p style="margin-top: 50px;">
Select an action to apply to all of the controls on this page:
<br />
<input type="button" id="makeReadonly" value="Read-only" />
<input type="button" id="unmakeReadonly" value="Not Read-only" disabled="disabled" /><br />
<input type="button" id="disable" value="Disable" />
<input type="button" id="enable" value="Enable" disabled="disabled" /><br />
<input type="button" id="destroy" value="Destroy" />
<input type="button" id="create" value="Create" disabled="disabled" /><br />
<input type="button" id="randomize" value="Random Color" />
</p>
</body>
</html>