Sha256: 4f08b53e828395f66e796c8ac12146ddb3bfe53fbb95011e71b2c693b3e7d8da

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

Blacklight.onLoad(function() {

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

  $('[data-map="index"]').each(function() {
    var data = $(this).data(),
        dynamicSearcher, geoblacklight, search, bbox;

    if (typeof data.mapBbox === "string") {
      bbox = L.bboxToBounds(data.mapBbox);
    } else {
      $('.document [data-bbox]').each(function() {
        if (typeof bbox === "undefined") {
          bbox = L.bboxToBounds($(this).data().bbox);
        } else {
          bbox.extend(L.bboxToBounds($(this).data().bbox));
        }
      });
    }

    dynamicSearcher = GeoBlacklight.debounce(function(querystring) {
      History.pushState(null, null, data.catalogPath + '?' + querystring);
    }, 800);
    geoblacklight = new GeoBlacklight(this, { bbox: bbox }).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

1 entries across 1 versions & 1 rubygems

Version Path
geoblacklight-0.1.0 app/assets/javascripts/geoblacklight/modules/results.js