|
| 1 | +/*global anno:false */ |
1 | 2 | (function () { |
2 | 3 | 'use strict'; |
3 | 4 |
|
|
18 | 19 | activateSelector: activateSelector,//(opt_item_url_or_callback, opt_callback) |
19 | 20 | addAnnotation: addAnnotation,//(annotation, opt_replace) |
20 | 21 |
|
| 22 | + setProperties: setProperties, //(opt_options) |
21 | 23 | addHandler: addHandler, //(type, handler) |
22 | 24 | addPlugin: addPlugin, //(pluginName, opt_config_options) |
23 | 25 | destroy: destroy, //(opt_item_url) |
|
40 | 42 | return anno; |
41 | 43 | } |
42 | 44 |
|
| 45 | + /** |
| 46 | + * Sets the color properties for the annotation canvas. |
| 47 | + * NOTE: The text dialogs are out-of-scope and per CSS customizable. |
| 48 | + * The following properties can be changed: |
| 49 | + * |
| 50 | + * { |
| 51 | + * outline: '#00f', |
| 52 | + * stroke: '#ff0000', |
| 53 | + * fill: 'rgba(255, 0, 0, 0.3)', |
| 54 | + * hi_stroke: '#00ff00', |
| 55 | + * hi_fill: 'rgba(0, 255, 0, 0.3)' |
| 56 | + * } |
| 57 | + * |
| 58 | + * @param props |
| 59 | + */ |
| 60 | + function setProperties(props) { |
| 61 | + getAnnotorious().setProperties(props); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Creates and registers a plugin. |
| 66 | + * |
| 67 | + * @param pluginId |
| 68 | + * @param opt_config_options |
| 69 | + * @param pluginFunc |
| 70 | + * @param initFunc |
| 71 | + * @param annotatorFunc |
| 72 | + */ |
43 | 73 | function createPlugin(pluginId, opt_config_options, pluginFunc, initFunc, annotatorFunc) { |
44 | 74 | if (!opt_config_options) { |
45 | 75 | opt_config_options = {}; |
|
71 | 101 | addPlugin(pluginId, opt_config_options); |
72 | 102 | } |
73 | 103 |
|
| 104 | + |
| 105 | + /** |
| 106 | + * NOTE: this method is currently only relevant for the OpenLayers module. |
| 107 | + * Feel free to ignore in case you are only using the standard image annotation features of Annotorious. |
| 108 | + * Manually actives the selector. The selector can be activated on a specific |
| 109 | + * item or globally, on all items (which serves mainly as a shortcut for pages where |
| 110 | + * there is only one annotatable item). The function can take a callback function as parameter, |
| 111 | + * which will be called when the selector is deactivated again. |
| 112 | + * |
| 113 | + * @param opt_item_url_or_callback |
| 114 | + * @param opt_callback |
| 115 | + * @returns {*} |
| 116 | + */ |
74 | 117 | function activateSelector(opt_item_url_or_callback, opt_callback) { |
75 | 118 | return getAnnotorious().activateSelector(opt_item_url_or_callback, opt_callback); |
76 | 119 | } |
77 | 120 |
|
| 121 | + /** |
| 122 | + * Adds a new annotation, or replaces an existing annotation with a new annotation. |
| 123 | + * (In the latter case, the parameter opt_replace must be the existing annotation.) |
| 124 | + * |
| 125 | + * @param annotation |
| 126 | + * @param opt_replace |
| 127 | + * @returns {*} |
| 128 | + */ |
78 | 129 | function addAnnotation(annotation, opt_replace) { |
79 | 130 | return getAnnotorious().addAnnotation(annotation, opt_replace); |
80 | 131 | } |
81 | 132 |
|
| 133 | + /** |
| 134 | + * Adds an event handler function. |
| 135 | + * |
| 136 | + Annotorious issues the following events: |
| 137 | +
|
| 138 | + onMouseOverItem(event) - fired when the mouse enters an annotatable item |
| 139 | + onMouseOutOfItem(event) - fired when the mouse leaves an annotatable item |
| 140 | + onMouseOverAnnotation(event) - fired when the mouse enters an annotation |
| 141 | + onMouseOutOfAnnotation(event) - fired when the mouse leaves an annotation |
| 142 | + onSelectionStarted(event) - fired when the user starts a selection |
| 143 | + onSelectionCanceled(event) - fired when the user cancels a selection (not available on all selection tools) |
| 144 | + onSelectionCompleted(event) - fired when the user completes a selection |
| 145 | + onSelectionChanged(event) - fired when the user changed a selection |
| 146 | + beforePopupHide(popup) - fired just before the annotation info popup window hides |
| 147 | + beforeAnnotationRemoved(annotation) - fired before an annotation is removed (Note: it is possible to prevent annotation removal by returning false from the handler method!) |
| 148 | + onAnnotationRemoved(annotation) - fired when an annotation is removed from an imgae |
| 149 | + onAnnotationCreated(annotation) - fired when an annotation was created |
| 150 | + onAnnotationUpdated(annotation) - fired when an existing annotation was edited/updated |
| 151 | + * |
| 152 | + * @param type |
| 153 | + * @param handler |
| 154 | + * @returns {*} |
| 155 | + */ |
82 | 156 | function addHandler(type, handler) { |
83 | 157 | return getAnnotorious().addHandler(type, handler); |
84 | 158 | } |
85 | 159 |
|
| 160 | + /** |
| 161 | + * Registers a plugin. For more information, |
| 162 | + * see the Plugins Wiki page https://github.com/annotorious/annotorious/wiki/Plugins. |
| 163 | + * |
| 164 | + * @param pluginName |
| 165 | + * @param opt_config_options |
| 166 | + * @returns {*} |
| 167 | + */ |
86 | 168 | function addPlugin(pluginName, opt_config_options) { |
87 | 169 | return getAnnotorious().addPlugin(pluginName, opt_config_options); |
88 | 170 | } |
89 | 171 |
|
| 172 | + /** |
| 173 | + * Destroys annotation functionality on a specific item, or on all items on the page. |
| 174 | + * Note that this method differs from anno.reset() (see below) insofar as destroy does not |
| 175 | + * re-evaluate the annotatable CSS attributes. What is destroyed, stays destroyed. |
| 176 | + * (Until re-enabled through anno.makeAnnotatable()). |
| 177 | + * |
| 178 | + * @param opt_item_url |
| 179 | + * @returns {*} |
| 180 | + */ |
90 | 181 | function destroy(opt_item_url) { |
91 | 182 | return getAnnotorious().destroy(opt_item_url); |
92 | 183 | } |
93 | 184 |
|
| 185 | + /** |
| 186 | + * Returns the current annotations. opt_item_url is optional. If omitted, |
| 187 | + * the method call will return all annotations, on all annotatable items on the page. |
| 188 | + * If set to a specific item URL, only the annotations on that item will be returned. |
| 189 | + * |
| 190 | + * @param opt_item_url |
| 191 | + * @returns {*} |
| 192 | + */ |
94 | 193 | function getAnnotations(opt_item_url) { |
95 | 194 | return getAnnotorious().getAnnotations(opt_item_url); |
96 | 195 | } |
97 | 196 |
|
| 197 | + /** |
| 198 | + * Hides existing annotations on all, or a specific item. |
| 199 | + * |
| 200 | + * @param opt_item_url |
| 201 | + * @returns {*} |
| 202 | + */ |
98 | 203 | function hideAnnotations(opt_item_url) { |
99 | 204 | return getAnnotorious().hideAnnotations(opt_item_url); |
100 | 205 | } |
101 | 206 |
|
| 207 | + /** |
| 208 | + * Disables the selection widget (the small tooltip in the upper left corner which |
| 209 | + * says "Click and Drag to Annotate"), thus preventing users from creating new annotations |
| 210 | + * altogether. The typical use case for this is 'read-only' annotated images. |
| 211 | + * I.e. if you want to add some pre-defined annotations using anno.addAnnotation without the |
| 212 | + * user being able to add or change anything. |
| 213 | + * |
| 214 | + * The selection widget can be hidden on a specific item or globally, on all annotatable items on the page. |
| 215 | + * |
| 216 | + * @param opt_item_url |
| 217 | + * @returns {*} |
| 218 | + */ |
102 | 219 | function hideSelectionWidget(opt_item_url) { |
103 | 220 | return getAnnotorious().hideSelectionWidget(opt_item_url); |
104 | 221 | } |
105 | 222 |
|
| 223 | + /** |
| 224 | + * Highlights the specified annotation, just as if the mouse pointer was hovering over it. |
| 225 | + * The annotation will remain highlighted until one of these conditions is met: |
| 226 | + * |
| 227 | + * -The user moves the mouse into, and out of the annotation |
| 228 | + * -The user moves the mouse over another annotation |
| 229 | + * -The highlight is removed by calling this method with an empty parameter, e.g. anno.highlightAnnotation() or anno.highlightAnnotation(undefined) |
| 230 | + * -Another annotation is highlighted via anno.highlightAnnotation |
| 231 | + * |
| 232 | + * @param annotation |
| 233 | + * @returns {*} |
| 234 | + */ |
106 | 235 | function highlightAnnotation(annotation) { |
107 | 236 | return getAnnotorious().highlightAnnotation(annotation); |
108 | 237 | } |
109 | 238 |
|
| 239 | + /** |
| 240 | + * Makes an item on the screen annotatable (if there is a module available supporting the item format). |
| 241 | + * You can use this method as an alternative to CSS-based activation. It works just the same way, |
| 242 | + * and is simply there for convenience, and to prepare for (future) item formats that technically |
| 243 | + * don't support CSS-based activation (such as Web maps). |
| 244 | + * |
| 245 | + * @param item |
| 246 | + * @returns {*} |
| 247 | + */ |
110 | 248 | function makeAnnotatable(item) { |
111 | 249 | return getAnnotorious().makeAnnotatable(item); |
112 | 250 | } |
113 | 251 |
|
| 252 | + /** |
| 253 | + * Removes all annotations. If the optional parameter opt_item_url is set, only the annotations on the |
| 254 | + * specified item will be removed. Otherwise all annotations on all items on the page will be removed. |
| 255 | + * |
| 256 | + * @param opt_item_url |
| 257 | + * @returns {*} |
| 258 | + */ |
114 | 259 | function removeAll(opt_item_url) { |
115 | 260 | return getAnnotorious().removeAll(opt_item_url); |
116 | 261 | } |
117 | 262 |
|
| 263 | + /** |
| 264 | + * Removes an annotation from the page. |
| 265 | + * |
| 266 | + * @param annotation |
| 267 | + * @returns {*} |
| 268 | + */ |
118 | 269 | function removeAnnotation(annotation) { |
119 | 270 | return getAnnotorious().removeAnnotation(annotation); |
120 | 271 | } |
121 | 272 |
|
122 | | - /* |
123 | | - reset Annotorious |
124 | | - Annotorious will destroy the current annotation canvas, and create a new one |
| 273 | + /** |
| 274 | + * Performs a 'hard reset' on Annotorious. This means all annotation features will be removed, |
| 275 | + * and the page will be re-scanned for items with the 'annotatable' CSS class. (Note: this method |
| 276 | + * could be handy in case you are working with JavaScript image carousels. Just make sure |
| 277 | + * the images have 'annotatable' set, then reset Annotorious after each page flip.) |
| 278 | + * |
| 279 | + * NOTE: Annotorious will destroy the current annotation canvas, and create a new one |
| 280 | + * |
| 281 | + * @returns {*} |
125 | 282 | */ |
126 | 283 | function reset() { |
127 | 284 | return getAnnotorious().reset(); |
128 | 285 | } |
129 | 286 |
|
| 287 | + /** |
| 288 | + * Shows existing annotations on all, or a specific item (if they were hidden using anno.hideAnnotations). |
| 289 | + * |
| 290 | + * @param opt_item_url |
| 291 | + * @returns {*} |
| 292 | + */ |
130 | 293 | function showAnnotations(opt_item_url) { |
131 | 294 | return getAnnotorious().showAnnotations(opt_item_url); |
132 | 295 | } |
133 | 296 |
|
| 297 | + /** |
| 298 | + * Enables the selection widget (the small tooltip in the upper left corner which says |
| 299 | + * "Click and Drag to Annotate"), thus enabling users to creating new annotations. |
| 300 | + * (Per default, the selection widget is enabled.) |
| 301 | + * |
| 302 | + * @param opt_item_url |
| 303 | + * @returns {*} |
| 304 | + */ |
134 | 305 | function showSelectionWidget(opt_item_url) { |
135 | 306 | return getAnnotorious().showSelectionWidget(opt_item_url); |
136 | 307 | } |
|
153 | 324 | if ($attributes.src) { |
154 | 325 | annotoriousService.makeAnnotatable($element[0]); |
155 | 326 | } else { |
156 | | - $element.bind('load', function() { |
| 327 | + $element.bind('load', function () { |
157 | 328 | $scope.$apply(function () { |
158 | 329 | annotoriousService.makeAnnotatable($element[0]); |
159 | 330 | }); |
|
0 commit comments