PageRenderTime 70ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/src/openseadragon.js

https://github.com/manmeet90/openseadragon
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

  1. /*
  2. * OpenSeadragon
  3. *
  4. * Copyright (C) 2009 CodePlex Foundation
  5. * Copyright (C) 2010-2013 OpenSeadragon contributors
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are
  9. * met:
  10. *
  11. * - Redistributions of source code must retain the above copyright notice,
  12. * this list of conditions and the following disclaimer.
  13. *
  14. * - Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. *
  18. * - Neither the name of CodePlex Foundation nor the names of its
  19. * contributors may be used to endorse or promote products derived from
  20. * this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  28. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. /*
  35. * Portions of this source file taken from jQuery:
  36. *
  37. * Copyright 2011 John Resig
  38. *
  39. * Permission is hereby granted, free of charge, to any person obtaining
  40. * a copy of this software and associated documentation files (the
  41. * "Software"), to deal in the Software without restriction, including
  42. * without limitation the rights to use, copy, modify, merge, publish,
  43. * distribute, sublicense, and/or sell copies of the Software, and to
  44. * permit persons to whom the Software is furnished to do so, subject to
  45. * the following conditions:
  46. *
  47. * The above copyright notice and this permission notice shall be
  48. * included in all copies or substantial portions of the Software.
  49. *
  50. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  51. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  52. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  53. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  54. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  55. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  56. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  57. */
  58. /*
  59. * Portions of this source file taken from mattsnider.com:
  60. *
  61. * Copyright (c) 2006-2013 Matt Snider
  62. *
  63. * Permission is hereby granted, free of charge, to any person obtaining a
  64. * copy of this software and associated documentation files (the "Software"),
  65. * to deal in the Software without restriction, including without limitation
  66. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  67. * and/or sell copies of the Software, and to permit persons to whom the
  68. * Software is furnished to do so, subject to the following conditions:
  69. *
  70. * The above copyright notice and this permission notice shall be included
  71. * in all copies or substantial portions of the Software.
  72. *
  73. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  74. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  75. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  76. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  77. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
  78. * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
  79. * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  80. */
  81. /**
  82. * @version <%= pkg.name %> <%= pkg.version %>
  83. *
  84. * @file
  85. * <h2><strong>OpenSeadragon - Javascript Deep Zooming</strong></h2>
  86. * <p>
  87. * OpenSeadragon provides an html interface for creating
  88. * deep zoom user interfaces. The simplest examples include deep
  89. * zoom for large resolution images, and complex examples include
  90. * zoomable map interfaces driven by SVG files.
  91. * </p>
  92. *
  93. */
  94. /**
  95. * @module OpenSeadragon
  96. *
  97. */
  98. /**
  99. * @namespace OpenSeadragon
  100. *
  101. * @classdesc The root namespace for OpenSeadragon. All utility methods
  102. * and classes are defined on or below this namespace.
  103. *
  104. */
  105. // Typedefs
  106. /**
  107. * All required and optional settings for instantiating a new instance of an OpenSeadragon image viewer.
  108. *
  109. * @typedef {Object} Options
  110. * @memberof OpenSeadragon
  111. *
  112. * @property {String} id
  113. * Id of the element to append the viewer's container element to. If not provided, the 'element' property must be provided.
  114. * If both the element and id properties are specified, the viewer is appended to the element provided in the element property.
  115. *
  116. * @property {Element} element
  117. * The element to append the viewer's container element to. If not provided, the 'id' property must be provided.
  118. * If both the element and id properties are specified, the viewer is appended to the element provided in the element property.
  119. *
  120. * @property {Array|String|Function|Object[]|Array[]|String[]|Function[]} [tileSources=null]
  121. * As an Array, the tileSource can hold either Objects or mixed
  122. * types of Arrays of Objects, Strings, or Functions. When a value is a String,
  123. * the tileSource is used to create a {@link OpenSeadragon.DziTileSource}.
  124. * When a value is a Function, the function is used to create a new
  125. * {@link OpenSeadragon.TileSource} whose abstract method
  126. * getUrl( level, x, y ) is implemented by the function. Finally, when it
  127. * is an Array of objects, it is used to create a
  128. * {@link OpenSeadragon.LegacyTileSource}.
  129. *
  130. * @property {Array} overlays Array of objects defining permanent overlays of
  131. * the viewer. The overlays added via this option and later removed with
  132. * {@link OpenSeadragon.Viewer#removeOverlay} will be added back when a new
  133. * image is opened.
  134. * To add overlays which can be definitively removed, one must use
  135. * {@link OpenSeadragon.Viewer#addOverlay}
  136. * If displaying a sequence of images, the overlays can be associated
  137. * with a specific page by passing the overlays array to the page's
  138. * tile source configuration.
  139. * Expected properties:
  140. * * x, y, (or px, py for pixel coordinates) to define the location.
  141. * * width, height in point if using x,y or in pixels if using px,py. If width
  142. * and height are specified, the overlay size is adjusted when zooming,
  143. * otherwise the size stays the size of the content (or the size defined by CSS).
  144. * * className to associate a class to the overlay
  145. * * id to set the overlay element. If an element with this id already exists,
  146. * it is reused, otherwise it is created. If not specified, a new element is
  147. * created.
  148. * * placement a string to define the relative position to the viewport.
  149. * Only used if no width and height are specified. Default: 'TOP_LEFT'.
  150. * See {@link OpenSeadragon.OverlayPlacement} for possible values.
  151. *
  152. * @property {String} [xmlPath=null]
  153. * <strong>DEPRECATED</strong>. A relative path to load a DZI file from the server.
  154. * Prefer the newer Options.tileSources.
  155. *
  156. * @property {String} [prefixUrl='/images/']
  157. * Prepends the prefixUrl to navImages paths, which is very useful
  158. * since the default paths are rarely useful for production
  159. * environments.
  160. *
  161. * @property {OpenSeadragon.NavImages} [navImages]
  162. * An object with a property for each button or other built-in navigation
  163. * control, eg the current 'zoomIn', 'zoomOut', 'home', and 'fullpage'.
  164. * Each of those in turn provides an image path for each state of the button
  165. * or navigation control, eg 'REST', 'GROUP', 'HOVER', 'PRESS'. Finally the
  166. * image paths, by default assume there is a folder on the servers root path
  167. * called '/images', eg '/images/zoomin_rest.png'. If you need to adjust
  168. * these paths, prefer setting the option.prefixUrl rather than overriding
  169. * every image path directly through this setting.
  170. *
  171. * @property {Object} [tileHost=null]
  172. * TODO: Implement this. Currently not used.
  173. *
  174. * @property {Boolean} [debugMode=false]
  175. * TODO: provide an in-screen panel providing event detail feedback.
  176. *
  177. * @property {String} [debugGridColor='#437AB2']
  178. *
  179. * @property {Number} [blendTime=0]
  180. * Specifies the duration of animation as higher or lower level tiles are
  181. * replacing the existing tile.
  182. *
  183. * @property {Boolean} [alwaysBlend=false]
  184. * Forces the tile to always blend. By default the tiles skip blending
  185. * when the blendTime is surpassed and the current animation frame would
  186. * not complete the blend.
  187. *
  188. * @property {Boolean} [autoHideControls=true]
  189. * If the user stops interacting with the viewport, fade the navigation
  190. * controls. Useful for presentation since the controls are by default
  191. * floated on top of the image the user is viewing.
  192. *
  193. * @property {Boolean} [immediateRender=false]
  194. * Render the best closest level first, ignoring the lowering levels which
  195. * provide the effect of very blurry to sharp. It is recommended to change
  196. * setting to true for mobile devices.
  197. *
  198. * @property {Number} [defaultZoomLevel=0]
  199. * Zoom level to use when image is first opened or the home button is clicked.
  200. * If 0, adjusts to fit viewer.
  201. *
  202. * @property {Number} [opacity=1]
  203. * Opacity of the drawer (1=opaque, 0=transparent)
  204. *
  205. * @property {Number} [layersAspectRatioEpsilon=0.0001]
  206. * Maximum aspectRatio mismatch between 2 layers.
  207. *
  208. * @property {Number} [degrees=0]
  209. * Initial rotation.
  210. *
  211. * @property {Number} [minZoomLevel=null]
  212. *
  213. * @property {Number} [maxZoomLevel=null]
  214. *
  215. * @property {Boolean} [panHorizontal=true]
  216. * Allow horizontal pan.
  217. *
  218. * @property {Boolean} [panVertical=true]
  219. * Allow vertical pan.
  220. *
  221. * @property {Boolean} [constrainDuringPan=false]
  222. *
  223. * @property {Boolean} [wrapHorizontal=false]
  224. * Set to true to force the image to wrap horizontally within the viewport.
  225. * Useful for maps or images representing the surface of a sphere or cylinder.
  226. *
  227. * @property {Boolean} [wrapVertical=false]
  228. * Set to true to force the image to wrap vertically within the viewport.
  229. * Useful for maps or images representing the surface of a sphere or cylinder.
  230. *
  231. * @property {Number} [minZoomImageRatio=0.9]
  232. * The minimum percentage ( expressed as a number between 0 and 1 ) of
  233. * the viewport height or width at which the zoom out will be constrained.
  234. * Setting it to 0, for example will allow you to zoom out infinitly.
  235. *
  236. * @property {Number} [maxZoomPixelRatio=1.1]
  237. * The maximum ratio to allow a zoom-in to affect the highest level pixel
  238. * ratio. This can be set to Infinity to allow 'infinite' zooming into the
  239. * image though it is less effective visually if the HTML5 Canvas is not
  240. * availble on the viewing device.
  241. *
  242. * @property {Boolean} [autoResize=true]
  243. * Set to false to prevent polling for viewer size changes. Useful for providing custom resize behavior.
  244. *
  245. * @property {Number} [pixelsPerWheelLine=40]
  246. * For pixel-resolution scrolling devices, the number of pixels equal to one scroll line.
  247. *
  248. * @property {Number} [visibilityRatio=0.5]
  249. * The percentage ( as a number from 0 to 1 ) of the source image which
  250. * must be kept within the viewport. If the image is dragged beyond that
  251. * limit, it will 'bounce' back until the minimum visibility ration is
  252. * achieved. Setting this to 0 and wrapHorizontal ( or wrapVertical ) to
  253. * true will provide the effect of an infinitely scrolling viewport.
  254. *
  255. * @property {Number} [imageLoaderLimit=0]
  256. * The maximum number of image requests to make concurrently. By default
  257. * it is set to 0 allowing the browser to make the maximum number of
  258. * image requests in parallel as allowed by the browsers policy.
  259. *
  260. * @property {Number} [clickTimeThreshold=300]
  261. * If multiple mouse clicks occurs within less than this number of
  262. * milliseconds, treat them as a single click.
  263. *
  264. * @property {Number} [clickDistThreshold=5]
  265. * If a mouse or touch drag occurs and the distance to the starting drag
  266. * point is less than this many pixels, ignore the drag event.
  267. *
  268. * @property {Number} [springStiffness=5.0]
  269. *
  270. * @property {Number} [animationTime=1.2]
  271. * Specifies the animation duration per each {@link OpenSeadragon.Spring}
  272. * which occur when the image is dragged or zoomed.
  273. *
  274. * @property {OpenSeadragon.GestureSettings} [gestureSettingsMouse]
  275. * Settings for gestures generated by a mouse pointer device. (See {@link OpenSeadragon.GestureSettings})
  276. * @property {Boolean} [gestureSettingsMouse.scrollToZoom=true] - Zoom on scroll gesture
  277. * @property {Boolean} [gestureSettingsMouse.clickToZoom=true] - Zoom on click gesture
  278. * @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture
  279. * @property {Boolean} [gestureSettingsMouse.flickEnabled=false] - Enable flick gesture
  280. * @property {Number} [gestureSettingsMouse.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
  281. * @property {Number} [gestureSettingsMouse.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture
  282. *
  283. * @property {OpenSeadragon.GestureSettings} [gestureSettingsTouch]
  284. * Settings for gestures generated by a touch pointer device. (See {@link OpenSeadragon.GestureSettings})
  285. * @property {Boolean} [gestureSettingsTouch.scrollToZoom=false] - Zoom on scroll gesture
  286. * @property {Boolean} [gestureSettingsTouch.clickToZoom=false] - Zoom on click gesture
  287. * @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture
  288. * @property {Boolean} [gestureSettingsTouch.flickEnabled=true] - Enable flick gesture
  289. * @property {Number} [gestureSettingsTouch.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
  290. * @property {Number} [gestureSettingsTouch.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture
  291. *
  292. * @property {OpenSeadragon.GestureSettings} [gestureSettingsPen]
  293. * Settings for gestures generated by a pen pointer device. (See {@link OpenSeadragon.GestureSettings})
  294. * @property {Boolean} [gestureSettingsPen.scrollToZoom=false] - Zoom on scroll gesture
  295. * @property {Boolean} [gestureSettingsPen.clickToZoom=true] - Zoom on click gesture
  296. * @property {Boolean} [gestureSettingsPen.pinchToZoom=false] - Zoom on pinch gesture
  297. * @property {Boolean} [gestureSettingsPen.flickEnabled=false] - Enable flick gesture
  298. * @property {Number} [gestureSettingsPen.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
  299. * @property {Number} [gestureSettingsPen.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture
  300. *
  301. * @property {OpenSeadragon.GestureSettings} [gestureSettingsUnknown]
  302. * Settings for gestures generated by unknown pointer devices. (See {@link OpenSeadragon.GestureSettings})
  303. * @property {Boolean} [gestureSettingsUnknown.scrollToZoom=true] - Zoom on scroll gesture
  304. * @property {Boolean} [gestureSettingsUnknown.clickToZoom=false] - Zoom on click gesture
  305. * @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture
  306. * @property {Boolean} [gestureSettingsUnknown.flickEnabled=true] - Enable flick gesture
  307. * @property {Number} [gestureSettingsUnknown.flickMinSpeed=20] - If flickEnabled is true, the minimum speed to initiate a flick gesture (pixels-per-second)
  308. * @property {Number} [gestureSettingsUnknown.flickMomentum=0.40] - If flickEnabled is true, the momentum factor for the flick gesture
  309. *
  310. * @property {Number} [zoomPerClick=2.0]
  311. * 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>
  312. *
  313. * @property {Number} [zoomPerScroll=1.2]
  314. * 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>
  315. *
  316. * @property {Number} [zoomPerSecond=1.0]
  317. * The number of seconds to animate a single zoom event over.
  318. *
  319. * @property {Boolean} [showNavigator=false]
  320. * Set to true to make the navigator minimap appear.
  321. *
  322. * @property {Boolean} [navigatorId=navigator-GENERATED DATE]
  323. * The ID of a div to hold the navigator minimap.
  324. * If an ID is specified, the navigatorPosition, navigatorSizeRatio, navigatorMaintainSizeRatio, and navigatorTop|Left|Height|Width options will be ignored.
  325. * If an ID is not specified, a div element will be generated and placed on top of the main image.
  326. *
  327. * @property {String} [navigatorPosition='TOP_RIGHT']
  328. * Valid values are 'TOP_LEFT', 'TOP_RIGHT', 'BOTTOM_LEFT', 'BOTTOM_RIGHT', or 'ABSOLUTE'.<br>
  329. * 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>
  330. * For 'TOP_LEFT', 'TOP_RIGHT', 'BOTTOM_LEFT', and 'BOTTOM_RIGHT', the navigatorSizeRatio or navigatorHeight|Width values determine the size of the navigator minimap.
  331. *
  332. * @property {Number} [navigatorSizeRatio=0.2]
  333. * Ratio of navigator size to viewer size. Ignored if navigatorHeight|Width are specified.
  334. *
  335. * @property {Boolean} [navigatorMaintainSizeRatio=false]
  336. * If true, the navigator minimap is resized (using navigatorSizeRatio) when the viewer size changes.
  337. *
  338. * @property {Number|String} [navigatorTop=null]
  339. * Specifies the location of the navigator minimap (see navigatorPosition).
  340. *
  341. * @property {Number|String} [navigatorLeft=null]
  342. * Specifies the location of the navigator minimap (see navigatorPosition).
  343. *
  344. * @property {Number|String} [navigatorHeight=null]
  345. * Specifies the size of the navigator minimap (see navigatorPosition).
  346. * If specified, navigatorSizeRatio and navigatorMaintainSizeRatio are ignored.
  347. *
  348. * @property {Number|String} [navigatorWidth=null]
  349. * Specifies the size of the navigator minimap (see navigatorPosition).
  350. * If specified, navigatorSizeRatio and navigatorMaintainSizeRatio are ignored.
  351. *
  352. * @property {Boolean} [navigatorAutoResize=true]
  353. * Set to false to prevent polling for navigator size changes. Useful for providing custom resize behavior.
  354. * Setting to false can also improve performance when the navigator is configured to a fixed size.
  355. *
  356. * @property {Number} [controlsFadeDelay=2000]
  357. * The number of milliseconds to wait once the user has stopped interacting
  358. * with the interface before begining to fade the controls. Assumes
  359. * showNavigationControl and autoHideControls are both true.
  360. *
  361. * @property {Number} [controlsFadeLength=1500]
  362. * The number of milliseconds to animate the controls fading out.
  363. *
  364. * @property {Number} [maxImageCacheCount=200]
  365. * The max number of images we should keep in memory (per drawer).
  366. *
  367. * @property {Number} [timeout=30000]
  368. *
  369. * @property {Boolean} [useCanvas=true]
  370. * Set to false to not use an HTML canvas element for image rendering even if canvas is supported.
  371. *
  372. * @property {Number} [minPixelRatio=0.5]
  373. * The higher the minPixelRatio, the lower the quality of the image that
  374. * is considered sufficient to stop rendering a given zoom level. For
  375. * example, if you are targeting mobile devices with less bandwith you may
  376. * try setting this to 1.5 or higher.
  377. *
  378. * @property {Boolean} [mouseNavEnabled=true]
  379. * Is the user able to interact with the image via mouse or touch. Default
  380. * interactions include draging the image in a plane, and zooming in toward
  381. * and away from the image.
  382. *
  383. * @property {Boolean} [showNavigationControl=true]
  384. * Set to false to prevent the appearance of the default navigation controls.<br>
  385. * Note that if set to false, the customs buttons set by the options
  386. * zoomInButton, zoomOutButton etc, are rendered inactive.
  387. *
  388. * @property {OpenSeadragon.ControlAnchor} [navigationControlAnchor=TOP_LEFT]
  389. * Placement of the default navigation controls.
  390. * To set the placement of the sequence controls, see the
  391. * sequenceControlAnchor option.
  392. *
  393. * @property {Boolean} [showZoomControl=true]
  394. * If true then + and - buttons to zoom in and out are displayed.<br>
  395. * Note: {@link OpenSeadragon.Options.showNavigationControl} is overriding
  396. * this setting when set to false.
  397. *
  398. * @property {Boolean} [showHomeControl=true]
  399. * If true then the 'Go home' button is displayed to go back to the original
  400. * zoom and pan.<br>
  401. * Note: {@link OpenSeadragon.Options.showNavigationControl} is overriding
  402. * this setting when set to false.
  403. *
  404. * @property {Boolean} [showFullPageControl=true]
  405. * If true then the 'Toggle full page' button is displayed to switch
  406. * between full page and normal mode.<br>
  407. * Note: {@link OpenSeadragon.Options.showNavigationControl} is overriding
  408. * this setting when set to false.
  409. *
  410. * @property {Boolean} [showRotationControl=false]
  411. * If true then the rotate left/right controls will be displayed as part of the
  412. * standard controls. This is also subject to the browser support for rotate
  413. * (e.g. viewer.drawer.canRotate()).<br>
  414. * Note: {@link OpenSeadragon.Options.showNavigationControl} is overriding
  415. * this setting when set to false.
  416. *
  417. * @property {Boolean} [showSequenceControl=true]
  418. * If the viewer has been configured with a sequence of tile sources, then
  419. * provide buttons for navigating forward and backward through the images.
  420. *
  421. * @property {OpenSeadragon.ControlAnchor} [sequenceControlAnchor=TOP_LEFT]
  422. * Placement of the default sequence controls.
  423. *
  424. * @property {Boolean} [navPrevNextWrap=false]
  425. * If true then the 'previous' button will wrap to the last image when
  426. * viewing the first image and the 'next' button will wrap to the first
  427. * image when viewing the last image.
  428. *
  429. * @property {String} zoomInButton
  430. * Set the id of the custom 'Zoom in' button to use.
  431. * This is useful to have a custom button anywhere in the web page.<br>
  432. * To only change the button images, consider using
  433. * {@link OpenSeadragon.Options.navImages}
  434. *
  435. * @property {String} zoomOutButton
  436. * Set the id of the custom 'Zoom out' button to use.
  437. * This is useful to have a custom button anywhere in the web page.<br>
  438. * To only change the button images, consider using
  439. * {@link OpenSeadragon.Options.navImages}
  440. *
  441. * @property {String} homeButton
  442. * Set the id of the custom 'Go home' button to use.
  443. * This is useful to have a custom button anywhere in the web page.<br>
  444. * To only change the button images, consider using
  445. * {@link OpenSeadragon.Options.navImages}
  446. *
  447. * @property {String} fullPageButton
  448. * Set the id of the custom 'Toggle full page' button to use.
  449. * This is useful to have a custom button anywhere in the web page.<br>
  450. * To only change the button images, consider using
  451. * {@link OpenSeadragon.Options.navImages}
  452. *
  453. * @property {String} rotateLeftButton
  454. * Set the id of the custom 'Rotate left' button to use.
  455. * This is useful to have a custom button anywhere in the web page.<br>
  456. * To only change the button images, consider using
  457. * {@link OpenSeadragon.Options.navImages}
  458. *
  459. * @property {String} rotateRightButton
  460. * Set the id of the custom 'Rotate right' button to use.
  461. * This is useful to have a custom button anywhere in the web page.<br>
  462. * To only change the button images, consider using
  463. * {@link OpenSeadragon.Options.navImages}
  464. *
  465. * @property {String} previousButton
  466. * Set the id of the custom 'Previous page' button to use.
  467. * This is useful to have a custom button anywhere in the web page.<br>
  468. * To only change the button images, consider using
  469. * {@link OpenSeadragon.Options.navImages}
  470. *
  471. * @property {String} nextButton
  472. * Set the id of the custom 'Next page' button to use.
  473. * This is useful to have a custom button anywhere in the web page.<br>
  474. * To only change the button images, consider using
  475. * {@link OpenSeadragon.Options.navImages}
  476. *
  477. * @property {Number} [initialPage=0]
  478. * If the viewer has been configured with a sequence of tile sources, display this page initially.
  479. *
  480. * @property {Boolean} [preserveViewport=false]
  481. * If the viewer has been configured with a sequence of tile sources, then
  482. * normally navigating to through each image resets the viewport to 'home'
  483. * position. If preserveViewport is set to true, then the viewport position
  484. * is preserved when navigating between images in the sequence.
  485. *
  486. * @property {Boolean} [showReferenceStrip=false]
  487. * If the viewer has been configured with a sequence of tile sources, then
  488. * display a scrolling strip of image thumbnails for navigating through the images.
  489. *
  490. * @property {String} [referenceStripScroll='horizontal']
  491. *
  492. * @property {Element} [referenceStripElement=null]
  493. *
  494. * @property {Number} [referenceStripHeight=null]
  495. *
  496. * @property {Number} [referenceStripWidth=null]
  497. *
  498. * @property {String} [referenceStripPosition='BOTTOM_LEFT']
  499. *
  500. * @property {Number} [referenceStripSizeRatio=0.2]
  501. *
  502. * @property {Boolean} [collectionMode=false]
  503. *
  504. * @property {Number} [collectionRows=3]
  505. *
  506. * @property {String} [collectionLayout='horizontal']
  507. *
  508. * @property {Number} [collectionTileSize=800]
  509. *
  510. * @property {String|Boolean} [crossOriginPolicy=false]
  511. * Valid values are 'Anonymous', 'use-credentials', and false. If false, canvas requests will
  512. * not use CORS, and the canvas will be tainted.
  513. *
  514. */
  515. /**
  516. * Settings for gestures generated by a pointer device.
  517. *
  518. * @typedef {Object} GestureSettings
  519. * @memberof OpenSeadragon
  520. *
  521. * @property {Boolean} scrollToZoom
  522. * Set to false to disable zooming on scroll gestures.
  523. *
  524. * @property {Boolean} clickToZoom
  525. * Set to false to disable zooming on click gestures.
  526. *
  527. * @property {Boolean} pinchToZoom
  528. * Set to false to disable zooming on pinch gestures.
  529. *
  530. * @property {Boolean} flickEnabled
  531. * Set to false to disable the kinetic panning effect (flick) at the end of a drag gesture.
  532. *
  533. * @property {Number} flickMinSpeed
  534. * 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.
  535. *
  536. * @property {Number} flickMomentum
  537. * 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.
  538. * A larger value will make the flick feel "lighter", while a smaller value will make the flick feel "heavier".
  539. * Note: springStiffness and animationTime also affect the "spring" used to stop the flick animation.
  540. *
  541. */
  542. /**
  543. * The names for the image resources used for the image navigation buttons.
  544. *
  545. * @typedef {Object} NavImages
  546. * @memberof OpenSeadragon
  547. *
  548. * @property {Object} zoomIn - Images for the zoom-in button.
  549. * @property {String} zoomIn.REST
  550. * @property {String} zoomIn.GROUP
  551. * @property {String} zoomIn.HOVER
  552. * @property {String} zoomIn.DOWN
  553. *
  554. * @property {Object} zoomOut - Images for the zoom-out button.
  555. * @property {String} zoomOut.REST
  556. * @property {String} zoomOut.GROUP
  557. * @property {String} zoomOut.HOVER
  558. * @property {String} zoomOut.DOWN
  559. *
  560. * @property {Object} home - Images for the home button.
  561. * @property {String} home.REST
  562. * @property {String} home.GROUP
  563. * @property {String} home.HOVER
  564. * @property {String} home.DOWN
  565. *
  566. * @property {Object} fullpage - Images for the full-page button.
  567. * @property {String} fullpage.REST
  568. * @property {String} fullpage.GROUP
  569. * @property {String} fullpage.HOVER
  570. * @property {String} fullpage.DOWN
  571. *
  572. * @property {Object} rotateleft - Images for the rotate left button.
  573. * @property {String} rotateleft.REST
  574. * @property {String} rotateleft.GROUP
  575. * @property {String} rotateleft.HOVER
  576. * @property {String} rotateleft.DOWN
  577. *
  578. * @property {Object} rotateright - Images for the rotate right button.
  579. * @property {String} rotateright.REST
  580. * @property {String} rotateright.GROUP
  581. * @property {String} rotateright.HOVER
  582. * @property {String} rotateright.DOWN
  583. *
  584. * @property {Object} previous - Images for the previous button.
  585. * @property {String} previous.REST
  586. * @property {String} previous.GROUP
  587. * @property {String} previous.HOVER
  588. * @property {String} previous.DOWN
  589. *
  590. * @property {Object} next - Images for the next button.
  591. * @property {String} next.REST
  592. * @property {String} next.GROUP
  593. * @property {String} next.HOVER
  594. * @property {String} next.DOWN
  595. *
  596. */
  597. /**
  598. * This function serves as a single point of instantiation for an {@link OpenSeadragon.Viewer}, including all
  599. * combinations of out-of-the-box configurable features.
  600. *
  601. * @function OpenSeadragon
  602. * @memberof module:OpenSeadragon
  603. * @param {OpenSeadragon.Options} options - Viewer options.
  604. * @returns {OpenSeadragon.Viewer}
  605. */
  606. window.OpenSeadragon = window.OpenSeadragon || function( options ){
  607. return new OpenSeadragon.Viewer( options );
  608. };
  609. (function( $ ){
  610. /**
  611. * The OpenSeadragon version.
  612. *
  613. * @member {Object} OpenSeadragon.version
  614. * @property {String} versionStr - The version number as a string ('major.minor.revision').
  615. * @property {Number} major - The major version number.
  616. * @property {Number} minor - The minor version number.
  617. * @property {Number} revision - The revision number.
  618. * @since 1.0.0
  619. */
  620. /* jshint ignore:start */
  621. $.version = {
  622. versionStr: '<%= osdVersion.versionStr %>',
  623. major: <%= osdVersion.major %>,
  624. minor: <%= osdVersion.minor %>,
  625. revision: <%= osdVersion.revision %>
  626. };
  627. /* jshint ignore:end */
  628. /**
  629. * Taken from jquery 1.6.1
  630. * [[Class]] -> type pairs
  631. * @private
  632. */
  633. var class2type = {
  634. '[object Boolean]': 'boolean',
  635. '[object Number]': 'number',
  636. '[object String]': 'string',
  637. '[object Function]': 'function',
  638. '[object Array]': 'array',
  639. '[object Date]': 'date',
  640. '[object RegExp]': 'regexp',
  641. '[object Object]': 'object'
  642. },
  643. // Save a reference to some core methods
  644. toString = Object.prototype.toString,
  645. hasOwn = Object.prototype.hasOwnProperty;
  646. /**
  647. * Taken from jQuery 1.6.1
  648. * @function isFunction
  649. * @memberof OpenSeadragon
  650. * @see {@link http://www.jquery.com/ jQuery}
  651. */
  652. $.isFunction = function( obj ) {
  653. return $.type(obj) === "function";
  654. };
  655. /**
  656. * Taken from jQuery 1.6.1
  657. * @function isArray
  658. * @memberof OpenSeadragon
  659. * @see {@link http://www.jquery.com/ jQuery}
  660. */
  661. $.isArray = Array.isArray || function( obj ) {
  662. return $.type(obj) === "array";
  663. };
  664. /**
  665. * A crude way of determining if an object is a window.
  666. * Taken from jQuery 1.6.1
  667. * @function isWindow
  668. * @memberof OpenSeadragon
  669. * @see {@link http://www.jquery.com/ jQuery}
  670. */
  671. $.isWindow = function( obj ) {
  672. return obj && typeof obj === "object" && "setInterval" in obj;
  673. };
  674. /**
  675. * Taken from jQuery 1.6.1
  676. * @function type
  677. * @memberof OpenSeadragon
  678. * @see {@link http://www.jquery.com/ jQuery}
  679. */
  680. $.type = function( obj ) {
  681. return ( obj === null ) || ( obj === undefined ) ?
  682. String( obj ) :
  683. class2type[ toString.call(obj) ] || "object";
  684. };
  685. /**
  686. * Taken from jQuery 1.6.1
  687. * @function isPlainObject
  688. * @memberof OpenSeadragon
  689. * @see {@link http://www.jquery.com/ jQuery}
  690. */
  691. $.isPlainObject = function( obj ) {
  692. // Must be an Object.
  693. // Because of IE, we also have to check the presence of the constructor property.
  694. // Make sure that DOM nodes and window objects don't pass through, as well
  695. if ( !obj || OpenSeadragon.type(obj) !== "object" || obj.nodeType || $.isWindow( obj ) ) {
  696. return false;
  697. }
  698. // Not own constructor property must be Object
  699. if ( obj.constructor &&
  700. !hasOwn.call(obj, "constructor") &&
  701. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  702. return false;
  703. }
  704. // Own properties are enumerated firstly, so to speed up,
  705. // if last one is own, then all properties are own.
  706. var key;
  707. for ( key in obj ) {}
  708. return key === undefined || hasOwn.call( obj, key );
  709. };
  710. /**
  711. * Taken from jQuery 1.6.1
  712. * @function isEmptyObject
  713. * @memberof OpenSeadragon
  714. * @see {@link http://www.jquery.com/ jQuery}
  715. */
  716. $.isEmptyObject = function( obj ) {
  717. for ( var name in obj ) {
  718. return false;
  719. }
  720. return true;
  721. };
  722. /**
  723. * True if the browser supports the HTML5 canvas element
  724. * @member {Boolean} supportsCanvas
  725. * @memberof OpenSeadragon
  726. */
  727. $.supportsCanvas = (function () {
  728. var canvasElement = document.createElement( 'canvas' );
  729. return !!( $.isFunction( canvasElement.getContext ) &&
  730. canvasElement.getContext( '2d' ) );
  731. }());
  732. }( OpenSeadragon ));
  733. /**
  734. * This closure defines all static methods available to the OpenSeadragon
  735. * namespace. Many, if not most, are taked directly from jQuery for use
  736. * to simplify and reduce common programming patterns. More static methods
  737. * from jQuery may eventually make their way into this though we are
  738. * attempting to avoid an explicit dependency on jQuery only because
  739. * OpenSeadragon is a broadly useful code base and would be made less broad
  740. * by requiring jQuery fully.
  741. *
  742. * Some static methods have also been refactored from the original OpenSeadragon
  743. * project.
  744. */
  745. (function( $ ){
  746. /**
  747. * Taken from jQuery 1.6.1
  748. * @function extend
  749. * @memberof OpenSeadragon
  750. * @see {@link http://www.jquery.com/ jQuery}
  751. */
  752. $.extend = function() {
  753. var options,
  754. name,
  755. src,
  756. copy,
  757. copyIsArray,
  758. clone,
  759. target = arguments[ 0 ] || {},
  760. length = arguments.length,
  761. deep = false,
  762. i = 1;
  763. // Handle a deep copy situation
  764. if ( typeof target === "boolean" ) {
  765. deep = target;
  766. target = arguments[ 1 ] || {};
  767. // skip the boolean and the target
  768. i = 2;
  769. }
  770. // Handle case when target is a string or something (possible in deep copy)
  771. if ( typeof target !== "object" && !OpenSeadragon.isFunction( target ) ) {
  772. target = {};
  773. }
  774. // extend jQuery itself if only one argument is passed
  775. if ( length === i ) {
  776. target = this;
  777. --i;
  778. }
  779. for ( ; i < length; i++ ) {
  780. // Only deal with non-null/undefined values
  781. options = arguments[ i ];
  782. if ( options !== null || options !== undefined ) {
  783. // Extend the base object
  784. for ( name in options ) {
  785. src = target[ name ];
  786. copy = options[ name ];
  787. // Prevent never-ending loop
  788. if ( target === copy ) {
  789. continue;
  790. }
  791. // Recurse if we're merging plain objects or arrays
  792. if ( deep && copy && ( OpenSeadragon.isPlainObject( copy ) || ( copyIsArray = OpenSeadragon.isArray( copy ) ) ) ) {
  793. if ( copyIsArray ) {
  794. copyIsArray = false;
  795. clone = src && OpenSeadragon.isArray( src ) ? src : [];
  796. } else {
  797. clone = src && OpenSeadragon.isPlainObject( src ) ? src : {};
  798. }
  799. // Never move original objects, clone them
  800. target[ name ] = OpenSeadragon.extend( deep, clone, copy );
  801. // Don't bring in undefined values
  802. } else if ( copy !== undefined ) {
  803. target[ name ] = copy;
  804. }
  805. }
  806. }
  807. }
  808. // Return the modified object
  809. return target;
  810. };
  811. $.extend( $, /** @lends OpenSeadragon */{
  812. /**
  813. * The default values for the optional settings documented at {@link OpenSeadragon.Options}.
  814. * @static
  815. * @type {Object}
  816. */
  817. DEFAULT_SETTINGS: {
  818. //DATA SOURCE DETAILS
  819. xmlPath: null,
  820. tileSources: null,
  821. tileHost: null,
  822. initialPage: 0,
  823. crossOriginPolicy: false,
  824. //PAN AND ZOOM SETTINGS AND CONSTRAINTS
  825. panHorizontal: true,
  826. panVertical: true,
  827. constrainDuringPan: false,
  828. wrapHorizontal: false,
  829. wrapVertical: false,
  830. visibilityRatio: 0.5, //-> how much of the viewer can be negative space
  831. minPixelRatio: 0.5, //->closer to 0 draws tiles meant for a higher zoom at this zoom
  832. defaultZoomLevel: 0,
  833. minZoomLevel: null,
  834. maxZoomLevel: null,
  835. //UI RESPONSIVENESS AND FEEL
  836. clickTimeThreshold: 300,
  837. clickDistThreshold: 5,
  838. springStiffness: 5.0,
  839. animationTime: 1.2,
  840. gestureSettingsMouse: { scrollToZoom: true, clickToZoom: true, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 20, flickMomentum: 0.40 },
  841. gestureSettingsTouch: { scrollToZoom: false, clickToZoom: false, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 20, flickMomentum: 0.40 },
  842. gestureSettingsPen: { scrollToZoom: false, clickToZoom: true, pinchToZoom: false, flickEnabled: false, flickMinSpeed: 20, flickMomentum: 0.40 },
  843. gestureSettingsUnknown: { scrollToZoom: false, clickToZoom: false, pinchToZoom: true, flickEnabled: true, flickMinSpeed: 20, flickMomentum: 0.40 },
  844. zoomPerClick: 2,
  845. zoomPerScroll: 1.2,
  846. zoomPerSecond: 1.0,
  847. blendTime: 0,
  848. alwaysBlend: false,
  849. autoHideControls: true,
  850. immediateRender: false,
  851. minZoomImageRatio: 0.9, //-> closer to 0 allows zoom out to infinity
  852. maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels
  853. pixelsPerWheelLine: 40,
  854. autoResize: true,
  855. //DEFAULT CONTROL SETTINGS
  856. showSequenceControl: true, //SEQUENCE
  857. sequenceControlAnchor: null, //SEQUENCE
  858. preserveViewport: false, //SEQUENCE
  859. navPrevNextWrap: false, //SEQUENCE
  860. showNavigationControl: true, //ZOOM/HOME/FULL/ROTATION
  861. navigationControlAnchor: null, //ZOOM/HOME/FULL/ROTATION
  862. showZoomControl: true, //ZOOM
  863. showHomeControl: true, //HOME
  864. showFullPageControl: true, //FULL
  865. showRotationControl: false, //ROTATION
  866. controlsFadeDelay: 2000, //ZOOM/HOME/FULL/SEQUENCE
  867. controlsFadeLength: 1500, //ZOOM/HOME/FULL/SEQUENCE
  868. mouseNavEnabled: true, //GENERAL MOUSE INTERACTIVITY
  869. //VIEWPORT NAVIGATOR SETTINGS
  870. showNavigator: false,
  871. navigatorId: null,
  872. navigatorPosition: null,
  873. navigatorSizeRatio: 0.2,
  874. navigatorMaintainSizeRatio: false,
  875. navigatorTop: null,
  876. navigatorLeft: null,
  877. navigatorHeight: null,
  878. navigatorWidth: null,
  879. navigatorAutoResize: true,
  880. // INITIAL ROTATION
  881. degrees: 0,
  882. // APPEARANCE
  883. opacity: 1,
  884. // LAYERS SETTINGS
  885. layersAspectRatioEpsilon: 0.0001,
  886. //REFERENCE STRIP SETTINGS
  887. showReferenceStrip: false,
  888. referenceStripScroll: 'horizontal',
  889. referenceStripElement: null,
  890. referenceStripHeight: null,
  891. referenceStripWidth: null,
  892. referenceStripPosition: 'BOTTOM_LEFT',
  893. referenceStripSizeRatio: 0.2,
  894. //COLLECTION VISUALIZATION SETTINGS
  895. collectionRows: 3, //or columns depending on layout
  896. collectionLayout: 'horizontal', //vertical
  897. collectionMode: false,
  898. collectionTileSize: 800,
  899. //PERFORMANCE SETTINGS
  900. imageLoaderLimit: 0,
  901. maxImageCacheCount: 200,
  902. timeout: 30000,
  903. useCanvas: true, // Use canvas element for drawing if available
  904. //INTERFACE RESOURCE SETTINGS
  905. prefixUrl: "/images/",
  906. navImages: {
  907. zoomIn: {
  908. REST: 'zoomin_rest.png',
  909. GROUP: 'zoomin_grouphover.png',
  910. HOVER: 'zoomin_hover.png',
  911. DOWN: 'zoomin_pressed.png'
  912. },
  913. zoomOut: {
  914. REST: 'zoomout_rest.png',
  915. GROUP: 'zoomout_grouphover.png',
  916. HOVER: 'zoomout_hover.png',
  917. DOWN: 'zoomout_pressed.png'
  918. },
  919. home: {
  920. REST: 'home_rest.png',
  921. GROUP: 'home_grouphover.png',
  922. HOVER: 'home_hover.png',
  923. DOWN: 'home_pressed.png'
  924. },
  925. fullpage: {
  926. REST: 'fullpage_rest.png',
  927. GROUP: 'fullpage_grouphover.png',
  928. HOVER: 'fullpage_hover.png',
  929. DOWN: 'fullpage_pressed.png'
  930. },
  931. rotateleft: {
  932. REST: 'rotateleft_rest.png',
  933. GROUP: 'rotateleft_grouphover.png',
  934. HOVER: 'rotateleft_hover.png',
  935. DOWN: 'rotateleft_pressed.png'
  936. },
  937. rotateright: {
  938. REST: 'rotateright_rest.png',
  939. GROUP: 'rotateright_grouphover.png',
  940. HOVER: 'rotateright_hover.png',
  941. DOWN: 'rotateright_pressed.png'
  942. },
  943. previous: {
  944. REST: 'previous_rest.png',
  945. GROUP: 'previous_grouphover.png',
  946. HOVER: 'previous_hover.png',
  947. DOWN: 'previous_pressed.png'
  948. },
  949. next: {
  950. REST: 'next_rest.png',
  951. GROUP: 'next_grouphover.png',
  952. HOVER: 'next_hover.png',
  953. DOWN: 'next_pressed.png'
  954. }
  955. },
  956. //DEVELOPER SETTINGS
  957. debugMode: false,
  958. debugGridColor: '#437AB2'
  959. },
  960. /**
  961. * TODO: get rid of this. I can't see how it's required at all. Looks
  962. * like an early legacy code artifact.
  963. * @static
  964. * @ignore
  965. */
  966. SIGNAL: "----seadragon----",
  967. /**
  968. * Returns a function which invokes the method as if it were a method belonging to the object.
  969. * @function
  970. * @param {Object} object
  971. * @param {Function} method
  972. * @returns {Function}
  973. */
  974. delegate: function( object, method ) {
  975. return function(){
  976. var args = arguments;
  977. if ( args === undefined ){
  978. args = [];
  979. }
  980. return method.apply( object, args );
  981. };
  982. },
  983. /**
  984. * An enumeration of Browser vendors.
  985. * @static
  986. * @type {Object}
  987. * @property {Number} UNKNOWN
  988. * @property {Number} IE
  989. * @property {Number} FIREFOX
  990. * @property {Number} SAFARI
  991. * @property {Number} CHROME
  992. * @property {Number} OPERA
  993. */
  994. BROWSERS: {
  995. UNKNOWN: 0,
  996. IE: 1,
  997. FIREFOX: 2,
  998. SAFARI: 3,
  999. CHROME: 4,
  1000. OPERA: 5
  1001. },
  1002. /**
  1003. * Returns a DOM Element for the given id or element.
  1004. * @function
  1005. * @param {String|Element} element Accepts an id or element.
  1006. * @returns {Element} The element with the given id, null, or the element itself.
  1007. */
  1008. getElement: function( element ) {
  1009. if ( typeof ( element ) == "string" ) {
  1010. element = document.getElementById( element );
  1011. }
  1012. return element;
  1013. },
  1014. /**
  1015. * Determines the position of the upper-left corner of the element.
  1016. * @function
  1017. * @param {Element|String} element - the elemenet we want the position for.
  1018. * @returns {OpenSeadragon.Point} - the position of the upper left corner of the element.
  1019. */
  1020. getElementPosition: function( element ) {
  1021. var result = new $.Point(),
  1022. isFixed,
  1023. offsetParent;
  1024. element = $.getElement( element );
  1025. isFixed = $.getElementStyle( element ).position == "fixed";
  1026. offsetParent = getOffsetParent( element, isFixed );
  1027. while ( offsetParent ) {
  1028. result.x += element.offsetLeft;
  1029. result.y += element.offsetTop;
  1030. if ( isFixed ) {
  1031. result = result.plus( $.getPageScroll() );
  1032. }
  1033. element = offsetParent;
  1034. isFixed = $.getElementStyle( element ).position == "fixed";
  1035. offsetParent = getOffsetParent( element, isFixed );
  1036. }
  1037. return result;
  1038. },
  1039. /**
  1040. * Determines the position of the upper-left corner of the element adjusted for current page and/or element scroll.
  1041. * @function
  1042. * @param {Element|String} element - the element we want the position for.
  1043. * @returns {OpenSeadragon.Point} - the position of the upper left corner of the element adjusted for current page and/or element scroll.
  1044. */
  1045. getElementOffset: function( element ) {
  1046. element = $.getElement( element );
  1047. var doc = element && element.ownerDocument,
  1048. docElement,
  1049. win,
  1050. boundingRect = { top: 0, left: 0 };
  1051. if ( !doc ) {
  1052. return new $.Point();
  1053. }
  1054. docElement = doc.documentElement;
  1055. if ( typeof element.getBoundingClientRect !== typeof undefined ) {
  1056. boundingRect = element.getBoundingClientRect();
  1057. }
  1058. win = ( doc == doc.window ) ?
  1059. doc :
  1060. ( doc.nodeType === 9 ) ?
  1061. doc.defaultView || doc.parentWindow :
  1062. false;
  1063. return new $.Point(
  1064. boundingRect.left + ( win.pageXOffset || docElement.scrollLeft ) - ( docElement.clientLeft || 0 ),
  1065. boundingRect.top + ( win.pageYOffset || docElement.scrollTop ) - ( docElement.clientTop || 0 )
  1066. );
  1067. },
  1068. /**
  1069. * Determines the height and width of the given element.
  1070. * @function
  1071. * @param {Element|String} element
  1072. * @returns {OpenSeadragon.Point}
  1073. */
  1074. getElementSize: function( element ) {
  1075. element = $.getElement( element );
  1076. return new $.Point(
  1077. element.clientWidth,
  1078. element.clientHeight
  1079. );
  1080. },
  1081. /**
  1082. * Returns the CSSStyle object for the given element.
  1083. * @function
  1084. * @param {Element|String} element
  1085. * @returns {CSSStyle}
  1086. */
  1087. getElementStyle:
  1088. document.documentElement.currentStyle ?
  1089. function( element ) {
  1090. element = $.getElement( element );
  1091. return element.currentStyle;
  1092. } :
  1093. function( element ) {
  1094. ele

Large files files are truncated, but you can click here to view the full file