-
Notifications
You must be signed in to change notification settings - Fork 5
/
cordova-loader.js
46 lines (44 loc) · 1.29 KB
/
cordova-loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Loads the cordova.js file for the current platform.
*/
(function(enyo, scope){
if(!scope.cordova && !scope.PhoneGap) {
var cordovaVersion = scope.useCordovaVersion || '2.9.1';
var cordovaSupport = [
{platform: 'android'},
{platform: 'ios'},
{platform: 'webos'},
{platform: 'windowsPhone'},
{platform: 'blackberry', version: 10, cordovaFilename: 'blackberry10'},
{platform: 'blackberry'},
{platform: 'firefoxOS'},
// TODO: Figure out how to detect desktop webapps vs in-browser
//{platform: 'ie', version: 10, cordovaFilename: 'windows8'},
//{platform: 'safari', cordovaFilename: 'osx'},
{platform: 'tizen'}
];
var platform;
if (scope.PalmSystem) {
platform = 'webos';
} else {
for (var i=0; i<cordovaSupport.length; i++) {
var c = cordovaSupport[i];
var p = enyo.platform[c.platform];
if (p) {
if (!c.version || p >= c.version) {
platform = (c.cordovaFilename || c.platform);
break;
}
}
}
}
if (platform) {
var fn = '$lib/enyo-cordova/assets/cordova-js-' + cordovaVersion + '/cordova.' + platform + '.js';
enyo.load(fn);
} else {
enyo.warn('Cordova not loaded: Current platform not supported.');
}
} else {
enyo.warn('External cordova.js build in use, skipping script injection');
}
})(enyo, this);