jQuery and AIR: AIR methods abstracted into jQuery plugin

Filed under: AIR, jQuery

comments (2) Views: 4,303

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!

Amazon logo

If this article was interesting, or helpful, or even wrong, please consider leaving a comment, or buying something from my wishlist. It's appreciated!

Related Posts


comments powered by Disqus
coach outlet online jordan 13 grey toe beats by dre cyber monday michael kors black friday beats by dre cyber monday jordan 6 black infrared north face cyber monday michael kors cyber monday north face black friday coach outlet black infrared 23 13s north face cyber monday jordan 6 black infrared north face black friday coach cyber monday jordan 11 legend blue north face cyber monday black infrared 6s lebron 12 north face black friday jordan 11 legend blue louis vuitton outlet jordan 13 grey toe grey toe 13s beats by dre black friday coach black friday jordan 13 grey toe coach cyber monday uggs black friday jordan 13 black infrared 23 uggs cyber monday barons 13s uggs black friday beats by dre cyber monday black infrared 6s jordan 13 bred jordan 13 black infrared 23 north face black friday black infrared 6s jordan 11 legend blue michael kors black friday jordan 13 grey toe coach black friday michael kors black friday michael kors cyber monday beats by dre cyber Monday north face cyber monday coach black friday michael kors cyber monday beats by dre cyber Monday north face black friday beats by dre black friday lululemon black friday uggs black friday jordan 13 bred coach cyber monday beats by dre black friday uggs black friday coach black friday black infrared 6s