jquery mobile: progressive enhancement with html5

55
jQuery Mobile: Progressive Enhancement with HTML5

Upload: todd-anderson

Post on 28-Jan-2015

121 views

Category:

Technology


3 download

DESCRIPTION

An overview of the jQuery Mobile framework and its foundation on Progressive Enhancement, as well as a few techniques on breaking a jQM application from the "traditional" browser.

TRANSCRIPT

Page 1: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile:Progressive Enhancement with HTML5

Page 2: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobileand Progressive Enhancement

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile

+JS

with

or really

but never

Page 3: jQuery Mobile: Progressive Enhancement with HTML5

Todd Anderson

jQuery Mobile: Progressive Enhancement with HTML5

Progressively Enhanced from NJ.Currently resides in Boston.

Shows displeasure for right-aligned fields.Took a picture of himself in a kitchen at least once.

Senior Software Engineer

[email protected]

@bustardcelly

100% Centaur

Author

Who?

kitchenphoto_3421.jpeg

http://twitter.com

http://infrared5.com

Page 4: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

What?

• 1.0 Alpha 4.1• Built on jQuery + jQuery UI* (Widget)• Cross Platform• A-grade browser support

http://jquerymobile.com

Page 5: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQM Graded Browser Support

http://jquerymobile.com/gbs/

Page 6: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

How?

• Progressive Enhancement• HTML5 dataset attribute (data-)• CSS3 & Themes• Unobtrusive JavaScript

http://jquerymobile.com

Page 7: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

Progressive Enhancement: Content

http://www.flickr.com/photos/bamawester/97776370/

Page 8: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

http://www.flickr.com/photos/bamawester/97776370/

Progressive Enhancement: Content + Presentation

Page 9: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

http://www.flickr.com/photos/bamawester/97776370/

http://selleckwaterfallsandwich.tumblr.com/

Progressive Enhancement:Content + Presentation + Behavior

Page 10: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

How?!

data-role

Page 11: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile Pages

data-role=”page”<!DOCTYPE html><html> <head> <title>Hello World</title> <link rel="stylesheet"

href="style/jquery.mobile-1.0a4.1.min.css"/>

</head> <body> <div data-role=”page”> <p>This is so selleck.</p> </div> </body> <script src="script/jquery-1.6.1.min.js"></script> <script src="script/jquery.mobile-1.0a4.1.js"></script></html>

Page 12: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile Pages

Page Anatomy<!DOCTYPE html><html> <head> <title>I am sure to mistype something when I show code.</title> <link rel="stylesheet" href=”style/jquery.mobile-1.0a4.1.min.css"/> </head> <body> <div data-role=”page”> <div data-role=”header”><h3>jQuery Mobile Pages</h3></div> <div data-role=”content”> <p class=”content-header”>Page Anatomy</p> </div> <div data-role=”footer”> <p class=”footer-right”>jQuery Mobile: ProgEnhan with HTML5</p> <img src=”fatc-logo.png” alt=”FATC” /> </div> </div> </body> <script src="script/jquery-1.6.1.min.js"></script> <script src="script/jquery.mobile-1.0a4.1.js"></script></html>

required

optional

Page 13: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile pages

page demo

Page 14: jQuery Mobile: Progressive Enhancement with HTML5

[rel=”external”] : multiple internal pages

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile Pages

Internal vs. External

href : #anotherpage

Internal

multiple internal pages

href : anotherpage.html

External

[data-ajax=”true”] : 1 internal page

[data-ajax=”false”] : multiple internal pages

Page 15: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile pages

pages demo

Page 16: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

blah blah mist blah blah hungry blah

dialogMessages

i think my presentation is going well!

do you, now?

*sigh* whatʼs happened between us?

you keep complaining about “mist”. itʼs annoying.

Page 17: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile pages

dialog demo

Page 18: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

methods & properties$.mobile

API

configuration

• $.mobile.path• $.mobile.base• $.mobile.silentScroll()• $.mobile.addResolutionBreakpoints()• $.mobile.activePage• $.mobile.pageLoading()• $.mobile.changePage()

Page 19: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

configuration

<script src="script/jquery-1.5.2.min.js"></script><script type="text/javascript"> (function( $, document ) { $(document).bind( "mobileinit", function() { $(document).unbind( "mobileinit"); $.extend( $.mobile, { ns: “custom-" }); }) })( jQuery, document );</script><script src="script/jquery.mobile-1.0a4.1.min.js"></script>

$.mobile

configuration

API • ns• defaultTransition• gradeA()• ajaxEnabled• more...

* custom namespace requires change to .ui-mobile in css

Page 20: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

.jqmData()

data access

$(page).find(“div:jqmData(role=ʼcontentʼ)”);

$(elem).data( key );

jQuery

$(elem).jqmData( key );

jQuery Mobile

$(elem).data( key, value );

$(elem).jqmData( key, value );

Page 21: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

itʼs our time, down here.

$(50).find(“:jqmData(hideout=ʻfratelliʼ)”);

real world

Page 22: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

this is so sandwich right now

UI Widgets

button

controlgroup

navbar

toolbars

form elements

list

Page 23: jQuery Mobile: Progressive Enhancement with HTML5

data-iconpos=”right”

jQuery Mobile: Progressive Enhancement with HTML5

buttons and such

data-role=”button”

data-iconpos

data-icon

rate

waddle

<a href=”#stop” data-role=”button”>no whammy!</a>

<button><button type=”submit” name=”submit” value=”submit-stop”>no whammy!</button>

swimdata-iconpos=”left” data-iconpos=”notext”

data-icon=”star”

Page 24: jQuery Mobile: Progressive Enhancement with HTML5

false [default]

jQuery Mobile: Progressive Enhancement with HTML5

jQM button group layout: inline

organization• data-inline

true

eep

quack

ow

eep quack ow

Page 25: jQuery Mobile: Progressive Enhancement with HTML5

• data-inline• data-role=”controlgroup”• data-type

jQuery Mobile: Progressive Enhancement with HTML5

jQM button group layout: controlgroup

organization

horizontalvertical [default]

home

favorites

settings

home favorites settings

Page 26: jQuery Mobile: Progressive Enhancement with HTML5

• data-inline• data-role=”controlgroup”• data-type• data-role• ui-grid-[a to d]• ui-block-[a to d]

home favorites settings

jQuery Mobile: Progressive Enhancement with HTML5

jQM button group layout: ui-grid

organization

Page 27: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile buttons!

button demo

Page 28: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQM button group layout: navbar

organization• data-inline• data-role=”controlgroup”• data-type• data-role• ui-grid-[a to d]• ui-block-[a to d]• data-role=”navbar”

Page 29: jQuery Mobile: Progressive Enhancement with HTML5

$(“div:jqmData(role=ʼnavbarʼ)”).bostonize();

jQuery Mobile: Progressive Enhancement with HTML5

jQM button navbah

data-role=”navbar”

cah mayah tonic

car mayor soda

<div data-role="navbar" data-grid="b"> <ul> <li><a href="#">home</a></li> <li><a href="#">settings</a></li> <li><a href="#">favorite</a></li> </ul></div>

• data-grid• column count • a(2) - d(5)

Page 30: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile buttons!

navbar demo

Page 31: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

lost password?

forms!

Page 32: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

form markup and makeup

forms

<form id=”myform” action=”login.php” method=”post”>...

</form>

• declaration

• content<label for="name">Username:</label><input type="text" name="name" id="name" value="" />

$(“myform”).bind( “submit”, function( event ) {...

});

• event

Page 33: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

demo

form demo: jQM docshttp://jquerymobile.com/demos/1.0a4/#docs/forms/forms-all.html

Page 34: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

form elements

$(“input[type=’text’]”).textinput(“disable”);

var myselect = $("select#myselect");myselect[0].selectedIndex = 0;myselect.selectmenu("refresh");

$(“#myform”).find(“input”) .filter(“[type=’checkbox’], [type=’radio’]”) .attr(“checked”, false) .checkboxradio(“refresh”);

selectmenuvar myselect = $("select#myselect");myselect[0].selectedIndex = 0;myselect.selectmenu("refresh");

slider

$("input[type=range]").val(100).slider("refresh");

checkboxradio

textinput

form element widgetshttp://jquerymobile.com/demos/1.0a4/docs/forms/docs-forms.html

Page 35: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

native data attributes

native*

* Must be declared on element prior to load of jQuery Mobile. Cannot be assigned and refreshed at runtime.

• provides no enhancement • data-role=”none”• data-native-menu=”true”

Page 36: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

lists

data-role=”listview”

Page 37: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQM item renderers

list item renderers

easy to create own custom list item renderers

no extra data-roles!

inspects the children declaration within a list item (<li>)

icon list item renderers, split button lists

look sorta like this by default

Page 38: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile lists

lists demo

Page 39: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

themes

themes• jQM provides 5 color swatch schemes• -a through -e; allows up to 26

• DO NOT DOUBLE-UP WRAP-AROUND!• eg. ui-bar-aa

Page 40: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

themes

beyond color swatches• valencia

http://jquerymobile.com/test/themes/valencia/

• ThemeRollerhttp://jqueryui.com/themeroller/

Page 41: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

accessibility

WAI-ARIA

Introduction to WAI ARIAGez Lemon, August 1 2008

• Roles, States and Properties• Keyboard navigation with tabIndex• Live Regions for dynamic content

http://dev.opera.com/articles/view/introduction-to-wai-aria/

http://www.w3.org/WAI/intro/aria.php

Page 42: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

accessibility

screen reader demo*

*shamelessly re-presented as seen in a Scott Jehl presentationhttp://dayofjs.com/videos/22152945/jquery-mobile_scott-jehl

Page 43: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

cʼmon already!

enhancement load

file min-gzip

jquery.min.js 31KB

jquery.mobile.min.js 19KB

jquery.mobile.min.css 7KB

57KB

Page 44: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

perception techniques

css<head> ... <link rel="stylesheet" href="style/jquery.mobile-1.0a4.1.min.css" /> <style type="text/css"> body { display: none; visibility: hidden; } </style></head><body>...</body><script src="script/jquery-1.6.1.min.js"></script><script src="script/jquery.mobile-1.0a4.1.min.js"></script><script type="text/javascript"> function showPage() { $("body").css( "visibility", "visible").css( "display", "inherit" ); } $().ready( showPage );</script>... eh...

Page 45: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

perception techniques

LabJS<html> <head> <title>labjs</title> <link rel="stylesheet" href="style/jquery.mobile-1.0a4.1.min.css" /> </head> <body> <p>loading...</p> </body> <script src="script/LAB.min.js"></script> <script> $LAB .script("script/jquery-1.6.1.min.js") .script("script/jquery.mobile-1.0a4.1.min.js").wait( function() { $("body").load("jqm_page.html"); }); </script></html>

better!

http://labjs.com/

Page 46: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

outta the browser... sorta

web-app

Page 47: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

home

home screen<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=false;"/>

• metadata

<meta name="apple-mobile-web-app-capable" content="yes" /><meta name="apple-mobile-web-app-status-bar-style" content="black" />

<link rel="apple-touch-icon" href="touch-icon-iphone.png" /><link rel="apple-touch-icon" sizes="72x72" href="touch-icon-ipad.png" /><link rel="apple-touch-icon" sizes="114x114" href="touch-icon-iphone4.png" /><link rel="apple-touch-startup-image" href="start-up-image.png" />

• webclips & appearance

http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safariwebcontent/configuringwebapplications/configuringwebapplications.html

http://developer.apple.com/library/safari/#documentation/appleapplications/reference/SafariHTMLRef/Articles/MetaTags.html

Page 48: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

we bapp

web-app demo

Page 49: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jQM home applications

web-app considerations

• use AJAX on change page• else will launch the browser• include Back buttons in header• use window.navigator.standalone• cache.manifest

higgins!

http://diveintohtml5.org/offline.html

Page 50: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

native deployment

native (easily)existing jQM application -> native install

Page 51: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

native deployment - PhoneGap

PhoneGap

• project templates• JS API for native access (limited)• PhoneGap Build (Beta invite)

http://www.phonegap.com/

Page 52: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

native deployment - Adobe AIR

Adobe AIR

• SDK compiler tools• StageWebView• JS <--> AS = iffy on device

Making the most of StageWebViewSean Voisen, October 29 2010http://voisen.org/blog/2010/10/making-the-most-of-stagewebview/

http://labs.adobe.com/technologies/flashplatformruntimes/

Page 53: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

native deployment - others

native: othersNimbleKit

http://www.nimblekit.com/

QuickConnectFamily

http://quickconnectfamily.org/

Titanium*

http://www.appcelerator.com/

Rhodes**

http://rhomobile.com/products/rhodes/

* in theory, using Titanium.UIWEbView

** havenʼt tested

existing jQM application -> native install

Page 54: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

i do like the shirt, though.

questions?*

* except from you in the blue shirt. 3rd row. you know who you are.

Page 55: jQuery Mobile: Progressive Enhancement with HTML5

jQuery Mobile: Progressive Enhancement with HTML5

jquery mobile

thank you!todd anderson / [email protected]

@bustardcellyhttp://github.com/bustardcellyhttp://www.custardbelly.com/blog