Skip to content

Commit

Permalink
added getRequiredStatement
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Aug 22, 2018
1 parent e5b749b commit 8bd5b63
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 172 deletions.
380 changes: 242 additions & 138 deletions dist/@iiif/manifold.bundle.js

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions dist/@iiif/manifold.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ declare namespace Manifold {
getLogo(): string | null;
getManifestType(): Manifesto.ManifestType;
getMetadata(options?: MetadataOptions): MetadataGroup[];
getRequiredStatement(): ILabelValuePair | null;
private _parseMetadataOptions(options, metadataGroups);
private _getRangeMetadata(metadataGroups, range);
getMultiSelectState(): Manifold.MultiSelectState;
Expand Down Expand Up @@ -246,6 +247,7 @@ declare namespace Manifold {
getRangeCanvases(range: Manifesto.IRange): Manifesto.ICanvas[];
getRanges(): IRange[];
getRelated(): any;
getRequiredStatement(): ILabelValuePair | null;
getSearchService(): Manifesto.IService | null;
getSeeAlso(): any;
getSequenceByIndex(index: number): Manifesto.ISequence;
Expand Down Expand Up @@ -283,6 +285,13 @@ declare namespace Manifold {
}
}

declare namespace Manifold {
class ILabelValuePair {
label: string | null;
value: string | null;
}
}

interface IManifold {
loadManifest: (options: Manifold.IManifoldOptions) => Promise<Manifold.IHelper>;
}
Expand All @@ -304,7 +313,7 @@ declare namespace Manifold {

/// <reference types="manifesto.js" />
declare namespace Manifold {
interface IMetadataItem extends Manifesto.MetadataItem {
interface IMetadataItem extends Manifesto.LabelValuePair {
isRootLevel: boolean;
}
}
Expand Down Expand Up @@ -345,7 +354,7 @@ declare namespace Manifold {
items: Manifold.IMetadataItem[];
constructor(resource: Manifesto.IManifestResource, label?: string);
addItem(item: Manifold.IMetadataItem): void;
addMetadata(metadata: Manifesto.MetadataItem[], isRootLevel?: boolean): void;
addMetadata(metadata: Manifesto.LabelValuePair[], isRootLevel?: boolean): void;
}
}

Expand Down
28 changes: 24 additions & 4 deletions dist/@iiif/manifold.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,14 @@ var Manifold;
manifestGroup.addMetadata(manifestMetadata, true);
}
if (this.manifest.getDescription().length) {
var metadataItem = new Manifesto.MetadataItem(this.options.locale);
var metadataItem = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.label = [new Manifesto.Translation("description", this.options.locale)];
metadataItem.value = this.manifest.getDescription();
metadataItem.isRootLevel = true;
manifestGroup.addItem(metadataItem);
}
if (this.manifest.getAttribution().length) {
var metadataItem = new Manifesto.MetadataItem(this.options.locale);
var metadataItem = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.label = [new Manifesto.Translation("attribution", this.options.locale)];
metadataItem.value = this.manifest.getAttribution();
metadataItem.isRootLevel = true;
Expand All @@ -596,7 +596,7 @@ var Manifold;
label: "license",
value: (options && options.licenseFormatter) ? options.licenseFormatter.format(license) : license
};
var metadataItem = new Manifesto.MetadataItem(this.options.locale);
var metadataItem = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.parse(item);
metadataItem.isRootLevel = true;
manifestGroup.addItem(metadataItem);
Expand All @@ -606,7 +606,7 @@ var Manifold;
label: "logo",
value: '<img src="' + this.manifest.getLogo() + '"/>'
};
var metadataItem = new Manifesto.MetadataItem(this.options.locale);
var metadataItem = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.parse(item);
metadataItem.isRootLevel = true;
manifestGroup.addItem(metadataItem);
Expand All @@ -619,6 +619,16 @@ var Manifold;
return metadataGroups;
}
};
Helper.prototype.getRequiredStatement = function () {
var requiredStatement = this.manifest.getRequiredStatement();
if (requiredStatement) {
return {
label: requiredStatement.getLabel(),
value: requiredStatement.getValue()
};
}
return null;
};
Helper.prototype._parseMetadataOptions = function (options, metadataGroups) {
// get sequence metadata
var sequence = this.getCurrentSequence();
Expand Down Expand Up @@ -1168,6 +1178,16 @@ var Manifold;



var Manifold;
(function (Manifold) {
var ILabelValuePair = /** @class */ (function () {
function ILabelValuePair() {
}
return ILabelValuePair;
}());
Manifold.ILabelValuePair = ILabelValuePair;
})(Manifold || (Manifold = {}));




Expand Down
15 changes: 12 additions & 3 deletions dist/manifold.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @iiif/manifold v1.2.30 https://github.com/iiif-commons/manifold#readme
// @iiif/manifold v1.2.31 https://github.com/iiif-commons/manifold#readme
interface Window {
manifestCallback: any;
}
Expand Down Expand Up @@ -128,6 +128,7 @@ declare namespace Manifold {
getLogo(): string | null;
getManifestType(): Manifesto.ManifestType;
getMetadata(options?: MetadataOptions): MetadataGroup[];
getRequiredStatement(): ILabelValuePair | null;
private _parseMetadataOptions(options, metadataGroups);
private _getRangeMetadata(metadataGroups, range);
getMultiSelectState(): Manifold.MultiSelectState;
Expand Down Expand Up @@ -247,6 +248,7 @@ declare namespace Manifold {
getRangeCanvases(range: Manifesto.IRange): Manifesto.ICanvas[];
getRanges(): IRange[];
getRelated(): any;
getRequiredStatement(): ILabelValuePair | null;
getSearchService(): Manifesto.IService | null;
getSeeAlso(): any;
getSequenceByIndex(index: number): Manifesto.ISequence;
Expand Down Expand Up @@ -284,6 +286,13 @@ declare namespace Manifold {
}
}

declare namespace Manifold {
class ILabelValuePair {
label: string | null;
value: string | null;
}
}

interface IManifold {
loadManifest: (options: Manifold.IManifoldOptions) => Promise<Manifold.IHelper>;
}
Expand All @@ -305,7 +314,7 @@ declare namespace Manifold {

/// <reference types="manifesto.js" />
declare namespace Manifold {
interface IMetadataItem extends Manifesto.MetadataItem {
interface IMetadataItem extends Manifesto.LabelValuePair {
isRootLevel: boolean;
}
}
Expand Down Expand Up @@ -346,7 +355,7 @@ declare namespace Manifold {
items: Manifold.IMetadataItem[];
constructor(resource: Manifesto.IManifestResource, label?: string);
addItem(item: Manifold.IMetadataItem): void;
addMetadata(metadata: Manifesto.MetadataItem[], isRootLevel?: boolean): void;
addMetadata(metadata: Manifesto.LabelValuePair[], isRootLevel?: boolean): void;
}
}

Expand Down
30 changes: 25 additions & 5 deletions dist/manifold.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @iiif/manifold v1.2.30 https://github.com/iiif-commons/manifold#readme
// @iiif/manifold v1.2.31 https://github.com/iiif-commons/manifold#readme
(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.iiifmanifold = 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 @@ -578,14 +578,14 @@ var Manifold;
manifestGroup.addMetadata(manifestMetadata, true);
}
if (this.manifest.getDescription().length) {
var metadataItem = new Manifesto.MetadataItem(this.options.locale);
var metadataItem = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.label = [new Manifesto.Translation("description", this.options.locale)];
metadataItem.value = this.manifest.getDescription();
metadataItem.isRootLevel = true;
manifestGroup.addItem(metadataItem);
}
if (this.manifest.getAttribution().length) {
var metadataItem = new Manifesto.MetadataItem(this.options.locale);
var metadataItem = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.label = [new Manifesto.Translation("attribution", this.options.locale)];
metadataItem.value = this.manifest.getAttribution();
metadataItem.isRootLevel = true;
Expand All @@ -597,7 +597,7 @@ var Manifold;
label: "license",
value: (options && options.licenseFormatter) ? options.licenseFormatter.format(license) : license
};
var metadataItem = new Manifesto.MetadataItem(this.options.locale);
var metadataItem = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.parse(item);
metadataItem.isRootLevel = true;
manifestGroup.addItem(metadataItem);
Expand All @@ -607,7 +607,7 @@ var Manifold;
label: "logo",
value: '<img src="' + this.manifest.getLogo() + '"/>'
};
var metadataItem = new Manifesto.MetadataItem(this.options.locale);
var metadataItem = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.parse(item);
metadataItem.isRootLevel = true;
manifestGroup.addItem(metadataItem);
Expand All @@ -620,6 +620,16 @@ var Manifold;
return metadataGroups;
}
};
Helper.prototype.getRequiredStatement = function () {
var requiredStatement = this.manifest.getRequiredStatement();
if (requiredStatement) {
return {
label: requiredStatement.getLabel(),
value: requiredStatement.getValue()
};
}
return null;
};
Helper.prototype._parseMetadataOptions = function (options, metadataGroups) {
// get sequence metadata
var sequence = this.getCurrentSequence();
Expand Down Expand Up @@ -1169,6 +1179,16 @@ var Manifold;



var Manifold;
(function (Manifold) {
var ILabelValuePair = /** @class */ (function () {
function ILabelValuePair() {
}
return ILabelValuePair;
}());
Manifold.ILabelValuePair = ILabelValuePair;
})(Manifold || (Manifold = {}));




Expand Down
4 changes: 2 additions & 2 deletions dist/manifold.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iiif/manifold",
"version": "1.2.30",
"version": "1.2.31",
"description": "",
"main": "./dist/manifold.js",
"types": "./dist/manifold.d.ts",
Expand All @@ -18,7 +18,7 @@
"devDependencies": {
"gulp": "^3.9.1",
"gulp-tasks": "iiif-commons/gulp-tasks#v1.0.7",
"manifesto.js": "2.2.30"
"manifesto.js": "2.3.1"
},
"dependencies": {
"@types/jquery": "^2.0.40"
Expand Down
39 changes: 26 additions & 13 deletions src/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,27 @@ namespace Manifold {
public getMetadata(options?: MetadataOptions): MetadataGroup[] {

const metadataGroups: MetadataGroup[] = [];
const manifestMetadata: Manifesto.MetadataItem[] = this.manifest.getMetadata();
const manifestMetadata: Manifesto.LabelValuePair[] = this.manifest.getMetadata();
const manifestGroup: MetadataGroup = new MetadataGroup(this.manifest);

if (manifestMetadata && manifestMetadata.length) {
manifestGroup.addMetadata(manifestMetadata, true);
}

if (this.manifest.getDescription().length) {
const metadataItem: Manifesto.MetadataItem = new Manifesto.MetadataItem(this.options.locale);
const metadataItem: Manifesto.LabelValuePair = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.label = [new Manifesto.Translation("description", this.options.locale)];
metadataItem.value = this.manifest.getDescription();
(<IMetadataItem>metadataItem).isRootLevel = true;
manifestGroup.addItem(<IMetadataItem>metadataItem);
(<Manifold.IMetadataItem>metadataItem).isRootLevel = true;
manifestGroup.addItem(<Manifold.IMetadataItem>metadataItem);
}

if (this.manifest.getAttribution().length) {
const metadataItem: Manifesto.MetadataItem = new Manifesto.MetadataItem(this.options.locale);
const metadataItem: Manifesto.LabelValuePair = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.label = [new Manifesto.Translation("attribution", this.options.locale)];
metadataItem.value = this.manifest.getAttribution();
(<IMetadataItem>metadataItem).isRootLevel = true;
manifestGroup.addItem(<IMetadataItem>metadataItem);
(<Manifold.IMetadataItem>metadataItem).isRootLevel = true;
manifestGroup.addItem(<Manifold.IMetadataItem>metadataItem);
}

const license: string | null = this.manifest.getLicense();
Expand All @@ -214,21 +214,21 @@ namespace Manifold {
label: "license",
value: (options && options.licenseFormatter) ? options.licenseFormatter.format(license) : license
};
const metadataItem: Manifesto.MetadataItem = new Manifesto.MetadataItem(this.options.locale);
const metadataItem: Manifesto.LabelValuePair = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.parse(item);
(<IMetadataItem>metadataItem).isRootLevel = true;
manifestGroup.addItem(<IMetadataItem>metadataItem);
(<Manifold.IMetadataItem>metadataItem).isRootLevel = true;
manifestGroup.addItem(<Manifold.IMetadataItem>metadataItem);
}

if (this.manifest.getLogo()) {
const item: any = {
label: "logo",
value: '<img src="' + this.manifest.getLogo() + '"/>'
};
const metadataItem: Manifesto.MetadataItem = new Manifesto.MetadataItem(this.options.locale);
const metadataItem: Manifesto.LabelValuePair = new Manifesto.LabelValuePair(this.options.locale);
metadataItem.parse(item);
(<IMetadataItem>metadataItem).isRootLevel = true;
manifestGroup.addItem(<IMetadataItem>metadataItem);
(<Manifold.IMetadataItem>metadataItem).isRootLevel = true;
manifestGroup.addItem(<Manifold.IMetadataItem>metadataItem);
}

metadataGroups.push(manifestGroup);
Expand All @@ -239,6 +239,19 @@ namespace Manifold {
return metadataGroups;
}
}

public getRequiredStatement(): ILabelValuePair | null {
const requiredStatement: Manifesto.LabelValuePair | null = this.manifest.getRequiredStatement();

if (requiredStatement) {
return {
label: requiredStatement.getLabel(),
value: requiredStatement.getValue()
}
}

return null;
}

private _parseMetadataOptions(options: MetadataOptions, metadataGroups: MetadataGroup[]): MetadataGroup[] {

Expand Down
1 change: 1 addition & 0 deletions src/IHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace Manifold {
getRangeCanvases(range: Manifesto.IRange): Manifesto.ICanvas[];
getRanges(): IRange[];
getRelated(): any;
getRequiredStatement(): ILabelValuePair | null;
getSearchService(): Manifesto.IService | null;
getSeeAlso(): any;
getSequenceByIndex(index: number): Manifesto.ISequence;
Expand Down
8 changes: 8 additions & 0 deletions src/ILabelValuePair.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Manifold {

export class ILabelValuePair {
label: string | null;
value: string | null;
}

}
2 changes: 1 addition & 1 deletion src/IMetadataItem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Manifold {

export interface IMetadataItem extends Manifesto.MetadataItem {
export interface IMetadataItem extends Manifesto.LabelValuePair {
isRootLevel: boolean;
}

Expand Down
4 changes: 2 additions & 2 deletions src/MetadataGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace Manifold {
this.items.push(item);
}

public addMetadata(metadata: Manifesto.MetadataItem[], isRootLevel: boolean = false): void {
public addMetadata(metadata: Manifesto.LabelValuePair[], isRootLevel: boolean = false): void {
for (let i = 0; i < metadata.length; i++) {
const item: Manifesto.MetadataItem = metadata[i];
const item: Manifesto.LabelValuePair = metadata[i];
(<Manifold.IMetadataItem>item).isRootLevel = isRootLevel;
this.addItem(<Manifold.IMetadataItem>item);
}
Expand Down

0 comments on commit 8bd5b63

Please sign in to comment.