mobile web with jquery mobile

35
Andreas Bjärlestam 2011-05-25

Upload: andreas-bjaerlestam

Post on 27-Jan-2015

130 views

Category:

Technology


5 download

DESCRIPTION

This presentation is an introduction to mobile web development with jQuery Mobile

TRANSCRIPT

Page 1: Mobile web with jQuery Mobile

Andreas Bjärlestam 2011-05-25

Page 2: Mobile web with jQuery Mobile

Web vs Apps

• Referral traffic is lost with Apps• Google does not index Apps• Customers are already going to the website• Cross device• Apps are in the hands of platform vendors

Page 3: Mobile web with jQuery Mobile

FrameworksFrameworks

Frameworks

Page 4: Mobile web with jQuery Mobile

For building mobile applications with web technology

For building mobile friendly websites

Sencha Touch

SproutCore jQTouch

jQuery Mobile

dojox.mobile

Page 5: Mobile web with jQuery Mobile

Features

• HTML5 based• Progressive enhancement– Works in less capable browsers but with limited

features• Accessibility– Designed to work with screen readers– WAI-ARIA

Page 6: Mobile web with jQuery Mobile

jQuery means JavaScript right?

Page 7: Mobile web with jQuery Mobile

Well… not in this case

jQuery-mobile development is mostly about markup

Page 8: Mobile web with jQuery Mobile

Pages

Page 9: Mobile web with jQuery Mobile
Page 10: Mobile web with jQuery Mobile

Simple page example

<div data-role="page" id="home">

<div data-role="header"> <h1>Page header</h1> </div>

<div data-role="content"> <h3>Hi!</h3> <p>This is a simple page made with jquery mobile</p> </div>

<div data-role="footer"> <h4>Page Footer</h4> </div>

</div>

Page 11: Mobile web with jQuery Mobile

Page navigation

Page 12: Mobile web with jQuery Mobile

UI elements

List viewsButtons

Dialogs

Popup menusSliders

Checkboxes

Page 13: Mobile web with jQuery Mobile

<form action="form.php" method="post">

<label for="slider">Slider: </label> <input type="number" data-type="range”

name="slider" id="slider" min="40" max="80" value="50"/>

<label for="q">Search: </label> <input data-type="search" name="q" id="q"/>

<fieldset data-role="controlgroup"> <legend>Choose many:</legend> <input type="checkbox"

name="checkbox-1" id="checkbox-1" /> <label for="checkbox-1">Option 1</label>

<input type="checkbox" name="checkbox-2"

id="checkbox-2" /> <label for="checkbox-2">Option 2</label>

<input type="checkbox" name="checkbox-3"

id="checkbox-3" /> <label for="checkbox-3">Option 3</label> </fieldset>

<label for=”switch">Flip switch:</label> <select name=”switch" id=”switch"

data-role="slider"> <option value="off">Off</option> <option value="on">On</option> </select>

</form>

Page 14: Mobile web with jQuery Mobile

Page transitions

Slide

Flip PopFade

Slide upSlide down

Page 15: Mobile web with jQuery Mobile

How are these nice effects done?

Page 16: Mobile web with jQuery Mobile

CSS transforms

• GPU accelerated• Compact code = efficient• Currently only implemented for webkit

Page 17: Mobile web with jQuery Mobile

.flip { -webkit-animation-name: flipinfromleft; -webkit-animation-timing-function: ease-in-out; -webkit-animation-duration: 2s; }

@-webkit-keyframes flipinfromleft { from { -webkit-transform: rotateY(180deg); } to { -webkit-transform: rotateY(0); } }

Page 18: Mobile web with jQuery Mobile

How can we handle all these phones?

Page 19: Mobile web with jQuery Mobile

Progressive Enhancement

Page 20: Mobile web with jQuery Mobile
Page 21: Mobile web with jQuery Mobile

Performance in the mobile environment

Page 22: Mobile web with jQuery Mobile

Bandwidth vs Latency

Page 23: Mobile web with jQuery Mobile

Bandwidth Latency

source: http://www.belshe.com/2010/05/24/more-bandwidth-doesnt-matter-much/

Page 24: Mobile web with jQuery Mobile

Latency is bad for wireless

Page 25: Mobile web with jQuery Mobile

Reduce roundtrips to fight latency

Page 26: Mobile web with jQuery Mobile

How does jQuery Mobile handle this?

Page 27: Mobile web with jQuery Mobile

How jQuery fights Latency

• Gradients and shadows with CSS3– No background-images to load

• Image icons in css-sprite• And…

Page 28: Mobile web with jQuery Mobile

Remember WAP and WML?

The Card Deck

Page 29: Mobile web with jQuery Mobile

jQuery mobile supports multiple pages in a single html document

Page 30: Mobile web with jQuery Mobile

JavaScript Event-listenerstap

tapholdswipe

swipeleftswiperight

orientationchange

scrollstartscrollstop

Page 31: Mobile web with jQuery Mobile

Events - examples

$('#tapMe').tap(function(e) { alert('tap!' ); });

$('#home').swipeleft(function(e) { alert('swipe left!' ); });

Page 32: Mobile web with jQuery Mobile

Theming

• Object oriented CSS• Similar to jQuery-UI• CSS3 to minify footprint– Rounded corners– Shadows– Gradients

• Color “swatches”– A theme includes several color schemes that can

be applied on different content

Page 33: Mobile web with jQuery Mobile

data-theme=“b”data-theme=“a” data-theme=“e”

Page 34: Mobile web with jQuery Mobile

Andreas Bjärlestammailto:[email protected]://twitter.com/bjarlestam