forked from ArthurClemens/JavaScript-Undo-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
69 lines (62 loc) · 2.11 KB
/
demo.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Undo and Redo</title>
<script type="text/javascript" src="js/undomanager.js"></script>
<script type="text/javascript" src="js/circledrawer.js"></script>
<script>
window.onload = function() {
// with jquery this would be on documentready
var undoManager = new UndoManager();
var circleDrawer = new CircleDrawer('view');
circleDrawer.setUndoManager(undoManager);
var btnUndo = document.getElementById('btnUndo');
var btnRedo = document.getElementById('btnRedo');
var btnClear = document.getElementById('btnClear');
function updateUI() {
btnUndo.disabled = !undoManager.hasUndo();
btnRedo.disabled = !undoManager.hasRedo();
}
undoManager.setCallback(updateUI);
btnUndo.onclick = function() {
undoManager.undo();
updateUI();
}
btnRedo.onclick = function() {
undoManager.redo();
updateUI();
}
btnClear.onclick = function() {
undoManager.clear();
updateUI();
}
updateUI();
}
</script>
<style type="text/css" media="all">
body {
font-family:arial, sans-serif;
}
#view {
margin:.5em 0 .25em 0;
border:1px solid #ccc;
}
.comment {
color:#999;
font-size:small;
}
</style>
</head>
<body>
<div class="commands">
<button id="btnUndo" href="#">Undo</button>
<button id="btnRedo" href="#">Redo</button>
<button id="btnClear" href="#">Clear memory</button>
</div>
<div>
<canvas id="view" width="300" height="150"></canvas>
</div>
<span class="comment">Click on the area to create circles</span>
</body>
</html>