Skip to content

Commit

Permalink
Fixes for bubble onclick
Browse files Browse the repository at this point in the history
  • Loading branch information
jhartz committed Apr 7, 2016
1 parent 82f1a56 commit f38e534
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Prototype_v1/scripts/map.js
Expand Up @@ -39,7 +39,7 @@ var MAX_RADIUS = 50;
* @property {Function} makeDescription - A function that is passed in the data
* and returns an HTML description of the location.
*
* @property {Function} makeUrl - A function that is passed in the data and
* @property {Function} makeLink - A function that is passed in the data and
* returns a URL to go to when the bubble is clicked (if applicable).
*/

Expand Down Expand Up @@ -99,14 +99,14 @@ function initMap(config) {
document.querySelector("#zoom-info"));

// Set up onclick
if (typeof config.makeUrl == "function") {
if (typeof config.makeLink == "function") {
// TODO: Is there a better way to do this?
map.svg[0][0].addEventListener("click", function (event) {
if (event.target.tagName.toLowerCase() == "circle") {
console.log("Item clicked: ", event.target);
var data = event.target.__data__;
if (data && data.url) {
window.open(data.url, "_blank");
if (data && data.link) {
window.open(data.link, "_blank");
}
}
}, false);
Expand Down Expand Up @@ -251,11 +251,11 @@ Location.prototype.getScaledRadius = function () {
* @return {Object} The object, ready to be passed to D3 Datamap.
*/
Location.prototype.getD3Object = function () {
var makeUrl = this.config.makeUrl;
var makeLink = this.config.makeLink;
var data = {
name: this.name,
htmlDescription: this.config.makeDescription(this.data),
url: typeof makeUrl == "function" ? makeUrl(this.data) : null,
link: typeof makeLink == "function" ? makeLink(this.data) : null,
radius: this.getScaledRadius(),
fillKey: this.fillKey
};
Expand Down
4 changes: 2 additions & 2 deletions Prototype_v1/scripts/social-media.js
Expand Up @@ -72,14 +72,14 @@ var SOCIAL_MEDIA_CONFIG = {
]);

if (data.url) {
desc += '<p><a href="' + escapeHTML(data.url) + '" target="_blank">Link</a></p>';
desc += '<p><a href="' + escapeHTML(data.url) + '" target="_blank">' + escapeHTML(data.url) + '</a></p>';
}

return desc;
},


makeUrl: function (data) {
makeLink: function (data) {
if (data.url) {
return data.url;
}
Expand Down

0 comments on commit f38e534

Please sign in to comment.