Thursday, April 8, 2010

AdLib - Apple’s secret iPad web framework?

I know, I know, enough news about the iPad already! I haven’t picked one up yet because I’m much more keen on having a device with 3G access. However, this isn’t about the iPad itself, but something very interesting I stumbled upon while playing with the iPad Simulator.

With the iPad comes a special Safari bookmark labeled “iPad User Guide.” The page it links to behaves almost exactly like a native application, but in the web browser. It has a split-view with all of the UI flare in UIKit. The crazy part is, it’s done completely in HTML/CSS/JavaScript.

Check out this video to see the iPad User Guide’s split-view scrolling panes in action:

Breaking the Rules

What’s particularly interesting is that it does something that shouldn’t really be possible in Mobile Safari: It includes scrolling panes that can be manipulated with a single finger, complete with the signature iPhone OS “scroll bars” and elastic transitions. If you have ever worked with Safari on the iPhone, you know that having scrolling boxes of content is sort of possible, but requires a special two-finger gesture to scroll.

Curiosity got the best of me, so I loaded the page in Safari on my laptop (and changed Safari’s user agent to mimic the iPad) and got to work with the developer tools. After extracting the JavaScript and de-minifying it, my suspicions were confirmed. Apple was manually reading the touch events, calculating the inertia of the scrolling, and manually drawing the scroll bars. It was incredible that it worked so smoothly in the browser.

The Mystery of “AD”

What was more interesting is that there was an entire framework running this web application. The framework weighed in at 4,300 lines of code, and was unmistakably an Apple-born API. Every class and constant was prefixed with the letters “AD” and some of the classes include ADTabBarController, ADScrollPane, ADViewController, ADView, ADToolbar, and dozens more.

What does the AD prefix stand for? I don’t know. The framework itself was contained in a file called AdLib-ug-ipad.js, so for the time being let’s call it AdLib. I also appreciate the sense of humor the developers seem to have about the name. The accompanying application code that utilizes the framework is about 1,500 lines and offers a few clues as to how to use the AdLib framework. There is no documentation in the code or anywhere online, and the local variables are shortened to a, b, c, etc… If you want to know more about how it works, take a look at the code linked below.

Is AdLib a framework that Apple plans to release for the public? I sure hope so. The framework looks to be extremely well thought out and complete. Perhaps this will be a framework to support a future release of Dashcode, an application for writing dashboard widgets and Safari/iPhone web apps. Maybe we’ll hear something about it this Thursday at Apple’s event for iPhone OS 4.

What do you think?

I have copied and de-minified the code, however there is absolutely no license from Apple for use of this code. This is purely for informational purposes.

What do you think about AdLib? What does “AD” stand for? Is Apple about to release a JavaScript framework? Let us know, in the comments.

No comments:

Post a Comment