poly-js-utils
Advanced tools
Comparing version 1.2.7 to 1.2.8
{ | ||
"name": "poly-js-utils", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"description": "Common client-side tools used in HSS Sites themes and locators.", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -477,2 +477,12 @@ # Poly JS Utils | ||
#### loadGoogleMapsScript | ||
Used to load Google Maps after the page has loaded. This takes a callback parameter that can be used if you need a callback once Google Maps is loaded. This function should go inside something like `$(document).ready()`. | ||
*Params:* | ||
* `key` (string, optional): The Google Maps API key | ||
* `callback` (string, optional): The function name of your callback | ||
*Return Type:* `None` | ||
## Contributing | ||
@@ -479,0 +489,0 @@ |
@@ -109,2 +109,19 @@ var _ = require('underscore'); | ||
var loadGoogleMapsScript = function(key, callback) { | ||
var script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
var keyString = key ? "key=" + key : ""; | ||
var callbackString = callback ? "callback=" + callback : ""; | ||
if(keyString && callbackString) { | ||
script.src = "https://maps.googleapis.com/maps/api/js?" + keyString + "&" + callbackString; | ||
} else if (keyString && !callbackString) { | ||
script.src = "https://maps.googleapis.com/maps/api/js?" + keyString; | ||
} else if (!keyString && callbackString) { | ||
script.src = "https://maps.googleapis.com/maps/api/js?" + callbackString; | ||
} else { | ||
script.src = "https://maps.googleapis.com/maps/api/js"; | ||
} | ||
document.body.appendChild(script); | ||
}; | ||
exports.stripNonDigits = stripNonDigits; | ||
@@ -121,1 +138,2 @@ exports.makeAbsolute = makeAbsolute; | ||
exports.selectBoxIsTrue = selectBoxIsTrue; | ||
exports.loadGoogleMapsScript = loadGoogleMapsScript; |
97726
2096
501