cours-02.html 15 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
 414
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Programmation Web Avancée   Client-Side Basics</title>
<meta name="cours-n" content="2">

<meta name="author" content="Rémi Emonet">
<meta name="venue" content="PWA M1 DSC">
<meta name="date" content="2016">
<meta name="affiliation" content="Université Jean Monnet − Laboratoire Hubert Curien">
<style type="text/css">
</style>


<style type="text/css">
.TIB {font-family: arial; font-size: 20px; border: 1px solid black; margin-top: -20px; padding: 10px; overflow:auto;}
.TIB img.float {transition: all 500ms; float: right;}
.TIB.styly {font-size: 30px; font-family: "Palatino Linotype", Palatino, Palladio, "URW Palladio L", "Book Antiqua", Baskerville, "Bookman Old Style", "Bitstream Charter", "Nimbus Roman No9 L", Garamond, "Apple Garamond", "ITC Garamond Narrow", "New Century Schoolbook", "Century Schoolbook", "Century Schoolbook L", Georgia, serif; }
.TIB ol.roman {list-style-type: upper-roman !important;}
.TIB img.border {border: 5px solid red;}
.TIB img.border {border: 5px solid red; }
.TIB img.border.shadow {transition: all 700ms; box-shadow: -10px 10px 10px black;}
.TIB input:hover {transition: all 700ms; box-shadow: 0px 0px 10px blue;}
.TIB li.blue {color: blue; }
.TIB li.green {color: green; font-weight: bold; }
.TIB img.bordered {border: 50px solid blue;}
li.server em {color: grey;}


.listisalpha ol {list-style: lower-alpha;}
.PAGE { font-family: helvetica; font-size: 16px; border: 1px solid grey; margin: 10px; box-shadow: 2px 2px 3px black;}
.selectors li em {font-weight: bold; font-family: monospace; display: inline-block; min-width: 40%;}
.selectors li em::after {content: ' ⇒ '; color: grey;}
section blockquote { font-size: 22px;}


.withredborder { border: 5px solid red; }
.withpinkoutline { outline: 5px solid pink; }
</style>

<!--
<script src="deck.js/extensions/includedeck/load.js"></script>
<script src="extensions/slides-dev.js"></script>
-->
<script src="extensions/deck-packed.js"></script>
<script src="extensions/slides.js"></script>
<script>go()</script>
</head>

<body>

<div class="deck-container">

<div class="deck-loading-splash" style="background: black; color: chartreuse;"><span class="vcenter" style="font-size: 30px; font-family: Arial; ">Please wait, while our marmots are preparing the hot chocolate…</span></div>

<section class="smart">


# @chunk: chunks/title.md

# Questions? <br/> Comments? {no-print}

# @chunk: chunks/objectives.md

## Design of Web Applications <span>{var-cours-n}</span> : Overview {#plan overview}
- Introduction {intro}
- HTML and DOM {dom}
- Styling and CSS {styling}
- More {more}
# @copy:#plan

# @copy:#plan: %+class:inred: .intro


## Client Side Technologies {/no-status} // hum
- A few langages {dense}
- HTML (declarative langage): page structure {html}
- CSS (declarative langage) : styling of elements {css} // including le hover sur les widgets
- Javascript (imperative/functional langage) : behavior {js} // le form dont avec le bouton + click l'image
- *Java, PHP, Python, ... : server-side behavior* {server} // also js
- @anim: .html + .TIB | .TIB p.par | .TIB img | .TIB ol | .TIB form | .TIB p.links | .css
- @anim: %+class:float:.TIB img
- @anim: %+class:styly:.TIB
- @anim: %+class:roman:.TIB ol
- @anim: %+class:border:.TIB img
- @anim: %+class:shadow:.TIB img
- @anim: %+class:green:.TIB li
- @anim: .js | .server

<div class="TIB">
<p class="par">This is a paragraph with an image, followed by a list and a form and two links. All together, they form a web page.</p>
<img src="media/kitten.jpg" width="200px" onclick="$(this).toggleClass('bordered')">
<ol>
<li>first interesting element</li>
<li>second element</li>
</ol>
<form>
<input type="text" id="tibtext" placeholder="your name..."><input type="submit" value="go" onclick="alert('Hey '+document.getElementById('tibtext').value+'! What\'s up?!')">
</form>
<p class="links">
<a href="http://graphhopper.com/" target="_blank">to infinity</a>
and <a href="https://cozy.io/" target="_blank">beyond</a>
</p>
</div>

# @copy:#plan: %+class:inred: .dom

## A Simple HTML page (minimal) {libyli}
```html
&lt;!DOCTYPE html>
&lt;html lang="en">
&lt;head>
&lt;meta charset="utf-8">
&lt;title>title&lt;/title>
&lt;/head>
&lt;body>
content
&lt;/body>
&lt;/html>
{slide dense}
```
- HTML Page Structure
- `html` root element
- `head` for metadata (encoding, title, ...)
- `body` for the actual page content
- HTML Elements {libyli}
- head elements: meta, title, style, script
- body elements: p, h1, h2, …, h6, ul, ol, li, dl, form, input, table, …
- more body elements: a, em, strong, i, b, …
- more body elements: div, span, img, video, object, …


## The Document Object Model (DOM) {libyli}
<blockquote>
<img class="floatright c5" src="media/dom-tree.png" alt="dom tree"/>
<p>
a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML, and XML documents
</p>
</blockquote>

- A set of nodes
- representing the document
- organized in a tree structure
- navigable in any direction (parent, children, previous/next siblings)
- A representation of an HTML document
- tree of elements
- each with possible attributes
- With APIs
- to manipulate the tree
- available for most existing languages
- (most importantly in this course, Javascript)

## Basic HTML Elements {libyli}

```html
&lt;h3>Demo&lt;/h3>
&lt;p class="hummm yeah">
This is a paragraph with an image then a list
and a form and two links
&lt;/p>
&lt;img src="media/kitten.jpg" width="200px" alt="kitten">
&lt;ol>
&lt;li>first interesting element&lt;/li>
&lt;li>second element&lt;/li>
&lt;/ol>
&lt;form>
&lt;input type="text" id="datext" placeholder="name...">
&lt;input type="submit" value="go">
&lt;/form>
&lt;p class="links">
&lt;a href="http://graphhopper.com/">to infinity&lt;/a>
and &lt;a href="https://cozy.io/">beyond&lt;/a>
&lt;/p>
{}
```
- Headings (`h1`...`h6`), paragraphs (`p`),
ordered (numbered) and un-ordered lists (`ol`, `ul`), list items (`li`),
images (`img`), links (`a`) {dense}
- <a href="http://dev.w3.org/html5/spec-author-view/Overview.html#contents">More</a>: section, nav, article, code, sup, sub, blockquote, pre, table/tr/td, … {dense}
- un-semantic blocks element (`div`) and inline element (`span`) {dense}

# HTML: Questions? Demo?

# @copy:#plan: %+class:inred: .styling

# CSS <br/> never go out of style

## Making the Web, With Style

<div class="PAGE">
<p>This is a first paragraph.</p>
<p style="color: red;
border: 1px solid blue;
background: #EEF;
margin-left: 50px;
padding-bottom: 30px;
">This is a second paragraph.</p>
</div>

```html
&lt;!DOCTYPE html>
&lt;html lang="en">
&lt;head>
&lt;meta charset="utf-8">
&lt;title>title&lt;/title>
&lt;/head>
&lt;body>
&lt;p>This is a first paragraph.&lt;/p>
&lt;p style="
color: red; border: 1px solid blue; background: #EFF;
margin-left: 50px; padding-bottom: 30px; ">
This is a second paragraph.
&lt;/p>
&lt;/body>
&lt;/html>
{slide dense}
```
- Style declarations {slide}
- «property» `:` «value»
- declarations are semicolon-separated (`;`)


## Basics of Cascading Style Sheets (CSS) {libyli}
- Motivation
- separate content from styling
- Principle
- define styling rules to apply to elements
- e.g., all paragraphs should have a margin
- CSS Syntax {libyli}
- comments: `/*` «whatever» `*/`
- NB: * // ...{smartcode}* is not a comment in CSS
- rule: «selector» `{{}` «semi-colon-separated-declarations» `}{}`
- example: `p.cool {color: red;}{}`
- Where to put the CSS rules?
- directly in a `style` element (within the `head`)
- in a separate file, with a `.css` extension, <br/> included with a `link rel="stylesheet"` element

## Basic CSS Selectors <a href="http://www.w3.org/TR/selectors/" target="_blank"></a> {libyli}
- Element selector
- `*`: any element (any node in the tree)
- `e`: any element of type `e` (any node *&lt;e>{smartcode}*)
- Class selector
- `.c`: any element with class `c` (e.g. *&lt;p class="toto c z">{smartcode}*)
- Identifier selector
- `#toto`: any element with identifier `toto` (e.g. *&lt;p id="toto">{smartcode}*)
- Conjunctions of selectors (no spaces) and “or”
- `e.c`: any element of type `e` with class `c`
- `e.c.d`: any element of type `e` with both class `c` and `d`
- `e#i`: element of type `e` if it has id `i`
- `E, F`: any element matching `E` or `F`
- Children and descendants
- `E F`: any `F` that is a **descendant** of a `E`
- *E > F{smartcode}* (or *E>F{smartcode}*): any `F` that is a **child** of a `E`

## More Advanced CSS Selectors {libyli}
- Attribute filters
- `E[attt]`: any `E` with a `attt` attribute
- `E[attt="toto"]`: any `E` with a `attt` attribute equal to `toto`
- `E[attt*="toto"]`: any `E` with a `attt` attribute contains `toto`
- …
- Pseudo-classes
- `:visited`: any already visited link
- `:hover`: an element with the mouse hovering it
- Following siblings
- `E + F`: any `F` that **immediately** follows an `E`
- `E ~ F`: any `F` that follows an `E`

# CSS Styling: Questions? Demo?

# CSS Styling: Box Model − Live

## CSS Styling: Box Model {libyli}
@SVG:media/border4.svg 200px 200px {floatright defaults}

<div class="demo floatright" style="clear: both; font-size: 70%; border: 1px dotted black;"><div>The <span class="demospan" style="display:inline-block; color: darkred">box</span> model</div></div>

- Margin
- example: `margin: 1em 2em 3em 4em`
- @anim: .defaults
- space around the object
- @anim: %attr:.demospan: margin: .5em 1em 1.5em 2em
- Border
- example: `border: 5px solid red`
- @anim: %%class:withredborder:.demospan
- Padding
- example: `padding: 1em 2em 3em 4em`
- space inside the object's border
- @anim: %attr:.demospan: padding: 0.5em 1em 1.5em 2em
- Outline (mostly for debugging)
- like a border, but takes no space
- @anim: %%class:withpinkoutline:.demospan
- Defaults, shorcuts and units {libyli}
- can use less than 4 values
- @anim: #a2to1,#a3to1,#a4to2
- can set only a part, e.g., `margin-left: 0`, `padding-right: 0`
- @anim: %attr:.demospan: margin-left: 0 +
- @anim: %attr:.demospan: padding-right: 0
- possible units: `0` (with no unit), `px`, `pt`, `em`, `%`

# CSS Styling: Positioning − Live

## CSS Styling: Positioning
- Notion of `display` as `inline`, `inline-block`, `block`
- Positioning (`left`, `top`, ..., `height`)
- `static`: default preferred positioning
- `relative`: offset with the preferred position
- `fixed`: absolute position inside the page
- `absolute`: position in the reference frame of the closest positioned ancestor
- Box sizing:
- `box-sizing: content-box` (default)
- `box-sizing: border-box`
- Flexbox !

# CSS Styling: Transitions/Animations − Live

## Priorities and Specificity in CSS {libyli}
- Priorities (decreasing)
- `!important`-values <br/>> inline-style <br/> > (CSS RULES) selector-specificity <br/> > (CSS RULES) rule-order <br/> > parent-inheritance <br/> > browser-default
- Selector specificity (<a href="http://specificity.keegan.st/" target="_blank">try</a>) {selectors}
- *p {color: white;}* 1
- *p em {color: green;}* 2
- *div p em {color: green;}* 3
- *.fancy {color: red;}* 1,0
- *p.fancy {color: blue;}* 1,1
- *p.fancy em.cool {color: yellow;}* 2,2
- *#id218 {color: brown;}* 1,0,0
- *(inline) style="…"* 1,0,0,0

## Different Ways of Adding Style {libyli}
1. Inline, with style attribute
- priority over other solutions
- thus, difficult to override
- *recommendation*: do not use it
2. Using CSS rules (preferred way) {listisalpha}
1. in a `style` element
2. in a file included via a `link rel="stylesheet"` element
```html
&lt;!DOCTYPE html>
&lt;html lang="en">
&lt;head>
&lt;meta charset="utf-8">
&lt;title>title&lt;/title>
&lt;link rel="stylesheet" href="allblue.css">
&lt;style> p {color: red;} &lt;/style>
&lt;/head>
&lt;body>
&lt;p style="color: green">This is a paragraph.&lt;/p>
&lt;/body>
&lt;/html>
{slide dense}
```

# @copy:#plan: %+class:inred: .more

## Potentially Useful Tools for Experimentation
- Your favorite editor + a browser + F5 (or an auto-refresh)
- Your browsers "dev tools" (Ctrl+Shift+I)
- A live CSS editor with autocompletion, in your browser, like <a href="http://liveweave.com/" target="_blank">liveweave</a>
- A CSS-aware IDE for auto-completion
- An IDE with live CSS edition (e.g. <a href="https://netbeans.org/kb/docs/webclient/html5-editing-css.html" target="_blank">in netbeans</a>)

## Next
- HTML+CSS+… + practice
- <a href="http://learn.heeere.com/DSC/guide.html#installation">Installation</a> help-desk

## Key Points {key deck-status-fake-end}
- ?



</section>

<!-- deck.status snippet -->
<p class="deck-status deck-progress-10"> <span class="deck-status-current"></span> / <span class="deck-status-total"></span><span class="var-author">will be replaced by the author</span><span class="var-title">will be replaced by the title</span></p>

<a data-progress-size=": spe.top(15, 555); height: 45*designRatio; left: slide.right - 90*designRatio; width: 90*designRatio" class="ccby" href="http://en.wikipedia.org/wiki/Creative_Commons_license" title="This work is under CC-BY licence." target="_blank"></a>

<a class="ujm" data-progress-size=": spe.top(15, 525); height: 65*designRatio; left: slide.left; width: 130*designRatio" target="_blank"></a>

</div>
<!-- clicky Cla -->
<script type="text/javascript">
var clicky_site_ids = clicky_site_ids || [];
clicky_site_ids.push(100779706);
(function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//static.getclicky.com/js';
( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
})();
</script>
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/100779706ns.gif" /></p></noscript>


<!-- Histats.com START (aync)-->
<script type="text/javascript">var _Hasync= _Hasync|| [];
_Hasync.push(['Histats.start', '1,2767123,4,0,0,0,00010000']);
_Hasync.push(['Histats.fasi', '1']);
_Hasync.push(['Histats.track_hits', '']);
(function() {
var hs = document.createElement('script'); hs.type = 'text/javascript'; hs.async = true;
hs.src = ('http://s10.histats.com/js15_as.js');
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(hs);
})();</script>
<noscript><a href="http://www.histats.com" target="_blank"><img src="http://sstatic1.histats.com/0.gif?2767123&101" alt="javascript hit counter" border="0"></a></noscript>
<!-- Histats.com END -->
</body>
</html>