Skip to content

Commit

Permalink
update leaflet to current version to add new accessibility features; …
Browse files Browse the repository at this point in the history
…update leaflet-iiif for compatibility; move leaflet related files to vendor/assets
  • Loading branch information
jmcglone committed Feb 2, 2017
1 parent d01919f commit 1aa89f9
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 68 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
// Required by Blacklight
//= require blacklight/blacklight
// Required by Heliotrope?
//= require leaflet
//= require leaflet-iiif
//= require leaflet_1.0.3
//= require leaflet-iiif_1.0.2
//= require 'edit_users'
//= require 'file_set_sort_date'
//= require 'disable_video_download'
Expand Down
9 changes: 0 additions & 9 deletions app/assets/javascripts/leaflet.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*= require_tree .
*= require_self
*= require jquery-ui/datepicker
*= require leaflet
*= require leaflet_1.0.3
*= require blacklight_facets
*= require ableplayer
*= require heliotrope
Expand Down
28 changes: 8 additions & 20 deletions app/assets/javascripts/leaflet-iiif.js → .../assets/javascripts/leaflet-iiif_1.0.2.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Leaflet-IIIF 0.1.2
* Leaflet-IIIF 1.0.2
* IIIF Viewer for Leaflet
* by Jack Reed, @mejackreed
*/
Expand Down Expand Up @@ -35,7 +35,7 @@ L.TileLayer.Iiif = L.TileLayer.extend({
var _this = this,
x = coords.x,
y = (coords.y),
zoom = _this._map.getZoom(),
zoom = _this._getZoomForUrl(),
scale = Math.pow(2, _this.maxNativeZoom - zoom),
tileBaseSize = _this.options.tileSize * scale,
minx = (x * tileBaseSize),
Expand All @@ -51,23 +51,9 @@ L.TileLayer.Iiif = L.TileLayer.extend({
quality: _this.quality,
region: [minx, miny, xDiff, yDiff].join(','),
rotation: 0,
size: _this._iiifSizeParam(Math.ceil(xDiff / scale), Math.ceil(yDiff / scale))
size: Math.ceil(xDiff / scale) + ','
}, this.options));
},
/**
* Returns a IIIF size parameter based off of the max dimension of
* a tile
* @param {Number} x - The width of a tile
* @param {Number} y - The height of a tile
* @returns {String}
*/
_iiifSizeParam: function(x, y) {
if (x >= y) {
return x + ',';
} else {
return ',' + y;
}
},
onAdd: function(map) {
var _this = this;

Expand Down Expand Up @@ -138,7 +124,9 @@ L.TileLayer.Iiif = L.TileLayer.extend({
_this._setQuality();

// Unless an explicit tileSize is set, use a preferred tileSize
if (!_this.explicitTileSize) {
if (!_this._explicitTileSize) {
// Set the default first
_this.options.tileSize = 256;
if (data.tiles) {
// Image API 2.0 Case
_this.options.tileSize = data.tiles[0].width;
Expand Down Expand Up @@ -207,9 +195,9 @@ L.TileLayer.Iiif = L.TileLayer.extend({
_templateUrl: function() {
return this._infoToBaseUrl() + '{region}/{size}/{rotation}/{quality}.{format}';
},
_tileShouldBeLoaded: function(coords) {
_isValidTile: function(coords) {
var _this = this,
zoom = _this._map.getZoom(),
zoom = _this._getZoomForUrl(),
sizes = _this._tierSizes[zoom],
x = coords.x,
y = (coords.y);
Expand Down
9 changes: 9 additions & 0 deletions vendor/assets/javascripts/leaflet_1.0.3.js

Large diffs are not rendered by default.

Loading

0 comments on commit 1aa89f9

Please sign in to comment.