Slide 1

Slide 1 text

Introduction to Mobile Development Every new phone has a Web browser Soon mobile usage will eclipse desktop usage Still trying to figure out the right solutions

Slide 2

Slide 2 text

How Mobile Web Differs • Mobile browser support is inconsistent • Mobile devices are smaller and slower • Different input tools (stylus, fingers) • Different browsers • 320 x 480 pixels is a common resolution for mobile • Not all mobile devices are “smart” Inconsistent particularly with CSS and JavaScript Networks are particularly slower Different input tools affects UI Opera mini and Opera mobile are the world’s most popular mobile browsers.

Slide 3

Slide 3 text

Development Options • Mobile-responsive Web Design • Mobile-first Responsive Web Design • Mobile-specific Version of a Web site Mobile-first = very similar to progressive enhancement, also called content-first design Plus, mobile app, which is an entirely different thing.

Slide 4

Slide 4 text

Responsive Web Design • techniques developed by Ethan Marcotte in 2010 • adapt layouts to the environment • largely uses CSS RWD, still cutting edge simple and quick way to make a Web site work on many devices

Slide 5

Slide 5 text

Responsive Web Design • Deliver same HTML and CSS to all devices • CSS media queries determine what to apply to current environment • Only custom CSS for the elements that need to be treated differently • Identify breakpoints • Maybe use JavaScript Draw diagram breakpoints are the resolutions at which the layout should be changed

Slide 6

Slide 6 text

Responsive Web Design • CSS3 media queries • Fluid-grid layouts • Images and media scale to fit using CSS • Change image sources in CSS Fluid grid layouts: percentages, not pixels

Slide 7

Slide 7 text

CSS Media Queries @media screen { /* rules */ } @media screen and (min-width: 480px) { /* rules */ } @media screen and (monochrome) {} @media screen and (color) {} @media all and (orientation: landscape) {} queries and logical expressions that evaluate the current values of media features in the user's browser logical "or" is represented by a comma You can also use @import Media queries can also be used to upscale: e.g., tv’s and newer displays

Slide 8

Slide 8 text

CSS Media Features • aspect-ratio • height • width • orientation These are some of the properties you can watch for.

Slide 9

Slide 9 text

RWD Goals • Reduce to a single column • Use a vertical layout • Reduce image sizes You can generally leave typography and colors alone. Mostly focus on layout and sizes of elements: the structure of the page.

Slide 10

Slide 10 text

CSS Media Queries & IE Not supported in IE8 and earlier You can use the conditional comments, only supported by IE, to add in IE specific CSS.

Slide 11

Slide 11 text

Fluid Layouts • Default body font size of 100% • Adjust percentages for widths • Set images and objects to a max width of 100% • img, object { max-width: 100%; } • Don’t use IMG width and height attributes Fonts can also be in ems Heights are tough to size and you can use hard numbers where necessary images and objects are limited to 100% of their container 1em = 100% ≈ 12pt ≈ 16px

Slide 12

Slide 12 text

Calculating Percentages Element Size Original Context Size percentage Total width should be 100% If you use a 960 full width and a column is supposed to be 240 pixels, that’s 25% If an element is within another container, based the percentage on that container

Slide 13

Slide 13 text

Using viewport affects zooming always want one bug in iOS

Slide 14

Slide 14 text

RWD Pros and Cons • Just one site • Not about the device • Development time • Device may download too much data/ unnecessary data • Hard to adjust for all possible devices and configurations A lot of testing Loading time can be poor Cross-browser compatibility can be poor

Slide 15

Slide 15 text

Mobile-First • Start with basic functionality • Add dynamic features when supported • Also uses CSS3 media queries You can use tools like sencha.io src to dynamically serve different image sizes

Slide 16

Slide 16 text

PE Pros and Cons • Just one site • Theoretically supports all devices • Focuses on accessibility first • Development time • Some users may get a more basic result than they should

Slide 17

Slide 17 text

Mobile Web Site • Build a separate site • All users go to main domain • Detect and redirect Detection is done via user-agent sniffing. Most major Web sites do do this. www.detectmobilebrowsers.com XHTML-Basic replaces XHMTL-MP

Slide 18

Slide 18 text

Mobile Web Development • Use XHTML-Basic • Use CSS-Mobile Profile These are alternatives to the common standards.

Slide 19

Slide 19 text

Mobile Site Pros and Cons • Better performance for mobile uses • better results for mobile users • Won’t impact desktop users • A lot more development time • Requires server configuration • False identifications

Slide 20

Slide 20 text

Development Tools • W3C Markup Validator • Desktop Browsers (and YSlow!) • Mobile Perf Bookmarklet • Proxy server (e.g. Blaze Mobitest) • Mobile Emulators • Some devices Also Charles Proxy for desktop No real plug-ins for mobile browsers Read articles online for what devices to have. Borrow devices. Try your site at a phone carrier store! Online services for testing on devices.

Slide 21

Slide 21 text

PERFORMANCE • Load time • Page size • Waterfall charts (e.g. HTTP Archive file) • Put non-essential JavaScript at the bottom Reduce image sizes, can reduce image quality for some mobile devices HTTP Archive = HAR Note that just hiding or not displaying content doesn’t help performance.

Slide 22

Slide 22 text

Be Future Friendly • Semantic markup • Progressive enhancement

Slide 23

Slide 23 text

Introduction to jQuery Mobile Is iOS-centric. Used for creating a separate, mobile version of a Web site You can use CSS Media Queries with this, for example, to create a tablet version that’s different than a phone version.

Slide 24

Slide 24 text

How jQuery Mobile Works • Built on top of jQuery • Mostly about UI • Supports custom (i.e., mobile) events • Will use Ajax to download and update content dynamically • ThemeRoller • Progressively enhanced UI example: lists that look like iOS lists, even with thumbnails Automatically truncate long names that go on UI elements Events include tap, swipe, and orientation changes jQuery Mobile won’t be a problem for users that don’t support JavaScript. Can even use it with PhoneGap to build native-like apps Great accessibility

Slide 25

Slide 25 text

Incorporating jQuery Mobile

Slide 26

Slide 26 text

Invoking jQuery $(document).ready(function() { // Your jQuery commands go here before the mobile reference }); If you’re doing mobile-specific JavaScript, you’d place that after the inclusion of the jQuery mobile script.

Slide 27

Slide 27 text

Invoking jQuery Mobile $(document).ready(function() { // Your jQuery commands go here before the mobile reference }); If you’re doing mobile-specific JavaScript, you’d place that after the inclusion of the jQuery mobile script.

Slide 28

Slide 28 text

A Standard Page !
!

Header

!
!

Content goes here

!
!

Footer

!
data-* attribute added in HTML5 Used by jQuery Mobile to help format elements. The header, content, and footer are optional. You can put multiple page elements in one HTML file and jQuery mobile will treat them as separate pages but they’ll be downloaded immediately.

Slide 29

Slide 29 text

Data-Roles • page • header • footer • navbar • listview • button

Slide 30

Slide 30 text

Ajax Navigation • User never leaves the initial page! • jQuery Mobile loads linked pages via Ajax for a better UX • jQuery Mobile updates the URL hash to create unique URLs Much better, more app like experience. You can even prevent Ajax-loading by adding rel=”external” to a link.

Slide 31

Slide 31 text

Other Data-* • data-theme • data-nobackbtn • data-icon • data-position • data-transition • data-rel themes are the letters a through e, which represent swatches or color patterns no back button used within the header to prevent automatic creation of the back button if you add the data-position=”fixed” to the header or footer, it will always stay there use data-transition to change transition data-rel can make a page appear like a dialog

Slide 32

Slide 32 text

Using Themes

Slide 33

Slide 33 text

Transitions • Slide • Slideup • Slidedown • Pop • Fade • Flip These are built-into jQuery Mobile. Can be applied to any object or page change event. Reverse effect is applied to Back button usage.

Slide 34

Slide 34 text

App-Like Layouts • persistent navbar • Native-like buttons • Persistent header

Slide 35

Slide 35 text

Creating Navbars
!
! ! !
Treats content like buttons

Slide 36

Slide 36 text

Layout Tools • Layout grids • Accordions Layout grids are for creating columns. Accordions are for collapsable content.

Slide 37

Slide 37 text

Creating Lists Mobile friendly list Each element in the list behaves like a button link to that page. Supports icons! You can have nested lists. data-inset creates curved corners and margins data-role=”list-divider” to break into sections data-filter=”true” property is awesome!

Slide 38

Slide 38 text

Creating Dialogs Pop up! The key is the data-rel=”dialog” attribute. Must be a reference to a complete HTML jQuery Mobile page. Rounded corners, margins, dark background. May want to specify the transition for it.

Slide 39

Slide 39 text

Cancel and Save
Cancel
Submit

Slide 40

Slide 40 text

Creating Forms
Your Name:
Use full path for the action attribute Form elements are touch optimized versions of standard inputs. Wrap each label-input pair in a div with a data-role of “fieldcontain” Labels and fields will be arranged based upon the available width