Skip to content

Commit 93558d0

Browse files
committed
added annotation body getWidth and getHeight
1 parent e3d598a commit 93558d0

File tree

8 files changed

+76
-4
lines changed

8 files changed

+76
-4
lines changed

dist/client/manifesto.bundle.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,6 +3453,12 @@ var Manifesto;
34533453
}
34543454
return null;
34553455
};
3456+
AnnotationBody.prototype.getWidth = function () {
3457+
return this.getProperty('width');
3458+
};
3459+
AnnotationBody.prototype.getHeight = function () {
3460+
return this.getProperty('height');
3461+
};
34563462
return AnnotationBody;
34573463
}(Manifesto.ManifestResource));
34583464
Manifesto.AnnotationBody = AnnotationBody;

dist/client/manifesto.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// manifesto v3.0.7 https://github.com/iiif-commons/manifesto
1+
// manifesto v3.0.8 https://github.com/iiif-commons/manifesto
22
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.manifesto = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
33
(function (global){
44

@@ -3381,6 +3381,12 @@ var Manifesto;
33813381
}
33823382
return null;
33833383
};
3384+
AnnotationBody.prototype.getWidth = function () {
3385+
return this.getProperty('width');
3386+
};
3387+
AnnotationBody.prototype.getHeight = function () {
3388+
return this.getProperty('height');
3389+
};
33843390
return AnnotationBody;
33853391
}(Manifesto.ManifestResource));
33863392
Manifesto.AnnotationBody = AnnotationBody;

dist/manifesto.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// manifesto v3.0.7 https://github.com/iiif-commons/manifesto
1+
// manifesto v3.0.8 https://github.com/iiif-commons/manifesto
22

33
declare namespace Manifesto {
44
class StringValue {
@@ -640,6 +640,8 @@ declare namespace Manifesto {
640640
constructor(jsonld?: any, options?: IManifestoOptions);
641641
getFormat(): MediaType | null;
642642
getType(): ResourceType | null;
643+
getWidth(): number;
644+
getHeight(): number;
643645
}
644646
}
645647

dist/server/manifesto.js

Lines changed: 7 additions & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "manifesto.js",
3-
"version": "3.0.7",
3+
"version": "3.0.8",
44
"description": "IIIF Presentation API utility library for client and server",
55
"main": "./dist/server/manifesto.js",
66
"types": "./dist/manifesto.d.ts",

src/AnnotationBody.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,13 @@ namespace Manifesto {
2424

2525
return null;
2626
}
27+
28+
getWidth(): number {
29+
return this.getProperty('width');
30+
}
31+
32+
getHeight(): number {
33+
return this.getProperty('height');
34+
}
2735
}
2836
}

test/annotation-dimensions.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
var expect = require('chai').expect;
2+
var manifesto = require('../dist/server/manifesto');
3+
var should = require('chai').should();
4+
var manifests = require('./fixtures/manifests');
5+
require('./shared');
6+
7+
var manifest, sequence, canvas, content, annotation, body, label;
8+
9+
describe('#annotationDimensions', function() {
10+
11+
it('loads successfully', function (done) {
12+
manifesto.loadManifest(manifests.annotationdimensions).then(function(data) {
13+
manifest = manifesto.create(data);
14+
done();
15+
});
16+
});
17+
18+
it('has a sequence', function() {
19+
sequence = manifest.getSequenceByIndex(0);
20+
expect(sequence).to.exist;
21+
});
22+
23+
it('has a canvas', function() {
24+
canvas = sequence.getCanvases()[0];
25+
expect(canvas).to.exist;
26+
});
27+
28+
it('has an annotation body', function() {
29+
content = canvas.getContent();
30+
annotation = content[0];
31+
expect(annotation).to.exist;
32+
body = annotation.getBody()[0];
33+
expect(body).to.exist;
34+
});
35+
36+
it('annotation body has a width and height', function() {
37+
var width = body.getWidth();
38+
expect(width === 916);
39+
var height = body.getHeight();
40+
expect(height === 1366);
41+
});
42+
43+
});

test/fixtures/manifests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
"aarau": "http://localhost:3001/aarau.json",
3+
"annotationdimensions": "http://localhost:3001/annotation-dimensions.json",
34
"anzacbulletin": "http://localhost:3001/anzacbulletin.json",
45
"audio": "http://localhost:3001/audio.json",
56
"bookofremembrance": "http://localhost:3001/book-of-remembrance.json",

0 commit comments

Comments
 (0)