-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
959 lines (821 loc) · 29.8 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript University</title>
<meta name="viewport" content="width=1024, user-scalable=no">
<!-- Replace path with correct path to deck.core.css. -->
<link rel="stylesheet" href="css/deck.js/deck.core.css" type="text/css">
<link rel="stylesheet" href="css/deck.js/themes/javascriptU.css" type="text/css">
<link rel="stylesheet" href="css/deck.js/transitions/fade.css" type="text/css">
<link rel="stylesheet" href="extensions/menu/deck.menu.css">
<link rel="stylesheet" href="extensions/navigation/deck.navigation.css">
<link rel="stylesheet" href="extensions/status/deck.status.css">
<link rel="stylesheet" href="extensions/hash/deck.hash.css">
<link href='http://fonts.googleapis.com/css?family=Mate+SC' rel='stylesheet' type='text/css'>
<!-- Any other extension CSS files go here. -->
<!-- Replace path with correct path to Modernizr file. -->
<script src="scripts/modernizr.custom.js"></script>
<style>
.container, html, body{
overflow:hidden !important;
}
</style>
</head>
<body class="deck-container">
<!-- ---------------------------------------------------------- -->
<!-- ---------------------------------------------------------- -->
<!-- ---------------------------------------------------------- -->
<!-- ---------------------------------------------------------- -->
<section class="slide" id="title-slide">
<h1><img src="img/JSULogo.png" alt="JavaScript University"></h1>
<h2>Open Source Education</h2>
</section>
<section class="slide">
<h2 class="center">Have questions?</h2>
<div class="slide">
<h2 class="center">cc @javascriptu on twitter</h2>
<h2 class="center">or use hashtag #jsu</h2>
</div>
</section>
<section class="slide" id="workshop-title">
<h1>Building Our Base</h1>
</section>
<section class="slide">
<h2></h2>
<h2 class="center">Our Goal For Workshop 1</h2>
<h2 class="center">Establish our baseline</h2>
<h4 class="center">Our new normal of easily reusable tools<br>that complement each other.</h4>
</section>
<section class="slide">
<h2></h2>
<h3 class="center">Last chance to follow the code</h3>
<ul>
<li class="slide"><code>git clone git://github.com/javascriptu/workshop-1.1-src.git</code></li>
<li class="slide"><code>cd workshop-1.1-src/</code></li>
<li class="slide"><code>npm install</code></li>
<li class="slide"><code>node fileServer.js</code></li>
<li class="slide">Visit http://127.0.0.1:3000/ in your browser</li>
</ul>
</section>
<section class="slide">
<h1><img src="img/node_started.jpg" class="focus-border"></h1>
</section>
<style>
#foundation-links a {
font-size:.8em;
}
</style>
<section class="slide" id="foundation-links">
<h2>What are our tools?</h2>
<ol>
<li class="slide">
<h3>Google Chrome - <a href="https://www.google.com/chrome">google.com/chrome</a></h3>
</li>
<li class="slide">
<h3>HTML5 Boilerplate - <a href="http://html5boilerplate.com/">html5boilerplate.com</a></h3>
</li>
<li class="slide">
<h3>jQuery - <a href="http://jquery.com/">jquery.com</a></h3>
</li>
<li class="slide">
<h3>LESS - <a href="http://lesscss.org/">lesscss.org</a></h3>
</li>
<li class="slide">
<h3>Twitter's Bootstrap - <a href="http://twitter.github.com/bootstrap/">twitter.github.com/bootstrap</a></h3>
</li>
<li class="slide">
<h3>RequireJS - <a href="http://requirejs.org/">requirejs.org</a></h3>
</li>
<li class="slide">
<h3>Jasmine - <a href="http://pivotal.github.com/jasmine/">pivotal.github.com/jasmine</a></h3>
</li>
</ol>
</section>
<section class="slide">
<h1>Laying the foundation</h1>
</section>
<section class="slide">
<h1><img src="img/h5bp-ss.jpg" class="focus-border"></h1>
</section>
<section class="slide">
<h2>HTML5 Boilerplate</h2>
<h3 class="slide">Features:</h3>
<ul>
<li class="slide">
<h3>Solid setup</h3>
<p>A checklist of things you'll probably need to think about anyway</p>
</li>
<li class="slide">
<h3>jQuery</h3>
<p>The one and only.</p>
</li>
<li class="slide">
<h3>Modernizr</h3>
<p>Feature detector. HTML5 supporter. Conditional loader.</p>
</li>
<li class="slide">
<h3>Outdated browser assistance</h3>
<p>IE class tags. Chrome frame. IE rendering engine tag.</p>
</li>
</ul>
</div>
</section>
<section class="slide">
<h1>Why a boilerplate?</h1>
</section>
<section class="slide">
<h2>A Reverse Todo List (A Done List)</h2>
<h3 class="slide center">Delete what you don't need.<br>Customize the rest.</h3>
<ul>
<li class="slide">Include an HTML5 shim? Awesome!</li>
<li class="slide">Google Analytics? Definitely!</li>
<li class="slide">Chrome frame? Maybe not this time.</li>
<li class="slide">Ensure IE Edge or Chrome frame? Oh yeah!</li>
<li class="slide">Google Analytics? Check!</li>
<li class="slide">IE Tags? Why not?</li>
</ul>
</section>
<section class="slide">
<h2>The customized directory</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2>Generic (and attractive) 404 page</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="1:*"></code></pre>
</section>
<section class="slide">
<h2>Apple Touch Icons</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="2.3.4.5.6:*"></code></pre>
<p>Icons for use on iOS and Android</p>
</section>
<section class="slide">
<h2>Cross Domain XML</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="7:*"></code></pre>
<p>For remote request granting</p>
</section>
<section class="slide">
<h2>Our CSS Directory</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="8:*"></code></pre>
</section>
<section class="slide">
<h2>A generic favicon</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="9:*"></code></pre>
<p>Favicons are retrieved by browsers and used in bookmarks and the URL bar</p>
</section>
<section class="slide">
<h2>Humans.txt</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="10:*"></code></pre>
<p>Because we're not robots</p>
</section>
<section class="slide">
<h2>Our index</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="11:*"></code></pre>
</section>
<section class="slide">
<h2>Our scripts directory</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="12:*"></code></pre>
</section>
<section class="slide">
<h2>A basic robots.txt</h2>
<pre><code src="code/h5bp-dirlist.txt" data-highlight="13:*"></code></pre>
<p>Dictate how search engines can crawl our site</p>
</section>
<section class="slide">
<h2>Original JS Directory</h2>
<pre><code src="code/h5bp-origJsDir.txt" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2>Our Preferred JS Structure</h2>
<pre><code src="code/h5bp-preferredJsDir.txt" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2><code>main.js</code> vs <code>script.js</code></h2>
<pre><code src="code/h5bp-preferredJsDir.txt" data-highlight="main.js"></code></pre>
<h3 class="slide center"><code>main.js</code> is a RequireJS convention</h3>
<h3 class="slide center">(and it is more meaningful than <code>script.js</code>)</h3>
</section>
<section class="slide">
<h2>The Value of "vendor"</h2>
<pre><code src="code/h5bp-preferredJsDir.txt" data-highlight="3:vendor"></code></pre>
<h3 class="slide center">Code that is <em>not</em> ours</h3>
<h3 class="slide center">Should <em>not</em> be alongside our code</h3>
</section>
<section class="slide">
<h2>Other H5BP Goodness</h2>
<h3>Modernizr combined with conditional comments</h3>
<pre><code src="code/h5bp-header.txt" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2>Other H5BP Goodness</h2>
<h3>Modernizr combined with conditional comments</h3>
<pre><code src="code/h5bp-header.txt" data-highlight="2:....!--,4:--...."></code></pre>
</section>
<section class="slide">
<h2>Other H5BP Goodness</h2>
<h3>Modernizr combined with conditional comments</h3>
<pre><code src="code/h5bp-header.txt" data-highlight="2.4:*"></code></pre>
</section>
<section class="slide">
<h2>Other H5BP Goodness</h2>
<h3>Modernizr combined with conditional comments</h3>
<pre><code src="code/h5bp-header.txt" data-highlight="3:*"></code></pre>
</section>
<section class="slide">
<h2>Other H5BP Goodness</h2>
<h3>Modernizr combined with conditional comments</h3>
<pre><code src="code/h5bp-header.txt" data-highlight="3:lt-ie7"></code></pre>
</section>
<section class="slide">
<h2>Other H5BP Goodness</h2>
<h3>Modernizr combined with conditional comments</h3>
<pre><code src="code/h5bp-header.txt" data-highlight="no-js"></code></pre>
</section>
<section class="slide">
<h2>Chrome 19 after modernizer</h2>
<pre><code src="code/h5bp-chrome-header.txt" data-highlight="wtf"></code></pre>
</section>
<section class="slide">
<h2>Chrome 19 after modernizer</h2>
<pre><code src="code/h5bp-chrome-header.txt" data-highlight="2:js"></code></pre>
</section>
<section class="slide">
<h2>Chrome 19 after modernizer</h2>
<pre><code src="code/h5bp-chrome-header.txt" data-highlight="no-[^ ]*"></code></pre>
</section>
<section class="slide">
<h2>IE8 after modernizer</h2>
<pre><code src="code/h5bp-ie8-header.txt" data-highlight="blah"></code></pre>
</section>
<section class="slide">
<h2>IE8 after modernizer</h2>
<pre><code src="code/h5bp-ie8-header.txt" data-highlight="2:lt-ie9"></code></pre>
</section>
<section class="slide">
<h2>IE8 after modernizer</h2>
<pre><code src="code/h5bp-ie8-header.txt" data-highlight="hashchange,fontface,postmessage,generatedcontent,(local|session)storage"></code></pre>
</section>
<section class="slide">
<h1>Adding to our toolkit...</h1>
</section>
<section class="slide">
<h1><img src="img/lesscss.jpg" class="focus-border"></h1>
</section>
<section class="slide">
<h2 class="center" style="margin-top:200px">Follow along</h2>
<h3 class="center"><a href="http://betabong.com/play/liveless/">Live LESS Editor</a></h3>
<h3 class="center"><a href="http://betabong.com/play/liveless/">http://betabong.com/play/liveless/</a></h3>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<div class="slide">
<h3>Variables!</h3>
<pre><code src="code/lesscss-variables.less"></code></pre>
</div>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Variables!</h3>
<pre><code src="code/lesscss-variables.less" data-highlight="@\w+"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Operations!</h3>
<pre><code src="code/lesscss-operations.less"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Operations!</h3>
<pre><code src="code/lesscss-operations.less" data-highlight="@baseColor - #0f0,@fontSize \* 1.5"></code></pre>
<h4 class="center">(holy crap!)</h4>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Mixins!</h3>
<pre><code src="code/lesscss-mixins.less"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Mixins!</h3>
<pre><code src="code/lesscss-mixins.less" data-highlight="\.rounded-border"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Parametric Mixins!</h3>
<pre><code src="code/lesscss-parametric.less"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Parametric Mixins!</h3>
<pre><code src="code/lesscss-parametric.less" data-highlight=".bordered\(.*?\)"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Color Operations!</h3>
<pre><code src="code/lesscss-color.less"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Color Operations!</h3>
<pre><code src="code/lesscss-color.less" data-highlight="(hue|darken)\(.*?\)"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Nesting!</h3>
<pre><code src="code/lesscss-nesting.less"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Nesting!</h3>
<pre><code src="code/lesscss-nesting.less" data-highlight="3:span.focus {,4: color.red;,5:}"></code></pre>
</section>
<section class="slide">
<h2>What does LESS give us?</h2>
<h3>Nesting!</h3>
<pre><code src="code/lesscss-nesting.less" data-highlight="10:&.visited {,11: color.darken\(@linkColor.20%\);,12:}"></code></pre>
</section>
<section class="slide">
<h1>And of course...</h1>
</section>
<section class="slide">
<h1>Single.</h1>
</section>
<section class="slide">
<h1>Line.</h1>
</section>
<section class="slide">
<h1>Comments.</h1>
</section>
<section class="slide">
<h2></h2>
<pre><code src="code/lesscss-comments.less"></code></pre>
</section>
<section class="slide">
<h2></h2>
<pre><code src="code/lesscss-comments.less" data-highlight="//.*"></code></pre>
</section>
<section class="slide">
<h2 class="center"></h2>
<pre><code src="code/lesscss-comments.less" data-highlight="11:*"></code></pre>
<h2 class="center">Seriously. Wtf, css.</h2>
</section>
<section class="slide">
<h2>Why LESS?</h2>
<ul>
<li class="slide">
<h3>Ease of development</h3>
<p>Client side compilation allows us to start using LESS as soon as we decide to.</p>
<p>Sass (and others) require pre-compilation to CSS before being useful.</p>
</li>
<li class="slide">
<h3>Does "enough"</h3>
<p>CSS is extremely repetitive. LESS evens it out without adding much extra.</p>
</li>
<li class="slide">
<h3>It doesn't matter what you use.</h3>
<p>As long as you use <em>something</em>. Sass, and others, are <strong>excellent</strong> but...</p>
</li>
<li class="slide">
<h3>We also wanted LESS for Bootstrap</h3>
<p>Make the most out of Bootstrap by embracing LESS.</p>
</li>
</ul>
</section>
<section class="slide">
<h1><img src="img/bootstrap-screenshot.jpg" class="focus-border"></h1>
</section>
<section class="slide">
<h2>Why use a style framework?</h2>
<ul>
<li class="slide">
<h3>Most web sites follow a similar structure.</h3>
<p>Aligned elements, Columns, and Grids.</p>
</li>
<li class="slide">
<h3>Most web sites need similar components.</h3>
<p>Buttons, Information Icons, Labels, Notifications...</p>
</li>
</ul>
<h3 class="slide center">Bootstrap is completely customizable.</h3>
<h3 class="slide center">You're not adhering to someone else's visual style.</h3>
<h3 class="slide center">You're adhering to a structure.</h3>
</section>
<section class="slide">
<h2>CSS Grid Systems</h2>
<pre><img src="img/bootstrap-gridSystem.jpg"></pre>
</section>
<section class="slide">
<h1>Responsive Web Design</h1>
</section>
<section class="slide">
<h2>Responsiveness baked in</h2>
<h4 class="slide center">What will happen if we resize the previous page<br>or view on a mobile device?</h4>
<img class="slide center focus-border" src="img/bootstrap-responsive.jpg">
<h4 class="slide center">After a certain point, every span becomes its own row.</h4>
<h4 class="slide center">(enabled only if you want it)</h4>
</section>
<section class="slide">
<h2>Basic markup</h2>
<pre><code src="code/bootstrap-basic.txt"></code></pre>
</section>
<section class="slide">
<h1>Holy Crap!<br>That's not semantic!</h1>
</section>
<section class="slide">
<h1>Who cares?</h1>
</section>
<section class="slide">
<h2>The argument is valid and important,</h2>
<h2 class="center">but it's not the only side</h2>
<div class="slide">
<h3 class="center">In the war of Semantics vs Maintenance and DRY<sup>*</sup></h3>
<h3 class="center">Maintenance and DRY will always win</h3>
<h5 class="center" style="margin-top:200px"><sup>*</sup>Don't Repeat Yourself</h5>
</div>
</section>
<section class="slide">
<h2>Markup revisited</h2>
<pre><code src="code/bootstrap-basic.txt" data-highlight="row"></code></pre>
</section>
<section class="slide">
<h2>Markup revisited</h2>
<pre><code src="code/bootstrap-basic.txt" data-highlight="span\d"></code></pre>
</section>
<section class="slide">
<h2>Markup revisited</h2>
<pre><code src="code/bootstrap-basic.txt" data-highlight="offset\d"></code></pre>
</section>
<section class="slide">
<h2>Other Components</h2>
<div class="slide">
<h2 class="center">Buttons</h2>
<pre><code src="code/bootstrap-buttons.txt" data-highlight="btn(-\w*)?"></code></pre>
<img src="img/bootstrap-buttons.jpg" class="center focus-border">
<div class="slide">
<h3 class="center">Also usable on other elements</h3>
<pre><code src="code/bootstrap-buttons2.txt" data-highlight="1:a(?= ),2:span(?= )"></code></pre>
</div>
</div>
</section>
<section class="slide">
<h2>Alerts</h2>
<div class="slide">
<pre><code src="code/bootstrap-alerts.txt" data-highlight="alert(-\w*)?"></code></pre>
<img src="img/bootstrap-alertSuccess.jpg" class="center focus-border">
<img src="img/bootstrap-alerts.jpg" class="slide center focus-border">
</div>
</section>
<section class="slide">
<h2>And <em>loads</em> more</h2>
<div class="slide">
<h3>and not just CSS, jQuery plugins like</h3>
<ul>
<li class="slide"><h3>Modal Popups</h3></li>
<li class="slide"><h3>Tooltips</h3></li>
<li class="slide"><h3>Typeahead (autocomplete)</h3></li>
<li class="slide"><h3>Popovers</h3></li>
<li class="slide"><h3>Tabs</h3></li>
<li class="slide"><h3>And more...</h3></li>
</ul>
</div>
</section>
<section class="slide">
<h1>Bootstrap and LESS</h1>
</section>
<section class="slide">
<h2>Bootstrap is written in LESS</h2>
<pre class="slide"><code src="code/bootstrap-lessDir.txt" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2>Bootstrap is written in LESS</h2>
<pre class=""><code src="code/bootstrap-lessDir2.txt" data-highlight="variables.less"></code></pre>
</section>
<section class="slide">
<h2><code>variables.less</code></h2>
<pre class=""><code src="code/bootstrap-variables.less" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2><code>variables.less</code></h2>
<pre class=""><code src="code/bootstrap-variables2.less" data-highlight=""></code></pre>
</section>
<section class="slide">
<h1>Putting the <em>JavaScript</em><br>in <em>JavaScript</em>U</h1>
</section>
<section class="slide">
<h1>RequireJS</h1>
</section>
<section class="slide">
<h1><img src="img/requirejs-ss.jpg" class="focus-border"></h1>
</section>
<section class="slide">
<h1>AMD?</h1>
</section>
<section class="slide">
<h2>Asynchronous Module Definition</h2>
<blockquote style="font-size:40px">The Asynchronous Module Definition (AMD) API specifies a mechanism for defining modules such that the module and its dependencies can be asynchronously loaded. </blockquote>
<h3 class="slide center">AMD is <em><strong>not</strong></em> a library.</h3>
<h3 class="slide center">AMD is a specification.</h3>
</section>
<section class="slide">
<h2><code>define()</code></h2>
<blockquote style="font-size:40px">The specification defines a single function "define" that is available as a free variable or a global variable.</blockquote>
<pre class="slide"><code>define(id?, dependencies?, factory);</code></pre>
<div class="slide">
<p></p>
<p>Using an ID is not recommended unless necessary.</p>
<pre><code>define(dependencies?, factory);</code></pre>
</div>
</section>
<section class="slide">
<h2>Why AMD?</h2>
<ul>
<li class="slide">
<h3>Dependency Management</h3>
<p>Large applications can easily become very unwieldy with manually managed dependencies.</p>
</li>
<li class="slide">
<h3>Encourages reusable code</h3>
<p>Easily define and use separate modules.</p>
</li>
<li class="slide">
<h3>Extremely easy to get started with</h3>
<p>Extends the module pattern you already know (and love).</p>
</li>
</ul>
</section>
<section class="slide">
<h2>Your new html</h2>
<pre><code src="code/require-html.js"></code></pre>
</section>
<section class="slide">
<h2><code>require.js</code></h2>
<pre><code src="code/require-html.js" data-highlight="js/vendor/require.js"></code></pre>
</section>
<section class="slide">
<h2>Your entry point</h2>
<pre><code src="code/require-html.js" data-highlight="js/main"></code></pre>
</section>
<section class="slide">
<h2><code>main.js</code></h2>
<pre><code src="code/require-main.js"></code></pre>
</section>
<section class="slide">
<h2><code>require.config</code></h2>
<pre><code src="code/require-main.js" data-highlight="" data-focus="1:{,2.3.4:*,5:}"></code></pre>
</section>
<section class="slide">
<h2>Path mappings</h2>
<pre><code src="code/require-main.js" data-highlight="paths"></code></pre>
</section>
<section class="slide">
<h2>Path mappings</h2>
<pre><code src="code/require-main.js" data-highlight="3:jquery(?= ),vendor/jquery-1.7.1.min"></code></pre>
</section>
<section class="slide">
<h2><code>require()</code></h2>
<pre><code src="code/require-main.js" data-highlight="7:require\(,9:\)"></code></pre>
</section>
<section class="slide">
<h2>Our dependencies</h2>
<pre><code src="code/require-main.js" data-highlight="7:jquery,\$(?=\))"></code></pre>
</section>
<section class="slide">
<h2>Our dependencies</h2>
<pre><code src="code/require-main.js" data-highlight="8:\$\('\w+'\)"></code></pre>
</section>
<section class="slide">
<h2><code>define()</code></h2>
<pre><code src="code/require-defineSpec.js" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2><code>fiveCount.js</code></h2>
<pre><code src="code/require-define.js" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2>Pre-AMD example</h2>
<pre><code src="code/require-definePreAMD.js" data-highlight="1:var fiveCount = \(,16:\)\(\)"></code></pre>
</section>
<section class="slide">
<h2>Usage of modules</h2>
<pre><code src="code/require-depUsage.js" data-highlight="1:fiveCount"></code></pre>
</section>
<section class="slide">
<h2 class="center">Asynchronous script loading</h2>
<h2 class="slide center">Great for development</h2>
<h2 class="slide center">Can be <em>expensive</em> in production</h2>
</section>
<section class="slide">
<h2>Enter <code>r.js</code></h2>
<div class="slide">
<h3>Run the RequireJS optimizer on the command line</h3>
<pre><code>node r.js main.js</code></pre>
</div>
<h4 class="slide">Locates and combines all dependencies, in proper order</h4>
<h4 class="slide">Minifies/Uglifies <em>all</em> your code</h4>
<h4 class="slide">Allows plugins to perform pre-loading work</h4>
<h4 class="slide">Minifies all your css for good measure</h4>
</section>
<section class="slide">
<h1>AMD <em>is</em> different</h1>
</section>
<section class="slide">
<h2>This ain't your mother's JavaScript</h2>
<ul>
<li class="slide">
<h3>In your world, everything is unicorns and rainbows</h3>
<p>New code written adhering to AMD is beautiful and made of cotton candy.</p>
</li>
<li class="slide">
<h3>Other people's code requires care</h3>
<p>A lot of existing modules don't expect to be loaded asynchronously.</p>
<p>Most other code expects access to existing global variables, or needs to create their own.</p>
</li>
<li class="slide">
<h3>Everything is usable, but understanding the differences is important</h3>
<p>Libraries that support AMD often still support non-AMD, global access for compatibility.</p>
</li>
</ul>
</section>
<section class="slide">
<h1>Rounding Out Our Foundation</h1>
</section>
<section class="slide">
<h1><img src="img/jasmine-ss.jpg" class="focus-border"></h1>
</section>
<section class="slide">
<h2>How Do You Test?</h2>
<h3 class="slide">You could do it one way:</h3>
<ol>
<li class="slide">
<p>Write some code you know should probably produce a "4" or something similar.</p>
</li>
<li class="slide">
<p>Go to your browser, refresh, verify that you see a "4".</p>
</li>
<li class="slide">
<p>Success? - Move on. Failure? Go back to 1.</p>
</li>
</ol>
</section>
<section class="slide">
<h1>Drawbacks to this approach?</h1>
</section>
<section class="slide">
<h2>Drawbacks.</h2>
<ul>
<li class="slide">
<h3>Slow</h3>
<p>You have to manually test every time.</p>
</li>
<li class="slide">
<h3>Unscalable</h3>
<p>You really can't test anything except what you are currently working on at any given time.</p>
</li>
<li class="slide">
<h3>A complete waste</h3>
<p>Every second you manually test is a second gone. You can't reuse your efforts.</p>
<p>Your a programmer. Have some respect.</p>
</li>
</ul>
</section>
<section class="slide">
<h2>Automated Testing</h2>
<h3 class="slide">Instead of the previous method:</h3>
<ol>
<li class="slide">
<p>Write a test to verify some code produces a "4".</p>
</li>
<li class="slide">
<p>Write some code you know should probably produce a "4".</p>
</li>
<li class="slide">
<p>Run your test.</p>
</li>
<li class="slide">
<p>Success? - Move on. Failure? Go back to 2.</p>
</li>
</ol>
</section>
<section class="slide">
<h1>Benefits?</h1>
</section>
<section class="slide">
<h2>Benefits.</h2>
<ul>
<li class="slide">
<h3>Grow your tests over time</h3>
<p>Ideally, every line of code can eventually be tested automatically.</p>
</li>
<li class="slide">
<h3>Your tests keep testing</h3>
<p>Other developers can run your tests to determine if they are breaking anything.</p>
</li>
<li class="slide">
<h3>It forces you to write against your API earlier</h3>
<p>You start using your code well before it is producing the final product.</p>
<p>This <em>will</em> expose bugs earlier, allow you to question design choices earlier, and keeps your logic
in testable chunks.</p>
</li>
</ul>
</section>
<section class="slide">
<h2>Using Jasmine</h2>
<pre><code src="code/jasmine-tests.js"></code></pre>
</section>
<section class="slide">
<h2>Test Specs</h2>
<pre><code src="code/jasmine-tests.js" data-highlight="it"></code></pre>
<p>A spec is a function that runs any number of tests.</p>
</section>
<section class="slide">
<h2>Test Suites</h2>
<pre><code src="code/jasmine-tests.js" data-highlight="describe"></code></pre>
<p>A test suite comprises of any number of specs, along with setup/teardown methods.</p>
</section>
<section class="slide">
<h2>Setup / Teardown</h2>
<pre><code src="code/jasmine-tests.js" data-highlight="beforeEach"></code></pre>
<p>With <code>beforeEach</code> and <code>afterEach</code>, you can set up a fresh environment before every spec.</p>
</section>
<section class="slide">
<h2>Matchers</h2>
<pre><code src="code/jasmine-tests.js" data-highlight="expect,toEqual"></code></pre>
<p>The individual tests that verify your code is working.</p>
</section>
<section class="slide">
<h2>Matchers</h2>
<pre><code src="code/jasmine-matchers.js" data-highlight=""></code></pre>
</section>
<section class="slide">
<h2>Custom Matchers</h2>
<pre><code src="code/jasmine-customMatchers.js" data-highlight=""></code></pre>
<pre class="slide"><code>expect(allDogs).toGoToHeaven();</code></pre>
</section>
<section class="slide">
<h2>RequireJS and Jasmine</h2>
<pre><code src="code/jasmine-require.txt"></code></pre>
</section>
<section class="slide">
<h2>RequireJS and Jasmine</h2>
<pre><code src="code/jasmine-require.txt" data-highlight="require"></code></pre>
</section>
<section class="slide">
<h2>RequireJS and Jasmine</h2>
<pre><code src="code/jasmine-require.js"></code></pre>
</section>
<section class="slide">
<h2>RequireJS and Jasmine</h2>
<pre><code src="code/jasmine-require.js" data-highlight="require"></code></pre>
</section>
<section class="slide">
<h1>Congratulations!</h1>
</section>
<section class="slide">
<h2>Our base is done</h2>
<ul>
<li class="slide">
<h3>Useful for a wide range of apps</h3>
<p>Unit tests, RequireJS, LESS, and the rest are all useful for just about anything you can think of.</p>
<p>We will add to our toolkit, but most other libraries will depend on the situation.</p>
<p>Our base, though, can be reused over and over.</p>
</li>
</ul>
<div class="slide">
<h3 class="center">Get it here</h3>
<h4 class="center"><a href="https://github.com/javascriptu/webapp-foundation">github.com/javascriptu/webapp-foundation</a></h4>
</div>
</section>
<section class="slide">
<h2>Where to go from here?</h2>
<ul>
<li>
<h3>Fork the repo</h3>
<p>Get it running locally.</p>
</li>
<li>
<h3>Step through the creation</h3>
<p>If you haven't already, checkout the workshop source and see how we incorporate each piece, step by step.</p>
</li>
<li>
<h3>Read (or at least skim) documentation</h3>
<p>Look into LESS, jQuery, and Bootstrap. Play with using RequireJS. Write some tests.</p>
</li>
<li>
<h3>Register for the next workshop!</h3>
<p><a href="http://www.javascriptu.org/">www.javascriptu.org</a></p>
</li>
</ul>
</section>
<!-- ---------------------------------------------------------- -->
<!-- ---------------------------------------------------------- -->
<!-- ---------------------------------------------------------- -->
<!-- ---------------------------------------------------------- -->
<script src="scripts/jquery-1.7.min.js"></script>
<script src="scripts/deck.js/deck.core.js"></script>
<script src="extensions/hash/deck.hash.js"></script>
<script src="extensions/menu/deck.menu.js"></script>
<script src="extensions/status/deck.status.js"></script>
<script src="extensions/navigation/deck.navigation.js"></script>
<script src="scripts/deck.init.js"></script>
</body>
</html>