forked from iamdanfox/anno.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
195 lines (158 loc) · 5.53 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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!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">
<title>Anno.js Demo 2</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style type="text/css">
h2 {
margin-top:40px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<link href="anno.css" rel="stylesheet" type="text/css" />
<script src="anno.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://yandex.st/highlightjs/8.0/styles/default.min.css">
</head>
<body>
<div class="jumbotron" style="text-align:center;">
<h1>anno.js</h1>
<iframe src="http://ghbtns.com/github-btn.html?user=iamdanfox&repo=anno.js&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
</div>
<div class="container">
<div class="col-md-8 col-md-offset-2">
<h2>Basic usage</h2>
<script type="text/javascript">
var anno1 = new Anno({
target : 'pre:first',
content: 'This is an annotation'
})
</script>
<p><button type="button" class="btn btn-default" onclick="anno1.show()">anno1.show()</button></p>
<h2 id="slightly-more">Size & Positioning</h2>
<script type="text/javascript">
var anno2 = Anno.chain([{
target: 'pre:eq(1)', // second block of code
position: 'top',
content: 'You can specify where you want each anno to appear.'
}, {
target: 'pre:eq(1)',
position: 'left',
content: "Use 'top', 'left', 'bottom' and 'right', just like CSS.",
}, {
target: 'pre:eq(1)',
position: 'center-bottom',
content: "You can also use 'center-bottom', 'center-right' etc"
}, {
target: 'pre:eq(1)',
position: 'right',
className: 'anno-width-200', // 150,175,200,250 (default 300)
content: 'Add CSS classes to customize each annotation.'
}, {
target: 'pre:eq(1)',
position: {
top: '44em',
left: '14em'
},
arrowPosition: 'center-left',
content: 'You can even specify precise top and left values.'
} ])
</script>
<p><button type="button" class="btn btn-default" onclick="anno2.show()">anno2.show()</button>
<button type="button" class="btn btn-default" onclick="anno2.chainIndex(3).show()">anno2.chainIndex(3).show()</button></p>
<h2 id="buttons">Buttons</h2>
<script type="text/javascript">
var anno3 = new Anno({
target: 'pre:eq(2)',
position: 'center-top',
content: "The buttons are completely customizable.",
buttons: []
})
</script>
<p><button type="button" class="btn btn-default" onclick="anno3.show()">anno3.show()</button></p>
<script type="text/javascript">
var anno4 = new Anno({
target: 'h2#buttons ~ p:eq(1) button:first',
position:'top',
content: "Anno.js provides defaults, but you can easily make your own:",
autoFocusLastButton:false,
buttons: [
{
text: 'Open HN',
click: function(anno, evt){
window.open('http://news.ycombinator.com/')
}
},{
text: 'Sweet',
className: 'anno-btn-low-importance',
click: function(anno, evt){
anno.hide()
}
}
]
})
</script>
<p><button type="button" class="btn btn-default" onclick="anno4.show()">anno4.show()</button></p>
<script type="text/javascript">
var anno5 = Anno.chain([{
target: 'pre:eq(4)',
position:'left',
content: "There are a few default buttons that you can use.",
buttons: [AnnoButton.NextButton]
}, {
target: 'pre:eq(4)',
position:'right',
content: "Try out the back button for example!",
buttons: [AnnoButton.BackButton]
}])
</script>
<p><button type="button" class="btn btn-default" onclick="anno5.show()">anno5.show()</button></p>
<h2>onShow, onHide</h2>
<script type="text/javascript">
var anno6 = new Anno({
target: 'pre:eq(5)',
content: "You can set up handlers for the just duration of the Anno. (Try clicking the code above)",
onShow: function (anno, $target, $annoElem) {
var handler = function(){ alert('Hello!'); }
$target[0].addEventListener('click', handler)
return handler
},
onHide: function(anno, $target, $annoElem, returnFromOnShow) {
var handler = returnFromOnShow
$target[0].removeEventListener('click', handler)
}
})
</script>
<p><button type="button" class="btn btn-default" onclick="anno6.show()">anno6.show()</button></p>
</div>
</div>
<div class="jumbotron" style="margin:40px 0 0 0;">
</div>
<script src="http://yandex.st/highlightjs/8.0/highlight.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="scrollintoview/jquery.scrollintoview.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('.container script').each(function(i,item){
$pre = $('<pre>'+item.innerHTML+'</pre>')
hljs.highlightBlock($pre[0])
$(item).after($pre)
})
$('#getstarted').click(function(){
anno1.show()
})
})
</script>
</body>
</html>