Skip to content

Commit

Permalink
threex.mozillaWebStoreInstall.js initial untested handler for mozilla…
Browse files Browse the repository at this point in the history
… apps store
  • Loading branch information
jeromeetienne committed Dec 22, 2011
1 parent 7335adc commit 83404a2
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions js/threex.mozillaWebStoreInstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// This THREEx helper makes it easy to handle navigator.mozApps API.
// * https://developer.mozilla.org/en/Apps/Apps_JavaScript_API
//
// # Code

//


/** @namespace */
var THREEx = THREEx || {};
THREEx.MozillaWebStoreInstall = THREEx.MozillaWebStoreInstall || {};

/**
* test if the API is available
* @returns {Boolean} true if the API is available, false otherwise
*/
THREEx.MozillaWebStoreInstall.apiAvailable = function()
{
return navigator.mozApps ? true : false;
}

/**
* Test if the application is already installed
*
* @returns {Boolean} true if the application is installed, false otherwise
*/
THREEx.MozillaWebStoreInstall.isInstalled = function(callback)
{
if( !this.apiAvailable() ) return false;
navigator.mozApps.amInstalled(callback);
}

/**
* Trigger an installation
* @param {String} url of the application (optional)
* @param {Function} callback called if installation succeed
* @param {Function} callback called if installation failed
*/
THREEx.MozillaWebStoreInstall.install = function(url, callback)
{
console.assert( this.apiAvailable() )
navigator.mozApps.install(url, successCallback, failureCallback);
}

0 comments on commit 83404a2

Please sign in to comment.