Skip to content

Commit

Permalink
normalise canvas ids
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Sep 13, 2018
1 parent 4bd9157 commit 203916b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 18 deletions.
4 changes: 2 additions & 2 deletions dist/iiif-av-component.bundle.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/iiif-av-component.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// iiif-av-component v0.0.79 https://github.com/iiif-commons/iiif-av-component#readme
// iiif-av-component v0.0.80 https://github.com/iiif-commons/iiif-av-component#readme
interface Array<T> {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
Expand Down Expand Up @@ -47,6 +47,7 @@ declare namespace IIIFComponents {
private _prevRange();
private _nextRange();
private _setCanvasInstanceVolumes(volume);
private _getNormaliseCanvasId(canvasId);
private _getCanvasInstanceById(canvasId);
private _getCurrentCanvas();
private _rewind();
Expand Down
15 changes: 11 additions & 4 deletions dist/iiif-av-component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// iiif-av-component v0.0.79 https://github.com/iiif-commons/iiif-av-component#readme
// iiif-av-component v0.0.80 https://github.com/iiif-commons/iiif-av-component#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.iiifAvComponent = 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 @@ -347,14 +347,21 @@ var IIIFComponents;
});
});
};
AVComponent.prototype._getNormaliseCanvasId = function (canvasId) {
return (canvasId.includes('://')) ? Manifesto.Utils.normaliseUrl(canvasId) : canvasId;
};
AVComponent.prototype._getCanvasInstanceById = function (canvasId) {
canvasId = (canvasId.includes('://')) ? Manifesto.Utils.normaliseUrl(canvasId) : canvasId;
canvasId = this._getNormaliseCanvasId(canvasId);
// if virtual canvas is enabled, check for that first
if (this._data.virtualCanvasEnabled) {
for (var i = 0; i < this.canvasInstances.length; i++) {
var canvasInstance = this.canvasInstances[i];
if (canvasInstance.isVirtual() && canvasInstance.getCanvasId() === canvasId || canvasInstance.includesVirtualSubCanvas(canvasId)) {
return canvasInstance;
var currentCanvasId = canvasInstance.getCanvasId();
if (currentCanvasId) {
currentCanvasId = this._getNormaliseCanvasId(currentCanvasId);
if (canvasInstance.isVirtual() && currentCanvasId === canvasId || canvasInstance.includesVirtualSubCanvas(canvasId)) {
return canvasInstance;
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions dist/iiif-av-component.min.js

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions examples/js/iiif-av-component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// iiif-av-component v0.0.79 https://github.com/iiif-commons/iiif-av-component#readme
// iiif-av-component v0.0.80 https://github.com/iiif-commons/iiif-av-component#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.iiifAvComponent = 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 @@ -347,14 +347,21 @@ var IIIFComponents;
});
});
};
AVComponent.prototype._getNormaliseCanvasId = function (canvasId) {
return (canvasId.includes('://')) ? Manifesto.Utils.normaliseUrl(canvasId) : canvasId;
};
AVComponent.prototype._getCanvasInstanceById = function (canvasId) {
canvasId = (canvasId.includes('://')) ? Manifesto.Utils.normaliseUrl(canvasId) : canvasId;
canvasId = this._getNormaliseCanvasId(canvasId);
// if virtual canvas is enabled, check for that first
if (this._data.virtualCanvasEnabled) {
for (var i = 0; i < this.canvasInstances.length; i++) {
var canvasInstance = this.canvasInstances[i];
if (canvasInstance.isVirtual() && canvasInstance.getCanvasId() === canvasId || canvasInstance.includesVirtualSubCanvas(canvasId)) {
return canvasInstance;
var currentCanvasId = canvasInstance.getCanvasId();
if (currentCanvasId) {
currentCanvasId = this._getNormaliseCanvasId(currentCanvasId);
if (canvasInstance.isVirtual() && currentCanvasId === canvasId || canvasInstance.includesVirtualSubCanvas(canvasId)) {
return canvasInstance;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iiif-av-component",
"version": "0.0.79",
"version": "0.0.80",
"description": "",
"main": "index.js",
"types": "./dist/iiif-av-component.d.ts",
Expand Down
19 changes: 16 additions & 3 deletions src/AVComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,13 @@ namespace IIIFComponents {
});
}

private _getNormaliseCanvasId(canvasId: string): string {
return (canvasId.includes('://')) ? Manifesto.Utils.normaliseUrl(canvasId) : canvasId;
}

private _getCanvasInstanceById(canvasId: string): CanvasInstance | undefined {

canvasId = (canvasId.includes('://')) ? Manifesto.Utils.normaliseUrl(canvasId) : canvasId;
canvasId = this._getNormaliseCanvasId(canvasId);

// if virtual canvas is enabled, check for that first
if (this._data.virtualCanvasEnabled) {
Expand All @@ -453,9 +457,18 @@ namespace IIIFComponents {

const canvasInstance: IIIFComponents.CanvasInstance = this.canvasInstances[i];

if (canvasInstance.isVirtual() && canvasInstance.getCanvasId() === canvasId || canvasInstance.includesVirtualSubCanvas(canvasId)) {
return canvasInstance;
let currentCanvasId: string | undefined = canvasInstance.getCanvasId();

if (currentCanvasId) {

currentCanvasId = this._getNormaliseCanvasId(currentCanvasId);

if (canvasInstance.isVirtual() && currentCanvasId === canvasId || canvasInstance.includesVirtualSubCanvas(canvasId)) {
return canvasInstance;
}

}

}

} else {
Expand Down

0 comments on commit 203916b

Please sign in to comment.