Skip to content

Commit

Permalink
added annotation body getWidth and getHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Sep 30, 2018
1 parent e3d598a commit 93558d0
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 4 deletions.
6 changes: 6 additions & 0 deletions dist/client/manifesto.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3453,6 +3453,12 @@ var Manifesto;
}
return null;
};
AnnotationBody.prototype.getWidth = function () {
return this.getProperty('width');
};
AnnotationBody.prototype.getHeight = function () {
return this.getProperty('height');
};
return AnnotationBody;
}(Manifesto.ManifestResource));
Manifesto.AnnotationBody = AnnotationBody;
Expand Down
8 changes: 7 additions & 1 deletion dist/client/manifesto.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// manifesto v3.0.7 https://github.com/iiif-commons/manifesto
// manifesto v3.0.8 https://github.com/iiif-commons/manifesto
(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){
(function (global){

Expand Down Expand Up @@ -3381,6 +3381,12 @@ var Manifesto;
}
return null;
};
AnnotationBody.prototype.getWidth = function () {
return this.getProperty('width');
};
AnnotationBody.prototype.getHeight = function () {
return this.getProperty('height');
};
return AnnotationBody;
}(Manifesto.ManifestResource));
Manifesto.AnnotationBody = AnnotationBody;
Expand Down
4 changes: 3 additions & 1 deletion dist/manifesto.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// manifesto v3.0.7 https://github.com/iiif-commons/manifesto
// manifesto v3.0.8 https://github.com/iiif-commons/manifesto

declare namespace Manifesto {
class StringValue {
Expand Down Expand Up @@ -640,6 +640,8 @@ declare namespace Manifesto {
constructor(jsonld?: any, options?: IManifestoOptions);
getFormat(): MediaType | null;
getType(): ResourceType | null;
getWidth(): number;
getHeight(): number;
}
}

Expand Down
8 changes: 7 additions & 1 deletion dist/server/manifesto.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manifesto.js",
"version": "3.0.7",
"version": "3.0.8",
"description": "IIIF Presentation API utility library for client and server",
"main": "./dist/server/manifesto.js",
"types": "./dist/manifesto.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions src/AnnotationBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,13 @@ namespace Manifesto {

return null;
}

getWidth(): number {
return this.getProperty('width');
}

getHeight(): number {
return this.getProperty('height');
}
}
}
43 changes: 43 additions & 0 deletions test/annotation-dimensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var expect = require('chai').expect;
var manifesto = require('../dist/server/manifesto');
var should = require('chai').should();
var manifests = require('./fixtures/manifests');
require('./shared');

var manifest, sequence, canvas, content, annotation, body, label;

describe('#annotationDimensions', function() {

it('loads successfully', function (done) {
manifesto.loadManifest(manifests.annotationdimensions).then(function(data) {
manifest = manifesto.create(data);
done();
});
});

it('has a sequence', function() {
sequence = manifest.getSequenceByIndex(0);
expect(sequence).to.exist;
});

it('has a canvas', function() {
canvas = sequence.getCanvases()[0];
expect(canvas).to.exist;
});

it('has an annotation body', function() {
content = canvas.getContent();
annotation = content[0];
expect(annotation).to.exist;
body = annotation.getBody()[0];
expect(body).to.exist;
});

it('annotation body has a width and height', function() {
var width = body.getWidth();
expect(width === 916);
var height = body.getHeight();
expect(height === 1366);
});

});
1 change: 1 addition & 0 deletions test/fixtures/manifests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
"aarau": "http://localhost:3001/aarau.json",
"annotationdimensions": "http://localhost:3001/annotation-dimensions.json",
"anzacbulletin": "http://localhost:3001/anzacbulletin.json",
"audio": "http://localhost:3001/audio.json",
"bookofremembrance": "http://localhost:3001/book-of-remembrance.json",
Expand Down

0 comments on commit 93558d0

Please sign in to comment.