• .NET Developer Tools DevTools

    UI controls for ASP.NET AJAX, MVC, WPF,
    Silverlight, Windows 8 and Windows Phone

  • Hybrid Mobile Development Icenium

    Cross-platform Mobile Development Tool
    with cloud-based architecture

  • HTML5 / JavaScript Development Kendo UI

    Everything you need to build sites and
    mobile apps with JavaScript and HTML5

  • Testing Tools TestStudio

    One easy tool for Functional, Performance,
    Load and Mobile software testing

  • Web Presence Platform Sitefinity CMS

    Everything for your online business - content
    management, ecommerce, emarketing

  • Agile Project Management TeamPulse

    Simple and intuitive project management
    and collaboration software

Contact us

We are here for you.
  • usa+1‒888‒365‒2779
  • uk+44‒20‒7291‒0580
  • bg+359‒2‒8099850
  • de+49‒89‒2441642‒70
  • au+61‒2‒8090‒1465
  • emailsales@telerik.com
Your account Access to your products, updates and support
Telerik Product Families
  • Your Account
    Your Account
    Log in
  • ABOUT US

    About Telerik

    • Company
    • Press Center
    • Customers
    • Community
    • Careers
    • Contacts
Kendo UI - The way of HTML5
Products ▼
Kendo UI Web Kendo UI Mobile Kendo UI DataViz Server Side Wrappers
Demos Purchase Download
Blogs Documentation
Support ▼
Premium Forums StackOverflow Forums
Resources ▼

Featured Resource

Kendo UI Dojo


Blogs Code Library Demos Documentation FAQ Testing
Premium Forums Roadmap User Voice Videos Webinars More Resources
Contact Us Search
 

Blogs

Universal Mobile Apps with HTML5 and Kendo UI

Tuesday, September 11, 2012 by Kendo UI Team Blog | Comments 3

At its core, Kendo UI Mobile makes it easy create cross-platform mobile apps using HTML5 and JavaScript. And more than any other framework, Kendo UI Mobile helps your apps automatically adapt to look and feel native on different platforms, like iOS and Android. But did you know that Kendo UI Mobile can also help build apps that look and feel native on different form-factors?

“Universal” apps allow you to build and deploy a single app that automatically presents phone-specific UI on phones, and tablet-specific UI on tablets.

The concept is familiar to iOS developers, where Apple introduced universal apps to support iPhone and iPad app development, but the same can be achieved with cross-platform results using HTML, JavaScript, and Kendo UI Mobile. You build one app, with UI for phones and tablets, and deploy to iOS, Android, and Blackberry.

Let’s examine the technique.

Tablet Specific UI

When building mobile apps to reach phone and tablet users, there are two options for supporting tablets:

  1. Deploy a single phone UI that simply scales-up on tablets
  2. Deploy an additional tablet-optimized UI that takes advantage of larger tablet screens

The first option is the easiest and least expensive because it only requires one app design. It eliminates the need to work through a second design for an app that is optimized for tablets.

Of course, Option #1 also fails to treat tablets like a unique form factor. More than a bigger screen, tablets have unique UI conventions not found on smartphones, such as the split views common in iPad apps. Developers serious about targeting tablets should aim to deploy apps that are optimized for these unique usability requirements. Building one app with one UI is easy, but it’s not enough to properly target multiple form factors.

Universal apps simplify the deployment of two distinct app experiences, while simultaneously making it easier for developers to share common app code between phone and tablet app variants (like common data handling code). When developers take the time to design unique experiences for both form factors, universal apps help put the right experience on the right device.

Fortunately, Kendo UI Mobile provides both tablet and phone specific UI widgets. Developers can leverage these widgets to create a perfectly tailored UI for both form factors, and then apply the following universal technique to easily deploy the results.

Universal Technique

Building a universal mobile app using Kendo UI Mobile is not automatic, but it is very simple. There are 3 steps involved in the entire process:

  1. Build phone AND tablet specific mobile app views using Kendo UI Mobile (remember this is not a one-size-fits-all experience, you need views for both form factors)
  2. Use Kendo UI to detect and profile the device using the app (phone or tablet)
  3. During app initialization, initialize EITHER the phone OR tablet views in your app

That’s it. Like I said, easy. The result allows the same deployed app to look like this on phones:

And like this on tablets:

In code, handling a universal app looks something like this:

HTML

<div id="tabletApp" style="display:none;">
   <!--Initial tablet mobile app views/splitview go here-->
</div>
<div id="phoneApp" style="display:none;">
   <!--Initial phone mobile app views/layouts go here-->
</div>​

JAVASCRIPT

$(function() {
    var app,
    //isTablet: Must be mobile OS AND tablet
    isTablet = kendo.support.mobileOS && kendo.support.mobileOS.tablet,
    appElement = null,
    appLayout = null;
 
    //Get the correct app HTML container based on tablet status
    appElement = (isTablet) ? $("#tabletApp") : $("#phoneApp");
    appLayout = (isTablet) ? null : "phoneDefault";
 
    //Initialize the app with the selected container
    app = new kendo.mobile.Application(appElement, {
        layout: appLayout,
        transition: 'slide'
    });
 
    //Adjust visibility of proper app container (used to prevent FOUJUI)
    appElement.show();
});​

You can try a live example using this jsFiddle. To test the behavior, I recommend using Chrome and the built-in Developer Tools to override the browser’s User Agent. Try changing between an iPhone and iPad UserAgent to see how the app initializes differently (refresh the page to see the app reinitialize).

REMINDER: Kendo UI Mobile only supports Webkit browsers today, so the previous demo will not work in IE or Firefox. Please use a mobile device or Chrome/Safari to view the demo.

In english, the prior code snippet is conceptually doing this:

  1. Using the Kendo UI API, which builds a complete profile of a mobile device when an app runs, we determine if the current device is a mobile OS and a tablet.
  2. If the device is a tablet, we grab the HTML element containing our initial tablet app view. If it’s not a tablet, we grab the container for our phone app view.
  3. Since the tablet view uses a SplitView, we do not need a app layout element. If it’s a phone, we specify our default view layout.
  4. Finally, we initialize the Kendo UI Mobile Application using the configured variables.
  5. And for a little extra polish, we use some CSS to avoid FOUJUI (more on this in a minute)

The net effect is a single app containing all of the HTML, CSS, and JavaScript for both tablet and phone users that can be “universally” packaged and deployed via the browser or in hybrid app containers (like PhoneGap).

Universal App and FOUJUI

When using the universal app approach, the “Flash of Uninitialized JavaScript UI” (or FOUJUI) can be particularly distracting because the initial HTML page contains markup for both the tablet and mobile views. To provide a polished loading experience and avoid displaying unsightly HTML, it is important to address FOUJUI with some simple CSS and JavaScript.

In the example linked above, I use this technique:

<div id="tabletApp" style="display:none;">
...
</div>
<div id="phoneApp" style="display:none;">
...
</div>​

As you can see, both HTML containers for the tablet and phone views are initially hidden via CSS. As part of the loading process, the correct container is shown after the Kendo UI Mobile application has been initialized:

appElement.show(); //Where appElement is either the phone or tablet container

You could make the effect even fancier with CSS3 transitions and opacity:

CSS

#tabletApp, #phoneApp {
   -webkit-transition:opacity 2s;
   transition:opacity 2s;
}

HTML

<div id="tabletApp" style="display:none;opacity:0;">

JAVASCRIPT

appElement.show();
appElement.css(“opacity”,1);

Now the correct app will fade in to view (hardware accelerated by CSS), and the unused views will remain properly hidden. No flash of uninitialized HTML. No ugly plain HTML displayed to users before your app is ready to go.

Automatic Tablet UI & Responsive Design

After trying this technique, the question often arises: “Why doesn’t Kendo UI Mobile automatically adapt phone UI for tablets?”

The answer is simple: we don’t know how. It’s not that we’re technically incapable, but adapting a phone UI to a tablet UI is not so dissimilar from trying to automatically adapt desktop UI to a phone. They are fundamentally different platforms with different usability considerations, and something that makes sense on phones may or may not belong on tablets. There is no predictable way to automatically transpose phone UI to tablet-specific UI.

Of course, Kendo UI Mobile apps can be built to run on both tablets and phones with a single UI, but as with any “one size fits alls” app, you will lose the benefit of optimizing for specific platforms.

What about responsive design, you ask?

Responsive design is great for creating mobile sites, but it’s not as useful for creating mobile apps. Responsive design can help you hide, show, resize, and reformat UI for screens of varying size, but it is less suited for presenting completely different modes of usability on different form factors.

What’s Next?

This is where we need your feedback again. We think the process for creating and configuring universal apps with Kendo UI Mobile is easy today, but clearly we could do more to make the process even easier to configure.

What else would you like Kendo UI Mobile to do for you if you’re building universal apps? Should we make it easier to define the entry points to the phone/tablet app UIs? Should we enhance any of the APIs?

Let us know. Sound-off in the comments and on the Kendo UI UserVoice site: feedback.kendoui.com.

For now, have fun building (and deploying) universal mobile apps created with Kendo UI Mobile!

About the Author
Todd Anglin is an avid HTML5, CSS3, and JavaScript advocate, and geek about all things web development. He is an active speaker and author, helping developers around the world learn and adopt HTML5. Todd works for Telerik as VP of HTML5 Web & Mobile Tools, where his current technical focus is on Kendo UI. Todd is @toddanglin on Twitter.

3 Comments

  1. 1 Guillermo 18 Sep 2012
    Our goal is to create a web form capable of being displayed on a desktop, tablet or phone and being functional on every instance, even though it may not be offer the best user experience on one of them. We work on the layout using floats and responsive design to tickle the UI  but there are issues like the use of kendoweb dropdowns on mobile that make this reality very hard to accomplish; problem that we are trying to solve changing the kendoweb dropdown CSS styling to follow more a kendomobile dropdown list container for smaller widths and user agents. I know you have very powerful motives to separate mobile from web, but that force developer to think into separate solutions instead of one html5 solution for all.  Just an opinion from a kendo fan !! keep the good work... 
  2. 2 Jack 19 Sep 2012
    With 7" tablets, you might want the phone layout in portrait mode and the tablet layout in landscape mode. How would you achieve that? Any recommendation to detect the rotate event?
  3. 3 Stephen Howe 26 Jan 2013
    Hi Todd,

    We are looking to build a "real" universal app in the sense that we would like one code base across desktop web and mobile web applications. Currently it seems that you have separate frameworks for web and mobile, which would means that we need two separate code bases, therefore it would not be universal in the sense we desire. Is it possible to use both frameworks in conjunction in order to smoothly achieve our goal? We would not want to head down this road to find many bumps along the way. 

    We have 3 options:
    • One codebase for each device (desktop and tablet)
    • One codebase for both devices
    • Responsive design web app which "responds" to either device's resolution
    In your experience what is better, one codebase or two? And if we go the responsive design route are there any major pitfalls using your framework?

    FYI: We have lots of experience with Kendo Web but none with Keno mobile. Also We are only interested on  running on web and Tablets not smartphones. We are building a behind the firewall enterprise application.

    Thanks,

    -Stephen

Comment

  1. Click to add

  2. Click to add

  3. Click to add

  4.    
     
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
     
      
       
Blogs feed
Categories

  • Tutorials (26)
  • Release (33)
  • Browsers (7)
  • Extensions (3)
  • Tip of the Week (10)
  • Videos (5)
  • Concepts and Theory (13)
  • Misc. (25)
  • Framework Constructs (6)
  • Mobile (6)
  • UI Widgets (5)
  • Blogs (1)
Archive
  • 2013 May (6)
  • 2013 April (10)
  • 2013 March (9)
  • 2013 February (12)
  • 2013 January (10)
  • 2012 December (9)
  • 2012 November (11)
  • 2012 October (6)
  • 2012 September (7)
  • 2012 August (8)
  • 2012 July (10)
  • 2012 June (8)
  • 2012 May (10)
  • 2012 April (7)
  • 2012 March (13)
  • 2012 February (10)
  • 2012 January (6)
  • 2011 December (10)
  • 2011 November (4)
  • 2011 October (6)
  • 2011 September (5)
  • 2011 August (9)
Home Web Mobile DataViz Server Wrappers Whitepapers Surveys Chrome Icenium Contact Us

Kendo UI framework is developed by Telerik - a leading provider of UI components for web, desktop and mobile applications. Trusted by over 100,000 customers worldwide for our devotion to quality and industry-best technical support, Telerik helps professionals maximize their productivity and "deliver more than expected" every day.

kendoui - powered by html5, css3 & jquery
get social
  • Twitter
  • Facebook
  • Google plus
  • RSS
Privacy Policy | Branding Guidelines
Powered by Sitefinity CMS

Copyright © 2011 - 2013 Telerik Inc. All rights reserved.