Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a custom function to specify popupDisplay #96

Merged
merged 8 commits into from
Mar 3, 2020

Conversation

nstjean
Copy link
Contributor

@nstjean nstjean commented Feb 25, 2020

I have pulled out the popup data into a function that can be passed in to LBLD just as JSONparser is passed in. This lets users create whatever output they want for their API data without affecting LBLD.

This is what the default function looks like:

FireShot Capture 318 - Index Leaflet BlurredLocationDisplay -

This is how a custom display can look like:

      function popupDisplay(obj) {
        var popup_content = "";
        // if (image_url) popup_content += "<img src='" + options.host + image_url + "' class='popup-thumb' />"; // not available in the api yet
        popup_content += "<h5><a href='https://publiclab.org" + obj.url + "'>@" + obj.title + "</a></h5>";
        popup_content += "<div>Joined " + obj.created_at + "</div>";
        return popup_content
      }

FireShot Capture 316 - Index Leaflet BlurredLocationDisplay -

I will be using this in LEL for the PLpeople layer.

@nstjean
Copy link
Contributor Author

nstjean commented Feb 25, 2020

@sagarpreet-chadha can you check this out?

@jywarren
Copy link
Member

jywarren commented Mar 3, 2020

Amazing! 🎉

@jywarren jywarren merged commit 884ac47 into publiclab:main Mar 3, 2020
@nstjean
Copy link
Contributor Author

nstjean commented Mar 3, 2020

@jywarren Thanks!! Can you publish on npm?

@sagarpreet-chadha
Copy link
Collaborator

Awesome 🎉 , i do not have access for LBL npm registry.

@@ -126,6 +127,12 @@ BlurredLocationDisplay = function BlurredLocationDisplay(options) {
}
}

function defaultPopupDisplay(obj) {
var popup_content = "";
popup_content += "<h5><a href='" + obj.url + "'>" + obj.title + "</a></h5>";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow up, let's make a check if url and title are present in the external API or not to avoid errors.
Can be a FTO, thanks!

@jywarren
Copy link
Member

jywarren commented Mar 9, 2020

Sorry, yes, will publish now!

@jywarren
Copy link
Member

jywarren commented Mar 9, 2020

Done v1.2.0!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants