App Framework is a JavaScript library for mobile HTML5 app development. It allows you to build simple, rich and full HTML5/JavaScript mobile applications. This short tutorial is an introduction to the App Framework, and it presents the basic concepts and its main concepts.
App Framework library is inspired by jQuery. App Framework can design powerful interfaces for mobile devices such as Android or iOS. App Framework is composed of three elements: a library of queries and event management, a library of graphical interface and a plugin for WebKit library.
The library is functionally richer than jQuery Mobile. Another strong point of App Framework is that it requires only 3KB of memory against 35KB for jQuery. Scripts are also three times faster than jQuery on Android, and 2.2 times more faster on iOS.
Competing Frameworks
There are several competing frameworks to App Framework. These frameworks have more or less the same functionality as App Framework. We can mention among the best known: jQuery Mobile, Sencha Touch, jQTouch. The biggest advantage of App Framework is its weight and its execution speed. App Framework is the most powerful solution for mobile HTML 5 frameworks.
Prerequisites
Creation of a proxy
For the specific needs of the tutorial, we will need to make cross-domain requests through Ajax. To set up an Apache and PHP server is necessary in order to process these requests. Since JavaScript does not directly manage the cross-domain requests, we will set up a small proxy through php. Copy and paste the following code into a server.php file located in the same place as our HTML page. The “php_curl” module must be enabled in php.ini.
App Framework is a mobile adaptation of jQuery, so, both Frameworks use the same syntax. For this tutorial it is better to have some knowledge of jQuery. The App Framework can be downloaded at this address. Copy and paste into the directory of your site the following folders and files:
kitchensink
plugins
ui
Note: To test, you need a browser compatible with webkit and HTML5.
Tutorial
We will show you through this example how you can use App Framework to build your mobile application. Briefly, our example will be based on the conception of a small reader of RSS feeds. This is just to give you a basic knowledge of App Framework. Firstly we will build our GUI with jqUI and implement some features with App Framework.
Create a page
As a first step, we will create our page and configure our App Framework. Here is the skeleton of an App Framework Application:
<html>
<head>
<meta content="text/html; http-equiv="Content-type" charset=utf-8"/>
<script src="//cdn.app-framework-software.intel.com/2.0/appframework.min.js" type="text/javascript">
</script><script type="text/javascript" charset="utf-8"src="./ui/appframework.ui.min.js">
<link rel="stylesheet" type="text/css" href="css /af.ui.css"title="default" />
</script><script>
$.ui.ready (function ( ) {
$.ui.backButtonText ="Back". / / We override the back button text to always say" Back"
} ) ;
if (! ( (window.DocumentTouch && document instanceof DocumentTouch ) | | ' ontouchstart ' in window )) {
var script = document.createElement (" script");
script.src =" plugins/af.desktopBrowsers.js" ;
var tag = $ (" head" ). append ( script) ;
$.os.android = true;. / / let 's make it run like an android device
$.os.desktop = true. ;
}
</script>
</head>
<body>
<div id="afui">
</ div>
</ body>
</ html>
Create a page “index.html” in the root of your server and add the code above. This code is the base of our page, it imports the scripts that are necessary to use App Framework.Our application will be decomposed into two components: a page and its content and a menu. With App Framework, in order to create a page, we will create several divs inside the “content” div of our HTML file.
We’ll start by creating our main page “RSS” It will contain an input that allow the user to enter an RSS link and a panel containing the list of titles in the RSS flow. In the “afui” div we will add the “content” div. It is within this specific div that we will create the different pages of our application. Our first page will be titled “RSS”.