-
Notifications
You must be signed in to change notification settings - Fork 0
/
frank_lightning_talk_slides.html
1024 lines (848 loc) · 28.9 KB
/
frank_lightning_talk_slides.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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--
Copyright 2010 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Original slides: Marcin Wichary (mwichary@google.com)
Modifications: Ernest Delgado (ernestd@google.com)
Alex Russell (slightlyoff@chromium.org)
Brad Neuberg
-->
<html>
<head>
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<![endif]-->
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" />
<![endif]-->
<meta charset="utf-8" />
<title>Frank lightning talk</title>
<link href=' http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<meta name="author" content="Pete Hodgson" />
<style>
body {
font: 20px/1.6 "Lucida Grande", "Trebuchet MS", Verdana, sans-serif;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
position: absolute;
left: 0px; top: 0px;
}
.presentation {
position: absolute;
height: 100%;
width: 100%;
left: 0px;
top: 0px;
display: block;
overflow: hidden;
background: #778;
}
.slides {
width: 100%;
height: 100%;
left: 0;
top: 0;
position: absolute;
display: block;
-webkit-transition: -webkit-transform 1s ease-in-out;
-moz-transition: -moz-transform 1s ease-in-out;
-o-transition: -o-transform 1s ease-in-out;
transition: transform 1s ease-in-out;
/* so it's visible in the iframe. */
-webkit-transform: scale(0.8);
-moz-transform: scale(0.8);
-o-transform: scale(0.8);
transform: scale(0.8);
}
.slide {
display: none;
position: absolute;
overflow: hidden;
width: 900px;
height: 700px;
left: 50%;
top: 50%;
margin-top: -350px;
background-color: #eee;
background: -webkit-gradient(linear, left bottom, left top, from(#bbd), to(#fff));
background: -moz-linear-gradient(bottom, #bbd, #fff);
background: linear-gradient(bottom, #bbd, #fff);
-webkit-transition: all 0.25s ease-in-out;
-moz-transition: all 0.25s ease-in-out;
-o-transition: all 0.25s ease-in-out;
transition: all 0.25s ease-in-out;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
transform: scale(1);
}
.slide:nth-child(even) {
-moz-border-radius: 20px 0;
-khtml-border-radius: 20px 0;
border-radius: 20px 0; /* includes Opera 10.5+ */
-webkit-border-top-left-radius: 20px;
-webkit-border-bottom-right-radius: 20px;
}
.slide:nth-child(odd) {
-moz-border-radius: 0 20px;
-khtml-border-radius: 0 20px;
border-radius: 0 20px;
-webkit-border-top-right-radius: 20px;
-webkit-border-bottom-left-radius: 20px;
}
.slide p, .slide textarea {
font-size: 120%;
}
.slide .counter {
color: #999999;
position: absolute;
left: 20px;
bottom: 20px;
display: block;
font-size: 70%;
}
.slide.title > .counter,
.slide.segue > .counter,
.slide.mainTitle > .counter {
display: none;
}
.force-render {
display: block;
visibility: hidden;
}
.slide.far-past {
display: block;
margin-left: -2400px;
}
.slide.past {
visibility: visible;
display: block;
margin-left: -1400px;
}
.slide.current {
visibility: visible;
display: block;
margin-left: -450px;
}
.slide.future {
visibility: visible;
display: block;
margin-left: 500px;
}
.slide.far-future {
display: block;
margin-left: 1500px;
}
body.three-d div.slides {
-webkit-transform: translateX(50px) scale(0.8) rotateY(10deg);
-moz-transform: translateX(50px) scale(0.8) rotateY(10deg);
-o-transform: translateX(50px) scale(0.8) rotateY(10deg);
transform: translateX(50px) scale(0.8) rotateY(10deg);
}
/* Content */
@font-face { font-family: 'Junction'; src: url(src/Junction02.otf); }
@font-face { font-family: 'LeagueGothic'; src: url(src/LeagueGothic.otf); }
header {
font-family: 'Droid Sans';
font-weight: normal;
letter-spacing: -.05em;
text-shadow: rgba(0, 0, 0, 0.2) 0 2px 5px;
left: 30px;
top: 25px;
margin: 0;
padding: 0;
font-size: 140%;
}
h1 {
font-size: 140%;
display: inline;
font-weight: normal;
padding: 0;
margin: 0;
}
h2 {
font-family: 'Droid Sans';
color: black;
font-size: 120%;
padding: 0;
margin: 20px 0;
}
h2:first-child {
margin-top: 0;
}
section, footer {
font-family: 'Droid Sans';
color: #3f3f3f;
text-shadow: rgba(0, 0, 0, 0.2) 0 2px 5px;
margin: 100px 30px 0;
display: block;
overflow: hidden;
}
footer {
font-size: 100%;
margin: 20px 0 0 30px;
}
a {
color: inherit;
display: inline-block;
text-decoration: none;
line-height: 110%;
border-bottom: 2px solid #3f3f3f;
}
button {
font-size: 100%;
}
pre button {
margin: 2px;
}
section.left {
float: left;
width: 390px;
}
section.small {
font-size: 24px;
}
section.small ul {
margin: 0 0 0 15px;
padding: 0;
}
section.small li {
padding-bottom: 0;
}
section.middle {
line-height: 2em;
text-align: center;
display: table-cell;
vertical-align: middle;
height: 700px;
width: 900px;
}
pre {
text-align: left;
font-family: 'Droid Sans Mono', Courier;
font-size: 80%;
padding: 10px 20px;
background: rgba(255, 0, 0, 0.05);
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
border: 1px solid rgba(255, 0, 0, 0.2);
}
pre select {
font-family: Monaco, Courier;
border: 1px solid #c61800;
}
input {
font-size: 100%;
margin-right: 10px;
font-family: Helvetica;
padding: 3px;
}
input[type="range"] {
width: 100%;
}
button {
margin: 20px 10px 0 0;
font-family: Verdana;
}
button.large {
font-size: 32px;
}
pre b {
font-weight: normal;
color: #c61800;
text-shadow: #c61800 0 0 1px;
/*letter-spacing: -1px;*/
}
pre em {
font-weight: normal;
font-style: normal;
color: #18a600;
text-shadow: #18a600 0 0 1px;
}
pre input[type="range"] {
height: 6px;
cursor: pointer;
width: auto;
}
div.example {
display: block;
padding: 10px 20px;
color: black;
background: rgba(255, 255, 255, 0.4);
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
margin-bottom: 10px;
border: 1px solid rgba(0, 0, 0, 0.2);
}
video {
-moz-border-radius: 8px;
-khtml-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.key {
font-family: 'Droid Sans';
color: black;
display: inline-block;
padding: 6px 10px 3px 10px;
font-size: 100%;
line-height: 30px;
text-shadow: none;
letter-spacing: 0;
bottom: 10px;
position: relative;
-moz-border-radius: 10px;
-khtml-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
background: white;
box-shadow: rgba(0, 0, 0, 0.1) 0 2px 5px;
-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0 2px 5px;
-moz-box-shadow: rgba(0, 0, 0, 0.1) 0 2px 5px;
-o-box-shadow: rgba(0, 0, 0, 0.1) 0 2px 5px;
}
.key { font-family: Arial; }
:not(header) > .key {
margin: 0 5px;
bottom: 4px;
}
.two-column {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
.stroke {
-webkit-text-stroke-color: red;
-webkit-text-stroke-width: 1px;
} /* currently webkit-only */
.center {
text-align: center;
}
#presentation-counter {
color: #ccc;
font-size: 70%;
letter-spacing: 1px;
position: absolute;
top: 40%;
left: 0;
width: 100%;
text-align: center;
}
div:not(.current).reduced {
-webkit-transform: scale(0.8);
-moz-transform: scale(0.8);
-o-transform: scale(0.8);
transform: scale(0.8);
}
.no-transitions {
-webkit-transition: none;
-moz-transition: none;
-o-transition: none;
transition: none;
}
.no-gradients {
background: none;
background-color: #fff;
}
</style>
</head>
<body>
<div class="presentation">
<div id="presentation-counter"></div>
<div class="slides">
<div class="slide">
<section class="middle">
<h2>Frank lightning talk</h2>
<p>Press <span class="key">→</span> key to advance.</p>
<p>Zoom in/out: <span class="key">Ctrl or Command</span> + <span class="key">+/-</span></p>
</section>
</div>
<div class="slide">
<!-- _S9SLIDE_ -->
<div style="width:100%;margin-left:auto;margin-right:auto">
<img style="padding:5%" width="90%" src="http://moredip.github.com/business_card.jpg" />
</div>
</div>
<div class="slide">
<section>
<header>
<h1 id="what-is-frank">What is Frank?</h1>
</header>
<p>Frank is a system for running automated tests against an iOS (iPhone/iPad) app. </p>
<p>It’s like a very basic Selenium for native apps.</p>
<p>It was created by my team so that we could write cucumber tests for the iPad application we’re developing. </p>
</section>
</div>
<div class="slide">
<section>
<header>
<h1 id="demo">Demo</h1>
</header>
<p><a target="_blank" href="http://vimeo.com/16591775">here’s a demo of Frank in action</a></p>
</section>
</div>
<div class="slide">
<section>
<header>
<h1 id="how-does-frank-work">How does Frank work?</h1>
</header>
<p>Frank consists of two parts:</p>
<ul>
<li>A small HTTP server written in Objective C is embedded into the app itself.</li>
<li>A driver which sends commands to that server (we’re using ruby/cucumber for that).</li>
</ul>
<p>The testing framework sends commands to the embedded HTTP server in order to inspect the current state of the UI and to perform actions against the UI.</p>
</section>
</div>
<div class="slide">
<section>
<header>
<h1 id="a-pretty-diagram">A pretty diagram</h1>
</header>
<p><img src="http://github.com/moredip/frank/raw/master/doc/Frank%20Architecture.png" alt="Frank Architecture" /></p>
</section>
</div>
<div class="slide">
<section>
<header>
<h1 id="cucumber-integration">Cucumber integration</h1>
</header>
<p>Frank comes bundled with Cucumber integration, allowing you to write cuke tests which drive your native iOS app. For example:</p>
<pre><code>Given I have launched my app
When I fill in the "username" textbox with "pete"
And I fill in the "password" textbox with "sekrit"
And I touch the button marked "Logon"
Then I should see "Welcome back, Pete"
</code></pre>
<p><a href="https://github.com/moredip/Frank/blob/master/example/EmployeeAdmin/features/main.feature">see here for further examples</a></p>
</section>
</div>
<div class="slide">
<section>
<header>
<h1 id="other-automation-facilities">Other automation facilities</h1>
</header>
<p>We’ve also had success in automating:</p>
<ul>
<li>rotation of the simulator</li>
<li>restarting the simulator</li>
<li>launching an arbitrary build into the simulator</li>
<li>recording a test run using QuickTime</li>
</ul>
</section>
</div>
<div class="slide">
<section>
<header>
<h1 id="symbiote">Symbiote</h1>
</header>
<p>The Frank server embedded in your app also serves up a simple single-web-page app called Symbiote.</p>
<p>Symbiote uses some basic HTML forms and javascript to talk to your running iOS application using the exact same API which your cuke scripts use.</p>
<p>It provides something like a crappy version of Firebug for your native iOS app. It allows you to inspect the state of the app, and to test selector paths as you start the process of automating a new section of your app’s UI.</p>
<p>By default it runs on <a href="http://localhost:37265/">http://localhost:37265/</a></p>
</section>
</div>
<div class="slide">
<section>
<header>
<h1 id="other-cool-stuffs">Other Cool Stuffs</h1>
</header>
<p>In addition to the basics of testing our iPad app using Frank, we’ve also had success with:</p>
<ul>
<li>running Frank tests as part of our CI build</li>
<li>Creating a QuickTime recording of each test run as a CI artifact </li>
<li>extending Cucumber to append timestamps to each scenario name [<a href="https://github.com/moredip/Timestamped">on github</a>]</li>
<li>extending Cucumber to report which step is currently running (as opposed to which step just completed) [<a href="https://github.com/moredip/SlowHandCuke">on github</a> and also <a href="https://rubygems.org/gems/slowhandcuke">packaged as a gem</a>]</li>
</ul>
</section>
</div>
<div class="slide">
<section>
<header>
<h1 id="thanks">Thanks!</h1>
</header>
<ul>
<li>These slides are available <a href="http://moredip.github.com/frank_lightning_talk_slides.html">here</a></li>
<li><a href="http://github.com/moredip/frank">Frank is on github</a></li>
<li><a href="http://blog.thepete.net/2010/07/frank-automated-acceptance-tests-for.html">My initial blog post announcing Frank</a></li>
<li><a href="http://bit.ly/9cyMjT">A podcast about Frank recorded with some colleagues at ThoughtWorks</a></li>
</ul>
<p>I’m always happy to talk more about Frank</p>
<ul>
<li>@beingagile</li>
<li>phodgson@thoughtworks.com</li>
</ul>
</section>
</div>
</div> <!-- slides -->
</div> <!-- presentation -->
<script>
(function() {
var doc = document;
var disableBuilds = true;
var ctr = 0;
var spaces = /\s+/, a1 = [''];
var toArray = function(list) {
return Array.prototype.slice.call(list || [], 0);
};
var byId = function(id) {
if (typeof id == 'string') { return doc.getElementById(id); }
return id;
};
var query = function(query, root) {
if (!query) { return []; }
if (typeof query != 'string') { return toArray(query); }
if (typeof root == 'string') {
root = byId(root);
if(!root){ return []; }
}
root = root || document;
var rootIsDoc = (root.nodeType == 9);
var doc = rootIsDoc ? root : (root.ownerDocument || document);
// rewrite the query to be ID rooted
if (!rootIsDoc || ('>~+'.indexOf(query.charAt(0)) >= 0)) {
root.id = root.id || ('qUnique' + (ctr++));
query = '#' + root.id + ' ' + query;
}
// don't choke on something like ".yada.yada >"
if ('>~+'.indexOf(query.slice(-1)) >= 0) { query += ' *'; }
return toArray(doc.querySelectorAll(query));
};
var strToArray = function(s) {
if (typeof s == 'string' || s instanceof String) {
if (s.indexOf(' ') < 0) {
a1[0] = s;
return a1;
} else {
return s.split(spaces);
}
}
return s;
};
var addClass = function(node, classStr) {
classStr = strToArray(classStr);
var cls = ' ' + node.className + ' ';
for (var i = 0, len = classStr.length, c; i < len; ++i) {
c = classStr[i];
if (c && cls.indexOf(' ' + c + ' ') < 0) {
cls += c + ' ';
}
}
node.className = cls.trim();
};
var removeClass = function(node, classStr) {
var cls;
if (classStr !== undefined) {
classStr = strToArray(classStr);
cls = ' ' + node.className + ' ';
for (var i = 0, len = classStr.length; i < len; ++i) {
cls = cls.replace(' ' + classStr[i] + ' ', ' ');
}
cls = cls.trim();
} else {
cls = '';
}
if (node.className != cls) {
node.className = cls;
}
};
var toggleClass = function(node, classStr) {
var cls = ' ' + node.className + ' ';
if (cls.indexOf(' ' + classStr.trim() + ' ') >= 0) {
removeClass(node, classStr);
} else {
addClass(node, classStr);
}
};
var ua = navigator.userAgent;
var isFF = parseFloat(ua.split('Firefox/')[1]) || undefined;
var isWK = parseFloat(ua.split('WebKit/')[1]) || undefined;
var isOpera = parseFloat(ua.split('Opera/')[1]) || undefined;
var canTransition = (function() {
var ver = parseFloat(ua.split('Version/')[1]) || undefined;
// test to determine if this browser can handle CSS transitions.
var cachedCanTransition =
(isWK || (isFF && isFF > 3.6 ) || (isOpera && ver >= 10.5));
return function() { return cachedCanTransition; }
})();
//
// Slide class
//
var Slide = function(node, idx) {
this._node = node;
if (idx >= 0) {
this._count = idx + 1;
}
if (this._node) {
addClass(this._node, 'slide distant-slide');
}
this._makeCounter();
this._makeBuildList();
};
Slide.prototype = {
_node: null,
_count: 0,
_buildList: [],
_visited: false,
_currentState: '',
_states: [ 'distant-slide', 'far-past',
'past', 'current', 'future',
'far-future', 'distant-slide' ],
setState: function(state) {
if (typeof state != 'string') {
state = this._states[state];
}
if (state == 'current' && !this._visited) {
this._visited = true;
this._makeBuildList();
}
removeClass(this._node, this._states);
addClass(this._node, state);
this._currentState = state;
// delay first auto run. Really wish this were in CSS.
/*
this._runAutos();
*/
var _t = this;
setTimeout(function(){ _t._runAutos(); } , 400);
},
_makeCounter: function() {
if(!this._count || !this._node) { return; }
var c = doc.createElement('span');
c.innerHTML = this._count;
c.className = 'counter';
this._node.appendChild(c);
},
_makeBuildList: function() {
this._buildList = [];
if (disableBuilds) { return; }
if (this._node) {
this._buildList = query('[data-build] > *', this._node);
}
this._buildList.forEach(function(el) {
addClass(el, 'to-build');
});
},
_runAutos: function() {
if (this._currentState != 'current') {
return;
}
// find the next auto, slice it out of the list, and run it
var idx = -1;
this._buildList.some(function(n, i) {
if (n.hasAttribute('data-auto')) {
idx = i;
return true;
}
return false;
});
if (idx >= 0) {
var elem = this._buildList.splice(idx, 1)[0];
var transitionEnd = isWK ? 'webkitTransitionEnd' : (isFF ? 'mozTransitionEnd' : 'oTransitionEnd');
var _t = this;
if (canTransition()) {
var l = function(evt) {
elem.parentNode.removeEventListener(transitionEnd, l, false);
_t._runAutos();
};
elem.parentNode.addEventListener(transitionEnd, l, false);
removeClass(elem, 'to-build');
} else {
setTimeout(function() {
removeClass(elem, 'to-build');
_t._runAutos();
}, 400);
}
}
},
buildNext: function() {
if (!this._buildList.length) {
return false;
}
removeClass(this._buildList.shift(), 'to-build');
return true;
},
};
//
// SlideShow class
//
var SlideShow = function(slides) {
this._slides = (slides || []).map(function(el, idx) {
return new Slide(el, idx);
});
var h = window.location.hash;
try {
this.current = parseInt(h.split('#slide')[1], 10);
}catch (e) { /* squeltch */ }
this.current = isNaN(this.current) ? 1 : this.current;
var _t = this;
doc.addEventListener('keydown',
function(e) { _t.handleKeys(e); }, false);
doc.addEventListener('mousewheel',
function(e) { _t.handleWheel(e); }, false);
doc.addEventListener('DOMMouseScroll',
function(e) { _t.handleWheel(e); }, false);
doc.addEventListener('touchstart',
function(e) { _t.handleTouchStart(e); }, false);
doc.addEventListener('touchend',
function(e) { _t.handleTouchEnd(e); }, false);
window.addEventListener('popstate',
function(e) { _t.go(e.state); }, false);
this._update();
};
SlideShow.prototype = {
_slides: [],
_update: function(dontPush) {
document.querySelector('#presentation-counter').innerText = this.current;
if (history.pushState) {
if (!dontPush) {
history.pushState(this.current, 'Slide ' + this.current, '#slide' + this.current);
}
} else {
window.location.hash = 'slide' + this.current;
}
for (var x = this.current-1; x < this.current + 7; x++) {
if (this._slides[x-4]) {
this._slides[x-4].setState(Math.max(0, x-this.current));
}
}
},
current: 0,
next: function() {
if (!this._slides[this.current-1].buildNext()) {
this.current = Math.min(this.current + 1, this._slides.length);
this._update();
}
},
prev: function() {
this.current = Math.max(this.current-1, 1);
this._update();
},
go: function(num) {
if (history.pushState && this.current != num) {
history.replaceState(this.current, 'Slide ' + this.current, '#slide' + this.current);
}
this.current = num;
this._update(true);
},
_notesOn: false,
showNotes: function() {
var isOn = this._notesOn = !this._notesOn;
query('.notes').forEach(function(el) {
el.style.display = (notesOn) ? 'block' : 'none';
});
},
switch3D: function() {
toggleClass(document.body, 'three-d');
},
handleWheel: function(e) {
var delta = 0;
if (e.wheelDelta) {
delta = e.wheelDelta/120;
if (isOpera) {
delta = -delta;
}
} else if (e.detail) {
delta = -e.detail/3;
}
if (delta > 0 ) {
this.prev();
return;
}
if (delta < 0 ) {
this.next();
return;
}
},
handleKeys: function(e) {
if (/^(input|textarea)$/i.test(e.target.nodeName)) return;
switch (e.keyCode) {
case 37: // left arrow
this.prev(); break;
case 39: // right arrow
case 32: // space
this.next(); break;
case 50: // 2
this.showNotes(); break;
case 51: // 3
this.switch3D(); break;
}
},
_touchStartX: 0,
handleTouchStart: function(e) {
this._touchStartX = e.touches[0].pageX;
},
handleTouchEnd: function(e) {
var delta = this._touchStartX - e.changedTouches[0].pageX;
var SWIPE_SIZE = 150;
if (delta > SWIPE_SIZE) {
this.next();
} else if (delta< -SWIPE_SIZE) {
this.prev();
}
},
};
// Initialize
var slideshow = new SlideShow(query('.slide'));
var counters = document.querySelectorAll('.counter');
var slides = document.querySelectorAll('.slide');
function toggleCounter() {
toArray(counters).forEach(function(el) {
el.style.display = (el.offsetHeight) ? 'none' : 'block';
});
}
function toggleSize() {
toArray(slides).forEach(function(el) {
if (!/reduced/.test(el.className)) {
addClass(el, 'reduced');
}
else {
removeClass(el, 'reduced');
}
});
}
function toggleTransitions() {
toArray(slides).forEach(function(el) {
if (!/no-transitions/.test(el.className)) {
addClass(el, 'no-transitions');
}
else {
removeClass(el, 'no-transitions');
}
});
}
function toggleGradients() {
toArray(slides).forEach(function(el) {
if (!/no-gradients/.test(el.className)) {
addClass(el, 'no-gradients');
}
else {