Skip to content

Commit 2a77a8c

Browse files
committed
Merge branch 'operational-work-sprint3-staging' of github.com:TAMULib/CAP into operational-work-sprint3-ci-fix
2 parents c15fe21 + 455bded commit 2a77a8c

File tree

6 files changed

+176
-3
lines changed

6 files changed

+176
-3
lines changed

.wvr/build-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const config = {
6161
'./node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
6262
'./node_modules/ng-table/bundles/ng-table.js',
6363
'./node_modules/openseadragon/build/openseadragon/openseadragon.js',
64-
'./node_modules/ng-openseadragon/build/angular-openseadragon.js',
64+
'./src/main/webapp/app/resources/scripts/ng-openseadragon/build/angular-openseadragon.js',
6565
'./node_modules/@wvr/core/app/config/coreConfig.js',
6666
'./node_modules/@wvr/core/app/components/version/version.js',
6767
'./node_modules/@wvr/core/app/components/version/version-directive.js',

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"dependencies": {
2828
"@wvr/core": "2.2.7",
2929
"ng-csv": "0.3.6",
30-
"ng-openseadragon": "1.3.5",
3130
"ng-table": "3.0.1",
3231
"openseadragon": "2.4.0"
3332
},

src/main/resources/templates/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<body>
3131
<main>
32-
<tl-header page-title="CAP"></tl-header>
32+
<tl-header page-title="CAP" page-title-url="/home/"></tl-header>
3333

3434
<alerts types="WARNING,ERROR"></alerts>
3535

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Damien DALY
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
"use strict";
2+
(function () {
3+
var module = angular.module("ui.openseadragon", []);
4+
module.directive("seadragon", ['$timeout', function ($timeout) {
5+
return {
6+
restrict: "E",
7+
scope: {
8+
options: "=",
9+
name: "=",
10+
tilesource: "=",
11+
prefixUrl: "="
12+
},
13+
controller: ["$scope", function ($scope) {
14+
$scope.osd = null;
15+
}],
16+
link: function (scope, element, attrs) {
17+
18+
19+
20+
if (attrs.tilesource) {
21+
opts.tileSources = [attrs.tilesource];
22+
}
23+
if (attrs.prefixUrl) {
24+
opts.prefixUrl = attrs.prefixUrl;
25+
}
26+
27+
function _bootstrap() {
28+
if (scope.osd) {
29+
scope.osd.destroy();
30+
scope.osd = null;
31+
}
32+
//Create options object
33+
var opts = angular.extend({}, scope.options, {
34+
id: "openseadragon-" + Math.random(),
35+
element: element[0],
36+
});
37+
//Create the viewer
38+
scope.osd = OpenSeadragon(opts);
39+
//Create a wrapper
40+
var wrapper = {
41+
mouse: {
42+
position: null,
43+
imageCoord: null,
44+
viewportCoord: null,
45+
},
46+
zoom: 0,
47+
viewport: {}
48+
}
49+
50+
for(var key in scope.osd) {
51+
wrapper[key] = scope.osd[key];
52+
}
53+
54+
if (attrs.name) {
55+
//Make the OSD available to parent scope
56+
scope.$parent[attrs.name] = wrapper;
57+
//Define event handlers
58+
zoomHandler = function (e) {
59+
$timeout(function() {
60+
scope.$apply(function () {
61+
wrapper.zoom = e.zoom;
62+
});
63+
},0);
64+
}
65+
updateViewportHandler = function (e) {
66+
scope.$apply(function () {
67+
wrapper.viewportInfo = {
68+
bounds: scope.osd.viewport.getBounds(false),
69+
center: scope.osd.viewport.getCenter(false),
70+
rotation: scope.osd.viewport.getRotation(),
71+
zoom: scope.osd.viewport.getZoom(false),
72+
};
73+
});
74+
}
75+
76+
//Assign event handlers
77+
scope.osd.addHandler("zoom", zoomHandler);
78+
scope.osd.addHandler("update-viewport", updateViewportHandler);
79+
80+
//Add a mouse handler
81+
scope.mouse = new OpenSeadragon.MouseTracker({
82+
element: scope.osd.canvas,
83+
enterHandler: function (e) {
84+
if (scope.osd.viewport) {
85+
var coord = OpenSeadragon.getElementPosition(scope.osd.canvas);
86+
var pos = e.position.plus(coord);
87+
var mouse = {
88+
position: pos,
89+
imageCoord: scope.osd.viewport.windowToImageCoordinates(pos),
90+
viewportCoord: scope.osd.viewport.windowToViewportCoordinates(pos),
91+
}
92+
scope.$apply(function () {
93+
wrapper.mouse = mouse;
94+
});
95+
}
96+
},
97+
moveHandler: function (e) {
98+
if (scope.osd.viewport) {
99+
var coord = OpenSeadragon.getElementPosition(scope.osd.canvas);
100+
var pos = e.position.plus(coord);
101+
var mouse = {
102+
position: pos,
103+
imageCoord: scope.osd.viewport.windowToImageCoordinates(pos),
104+
viewportCoord: scope.osd.viewport.windowToViewportCoordinates(pos),
105+
}
106+
scope.$apply(function () {
107+
wrapper.mouse = mouse;
108+
});
109+
}
110+
},
111+
exitHandler: function (e) {
112+
scope.$apply(function () {
113+
wrapper.mouse.position = null;
114+
wrapper.mouse.imageCoord = null;
115+
wrapper.mouse.viewportCoord = null;
116+
});
117+
},
118+
});
119+
scope.mouse.setTracking(true);
120+
}
121+
122+
}
123+
_bootstrap();
124+
var optionsWatcher = scope.$watch('options', _bootstrap);
125+
126+
//if @name is set, put the wrapper in the scope and handle the events
127+
var zoomHandler = null;
128+
var updateViewportHandler = null;
129+
130+
131+
//When element is destroyed, destroy the viewer
132+
element.on('$destroy', function () {
133+
//if @nam eis set, remove it from parent scope, and remove event handlers
134+
if (attrs.name) {
135+
//Remove from parent scope
136+
scope.$parent[attrs.name] = null;
137+
138+
//Destroy mouse handler
139+
scope.mouse.destroy();
140+
optionsWatcher();
141+
//Remove event handlers
142+
scope.osd.removeHandler("zoom", zoomHandler);
143+
scope.osd.removeHandler("update-viewport", updateViewportHandler);
144+
}
145+
146+
//Destroy the viewer
147+
scope.osd.destroy();
148+
});
149+
},
150+
};
151+
}]);
152+
})();

src/main/webapp/app/resources/scripts/ng-openseadragon/build/ng-openseadragon.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)