Sha256: 3180bf0bf324f65691a845796c972ab2b2a2f22a7a5c2428ad99ffb68911d2f9

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

Blacklight.onLoad(function() {
  var dynamicSearcher;

  dynamicSearcher = GeoBlacklight.debounce(function(querystring) {
    History.pushState(null, null, "/catalog?" + querystring);
  }, 800);

  History.Adapter.bind(window, 'statechange', function() {
    var state = History.getState();
    updatePage(state.url);
  });

  $('[data-map="index"]').each(function() {
    var geoblacklight = new GeoBlacklight(this).setHoverListeners(),
        search = new L.Control.GeoSearch(dynamicSearcher);
    geoblacklight.map.addControl(search);
  });

  function updatePage(url) {
    $.get(url).done(function(data) {
      var resp = $.parseHTML(data);
          $doc = $(resp);
      $("#documents").replaceWith($doc.find("#documents"));
      $("#sidebar").replaceWith($doc.find("#sidebar"));
      $("#sortAndPerPage").replaceWith($doc.find("#sortAndPerPage"));
      if ($("#map").next().length) {
        $("#map").next().replaceWith($doc.find("#map").next());
      } else {
        $("#map").after($doc.find("#map").next());
      }
    });
  }

});

GeoBlacklight.prototype.setHoverListeners = function() {
  var _this = this;

  $("#content")
    .on("mouseenter", "#documents [data-layer-id]", function() {
      var bounds = L.bboxToBounds($(this).data('bbox'));
      _this.addBoundsOverlay(bounds);
    })
    .on("mouseleave", "#documents [data-layer-id]", function() {
      _this.removeBoundsOverlay();
    });

  return this;

};

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
geoblacklight-0.0.6 app/assets/javascripts/geoblacklight/modules/results.js
geoblacklight-0.0.5 app/assets/javascripts/geoblacklight/modules/results.js
geoblacklight-0.0.4 app/assets/javascripts/geoblacklight/modules/results.js
geoblacklight-0.0.3 app/assets/javascripts/geoblacklight/modules/results.js