-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path10-interactive.html
More file actions
413 lines (350 loc) · 17.1 KB
/
10-interactive.html
File metadata and controls
413 lines (350 loc) · 17.1 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>How to make interactives</title>
<meta name="description" content="How to make interactives, How jQuery Works">
<meta name="author" content="Code with me, Tom Giratikanon, Sisi Wei">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/theme/default.css">
<link rel="stylesheet" href="css/codewithme.css">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<script>
// If the query includes 'print-pdf' we'll use the PDF print sheet
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Used to fade in a background when a specific slide state is reached -->
<div class="state-background"></div>
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section class="small">
<h1 class="opening special-margin" style="margin-top: 100px;">How to make interactives</h1>
<div class="small-logo-container disappear">
<img src="images/basic-logo-tan-bg.png"/>
<div class="copyright">© <span>2013</span></div>
</div>
<div class="notes">
<p>So, here it is at last: How to make your webpages interactive. How do I make an interactive story?</p>
</div>
</section>
<section>
<h2 id="so-what-is-javascript">Where we're going</h2>
<ol>
<li>Learn a few basic programming concepts ...</li>
<li class="fragment">... so we can learn three lines of code ...</li>
<li class="fragment">... that are the foundation of many interactives</li>
</ol>
<div class="notes">
<p>What we're headed to, by the end of the lesson, is learning how to write a few lines of code that you can reuse and adapt to do a huge range of interactions, from slideshows to timelapses to tabs to calculators to simple animation.</p>
<p>So keep that in mind. Three lines of code. It's going to be a bit of a walk, but we'll get there together.</p>
</div>
</section>
<section>
<h2 id="the-simplest-javascript">Under the hood</h2>
<a href="http://www.nytimes.com/interactive/2010/05/01/us/20100501-oil-spill-tracker.html">
<img src="images/gulf.png" />
</a>
<div class="notes">
<p>To start us off, I thought it'd be helpful to show you how an interactive works.</p>
<p>It's the Times map of the oil spill of the Gulf. This was before I got there, but I think this is a great graphic: It's simple, tells a meaningful story, and is interactive in exactly the way you want for this.</p>
</div>
</section>
<section>
<video src="images/presentations/interactive/earthhour2.mov" controls width=700></video>
<div class="notes">
<p>Showing example form a smaller newsroom. If you have two photos, and some knowledge, you can do this. And it's powerful.</p>
</div>
</section>
<section>
<h2 id="functions-and-calls">What is an interactive?</h2>
<ul>
<li class="fragment">When the user interacts with the page, the page does something, like show text or hide an image</li>
</ul>
<video class="fragment" src="images/presentations/interactive/twitter.mov" controls style="margin: 0 auto; margin-top: 30px"></video>
<div class="notes">
<ul>
<li>When I click on a "before" photo, the "after" photo appears</li>
<li>When I type in a tweet box, the number of remaining characters appears</li>
</ul>
<p>This is what Andrew was talking about, interaction.</p>
</div>
</section>
<section>
<h2>Enter jQuery</h2>
<ul>
<li>It's a JavaScript file that makes coding easier</li>
<li>Use it on your page by "installing", or including, it.</li>
</ul>
<div class="notes">
You may feel like we're skipping something, but you don't need to know JavaScript before you learn jQuery.
</div>
</section>
<section>
<h2>How do we include jQuery?</h2>
<ol>
<li>Google "jquery google"</li>
<li>Paste the snippet below into your head</li>
<li>Add "http:" before the "//" to finish linking it</li>
</ol>
<p class="disappear"> </p><pre class="disappear"><code contenteditable><html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
</head>
</html></code></pre><p> </p>
<div class="notes">
<p>Basically, you find the URL of a jQuery file, and tell your Web page to load it. Google is willing to pay the costs of sending this file to millions of people, and lets you use the file on their computers for free. </p>
<p>So: Google jQuery. Go to page. Copy the URL. </p>
</div>
</section>
<section>
<h2>Creating your JavaScript file</h2>
<ol>
<li>In your "js" folder, create a "script.js" file</li>
<li>In your "index.html", add a script tag after jQuery</li>
</ol>
<p class="disappear"> </p><pre class="disappear"><code contenteditable><html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<!-- Add the following line -->
<script src="js/script.js"> </script>
</head>
</html></code></pre><p> </p>
<div class="notes">
<p>Basically, you find the URL of a jQuery file, and tell your Web page to load it. Google is willing to pay the costs of sending this file to millions of people, and lets you use the file on their computers for free. </p>
<p>So: Google jQuery. Go to page. Copy the URL. </p>
</div>
</section>
<section>
<h2>A basic jQuery call</h2>
<p style="color: #00B19D; font-size: 60px; margin-top: 50px; margin-bottom: 50px;">jQuery("img").fadeOut();</p>
<iframe src="jquery-simple.html" width=408 height=287 scrolling="no"></iframe>
</section>
<section>
<h2>Syntax of a call</h2>
<div style="position: relative; margin: 0 auto; width: 600px">
<div style="position: absolute;">
<img src="images/jquery-call-analysis.png">
</div>
<div class="fragment" style="position: absolute; background-color: #f3f1dc">
<img src="images/jquery-the-same-0.png">
</div>
<div class="fragment" style="position: absolute; background-color: #f3f1dc">
<img src="images/jquery-the-same.png">
</div>
<div class="fragment" style="position: absolute; background-color: #f3f1dc">
<img src="images/jquery-the-same-2.png">
</div>
</div>
</section>
<section>
<h2>Try it!</h2>
<ol>
<li>Go to <a href="http://codewithme.us/jquery">codewithme.us/jquery</a></li>
<li>Inspect the page, and click on Console</li>
<li>Type this and hit enter: <strong>jQuery("img").fadeOut();</strong></li>
<li>Then try this: <strong>jQuery("img").fadeIn();</strong></li>
</ol>
</section>
<section>
<p class="special-margin special-smaller" style="font-size: 100px; margin: 140px 0px 0px;"><a href="http://jquery.com" target="_blank" style="font-size: 100px; margin: 150px 0 40px 0; display: inline-block;">jquery.com</a></p>
<p>Helpful reference for jQuery.</p>
</section>
<section>
<h2>Let's do it live!</h2>
<p style="color: #999999; font-size: 60px; margin-top: 50px; margin-bottom: 50px;">jQuery("img").fadeOut();</p>
<p class="fragment" style="color: #00B19D; font-size: 60px; margin-top: 50px; margin-bottom: 50px;">sisi("door").open();</p>
<p class="fragment" style="color: #00B19D; font-size: 60px; margin-top: 50px; margin-bottom: 50px;">sisi("door").close();</p>
<div class="notes">
<li>jQuery is a program, a kind of very talented butler or assistant. So let's take a real life analogy. Let's say Sisi is a library like jQuery.</li>
</div>
</section>
<section>
<h2>What about the timing?</h2>
<p style="color: #00B19D; font-size: 60px; margin-top: 50px; margin-bottom: 50px; text-align: left;">sisi(".main-door").open();</p>
<div class="fragment" style="text-align: left; color: #00B19D; font-size: 60px; line-height: 1.3; ">sisi(".main-door").knock(function() {
<br style="display: block" /> <span style="color: #999;">sisi(".main-door").open();</span>
<br style="display: block" />});</div>
</section>
<section>
<h2>Back to jQuery</h2>
<div style="text-align: left; color: #00B19D; font-size: 60px; line-height: 1.3; ">sisi(".main-door").knock(function() {
<br style="display: block" /> <span style="color: #00B19D;">sisi(".main-door").open();</span>
<br style="display: block" />});</div>
<div class="fragment" style="text-align: left; color: #00B19D; font-size: 60px; line-height: 1.3; margin-top: 25px;">jQuery("p").click(function() {
<br style="display: block" /> <span style="color: #00B19D;">jQuery("img").fadeOut();</span>
<br style="display: block" />});</div>
</section>
<section>
<div style="text-align: left;">index.html</div>
<pre style="margin-left: 0px;"><code contenteditable style="margin-left: 0px;"><img src="http://codewithme.us/images/owl.gif" />
<p>Click to shoo away the owl! </p></code></pre>
<div style="text-align: left;">script.js</div>
<pre style="margin-left: 0px;"><code contenteditable style="margin-left: 0px;">jQuery("p").click(function() {
jQuery("img").fadeOut();
});</code></pre>
<iframe src="jquery-event.html" width=500 height=500 scrolling="no"></iframe>
</section>
<section>
<h2>When using jQuery, ask yourself:</h2>
<ul>
<li>What part of the page is the user interacting with? <strong class="fragment">The paragraph.</strong></li>
<li class="fragment">What are they doing to it? <strong class="fragment">Clicking it.</strong></li>
<li class="fragment">In response, what part of the page do you want to change? <strong class="fragment">The image.</strong> </li>
<li class="fragment">How do you want to change it? <strong class="fragment">Fade it out.</strong> </li>
</ul>
</section>
<section>
<h2>Fill in the jQuery blanks</h2>
<ul class="smaller">
<li>When <strong>the paragraph</strong> is <strong>clicked</strong>, the <strong>image</strong> will <strong>fade out</strong>.</li>
</ul>
<p style="clear; both"></p>
<p style="clear; both"></p>
<p style="clear; both"></p>
<div style="text-align: left;">index.html</div>
<pre style="margin-left: 0px;"><code contenteditable style="margin-left: 0px;"><img src="http://codewithme.us/images/owl.gif" />
<p>Click to shoo away the owl! </p></code></pre>
<div style="text-align: left;">script.js</div>
<pre style="margin-left: 0px;"><code contenteditable style="margin-left: 0px;">jQuery("______").______(function() {
jQuery("______").______();
});</code></pre>
</section>
<section>
<h2>Fill in the jQuery blanks</h2>
<ul class="smaller">
<li>When <strong>the paragraph</strong> is <strong>clicked</strong>, the <strong>image</strong> will <strong>fade out</strong>.</li>
</ul>
<p style="clear; both"></p>
<p style="clear; both"></p>
<p style="clear; both"></p>
<div style="text-align: left;">index.html</div>
<pre style="margin-left: 0px;"><code contenteditable style="margin-left: 0px;"><img src="http://codewithmemiami.com/images/owl.gif" />
<p>Click to shoo away the owl! </p></code></pre>
<div style="text-align: left;">script.js</div>
<pre style="margin-left: 0px;"><code contenteditable style="margin-left: 0px;">jQuery("paragraph").is clicked(function() {
jQuery("img").will fade out();
});</code></pre>
</section>
<section>
<h2>In real jQuery</h2>
<ul class="smaller">
<li>When <strong>the paragraph</strong> is <strong>clicked</strong>, the <strong>image</strong> will <strong>fade out</strong>.</li>
</ul>
<p style="clear; both"></p>
<div style="text-align: left;">index.html</div>
<pre style="margin-left: 0px;"><code contenteditable style="margin-left: 0px;"><img src="http://codewithme.us/images/owl.gif" />
<p>Click to shoo away the owl! </p></code></pre>
<div style="text-align: left;">script.js</div>
<pre style="margin-left: 0px;"><code contenteditable style="margin-left: 0px;">jQuery("p").click(function() {
jQuery("img").fadeOut();
});</code></pre>
</section>
<section>
<div style="text-align: left; margin-top: -50px">index.html</div>
<pre style="margin-left: 0px; font-size: .85em;"><code contenteditable style="margin-left: 0px; "><html>
<head>
<script src="js/jquery.min.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<img src="http://codewithme.us/images/owl.gif" />
<p>Click to shoo away the owl!</p>
</body>
</html></code></pre>
<div style="text-align: left;">script.js</div>
<pre style="margin-left: 0px; font-size: .85em;"><code contenteditable style="margin-left: 0px;">jQuery("p").click(function() {
jQuery("img").fadeOut();
});</code></pre>
<div class="notes">
Why doesn't it work? Buecause there is no paragraph yet! It's as if Sisi told me, hand out the papers to the students -- but the students weren't here yet. To the computer, it doesn't make sense.
</div>
</section>
<section>
<h2>A robot goes across the street...</h2>
</section>
<section>
<div style="text-align: left;margin-top: -50px">index.html</div>
<pre style="margin-left: 0px; font-size: .85em;"><code contenteditable style="margin-left: 0px;"><html>
<head>
<script src="js/jquery.min.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<img src="http://codewithme.us/images/owl.gif" />
<p>Click to shoo away the owl!</p>
</body>
</html></code></pre>
<div style="text-align: left;">script.js</div>
<pre style="margin-left: 0px; font-size: .85em;"><code contenteditable style="margin-left: 0px;">jQuery(document).ready(function() {
jQuery("p").click(function() {
jQuery("img").fadeOut();
});
});</code></pre>
</section>
<section>
<h2>With your mentor</h2>
<ul>
<li>Take a breath. You can do this!</li>
<li>Do exercise 10: Create a before and after graphic</li>
</ul>
</section>
</div>
<!-- The navigational controls UI -->
<aside class="controls">
<a class="left" href="#">◄</a>
<a class="right" href="#">►</a>
<a class="up" href="#">▲</a>
<a class="down" href="#">▼</a>
</aside>
<!-- Presentation progress bar -->
<div class="progress"><span></span></div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/linear(2d)
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/highlight.js', async: true, callback: function() { window.hljs.initHighlightingOnLoad(); } },
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'lib/js/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'lib/js/data-markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'socket.io/socket.io.js', async: true, condition: function() { return window.location.host === 'localhost:1947'; } },
{ src: 'plugin/speakernotes/client.js', async: true, condition: function() { return window.location.host === 'localhost:1947'; } },
]
});
$(document).ready(function() {
Reveal.addEventListener( 'customevent', function() {
$("#img-1").show();
$("#img-1").delay(1000).fadeOut(1000);
} );
$("#img-2").click(function() {
$("#img-2").fadeOut(1000);
})
$("#img-2b").click(function() {
$("#img-2b").css({ marginRight: "500px" })
});
$("#img-3").click(function() {
$("#img-3").animate({ marginRight: "500px" });;
})
});
</script>
</body>
</html>