jQuery and AIR: AIR methods abstracted into jQuery plugin
comments (2) Views: 3,432
Before getting your hopes up, no this isn't a post with real code, or even pseudo code. It's meant more of a challenge, either to myself, or to someone else, to take this idea and run with it. You know about my love for jQuery and AIR and so don't take this as a complaint. AIR (with jQuery) makes it easy for traditional web developers to build high impact desktop applications. But it could be even easier. Take the following examples...
Even though the AIR method for minimizing a window to the system tray is short:
nativeWindow.minimize();
It still has to be bound to something:
$('#minimize').bind('click', function(event) {
iface.minimize();
});
Wouldn't it be cool if you could do something like this:
$('#minimize').air('minimize');
Obviously that's not a great example, but the code for adding a menu to an icon running in the task bar is much lengthier. You can see how this might benefit from an abstraction layer:
setupIconTray: function() {
var app = air.NativeApplication.nativeApplication;
app.addEventListener(air.Event.COMPLETE, iconLoadComplete);
var iconLoader = new air.Loader();
if(air.NativeApplication.supportsSystemTrayIcon){
iconLoader.contentLoaderInfo.addEventListener(air.Event.COMPLETE,iconLoadComplete);
iconLoader.load(new air.URLRequest("images/AIRApp_16.png"));
app.icon.addEventListener(window.runtime.flash.events.MouseEvent.CLICK, this.restore);
app.icon.tooltip = "Shrinkadoo";
}
function iconLoadComplete(event) {
app.icon.bitmaps = new runtime.Array(event.target.content.bitmapData);
}
}
Possibly it could look something like this:
$.air('addToIconTray',{
iconLoadComplete: fn,
restoreFromTray: fn,
trayIcon: "images/AIRApp_16.png",
trayTooltip: "Shrinkadoo"
});
So, dear readers, tell me. Does something like this already exist? Would anyone care to create it on their own? I've yet to try my hand at writing a jQuery plugin, but this could be the time to start. I can do it on my own, but I'd love some input, guidance, spiritual assistance, etc. How about a Google code project that can be shared amongst interested developers? Let's do it!
If this article was interesting, or helpful, or even wrong, please consider leaving a comment, or buying something from my wishlist. It's appreciated!
Andy, this looks like it would be really cool. I would certainly be down for contributing to this in some way. Maybe this should be my excuse to play with AIR.
Ben Nadel - June 12, 2009 12:26 pm
Thanks for the input Ben. I'd love to do some work with you...I'm sure it would be beneficial to me.
andy matthews - June 12, 2009 12:53 pm