forked from esbanarango/ember-place-autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (45 loc) · 1.58 KB
/
index.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
47
48
49
50
51
52
53
'use strict';
module.exports = {
name: require('./package').name,
contentFor: function(type, config) {
var content = '';
var placeAutocompleteConfig = config['place-autocomplete'] || {};
if (type === (placeAutocompleteConfig.contentForType || 'head')) {
var src = placeAutocompleteConfig.src || '//maps.googleapis.com/maps/api/js',
params = [],
exclude = placeAutocompleteConfig.exclude,
client = placeAutocompleteConfig.client,
version = parseFloat(placeAutocompleteConfig.version),
key = placeAutocompleteConfig.key,
language = placeAutocompleteConfig.language,
region = placeAutocompleteConfig.region;
if (!exclude) {
if (key) {
params.push('key=' + encodeURIComponent(key));
}
if (client) {
params.push('client=' + encodeURIComponent(client));
}
if (version) {
if (client && version < 3.24) {
version = 3.24;
}
params.push('v=' + encodeURIComponent(version));
}
if (language) {
params.push('language=' + encodeURIComponent(language));
}
if (region) {
params.push('region=' + encodeURIComponent(region));
}
src += '?' + params.join('&') + "&libraries=places";
if (config.environment === 'test') {
content = '<script type="text/javascript" src="' + src + '"></script>';
} else {
content = '<script type="text/javascript" src="' + src + '" async defer></script>';
}
}
}
return content;
}
};