-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSession.html
261 lines (234 loc) · 10.7 KB
/
Session.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
<!DOCTYPE html>
<html>
<head>
<title>PrePrompt: JQuery</title>
<link rel="stylesheet" type="text/css" href="session.css" />
<script type="text/javascript" src="./Scripts/jquery-1.4.1.js">
/// <reference path="./Scripts/jquery-1.4.1.js" />
</script>
<script type="text/javascript">
// Setting hyperlinks' common properties
$(function () {
$("a[href^='http://']")
.attr("target", "_blank")
.not("[href*='jsfiddle.net']")
.after(function () {
return "<code> [" + $(this).attr("href") + "]</code>"
});
});
// Set up animation
$(function() {
$("#books").children("li").click(function(event) {
$(this).addClass('selected').siblings("li").removeClass('selected');
var vMargin = 50;
var imgHeight = $(window).height()-vMargin*2;
var imgWidth = imgHeight/1.3; // Maintain aspect ratio
var hMargin = ($(window).width()-imgWidth)/2;
var this$ = $(this);
$("#CoverPlaceHolder")
.empty()
.css({
top: $(window).height()/2,
left: $(window).width()/2,
right: $(window).width()/2+1,
bottom: $(window).height()/2+1
})
.show()
.animate({
top: vMargin,
left: hMargin,
bottom: vMargin,
right: hMargin
}, 'slow', function() {
$("<img src='./Images/" + $(event.currentTarget).attr('id') + ".jpg' />")
.css({ width:'100%', height: '100%'})
.appendTo($(this));
})
.click(function(event) {
$(this).hide().empty();
this$.removeClass('selected');
});
})
.end()
.after("<div id='CoverPlaceHolder'></div>");
});
</script>
<link rel="stylesheet" type="text/css" href="toc.css" />
<script type="text/javascript" src="./toc.js"></script>
<script type="text/javascript">
// Add a simple TOC to the page
$(function () {
$("section > h1").toc();
});
</script>
<script type="text/javascript">
// Collapse sections
function activateCollapse()
{
$("section > h1").click(function() {
$(this).parent().children().not(this).toggle();
//$(this).siblings().toggle();
});
// Hide all sections
$("section").children().not("h1").fadeOut();
}
$(function () {
//activateCollapse();
});
</script>
</head>
<body>
<section>
<h1>Apresentação</h1>
<ul>
<li><strong>Sessão:</strong> Devenvolvimento de Aplicações Web com jQuery</li>
<li><strong>Data:</strong> 10/Fev/2011, 17h-22h30m</li>
<li><strong>Anfitriões:</strong> Carlos Guedes e Paulo Pereira</li>
</ul>
</section>
<section>
<h1>Referências</h1>
<h2>Bibliografia</h2>
<ul id="books">
<li id="jQueryBook">jQuery in Action - 2nd edition</li>
<li id="NinjaBook">Secrets of the JavaScript Ninja</li>
</ul>
<h2> Links úteis </h2>
<ul>
<li class="JavaScript"> JavaScript
<ul>
<li><a href="http://ejohn.org/apps/learn/">Learning Advanced JavaScript</a></li>
</ul>
</li>
<li class="jQuery"> jQuery
<ul>
<li class="jQueryAPI"> API
<ul>
<li><a href="http://jquery.com/">jQuery "write less, do more."</a></li>
<li><a href="http://www.futurecolors.ru/jquery/">jQuery 1.5 API Cheat Sheet</a></li>
</ul>
</li>
<li class="jQuerySourceViewers"> jQuery Source Code viewers
<ul>
<li><a href="http://www.keyframesandcode.com/resources/javascript/deconstructed/jquery/">JS Libs Deconstructed</a></li>
<li><a href="http://james.padolsey.com/jquery/">jQuery source viewer</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h2>Utilitários</h2>
<ul>
<li><a href="http://jsfiddle.net/">JsFiddle: a playground for web developers</a></li>
</ul>
</section>
<section>
<h1>Pré-requisitos</h1>
<h2>Exercício: Etapa 0 (<a href="Solved/Etapa0_Solved.html">Soluções</a>)</h2>
<p> Admita a existência do documento HTML apresentado na figura seguinte. No elemento documento está definido, em JavaScript,
um <em>array</em> de objectos que representam clubes de futebol. Cada objecto inclui o nome do clube de futebol em causa
(propriedade <code>nome</code>) e a caracterização do respectivo estádio (propriedade <code>stadium</code>). A caracterização
do estádio é realizada através de objectos que contêm o nome do estádio e a sua capacidade (propriedades <code>name</code> e
<code>capacity</code>, respectivamente.</p>
<iframe style="width: 99%; height: 375px" src="http://jsfiddle.net/cguedes/ajHK7/embedded/html,result/"></iframe>
<p>Através de troços de código em JavaScript, acrescente as seguintes funcionalidades ao documento ilustrado:</p>
<ol>
<li> Escreva o troço de código que apresenta a informação relativa a cada um dos clubes contidos no <em>array</em>
<code>clubs</code>. Realize a apresentação da informação através da função <code>alert(someString)</code> ou, em alternativa,
através da função <code> console.log(someString)</code>. </li>
<li>Por cada elemento do <em>array</em> <code>clubs</code>, acrescente à lista dos descendentes imediatos de
<code> <div id="divclubs"> </code>, um <code>div</code> contendo o nome do clube e o nome do seu estádio.
<br /><strong>Nota:</strong> Caso pretenda, acresente as regras de estilo CSS necessárias a melhorar o aspecto da interface gerada.
</li>
<li> Acrescente à interface anterior suporte para, quando premido o rato na área correspondente à informação de determinado
clube, seja apresentado o número de lugares no estádio desse clube.
</li>
<li> Implemente a função <code>each(arr, action)</code> que aplica a função <code>action</code> a cada elemento de <code>arr</code>.
A função <code>action</code> recebe três parâmetros, nomeadamente: o índice do elemento no <em>array</em> <code>arr</code>, o elemento
e o <em>array</em>.<br /><strong>Exemplo de utilização:</strong>
<code>each(clubs, function(i, elem, arr) { /* action implementation */ }</code>.
</li>
<li>
<strong>(*)</strong> Implemente as funções <code>select</code>, <code>where</code> e <code>each</code>, de forma viabilizar a seguinte utilização:
<pre>
clubs
.select(function() { return this.stadium })
.where(function() { return this.capacity > 60000 })
.each(function() { console.log(this.name); });</pre>
<em><strong>*</strong> A implementação desta alínea é facultativa.</em>
</li>
</ol>
</section>
<section>
<h1>jQuery: Introdução</h1>
<h2>Aspectos avançados de JavaScript</h2>
<ul>
<li>prototypes</li><li>closures</li> <li>call-context</li>
</ul>
<p>
<a href="http://jsfiddle.net/palbp/7S88x/"> JavaScript Demo (Start)</a> /
<a href="http://jsfiddle.net/palbp/884rK/"> JavaScript Demo (Complete)</a> (Resolução da Etapa 0, Alínea 5.)
</p>
<h2>Exercício: Etapa 1 (<a href="Solved/Etapa1_Solved.html">Solução</a>)</h2>
<ol>
<li>
Implemente as função <code>bindToContext</code> de forma a viabilizar a seguinte utilização:
<iframe style="width: 99%; height: 310px" src="http://jsfiddle.net/cguedes/HxXgh/embedded/js,result/"></iframe>
</li>
<li>Acrescente à solução anterior o suporte necessário para que, cada chamada a <code>console.log</code>, para além
de produzir a escrita na consola, acrescente ao final do documento HTML um <code>div</code> contendo a string recebida como parâmetro.</li>
</ol>
<h2>O modelo de programação jQuery</h2>
<ul>
<li>Wrapped element set: selecção, navegação e manipulação.</li>
<li>Modelo de eventos.</li>
</ul>
<p>
<a href="http://jsfiddle.net/palbp/7S88x/"> jQuery: Demo 1 (Start)</a> :
<a href="http://jsfiddle.net/palbp/884rK/"> (Complete)</a> (Script da página actual)
</p>
<p>
<a href=""> jQuery: Demo 2 (Start)</a> :
<a href=""> (Complete)</a> (Modelo de eventos ilustrando event bubbling)
<!--<p style="background-color:red; color:white"><b>Por fazer...</p>-->
</p>
<h2>Exercício: Etapa 2 (<a href="Solved/Etapa2_Solved.html">Solução</a>)</h2>
<ol>
<li>Implemente, usando jQuery, as funcionalidades das alíneas 2 e 3 do exercício da etapa 0.</li>
</ol>
</section>
<section>
<h1>jQuery: Animações</h1>
<h2>Animações existentes</h2>
<p>
<a href=""> jQuery: Demo 3 (Start)</a> :
<a href=""> (Complete)</a> (Brincando com jsFiddle)
<!--<p style="background-color:red; color:white"><b>Por fazer...</p>-->
</p>
<h2>Animações personalizadas</h2>
<ul>
<li>função <code>animate</code>.</li>
<li>As queues de animação (fx).</li>
</ul>
<p>
<a href=""> jQuery: Demo 4 (Start)</a> :
<a href=""> (Complete)</a> (Script desta página)
</p>
</section>
<section>
<h1>jQuery: Anatomia de extensões</h1>
<ul>
<li>poluição do espaço de nomes global</li>
<li>opções e valores por omissão</li>
</ul>
<h2>Estrutura típica de uma extensão jQuery</h2>
<iframe style="width: 99%; height: 500px" src="http://jsfiddle.net/cguedes/UBw6H/embedded/js,result/"></iframe>
</section>
<!--
<section>
<h1>jQuery: Suporte AJAX</h1>
<p style="background-color:red; color:white"><b>Por fazer... (Não sei se vale a pena. É trivial!) </p>
</section>
-->
</body>
</html>