mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +03:00
finsihed removing psuedo private methods from Drawer and added many jsdoc strings, labeled 0.8.26
This commit is contained in:
parent
012255d622
commit
2410b01943
@ -6,7 +6,7 @@
|
|||||||
PROJECT: openseadragon
|
PROJECT: openseadragon
|
||||||
BUILD_MAJOR: 0
|
BUILD_MAJOR: 0
|
||||||
BUILD_MINOR: 8
|
BUILD_MINOR: 8
|
||||||
BUILD_ID: 24
|
BUILD_ID: 26
|
||||||
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}
|
||||||
|
|
||||||
|
2215
openseadragon.js
2215
openseadragon.js
File diff suppressed because it is too large
Load Diff
@ -18,12 +18,34 @@ $.ButtonState = {
|
|||||||
* as fading the bottons out when the user has not interacted with them
|
* as fading the bottons out when the user has not interacted with them
|
||||||
* for a specified period.
|
* for a specified period.
|
||||||
* @class
|
* @class
|
||||||
|
* @extends OpenSeadragon.EventHandler
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
* @param {String} options.tooltip
|
* @param {String} options.tooltip Provides context help for the button we the
|
||||||
|
* user hovers over it.
|
||||||
* @param {String} options.srcRest URL of image to use in 'rest' state
|
* @param {String} options.srcRest URL of image to use in 'rest' state
|
||||||
* @param {String} options.srcGroup URL of image to use in 'up' state
|
* @param {String} options.srcGroup URL of image to use in 'up' state
|
||||||
* @param {String} options.srcHover URL of image to use in 'hover' state
|
* @param {String} options.srcHover URL of image to use in 'hover' state
|
||||||
* @param {String} options.srcDown URL of image to use in 'domn' state
|
* @param {String} options.srcDown URL of image to use in 'domn' state
|
||||||
|
* @param {Element} [options.element] Element to use as a container for the
|
||||||
|
* button.
|
||||||
|
* @property {String} tooltip Provides context help for the button we the
|
||||||
|
* user hovers over it.
|
||||||
|
* @property {String} srcRest URL of image to use in 'rest' state
|
||||||
|
* @property {String} srcGroup URL of image to use in 'up' state
|
||||||
|
* @property {String} srcHover URL of image to use in 'hover' state
|
||||||
|
* @property {String} srcDown URL of image to use in 'domn' state
|
||||||
|
* @property {Object} config Configurable settings for this button.
|
||||||
|
* @property {Element} [element] Element to use as a container for the
|
||||||
|
* button.
|
||||||
|
* @property {Number} fadeDelay How long to wait before fading
|
||||||
|
* @property {Number} fadeLength How long should it take to fade the button.
|
||||||
|
* @property {Number} fadeBeginTime When the button last began to fade.
|
||||||
|
* @property {Boolean} shouldFade Whether this button should fade after user
|
||||||
|
* stops interacting with the viewport.
|
||||||
|
this.fadeDelay = 0; // begin fading immediately
|
||||||
|
this.fadeLength = 2000; // fade over a period of 2 seconds
|
||||||
|
this.fadeBeginTime = null;
|
||||||
|
this.shouldFade = false;
|
||||||
*/
|
*/
|
||||||
$.Button = function( options ) {
|
$.Button = function( options ) {
|
||||||
|
|
||||||
@ -36,6 +58,7 @@ $.Button = function( options ) {
|
|||||||
this.srcGroup = options.srcGroup;
|
this.srcGroup = options.srcGroup;
|
||||||
this.srcHover = options.srcHover;
|
this.srcHover = options.srcHover;
|
||||||
this.srcDown = options.srcDown;
|
this.srcDown = options.srcDown;
|
||||||
|
|
||||||
//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.
|
||||||
@ -159,10 +182,22 @@ $.Button = function( options ) {
|
|||||||
|
|
||||||
$.extend( $.Button.prototype, $.EventHandler.prototype, {
|
$.extend( $.Button.prototype, $.EventHandler.prototype, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Determine what this function is intended to do and if it's actually
|
||||||
|
* useful as an API point.
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Button.prototype.notifyGroupEnter
|
||||||
|
*/
|
||||||
notifyGroupEnter: function() {
|
notifyGroupEnter: function() {
|
||||||
inTo( this, $.ButtonState.GROUP );
|
inTo( this, $.ButtonState.GROUP );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Determine what this function is intended to do and if it's actually
|
||||||
|
* useful as an API point.
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Button.prototype.notifyGroupExit
|
||||||
|
*/
|
||||||
notifyGroupExit: function() {
|
notifyGroupExit: function() {
|
||||||
outTo( this, $.ButtonState.REST );
|
outTo( this, $.ButtonState.REST );
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
/**
|
/**
|
||||||
* @class
|
|
||||||
*
|
|
||||||
* Manages events on groups of buttons.
|
* Manages events on groups of buttons.
|
||||||
*
|
* @class
|
||||||
* options: {
|
* @param {Object} options - a dictionary of settings applied against the entire
|
||||||
* buttons: Array of buttons * required,
|
* group of buttons
|
||||||
* group: Element to use as the container,
|
* @param {Array} options.buttons Array of buttons
|
||||||
* config: Object with Viewer settings ( TODO: is this actually used anywhere? )
|
* @param {Element} [options.group] Element to use as the container,
|
||||||
* enter: Function callback for when the mouse enters group
|
* @param {Object} options.config Object with Viewer settings ( TODO: is
|
||||||
* exit: Function callback for when mouse leaves the group
|
* this actually used anywhere? )
|
||||||
* release: Function callback for when mouse is released
|
* @param {Function} [options.enter] Function callback for when the mouse
|
||||||
* }
|
* enters group
|
||||||
|
* @param {Function} [options.exit] Function callback for when mouse leaves
|
||||||
|
* the group
|
||||||
|
* @param {Function} [options.release] Function callback for when mouse is
|
||||||
|
* released
|
||||||
|
* @property {Array} buttons - An array containing the buttons themselves.
|
||||||
|
* @property {Element} element - The shared container for the buttons.
|
||||||
|
* @property {Object} config - Configurable settings for the group of buttons.
|
||||||
|
* @property {OpenSeadragon.MouseTracker} tracker - Tracks mouse events accross
|
||||||
|
* the group of buttons.
|
||||||
**/
|
**/
|
||||||
$.ButtonGroup = function( options ) {
|
$.ButtonGroup = function( options ) {
|
||||||
|
|
||||||
@ -68,10 +75,22 @@ $.ButtonGroup = function( options ) {
|
|||||||
|
|
||||||
$.ButtonGroup.prototype = {
|
$.ButtonGroup.prototype = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Figure out why this is used on the public API and if a more useful
|
||||||
|
* api can be created.
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.ButtonGroup.prototype.emulateEnter
|
||||||
|
*/
|
||||||
emulateEnter: function() {
|
emulateEnter: function() {
|
||||||
this.tracker.enter();
|
this.tracker.enter();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Figure out why this is used on the public API and if a more useful
|
||||||
|
* api can be created.
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.ButtonGroup.prototype.emulateExit
|
||||||
|
*/
|
||||||
emulateExit: function() {
|
emulateExit: function() {
|
||||||
this.tracker.exit();
|
this.tracker.exit();
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,19 @@
|
|||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A display rectanlge is very similar to the OpenSeadragon.Rect but adds two
|
||||||
|
* fields, 'minLevel' and 'maxLevel' which denote the supported zoom levels
|
||||||
|
* for this rectangle.
|
||||||
* @class
|
* @class
|
||||||
|
* @extends OpenSeadragon.Rect
|
||||||
|
* @param {Number} x The vector component 'x'.
|
||||||
|
* @param {Number} y The vector component 'y'.
|
||||||
|
* @param {Number} width The vector component 'height'.
|
||||||
|
* @param {Number} height The vector component 'width'.
|
||||||
|
* @param {Number} minLevel The lowest zoom level supported.
|
||||||
|
* @param {Number} maxLevel The highest zoom level supported.
|
||||||
|
* @property {Number} minLevel The lowest zoom level supported.
|
||||||
|
* @property {Number} maxLevel The highest zoom level supported.
|
||||||
*/
|
*/
|
||||||
$.DisplayRect = function( x, y, width, height, minLevel, maxLevel ) {
|
$.DisplayRect = function( x, y, width, height, minLevel, maxLevel ) {
|
||||||
$.Rect.apply( this, [ x, y, width, height ] );
|
$.Rect.apply( this, [ x, y, width, height ] );
|
||||||
|
1240
src/drawer.js
1240
src/drawer.js
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,17 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
|
* @extends OpenSeadragon.TileSource
|
||||||
|
* @param {Number} width
|
||||||
|
* @param {Number} height
|
||||||
|
* @param {Number} tileSize
|
||||||
|
* @param {Number} tileOverlap
|
||||||
|
* @param {String} tilesUrl
|
||||||
|
* @param {String} fileFormat
|
||||||
|
* @param {OpenSeadragon.DisplayRect[]} displayRects
|
||||||
|
* @property {String} tilesUrl
|
||||||
|
* @property {String} fileFormat
|
||||||
|
* @property {OpenSeadragon.DisplayRect[]} displayRects
|
||||||
*/
|
*/
|
||||||
$.DziTileSource = function( width, height, tileSize, tileOverlap, tilesUrl, fileFormat, displayRects ) {
|
$.DziTileSource = function( width, height, tileSize, tileOverlap, tilesUrl, fileFormat, displayRects ) {
|
||||||
var i,
|
var i,
|
||||||
@ -32,10 +43,24 @@ $.DziTileSource = function( width, height, tileSize, tileOverlap, tilesUrl, file
|
|||||||
|
|
||||||
$.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
|
$.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.DziTileSource.prototype.getTileUrl
|
||||||
|
* @param {Number} level
|
||||||
|
* @param {Number} x
|
||||||
|
* @param {Number} y
|
||||||
|
*/
|
||||||
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( '' );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.DziTileSource.prototype.tileExists
|
||||||
|
* @param {Number} level
|
||||||
|
* @param {Number} x
|
||||||
|
* @param {Number} y
|
||||||
|
*/
|
||||||
tileExists: function( level, x, y ) {
|
tileExists: function( level, x, y ) {
|
||||||
var rects = this._levelRects[ level ],
|
var rects = this._levelRects[ level ],
|
||||||
rect,
|
rect,
|
||||||
@ -77,185 +102,6 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
$.DziTileSourceHelper = {
|
|
||||||
|
|
||||||
createFromXml: function( xmlUrl, xmlString, callback ) {
|
|
||||||
var async = typeof (callback) == "function",
|
|
||||||
error = null,
|
|
||||||
urlParts,
|
|
||||||
filename,
|
|
||||||
lastDot,
|
|
||||||
tilesUrl,
|
|
||||||
handler;
|
|
||||||
|
|
||||||
if ( !xmlUrl ) {
|
|
||||||
this.error = $.getString( "Errors.Empty" );
|
|
||||||
if ( async ) {
|
|
||||||
window.setTimeout( function() {
|
|
||||||
callback( null, error );
|
|
||||||
}, 1 );
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
throw new Error( error );
|
|
||||||
}
|
|
||||||
|
|
||||||
urlParts = xmlUrl.split( '/' );
|
|
||||||
filename = urlParts[ urlParts.length - 1 ];
|
|
||||||
lastDot = filename.lastIndexOf( '.' );
|
|
||||||
|
|
||||||
if ( lastDot > -1 ) {
|
|
||||||
urlParts[ urlParts.length - 1 ] = filename.slice( 0, lastDot );
|
|
||||||
}
|
|
||||||
|
|
||||||
tilesUrl = urlParts.join( '/' ) + "_files/";
|
|
||||||
|
|
||||||
function finish( func, obj ) {
|
|
||||||
try {
|
|
||||||
return func( obj, tilesUrl );
|
|
||||||
} catch ( e ) {
|
|
||||||
if ( async ) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( async ) {
|
|
||||||
if ( xmlString ) {
|
|
||||||
handler = $.delegate( this, this.processXml );
|
|
||||||
window.setTimeout( function() {
|
|
||||||
var source = finish( handler, $.parseXml( xmlString ) );
|
|
||||||
// call after finish sets error
|
|
||||||
callback( source, error );
|
|
||||||
}, 1);
|
|
||||||
} else {
|
|
||||||
handler = $.delegate( this, this.processResponse );
|
|
||||||
$.makeAjaxRequest( xmlUrl, function( xhr ) {
|
|
||||||
var source = finish( handler, xhr );
|
|
||||||
// call after finish sets error
|
|
||||||
callback( source, error );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( xmlString ) {
|
|
||||||
return finish(
|
|
||||||
$.delegate( this, this.processXml ),
|
|
||||||
$.parseXml( xmlString )
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return finish(
|
|
||||||
$.delegate( this, this.processResponse ),
|
|
||||||
$.makeAjaxRequest( xmlUrl )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
processResponse: function( xhr, tilesUrl ) {
|
|
||||||
var status,
|
|
||||||
statusText,
|
|
||||||
doc = null;
|
|
||||||
|
|
||||||
if ( !xhr ) {
|
|
||||||
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 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( xhr.responseXML && xhr.responseXML.documentElement ) {
|
|
||||||
doc = xhr.responseXML;
|
|
||||||
} else if ( xhr.responseText ) {
|
|
||||||
doc = $.parseXml( xhr.responseText );
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.processXml( doc, tilesUrl );
|
|
||||||
},
|
|
||||||
|
|
||||||
processXml: function( xmlDoc, tilesUrl ) {
|
|
||||||
|
|
||||||
if ( !xmlDoc || !xmlDoc.documentElement ) {
|
|
||||||
throw new Error( $.getString( "Errors.Xml" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
var root = xmlDoc.documentElement,
|
|
||||||
rootName = root.tagName;
|
|
||||||
|
|
||||||
if ( rootName == "Image" ) {
|
|
||||||
try {
|
|
||||||
return this.processDzi( root, tilesUrl );
|
|
||||||
} catch ( e ) {
|
|
||||||
throw (e instanceof Error) ?
|
|
||||||
e :
|
|
||||||
new Error( $.getString("Errors.Dzi") );
|
|
||||||
}
|
|
||||||
} else if ( rootName == "Collection" ) {
|
|
||||||
throw new Error( $.getString( "Errors.Dzc" ) );
|
|
||||||
} else if ( rootName == "Error" ) {
|
|
||||||
return this.processError( root );
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error( $.getString( "Errors.Dzi" ) );
|
|
||||||
},
|
|
||||||
|
|
||||||
processDzi: function( imageNode, tilesUrl ) {
|
|
||||||
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 ) ) {
|
|
||||||
throw new Error(
|
|
||||||
$.getString( "Errors.ImageFormat", fileFormat.toUpperCase() )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( i = 0; i < dispRectNodes.length; i++ ) {
|
|
||||||
dispRectNode = dispRectNodes[ i ];
|
|
||||||
rectNode = dispRectNode.getElementsByTagName( "Rect" )[ 0 ];
|
|
||||||
|
|
||||||
dispRects.push( new $.DisplayRect(
|
|
||||||
parseInt( rectNode.getAttribute( "X" ) ),
|
|
||||||
parseInt( rectNode.getAttribute( "Y" ) ),
|
|
||||||
parseInt( rectNode.getAttribute( "Width" ) ),
|
|
||||||
parseInt( rectNode.getAttribute( "Height" ) ),
|
|
||||||
0, // ignore MinLevel attribute, bug in Deep Zoom Composer
|
|
||||||
parseInt( dispRectNode.getAttribute( "MaxLevel" ) )
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return new $.DziTileSource(
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
tileSize,
|
|
||||||
tileOverlap,
|
|
||||||
tilesUrl,
|
|
||||||
fileFormat,
|
|
||||||
dispRects
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
processError: function( errorNode ) {
|
|
||||||
var messageNode = errorNode.getElementsByTagName( "Message" )[ 0 ],
|
|
||||||
message = messageNode.firstChild.nodeValue;
|
|
||||||
|
|
||||||
throw new Error(message);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}( OpenSeadragon ));
|
||||||
|
@ -391,25 +391,11 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* Determines the position of the upper-left corner of the element.
|
||||||
* @name OpenSeadragon.getOffsetParent
|
|
||||||
* @param {Element} element
|
|
||||||
* @param {Boolean} [isFixed]
|
|
||||||
* @returns {Element}
|
|
||||||
*/
|
|
||||||
getOffsetParent: function( element, isFixed ) {
|
|
||||||
if ( isFixed && element != document.body ) {
|
|
||||||
return document.body;
|
|
||||||
} else {
|
|
||||||
return element.offsetParent;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.getElementPosition
|
* @name OpenSeadragon.getElementPosition
|
||||||
* @param {Element|String} element
|
* @param {Element|String} element - the elemenet we want the position for.
|
||||||
* @returns {Point}
|
* @returns {Point} - the position of the upper left corner of the element.
|
||||||
*/
|
*/
|
||||||
getElementPosition: function( element ) {
|
getElementPosition: function( element ) {
|
||||||
var result = new $.Point(),
|
var result = new $.Point(),
|
||||||
@ -418,7 +404,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
|
|
||||||
element = $.getElement( element );
|
element = $.getElement( element );
|
||||||
isFixed = $.getElementStyle( element ).position == "fixed";
|
isFixed = $.getElementStyle( element ).position == "fixed";
|
||||||
offsetParent = $.getOffsetParent( element, isFixed );
|
offsetParent = getOffsetParent( element, isFixed );
|
||||||
|
|
||||||
while ( offsetParent ) {
|
while ( offsetParent ) {
|
||||||
|
|
||||||
@ -431,13 +417,14 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
|
|
||||||
element = offsetParent;
|
element = offsetParent;
|
||||||
isFixed = $.getElementStyle( element ).position == "fixed";
|
isFixed = $.getElementStyle( element ).position == "fixed";
|
||||||
offsetParent = $.getOffsetParent( element, isFixed );
|
offsetParent = getOffsetParent( element, isFixed );
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Determines the height and width of the given element.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.getElementSize
|
* @name OpenSeadragon.getElementSize
|
||||||
* @param {Element|String} element
|
* @param {Element|String} element
|
||||||
@ -453,6 +440,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns the CSSStyle object for the given element.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.getElementStyle
|
* @name OpenSeadragon.getElementStyle
|
||||||
* @param {Element|String} element
|
* @param {Element|String} element
|
||||||
@ -471,6 +459,9 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the latest event, really only useful internally since its
|
||||||
|
* specific to IE behavior. TODO: Deprecate this from the api and
|
||||||
|
* use it internally.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.getEvent
|
* @name OpenSeadragon.getEvent
|
||||||
* @param {Event} [event]
|
* @param {Event} [event]
|
||||||
@ -481,6 +472,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the position of the mouse on the screen for a given event.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.getMousePosition
|
* @name OpenSeadragon.getMousePosition
|
||||||
* @param {Event} [event]
|
* @param {Event} [event]
|
||||||
@ -513,6 +505,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Determines the pages current scroll position.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.getPageScroll
|
* @name OpenSeadragon.getPageScroll
|
||||||
* @returns {Point}
|
* @returns {Point}
|
||||||
@ -537,6 +530,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Determines the size of the browsers window.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.getWindowSize
|
* @name OpenSeadragon.getWindowSize
|
||||||
* @returns {Point}
|
* @returns {Point}
|
||||||
@ -562,18 +556,10 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @function
|
|
||||||
* @name OpenSeadragon.imageFormatSupported
|
|
||||||
* @param {String} [extension]
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
imageFormatSupported: function( extension ) {
|
|
||||||
extension = extension ? extension : "";
|
|
||||||
return !!FILEFORMATS[ extension.toLowerCase() ];
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Wraps the given element in a nest of divs so that the element can
|
||||||
|
* be easily centered.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.makeCenteredNode
|
* @name OpenSeadragon.makeCenteredNode
|
||||||
* @param {Element|String} element
|
* @param {Element|String} element
|
||||||
@ -617,6 +603,8 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates an easily positionable element of the given type that therefor
|
||||||
|
* serves as an excellent container element.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.makeNeutralElement
|
* @name OpenSeadragon.makeNeutralElement
|
||||||
* @param {String} tagName
|
* @param {String} tagName
|
||||||
@ -636,6 +624,9 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Ensures an image is loaded correctly to support alpha transparency.
|
||||||
|
* Generally only IE has issues doing this correctly for formats like
|
||||||
|
* png.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.makeTransparentImage
|
* @name OpenSeadragon.makeTransparentImage
|
||||||
* @param {String} src
|
* @param {String} src
|
||||||
@ -676,6 +667,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the opacity of the specified element.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.setElementOpacity
|
* @name OpenSeadragon.setElementOpacity
|
||||||
* @param {Element|String} element
|
* @param {Element|String} element
|
||||||
@ -723,6 +715,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Adds an event listener for the given element, eventName and handler.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.addEvent
|
* @name OpenSeadragon.addEvent
|
||||||
* @param {Element|String} element
|
* @param {Element|String} element
|
||||||
@ -751,6 +744,8 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Remove a given event listener for the given element, event type and
|
||||||
|
* handler.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.removeEvent
|
* @name OpenSeadragon.removeEvent
|
||||||
* @param {Element|String} element
|
* @param {Element|String} element
|
||||||
@ -779,6 +774,8 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Cancels the default browser behavior had the event propagated all
|
||||||
|
* the way up the DOM to the window object.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.cancelEvent
|
* @name OpenSeadragon.cancelEvent
|
||||||
* @param {Event} [event]
|
* @param {Event} [event]
|
||||||
@ -797,6 +794,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Stops the propagation of the event up the DOM.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.stopEvent
|
* @name OpenSeadragon.stopEvent
|
||||||
* @param {Event} [event]
|
* @param {Event} [event]
|
||||||
@ -812,11 +810,18 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Similar to OpenSeadragon.delegate, but it does not immediately call
|
||||||
|
* the method on the object, returning a function which can be called
|
||||||
|
* repeatedly to delegate the method. It also allows additonal arguments
|
||||||
|
* to be passed during construction which will be added during each
|
||||||
|
* invocation, and each invocation can add additional arguments as well.
|
||||||
|
*
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.createCallback
|
* @name OpenSeadragon.createCallback
|
||||||
* @param {Object} object
|
* @param {Object} object
|
||||||
* @param {Function} method
|
* @param {Function} method
|
||||||
* @param [args] any additional arguments are passed as arguments to the created callback
|
* @param [args] any additional arguments are passed as arguments to the
|
||||||
|
* created callback
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
createCallback: function( object, method ) {
|
createCallback: function( object, method ) {
|
||||||
@ -841,6 +846,7 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Retreives the value of a url parameter from the window.location string.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.getUrlParameter
|
* @name OpenSeadragon.getUrlParameter
|
||||||
* @param {String} key
|
* @param {String} key
|
||||||
@ -852,10 +858,12 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Makes an AJAX request.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.makeAjaxRequest
|
* @name OpenSeadragon.makeAjaxRequest
|
||||||
* @param {String} url
|
* @param {String} url - the url to request
|
||||||
* @param {Function} [callback]
|
* @param {Function} [callback] - a function to call when complete
|
||||||
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
makeAjaxRequest: function( url, callback ) {
|
makeAjaxRequest: function( url, callback ) {
|
||||||
var async = typeof( callback ) == "function",
|
var async = typeof( callback ) == "function",
|
||||||
@ -909,7 +917,7 @@ 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(
|
$.console.log(
|
||||||
"%s while making AJAX request: %s",
|
"%s while making AJAX request: %s",
|
||||||
e.name,
|
e.name,
|
||||||
e.message
|
e.message
|
||||||
@ -926,14 +934,252 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
return async ? null : request;
|
return async ? null : request;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a Deep Zoom Image description from a url or XML string and
|
||||||
|
* provides a callback hook for the resulting Document
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.createFromDZI
|
||||||
|
* @param {String} xmlUrl
|
||||||
|
* @param {String} xmlString
|
||||||
|
* @param {Function} callback
|
||||||
|
*/
|
||||||
|
createFromDZI: function( dzi, callback ) {
|
||||||
|
var async = typeof ( callback ) == "function",
|
||||||
|
xmlUrl = dzi.substring(0,1) != '<' ? dzi : null,
|
||||||
|
xmlString = xmlUrl ? null : dzi,
|
||||||
|
error = null,
|
||||||
|
urlParts,
|
||||||
|
filename,
|
||||||
|
lastDot,
|
||||||
|
tilesUrl;
|
||||||
|
|
||||||
|
|
||||||
|
if( xmlUrl ){
|
||||||
|
urlParts = xmlUrl.split( '/' );
|
||||||
|
filename = urlParts[ urlParts.length - 1 ];
|
||||||
|
lastDot = filename.lastIndexOf( '.' );
|
||||||
|
|
||||||
|
if ( lastDot > -1 ) {
|
||||||
|
urlParts[ urlParts.length - 1 ] = filename.slice( 0, lastDot );
|
||||||
|
}
|
||||||
|
|
||||||
|
tilesUrl = urlParts.join( '/' ) + "_files/";
|
||||||
|
}
|
||||||
|
|
||||||
|
function finish( func, obj ) {
|
||||||
|
try {
|
||||||
|
return func( obj, tilesUrl );
|
||||||
|
} catch ( e ) {
|
||||||
|
if ( async ) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( async ) {
|
||||||
|
if ( xmlString ) {
|
||||||
|
window.setTimeout( function() {
|
||||||
|
var source = finish( processDZIXml, parseXml( xmlString ) );
|
||||||
|
// call after finish sets error
|
||||||
|
callback( source, error );
|
||||||
|
}, 1);
|
||||||
|
} else {
|
||||||
|
$.makeAjaxRequest( xmlUrl, function( xhr ) {
|
||||||
|
var source = finish( processDZIResponse, xhr );
|
||||||
|
// call after finish sets error
|
||||||
|
callback( source, error );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( xmlString ) {
|
||||||
|
return finish(
|
||||||
|
processDZIXml,
|
||||||
|
parseXml( xmlString )
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return finish(
|
||||||
|
processDZIResponse,
|
||||||
|
$.makeAjaxRequest( xmlUrl )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* @function
|
||||||
|
* @param {Element} element
|
||||||
|
* @param {Boolean} [isFixed]
|
||||||
|
* @returns {Element}
|
||||||
|
*/
|
||||||
|
function getOffsetParent( element, isFixed ) {
|
||||||
|
if ( isFixed && element != document.body ) {
|
||||||
|
return document.body;
|
||||||
|
} else {
|
||||||
|
return element.offsetParent;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* @function
|
||||||
|
* @param {XMLHttpRequest} xhr
|
||||||
|
* @param {String} tilesUrl
|
||||||
|
*/
|
||||||
|
function processDZIResponse( xhr, tilesUrl ) {
|
||||||
|
var status,
|
||||||
|
statusText,
|
||||||
|
doc = null;
|
||||||
|
|
||||||
|
if ( !xhr ) {
|
||||||
|
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 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( xhr.responseXML && xhr.responseXML.documentElement ) {
|
||||||
|
doc = xhr.responseXML;
|
||||||
|
} else if ( xhr.responseText ) {
|
||||||
|
doc = parseXml( xhr.responseText );
|
||||||
|
}
|
||||||
|
|
||||||
|
return processDZIXml( doc, tilesUrl );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* @function
|
||||||
|
* @param {Document} xmlDoc
|
||||||
|
* @param {String} tilesUrl
|
||||||
|
*/
|
||||||
|
function processDZIXml( xmlDoc, tilesUrl ) {
|
||||||
|
|
||||||
|
if ( !xmlDoc || !xmlDoc.documentElement ) {
|
||||||
|
throw new Error( $.getString( "Errors.Xml" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
var root = xmlDoc.documentElement,
|
||||||
|
rootName = root.tagName;
|
||||||
|
|
||||||
|
if ( rootName == "Image" ) {
|
||||||
|
try {
|
||||||
|
return processDZI( root, tilesUrl );
|
||||||
|
} catch ( e ) {
|
||||||
|
throw (e instanceof Error) ?
|
||||||
|
e :
|
||||||
|
new Error( $.getString("Errors.Dzi") );
|
||||||
|
}
|
||||||
|
} else if ( rootName == "Collection" ) {
|
||||||
|
throw new Error( $.getString( "Errors.Dzc" ) );
|
||||||
|
} else if ( rootName == "Error" ) {
|
||||||
|
return processDZIError( root );
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error( $.getString( "Errors.Dzi" ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* @function
|
||||||
|
* @param {Element} imageNode
|
||||||
|
* @param {String} tilesUrl
|
||||||
|
*/
|
||||||
|
function processDZI( imageNode, tilesUrl ) {
|
||||||
|
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 ) ) {
|
||||||
|
throw new Error(
|
||||||
|
$.getString( "Errors.ImageFormat", fileFormat.toUpperCase() )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = 0; i < dispRectNodes.length; i++ ) {
|
||||||
|
dispRectNode = dispRectNodes[ i ];
|
||||||
|
rectNode = dispRectNode.getElementsByTagName( "Rect" )[ 0 ];
|
||||||
|
|
||||||
|
dispRects.push( new $.DisplayRect(
|
||||||
|
parseInt( rectNode.getAttribute( "X" ) ),
|
||||||
|
parseInt( rectNode.getAttribute( "Y" ) ),
|
||||||
|
parseInt( rectNode.getAttribute( "Width" ) ),
|
||||||
|
parseInt( rectNode.getAttribute( "Height" ) ),
|
||||||
|
0, // ignore MinLevel attribute, bug in Deep Zoom Composer
|
||||||
|
parseInt( dispRectNode.getAttribute( "MaxLevel" ) )
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return new $.DziTileSource(
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
tileSize,
|
||||||
|
tileOverlap,
|
||||||
|
tilesUrl,
|
||||||
|
fileFormat,
|
||||||
|
dispRects
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* @function
|
||||||
|
* @param {Document} errorNode
|
||||||
|
* @throws {Error}
|
||||||
|
*/
|
||||||
|
function processDZIError( errorNode ) {
|
||||||
|
var messageNode = errorNode.getElementsByTagName( "Message" )[ 0 ],
|
||||||
|
message = messageNode.firstChild.nodeValue;
|
||||||
|
|
||||||
|
throw new Error(message);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports whether the image format is supported for tiling in this
|
||||||
|
* version.
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* @function
|
||||||
|
* @param {String} [extension]
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
function imageFormatSupported( extension ) {
|
||||||
|
extension = extension ? extension : "";
|
||||||
|
return !!FILEFORMATS[ extension.toLowerCase() ];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses an XML string into a DOM Document.
|
* Parses an XML string into a DOM Document.
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.parseXml
|
* @name OpenSeadragon.parseXml
|
||||||
* @param {String} string
|
* @param {String} string
|
||||||
* @returns {Document}
|
* @returns {Document}
|
||||||
*/
|
*/
|
||||||
parseXml: function( string ) {
|
function parseXml( string ) {
|
||||||
//TODO: yet another example where we can determine the correct
|
//TODO: yet another example where we can determine the correct
|
||||||
// implementation once at start-up instead of everytime we use
|
// implementation once at start-up instead of everytime we use
|
||||||
// the function.
|
// the function.
|
||||||
@ -956,8 +1202,6 @@ OpenSeadragon = window.OpenSeadragon || (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return xmlDoc;
|
return xmlDoc;
|
||||||
}
|
};
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}( OpenSeadragon ));
|
||||||
|
70
src/point.js
70
src/point.js
@ -2,7 +2,14 @@
|
|||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A Point is really used as a 2-dimensional vector, equally useful for
|
||||||
|
* representing a point on a plane, or the height and width of a plane
|
||||||
|
* not requiring any other frame of reference.
|
||||||
* @class
|
* @class
|
||||||
|
* @param {Number} [x] The vector component 'x'. Defaults to the origin at 0.
|
||||||
|
* @param {Number} [y] The vector component 'y'. Defaults to the origin at 0.
|
||||||
|
* @property {Number} [x] The vector component 'x'.
|
||||||
|
* @property {Number} [y] The vector component 'y'.
|
||||||
*/
|
*/
|
||||||
$.Point = function( x, y ) {
|
$.Point = function( x, y ) {
|
||||||
this.x = typeof ( x ) == "number" ? x : 0;
|
this.x = typeof ( x ) == "number" ? x : 0;
|
||||||
@ -11,6 +18,13 @@ $.Point = function( x, y ) {
|
|||||||
|
|
||||||
$.Point.prototype = {
|
$.Point.prototype = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
plus: function( point ) {
|
plus: function( point ) {
|
||||||
return new $.Point(
|
return new $.Point(
|
||||||
this.x + point.x,
|
this.x + point.x,
|
||||||
@ -18,6 +32,13 @@ $.Point.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
minus: function( point ) {
|
minus: function( point ) {
|
||||||
return new $.Point(
|
return new $.Point(
|
||||||
this.x - point.x,
|
this.x - point.x,
|
||||||
@ -25,6 +46,13 @@ $.Point.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
times: function( factor ) {
|
times: function( factor ) {
|
||||||
return new $.Point(
|
return new $.Point(
|
||||||
this.x * factor,
|
this.x * factor,
|
||||||
@ -32,6 +60,13 @@ $.Point.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
divide: function( factor ) {
|
divide: function( factor ) {
|
||||||
return new $.Point(
|
return new $.Point(
|
||||||
this.x / factor,
|
this.x / factor,
|
||||||
@ -39,10 +74,24 @@ $.Point.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
negate: function() {
|
negate: function() {
|
||||||
return new $.Point( -this.x, -this.y );
|
return new $.Point( -this.x, -this.y );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
distanceTo: function( point ) {
|
distanceTo: function( point ) {
|
||||||
return Math.sqrt(
|
return Math.sqrt(
|
||||||
Math.pow( this.x - point.x, 2 ) +
|
Math.pow( this.x - point.x, 2 ) +
|
||||||
@ -50,10 +99,24 @@ $.Point.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
apply: function( func ) {
|
apply: function( func ) {
|
||||||
return new $.Point( func( this.x ), func( this.y ) );
|
return new $.Point( func( this.x ), func( this.y ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
equals: function( point ) {
|
equals: function( point ) {
|
||||||
return (
|
return (
|
||||||
point instanceof $.Point
|
point instanceof $.Point
|
||||||
@ -64,6 +127,13 @@ $.Point.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add another Point to this point and return a new Point.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Point} point The point to add vector components.
|
||||||
|
* @returns {OpenSeadragon.Point} A new point representing the sum of the
|
||||||
|
* vector components
|
||||||
|
*/
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return "(" + this.x + "," + this.y + ")";
|
return "(" + this.x + "," + this.y + ")";
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,20 @@
|
|||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A Rectangle really represents a 2x2 matrix where each row represents a
|
||||||
|
* 2 dimensional vector component, the first is (x,y) and the second is
|
||||||
|
* (width, height). The latter component implies the equation of a simple
|
||||||
|
* plane.
|
||||||
|
*
|
||||||
* @class
|
* @class
|
||||||
|
* @param {Number} x The vector component 'x'.
|
||||||
|
* @param {Number} y The vector component 'y'.
|
||||||
|
* @param {Number} width The vector component 'height'.
|
||||||
|
* @param {Number} height The vector component 'width'.
|
||||||
|
* @property {Number} x The vector component 'x'.
|
||||||
|
* @property {Number} y The vector component 'y'.
|
||||||
|
* @property {Number} width The vector component 'width'.
|
||||||
|
* @property {Number} height The vector component 'height'.
|
||||||
*/
|
*/
|
||||||
$.Rect = function( x, y, width, height ) {
|
$.Rect = function( x, y, width, height ) {
|
||||||
this.x = typeof ( x ) == "number" ? x : 0;
|
this.x = typeof ( x ) == "number" ? x : 0;
|
||||||
@ -12,14 +25,34 @@ $.Rect = function( x, y, width, height ) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.Rect.prototype = {
|
$.Rect.prototype = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The aspect ratio is simply the ratio of width to height.
|
||||||
|
* @function
|
||||||
|
* @returns {Number} The ratio of width to height.
|
||||||
|
*/
|
||||||
getAspectRatio: function() {
|
getAspectRatio: function() {
|
||||||
return this.width / this.height;
|
return this.width / this.height;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the coordinates of the upper-left corner of the rectanglea s a
|
||||||
|
* point.
|
||||||
|
* @function
|
||||||
|
* @returns {OpenSeadragon.Point} The coordinate of the upper-left corner of
|
||||||
|
* the rectangle.
|
||||||
|
*/
|
||||||
getTopLeft: function() {
|
getTopLeft: function() {
|
||||||
return new $.Point( this.x, this.y );
|
return new $.Point( this.x, this.y );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the coordinates of the bottom-right corner of the rectangle as a
|
||||||
|
* point.
|
||||||
|
* @function
|
||||||
|
* @returns {OpenSeadragon.Point} The coordinate of the bottom-right corner of
|
||||||
|
* the rectangle.
|
||||||
|
*/
|
||||||
getBottomRight: function() {
|
getBottomRight: function() {
|
||||||
return new $.Point(
|
return new $.Point(
|
||||||
this.x + this.width,
|
this.x + this.width,
|
||||||
@ -27,6 +60,12 @@ $.Rect.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the center of the rectangle.
|
||||||
|
* @function
|
||||||
|
* @returns {OpenSeadragon.Point} The center of the rectangle as represnted
|
||||||
|
* as represented by a 2-dimensional vector (x,y)
|
||||||
|
*/
|
||||||
getCenter: function() {
|
getCenter: function() {
|
||||||
return new $.Point(
|
return new $.Point(
|
||||||
this.x + this.width / 2.0,
|
this.x + this.width / 2.0,
|
||||||
@ -34,19 +73,36 @@ $.Rect.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the width and height component as a vector OpenSeadragon.Point
|
||||||
|
* @function
|
||||||
|
* @returns {OpenSeadragon.Point} The 2 dimensional vector represnting the
|
||||||
|
* the width and height of the rectangle.
|
||||||
|
*/
|
||||||
getSize: function() {
|
getSize: function() {
|
||||||
return new $.Point( this.width, this.height );
|
return new $.Point( this.width, this.height );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if two Rectanlges have equivalent components.
|
||||||
|
* @function
|
||||||
|
* @param {OpenSeadragon.Rect} rectangle The Rectangle to compare to.
|
||||||
|
* @return {Boolean} 'true' if all components are equal, otherwise 'false'.
|
||||||
|
*/
|
||||||
equals: function( other ) {
|
equals: function( other ) {
|
||||||
return
|
return ( other instanceof $.Rect ) &&
|
||||||
( other instanceof $.Rect ) &&
|
|
||||||
( this.x === other.x ) &&
|
( this.x === other.x ) &&
|
||||||
( this.y === other.y ) &&
|
( this.y === other.y ) &&
|
||||||
( this.width === other.width ) &&
|
( this.width === other.width ) &&
|
||||||
( this.height === other.height );
|
( this.height === other.height );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a string representation of the retangle which is useful for
|
||||||
|
* debugging.
|
||||||
|
* @function
|
||||||
|
* @returns {String} A string representation of the rectangle.
|
||||||
|
*/
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return "[" +
|
return "[" +
|
||||||
this.x + "," +
|
this.x + "," +
|
||||||
@ -57,4 +113,5 @@ $.Rect.prototype = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}( OpenSeadragon ));
|
||||||
|
82
src/tile.js
82
src/tile.js
@ -3,38 +3,79 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
|
* @param {Number} level The zoom level this tile belongs to.
|
||||||
|
* @param {Number} x The vector component 'x'.
|
||||||
|
* @param {Number} y The vector component 'y'.
|
||||||
|
* @param {OpenSeadragon.Point} bounds Where this tile fits, in normalized
|
||||||
|
* coordinates
|
||||||
|
* @param {Boolean} exists Is this tile a part of a sparse image? ( Also has
|
||||||
|
* this tile failed to load?
|
||||||
|
* @param {String} url The URL of this tile's image.
|
||||||
|
*
|
||||||
|
* @property {Number} level The zoom level this tile belongs to.
|
||||||
|
* @property {Number} x The vector component 'x'.
|
||||||
|
* @property {Number} y The vector component 'y'.
|
||||||
|
* @property {OpenSeadragon.Point} bounds Where this tile fits, in normalized
|
||||||
|
* coordinates
|
||||||
|
* @property {Boolean} exists Is this tile a part of a sparse image? ( Also has
|
||||||
|
* this tile failed to load?
|
||||||
|
* @property {String} url The URL of this tile's image.
|
||||||
|
* @property {Boolean} loaded Is this tile loaded?
|
||||||
|
* @property {Boolean} loading Is this tile loading
|
||||||
|
* @property {Element} elmt The HTML element for this tile
|
||||||
|
* @property {Image} image The Image object for this tile
|
||||||
|
* @property {String} style The alias of this.elmt.style.
|
||||||
|
* @property {String} position This tile's position on screen, in pixels.
|
||||||
|
* @property {String} size This tile's size on screen, in pixels
|
||||||
|
* @property {String} blendStart The start time of this tile's blending
|
||||||
|
* @property {String} opacity The current opacity this tile should be.
|
||||||
|
* @property {String} distance The distance of this tile to the viewport center
|
||||||
|
* @property {String} visibility The visibility score of this tile.
|
||||||
|
* @property {Boolean} beingDrawn Whether this tile is currently being drawn
|
||||||
|
* @property {Number} lastTouchTime Timestamp the tile was last touched.
|
||||||
*/
|
*/
|
||||||
$.Tile = function(level, x, y, bounds, exists, url) {
|
$.Tile = function(level, x, y, bounds, exists, url) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.bounds = bounds; // where this tile fits, in normalized coordinates
|
this.bounds = bounds;
|
||||||
this.exists = exists; // part of sparse image? tile hasn't failed to load?
|
this.exists = exists;
|
||||||
this.loaded = false; // is this tile loaded?
|
this.url = url;
|
||||||
this.loading = false; // or is this tile loading?
|
this.loaded = false;
|
||||||
|
this.loading = false;
|
||||||
|
|
||||||
this.elmt = null; // the HTML element for this tile
|
this.elmt = null;
|
||||||
this.image = null; // the Image object for this tile
|
this.image = null;
|
||||||
this.url = url; // the URL of this tile's image
|
|
||||||
|
|
||||||
this.style = null; // alias of this.elmt.style
|
this.style = null;
|
||||||
this.position = null; // this tile's position on screen, in pixels
|
this.position = null;
|
||||||
this.size = null; // this tile's size on screen, in pixels
|
this.size = null;
|
||||||
this.blendStart = null; // the start time of this tile's blending
|
this.blendStart = null;
|
||||||
this.opacity = null; // the current opacity this tile should be
|
this.opacity = null;
|
||||||
this.distance = null; // the distance of this tile to the viewport center
|
this.distance = null;
|
||||||
this.visibility = null; // the visibility score of this tile
|
this.visibility = null;
|
||||||
|
|
||||||
this.beingDrawn = false; // whether this tile is currently being drawn
|
this.beingDrawn = false;
|
||||||
this.lastTouchTime = 0; // the time that tile was last touched
|
this.lastTouchTime = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
$.Tile.prototype = {
|
$.Tile.prototype = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a string representation of this tiles level and (x,y)
|
||||||
|
* components.
|
||||||
|
* @function
|
||||||
|
* @returns {String}
|
||||||
|
*/
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return this.level + "/" + this.x + "_" + this.y;
|
return this.level + "/" + this.x + "_" + this.y;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the tile in an html container.
|
||||||
|
* @function
|
||||||
|
* @param {Element} container
|
||||||
|
*/
|
||||||
drawHTML: function( container ) {
|
drawHTML: function( container ) {
|
||||||
|
|
||||||
var position = this.position.apply( Math.floor ),
|
var position = this.position.apply( Math.floor ),
|
||||||
@ -71,6 +112,11 @@ $.Tile.prototype = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the tile in a canvas-based context.
|
||||||
|
* @function
|
||||||
|
* @param {Canvas} context
|
||||||
|
*/
|
||||||
drawCanvas: function( context ) {
|
drawCanvas: function( context ) {
|
||||||
|
|
||||||
var position = this.position,
|
var position = this.position,
|
||||||
@ -88,6 +134,10 @@ $.Tile.prototype = {
|
|||||||
context.drawImage( this.image, position.x, position.y, size.x, size.y );
|
context.drawImage( this.image, position.x, position.y, size.x, size.y );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes tile from it's contianer.
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
unload: function() {
|
unload: function() {
|
||||||
if ( this.elmt && this.elmt.parentNode ) {
|
if ( this.elmt && this.elmt.parentNode ) {
|
||||||
this.elmt.parentNode.removeChild( this.elmt );
|
this.elmt.parentNode.removeChild( this.elmt );
|
||||||
|
@ -4,6 +4,18 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
|
* @param {Number} width
|
||||||
|
* @param {Number} height
|
||||||
|
* @param {Number} tileSize
|
||||||
|
* @param {Number} tileOverlap
|
||||||
|
* @param {Number} minLevel
|
||||||
|
* @param {Number} maxLevel
|
||||||
|
* @property {Number} aspectRatio
|
||||||
|
* @property {Number} dimensions
|
||||||
|
* @property {Number} tileSize
|
||||||
|
* @property {Number} tileOverlap
|
||||||
|
* @property {Number} minLevel
|
||||||
|
* @property {Number} maxLevel
|
||||||
*/
|
*/
|
||||||
$.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLevel ) {
|
$.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLevel ) {
|
||||||
this.aspectRatio = width / height;
|
this.aspectRatio = width / height;
|
||||||
@ -20,10 +32,18 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
|||||||
|
|
||||||
$.TileSource.prototype = {
|
$.TileSource.prototype = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
*/
|
||||||
getLevelScale: function( level ) {
|
getLevelScale: function( level ) {
|
||||||
return 1 / ( 1 << ( this.maxLevel - level ) );
|
return 1 / ( 1 << ( this.maxLevel - level ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
*/
|
||||||
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.tileSize ),
|
||||||
@ -32,6 +52,10 @@ $.TileSource.prototype = {
|
|||||||
return new $.Point( x, y );
|
return new $.Point( x, y );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
*/
|
||||||
getPixelRatio: function( level ) {
|
getPixelRatio: function( level ) {
|
||||||
var imageSizeScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
var imageSizeScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
||||||
rx = 1.0 / imageSizeScaled.x,
|
rx = 1.0 / imageSizeScaled.x,
|
||||||
@ -40,6 +64,11 @@ $.TileSource.prototype = {
|
|||||||
return new $.Point(rx, ry);
|
return new $.Point(rx, ry);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
* @param {OpenSeadragon.Point} point
|
||||||
|
*/
|
||||||
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.tileSize ),
|
||||||
@ -48,6 +77,12 @@ $.TileSource.prototype = {
|
|||||||
return new $.Point( tx, ty );
|
return new $.Point( tx, ty );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
* @param {Number} x
|
||||||
|
* @param {Number} y
|
||||||
|
*/
|
||||||
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,
|
px = ( x === 0 ) ? 0 : this.tileSize * x - this.tileOverlap,
|
||||||
@ -62,10 +97,27 @@ $.TileSource.prototype = {
|
|||||||
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
|
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is not implemented by this class other than to throw an Error
|
||||||
|
* announcing you have to implement it. Because of the variety of tile
|
||||||
|
* server technologies, and various specifications for building image
|
||||||
|
* pyramids, this method is here to allow easy integration.
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
* @param {Number} x
|
||||||
|
* @param {Number} y
|
||||||
|
* @throws {Error}
|
||||||
|
*/
|
||||||
getTileUrl: function( level, x, y ) {
|
getTileUrl: function( level, x, y ) {
|
||||||
throw new Error( "Method not implemented." );
|
throw new Error( "Method not implemented." );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
* @param {Number} x
|
||||||
|
* @param {Number} y
|
||||||
|
*/
|
||||||
tileExists: function( level, x, y ) {
|
tileExists: function( level, x, y ) {
|
||||||
var numTiles = this.getNumTiles( level );
|
var numTiles = this.getNumTiles( level );
|
||||||
return level >= this.minLevel &&
|
return level >= this.minLevel &&
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
/**
|
/**
|
||||||
* @class
|
|
||||||
*
|
*
|
||||||
* The main point of entry into creating a zoomable image on the page.
|
* The main point of entry into creating a zoomable image on the page.
|
||||||
*
|
*
|
||||||
@ -11,15 +10,17 @@
|
|||||||
* The options below are given in order that they appeared in the constructor
|
* The options below are given in order that they appeared in the constructor
|
||||||
* as arguments and we translate a positional call into an idiomatic call.
|
* as arguments and we translate a positional call into an idiomatic call.
|
||||||
*
|
*
|
||||||
* options:{
|
* @class
|
||||||
* element: String id of Element to attach to,
|
* @extends OpenSeadragon.EventHandler
|
||||||
* xmlPath: String xpath ( TODO: not sure! ),
|
* @param {Object} options
|
||||||
* prefixUrl: String url used to prepend to paths, eg button images,
|
* @param {String} options.element Id of Element to attach to,
|
||||||
* controls: Array of Seadragon.Controls,
|
* @param {String} options.xmlPath Xpath ( TODO: not sure! ),
|
||||||
* overlays: Array of Seadragon.Overlays,
|
* @param {String} options.prefixUrl Url used to prepend to paths, eg button
|
||||||
* overlayControls: An Array of ( TODO: not sure! )
|
* images, etc.
|
||||||
* }
|
* @param {Seadragon.Controls[]} options.controls Array of Seadragon.Controls,
|
||||||
*
|
* @param {Seadragon.Overlays[]} options.overlays Array of Seadragon.Overlays,
|
||||||
|
* @param {Seadragon.Controls[]} options.overlayControls An Array of ( TODO:
|
||||||
|
* not sure! )
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
$.Viewer = function( options ) {
|
$.Viewer = function( options ) {
|
||||||
@ -306,6 +307,10 @@ $.Viewer = function( options ) {
|
|||||||
|
|
||||||
$.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
$.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.addControl
|
||||||
|
*/
|
||||||
addControl: function ( elmt, anchor ) {
|
addControl: function ( elmt, anchor ) {
|
||||||
var elmt = $.getElement( elmt ),
|
var elmt = $.getElement( elmt ),
|
||||||
div = null;
|
div = null;
|
||||||
@ -344,21 +349,36 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
elmt.style.display = "inline-block";
|
elmt.style.display = "inline-block";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.isOpen
|
||||||
|
*/
|
||||||
isOpen: function () {
|
isOpen: function () {
|
||||||
return !!this.source;
|
return !!this.source;
|
||||||
},
|
},
|
||||||
|
|
||||||
openDzi: function ( xmlUrl, xmlString ) {
|
/**
|
||||||
|
* If the string is xml is simply parsed and opened, otherwise the string
|
||||||
|
* is treated as an URL and an xml document is requested via ajax, parsed
|
||||||
|
* and then opened in the viewer.
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.openDzi
|
||||||
|
* @param {String} dzi and xml string or the url to a DZI xml document.
|
||||||
|
*/
|
||||||
|
openDzi: function ( dzi ) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$.DziTileSourceHelper.createFromXml(
|
$.createFromDZI(
|
||||||
xmlUrl,
|
dzi,
|
||||||
xmlString,
|
|
||||||
function( source ){
|
function( source ){
|
||||||
_this.open( source );
|
_this.open( source );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.openTileSource
|
||||||
|
*/
|
||||||
openTileSource: function ( tileSource ) {
|
openTileSource: function ( tileSource ) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
window.setTimeout( function () {
|
window.setTimeout( function () {
|
||||||
@ -366,6 +386,10 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
}, 1 );
|
}, 1 );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.open
|
||||||
|
*/
|
||||||
open: function( source ) {
|
open: function( source ) {
|
||||||
var _this = this,
|
var _this = this,
|
||||||
overlay,
|
overlay,
|
||||||
@ -448,6 +472,10 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
this.raiseEvent( "open" );
|
this.raiseEvent( "open" );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.close
|
||||||
|
*/
|
||||||
close: function () {
|
close: function () {
|
||||||
this.source = null;
|
this.source = null;
|
||||||
this.viewport = null;
|
this.viewport = null;
|
||||||
@ -456,6 +484,10 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
this.canvas.innerHTML = "";
|
this.canvas.innerHTML = "";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.removeControl
|
||||||
|
*/
|
||||||
removeControl: function ( elmt ) {
|
removeControl: function ( elmt ) {
|
||||||
|
|
||||||
var elmt = $.getElement( elmt ),
|
var elmt = $.getElement( elmt ),
|
||||||
@ -467,12 +499,20 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.clearControls
|
||||||
|
*/
|
||||||
clearControls: function () {
|
clearControls: function () {
|
||||||
while ( this.controls.length > 0 ) {
|
while ( this.controls.length > 0 ) {
|
||||||
this.controls.pop().destroy();
|
this.controls.pop().destroy();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.isDashboardEnabled
|
||||||
|
*/
|
||||||
isDashboardEnabled: function () {
|
isDashboardEnabled: function () {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
@ -485,18 +525,34 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.isFullPage
|
||||||
|
*/
|
||||||
isFullPage: function () {
|
isFullPage: function () {
|
||||||
return this.container.parentNode == document.body;
|
return this.container.parentNode == document.body;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.isMouseNavEnabled
|
||||||
|
*/
|
||||||
isMouseNavEnabled: function () {
|
isMouseNavEnabled: function () {
|
||||||
return this.innerTracker.isTracking();
|
return this.innerTracker.isTracking();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.isVisible
|
||||||
|
*/
|
||||||
isVisible: function () {
|
isVisible: function () {
|
||||||
return this.container.style.visibility != "hidden";
|
return this.container.style.visibility != "hidden";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.setDashboardEnabled
|
||||||
|
*/
|
||||||
setDashboardEnabled: function( enabled ) {
|
setDashboardEnabled: function( enabled ) {
|
||||||
var i;
|
var i;
|
||||||
for ( i = this.controls.length - 1; i >= 0; i-- ) {
|
for ( i = this.controls.length - 1; i >= 0; i-- ) {
|
||||||
@ -504,6 +560,10 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.setFullPage
|
||||||
|
*/
|
||||||
setFullPage: function( fullPage ) {
|
setFullPage: function( fullPage ) {
|
||||||
|
|
||||||
var body = document.body,
|
var body = document.body,
|
||||||
@ -592,10 +652,18 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.setMouseNavEnabled
|
||||||
|
*/
|
||||||
setMouseNavEnabled: function( enabled ){
|
setMouseNavEnabled: function( enabled ){
|
||||||
this.innerTracker.setTracking( enabled );
|
this.innerTracker.setTracking( enabled );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.setVisible
|
||||||
|
*/
|
||||||
setVisible: function( visible ){
|
setVisible: function( visible ){
|
||||||
this.container.style.visibility = visible ? "" : "hidden";
|
this.container.style.visibility = visible ? "" : "hidden";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user