-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
threex.mozillaWebStoreInstall.js initial untested handler for mozilla…
… apps store
- Loading branch information
1 parent
7335adc
commit 83404a2
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |