forked from iamdanfox/anno.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
341 lines (275 loc) · 11.2 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!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;
}
.hljs-keyword{
color:#008;
}
</style>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<link href="dist/anno.css" rel="stylesheet" type="text/css" />
<script src="dist/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>
<p style="margin-top:20px">Better step-by-step guides for powerful web apps.</p>
<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-2"></div>
<div class="col-md-8">
<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-primary" onclick="demoBtnClick();anno1.show()">anno1.show()</button></p>
<h2 id="slightly-more">Size & Positioning</h2>
<script type="text/javascript">
var anno2 = new Anno([{
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 <code>top</code> and <code>left</code> values.'
}])
</script>
<p><button type="button" class="btn btn-primary" onclick="demoBtnClick();anno2.show()">anno2.show()</button>
<button type="button" class="btn btn-primary" onclick="demoBtnClick();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 : "Anno buttons are completely customizable; you can even have none!",
buttons : []
})
</script>
<p><button type="button" class="btn btn-primary" onclick="demoBtnClick();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-primary" onclick="demoBtnClick();anno4.show()">anno4.show()</button></p>
<script type="text/javascript">
var anno5 = new Anno([{
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-primary" onclick="demoBtnClick();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-primary" onclick="demoBtnClick();anno6.show()">anno6.show()</button></p>
<h2>Bootstrap Modals</h2>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
I am a modal.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var anno7 = new Anno({
target: '#myModal .modal-content',
content: "Because Anno is very flexible, you can make it work with all sorts of other libraries, e.g. Bootstrap",
position: { top:'auto', left:'145px' },
showOverlay: function(){}, // the modal already has one, so disable the anno.js one
buttons: {
text:'Done',
click: function(){ $('#myModal').modal('hide') }
}
})
</script>
<script type="text/javascript">
// link the anno object to the modal
$('#myModal').on('shown.bs.modal', function(){
anno7.show()
}).on('hide.bs.modal', function(){
anno7.hide()
})
</script>
<!-- Button trigger modal -->
<p><button class="btn btn-primary" id="modalbutton" onclick="demoBtnClick();$('#myModal').modal('show')">$('#myModal').modal('show')</button></p>
<h2 id="scrolling-inside-divs">Scrolling inside divs</h2>
<div style="border:1px solid #aaa;overflow-y:scroll;border-radius:4px;margin:10px 0;">
<div style="height:240px;width:170%;position:relative;">
<div style="background:#ccc;height:70px;width:70px;position:absolute;left:20px;top:40px;text-align:center;line-height:70px;" id="box1"><code>#box1</code></div>
<div style="background:#bbb;height:70px;width:70px;position:absolute;right:20px;top:40px;text-align:center;line-height:70px;" id="box2"><code>#box2</code></div>
<div style="width:400px;margin:10px auto;">
This is a scrollable div, with <code>overflow-y:scroll</code>. Lorem ipsum dolor
sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
</div>
<script type="text/javascript">
var anno8 = new Anno([{
target: '#box1',
position: 'center-right',
content: "Guide your users through nested scrolling panels..."
},{
target: '#box2',
position:'center-left',
content: "...without confusing them.",
buttons: [AnnoButton.BackButton, AnnoButton.DoneButton]
}])
</script>
<p><button class="btn btn-primary" id="modalbutton" onclick="demoBtnClick();anno8.show()">anno8.show()</button></p>
<h2 id="unclickable-target">Unclickable target</h2>
<div style="border:1px solid #aaa;overflow-y:scroll;border-radius:4px;margin:10px 0;padding:20px;" id="region9">
<p><button class="btn btn-default" id="button1" onclick="$(this).next('span').stop().fadeIn(100).fadeOut(1500)">#button1</button>
<span style="background:#dff0d8;padding:8px 10px;display:none;"><code>#button1</code> clicked!</span></p>
<p><button class="btn btn-default" id="button2" onclick="$(this).next('span').stop().fadeIn(100).fadeOut(1500)">#button2</button>
<span style="background:#dff0d8;padding:8px 10px;display:none;"><code>#button2</code> clicked!</span></p>
</div>
<script type="text/javascript">
var anno9 = new Anno({
target: '#region9',
content: "<code>#button1</code> is disabled, but <code>#button2</code> still works.",
className: 'anno-width-400',
onShow: function (anno, $target, $annoElem) {
var handler = function(e){
if(e.target.id === 'button1') e.stopPropagation() // filters out #button1
}
$target[0].addEventListener('click', handler, true) // `true` is essential
return handler
},
onHide: function(anno, $target, $annoElem, handler) {
$target[0].removeEventListener('click', handler, true)
}
})
</script>
<p><button class="btn btn-primary" id="modalbutton" onclick="demoBtnClick();anno9.show()">anno9.show()</button></p>
</div>
<div class="col-md-2"></div>
</div>
<div class="jumbotron" style="margin:40px 0 0 0;">
<p class="text-center">Keen to try it yourself? See <a href="https://github.com/iamdanfox/anno.js#usage">usage</a>.</p>
<p class="text-center" style="opacity:0.7;">Read <a href="docco/anno.html">the literate coffeescript source</a>.</p>
<p class="text-center" style="opacity:0.7;">made by <a href="http://twitter.com/iamdanfox">@iamdanfox</a></p>
</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 type="text/javascript">
$(function(){
hljs.configure({languages:['js']})
$('.container script:not(.invisible)').each(function(i,item){
$pre = $('<pre>'+item.innerHTML.replace(/>/g,'>').replace(/</g,'<')+'</pre>')
hljs.highlightBlock($pre[0])
$(item).after($pre)
})
$('.btn-primary').click(function(){
$(this).addClass('btn-default').removeClass('btn-primary')
})
})
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-48159148-1', 'iamdanfox.github.io');
ga('send', 'pageview');
var demoBtnClicks = 0;
function demoBtnClick(){
demoBtnClicks++
ga('set', 'DemoBtnClicks', demoBtnClicks)
return true
}
</script>
</body>
</html>