Skip to content

Commit

Permalink
Don't double-load geojs
Browse files Browse the repository at this point in the history
Also fixup image viewer extensions
  • Loading branch information
zachmullen committed Jul 10, 2024
1 parent dcaa218 commit 21bd063
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,27 @@ var GeojsImageViewerWidget = ImageViewerWidget.extend({
this._scale = settings.scale;
this._setFrames = settings.setFrames;

$.when(
ImageViewerWidget.prototype.initialize.call(this, settings).then(() => {
if (this.metadata.geospatial) {
this.tileWidth = this.tileHeight = null;
return restRequest({
type: 'GET',
url: 'item/' + this.itemId + '/tiles',
data: {projection: 'EPSG:3857'}
}).done((resp) => {
this.levels = resp.levels;
this.tileWidth = resp.tileWidth;
this.tileHeight = resp.tileHeight;
this.sizeX = resp.sizeX;
this.sizeY = resp.sizeY;
this.metadata = resp;
});
}
return this;
}),
$.ajax({ // like $.getScript, but allow caching
url: `/plugin_static/large_image/extra/geojs.js?_=${__BUILD_TIMESTAMP__}`,
dataType: 'script',
cache: true
}))
.done(() => {
this.trigger('g:beforeFirstRender', this);
this.render();
});
ImageViewerWidget.prototype.initialize.call(this, settings).then(() => {
if (this.metadata.geospatial) {
this.tileWidth = this.tileHeight = null;
return restRequest({
type: 'GET',
url: 'item/' + this.itemId + '/tiles',
data: {projection: 'EPSG:3857'}
}).done((resp) => {
this.levels = resp.levels;
this.tileWidth = resp.tileWidth;
this.tileHeight = resp.tileHeight;
this.sizeX = resp.sizeX;
this.sizeY = resp.sizeY;
this.metadata = resp;
});
}
return this;
}).then(() => {
this.trigger('g:beforeFirstRender', this);
this.render();
})
},

render: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@ import ItemListWidget from './itemList';
import ImageViewerWidgetAnnotationExtension from './imageViewerWidget/base';
import * as extensions from './imageViewerWidget';

const events = girder.events;
const viewers = {};

events.on('g:appload.before', function () {
const _ = girder._;
for (var key in girder.plugins.large_image.views.imageViewerWidget) {
viewers[key] = girder.plugins.large_image.views.imageViewerWidget[key].extend(ImageViewerWidgetAnnotationExtension);

for (var key in girder.plugins.large_image.views.imageViewerWidget) {
viewers[key] = girder.plugins.large_image.views.imageViewerWidget[key];

_.extend(viewers[key].prototype, ImageViewerWidgetAnnotationExtension);
if (extensions[key]) {
const extension = extensions[key](viewers[key]).prototype;
_.extend(viewers[key], extension);
}
if (extensions[key]) {
viewers[key] = extensions[key](viewers[key]);
}
});
}

export {
ConfigView,
Expand Down

0 comments on commit 21bd063

Please sign in to comment.