-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
54 lines (48 loc) · 1.48 KB
/
index.html
File metadata and controls
54 lines (48 loc) · 1.48 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Simple Color Picker</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
<script src="js/colorPicker.js"></script>
<link rel="stylesheet" type="text/css" href="styles/colorPicker.css">
<style>
.myColor {
position: absolute;
left: 50px;
top: 150px;
width: 50px;
height: 50px;
background-color: lightgray;
}
.second.myColor {
left: auto;
right: 100px;
top: 250px;
background-color: darkgreen;
}
</style>
<script>
$(function() {
colorPicker = new ColorPicker();
$('.myColor').on(MOBILE?'touchstart':'mousedown', clickTouch);
function clickTouch(e) {
e.stopPropagation();
currentElement = $(this);
colorPicker.show($(this), updateColor);
}
function updateColor(newColor) {
var newColorStr = 'hsla(' + newColor.get('h') + ',' + newColor.get('s') + '%,' + newColor.get('l') + '%,1)';
currentElement.css('background-color', newColorStr);
}
});
</script>
</head>
<body>
<h1>Simple color picker</h1>
<p>Touch / click any color to load the color picker, then use it to change the current color</p>
<div class="myColor"></div>
<div class="second myColor"></div>
</body>
</html>