forked from openannotation/annotator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.html
171 lines (148 loc) · 6.13 KB
/
dev.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JS annotation test</title>
<script src="lib/vendor/jquery.js"></script><!-- dynamically provided -->
<!--[if lt IE 9]>
<script src="lib/vendor/json2.js"></script>
<![endif]-->
<script src="/lib/vendor/wgxpath.install.js"></script>
<script src="lib/annotator.js"></script>
<script src="lib/plugin/store.js"></script>
<script src="lib/plugin/permissions.js"></script>
<script src="lib/plugin/auth.js"></script>
<script src="lib/plugin/tags.js"></script>
<script src="lib/plugin/unsupported.js"></script>
<script src="lib/plugin/filter.js"></script>
<link rel="stylesheet" type="text/css" href="css/annotator.css">
<style>
/* This is evil but people do it. This checks that we correctly
calculate the position of the adder and other UI elements in any
situation. */
body {
position: relative;
margin-top: 3em;
}
#absolute {
border: 1px solid #eee;
background: rgba(255, 255, 255, 0.9);
padding: 1em;
margin: 0;
position: absolute;
top: 1em;
right: 1em;
width: 20em;
}
#fixed {
border: 1px solid #eee;
background: rgba(255, 255, 255, 0.9);
padding: 1em;
margin: 0;
position: fixed;
bottom: 1em;
right: 1em;
width: 20em;
}
</style>
</head>
<body>
<header>
<h1>Javascript annotation service test</h1>
</header>
<div id="airlock">
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
<h2>Header Level 2</h2>
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ol>
<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>
<p id='absolute'>Here's an interesting one. This is absolutely positioned content. If we can't get the adder positioning right on this one then we're screwed.</p>
<p id='fixed'>And the same but with <code>position: fixed;</code> Make the window smaller and scroll to make sure that adder/viewer/editor positioning is still correct.</p>
<h3>Header Level 3</h3>
<ul>
<li id="listone">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li id="listtwo">Aliquam tincidunt mauris eu risus.</li>
</ul>
<pre><code>
#header h1 a {
display: block;
width: 300px;
height: 80px;
}
</code></pre>
<table>
<thead>
<tr>
<td>Heading One</td>
<td>Heading Two</td>
<td>Heading Three</td>
</tr>
</thead>
<tbody>
<tr>
<th>Side One</th>
<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</td>
<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</td>
</tr>
<tr>
<th>Side Two</th>
<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</td>
<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</td>
</tr>
<tr>
<th>Side Three</th>
<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</td>
<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</td>
</tr>
<tr>
<th>Side Four</th>
<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</td>
<td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</td>
</tr>
</tbody>
</table>
</div>
<script>
var devAnnotator;
var $ = require('jquery');
var Annotator = require('annotator');
var elem = document.getElementById('airlock');
var Adder = Annotator.Plugin.fetch('Adder');
var TextSelector = Annotator.Plugin.fetch('TextSelector');
var LegacyRanges = Annotator.Plugin.fetch('LegacyRanges');
var Editor = Annotator.Plugin.fetch('Editor');
var Highlighter = Annotator.Plugin.fetch('Highlighter');
var Viewer = Annotator.Plugin.fetch('Viewer');
var Store = Annotator.Plugin.fetch('Store');
var Auth = Annotator.Plugin.fetch('Auth');
var Unsupported = Annotator.Plugin.fetch('Unsupported');
var Permissions = Annotator.Plugin.fetch('Permissions');
var factory = new Annotator.Factory();
var devAnnotator = factory
.addPlugin(Adder)
.addPlugin(TextSelector, elem)
.addPlugin(LegacyRanges, elem)
.addPlugin(Highlighter, elem)
.addPlugin(Viewer, {
showEditButton: true,
showDeleteButton: true,
})
.addPlugin(Editor)
.setStore(Store, {prefix: 'http://localhost:5000'})
.addPlugin(Auth, {tokenUrl: 'http://localhost:4000/api/token'})
.addPlugin(Permissions)
.addPlugin(Unsupported)
.getInstance();
devAnnotator.subscribe('beforeAnnotationCreated', function (annotation) {
annotation.uri = window.location.href;
})
devAnnotator.attach(elem);
devAnnotator.annotations.load({uri: window.location.href});
devAnnotator.on("all", function () {
console.log("Annotator event:", arguments);
});
</script>
</body>
</html>