This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
cologne-additional-standards.html
552 lines (433 loc) · 29.7 KB
/
cologne-additional-standards.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
<!DOCTYPE html> <!--[if lt IE 7]>
<html lang="en" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--><!--[if IE 7]>
<html lang="en" class="no-js lt-ie9 lt-ie8"> <![endif]--><!--[if IE 8]>
<html lang="en" class="no-js lt-ie9"> <![endif]--><!--[if gt IE 8]><!-->
<html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Sapient Cologne Interactive Dev Standards</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible"/>
<meta name="description" content="Sapient Cologne Interactive Developers use these to work together smoothly, across geographies and on large scale projects. Not necessarily the only way to do things right when it comes to HTML/CSS/JS/Processes, but working well for us."/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" href="stylesheets/all.combined.min.css" type="text/css" />
<link rel="shortcut icon" href="images/favicon.ico" />
<link rel="icon" href="images/favicon.ico"/>
<meta name="google-site-verification" content="zJfA8m1SUdIU5TDrULJOEstqsFXtBdbdbPUYPlKq40I" />
</head>
<body>
<!-- Working Draft HHR and NZR -->
<div class="row">
<article class="twelve columns l-document">
<header>
<img src="images/logo.jpg" alt="sapient-nitro id logo" class="logo" />
<h1>Sapient Cologne Interactive Dev Standards</h1>
<nav>
<h2>Table of contents</h2>
<div class="row l-slice">
<ul class="nav-list">
<li><a href="#introduction">Introduction</a></li>
<li><a href="#general">Device DB</a></li>
<li><a href="#head">HTML</a></li>
<li><a href="#css">CSS</a></li>
<li><a href="#javascript">JavaScript</a></li>
<li><a href="#images">Images</a></li>
<li><a href="#credits">Credits</a></li>
<li><a href="#references">Collected References</a></li>
</ul>
</div>
</nav>
</header>
<h2 id="introduction">Introduction</h2>
<p>This document is a base document helping the Mobile Studio in Cologne and new Team Members in mobile teams, to create more easy and faster valuable HTML5 projects, write proper JavaScript and increase the usage of powerful CSS features. <a href="index.html">For Basic Standards refer to the <q>Sapient Global Interactive Dev Standards</q></a>.</p>
<h2 id="general">Device DB</h2>
<mark>HHR: Should be more detailed. Maybe some input from people working with it for longer</mark>
<p>The Mobile Studio Cologne works with a powerful device DB, that allows reacting on user agents and creation of adjusted CSS, JavaScript and documents for increasing performance and reducing consuming bandwidth of mobile data restricted tariffs. </p>
<p>Initially created as so called <q>Feature Phones</q> were highly restricted in performance and capabilities, and so a device DB handling all kind of features made a lot of sense, and probably will do for a long time. </p>
<p>This db keeps track of thousands of mobile user agents that allow developers to create optimized CSS and other files that are delivered to the mobile client. There is an additional, not to forget powerful image processor, that allows creation of size and resolution optimized images depending on the device display. </p>
<p>All the below shown examples are often shown together, where the system between device DB and frontend, can help us delivering only most needed styles and CSS. This could be in some cases also true for JavaScript. </p>
<h2 id="head">HTML</h2>
<h3>HTML5 Doc-Type</h3>
<p>Although some Feature Phones could require a XHTML Mobile Doc-Type we should go ahead and use HTML5 Doc-Types. Actually almost all available device browser are quite good in interpreting HTML5. For reference see: <a data-reference="true" href="http://caniuse.com/">Can I Use?</a>. Or check the <a data-reference="true" href="http://joshduck.com/periodic-table.html">Periodic Table of the Elements</a>.</p>
<p>The way things are at the moment is that the <b><m4:document></b> tag of colognes mobile framework automatically sets the needed Doc-Type. If the mobile device supports HTML5 the HTML5 Doc-Type is set, otherwise the XHTML Mobile Doc-Type is set. So that the developer does not have to think about it.</p>
<pre data-rel="html" class="prettyprint lang-html"><code>
<!DOCTYPE html>
</code></pre>
<pre data-rel="html" class="prettyprint lang-html"><code>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
</code></pre>
<h3>HTML5 Form Elements</h3>
<p>Using HTML5 form elements allows us to create much more user friendly interfaces that allow us to interact with devices like used to, and often following best practices. <a data-reference="true" href="http://www.w3schools.com/html5/tag_input.asp">See the available types here</a>. There is no big risk, if the type is not supported. Allmost all browsers then interpret them as <code>type="text"</code>.</p>
<p>But there can be problems in the way types <b>are</b> supported. For example: input type number can be a problem on iOS5 and higher, were the typed in number is shown with dots between the single numbers. First you think ok, it's the way it's displayed, but these dots will also be submitted. Other devices as Android don't display the value of input type number with dots between so you can see there could be a problem on using some HTML5 form element types.</p>
<p>It is safe to say that we should use HTML5 form fields, but it's important that we check before how wide-reaching they are supported in the same way. It's not often useful if only some devices do it right, and the others fail. So it's not right to says use <b>all</b> available HTML5 form fields without any risk. We have to differentiate.</p>
<pre data-rel="html" class="prettyprint lang-html"><code>
<form action="#">
<fieldet>
<legend>My Form</legend>
<label for="data">
Date
<input type="date" id="date" />
</label>
<label for="range">
Range
<input type="range" id="range" />
</label>
<label for="email">
E-Mail
<input type="email" id="email" />
</label>
</fieldet>
</form>
</code></pre>
<h3>HTML5 Video</h3>
<p>Use it where possible. Just go native, just do not forget that auto run, and automated full screen does not work properly on mobile devices. Some older Androids do have issues, but this is the same for older iOS where a lot of first devices stuck to. If inline players won't work, offer just a download to the Video file (depending on the capabilities) Fallback chould always be Flash on Desktops. <mark>HHR Device DB flag for Supported Formats would help?</mark></p>
<h3>HTML5 Audio</h3>
<p>Same here, use it where possible. Fallback should always be Flash on Desktops. <mark>HHR Device DB flag for Supported Formats would help?</mark></p>
<h2 id="css">CSS</h2>
<p><a href="index.html#css">For more details see: Sapient CSS Standards</a></p>
<h3>Fixed Position</h3>
<p>The device DB provides a flag that allows to switch this CSS property. Fallback should be an absolute, or inline approach, and not ressource hungry JavaScript follow solutions. This counts for <code>position:fixed</code>, and <code>background-attachment:fixed;</code> <mark>DeviceDB Flag not available at the moment. It will be available after feature tests.</mark></p>
<h3>Opacity</h3>
<p>The device DB provides a flag that allows to switch this CSS property. This flag then allows us to switch css like the following, and only deliver what the browser needs. Fallback should be the extended version. <mark>DeviceDB Flag not available at the moment. It will be available after feature tests. I guess the RGB version could work or degrade well on each device. We'll test it. The opacity style contains problems. We'll enhance this section after test results.</mark></p>
<pre data-rel="css" class="prettyprint lang-css"><code>
/* the following definition could be stripped to only one true line */
.classdefinition {
background-color: rgb(0,0,0) /* 100% black on all browsers that do not know RGB */
background-color: rgba(0,0,0,0.5) /* 50% black on all browsers that do know RGBA */
}
/* the following class could be left out on not capable browsers */
.mypacity {
opacity:0.5;
}
</code></pre>
<h3>Shadows</h3>
<p>The device DB provides a flag that allows to switch this CSS property. Fallback should be none, or inspecial cases some other styles, depending on the flag. <mark>DeviceDB Flag not available at the moment. It will be available after feature tests.</mark></p>
<h3>CSS Gradients</h3>
<p>The device DB provides a flag that allows switching this CSS property. Fallback should be 100%. Cross device Gradients can be found here: <a data-reference="true" href="http://www.colorzilla.com/gradient-editor/">Ultimate CSS Gradient Generator</a>. The different implementations then could be switched by the device DB flag. <mark>DeviceDB Flag not available at the moment. It will be available in future.</mark></p>
<h4>Examples for cross device gradients:</h4>
<pre data-rel="css" class="prettyprint lang-css"><code>
.gradient {
background: rgb(149,149,149);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMTAwJSI+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjOTU5NTk1IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNDYlIiBzdG9wLWNvbG9yPSIjMGQwZDBkIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNTAlIiBzdG9wLWNvbG9yPSIjMDEwMTAxIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNTMlIiBzdG9wLWNvbG9yPSIjMGEwYTBhIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNzYlIiBzdG9wLWNvbG9yPSIjNGU0ZTRlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iODclIiBzdG9wLWNvbG9yPSIjMzgzODM4IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzFiMWIxYiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(-45deg, rgba(149,149,149,1) 0%, rgba(13,13,13,1) 46%, rgba(1,1,1,1) 50%, rgba(10,10,10,1) 53%, rgba(78,78,78,1) 76%, rgba(56,56,56,1) 87%, rgba(27,27,27,1) 100%);
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,rgba(149,149,149,1)), color-stop(46%,rgba(13,13,13,1)), color-stop(50%,rgba(1,1,1,1)), color-stop(53%,rgba(10,10,10,1)), color-stop(76%,rgba(78,78,78,1)), color-stop(87%,rgba(56,56,56,1)), color-stop(100%,rgba(27,27,27,1)));
background: -webkit-linear-gradient(-45deg, rgba(149,149,149,1) 0%,rgba(13,13,13,1) 46%,rgba(1,1,1,1) 50%,rgba(10,10,10,1) 53%,rgba(78,78,78,1) 76%,rgba(56,56,56,1) 87%,rgba(27,27,27,1) 100%);
background: -o-linear-gradient(-45deg, rgba(149,149,149,1) 0%,rgba(13,13,13,1) 46%,rgba(1,1,1,1) 50%,rgba(10,10,10,1) 53%,rgba(78,78,78,1) 76%,rgba(56,56,56,1) 87%,rgba(27,27,27,1) 100%);
background: -ms-linear-gradient(-45deg, rgba(149,149,149,1) 0%,rgba(13,13,13,1) 46%,rgba(1,1,1,1) 50%,rgba(10,10,10,1) 53%,rgba(78,78,78,1) 76%,rgba(56,56,56,1) 87%,rgba(27,27,27,1) 100%);
background: linear-gradient(135deg, rgba(149,149,149,1) 0%,rgba(13,13,13,1) 46%,rgba(1,1,1,1) 50%,rgba(10,10,10,1) 53%,rgba(78,78,78,1) 76%,rgba(56,56,56,1) 87%,rgba(27,27,27,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#959595', endColorstr='#1b1b1b',GradientType=1 );
}
</code></pre>
<p>IE >= 9 can properly use gradients, so hide filter for them</p>
<pre data-rel="html" class="prettyprint lang-html"><code>
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
filter: none;
}
</style>
<![endif]-->
</code></pre>
<h3>CSS3 Transitions and Animations</h3>
<p>Mobile development brings additional challenges with it. The performance (RAM, processor power) is usually quite poor (but improving). Thus it's beneficial to leverage as much built-in performance optimizations as possible. A great example is using CSS3 instead of Javascript for transitions, transformations and animations. CSS3 techniques are based on built-in browser mechanisms and therefore more performant, than frequent DOM manipulations, which are necessary with Javascript based animations.</p>
<h4>Trigger Animations with CSS</h4>
<h5>:hover</h5>
<p>
The classical way is the :hover pseudo-class, which is triggered when a mouse-pointer is over a defined target (f. e. anchor). Unfortunately this isn't very reliable on touch devices, which obviously miss a specific mouse-pointer. Based on the OS and the device the :hover-rule is interpreted and applied differently. Thus avoid it, if possible.
</p>
<h5>:focus</h5>
<p>
The :focus pseudo-class is triggered when an element has gained focus. On touch devices this is usually relevant for form-fields, which are modified as soon as the user taps in.
</p>
<h5>:target</h5>
<p>The <a data-reference="true" href="http://www.w3schools.com/cssref/sel_target.asp">:target pseudo class</a> is a new invention with the CSS3 specification. It offers a bunch of new chances to display content. The class is triggered when the user "jumps" to the defined target. For example the click on the link below, forces the browser to jump to the defined content-target, which then changes its background-color. This style stays active as long as the target is applied (#div1 hash in URL). Instead of a simple style change an animation could be defined as well.</p>
<pre data-rel="html" class="prettyprint lang-html"><code>
<a href="#div1">Link</a>
<div id="div1">Content</div>
</code></pre>
<pre data-rel="css" class="prettyprint lang-css"><code>
div {
background: red;
width: 100px;
height: 100px;
}
div:target {
background: blue;
}
</code></pre>
<h4>CSS3 Animation Types</h4>
<p>
CSS3 provides different approaches for realizing animations / movements of website-modules. They differ in terms of complexity and effect. Currently it's still necessary to apply vendor-prefixes (-webkit, -moz, -ms, etc.) for most animation-rules. For readability the following examples only show the official W3C property.
</p>
<h5>Transition</h5>
<p>
CSS3 Transition are best suited for simple transitions bounded to a single trigger. This can be setting a class with Javascript or one of the above mentioned CSS-Triggers.<br/>
Style propertied of an element can be changed within a defined time and upon a specified delay. Even the easing can be set. For more details see: <a data-reference="true" href="http://css3.bradshawenterprises.com/transitions/">http://css3.bradshawenterprises.com/transitions/</a>
</p>
<p>Specification:</p>
<pre data-rel="css" class="prettyprint lang-css"><code>
transition: [ <transition-property> ||
<transition-duration> ||
<transition-timing-function> ||
<transition-delay> ]
</code></pre>
<p>Example:</p>
<pre data-rel="css" class="prettyprint lang-css"><code>
.button {
width: 50px;
height: 30px;
background: red;
transition: all 1s ease-in-out;
}
.button.active {
width: 100px;
height: 80px;
background: blue;
}
</code></pre>
<h5>Transforms</h5>
<p>
Transforms actually don't belong to transitions and animations in a technical manner. However they are usually combined and therefore described here as well.<br/>
CSS3 transformations allow to modify the physical appearance of a DOM element including text, images and forms. There are possibilities to rotate, scale or skew an element. The count of devices with 3d transformation capabilities is increasing, too.
<br/>
For more details see: <a data-reference="true" href="http://css3.bradshawenterprises.com/transforms/">http://css3.bradshawenterprises.com/transforms/</a>
</p>
<h5>Keyframe animation</h5>
<p>All the above mentioned transforms and transitions can be combined to a keyframe animation. This enables you to specify an animation more detailed and therefore realize a higher level of complexity.</p>
<p>Example:</p>
<pre data-rel="css" class="prettyprint lang-css"><code>
div {
width: 100px;
height: 100px;
background-color:rgba(255,0,0,0.5);
}
div.on {
animation-name: pulse;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-duration: 0.5s;
}
@keyframes pulse {
0% {
transform: scale(1,1);
background-color:rgba(255,0,0,0.5);
}
50% {
transform: scale(1.25,1.25);
background-color:rgba(0,255,0,0.5);
}
100% {
transform: scale(1,1);
background-color:rgba(0,0,255,0.5);
}
}
</code></pre>
<h3>Vertical Alignments</h3>
<p>CSS and vertical alignment is a mess. And we know about. There are several techniques to handle this, some are mentioned below. The device DB could provide a flag that allows switching CSS to the one of the below, fallback should be always top.</p>
<h4>Line heights</h4>
<p>Single Block elements can be easy aligned vertical with setting a line-height to it. </p>
<pre data-rel="html" class="prettyprint lang-html"><code>
<p>Vertical aligned</p>
</code></pre>
<pre data-rel="css" class="prettyprint lang-css"><code>
p {
background-color: red;
padding: 0px;
line-height: 5em;
}
</code></pre>
<p> The problem is that line-height doesn't work on all browsers. Some feature phones as old blackberrys (older than OS6), some internet explorers, opera browser and others don't support line-height or don't support it well. Design isn't that pretty then. Fallback could be <i><b>display: table-cell</b></i> as below.</p>
<h4><code>display:table-cell</code></h4>
<p>Table cells allow aligning vertical middle. So this is one of the solutions of aligning middle, when a line height is not appropriate.</p>
<pre data-rel="html" class="prettyprint lang-html"><code>
<div>
<span>Some code here</div>
</div>
</code></pre>
<pre data-rel="css" class="prettyprint lang-css"><code>
div {
display: table;
}
span {
display: table-cell;
vertical-align: middle;
}
</code></pre>
<h4>Absolute positioning in Parents</h4>
<p>Table cell and line height may not help on complex layouts, or other cases. Sometimes helps absolute positioning with a negative margin. In the following example we could give the <p> a proper height, position it absolute, set top:50% and a negative margin-top: to half of the height of the element. </p>
<pre data-rel="html" class="prettyprint lang-html"><code>
<body>
<p>Some code here</div>
</body>
</code></pre>
<p>CSS would like like below:</p>
<pre data-rel="css" class="prettyprint lang-css"><code>
p {
position: absolute;
top: 50%;
left: 0;
height: 200px;
width: 200px;
margin-top: -100px;
}
</code></pre>
<p><a data-reference="true" href="http://www.vanseodesign.com/css/vertical-centering/">More examples of vertical centering/alignment with CSS</a></p>
<h3>Horizontal centering</h3>
<p>The device DB provides a flag that allows reacting on this capability. Some older devices and browsers do not support centering with <code>margin: 0 auto;</code>. One, but not preffered solution, could be to give parent elements sometimes a <code>text-align:center;</code> and childs need to be Inline elements. This is not practicable for complex markup, but on some places a device DB flag could help work around this. <mark>Device DB Flag for margin is not available at the moment. It will be available after feature tests. Maybe the margin problem is not anymore existing.</mark></p>
<h3>Media Queries</h3>
<p>
Media Queries in CSS3 provide the possibility to react on attributes and capabilities of a certain device-type.
The most common usage is the detection of device-orientation as well as viewport-width, -height and pixel-density. Those information help creating optimized layout-rules for (mobile) user-interfaces.
</p>
<p>
The horizontal (& vertical) device-resolution detection can be defined absolute (pixel-based) or relative to the user's default font-size (em-based).
</p>
<h4>Absolute definition</h4>
<p>
The advantage of a pixel-definition is the obvious readability and the tight coupling to the viewport meta-tag, which is populated with a "best-viewed-in" resolution by device- and browser-vendors. Thus there are good odds to realize an optimized layout for most devices.
</p>
<pre data-rel="css" class="prettyprint lang-css"><code>
@media screen and ( min-width: 768px ) {
/**
* put here your > 768px styles
* (based on viewport meta-tag values)
*/
}
</code></pre>
<h4>Relative definition</h4>
<p>The definition relative to the user's default font-size causes minor impacts in code readability. In return it offers an additional benefit for accessibility, while preserving the same coupling to the viewport meta-tag like the absolute definitiona.<br/>
Users with debility of sight or visual impairment usually have a higher default font-size than 16px. This increases readability for them but often destroys the website's layout, if it doesn't react properly to bigger characters and longer sentences. </p>
<p>
If a media-query is defined with an em-value, the layout can gracefully degrade to state, where it can handle the above mentioned text-size changes. For example, defining a mobile (singel-column) and a tablet (two-column) layout with an accordant min-width value in em, the tablet layout automatically falls back to a single column view, when the default font-size is set to a higher value.<br/>
For further details read: <a data-reference="true" href="http://blog.cloudfour.com/the-ems-have-it-proportional-media-queries-ftw/">Proportional Media Queries</a></p>
<pre data-rel="css" class="prettyprint lang-css"><code>
@media screen and ( min-width: 40.625em ) {
/**
* put here your > 768px styles
* (based on 16px default font-size and viewport meta-tag values)
* if default font-size is higher than 16px, this media-query is
* not applied
*/
}
</code></pre>
<h2 id="javascript">JavaScript</h2>
<p><a href="index.html#javascript">For more details see: Sapient JavaScript Standards</a></p>
<h3>Inline Usage</h3>
<p>Inline usage, does not mean usage as on click events or similar. As of some caching issues of older devices it often makes sense to load the JavaScript into the DOM. This makes the DOM heavier, but helps reducing requests to server side. This could be important, when a lot of special functionality is needed. For example each page loaded contains unique JS functionality that is only needed in those views, and the minified and to one file merged JS is getting bigger than 100k after gzipped delivery from server side.</p>
<h3>Defered loaded</h3>
<p>Normally JavaScript should be loaded deferred at the end of the document, to avoid preventing the executable code to be loaded before the static document. <a data-reference="true" href="https://developers.google.com/speed/docs/best-practices/payload?hl=de#DeferLoadingJS">See more for Defer loading of JavaScript</a>.</p>
<h3>Module Loaders</h3>
<p>Do also always think of an on demand loading with <a data-reference="true" href="http://requirejs.org/">file and module loaders like Require.js</a>.</p>
<h3>JS Testing</h3>
<p>Always consider unit tests with tools like <a data-reference="true" href="http://pivotal.github.com/jasmine/">Jasmin</a> and make your code validate against <a data-reference="true" href="http://jslint.com/">js validator tools like JSLint</a> alternatively you can use <a data-reference="true" href="http://www.jshint.com/">the JSHint tool</a>.</p>
<h2 id="images">Images</h2>
<h3>Images general</h3>
<p>The display of images related to a user agent rendered to related CSS and/or the DOM is an important option offered by the system. Images should always be provided optimized for devices. As of an upcoming amount of clients (browsers) that cannot be detected properly as the User Agent string is not unique, possibly the fallback should in future be the better quality, instead of less.</p>
<h3>Scaled image tag</h3>
<p>Colognes mobile framework provides a tag that is able to scale and cache images optimized for the related device. It's very easy to use. You set the image url and additional information like width and/or height. You also can convert pngs to jpgs, set quality in percent or handle retina display images. As a result you get the image url where the optimized image is available, together width information about width and height. Afterwards you can use the new url on image tag <img>. <b>This is also relevant for animated gif.</b> You can set the url of an animated gif and additionally the url of a default picture for the case the device does not support animated gifs. Then the tag choose the default image url.</p>
<pre data-rel="html" class="prettyprint lang-html"><code>
<mmwap-core:scaledImage src="/images/example.png" width="320px" var="img_example" scope="request"/>
</code></pre>
<p><b>Available options for scaledImage:</b></p>
<ul>
<li>width (pixel or percent)</li>
<li>height (pixel or percent)</li>
<li>output (example: jpeg)</li>
<li>pixelScale (to handle retina displays use 2, otherwise 1 as value)</li>
<li>method</li>
<li>quality (percent)</li>
<li>scope (example: request or session)</li>
<li>urlprefix</li>
<li>animatedsrc (for animated gif)</li>
<li>src</li>
</ul>
<pre data-rel="html" class="prettyprint lang-html"><code>
<img src="${fn:escapeXml(img_example)}" width="${img_example.width}" height="${img_example.height}" alt=""/>
</code></pre>
<h3>Images Sprites</h3>
<mark>under construction</mark>
<p>Image sprites could easily be adapted to the device DBs offered flags. The system will provide device DB related image sizes, and the CSS will be adapted. Later the background image could be adjusted with background size if, for example, the display is a retina display</p>
<pre data-rel="css" class="prettyprint lang-css"><code>
img.style {
background-image: url(img.png);
background-repeat: no-repeat;
background-size:100%;
}
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 2dppx) {
img.style {
background-image: url(img_2x.png);
}
}
</code></pre>
<p>
</p>
<h2 id="credits">Credits</h2>
<p>This document is a joint effort by</p>
<ul>
<li>Holger Hellinger, <a href="mailto:[email protected]">[email protected]</a></li>
<li>Niklas Zillinger, <a href="mailto:[email protected]">[email protected]</a></li>
<li>Annick Querfeld, <a href="mailto:[email protected]">[email protected]</a></li>
</ul>
<footer>
<h2 id="references">Collected References</h2>
<ol>
</ol>
<nav id="legalese-footer" class="inline-list">
<a href="http://www.sapient.com">© SAPIENTNITRO - 2012</a>
<a href="http://www.sapient.en/com-us/Terms-of-Use.html">Terms of Use</a>
<a href="http://www.sapient.com/en-us/Privacy-Policy.html">Privacy Policy</a>/<a href="http://www.sapient.com/de-de/Privacy-Policy.html">Datenschutzerklärung</a>
<a href="http://www.sapient.com/de-de/Imprint.html">Impressum (Deutsch)</a>
</nav>
</footer>
</article>
</div>
<script type="text/javascript" src="javascripts/libs/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="javascripts/plugins/google-prettify/prettify.js"></script>
<script type="text/javascript">
/*
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34737353-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_gat._anonymizeIp']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
*/
/**
* doing it inline for now - if there is more JS required,
* I'll create a clean namespace structure
*/
$(document).ready(function(){
var html;
// stringify the example html-tags for presentation
$("pre.lang-html > code").each(function(){
html = $(this).html().replace(/[<>]/g, function(m) { return {'<':'<','>':'>'}[m]});
$(this).html(html);
});
prettyPrint();
var ref = $("a[data-reference='true']"),
lis = "",
refList = $("footer ol");
//Instead of using ugly target attribut
$("body").on("click","a[data-reference='true']", function(e){
e.preventDefault();
window.open($(this).attr("href"));
});
ref.each(function(i,v){
i = i+1;
var _this = $(v),
href = _this.attr("href"),
text = _this.text(),
refa = '<a href="#footnotes-'+i+'">[ref: '+i+']</a>';
if(href.length>0) {
$(refa).insertAfter(_this);
lis += '<li id="footnotes-'+i+'"><a data-reference="true" href="'+href+'">'+text+'</a></li>';
}
});
refList.html(lis);
});
</script>
</body>
</html>