poly-js-utils
Advanced tools
Comparing version 1.2.11 to 1.2.12
{ | ||
"name": "poly-js-utils", | ||
"version": "1.2.11", | ||
"version": "1.2.12", | ||
"description": "Common client-side tools used in HSS Sites themes and locators.", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -41,3 +41,3 @@ # Poly JS Utils | ||
To use an asynchronous version of Raven, follow these two steps: | ||
1. gulp include the srv/raven-async.js file from this package | ||
1. gulp include the src/raven-async.js file from this package | ||
2. call Raven.config().load() as normal | ||
@@ -44,0 +44,0 @@ |
@@ -10,2 +10,20 @@ var viewHelpers = require('../src/view-helpers'); | ||
// Test to Make Designations into a String | ||
describe('Designations String', function() { | ||
var designationDict = { | ||
"WA": "Washington", | ||
"DE": "Delaware", | ||
"DC": "District of Columbia", | ||
"WI": "Wisconsin", | ||
"WV": "West Virginia" | ||
}; | ||
it('takes an array of designations and turns into a single string', function() { | ||
expect(viewHelpers.makeDesignationString(["WA", "DE", "DC"], designationDict) | ||
).toBe("Washington, Delaware, District of Columbia"); | ||
}); | ||
it('when no designations are selected, returns an empty string', function() { | ||
expect(viewHelpers.makeDesignationString(undefined, designationDict)).toBe(""); | ||
}); | ||
}); | ||
describe("Phone Formatting", function() { | ||
@@ -12,0 +30,0 @@ it("should strip non-digits", function() { |
@@ -9,4 +9,2 @@ /************************/ | ||
var getValidatedPostData = function(options) { | ||
@@ -160,3 +158,12 @@ var defaults = { | ||
var activate = function(apiLink, slug, options) { | ||
var activate = function(apiLink, slug, options, emailPattern) { | ||
emailPattern = $('input[name="email"]').attr('pattern'); | ||
if(!emailPattern) { | ||
/* eslint-disable max-len */ | ||
var pattern = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/; | ||
/* eslint-enable max-len */ | ||
emailPattern = pattern; | ||
} | ||
options = options || {}; | ||
@@ -163,0 +170,0 @@ _.defaults(options, { |
@@ -115,4 +115,11 @@ /******************/ | ||
var addMarkerToMap = function(markerOptions) { | ||
if(typeof google === 'object' && typeof google.maps === 'object') { | ||
return new google.maps.Marker(markerOptions); | ||
} | ||
}; | ||
exports.googleGeocodeAddress = googleGeocodeAddress; | ||
exports.showGoogleMap = showGoogleMap; | ||
exports.showStaticGoogleMap = showStaticGoogleMap; | ||
exports.addMarkerToMap = addMarkerToMap; |
@@ -135,2 +135,10 @@ var _ = require('underscore'); | ||
var renderTemplate = function(selector, html, data) { | ||
var element = document.querySelector(selector); | ||
if(element.length) { | ||
var template = _.template(html); | ||
element.appendChild(template(data)); | ||
} | ||
}; | ||
exports.stripNonDigits = stripNonDigits; | ||
@@ -148,1 +156,2 @@ exports.makeAbsolute = makeAbsolute; | ||
exports.loadGoogleMapsScript = loadGoogleMapsScript; | ||
exports.renderTemplate = renderTemplate; |
@@ -43,2 +43,12 @@ /****************************/ | ||
var makeDesignationString = function(designationsArray, dictionary) { | ||
var output = []; | ||
_.each(designationsArray, function(designation) { | ||
if (designation && dictionary[designation]) { | ||
output.push(dictionary[designation].replace(/(®)/ig, "<sup>$1</sup>")); | ||
} | ||
}); | ||
return output.join(", "); | ||
}; | ||
/* Filter phone number to just the digits, and format nicely if asked. */ | ||
@@ -153,2 +163,3 @@ var phoneFormat = function(phone, pretty) { | ||
exports.makeAbsolute = utils.makeAbsolute; | ||
exports.makeDesignationString = makeDesignationString; | ||
exports.phoneFormat = phoneFormat; | ||
@@ -155,0 +166,0 @@ exports.zipFormat = zipFormat; |
101168
2177