spotlight-frontend 3.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +114 -0
- package/app/assets/images/blacklight/arrow-alt-circle-left.svg +1 -0
- package/app/assets/images/blacklight/arrow-alt-circle-right.svg +1 -0
- package/app/assets/images/blacklight/arrow_back_ios.svg +1 -0
- package/app/assets/images/blacklight/arrow_forward_ios.svg +1 -0
- package/app/assets/images/blacklight/check.svg +1 -0
- package/app/assets/images/blacklight/check_circle.svg +1 -0
- package/app/assets/images/blacklight/chevron_right.svg +1 -0
- package/app/assets/images/blacklight/close.svg +1 -0
- package/app/assets/images/blacklight/edit.svg +1 -0
- package/app/assets/images/blacklight/error.svg +1 -0
- package/app/assets/images/blacklight/highlight_off.svg +1 -0
- package/app/assets/images/blacklight/info.svg +1 -0
- package/app/assets/images/blacklight/warning.svg +1 -0
- package/app/assets/images/blacklight/zoom_in.svg +1 -0
- package/app/assets/images/blacklight/zoom_out.svg +1 -0
- package/app/assets/images/spotlight/.keep +0 -0
- package/app/assets/images/spotlight/blocks/sir-trevor-icons.svg +320 -0
- package/app/assets/images/spotlight/default_browse_thumbnail.jpg +0 -0
- package/app/assets/images/spotlight/default_thumbnail.jpg +0 -0
- package/app/assets/images/spotlight/fallback/default.png +0 -0
- package/app/assets/javascripts/spotlight/admin/add_another.js +22 -0
- package/app/assets/javascripts/spotlight/admin/add_new_button.js +81 -0
- package/app/assets/javascripts/spotlight/admin/appearance.js +24 -0
- package/app/assets/javascripts/spotlight/admin/attachments.js +2 -0
- package/app/assets/javascripts/spotlight/admin/blacklight_configuration.js +63 -0
- package/app/assets/javascripts/spotlight/admin/block_mixins/autocompleteable.js +72 -0
- package/app/assets/javascripts/spotlight/admin/block_mixins/formable.js +78 -0
- package/app/assets/javascripts/spotlight/admin/block_mixins/plustextable.js +57 -0
- package/app/assets/javascripts/spotlight/admin/blocks/block.js +23 -0
- package/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +87 -0
- package/app/assets/javascripts/spotlight/admin/blocks/browse_group_categories_block.js +88 -0
- package/app/assets/javascripts/spotlight/admin/blocks/iframe_block.js +34 -0
- package/app/assets/javascripts/spotlight/admin/blocks/link_to_search_block.js +16 -0
- package/app/assets/javascripts/spotlight/admin/blocks/oembed_block.js +40 -0
- package/app/assets/javascripts/spotlight/admin/blocks/pages_block.js +22 -0
- package/app/assets/javascripts/spotlight/admin/blocks/resources_block.js +145 -0
- package/app/assets/javascripts/spotlight/admin/blocks/rule_block.js +25 -0
- package/app/assets/javascripts/spotlight/admin/blocks/search_result_block.js +44 -0
- package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_base_block.js +108 -0
- package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_block.js +25 -0
- package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_carousel_block.js +103 -0
- package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_embed_block.js +17 -0
- package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_features_block.js +41 -0
- package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_grid_block.js +14 -0
- package/app/assets/javascripts/spotlight/admin/blocks/uploaded_items_block.js +145 -0
- package/app/assets/javascripts/spotlight/admin/catalog_edit.js +16 -0
- package/app/assets/javascripts/spotlight/admin/copy_email_addresses.js +9 -0
- package/app/assets/javascripts/spotlight/admin/crop.es6 +310 -0
- package/app/assets/javascripts/spotlight/admin/croppable.js +25 -0
- package/app/assets/javascripts/spotlight/admin/edit_in_place.js +54 -0
- package/app/assets/javascripts/spotlight/admin/exhibit_tag_autocomplete.js +37 -0
- package/app/assets/javascripts/spotlight/admin/exhibits.js +58 -0
- package/app/assets/javascripts/spotlight/admin/form_observer.js +86 -0
- package/app/assets/javascripts/spotlight/admin/iiif.es6 +54 -0
- package/app/assets/javascripts/spotlight/admin/index.js +16 -0
- package/app/assets/javascripts/spotlight/admin/locks.js +12 -0
- package/app/assets/javascripts/spotlight/admin/multi_image_selector.js +158 -0
- package/app/assets/javascripts/spotlight/admin/pages.js.erb +40 -0
- package/app/assets/javascripts/spotlight/admin/progress_monitor.js +148 -0
- package/app/assets/javascripts/spotlight/admin/readonly_checkbox.js +6 -0
- package/app/assets/javascripts/spotlight/admin/search_typeahead.js +108 -0
- package/app/assets/javascripts/spotlight/admin/select_related_input.js +34 -0
- package/app/assets/javascripts/spotlight/admin/sir-trevor/block_controls.js +120 -0
- package/app/assets/javascripts/spotlight/admin/sir-trevor/block_limits.js +37 -0
- package/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +120 -0
- package/app/assets/javascripts/spotlight/admin/spotlight_nestable.js +72 -0
- package/app/assets/javascripts/spotlight/admin/tabs.js +6 -0
- package/app/assets/javascripts/spotlight/admin/translation_progress.js +23 -0
- package/app/assets/javascripts/spotlight/admin/users.js +79 -0
- package/app/assets/javascripts/spotlight/application.js +14 -0
- package/app/assets/javascripts/spotlight/spotlight.js +23 -0
- package/app/assets/javascripts/spotlight/user/analytics.js +9 -0
- package/app/assets/javascripts/spotlight/user/browse_group_categories.js +59 -0
- package/app/assets/javascripts/spotlight/user/carousel.js +3 -0
- package/app/assets/javascripts/spotlight/user/clear_form_button.js +27 -0
- package/app/assets/javascripts/spotlight/user/index.js +8 -0
- package/app/assets/javascripts/spotlight/user/report_a_problem.js +39 -0
- package/app/assets/javascripts/spotlight/user/zpr_links.js.erb +45 -0
- package/app/assets/stylesheets/spotlight/_accessibility.scss +8 -0
- package/app/assets/stylesheets/spotlight/_attachments.css +4 -0
- package/app/assets/stylesheets/spotlight/_blacklight_configuration.scss +82 -0
- package/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +21 -0
- package/app/assets/stylesheets/spotlight/_bootstrap_overrides.scss +105 -0
- package/app/assets/stylesheets/spotlight/_breadcrumbs.scss +6 -0
- package/app/assets/stylesheets/spotlight/_browse.scss +158 -0
- package/app/assets/stylesheets/spotlight/_catalog.scss +161 -0
- package/app/assets/stylesheets/spotlight/_collapse_toggle.scss +14 -0
- package/app/assets/stylesheets/spotlight/_croppable.scss +4 -0
- package/app/assets/stylesheets/spotlight/_curation.scss +224 -0
- package/app/assets/stylesheets/spotlight/_edit_in_place.scss +9 -0
- package/app/assets/stylesheets/spotlight/_exhibit_admin.scss +81 -0
- package/app/assets/stylesheets/spotlight/_exhibit_navbar.scss +10 -0
- package/app/assets/stylesheets/spotlight/_exhibits_index.scss +147 -0
- package/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +269 -0
- package/app/assets/stylesheets/spotlight/_footer.scss +12 -0
- package/app/assets/stylesheets/spotlight/_header.scss +155 -0
- package/app/assets/stylesheets/spotlight/_item_text_block.scss +50 -0
- package/app/assets/stylesheets/spotlight/_mixins.scss +17 -0
- package/app/assets/stylesheets/spotlight/_modals.scss +3 -0
- package/app/assets/stylesheets/spotlight/_multi_image_selector.scss +22 -0
- package/app/assets/stylesheets/spotlight/_multi_up_item_grid.scss +63 -0
- package/app/assets/stylesheets/spotlight/_nestable.scss +124 -0
- package/app/assets/stylesheets/spotlight/_pages.scss +282 -0
- package/app/assets/stylesheets/spotlight/_report_a_problem.scss +14 -0
- package/app/assets/stylesheets/spotlight/_sir-trevor_overrides.scss +87 -0
- package/app/assets/stylesheets/spotlight/_slideshow_block.scss +87 -0
- package/app/assets/stylesheets/spotlight/_spotlight.scss +49 -0
- package/app/assets/stylesheets/spotlight/_translations.scss +86 -0
- package/app/assets/stylesheets/spotlight/_upload.scss +0 -0
- package/app/assets/stylesheets/spotlight/_uploaded_items_block.scss +7 -0
- package/app/assets/stylesheets/spotlight/_utilities.scss +7 -0
- package/app/assets/stylesheets/spotlight/_variables.scss +42 -0
- package/app/assets/stylesheets/spotlight/_variables_bootstrap.scss +7 -0
- package/app/assets/stylesheets/spotlight/_view_larger.scss +22 -0
- package/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +92 -0
- package/app/assets/stylesheets/spotlight/typeahead.css +77 -0
- package/package.json +29 -0
- package/vendor/assets/images/sir-trevor-icons.svg +263 -0
- package/vendor/assets/javascripts/Leaflet.Editable.js +1917 -0
- package/vendor/assets/javascripts/MutationObserver.js +625 -0
- package/vendor/assets/javascripts/Path.Drag.js +137 -0
- package/vendor/assets/javascripts/bootstrap-tagsinput.js +530 -0
- package/vendor/assets/javascripts/eventable.js +205 -0
- package/vendor/assets/javascripts/jquery.serializejson.js +234 -0
- package/vendor/assets/javascripts/jquery.waitforimages.min.js +2 -0
- package/vendor/assets/javascripts/leaflet-iiif.js +323 -0
- package/vendor/assets/javascripts/nestable.js +645 -0
- package/vendor/assets/javascripts/parameterize.js +137 -0
- package/vendor/assets/javascripts/polyfill.min.js +4 -0
- package/vendor/assets/javascripts/sir-trevor.js +21639 -0
- package/vendor/assets/javascripts/tiny-slider.js +3218 -0
- package/vendor/assets/javascripts/typeahead.bundle.min.js +7 -0
- package/vendor/assets/stylesheets/bootstrap-tagsinput.css +46 -0
- package/vendor/assets/stylesheets/leaflet-areaselect.css +15 -0
- package/vendor/assets/stylesheets/sir-trevor/_icons.scss +6 -0
- package/vendor/assets/stylesheets/sir-trevor/_variables.scss +22 -0
- package/vendor/assets/stylesheets/sir-trevor/base.scss +17 -0
- package/vendor/assets/stylesheets/sir-trevor/block-addition-top.scss +95 -0
- package/vendor/assets/stylesheets/sir-trevor/block-addition.scss +72 -0
- package/vendor/assets/stylesheets/sir-trevor/block-controls.scss +34 -0
- package/vendor/assets/stylesheets/sir-trevor/block-positioner.scss +34 -0
- package/vendor/assets/stylesheets/sir-trevor/block-replacer.scss +43 -0
- package/vendor/assets/stylesheets/sir-trevor/block-ui.scss +120 -0
- package/vendor/assets/stylesheets/sir-trevor/block.scss +300 -0
- package/vendor/assets/stylesheets/sir-trevor/errors.scss +21 -0
- package/vendor/assets/stylesheets/sir-trevor/format-bar.scss +65 -0
- package/vendor/assets/stylesheets/sir-trevor/inputs.scss +45 -0
- package/vendor/assets/stylesheets/sir-trevor/main.scss +24 -0
- package/vendor/assets/stylesheets/sir-trevor/patterns/ui-popup.scss +38 -0
- package/vendor/assets/stylesheets/sir-trevor/utils.scss +10 -0
- package/vendor/assets/stylesheets/tiny-slider.css +1 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Leaflet-IIIF 3.0.0
|
|
3
|
+
* IIIF Viewer for Leaflet
|
|
4
|
+
* by Jack Reed, @mejackreed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
L.TileLayer.Iiif = L.TileLayer.extend({
|
|
8
|
+
options: {
|
|
9
|
+
continuousWorld: true,
|
|
10
|
+
tileSize: 256,
|
|
11
|
+
updateWhenIdle: true,
|
|
12
|
+
tileFormat: 'jpg',
|
|
13
|
+
fitBounds: true,
|
|
14
|
+
setMaxBounds: false
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
initialize: function(url, options) {
|
|
18
|
+
options = typeof options !== 'undefined' ? options : {};
|
|
19
|
+
|
|
20
|
+
if (options.maxZoom) {
|
|
21
|
+
this._customMaxZoom = true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Check for explicit tileSize set
|
|
25
|
+
if (options.tileSize) {
|
|
26
|
+
this._explicitTileSize = true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Check for an explicit quality
|
|
30
|
+
if (options.quality) {
|
|
31
|
+
this._explicitQuality = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
options = L.setOptions(this, options);
|
|
35
|
+
this._infoPromise = null;
|
|
36
|
+
this._infoUrl = url;
|
|
37
|
+
this._baseUrl = this._templateUrl();
|
|
38
|
+
this._getInfo();
|
|
39
|
+
},
|
|
40
|
+
getTileUrl: function(coords) {
|
|
41
|
+
var _this = this,
|
|
42
|
+
x = coords.x,
|
|
43
|
+
y = (coords.y),
|
|
44
|
+
zoom = _this._getZoomForUrl(),
|
|
45
|
+
scale = Math.pow(2, _this.maxNativeZoom - zoom),
|
|
46
|
+
tileBaseSize = _this.options.tileSize * scale,
|
|
47
|
+
minx = (x * tileBaseSize),
|
|
48
|
+
miny = (y * tileBaseSize),
|
|
49
|
+
maxx = Math.min(minx + tileBaseSize, _this.x),
|
|
50
|
+
maxy = Math.min(miny + tileBaseSize, _this.y);
|
|
51
|
+
|
|
52
|
+
var xDiff = (maxx - minx);
|
|
53
|
+
var yDiff = (maxy - miny);
|
|
54
|
+
|
|
55
|
+
// Canonical URI Syntax for v2
|
|
56
|
+
var size = Math.ceil(xDiff / scale) + ',';
|
|
57
|
+
if (_this.type === 'ImageService3') {
|
|
58
|
+
// Cannonical URI Syntax for v3
|
|
59
|
+
size = size + Math.ceil(yDiff / scale);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return L.Util.template(this._baseUrl, L.extend({
|
|
63
|
+
format: _this.options.tileFormat,
|
|
64
|
+
quality: _this.quality,
|
|
65
|
+
region: [minx, miny, xDiff, yDiff].join(','),
|
|
66
|
+
rotation: 0,
|
|
67
|
+
size: size
|
|
68
|
+
}, this.options));
|
|
69
|
+
},
|
|
70
|
+
onAdd: function(map) {
|
|
71
|
+
var _this = this;
|
|
72
|
+
|
|
73
|
+
// Wait for info.json fetch and parse to complete
|
|
74
|
+
Promise.all([_this._infoPromise]).then(function() {
|
|
75
|
+
// Store unmutated imageSizes
|
|
76
|
+
_this._imageSizesOriginal = _this._imageSizes.slice(0);
|
|
77
|
+
|
|
78
|
+
// Set maxZoom for map
|
|
79
|
+
map._layersMaxZoom = _this.maxZoom;
|
|
80
|
+
|
|
81
|
+
// Call add TileLayer
|
|
82
|
+
L.TileLayer.prototype.onAdd.call(_this, map);
|
|
83
|
+
|
|
84
|
+
// Set minZoom and minNativeZoom based on how the imageSizes match up
|
|
85
|
+
var smallestImage = _this._imageSizes[0];
|
|
86
|
+
var mapSize = _this._map.getSize();
|
|
87
|
+
var newMinZoom = 0;
|
|
88
|
+
// Loop back through 5 times to see if a better fit can be found.
|
|
89
|
+
for (var i = 1; i <= 5; i++) {
|
|
90
|
+
if (smallestImage.x > mapSize.x || smallestImage.y > mapSize.y) {
|
|
91
|
+
smallestImage = smallestImage.divideBy(2);
|
|
92
|
+
_this._imageSizes.unshift(smallestImage);
|
|
93
|
+
newMinZoom = -i;
|
|
94
|
+
} else {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
_this.options.minZoom = newMinZoom;
|
|
99
|
+
_this.options.minNativeZoom = newMinZoom;
|
|
100
|
+
_this._prev_map_layersMinZoom = _this._map._layersMinZoom;
|
|
101
|
+
_this._map._layersMinZoom = newMinZoom;
|
|
102
|
+
|
|
103
|
+
if (_this.options.fitBounds) {
|
|
104
|
+
_this._fitBounds();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if(_this.options.setMaxBounds) {
|
|
108
|
+
_this._setMaxBounds();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Reset tile sizes to handle non 256x256 IIIF tiles
|
|
112
|
+
_this.on('tileload', function(tile, url) {
|
|
113
|
+
|
|
114
|
+
var height = tile.tile.naturalHeight,
|
|
115
|
+
width = tile.tile.naturalWidth;
|
|
116
|
+
|
|
117
|
+
// No need to resize if tile is 256 x 256
|
|
118
|
+
if (height === 256 && width === 256) return;
|
|
119
|
+
|
|
120
|
+
tile.tile.style.width = width + 'px';
|
|
121
|
+
tile.tile.style.height = height + 'px';
|
|
122
|
+
|
|
123
|
+
});
|
|
124
|
+
})
|
|
125
|
+
.catch(function(err){
|
|
126
|
+
console.error(err);
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
onRemove: function(map) {
|
|
130
|
+
var _this = this;
|
|
131
|
+
|
|
132
|
+
map._layersMinZoom = _this._prev_map_layersMinZoom;
|
|
133
|
+
_this._imageSizes = _this._imageSizesOriginal;
|
|
134
|
+
|
|
135
|
+
// Remove maxBounds set for this image
|
|
136
|
+
if(_this.options.setMaxBounds) {
|
|
137
|
+
map.setMaxBounds(null);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Call remove TileLayer
|
|
141
|
+
L.TileLayer.prototype.onRemove.call(_this, map);
|
|
142
|
+
|
|
143
|
+
},
|
|
144
|
+
_fitBounds: function() {
|
|
145
|
+
var _this = this;
|
|
146
|
+
|
|
147
|
+
// Find best zoom level and center map
|
|
148
|
+
var initialZoom = _this._getInitialZoom(_this._map.getSize());
|
|
149
|
+
var offset = _this._imageSizes.length - 1 - _this.options.maxNativeZoom;
|
|
150
|
+
var imageSize = _this._imageSizes[initialZoom + offset];
|
|
151
|
+
var sw = _this._map.options.crs.pointToLatLng(L.point(0, imageSize.y), initialZoom);
|
|
152
|
+
var ne = _this._map.options.crs.pointToLatLng(L.point(imageSize.x, 0), initialZoom);
|
|
153
|
+
var bounds = L.latLngBounds(sw, ne);
|
|
154
|
+
|
|
155
|
+
_this._map.fitBounds(bounds, true);
|
|
156
|
+
},
|
|
157
|
+
_setMaxBounds: function() {
|
|
158
|
+
var _this = this;
|
|
159
|
+
|
|
160
|
+
// Find best zoom level, center map, and constrain viewer
|
|
161
|
+
var initialZoom = _this._getInitialZoom(_this._map.getSize());
|
|
162
|
+
var imageSize = _this._imageSizes[initialZoom];
|
|
163
|
+
var sw = _this._map.options.crs.pointToLatLng(L.point(0, imageSize.y), initialZoom);
|
|
164
|
+
var ne = _this._map.options.crs.pointToLatLng(L.point(imageSize.x, 0), initialZoom);
|
|
165
|
+
var bounds = L.latLngBounds(sw, ne);
|
|
166
|
+
|
|
167
|
+
_this._map.setMaxBounds(bounds, true);
|
|
168
|
+
},
|
|
169
|
+
_getInfo: function() {
|
|
170
|
+
var _this = this;
|
|
171
|
+
|
|
172
|
+
_this._infoPromise = fetch(_this._infoUrl)
|
|
173
|
+
.then(function(response) {
|
|
174
|
+
return response.json();
|
|
175
|
+
})
|
|
176
|
+
.catch(function(err){
|
|
177
|
+
console.error(err);
|
|
178
|
+
})
|
|
179
|
+
.then(function(data) {
|
|
180
|
+
_this.y = data.height;
|
|
181
|
+
_this.x = data.width;
|
|
182
|
+
|
|
183
|
+
var tierSizes = [],
|
|
184
|
+
imageSizes = [],
|
|
185
|
+
scale,
|
|
186
|
+
width_,
|
|
187
|
+
height_,
|
|
188
|
+
tilesX_,
|
|
189
|
+
tilesY_;
|
|
190
|
+
|
|
191
|
+
// Set quality based off of IIIF version
|
|
192
|
+
if (data.profile instanceof Array) {
|
|
193
|
+
_this.profile = data.profile[0];
|
|
194
|
+
}else {
|
|
195
|
+
_this.profile = data.profile;
|
|
196
|
+
}
|
|
197
|
+
_this.type = data.type;
|
|
198
|
+
|
|
199
|
+
_this._setQuality();
|
|
200
|
+
|
|
201
|
+
// Unless an explicit tileSize is set, use a preferred tileSize
|
|
202
|
+
if (!_this._explicitTileSize) {
|
|
203
|
+
// Set the default first
|
|
204
|
+
_this.options.tileSize = 256;
|
|
205
|
+
if (data.tiles) {
|
|
206
|
+
// Image API 2.0 Case
|
|
207
|
+
_this.options.tileSize = data.tiles[0].width;
|
|
208
|
+
} else if (data.tile_width){
|
|
209
|
+
// Image API 1.1 Case
|
|
210
|
+
_this.options.tileSize = data.tile_width;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function ceilLog2(x) {
|
|
215
|
+
return Math.ceil(Math.log(x) / Math.LN2);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// Calculates maximum native zoom for the layer
|
|
219
|
+
_this.maxNativeZoom = Math.max(
|
|
220
|
+
ceilLog2(_this.x / _this.options.tileSize),
|
|
221
|
+
ceilLog2(_this.y / _this.options.tileSize),
|
|
222
|
+
0
|
|
223
|
+
);
|
|
224
|
+
_this.options.maxNativeZoom = _this.maxNativeZoom;
|
|
225
|
+
|
|
226
|
+
// Enable zooming further than native if maxZoom option supplied
|
|
227
|
+
if (_this._customMaxZoom && _this.options.maxZoom > _this.maxNativeZoom) {
|
|
228
|
+
_this.maxZoom = _this.options.maxZoom;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
_this.maxZoom = _this.maxNativeZoom;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
for (var i = 0; i <= _this.maxZoom; i++) {
|
|
235
|
+
scale = Math.pow(2, _this.maxNativeZoom - i);
|
|
236
|
+
width_ = Math.ceil(_this.x / scale);
|
|
237
|
+
height_ = Math.ceil(_this.y / scale);
|
|
238
|
+
tilesX_ = Math.ceil(width_ / _this.options.tileSize);
|
|
239
|
+
tilesY_ = Math.ceil(height_ / _this.options.tileSize);
|
|
240
|
+
tierSizes.push([tilesX_, tilesY_]);
|
|
241
|
+
imageSizes.push(L.point(width_,height_));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
_this._tierSizes = tierSizes;
|
|
245
|
+
_this._imageSizes = imageSizes;
|
|
246
|
+
})
|
|
247
|
+
.catch(function(err){
|
|
248
|
+
console.error(err);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
_setQuality: function() {
|
|
254
|
+
var _this = this;
|
|
255
|
+
var profileToCheck = _this.profile;
|
|
256
|
+
|
|
257
|
+
if (_this._explicitQuality) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// If profile is an object
|
|
262
|
+
if (typeof(profileToCheck) === 'object') {
|
|
263
|
+
profileToCheck = profileToCheck['@id'];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Set the quality based on the IIIF compliance level
|
|
267
|
+
switch (true) {
|
|
268
|
+
case /^http:\/\/library.stanford.edu\/iiif\/image-api\/1.1\/compliance.html.*$/.test(profileToCheck):
|
|
269
|
+
_this.options.quality = 'native';
|
|
270
|
+
break;
|
|
271
|
+
// Assume later profiles and set to default
|
|
272
|
+
default:
|
|
273
|
+
_this.options.quality = 'default';
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
_infoToBaseUrl: function() {
|
|
279
|
+
return this._infoUrl.replace('info.json', '');
|
|
280
|
+
},
|
|
281
|
+
_templateUrl: function() {
|
|
282
|
+
return this._infoToBaseUrl() + '{region}/{size}/{rotation}/{quality}.{format}';
|
|
283
|
+
},
|
|
284
|
+
_isValidTile: function(coords) {
|
|
285
|
+
var _this = this;
|
|
286
|
+
var zoom = _this._getZoomForUrl();
|
|
287
|
+
var sizes = _this._tierSizes[zoom];
|
|
288
|
+
var x = coords.x;
|
|
289
|
+
var y = coords.y;
|
|
290
|
+
if (zoom < 0 && x >= 0 && y >= 0) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (!sizes) return false;
|
|
295
|
+
if (x < 0 || sizes[0] <= x || y < 0 || sizes[1] <= y) {
|
|
296
|
+
return false;
|
|
297
|
+
}else {
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
_tileShouldBeLoaded: function(coords) {
|
|
302
|
+
return this._isValidTile(coords);
|
|
303
|
+
},
|
|
304
|
+
_getInitialZoom: function (mapSize) {
|
|
305
|
+
var _this = this;
|
|
306
|
+
var tolerance = 0.8;
|
|
307
|
+
var imageSize;
|
|
308
|
+
// Calculate an offset between the zoom levels and the array accessors
|
|
309
|
+
var offset = _this._imageSizes.length - 1 - _this.options.maxNativeZoom;
|
|
310
|
+
for (var i = _this._imageSizes.length - 1; i >= 0; i--) {
|
|
311
|
+
imageSize = _this._imageSizes[i];
|
|
312
|
+
if (imageSize.x * tolerance < mapSize.x && imageSize.y * tolerance < mapSize.y) {
|
|
313
|
+
return i - offset;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// return a default zoom
|
|
317
|
+
return 2;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
L.tileLayer.iiif = function(url, options) {
|
|
322
|
+
return new L.TileLayer.Iiif(url, options);
|
|
323
|
+
};
|