-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.js
68 lines (50 loc) · 1.13 KB
/
button.js
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
var element;
function init()
{
state = "enabled";
element = document.getElementById("canvas");
element.addEventListener("mousedown", mousedown, false);
}
function mousedown(evt)
{
evt.preventDefault();
mousedownCallback();
if(state == "enabled") {
element.viewBox.baseVal.y = 30;
document.addEventListener("mousemove", mousemove, true);
document.addEventListener("mouseup", mouseup, true);
}
}
function mouseup(evt)
{
evt.preventDefault();
mouseupCallback();
element.viewBox.baseVal.y = 0;
document.removeEventListener("mousemove", mousemove, true);
document.removeEventListener("mouseup", mouseup, true);
}
function mousemove(evt)
{
evt.preventDefault();
mousemoveCallback();
}
function setText(text)
{
document.getElementById("active_text").textContent = text;
document.getElementById("press_text").textContent = text;
document.getElementById("disabled_text").textContent = text;
}
function getText()
{
return document.getElementById("active_text").textContent;
}
function disable()
{
state = "disabled";
element.viewBox.baseVal.y = 60;
}
function enable()
{
state = "enabled";
element.viewBox.baseVal.y = 0;
}