Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

poly-js-utils

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poly-js-utils - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

3

package.json
{
"name": "poly-js-utils",
"version": "0.0.2",
"version": "0.0.3",
"description": "Common client-side tools used in HSS Sites themes and locators.",

@@ -13,3 +13,2 @@ "main": "main.js",

"jquery": "^2.2.4",
"mapbox": "^1.0.0-beta",
"moment": "^2.13.0",

@@ -16,0 +15,0 @@ "moment-timezone": "^0.5.4",

@@ -112,3 +112,3 @@ /************************/

if (_.isFunction(options.customProcessor)) {
postParams = options.customProcessor(postParams);
postParams = _.extend(postParams, options.customProcessor(postParams));
}

@@ -166,3 +166,3 @@ // stringify custom data

$(options.formElementSelector + " button[type='submit']").on("click", function(e) {
$(options.formElementSelector + " input[type='submit'], " + options.formElementSelector + " button[type='submit']").on("click", function(e) {
var $target = $(e.currentTarget);

@@ -169,0 +169,0 @@ e.preventDefault();

@@ -7,3 +7,2 @@ /******************/

var _ = require('underscore');
var mapbox = require('mapbox');

@@ -13,99 +12,5 @@ var JSContext = require('./jscontext');

var HEARSAY_ACCESS_TOKEN = "pk.eyJ1IjoibWZsZXNjaGxlciIsImEiOiJqOWxZSE8wIn0.VcRq5IxyVLXPzTOz9P2WGg";
var DEFAULT_MARKER_SYMBOL = "circle";
var DEFAULT_MARKER_COLOR = "ed1651";
var DEFAULT_ZOOM_LEVEL = 15;
var DEFAULT_MOBILE_WIDEST = 765;
var initialized = false;
var _initMapbox = function() {
mapbox.mapbox.accessToken = HEARSAY_ACCESS_TOKEN;
initialized = true;
};
var _geocodeAddress = function(address, callback) {
if(!initialized) {
_initMapbox();
}
// If we were passed a valid [lat, lng] array, we use that directly
if (_.isArray(address) && address.length === 2 && !!address[0] && !!address[1]) {
callback(null, {"latlng": address});
} else {
// Otherwise we fallback to the previous behavior which
// is to try geocoding the address, whatever form its in
var geocoder = mapbox.mapbox.geocoder("mapbox.places");
geocoder.query(address, callback);
}
};
var showMap = function(address, containerID, options, markerClickHandler) {
if(!this.initialized) {
_initMapbox();
}
var map;
options = options || {};
map = mapbox.mapbox.map(containerID, "mapbox.streets", options);
map.scrollWheelZoom.disable();
_geocodeAddress(address, function(err, data) {
// The geocoder can return an area, like a city, or a
// point, like an address. Here we handle both cases,
// by fitting the map location to an area if we don't have a point.
if (data.latlng) {
map.setView(data.latlng, DEFAULT_ZOOM_LEVEL);
// If we have a point, we can put a marker there.
var destinationMarker = mapbox.marker(data.latlng, {
icon: mapbox.mapbox.marker.icon({
"marker-color": "#" + DEFAULT_MARKER_COLOR,
"marker-symbol": DEFAULT_MARKER_SYMBOL
})
});
if(markerClickHandler) {
destinationMarker.on("click", markerClickHandler);
}
destinationMarker.addTo(map);
} else if (data.lbounds) {
map.fitlocation(data.lbounds);
}
});
return map;
};
var showSwappableMap = function(address, containerID, options, markerClickHandler) {
if(this.map) {
this.map.remove();
}
this.map = this.showMap(address, containerID, options, markerClickHandler);
};
var showStaticMap = function(address, containerID) {
var container = $('#' + containerID);
var containerHeight = container.innerHeight();
_geocodeAddress(address, function(err, data) {
var location;
if(data.latlng) {
location = data.latlng;
} else if (data.lbounds) {
location = data.lbounds.northEast;
}
// mapbox wants input to the static api the other way around from their geocoder output
var locationString = location[1] + "," + location[0];
var staticMapUrl = "url( 'https://api.mapbox.com/v4/mapbox.streets/" +
"pin-m-" + DEFAULT_MARKER_SYMBOL + "+" + DEFAULT_MARKER_COLOR + "(" + locationString + ")/" +
locationString + "," + DEFAULT_ZOOM_LEVEL + "/" + DEFAULT_MOBILE_WIDEST + "x" +
containerHeight + ".png?access_token=" + HEARSAY_ACCESS_TOKEN + "' )";
var styles = {
"background-size": "cover",
"background-position": "center",
"background-image": staticMapUrl
};
container.css(styles);
});
};
var googleGeocodeAddress = function(address, callback) {

@@ -201,7 +106,4 @@ var geocoder = new google.maps.Geocoder();

exports.showMap = showMap;
exports.showSwappableMap = showSwappableMap;
exports.showStaticMap = showStaticMap;
exports.googleGeocodeAddress = googleGeocodeAddress;
exports.showGoogleMap = showGoogleMap;
exports.showStaticGoogleMap = showStaticGoogleMap;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc