├── build ├── ajaxmin.exe ├── build.cmd ├── build.py └── jsmin.py ├── doc ├── Seadragon.Browser.html ├── Seadragon.Button.html ├── Seadragon.ButtonGroup.html ├── Seadragon.Config.html ├── Seadragon.ControlAnchor.html ├── Seadragon.Debug.html ├── Seadragon.DisplayRect.html ├── Seadragon.Drawer.html ├── Seadragon.DziTileSource.html ├── Seadragon.EventManager.html ├── Seadragon.ImageLoader.html ├── Seadragon.MouseTracker.html ├── Seadragon.OverlayPlacement.html ├── Seadragon.Point.html ├── Seadragon.Profiler.html ├── Seadragon.Rect.html ├── Seadragon.Spring.html ├── Seadragon.Strings.html ├── Seadragon.TileSource.html ├── Seadragon.Utils.html ├── Seadragon.Viewer.html ├── Seadragon.Viewport.html ├── header.png ├── index.html └── styles.css ├── img ├── fullpage_grouphover.png ├── fullpage_hover.png ├── fullpage_pressed.png ├── fullpage_rest.png ├── home_grouphover.png ├── home_hover.png ├── home_pressed.png ├── home_rest.png ├── zoomin_grouphover.png ├── zoomin_hover.png ├── zoomin_pressed.png ├── zoomin_rest.png ├── zoomout_grouphover.png ├── zoomout_hover.png ├── zoomout_pressed.png └── zoomout_rest.png ├── license.txt ├── logo.dzi ├── logo_files ├── 0 │ └── 0_0.jpg ├── 1 │ └── 0_0.jpg ├── 2 │ └── 0_0.jpg ├── 3 │ └── 0_0.jpg ├── 4 │ └── 0_0.jpg ├── 5 │ └── 0_0.jpg ├── 6 │ └── 0_0.jpg ├── 7 │ └── 0_0.jpg ├── 8 │ └── 0_0.jpg ├── 9 │ ├── 0_0.jpg │ ├── 0_1.jpg │ ├── 1_0.jpg │ └── 1_1.jpg └── 10 │ ├── 0_0.jpg │ ├── 0_1.jpg │ ├── 0_2.jpg │ ├── 0_3.jpg │ ├── 1_0.jpg │ ├── 1_1.jpg │ ├── 1_2.jpg │ ├── 1_3.jpg │ ├── 2_0.jpg │ ├── 2_1.jpg │ ├── 2_2.jpg │ ├── 2_3.jpg │ ├── 3_0.jpg │ ├── 3_1.jpg │ ├── 3_2.jpg │ └── 3_3.jpg ├── readme.md ├── sample.html ├── seadragon-dev.js ├── seadragon-min.js └── src ├── Seadragon.Buttons.js ├── Seadragon.Config.js ├── Seadragon.Core.js ├── Seadragon.Debug.js ├── Seadragon.DeepZoom.js ├── Seadragon.DisplayRect.js ├── Seadragon.Drawer.js ├── Seadragon.EventManager.js ├── Seadragon.ImageLoader.js ├── Seadragon.MouseTracker.js ├── Seadragon.Point.js ├── Seadragon.Profiler.js ├── Seadragon.Rect.js ├── Seadragon.Spring.js ├── Seadragon.Strings.js ├── Seadragon.TileSource.js ├── Seadragon.Utils.js ├── Seadragon.Viewer.js ├── Seadragon.Viewport.js ├── _intro.txt └── _outro.txt /build/ajaxmin.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/build/ajaxmin.exe -------------------------------------------------------------------------------- /build/build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo /*! > seadragon-min.js 4 | echo * Seadragon Ajax 0.8.9 (custom build from source) >> seadragon-min.js 5 | echo * http://gallery.expression.microsoft.com/SeadragonAjax >> seadragon-min.js 6 | echo * This code is distributed under the license agreement at: >> seadragon-min.js 7 | echo * http://go.microsoft.com/fwlink/?LinkId=164943 >> seadragon-min.js 8 | echo */ >> seadragon-min.js 9 | 10 | type ..\src\_intro.txt > seadragon.js 11 | 12 | for %%f in ( 13 | Seadragon.Core.js 14 | Seadragon.Config.js 15 | Seadragon.Strings.js 16 | Seadragon.Debug.js 17 | Seadragon.Profiler.js 18 | Seadragon.Point.js 19 | Seadragon.Rect.js 20 | Seadragon.Spring.js 21 | Seadragon.Utils.js 22 | Seadragon.MouseTracker.js 23 | Seadragon.EventManager.js 24 | Seadragon.ImageLoader.js 25 | Seadragon.Buttons.js 26 | Seadragon.TileSource.js 27 | Seadragon.DisplayRect.js 28 | Seadragon.DeepZoom.js 29 | Seadragon.Viewport.js 30 | Seadragon.Drawer.js 31 | Seadragon.Viewer.js 32 | ) do ( 33 | echo. 34 | echo // %%f: 35 | echo. 36 | type ..\src\%%f 37 | ) >> seadragon.js 38 | 39 | type ..\src\_outro.txt >> seadragon.js 40 | 41 | ajaxmin.exe /Z /HC seadragon.js >> seadragon-min.js 42 | 43 | del seadragon.js -------------------------------------------------------------------------------- /build/build.py: -------------------------------------------------------------------------------- 1 | # Seadragon Ajax build script - concatenates the source files in dependency 2 | # order and minifies the result into seadragon-min.js. 3 | 4 | from jsmin import jsmin 5 | 6 | if __name__ != "__main__": 7 | print "Error: this script should be executed directly, not included." 8 | exit(1) 9 | 10 | HEADER = ''' 11 | /*! 12 | * Seadragon Ajax 0.8.9 (custom build from source) 13 | * http://gallery.expression.microsoft.com/SeadragonAjax 14 | * This code is distributed under the license agreement at: 15 | * http://go.microsoft.com/fwlink/?LinkId=164943 16 | */ 17 | ''' 18 | 19 | SRC_PATH = "../src/" 20 | SRC_FILES = [ 21 | "_intro.txt", 22 | "Seadragon.Core.js", 23 | "Seadragon.Config.js", 24 | "Seadragon.Strings.js", 25 | "Seadragon.Debug.js", 26 | "Seadragon.Profiler.js", 27 | "Seadragon.Point.js", 28 | "Seadragon.Rect.js", 29 | "Seadragon.Spring.js", 30 | "Seadragon.Utils.js", 31 | "Seadragon.MouseTracker.js", 32 | "Seadragon.EventManager.js", 33 | "Seadragon.ImageLoader.js", 34 | "Seadragon.Buttons.js", 35 | "Seadragon.TileSource.js", 36 | "Seadragon.DisplayRect.js", 37 | "Seadragon.DeepZoom.js", 38 | "Seadragon.Viewport.js", 39 | "Seadragon.Drawer.js", 40 | "Seadragon.Viewer.js", 41 | "_outro.txt" 42 | ] 43 | 44 | MIN_PATH = "seadragon-min.js" 45 | 46 | def readfile(path): 47 | file = open(path, 'r') 48 | contents = file.read() 49 | file.close() 50 | return contents 51 | 52 | def writefile(path, contents): 53 | file = open(path, 'w') 54 | file.write(contents) 55 | file.close() 56 | 57 | src_raw = '\n'.join([readfile(SRC_PATH + src_file) for src_file in SRC_FILES]) 58 | src_min = HEADER.strip() + '\n' + jsmin(src_raw) 59 | 60 | writefile(MIN_PATH, src_min) -------------------------------------------------------------------------------- /build/jsmin.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This code is original from jsmin by Douglas Crockford, it was translated to 4 | # Python by Baruch Even. The original code had the following copyright and 5 | # license. 6 | # 7 | # /* jsmin.c 8 | # 2007-05-22 9 | # 10 | # Copyright (c) 2002 Douglas Crockford (www.crockford.com) 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy of 13 | # this software and associated documentation files (the "Software"), to deal in 14 | # the Software without restriction, including without limitation the rights to 15 | # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 16 | # of the Software, and to permit persons to whom the Software is furnished to do 17 | # so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in all 20 | # copies or substantial portions of the Software. 21 | # 22 | # The Software shall be used for Good, not Evil. 23 | # 24 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 | # SOFTWARE. 31 | # */ 32 | 33 | from StringIO import StringIO 34 | 35 | def jsmin(js): 36 | ins = StringIO(js) 37 | outs = StringIO() 38 | JavascriptMinify().minify(ins, outs) 39 | str = outs.getvalue() 40 | if len(str) > 0 and str[0] == '\n': 41 | str = str[1:] 42 | return str 43 | 44 | def isAlphanum(c): 45 | """return true if the character is a letter, digit, underscore, 46 | dollar sign, or non-ASCII character. 47 | """ 48 | return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or 49 | (c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126)); 50 | 51 | class UnterminatedComment(Exception): 52 | pass 53 | 54 | class UnterminatedStringLiteral(Exception): 55 | pass 56 | 57 | class UnterminatedRegularExpression(Exception): 58 | pass 59 | 60 | class JavascriptMinify(object): 61 | 62 | def _outA(self): 63 | self.outstream.write(self.theA) 64 | def _outB(self): 65 | self.outstream.write(self.theB) 66 | 67 | def _get(self): 68 | """return the next character from stdin. Watch out for lookahead. If 69 | the character is a control character, translate it to a space or 70 | linefeed. 71 | """ 72 | c = self.theLookahead 73 | self.theLookahead = None 74 | if c == None: 75 | c = self.instream.read(1) 76 | if c >= ' ' or c == '\n': 77 | return c 78 | if c == '': # EOF 79 | return '\000' 80 | if c == '\r': 81 | return '\n' 82 | return ' ' 83 | 84 | def _peek(self): 85 | self.theLookahead = self._get() 86 | return self.theLookahead 87 | 88 | def _next(self): 89 | """get the next character, excluding comments. peek() is used to see 90 | if a '/' is followed by a '/' or '*'. 91 | """ 92 | c = self._get() 93 | if c == '/': 94 | p = self._peek() 95 | if p == '/': 96 | c = self._get() 97 | while c > '\n': 98 | c = self._get() 99 | return c 100 | if p == '*': 101 | c = self._get() 102 | while 1: 103 | c = self._get() 104 | if c == '*': 105 | if self._peek() == '/': 106 | self._get() 107 | return ' ' 108 | if c == '\000': 109 | raise UnterminatedComment() 110 | 111 | return c 112 | 113 | def _action(self, action): 114 | """do something! What you do is determined by the argument: 115 | 1 Output A. Copy B to A. Get the next B. 116 | 2 Copy B to A. Get the next B. (Delete A). 117 | 3 Get the next B. (Delete B). 118 | action treats a string as a single character. Wow! 119 | action recognizes a regular expression if it is preceded by ( or , or =. 120 | """ 121 | if action <= 1: 122 | self._outA() 123 | 124 | if action <= 2: 125 | self.theA = self.theB 126 | if self.theA == "'" or self.theA == '"': 127 | while 1: 128 | self._outA() 129 | self.theA = self._get() 130 | if self.theA == self.theB: 131 | break 132 | if self.theA <= '\n': 133 | raise UnterminatedStringLiteral() 134 | if self.theA == '\\': 135 | self._outA() 136 | self.theA = self._get() 137 | 138 | 139 | if action <= 3: 140 | self.theB = self._next() 141 | if self.theB == '/' and (self.theA == '(' or self.theA == ',' or 142 | self.theA == '=' or self.theA == ':' or 143 | self.theA == '[' or self.theA == '?' or 144 | self.theA == '!' or self.theA == '&' or 145 | self.theA == '|' or self.theA == ';' or 146 | self.theA == '{' or self.theA == '}' or 147 | self.theA == '\n'): 148 | self._outA() 149 | self._outB() 150 | while 1: 151 | self.theA = self._get() 152 | if self.theA == '/': 153 | break 154 | elif self.theA == '\\': 155 | self._outA() 156 | self.theA = self._get() 157 | elif self.theA <= '\n': 158 | raise UnterminatedRegularExpression() 159 | self._outA() 160 | self.theB = self._next() 161 | 162 | 163 | def _jsmin(self): 164 | """Copy the input to the output, deleting the characters which are 165 | insignificant to JavaScript. Comments will be removed. Tabs will be 166 | replaced with spaces. Carriage returns will be replaced with linefeeds. 167 | Most spaces and linefeeds will be removed. 168 | """ 169 | self.theA = '\n' 170 | self._action(3) 171 | 172 | while self.theA != '\000': 173 | if self.theA == ' ': 174 | if isAlphanum(self.theB): 175 | self._action(1) 176 | else: 177 | self._action(2) 178 | elif self.theA == '\n': 179 | if self.theB in ['{', '[', '(', '+', '-']: 180 | self._action(1) 181 | elif self.theB == ' ': 182 | self._action(3) 183 | else: 184 | if isAlphanum(self.theB): 185 | self._action(1) 186 | else: 187 | self._action(2) 188 | else: 189 | if self.theB == ' ': 190 | if isAlphanum(self.theA): 191 | self._action(1) 192 | else: 193 | self._action(3) 194 | elif self.theB == '\n': 195 | if self.theA in ['}', ']', ')', '+', '-', '"', '\'']: 196 | self._action(1) 197 | else: 198 | if isAlphanum(self.theA): 199 | self._action(1) 200 | else: 201 | self._action(3) 202 | else: 203 | self._action(1) 204 | 205 | def minify(self, instream, outstream): 206 | self.instream = instream 207 | self.outstream = outstream 208 | self.theA = '\n' 209 | self.theB = None 210 | self.theLookahead = None 211 | 212 | self._jsmin() 213 | self.instream.close() 214 | 215 | if __name__ == '__main__': 216 | import sys 217 | jsm = JavascriptMinify() 218 | jsm.minify(sys.stdin, sys.stdout) 219 | -------------------------------------------------------------------------------- /doc/Seadragon.Browser.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |
7 |18 | Describes the user's browser. 19 |
20 | 21 |25 | Name 26 | | 27 |28 | Description 29 | | 30 |
---|---|
33 | UNKNOWN 34 | | 35 |36 | Any browser that's not one of the below. 37 | | 38 |
41 | IE 42 | | 43 |44 | Microsoft Internet Explorer. 45 | | 46 |
49 | FIREFOX 50 | | 51 |52 | Mozilla Firefox. 53 | | 54 |
57 | SAFARI 58 | | 59 |60 | Apple Safari. 61 | | 62 |
65 | CHROME 66 | | 67 |68 | Google Chrome. 69 | | 70 |
73 | OPERA 74 | | 75 |76 | Opera. 77 | | 78 |
18 | A utility class for creating interactive and flexible image-based buttons. 19 | These buttons have four states: 20 |
21 |28 | This class requires an image for each state. It encapsulates the transitions 29 | between and behavior of these images. In addition, it supports callbacks 30 | for five different events: 31 |
32 |40 | These events are restricted subsets of the corresponding 41 | Seadragon.MouseTracker 42 | events. For example, the "release" callback is only fired when the MouseTracker 43 | releaseHandler's insideElmtPress and insideElmtRelease are both true. 44 | Similarly, the "click" callback is only fired when the MouseTracker clickHandler's 45 | quick is true. 46 |
47 |48 | To have related buttons function as a group, see the 49 | 50 | Seadragon.ButtonGroup class. 51 |
52 | 53 |57 | Signature 58 | | 59 |60 | Description 61 | | 62 |
---|---|
65 | Seadragon.Button(tooltip, srcRest, srcGroup, srcHover, srcDown, 66 | onPress, onRelease, onClick, onEnter, onExit) 67 | | 68 |69 | Creates a button with the given tooltip, state images and event handlers. 70 | | 71 |
78 | Name 79 | | 80 |81 | Type 82 | | 83 |84 | Description 85 | | 86 |
---|---|---|
89 | elmt 90 | | 91 |92 | HTML Element 93 | | 94 |95 | The element representing this button. This property is aliased; 96 | re-assigning it has no effect, but modifying it does. 97 | | 98 |
105 | Name and Signature 106 | | 107 |108 | Return Type 109 | | 110 |111 | Description 112 | | 113 |
---|---|---|
116 | notifyGroupEnter() 117 | | 118 |119 | - 120 | | 121 |122 | Notifies this button that the mouse has entered a button group 123 | that contains this button. This method is used by the 124 | Seadragon.ButtonGroup 125 | class. 126 | | 127 |
130 | notifyGroupExit() 131 | | 132 |133 | - 134 | | 135 |136 | Notifies this button that the mouse has exited a button group 137 | that contains this button. This method is used by the 138 | Seadragon.ButtonGroup 139 | class. 140 | | 141 |
146 | The following code creates a typical action-on-release button for going home 147 | and adds the HTML element as a control to an existing Seadragon viewer. 148 | Note that because the action should occur on any release over the button, 149 | the function is passed as the release handler and not the click handler. 150 | This allows the user to move the mouse and keep it pressed for any period 151 | of time before releasing. 152 |
153 |154 | If you want to add multiple buttons that are related, see the 155 | 156 | Seadragon.ButtonGroup example usage. 157 |
158 |159 | function goHome() { 160 | // ... 161 | } 162 | 163 | var button = new Seadragon.Button( 164 | "Go Home", 165 | "home_rest.png", 166 | "home_group.png", 167 | "home_hover.png", 168 | "home_down.png", 169 | null, // do nothing on initial press 170 | goHome, // go home on release 171 | null, // no need to use click thresholds 172 | null, // do nothing on enter 173 | null, // do nothing on exit 174 | ); 175 | 176 | viewer.addControl(button.elmt, Seadragon.ControlAnchor.TOP_LEFT); 177 |
178 | 179 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /doc/Seadragon.ButtonGroup.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 |18 | A utility class for grouping related Seadragon.Buttons. Handles activating and 20 | de-activating all buttons when the mouse enters and exits the group. 21 |
22 | 23 |27 | Signature 28 | | 29 |30 | Description 31 | | 32 |
---|---|
35 | Seadragon.ButtonGroup(buttons) 36 | | 37 |38 | Creates a ButtonGroup for the given list of buttons. 39 | | 40 |
47 | Name 48 | | 49 |50 | Type 51 | | 52 |53 | Description 54 | | 55 |
---|---|---|
58 | elmt 59 | | 60 |61 | HTML Element 62 | | 63 |64 | The element representing this button group. This property is 65 | aliased; re-assigning it has no effect, but modifying it does. 66 | | 67 |
74 | Name and Signature 75 | | 76 |77 | Return Type 78 | | 79 |80 | Description 81 | | 82 |
---|---|---|
85 | emulateEnter() 86 | | 87 |88 | - 89 | | 90 |91 | Emulates the mouse entering this button group, so that each 92 | contained button is activated. 93 | | 94 |
97 | emulateExit() 98 | | 99 |100 | - 101 | | 102 |103 | Emulates the mouse exiting this button group, so that each 104 | contained button is de-activated. 105 | | 106 |
111 | The following code groups together four related buttons, and adds the 112 | group's HTML element as a control to an existing Seadragon viewer. 113 | This is the technique we use for our own navigation control. 114 |
115 |116 | var zoomInButton = new Seadragon.Button(...); 117 | var zoomOutButton = new Seadragon.Button(...); 118 | var goHomeButton = new Seadragon.Button(...); 119 | var fullPageButton = new Seadragon.Button(...); 120 | 121 | var navBar = new Seadragon.ButtonGroup([ 122 | zoomInButton, zoomOutButton, goHomeButton, fullPageButton]); 123 | 124 | viewer.addControl(navBar.elmt, Seadragon.ControlAnchor.BOTTOM_RIGHT); 125 |
126 | 127 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /doc/Seadragon.Config.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 |18 | This static class defines configuration values that can be tweaked to customize 19 | Seadragon behavior. Unless otherwise noted, a change to any value will result 20 | in immediately visible changes to all viewers. 21 |
22 | 23 |27 | Name 28 | | 29 |30 | Type 31 | | 32 |33 | Description 34 | | 35 |
---|---|---|
38 | debugMode 39 | | 40 |41 | Boolean 42 | | 43 |44 | Whether messages should be logged and fail-fast behavior should 45 | be provided. Default is false. 46 | | 47 |
50 | animationTime 51 | | 52 |53 | Number 54 | | 55 |56 | The amount of time in seconds that animations should last. Default is 1.5. 57 | | 58 |
61 | blendTime 62 | | 63 |64 | Number 65 | | 66 |67 | The amount of time in seconds that new tiles take to blend from transparent to opaque. 68 | Default is 0.5. 69 | | 70 |
73 | alwaysBlend 74 | | 75 |76 | Boolean 77 | | 78 |79 | Whether tiles should always blend in and out, not just when they're first loaded. 80 | Default is false. 81 | | 82 |
85 | autoHideControls 86 | | 87 |88 | Boolean 89 | | 90 |91 | Whether controls should get automatically hidden when the user's 92 | mouse is off the viewer and the image has stopped animating. 93 | Default is true. 94 | | 95 |
98 | constrainDuringPan 99 | | 100 |101 | Boolean 102 | | 103 |104 | Whether the viewport should be constrained during panning 105 | (i.e. while the mouse is being is dragged), not just afterwards 106 | (i.e. after the mouse has been released). Default is true. 107 | | 108 |
111 | immediateRender 112 | | 113 |114 | Boolean 115 | | 116 |117 | Whether the most appropriate tiles should always be rendered first, before any lower-res 118 | tiles are rendered. This loses the "sharpening" effect and instead creates a very 119 | visible "tiling" effect. Default is false. 120 | | 121 |
124 | logarithmicZoom 125 | | 126 |127 | Boolean 128 | | 129 |130 | Whether the viewport should animate zoom logarithmically instead of linearly. 131 | This results in zooming in at the same rate as zooming out. Default is true. 132 | | 133 |
136 | wrapHorizontal 137 | | 138 |139 | Boolean 140 | | 141 |142 | Whether tiles should be "wrapped" horizontally, so that there are no left or right edges. 143 | Default is false. 144 | NOTE: this is an experimental API and is not guaranteed to work. 145 | The API is also very likely to change in the future. Use at your own risk! 146 | | 147 |
150 | wrapVertical 151 | | 152 |153 | Boolean 154 | | 155 |156 | Whether tiles should be "wrapped" vertically, so that there are no top or bottom edges. 157 | Default is false. 158 | NOTE: this is an experimental API and is not guaranteed to work. 159 | The API is also very likely to change in the future. Use at your own risk! 160 | | 161 |
164 | wrapOverlays 165 | | 166 |167 | Boolean 168 | | 169 |170 | Whether overlays should be continually re-positioned to match any 171 | horizontal or vertical wrapping. This has no effect if neither 172 | wrapHorizontal nor wrapVertical are set. 173 | Default is false. 174 | NOTE: this is an experimental API and is not guaranteed to work. 175 | The API is also very likely to change in the future. Use at your own risk! 176 | | 177 |
180 | transformOverlays 181 | | 182 |183 | Boolean 184 | | 185 |186 | Whether overlays should be scaled using CSS transforms rather than 188 | regular block sizing, in browsers that support it. This smoothly scales overlays and 189 | their content, including text, but the results may not appear the same in other browsers. 190 | Default is false. 191 | NOTE: this is an experimental API and is not guaranteed to work. 192 | The API is also very likely to change in the future. Use at your own risk! 193 | | 194 |
197 | minZoomDimension 198 | | 199 |200 | Number 201 | | 202 |203 | [Deprecated] The minimum size (in screen pixels) of either dimension that can result from zooming 204 | out. Default is null. This has been deprecated in favor of minZoomImageRatio, but this will still 205 | be respected if it's explicitly set. 206 | | 207 |
210 | minZoomImageRatio 211 | | 212 |213 | Number 214 | | 215 |216 | The minimum image ratio (image size to viewer size) in both dimensions that can result 217 | from zooming out. Default is 0.8. 218 | | 219 |
222 | maxZoomPixelRatio 223 | | 224 |225 | Number 226 | | 227 |228 | The maximum pixel ratio (screen pixel to content pixel) that can result from zooming 229 | in. Default is 2. 230 | | 231 |
234 | visibilityRatio 235 | | 236 |237 | Number 238 | | 239 |240 | The minimum portion of the viewport that must show visible content 241 | in both dimensions. Default is 0.8. 242 | | 243 |
246 | springStiffness 247 | | 248 |249 | Number 250 | | 251 |252 | Determines how sharply the springs used for animations move. Default is 5.0. 253 | | 254 |
257 | imageLoaderLimit 258 | | 259 |260 | Number 261 | | 262 |263 | The maximum number of concurrent image downloads that can be performed by each viewer. 264 | Default is 2. 265 | | 266 |
269 | clickTimeThreshold 270 | | 271 |272 | Number 273 | | 274 |275 | The maximum number of milliseconds that can pass between a mousedown and a mouseup 276 | for the action to still be considered a "quick" click. Default is 200. 277 | | 278 |
281 | clickDistThreshold 282 | | 283 |284 | Number 285 | | 286 |287 | The maximum number of pixels the mouse can move between a mousedown and a mouseup 288 | for the action to still be considered a "quick" click. Default is 5. 289 | | 290 |
293 | zoomPerClick 294 | | 295 |296 | Number 297 | | 298 |299 | The factor by which images should zoom when clicked on. 300 | Default is 2. 301 | | 302 |
305 | zoomPerScroll 306 | | 307 |308 | Number 309 | | 310 |311 | The factor by which images should zoom when scrolled over. 312 | Default is cube root of 2. 313 | | 314 |
317 | zoomPerSecond 318 | | 319 |320 | Number 321 | | 322 |323 | The factor by which images should zoom over each second when the 324 | zoom buttons are held down. Default is 2. 325 | | 326 |
329 | proxyUrl 330 | | 331 |332 | String 333 | | 334 |335 | The URL to prefix before any AJAX requests to overcome browser cross-site restrictions. 336 | The URL should be of the form "some/proxy.aspx?site=", so that the target site URL 337 | is passed as a GET parameter to the proxy. This URL can be 338 | absolute or relative, but must be on the same domain as the HTML 339 | page. If relative, it must be relative to the HTML page. Default is null. 340 | | 341 |
344 | imagePath 345 | | 346 |347 | String 348 | | 349 |350 | The path for all UI images. This can be absolute or relative. 351 | If relative, it must be relative to the HTML page. 352 | A change to this value will only affect new viewers. 353 | Default is "img/" for the distributed version of this library, 354 | and "http://seadragon.com/ajax/0.8/img/" for the version hosted on 355 | seadragon.com. 356 | | 357 |
18 | Used to define which corner a control is anchored to. This allows newly 19 | added controls to be placed without overlapping previous controls, and 20 | for controls to stretch and shrink as another control is resized. 21 |
22 | 23 |27 | Name 28 | | 29 |30 | Description 31 | | 32 |
---|---|
35 | NONE 36 | | 37 |38 | The control is not anchored; it must be absolutely positioned through CSS. 39 | | 40 |
43 | TOP_LEFT 44 | | 45 |46 | The control is anchored to the top-left corner of the viewer. 47 | | 48 |
51 | TOP_RIGHT 52 | | 53 |54 | The control is anchored to the top-right corner of the viewer. 55 | | 56 |
59 | BOTTOM_RIGHT 60 | | 61 |62 | The control is anchored to the bottom-right corner of the viewer. 63 | | 64 |
67 | BOTTOM_LEFT 68 | | 69 |70 | The control is anchored to the bottom-left corner of the viewer. 71 | | 72 |
18 | This static class provides convenience debugging functions. 19 |
20 | 21 |25 | Name and Signature 26 | | 27 |28 | Return Type 29 | | 30 |31 | Description 32 | | 33 |
---|---|---|
36 | log(msg, important?) 37 | | 38 |39 | - 40 | | 41 |42 | If Seadragon.Config.debugMode is true, writes the given message to 43 | the browser's Javascript console. If the browser doesn't provide 44 | a Javascript console and the optional important parameter is 45 | true, alerts the message instead. 46 | | 47 |
50 | error(msg, exception?) 51 | | 52 |53 | - 54 | | 55 |56 | Writes the given message to the browser's Javascript console as 57 | an error message. If the browser doesn't provide a Javascript 58 | console, alerts the message if Seadragon.Config.debugMode is true. 59 | In either case, if Seadragon.Config.debugMode is true, provides 60 | fail-fast behavior by throwing an error to crash Seadragon. If an 61 | exception is given, the thrown error is the same exception, 62 | otherwise it is a new Error object with the given message. 63 | | 64 |
67 | fail(msg) 68 | | 69 |70 | - 71 | | 72 |73 | Alerts to the user the Seadragon.Strings "Errors.Failure" message, 74 | and throws an error to crash Seadragon. 75 | | 76 |
18 | A class that represents a display rectangle, used by the Deep Zoom 19 | file format. This class extends the Seadragon.Rect class to include the minimum 21 | and maximum tile level. 22 |
23 | 24 |28 | Signature 29 | | 30 |31 | Description 32 | | 33 |
---|---|
36 | Seadragon.DisplayRect(x, y, width, height, minLevel, maxLevel) 37 | | 38 |39 | Creates a DisplayRect for the given point, size and levels. 40 | Note that minLevel and maxLevel are both inclusive. 41 | | 42 |
49 | Name 50 | | 51 |52 | Type 53 | | 54 |55 | Description 56 | | 57 |
---|---|---|
60 | minLevel 61 | | 62 |63 | Number 64 | | 65 |66 | The minimum level of this display rectangle. 67 | | 68 |
71 | maxLevel 72 | | 73 |74 | Number 75 | | 76 |77 | The maximum level of this display rectangle. 78 | | 79 |
18 | This class handles and encapsulates the rendering of Seadragon content. 19 | It also provides support for overlays, which are HTML elements that are 20 | rendered on top of the content. 21 |
22 |23 | Currently, the Drawer supports two rendering methods: the first uses 24 | regular <img> elements, while the second uses the HTML 5 25 | <canvas> element. The 27 | rendering method used for a given browser is determined by browser 28 | capability and rendering quality. 29 |
30 | 31 |35 | Signature 36 | | 37 |38 | Description 39 | | 40 |
---|---|
43 | Seadragon.Drawer(source, viewport, elmt) 44 | | 45 |46 | Creates a Drawer for the given Seadragon.TileSource, in the given 48 | Seadragon.Viewport, 49 | inside the given HTML element. 50 | | 51 |
56 | All properties are aliased; re-assigning them has no effect, but 57 | modifying them does. 58 |
59 |62 | Name 63 | | 64 |65 | Type 66 | | 67 |68 | Description 69 | | 70 |
---|---|---|
73 | elmt 74 | | 75 |76 | HTML Element 77 | | 78 |79 | The HTML element inside which the content is rendered. This is 80 | the same HTML element that is passed into the constructor. The 81 | specifics of this element and its children are unspecified and 82 | implementation-dependent. 83 | | 84 |
87 | profiler 88 | | 89 |90 | Seadragon.Profiler 91 | | 92 |93 | A Seadragon.Profiler 94 | instance that is profiling each update. 95 | | 96 |
104 | Name and Signature 105 | | 106 |107 | Return Type 108 | | 109 |110 | Description 111 | | 112 |
---|---|---|
115 | addOverlay(elmt, rect) 116 | | 117 |118 | - 119 | | 120 |121 | Adds the given HTML element as an overlay to the content if it 122 | has not been added before. This overlay will 123 | scale with the content; the element's size will always match the 124 | given Seadragon.Rect, 125 | which must be in normalized coordinates (see 126 | Seadragon.Viewport 127 | for details). 128 | | 129 |
132 | addOverlay(elmt, point, placement?) 133 | | 134 |135 | - 136 | | 137 |138 | Adds the given HTML element as an overlay to the content if it 139 | has not been added before. This overlay will not 140 | scale with the content; its size will remain untouched. The 141 | overlay will be placed at the given Seadragon.Point, which must be a 143 | normalized coordinate (see Seadragon.Viewport for details). 145 | An optional Seadragon.OverlayPlacement 147 | value can be given that describes which part of the element is 148 | specifically placed at the given point. If none is given, the 149 | element is placed by its center. 150 | | 151 |
154 | updateOverlay(elmt, rect) 155 | | 156 |157 | - 158 | | 159 |160 | Updates the given HTML element overlay to the given 161 | Seadragon.Rect. 162 | The overlay will scale with the content. 163 | | 164 |
167 | updateOverlay(elmt, point, placement?) 168 | | 169 |170 | - 171 | | 172 |173 | Updates the given HTML element overlay to the given 174 | Seadragon.Point. 175 | and optionally the given Seadragon.OverlayPlacement. 177 | If no placement is given, the element is placed by its center. 178 | The overlay will not scale with the content. 179 | | 180 |
183 | removeOverlay(elmt) 184 | | 185 |186 | - 187 | | 188 |189 | Removes the given HTML element overlay. 190 | | 191 |
194 | clearOverlays() 195 | | 196 |197 | - 198 | | 199 |200 | Removes all HTML element overlays. 201 | | 202 |
208 | Name and Signature 209 | | 210 |211 | Return Type 212 | | 213 |214 | Description 215 | | 216 |
---|---|---|
219 | needsUpdate() 220 | | 221 |222 | Boolean 223 | | 224 |225 | Returns true if the drawer needs an update since the last update. 226 | | 227 |
230 | reset() 231 | | 232 |233 | - 234 | | 235 |236 | Resets this drawer so that the content is re-drawn from scratch. 237 | Overlays are maintained, however. 238 | | 239 |
242 | update() 243 | | 244 |245 | - 246 | | 247 |248 | Updates the drawn content based on the viewport's current values. 249 | | 250 |
18 | A subclass of Seadragon.TileSource that handles 20 | Deep Zoom Images. This class supports sparse images. 21 |
22 | 23 |27 | Signature 28 | | 29 |30 | Description 31 | | 32 |
---|---|
35 | Seadragon.DziTileSource(width, height, tileSize, tileOverlap, tilesUrl, tileFormat, 36 | displayRects?) 37 | | 38 |39 | Creates a DziTileSource for a Deep Zoom Image having tiles of the given format at 40 | the given URL. If the image is sparse, the image's display rectangles should be 41 | given as a list of Seadragon.DisplayRect instances. 43 | | 44 |
51 | Name 52 | | 53 |54 | Type 55 | | 56 |57 | Description 58 | | 59 |
---|---|---|
62 | tileFormat 63 | | 64 |65 | String 66 | | 67 |68 | The image format of the tiles in this Deep Zoom Image, e.g. "jpg" or "png". 69 | | 70 |
73 | displayRects 74 | | 75 |76 | Array 77 | | 78 |79 | If this image is sparse, the Seadragon.DisplayRect instances 81 | given to the constructor, otherwise null. 82 | | 83 |
90 | Name and Signature 91 | | 92 |93 | Return Type 94 | | 95 |96 | Description 97 | | 98 |
---|---|---|
101 | getTileUrl(level, x, y) 102 | | 103 |104 | String 105 | | 106 |107 | Returns the URL for the given tile. 108 | | 109 |
112 | tileExists(level, x, y) 113 | | 114 |115 | Boolean 116 | | 117 |118 | Returns true if the given tile exists and is part of the sparse image. 119 | | 120 |
127 | Name and Signature 128 | | 129 |130 | Return Type 131 | | 132 |133 | Description 134 | | 135 |
---|---|---|
138 | createFromJson(jsonObj, callback?) 139 | | 140 |141 | Seadragon.DziTileSource 142 | | 143 |
144 | Creates a new Seadragon.DziTileSource from the given JSON object of the form:
145 |
146 | { 147 | url: "http://example.com/foo.dzi", 148 | width: 5000, 149 | height: 4000, 150 | tileSize: 254, 151 | tileOverlap: 1, 152 | tileFormat: "png" 153 | }154 | 155 | This is the same JSON format that's returned by the 156 | Zoom.it API. 157 | 158 | The JSON object may optionally have a displayRects 159 | property if the DZI is a sparse image. This property should be an array of 160 | DisplayRect arrays, where a DisplayRect array is of the form 161 | [x, y, width, height, minLevel, maxLevel]. 162 | 163 | With this method, the XML of the DZI is never downloaded. (The location of the XML, 164 | given by the url property, is still needed in order to 165 | determine the location of the tiles.) 166 | 167 | If a callback function is given, the Seadragon.DziTileSource is passed as the sole 168 | parameter to the callback upon completion. Otherwise, the Seadragon.DziTileSource 169 | is returned by this method. 170 | 171 | If there was an error with the JSON and a callback function was given, null is 172 | passed to the callback along with an optional error message as a second parameter. 173 | If there was an error with the JSON and no callback function was given, an error is thrown. 174 | |
175 |
178 | createFromXml(xmlUrl, xmlString?, callback?) 179 | | 180 |181 | Seadragon.DziTileSource 182 | | 183 |
184 | Creates a new Seadragon.DziTileSource from the XML file at the given URL. If the contents
185 | of the XML are given, the XML is not actually downloaded; otherwise, it is.
186 | (The location of the XML is needed in either case to determine the location of the
187 | tiles.) 188 | 189 | If a callback function is given, the XML is loaded/parsed asynchronously, 190 | and the Seadragon.DziTileSource is passed as the sole parameter to the callback upon 191 | completion. Otherwise, the XML is loaded/parsed synchronously and the Seadragon.DziTileSource 192 | is returned by this method. 193 | 194 | If the XML fails to load/parse and a callback function 195 | was given, null is passed to the callback along with an optional error message as 196 | a second parameter. If the XML fails to load/parse and no callback function was 197 | given, an error is thrown. 198 | |
199 |
202 | getTilesUrl(xmlUrl) 203 | | 204 |205 | String 206 | | 207 |208 | Given the XML URL of a DZI (e.g. "http://example.com/foo.dzi"), 209 | returns the URL of the DZI's tiles (e.g. "http://example.com/foo_files/"). 210 | | 211 |
18 | A utility class for managing event listeners. 19 |
20 | 21 |25 | Signature 26 | | 27 |28 | Description 29 | | 30 |
---|---|
33 | Seadragon.EventManager() 34 | | 35 |36 | Creates an EventManager. 37 | | 38 |
45 | Name and Signature 46 | | 47 |48 | Return Type 49 | | 50 |51 | Description 52 | | 53 |
---|---|---|
56 | addListener(eventName, handler) 57 | | 58 |59 | - 60 | | 61 |62 | Adds the given handler function as a listener for the event with the given name. 63 | | 64 |
67 | removeListener(eventName, handler) 68 | | 69 |70 | - 71 | | 72 |73 | Removes the given handler function as a listener for the event with the given name. 74 | | 75 |
78 | clearListeners(eventName) 79 | | 80 |81 | - 82 | | 83 |84 | Removes all listeners for the given event. 85 | | 86 |
89 | trigger(eventName, ...) 90 | | 91 |92 | - 93 | | 94 |95 | Triggers the event with the given name, optionally passing any 96 | additional arguments to the registered handler functions. 97 | | 98 |
18 | A utility class that manages the asynchronous download of images. The 19 | maximum number of concurrent downloads per instance of this class is 20 | defined by Seadragon.Config.imageLoaderLimit, and new image download 21 | requests are rejected when all "slots" are filled. As images finish 22 | downloading, these slots open up. 23 |
24 | 25 |29 | Signature 30 | | 31 |32 | Description 33 | | 34 |
---|---|
37 | Seadragon.ImageLoader() 38 | | 39 |40 | Creates an ImageLoader with all slots empty. 41 | | 42 |
49 | Name and Signature 50 | | 51 |52 | Return Type 53 | | 54 |55 | Description 56 | | 57 |
---|---|---|
60 | loadImage(src, callback) 61 | | 62 |63 | Boolean 64 | | 65 |66 | If no image download slots are available, returns false immediately. 67 | Otherwise queues an asynchronous download of the image at the given 68 | URL and returns true. Once the download is complete, the given 69 | callback function is called with the image as the sole argument 70 | if the download succeeded, or null if the download failed. 71 | | 72 |
18 | A utility class that abstracts away the complexity of a proper mouse-tracking state 19 | machine. Registers mouse event listeners on an element, and invokes user-set handlers 20 | for useful mouse events. Also uses custom thresholds for clicks to differentiate 21 | them from drags and holds more precisely. 22 |
23 | 24 |28 | Signature 29 | | 30 |31 | Description 32 | | 33 |
---|---|
36 | Seadragon.MouseTracker(elmt) 37 | | 38 |39 | Creates a MouseTracker for the given HTML element. 40 | This MouseTracker is not initially tracking. 41 | | 42 |
47 | All handler properties except target are user-defined functions that are 48 | invoked by this class. Setting a handler means that it will get invoked 49 | on the next corresponding event. All handlers are passed at least two 50 | arguments: the MouseTracker instance that invoked the handler, and the 51 | position of the mouse, relative to the target element, as a 52 | Seadragon.Point. 53 | All handlers are initially null. 54 |
55 |58 | Name 59 | | 60 |61 | Type 62 | | 63 |64 | Description 65 | | 66 |
---|---|---|
69 | target 70 | | 71 |72 | HTML Element 73 | | 74 |75 | The element that is getting tracked. This property is aliased; 76 | re-assigning it has no effect, but modifying it does. 77 | | 78 |
81 | enterHandler 82 | | 83 |84 | Function ( 85 | tracker, 86 | position, 87 | buttonDownElmt, 88 | buttonDownAny 89 | ) 90 | | 91 |
92 | Handler function for the mouse entering the target element. 93 | 94 | Both buttonDownElmt and buttonDownAny are 95 | false if the mouse button is up. Otherwise, buttonDownAny 96 | is always true, and buttonDownElmt is true if the mouse 97 | was initially pressed inside the target element. (Note that 98 | buttonDownElmt implies buttonDownAny, but not 99 | necessarily the reverse.) 100 | |
101 |
104 | exitHandler 105 | | 106 |107 | Function ( 108 | tracker, 109 | position, 110 | buttonDownElmt, 111 | buttonDownAny 112 | ) 113 | | 114 |
115 | Handler function for the mouse exiting the target element. 116 | 117 | Both buttonDownElmt and buttonDownAny are 118 | false if the mouse button is up. Otherwise, buttonDownAny 119 | is always true, and buttonDownElmt is true if the mouse 120 | was initially pressed inside the target element. (Note that 121 | buttonDownElmt implies buttonDownAny, but not 122 | necessarily the reverse.) 123 | |
124 |
127 | pressHandler 128 | | 129 |130 | Function ( 131 | tracker, 132 | position 133 | ) 134 | | 135 |136 | Handler function for the mouse button being pressed inside the 137 | target element. 138 | | 139 |
142 | releaseHandler 143 | | 144 |145 | Function ( 146 | tracker, 147 | position, 148 | insideElmtPress, 149 | insideElmtRelease 150 | ) 151 | | 152 |
153 | Handler function for the mouse button being released. Note that
154 | like regular "mouseup" events, this is always triggered when the
155 | mouse is released over the target element. However, unlike
156 | regular "mouseup" events, this is also always triggered when the
157 | corresponding "mousedown" event was fired inside the target
158 | element, even if the mouse is no longer over the element. 159 | 160 | insideElmtPress is true if the mouse was initially 161 | pressed inside the target element, and insideElmtRelease 162 | is true if this release occured inside the target element. (Note 163 | that at least one of insideElmtPress and 164 | insideElmtRelease will be true.) 165 | |
166 |
169 | clickHandler 170 | | 171 |172 | Function ( 173 | tracker, 174 | position, 175 | quick, 176 | shift 177 | ) 178 | | 179 |
180 | Handler function for the mouse button being clicked inside the
181 | target element. 182 | 183 | quick is true if, during the click, the mouse was 184 | neither moved a significant distance nor held down for a 185 | significant amount of time. shift is true if the shift 186 | key was pressed during the click. (The thresholds used to 187 | determine if the click was quick are defined in 188 | Seadragon.Config.) 189 | |
190 |
193 | dragHandler 194 | | 195 |196 | Function ( 197 | tracker, 198 | position, 199 | delta, 200 | shift 201 | ) 202 | | 203 |
204 | Handler function for the mouse being dragged. This is triggered only when the drag
205 | was initially begun inside the target element, but is triggered wherever the mouse
206 | may be at the moment. 207 | 208 | delta is a Seadragon.Point for the distance the 210 | mouse was dragged. shift is true if the shift key was 211 | pressed during the drag. 212 | |
213 |
216 | scrollHandler 217 | | 218 |219 | Function ( 220 | tracker, 221 | position, 222 | scroll, 223 | shift 224 | ) 225 | | 226 |
227 | Handler function for the mouse wheel being scrolled inside the
228 | target element. 229 | 230 | scroll is the amount the mouse wheel was scrolled, 231 | normalized between -1 and 1. shift is true if the shift 232 | key was pressed during the scroll. 233 | |
234 |
241 | Name and Signature 242 | | 243 |244 | Return Type 245 | | 246 |247 | Description 248 | | 249 |
---|---|---|
252 | isTracking() 253 | | 254 |255 | Boolean 256 | | 257 |258 | Returns true if the target element is currently being tracked. 259 | | 260 |
263 | setTracking(tracking) 264 | | 265 |266 | - 267 | | 268 |269 | Sets whether the target element should be tracked. 270 | | 271 |
276 | The following code allows a chess piece to be dragged and dropped on a 277 | chess board. 278 |
279 |280 | var tracker = new Seadragon.MouseTracker(piece); 281 | var location = null; 282 | 283 | tracker.pressHandler = function(tracker, position) { 284 | piece.pickUp(); // draw piece bigger, add shadow, etc. 285 | location = new Seadragon.Point( 286 | parseInt(piece.style.left), 287 | parseInt(piece.style.top) 288 | ); // remember where piece was originally drawn 289 | }; 290 | 291 | tracker.dragHandler = function(tracker, position, delta, shift) { 292 | location = location.plus(delta); 293 | piece.style.left = location.x + "px"; 294 | piece.style.top = location.y + "px"; 295 | }; 296 | 297 | tracker.releaseHandler = function(tracker, position, insideElmtPress, insideElmtRelease) { 298 | if (!insideElmtPress) { 299 | return; // ignore releases from outside 300 | } 301 | 302 | piece.putDown(); // draw piece smaller, remove shadow, etc. 303 | location = null; 304 | }; 305 | 306 | tracker.setTracking(true); // begin tracking 307 |
308 |309 | The following code toggles a button between a regular state, a hover 310 | state, and a pressed state. It only goes to hover when the mouse is over 311 | the button and the mouse button is up. 312 |
313 |314 | var tracker = new Seadragon.MouseTracker(button); 315 | 316 | tracker.enterHandler = function(tracker, position, buttonDownElmt, buttonDownAny) { 317 | if (buttonDownElmt) { 318 | // the mouse is down and was pressed inside the button 319 | button.goToPressedState(); 320 | } else if (buttonDownAny) { 321 | // the mouse is down from elsewhere, stay in normal state 322 | return; 323 | } else { 324 | // the mouse is up 325 | button.goToHoverState(); 326 | } 327 | }; 328 | 329 | tracker.exitHandler = function(tracker, position, buttonDownElmt, buttonDownAny) { 330 | // always go to normal state 331 | button.goToNormalState(); 332 | }; 333 | 334 | tracker.pressHandler = function(tracker, position) { 335 | // always go to pressed state 336 | button.goToPressedState(); 337 | }; 338 | 339 | tracker.releaseHandler = function(tracker, position, insideElmtPress, insideElmtRelease) { 340 | if (insideElmtPress) { 341 | // mouse was pressed inside the button and released inside the button 342 | button.goToHoverState(); 343 | button.doAction(); 344 | } else { 345 | // precondition: insideElmtRelease must be true if insideElmtPress is false. 346 | // the mouse was pressed elsewhere and released inside the button. 347 | // we didn't go to hover when the mouse entered since the mouse was down, 348 | // so we'll go to hover now that the mouse is up again. 349 | button.goToHoverState(); 350 | } 351 | }; 352 | 353 | tracker.setTracking(true); 354 |
355 | 356 | 361 | 362 | 363 | 364 | -------------------------------------------------------------------------------- /doc/Seadragon.OverlayPlacement.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 |18 | For overlays that do not scale with the content, describes what part of 19 | the overlay is actually placed at the overlay's point of placement. 20 | For example, a cross-hair overlay should be placed at its center, 21 | whereas a pin overlay may need to be placed at its bottom-right corner. 22 |
23 | 24 |28 | Name 29 | | 30 |31 | Description 32 | | 33 |
---|---|
36 | CENTER 37 | | 38 |39 | The overlay's center is the point of placement. 40 | | 41 |
44 | TOP_LEFT 45 | | 46 |47 | The overlay's top-left corner is the point of placement. 48 | | 49 |
52 | TOP 53 | | 54 |55 | The center of the overlay's top edge is the point of placement. 56 | | 57 |
60 | TOP_RIGHT 61 | | 62 |63 | The overlay's top-right corner is the point of placement. 64 | | 65 |
68 | RIGHT 69 | | 70 |71 | The middle of the overlay's right edge is the point of placement. 72 | | 73 |
76 | BOTTOM_RIGHT 77 | | 78 |79 | The overlay's bottom-right corner is the point of placement. 80 | | 81 |
84 | BOTTOM 85 | | 86 |87 | The center of the overlay's bottom edge is the point of placement. 88 | | 89 |
92 | BOTTOM_LEFT 93 | | 94 |95 | The overlay's bottom-left corner is the point of placement. 96 | | 97 |
100 | LEFT 101 | | 102 |103 | The middle of the overlay's left edge is the point of placement. 104 | | 105 |
18 | A class that represents a 2-dimensional point. 19 |
20 | 21 |25 | Signature 26 | | 27 |28 | Description 29 | | 30 |
---|---|
33 | Seadragon.Point() 34 | | 35 |36 | Creates a point at (0, 0). 37 | | 38 |
41 | Seadragon.Point(x, y) 42 | | 43 |44 | Creates a point at (x, y). 45 | | 46 |
53 | Name 54 | | 55 |56 | Type 57 | | 58 |59 | Description 60 | | 61 |
---|---|---|
64 | x 65 | | 66 |67 | Number 68 | | 69 |70 | The x value. 71 | | 72 |
75 | y 76 | | 77 |78 | Number 79 | | 80 |81 | The y value. 82 | | 83 |
90 | Name and Signature 91 | | 92 |93 | Return Type 94 | | 95 |96 | Description 97 | | 98 |
---|---|---|
101 | plus(point) 102 | | 103 |104 | Seadragon.Point 105 | | 106 |107 | These operations return a new Seadragon.Point, without modifying the current Seadragon.Point. 108 | Note that plus() and minus() take Seadragon.Points while times() and divide() take numbers. 109 | | 110 |
113 | minus(point) 114 | | 115 |116 | Seadragon.Point 117 | | 118 ||
121 | times(factor) 122 | | 123 |124 | Seadragon.Point 125 | | 126 ||
129 | divide(factor) 130 | | 131 |132 | Seadragon.Point 133 | | 134 ||
137 | apply(func) 138 | | 139 |140 | Seadragon.Point 141 | | 142 |143 | Applies the given function to both x and y, and returns a new Seadragon.Point. 144 | An example function is Math.round. 145 | | 146 |
149 | distanceTo(point) 150 | | 151 |152 | Number 153 | | 154 |155 | Returns the distance from this point to the given point. 156 | | 157 |
160 | equals(point) 161 | | 162 |163 | Boolean 164 | | 165 |166 | Returns true if this point has the same x and y as the given point. 167 | | 168 |
18 | A utility class for profiling regular updates. Times the length of each 19 | update as well as the idle periods between updates. For both, tracks the 20 | minimum, average and maximum times. All times are in milliseconds. 21 |
22 | 23 |27 | Signature 28 | | 29 |30 | Description 31 | | 32 |
---|---|
35 | Seadragon.Profiler() 36 | | 37 |38 | Creates a Profiler. 39 | | 40 |
48 | Name and Signature 49 | | 50 |51 | Return Type 52 | | 53 |54 | Description 55 | | 56 |
---|---|---|
59 | isMidUpdate() 60 | | 61 |62 | Boolean 63 | | 64 |65 | Returns true if an update has begun but has not yet ended. 66 | | 67 |
70 | getNumUpdates() 71 | | 72 |73 | Number 74 | | 75 |76 | Returns the number of updates that have been profiled. 77 | | 78 |
84 | Name and Signature 85 | | 86 |87 | Return Type 88 | | 89 |90 | Description 91 | | 92 |
---|---|---|
95 | getAvgUpdateTime() 96 | | 97 |98 | Number 99 | | 100 |101 | Returns the average length of each update. 102 | | 103 |
106 | getMinUpdateTime() 107 | | 108 |109 | Number 110 | | 111 |112 | Returns the length of the shortest update. 113 | | 114 |
117 | getMaxUpdateTime() 118 | | 119 |120 | Number 121 | | 122 |123 | Returns the length of the longest update. 124 | | 125 |
131 | Name and Signature 132 | | 133 |134 | Return Type 135 | | 136 |137 | Description 138 | | 139 |
---|---|---|
142 | getAvgIdleTime() 143 | | 144 |145 | Number 146 | | 147 |148 | Returns the average length of each idle period between two updates. 149 | | 150 |
153 | getMinIdleTime() 154 | | 155 |156 | Number 157 | | 158 |159 | Returns the length of the shortest idle period between two updates. 160 | | 161 |
164 | getMaxIdleTime() 165 | | 166 |167 | Number 168 | | 169 |170 | Returns the length of the longest idle period between two updates. 171 | | 172 |
178 | Name and Signature 179 | | 180 |181 | Return Type 182 | | 183 |184 | Description 185 | | 186 |
---|---|---|
189 | beginUpdate() 190 | | 191 |192 | - 193 | | 194 |195 | Signals to the Profiler that an update has begun. 196 | | 197 |
200 | endUpdate() 201 | | 202 |203 | - 204 | | 205 |206 | Signals to the Profiler that the last update has ended. 207 | | 208 |
211 | clearProfile() 212 | | 213 |214 | - 215 | | 216 |217 | Clears all previously tracked information. 218 | | 219 |
224 | The following code profiles an update function. The function is run on a 225 | timer, and the average update time is shown when a button is clicked. 226 |
227 |228 | var profiler = new Seadragon.Profiler(); 229 | var button = document.getElementById("show_profile_button"); 230 | 231 | function update() { 232 | profiler.beginUpdate(); 233 | ... 234 | profiler.endUpdate(); 235 | } 236 | 237 | window.setInterval(update, 50); 238 | Seadragon.Utils.addEvent(button, "click", function() { 239 | alert("Average update time = " + profiler.getAvgUpdateTime()); 240 | }); 241 |
242 |243 | The following code shows a computed updates per second value. 244 |
245 |246 | function showProfile(profiler) { 247 | var period = profiler.getAvgUpdateTime() + profiler.getAvgIdleTime(); 248 | var freq = 1000 / period; // 1000 milliseconds in 1 second 249 | 250 | alert("Averaging " + freq + " updates per second over " + 251 | profiler.getNumUpdates() + " updates."); 252 | } 253 |
254 | 255 | 260 | 261 | 262 | 263 | -------------------------------------------------------------------------------- /doc/Seadragon.Rect.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 |18 | A class that represents a rectangle. 19 |
20 | 21 |25 | Signature 26 | | 27 |28 | Description 29 | | 30 |
---|---|
33 | Seadragon.Rect() 34 | | 35 |36 | Creates a rectangle at (0, 0) of size 0 x 0. 37 | | 38 |
41 | Seadragon.Rect(x, y, width, height) 42 | | 43 |44 | Creates a rectangle at (x, y) of size width x height. 45 | | 46 |
53 | Name 54 | | 55 |56 | Type 57 | | 58 |59 | Description 60 | | 61 |
---|---|---|
64 | x 65 | | 66 |67 | Number 68 | | 69 |70 | The left edge of the rectangle. 71 | | 72 |
75 | y 76 | | 77 |78 | Number 79 | | 80 |81 | The top edge of the rectangle. 82 | | 83 |
86 | width 87 | | 88 |89 | Number 90 | | 91 |92 | The width of the rectangle. 93 | | 94 |
97 | height 98 | | 99 |100 | Number 101 | | 102 |103 | The height of the rectangle. 104 | | 105 |
112 | Name and Signature 113 | | 114 |115 | Return Type 116 | | 117 |118 | Description 119 | | 120 |
---|---|---|
123 | getAspectRatio() 124 | | 125 |126 | Number 127 | | 128 |129 | Returns this rectangle's aspect ratio (width / height). 130 | | 131 |
134 | getTopLeft() 135 | | 136 |137 | Seadragon.Point 138 | | 139 |140 | Returns (x, y) as a 141 | Seadragon.Point. 142 | | 143 |
146 | getBottomRight() 147 | | 148 |149 | Seadragon.Point 150 | | 151 |152 | Returns (x + width, y + height) as a 153 | Seadragon.Point. 154 | | 155 |
158 | getCenter() 159 | | 160 |161 | Seadragon.Point 162 | | 163 |164 | Returns (x + 0.5 * width, y + 0.5 * height) as a 165 | Seadragon.Point. 166 | | 167 |
170 | getSize() 171 | | 172 |173 | Seadragon.Point 174 | | 175 |176 | Returns (width, height) as a 177 | Seadragon.Point. 178 | | 179 |
182 | equals(rect) 183 | | 184 |185 | Boolean 186 | | 187 |188 | Returns true if this rectangle has the same x, y, width and height as the given 189 | rectangle. 190 | | 191 |
18 | A time-based spring class that moves its current value towards its target value 19 | if the two are ever different. The length and shape of the movement are determined 20 | by Seadragon.Config.animationTime and Seadragon.Config.springStiffness, respectively. 21 |
22 |23 | Note that while this class is time-based, the current value of the spring is only 24 | changed on calls to update(). Any calls to modifier methods will not reflect a changed 25 | current value until update() is called. 26 |
27 | 28 |32 | Signature 33 | | 34 |35 | Description 36 | | 37 |
---|---|
40 | Seadragon.Spring(initialValue) 41 | | 42 |43 | Creates a spring with the given initial current and target value. 44 | | 45 |
52 | Name and Signature 53 | | 54 |55 | Return Type 56 | | 57 |58 | Description 59 | | 60 |
---|---|---|
63 | getCurrent() 64 | | 65 |66 | Number 67 | | 68 |69 | Returns the current value of the spring. 70 | | 71 |
74 | getTarget() 75 | | 76 |77 | Number 78 | | 79 |80 | Returns the target value of the spring. 81 | | 82 |
85 | resetTo(target) 86 | | 87 |88 | - 89 | | 90 |91 | Sets both the current and target values of the spring to the given value. 92 | | 93 |
96 | shiftBy(delta) 97 | | 98 |99 | - 100 | | 101 |102 | Shifts both the current and target values of the spring by the given amount. 103 | | 104 |
107 | springTo(target) 108 | | 109 |110 | - 111 | | 112 |113 | Sets the target value of the spring to the given value. 114 | | 115 |
118 | update() 119 | | 120 |121 | - 122 | | 123 |124 | Updates the current value of the spring to move closer towards the target value. 125 | | 126 |
18 | This static class defines all user-facing strings so that they may be 19 | tweaked and localized as needed. It also provides support for string 20 | arguments. The strings are static properties of this class as nested 21 | objects, but they should only be accessed via the getString() method so 22 | that missing strings and missing arguments can be properly handled. 23 |
24 | 25 |27 | Note that all dot-separated properties are actually nested subproperties. 28 | This means that Seadragon.Strings.Errors.Failure 29 | is valid, but Seadragon.Strings["Errors.Failure"] 30 | is not. 31 |
32 |35 | Name 36 | | 37 |38 | Type 39 | | 40 |41 | Description 42 | | 43 |
---|---|---|
46 | Errors.Failure 47 | | 48 |49 | String 50 | | 51 |52 | Shown when the user's browser does not support Seadragon. 53 | Expects no arguments. 54 | | 55 |
58 | Errors.Dzc 59 | | 60 |61 | String 62 | | 63 |64 | Shown when an image file is in fact a Deep Zoom Collection. 65 | Expects no arguments. 66 | | 67 |
70 | Errors.Dzi 71 | | 72 |73 | String 74 | | 75 |76 | Shown when an image file is not a valid Deep Zoom Image. 77 | Expects no arguments. 78 | | 79 |
82 | Errors.Xml 83 | | 84 |85 | String 86 | | 87 |88 | Shown when an image file is not well-formed XML. 89 | Expects no arguments. 90 | | 91 |
94 | Errors.Empty 95 | | 96 |97 | String 98 | | 99 |100 | Shown when the empty string is given as an image URL. 101 | Expects no arguments. 102 | | 103 |
106 | Errors.ImageFormat 107 | | 108 |109 | String 110 | | 111 |112 | Shown when an image uses an unsupported image format, e.g. WDP. 113 | Expects one argument: the uppercase image format. 114 | | 115 |
118 | Errors.Security 119 | | 120 |121 | String 122 | | 123 |124 | Shown when an image cannot be opened due to browser cross-site 125 | security restrictions. Expects no arguments. 126 | | 127 |
130 | Errors.Status 131 | | 132 |133 | String 134 | | 135 |136 | Shown when an image returns a non-200 HTTP status code. 137 | Expects two arguments: the status code, and the capitalized status text. 138 | | 139 |
142 | Errors.Unknown 143 | | 144 |145 | String 146 | | 147 |148 | Shown when there is an unknown error while attempting to open 149 | an image. Expects no arguments. 150 | | 151 |
154 | Messages.Loading 155 | | 156 |157 | String 158 | | 159 |160 | Shown when an image has been loading for a noticeable amount of 161 | time. Expects no arguments. 162 | | 163 |
166 | Tooltips.FullPage 167 | | 168 |169 | String 170 | | 171 |172 | Shown as the tooltip for the Full Page button. 173 | | 174 |
177 | Tooltips.Home 178 | | 179 |180 | String 181 | | 182 |183 | Shown as the tooltip for the Home button. 184 | | 185 |
188 | Tooltips.ZoomIn 189 | | 190 |191 | String 192 | | 193 |194 | Shown as the tooltip for the Zoom In button. 195 | | 196 |
199 | Tooltips.ZoomOut 200 | | 201 |202 | String 203 | | 204 |205 | Shown as the tooltip for the Zoom Out button. 206 | | 207 |
214 | Name and Signature 215 | | 216 |217 | Return Type 218 | | 219 |220 | Description 221 | | 222 |
---|---|---|
225 | getString(name, ...) 226 | | 227 |228 | String 229 | | 230 |231 | Returns the string for the given name, formatted with the given 232 | arguments. Uses the empty string in place of any missing arguments, 233 | and returns the empty string if no string with the given name exists. 234 | | 235 |
238 | setString(name, value) 239 | | 240 |241 | - 242 | | 243 |244 | Sets the string with the given name to the given value. This 245 | string can contain numbered argument placeholders in the form of 246 | "{0}", "{1}", etc. Creates static properties where necessary. 247 | | 248 |
253 | The following code alerts the Errors.Status string, passing in a non-200 254 | status code and its corresponding status text as arguments. 255 |
256 |257 | if (statusCode != 200) { 258 | alert(Seadragon.Strings.getString("Errors.Status", statusCode, statusText)); 259 | } 260 |
261 |262 | The following code sets a new string to be shown for a custom pan 263 | control. It expects arguments for the amount of pan in each dimension. 264 |
265 |266 | Seadragon.Strings.setString("PanControl.CurrentPan", 267 | "Currently panning {0} pixels by {1} pixels..."); 268 |
269 | 270 | 275 | 276 | 277 | 278 | -------------------------------------------------------------------------------- /doc/Seadragon.TileSource.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 |18 | An abstract class that describes tiled content. This class handles common tiling 19 | math, but all of its properties and methods can be overridden by subclasses. 20 |
21 | 22 |26 | Signature 27 | | 28 |29 | Description 30 | | 31 |
---|---|
34 | Seadragon.TileSource(width, height, tileSize, tileOverlap, minLevel?, maxLevel?) 35 | | 36 |37 | Creates a TileSource for content of the given width and height, using tiles having 38 | the given size and overlap. The minimum and maximum levels for tiles can be supplied, 39 | otherwise default values of based on the width and height are used. 40 | | 41 |
48 | Name 49 | | 50 |51 | Type 52 | | 53 |54 | Description 55 | | 56 |
---|---|---|
59 | width 60 | | 61 |62 | Number 63 | | 64 |65 | The width of the content. 66 | | 67 |
70 | height 71 | | 72 |73 | Number 74 | | 75 |76 | The height of the content. 77 | | 78 |
81 | aspectRatio 82 | | 83 |84 | Number 85 | | 86 |87 | The aspect ratio of the content (width/height). 88 | | 89 |
92 | dimensions 93 | | 94 |95 | Seadragon.Point 96 | | 97 |98 | The natural dimensions of the content (width, height). 99 | | 100 |
103 | minLevel 104 | | 105 |106 | Number 107 | | 108 |109 | The minimum level for which tiles exist. The default value is 0. 110 | | 111 |
114 | maxLevel 115 | | 116 |117 | Number 118 | | 119 |120 | The maximum level for which tiles exist. The default value is that required to display 121 | the content at its natural dimensions. 122 | | 123 |
126 | tileSize 127 | | 128 |129 | Number 130 | | 131 |132 | The size of the tiles, in pixels. 133 | | 134 |
137 | tileOverlap 138 | | 139 |140 | Number 141 | | 142 |143 | The overlap of the tiles on each edge, in pixels. 144 | | 145 |
152 | Name and Signature 153 | | 154 |155 | Return Type 156 | | 157 |158 | Description 159 | | 160 |
---|---|---|
163 | getLevelScale(level) 164 | | 165 |166 | Number 167 | | 168 |169 | Returns the scale by which all dimensions should be multiplied for the given level. 170 | This value increases with the level and is 1 at the default maximum level. 171 | | 172 |
175 | getNumTiles(level) 176 | | 177 |178 | Seadragon.Point 179 | | 180 |181 | Returns the number of tiles at the given level in each dimension. 182 | | 183 |
186 | getPixelRatio(level) 187 | | 188 |189 | Seadragon.Point 190 | | 191 |192 | Returns the ratio of one pixel to the size of the content at the given level, in 193 | both dimensions. For example, at level 0, the ratio is at least 1 in both dimensions, 194 | and at the default maximum level, the ratio is exactly the inverse of the content's 195 | natural size. 196 | | 197 |
200 | getTileAtPoint(level, point) 201 | | 202 |203 | Seadragon.Point 204 | | 205 |206 | Returns the tile at the given level containing the given normalized point. If there 207 | is more than one such tile due to tile overlap, returns the most top-left tile. 208 | | 209 |
212 | getTileBounds(level, x, y) 213 | | 214 |215 | Seadragon.Rect 216 | | 217 |218 | Returns the bounds (position and size) of the given tile in normalized coordinates. 219 | | 220 |
223 | getTileUrl(level, x, y) 224 | | 225 |226 | String 227 | | 228 |229 | Returns the URL for the given tile, or null if the URL is not known. Subclasses 230 | must override this method. 231 | | 232 |
235 | tileExists(level, x, y) 236 | | 237 |238 | Boolean 239 | | 240 |241 | Returns true if the given tile exists. The default behavior of this method is to 242 | simply check that the given tile is within the minimum and maximum levels and the 243 | bounds of the given level. Subclasses can override this method for more specific 244 | behavior. 245 | | 246 |
21 | You'll want to start off with a Seadragon.Viewer. 22 | To control zoom and pan, access your viewer's Seadragon.Viewport. 23 | For general behavior configurations, see Seadragon.Config. 24 | To customize the display strings, use Seadragon.Strings. 25 | For simple scenarios, these classes are all you need. 26 |
27 |28 | On the more advanced side, Seadragon.Drawer 29 | does the graphical heavy lifting. You can use its addOverlay() method to add overlays 30 | to your image. To add custom controls, use Seadragon.Viewer.addControl(). 31 | Seadragon.Button and Seadragon.ButtonGroup 32 | can help out with that if you want. Write your own 33 | Seadragon.TileSource if you want to handle custom content types; 34 | Seadragon.DziTileSource handles Deep Zoom Images. 35 |
36 |37 | Seadragon.EventManager, 38 | Seadragon.ImageLoader, Seadragon.MouseTracker, 39 | and Seadragon.Utils are general-purpose utilites. 40 | Seadragon.DisplayRect, 41 | Seadragon.Point, Seadragon.Rect, and 42 | Seadragon.Spring are basic types. Seadragon.Debug 43 | and Seadragon.Profiler are just for debugging. 44 |
45 |46 | For more general information, see our library how-to's. 49 |
50 |83 | All methods and constructors which take an HTML element can also take a string with 84 | the element's id instead. This is done through the use of Seadragon.Utils.getElement(). 85 |
86 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /doc/styles.css: -------------------------------------------------------------------------------- 1 | 2 | body 3 | { 4 | background: transparent url("header.png") no-repeat; 5 | color: #555555; 6 | font: 75% 'Segoe UI', Verdana, Arial, Helvetica, sans-serif; 7 | margin: 20px 50px 40px 50px; 8 | padding-top: 100px; 9 | } 10 | 11 | h1 { font-size: 30px; font-weight: normal; color:#888888; } 12 | h2 { font-size: 23px; font-weight: normal; color:#888888; } 13 | h3 { font-size: 18px; line-height: 16px; font-weight: normal; color:#888888; } 14 | h4 { font-size: 14px; line-height: 16px; font-weight: normal; color:#888888; } 15 | 16 | a, a:visited { 17 | color: #AF2D0C; 18 | text-decoration: none; 19 | } 20 | 21 | a:hover, a:active { 22 | color: #FF2C0D; 23 | text-decoration: underline; 24 | } 25 | 26 | table 27 | { 28 | border: 1px #CCCCCC solid; 29 | padding: 0px; 30 | border-left:0px; 31 | } 32 | 33 | td 34 | { 35 | padding: 5px; 36 | border: 1px #CCCCCC solid; 37 | border-bottom:0px; 38 | border-right:0px; 39 | vertical-align:top; 40 | } 41 | 42 | th 43 | { 44 | padding: 5px 0px 5px 0px; 45 | background-color: #F8F8F8; 46 | border: 1px #CCCCCC solid; 47 | border-bottom:0px; 48 | border-top:0px; 49 | border-right:0px; 50 | } 51 | 52 | th.return 53 | { 54 | 55 | width: 150px; 56 | text-align:left; 57 | padding: 6px; 58 | } 59 | 60 | th.signature 61 | { 62 | width: 400px; 63 | text-align:left; 64 | padding: 6px; 65 | } 66 | 67 | th.nameSignature 68 | { 69 | width: 250px; 70 | text-align:left; 71 | padding: 6px; 72 | } 73 | 74 | th.description 75 | { 76 | width: 700px; 77 | text-align: left; 78 | padding: 6px; 79 | } 80 | 81 | .code 82 | { 83 | background-color:#eeeeee; 84 | font-family: Consolas, Courier New, Courier; 85 | white-space: pre; 86 | } 87 | 88 | .footer 89 | { 90 | color: #555555; 91 | font: 75% 'Segoe UI', Verdana, Arial, Helvetica, sans-serif; 92 | text-align: right; 93 | margin-top: 2em; 94 | } 95 | 96 | p.code 97 | { 98 | padding-top: 10px; 99 | } 100 | 101 | .deprecated 102 | { 103 | color: #aaaaaa; 104 | } 105 | 106 | .experimental 107 | { 108 | background-color: #ffe0e0; 109 | } 110 | -------------------------------------------------------------------------------- /img/fullpage_grouphover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/fullpage_grouphover.png -------------------------------------------------------------------------------- /img/fullpage_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/fullpage_hover.png -------------------------------------------------------------------------------- /img/fullpage_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/fullpage_pressed.png -------------------------------------------------------------------------------- /img/fullpage_rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/fullpage_rest.png -------------------------------------------------------------------------------- /img/home_grouphover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/home_grouphover.png -------------------------------------------------------------------------------- /img/home_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/home_hover.png -------------------------------------------------------------------------------- /img/home_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/home_pressed.png -------------------------------------------------------------------------------- /img/home_rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/home_rest.png -------------------------------------------------------------------------------- /img/zoomin_grouphover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/zoomin_grouphover.png -------------------------------------------------------------------------------- /img/zoomin_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/zoomin_hover.png -------------------------------------------------------------------------------- /img/zoomin_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/zoomin_pressed.png -------------------------------------------------------------------------------- /img/zoomin_rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/zoomin_rest.png -------------------------------------------------------------------------------- /img/zoomout_grouphover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/zoomout_grouphover.png -------------------------------------------------------------------------------- /img/zoomout_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/zoomout_hover.png -------------------------------------------------------------------------------- /img/zoomout_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/zoomout_pressed.png -------------------------------------------------------------------------------- /img/zoomout_rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aseemk/seadragon-ajax/826e04c808192951d6d7419f015bbde83e27fa2b/img/zoomout_rest.png -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Live Labs Software License Agreement - Seadragon Ajax Code 2 | 3 | This is an agreement between You ( "You") and Microsoft Corporation, 4 | located at One Microsoft Way, Redmond, WA 98052-6399, ("Microsoft") 5 | regarding Your use of the Seadragon Ajax Code made available by 6 | Microsoft ("Software") at this link: 7 | 8 | http://go.microsoft.com/fwlink/?LinkId=164943. 9 | 10 | By installing, accessing or otherwise using the Software, You accept the 11 | terms of this agreement. If You do not agree to the terms of this 12 | agreement, do not install, access or use the Software. 13 | 14 | If You comply with this agreement, You have the rights below. 15 | 16 | 1. USE AND MODIFICATION OF THE SOFTWARE. 17 | 18 | A) Subject to the terms, conditions, and limitations in this 19 | Agreement, Microsoft grants you a non-exclusive, world-wide, 20 | royalty-free copyright license to use and modify the Software 21 | solely as part of your own web applications which are served at 22 | runtime from a web server over the internet to run on a Javascript 23 | runtime in a remote end user's web browser (referred to as 24 | "Applications"). You may distribute the Software only to the 25 | extent necessary for end users to make use of your Application(s) 26 | in their web browsers. You may not rent, lease or lend any of 27 | Your rights in the Software. 28 | 29 | B) Subject to the terms, conditions, and limitations in this 30 | Agreement, Microsoft grants you a non-exclusive, worldwide, 31 | non-transferable, non-sublicensable, royalty-free license under 32 | only its patents that read directly on the Software as provided to 33 | you to make, use, sell, offer for sale, import and/or otherwise 34 | dispose of the Software in your Applications, conditioned upon 35 | your compliance with the requirements and limitations described in 36 | Sections 1(A) and 1(C). 37 | 38 | C) You must 39 | 40 | - ensure that the Applications are compatible with the then 41 | current Deep Zoom Image (DZI) File Format published by Microsoft 42 | at http://go.microsoft.com/fwlink/?LinkId=164944; 43 | 44 | - indicate in the user interface of your Application that your 45 | Application is "built on Microsoft technology"; and 46 | 47 | - indemnify, defend and hold harmless Microsoft from any claims, 48 | including attorneys' fees, related to the distribution or use of 49 | Your Applications. 50 | 51 | Additionally, You may not 52 | 53 | - alter any copyright, trademark or patent notice in the Software; 54 | 55 | - Except as expressly granted in this Agreement, use Microsoft's 56 | trademarks in Your programs' names or in a way that suggests 57 | Your Applications come from or are endorsed by Microsoft; 58 | 59 | - include the Software in malicious, deceptive or unlawful 60 | Applications; 61 | 62 | - port the Software to another programming language; or 63 | 64 | - modify or distribute the Software so that any part of it becomes 65 | subject to an Excluded License. An Excluded License is one that 66 | requires, as a condition of use, modification or distribution, 67 | that 68 | 69 | - the code be disclosed or distributed in source code form; or 70 | 71 | - others have the right to modify it. 72 | 73 | 2. SCOPE OF LICENSES. The Software is licensed, not sold. This 74 | agreement only gives You some rights to use and distribute the 75 | Software. Microsoft reserves all other rights. Unless applicable 76 | law gives You more rights despite this limitation, You may use and 77 | distribute the Software only as expressly permitted in this 78 | agreement. 79 | 80 | 3. EXPORT RESTRICTIONS. THE SOFTWARE IS SUBJECT TO UNITED STATES EXPORT 81 | LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND 82 | INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SOFTWARE. 83 | THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END 84 | USE. FOR ADDITIONAL INFORMATION, SEE WWW.MICROSOFT.COM/EXPORTING. 85 | 86 | 4. SUPPORT. Microsoft is not obligated to provide any technical or 87 | other support ("Support Services") for the Software to You. However, 88 | if Microsoft chooses to provide any Support Services to You, Your use 89 | of such Support Services will be governed by then-current Microsoft 90 | policies. With respect to any technical or other information You 91 | provide to Microsoft in connection with the Support Services, You 92 | agree that Microsoft has an unrestricted right to use such 93 | information for its business purposes, including for product support 94 | and development. Microsoft will not use such information in a form 95 | that personally identifies You. 96 | 97 | 5. TERMINATION. If You are dissatisfied with any aspect of the Software 98 | at any time, Your sole and exclusive remedy is to cease using it. 99 | You acknowledge that termination and/or monetary damages may not be a 100 | sufficient remedy if You breach this agreement and that Microsoft 101 | will be entitled, without waiving any other rights or remedies, to 102 | injunctive or equitable relief as may be deemed proper by a court of 103 | competent jurisdiction in the event of a breach. This Section and 104 | Sections 2, 6, 7, 8, 9, 10, and 11 will survive termination of this 105 | agreement, along with any other provisions that would reasonably be 106 | deemed to survive such events. 107 | 108 | 6. RESERVATION OF RIGHTS. Except for the licenses expressly granted 109 | under this agreement, Microsoft retains all right, title and interest 110 | in and to the Software, and all intellectual property rights therein. 111 | No other rights except those expressly granted in this Agreement 112 | shall be deemed granted, waived or received by implication, 113 | exhaustion, estoppel, or otherwise. Without limiting the foregoing, 114 | You are not authorized to alter, modify, copy, edit, format, create 115 | derivative works of or otherwise use any materials, content or 116 | technology provided under this agreement except as explicitly 117 | provided in this agreement. 118 | 119 | 7. ENTIRE AGREEMENT. This agreement is the entire agreement with 120 | respect to the Software. 121 | 122 | 8. APPLICABLE LAW. 123 | 124 | i. United States. If You acquired the Software in the United States, 125 | Washington State law governs the interpretation of this agreement 126 | and applies to claims for breach of it, regardless of conflict of 127 | laws principles. The laws of the state where You live govern all 128 | other claims, including claims under state consumer protection 129 | laws, unfair competition laws and in tort. 130 | 131 | ii. Outside the United States. If You acquired the Software in any 132 | other country, the laws of that country apply. 133 | 134 | 9. LEGAL EFFECT. This agreement describes certain legal rights. You 135 | may have other rights under the laws of Your country. This agreement 136 | does not change Your rights under the laws of Your country if the 137 | laws of Your country do not permit it to do so. 138 | 139 | 10. DISCLAIMER OF WARRANTY. The Software is licensed "as-is." You 140 | bear the risk of using it. Microsoft gives no express or implied 141 | warranties, guarantees or conditions. You may have additional 142 | consumer rights under Your local laws which this agreement cannot 143 | change. To the extent permitted under Your local laws, Microsoft 144 | excludes the implied warranties of merchantability, fitness for a 145 | particular purpose and non-infringement. Without limiting the 146 | generality of the foregoing, Microsoft makes no warranties regarding 147 | the Software, and hereby disclaims all warranties that might 148 | otherwise be implied by law. 149 | 150 | 11. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. You can 151 | recover from Microsoft and its suppliers only direct damages up to 152 | U.S. $5.00. You cannot recover any other damages, including 153 | consequential, lost profits, special, indirect or incidental 154 | damages. 155 | 156 | This limitation applies to 157 | 158 | - anything related to the Software; and 159 | 160 | - claims for breach of contract, breach of warranty, guarantee or 161 | condition, strict liability, negligence, or other tort to the 162 | extent permitted by applicable law. 163 | 164 | It applies even if Microsoft knew or should have known about the 165 | possibility of the damages. The above limitation or exclusion may 166 | not apply to You because Your country may not allow the exclusion or 167 | limitation of incidental, consequential or other damages. 168 | -------------------------------------------------------------------------------- /logo.dzi: -------------------------------------------------------------------------------- 1 |21 | This is a sample page using the Seadragon Ajax Library. 22 | You can view the API reference to learn more. 23 |
24 | 25 | 26 | 30 | 31 | -------------------------------------------------------------------------------- /seadragon-dev.js: -------------------------------------------------------------------------------- 1 | 2 | (function() { 3 | var PATH = "src/"; // the path to the scripts, relative to HTML page 4 | var SCRIPTS = [ // the script filenames, in dependency order 5 | "Seadragon.Core.js", 6 | "Seadragon.Config.js", 7 | "Seadragon.Strings.js", 8 | "Seadragon.Debug.js", 9 | "Seadragon.Profiler.js", 10 | "Seadragon.Point.js", 11 | "Seadragon.Rect.js", 12 | "Seadragon.Spring.js", 13 | "Seadragon.Utils.js", 14 | "Seadragon.MouseTracker.js", 15 | "Seadragon.EventManager.js", 16 | "Seadragon.ImageLoader.js", 17 | "Seadragon.Buttons.js", 18 | "Seadragon.TileSource.js", 19 | "Seadragon.DisplayRect.js", 20 | "Seadragon.DeepZoom.js", 21 | "Seadragon.Viewport.js", 22 | "Seadragon.Drawer.js", 23 | "Seadragon.Viewer.js" 24 | ]; 25 | 26 | var html = []; 27 | 28 | for (var i = 0; i < SCRIPTS.length; i++) { 29 | html.push('\n'); 33 | } 34 | 35 | // "defer" attr is needed here otherwise IE executes this too early 36 | html.push('\n'); 39 | 40 | document.write(html.join('')); 41 | })(); 42 | -------------------------------------------------------------------------------- /src/Seadragon.Buttons.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonButton, 5 | SeadragonButtonGroup; 6 | 7 | (function() { 8 | 9 | // Enumerations 10 | 11 | var ButtonState = { 12 | REST: 0, 13 | GROUP: 1, 14 | HOVER: 2, 15 | DOWN: 3 16 | }; 17 | 18 | // Button class 19 | 20 | SeadragonButton = Seadragon.Button = function(tooltip, 21 | srcRest, srcGroup, srcHover, srcDown, 22 | onPress, onRelease, onClick, onEnter, onExit) { 23 | 24 | // Fields 25 | 26 | var button = SeadragonUtils.makeNeutralElement("span"); 27 | var currentState = ButtonState.GROUP; 28 | var tracker = new SeadragonMouseTracker(button); 29 | 30 | var imgRest = SeadragonUtils.makeTransparentImage(srcRest); 31 | var imgGroup = SeadragonUtils.makeTransparentImage(srcGroup); 32 | var imgHover = SeadragonUtils.makeTransparentImage(srcHover); 33 | var imgDown = SeadragonUtils.makeTransparentImage(srcDown); 34 | 35 | var onPress = typeof(onPress) == "function" ? onPress : null; 36 | var onRelease = typeof(onRelease) == "function" ? onRelease : null; 37 | var onClick = typeof(onClick) == "function" ? onClick : null; 38 | var onEnter = typeof(onEnter) == "function" ? onEnter : null; 39 | var onExit = typeof(onExit) == "function" ? onExit : null; 40 | 41 | var fadeDelay = 0; // begin fading immediately 42 | var fadeLength = 2000; // fade over a period of 2 seconds 43 | var fadeBeginTime = null; 44 | var shouldFade = false; 45 | 46 | // Properties 47 | 48 | this.elmt = button; 49 | 50 | // Fading helpers 51 | 52 | function scheduleFade() { 53 | window.setTimeout(updateFade, 20); 54 | } 55 | 56 | function updateFade() { 57 | if (shouldFade) { 58 | var currentTime = new Date().getTime(); 59 | var deltaTime = currentTime - fadeBeginTime; 60 | var opacity = 1.0 - deltaTime / fadeLength; 61 | 62 | opacity = Math.min(1.0, opacity); 63 | opacity = Math.max(0.0, opacity); 64 | 65 | SeadragonUtils.setElementOpacity(imgGroup, opacity, true); 66 | if (opacity > 0) { 67 | scheduleFade(); // fade again 68 | } 69 | } 70 | } 71 | 72 | function beginFading() { 73 | shouldFade = true; 74 | fadeBeginTime = new Date().getTime() + fadeDelay; 75 | window.setTimeout(scheduleFade, fadeDelay); 76 | } 77 | 78 | function stopFading() { 79 | shouldFade = false; 80 | SeadragonUtils.setElementOpacity(imgGroup, 1.0, true); 81 | } 82 | 83 | // State helpers 84 | 85 | function inTo(newState) { 86 | if (newState >= ButtonState.GROUP && currentState == ButtonState.REST) { 87 | stopFading(); 88 | currentState = ButtonState.GROUP; 89 | } 90 | 91 | if (newState >= ButtonState.HOVER && currentState == ButtonState.GROUP) { 92 | // important: don't explicitly say "visibility: visible". 93 | // see note in Viewer.setVisible() for explanation. 94 | imgHover.style.visibility = ""; 95 | currentState = ButtonState.HOVER; 96 | } 97 | 98 | if (newState >= ButtonState.DOWN && currentState == ButtonState.HOVER) { 99 | // important: don't explicitly say "visibility: visible". 100 | // see note in Viewer.setVisible() for explanation. 101 | imgDown.style.visibility = ""; 102 | currentState = ButtonState.DOWN; 103 | } 104 | } 105 | 106 | function outTo(newState) { 107 | if (newState <= ButtonState.HOVER && currentState == ButtonState.DOWN) { 108 | imgDown.style.visibility = "hidden"; 109 | currentState = ButtonState.HOVER; 110 | } 111 | 112 | if (newState <= ButtonState.GROUP && currentState == ButtonState.HOVER) { 113 | imgHover.style.visibility = "hidden"; 114 | currentState = ButtonState.GROUP; 115 | } 116 | 117 | if (newState <= ButtonState.REST && currentState == ButtonState.GROUP) { 118 | beginFading(); 119 | currentState = ButtonState.REST; 120 | } 121 | } 122 | 123 | // Tracker helpers 124 | 125 | function enterHandler(tracker, position, buttonDownElmt, buttonDownAny) { 126 | if (buttonDownElmt) { 127 | inTo(ButtonState.DOWN); 128 | if (onEnter) { 129 | onEnter(); 130 | } 131 | } else if (!buttonDownAny) { 132 | inTo(ButtonState.HOVER); 133 | } 134 | } 135 | 136 | function exitHandler(tracker, position, buttonDownElmt, buttonDownAny) { 137 | outTo(ButtonState.GROUP); 138 | if (buttonDownElmt && onExit) { 139 | onExit(); 140 | } 141 | } 142 | 143 | function pressHandler(tracker, position) { 144 | inTo(ButtonState.DOWN); 145 | if (onPress) { 146 | onPress(); 147 | } 148 | } 149 | 150 | function releaseHandler(tracker, position, insideElmtPress, insideElmtRelease) { 151 | if (insideElmtPress && insideElmtRelease) { 152 | outTo(ButtonState.HOVER); 153 | if (onRelease) { 154 | onRelease(); 155 | } 156 | } else if (insideElmtPress) { 157 | outTo(ButtonState.GROUP); 158 | } else { 159 | // pressed elsewhere, but released on it. if we ignored the 160 | // enter event because a button was down, activate hover now 161 | inTo(ButtonState.HOVER); 162 | } 163 | } 164 | 165 | function clickHandler(tracker, position, quick, shift) { 166 | if (onClick && quick) { 167 | onClick(); 168 | } 169 | } 170 | 171 | // Methods 172 | 173 | this.notifyGroupEnter = function() { 174 | inTo(ButtonState.GROUP); 175 | }; 176 | 177 | this.notifyGroupExit = function() { 178 | outTo(ButtonState.REST); 179 | }; 180 | 181 | // Constructor 182 | 183 | (function() { 184 | button.style.display = "inline-block"; 185 | button.style.position = "relative"; 186 | button.title = tooltip; 187 | 188 | button.appendChild(imgRest); 189 | button.appendChild(imgGroup); 190 | button.appendChild(imgHover); 191 | button.appendChild(imgDown); 192 | 193 | var styleRest = imgRest.style; 194 | var styleGroup = imgGroup.style; 195 | var styleHover = imgHover.style; 196 | var styleDown = imgDown.style; 197 | 198 | // DON'T position imgRest absolutely -- let it be inline so it fills 199 | // up the div, sizing the div appropriately 200 | styleGroup.position = styleHover.position = styleDown.position = "absolute"; 201 | styleGroup.top = styleHover.top = styleDown.top = "0px"; 202 | styleGroup.left = styleHover.left = styleDown.left = "0px"; 203 | styleHover.visibility = styleDown.visibility = "hidden"; 204 | // rest and group are always visible 205 | 206 | // FF2 is very buggy with inline-block. it squashes the button div, 207 | // making the group-pressed states' images lower than rest. but 208 | // apparently, clearing the "top" style fixes this. (note that this 209 | // breaks the buttons in every other browser, so we're not clearing 210 | // the "top" style by default...) 211 | if (SeadragonUtils.getBrowser() == SeadragonBrowser.FIREFOX && 212 | SeadragonUtils.getBrowserVersion() < 3) { 213 | styleGroup.top = styleHover.top = styleDown.top = ""; 214 | } 215 | 216 | tracker.enterHandler = enterHandler; 217 | tracker.exitHandler = exitHandler; 218 | tracker.pressHandler = pressHandler; 219 | tracker.releaseHandler = releaseHandler; 220 | tracker.clickHandler = clickHandler; 221 | 222 | tracker.setTracking(true); 223 | outTo(ButtonState.REST); 224 | })(); 225 | 226 | }; 227 | 228 | // ButtonGroup class 229 | 230 | SeadragonButtonGroup = Seadragon.ButtonGroup = function(buttons) { 231 | 232 | // Fields 233 | 234 | var group = SeadragonUtils.makeNeutralElement("span"); 235 | var buttons = buttons.concat([]); // copy 236 | var tracker = new SeadragonMouseTracker(group); 237 | 238 | // Properties 239 | 240 | this.elmt = group; 241 | 242 | // Tracker helpers 243 | 244 | function enterHandler(tracker, position, buttonDownElmt, buttonDownAny) { 245 | // somewhat office ribbon style -- we do this regardless of whether 246 | // the mouse is down from elsewhere. it's a nice soft glow effect. 247 | for (var i = 0; i < buttons.length; i++) { 248 | buttons[i].notifyGroupEnter(); 249 | } 250 | } 251 | 252 | function exitHandler(tracker, position, buttonDownElmt, buttonDownAny) { 253 | if (!buttonDownElmt) { 254 | // only go to rest if the mouse isn't down from a button 255 | for (var i = 0; i < buttons.length; i++) { 256 | buttons[i].notifyGroupExit(); 257 | } 258 | } 259 | } 260 | 261 | function releaseHandler(tracker, position, insideElmtPress, insideElmtRelease) { 262 | if (!insideElmtRelease) { 263 | // this means was the mouse was inside the div during press, so 264 | // since it's no longer inside the div during release, it left 265 | // the div. but onDivExit() ignored it since the mouse was down 266 | // from the div, so we'll go out to rest state now. 267 | for (var i = 0; i < buttons.length; i++) { 268 | buttons[i].notifyGroupExit(); 269 | } 270 | } 271 | } 272 | 273 | // Methods 274 | 275 | this.emulateEnter = function() { 276 | enterHandler(); 277 | }; 278 | 279 | this.emulateExit = function() { 280 | exitHandler(); 281 | }; 282 | 283 | // Constructor 284 | 285 | (function() { 286 | group.style.display = "inline-block"; 287 | 288 | for (var i = 0; i < buttons.length; i++) { 289 | group.appendChild(buttons[i].elmt); 290 | } 291 | 292 | tracker.enterHandler = enterHandler; 293 | tracker.exitHandler = exitHandler; 294 | tracker.releaseHandler = releaseHandler; 295 | 296 | tracker.setTracking(true); 297 | })(); 298 | 299 | }; 300 | 301 | })(); 302 | -------------------------------------------------------------------------------- /src/Seadragon.Config.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonConfig = Seadragon.Config; 5 | 6 | (function() { 7 | 8 | // DUPLICATION CHECK -- necessary to prevent overwriting user changes 9 | if (SeadragonConfig) { 10 | return; 11 | } 12 | 13 | SeadragonConfig = Seadragon.Config = { 14 | 15 | debugMode: false, 16 | 17 | animationTime: 1.5, 18 | 19 | blendTime: 0.5, 20 | 21 | alwaysBlend: false, 22 | 23 | autoHideControls: true, 24 | 25 | constrainDuringPan: true, 26 | 27 | immediateRender: false, 28 | 29 | logarithmicZoom: true, 30 | 31 | wrapHorizontal: false, 32 | 33 | wrapVertical: false, 34 | 35 | wrapOverlays: false, 36 | 37 | transformOverlays: false, 38 | 39 | // for backwards compatibility, keeping this around and defaulting to null. 40 | // if it ever has a non-null value, that means it was explicitly set. 41 | minZoomDimension: null, 42 | 43 | minZoomImageRatio: 0.8, 44 | 45 | maxZoomPixelRatio: 2, 46 | 47 | visibilityRatio: 0.8, 48 | 49 | springStiffness: 5.0, 50 | 51 | imageLoaderLimit: 2, 52 | 53 | clickTimeThreshold: 200, 54 | 55 | clickDistThreshold: 5, 56 | 57 | zoomPerClick: 2.0, 58 | 59 | zoomPerScroll: Math.pow(2, 1/3), 60 | 61 | zoomPerSecond: 2.0, 62 | 63 | proxyUrl: null, 64 | 65 | imagePath: "img/" 66 | 67 | }; 68 | 69 | })(); 70 | -------------------------------------------------------------------------------- /src/Seadragon.Core.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | if (!window.Seadragon) { 5 | window.Seadragon = {}; 6 | } 7 | 8 | // this line overwrites any previous window.Seadragon value in IE before this file 9 | // executes! since this is a global variable, IE does a forward-reference check 10 | // and deletes any global variables which are declared through var. so for now, 11 | // every piece of code that references Seadragon will just have to implicitly 12 | // refer to window.Seadragon and not this global variable Seadragon. 13 | // UPDATE: re-adding this since we're now wrapping all the code in a function. 14 | var Seadragon = window.Seadragon; 15 | -------------------------------------------------------------------------------- /src/Seadragon.Debug.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonDebug = function() { 5 | 6 | // Methods 7 | 8 | this.log = function(msg, important) { 9 | var console = window.console || {}; 10 | var debug = SeadragonConfig.debugMode; 11 | 12 | if (debug && console.log) { 13 | console.log(msg); 14 | } else if (debug && important) { 15 | alert(msg); 16 | } 17 | }; 18 | 19 | this.error = function(msg, e) { 20 | var console = window.console || {}; 21 | var debug = SeadragonConfig.debugMode; 22 | 23 | if (debug && console.error) { 24 | console.error(msg); 25 | } else if (debug) { 26 | alert(msg); 27 | } 28 | 29 | if (debug) { 30 | // since we're debugging, fail fast by crashing 31 | throw e || new Error(msg); 32 | } 33 | }; 34 | 35 | this.fail = function(msg) { 36 | alert(SeadragonStrings.getString("Errors.Failure")); 37 | throw new Error(msg); 38 | }; 39 | 40 | }; 41 | 42 | // Seadragon.Debug is a static class, so make it singleton instance 43 | SeadragonDebug = Seadragon.Debug = new SeadragonDebug(); 44 | -------------------------------------------------------------------------------- /src/Seadragon.DeepZoom.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonDziTileSource = Seadragon.DziTileSource = function( 5 | width, height, tileSize, tileOverlap, tilesUrl, tileFormat, displayRects) { 6 | 7 | // Inheritance 8 | 9 | SeadragonTileSource.apply(this, [width, height, tileSize, tileOverlap]); 10 | 11 | // Fields 12 | 13 | var self = this; 14 | var levelRects = {}; // 1D dictionary [level] --> array of DisplayRects 15 | 16 | // Properties 17 | 18 | this.fileFormat = tileFormat; // deprecated old property ("file" instead of "tile") 19 | this.tileFormat = tileFormat; 20 | this.displayRects = displayRects; 21 | 22 | // Constructor 23 | 24 | (function() { 25 | if (!displayRects) { 26 | return; 27 | } 28 | 29 | for (var i = displayRects.length - 1; i >= 0; i--) { 30 | var rect = displayRects[i]; 31 | for (var level = rect.minLevel; level <= rect.maxLevel; level++) { 32 | if (!levelRects[level]) { 33 | levelRects[level] = []; 34 | } 35 | levelRects[level].push(rect); 36 | } 37 | } 38 | })(); 39 | 40 | // Methods -- OVERRIDDEN 41 | 42 | this.getTileUrl = function(level, x, y) { 43 | // using array join because it's faster than string concatenation 44 | return [tilesUrl, level, '/', x, '_', y, '.', tileFormat].join(''); 45 | }; 46 | 47 | this.tileExists = function(level, x, y) { 48 | var rects = levelRects[level]; 49 | 50 | if (!rects || !rects.length) { 51 | return true; 52 | } 53 | 54 | var scale = self.getLevelScale(level); 55 | 56 | for (var i = rects.length - 1; i >= 0; i--) { 57 | var rect = rects[i]; 58 | 59 | // check level 60 | if (level < rect.minLevel || level > rect.maxLevel) { 61 | continue; 62 | } 63 | 64 | // transform rectangle coordinates to this level 65 | var xMin = rect.x * scale; 66 | var yMin = rect.y * scale; 67 | var xMax = xMin + rect.width * scale; 68 | var yMax = yMin + rect.height * scale; 69 | 70 | // convert to rows and columns -- note that we're ignoring tile 71 | // overlap, but it's a reasonable approximation. it errs on the side 72 | // of false positives, which is much better than false negatives. 73 | xMin = Math.floor(xMin / tileSize); 74 | yMin = Math.floor(yMin / tileSize); 75 | xMax = Math.ceil(xMax / tileSize); 76 | yMax = Math.ceil(yMax / tileSize); 77 | 78 | if (xMin <= x && x < xMax && yMin <= y && y < yMax) { 79 | return true; 80 | } 81 | } 82 | 83 | return false; 84 | }; 85 | 86 | }; 87 | 88 | SeadragonDziTileSource.prototype = new SeadragonTileSource(); 89 | 90 | 91 | 92 | (function() { 93 | 94 | // Helpers -- Errors 95 | 96 | function DziError(message) { 97 | Error.apply(this, arguments); 98 | this.message = message; 99 | } 100 | 101 | DziError.prototype = new Error(); 102 | 103 | function getError(e) { 104 | if (!(e instanceof DziError)) { 105 | // shouldn't happen, but if it does, fail fast or at least log it 106 | SeadragonDebug.error(e.name + " while creating DZI from XML: " + e.message); 107 | e = new DziError(SeadragonStrings.getString("Errors.Unknown")); 108 | } 109 | 110 | return e; 111 | } 112 | 113 | // Helpers -- URL 114 | 115 | function getTilesUrl(xmlUrl) { 116 | var urlParts = xmlUrl.split('/'); 117 | var filename = urlParts[urlParts.length - 1]; 118 | var lastDot = filename.lastIndexOf('.'); 119 | 120 | if (lastDot > -1) { 121 | urlParts[urlParts.length - 1] = filename.slice(0, lastDot); 122 | } 123 | 124 | return urlParts.join('/') + "_files/"; 125 | } 126 | 127 | // Helpers -- XML 128 | 129 | function processResponse(xhr, tilesUrl) { 130 | if (!xhr) { 131 | throw new DziError(SeadragonStrings.getString("Errors.Security")); 132 | } else if (xhr.status !== 200 && xhr.status !== 0) { 133 | // chrome has bug where it sends "OK" for 404 134 | var status = xhr.status; 135 | var statusText = (status == 404) ? "Not Found" : xhr.statusText; 136 | throw new DziError(SeadragonStrings.getString("Errors.Status", status, statusText)); 137 | } 138 | 139 | var doc = null; 140 | 141 | if (xhr.responseXML && xhr.responseXML.documentElement) { 142 | doc = xhr.responseXML; 143 | } else if (xhr.responseText) { 144 | doc = SeadragonUtils.parseXml(xhr.responseText); 145 | } 146 | 147 | return processXml(doc, tilesUrl); 148 | } 149 | 150 | function processXml(xmlDoc, tilesUrl) { 151 | if (!xmlDoc || !xmlDoc.documentElement) { 152 | throw new DziError(SeadragonStrings.getString("Errors.Xml")); 153 | } 154 | 155 | var root = xmlDoc.documentElement; 156 | var rootName = root.tagName; 157 | 158 | if (rootName == "Image") { 159 | try { 160 | return processDzi(root, tilesUrl); 161 | } catch (e) { 162 | var defMsg = SeadragonStrings.getString("Errors.Dzi"); 163 | throw (e instanceof DziError) ? e : new DziError(defMsg); 164 | } 165 | } else if (rootName == "Collection") { 166 | throw new DziError(SeadragonStrings.getString("Errors.Dzc")); 167 | } else if (rootName == "Error") { 168 | return processError(root); 169 | } 170 | 171 | throw new DziError(SeadragonStrings.getString("Errors.Dzi")); 172 | } 173 | 174 | function processDzi(imageNode, tilesUrl) { 175 | var tileFormat = imageNode.getAttribute("Format"); 176 | 177 | if (!SeadragonUtils.imageFormatSupported(tileFormat)) { 178 | throw new DziError(SeadragonStrings.getString("Errors.ImageFormat", 179 | tileFormat.toUpperCase())); 180 | } 181 | 182 | var sizeNode = imageNode.getElementsByTagName("Size")[0]; 183 | var dispRectNodes = imageNode.getElementsByTagName("DisplayRect"); 184 | 185 | var width = parseInt(sizeNode.getAttribute("Width"), 10); 186 | var height = parseInt(sizeNode.getAttribute("Height"), 10); 187 | var tileSize = parseInt(imageNode.getAttribute("TileSize")); 188 | var tileOverlap = parseInt(imageNode.getAttribute("Overlap")); 189 | var dispRects = []; 190 | 191 | for (var i = 0; i < dispRectNodes.length; i++) { 192 | var dispRectNode = dispRectNodes[i]; 193 | var rectNode = dispRectNode.getElementsByTagName("Rect")[0]; 194 | 195 | dispRects.push(new SeadragonDisplayRect( 196 | parseInt(rectNode.getAttribute("X"), 10), 197 | parseInt(rectNode.getAttribute("Y"), 10), 198 | parseInt(rectNode.getAttribute("Width"), 10), 199 | parseInt(rectNode.getAttribute("Height"), 10), 200 | // TEMP not sure why we did this -- seems like it's wrong. 201 | // commenting out the hardcoded 0 and using the XML's value. 202 | //0, // ignore MinLevel attribute, bug in Deep Zoom Composer 203 | parseInt(dispRectNode.getAttribute("MinLevel"), 10), 204 | parseInt(dispRectNode.getAttribute("MaxLevel"), 10) 205 | )); 206 | } 207 | 208 | return new SeadragonDziTileSource(width, height, tileSize, tileOverlap, 209 | tilesUrl, tileFormat, dispRects); 210 | } 211 | 212 | function processError(errorNode) { 213 | var messageNode = errorNode.getElementsByTagName("Message")[0]; 214 | var message = messageNode.firstChild.nodeValue; 215 | 216 | throw new DziError(message); 217 | } 218 | 219 | // Methods -- FACTORIES 220 | 221 | SeadragonDziTileSource.getTilesUrl = getTilesUrl; 222 | // expose this publicly because it's useful for multiple clients 223 | 224 | SeadragonDziTileSource.createFromJson = function(jsonObj, callback) { 225 | var async = typeof(callback) == "function"; 226 | var source, error; 227 | var dzi = jsonObj; 228 | 229 | if (!dzi || (!dzi.url && !dzi.tilesUrl)) { 230 | error = new DziError(SeadragonStrings.getString("Errors.Empty")); 231 | 232 | } else { 233 | 234 | try { 235 | 236 | var displayRects = dzi.displayRects; 237 | if (displayRects && displayRects.length) { 238 | for (var i = 0, n = displayRects.length; i < n; i++) { 239 | var dr = displayRects[i]; 240 | displayRects[i] = new SeadragonDisplayRect( 241 | dr.x || dr[0], 242 | dr.y || dr[1], 243 | dr.width || dr[2], 244 | dr.height || dr[3], 245 | dr.minLevel || dr[4], 246 | dr.maxLevel || dr[5] 247 | ); 248 | } 249 | } 250 | 251 | source = new SeadragonDziTileSource( 252 | dzi.width, 253 | dzi.height, 254 | dzi.tileSize, 255 | dzi.tileOverlap, 256 | dzi.tilesUrl || getTilesUrl(dzi.url), 257 | dzi.tileFormat, 258 | dzi.displayRects 259 | ); 260 | 261 | source.xmlUrl = dzi.url; 262 | 263 | } catch (e) { 264 | error = getError(e); 265 | } 266 | 267 | } 268 | 269 | if (async) { 270 | window.setTimeout(SeadragonUtils.createCallback(null, callback, source, error && error.message), 1); 271 | } else if (error) { 272 | throw error; 273 | } else { 274 | return source; 275 | } 276 | }; 277 | 278 | SeadragonDziTileSource.createFromXml = function(xmlUrl, xmlString, callback) { 279 | var async = typeof(callback) == "function"; 280 | var error = null; 281 | 282 | if (!xmlUrl) { 283 | error = SeadragonStrings.getString("Errors.Empty"); 284 | if (async) { 285 | window.setTimeout(function() { 286 | callback(null, error); 287 | }, 1); 288 | return null; 289 | } 290 | throw new DziError(error); 291 | } 292 | 293 | var tilesUrl = getTilesUrl(xmlUrl); 294 | 295 | function finish(func, obj) { 296 | try { 297 | var source = func(obj, tilesUrl); 298 | source.xmlUrl = xmlUrl; 299 | return source; 300 | } catch (e) { 301 | if (async) { 302 | error = getError(e).message; 303 | return null; 304 | } else { 305 | throw getError(e); 306 | } 307 | } 308 | } 309 | 310 | if (async) { 311 | if (xmlString) { 312 | window.setTimeout(function() { 313 | var source = finish(processXml, SeadragonUtils.parseXml(xmlString)); 314 | callback(source, error); // call after finish sets error 315 | }, 1); 316 | } else { 317 | SeadragonUtils.makeAjaxRequest(xmlUrl, function(xhr) { 318 | var source = finish(processResponse, xhr); 319 | callback(source, error); // call after finish sets error 320 | }); 321 | } 322 | 323 | return null; 324 | } 325 | 326 | // synchronous version 327 | if (xmlString) { 328 | return finish(processXml, SeadragonUtils.parseXml(xmlString)); 329 | } else { 330 | return finish(processResponse, SeadragonUtils.makeAjaxRequest(xmlUrl)); 331 | } 332 | }; 333 | 334 | })(); 335 | -------------------------------------------------------------------------------- /src/Seadragon.DisplayRect.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonDisplayRect = Seadragon.DisplayRect = function(x, y, width, height, minLevel, maxLevel) { 5 | 6 | // Inheritance 7 | 8 | SeadragonRect.apply(this, arguments); 9 | 10 | // Properties (extended) 11 | 12 | this.minLevel = minLevel; 13 | this.maxLevel = maxLevel; 14 | 15 | }; 16 | 17 | SeadragonDisplayRect.prototype = new SeadragonRect(); 18 | -------------------------------------------------------------------------------- /src/Seadragon.EventManager.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonEventManager = Seadragon.EventManager = function() { 5 | 6 | // Fields 7 | 8 | var listeners = {}; // dictionary of eventName --> array of handlers 9 | 10 | // Methods 11 | 12 | this.addListener = function(eventName, handler) { 13 | if (typeof(handler) != "function") { 14 | return; 15 | } 16 | 17 | if (!listeners[eventName]) { 18 | listeners[eventName] = []; 19 | } 20 | 21 | listeners[eventName].push(handler); 22 | }; 23 | 24 | this.removeListener = function(eventName, handler) { 25 | var handlers = listeners[eventName]; 26 | 27 | if (typeof(handler) != "function") { 28 | return; 29 | } else if (!handlers) { 30 | return; 31 | } 32 | 33 | for (var i = 0; i < handlers.length; i++) { 34 | if (handler == handlers[i]) { 35 | handlers.splice(i, 1); 36 | return; 37 | } 38 | } 39 | }; 40 | 41 | this.clearListeners = function(eventName) { 42 | if (listeners[eventName]) { 43 | delete listeners[eventName]; 44 | } 45 | }; 46 | 47 | this.trigger = function(eventName) { 48 | var handlers = listeners[eventName]; 49 | var args = []; 50 | 51 | if (!handlers) { 52 | return; 53 | } 54 | 55 | for (var i = 1; i < arguments.length; i++) { 56 | args.push(arguments[i]); 57 | } 58 | 59 | for (var i = 0; i < handlers.length; i++) { 60 | try { 61 | handlers[i].apply(window, args); 62 | } catch (e) { 63 | // handler threw an error, ignore, go on to next one 64 | SeadragonDebug.error(e.name + " while executing " + eventName + 65 | " handler: " + e.message, e); 66 | } 67 | } 68 | }; 69 | 70 | }; 71 | -------------------------------------------------------------------------------- /src/Seadragon.ImageLoader.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonImageLoader; 5 | 6 | (function() { 7 | 8 | var TIMEOUT = 15000; // milliseconds after which an image times out 9 | 10 | function Job(src, callback) { 11 | 12 | // Fields 13 | 14 | var image = null; 15 | var timeout = null; // IE8 fix: no finishing event raised sometimes 16 | 17 | // Helpers 18 | 19 | function finish(success) { 20 | image.onload = null; 21 | image.onabort = null; 22 | image.onerror = null; 23 | 24 | if (timeout) { 25 | window.clearTimeout(timeout); 26 | } 27 | 28 | // call on a timeout to ensure asynchronous behavior 29 | window.setTimeout(function() { 30 | callback(src, success ? image : null); 31 | }, 1); 32 | } 33 | 34 | // Methods 35 | 36 | this.start = function() { 37 | image = new Image(); 38 | 39 | var successFunc = function() { finish(true); }; 40 | var failureFunc = function() { finish(false); }; 41 | var timeoutFunc = function() { 42 | SeadragonDebug.log("Image timed out: " + src); 43 | finish(false); 44 | }; 45 | 46 | image.onload = successFunc; 47 | image.onabort = failureFunc; 48 | image.onerror = failureFunc; 49 | 50 | // consider it a failure if the image times out. 51 | timeout = window.setTimeout(timeoutFunc, TIMEOUT); 52 | 53 | image.src = src; 54 | }; 55 | 56 | } 57 | 58 | SeadragonImageLoader = Seadragon.ImageLoader = function() { 59 | 60 | // Fields 61 | 62 | var downloading = 0; // number of Jobs currently downloading 63 | 64 | // Helpers 65 | 66 | function onComplete(callback, src, image) { 67 | downloading--; 68 | if (typeof(callback) == "function") { 69 | try { 70 | callback(image); 71 | } catch (e) { 72 | SeadragonDebug.error(e.name + " while executing " + src + 73 | " callback: " + e.message, e); 74 | } 75 | } 76 | } 77 | 78 | // Methods 79 | 80 | this.loadImage = function(src, callback) { 81 | if (downloading >= SeadragonConfig.imageLoaderLimit) { 82 | return false; 83 | } 84 | 85 | var func = SeadragonUtils.createCallback(null, onComplete, callback); 86 | var job = new Job(src, func); 87 | 88 | downloading++; 89 | job.start(); 90 | 91 | return true; 92 | }; 93 | 94 | }; 95 | 96 | })(); 97 | -------------------------------------------------------------------------------- /src/Seadragon.Point.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonPoint = Seadragon.Point; 5 | 6 | (function() { 7 | 8 | // preventing duplicate definitions because our code checks instanceof 9 | // SeadragonPoint, and that breaks if Seadragon.Point is redefined! 10 | if (SeadragonPoint) { 11 | return; 12 | } 13 | 14 | SeadragonPoint = Seadragon.Point = function(x, y) { 15 | 16 | // Properties 17 | 18 | this.x = typeof(x) == "number" ? x : 0; 19 | this.y = typeof(y) == "number" ? y : 0; 20 | 21 | }; 22 | 23 | // Methods 24 | 25 | var SDPointPrototype = SeadragonPoint.prototype; 26 | 27 | SDPointPrototype.plus = function(point) { 28 | return new SeadragonPoint(this.x + point.x, this.y + point.y); 29 | }; 30 | 31 | SDPointPrototype.minus = function(point) { 32 | return new SeadragonPoint(this.x - point.x, this.y - point.y); 33 | }; 34 | 35 | SDPointPrototype.times = function(factor) { 36 | return new SeadragonPoint(this.x * factor, this.y * factor); 37 | }; 38 | 39 | SDPointPrototype.divide = function(factor) { 40 | return new SeadragonPoint(this.x / factor, this.y / factor); 41 | }; 42 | 43 | SDPointPrototype.negate = function() { 44 | return new SeadragonPoint(-this.x, -this.y); 45 | }; 46 | 47 | SDPointPrototype.distanceTo = function(point) { 48 | return Math.sqrt(Math.pow(this.x - point.x, 2) + 49 | Math.pow(this.y - point.y, 2)); 50 | }; 51 | 52 | SDPointPrototype.apply = function(func) { 53 | return new SeadragonPoint(func(this.x), func(this.y)); 54 | }; 55 | 56 | SDPointPrototype.equals = function(point) { 57 | return (point instanceof SeadragonPoint) && 58 | (this.x === point.x) && (this.y === point.y); 59 | }; 60 | 61 | SDPointPrototype.toString = function() { 62 | return "(" + this.x + "," + this.y + ")"; 63 | }; 64 | 65 | })(); 66 | -------------------------------------------------------------------------------- /src/Seadragon.Profiler.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonProfiler = Seadragon.Profiler = function() { 5 | 6 | // Fields 7 | 8 | var self = this; 9 | 10 | var midUpdate = false; 11 | var numUpdates = 0; 12 | 13 | var lastBeginTime = null; 14 | var lastEndTime = null; 15 | 16 | var minUpdateTime = Infinity; 17 | var avgUpdateTime = 0; 18 | var maxUpdateTime = 0; 19 | 20 | var minIdleTime = Infinity; 21 | var avgIdleTime = 0; 22 | var maxIdleTime = 0; 23 | 24 | // Methods -- UPDATE TIME ACCESSORS 25 | 26 | this.getAvgUpdateTime = function() { 27 | return avgUpdateTime; 28 | }; 29 | 30 | this.getMinUpdateTime = function() { 31 | return minUpdateTime; 32 | }; 33 | 34 | this.getMaxUpdateTime = function() { 35 | return maxUpdateTime; 36 | }; 37 | 38 | // Methods -- IDLING TIME ACCESSORS 39 | 40 | this.getAvgIdleTime = function() { 41 | return avgIdleTime; 42 | }; 43 | 44 | this.getMinIdleTime = function() { 45 | return minIdleTime; 46 | }; 47 | 48 | this.getMaxIdleTime = function() { 49 | return maxIdleTime; 50 | }; 51 | 52 | // Methods -- GENERAL ACCESSORS 53 | 54 | this.isMidUpdate = function() { 55 | return midUpdate; 56 | }; 57 | 58 | this.getNumUpdates = function() { 59 | return numUpdates; 60 | }; 61 | 62 | // Methods -- MODIFIERS 63 | 64 | this.beginUpdate = function() { 65 | if (midUpdate) { 66 | self.endUpdate(); 67 | } 68 | 69 | midUpdate = true; 70 | lastBeginTime = new Date().getTime(); 71 | 72 | if (numUpdates <1) { 73 | return; // this is the first update 74 | } 75 | 76 | var time = lastBeginTime - lastEndTime; 77 | 78 | avgIdleTime = (avgIdleTime * (numUpdates - 1) + time) / numUpdates; 79 | 80 | if (time < minIdleTime) { 81 | minIdleTime = time; 82 | } 83 | if (time > maxIdleTime) { 84 | maxIdleTime = time; 85 | } 86 | }; 87 | 88 | this.endUpdate = function() { if (!midUpdate) { 89 | return; 90 | } 91 | 92 | lastEndTime = new Date().getTime(); 93 | midUpdate = false; 94 | 95 | var time = lastEndTime - lastBeginTime; 96 | 97 | numUpdates++; 98 | avgUpdateTime = (avgUpdateTime * (numUpdates - 1) + time) / numUpdates; 99 | 100 | if (time < minUpdateTime) { 101 | minUpdateTime = time; 102 | } 103 | if (time > maxUpdateTime) { 104 | maxUpdateTime = time; 105 | } 106 | }; 107 | 108 | this.clearProfile = function() { 109 | midUpdate = false; 110 | numUpdates = 0; 111 | 112 | lastBeginTime = null; 113 | lastEndTime = null; 114 | 115 | minUpdateTime = Infinity; 116 | avgUpdateTime = 0; 117 | maxUpdateTime = 0; 118 | 119 | minIdleTime = Infinity; 120 | avgIdleTime = 0; 121 | maxIdleTime = 0; 122 | }; 123 | 124 | }; 125 | -------------------------------------------------------------------------------- /src/Seadragon.Rect.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonRect = Seadragon.Rect; 5 | 6 | (function () { 7 | 8 | // preventing duplicate definitions because our code checks instanceof 9 | // SeadragonRect, and that breaks if Seadragon.Rect is redefined! 10 | if (SeadragonRect) { 11 | return; 12 | } 13 | 14 | SeadragonRect = Seadragon.Rect = function(x, y, width, height) { 15 | 16 | // Properties 17 | 18 | this.x = typeof(x) == "number" ? x : 0; 19 | this.y = typeof(y) == "number" ? y : 0; 20 | this.width = typeof(width) == "number" ? width : 0; 21 | this.height = typeof(height) == "number" ? height : 0; 22 | 23 | }; 24 | 25 | // Methods 26 | 27 | var SDRectPrototype = SeadragonRect.prototype; 28 | 29 | SDRectPrototype.getAspectRatio = function() { 30 | return this.width / this.height; 31 | }; 32 | 33 | SDRectPrototype.getTopLeft = function() { 34 | return new SeadragonPoint(this.x, this.y); 35 | }; 36 | 37 | SDRectPrototype.getBottomRight = function() { 38 | return new SeadragonPoint(this.x + this.width, this.y + this.height); 39 | }; 40 | 41 | SDRectPrototype.getCenter = function() { 42 | return new SeadragonPoint(this.x + this.width / 2.0, 43 | this.y + this.height / 2.0); 44 | }; 45 | 46 | SDRectPrototype.getSize = function() { 47 | return new SeadragonPoint(this.width, this.height); 48 | }; 49 | 50 | SDRectPrototype.equals = function(other) { 51 | return (other instanceof SeadragonRect) && 52 | (this.x === other.x) && (this.y === other.y) && 53 | (this.width === other.width) && (this.height === other.height); 54 | }; 55 | 56 | SDRectPrototype.toString = function() { 57 | return "[" + this.x + "," + this.y + "," + this.width + "x" + 58 | this.height + "]"; 59 | }; 60 | 61 | })(); 62 | -------------------------------------------------------------------------------- /src/Seadragon.Spring.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonSpring = Seadragon.Spring = function(initialValue) { 5 | 6 | // Fields 7 | 8 | var currentValue = typeof(initialValue) == "number" ? initialValue : 0; 9 | var startValue = currentValue; 10 | var targetValue = currentValue; 11 | 12 | var currentTime = new Date().getTime(); // always work in milliseconds 13 | var startTime = currentTime; 14 | var targetTime = currentTime; 15 | 16 | // Helpers 17 | 18 | /** 19 | * Transform from linear [0,1] to spring [0,1]. 20 | */ 21 | function transform(x) { 22 | var s = SeadragonConfig.springStiffness; 23 | return (1.0 - Math.exp(-x * s)) / (1.0 - Math.exp(-s)); 24 | } 25 | 26 | // Methods 27 | 28 | this.getCurrent = function() { 29 | return currentValue; 30 | }; 31 | 32 | this.getTarget = function() { 33 | return targetValue; 34 | }; 35 | 36 | this.resetTo = function(target) { 37 | targetValue = target; 38 | targetTime = currentTime; 39 | startValue = targetValue; 40 | startTime = targetTime; 41 | }; 42 | 43 | this.springTo = function(target) { 44 | startValue = currentValue; 45 | startTime = currentTime; 46 | targetValue = target; 47 | targetTime = startTime + 1000 * SeadragonConfig.animationTime; 48 | }; 49 | 50 | this.shiftBy = function(delta) { 51 | startValue += delta; 52 | targetValue += delta; 53 | }; 54 | 55 | this.update = function() { 56 | currentTime = new Date().getTime(); 57 | currentValue = (currentTime >= targetTime) ? targetValue : 58 | startValue + (targetValue - startValue) * 59 | transform((currentTime - startTime) / (targetTime - startTime)); 60 | }; 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /src/Seadragon.Strings.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonStrings = Seadragon.Strings; 5 | 6 | (function() { 7 | 8 | if (SeadragonStrings) { 9 | return; // don't overwrite any strings that may have been added or changed 10 | } 11 | 12 | SeadragonStrings = Seadragon.Strings = { 13 | 14 | Errors: { 15 | Failure: "Sorry, but Seadragon Ajax can't run on your browser!\n" + 16 | "Please try using IE 8 or Firefox 3.\n", 17 | Dzc: "Sorry, we don't support Deep Zoom Collections!", 18 | Dzi: "Hmm, this doesn't appear to be a valid Deep Zoom Image.", 19 | Xml: "Hmm, this doesn't appear to be a valid Deep Zoom Image.", 20 | Empty: "You asked us to open nothing, so we did just that.", 21 | ImageFormat: "Sorry, we don't support {0}-based Deep Zoom Images.", 22 | Security: "It looks like a security restriction stopped us from " + 23 | "loading this Deep Zoom Image.", 24 | Status: "This space unintentionally left blank ({0} {1}).", 25 | Unknown: "Whoops, something inexplicably went wrong. Sorry!" 26 | }, 27 | 28 | Messages: { 29 | Loading: "Loading..." 30 | }, 31 | 32 | Tooltips: { 33 | FullPage: "Toggle full page", 34 | Home: "Go home", 35 | ZoomIn: "Zoom in (you can also use your mouse's scroll wheel)", 36 | ZoomOut: "Zoom out (you can also use your mouse's scroll wheel)" 37 | } 38 | 39 | }; 40 | 41 | SeadragonStrings.getString = function(prop) { 42 | var props = prop.split('.'); 43 | var string = SeadragonStrings; 44 | 45 | // get property, which may contain dots, meaning subproperty 46 | for (var i = 0; i < props.length; i++) { 47 | string = string[props[i]] || {}; // in case not a subproperty 48 | } 49 | 50 | // in case the string didn't exist 51 | if (typeof(string) != "string") { 52 | string = ""; 53 | } 54 | 55 | // regular expression and lambda technique from: 56 | // http://frogsbrain.wordpress.com/2007/04/28/javascript-stringformat-method/#comment-236 57 | var args = arguments; 58 | return string.replace(/\{\d+\}/g, function(capture) { 59 | var i = parseInt(capture.match(/\d+/)) + 1; 60 | return i < args.length ? args[i] : ""; 61 | }); 62 | }; 63 | 64 | SeadragonStrings.setString = function(prop, value) { 65 | var props = prop.split('.'); 66 | var container = SeadragonStrings; 67 | 68 | // get property's container, up to but not after last dot 69 | for (var i = 0; i < props.length - 1; i++) { 70 | if (!container[props[i]]) { 71 | container[props[i]] = {}; 72 | } 73 | container = container[props[i]]; 74 | } 75 | 76 | container[props[i]] = value; 77 | }; 78 | 79 | })(); 80 | -------------------------------------------------------------------------------- /src/Seadragon.TileSource.js: -------------------------------------------------------------------------------- 1 | // This code is distributed under the included license agreement, also 2 | // available here: http://go.microsoft.com/fwlink/?LinkId=164943 3 | 4 | var SeadragonTileSource = Seadragon.TileSource = function( 5 | width, height, tileSize, tileOverlap, minLevel, maxLevel) { 6 | 7 | // Fields 8 | 9 | var self = this; 10 | var normHeight = height / width; 11 | 12 | // Properties 13 | 14 | this.width = width; 15 | this.height = height; 16 | this.aspectRatio = width / height; 17 | this.dimensions = new SeadragonPoint(width, height); 18 | this.minLevel = minLevel ? minLevel : 0; 19 | this.maxLevel = maxLevel ? maxLevel : 20 | Math.ceil(Math.log(Math.max(width, height)) / Math.log(2)); 21 | this.tileSize = tileSize ? tileSize : 0; 22 | this.tileOverlap = tileOverlap ? tileOverlap : 0; 23 | 24 | // Methods 25 | 26 | this.getLevelScale = function(level) { 27 | // equivalent to Math.pow(0.5, numLevels - level); 28 | return 1 / (1 << (self.maxLevel - level)); 29 | }; 30 | 31 | this.getNumTiles = function(level) { 32 | var scale = self.getLevelScale(level); 33 | var x = Math.ceil(scale * width / self.tileSize); 34 | var y = Math.ceil(scale * height / self.tileSize); 35 | 36 | return new SeadragonPoint(x, y); 37 | }; 38 | 39 | this.getPixelRatio = function(level) { 40 | var imageSizeScaled = self.dimensions.times(self.getLevelScale(level)); 41 | var rx = 1.0 / imageSizeScaled.x; 42 | var ry = 1.0 / imageSizeScaled.y; 43 | 44 | return new SeadragonPoint(rx, ry); 45 | }; 46 | 47 | this.getTileAtPoint = function(level, point) { 48 | // support wrapping by taking less-than-full tiles into account! 49 | // this is necessary in order to properly wrap low-res tiles. 50 | var scaledSize = self.dimensions.times(self.getLevelScale(level)); 51 | var pixel = point.times(scaledSize.x); 52 | var tx, ty; 53 | 54 | // optimize for the non-wrapping case, but support wrapping 55 | if (point.x >= 0.0 && point.x <= 1.0) { 56 | tx = Math.floor(pixel.x / self.tileSize); 57 | } else { 58 | tx = Math.ceil(scaledSize.x / self.tileSize) * Math.floor(pixel.x / scaledSize.x) + 59 | Math.floor(((scaledSize.x + (pixel.x % scaledSize.x)) % scaledSize.x) / self.tileSize); 60 | } 61 | 62 | // same thing vertically 63 | if (point.y >= 0.0 && point.y <= normHeight) { 64 | ty = Math.floor(pixel.y / self.tileSize); 65 | } else { 66 | ty = Math.ceil(scaledSize.y / self.tileSize) * Math.floor(pixel.y / scaledSize.y) + 67 | Math.floor(((scaledSize.y + (pixel.y % scaledSize.y)) % scaledSize.y) / self.tileSize); 68 | } 69 | 70 | return new SeadragonPoint(tx, ty); 71 | }; 72 | 73 | this.getTileBounds = function(level, x, y) { 74 | // work in scaled pixels for this level 75 | var dimensionsScaled = self.dimensions.times(self.getLevelScale(level)); 76 | 77 | // find position, adjust for no overlap data on top and left edges 78 | var px = (x === 0) ? 0 : self.tileSize * x - self.tileOverlap; 79 | var py = (y === 0) ? 0 : self.tileSize * y - self.tileOverlap; 80 | 81 | // find size, adjust for no overlap data on top and left edges 82 | var sx = self.tileSize + (x === 0 ? 1 : 2) * self.tileOverlap; 83 | var sy = self.tileSize + (y === 0 ? 1 : 2) * self.tileOverlap; 84 | 85 | // adjust size for single-tile levels where the image size is smaller 86 | // than the regular tile size, and for tiles on the bottom and right 87 | // edges that would exceed the image bounds 88 | sx = Math.min(sx, dimensionsScaled.x - px); 89 | sy = Math.min(sy, dimensionsScaled.y - py); 90 | 91 | // finally, normalize... 92 | // note that isotropic coordinates ==> only dividing by scaled x! 93 | var scale = 1.0 / dimensionsScaled.x; 94 | return new SeadragonRect(px * scale, py * scale, sx * scale, sy * scale); 95 | }; 96 | 97 | this.getTileUrl = function(level, x, y) { 98 | throw new Error("Method not implemented."); 99 | }; 100 | 101 | this.tileExists = function(level, x, y) { 102 | var numTiles = self.getNumTiles(level); 103 | return level >= self.minLevel && level <= self.maxLevel && 104 | x >= 0 && y >= 0 && x < numTiles.x && y < numTiles.y; 105 | }; 106 | 107 | }; 108 | -------------------------------------------------------------------------------- /src/_intro.txt: -------------------------------------------------------------------------------- 1 | (function (window, document, Math, undefined) { 2 | -------------------------------------------------------------------------------- /src/_outro.txt: -------------------------------------------------------------------------------- 1 | 2 | })(window, document, Math); --------------------------------------------------------------------------------