7. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
License
This work is licensed under a Creative Commons Attribution-NoDerivs 3.0 Unported License.
You are free:
• to Share — to copy, distribute and transmit the work
• to make commercial use of the work
Under the following conditions:
• Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way
that suggests that they endorse you or your use of the work).
• No Derivative Works — You may not alter, transform, or build upon this work.
With the understanding that:
• Waiver — Any of the above conditions can be waived if you get permission from the copyright holder.
• Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status
is in no way affected by the license.
• Other Rights — In no way are any of the following rights affected by the license:
◦ Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations;
◦ The author's moral rights;
◦ Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy
rights.
• Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way
to do this is with a link to this web page.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
7
15. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
CSS pixel
定義於 CSS 裡的稱為 device pixel
非眼睛所見
圖像的像素
#content {
width: 128px;
}
See more: http://www.quirksmode.org/mobile/viewports.html
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
15
16. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
device pixel
螢幕 (Screen) 的顯示像素
眼睛所見
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
16
17. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
high-resolution
1 CSS pixel 需要 16 個 device pixel
更細緻
Source: www.w3.org/TR/css3-values/
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
17
18. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
with zoom out
4 pixel
CSS pixel 等於 device pixel
Zoom out: ⼀一個 device pixel 包含多個 CSS pixel
Source: http://www.quirksmode.org/mobile/viewports.html
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
18
19. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
screen size
screen.width
screen.height
Source: Moko365 Inc.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
19
20. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Screen Size 測量方式
screen size 使用 device pixel 測量
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
20
21. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
window size
window.innerWidth
window.innerHeight
Source: Moko365 Inc.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
21
22. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
viewport
window.innerWidth
window.innerHeight
Source: Moko365 Inc.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
22
23. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
viewport
document.documentElement.clientWidth
document.documentElement.clientHeight
Source: Moko365 Inc.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
23
24. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
visual viewport
visual viewport
the part of the page that s
currently shown on-screen
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
24
25. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
layout viewport
layout
viewport
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
25
26. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
visual 不等於 layout
visual layout
viewport viewport
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
26
27. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
“width=320”
1 <!DOCTYPE html >
2 <html>
3 <head>
4 <meta charset="UTF-8" />
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <link href="2.css" rel="stylesheet" type="text/css" />
7 <meta name="viewport" content="width=320">
8 <title>我在 Android World 2012 深圳:與會心得分享</title>
9 </head>
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
27
28. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
content width
content width = 900px
使用 %
1 #content {
2 width: 900px;
3}
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
28
29. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
content = document
content width = document width
使用 %
1 #content {
2 width: 100%;
3}
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
29
31. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
其它 layout 屬性
margin >> border >> padding
position >> box-sizing >> z
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
31
32. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
更多關於 viewport
只適用於 mobile browser
手機瀏覽可讓 visual viewport = layout viewport
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
32
33. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
visual viewport
visual viewport
the part of the page that s
currently shown on-screen
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
33
36. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
圖片大小怎麼處理
no good
1 #content {
2 width: 100%;
3 }
4
5 img {
6 width: 300px;
7 }
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
36
37. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Media Query
CSS @media rule
<style>
@media screen
{
p.test {font-family:verdana,sans-serif;font-size:14px;}
}
@media print
{
p.test {font-family:times,serif;font-size:10px;}
}
@media screen,print
{
p.test {font-weight:bold;}
}
</style>
See more: http://www.w3schools.com/css/css_mediatypes.asp
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
37
38. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Media Type
Source: http://www.w3schools.com/css/css_mediatypes.asp
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
38
45. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Scale = 2.0
scale=1.0
100% zoom
480x320
(Content)
scale=2.0
200% zoom
960x640
(Content)
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
45
46. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Scale
考慮 Scaling
手機設定 scale=1.0 (100% zoom)
➡ one CSS pixel 等於 one device pixel
➡ 12px / 1.2em
➡ ppi = pixel per inch
➡ 240 ppi
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
46
47. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
使用 ViewPort
<head>
<title>Example</title>
<meta name="viewport" content="width=device-width, user-
scalable=no" />
</head>
<meta name="viewport"
content="
height = [pixel_value ¦ device-height] ,
width = [pixel_value ¦ device-width ] ,
initial-scale = float_value ,
minimum-scale = float_value ,
maximum-scale = float_value ,
user-scalable = [yes ¦ no] ,
target-densitydpi = [dpi_value ¦ device-dpi ¦
high-dpi ¦ medium-dpi ¦ low-dpi]
" />
Source: Android Dev Guide. Portions of this page are reproduced from work
created and shared by the Android Open Source Project and used according
to terms described in the Creative Commons 2.5 Attribution License.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
47
56. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
-webkit-device-pixel-ratio
WebView 支援 “-webkit-device-pixel-ratio” CSS 樣式
➡ 0.75, 1.0, 1.5
<link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio: 1.5)"
href="hdpi.css" />
<link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio: 1.0)"
href="mdpi.css" />
<link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio: 0.75)"
href="ldpi.css" />
Source: Android Dev Guide. Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to
terms described in the Creative Commons 2.5 Attribution License.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
56
57. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Webkit 有自已的個性
#header {
background:url(medium-density-image.png);
}
@media screen and (-webkit-device-pixel-ratio: 1.5) {
/* CSS for high-density screens */
#header {
background:url(high-density-image.png);
}
}
@media screen and (-webkit-device-pixel-ratio: 0.75) {
/* CSS for low-density screens */
#header {
background:url(low-density-image.png); Figure 5. A web page with CSS that's
} targetted to specific screen densities using
the -webkit-device-pixel-ratio media feature.
Notice that the hdpi device shows a different
image that's applied in CSS.
Source: Android Dev Guide. Portions of this page are reproduced from work
created and shared by the Android Open Source Project and used according
to terms described in the Creative Commons 2.5 Attribution License.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
57
58. 第一次學跨裝置 Font Size 就上手
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
本教材由仕橙3G教室製作與維護
58
59. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
property of the element
element size
p { font-size: 1.2em } 表示比原本預設的大 20%
p {font-size: 14px} 不建議使用絕對值
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
59
62. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
em vs rem
p { font-size: 1.2em} p { font-size: 1.2rem}
elements will elements will
be 20% be 20%
greater the greater then
element root em
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
62
63. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
font size 建議做法
將 root element 的 default font size 改為 10px
➡ 原本是 16px
使用 rem 單位
➡ 相對於 root element
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
63
64. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
em vs rem
body { font-size:62.5%; } 16px * 0.625 = 10px
h1 { font-size: 2.4em; } /* =24px */
p { font-size: 1.4em; } /* =14px */
li { font-size: 1.4em; } /* =14px ? */
body { font-size:62.5%; }
h1 { font-size: 2.4em; } /* =24px */
p { font-size: 1.4em; } /* =14px */
li { font-size: 1.4em; } /* =14px */
html { font-size: 62.5%; }
body { font-size: 14px; font-size: 1.4rem; } /* =14px */
h1 { font-size: 24px; font-size: 2.4rem; } /* =24px */
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
64
65. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Base Property 觀念
WebKit based browser 的問題
可使用 “Base” 觀念解決
➡ thierryk/base.css - https://gist.github.com/1396486
➡ “Styling for WebKit-based browsers”,
➡ http://www.css-101.org/articles/base-styles-sheet-for-webkit-based-
browsers/index.php
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
65
66. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
修改 base font size
將 default (base) font size 改為 8px
7 /* setting line-height and family while leaving default font-size using *rem * */
8
9 html {
10 font: 62.5%/1.3 sans-serif;
11 }
Root Element (HTML):
12
16px * 0.625 = 10px
13 /* zeroing out the default 8px margin */
10px / 1.3 = 7.69px = 8px
14
15 body {
Body:
16 font-size: 1.3rem;
8px * 1.3rem = 10px;
17 margin: 0;
18 }
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
66
67. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
使用 base.css + 120% font size
HTC One X Galaxy SII
(ratio = 50%) (ratio = 50%)
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
67
68. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
很重要但不能用
切勿在 @media {} 裡使用 ‘rem’ 單位
@media {} 裡無法使用 ‘rem’ 單位 ?
➡ Bug 78295: Support for CSS rem unit in Media Queries,
➡ https://bugs.webkit.org/show_bug.cgi?id=78295
├── css
│ ├── 480.css
│ ├── 720.css
│ ├── 800.css 1p{
│ ├── base.css 2 font-size: 1.2rem;
│ ├── common.css 3}
│ └── large.css
└── index.html
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
68
69. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
All in ‘12px’
HTC One X Galaxy SII Galaxy SII
Android Browser Firefox Android Browser
Galaxy SII
Firefox
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
69
71. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
關掉 scaling 功能
24 <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
25 <title>我在 Android World 2012 深圳:與會心得分享</title>
26 </head>
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
71
72. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
使用 “font-size: 4vw”
vw: viewport’s width (%)
4x165mm/100 = 6.6mm = 0.66cm
viewport 的實體大小 ? 用尺量 !
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
72
73. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
字的大小是 0.66 公分
目前發佈的 webkit based 瀏覽器不支援
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
73
74. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
現在能用 vw 嗎
Bad news: 瀏覽器不支援
➡ Please just wait.
Good news:
➡ Implement vw/vh/vmin (viewport sizes) from CSS 3 Values and Units,
➡ https://bugs.webkit.org/show_bug.cgi?id=27160 and
➡ http://trac.webkit.org/changeset/109656
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
74
75. 第一次寫 Screen Detection 就上手
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
本教材由仕橙3G教室製作與維護
75
76. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Screen 大小偵測
iMac Galaxy SII HTC One X
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
76
77. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
找喳時間又到了
Firefox Android Browser Android Browser
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
77
88. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
使用 $(document)
$ $(document)
selector. 從 DOM 裡面有一
DOM 裡找出指 個 document
定的對象 對象
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
88
89. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
載入後再執行
$(document).ready() $(document).ready(screenSize)
screenSize 是
接著呼叫
ready 事件的
jQuery 的
callback
ready() 函數
function
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
89
90. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
認識 DOM
DOM
Document Object Model
document 是 DOM 裡的根 (root) 對象
每⼀一個標籤都是⼀一個對象,文件載入後掛進 DOM
學習 JavaScript 的重點是認識 DOM
JavaScript 的核心概念: Access DOM
不的標籤是不同的對象,並提供許多 API (函數)
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
90
91. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
認識 Selector
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
id=notes <body>
<header>
</header>
<nav>
</nav>
<article>
var content =
findElememtById(“notes”); <section>summary</section>
<div id= notes ></div>
var content = $(“notes”); </article>
<aside>
</aside>
<footer>
</footer>
</body>
</html>
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
91
92. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
二種選擇對象的方法
var content =
findElememtById( notes ); var content = $( notes );
呼叫 DOM 提 使用 jQuery 選
供的函數來找出 擇器來找出
notes notes
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
92
94. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
使用於 Callback function 參數
function screenSize() { function() {
} }
具名函數 匿名函數,使用
於 callback
function 參數
function screenSize() {
}
不需要名字
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
94
95. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
認識 Anonymous Function
匿名函數
function constant
lambda function
發源於 1958 LISP 語言
多種語言採用
經常使用於 Callback function 參數
在 JavaScript 裡,anonymous function 有別於 Closure
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
95
97. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
查詢函數用法
.css(); .fadeIn();
1 .css( propertyName ) .fadeIn( [duration] [, callback] )
2 .css( propertyName, value )
3 .css( propertyName, function(index, value) )
4 .css( map )
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
97
98. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
動態修改 CSS
#content {
$( #content ).css(
display: none;
display , none );
}
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
98
99. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
DOM Selector
getElememtById()
jQuery
Sizzle
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
99
100. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
JavaScript 重要基礎
Object (物件觀念)
Module Pattern (模組製作)
輸入事件處理 (Input Events)
➡ Drag & Drop
DOM (Document Object Model)
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
100
101. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Create Objects
var person = {
! name: "Jollen",
! job: "Software Developer",
!
! queryJob: function() {
! ! alert(this.job);
! }
};
person.queryJob();
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
101
102. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
JavaScript Constructor Pattern
function Person(name, job) {
! this.name = name;
! this.job = job;
! this.queryJob = function() {
! ! alert(this.job);
! };
}
// 將 Person() 視為 constructor
var person = new Person("Jollen", "Software Developer");
alert(person instanceof Person); // true
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
102
103. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Closure (封閉性)
function() { (function() {
var base; var base; var base;
function square( ) { function square( ) { function square( ) {
base = base * base; base = base * base; base = base * base;
} } }
} }) ();
沒有封閉...
完成封閉,成
(function() {
var base; 為一個封包
function square( ) {
base = base * base;
}
})
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
103
104. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
匯入外部封包
(function($) {
var base;
function square( ) { $ = jQuery
base = base * base;
$( #content ).html(base);
}
}) (jQuery);
匯入 jQuery
封包
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
104
105. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
jQuery Plugins
Add new methods to jQuery module (object).
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
105
106. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
做⼀一個 jQuery Plugin
$.fn.cover = function () {
...
};
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
106
107. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
將功能插件化
(function($) {
var base;
$.fn.square = function( ) {
base = base * base;
$( #content ).html(base);
}
}) (jQuery);
插件要打包,
一個插件裡有
一個函數
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
107
108. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
插件裡有多個函數
(function($) {
var base;
$.fn.square = function( ) {
base = base * base;
插件包, 這個
$( #content ).html(base); 插件裡有2個
}
$.fn.minus = function( ) { 函數
base = base - 10;
$( #content ).html(base);
}
}) (jQuery);
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
108
109. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
插件裡有多個函數
(function($) {
var base = 5; up objct
$.fn.square = function( ) {
base = base * base;
this.html(base);
}
$.fn.minus = function( ) { <div id= content ></div>
base = base - 10; <div id= message ></div>
this.html(base); <script>
} $( #content ).square();
$( #message ).minus();
}) (jQuery); </script>
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
109
110. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
this 的 up object 是 content
<div id= content ></div>
<div id= message ></div>
<script>
$( #content ).square();
$( #message ).minus();
</script> content
function() {
(function($) { this
var base = 5; }
$.fn.square = function( ) {
base = base * base; message
this.html(base);
}
}) (jQuery);
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
110
111. 第一次學 UI Framework 就上手
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
本教材由仕橙3G教室製作與維護
111
112. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
JavaScript UI Framework
jQuery Mobile
jQuery Tools, http://flowplayer.org/tools/index.html
jQuery UI, http://jqueryui.com/home
Kendo UI, http://www.kendoui.com/
Ignite,
Prototype UI, http://www.prototype-ui.com/
MochaUI, http://mochaui.com/
UKI, http://ukijs.org/
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
112
113. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
非常多 Open Source 計畫
iUI, http://code.google.com/p/iui/
Yahoo YUI, http://developer.yahoo.com/yui/
XUI, http://xuijs.com/
Alloy, http://alloy.liferay.com/
Jitsu, http://www.jitsu.org/jitsu/index.html
Qutensil, http://qutensil.com/
Dojo Mobile, http://http://dojotoolkit.org/
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
113
121. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
jquery.ebook.js
1 (function() {
2
3 $.fn.cover = function() {
4 var ctx = this;
5
6 ctx.addClass("ebook_cover");
7}
8
9 }) (jQuery);
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
121
122. 第一次學 jQuery Mobile 就上手
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
本教材由仕橙3G教室製作與維護
122
123. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
jQuery UI Framework
jQTouch
jQuery Mobile
➡ http://jquerymobile.com/
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
123
124. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
“data-” attribute
The jQuery Mobile framework uses HTML5 data-
attributes to allow for markup-based initialization
and configuration of widgets. These attributes are
completely optional; calling plugins manually and
passing options directly is also supported.
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
124
125. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
data-role=”page”
使用 “data-” attribute
<body data-role="page">
...content goes here...
</body>
</html>
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
125
132. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
將網站打包成 App
package com.moko365.examples.phonegap;
import android.app.Activity;
import android.os.Bundle;
import com.phonegap.*;
import org.apache.cordova.*;
public class HelloPhoneGapActivity extends ActivityDroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
super.loadUrl("file:///android_asset/www/index.html");
}
}
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
132
133. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
應用程式的 UI: index.html
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
133
138. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Native Web App 觀念
Figure 1. You can make your web content available to
users in two ways: in a traditional web browser and in an
Android application, by including a WebView in the layout.
Source: Android Dev Guide. Portions of this page are reproduced from work
created and shared by the Android Open Source Project and used according
to terms described(C) 2013 Moko365 Inc. All Rights Reserved.
Copyright in the Creative Commons 2.5 Attribution License.
138
139. 《八屏⼀一雲時代來臨 教你HTML5六小時打通關 》
Canvas
HTML5 新增的繪圖標籤
不同瀏覽器的支援程度不同
Copyright (C) 2013 Moko365 Inc. All Rights Reserved.
139