Merge branch 'master' into IE9-MouseTracker-Clicks
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
*.sublime-workspace
|
*.sublime-workspace
|
||||||
node_modules
|
node_modules
|
||||||
build/
|
build/
|
||||||
|
sftp-config.json
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- 0.8
|
- 0.10
|
||||||
before_script:
|
before_script:
|
||||||
- npm install -g grunt-cli
|
- npm install -g grunt-cli
|
||||||
|
20
Gruntfile.js
@ -34,7 +34,6 @@ module.exports = function(grunt) {
|
|||||||
"src/tilesource.js",
|
"src/tilesource.js",
|
||||||
"src/dzitilesource.js",
|
"src/dzitilesource.js",
|
||||||
"src/iiiftilesource.js",
|
"src/iiiftilesource.js",
|
||||||
"src/iiif1_1tilesource.js",
|
|
||||||
"src/osmtilesource.js",
|
"src/osmtilesource.js",
|
||||||
"src/tmstilesource.js",
|
"src/tmstilesource.js",
|
||||||
"src/legacytilesource.js",
|
"src/legacytilesource.js",
|
||||||
@ -52,6 +51,11 @@ module.exports = function(grunt) {
|
|||||||
"src/viewport.js"
|
"src/viewport.js"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
grunt.event.once('git-describe', function (rev) {
|
||||||
|
grunt.config.set('gitInfo', rev);
|
||||||
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Project configuration.
|
// Project configuration.
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
@ -101,12 +105,8 @@ module.exports = function(grunt) {
|
|||||||
uglify: {
|
uglify: {
|
||||||
options: {
|
options: {
|
||||||
preserveComments: "some",
|
preserveComments: "some",
|
||||||
sourceMap: function (filename) {
|
sourceMap: true,
|
||||||
return filename.replace(/\.js$/, '.js.map');
|
sourceMapName: 'build/openseadragon/openseadragon.min.js.map'
|
||||||
},
|
|
||||||
sourceMappingURL: function (filename) {
|
|
||||||
return filename.replace(/\.js$/, '.js.map').replace('build/openseadragon/', '');
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
openseadragon: {
|
openseadragon: {
|
||||||
src: [ distribution ],
|
src: [ distribution ],
|
||||||
@ -161,11 +161,7 @@ module.exports = function(grunt) {
|
|||||||
afterconcat: [ distribution ]
|
afterconcat: [ distribution ]
|
||||||
},
|
},
|
||||||
"git-describe": {
|
"git-describe": {
|
||||||
build: {
|
build: {}
|
||||||
options: {
|
|
||||||
prop: "gitInfo"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
OPENSEADRAGON CHANGELOG
|
OPENSEADRAGON CHANGELOG
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
1.1.2: (in progress)
|
1.2.0: (in progress)
|
||||||
|
|
||||||
|
* New combined IIIF TileSource for 1.0 through 2.0 (#441)
|
||||||
|
* BREAKING CHANGE: Removed IIIF1_1TileSource (now that IIIFTileSource supports all versions)
|
||||||
|
* Allowed TileSources to have dynamic tileSize via source.getTileSize(level) (#441)
|
||||||
|
* DEPRECATION: Use .getTileSize(level) instead of .tileSize
|
||||||
|
* Fix for IIPServer-style urls when using DZI (#413)
|
||||||
|
* Fix memory leak while destroying the viewer (#421)
|
||||||
|
* Added fitBoundsWithConstraints() to the viewport (#423)
|
||||||
|
|
||||||
1.1.1:
|
1.1.1:
|
||||||
|
|
||||||
|
23
package.json
@ -3,17 +3,18 @@
|
|||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"description": "Provides a smooth, zoomable user interface for HTML/Javascript.",
|
"description": "Provides a smooth, zoomable user interface for HTML/Javascript.",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt": "~0.4.1",
|
"grunt": "^0.4.5",
|
||||||
"grunt-contrib-compress": "~0.5.2",
|
"grunt-contrib-clean": "^0.5.0",
|
||||||
"grunt-contrib-concat": "~0.3.0",
|
"grunt-text-replace": "^0.3.11",
|
||||||
"grunt-contrib-jshint": "~0.7.2",
|
"grunt-contrib-concat": "^0.4.0",
|
||||||
"grunt-contrib-uglify": "~0.2.7",
|
"grunt-git-describe": "^2.3.2",
|
||||||
"grunt-contrib-qunit": "~0.3.0",
|
"grunt-contrib-uglify": "^0.4.0",
|
||||||
"grunt-contrib-connect": "~0.5.0",
|
"grunt-contrib-watch": "^0.6.1",
|
||||||
"grunt-contrib-watch": "~0.5.3",
|
"grunt-contrib-qunit": "^0.5.1",
|
||||||
"grunt-contrib-clean": "~0.5.0",
|
"grunt-contrib-jshint": "^0.10.0",
|
||||||
"grunt-git-describe": "~2.0.0",
|
"grunt-contrib-compress": "^0.9.1",
|
||||||
"grunt-text-replace": "~0.3.9"
|
"grunt-contrib-connect": "^0.7.1",
|
||||||
|
"qunitjs": "^1.14.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "grunt test"
|
"test": "grunt test"
|
||||||
|
@ -302,6 +302,22 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
|
|||||||
*/
|
*/
|
||||||
canRotate: function() {
|
canRotate: function() {
|
||||||
return this.useCanvas;
|
return this.useCanvas;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy the drawer (unload current loaded tiles)
|
||||||
|
* @method
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
destroy: function() {
|
||||||
|
//unload current loaded tiles (=empty TILE_CACHE)
|
||||||
|
for ( var i = 0; i < this.tilesLoaded.length; ++i ) {
|
||||||
|
this.tilesLoaded[i].unload();
|
||||||
|
}
|
||||||
|
|
||||||
|
//force unloading of current canvas (1x1 will be gc later, trick not necessarily needed)
|
||||||
|
this.canvas.width = 1;
|
||||||
|
this.canvas.height = 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -695,6 +711,7 @@ function loadTile( drawer, tile, time ) {
|
|||||||
tile.loading = true;
|
tile.loading = true;
|
||||||
drawer.imageLoader.addJob({
|
drawer.imageLoader.addJob({
|
||||||
src: tile.url,
|
src: tile.url,
|
||||||
|
crossOriginPolicy: drawer.crossOriginPolicy,
|
||||||
callback: function( image ){
|
callback: function( image ){
|
||||||
onTileLoad( drawer, tile, time, image );
|
onTileLoad( drawer, tile, time, image );
|
||||||
}
|
}
|
||||||
@ -733,11 +750,10 @@ function onTileLoad( drawer, tile, time, image ) {
|
|||||||
tile.loaded = true;
|
tile.loaded = true;
|
||||||
tile.image = image;
|
tile.image = image;
|
||||||
|
|
||||||
|
|
||||||
insertionIndex = drawer.tilesLoaded.length;
|
insertionIndex = drawer.tilesLoaded.length;
|
||||||
|
|
||||||
if ( drawer.tilesLoaded.length >= drawer.maxImageCacheCount ) {
|
if ( drawer.tilesLoaded.length >= drawer.maxImageCacheCount ) {
|
||||||
cutoff = Math.ceil( Math.log( drawer.source.tileSize ) / Math.log( 2 ) );
|
cutoff = Math.ceil( Math.log( drawer.source.getTileSize(tile.level) ) / Math.log( 2 ) );
|
||||||
|
|
||||||
worstTile = null;
|
worstTile = null;
|
||||||
worstTileIndex = -1;
|
worstTileIndex = -1;
|
||||||
|
@ -138,7 +138,12 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, /** @lends OpenSead
|
|||||||
|
|
||||||
if (url && !options.tilesUrl) {
|
if (url && !options.tilesUrl) {
|
||||||
options.tilesUrl = url.replace(/([^\/]+)\.(dzi|xml|js)(\?.*|$)/, '$1_files/');
|
options.tilesUrl = url.replace(/([^\/]+)\.(dzi|xml|js)(\?.*|$)/, '$1_files/');
|
||||||
|
|
||||||
|
if (url.search(/\.(dzi|xml|js)\?/) != -1) {
|
||||||
options.queryParams = url.match(/\?.*/);
|
options.queryParams = url.match(/\?.*/);
|
||||||
|
}else{
|
||||||
|
options.queryParams = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
@ -1,192 +0,0 @@
|
|||||||
/*
|
|
||||||
* OpenSeadragon - IIIF1_1TileSource
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 CodePlex Foundation
|
|
||||||
* Copyright (C) 2010-2013 OpenSeadragon contributors
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of CodePlex Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function( $ ){
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class IIIF1_1TileSource
|
|
||||||
* @classdesc A client implementation of the International Image Interoperability
|
|
||||||
* Format: Image API 1.1
|
|
||||||
*
|
|
||||||
* @memberof OpenSeadragon
|
|
||||||
* @extends OpenSeadragon.TileSource
|
|
||||||
* @see http://library.stanford.edu/iiif/image-api/
|
|
||||||
*/
|
|
||||||
$.IIIF1_1TileSource = function( options ){
|
|
||||||
|
|
||||||
|
|
||||||
$.extend( true, this, options );
|
|
||||||
|
|
||||||
|
|
||||||
if ( !( this.height && this.width && this['@id'] ) ){
|
|
||||||
throw new Error( 'IIIF required parameters not provided.' );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ( this.profile &&
|
|
||||||
this.profile == "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0" ) ){
|
|
||||||
// what if not reporting a profile?
|
|
||||||
throw new Error( 'IIIF Image API 1.1 compliance level 1 or greater is required.' );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( this.tile_width ) {
|
|
||||||
options.tileSize = this.tile_width;
|
|
||||||
} else if ( this.tile_height ) {
|
|
||||||
options.tileSize = this.tile_height;
|
|
||||||
} else {
|
|
||||||
// use the largest of tileOptions that is smaller than the short
|
|
||||||
// dimension
|
|
||||||
|
|
||||||
var shortDim = Math.min( this.height, this.width ),
|
|
||||||
tileOptions = [256,512,1024],
|
|
||||||
smallerTiles = [];
|
|
||||||
|
|
||||||
for ( var c = 0; c < tileOptions.length; c++ ) {
|
|
||||||
if ( tileOptions[c] <= shortDim ) {
|
|
||||||
smallerTiles.push( tileOptions[c] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( smallerTiles.length > 0 ) {
|
|
||||||
options.tileSize = Math.max.apply( null, smallerTiles );
|
|
||||||
} else {
|
|
||||||
// If we're smaller than 256, just use the short side.
|
|
||||||
options.tileSize = shortDim;
|
|
||||||
}
|
|
||||||
this.tile_width = options.tileSize; // So that 'full' gets used for
|
|
||||||
this.tile_height = options.tileSize; // the region below
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !options.maxLevel ) {
|
|
||||||
var mf = -1;
|
|
||||||
var scfs = this.scale_factors || this.scale_factor;
|
|
||||||
if ( scfs instanceof Array ) {
|
|
||||||
for ( var i = 0; i < scfs.length; i++ ) {
|
|
||||||
var cf = Number( scfs[i] );
|
|
||||||
if ( !isNaN( cf ) && cf > mf ) { mf = cf; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( mf < 0 ) { options.maxLevel = Number( Math.ceil( Math.log( Math.max( this.width, this.height ), 2 ) ) ); }
|
|
||||||
else { options.maxLevel = mf; }
|
|
||||||
}
|
|
||||||
|
|
||||||
$.TileSource.apply( this, [ options ] );
|
|
||||||
};
|
|
||||||
|
|
||||||
$.extend( $.IIIF1_1TileSource.prototype, $.TileSource.prototype, /** @lends OpenSeadragon.IIIF1_1TileSource.prototype */{
|
|
||||||
/**
|
|
||||||
* Determine if the data and/or url imply the image service is supported by
|
|
||||||
* this tile source.
|
|
||||||
* @function
|
|
||||||
* @param {Object|Array} data
|
|
||||||
* @param {String} optional - url
|
|
||||||
*/
|
|
||||||
supports: function( data, url ) {
|
|
||||||
return ( data['@context'] &&
|
|
||||||
data['@context'] == "http://library.stanford.edu/iiif/image-api/1.1/context.json" );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @function
|
|
||||||
* @param {Object} data - the raw configuration
|
|
||||||
* @example <caption>IIIF 1.1 Info Looks like this (XML syntax is no more)</caption>
|
|
||||||
* {
|
|
||||||
* "@context" : "http://library.stanford.edu/iiif/image-api/1.1/context.json",
|
|
||||||
* "@id" : "http://iiif.example.com/prefix/1E34750D-38DB-4825-A38A-B60A345E591C",
|
|
||||||
* "width" : 6000,
|
|
||||||
* "height" : 4000,
|
|
||||||
* "scale_factors" : [ 1, 2, 4 ],
|
|
||||||
* "tile_width" : 1024,
|
|
||||||
* "tile_height" : 1024,
|
|
||||||
* "formats" : [ "jpg", "png" ],
|
|
||||||
* "qualities" : [ "native", "grey" ],
|
|
||||||
* "profile" : "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0"
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
configure: function( data ){
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Responsible for retreiving the url which will return an image for the
|
|
||||||
* region specified by the given x, y, and level components.
|
|
||||||
* @function
|
|
||||||
* @param {Number} level - z index
|
|
||||||
* @param {Number} x
|
|
||||||
* @param {Number} y
|
|
||||||
* @throws {Error}
|
|
||||||
*/
|
|
||||||
getTileUrl: function( level, x, y ){
|
|
||||||
|
|
||||||
//# constants
|
|
||||||
|
|
||||||
var IIIF_ROTATION = '0',
|
|
||||||
IIIF_QUALITY = 'native.jpg',
|
|
||||||
|
|
||||||
//## get the scale (level as a decimal)
|
|
||||||
scale = Math.pow( 0.5, this.maxLevel - level ),
|
|
||||||
|
|
||||||
//# image dimensions at this level
|
|
||||||
levelWidth = Math.ceil( this.width * scale ),
|
|
||||||
levelHeight = Math.ceil( this.height * scale ),
|
|
||||||
|
|
||||||
//## iiif region
|
|
||||||
iiifTileSizeWidth = Math.ceil( this.tileSize / scale ),
|
|
||||||
iiifTileSizeHeight = Math.ceil( this.tileSize / scale ),
|
|
||||||
iiifRegion,
|
|
||||||
iiifTileX,
|
|
||||||
iiifTileY,
|
|
||||||
iiifTileW,
|
|
||||||
iiifTileH,
|
|
||||||
iiifSize,
|
|
||||||
uri;
|
|
||||||
|
|
||||||
if ( levelWidth < this.tile_width && levelHeight < this.tile_height ){
|
|
||||||
iiifSize = levelWidth + ",";
|
|
||||||
iiifRegion = 'full';
|
|
||||||
} else {
|
|
||||||
iiifTileX = x * iiifTileSizeWidth;
|
|
||||||
iiifTileY = y * iiifTileSizeHeight;
|
|
||||||
iiifTileW = Math.min( iiifTileSizeWidth, this.width - iiifTileX );
|
|
||||||
iiifTileH = Math.min( iiifTileSizeHeight, this.height - iiifTileY );
|
|
||||||
|
|
||||||
iiifSize = Math.ceil( iiifTileW * scale ) + ",";
|
|
||||||
|
|
||||||
iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' );
|
|
||||||
}
|
|
||||||
uri = [ this['@id'], iiifRegion, iiifSize, IIIF_ROTATION, IIIF_QUALITY ].join( '/' );
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
|
@ -32,51 +32,78 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* The getTileUrl implementation is based on Jon Stroop's Python version,
|
|
||||||
* which is released under the New BSD license:
|
|
||||||
* https://gist.github.com/jpstroop/4624253
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class IIIFTileSource
|
* @class IIIFTileSource
|
||||||
* @classdesc A client implementation of the International Image Interoperability
|
* @classdesc A client implementation of the International Image Interoperability
|
||||||
* Format: Image API Draft 0.2
|
* Format: Image API 1.0 - 2.0
|
||||||
*
|
*
|
||||||
* @memberof OpenSeadragon
|
* @memberof OpenSeadragon
|
||||||
* @extends OpenSeadragon.TileSource
|
* @extends OpenSeadragon.TileSource
|
||||||
* @see http://library.stanford.edu/iiif/image-api/
|
* @see http://iiif.io/api/image/
|
||||||
*/
|
*/
|
||||||
$.IIIFTileSource = function( options ){
|
$.IIIFTileSource = function( options ){
|
||||||
|
|
||||||
|
|
||||||
$.extend( true, this, options );
|
$.extend( true, this, options );
|
||||||
|
|
||||||
if( !(this.height && this.width && this.identifier && this.tilesUrl ) ){
|
if ( !( this.height && this.width && this['@id'] ) ) {
|
||||||
throw new Error( 'IIIF required parameters not provided.' );
|
throw new Error( 'IIIF required parameters not provided.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: at this point the base tile source implementation assumes
|
options.tileSizePerScaleFactor = {};
|
||||||
// a tile is a square and so only has one property tileSize
|
|
||||||
// to store it. It may be possible to make tileSize a vector
|
if ( this.tile_width ) {
|
||||||
// OpenSeadraon.Point but would require careful implementation
|
|
||||||
// to preserve backward compatibility.
|
|
||||||
options.tileSize = this.tile_width;
|
options.tileSize = this.tile_width;
|
||||||
|
} else if ( this.tile_height ) {
|
||||||
|
options.tileSize = this.tile_height;
|
||||||
|
} else if ( this.tiles ) {
|
||||||
|
// Version 2.0 forwards
|
||||||
|
if ( this.tiles.length == 1 ) {
|
||||||
|
options.tileSize = this.tiles[0].width;
|
||||||
|
this.scale_factors = this.tiles[0].scale_factors;
|
||||||
|
} else {
|
||||||
|
// Multiple tile sizes at different levels
|
||||||
|
this.scale_factors = [];
|
||||||
|
for (var t = 0; t < this.tiles.length; t++ ) {
|
||||||
|
for (var sf = 0; sf < this.tiles[t].scale_factors.length; sf++) {
|
||||||
|
var scaleFactor = this.tiles[t].scale_factors[sf];
|
||||||
|
this.scale_factors.push(scaleFactor);
|
||||||
|
options.tileSizePerScaleFactor[scaleFactor] = this.tiles[t].width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// use the largest of tileOptions that is smaller than the short dimension
|
||||||
|
|
||||||
|
var shortDim = Math.min( this.height, this.width ),
|
||||||
|
tileOptions = [256,512,1024],
|
||||||
|
smallerTiles = [];
|
||||||
|
|
||||||
|
for ( var c = 0; c < tileOptions.length; c++ ) {
|
||||||
|
if ( tileOptions[c] <= shortDim ) {
|
||||||
|
smallerTiles.push( tileOptions[c] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( smallerTiles.length > 0 ) {
|
||||||
|
options.tileSize = Math.max.apply( null, smallerTiles );
|
||||||
|
} else {
|
||||||
|
// If we're smaller than 256, just use the short side.
|
||||||
|
options.tileSize = shortDim;
|
||||||
|
}
|
||||||
|
this.tile_width = options.tileSize; // So that 'full' gets used for
|
||||||
|
this.tile_height = options.tileSize; // the region below
|
||||||
|
}
|
||||||
|
|
||||||
if ( !options.maxLevel ) {
|
if ( !options.maxLevel ) {
|
||||||
var mf = -1;
|
if ( !this.scale_factors ) {
|
||||||
var scfs = this.scale_factors || this.scale_factor;
|
options.maxLevel = Number( Math.ceil( Math.log( Math.max( this.width, this.height ), 2 ) ) );
|
||||||
if ( scfs instanceof Array ) {
|
} else {
|
||||||
for ( var i = 0; i < scfs.length; i++ ) {
|
options.maxLevel = Math.floor( Math.pow( Math.max.apply(null, this.scale_factors), 0.5) );
|
||||||
var cf = Number( scfs[i] );
|
|
||||||
if ( !isNaN( cf ) && cf > mf ) { mf = cf; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( mf < 0 ) { options.maxLevel = Number(Math.ceil(Math.log(Math.max(this.width, this.height), 2))); }
|
|
||||||
else { options.maxLevel = mf; }
|
|
||||||
}
|
|
||||||
|
|
||||||
$.TileSource.apply( this, [ options ] );
|
$.TileSource.apply( this, [ options ] );
|
||||||
};
|
};
|
||||||
@ -85,72 +112,92 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
|||||||
/**
|
/**
|
||||||
* Determine if the data and/or url imply the image service is supported by
|
* Determine if the data and/or url imply the image service is supported by
|
||||||
* this tile source.
|
* this tile source.
|
||||||
* @method
|
* @function
|
||||||
* @param {Object|Array} data
|
* @param {Object|Array} data
|
||||||
* @param {String} optional - url
|
* @param {String} optional - url
|
||||||
*/
|
*/
|
||||||
supports: function( data, url ) {
|
supports: function( data, url ) {
|
||||||
return (
|
// Version 2.0 and forwards
|
||||||
data.ns &&
|
if (data.protocol && data.protocol == 'http://iiif.io/api/image') {
|
||||||
"http://library.stanford.edu/iiif/image-api/ns/" == data.ns
|
return true;
|
||||||
) || (
|
// Version 1.1
|
||||||
data.profile && (
|
} else if ( data['@context'] && (
|
||||||
"http://library.stanford.edu/iiif/image-api/compliance.html#level1" == data.profile ||
|
data['@context'] == "http://library.stanford.edu/iiif/image-api/1.1/context.json" ||
|
||||||
"http://library.stanford.edu/iiif/image-api/compliance.html#level2" == data.profile ||
|
data['@context'] == "http://iiif.io/api/image/1/context.json") ) {
|
||||||
"http://library.stanford.edu/iiif/image-api/compliance.html#level3" == data.profile ||
|
// N.B. the iiif.io context is wrong, but where the representation lives so likely to be used
|
||||||
"http://library.stanford.edu/iiif/image-api/compliance.html" == data.profile
|
return true;
|
||||||
)
|
|
||||||
) || (
|
// Version 1.0
|
||||||
data.documentElement &&
|
} else if ( data.profile &&
|
||||||
|
data.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html") === 0) {
|
||||||
|
return true;
|
||||||
|
} else if ( data.identifier && data.width && data.height ) {
|
||||||
|
return true;
|
||||||
|
} else if ( data.documentElement &&
|
||||||
"info" == data.documentElement.tagName &&
|
"info" == data.documentElement.tagName &&
|
||||||
"http://library.stanford.edu/iiif/image-api/ns/" ==
|
"http://library.stanford.edu/iiif/image-api/ns/" ==
|
||||||
data.documentElement.namespaceURI
|
data.documentElement.namespaceURI) {
|
||||||
);
|
return true;
|
||||||
|
|
||||||
|
// Not IIIF
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @method
|
* @function
|
||||||
* @param {Object|XMLDocument} data - the raw configuration
|
* @param {Object} data - the raw configuration
|
||||||
* @param {String} url - the url the data was retreived from if any.
|
* @example <caption>IIIF 1.1 Info Looks like this</caption>
|
||||||
* @return {Object} options - A dictionary of keyword arguments sufficient
|
* {
|
||||||
* to configure this tile source via its constructor.
|
* "@context" : "http://library.stanford.edu/iiif/image-api/1.1/context.json",
|
||||||
|
* "@id" : "http://iiif.example.com/prefix/1E34750D-38DB-4825-A38A-B60A345E591C",
|
||||||
|
* "width" : 6000,
|
||||||
|
* "height" : 4000,
|
||||||
|
* "scale_factors" : [ 1, 2, 4 ],
|
||||||
|
* "tile_width" : 1024,
|
||||||
|
* "tile_height" : 1024,
|
||||||
|
* "formats" : [ "jpg", "png" ],
|
||||||
|
* "qualities" : [ "native", "grey" ],
|
||||||
|
* "profile" : "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0"
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
configure: function( data, url ){
|
configure: function( data, url ){
|
||||||
var service,
|
// Try to deduce our version and fake it upwards if needed
|
||||||
options,
|
|
||||||
host;
|
|
||||||
|
|
||||||
if ( !$.isPlainObject(data) ) {
|
if ( !$.isPlainObject(data) ) {
|
||||||
|
var options = configureFromXml10( data );
|
||||||
options = configureFromXml( this, data );
|
options['@context'] = "http://iiif.io/api/image/1.0/context.json";
|
||||||
|
options['@id'] = url.replace('/info.xml', '');
|
||||||
}else{
|
|
||||||
|
|
||||||
options = configureFromObject( this, data );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( url && !options.tilesUrl ){
|
|
||||||
service = url.split('/');
|
|
||||||
service.pop(); //info.json or info.xml
|
|
||||||
service = service.join('/');
|
|
||||||
if( 'http' !== url.substring( 0, 4 ) ){
|
|
||||||
host = location.protocol + '//' + location.host;
|
|
||||||
service = host + service;
|
|
||||||
}
|
|
||||||
options.tilesUrl = service.replace(
|
|
||||||
data.identifier,
|
|
||||||
''
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
} else if ( !data['@context'] ) {
|
||||||
|
data['@context'] = 'http://iiif.io/api/image/1.0/context.json';
|
||||||
|
data['@id'] = url.replace('/info.json', '');
|
||||||
|
return data;
|
||||||
|
} else {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the tileSize for the given level.
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
*/
|
||||||
|
|
||||||
|
getTileSize: function( level ){
|
||||||
|
var scaleFactor = Math.pow(2, this.maxLevel - level);
|
||||||
|
// cache it in case any external code is going to read it directly
|
||||||
|
if (this.tileSizePerScaleFactor && this.tileSizePerScaleFactor[scaleFactor]) {
|
||||||
|
this.tileSize = this.tileSizePerScaleFactor[scaleFactor];
|
||||||
|
}
|
||||||
|
return this.tileSize;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for retreiving the url which will return an image for the
|
* Responsible for retreiving the url which will return an image for the
|
||||||
* region speified by the given x, y, and level components.
|
* region specified by the given x, y, and level components.
|
||||||
* @method
|
* @function
|
||||||
* @param {Number} level - z index
|
* @param {Number} level - z index
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
@ -160,83 +207,55 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
|||||||
|
|
||||||
//# constants
|
//# constants
|
||||||
var IIIF_ROTATION = '0',
|
var IIIF_ROTATION = '0',
|
||||||
IIIF_QUALITY = 'native.jpg',
|
|
||||||
|
|
||||||
//## get the scale (level as a decimal)
|
//## get the scale (level as a decimal)
|
||||||
scale = Math.pow( 0.5, this.maxLevel - level ),
|
scale = Math.pow( 0.5, this.maxLevel - level ),
|
||||||
|
|
||||||
//## get iiif size
|
|
||||||
// iiif_size = 'pct:' + ( scale * 100 ),
|
|
||||||
|
|
||||||
//# image dimensions at this level
|
//# image dimensions at this level
|
||||||
level_width = Math.ceil( this.width * scale ),
|
levelWidth = Math.ceil( this.width * scale ),
|
||||||
level_height = Math.ceil( this.height * scale ),
|
levelHeight = Math.ceil( this.height * scale ),
|
||||||
|
|
||||||
//## iiif region
|
//## iiif region
|
||||||
iiif_tile_size_width = Math.ceil( this.tileSize / scale ),
|
iiifTileSizeWidth,
|
||||||
iiif_tile_size_height = Math.ceil( this.tileSize / scale ),
|
iiifTileSizeHeight,
|
||||||
iiif_region,
|
iiifRegion,
|
||||||
iiif_tile_x,
|
iiifTileX,
|
||||||
iiif_tile_y,
|
iiifTileY,
|
||||||
iiif_tile_w,
|
iiifTileW,
|
||||||
iiif_tile_h,
|
iiifTileH,
|
||||||
iiif_size;
|
iiifSize,
|
||||||
|
iiifQuality,
|
||||||
|
uri;
|
||||||
|
|
||||||
|
iiifTileSizeWidth = Math.ceil( this.getTileSize(level) / scale );
|
||||||
|
iiifTileSizeHeight = iiifTileSizeWidth;
|
||||||
|
|
||||||
if ( level_width < this.tile_width && level_height < this.tile_height ){
|
if ( this['@context'].indexOf('/1.0/context.json') > -1 ||
|
||||||
iiif_size = level_width + ","; // + level_height; only one dim. for IIIF level 1 compliance
|
this['@context'].indexOf('/1.1/context.json') > -1 ||
|
||||||
iiif_region = 'full';
|
this['@context'].indexOf('/1/context.json') > -1 ) {
|
||||||
|
iiifQuality = "native.jpg";
|
||||||
} else {
|
} else {
|
||||||
iiif_tile_x = x * iiif_tile_size_width;
|
iiifQuality = "default.jpg";
|
||||||
iiif_tile_y = y * iiif_tile_size_height;
|
|
||||||
iiif_tile_w = Math.min( iiif_tile_size_width, this.width - iiif_tile_x );
|
|
||||||
iiif_tile_h = Math.min( iiif_tile_size_height, this.height - iiif_tile_y );
|
|
||||||
iiif_size = Math.ceil(iiif_tile_w * scale) + ",";
|
|
||||||
iiif_region = [ iiif_tile_x, iiif_tile_y, iiif_tile_w, iiif_tile_h ].join(',');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
if ( levelWidth < this.tile_width && levelHeight < this.tile_height ){
|
||||||
this.tilesUrl,
|
iiifSize = levelWidth + ",";
|
||||||
this.identifier,
|
iiifRegion = 'full';
|
||||||
iiif_region,
|
} else {
|
||||||
iiif_size,
|
iiifTileX = x * iiifTileSizeWidth;
|
||||||
IIIF_ROTATION,
|
iiifTileY = y * iiifTileSizeHeight;
|
||||||
IIIF_QUALITY
|
iiifTileW = Math.min( iiifTileSizeWidth, this.width - iiifTileX );
|
||||||
].join('/');
|
iiifTileH = Math.min( iiifTileSizeHeight, this.height - iiifTileY );
|
||||||
|
iiifSize = Math.ceil( iiifTileW * scale ) + ",";
|
||||||
|
iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' );
|
||||||
}
|
}
|
||||||
|
uri = [ this['@id'], iiifRegion, iiifSize, IIIF_ROTATION, iiifQuality ].join( '/' );
|
||||||
|
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
function configureFromXml10(xmlDoc) {
|
||||||
* @private
|
|
||||||
* @inner
|
|
||||||
* @function
|
|
||||||
* @example
|
|
||||||
* <?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
* <info xmlns="http://library.stanford.edu/iiif/image-api/ns/">
|
|
||||||
* <identifier>1E34750D-38DB-4825-A38A-B60A345E591C</identifier>
|
|
||||||
* <width>6000</width>
|
|
||||||
* <height>4000</height>
|
|
||||||
* <scale_factors>
|
|
||||||
* <scale_factor>1</scale_factor>
|
|
||||||
* <scale_factor>2</scale_factor>
|
|
||||||
* <scale_factor>4</scale_factor>
|
|
||||||
* </scale_factors>
|
|
||||||
* <tile_width>1024</tile_width>
|
|
||||||
* <tile_height>1024</tile_height>
|
|
||||||
* <formats>
|
|
||||||
* <format>jpg</format>
|
|
||||||
* <format>png</format>
|
|
||||||
* </formats>
|
|
||||||
* <qualities>
|
|
||||||
* <quality>native</quality>
|
|
||||||
* <quality>grey</quality>
|
|
||||||
* </qualities>
|
|
||||||
* </info>
|
|
||||||
*/
|
|
||||||
function configureFromXml( tileSource, xmlDoc ){
|
|
||||||
|
|
||||||
//parse the xml
|
//parse the xml
|
||||||
if ( !xmlDoc || !xmlDoc.documentElement ) {
|
if ( !xmlDoc || !xmlDoc.documentElement ) {
|
||||||
throw new Error( $.getString( "Errors.Xml" ) );
|
throw new Error( $.getString( "Errors.Xml" ) );
|
||||||
@ -247,16 +266,10 @@ function configureFromXml( tileSource, xmlDoc ){
|
|||||||
configuration = null;
|
configuration = null;
|
||||||
|
|
||||||
if ( rootName == "info" ) {
|
if ( rootName == "info" ) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
configuration = {};
|
||||||
configuration = {
|
parseXML10( root, configuration );
|
||||||
"ns": root.namespaceURI
|
return configuration;
|
||||||
};
|
|
||||||
|
|
||||||
parseXML( root, configuration );
|
|
||||||
|
|
||||||
return configureFromObject( tileSource, configuration );
|
|
||||||
|
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
throw (e instanceof Error) ?
|
throw (e instanceof Error) ?
|
||||||
@ -264,18 +277,10 @@ function configureFromXml( tileSource, xmlDoc ){
|
|||||||
new Error( $.getString("Errors.IIIF") );
|
new Error( $.getString("Errors.IIIF") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error( $.getString( "Errors.IIIF" ) );
|
throw new Error( $.getString( "Errors.IIIF" ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseXML10( node, configuration, property ) {
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @inner
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
function parseXML( node, configuration, property ){
|
|
||||||
var i,
|
var i,
|
||||||
value;
|
value;
|
||||||
if ( node.nodeType == 3 && property ) {//text node
|
if ( node.nodeType == 3 && property ) {//text node
|
||||||
@ -293,37 +298,10 @@ function parseXML( node, configuration, property ){
|
|||||||
}
|
}
|
||||||
} else if( node.nodeType == 1 ){
|
} else if( node.nodeType == 1 ){
|
||||||
for( i = 0; i < node.childNodes.length; i++ ){
|
for( i = 0; i < node.childNodes.length; i++ ){
|
||||||
parseXML( node.childNodes[ i ], configuration, node.nodeName );
|
parseXML10( node.childNodes[ i ], configuration, node.nodeName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @inner
|
|
||||||
* @function
|
|
||||||
* @example
|
|
||||||
* {
|
|
||||||
* "profile" : "http://library.stanford.edu/iiif/image-api/compliance.html#level1",
|
|
||||||
* "identifier" : "1E34750D-38DB-4825-A38A-B60A345E591C",
|
|
||||||
* "width" : 6000,
|
|
||||||
* "height" : 4000,
|
|
||||||
* "scale_factors" : [ 1, 2, 4 ],
|
|
||||||
* "tile_width" : 1024,
|
|
||||||
* "tile_height" : 1024,
|
|
||||||
* "formats" : [ "jpg", "png" ],
|
|
||||||
* "quality" : [ "native", "grey" ]
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
function configureFromObject( tileSource, configuration ){
|
|
||||||
//the image_host property is not part of the iiif standard but is included here to
|
|
||||||
//allow the info.json and info.xml specify a different server to load the
|
|
||||||
//images from so we can test the implementation.
|
|
||||||
if( configuration.image_host ){
|
|
||||||
configuration.tilesUrl = configuration.image_host;
|
|
||||||
}
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}( OpenSeadragon ));
|
||||||
|
@ -41,13 +41,14 @@
|
|||||||
*
|
*
|
||||||
* @memberof OpenSeadragon
|
* @memberof OpenSeadragon
|
||||||
* @param {String} source - URL of image to download.
|
* @param {String} source - URL of image to download.
|
||||||
|
* @param {String} crossOriginPolicy - CORS policy to use for downloads
|
||||||
* @param {Function} callback - Called once image has finished downloading.
|
* @param {Function} callback - Called once image has finished downloading.
|
||||||
*/
|
*/
|
||||||
function ImageJob ( options ) {
|
function ImageJob ( options ) {
|
||||||
|
|
||||||
$.extend( true, this, {
|
$.extend( true, this, {
|
||||||
timeout: $.DEFAULT_SETTINGS.timeout,
|
timeout: $.DEFAULT_SETTINGS.timeout,
|
||||||
jobId: null,
|
jobId: null
|
||||||
}, options );
|
}, options );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +70,7 @@ ImageJob.prototype = {
|
|||||||
|
|
||||||
this.image = new Image();
|
this.image = new Image();
|
||||||
|
|
||||||
if ( _this.crossOriginPolicy !== false ) {
|
if ( this.crossOriginPolicy !== false ) {
|
||||||
this.image.crossOrigin = this.crossOriginPolicy;
|
this.image.crossOrigin = this.crossOriginPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +123,7 @@ $.ImageLoader.prototype = {
|
|||||||
* Add an unloaded image to the loader queue.
|
* Add an unloaded image to the loader queue.
|
||||||
* @method
|
* @method
|
||||||
* @param {String} src - URL of image to download.
|
* @param {String} src - URL of image to download.
|
||||||
|
* @param {String} crossOriginPolicy - CORS policy to use for downloads
|
||||||
* @param {Function} callback - Called once image has been downloaded.
|
* @param {Function} callback - Called once image has been downloaded.
|
||||||
*/
|
*/
|
||||||
addJob: function( options ) {
|
addJob: function( options ) {
|
||||||
@ -131,6 +133,7 @@ $.ImageLoader.prototype = {
|
|||||||
},
|
},
|
||||||
jobOptions = {
|
jobOptions = {
|
||||||
src: options.src,
|
src: options.src,
|
||||||
|
crossOriginPolicy: options.crossOriginPolicy,
|
||||||
callback: complete
|
callback: complete
|
||||||
},
|
},
|
||||||
newJob = new ImageJob( jobOptions );
|
newJob = new ImageJob( jobOptions );
|
||||||
|
@ -258,6 +258,9 @@
|
|||||||
destroy: function () {
|
destroy: function () {
|
||||||
stopTracking( this );
|
stopTracking( this );
|
||||||
this.element = null;
|
this.element = null;
|
||||||
|
|
||||||
|
THIS[ this.hash ] = null;
|
||||||
|
delete THIS[ this.hash ];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1788,7 +1791,7 @@
|
|||||||
for ( i = 0; i < touchCount; i++ ) {
|
for ( i = 0; i < touchCount; i++ ) {
|
||||||
gPoints.push( {
|
gPoints.push( {
|
||||||
id: event.changedTouches[ i ].identifier,
|
id: event.changedTouches[ i ].identifier,
|
||||||
type: 'touch',
|
type: 'touch'
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2099,7 +2102,7 @@
|
|||||||
|
|
||||||
gPoint = {
|
gPoint = {
|
||||||
id: event.pointerId,
|
id: event.pointerId,
|
||||||
type: getPointerType( event ),
|
type: getPointerType( event )
|
||||||
};
|
};
|
||||||
|
|
||||||
updatePointersCancel( tracker, event, [ gPoint ] );
|
updatePointersCancel( tracker, event, [ gPoint ] );
|
||||||
|
@ -304,12 +304,9 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
|
|||||||
open: function( source ) {
|
open: function( source ) {
|
||||||
this.updateSize();
|
this.updateSize();
|
||||||
var containerSize = this.viewer.viewport.containerSize.times( this.sizeRatio );
|
var containerSize = this.viewer.viewport.containerSize.times( this.sizeRatio );
|
||||||
if( source.tileSize > containerSize.x ||
|
var ts = source.getTileSize(source.maxLevel);
|
||||||
source.tileSize > containerSize.y ){
|
if ( ts > containerSize.x || ts > containerSize.y ) {
|
||||||
this.minPixelRatio = Math.min(
|
this.minPixelRatio = Math.min( containerSize.x, containerSize.y ) / ts;
|
||||||
containerSize.x,
|
|
||||||
containerSize.y
|
|
||||||
) / source.tileSize;
|
|
||||||
} else {
|
} else {
|
||||||
this.minPixelRatio = this.viewer.minPixelRatio;
|
this.minPixelRatio = this.viewer.minPixelRatio;
|
||||||
}
|
}
|
||||||
|
@ -656,14 +656,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
* @property {Number} revision - The revision number.
|
* @property {Number} revision - The revision number.
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
/* jshint ignore:start */
|
|
||||||
$.version = {
|
$.version = {
|
||||||
versionStr: '<%= osdVersion.versionStr %>',
|
versionStr: '<%= osdVersion.versionStr %>',
|
||||||
major: <%= osdVersion.major %>,
|
major: parseInt('<%= osdVersion.major %>', 10),
|
||||||
minor: <%= osdVersion.minor %>,
|
minor: parseInt('<%= osdVersion.minor %>', 10),
|
||||||
revision: <%= osdVersion.revision %>
|
revision: parseInt('<%= osdVersion.revision %>', 10)
|
||||||
};
|
};
|
||||||
/* jshint ignore:end */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,6 +127,8 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* The size of the image tiles used to compose the image.
|
* The size of the image tiles used to compose the image.
|
||||||
|
* Please note that tileSize may be deprecated in a future release.
|
||||||
|
* Instead the getTileSize(level) function should be used.
|
||||||
* @member {Number} tileSize
|
* @member {Number} tileSize
|
||||||
* @memberof OpenSeadragon.TileSource#
|
* @memberof OpenSeadragon.TileSource#
|
||||||
*/
|
*/
|
||||||
@ -194,6 +196,18 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
|||||||
|
|
||||||
$.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
$.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the tileSize for a given level.
|
||||||
|
* Subclasses should override this if tileSizes can be different at different levels
|
||||||
|
* such as in IIIFTileSource. Code should use this function rather than reading
|
||||||
|
* from .tileSize directly. tileSize may be deprecated in a future release.
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
*/
|
||||||
|
getTileSize: function( level ) {
|
||||||
|
return this.tileSize;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
* @param {Number} level
|
* @param {Number} level
|
||||||
@ -220,8 +234,8 @@ $.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
|||||||
*/
|
*/
|
||||||
getNumTiles: function( level ) {
|
getNumTiles: function( level ) {
|
||||||
var scale = this.getLevelScale( level ),
|
var scale = this.getLevelScale( level ),
|
||||||
x = Math.ceil( scale * this.dimensions.x / this.tileSize ),
|
x = Math.ceil( scale * this.dimensions.x / this.getTileSize(level) ),
|
||||||
y = Math.ceil( scale * this.dimensions.y / this.tileSize );
|
y = Math.ceil( scale * this.dimensions.y / this.getTileSize(level) );
|
||||||
|
|
||||||
return new $.Point( x, y );
|
return new $.Point( x, y );
|
||||||
},
|
},
|
||||||
@ -245,10 +259,11 @@ $.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
|||||||
*/
|
*/
|
||||||
getClosestLevel: function( rect ) {
|
getClosestLevel: function( rect ) {
|
||||||
var i,
|
var i,
|
||||||
tilesPerSide = Math.floor( Math.max( rect.x, rect.y ) / this.tileSize ),
|
tilesPerSide,
|
||||||
tiles;
|
tiles;
|
||||||
for( i = this.minLevel; i < this.maxLevel; i++ ){
|
for( i = this.minLevel; i < this.maxLevel; i++ ){
|
||||||
tiles = this.getNumTiles( i );
|
tiles = this.getNumTiles( i );
|
||||||
|
tilesPerSide = Math.floor( Math.max( rect.x, rect.y ) / this.getTileSize(i) );
|
||||||
if( Math.max( tiles.x, tiles.y ) + 1 >= tilesPerSide ){
|
if( Math.max( tiles.x, tiles.y ) + 1 >= tilesPerSide ){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -263,8 +278,8 @@ $.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
|||||||
*/
|
*/
|
||||||
getTileAtPoint: function( level, point ) {
|
getTileAtPoint: function( level, point ) {
|
||||||
var pixel = point.times( this.dimensions.x ).times( this.getLevelScale(level ) ),
|
var pixel = point.times( this.dimensions.x ).times( this.getLevelScale(level ) ),
|
||||||
tx = Math.floor( pixel.x / this.tileSize ),
|
tx = Math.floor( pixel.x / this.getTileSize(level) ),
|
||||||
ty = Math.floor( pixel.y / this.tileSize );
|
ty = Math.floor( pixel.y / this.getTileSize(level) );
|
||||||
|
|
||||||
return new $.Point( tx, ty );
|
return new $.Point( tx, ty );
|
||||||
},
|
},
|
||||||
@ -277,10 +292,11 @@ $.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
|||||||
*/
|
*/
|
||||||
getTileBounds: function( level, x, y ) {
|
getTileBounds: function( level, x, y ) {
|
||||||
var dimensionsScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
var dimensionsScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
||||||
px = ( x === 0 ) ? 0 : this.tileSize * x - this.tileOverlap,
|
tileSize = this.getTileSize(level),
|
||||||
py = ( y === 0 ) ? 0 : this.tileSize * y - this.tileOverlap,
|
px = ( x === 0 ) ? 0 : tileSize * x - this.tileOverlap,
|
||||||
sx = this.tileSize + ( x === 0 ? 1 : 2 ) * this.tileOverlap,
|
py = ( y === 0 ) ? 0 : tileSize * y - this.tileOverlap,
|
||||||
sy = this.tileSize + ( y === 0 ? 1 : 2 ) * this.tileOverlap,
|
sx = tileSize + ( x === 0 ? 1 : 2 ) * this.tileOverlap,
|
||||||
|
sy = tileSize + ( y === 0 ? 1 : 2 ) * this.tileOverlap,
|
||||||
scale = 1.0 / dimensionsScaled.x;
|
scale = 1.0 / dimensionsScaled.x;
|
||||||
|
|
||||||
sx = Math.min( sx, dimensionsScaled.x - px );
|
sx = Math.min( sx, dimensionsScaled.x - px );
|
||||||
|
@ -529,6 +529,12 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
* @fires OpenSeadragon.Viewer.event:close
|
* @fires OpenSeadragon.Viewer.event:close
|
||||||
*/
|
*/
|
||||||
close: function ( ) {
|
close: function ( ) {
|
||||||
|
|
||||||
|
if ( !THIS[ this.hash ] ) {
|
||||||
|
//this viewer has already been destroyed: returning immediately
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
if ( this._updateRequestId !== null ) {
|
if ( this._updateRequestId !== null ) {
|
||||||
$.cancelAnimationFrame( this._updateRequestId );
|
$.cancelAnimationFrame( this._updateRequestId );
|
||||||
this._updateRequestId = null;
|
this._updateRequestId = null;
|
||||||
@ -542,6 +548,10 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
this.drawersContainer.innerHTML = "";
|
this.drawersContainer.innerHTML = "";
|
||||||
this.overlaysContainer.innerHTML = "";
|
this.overlaysContainer.innerHTML = "";
|
||||||
|
|
||||||
|
if ( this.drawer ) {
|
||||||
|
this.drawer.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
this.source = null;
|
this.source = null;
|
||||||
this.drawer = null;
|
this.drawer = null;
|
||||||
this.drawers = [];
|
this.drawers = [];
|
||||||
@ -568,13 +578,26 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to destroy the viewer and clean up everything created by
|
* Function to destroy the viewer and clean up everything created by OpenSeadragon.
|
||||||
* OpenSeadragon.
|
*
|
||||||
|
* Example:
|
||||||
|
* var viewer = OpenSeadragon({
|
||||||
|
* [...]
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* //when you are done with the viewer:
|
||||||
|
* viewer.destroy();
|
||||||
|
* viewer = null; //important
|
||||||
|
*
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
destroy: function( ) {
|
destroy: function( ) {
|
||||||
this.close();
|
this.close();
|
||||||
|
|
||||||
|
//TODO: implement this...
|
||||||
|
//this.unbindSequenceControls()
|
||||||
|
//this.unbindStandardControls()
|
||||||
|
|
||||||
this.removeAllHandlers();
|
this.removeAllHandlers();
|
||||||
|
|
||||||
// Go through top element (passed to us) and remove all children
|
// Go through top element (passed to us) and remove all children
|
||||||
@ -597,6 +620,9 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
this.outerTracker.destroy();
|
this.outerTracker.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
THIS[ this.hash ] = null;
|
||||||
|
delete THIS[ this.hash ];
|
||||||
|
|
||||||
// clear all our references to dom objects
|
// clear all our references to dom objects
|
||||||
this.canvas = null;
|
this.canvas = null;
|
||||||
this.keyboardCommandArea = null;
|
this.keyboardCommandArea = null;
|
||||||
|
146
src/viewport.js
@ -322,38 +322,34 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
* @return {OpenSeadragon.Viewport} Chainable.
|
* @private
|
||||||
* @fires OpenSeadragon.Viewer.event:constrain
|
* @param {OpenSeadragon.Rect} bounds
|
||||||
|
* @param {Boolean} immediately
|
||||||
|
* @return {OpenSeadragon.Rect} constrained bounds.
|
||||||
*/
|
*/
|
||||||
applyConstraints: function( immediately ) {
|
_applyBoundaryConstraints: function( bounds, immediately ) {
|
||||||
var actualZoom = this.getZoom(),
|
var horizontalThreshold,
|
||||||
constrainedZoom = Math.max(
|
|
||||||
Math.min( actualZoom, this.getMaxZoom() ),
|
|
||||||
this.getMinZoom()
|
|
||||||
),
|
|
||||||
bounds,
|
|
||||||
horizontalThreshold,
|
|
||||||
verticalThreshold,
|
verticalThreshold,
|
||||||
left,
|
left,
|
||||||
right,
|
right,
|
||||||
top,
|
top,
|
||||||
bottom,
|
bottom,
|
||||||
dx = 0,
|
dx = 0,
|
||||||
dy = 0;
|
dy = 0,
|
||||||
|
newBounds = new $.Rect(
|
||||||
|
bounds.x,
|
||||||
|
bounds.y,
|
||||||
|
bounds.width,
|
||||||
|
bounds.height
|
||||||
|
);
|
||||||
|
|
||||||
if ( actualZoom != constrainedZoom ) {
|
horizontalThreshold = this.visibilityRatio * newBounds.width;
|
||||||
this.zoomTo( constrainedZoom, this.zoomPoint, immediately );
|
verticalThreshold = this.visibilityRatio * newBounds.height;
|
||||||
}
|
|
||||||
|
|
||||||
bounds = this.getBounds();
|
left = newBounds.x + newBounds.width;
|
||||||
|
right = 1 - newBounds.x;
|
||||||
horizontalThreshold = this.visibilityRatio * bounds.width;
|
top = newBounds.y + newBounds.height;
|
||||||
verticalThreshold = this.visibilityRatio * bounds.height;
|
bottom = this.contentAspectY - newBounds.y;
|
||||||
|
|
||||||
left = bounds.x + bounds.width;
|
|
||||||
right = 1 - bounds.x;
|
|
||||||
top = bounds.y + bounds.height;
|
|
||||||
bottom = this.contentAspectY - bounds.y;
|
|
||||||
|
|
||||||
if ( this.wrapHorizontal ) {
|
if ( this.wrapHorizontal ) {
|
||||||
//do nothing
|
//do nothing
|
||||||
@ -382,15 +378,14 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( dx || dy || immediately ) {
|
if ( dx || dy || immediately ) {
|
||||||
bounds.x += dx;
|
newBounds.x += dx;
|
||||||
bounds.y += dy;
|
newBounds.y += dy;
|
||||||
if( bounds.width > 1 ){
|
if( newBounds.width > 1 ){
|
||||||
bounds.x = 0.5 - bounds.width/2;
|
newBounds.x = 0.5 - newBounds.width/2;
|
||||||
}
|
}
|
||||||
if( bounds.height > this.contentAspectY ){
|
if( newBounds.height > this.contentAspectY ){
|
||||||
bounds.y = this.contentAspectY/2 - bounds.height/2;
|
newBounds.y = this.contentAspectY/2 - newBounds.height/2;
|
||||||
}
|
}
|
||||||
this.fitBounds( bounds, immediately );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
@ -409,6 +404,35 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return newBounds;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
|
* @fires OpenSeadragon.Viewer.event:constrain
|
||||||
|
*/
|
||||||
|
applyConstraints: function( immediately ) {
|
||||||
|
var actualZoom = this.getZoom(),
|
||||||
|
constrainedZoom = Math.max(
|
||||||
|
Math.min( actualZoom, this.getMaxZoom() ),
|
||||||
|
this.getMinZoom()
|
||||||
|
),
|
||||||
|
bounds,
|
||||||
|
constrainedBounds;
|
||||||
|
|
||||||
|
if ( actualZoom != constrainedZoom ) {
|
||||||
|
this.zoomTo( constrainedZoom, this.zoomPoint, immediately );
|
||||||
|
}
|
||||||
|
|
||||||
|
bounds = this.getBounds();
|
||||||
|
|
||||||
|
constrainedBounds = this._applyBoundaryConstraints( bounds, immediately );
|
||||||
|
|
||||||
|
if ( bounds.x !== constrainedBounds.x || bounds.y !== constrainedBounds.y || immediately ){
|
||||||
|
this.fitBounds( constrainedBounds, immediately );
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -422,11 +446,16 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
* @private
|
||||||
* @param {OpenSeadragon.Rect} bounds
|
* @param {OpenSeadragon.Rect} bounds
|
||||||
* @param {Boolean} immediately
|
* @param {Object} options (immediately=false, constraints=false)
|
||||||
* @return {OpenSeadragon.Viewport} Chainable.
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
*/
|
*/
|
||||||
fitBounds: function( bounds, immediately ) {
|
_fitBounds: function( bounds, options ) {
|
||||||
|
options = options || {};
|
||||||
|
var immediately = options.immediately || false;
|
||||||
|
var constraints = options.constraints || false;
|
||||||
|
|
||||||
var aspect = this.getAspectRatio(),
|
var aspect = this.getAspectRatio(),
|
||||||
center = bounds.getCenter(),
|
center = bounds.getCenter(),
|
||||||
newBounds = new $.Rect(
|
newBounds = new $.Rect(
|
||||||
@ -438,7 +467,9 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
oldBounds,
|
oldBounds,
|
||||||
oldZoom,
|
oldZoom,
|
||||||
newZoom,
|
newZoom,
|
||||||
referencePoint;
|
referencePoint,
|
||||||
|
newBoundsAspectRatio,
|
||||||
|
newConstrainedZoom;
|
||||||
|
|
||||||
if ( newBounds.getAspectRatio() >= aspect ) {
|
if ( newBounds.getAspectRatio() >= aspect ) {
|
||||||
newBounds.height = bounds.width / aspect;
|
newBounds.height = bounds.width / aspect;
|
||||||
@ -448,14 +479,36 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
newBounds.x = center.x - newBounds.width / 2;
|
newBounds.x = center.x - newBounds.width / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( constraints ) {
|
||||||
|
newBoundsAspectRatio = newBounds.getAspectRatio();
|
||||||
|
}
|
||||||
|
|
||||||
this.panTo( this.getCenter( true ), true );
|
this.panTo( this.getCenter( true ), true );
|
||||||
this.zoomTo( this.getZoom( true ), null, true );
|
this.zoomTo( this.getZoom( true ), null, true );
|
||||||
|
|
||||||
oldBounds = this.getBounds();
|
oldBounds = this.getBounds();
|
||||||
oldZoom = this.getZoom();
|
oldZoom = this.getZoom();
|
||||||
newZoom = 1.0 / newBounds.width;
|
newZoom = 1.0 / newBounds.width;
|
||||||
|
|
||||||
|
if ( constraints ) {
|
||||||
|
newConstrainedZoom = Math.max(
|
||||||
|
Math.min(newZoom, this.getMaxZoom() ),
|
||||||
|
this.getMinZoom()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (newZoom !== newConstrainedZoom) {
|
||||||
|
newZoom = newConstrainedZoom;
|
||||||
|
newBounds.width = 1.0 / newZoom;
|
||||||
|
newBounds.x = center.x - newBounds.width / 2;
|
||||||
|
newBounds.height = newBounds.width / newBoundsAspectRatio;
|
||||||
|
newBounds.y = center.y - newBounds.height / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
newBounds = this._applyBoundaryConstraints( newBounds, immediately );
|
||||||
|
}
|
||||||
|
|
||||||
if ( newZoom == oldZoom || newBounds.width == oldBounds.width ) {
|
if ( newZoom == oldZoom || newBounds.width == oldBounds.width ) {
|
||||||
return this.panTo( center, immediately );
|
return this.panTo( constraints ? newBounds.getCenter() : center, immediately );
|
||||||
}
|
}
|
||||||
|
|
||||||
referencePoint = oldBounds.getTopLeft().times(
|
referencePoint = oldBounds.getTopLeft().times(
|
||||||
@ -472,6 +525,31 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
return this.zoomTo( newZoom, referencePoint, immediately );
|
return this.zoomTo( newZoom, referencePoint, immediately );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Rect} bounds
|
||||||
|
* @param {Boolean} immediately
|
||||||
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
|
*/
|
||||||
|
fitBounds: function( bounds, immediately ) {
|
||||||
|
return this._fitBounds( bounds, {
|
||||||
|
immediately: immediately,
|
||||||
|
constraints: false
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Rect} bounds
|
||||||
|
* @param {Boolean} immediately
|
||||||
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
|
*/
|
||||||
|
fitBoundsWithConstraints: function( bounds, immediately ) {
|
||||||
|
return this._fitBounds( bounds, {
|
||||||
|
immediately: immediately,
|
||||||
|
constraints: true
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
|
@ -295,6 +295,7 @@
|
|||||||
equal(null, viewer.container);
|
equal(null, viewer.container);
|
||||||
equal(null, viewer.element);
|
equal(null, viewer.element);
|
||||||
equal(true, closeCalled);
|
equal(true, closeCalled);
|
||||||
|
viewer = null;
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
|
BIN
test/data/iiif_2_0_tiled/0,0,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
test/data/iiif_2_0_tiled/0,0,512,512/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
test/data/iiif_2_0_tiled/0,0,775,1024/194,/0/default.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/data/iiif_2_0_tiled/0,256,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
test/data/iiif_2_0_tiled/0,512,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
test/data/iiif_2_0_tiled/0,512,512,512/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
test/data/iiif_2_0_tiled/0,768,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/data/iiif_2_0_tiled/256,0,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
test/data/iiif_2_0_tiled/256,256,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
test/data/iiif_2_0_tiled/256,512,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
test/data/iiif_2_0_tiled/256,768,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
test/data/iiif_2_0_tiled/512,0,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
test/data/iiif_2_0_tiled/512,0,263,512/132,/0/default.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/data/iiif_2_0_tiled/512,256,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
test/data/iiif_2_0_tiled/512,512,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
test/data/iiif_2_0_tiled/512,512,263,512/132,/0/default.jpg
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
test/data/iiif_2_0_tiled/512,768,256,256/256,/0/default.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/data/iiif_2_0_tiled/768,0,7,256/7,/0/default.jpg
Normal file
After Width: | Height: | Size: 717 B |
BIN
test/data/iiif_2_0_tiled/768,256,7,256/7,/0/default.jpg
Normal file
After Width: | Height: | Size: 716 B |
BIN
test/data/iiif_2_0_tiled/768,512,7,256/7,/0/default.jpg
Normal file
After Width: | Height: | Size: 717 B |
BIN
test/data/iiif_2_0_tiled/768,768,7,256/7,/0/default.jpg
Normal file
After Width: | Height: | Size: 712 B |
BIN
test/data/iiif_2_0_tiled/full/1,/0/default.jpg
Normal file
After Width: | Height: | Size: 633 B |
BIN
test/data/iiif_2_0_tiled/full/13,/0/default.jpg
Normal file
After Width: | Height: | Size: 810 B |
BIN
test/data/iiif_2_0_tiled/full/2,/0/default.jpg
Normal file
After Width: | Height: | Size: 663 B |
BIN
test/data/iiif_2_0_tiled/full/25,/0/default.jpg
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
test/data/iiif_2_0_tiled/full/4,/0/default.jpg
Normal file
After Width: | Height: | Size: 675 B |
BIN
test/data/iiif_2_0_tiled/full/49,/0/default.jpg
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
test/data/iiif_2_0_tiled/full/7,/0/default.jpg
Normal file
After Width: | Height: | Size: 683 B |
BIN
test/data/iiif_2_0_tiled/full/97,/0/default.jpg
Normal file
After Width: | Height: | Size: 7.1 KiB |
24
test/data/iiif_2_0_tiled/info.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"@context": "http://iiif.io/api/image/2/context.json",
|
||||||
|
"@id": "http://localhost:8000/test/data/iiif_2_0_tiled",
|
||||||
|
"protocol": "http://iiif.io/api/image",
|
||||||
|
"height": 1024,
|
||||||
|
"width": 775,
|
||||||
|
"tiles" : [{"width":256, "scale_factors":[1,2,4,8]}],
|
||||||
|
|
||||||
|
"profile": ["http://iiif.io/api/image/2/level1.json",
|
||||||
|
{
|
||||||
|
"qualities": [
|
||||||
|
"native",
|
||||||
|
"bitonal",
|
||||||
|
"grey",
|
||||||
|
"color"
|
||||||
|
],
|
||||||
|
"formats": [
|
||||||
|
"jpg",
|
||||||
|
"png",
|
||||||
|
"gif"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
113
test/demo/fitboundswithconstraints.html
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OpenSeadragon fitBoundsWithConstraints() Demo</title>
|
||||||
|
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
.openseadragon1 {
|
||||||
|
width: 800px;
|
||||||
|
height: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#highlights li {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
Simple demo page to show 'viewport.fitBounds().applyConstraints()' issue.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="contentDiv" class="openseadragon1"></div>
|
||||||
|
<div id="highlights"></div>
|
||||||
|
|
||||||
|
<select onchange="changeMethod(this.value);">
|
||||||
|
<option value=0>viewport.fitBoundsWithConstraints(bounds);</option>
|
||||||
|
<option value=1>viewport.fitBounds(bounds);</option>
|
||||||
|
<option value=2>viewport.fitBounds(bounds).applyConstraints();</option>
|
||||||
|
</select>
|
||||||
|
<input type="button" value="Go home" onclick="goHome()"/>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var _viewer;
|
||||||
|
var _fittingMethod = 0;
|
||||||
|
|
||||||
|
var _highlights = [
|
||||||
|
{"queryPoint":[0.13789887359998443,0.43710575899579285], "radius":0.004479581945070337,"text":"Pipe"},
|
||||||
|
{"queryPoint":[0.5923298766583593,0.6461653354541856], "radius":0.013175241014912752,"text":"Fuel here"},
|
||||||
|
{"queryPoint":[0.43920338711232304,0.7483181389302148], "radius":0.09222668710438928, "text":"Wheel"},
|
||||||
|
{"queryPoint":[0.07341677959486298,0.9028719921872319], "radius":0.08996845561083797, "text":"Nothing special"}
|
||||||
|
];
|
||||||
|
|
||||||
|
var generateUniqueHash = (function() {
|
||||||
|
var counter = 0;
|
||||||
|
return function() {
|
||||||
|
return "openseadragon_" + (counter++);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
var _viewer = OpenSeadragon({
|
||||||
|
element: document.getElementById("contentDiv"),
|
||||||
|
showNavigationControl: false,
|
||||||
|
prefixUrl: "../../build/openseadragon/images/",
|
||||||
|
hash: generateUniqueHash(), //this is only needed if you want to instantiate more than one viewer at a time.
|
||||||
|
tileSources: {
|
||||||
|
Image: {
|
||||||
|
xmlns: "http://schemas.microsoft.com/deepzoom/2008",
|
||||||
|
Url: 'http://cdn.photosynth.net/ps2/19d5cf2b-77ed-439f-ac21-d3046320384c/packet/undistorted/img0043/',
|
||||||
|
Format: "jpg",
|
||||||
|
Overlap: 1,
|
||||||
|
TileSize: 510,
|
||||||
|
Size: {
|
||||||
|
Width: 4592,
|
||||||
|
Height: 3448
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_viewer.addHandler("open", function() {
|
||||||
|
var str = "<ul>";
|
||||||
|
for (var i=0; i<_highlights.length; ++i) {
|
||||||
|
var highlight = _highlights[i];
|
||||||
|
str += "<li onclick='gotoHighlight("+i+")'>"+highlight.text+"</li>";
|
||||||
|
}
|
||||||
|
str += "</ul>";
|
||||||
|
document.getElementById("highlights").innerHTML = str;
|
||||||
|
});
|
||||||
|
|
||||||
|
function gotoHighlight(index) {
|
||||||
|
var highlight = _highlights[index];
|
||||||
|
|
||||||
|
var viewport = _viewer.viewport;
|
||||||
|
var contentSize = viewport.contentSize;
|
||||||
|
var scaling = 1.0 / viewport.viewportToImageZoom(viewport.getZoom());
|
||||||
|
var radius = highlight.radius*Math.min(contentSize.x, contentSize.y);/*annotation.accurateRadius*scaling;*/
|
||||||
|
var center = new OpenSeadragon.Point(contentSize.x*highlight.queryPoint[0], contentSize.y*highlight.queryPoint[1]);
|
||||||
|
var bounds = viewport.imageToViewportRectangle(new OpenSeadragon.Rect(center.x-radius, center.y-radius, radius*2, radius*2));
|
||||||
|
|
||||||
|
if (_fittingMethod === 0) {
|
||||||
|
viewport.fitBoundsWithConstraints(bounds, false);
|
||||||
|
}
|
||||||
|
else if (_fittingMethod === 1) {
|
||||||
|
viewport.fitBounds(bounds, false);
|
||||||
|
}
|
||||||
|
else if (_fittingMethod === 2) {
|
||||||
|
viewport.fitBounds(bounds, false).applyConstraints();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeMethod(value) {
|
||||||
|
_fittingMethod = parseInt(value, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
function goHome() {
|
||||||
|
_viewer.viewport.goHome();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
57
test/demo/memorycheck.html
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OpenSeadragon Memory Check Demo</title>
|
||||||
|
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
.openseadragon1 {
|
||||||
|
width: 800px;
|
||||||
|
height: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
Simple demo page to monitor OpenSeadragon Memory Usage.
|
||||||
|
</div>
|
||||||
|
<button onclick="createViewer()">Create</button>
|
||||||
|
<button onclick="destroyViewer()">Destroy</button>
|
||||||
|
|
||||||
|
<div id="contentDiv" class="openseadragon1"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var _viewer;
|
||||||
|
|
||||||
|
var generateUniqueHash = (function() {
|
||||||
|
var counter = 0;
|
||||||
|
return function() {
|
||||||
|
return "openseadragon_" + (counter++);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
function createViewer() {
|
||||||
|
if ( _viewer ) {
|
||||||
|
destroyViewer();
|
||||||
|
}
|
||||||
|
|
||||||
|
_viewer = OpenSeadragon({
|
||||||
|
element: document.getElementById("contentDiv"),
|
||||||
|
showNavigationControl: false,
|
||||||
|
prefixUrl: "../../build/openseadragon/images/",
|
||||||
|
hash: generateUniqueHash(), //this is only needed if you want to instantiate more than one viewer at a time.
|
||||||
|
tileSources: "../data/testpattern.dzi"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroyViewer() {
|
||||||
|
if ( _viewer ) {
|
||||||
|
_viewer.destroy();
|
||||||
|
}
|
||||||
|
_viewer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -72,37 +72,42 @@
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.0 JSON', function() {
|
asyncTest('IIIF 1.0 JSON', function() {
|
||||||
testOpen('iiif1_0.json');
|
testOpen('iiif_1_0_files/info.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.0 XML', function() {
|
asyncTest('IIIF 1.0 XML', function() {
|
||||||
testOpen('iiif1_0.xml');
|
testOpen('iiif_1_0_files/info.xml');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.1 JSON', function() {
|
asyncTest('IIIF 1.1 JSON', function() {
|
||||||
testOpen('iiif_1_1_tiled.json');
|
testOpen('iiif_1_1_tiled/info.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Less than 256', function() {
|
asyncTest('IIIF No Tiles, Less than 256', function() {
|
||||||
testOpen('iiif_1_1_no_tiles_255.json');
|
testOpen('iiif_1_1_no_tiles_255/info.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Bet. 256 and 512', function() {
|
asyncTest('IIIF No Tiles, Bet. 256 and 512', function() {
|
||||||
testOpen('iiif_1_1_no_tiles_384.json');
|
testOpen('iiif_1_1_no_tiles_384/info.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Bet. 512 and 1024', function() {
|
asyncTest('IIIF No Tiles, Bet. 512 and 1024', function() {
|
||||||
testOpen('iiif_1_1_no_tiles_768.json');
|
testOpen('iiif_1_1_no_tiles_768/info.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Larger than 1024', function() {
|
asyncTest('IIIF No Tiles, Larger than 1024', function() {
|
||||||
testOpen('iiif_1_1_no_tiles_1048.json');
|
testOpen('iiif_1_1_no_tiles_1048/info.json');
|
||||||
|
});
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
asyncTest('IIIF 2.0 JSON', function() {
|
||||||
|
testOpen('iiif_2_0_tiled/info.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>OpenSeadragon QUnit</title>
|
<title>OpenSeadragon QUnit</title>
|
||||||
<link rel="stylesheet" href="/node_modules/grunt-contrib-qunit/test/libs/qunit.css">
|
<link rel="stylesheet" href="/node_modules/qunitjs/qunit/qunit.css">
|
||||||
<link rel="stylesheet" href="/test/lib/jquery-ui-1.10.2/css/smoothness/jquery-ui-1.10.2.min.css">
|
<link rel="stylesheet" href="/test/lib/jquery-ui-1.10.2/css/smoothness/jquery-ui-1.10.2.min.css">
|
||||||
<link rel="stylesheet" href="/test/test.css">
|
<link rel="stylesheet" href="/test/test.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="qunit"></div>
|
<div id="qunit"></div>
|
||||||
<div id="qunit-fixture"></div>
|
<div id="qunit-fixture"></div>
|
||||||
<script src="/node_modules/grunt-contrib-qunit/test/libs/qunit.js"></script>
|
<script src="/node_modules/qunitjs/qunit/qunit.js"></script>
|
||||||
<script src="/test/lib/jquery-1.9.1.min.js"></script>
|
<script src="/test/lib/jquery-1.9.1.min.js"></script>
|
||||||
<script src="/test/lib/jquery-ui-1.10.2/js/jquery-ui-1.10.2.min.js"></script>
|
<script src="/test/lib/jquery-ui-1.10.2/js/jquery-ui-1.10.2.min.js"></script>
|
||||||
<script src="/test/lib/jquery.simulate.js"></script>
|
<script src="/test/lib/jquery.simulate.js"></script>
|
||||||
|