From 7b759558b126c27ac08e7126bdf99d49e74fb50f Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 7 Jun 2022 14:53:18 +0200 Subject: [PATCH] Add tile reference to imagejob options. --- src/imageloader.js | 9 +++++++-- src/tiledimage.js | 1 + src/tilesource.js | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/imageloader.js b/src/imageloader.js index 1fea59b3..c5788c84 100644 --- a/src/imageloader.js +++ b/src/imageloader.js @@ -39,9 +39,11 @@ * @classdesc Handles downloading of a single image. * @param {Object} options - Options for this ImageJob. * @param {String} [options.src] - URL of image to download. + * @param {Tile} [options.tile] - Tile that belongs the data to. * @param {TileSource} [options.source] - Image loading strategy * @param {String} [options.loadWithAjax] - Whether to load this image with AJAX. * @param {String} [options.ajaxHeaders] - Headers to add to the image request if using AJAX. + * @param {Boolean} [options.ajaxWithCredentials] - Whether to set withCredentials on AJAX requests. * @param {String} [options.crossOriginPolicy] - CORS policy to use for downloads * @param {String} [options.postData] - HTTP POST data (usually but not necessarily in k=v&k2=v2... form, * see TileSource::getPostData) or null @@ -89,7 +91,7 @@ $.ImageJob.prototype = { var selfAbort = this.abort; this.jobId = window.setTimeout(function () { - self.finish(null, "Image load exceeded timeout (" + self.timeout + " ms)"); + self.finish(null, null, "Image load exceeded timeout (" + self.timeout + " ms)"); }, this.timeout); this.abort = function() { @@ -149,6 +151,8 @@ $.ImageLoader.prototype = { * @method * @param {Object} options - Options for this job. * @param {String} [options.src] - URL of image to download. + * @param {Tile} [options.tile] - Tile that belongs the data to. The tile instance + * is not internally used and serves for custom TileSources implementations. * @param {TileSource} [options.source] - Image loading strategy * @param {String} [options.loadWithAjax] - Whether to load this image with AJAX. * @param {String} [options.ajaxHeaders] - Headers to add to the image request if using AJAX. @@ -177,6 +181,7 @@ $.ImageLoader.prototype = { }, jobOptions = { src: options.src, + tile: options.tile || {}, source: options.source, loadWithAjax: options.loadWithAjax, ajaxHeaders: options.loadWithAjax ? options.ajaxHeaders : null, @@ -233,7 +238,7 @@ function completeJob(loader, job, callback) { loader.jobsInProgress++; } - callback(job.data, job.errorMsg, job.request); //todo job.request might not exist + callback(job.data, job.errorMsg, job.request); } }(OpenSeadragon)); diff --git a/src/tiledimage.js b/src/tiledimage.js index c60bd08a..962bfd7d 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1570,6 +1570,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag tile.loading = true; this._imageLoader.addJob({ src: tile.url, + tile: tile, source: this.source, postData: tile.postData, loadWithAjax: tile.loadWithAjax, diff --git a/src/tilesource.js b/src/tilesource.js index 59a35d62..a64869d5 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -726,6 +726,7 @@ $.TileSource.prototype = { * @param {String} [context.src] - URL of image to download. * @param {String} [context.loadWithAjax] - Whether to load this image with AJAX. * @param {String} [context.ajaxHeaders] - Headers to add to the image request if using AJAX. + * @param {Boolean} [context.ajaxWithCredentials] - Whether to set withCredentials on AJAX requests. * @param {String} [context.crossOriginPolicy] - CORS policy to use for downloads * @param {String} [context.postData] - HTTP POST data (usually but not necessarily in k=v&k2=v2... form, * see TileSource::getPostData) or null