mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-20 09:41:45 +03:00
Minor style fixes
This commit is contained in:
parent
48eee7e75c
commit
7d4eff0bb8
@ -1,4 +1,4 @@
|
|||||||
(function( $ ){
|
(function($) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class ZoomifyTileSource
|
* @class ZoomifyTileSource
|
||||||
@ -11,44 +11,58 @@
|
|||||||
* @param {Number} tileSize
|
* @param {Number} tileSize
|
||||||
* @param {String} tilesUrl
|
* @param {String} tilesUrl
|
||||||
*/
|
*/
|
||||||
$.ZoomifyTileSource = function( options ) {
|
$.ZoomifyTileSource = function(options) {
|
||||||
|
|
||||||
options.tileSize = 256;
|
options.tileSize = 256;
|
||||||
|
|
||||||
var currentImageSize = {x:options.width,y:options.height};
|
var currentImageSize = {
|
||||||
options.imageSizes = [{x:options.width,y:options.height}];
|
x: options.width,
|
||||||
options.gridSize = [this._getGridSize(options.width,options.height,options.tileSize)];
|
y: options.height
|
||||||
|
};
|
||||||
|
options.imageSizes = [{
|
||||||
|
x: options.width,
|
||||||
|
y: options.height
|
||||||
|
}];
|
||||||
|
options.gridSize = [this._getGridSize(options.width, options.height, options.tileSize)];
|
||||||
|
|
||||||
while(parseInt(currentImageSize.x) > options.tileSize || parseInt(currentImageSize.y) > options.tileSize) {
|
while (parseInt(currentImageSize.x, 10) > options.tileSize || parseInt(currentImageSize.y, 10) > options.tileSize) {
|
||||||
currentImageSize.x = Math.floor(currentImageSize.x/2);
|
currentImageSize.x = Math.floor(currentImageSize.x / 2);
|
||||||
currentImageSize.y = Math.floor(currentImageSize.y/2);
|
currentImageSize.y = Math.floor(currentImageSize.y / 2);
|
||||||
options.imageSizes.push({x:currentImageSize.x,y:currentImageSize.y});
|
options.imageSizes.push({
|
||||||
options.gridSize.push(this._getGridSize(currentImageSize.x,currentImageSize.y,options.tileSize));
|
x: currentImageSize.x,
|
||||||
|
y: currentImageSize.y
|
||||||
|
});
|
||||||
|
options.gridSize.push(this._getGridSize(currentImageSize.x, currentImageSize.y, options.tileSize));
|
||||||
}
|
}
|
||||||
options.imageSizes.reverse();
|
options.imageSizes.reverse();
|
||||||
options.gridSize.reverse();
|
options.gridSize.reverse();
|
||||||
options.minLevel = 0;
|
options.minLevel = 0;
|
||||||
options.maxLevel = options.gridSize.length-1;
|
options.maxLevel = options.gridSize.length - 1;
|
||||||
|
|
||||||
|
|
||||||
OpenSeadragon.TileSource.apply( this, [ options ] );
|
OpenSeadragon.TileSource.apply(this, [options]);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$.extend( $.ZoomifyTileSource.prototype, $.TileSource.prototype, /** @lends OpenSeadragon.ZoomifyTileSource.prototype */{
|
$.extend($.ZoomifyTileSource.prototype, $.TileSource.prototype, /** @lends OpenSeadragon.ZoomifyTileSource.prototype */ {
|
||||||
|
|
||||||
_getGridSize: function(width,height,tileSize) {
|
//private
|
||||||
return {x: Math.ceil(width/tileSize),y:Math.ceil(height/tileSize)};
|
_getGridSize: function(width, height, tileSize) {
|
||||||
|
return {
|
||||||
|
x: Math.ceil(width / tileSize),
|
||||||
|
y: Math.ceil(height / tileSize)
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
_calculateAbsoluteTileNumber: function (level, x, y) {
|
//private
|
||||||
|
_calculateAbsoluteTileNumber: function(level, x, y) {
|
||||||
var num = 0;
|
var num = 0;
|
||||||
for (var z = 0; z < level; z++) {
|
for (var z = 0; z < level; z++) {
|
||||||
var size = this.gridSize[z];
|
var size = this.gridSize[z];
|
||||||
num += size.x * size.y;
|
num += size.x * size.y;
|
||||||
}
|
}
|
||||||
var size = this.gridSize[level];
|
var size = this.gridSize[level];
|
||||||
num += size.x*y+ x
|
num += size.x * y + x
|
||||||
return num;
|
return num;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -59,9 +73,8 @@
|
|||||||
* @param {Object|Array} data
|
* @param {Object|Array} data
|
||||||
* @param {String} optional - url
|
* @param {String} optional - url
|
||||||
*/
|
*/
|
||||||
supports: function( data, url ){
|
supports: function(data, url) {
|
||||||
//console.log('ZoomifyTileSource supports ' + data.type);
|
return (data.type && "zoomifytileservice" == data.type);
|
||||||
return ( data.type && "zoomifytileservice" == data.type );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,8 +85,7 @@
|
|||||||
* @return {Object} options - A dictionary of keyword arguments sufficient
|
* @return {Object} options - A dictionary of keyword arguments sufficient
|
||||||
* to configure this tile sources constructor.
|
* to configure this tile sources constructor.
|
||||||
*/
|
*/
|
||||||
configure: function( data, url ){
|
configure: function(data, url) {
|
||||||
//console.log('ZoomifyTileSource configure ' + data.tilesUrl);
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -84,14 +96,14 @@
|
|||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
getTileUrl: function( level, x, y ){
|
getTileUrl: function(level, x, y) {
|
||||||
//console.log(level);
|
//console.log(level);
|
||||||
var result = 0;
|
var result = 0;
|
||||||
var num = this._calculateAbsoluteTileNumber(level,x,y);
|
var num = this._calculateAbsoluteTileNumber(level, x, y);
|
||||||
result = Math.floor(num/256);
|
result = Math.floor(num / 256);
|
||||||
return this.tilesUrl + 'TileGroup' + result + '/' + level + '-' + x + '-' + y + '.jpg';
|
return this.tilesUrl + 'TileGroup' + result + '/' + level + '-' + x + '-' + y + '.jpg';
|
||||||
|
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}(OpenSeadragon));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user