SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 82 | Next

Richard Wagner

"Professional iPhone and iPod touch Programming: Building Applications for Mobile Safari"

js
When you use the iUI framework, iui.js powers all of the UI behavior for you once you include it in your
document head. However, because the iUI framework does take control over many aspects of the
environment, it is important that you have a solid understanding of the library ??™ s internals.
The iui.js consists of a JSON object window.iui , three listeners for load and click events, and several
supporting routines. All of the JavaScript code is enclosed in an anonymous function with several
constants and variables defined:
(function() {
var slideSpeed = 20;
var slideInterval = 0;
var currentPage = null;
var currentDialog = null;
var currentWidth = 0;
var currentHash = location.hash;
var hashPrefix = ???#_???;
var pageHistory = [];
var newPageCount = 0;
var checkTimer;
// **** REST OF IUI CODE HERE ****
})();
The anonymous function creates a local scope to allow private semi - global variables and avoid name
conflicts with applications that use iui.js.
On Document Load
When the HTML document loads, the following listener function is triggered:
addEventListener(???load???, function(event)
{
var page = iui.getSelectedPage();
if (page)
iui.showPage(page);
setTimeout(preloadImages, 0);
setTimeout(checkOrientAndLocation, 0);
checkTimer = setInterval(checkOrientAndLocation, 300);
}, false);
The getSelectedPage() method of the JSON object iui is called to get the selected page ??” the block
element node that contains a selected=???true??? attribute.


Pages:
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94