UI Development using jQueryMobile

本文介绍jQuery Mobile框架,一种跨平台的触摸优化Web框架,适用于智能手机和平板电脑。通过示例展示了如何将jQuery Mobile与PhoneGap结合使用,创建响应式的移动应用。
Introduction to jQueryMobile



Following is an extract from jQueryMobile site -





jQuery Mobile: Touch-Optimized Web Framework for Smartphones & Tablets



A unified user interface system across all popular mobile device platforms, built on the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design. Alpha Release Notes







Seriously cross-platform & cross-device



jQuery mobile framework takes the "write less, do more" mantra to the next level: Instead of writing unique apps for each mobile device or OS, the jQuery mobile framework will allow you to design a single highly branded and customized web application that will work on all popular smartphone and tablet platforms. Device support grid



iOS
Android
BlackBerry™
Bada
Windows® Phone
Palm webOS™
Symbian
MeeGo™








Touch-optimized layouts & UI widgets


Our aim is to provide tools to build dynamic touch interfaces that will adapt gracefully to a range of device form factors. The system will include both layouts (lists, detail panes, overlays) and a rich set of form controls and UI widgets (toggles, sliders, tabs). Demos











Themable designs: Bigger and better

To make building mobile themes easy, we’re dramatically expanding the CSS framework to have the power to design full applications. For more polished visuals without the bloat, we added support for more CSS3 properties liketext-shadow, box-shadow, and gradients.






Demo Video




Getting started with JQueryMobile



There are two parts to jQueryMobile





jQuery - (Event Handling, DOM Manipulation and Ajax)
jQuery Mobile UI




jQuery - ( Event Handling, DOM Manipulation and Ajax)



This is out of scope for this Article. Please refer to w3c Tutorial on jQuery - http://www.w3schools.com/jquery/default.asp





jQuery Mobile UI



jQuery Mobile Declarative UI

This is the best part about jQuery Mobile. The UI is not declared by using HTML 5 style "data-role". This makes the UI development a breeze. Building a prototype of jQuery Mobile UI (wireframe) would not require any coding, but just html tags.



Lets try to build the following Page in Phone Gap









Step 1 - Include needed Javascript and CSS

<head>

<link rel="stylesheet" href="/jquery.mobile-1.0a1.min.css" />

<script src="jquery-1.4.3.min.js"></script>

<script src="jquery.mobile-1.0a1.min.js"></script>

</head>



Step 2 - Declare different Pages



home is the first screenshot and search is the second screen shot.



<body>

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

.....

</div>



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

.....

</div>



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

.....

</div>



</body>



Step 3 - Declare Header and Page Navigation



<body>

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

<div data-role="header"> <!-- This div with data-role is the header, shown in the black -->

<h1>AlternativeTo Home</h1>

</div>

<div data-role="content"> <!-- This div is the body of the page -->

<p>Find Alternatives To Your favourite Softwares </p>

<p><a href="#search" data-role="button">Search Alternatives</a></p> <!-- navigation button's href points to other page -->

<p><a href="#recent" data-role="button">Recent Alternatives</a></p>

</div>

</div>





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

<div data-role="content">

<ul data-role="listview" id="list"> <!-- Special Widget which is List View to show data in a list -->

</ul>

</div>

</div>





</body>



jQuery Mobile API



The jQuery Mobile API talks about Page Loading, Transition, Dialog box handling, List View manipulation, item click etc.



Complete API reference - http://jquerymobile.com/demos/1.0a3/







JQueryMobile + PhoneGap



Boot Events

The main thing when using any Javascript library is to be handle the library boot strap event. A Boot strap event is when js library hells that it is ok to start using its api





A Boot strap event handling in case of jquery is the as follows





$(document).ready(function() {
//Its ok to use all jquery functions here
});

A Boot strap event handling in case of jQuery mobile is as follows (read more here)


$(document).bind("deviceready", function(){

});

or

document.addEventListener("deviceready", onDeviceReady, false);



These bootstraps need to be chained (i,e one calling another one), in order to properly bootstrap both jquery/jquerymobile and phonegap.

Ideally following should be enough ( PS- I need to verify the following code)



$(document).ready(function() {

$(document).bind("deviceready", function(){

});
});





Rest of Integration

The Rest of the Integration is using jQuery selector, event handling to call jQueryMobile and phonegap api.





Demo Apps



Following is the Demo App, with complete index.html file of the UI






Source Code



<!DOCTYPE HTML>

<html>

<head>

<title>PhoneGap</title>

<script type="text/javascript" charset="utf-8" src="phonegap-0.9.3.js"></script>





<link rel="stylesheet" href="/jquery.mobile-1.0a1.min.css" />

<script src="jquery-1.4.3.min.js"></script>

<script src="jquery.mobile-1.0a1.min.js"></script>



<script type="text/javascript">



$( function() {



$('#searchButton').click(function() {







$.getJSON('http://api.alternativeto.net/software/'+$('#searchBox').val()+'/?count=15',

function(data) {



var items=data.Items;

var list = $('#list');

list.html("");

$.each(items, function(key, val) {



list.append(

$(document.createElement('li')).html(val.Name)

);

});





list.listview("destroy").listview()



});



});



document.addEventListener("deviceready", onDeviceReady, false);



} );



function reachableCallback(reachability) {

// There is no consistency on the format of reachability

var networkState = reachability.code || reachability;



var states = {};

states[NetworkStatus.NOT_REACHABLE] = 'No network connection';

states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';

states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';



alert('Connection type: ' + states[networkState]);

}



// PhoneGap is loaded and it is now safe to make calls PhoneGap methods

//

function onDeviceReady() {

navigator.network.isReachable('phonegap.com', reachableCallback);

}



</script>



</head>

<body>



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



<div data-role="header">

<h1>AlternativeTo Home</h1>

</div>



<div data-role="content">

<p>Find Alternatives To Your favourite Softwares </p>

<p><a href="#search" data-role="button">Search Alternatives</a></p>

<p><a href="#recent" data-role="button">Recent Alternatives</a></p>

</div>



</div>



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



<div data-role="header" data-position="fixed">

<h1>Search Alternatives</h1>

<div class="class= ui-body ui-body-b">



<input type="text" name="search" id="searchBox" value="" data-theme="a" />

<button type="submit" data-theme="a" id="searchButton">Search</button>



</div>

</div>



<div data-role="content">



<ul data-role="listview" id="list">



</ul>







</div>



</div>



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



<div data-role="header">

<h1> Recent Alternatives</h1>

</div>



<div data-role="content">

<p>This app rocks!</p>



</div>



</div>



</body>

</html>



Download Demo Source



Download Demo Source here - PhoneGap.zip



This is a working Demo of PhoneGap Client of site - http://alternativeto.net



Issues to watch out



The issue you will notice first and not like is that of ListView with header and footer.



Here is an example









Notice the scrollbar starting from top of page and going it the bottom
Notice the header missing in the second image, (it is missing because it has moved up)


Ideally we would want



Scroll to start below header and end above footer
Header and Footer to be fixed


Fortunately, the fix for this could be provided very soon. Here is an experimental source of jQuery mobile handling the issue - http://jquerymobile.com/test/experiments/scrollview



I would wait for this fix and still bet on jQuery Mobile.
潮汐研究作为海洋科学的关键分支,融合了物理海洋学、地理信息系统及水利工程等多领域知识。TMD2.05.zip是一套基于MATLAB环境开发的潮汐专用分析工具集,为科研人员与工程实践者提供系统化的潮汐建模与计算支持。该工具箱通过模块化设计实现了两大核心功能: 在交互界面设计方面,工具箱构建了图形化操作环境,有效降低了非专业用户的操作门槛。通过预设参数输入模块(涵盖地理坐标、时间序列、测站数据等),用户可自主配置模型运行条件。界面集成数据加载、参数调整、可视化呈现及流程控制等标准化组件,将复杂的数值运算过程转化为可交互的操作流程。 在潮汐预测模块中,工具箱整合了谐波分解法与潮流要素解析法等数学模型。这些算法能够解构潮汐观测数据,识别关键影响要素(包括K1、O1、M2等核心分潮),并生成不同时间尺度的潮汐预报。基于这些模型,研究者可精准推算特定海域的潮位变化周期与振幅特征,为海洋工程建设、港湾规划设计及海洋生态研究提供定量依据。 该工具集在实践中的应用方向包括: - **潮汐动力解析**:通过多站点观测数据比对,揭示区域主导潮汐成分的时空分布规律 - **数值模型构建**:基于历史观测序列建立潮汐动力学模型,实现潮汐现象的数字化重构与预测 - **工程影响量化**:在海岸开发项目中评估人工构筑物对自然潮汐节律的扰动效应 - **极端事件模拟**:建立风暴潮与天文潮耦合模型,提升海洋灾害预警的时空精度 工具箱以"TMD"为主程序包,内含完整的函数库与示例脚本。用户部署后可通过MATLAB平台调用相关模块,参照技术文档完成全流程操作。这套工具集将专业计算能力与人性化操作界面有机结合,形成了从数据输入到成果输出的完整研究链条,显著提升了潮汐研究的工程适用性与科研效率。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值