/src/openseadragon.js
JavaScript | 2472 lines | 1106 code | 272 blank | 1094 comment | 219 complexity | 53c050f174221960935c175fb6a8684c MD5 | raw file
Possible License(s): BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- /*
- * OpenSeadragon
- *
- * Copyright (C) 2009 CodePlex Foundation
- * Copyright (C) 2010-2013 OpenSeadragon contributors
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * - Neither the name of CodePlex Foundation nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- /*
- * Portions of this source file taken from jQuery:
- *
- * Copyright 2011 John Resig
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- /*
- * Portions of this source file taken from mattsnider.com:
- *
- * Copyright (c) 2006-2013 Matt Snider
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- /**
- * @version <%= pkg.name %> <%= pkg.version %>
- *
- * @file
- * <h2><strong>OpenSeadragon - Javascript Deep Zooming</strong></h2>
- * <p>
- * OpenSeadragon provides an html interface for creating
- * deep zoom user interfaces. The simplest examples include deep
- * zoom for large resolution images, and complex examples include
- * zoomable map interfaces driven by SVG files.
- * </p>
- *
- */
- /**
- * @module OpenSeadragon
- *
- */
- /**
- * @namespace OpenSeadragon
- *
- * @classdesc The root namespace for OpenSeadragon. All utility methods
- * and classes are defined on or below this namespace.
- *
- */
- // Typedefs
- /**
- * All required and optional settings for instantiating a new instance of an OpenSeadragon image viewer.
- *
- * @typedef {Object} Options
- * @memberof OpenSeadragon
- *
- * @property {String} id
- * Id of the element to append the viewer's container element to. If not provided, the 'element' property must be provided.
- * If both the element and id properties are specified, the viewer is appended to the element provided in the element property.
- *
- * @property {Element} element
- * The element to append the viewer's container element to. If not provided, the 'id' property must be provided.
- * If both the element and id properties are specified, the viewer is appended to the element provided in the element property.
- *
- * @property {Array|String|Function|Object[]|Array[]|String[]|Function[]} [tileSources=null]
- * As an Array, the tileSource can hold either Objects or mixed
- * types of Arrays of Objects, Strings, or Functions. When a value is a String,
- * the tileSource is used to create a {@link OpenSeadragon.DziTileSource}.
- * When a value is a Function, the function is used to create a new
- * {@link OpenSeadragon.TileSource} whose abstract method
- * getUrl( level, x, y ) is implemented by the function. Finally, when it
- * is an Array of objects, it is used to create a
- * {@link OpenSeadragon.LegacyTileSource}.
- *
- * @property {Array} overlays Array of objects defining permanent overlays of
- * the viewer. The overlays added via this option and later removed with
- * {@link OpenSeadragon.Viewer#removeOverlay} will be added back when a new
- * image is opened.
- * To add overlays which can be definitively removed, one must use
- * {@link OpenSeadragon.Viewer#addOverlay}
- * If displaying a sequence of images, the overlays can be associated
- * with a specific page by passing the overlays array to the page's
- * tile source configuration.
- * Expected properties:
- * * x, y, (or px, py for pixel coordinates) to define the location.
- * * width, height in point if using x,y or in pixels if using px,py. If width
- * and height are specified, the overlay size is adjusted when zooming,
- * otherwise the size stays the size of the content (or the size defined by CSS).
- * * className to associate a class to the overlay
- * * id to set the overlay element. If an element with this id already exists,
- * it is reused, otherwise it is created. If not specified, a new element is
- * created.
- * * placement a string to define the relative position to the viewport.
- * Only used if no width and height are specified. Default: 'TOP_LEFT'.
- * See {@link OpenSeadragon.OverlayPlacement} for possible values.
- *
- * @property {String} [xmlPath=null]
- * <strong>DEPRECATED</strong>. A relative path to load a DZI file from the server.
- * Prefer the newer Options.tileSources.
- *
- * @property {String} [prefixUrl='/images/']
- * Prepends the prefixUrl to navImages paths, which is very useful
- * since the default paths are rarely useful for production
- * environments.
- *
- * @property {OpenSeadragon.NavImages} [navImages]
- * An object with a property for each button or other built-in navigation
- * control, eg the current 'zoomIn', 'zoomOut', 'home', and 'fullpage'.
- * Each of those in turn provides an image path for each state of the button
- * or navigation control, eg 'REST', 'GROUP', 'HOVER', 'PRESS'. Finally the
- * image paths, by default assume there is a folder on the servers root path
- * called '/images', eg '/images/zoomin_rest.png'. If you need to adjust
- * these paths, prefer setting the option.prefixUrl rather than overriding
- * every image path directly through this setting.
- *
- * @property {Object} [tileHost=null]
- * TODO: Implement this. Currently not used.
- *
- * @property {Boolean} [debugMode=false]
- * TODO: provide an in-screen panel providing event detail feedback.
- *
- * @property {String} [debugGridColor='#437AB2']
- *
- * @property {Number} [blendTime=0]
- * Specifies the duration of animation as higher or lower level tiles are
- * replacing the existing tile.
- *
- * @property {Boolean} [alwaysBlend=false]
- * Forces the tile to always blend. By default the tiles skip blending
- * when the blendTime is surpassed and the current animation frame would
- * not complete the blend.
- *
- * @property {Boolean} [autoHideControls=true]
- * If the user stops interacting with the viewport, fade the navigation
- * controls. Useful for presentation since the controls are by default
- * floated on top of the image the user is viewing.
- *
- * @property {Boolean} [immediateRender=false]
- * Render the best closest level first, ignoring the lowering levels which
- * provide the effect of very blurry to sharp. It is recommended to change
- * setting to true for mobile devices.
- *
- * @property {Number} [defaultZoomLevel=0]
- * Zoom level to use when image is first opened or the home button is clicked.
- * If 0, adjusts to fit viewer.
- *
- * @property {Number} [opacity=1]
- * Opacity of the drawer (1=opaque, 0=transparent)
- *
- * @property {Number} [layersAspectRatioEpsilon=0.0001]
- * Maximum aspectRatio mismatch between 2 layers.
- *
- * @property {Number} [degrees=0]
- * Initial rotation.
- *
- * @property {Number} [minZoomLevel=null]
- *
- * @property {Number} [maxZoomLevel=null]
- *
- * @property {Boolean} [panHorizontal=true]
- * Allow horizontal pan.
- *
- * @property {Boolean} [panVertical=true]
- * Allow vertical pan.
- *
- * @property {Boolean} [constrainDuringPan=false]
- *
- * @property {Boolean} [wrapHorizontal=false]
- * Set to true to force the image to wrap horizontally within the viewport.
- * Useful for maps or images representing the surface of a sphere or cylinder.
- *
- * @property {Boolean} [wrapVertical=false]
- * Set to true to force the image to wrap vertically within the viewport.
- * Useful for maps or images representing the surface of a sphere or cylinder.
- *
- * @property {Number} [minZoomImageRatio=0.9]
- * The minimum percentage ( expressed as a number between 0 and 1 ) of
- * the viewport height or width at which the zoom out will be constrained.
- * Setting it to 0, for example will allow you to zoom out infinitly.
- *
- * @property {Number} [maxZoomPixelRatio=1.1]
- * The maximum ratio to allow a zoom-in to affect the highest level pixel
- * ratio. This can be set to Infinity to allow 'infinite' zooming into the
- * image though it is less effective visually if the HTML5 Canvas is not
- * availble on the viewing device.
- *
- * @property {Boolean} [autoResize=true]
- * Set to false to prevent polling for viewer size changes. Useful for providing custom resize behavior.
- *
- * @property {Number} [pixelsPerWheelLine=40]
- * For pixel-resolution scrolling devices, the number of pixels equal to one scroll line.
- *
- * @property {Number} [visibilityRatio=0.5]
- * The percentage ( as a number from 0 to 1 ) of the source image which
- * must be kept within the viewport. If the image is dragged beyond that
- * limit, it will 'bounce' back until the minimum visibility ration is
- * achieved. Setting this to 0 and wrapHorizontal ( or wrapVertical ) to
- * true will provide the effect of an infinitely scrolling viewport.
- *
- * @property {Number} [imageLoaderLimit=0]
- * The maximum number of image requests to make concurrently. By default
- * it is set to 0 allowing the browser to make the maximum number of
- * image requests in parallel as allowed by the browsers policy.
- *
- * @property {Number} [clickTimeThreshold=300]
- * If multiple mouse clicks occurs within less than this number of
- * milliseconds, treat them as a single click.
- *
- * @property {Number} [clickDistThreshold=5]
- * If a mouse or touch drag occurs and the distance to the starting drag
- * point is less than this many pixels, ignore the drag event.
- *
- * @property {Number} [springStiffness=5.0]
- *
- * @property {Number} [animationTime=1.2]
- * Specifies the animation duration per each {@link OpenSeadragon.Spring}
- * which occur when the image is dragged or zoomed.
- *
- * @property {OpenSeadragon.GestureSettings} [gestureSettingsMouse]
- * Settings for gestures generated by a mouse pointer device. (See {@link OpenSeadragon.GestureSettings})
- * @property {Boolean} [gestureSettingsMouse.scrollToZoom=true] - Zoom on scroll gesture
- * @property {Boolean} [gestureSettingsMouse.clickToZoom=true] - Zoom on click gesture
- * @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture
- * @property {Boolean} [gestureSettingsMouse.flickEnabled=false] - Enable flick gesture
- * @property {Number} [gestureSettingsMouse.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
- * @property {Number} [gestureSettingsMouse.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture
- *
- * @property {OpenSeadragon.GestureSettings} [gestureSettingsTouch]
- * Settings for gestures generated by a touch pointer device. (See {@link OpenSeadragon.GestureSettings})
- * @property {Boolean} [gestureSettingsTouch.scrollToZoom=false] - Zoom on scroll gesture
- * @property {Boolean} [gestureSettingsTouch.clickToZoom=false] - Zoom on click gesture
- * @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture
- * @property {Boolean} [gestureSettingsTouch.flickEnabled=true] - Enable flick gesture
- * @property {Number} [gestureSettingsTouch.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
- * @property {Number} [gestureSettingsTouch.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture
- *
- * @property {OpenSeadragon.GestureSettings} [gestureSettingsPen]
- * Settings for gestures generated by a pen pointer device. (See {@link OpenSeadragon.GestureSettings})
- * @property {Boolean} [gestureSettingsPen.scrollToZoom=false] - Zoom on scroll gesture
- * @property {Boolean} [gestureSettingsPen.clickToZoom=true] - Zoom on click gesture
- * @property {Boolean} [gestureSettingsPen.pinchToZoom=false] - Zoom on pinch gesture
- * @property {Boolean} [gestureSettingsPen.flickEnabled=false] - Enable flick gesture
- * @property {Number} [gestureSettingsPen.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
- * @property {Number} [gestureSettingsPen.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture
- *
- * @property {OpenSeadragon.GestureSettings} [gestureSettingsUnknown]
- * Settings for gestures generated by unknown pointer devices. (See {@link OpenSeadragon.GestureSettings})
- * @property {Boolean} [gestureSettingsUnknown.scrollToZoom=true] - Zoom on scroll gesture
- * @property {Boolean} [gestureSettingsUnknown.clickToZoom=false] - Zoom on click gesture
- * @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture
- * @property {Boolean} [gestureSettingsUnknown.flickEnabled=true] - Enable flick gesture
- * @property {Number} [gestureSettingsUnknown.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
- * @property {Number} [gestureSettingsUnknown.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture
- *
- * @property {Number} [zoomPerClick=2.0]
- * The "zoom distance" per mouse click or touch tap. <em><strong>Note:</strong> Setting this to 1.0 effectively disables the click-to-zoom feature (also see gestureSettings[Mouse|Touch|Pen].clickToZoom).</em>
- *
- * @property {Number} [zoomPerScroll=1.2]
- * The "zoom distance" per mouse scroll or touch pinch. <em><strong>Note:</strong> Setting this to 1.0 effectively disables the mouse-wheel zoom feature (also see gestureSettings[Mouse|Touch|Pen].scrollToZoom}).</em>
- *
- * @property {Number} [zoomPerSecond=1.0]
- * The number of seconds to animate a single zoom event over.
- *
- * @property {Boolean} [showNavigator=false]
- * Set to true to make the navigator minimap appear.
- *
- * @property {Boolean} [navigatorId=navigator-GENERATED DATE]
- * The ID of a div to hold the navigator minimap.
- * If an ID is specified, the navigatorPosition, navigatorSizeRatio, navigatorMaintainSizeRatio, and navigatorTop|Left|Height|Width options will be ignored.
- * If an ID is not specified, a div element will be generated and placed on top of the main image.
- *
- * @property {String} [navigatorPosition='TOP_RIGHT']
- * Valid values are 'TOP_LEFT', 'TOP_RIGHT', 'BOTTOM_LEFT', 'BOTTOM_RIGHT', or 'ABSOLUTE'.<br>
- * If 'ABSOLUTE' is specified, then navigatorTop|Left|Height|Width determines the size and position of the navigator minimap in the viewer, and navigatorSizeRatio and navigatorMaintainSizeRatio are ignored.<br>
- * For 'TOP_LEFT', 'TOP_RIGHT', 'BOTTOM_LEFT', and 'BOTTOM_RIGHT', the navigatorSizeRatio or navigatorHeight|Width values determine the size of the navigator minimap.
- *
- * @property {Number} [navigatorSizeRatio=0.2]
- * Ratio of navigator size to viewer size. Ignored if navigatorHeight|Width are specified.
- *
- * @property {Boolean} [navigatorMaintainSizeRatio=false]
- * If true, the navigator minimap is resized (using navigatorSizeRatio) when the viewer size changes.
- *
- * @property {Number|String} [navigatorTop=null]
- * Specifies the location of the navigator minimap (see navigatorPosition).
- *
- * @property {Number|String} [navigatorLeft=null]
- * Specifies the location of the navigator minimap (see navigatorPosition).
- *
- * @property {Number|String} [navigatorHeight=null]
- * Specifies the size of the navigator minimap (see navigatorPosition).
- * If specified, navigatorSizeRatio and navigatorMaintainSizeRatio are ignored.
- *
- * @property {Number|String} [navigatorWidth=null]
- * Specifies the size of the navigator minimap (see navigatorPosition).
- * If specified, navigatorSizeRatio and navigatorMaintainSizeRatio are ignored.
- *
- * @property {Boolean} [navigatorAutoResize=true]
- * Set to false to prevent polling for navigator size changes. Useful for providing custom resize behavior.
- * Setting to false can also improve performance when the navigator is configured to a fixed size.
- *
- * @property {Number} [controlsFadeDelay=2000]
- * The number of milliseconds to wait once the user has stopped interacting
- * with the interface before begining to fade the controls. Assumes
- * showNavigationControl and autoHideControls are both true.
- *
- * @property {Number} [controlsFadeLength=1500]
- * The number of milliseconds to animate the controls fading out.
- *
- * @property {Number} [maxImageCacheCount=200]
- * The max number of images we should keep in memory (per drawer).
- *
- * @property {Number} [timeout=30000]
- *
- * @property {Boolean} [useCanvas=true]
- * Set to false to not use an HTML canvas element for image rendering even if canvas is supported.
- *
- * @property {Number} [minPixelRatio=0.5]
- * The higher the minPixelRatio, the lower the quality of the image that
- * is considered sufficient to stop rendering a given zoom level. For
- * example, if you are targeting mobile devices with less bandwith you may
- * try setting this to 1.5 or higher.
- *
- * @property {Boolean} [mouseNavEnabled=true]
- * Is the user able to interact with the image via mouse or touch. Default
- * interactions include draging the image in a plane, and zooming in toward
- * and away from the image.
- *
- * @property {Boolean} [showNavigationControl=true]
- * Set to false to prevent the appearance of the default navigation controls.<br>
- * Note that if set to false, the customs buttons set by the options
- * zoomInButton, zoomOutButton etc, are rendered inactive.
- *
- * @property {OpenSeadragon.ControlAnchor} [navigationControlAnchor=TOP_LEFT]
- * Placement of the default navigation controls.
- * To set the placement of the sequence controls, see the
- * sequenceControlAnchor option.
- *
- * @property {Boolean} [showZoomControl=true]
- * If true then + and - buttons to zoom in and out are displayed.<br>
- * Note: {@link OpenSeadragon.Options.showNavigationControl} is overriding
- * this setting when set to false.
- *
- * @property {Boolean} [showHomeControl=true]
- * If true then the 'Go home' button is displayed to go back to the original
- * zoom and pan.<br>
- * Note: {@link OpenSeadragon.Options.showNavigationControl} is overriding
- * this setting when set to false.
- *
- * @property {Boolean} [showFullPageControl=true]
- * If true then the 'Toggle full page' button is displayed to switch
- * between full page and normal mode.<br>
- * Note: {@link OpenSeadragon.Options.showNavigationControl} is overriding
- * this setting when set to false.
- *
- * @property {Boolean} [showRotationControl=false]
- * If true then the rotate left/right controls will be displayed as part of the
- * standard controls. This is also subject to the browser support for rotate
- * (e.g. viewer.drawer.canRotate()).<br>
- * Note: {@link OpenSeadragon.Options.showNavigationControl} is overriding
- * this setting when set to false.
- *
- * @property {Boolean} [showSequenceControl=true]
- * If the viewer has been configured with a sequence of tile sources, then
- * provide buttons for navigating forward and backward through the images.
- *
- * @property {OpenSeadragon.ControlAnchor} [sequenceControlAnchor=TOP_LEFT]
- * Placement of the default sequence controls.
- *
- * @property {Boolean} [navPrevNextWrap=false]
- * If true then the 'previous' button will wrap to the last image when
- * viewing the first image and the 'next' button will wrap to the first
- * image when viewing the last image.
- *
- * @property {String} zoomInButton
- * Set the id of the custom 'Zoom in' button to use.
- * This is useful to have a custom button anywhere in the web page.<br>
- * To only change the button images, consider using
- * {@link OpenSeadragon.Options.navImages}
- *
- * @property {String} zoomOutButton
- * Set the id of the custom 'Zoom out' button to use.
- * This is useful to have a custom button anywhere in the web page.<br>
- * To only change the button images, consider using
- * {@link OpenSeadragon.Options.navImages}
- *
- * @property {String} homeButton
- * Set the id of the custom 'Go home' button to use.
- * This is useful to have a custom button anywhere in the web page.<br>
- * To only change the button images, consider using
- * {@link OpenSeadragon.Options.navImages}
- *
- * @property {String} fullPageButton
- * Set the id of the custom 'Toggle full page' button to use.
- * This is useful to have a custom button anywhere in the web page.<br>
- * To only change the button images, consider using
- * {@link OpenSeadragon.Options.navImages}
- *
- * @property {String} rotateLeftButton
- * Set the id of the custom 'Rotate left' button to use.
- * This is useful to have a custom button anywhere in the web page.<br>
- * To only change the button images, consider using
- * {@link OpenSeadragon.Options.navImages}
- *
- * @property {String} rotateRightButton
- * Set the id of the custom 'Rotate right' button to use.
- * This is useful to have a custom button anywhere in the web page.<br>
- * To only change the button images, consider using
- * {@link OpenSeadragon.Options.navImages}
- *
- * @property {String} previousButton
- * Set the id of the custom 'Previous page' button to use.
- * This is useful to have a custom button anywhere in the web page.<br>
- * To only change the button images, consider using
- * {@link OpenSeadragon.Options.navImages}
- *
- * @property {String} nextButton
- * Set the id of the custom 'Next page' button to use.
- * This is useful to have a custom button anywhere in the web page.<br>
- * To only change the button images, consider using
- * {@link OpenSeadragon.Options.navImages}
- *
- * @property {Number} [initialPage=0]
- * If the viewer has been configured with a sequence of tile sources, display this page initially.
- *
- * @property {Boolean} [preserveViewport=false]
- * If the viewer has been configured with a sequence of tile sources, then
- * normally navigating to through each image resets the viewport to 'home'
- * position. If preserveViewport is set to true, then the viewport position
- * is preserved when navigating between images in the sequence.
- *
- * @property {Boolean} [showReferenceStrip=false]
- * If the viewer has been configured with a sequence of tile sources, then
- * display a scrolling strip of image thumbnails for navigating through the images.
- *
- * @property {String} [referenceStripScroll='horizontal']
- *
- * @property {Element} [referenceStripElement=null]
- *
- * @property {Number} [referenceStripHeight=null]
- *
- * @property {Number} [referenceStripWidth=null]
- *
- * @property {String} [referenceStripPosition='BOTTOM_LEFT']
- *
- * @property {Number} [referenceStripSizeRatio=0.2]
- *
- * @property {Boolean} [collectionMode=false]
- *
- * @property {Number} [collectionRows=3]
- *
- * @property {String} [collectionLayout='horizontal']
- *
- * @property {Number} [collectionTileSize=800]
- *
- * @property {String|Boolean} [crossOriginPolicy=false]
- * Valid values are 'Anonymous', 'use-credentials', and false. If false, canvas requests will
- * not use CORS, and the canvas will be tainted.
- *
- */
- /**
- * Settings for gestures generated by a pointer device.
- *
- * @typedef {Object} GestureSettings
- * @memberof OpenSeadragon
- *
- * @property {Boolean} scrollToZoom
- * Set to false to disable zooming on scroll gestures.
- *
- * @property {Boolean} clickToZoom
- * Set to false to disable zooming on click gestures.
- *
- * @property {Boolean} pinchToZoom
- * Set to false to disable zooming on pinch gestures.
- *
- * @property {Boolean} flickEnabled
- * Set to false to disable the kinetic panning effect (flick) at the end of a drag gesture.
- *
- * @property {Number} flickMinSpeed
- * If flickEnabled is true, the minimum speed (in pixels-per-second) required to cause the kinetic panning effect (flick) at the end of a drag gesture.
- *
- * @property {Number} flickMomentum
- * If flickEnabled is true, a constant multiplied by the velocity to determine the distance of the kinetic panning effect (flick) at the end of a drag gesture.
- * A larger value will make the flick feel "lighter", while a smaller value will make the flick feel "heavier".
- * Note: springStiffness and animationTime also affect the "spring" used to stop the flick animation.
- *
- */
- /**
- * The names for the image resources used for the image navigation buttons.
- *
- * @typedef {Object} NavImages
- * @memberof OpenSeadragon
- *
- * @property {Object} zoomIn - Images for the zoom-in button.
- * @property {String} zoomIn.REST
- * @property {String} zoomIn.GROUP
- * @property {String} zoomIn.HOVER
- * @property {String} zoomIn.DOWN
- *
- * @property {Object} zoomOut - Images for the zoom-out button.
- * @property {String} zoomOut.REST
- * @property {String} zoomOut.GROUP
- * @property {String} zoomOut.HOVER
- * @property {String} zoomOut.DOWN
- *
- * @property {Object} home - Images for the home button.
- * @property {String} home.REST
- * @property {String} home.GROUP
- * @property {String} home.HOVER
- * @property {String} home.DOWN
- *
- * @property {Object} fullpage - Images for the full-page button.
- * @property {String} fullpage.REST
- * @property {String} fullpage.GROUP
- * @property {String} fullpage.HOVER
- * @property {String} fullpage.DOWN
- *
- * @property {Object} rotateleft - Images for the rotate left button.
- * @property {String} rotateleft.REST
- * @property {String} rotateleft.GROUP
- * @property {String} rotateleft.HOVER
- * @property {String} rotateleft.DOWN
- *
- * @property {Object} rotateright - Images for the rotate right button.
- * @property {String} rotateright.REST
- * @property {String} rotateright.GROUP
- * @property {String} rotateright.HOVER
- * @property {String} rotateright.DOWN
- *
- * @property {Object} previous - Images for the previous button.
- * @property {String} previous.REST
- * @property {String} previous.GROUP
- * @property {String} previous.HOVER
- * @property {String} previous.DOWN
- *
- * @property {Object} next - Images for the next button.
- * @property {String} next.REST
- * @property {String} next.GROUP
- * @property {String} next.HOVER
- * @property {String} next.DOWN
- *
- */
- /**
- * This function serves as a single point of instantiation for an {@link OpenSeadragon.Viewer}, including all
- * combinations of out-of-the-box configurable features.
- *
- * @function OpenSeadragon
- * @memberof module:OpenSeadragon
- * @param {OpenSeadragon.Options} options - Viewer options.
- * @returns {OpenSeadragon.Viewer}
- */
- window.OpenSeadragon = window.OpenSeadragon || function( options ){
- return new OpenSeadragon.Viewer( options );
- };
- (function( $ ){
- /**
- * The OpenSeadragon version.
- *
- * @member {Object} OpenSeadragon.version
- * @property {String} versionStr - The version number as a string ('major.minor.revision').
- * @property {Number} major - The major version number.
- * @property {Number} minor - The minor version number.
- * @property {Number} revision - The revision number.
- * @since 1.0.0
- */
- /* jshint ignore:start */
- $.version = {
- versionStr: '<%= osdVersion.versionStr %>',
- major: <%= osdVersion.major %>,
- minor: <%= osdVersion.minor %>,
- revision: <%= osdVersion.revision %>
- };
- /* jshint ignore:end */
- /**
- * Taken from jquery 1.6.1
- * [[Class]] -> type pairs
- * @private
- */
- var class2type = {
- '[object Boolean]': 'boolean',
- '[object Number]': 'number',
- '[object String]': 'string',
- '[object Function]': 'function',
- '[object Array]': 'array',
- '[object Date]': 'date',
- '[object RegExp]': 'regexp',
- '[object Object]': 'object'
- },
- // Save a reference to some core methods
- toString = Object.prototype.toString,
- hasOwn = Object.prototype.hasOwnProperty;
- /**
- * Taken from jQuery 1.6.1
- * @function isFunction
- * @memberof OpenSeadragon
- * @see {@link http://www.jquery.com/ jQuery}
- */
- $.isFunction = function( obj ) {
- return $.type(obj) === "function";
- };
- /**
- * Taken from jQuery 1.6.1
- * @function isArray
- * @memberof OpenSeadragon
- * @see {@link http://www.jquery.com/ jQuery}
- */
- $.isArray = Array.isArray || function( obj ) {
- return $.type(obj) === "array";
- };
- /**
- * A crude way of determining if an object is a window.
- * Taken from jQuery 1.6.1
- * @function isWindow
- * @memberof OpenSeadragon
- * @see {@link http://www.jquery.com/ jQuery}
- */
- $.isWindow = function( obj ) {
- return obj && typeof obj === "object" && "setInterval" in obj;
- };
- /**
- * Taken from jQuery 1.6.1
- * @function type
- * @memberof OpenSeadragon
- * @see {@link http://www.jquery.com/ jQuery}
- */
- $.type = function( obj ) {
- return ( obj === null ) || ( obj === undefined ) ?
- String( obj ) :
- class2type[ toString.call(obj) ] || "object";
- };
- /**
- * Taken from jQuery 1.6.1
- * @function isPlainObject
- * @memberof OpenSeadragon
- * @see {@link http://www.jquery.com/ jQuery}
- */
- $.isPlainObject = function( obj ) {
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || OpenSeadragon.type(obj) !== "object" || obj.nodeType || $.isWindow( obj ) ) {
- return false;
- }
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !hasOwn.call(obj, "constructor") &&
- !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
- return false;
- }
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
- var key;
- for ( key in obj ) {}
- return key === undefined || hasOwn.call( obj, key );
- };
- /**
- * Taken from jQuery 1.6.1
- * @function isEmptyObject
- * @memberof OpenSeadragon
- * @see {@link http://www.jquery.com/ jQuery}
- */
- $.isEmptyObject = function( obj ) {
- for ( var name in obj ) {
- return false;
- }
- return true;
- };
- /**
- * True if the browser supports the HTML5 canvas element
- * @member {Boolean} supportsCanvas
- * @memberof OpenSeadragon
- */
- $.supportsCanvas = (function () {
- var canvasElement = document.createElement( 'canvas' );
- return !!( $.isFunction( canvasElement.getContext ) &&
- canvasElement.getContext( '2d' ) );
- }());
- }( OpenSeadragon ));
- /**
- * This closure defines all static methods available to the OpenSeadragon
- * namespace. Many, if not most, are taked directly from jQuery for use
- * to simplify and reduce common programming patterns. More static methods
- * from jQuery may eventually make their way into this though we are
- * attempting to avoid an explicit dependency on jQuery only because
- * OpenSeadragon is a broadly useful code base and would be made less broad
- * by requiring jQuery fully.
- *
- * Some static methods have also been refactored from the original OpenSeadragon
- * project.
- */
- (function( $ ){
- /**
- * Taken from jQuery 1.6.1
- * @function extend
- * @memberof OpenSeadragon
- * @see {@link http://www.jquery.com/ jQuery}
- */
- $.extend = function() {
- var options,
- name,
- src,
- copy,
- copyIsArray,
- clone,
- target = arguments[ 0 ] || {},
- length = arguments.length,
- deep = false,
- i = 1;
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[ 1 ] || {};
- // skip the boolean and the target
- i = 2;
- }
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !OpenSeadragon.isFunction( target ) ) {
- target = {};
- }
- // extend jQuery itself if only one argument is passed
- if ( length === i ) {
- target = this;
- --i;
- }
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- options = arguments[ i ];
- if ( options !== null || options !== undefined ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( OpenSeadragon.isPlainObject( copy ) || ( copyIsArray = OpenSeadragon.isArray( copy ) ) ) ) {
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && OpenSeadragon.isArray( src ) ? src : [];
- } else {
- clone = src && OpenSeadragon.isPlainObject( src ) ? src : {};
- }
- // Never move original objects, clone them
- target[ name ] = OpenSeadragon.extend( deep, clone, copy );
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
- // Return the modified object
- return target;
- };
- $.extend( $, /** @lends OpenSeadragon */{
- /**
- * The default values for the optional settings documented at {@link OpenSeadragon.Options}.
- * @static
- * @type {Object}
- */
- DEFAULT_SETTINGS: {
- //DATA SOURCE DETAILS
- xmlPath: null,
- tileSources: null,
- tileHost: null,
- initialPage: 0,
- crossOriginPolicy: false,
- //PAN AND ZOOM SETTINGS AND CONSTRAINTS
- panHorizontal: true,
- panVertical: true,
- constrainDuringPan: false,
- wrapHorizontal: false,
- wrapVertical: false,
- visibilityRatio: 0.5, //-> how much of the viewer can be negative space
- minPixelRatio: 0.5, //->closer to 0 draws tiles meant for a higher zoom at this zoom
- defaultZoomLevel: 0,
- minZoomLevel: null,
- maxZoomLevel: null,
- //UI RESPONSIVENESS AND FEEL
- clickTimeThreshold: 300,
- clickDistThreshold: 5,
- springStiffness: 5.0,
- animationTime: 1.2,
- gestureSettingsMouse: { scrollToZoom: true, clickToZoom: true, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 20, flickMomentum: 0.40 },
- gestureSettingsTouch: { scrollToZoom: false, clickToZoom: false, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 20, flickMomentum: 0.40 },
- gestureSettingsPen: { scrollToZoom: false, clickToZoom: true, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 20, flickMomentum: 0.40 },
- gestureSettingsUnknown: { scrollToZoom: false, clickToZoom: false, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 20, flickMomentum: 0.40 },
- zoomPerClick: 2,
- zoomPerScroll: 1.2,
- zoomPerSecond: 1.0,
- blendTime: 0,
- alwaysBlend: false,
- autoHideControls: true,
- immediateRender: false,
- minZoomImageRatio: 0.9, //-> closer to 0 allows zoom out to infinity
- maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels
- pixelsPerWheelLine: 40,
- autoResize: true,
- //DEFAULT CONTROL SETTINGS
- showSequenceControl: true, //SEQUENCE
- sequenceControlAnchor: null, //SEQUENCE
- preserveViewport: false, //SEQUENCE
- navPrevNextWrap: false, //SEQUENCE
- showNavigationControl: true, //ZOOM/HOME/FULL/ROTATION
- navigationControlAnchor: null, //ZOOM/HOME/FULL/ROTATION
- showZoomControl: true, //ZOOM
- showHomeControl: true, //HOME
- showFullPageControl: true, //FULL
- showRotationControl: false, //ROTATION
- controlsFadeDelay: 2000, //ZOOM/HOME/FULL/SEQUENCE
- controlsFadeLength: 1500, //ZOOM/HOME/FULL/SEQUENCE
- mouseNavEnabled: true, //GENERAL MOUSE INTERACTIVITY
- //VIEWPORT NAVIGATOR SETTINGS
- showNavigator: false,
- navigatorId: null,
- navigatorPosition: null,
- navigatorSizeRatio: 0.2,
- navigatorMaintainSizeRatio: false,
- navigatorTop: null,
- navigatorLeft: null,
- navigatorHeight: null,
- navigatorWidth: null,
- navigatorAutoResize: true,
- // INITIAL ROTATION
- degrees: 0,
- // APPEARANCE
- opacity: 1,
- // LAYERS SETTINGS
- layersAspectRatioEpsilon: 0.0001,
- //REFERENCE STRIP SETTINGS
- showReferenceStrip: false,
- referenceStripScroll: 'horizontal',
- referenceStripElement: null,
- referenceStripHeight: null,
- referenceStripWidth: null,
- referenceStripPosition: 'BOTTOM_LEFT',
- referenceStripSizeRatio: 0.2,
- //COLLECTION VISUALIZATION SETTINGS
- collectionRows: 3, //or columns depending on layout
- collectionLayout: 'horizontal', //vertical
- collectionMode: false,
- collectionTileSize: 800,
- //PERFORMANCE SETTINGS
- imageLoaderLimit: 0,
- maxImageCacheCount: 200,
- timeout: 30000,
- useCanvas: true, // Use canvas element for drawing if available
- //INTERFACE RESOURCE SETTINGS
- prefixUrl: "/images/",
- navImages: {
- zoomIn: {
- REST: 'zoomin_rest.png',
- GROUP: 'zoomin_grouphover.png',
- HOVER: 'zoomin_hover.png',
- DOWN: 'zoomin_pressed.png'
- },
- zoomOut: {
- REST: 'zoomout_rest.png',
- GROUP: 'zoomout_grouphover.png',
- HOVER: 'zoomout_hover.png',
- DOWN: 'zoomout_pressed.png'
- },
- home: {
- REST: 'home_rest.png',
- GROUP: 'home_grouphover.png',
- HOVER: 'home_hover.png',
- DOWN: 'home_pressed.png'
- },
- fullpage: {
- REST: 'fullpage_rest.png',
- GROUP: 'fullpage_grouphover.png',
- HOVER: 'fullpage_hover.png',
- DOWN: 'fullpage_pressed.png'
- },
- rotateleft: {
- REST: 'rotateleft_rest.png',
- GROUP: 'rotateleft_grouphover.png',
- HOVER: 'rotateleft_hover.png',
- DOWN: 'rotateleft_pressed.png'
- },
- rotateright: {
- REST: 'rotateright_rest.png',
- GROUP: 'rotateright_grouphover.png',
- HOVER: 'rotateright_hover.png',
- DOWN: 'rotateright_pressed.png'
- },
- previous: {
- REST: 'previous_rest.png',
- GROUP: 'previous_grouphover.png',
- HOVER: 'previous_hover.png',
- DOWN: 'previous_pressed.png'
- },
- next: {
- REST: 'next_rest.png',
- GROUP: 'next_grouphover.png',
- HOVER: 'next_hover.png',
- DOWN: 'next_pressed.png'
- }
- },
- //DEVELOPER SETTINGS
- debugMode: false,
- debugGridColor: '#437AB2'
- },
- /**
- * TODO: get rid of this. I can't see how it's required at all. Looks
- * like an early legacy code artifact.
- * @static
- * @ignore
- */
- SIGNAL: "----seadragon----",
- /**
- * Returns a function which invokes the method as if it were a method belonging to the object.
- * @function
- * @param {Object} object
- * @param {Function} method
- * @returns {Function}
- */
- delegate: function( object, method ) {
- return function(){
- var args = arguments;
- if ( args === undefined ){
- args = [];
- }
- return method.apply( object, args );
- };
- },
- /**
- * An enumeration of Browser vendors.
- * @static
- * @type {Object}
- * @property {Number} UNKNOWN
- * @property {Number} IE
- * @property {Number} FIREFOX
- * @property {Number} SAFARI
- * @property {Number} CHROME
- * @property {Number} OPERA
- */
- BROWSERS: {
- UNKNOWN: 0,
- IE: 1,
- FIREFOX: 2,
- SAFARI: 3,
- CHROME: 4,
- OPERA: 5
- },
- /**
- * Returns a DOM Element for the given id or element.
- * @function
- * @param {String|Element} element Accepts an id or element.
- * @returns {Element} The element with the given id, null, or the element itself.
- */
- getElement: function( element ) {
- if ( typeof ( element ) == "string" ) {
- element = document.getElementById( element );
- }
- return element;
- },
- /**
- * Determines the position of the upper-left corner of the element.
- * @function
- * @param {Element|String} element - the elemenet we want the position for.
- * @returns {OpenSeadragon.Point} - the position of the upper left corner of the element.
- */
- getElementPosition: function( element ) {
- var result = new $.Point(),
- isFixed,
- offsetParent;
- element = $.getElement( element );
- isFixed = $.getElementStyle( element ).position == "fixed";
- offsetParent = getOffsetParent( element, isFixed );
- while ( offsetParent ) {
- result.x += element.offsetLeft;
- result.y += element.offsetTop;
- if ( isFixed ) {
- result = result.plus( $.getPageScroll() );
- }
- element = offsetParent;
- isFixed = $.getElementStyle( element ).position == "fixed";
- offsetParent = getOffsetParent( element, isFixed );
- }
- return result;
- },
- /**
- * Determines the position of the upper-left corner of the element adjusted for current page and/or element scroll.
- * @function
- * @param {Element|String} element - the element we want the position for.
- * @returns {OpenSeadragon.Point} - the position of the upper left corner of the element adjusted for current page and/or element scroll.
- */
- getElementOffset: function( element ) {
- element = $.getElement( element );
- var doc = element && element.ownerDocument,
- docElement,
- win,
- boundingRect = { top: 0, left: 0 };
- if ( !doc ) {
- return new $.Point();
- }
- docElement = doc.documentElement;
- if ( typeof element.getBoundingClientRect !== typeof undefined ) {
- boundingRect = element.getBoundingClientRect();
- }
- win = ( doc == doc.window ) ?
- doc :
- ( doc.nodeType === 9 ) ?
- doc.defaultView || doc.parentWindow :
- false;
- return new $.Point(
- boundingRect.left + ( win.pageXOffset || docElement.scrollLeft ) - ( docElement.clientLeft || 0 ),
- boundingRect.top + ( win.pageYOffset || docElement.scrollTop ) - ( docElement.clientTop || 0 )
- );
- },
- /**
- * Determines the height and width of the given element.
- * @function
- * @param {Element|String} element
- * @returns {OpenSeadragon.Point}
- */
- getElementSize: function( element ) {
- element = $.getElement( element );
- return new $.Point(
- element.clientWidth,
- element.clientHeight
- );
- },
- /**
- * Returns the CSSStyle object for the given element.
- * @function
- * @param {Element|String} element
- * @returns {CSSStyle}
- */
- getElementStyle:
- document.documentElement.currentStyle ?
- function( element ) {
- element = $.getElement( element );
- return element.currentStyle;
- } :
- function( element ) {
- ele…
Large files files are truncated, but you can click here to view the full file