forked from daattali/jquery-colourpicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
141 lines (126 loc) · 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link href="css/colourpicker.css" rel="stylesheet">
<style>
body {
padding: 30px;
}
.colourpicker {
margin-top: 3px;
margin-bottom: 20px;
width: 300px;
}
</style>
</head>
<body>
<div>
Default settings
<br> Value: <span></span>
<input type="text" id="col1" class="form-control my-cp">
</div>
<div>
{showColour: background, closeOnClick: true}
<br> Value: <span></span>
<input type="text" id="col2" class="form-control my-cp" value="#ff0000">
</div>
<div>
{allowTransparent: true}
<Br> Value: <span></span>
<input type="text" id="col3" class="form-control my-cp" value="#abc123">
</div>
<div>
{palette: "limited", returnName: true}
<br> Value: <span></span>
<input type="text" id="col4" class="form-control my-cp">
</div>
<div>
{allowAlpha: true, showColour: "text"}
<Br> Value: <span></span>
<input type="text" id="col5" class="form-control my-cp">
</div>
<div>
{allowAlpha: true, showColour: "both"}
<Br> Value: <span></span>
<input type="text" id="col6" class="form-control my-cp">
</div>
<div>
{palette: "limited", allowAlpha: true, returnName: true, <br>
allowedCols: ["transparent", "red", "green", "blue", "yellow"], <br>
closeOnClick: true}
<br> Value: <span></span>
<input type="text" id="col7" class="form-control my-cp" value="#ff0000">
</div>
<div>
{palette: "limited", allowAlpha: false, returnName: true, <br>
allowedCols: ["transparent", "red", "green", "blue", "yellow","#12323480", "rgba(132, 167, 23, .7)"]}
<br> Value: <span></span>
<input type="text" id="col8" class="form-control my-cp" value="#abc123">
</div>
<div>
{allowAlpha: true, showColour: "background", allowTransparent: true, returnName: true}
<br> Value: <span></span>
<input type="text" id="col9" class="form-control my-cp">
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="js/colourpicker.js"></script>
<script>
$("#col1").colourpicker();
$("#col2").colourpicker({
showColour: "background",
closeOnClick: true
});
$("#col3").colourpicker({
allowTransparent: true,
returnName: true
});
$("#col4").colourpicker({
palette: "limited",
returnName: true
});
$("#col5").colourpicker({
allowAlpha: true,
showColour: "text"
});
$("#col6").colourpicker({
allowAlpha: true,
showColour: "both"
});
$('#col7').colourpicker({
palette: "limited",
allowAlpha: true,
returnName: true,
allowedCols: ["transparent", "red", "green", "blue", "yellow"],
closeOnClick: true
});
$('#col8').colourpicker({
palette: "limited",
allowAlpha: false,
returnName: true,
allowedCols: ["transparent", "red", "green", "blue", "yellow", "#12323480", "rgba(132, 167, 23, .7)"]
});
$("#col9").colourpicker({
allowAlpha: true,
showColour: "background",
allowTransparent: true,
returnName: true
});
$.each($(".my-cp"), function(i, el) {
var value = $(el).colourpicker('value');
$($(el).closest('.colourpicker').parent().find("span")[0]).text(value);
});
$(document).on("change", ".my-cp", function(e) {
var value = $(e.target).colourpicker('value');
$($(e.target).closest('.colourpicker').parent().find("span")[0]).text(value);
});
</script>
</body>
</html>