laws-africa / indigo

Indigo Platform for publishing beautiful legislation.
https://laws.africa/indigo
Other
57 stars 25 forks source link

As a reviewer I want to get a quick idea of key details of a work by hovering over a link to that work #388

Closed longhotsummer closed 5 years ago

longhotsummer commented 5 years ago

For instance, when reviewing that amending information is correct, I don't want to have to click through to the amending work's page. Showing a popover similar to have wikipedia does it would be very helpful.

We could use JS to bind to A tags that link to a work, and use BS4's popover feature to shower a popover box on hover. We can call .../work/popover to generate it on the server side.

longhotsummer commented 5 years ago

Here's the skeleton of my idea.

  1. On page load, wrap a BS4 popover to links to "/works/foo/bar" (or maybe we need to use a data-popup to decorate just the ones we want, we'll have to see, otherwise it may decorate "edit this work" buttons.
  2. When the popover loads, get the html from /works/foo/bar/popover

Something like this (untested):

$('body').on('mouseover', 'a[href^="/works/"]:not(.btn)', function(e) {
  var el = this;
  $.ajax.get(this.href + '/popup').then(function(html) {
    // we probably want to cache html somewhere, for this work on this page
    $(el).popover({content: html}).popover('show');
  });
});

The popup could look like a simplified version of this:

nature conservation amendment act 1986 laws africa 2019-02-21 14-41-42

ie, basic HTML:

AliciadW commented 5 years ago

https://github.com/laws-africa/indigo/pull/411