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 54dab7e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 44 deletions.
2 changes: 2 additions & 0 deletions girder/girder_large_image/web_client/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as utils from './utils.js';
import * as views from './views';
import * as vue from './vue';

export {
utils,
views,
vue,
};
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ function setFrameQuad(tileinfo, layer, options) {
layer.setFrameQuad.status = status;
}

export default setFrameQuad;
export { setFrameQuad };
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Hammer from '@egjs/hammerjs';

import ImageViewerWidget from './base';
import setFrameQuad from './setFrameQuad.js';
import { setFrameQuad } from '../../utils.js';

const $ = girder.$;
const _ = girder._;
Expand All @@ -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 @@ -3,13 +3,11 @@ import leaflet from './leaflet';
import openlayers from './openlayers';
import openseadragon from './openseadragon';
import slideatlas from './slideatlas';
import setFrameQuad from './setFrameQuad';

export {
geojs,
leaflet,
openlayers,
openseadragon,
slideatlas,
setFrameQuad,
};
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 54dab7e

Please sign in to comment.