mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 16:46:08 +03:00
mostly superficial formating. removing $.Strings and putting it directly in $. more clean up of the Drawer update related functions
This commit is contained in:
parent
bc50a7df04
commit
a8730a9f00
@ -6,7 +6,7 @@
|
|||||||
PROJECT: openseadragon
|
PROJECT: openseadragon
|
||||||
BUILD_MAJOR: 0
|
BUILD_MAJOR: 0
|
||||||
BUILD_MINOR: 8
|
BUILD_MINOR: 8
|
||||||
BUILD_ID: 20
|
BUILD_ID: 22
|
||||||
BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
|
BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
|
||||||
VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
|
VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
|
||||||
|
|
||||||
|
681
openseadragon.js
681
openseadragon.js
File diff suppressed because it is too large
Load Diff
@ -22,23 +22,24 @@ $.Button = function( options ) {
|
|||||||
//TODO: make button elements accessible by making them a-tags
|
//TODO: make button elements accessible by making them a-tags
|
||||||
// maybe even consider basing them on the element and adding
|
// maybe even consider basing them on the element and adding
|
||||||
// methods jquery-style.
|
// methods jquery-style.
|
||||||
this.element = options.element || $.makeNeutralElement("span");
|
this.element = options.element || $.makeNeutralElement( "a" );
|
||||||
|
this.element.href = '#';
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
|
|
||||||
if ( options.onPress != undefined ){
|
if ( options.onPress ){
|
||||||
this.addHandler("onPress", options.onPress );
|
this.addHandler( "onPress", options.onPress );
|
||||||
}
|
}
|
||||||
if ( options.onRelease != undefined ){
|
if ( options.onRelease ){
|
||||||
this.addHandler("onRelease", options.onRelease );
|
this.addHandler( "onRelease", options.onRelease );
|
||||||
}
|
}
|
||||||
if ( options.onClick != undefined ){
|
if ( options.onClick ){
|
||||||
this.addHandler("onClick", options.onClick );
|
this.addHandler( "onClick", options.onClick );
|
||||||
}
|
}
|
||||||
if ( options.onEnter != undefined ){
|
if ( options.onEnter ){
|
||||||
this.addHandler("onEnter", options.onEnter );
|
this.addHandler( "onEnter", options.onEnter );
|
||||||
}
|
}
|
||||||
if ( options.onExit != undefined ){
|
if ( options.onExit ){
|
||||||
this.addHandler("onExit", options.onExit );
|
this.addHandler( "onExit", options.onExit );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentState = $.ButtonState.GROUP;
|
this.currentState = $.ButtonState.GROUP;
|
||||||
@ -66,10 +67,10 @@ $.Button = function( options ) {
|
|||||||
this.element.appendChild( this.imgHover );
|
this.element.appendChild( this.imgHover );
|
||||||
this.element.appendChild( this.imgDown );
|
this.element.appendChild( this.imgDown );
|
||||||
|
|
||||||
var styleRest = this.imgRest.style;
|
var styleRest = this.imgRest.style,
|
||||||
var styleGroup = this.imgGroup.style;
|
styleGroup = this.imgGroup.style,
|
||||||
var styleHover = this.imgHover.style;
|
styleHover = this.imgHover.style,
|
||||||
var styleDown = this.imgDown.style;
|
styleDown = this.imgDown.style;
|
||||||
|
|
||||||
styleGroup.position =
|
styleGroup.position =
|
||||||
styleHover.position =
|
styleHover.position =
|
||||||
@ -100,7 +101,7 @@ $.Button = function( options ) {
|
|||||||
|
|
||||||
//TODO - refactor mousetracer next to avoid this extension
|
//TODO - refactor mousetracer next to avoid this extension
|
||||||
$.extend( this.tracker, {
|
$.extend( this.tracker, {
|
||||||
enterHandler: function(tracker, position, buttonDownElmt, buttonDownAny) {
|
enterHandler: function( tracker, position, buttonDownElmt, buttonDownAny ) {
|
||||||
if ( buttonDownElmt ) {
|
if ( buttonDownElmt ) {
|
||||||
inTo( _this, $.ButtonState.DOWN );
|
inTo( _this, $.ButtonState.DOWN );
|
||||||
_this.raiseEvent( "onEnter", _this );
|
_this.raiseEvent( "onEnter", _this );
|
||||||
@ -108,17 +109,17 @@ $.Button = function( options ) {
|
|||||||
inTo( _this, $.ButtonState.HOVER );
|
inTo( _this, $.ButtonState.HOVER );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
exitHandler: function(tracker, position, buttonDownElmt, buttonDownAny) {
|
exitHandler: function( tracker, position, buttonDownElmt, buttonDownAny ) {
|
||||||
outTo( _this, $.ButtonState.GROUP );
|
outTo( _this, $.ButtonState.GROUP );
|
||||||
if ( buttonDownElmt ) {
|
if ( buttonDownElmt ) {
|
||||||
_this.raiseEvent( "onExit", _this );
|
_this.raiseEvent( "onExit", _this );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pressHandler: function(tracker, position) {
|
pressHandler: function( tracker, position ) {
|
||||||
inTo( _this, $.ButtonState.DOWN );
|
inTo( _this, $.ButtonState.DOWN );
|
||||||
_this.raiseEvent( "onPress", _this );
|
_this.raiseEvent( "onPress", _this );
|
||||||
},
|
},
|
||||||
releaseHandler: function(tracker, position, insideElmtPress, insideElmtRelease) {
|
releaseHandler: function( tracker, position, insideElmtPress, insideElmtRelease ) {
|
||||||
if ( insideElmtPress && insideElmtRelease ) {
|
if ( insideElmtPress && insideElmtRelease ) {
|
||||||
outTo( _this, $.ButtonState.HOVER );
|
outTo( _this, $.ButtonState.HOVER );
|
||||||
_this.raiseEvent( "onRelease", _this );
|
_this.raiseEvent( "onRelease", _this );
|
||||||
@ -128,7 +129,7 @@ $.Button = function( options ) {
|
|||||||
inTo( _this, $.ButtonState.HOVER );
|
inTo( _this, $.ButtonState.HOVER );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clickHandler: function(tracker, position, quick, shift) {
|
clickHandler: function( tracker, position, quick, shift ) {
|
||||||
if ( quick ) {
|
if ( quick ) {
|
||||||
_this.raiseEvent("onClick", _this);
|
_this.raiseEvent("onClick", _this);
|
||||||
}
|
}
|
||||||
@ -140,12 +141,15 @@ $.Button = function( options ) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.extend( $.Button.prototype, $.EventHandler.prototype, {
|
$.extend( $.Button.prototype, $.EventHandler.prototype, {
|
||||||
|
|
||||||
notifyGroupEnter: function() {
|
notifyGroupEnter: function() {
|
||||||
inTo( this, $.ButtonState.GROUP );
|
inTo( this, $.ButtonState.GROUP );
|
||||||
},
|
},
|
||||||
|
|
||||||
notifyGroupExit: function() {
|
notifyGroupExit: function() {
|
||||||
outTo( this, $.ButtonState.REST );
|
outTo( this, $.ButtonState.REST );
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -178,7 +182,7 @@ function updateFade( button ) {
|
|||||||
function beginFading( button ) {
|
function beginFading( button ) {
|
||||||
button.shouldFade = true;
|
button.shouldFade = true;
|
||||||
button.fadeBeginTime = new Date().getTime() + button.fadeDelay;
|
button.fadeBeginTime = new Date().getTime() + button.fadeDelay;
|
||||||
window.setTimeout(function(){
|
window.setTimeout( function(){
|
||||||
scheduleFade( button );
|
scheduleFade( button );
|
||||||
}, button.fadeDelay );
|
}, button.fadeDelay );
|
||||||
};
|
};
|
||||||
@ -189,17 +193,20 @@ function stopFading( button ) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function inTo( button, newState ) {
|
function inTo( button, newState ) {
|
||||||
if ( newState >= $.ButtonState.GROUP && button.currentState == $.ButtonState.REST ) {
|
if ( newState >= $.ButtonState.GROUP &&
|
||||||
|
button.currentState == $.ButtonState.REST ) {
|
||||||
stopFading( button );
|
stopFading( button );
|
||||||
button.currentState = $.ButtonState.GROUP;
|
button.currentState = $.ButtonState.GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( newState >= $.ButtonState.HOVER && button.currentState == $.ButtonState.GROUP ) {
|
if ( newState >= $.ButtonState.HOVER &&
|
||||||
|
button.currentState == $.ButtonState.GROUP ) {
|
||||||
button.imgHover.style.visibility = "";
|
button.imgHover.style.visibility = "";
|
||||||
button.currentState = $.ButtonState.HOVER;
|
button.currentState = $.ButtonState.HOVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( newState >= $.ButtonState.DOWN && button.currentState == $.ButtonState.HOVER ) {
|
if ( newState >= $.ButtonState.DOWN &&
|
||||||
|
button.currentState == $.ButtonState.HOVER ) {
|
||||||
button.imgDown.style.visibility = "";
|
button.imgDown.style.visibility = "";
|
||||||
button.currentState = $.ButtonState.DOWN;
|
button.currentState = $.ButtonState.DOWN;
|
||||||
}
|
}
|
||||||
@ -207,17 +214,20 @@ function inTo( button, newState ) {
|
|||||||
|
|
||||||
|
|
||||||
function outTo( button, newState ) {
|
function outTo( button, newState ) {
|
||||||
if ( newState <= $.ButtonState.HOVER && button.currentState == $.ButtonState.DOWN ) {
|
if ( newState <= $.ButtonState.HOVER &&
|
||||||
|
button.currentState == $.ButtonState.DOWN ) {
|
||||||
button.imgDown.style.visibility = "hidden";
|
button.imgDown.style.visibility = "hidden";
|
||||||
button.currentState = $.ButtonState.HOVER;
|
button.currentState = $.ButtonState.HOVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( newState <= $.ButtonState.GROUP && button.currentState == $.ButtonState.HOVER ) {
|
if ( newState <= $.ButtonState.GROUP &&
|
||||||
|
button.currentState == $.ButtonState.HOVER ) {
|
||||||
button.imgHover.style.visibility = "hidden";
|
button.imgHover.style.visibility = "hidden";
|
||||||
button.currentState = $.ButtonState.GROUP;
|
button.currentState = $.ButtonState.GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( button.newState <= $.ButtonState.REST && button.currentState == $.ButtonState.GROUP ) {
|
if ( button.newState <= $.ButtonState.REST &&
|
||||||
|
button.currentState == $.ButtonState.GROUP ) {
|
||||||
button.beginFading();
|
button.beginFading();
|
||||||
button.currentState = $.ButtonState.REST;
|
button.currentState = $.ButtonState.REST;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
$.ButtonGroup = function( options ) {
|
$.ButtonGroup = function( options ) {
|
||||||
|
|
||||||
this.buttons = options.buttons;
|
this.buttons = options.buttons;
|
||||||
this.element = options.group || $.makeNeutralElement("span");
|
this.element = options.group || $.makeNeutralElement( "span" );
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
this.tracker = new $.MouseTracker(
|
this.tracker = new $.MouseTracker(
|
||||||
this.element,
|
this.element,
|
||||||
@ -38,14 +38,14 @@ $.ButtonGroup = function( options ) {
|
|||||||
|
|
||||||
this.tracker.enter = options.enter || function() {
|
this.tracker.enter = options.enter || function() {
|
||||||
var i;
|
var i;
|
||||||
for ( i = 0; i < _this.buttons.length; i++) {
|
for ( i = 0; i < _this.buttons.length; i++ ) {
|
||||||
_this.buttons[ i ].notifyGroupEnter();
|
_this.buttons[ i ].notifyGroupEnter();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.tracker.exit = options.exit || function() {
|
this.tracker.exit = options.exit || function() {
|
||||||
var i,
|
var i,
|
||||||
buttonDownElmt = arguments.length > 2 ? arguments[2] : null;
|
buttonDownElmt = arguments.length > 2 ? arguments[ 2 ] : null;
|
||||||
if ( !buttonDownElmt ) {
|
if ( !buttonDownElmt ) {
|
||||||
for ( i = 0; i < _this.buttons.length; i++ ) {
|
for ( i = 0; i < _this.buttons.length; i++ ) {
|
||||||
_this.buttons[ i ].notifyGroupExit();
|
_this.buttons[ i ].notifyGroupExit();
|
||||||
@ -55,7 +55,7 @@ $.ButtonGroup = function( options ) {
|
|||||||
|
|
||||||
this.tracker.release = options.release || function() {
|
this.tracker.release = options.release || function() {
|
||||||
var i,
|
var i,
|
||||||
insideElmtRelease = arguments.length > 3 ? arguments[3] : null;
|
insideElmtRelease = arguments.length > 3 ? arguments[ 3 ] : null;
|
||||||
if ( !insideElmtRelease ) {
|
if ( !insideElmtRelease ) {
|
||||||
for ( i = 0; i < _this.buttons.length; i++ ) {
|
for ( i = 0; i < _this.buttons.length; i++ ) {
|
||||||
_this.buttons[ i ].notifyGroupExit();
|
_this.buttons[ i ].notifyGroupExit();
|
||||||
|
@ -10,43 +10,52 @@ $.ControlAnchor = {
|
|||||||
BOTTOM_LEFT: 4
|
BOTTOM_LEFT: 4
|
||||||
};
|
};
|
||||||
|
|
||||||
$.Control = function (elmt, anchor, container) {
|
$.Control = function ( elmt, anchor, container ) {
|
||||||
this.elmt = elmt;
|
this.elmt = elmt;
|
||||||
this.anchor = anchor;
|
this.anchor = anchor;
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.wrapper = $.makeNeutralElement("span");
|
this.wrapper = $.makeNeutralElement( "span" );
|
||||||
this.wrapper.style.display = "inline-block";
|
this.wrapper.style.display = "inline-block";
|
||||||
this.wrapper.appendChild(this.elmt);
|
this.wrapper.appendChild( this.elmt );
|
||||||
|
|
||||||
if (this.anchor == $.ControlAnchor.NONE) {
|
if ( this.anchor == $.ControlAnchor.NONE ) {
|
||||||
// IE6 fix
|
// IE6 fix
|
||||||
this.wrapper.style.width = this.wrapper.style.height = "100%";
|
this.wrapper.style.width = this.wrapper.style.height = "100%";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( this.anchor == $.ControlAnchor.TOP_RIGHT ||
|
if ( this.anchor == $.ControlAnchor.TOP_RIGHT ||
|
||||||
this.anchor == $.ControlAnchor.BOTTOM_RIGHT ) {
|
this.anchor == $.ControlAnchor.BOTTOM_RIGHT ) {
|
||||||
this.container.insertBefore(this.wrapper, this.container.firstChild);
|
this.container.insertBefore(
|
||||||
|
this.wrapper,
|
||||||
|
this.container.firstChild
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.container.appendChild(this.wrapper);
|
this.container.appendChild( this.wrapper );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$.Control.prototype = {
|
$.Control.prototype = {
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
this.wrapper.removeChild(this.elmt);
|
this.wrapper.removeChild( this.elmt );
|
||||||
this.container.removeChild(this.wrapper);
|
this.container.removeChild( this.wrapper );
|
||||||
},
|
},
|
||||||
|
|
||||||
isVisible: function() {
|
isVisible: function() {
|
||||||
return this.wrapper.style.display != "none";
|
return this.wrapper.style.display != "none";
|
||||||
},
|
},
|
||||||
setVisible: function(visible) {
|
|
||||||
this.wrapper.style.display = visible ? "inline-block" : "none";
|
setVisible: function( visible ) {
|
||||||
|
this.wrapper.style.display = visible ?
|
||||||
|
"inline-block" :
|
||||||
|
"none";
|
||||||
},
|
},
|
||||||
setOpacity: function(opacity) {
|
|
||||||
if (this.elmt[ $.SIGNAL ] && $.Browser.vendor == $.BROWSERS.IE ) {
|
setOpacity: function( opacity ) {
|
||||||
$.setElementOpacity(this.elmt, opacity, true);
|
if ( this.elmt[ $.SIGNAL ] && $.Browser.vendor == $.BROWSERS.IE ) {
|
||||||
|
$.setElementOpacity( this.elmt, opacity, true );
|
||||||
} else {
|
} else {
|
||||||
$.setElementOpacity(this.wrapper, opacity, true);
|
$.setElementOpacity( this.wrapper, opacity, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ $.DisplayRect = function( x, y, width, height, minLevel, maxLevel ) {
|
|||||||
this.minLevel = minLevel;
|
this.minLevel = minLevel;
|
||||||
this.maxLevel = maxLevel;
|
this.maxLevel = maxLevel;
|
||||||
}
|
}
|
||||||
$.DisplayRect.prototype = new $.Rect();
|
|
||||||
$.DisplayRect.prototype.constructor = $.DisplayRect;
|
$.extend( $.DisplayRect.prototype, $.Rect.prototype );
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}( OpenSeadragon ));
|
||||||
|
@ -26,7 +26,7 @@ $.Drawer = function(source, viewport, elmt) {
|
|||||||
|
|
||||||
this.container = $.getElement( elmt );
|
this.container = $.getElement( elmt );
|
||||||
this.canvas = $.makeNeutralElement( USE_CANVAS ? "canvas" : "div" );
|
this.canvas = $.makeNeutralElement( USE_CANVAS ? "canvas" : "div" );
|
||||||
this.context = USE_CANVAS ? this.canvas.getContext("2d") : null;
|
this.context = USE_CANVAS ? this.canvas.getContext( "2d" ) : null;
|
||||||
this.viewport = viewport;
|
this.viewport = viewport;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.config = this.viewport.config;
|
this.config = this.viewport.config;
|
||||||
@ -34,7 +34,7 @@ $.Drawer = function(source, viewport, elmt) {
|
|||||||
this.downloading = 0;
|
this.downloading = 0;
|
||||||
this.imageLoaderLimit = this.config.imageLoaderLimit;
|
this.imageLoaderLimit = this.config.imageLoaderLimit;
|
||||||
|
|
||||||
this.profiler = new $.Profiler();
|
//this.profiler = new $.Profiler();
|
||||||
|
|
||||||
this.minLevel = source.minLevel;
|
this.minLevel = source.minLevel;
|
||||||
this.maxLevel = source.maxLevel;
|
this.maxLevel = source.maxLevel;
|
||||||
@ -136,7 +136,7 @@ $.Drawer.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onTileLoad: function(tile, time, image) {
|
_onTileLoad: function( tile, time, image ) {
|
||||||
var insertionIndex,
|
var insertionIndex,
|
||||||
cutoff,
|
cutoff,
|
||||||
worstTile,
|
worstTile,
|
||||||
@ -151,14 +151,14 @@ $.Drawer.prototype = {
|
|||||||
tile.loading = false;
|
tile.loading = false;
|
||||||
|
|
||||||
if ( this.midUpdate ) {
|
if ( this.midUpdate ) {
|
||||||
$.Debug.error( "Tile load callback in middle of drawing routine." );
|
$.Debug.warn( "Tile load callback in middle of drawing routine." );
|
||||||
return;
|
return;
|
||||||
} else if ( !image ) {
|
} else if ( !image ) {
|
||||||
$.Debug.log( "Tile " + tile + " failed to load: " + tile.url );
|
$.Debug.log( "Tile %s failed to load: %s", tile, tile.url );
|
||||||
tile.exists = false;
|
tile.exists = false;
|
||||||
return;
|
return;
|
||||||
} else if ( time < this.lastResetTime ) {
|
} else if ( time < this.lastResetTime ) {
|
||||||
$.Debug.log( "Ignoring tile " + tile + " loaded before reset: " + tile.url );
|
$.Debug.log( "Ignoring tile %s loaded before reset: %s", tile, tile.url );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,8 +277,9 @@ $.Drawer.prototype = {
|
|||||||
*/
|
*/
|
||||||
_setCoverage: function( level, x, y, covers ) {
|
_setCoverage: function( level, x, y, covers ) {
|
||||||
if ( !this.coverage[ level ] ) {
|
if ( !this.coverage[ level ] ) {
|
||||||
$.Debug.error(
|
$.Debug.warn(
|
||||||
"Setting coverage for a tile before its level's coverage has been reset: " + level
|
"Setting coverage for a tile before its level's coverage has been reset: %s",
|
||||||
|
level
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -403,7 +404,14 @@ $.Drawer.prototype = {
|
|||||||
for ( level = highestLevel; level >= lowestLevel; level-- ) {
|
for ( level = highestLevel; level >= lowestLevel; level-- ) {
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
best = this._drawLevel( level, lowestLevel, viewportTL, viewportBR, currentTime, best );
|
best = this._drawLevel(
|
||||||
|
level,
|
||||||
|
lowestLevel,
|
||||||
|
viewportTL,
|
||||||
|
viewportBR,
|
||||||
|
currentTime,
|
||||||
|
best
|
||||||
|
);
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
if ( this._providesCoverage( level ) ) {
|
if ( this._providesCoverage( level ) ) {
|
||||||
@ -491,7 +499,7 @@ $.Drawer.prototype = {
|
|||||||
|
|
||||||
for ( x = tileTL.x; x <= tileBR.x; x++ ) {
|
for ( x = tileTL.x; x <= tileBR.x; x++ ) {
|
||||||
for ( y = tileTL.y; y <= tileBR.y; y++ ) {
|
for ( y = tileTL.y; y <= tileBR.y; y++ ) {
|
||||||
drawTile = drawLevel;
|
|
||||||
tile = this._getTile(
|
tile = this._getTile(
|
||||||
level,
|
level,
|
||||||
x, y,
|
x, y,
|
||||||
@ -506,6 +514,7 @@ $.Drawer.prototype = {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawTile = drawLevel;
|
||||||
if ( haveDrawn && !drawTile ) {
|
if ( haveDrawn && !drawTile ) {
|
||||||
if ( this._isCovered( level, x, y ) ) {
|
if ( this._isCovered( level, x, y ) ) {
|
||||||
this._setCoverage( level, x, y, true );
|
this._setCoverage( level, x, y, true );
|
||||||
@ -722,7 +731,10 @@ $.Drawer.prototype = {
|
|||||||
callback( image );
|
callback( image );
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
$.Debug.error(
|
$.Debug.error(
|
||||||
e.name + " while executing " + src +" callback: " + e.message,
|
"%s while executing %s callback: %s",
|
||||||
|
e.name,
|
||||||
|
src,
|
||||||
|
e.message,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,26 @@
|
|||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
|
|
||||||
$.DziTileSource = function(width, height, tileSize, tileOverlap, tilesUrl, fileFormat, displayRects) {
|
$.DziTileSource = function( width, height, tileSize, tileOverlap, tilesUrl, fileFormat, displayRects ) {
|
||||||
$.TileSource.call(this, width, height, tileSize, tileOverlap, null, null);
|
var i,
|
||||||
|
rect,
|
||||||
|
level;
|
||||||
|
|
||||||
|
$.TileSource.call( this, width, height, tileSize, tileOverlap, null, null );
|
||||||
|
|
||||||
this._levelRects = {};
|
this._levelRects = {};
|
||||||
this.tilesUrl = tilesUrl;
|
this.tilesUrl = tilesUrl;
|
||||||
|
|
||||||
this.fileFormat = fileFormat;
|
this.fileFormat = fileFormat;
|
||||||
this.displayRects = displayRects;
|
this.displayRects = displayRects;
|
||||||
|
|
||||||
if ( this.displayRects ) {
|
if ( this.displayRects ) {
|
||||||
for (var i = this.displayRects.length - 1; i >= 0; i--) {
|
for ( i = this.displayRects.length - 1; i >= 0; i-- ) {
|
||||||
var rect = this.displayRects[i];
|
rect = this.displayRects[ i ];
|
||||||
for (var level = rect.minLevel; level <= rect.maxLevel; level++) {
|
for ( level = rect.minLevel; level <= rect.maxLevel; level++ ) {
|
||||||
if (!this._levelRects[level]) {
|
if ( !this._levelRects[ level ] ) {
|
||||||
this._levelRects[level] = [];
|
this._levelRects[ level ] = [];
|
||||||
}
|
}
|
||||||
this._levelRects[level].push(rect);
|
this._levelRects[ level ].push( rect );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,36 +30,43 @@ $.DziTileSource = function(width, height, tileSize, tileOverlap, tilesUrl, fileF
|
|||||||
|
|
||||||
$.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
|
$.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
|
||||||
|
|
||||||
getTileUrl: function(level, x, y) {
|
getTileUrl: function( level, x, y ) {
|
||||||
return [this.tilesUrl, level, '/', x, '_', y, '.', this.fileFormat].join('');
|
return [ this.tilesUrl, level, '/', x, '_', y, '.', this.fileFormat ].join( '' );
|
||||||
},
|
},
|
||||||
|
|
||||||
tileExists: function(level, x, y) {
|
tileExists: function( level, x, y ) {
|
||||||
var rects = this._levelRects[level];
|
var rects = this._levelRects[ level ],
|
||||||
|
rect,
|
||||||
|
scale,
|
||||||
|
xMin,
|
||||||
|
yMin,
|
||||||
|
xMax,
|
||||||
|
yMax,
|
||||||
|
i;
|
||||||
|
|
||||||
if (!rects || !rects.length) {
|
if ( !rects || !rects.length ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = rects.length - 1; i >= 0; i--) {
|
for ( i = rects.length - 1; i >= 0; i-- ) {
|
||||||
var rect = rects[i];
|
rect = rects[ i ];
|
||||||
|
|
||||||
if (level < rect.minLevel || level > rect.maxLevel) {
|
if ( level < rect.minLevel || level > rect.maxLevel ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var scale = this.getLevelScale(level);
|
scale = this.getLevelScale( level );
|
||||||
var xMin = rect.x * scale;
|
xMin = rect.x * scale;
|
||||||
var yMin = rect.y * scale;
|
yMin = rect.y * scale;
|
||||||
var xMax = xMin + rect.width * scale;
|
xMax = xMin + rect.width * scale;
|
||||||
var yMax = yMin + rect.height * scale;
|
yMax = yMin + rect.height * scale;
|
||||||
|
|
||||||
xMin = Math.floor(xMin / this.tileSize);
|
xMin = Math.floor( xMin / this.tileSize );
|
||||||
yMin = Math.floor(yMin / this.tileSize);
|
yMin = Math.floor( yMin / this.tileSize );
|
||||||
xMax = Math.ceil(xMax / this.tileSize);
|
xMax = Math.ceil( xMax / this.tileSize );
|
||||||
yMax = Math.ceil(yMax / this.tileSize);
|
yMax = Math.ceil( yMax / this.tileSize );
|
||||||
|
|
||||||
if (xMin <= x && x < xMax && yMin <= y && y < yMax) {
|
if ( xMin <= x && x < xMax && yMin <= y && y < yMax ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,146 +76,177 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.DziTileSourceHelper = {
|
$.DziTileSourceHelper = {
|
||||||
createFromXml: function(xmlUrl, xmlString, callback) {
|
|
||||||
var async = typeof (callback) == "function";
|
|
||||||
var error = null;
|
|
||||||
|
|
||||||
if (!xmlUrl) {
|
createFromXml: function( xmlUrl, xmlString, callback ) {
|
||||||
this.error = $.Strings.getString("Errors.Empty");
|
var async = typeof (callback) == "function",
|
||||||
if (async) {
|
error = null,
|
||||||
window.setTimeout(function() {
|
urlParts,
|
||||||
callback(null, error);
|
filename,
|
||||||
}, 1);
|
lastDot,
|
||||||
|
tilesUrl,
|
||||||
|
handler;
|
||||||
|
|
||||||
|
if ( !xmlUrl ) {
|
||||||
|
this.error = $.getString( "Errors.Empty" );
|
||||||
|
if ( async ) {
|
||||||
|
window.setTimeout( function() {
|
||||||
|
callback( null, error );
|
||||||
|
}, 1 );
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new Error(error);
|
throw new Error( error );
|
||||||
}
|
}
|
||||||
|
|
||||||
var urlParts = xmlUrl.split('/');
|
urlParts = xmlUrl.split( '/' );
|
||||||
var filename = urlParts[urlParts.length - 1];
|
filename = urlParts[ urlParts.length - 1 ];
|
||||||
var lastDot = filename.lastIndexOf('.');
|
lastDot = filename.lastIndexOf( '.' );
|
||||||
|
|
||||||
if (lastDot > -1) {
|
if ( lastDot > -1 ) {
|
||||||
urlParts[urlParts.length - 1] = filename.slice(0, lastDot);
|
urlParts[ urlParts.length - 1 ] = filename.slice( 0, lastDot );
|
||||||
}
|
}
|
||||||
|
|
||||||
var tilesUrl = urlParts.join('/') + "_files/";
|
tilesUrl = urlParts.join( '/' ) + "_files/";
|
||||||
function finish(func, obj) {
|
|
||||||
|
function finish( func, obj ) {
|
||||||
try {
|
try {
|
||||||
return func(obj, tilesUrl);
|
return func( obj, tilesUrl );
|
||||||
} catch (e) {
|
} catch ( e ) {
|
||||||
if (async) {
|
if ( async ) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (async) {
|
|
||||||
if (xmlString) {
|
if ( async ) {
|
||||||
var handler = $.delegate(this, this.processXml);
|
if ( xmlString ) {
|
||||||
window.setTimeout(function() {
|
handler = $.delegate( this, this.processXml );
|
||||||
var source = finish(handler, $.parseXml(xmlString));
|
window.setTimeout( function() {
|
||||||
callback(source, error); // call after finish sets error
|
var source = finish( handler, $.parseXml( xmlString ) );
|
||||||
|
// call after finish sets error
|
||||||
|
callback( source, error );
|
||||||
}, 1);
|
}, 1);
|
||||||
} else {
|
} else {
|
||||||
var handler = $.delegate(this, this.processResponse);
|
handler = $.delegate( this, this.processResponse );
|
||||||
$.makeAjaxRequest(xmlUrl, function(xhr) {
|
$.makeAjaxRequest( xmlUrl, function( xhr ) {
|
||||||
var source = finish(handler, xhr);
|
var source = finish( handler, xhr );
|
||||||
callback(source, error); // call after finish sets error
|
// call after finish sets error
|
||||||
|
callback( source, error );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xmlString) {
|
if ( xmlString ) {
|
||||||
return finish($.delegate(this, this.processXml), $.parseXml(xmlString));
|
return finish(
|
||||||
|
$.delegate( this, this.processXml ),
|
||||||
|
$.parseXml( xmlString )
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return finish($.delegate(this, this.processResponse), $.makeAjaxRequest(xmlUrl));
|
return finish(
|
||||||
|
$.delegate( this, this.processResponse ),
|
||||||
|
$.makeAjaxRequest( xmlUrl )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
processResponse: function(xhr, tilesUrl) {
|
processResponse: function( xhr, tilesUrl ) {
|
||||||
if (!xhr) {
|
var status,
|
||||||
throw new Error($.Strings.getString("Errors.Security"));
|
statusText,
|
||||||
} else if (xhr.status !== 200 && xhr.status !== 0) {
|
doc = null;
|
||||||
var status = xhr.status;
|
|
||||||
var statusText = (status == 404) ? "Not Found" : xhr.statusText;
|
if ( !xhr ) {
|
||||||
throw new Error($.Strings.getString("Errors.Status", status, statusText));
|
throw new Error( $.getString( "Errors.Security" ) );
|
||||||
|
} else if ( xhr.status !== 200 && xhr.status !== 0 ) {
|
||||||
|
status = xhr.status;
|
||||||
|
statusText = ( status == 404 ) ?
|
||||||
|
"Not Found" :
|
||||||
|
xhr.statusText;
|
||||||
|
throw new Error( $.getString( "Errors.Status", status, statusText ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
var doc = null;
|
if ( xhr.responseXML && xhr.responseXML.documentElement ) {
|
||||||
|
|
||||||
if (xhr.responseXML && xhr.responseXML.documentElement) {
|
|
||||||
doc = xhr.responseXML;
|
doc = xhr.responseXML;
|
||||||
} else if (xhr.responseText) {
|
} else if ( xhr.responseText ) {
|
||||||
doc = $.parseXml(xhr.responseText);
|
doc = $.parseXml( xhr.responseText );
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.processXml(doc, tilesUrl);
|
return this.processXml( doc, tilesUrl );
|
||||||
},
|
},
|
||||||
|
|
||||||
processXml: function(xmlDoc, tilesUrl) {
|
processXml: function( xmlDoc, tilesUrl ) {
|
||||||
if (!xmlDoc || !xmlDoc.documentElement) {
|
|
||||||
throw new Error($.Strings.getString("Errors.Xml"));
|
if ( !xmlDoc || !xmlDoc.documentElement ) {
|
||||||
|
throw new Error( $.getString( "Errors.Xml" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
var root = xmlDoc.documentElement;
|
var root = xmlDoc.documentElement,
|
||||||
var rootName = root.tagName;
|
rootName = root.tagName;
|
||||||
|
|
||||||
if (rootName == "Image") {
|
if ( rootName == "Image" ) {
|
||||||
try {
|
try {
|
||||||
return this.processDzi(root, tilesUrl);
|
return this.processDzi( root, tilesUrl );
|
||||||
} catch (e) {
|
} catch ( e ) {
|
||||||
var defMsg = $.Strings.getString("Errors.Dzi");
|
throw (e instanceof Error) ?
|
||||||
throw (e instanceof Error) ? e : new Error(defMsg);
|
e :
|
||||||
|
new Error( $.getString("Errors.Dzi") );
|
||||||
}
|
}
|
||||||
} else if (rootName == "Collection") {
|
} else if ( rootName == "Collection" ) {
|
||||||
throw new Error($.Strings.getString("Errors.Dzc"));
|
throw new Error( $.getString( "Errors.Dzc" ) );
|
||||||
} else if (rootName == "Error") {
|
} else if ( rootName == "Error" ) {
|
||||||
return this.processError(root);
|
return this.processError( root );
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error($.Strings.getString("Errors.Dzi"));
|
throw new Error( $.getString( "Errors.Dzi" ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
processDzi: function(imageNode, tilesUrl) {
|
processDzi: function( imageNode, tilesUrl ) {
|
||||||
var fileFormat = imageNode.getAttribute("Format");
|
var fileFormat = imageNode.getAttribute( "Format" ),
|
||||||
|
sizeNode = imageNode.getElementsByTagName( "Size" )[ 0 ],
|
||||||
|
dispRectNodes = imageNode.getElementsByTagName( "DisplayRect" ),
|
||||||
|
width = parseInt( sizeNode.getAttribute( "Width" ) ),
|
||||||
|
height = parseInt( sizeNode.getAttribute( "Height" ) ),
|
||||||
|
tileSize = parseInt( imageNode.getAttribute( "TileSize" ) ),
|
||||||
|
tileOverlap = parseInt( imageNode.getAttribute( "Overlap" ) ),
|
||||||
|
dispRects = [],
|
||||||
|
dispRectNode,
|
||||||
|
rectNode,
|
||||||
|
i;
|
||||||
|
|
||||||
if (!$.imageFormatSupported(fileFormat)) {
|
if ( !$.imageFormatSupported( fileFormat ) ) {
|
||||||
throw new Error($.Strings.getString("Errors.ImageFormat",
|
throw new Error(
|
||||||
fileFormat.toUpperCase()));
|
$.getString( "Errors.ImageFormat", fileFormat.toUpperCase() )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var sizeNode = imageNode.getElementsByTagName("Size")[0];
|
for ( i = 0; i < dispRectNodes.length; i++ ) {
|
||||||
var dispRectNodes = imageNode.getElementsByTagName("DisplayRect");
|
dispRectNode = dispRectNodes[ i ];
|
||||||
|
rectNode = dispRectNode.getElementsByTagName( "Rect" )[ 0 ];
|
||||||
|
|
||||||
var width = parseInt(sizeNode.getAttribute("Width"), 10);
|
dispRects.push( new $.DisplayRect(
|
||||||
var height = parseInt(sizeNode.getAttribute("Height"), 10);
|
parseInt( rectNode.getAttribute( "X" ) ),
|
||||||
var tileSize = parseInt(imageNode.getAttribute("TileSize"));
|
parseInt( rectNode.getAttribute( "Y" ) ),
|
||||||
var tileOverlap = parseInt(imageNode.getAttribute("Overlap"));
|
parseInt( rectNode.getAttribute( "Width" ) ),
|
||||||
var dispRects = [];
|
parseInt( rectNode.getAttribute( "Height" ) ),
|
||||||
|
|
||||||
for (var i = 0; i < dispRectNodes.length; i++) {
|
|
||||||
var dispRectNode = dispRectNodes[i];
|
|
||||||
var rectNode = dispRectNode.getElementsByTagName("Rect")[0];
|
|
||||||
|
|
||||||
dispRects.push(new $.DisplayRect(
|
|
||||||
parseInt(rectNode.getAttribute("X"), 10),
|
|
||||||
parseInt(rectNode.getAttribute("Y"), 10),
|
|
||||||
parseInt(rectNode.getAttribute("Width"), 10),
|
|
||||||
parseInt(rectNode.getAttribute("Height"), 10),
|
|
||||||
0, // ignore MinLevel attribute, bug in Deep Zoom Composer
|
0, // ignore MinLevel attribute, bug in Deep Zoom Composer
|
||||||
parseInt(dispRectNode.getAttribute("MaxLevel"), 10)
|
parseInt( dispRectNode.getAttribute( "MaxLevel" ) )
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return new $.DziTileSource(width, height, tileSize, tileOverlap,
|
return new $.DziTileSource(
|
||||||
tilesUrl, fileFormat, dispRects);
|
width,
|
||||||
|
height,
|
||||||
|
tileSize,
|
||||||
|
tileOverlap,
|
||||||
|
tilesUrl,
|
||||||
|
fileFormat,
|
||||||
|
dispRects
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
processError: function(errorNode) {
|
processError: function( errorNode ) {
|
||||||
var messageNode = errorNode.getElementsByTagName("Message")[0];
|
var messageNode = errorNode.getElementsByTagName( "Message" )[ 0 ],
|
||||||
var message = messageNode.firstChild.nodeValue;
|
message = messageNode.firstChild.nodeValue;
|
||||||
|
|
||||||
throw new Error(message);
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
Array.apply( null, events );
|
Array.apply( null, events );
|
||||||
return function( source, args ) {
|
return function( source, args ) {
|
||||||
var i,
|
var i,
|
||||||
l = events.length;
|
length = events.length;
|
||||||
for ( i = 0; i < l; i++ ) {
|
for ( i = 0; i < length; i++ ) {
|
||||||
events[ i ]( source, args );
|
events[ i ]( source, args );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -711,7 +711,11 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
request.open( "GET", url, async );
|
request.open( "GET", url, async );
|
||||||
request.send( null );
|
request.send( null );
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$.Debug.log(e.name + " while making AJAX request: " + e.message);
|
$.Debug.log(
|
||||||
|
"%s while making AJAX request: %s",
|
||||||
|
e.name,
|
||||||
|
e.message
|
||||||
|
);
|
||||||
|
|
||||||
request.onreadystatechange = null;
|
request.onreadystatechange = null;
|
||||||
request = null;
|
request = null;
|
||||||
|
@ -13,15 +13,15 @@
|
|||||||
LEFT: 8
|
LEFT: 8
|
||||||
};
|
};
|
||||||
|
|
||||||
$.Overlay = function(elmt, location, placement) {
|
$.Overlay = function( elmt, location, placement ) {
|
||||||
this.elmt = elmt;
|
this.elmt = elmt;
|
||||||
this.scales = location instanceof $.Rect;
|
this.scales = location instanceof $.Rect;
|
||||||
this.bounds = new $.Rect(
|
this.bounds = new $.Rect(
|
||||||
location.x,
|
location.x,
|
||||||
location.y,
|
location.y,
|
||||||
location.width,
|
location.width,
|
||||||
location.height)
|
location.height
|
||||||
;
|
);
|
||||||
this.position = new $.Point(
|
this.position = new $.Point(
|
||||||
location.x,
|
location.x,
|
||||||
location.y
|
location.y
|
||||||
@ -39,8 +39,8 @@
|
|||||||
|
|
||||||
$.Overlay.prototype = {
|
$.Overlay.prototype = {
|
||||||
|
|
||||||
adjust: function(position, size) {
|
adjust: function( position, size ) {
|
||||||
switch (this.placement) {
|
switch ( this.placement ) {
|
||||||
case $.OverlayPlacement.TOP_LEFT:
|
case $.OverlayPlacement.TOP_LEFT:
|
||||||
break;
|
break;
|
||||||
case $.OverlayPlacement.TOP:
|
case $.OverlayPlacement.TOP:
|
||||||
@ -74,36 +74,38 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
destroy: function() {
|
|
||||||
var elmt = this.elmt;
|
|
||||||
var style = this.style;
|
|
||||||
|
|
||||||
if (elmt.parentNode) {
|
destroy: function() {
|
||||||
elmt.parentNode.removeChild(elmt);
|
var element = this.elmt,
|
||||||
|
style = this.style;
|
||||||
|
|
||||||
|
if ( element.parentNode ) {
|
||||||
|
element.parentNode.removeChild( element );
|
||||||
}
|
}
|
||||||
|
|
||||||
style.top = "";
|
style.top = "";
|
||||||
style.left = "";
|
style.left = "";
|
||||||
style.position = "";
|
style.position = "";
|
||||||
|
|
||||||
if (this.scales) {
|
if ( this.scales ) {
|
||||||
style.width = "";
|
style.width = "";
|
||||||
style.height = "";
|
style.height = "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
drawHTML: function( container ) {
|
drawHTML: function( container ) {
|
||||||
var elmt = this.elmt,
|
var element = this.elmt,
|
||||||
style = this.style,
|
style = this.style,
|
||||||
scales = this.scales,
|
scales = this.scales,
|
||||||
position,
|
position,
|
||||||
size;
|
size;
|
||||||
|
|
||||||
if ( elmt.parentNode != container ) {
|
if ( element.parentNode != container ) {
|
||||||
container.appendChild( elmt );
|
container.appendChild( element );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !scales ) {
|
if ( !scales ) {
|
||||||
this.size = $.getElementSize( elmt );
|
this.size = $.getElementSize( element );
|
||||||
}
|
}
|
||||||
|
|
||||||
position = this.position;
|
position = this.position;
|
||||||
@ -123,11 +125,17 @@
|
|||||||
style.height = size.y + "px";
|
style.height = size.y + "px";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update: function( loc, placement ) {
|
|
||||||
this.scales = ( loc instanceof $.Rect );
|
update: function( location, placement ) {
|
||||||
this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height);
|
this.scales = location instanceof $.Rect;
|
||||||
|
this.bounds = new $.Rect(
|
||||||
|
location.x,
|
||||||
|
location.y,
|
||||||
|
location.width,
|
||||||
|
location.height
|
||||||
|
);
|
||||||
// rects are always top-left
|
// rects are always top-left
|
||||||
this.placement = loc instanceof $.Point ?
|
this.placement = location instanceof $.Point ?
|
||||||
placement :
|
placement :
|
||||||
$.OverlayPlacement.TOP_LEFT;
|
$.OverlayPlacement.TOP_LEFT;
|
||||||
}
|
}
|
||||||
|
18
src/point.js
18
src/point.js
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
$.Point = function(x, y) {
|
$.Point = function( x, y ) {
|
||||||
this.x = typeof (x) == "number" ? x : 0;
|
this.x = typeof ( x ) == "number" ? x : 0;
|
||||||
this.y = typeof (y) == "number" ? y : 0;
|
this.y = typeof ( y ) == "number" ? y : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
$.Point.prototype = {
|
$.Point.prototype = {
|
||||||
@ -48,13 +48,17 @@ $.Point.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
apply: function( func ) {
|
apply: function( func ) {
|
||||||
return new $.Point( func(this.x), func(this.y) );
|
return new $.Point( func( this.x ), func( this.y ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
equals: function( point ) {
|
equals: function( point ) {
|
||||||
return ( point instanceof $.Point ) &&
|
return (
|
||||||
( this.x === point.x ) &&
|
point instanceof $.Point
|
||||||
( this.y === point.y );
|
) && (
|
||||||
|
this.x === point.x
|
||||||
|
) && (
|
||||||
|
this.y === point.y
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
toString: function() {
|
toString: function() {
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
//TODO: I guess this is where the i18n needs to be reimplemented. I'll look
|
//TODO: I guess this is where the i18n needs to be reimplemented. I'll look
|
||||||
// into existing patterns for i18n in javascript but i think that mimicking
|
// into existing patterns for i18n in javascript but i think that mimicking
|
||||||
// pythons gettext might be a reasonable approach.
|
// pythons gettext might be a reasonable approach.
|
||||||
|
var I18N = {
|
||||||
$.Strings = {
|
|
||||||
|
|
||||||
Errors: {
|
Errors: {
|
||||||
Failure: "Sorry, but Seadragon Ajax can't run on your browser!\n" +
|
Failure: "Sorry, but Seadragon Ajax can't run on your browser!\n" +
|
||||||
"Please try using IE 7 or Firefox 3.\n",
|
"Please try using IE 7 or Firefox 3.\n",
|
||||||
@ -30,12 +28,15 @@ $.Strings = {
|
|||||||
Home: "Go home",
|
Home: "Go home",
|
||||||
ZoomIn: "Zoom in",
|
ZoomIn: "Zoom in",
|
||||||
ZoomOut: "Zoom out"
|
ZoomOut: "Zoom out"
|
||||||
},
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.extend( $, {
|
||||||
|
|
||||||
getString: function( prop ) {
|
getString: function( prop ) {
|
||||||
|
|
||||||
var props = prop.split('.'),
|
var props = prop.split('.'),
|
||||||
string = $.Strings,
|
string = I18N,
|
||||||
args = arguments,
|
args = arguments,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
@ -71,6 +72,6 @@ $.Strings = {
|
|||||||
container[ props[ i ] ] = value;
|
container[ props[ i ] ] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
});
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}( OpenSeadragon ));
|
||||||
|
29
src/tile.js
29
src/tile.js
@ -34,11 +34,13 @@ $.Tile.prototype = {
|
|||||||
|
|
||||||
drawHTML: function( container ) {
|
drawHTML: function( container ) {
|
||||||
|
|
||||||
|
var position = this.position.apply( Math.floor ),
|
||||||
|
size = this.size.apply( Math.ceil );
|
||||||
|
|
||||||
if ( !this.loaded ) {
|
if ( !this.loaded ) {
|
||||||
$.Debug.error(
|
$.Debug.warn(
|
||||||
"Attempting to draw tile " +
|
"Attempting to draw tile %s when it's not yet loaded.",
|
||||||
this.toString() +
|
this.toString()
|
||||||
" when it's not yet loaded."
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -52,9 +54,6 @@ $.Tile.prototype = {
|
|||||||
this.style.msInterpolationMode = "nearest-neighbor";
|
this.style.msInterpolationMode = "nearest-neighbor";
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = this.position.apply( Math.floor );
|
|
||||||
var size = this.size.apply( Math.ceil );
|
|
||||||
|
|
||||||
|
|
||||||
if ( this.elmt.parentNode != container ) {
|
if ( this.elmt.parentNode != container ) {
|
||||||
container.appendChild( this.elmt );
|
container.appendChild( this.elmt );
|
||||||
@ -70,18 +69,18 @@ $.Tile.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
drawCanvas: function(context) {
|
drawCanvas: function(context) {
|
||||||
if (!this.loaded) {
|
|
||||||
$.Debug.error(
|
|
||||||
"Attempting to draw tile " +
|
|
||||||
this.toString() +
|
|
||||||
" when it's not yet loaded."
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var position = this.position,
|
var position = this.position,
|
||||||
size = this.size;
|
size = this.size;
|
||||||
|
|
||||||
|
if (!this.loaded) {
|
||||||
|
$.Debug.warn(
|
||||||
|
"Attempting to draw tile %s when it's not yet loaded.",
|
||||||
|
this.toString()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context.globalAlpha = this.opacity;
|
context.globalAlpha = this.opacity;
|
||||||
context.drawImage(this.image, position.x, position.y, size.x, size.y);
|
context.drawImage(this.image, position.x, position.y, size.x, size.y);
|
||||||
},
|
},
|
||||||
|
@ -1,67 +1,65 @@
|
|||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
$.TileSource = function(width, height, tileSize, tileOverlap, minLevel, maxLevel) {
|
$.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLevel ) {
|
||||||
this.aspectRatio = width / height;
|
this.aspectRatio = width / height;
|
||||||
this.dimensions = new $.Point(width, height);
|
this.dimensions = new $.Point( width, height );
|
||||||
|
this.tileSize = tileSize ? tileSize : 0;
|
||||||
|
this.tileOverlap = tileOverlap ? tileOverlap : 0;
|
||||||
this.minLevel = minLevel ? minLevel : 0;
|
this.minLevel = minLevel ? minLevel : 0;
|
||||||
this.maxLevel = maxLevel ? maxLevel :
|
this.maxLevel = maxLevel ? maxLevel :
|
||||||
Math.ceil(
|
Math.ceil(
|
||||||
Math.log( Math.max( width, height ) ) /
|
Math.log( Math.max( width, height ) ) /
|
||||||
Math.log( 2 )
|
Math.log( 2 )
|
||||||
);
|
);
|
||||||
this.tileSize = tileSize ? tileSize : 0;
|
|
||||||
this.tileOverlap = tileOverlap ? tileOverlap : 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$.TileSource.prototype = {
|
$.TileSource.prototype = {
|
||||||
getLevelScale: function(level) {
|
|
||||||
return 1 / (1 << (this.maxLevel - level));
|
getLevelScale: function( level ) {
|
||||||
|
return 1 / ( 1 << ( this.maxLevel - level ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
getNumTiles: function(level) {
|
getNumTiles: function( level ) {
|
||||||
var scale = this.getLevelScale(level);
|
var scale = this.getLevelScale( level ),
|
||||||
var x = Math.ceil(scale * this.dimensions.x / this.tileSize);
|
x = Math.ceil( scale * this.dimensions.x / this.tileSize ),
|
||||||
var y = Math.ceil(scale * this.dimensions.y / this.tileSize);
|
y = Math.ceil( scale * this.dimensions.y / this.tileSize );
|
||||||
|
|
||||||
return new $.Point(x, y);
|
return new $.Point( x, y );
|
||||||
},
|
},
|
||||||
|
|
||||||
getPixelRatio: function(level) {
|
getPixelRatio: function( level ) {
|
||||||
var imageSizeScaled = this.dimensions.times(this.getLevelScale(level));
|
var imageSizeScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
||||||
var rx = 1.0 / imageSizeScaled.x;
|
rx = 1.0 / imageSizeScaled.x,
|
||||||
var ry = 1.0 / imageSizeScaled.y;
|
ry = 1.0 / imageSizeScaled.y;
|
||||||
|
|
||||||
return new $.Point(rx, ry);
|
return new $.Point(rx, ry);
|
||||||
},
|
},
|
||||||
|
|
||||||
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 ),
|
||||||
|
ty = Math.floor( pixel.y / this.tileSize );
|
||||||
|
|
||||||
var tx = Math.floor(pixel.x / this.tileSize);
|
return new $.Point( tx, ty );
|
||||||
var ty = Math.floor(pixel.y / this.tileSize);
|
|
||||||
|
|
||||||
return new $.Point(tx, ty);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
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,
|
||||||
|
py = ( y === 0 ) ? 0 : this.tileSize * y - this.tileOverlap,
|
||||||
|
sx = this.tileSize + ( x === 0 ? 1 : 2 ) * this.tileOverlap,
|
||||||
|
sy = this.tileSize + ( y === 0 ? 1 : 2 ) * this.tileOverlap,
|
||||||
|
scale = 1.0 / dimensionsScaled.x;
|
||||||
|
|
||||||
var px = (x === 0) ? 0 : this.tileSize * x - this.tileOverlap;
|
sx = Math.min( sx, dimensionsScaled.x - px );
|
||||||
var py = (y === 0) ? 0 : this.tileSize * y - this.tileOverlap;
|
sy = Math.min( sy, dimensionsScaled.y - py );
|
||||||
|
|
||||||
var sx = this.tileSize + (x === 0 ? 1 : 2) * this.tileOverlap;
|
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
|
||||||
var sy = this.tileSize + (y === 0 ? 1 : 2) * this.tileOverlap;
|
|
||||||
|
|
||||||
sx = Math.min(sx, dimensionsScaled.x - px);
|
|
||||||
sy = Math.min(sy, dimensionsScaled.y - py);
|
|
||||||
|
|
||||||
var scale = 1.0 / dimensionsScaled.x;
|
|
||||||
return new $.Rect(px * scale, py * scale, sx * scale, sy * scale);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getTileUrl: function( level, x, y ) {
|
getTileUrl: function( level, x, y ) {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error( "Method not implemented." );
|
||||||
},
|
},
|
||||||
|
|
||||||
tileExists: function( level, x, y ) {
|
tileExists: function( level, x, y ) {
|
||||||
|
@ -199,25 +199,27 @@ $.Viewer = function( options ) {
|
|||||||
// Navigation Controls
|
// Navigation Controls
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
this._group = null;
|
this._group = null;
|
||||||
this._zooming = false; // whether we should be continuously zooming
|
// whether we should be continuously zooming
|
||||||
this._zoomFactor = null; // how much we should be continuously zooming by
|
this._zooming = false;
|
||||||
|
// how much we should be continuously zooming by
|
||||||
|
this._zoomFactor = null;
|
||||||
this._lastZoomTime = null;
|
this._lastZoomTime = null;
|
||||||
|
|
||||||
this.elmt = null;
|
this.elmt = null;
|
||||||
|
|
||||||
var beginZoomingInHandler = $.delegate(this, beginZoomingIn);
|
var beginZoomingInHandler = $.delegate(this, beginZoomingIn),
|
||||||
var endZoomingHandler = $.delegate(this, endZooming);
|
endZoomingHandler = $.delegate(this, endZooming),
|
||||||
var doSingleZoomInHandler = $.delegate(this, doSingleZoomIn);
|
doSingleZoomInHandler = $.delegate(this, doSingleZoomIn),
|
||||||
var beginZoomingOutHandler = $.delegate(this, beginZoomingOut);
|
beginZoomingOutHandler = $.delegate(this, beginZoomingOut),
|
||||||
var doSingleZoomOutHandler = $.delegate(this, doSingleZoomOut);
|
doSingleZoomOutHandler = $.delegate(this, doSingleZoomOut),
|
||||||
var onHomeHandler = $.delegate(this, onHome);
|
onHomeHandler = $.delegate(this, onHome),
|
||||||
var onFullPageHandler = $.delegate(this, onFullPage);
|
onFullPageHandler = $.delegate(this, onFullPage);
|
||||||
|
|
||||||
var navImages = this.config.navImages;
|
var navImages = this.config.navImages;
|
||||||
|
|
||||||
var zoomIn = new $.Button({
|
var zoomIn = new $.Button({
|
||||||
config: this.config,
|
config: this.config,
|
||||||
tooltip: $.Strings.getString("Tooltips.ZoomIn"),
|
tooltip: $.getString("Tooltips.ZoomIn"),
|
||||||
srcRest: resolveUrl(this.urlPrefix, navImages.zoomIn.REST),
|
srcRest: resolveUrl(this.urlPrefix, navImages.zoomIn.REST),
|
||||||
srcGroup: resolveUrl(this.urlPrefix, navImages.zoomIn.GROUP),
|
srcGroup: resolveUrl(this.urlPrefix, navImages.zoomIn.GROUP),
|
||||||
srcHover: resolveUrl(this.urlPrefix, navImages.zoomIn.HOVER),
|
srcHover: resolveUrl(this.urlPrefix, navImages.zoomIn.HOVER),
|
||||||
@ -231,7 +233,7 @@ $.Viewer = function( options ) {
|
|||||||
|
|
||||||
var zoomOut = new $.Button({
|
var zoomOut = new $.Button({
|
||||||
config: this.config,
|
config: this.config,
|
||||||
tooltip: $.Strings.getString("Tooltips.ZoomOut"),
|
tooltip: $.getString("Tooltips.ZoomOut"),
|
||||||
srcRest: resolveUrl(this.urlPrefix, navImages.zoomOut.REST),
|
srcRest: resolveUrl(this.urlPrefix, navImages.zoomOut.REST),
|
||||||
srcGroup: resolveUrl(this.urlPrefix, navImages.zoomOut.GROUP),
|
srcGroup: resolveUrl(this.urlPrefix, navImages.zoomOut.GROUP),
|
||||||
srcHover: resolveUrl(this.urlPrefix, navImages.zoomOut.HOVER),
|
srcHover: resolveUrl(this.urlPrefix, navImages.zoomOut.HOVER),
|
||||||
@ -244,7 +246,7 @@ $.Viewer = function( options ) {
|
|||||||
});
|
});
|
||||||
var goHome = new $.Button({
|
var goHome = new $.Button({
|
||||||
config: this.config,
|
config: this.config,
|
||||||
tooltip: $.Strings.getString("Tooltips.Home"),
|
tooltip: $.getString("Tooltips.Home"),
|
||||||
srcRest: resolveUrl(this.urlPrefix, navImages.home.REST),
|
srcRest: resolveUrl(this.urlPrefix, navImages.home.REST),
|
||||||
srcGroup: resolveUrl(this.urlPrefix, navImages.home.GROUP),
|
srcGroup: resolveUrl(this.urlPrefix, navImages.home.GROUP),
|
||||||
srcHover: resolveUrl(this.urlPrefix, navImages.home.HOVER),
|
srcHover: resolveUrl(this.urlPrefix, navImages.home.HOVER),
|
||||||
@ -253,7 +255,7 @@ $.Viewer = function( options ) {
|
|||||||
});
|
});
|
||||||
var fullPage = new $.Button({
|
var fullPage = new $.Button({
|
||||||
config: this.config,
|
config: this.config,
|
||||||
tooltip: $.Strings.getString("Tooltips.FullPage"),
|
tooltip: $.getString("Tooltips.FullPage"),
|
||||||
srcRest: resolveUrl(this.urlPrefix, navImages.fullpage.REST),
|
srcRest: resolveUrl(this.urlPrefix, navImages.fullpage.REST),
|
||||||
srcGroup: resolveUrl(this.urlPrefix, navImages.fullpage.GROUP),
|
srcGroup: resolveUrl(this.urlPrefix, navImages.fullpage.GROUP),
|
||||||
srcHover: resolveUrl(this.urlPrefix, navImages.fullpage.HOVER),
|
srcHover: resolveUrl(this.urlPrefix, navImages.fullpage.HOVER),
|
||||||
@ -372,7 +374,7 @@ $.extend($.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
|
|
||||||
window.setTimeout( function () {
|
window.setTimeout( function () {
|
||||||
if ( _this._lastOpenStartTime > _this._lastOpenEndTime ) {
|
if ( _this._lastOpenStartTime > _this._lastOpenEndTime ) {
|
||||||
_this._setMessage( $.Strings.getString( "Messages.Loading" ) );
|
_this._setMessage( $.getString( "Messages.Loading" ) );
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
|
@ -1,35 +1,48 @@
|
|||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
$.Viewport = function(containerSize, contentSize, config) {
|
$.Viewport = function( options ) {
|
||||||
|
|
||||||
|
var options;
|
||||||
|
|
||||||
|
if( arguments.length && arguments[ 0 ] instanceof $.Point ){
|
||||||
|
options = {
|
||||||
|
containerSize: arguments[ 0 ],
|
||||||
|
contentSize: arguments[ 1 ],
|
||||||
|
config: arguments[ 2 ]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
options = arguments[ 0 ];
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: this.config is something that should go away but currently the
|
//TODO: this.config is something that should go away but currently the
|
||||||
// Drawer references the viewport.config
|
// Drawer references the viewport.config
|
||||||
this.config = config;
|
this.config = options.config;
|
||||||
this.zoomPoint = null;
|
this.zoomPoint = null;
|
||||||
this.containerSize = containerSize;
|
this.containerSize = options.containerSize;
|
||||||
this.contentSize = contentSize;
|
this.contentSize = options.contentSize;
|
||||||
this.contentAspect = contentSize.x / contentSize.y;
|
this.contentAspect = this.contentSize.x / this.contentSize.y;
|
||||||
this.contentHeight = contentSize.y / contentSize.x;
|
this.contentHeight = this.contentSize.y / this.contentSize.x;
|
||||||
this.centerSpringX = new $.Spring({
|
this.centerSpringX = new $.Spring({
|
||||||
initial: 0,
|
initial: 0,
|
||||||
springStiffness: config.springStiffness,
|
springStiffness: this.config.springStiffness,
|
||||||
animationTime: config.animationTime
|
animationTime: this.config.animationTime
|
||||||
});
|
});
|
||||||
this.centerSpringY = new $.Spring({
|
this.centerSpringY = new $.Spring({
|
||||||
initial: 0,
|
initial: 0,
|
||||||
springStiffness: config.springStiffness,
|
springStiffness: this.config.springStiffness,
|
||||||
animationTime: config.animationTime
|
animationTime: this.config.animationTime
|
||||||
});
|
});
|
||||||
this.zoomSpring = new $.Spring({
|
this.zoomSpring = new $.Spring({
|
||||||
initial: 1,
|
initial: 1,
|
||||||
springStiffness: config.springStiffness,
|
springStiffness: this.config.springStiffness,
|
||||||
animationTime: config.animationTime
|
animationTime: this.config.animationTime
|
||||||
});
|
});
|
||||||
this.minZoomImageRatio = config.minZoomImageRatio;
|
this.minZoomImageRatio = this.config.minZoomImageRatio;
|
||||||
this.maxZoomPixelRatio = config.maxZoomPixelRatio;
|
this.maxZoomPixelRatio = this.config.maxZoomPixelRatio;
|
||||||
this.visibilityRatio = config.visibilityRatio;
|
this.visibilityRatio = this.config.visibilityRatio;
|
||||||
this.wrapHorizontal = config.wrapHorizontal;
|
this.wrapHorizontal = this.config.wrapHorizontal;
|
||||||
this.wrapVertical = config.wrapVertical;
|
this.wrapVertical = this.config.wrapVertical;
|
||||||
this.homeBounds = new $.Rect( 0, 0, 1, this.contentHeight );
|
this.homeBounds = new $.Rect( 0, 0, 1, this.contentHeight );
|
||||||
this.goHome( true );
|
this.goHome( true );
|
||||||
this.update();
|
this.update();
|
||||||
|
Loading…
Reference in New Issue
Block a user